From 7cc6cc696c12dcee5a294f67527cebb28374c49e Mon Sep 17 00:00:00 2001 From: andre Date: Mon, 19 Aug 2013 13:27:32 +0000 Subject: 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 --- sys/netinet/if_ether.c | 4 ++++ sys/netinet/igmp.c | 2 +- sys/netinet/ip_fastfwd.c | 8 ++++++++ sys/netinet/ip_output.c | 4 ++-- sys/netinet/sctp_os_bsd.h | 2 ++ 5 files changed, 17 insertions(+), 3 deletions(-) (limited to 'sys/netinet') diff --git a/sys/netinet/if_ether.c b/sys/netinet/if_ether.c index 675e0dd..9660edc 100644 --- a/sys/netinet/if_ether.c +++ b/sys/netinet/if_ether.c @@ -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 @@ match: 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 @@ reply: 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; diff --git a/sys/netinet/igmp.c b/sys/netinet/igmp.c index 725e4ec..9a43108 100644 --- a/sys/netinet/igmp.c +++ b/sys/netinet/igmp.c @@ -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); diff --git a/sys/netinet/ip_fastfwd.c b/sys/netinet/ip_fastfwd.c index 3a228ca..989318e 100644 --- a/sys/netinet/ip_fastfwd.c +++ b/sys/netinet/ip_fastfwd.c @@ -525,6 +525,10 @@ passout: 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 */ error = (*ifp->if_output)(ifp, m, @@ -553,6 +557,10 @@ passout: 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); diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index b37f508..0a87e7a 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -621,7 +621,7 @@ passout: * 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 @@ passout: * 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); diff --git a/sys/netinet/sctp_os_bsd.h b/sys/netinet/sctp_os_bsd.h index 4eff47b..ff32748 100644 --- a/sys/netinet/sctp_os_bsd.h +++ b/sys/netinet/sctp_os_bsd.h @@ -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, \ -- cgit v1.1