PERFORCE change 164368 for review

Ana Kukec anchie at FreeBSD.org
Sun Jun 14 18:46:30 UTC 2009


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

Change 164368 by anchie at anchie_malimis on 2009/06/14 18:45:39

		Processing of the outgoing traffic on the output hook (from ND stack
	in kernel to sendd in the userspace), for NS/A messages.	

Affected files ...

.. //depot/projects/soc2009/anchie_send/send_0.2/sendd/net.c#7 edit
.. //depot/projects/soc2009/anchie_send/send_0.2/sendd/proto.c#5 edit
.. //depot/projects/soc2009/anchie_send/src/sys/netinet6/icmp6.c#6 edit
.. //depot/projects/soc2009/anchie_send/src/sys/netinet6/nd6.c#3 edit
.. //depot/projects/soc2009/anchie_send/src/sys/netinet6/send.c#8 edit

Differences ...

==== //depot/projects/soc2009/anchie_send/send_0.2/sendd/net.c#7 (text+ko) ====

@@ -204,12 +204,20 @@
 			in = 1;
 
 			/* n = RTM hdr + m as passed to nd6_ns_input() */
-			m = (struct ip6_hdr *) &ifan[1];
+			m = (struct rt_msghdr *) &ifan[1];
 
 			/* ToDo: Extract ifidx. */
 			snd_recv_pkt(m, ifidx, in);		
 			break;
 		case RTM_SND_OUT:
+			in = 0;
+
+			/* n = RTM hdr + ether_hdr + ip6_hdr + icmp6len == ND message (as sent to if_output()) */
+			m = (struct rt_msghdr *) &ifan[1];
+
+			/* ToDo: Extract ifidx. */
+			snd_recv_pkt(m, ifidx, in);
+
 			break;
 		}
 		break;

==== //depot/projects/soc2009/anchie_send/send_0.2/sendd/proto.c#5 (text+ko) ====

@@ -669,6 +669,14 @@
 		return;
 	}
 */
+/*
+	if (!in)
+		if (sbuff_pull(b, sizeof (struct ether_header)) == NULL) {
+			DBG(&dbg_snd, "invalid pkt (not enough for ether header");
+			goto drop;
+		}
+	}
+*/
 	start = sbuff_data(b);
 
 	DBG(&dbg, "%s", in ? "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" :

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

@@ -411,6 +411,7 @@
 	int code, sum, noff;
 	char ip6bufs[INET6_ADDRSTRLEN], ip6bufd[INET6_ADDRSTRLEN];
 	int in;
+	int ip6len = -1;
 
 	in = 1;
 
@@ -427,6 +428,7 @@
 	 */
 
 	ip6 = mtod(m, struct ip6_hdr *);
+	ip6len = ip6->ip6_plen;
 	if (icmp6len < sizeof(struct icmp6_hdr)) {
 		ICMP6STAT_INC(icp6s_tooshort);
 		goto freeit;
@@ -766,8 +768,6 @@
 			/* give up local */
 
 		/* send incoming SeND-protected/ND packet to sendd */
-		if (send_input_hook != NULL)
-			send_input_hook();
 
 			nd6_rs_input(m, off, icmp6len);
 			m = NULL;
@@ -805,8 +805,9 @@
 		if ((n = m_copym(m, 0, M_COPYALL, M_DONTWAIT)) == NULL) {
 
 		/* send incoming SeND-protected/ND packet to sendd */
-		if (send_input_hook != NULL)
-			send_output_hook(in, ifp, m, icmp6len);
+		/* ip6len should be the same as icmp6len + off! */
+		if (send_output_hook != NULL)
+			send_output_hook(in, ifp, m, ip6len);
 			/* give up local */
 			/* nd6_ns_input() will be called in X_send_input_hook() */
 			nd6_ns_input(in, m, off, icmp6len);
@@ -814,7 +815,7 @@
 			goto freeit;
 		}
 		if (send_output_hook != NULL)
-			send_output_hook(in, ifp, n, icmp6len);
+			send_output_hook(in, ifp, n, ip6len);
 		/* nd6_ns_input() will be called in X_send_input_hook() */
 		nd6_ns_input(n, off, icmp6len);
 		/* m stays. */

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

@@ -1724,8 +1724,12 @@
 	INIT_VNET_INET6(curvnet);
 	struct mbuf *m = m0;
 	struct llentry *ln = lle;
+	struct ip6_hdr *ip6;
 	int error = 0;
 	int flags = 0;
+	int in = -1;
+
+	ip6 = mtod(m, struct ip6_hdr *);
 
 #ifdef INVARIANTS
 	if (lle != NULL) {
@@ -1876,6 +1880,7 @@
 		
 		nd6_llinfo_settimer(ln,
 		    (long)ND_IFINFO(ifp)->retrans * hz / 1000);
+
 		nd6_ns_output(ifp, NULL, &dst->sin6_addr, ln, 0);
 	}
 	return (0);
@@ -1900,6 +1905,12 @@
 #ifdef MAC
 	mac_netinet6_nd6_send(ifp, m);
 #endif
+
+	/* send outgoing SeND/ND packet to sendd. */
+	in = 0;
+	if (send_output_hook != NULL)
+		send_output_hook(in, ifp, m, ip6->ip6_plen);
+
 	/*
 	 * We were passed in a pointer to an lle with the lock held 
 	 * this means that we can't call if_output as we will
@@ -1907,6 +1918,8 @@
 	 * a list of mbufs to send and transmit them in the caller
 	 * after the lock is dropped
 	 */
+
+	/* This will be done in the input hook.. */
 	if (lle != NULL) {
 		if (*chain == NULL)
 			*chain = m;
@@ -1923,19 +1936,20 @@
 		return (error);
 	}
 
-	/* send outgoing SeND/ND packet to sendd. */
-
 	/* 
 	 * In case of NS and NA, we end-up here after calling nd6_ns_output() 
 	 * or nd6_na_output(). RS, RA, and Redirect do not have such output 
-	 * routines. They are handler instead by rtadvd and rtsol daemons. 
+	 * routines. They are handled instead by rtadvd and rtsol daemons. 
+	 *
+	 * if_output() routines together with previous chaining will be called from input hook. 
 	 */
-
+/*
 	if ((ifp->if_flags & IFF_LOOPBACK) != 0) {
 		return ((*ifp->if_output)(origifp, m, (struct sockaddr *)dst,
 		    NULL));
 	}
 	error = (*ifp->if_output)(ifp, m, (struct sockaddr *)dst, NULL);
+*/
 	return (error);
 
   bad:

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

@@ -20,18 +20,17 @@
 
 	/* 
 	 * send module is loaded, process incoming packets passed from
-	 * sendd to kernel. Outgoing packets are sent directly to
-	 * corresponding node's sendd.(?)
+	 * sendd to kernel. Outgoing packets are sent out using if_output(). 
 	 */	
 
 	return 0;
 }
 
 static int
-X_send_output_hook(int in, struct ifnet *ifp, struct mbuf *m, int icmp6len)
+X_send_output_hook(int in, struct ifnet *ifp, struct mbuf *m, int msglen)
 {
 	/* send module is loaded, send incoming or outgoing traffic to sendd */
-	rt_sndmsg(ifp, in, m, icmp6len);
+	rt_sndmsg(ifp, in, m, msglen);
 
 	return 0;
 }


More information about the p4-projects mailing list