Author: andre Date: Mon Aug 19 13:27:32 2013 New Revision: 254523 URL: http://svnweb.freebsd.org/changeset/base/254523
Log: 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 Modified: head/sys/net/if_ethersubr.c head/sys/net80211/ieee80211_hostap.c head/sys/net80211/ieee80211_input.c head/sys/netinet/if_ether.c head/sys/netinet/igmp.c head/sys/netinet/ip_fastfwd.c head/sys/netinet/ip_output.c head/sys/netinet/sctp_os_bsd.h head/sys/netinet6/ip6_mroute.c head/sys/netinet6/mld6.c head/sys/netinet6/nd6.c head/sys/netinet6/send.c head/sys/netpfil/pf/pf.c head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c head/sys/sys/mbuf.h Modified: head/sys/net/if_ethersubr.c ============================================================================== --- head/sys/net/if_ethersubr.c Mon Aug 19 12:37:13 2013 (r254522) +++ head/sys/net/if_ethersubr.c Mon Aug 19 13:27:32 2013 (r254523) @@ -774,7 +774,7 @@ ether_demux(struct ifnet *ifp, struct mb * Strip off Ethernet header. */ m->m_flags &= ~M_VLANTAG; - m->m_flags &= ~(M_PROTOFLAGS); + m_clrprotoflags(m); m_adj(m, ETHER_HDR_LEN); /* Modified: head/sys/net80211/ieee80211_hostap.c ============================================================================== --- head/sys/net80211/ieee80211_hostap.c Mon Aug 19 12:37:13 2013 (r254522) +++ head/sys/net80211/ieee80211_hostap.c Mon Aug 19 13:27:32 2013 (r254523) @@ -355,7 +355,8 @@ hostap_deliver_data(struct ieee80211vap 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)); Modified: head/sys/net80211/ieee80211_input.c ============================================================================== --- head/sys/net80211/ieee80211_input.c Mon Aug 19 12:37:13 2013 (r254522) +++ head/sys/net80211/ieee80211_input.c Mon Aug 19 13:27:32 2013 (r254523) @@ -250,7 +250,8 @@ ieee80211_deliver_data(struct ieee80211v 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")); Modified: head/sys/netinet/if_ether.c ============================================================================== --- head/sys/netinet/if_ether.c Mon Aug 19 12:37:13 2013 (r254522) +++ head/sys/netinet/if_ether.c Mon Aug 19 13:27:32 2013 (r254523) @@ -281,6 +281,7 @@ arprequest(struct ifnet *ifp, const stru 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; Modified: head/sys/netinet/igmp.c ============================================================================== --- head/sys/netinet/igmp.c Mon Aug 19 12:37:13 2013 (r254522) +++ head/sys/netinet/igmp.c Mon Aug 19 13:27:32 2013 (r254523) @@ -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); Modified: head/sys/netinet/ip_fastfwd.c ============================================================================== --- head/sys/netinet/ip_fastfwd.c Mon Aug 19 12:37:13 2013 (r254522) +++ head/sys/netinet/ip_fastfwd.c Mon Aug 19 13:27:32 2013 (r254523) @@ -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); Modified: head/sys/netinet/ip_output.c ============================================================================== --- head/sys/netinet/ip_output.c Mon Aug 19 12:37:13 2013 (r254522) +++ head/sys/netinet/ip_output.c Mon Aug 19 13:27:32 2013 (r254523) @@ -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); Modified: head/sys/netinet/sctp_os_bsd.h ============================================================================== --- head/sys/netinet/sctp_os_bsd.h Mon Aug 19 12:37:13 2013 (r254522) +++ head/sys/netinet/sctp_os_bsd.h Mon Aug 19 13:27:32 2013 (r254523) @@ -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, \ Modified: head/sys/netinet6/ip6_mroute.c ============================================================================== --- head/sys/netinet6/ip6_mroute.c Mon Aug 19 12:37:13 2013 (r254522) +++ head/sys/netinet6/ip6_mroute.c Mon Aug 19 13:27:32 2013 (r254523) @@ -1648,6 +1648,7 @@ phyint_send(struct ip6_hdr *ip6, struct * 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 Modified: head/sys/netinet6/mld6.c ============================================================================== --- head/sys/netinet6/mld6.c Mon Aug 19 12:37:13 2013 (r254522) +++ head/sys/netinet6/mld6.c Mon Aug 19 13:27:32 2013 (r254523) @@ -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 *); Modified: head/sys/netinet6/nd6.c ============================================================================== --- head/sys/netinet6/nd6.c Mon Aug 19 12:37:13 2013 (r254522) +++ head/sys/netinet6/nd6.c Mon Aug 19 13:27:32 2013 (r254523) @@ -2082,8 +2082,7 @@ nd6_output_lle(struct ifnet *ifp, struct } 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)); Modified: head/sys/netinet6/send.c ============================================================================== --- head/sys/netinet6/send.c Mon Aug 19 12:37:13 2013 (r254522) +++ head/sys/netinet6/send.c Mon Aug 19 13:27:32 2013 (r254523) @@ -180,6 +180,8 @@ send_output(struct mbuf *m, struct ifnet 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 Modified: head/sys/netpfil/pf/pf.c ============================================================================== --- head/sys/netpfil/pf/pf.c Mon Aug 19 12:37:13 2013 (r254522) +++ head/sys/netpfil/pf/pf.c Mon Aug 19 13:27:32 2013 (r254523) @@ -5310,7 +5310,7 @@ pf_route(struct mbuf **m, struct pf_rule 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 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); Modified: head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c ============================================================================== --- head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c Mon Aug 19 12:37:13 2013 (r254522) +++ head/sys/ofed/drivers/infiniband/ulp/ipoib/ipoib_main.c Mon Aug 19 13:27:32 2013 (r254523) @@ -1442,7 +1442,7 @@ ipoib_input(struct ifnet *ifp, struct mb * 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)) { Modified: head/sys/sys/mbuf.h ============================================================================== --- head/sys/sys/mbuf.h Mon Aug 19 12:37:13 2013 (r254522) +++ head/sys/sys/mbuf.h Mon Aug 19 13:27:32 2013 (r254523) @@ -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) { _______________________________________________ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"