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 | |
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')
-rw-r--r-- | sys/net/if.c | 25 | ||||
-rw-r--r-- | sys/net/if_var.h | 26 |
2 files changed, 27 insertions, 24 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"); diff --git a/sys/net/if_var.h b/sys/net/if_var.h index 149f895..0541126 100644 --- a/sys/net/if_var.h +++ b/sys/net/if_var.h @@ -342,6 +342,8 @@ EVENTHANDLER_DECLARE(ifnet_departure_event, ifnet_departure_event_handler_t); mtx_unlock(&Giant); \ } while (0) +int if_handoff(struct ifqueue *ifq, struct mbuf *m, struct ifnet *ifp, + int adjust); #define IF_HANDOFF(ifq, m, ifp) \ if_handoff((struct ifqueue *)ifq, m, ifp, 0) #define IF_HANDOFF_ADJ(ifq, m, ifp, adj) \ @@ -349,30 +351,6 @@ EVENTHANDLER_DECLARE(ifnet_departure_event, ifnet_departure_event_handler_t); void if_start(struct ifnet *); -static __inline 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); -} #if 1 /* ALTQ */ #define IFQ_ENQUEUE(ifq, m, err) \ do { \ |