From: Sepherosa Ziehau Date: Sat, 23 Aug 2008 04:12:23 +0000 (+0000) Subject: - Test m_pkthdr.fw_flags against DUMMYNET_MBUF_TAGGED before trying to locate X-Git-Tag: v2.1.1~608 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/eb2415495ba9f14e3e966bc2f33cb15f9889d5d5?ds=sidebyside - Test m_pkthdr.fw_flags against DUMMYNET_MBUF_TAGGED before trying to locate dummynet mtag. - Clear DUMMYNET_MBUF_TAGGED from m_pkthdr.fw_flags, once dummynet mtag is deleted. --- diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c index 1d26299e4f..d0e7bcc82e 100644 --- a/sys/net/if_ethersubr.c +++ b/sys/net/if_ethersubr.c @@ -32,7 +32,7 @@ * * @(#)if_ethersubr.c 8.1 (Berkeley) 6/10/93 * $FreeBSD: src/sys/net/if_ethersubr.c,v 1.70.2.33 2003/04/28 15:45:53 archie Exp $ - * $DragonFly: src/sys/net/if_ethersubr.c,v 1.83 2008/08/22 09:14:16 sephe Exp $ + * $DragonFly: src/sys/net/if_ethersubr.c,v 1.84 2008/08/23 04:12:23 sephe Exp $ */ #include "opt_atalk.h" @@ -409,17 +409,20 @@ ether_output_frame(struct ifnet *ifp, struct mbuf *m) struct ip_fw *rule = NULL; int error = 0; struct altq_pktattr pktattr; - struct m_tag *mtag; ASSERT_NOT_SERIALIZED(ifp->if_serializer); - /* Extract info from dummynet tag */ - mtag = m_tag_find(m, PACKET_TAG_DUMMYNET, NULL); - if (mtag != NULL) { + if (m->m_pkthdr.fw_flags & DUMMYNET_MBUF_TAGGED) { + struct m_tag *mtag; + + /* Extract info from dummynet tag */ + mtag = m_tag_find(m, PACKET_TAG_DUMMYNET, NULL); + KKASSERT(mtag != NULL); rule = ((struct dn_pkt *)m_tag_data(mtag))->dn_priv; + KKASSERT(rule != NULL); m_tag_delete(m, mtag); - mtag = NULL; + m->m_pkthdr.fw_flags &= ~DUMMYNET_MBUF_TAGGED; } if (ifq_is_enabled(&ifp->if_snd)) @@ -1011,7 +1014,6 @@ ether_demux_oncpu(struct ifnet *ifp, struct mbuf *m) int isr, redispatch; u_short ether_type; struct ip_fw *rule = NULL; - struct m_tag *mtag; #ifdef NETATALK struct llc *l; #endif @@ -1022,18 +1024,24 @@ ether_demux_oncpu(struct ifnet *ifp, struct mbuf *m) eh = mtod(m, struct ether_header *); - /* Extract info from dummynet tag */ - mtag = m_tag_find(m, PACKET_TAG_DUMMYNET, NULL); - if (mtag != NULL) { + if (m->m_pkthdr.fw_flags & DUMMYNET_MBUF_TAGGED) { + struct m_tag *mtag; + + /* Extract info from dummynet tag */ + mtag = m_tag_find(m, PACKET_TAG_DUMMYNET, NULL); + KKASSERT(mtag != NULL); rule = ((struct dn_pkt *)m_tag_data(mtag))->dn_priv; + KKASSERT(rule != NULL); + KKASSERT(ifp == NULL); ifp = m->m_pkthdr.rcvif; m_tag_delete(m, mtag); - mtag = NULL; - } - if (rule) /* packet is passing the second time */ + m->m_pkthdr.fw_flags &= ~DUMMYNET_MBUF_TAGGED; + + /* packet is passing the second time */ goto post_stats; + } #ifdef CARP /* diff --git a/sys/netinet/ip_input.c b/sys/netinet/ip_input.c index a7fa5bdc8b..bca6d49b7a 100644 --- a/sys/netinet/ip_input.c +++ b/sys/netinet/ip_input.c @@ -65,7 +65,7 @@ * * @(#)ip_input.c 8.2 (Berkeley) 1/4/94 * $FreeBSD: src/sys/netinet/ip_input.c,v 1.130.2.52 2003/03/07 07:01:28 silby Exp $ - * $DragonFly: src/sys/netinet/ip_input.c,v 1.89 2008/08/22 13:37:22 sephe Exp $ + * $DragonFly: src/sys/netinet/ip_input.c,v 1.90 2008/08/23 04:12:23 sephe Exp $ */ #define _IP_VHL @@ -441,14 +441,17 @@ ip_input(struct mbuf *m) next_hop = m_tag_data(mtag); } - /* Extract info from dummynet tag */ - mtag = m_tag_find(m, PACKET_TAG_DUMMYNET, NULL); - if (mtag != NULL) { + if (m->m_pkthdr.fw_flags & DUMMYNET_MBUF_TAGGED) { + /* Extract info from dummynet tag */ + mtag = m_tag_find(m, PACKET_TAG_DUMMYNET, NULL); + KKASSERT(mtag != NULL); args.rule = ((struct dn_pkt *)m_tag_data(mtag))->dn_priv; + KKASSERT(args.rule != NULL); + m_tag_delete(m, mtag); - } + m->m_pkthdr.fw_flags &= ~DUMMYNET_MBUF_TAGGED; - if (args.rule != NULL) { /* dummynet already filtered us */ + /* dummynet already filtered us */ ip = mtod(m, struct ip *); hlen = IP_VHL_HL(ip->ip_vhl) << 2; goto iphack; diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index cab77a7fd1..5959fba3b1 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -28,7 +28,7 @@ * * @(#)ip_output.c 8.3 (Berkeley) 1/21/94 * $FreeBSD: src/sys/netinet/ip_output.c,v 1.99.2.37 2003/04/15 06:44:45 silby Exp $ - * $DragonFly: src/sys/netinet/ip_output.c,v 1.49 2008/08/22 09:14:16 sephe Exp $ + * $DragonFly: src/sys/netinet/ip_output.c,v 1.50 2008/08/23 04:12:23 sephe Exp $ */ #define _IP_VHL @@ -138,7 +138,7 @@ ip_output(struct mbuf *m0, struct mbuf *opt, struct route *ro, int isbroadcast, sw_csum; struct in_addr pkt_dst; struct route iproute; - struct m_tag *dn_mtag, *mtag; + struct m_tag *dn_mtag = NULL, *mtag; #ifdef IPSEC struct secpolicy *sp = NULL; struct socket *so = inp ? inp->inp_socket : NULL; @@ -158,15 +158,19 @@ ip_output(struct mbuf *m0, struct mbuf *opt, struct route *ro, M_ASSERTPKTHDR(m); if (m->m_pkthdr.fw_flags & IPFORWARD_MBUF_TAGGED) { + /* Next hop */ mtag = m_tag_find(m, PACKET_TAG_IPFORWARD, NULL); KKASSERT(mtag != NULL); next_hop = m_tag_data(mtag); } - /* Extract info from dummynet tag */ - dn_mtag = m_tag_find(m, PACKET_TAG_DUMMYNET, NULL); - if (dn_mtag != NULL) { - struct dn_pkt *dn_pkt = m_tag_data(dn_mtag); + if (m->m_pkthdr.fw_flags & DUMMYNET_MBUF_TAGGED) { + struct dn_pkt *dn_pkt; + + /* Extract info from dummynet tag */ + dn_mtag = m_tag_find(m, PACKET_TAG_DUMMYNET, NULL); + KKASSERT(dn_mtag != NULL); + dn_pkt = m_tag_data(dn_mtag); /* * The packet was already tagged, so part of the @@ -174,6 +178,7 @@ ip_output(struct mbuf *m0, struct mbuf *opt, struct route *ro, * Get parameters from the tag. */ args.rule = dn_pkt->dn_priv; + KKASSERT(args.rule != NULL); opt = NULL; ro = &dn_pkt->ro; imo = NULL; @@ -189,6 +194,7 @@ ip_output(struct mbuf *m0, struct mbuf *opt, struct route *ro, * output process. */ m_tag_unlink(m, dn_mtag); + m->m_pkthdr.fw_flags &= ~DUMMYNET_MBUF_TAGGED; } if (ro == NULL) {