Add m_clrprotoflags() to clear protocol specific mbuf flags at up and
downwards layer crossings. Consistently use it within IP, IPv6 and ethernet protocols. Discussed with: trociny, glebius
This commit is contained in:
parent
a84c641767
commit
7cc6cc696c
@ -774,7 +774,7 @@ ether_demux(struct ifnet *ifp, struct mbuf *m)
|
||||
* Strip off Ethernet header.
|
||||
*/
|
||||
m->m_flags &= ~M_VLANTAG;
|
||||
m->m_flags &= ~(M_PROTOFLAGS);
|
||||
m_clrprotoflags(m);
|
||||
m_adj(m, ETHER_HDR_LEN);
|
||||
|
||||
/*
|
||||
|
@ -355,7 +355,8 @@ hostap_deliver_data(struct ieee80211vap *vap,
|
||||
struct ifnet *ifp = vap->iv_ifp;
|
||||
|
||||
/* clear driver/net80211 flags before passing up */
|
||||
m->m_flags &= ~(M_80211_RX | M_MCAST | M_BCAST);
|
||||
m->m_flags &= ~(M_MCAST | M_BCAST);
|
||||
m_clrprotoflags(m);
|
||||
|
||||
KASSERT(vap->iv_opmode == IEEE80211_M_HOSTAP,
|
||||
("gack, opmode %d", vap->iv_opmode));
|
||||
|
@ -250,7 +250,8 @@ ieee80211_deliver_data(struct ieee80211vap *vap,
|
||||
struct ifnet *ifp = vap->iv_ifp;
|
||||
|
||||
/* clear driver/net80211 flags before passing up */
|
||||
m->m_flags &= ~(M_80211_RX | M_MCAST | M_BCAST);
|
||||
m->m_flags &= ~(M_MCAST | M_BCAST);
|
||||
m_clrprotoflags(m);
|
||||
|
||||
/* NB: see hostap_deliver_data, this path doesn't handle hostap */
|
||||
KASSERT(vap->iv_opmode != IEEE80211_M_HOSTAP, ("gack, hostap"));
|
||||
|
@ -281,6 +281,7 @@ arprequest(struct ifnet *ifp, const struct in_addr *sip,
|
||||
sa.sa_family = AF_ARP;
|
||||
sa.sa_len = 2;
|
||||
m->m_flags |= M_BCAST;
|
||||
m_clrprotoflags(m); /* Avoid confusing lower layers. */
|
||||
(*ifp->if_output)(ifp, m, &sa, NULL);
|
||||
ARPSTAT_INC(txrequests);
|
||||
}
|
||||
@ -784,6 +785,8 @@ in_arpinput(struct mbuf *m)
|
||||
for (; m_hold != NULL; m_hold = m_hold_next) {
|
||||
m_hold_next = m_hold->m_nextpkt;
|
||||
m_hold->m_nextpkt = NULL;
|
||||
/* Avoid confusing lower layers. */
|
||||
m_clrprotoflags(m_hold);
|
||||
(*ifp->if_output)(ifp, m_hold, &sa, NULL);
|
||||
}
|
||||
} else
|
||||
@ -888,6 +891,7 @@ in_arpinput(struct mbuf *m)
|
||||
m->m_pkthdr.rcvif = NULL;
|
||||
sa.sa_family = AF_ARP;
|
||||
sa.sa_len = 2;
|
||||
m_clrprotoflags(m); /* Avoid confusing lower layers. */
|
||||
(*ifp->if_output)(ifp, m, &sa, NULL);
|
||||
ARPSTAT_INC(txreplies);
|
||||
return;
|
||||
|
@ -3450,7 +3450,7 @@ igmp_intr(struct mbuf *m)
|
||||
}
|
||||
|
||||
igmp_scrub_context(m0);
|
||||
m->m_flags &= ~(M_PROTOFLAGS);
|
||||
m_clrprotoflags(m);
|
||||
m0->m_pkthdr.rcvif = V_loif;
|
||||
#ifdef MAC
|
||||
mac_netinet_igmp_send(ifp, m0);
|
||||
|
@ -524,6 +524,10 @@ ip_fastforward(struct mbuf *m)
|
||||
|
||||
if (ip_len <= mtu ||
|
||||
(ifp->if_hwassist & CSUM_FRAGMENT && (ip_off & IP_DF) == 0)) {
|
||||
/*
|
||||
* Avoid confusing lower layers.
|
||||
*/
|
||||
m_clrprotoflags(m);
|
||||
/*
|
||||
* Send off the packet via outgoing interface
|
||||
*/
|
||||
@ -553,6 +557,10 @@ ip_fastforward(struct mbuf *m)
|
||||
do {
|
||||
m0 = m->m_nextpkt;
|
||||
m->m_nextpkt = NULL;
|
||||
/*
|
||||
* Avoid confusing lower layers.
|
||||
*/
|
||||
m_clrprotoflags(m);
|
||||
|
||||
error = (*ifp->if_output)(ifp, m,
|
||||
(struct sockaddr *)dst, &ro);
|
||||
|
@ -621,7 +621,7 @@ ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro, int flags,
|
||||
* Reset layer specific mbuf flags
|
||||
* to avoid confusing lower layers.
|
||||
*/
|
||||
m->m_flags &= ~(M_PROTOFLAGS);
|
||||
m_clrprotoflags(m);
|
||||
error = (*ifp->if_output)(ifp, m,
|
||||
(const struct sockaddr *)gw, ro);
|
||||
goto done;
|
||||
@ -654,7 +654,7 @@ ip_output(struct mbuf *m, struct mbuf *opt, struct route *ro, int flags,
|
||||
* Reset layer specific mbuf flags
|
||||
* to avoid confusing upper layers.
|
||||
*/
|
||||
m->m_flags &= ~(M_PROTOFLAGS);
|
||||
m_clrprotoflags(m);
|
||||
|
||||
error = (*ifp->if_output)(ifp, m,
|
||||
(const struct sockaddr *)gw, ro);
|
||||
|
@ -444,12 +444,14 @@ typedef struct rtentry sctp_rtentry_t;
|
||||
local_stcb->sctp_ep && \
|
||||
local_stcb->sctp_ep->sctp_socket) \
|
||||
o_flgs |= local_stcb->sctp_ep->sctp_socket->so_options & SO_DONTROUTE; \
|
||||
m_clrprotoflags(o_pak); \
|
||||
result = ip_output(o_pak, NULL, ro, o_flgs, 0, NULL); \
|
||||
}
|
||||
|
||||
#define SCTP_IP6_OUTPUT(result, o_pak, ro, ifp, stcb, vrf_id) \
|
||||
{ \
|
||||
struct sctp_tcb *local_stcb = stcb; \
|
||||
m_clrprotoflags(o_pak); \
|
||||
if (local_stcb && local_stcb->sctp_ep) \
|
||||
result = ip6_output(o_pak, \
|
||||
((struct in6pcb *)(local_stcb->sctp_ep))->in6p_outputopts, \
|
||||
|
@ -1648,6 +1648,7 @@ phyint_send(struct ip6_hdr *ip6, struct mif6 *mifp, struct mbuf *m)
|
||||
* We just call if_output instead of nd6_output here, since
|
||||
* we need no ND for a multicast forwarded packet...right?
|
||||
*/
|
||||
m_clrprotoflags(m); /* Avoid confusing lower layers. */
|
||||
error = (*ifp->if_output)(ifp, mb_copy,
|
||||
(struct sockaddr *)&dst6, NULL);
|
||||
#ifdef MRT6DEBUG
|
||||
|
@ -3098,7 +3098,7 @@ mld_dispatch_packet(struct mbuf *m)
|
||||
}
|
||||
|
||||
mld_scrub_context(m0);
|
||||
m->m_flags &= ~(M_PROTOFLAGS);
|
||||
m_clrprotoflags(m);
|
||||
m0->m_pkthdr.rcvif = V_loif;
|
||||
|
||||
ip6 = mtod(m0, struct ip6_hdr *);
|
||||
|
@ -2082,8 +2082,7 @@ nd6_output_lle(struct ifnet *ifp, struct ifnet *origifp, struct mbuf *m0,
|
||||
}
|
||||
return (error);
|
||||
}
|
||||
/* Reset layer specific mbuf flags to avoid confusing lower layers. */
|
||||
m->m_flags &= ~(M_PROTOFLAGS);
|
||||
m_clrprotoflags(m); /* Avoid confusing lower layers. */
|
||||
if ((ifp->if_flags & IFF_LOOPBACK) != 0) {
|
||||
return ((*ifp->if_output)(origifp, m, (struct sockaddr *)dst,
|
||||
NULL));
|
||||
|
@ -180,6 +180,8 @@ send_output(struct mbuf *m, struct ifnet *ifp, int direction)
|
||||
dst.sin6_len = sizeof(dst);
|
||||
dst.sin6_addr = ip6->ip6_dst;
|
||||
|
||||
m_clrprotoflags(m); /* Avoid confusing lower layers. */
|
||||
|
||||
/*
|
||||
* Output the packet as nd6.c:nd6_output_lle() would do.
|
||||
* The mbuf is always consumed, so we do not have to care
|
||||
|
@ -5310,7 +5310,7 @@ pf_route(struct mbuf **m, struct pf_rule *r, int dir, struct ifnet *oifp,
|
||||
ip->ip_sum = in_cksum(m0, ip->ip_hl << 2);
|
||||
m0->m_pkthdr.csum_flags &= ~CSUM_IP;
|
||||
}
|
||||
m0->m_flags &= ~(M_PROTOFLAGS);
|
||||
m_clrprotoflags(m0); /* Avoid confusing lower layers. */
|
||||
error = (*ifp->if_output)(ifp, m0, sintosa(&dst), NULL);
|
||||
goto done;
|
||||
}
|
||||
@ -5335,7 +5335,7 @@ pf_route(struct mbuf **m, struct pf_rule *r, int dir, struct ifnet *oifp,
|
||||
m1 = m0->m_nextpkt;
|
||||
m0->m_nextpkt = NULL;
|
||||
if (error == 0) {
|
||||
m0->m_flags &= ~(M_PROTOFLAGS);
|
||||
m_clrprotoflags(m0);
|
||||
error = (*ifp->if_output)(ifp, m0, sintosa(&dst), NULL);
|
||||
} else
|
||||
m_freem(m0);
|
||||
|
@ -1442,7 +1442,7 @@ ipoib_input(struct ifnet *ifp, struct mbuf *m)
|
||||
* Strip off Infiniband header.
|
||||
*/
|
||||
m->m_flags &= ~M_VLANTAG;
|
||||
m->m_flags &= ~(M_PROTOFLAGS);
|
||||
m_clrprotoflags(m);
|
||||
m_adj(m, IPOIB_HEADER_LEN);
|
||||
|
||||
if (IPOIB_IS_MULTICAST(eh->hwaddr)) {
|
||||
|
@ -603,6 +603,13 @@ m_chtype(struct mbuf *m, short new_type)
|
||||
m->m_type = new_type;
|
||||
}
|
||||
|
||||
static __inline void
|
||||
m_clrprotoflags(struct mbuf *m)
|
||||
{
|
||||
|
||||
m->m_flags &= ~M_PROTOFLAGS;
|
||||
}
|
||||
|
||||
static __inline struct mbuf *
|
||||
m_last(struct mbuf *m)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user