PERFORCE change 165172 for review

Ana Kukec anchie at FreeBSD.org
Thu Jun 25 15:45:30 UTC 2009


http://perforce.freebsd.org/chv.cgi?CH=165172

Change 165172 by anchie at anchie_malimis on 2009/06/25 15:44:49

	Added m_tags for outgoing NS/NA/Redirect packets that must be sent to
	sendd in the userspace.	

Affected files ...

.. //depot/projects/soc2009/anchie_send/src/sys/netinet6/icmp6.c#12 edit
.. //depot/projects/soc2009/anchie_send/src/sys/netinet6/nd6.c#10 edit
.. //depot/projects/soc2009/anchie_send/src/sys/netinet6/nd6_nbr.c#3 edit
.. //depot/projects/soc2009/anchie_send/src/sys/sys/mbuf.h#4 edit

Differences ...

==== //depot/projects/soc2009/anchie_send/src/sys/netinet6/icmp6.c#12 (text+ko) ====

@@ -768,12 +768,18 @@
 			/* give up local */
 
 		/* send incoming SeND-protected/ND packet to sendd */
-
-			nd6_rs_input(m, off, icmp6len);
+			if (send_output_hook != NULL) {
+				send_output_hook(in, ifp, m, ip6len);
+			} else {
+				nd6_rs_input(m, off, icmp6len);
+			}
 			m = NULL;
 			goto freeit;
 		}
-		nd6_rs_input(n, off, icmp6len);
+		if (send_output_hook != NULL)
+			send_output_hook(in, ifp, n, ip6len);
+		else
+			nd6_rs_input(n, off, icmp6len);
 		/* m stays. */
 		break;
 
@@ -786,13 +792,19 @@
 		if ((n = m_copym(m, 0, M_COPYALL, M_DONTWAIT)) == NULL) {
 
 		/* send incoming SeND-protected/ND packet to sendd */
-
-			/* give up local */
-			nd6_ra_input(m, off, icmp6len);
+			if (send_output_hook != NULL) {
+				send_output_hook(in, ifp, m, ip6len);
+			} else {
+				/* give up local */
+				nd6_ra_input(m, off, icmp6len);
+			}
 			m = NULL;
 			goto freeit;
 		}
-		nd6_ra_input(n, off, icmp6len);
+		if (send_output_hook != NULL)
+			send_output_hook(in, ifp, n, ip6len);
+		else
+			nd6_ra_input(n, off, icmp6len);
 		/* m stays. */
 		break;
 
@@ -805,25 +817,20 @@
 		if ((n = m_copym(m, 0, M_COPYALL, M_DONTWAIT)) == NULL) {
 
 			/* send incoming SeND-protected/ND packet to sendd */
-			/* ip6len should be the same as icmp6len + off! */
 			if (send_output_hook != NULL) {
-				printf("%s %d: send_output_hook != NULL\n", __FUNCTION__, __LINE__);
 				send_output_hook(in, ifp, m, ip6len);
 				/* nd6_ns_input() will be called in X_send_input_hook() */
 			} else {
 				/* give up local */
-				printf("%s %d: send_output_hook == NULL\n", __FUNCTION__, __LINE__);
 				nd6_ns_input(m, off, icmp6len);
 			}
 			m = NULL;
 			goto freeit;
 		}
 		if (send_output_hook != NULL) {
-			printf("%s %d: send_output_hook != NULL \n", __FUNCTION__, __LINE__);
 			send_output_hook(in, ifp, n, ip6len);
 			/* nd6_ns_input() will be called in X_send_input_hook() */
 		} else {
-			printf("%s %d: send_output_hook == NULL \n", __FUNCTION__, __LINE__);
 			nd6_ns_input(n, off, icmp6len);
 		}
 		/* m stays. */
@@ -838,13 +845,19 @@
 		if ((n = m_copym(m, 0, M_COPYALL, M_DONTWAIT)) == NULL) {
 
 		/* send incoming SeND-protected/ND packet to sendd */
-
-			/* give up local */
-			nd6_na_input(m, off, icmp6len);
+			if (send_output_hook != NULL) {
+				send_output_hook(in, ifp, m, ip6len);
+			} else {
+				/* give up local */
+				nd6_na_input(m, off, icmp6len);
+			}
 			m = NULL;
 			goto freeit;
 		}
-		nd6_na_input(n, off, icmp6len);
+		if (send_output_hook != NULL)
+			send_output_hook(in, ifp, n, ip6len);
+		else
+			nd6_na_input(n, off, icmp6len);
 		/* m stays. */
 		break;
 
@@ -857,13 +870,19 @@
 		if ((n = m_copym(m, 0, M_COPYALL, M_DONTWAIT)) == NULL) {
 
 		/* send incoming SeND-protected/ND packet to sendd */
-
-			/* give up local */
-			icmp6_redirect_input(m, off);
+			if (send_output_hook != NULL) {
+				send_output_hook(in, ifp, m, ip6len);
+			} else {
+				/* give up local */
+				icmp6_redirect_input(m, off);
+			}
 			m = NULL;
 			goto freeit;
 		}
-		icmp6_redirect_input(n, off);
+		if (send_output_hook != NULL)
+			send_output_hook(in, ifp, n, ip6len);
+		else
+			icmp6_redirect_input(n, off);
 		/* m stays. */
 		break;
 
@@ -2520,6 +2539,7 @@
 	struct in6_addr *router_ll6;
 	struct ip6_hdr *sip6;	/* m0 as struct ip6_hdr */
 	struct mbuf *m = NULL;	/* newly allocated one */
+	struct m_tag *mtag;
 	struct ip6_hdr *ip6;	/* m as struct ip6_hdr */
 	struct nd_redirect *nd_rd;
 	struct llentry *ln = NULL;
