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

Function ng_iface_send

freebsd/netgraph/ng_iface.c:433–475  ·  view source on GitHub ↗

* This routine does actual delivery of the packet into the * netgraph(4). It is called from ng_iface_start() and * ng_iface_output(). */

Source from the content-addressed store, hash-verified

431 * ng_iface_output().
432 */
433static int
434ng_iface_send(struct ifnet *ifp, struct mbuf *m, sa_family_t sa)
435{
436 struct rm_priotracker priv_tracker;
437 const priv_p priv = (priv_p) ifp->if_softc;
438 const iffam_p iffam = get_iffam_from_af(sa);
439 hook_p hook;
440 int error;
441 int len;
442
443 /* Check address family to determine hook (if known) */
444 if (iffam == NULL) {
445 m_freem(m);
446 log(LOG_WARNING, "%s: can't handle af%d\n", ifp->if_xname, sa);
447 return (EAFNOSUPPORT);
448 }
449
450 /* Copy length before the mbuf gets invalidated. */
451 len = m->m_pkthdr.len;
452
453 PRIV_RLOCK(priv, &priv_tracker);
454 hook = *get_hook_from_iffam(priv, iffam);
455 if (hook == NULL) {
456 NG_FREE_M(m);
457 PRIV_RUNLOCK(priv, &priv_tracker);
458 return ENETDOWN;
459 }
460 NG_HOOK_REF(hook);
461 PRIV_RUNLOCK(priv, &priv_tracker);
462
463 NG_OUTBOUND_THREAD_REF();
464 NG_SEND_DATA_ONLY(error, hook, m);
465 NG_OUTBOUND_THREAD_UNREF();
466 NG_HOOK_UNREF(hook);
467
468 /* Update stats. */
469 if (error == 0) {
470 if_inc_counter(ifp, IFCOUNTER_OBYTES, len);
471 if_inc_counter(ifp, IFCOUNTER_OPACKETS, 1);
472 }
473
474 return (error);
475}
476
477#ifdef DEBUG
478/*

Callers 2

ng_iface_outputFunction · 0.85
ng_iface_startFunction · 0.85

Calls 5

if_inc_counterFunction · 0.85
get_iffam_from_afFunction · 0.70
get_hook_from_iffamFunction · 0.70
m_freemFunction · 0.50
logFunction · 0.50

Tested by

no test coverage detected