MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ng_iface_output

Function ng_iface_output

freebsd/netgraph/ng_iface.c:348–391  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

346 */
347
348static int
349ng_iface_output(struct ifnet *ifp, struct mbuf *m,
350 const struct sockaddr *dst, struct route *ro)
351{
352 uint32_t af;
353 int error;
354
355 /* Check interface flags */
356 if (!((ifp->if_flags & IFF_UP) &&
357 (ifp->if_drv_flags & IFF_DRV_RUNNING))) {
358 m_freem(m);
359 return (ENETDOWN);
360 }
361
362 /* Protect from deadly infinite recursion. */
363 error = if_tunnel_check_nesting(ifp, m, NGM_IFACE_COOKIE,
364 V_ng_iface_max_nest);
365 if (error) {
366 m_freem(m);
367 return (error);
368 }
369
370 /* BPF writes need to be handled specially. */
371 if (dst->sa_family == AF_UNSPEC)
372 bcopy(dst->sa_data, &af, sizeof(af));
373 else
374 af = dst->sa_family;
375
376 /* Berkeley packet filter */
377 ng_iface_bpftap(ifp, m, af);
378
379 if (ALTQ_IS_ENABLED(&ifp->if_snd)) {
380 M_PREPEND(m, sizeof(sa_family_t), M_NOWAIT);
381 if (m == NULL) {
382 if_inc_counter(ifp, IFCOUNTER_OQDROPS, 1);
383 return (ENOBUFS);
384 }
385 *(sa_family_t *)m->m_data = af;
386 error = (ifp->if_transmit)(ifp, m);
387 } else
388 error = ng_iface_send(ifp, m, af);
389
390 return (error);
391}
392
393/*
394 * Start method is used only when ALTQ is enabled.

Callers

nothing calls this directly

Calls 5

if_tunnel_check_nestingFunction · 0.85
ng_iface_bpftapFunction · 0.85
if_inc_counterFunction · 0.85
ng_iface_sendFunction · 0.85
m_freemFunction · 0.50

Tested by

no test coverage detected