@@ -2779,6 +2799,14 @@
 	nd_rd->nd_rd_cksum = in6_cksum(m, IPPROTO_ICMPV6,
 	    sizeof(*ip6), ntohs(ip6->ip6_plen));
 
+        if (send_output_hook != NULL) {
+		mtag = m_tag_get(PACKET_TAG_ND_OUTGOING, sizeof(unsigned short), M_NOWAIT);
+		if (mtag == NULL)
+			goto fail;
+		*(unsigned short *)(mtag + 1) = nd_rd->nd_rd_type;
+		m_tag_prepend(m, mtag);
+	}
+
 	/* send the packet to outside... */
 	ip6_output(m, NULL, NULL, 0, NULL, &outif, NULL);
 	if (outif) {

==== //depot/projects/soc2009/anchie_send/src/sys/netinet6/nd6.c#10 (text+ko) ====

@@ -1728,7 +1728,7 @@
 	int error = 0;
 	int flags = 0;
 	int ip6len;
-	unsigned short nd_type;
+	unsigned short *nd_type;
 
 	printf("%s %d\n", __FUNCTION__, __LINE__);
 
@@ -1911,12 +1911,15 @@
 #endif
 
 	/* send outgoing NS/NA/RS/RA/REDIRECT packet to sendd. */
-	mtag = m_tag_find(m, PACKET_TAG_ND_OUTGOING, NULL);
-	if (mtag != NULL) {
-		printf("%s %d: ND_OUTGOING tag found.\n", __FUNCTION__, __LINE__);
-		/*nd_type = (unsigned short *)(mtag + 1);*/	
-		if (send_output_hook != NULL) {
-			send_output_hook(0, ifp, m, ip6len);
+	if (send_output_hook != NULL) {
+		mtag = m_tag_find(m, PACKET_TAG_ND_OUTGOING, NULL);
+		if (mtag != NULL) {
+			printf("%s %d: ND_OUTGOING tag found.\n", __FUNCTION__, __LINE__);
+			nd_type = (unsigned short *)(mtag + 1);
+		} else
+			return(error);
+
+		send_output_hook(0, ifp, m, ip6len);
 	} else {
 
 	/*

==== //depot/projects/soc2009/anchie_send/src/sys/netinet6/nd6_nbr.c#3 (text+ko) ====

@@ -1,4 +1,4 @@
-/*-
+/*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
  * All rights reserved.
  *
@@ -74,6 +74,7 @@
 #include <netinet6/scope6_var.h>
 #include <netinet6/nd6.h>
 #include <netinet/icmp6.h>
+#include <netinet6/send.h>
 #include <netinet6/vinet6.h>
 
 #ifdef DEV_CARP
@@ -563,11 +564,15 @@
 	nd_ns->nd_ns_cksum =
 	    in6_cksum(m, IPPROTO_ICMPV6, sizeof(*ip6), icmp6len);
 
-	mtag = m_tag_get(PACKET_TAG_ND_OUTGOING, sizeof(unsigned short), M_NOWAIT);
-	if (mtag == NULL)
-		goto bad;
-	/* *(unsigned short *)(mtag + 1) = nd_ns->nd_ns_type;*/
-	m_tag_prepend(m, mtag); 
+	if (send_output_hook != NULL) {
+		mtag = m_tag_get(PACKET_TAG_ND_OUTGOING, sizeof(unsigned short), M_NOWAIT);
+		if (mtag == NULL)
+			goto bad;
+		else
+			printf("%s: PACKET_TAG_ND_OUTGOING added.\n", __FUNCTION__);
+		*(unsigned short *)(mtag + 1) = nd_ns->nd_ns_type;
+		m_tag_prepend(m, mtag); 
+	}
 
 	ip6_output(m, NULL, &ro, dad ? IPV6_UNSPECSRC : 0, &im6o, NULL, NULL);
 	icmp6_ifstat_inc(ifp, ifs6_out_msg);
@@ -884,7 +889,6 @@
 			 * we assume ifp is not a loopback here, so just set
 			 * the 2nd argument as the 1st one.
 			 */
-			printf("%s %d: before ned6_output_lle()\n", __FUNCTION__, __LINE__);
 			nd6_output_lle(ifp, ifp, m_hold, L3_ADDR_SIN6(ln), NULL, ln, &chain);
 		}
 	}
@@ -930,6 +934,7 @@
 {
 	INIT_VNET_INET6(ifp->if_vnet);
 	struct mbuf *m;
+	struct m_tag *mtag;
 	struct ip6_hdr *ip6;
 	struct nd_neighbor_advert *nd_na;
 	struct ip6_moptions im6o;
@@ -1074,6 +1079,14 @@
 	nd_na->nd_na_cksum =
 	    in6_cksum(m, IPPROTO_ICMPV6, sizeof(struct ip6_hdr), icmp6len);
 
+	if (send_output_hook != NULL) {
+		mtag = m_tag_get(PACKET_TAG_ND_OUTGOING, sizeof(unsigned short), M_NOWAIT);
+		if (mtag == NULL)
+			goto bad;
+		*(unsigned short *)(mtag + 1) = nd_na->nd_na_type;
+		m_tag_prepend(m, mtag);
+	}
+
 	ip6_output(m, NULL, &ro, 0, &im6o, NULL, NULL);
 	icmp6_ifstat_inc(ifp, ifs6_out_msg);
 	icmp6_ifstat_inc(ifp, ifs6_out_neighboradvert);

==== //depot/projects/soc2009/anchie_send/src/sys/sys/mbuf.h#4 (text+ko) ====



More information about the p4-projects mailing list