PERFORCE change 164264 for review

Ana Kukec anchie at FreeBSD.org
Sat Jun 13 12:58:36 UTC 2009


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

Change 164264 by anchie at anchie_malimis on 2009/06/13 12:57:33

	Introduction of the initial code for sending RTM_SND message to
	SeND userspace application.	

Affected files ...

.. //depot/projects/soc2009/anchie_send/src/sys/net/route.h#2 edit
.. //depot/projects/soc2009/anchie_send/src/sys/net/rtsock.c#2 edit
.. //depot/projects/soc2009/anchie_send/src/sys/netinet6/icmp6.c#5 edit
.. //depot/projects/soc2009/anchie_send/src/sys/netinet6/send.c#7 edit
.. //depot/projects/soc2009/anchie_send/src/sys/netinet6/send.h#7 edit

Differences ...

==== //depot/projects/soc2009/anchie_send/src/sys/net/route.h#2 (text+ko) ====

@@ -258,6 +258,7 @@
 #define	RTM_DELMADDR	0x10	/* mcast group membership being deleted */
 #define	RTM_IFANNOUNCE	0x11	/* iface arrival/departure */
 #define	RTM_IEEE80211	0x12	/* IEEE80211 wireless event */
+#define RTM_SND		0x13	/* SeND event. */
 
 /*
  * Bitmask values for rtm_inits and rmx_locks.
@@ -378,6 +379,7 @@
 struct ifmultiaddr;
 
 void	 rt_ieee80211msg(struct ifnet *, int, void *, size_t);
+void	 rt_sndmsg(struct ifnet *, int, void *, size_t data_len);
 void	 rt_ifannouncemsg(struct ifnet *, int);
 void	 rt_ifmsg(struct ifnet *);
 void	 rt_missmsg(int, struct rt_addrinfo *, int, int);

==== //depot/projects/soc2009/anchie_send/src/sys/net/rtsock.c#2 (text+ko) ====

@@ -1153,6 +1153,47 @@
 }
 
 /*
+ * Generation of the routing socket message indicating SeND event.
+ */
+void
+rt_sndmsg(struct ifnet *ifp, int in, void *data, size_t data_len)
+{
+	struct mbuf *m;
+	struct rt_addrinfo info;
+
+	if (in) {
+		/* Incoming traffic sent to userspace for SeND validation */
+		m = rt_makeifannouncemsg(ifp, RTM_SND, RTM_SND_IN, &info);
+	} else {
+		/* Outgoing traffic sent to userspace for SeND protection */
+		m = rt_makeifannouncemsg(ifp, RTM_SND, RTM_SND_OUT, &info);
+	}
+	if (m != NULL) {
+		/*
+		 * Append ND/SeND message to ifannounce hdr.
+		 * Taken from rt_ieee80211msg().
+		 */
+		if (data_len > M_TRAILINGSPACE(m)) {
+			struct mbuf *n = m_get(M_NOWAIT, MT_DATA);
+			if (n == NULL) {
+				m_freem(m);
+				return;
+			}
+			bcopy(data, mtod(n, void *), data_len);
+			n->m_len = data_len;
+			m->m_next = n;
+		} else if (data_len > 0) {
+			bcopy(data, mtod(m, u_int8_t *) + m->m_len, data_len);
+			m->m_len += data_len;
+		}
+		if (m->m_flags & M_PKTHDR)
+			m->m_pkthdr.len += data_len;
+		mtod(m, struct if_announcemsghdr *)->ifan_msglen += data_len;
+		rt_dispatch(m, NULL);
+	}
+}
+
+/*
  * This is called to generate routing socket messages indicating
  * IEEE80211 wireless events.
  * XXX we piggyback on the RTM_IFANNOUNCE msg format in a clumsy way.

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

@@ -410,6 +410,9 @@
 	int icmp6len = m->m_pkthdr.len - *offp;
 	int code, sum, noff;
 	char ip6bufs[INET6_ADDRSTRLEN], ip6bufd[INET6_ADDRSTRLEN];
+	int in;
+
+	in = 1;
 
 	ifp = m->m_pkthdr.rcvif;
 
@@ -803,13 +806,16 @@
 
 		/* send incoming SeND-protected/ND packet to sendd */
 		if (send_input_hook != NULL)
-			send_input_hook();
-
+			send_output_hook(in, ifp, m, icmp6len);
 			/* give up local */
-			nd6_ns_input(m, off, icmp6len);
+			/* nd6_ns_input() will be called in X_send_input_hook() */
+			nd6_ns_input(in, m, off, icmp6len);
 			m = NULL;
 			goto freeit;
 		}
+		if (send_output_hook != NULL)
+			send_output_hook(in, ifp, n, icmp6len);
+		/* nd6_ns_input() will be called in X_send_input_hook() */
 		nd6_ns_input(n, off, icmp6len);
 		/* m stays. */
 		break;

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

@@ -9,13 +9,29 @@
 
 #include <send.h>
 
-static int	X_send_input_hook(void);
+static int	X_send_input_hook(void); 
+static int	X_send_output_hook(int, struct ifnet *, struct mbuf *, int);
+
+
 
 static int
 X_send_input_hook(void)
 {
 
-	/* send module is loaded, send incoming packet to sendd */	
+	/* 
+	 * send module is loaded, process incoming packets passed from
+	 * sendd to kernel. Outgoing packets are sent directly to
+	 * corresponding node's sendd.(?)
+	 */	
+
+	return 0;
+}
+
+static int
+X_send_output_hook(int in, struct ifnet *ifp, struct mbuf *m, int icmp6len)
+{
+	/* send module is loaded, send incoming or outgoing traffic to sendd */
+	rt_sndmsg(ifp, in, m, icmp6len);
 
 	return 0;
 }
@@ -27,7 +43,7 @@
 
 	switch (type) {
 	case MOD_LOAD:
-		send_input_hook = X_send_input_hook;
+		send_output_hook = X_send_output_hook;
 		break;
 
 	case MOD_UNLOAD:

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

@@ -1,2 +1,12 @@
 /* send.c */
-int	(*send_input_hook)(struct mbuf *, int, int);
+int	(*send_output_hook)(int, struct ifnet *, struct mbuf *, int, int);
+
+/* Message formats for messages from ND to applications (sendd) via the 
+ * routing socket. These messages are appended to an if_announcemsghdr 
+ * structure.
+ */
+struct snd_message_event {
+}
+
+#define RTM_SND_OUT	0	/* outgoing traffic sent to sendd */
+#define RTM_SND_IN	1	/* incoming traffic sent to sendd */


More information about the p4-projects mailing list