Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 22 Nov 2003 21:59:18 -0800 (PST)
From:      Sam Leffler <sam@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 42947 for review
Message-ID:  <200311230559.hAN5xI5A059547@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=42947

Change 42947 by sam@sam_ebb on 2003/11/22 21:59:17

	fixup merge problems

Affected files ...

.. //depot/projects/tagcleanup/sys/net/bridge.c#4 edit
.. //depot/projects/tagcleanup/sys/netinet/ip_fastfwd.c#2 edit
.. //depot/projects/tagcleanup/sys/netinet/ip_input.c#4 edit

Differences ...

==== //depot/projects/tagcleanup/sys/net/bridge.c#4 (text+ko) ====

@@ -863,9 +863,6 @@
 static struct mbuf *
 bdg_filter_and_forward(struct ifnet *dst, struct mbuf *m0, struct ifnet *src)
 {
-#ifdef PFIL_HOOKS
-    struct packet_filter_hook *pfh;
-#endif /* PFIL_HOOKS */
 
     DDB(quad_t ticks; ticks = rdtsc();)
 
@@ -878,7 +875,7 @@
      */
     if ((IPFW_LOADED && bdg_ipfw != 0)
 #ifdef PFIL_HOOKS
-	|| (inet_pfil_hook.ph_busy_count >= 0 && bdg_ipf != 0) ||
+	|| (inet_pfil_hook.ph_busy_count >= 0 && bdg_ipf != 0)
 #endif
 	) {
 #define	EH_RESTORE(_m) do {						   \
@@ -1084,10 +1081,9 @@
 	     * from the old interface.
 	     */
 	    bt->name = ifp;		/* relocate address */
-	    printf("-- loop (%d) %6D to %s%d from %s%d (%s)\n",
+	    printf("-- loop (%d) %6D to %s from %s (%s)\n",
 			bdg_loops, eh->ether_shost, ".",
-			ifp->if_name, ifp->if_unit,
-			old->if_name, old->if_unit,
+			ifp->if_xname, old->if_xname,
 			BDG_MUTED(old) ? "muted":"active");
 	    dropit = 1;
 	    if (!BDG_MUTED(old)) {
@@ -1101,21 +1097,20 @@
      * now write the source address into the table
      */
     if (bt->name == NULL) {
-	DPRINTF(("%s: new addr %6D at %d for %s%d\n",
-	    __func__, eh->ether_shost, ".", index, ifp->if_name, ifp->if_unit));
+	DPRINTF(("%s: new addr %6D at %d for %s\n",
+	    __func__, eh->ether_shost, ".", index, ifp->if_xname));
 	ETHER_ADDR_COPY(bt->etheraddr, eh->ether_shost);
 	bt->name = ifp;
     }
     dst = bridge_dst_lookup(eh, BDG_CLUSTER(ifp));
     BDG_UNLOCK();
 
-    DPRINTF(("%s: %6D ->%6D ty 0x%04x dst %s%d\n", __func__,
+    DPRINTF(("%s: %6D ->%6D ty 0x%04x dst %s\n", __func__,
 	eh->ether_shost, ".",
 	eh->ether_dhost, ".",
 	ntohs(eh->ether_type),
 	(dst <= BDG_FORWARD) ? bdg_dst_names[(int)dst] :
-		dst->if_name,
-	(dst <= BDG_FORWARD) ? 0 : dst->if_unit));
+		dst->if_xname));
 
     /*
      * bridge_dst_lookup can return the following values:

==== //depot/projects/tagcleanup/sys/netinet/ip_fastfwd.c#2 (text+ko) ====

@@ -132,7 +132,7 @@
 	struct ip *tip;
 	struct mbuf *teem = NULL;
 #endif
-	struct mbuf *tag = NULL;
+	struct m_tag *mtag;
 	struct route ro;
 	struct sockaddr_in *dst = NULL;
 	struct in_ifaddr *ia = NULL;
@@ -150,16 +150,6 @@
 	if (!ipfastforward_active || !ipforwarding)
 		return 0;
 
-	/*
-	 * If there is any MT_TAG we fall back to ip_input because we can't
-	 * handle TAGs here. Should never happen as we get directly called
-	 * from the if_output routines.
-	 */
-	if (m->m_type == MT_TAG) {
-		KASSERT(0, ("%s: packet with MT_TAG not expected", __func__));
-		return 0;
-	}
-
 	M_ASSERTVALID(m);
 	M_ASSERTPKTHDR(m);
 
@@ -362,7 +352,7 @@
 		 * Send packet to the appropriate pipe
 		 */
 		if (DUMMYNET_LOADED && (ipfw & IP_FW_PORT_DYNT_FLAG) != 0) {
-			ip_dn_io_ptr(m, ipfw & 0xffff, DN_TO_IP_IN, &args);
+			ip_dn_io_ptr(m, ipfw & 0xffff, DN_TO_IP_IN);
 			return 1;
 		}
 #ifdef IPDIVERT
@@ -374,17 +364,12 @@
 			 * See if this is a fragment
 			 */
 			if (ip->ip_off & (IP_MF | IP_OFFMASK)) {
-				MGETHDR(tag, M_DONTWAIT, MT_TAG);
-				if (tag == NULL)
+				mtag = m_tag_get(PACKET_TAG_DIVERT,
+						sizeof(int), M_NOWAIT);
+				if (mtag == NULL)
 					goto drop;
-				tag->m_flags = PACKET_TAG_DIVERT;
-				tag->m_data = (caddr_t)(intptr_t)args.divert_rule;
-				tag->m_next = m;
-				/* XXX: really bloody hack, see ip_input */
-				tag->m_nextpkt = (struct mbuf *)1;
-				m = tag;
-				tag = NULL;
-
+				*(int *)(mtag+1) = args.divert_rule;
+				m_tag_prepend(m, mtag);
 				goto droptoours;
 			}
 			/*
@@ -413,7 +398,7 @@
 			/*
 			 * Deliver packet to divert input routine
 			 */
-			divert_packet(teem, 0, ipfw & 0xffff, args.divert_rule);
+			divert_packet(teem, 0, ipfw & 0xffff);
 			/*
 			 * If this was not tee, we are done
 			 */
@@ -545,13 +530,24 @@
 		}
 		if (DUMMYNET_LOADED && (ipfw & IP_FW_PORT_DYNT_FLAG) != 0) {
 			/*
-			 * XXX note: if the ifp or rt entry are deleted
+			 * pass the pkt to dummynet. Need to include
+			 * pipe number, m, ifp, ro, dst because these are
+			 * not recomputed in the next pass.
+			 * All other parameters have been already used and
+			 * so they are not needed anymore. 
+			 * XXX note: if the ifp or ro entry are deleted
 			 * while a pkt is in dummynet, we are in trouble!
-			 */
-			args.ro = &ro;		/* dummynet does not save it */
-			args.dst = dst;
-
-			ip_dn_io_ptr(m, ipfw & 0xffff, DN_TO_IP_OUT, &args);
+			 */ 
+			mtag = m_tag_find(m, PACKET_TAG_IPFW, NULL);
+			if (mtag != NULL) {
+				struct ip_fw_args *args =
+					(struct ip_fw_args *)(mtag+1);
+				args->ro = &ro;
+				args->dst = dst;
+				args->flags = 0;
+			}
+			/* XXX check return */
+			ip_dn_io_ptr(m, ipfw & 0xffff, DN_TO_IP_OUT);
 			RTFREE(ro.ro_rt);
 			return 1;
 		}
@@ -561,19 +557,14 @@
 			 * See if this is a fragment
 			 */
 			if (ip->ip_off & (IP_MF | IP_OFFMASK)) {
-				MGETHDR(tag, M_DONTWAIT, MT_TAG);
-				if (tag == NULL) {
+				mtag = m_tag_get(PACKET_TAG_DIVERT,
+						sizeof(int), M_NOWAIT);
+				if (mtag == NULL) {
 					RTFREE(ro.ro_rt);
 					goto drop;
 				}
-				tag->m_flags = PACKET_TAG_DIVERT;
-				tag->m_data = (caddr_t)(intptr_t)args.divert_rule;
-				tag->m_next = m;
-				/* XXX: really bloody hack, see ip_input */
-				tag->m_nextpkt = (struct mbuf *)1;
-				m = tag;
-				tag = NULL;
-
+				*(int *)(mtag+1) = args.divert_rule;
+				m_tag_prepend(m, mtag);
 				goto droptoours;
 			}
 			/*
@@ -602,7 +593,7 @@
 			/*
 			 * Deliver packet to divert input routine
 			 */
-			divert_packet(teem, 0, ipfw & 0xffff, args.divert_rule);
+			divert_packet(teem, 0, ipfw & 0xffff);
 			/*
 			 * If this was not tee, we are done
 			 */
@@ -638,38 +629,29 @@
 			if (IA_SIN(ia)->sin_addr.s_addr == ip->ip_dst.s_addr) {
 forwardlocal:
 				if (args.next_hop) {
-					/* XXX leak */
-					MGETHDR(tag, M_DONTWAIT, MT_TAG);
-					if (tag == NULL) {
+					mtag = m_tag_get(PACKET_TAG_IPFORWARD,
+						   sizeof(struct sockaddr_in *),
+							M_NOWAIT);
+					if (mtag == NULL) {
 						if (ro.ro_rt)
 							RTFREE(ro.ro_rt);
 						goto drop;
 					}
-					tag->m_flags = PACKET_TAG_IPFORWARD;
-					tag->m_data = (caddr_t)args.next_hop;
-					tag->m_next = m;
-					/* XXX: really bloody hack,
-					 * see ip_input */
-					tag->m_nextpkt = (struct mbuf *)1;
-					m = tag;
-					tag = NULL;
+					*(struct sockaddr_in **)(mtag+1) =
+						args.next_hop;
+					m_tag_prepend(m, mtag);
 				}
 #ifdef IPDIVERT
 droptoours:	/* Used for DIVERT */
 #endif
-				MGETHDR(tag, M_DONTWAIT, MT_TAG);
-				if (tag == NULL) {
+				mtag = m_tag_get(PACKET_TAG_IPFASTFWD_OURS, 0,
+						M_NOWAIT);
+				if (mtag == NULL) {
 					if (ro.ro_rt)
 						RTFREE(ro.ro_rt);
 					goto drop;
 				}
-				tag->m_flags = PACKET_TAG_IPFASTFWD_OURS;
-				tag->m_data = NULL;
-				tag->m_next = m;
-				/* XXX: really bloody hack, see ip_input */
-				tag->m_nextpkt = (struct mbuf *)1;
-				m = tag;
-				tag = NULL;
+				m_tag_prepend(m, mtag);
 
 				/* ip still points to the real packet */
 				ip->ip_len = htons(ip->ip_len);

==== //depot/projects/tagcleanup/sys/netinet/ip_input.c#4 (text+ko) ====

@@ -297,16 +297,15 @@
 	struct in_ifaddr *ia = NULL;
 	struct ifaddr *ifa;
 	int    i, checkif, hlen = 0;
-	int    ours = 0;
 	u_short sum;
 	struct in_addr pkt_dst;
 	struct ip_fw_args args;
+	struct m_tag *mtag;
 	int dchg = 0;				/* dest changed after fw */
 #ifdef PFIL_HOOKS
 	struct in_addr odst;			/* original dst address */
 #endif
 #ifdef FAST_IPSEC
-	struct m_tag *mtag;
 	struct tdb_ident *tdbi;
 	struct secpolicy *sp;
 	int s, error;
@@ -315,7 +314,7 @@
 	M_ASSERTPKTHDR(m);
 
 	/* check if ip_fastforward firewall changed dest to local */
-	if (m_tag_find(m, PACKET_TAG_FASTFWD_OURS, NULL) != NULL)
+	if (m_tag_find(m, PACKET_TAG_IPFASTFWD_OURS, NULL) != NULL)
 		goto ours;
 	/* check if dummynet already filtered us */
 	if (m_tag_find(m, PACKET_TAG_DUMMYNET, NULL) != NULL) {
@@ -1831,8 +1830,7 @@
 			RTFREE(rt);
 	}
 
-	error = ip_output(m, (struct mbuf *)0, &ipforward_rt, 
-			  IP_FORWARDING, 0, NULL);
+	error = ip_output(m, (struct mbuf *)0, NULL, IP_FORWARDING, 0, NULL);
 	if (error)
 		ipstat.ips_cantforward++;
 	else {


Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200311230559.hAN5xI5A059547>