diff options
author | rwatson <rwatson@FreeBSD.org> | 2004-10-30 09:39:13 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2004-10-30 09:39:13 +0000 |
commit | f71b496ed7e5680b0f0e4a9da173613f1e0ab32c (patch) | |
tree | fb5fe1e577fbebdf4db11d4f77dc81c15915fb48 /sys/net/if.c | |
parent | 17c0d55bc06a42141bc410a636e74a2a8a31a933 (diff) | |
download | FreeBSD-src-f71b496ed7e5680b0f0e4a9da173613f1e0ab32c.zip FreeBSD-src-f71b496ed7e5680b0f0e4a9da173613f1e0ab32c.tar.gz |
Move if_handoff() from an inline in if_var.h to a function to if.c
in orden to harden the ABI for 5.x; this will permit us to modify
the locking in the ifnet packet dispatch without requiring drivers
to be recompiled.
MFC after: 3 days
Discussed at: EuroBSDCon Developer's Summit
Diffstat (limited to 'sys/net/if.c')
-rw-r--r-- | sys/net/if.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/sys/net/if.c b/sys/net/if.c index ef1a681..b93e81b 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1947,5 +1947,30 @@ if_start_deferred(void *context, int pending) (ifp->if_start)(ifp); } +int +if_handoff(struct ifqueue *ifq, struct mbuf *m, struct ifnet *ifp, int adjust) +{ + int active = 0; + + IF_LOCK(ifq); + if (_IF_QFULL(ifq)) { + _IF_DROP(ifq); + IF_UNLOCK(ifq); + m_freem(m); + return (0); + } + if (ifp != NULL) { + ifp->if_obytes += m->m_pkthdr.len + adjust; + if (m->m_flags & (M_BCAST|M_MCAST)) + ifp->if_omcasts++; + active = ifp->if_flags & IFF_OACTIVE; + } + _IF_ENQUEUE(ifq, m); + IF_UNLOCK(ifq); + if (ifp != NULL && !active) + if_start(ifp); + return (1); +} + SYSCTL_NODE(_net, PF_LINK, link, CTLFLAG_RW, 0, "Link layers"); SYSCTL_NODE(_net_link, 0, generic, CTLFLAG_RW, 0, "Generic link-management"); |