PERFORCE change 165506 for review
Ana Kukec
anchie at FreeBSD.org
Wed Jul 1 16:43:18 UTC 2009
http://perforce.freebsd.org/chv.cgi?CH=165506
Change 165506 by anchie at anchie_malimis on 2009/07/01 16:43:01
Editorial changes.
New function (net/rtsock.c: rt_msg3()) in order to avoide the duplication of
the code in rt_ieee80211msg() and rt_securendmsg().
Affected files ...
.. //depot/projects/soc2009/anchie_send/src/sys/net/route.h#5 edit
.. //depot/projects/soc2009/anchie_send/src/sys/net/rtsock.c#5 edit
.. //depot/projects/soc2009/anchie_send/src/sys/netinet/icmp6.h#8 edit
.. //depot/projects/soc2009/anchie_send/src/sys/netinet6/icmp6.c#13 edit
.. //depot/projects/soc2009/anchie_send/src/sys/netinet6/nd6.c#11 edit
.. //depot/projects/soc2009/anchie_send/src/sys/netinet6/nd6_rtr.c#5 edit
.. //depot/projects/soc2009/anchie_send/src/sys/netinet6/send.c#11 edit
.. //depot/projects/soc2009/anchie_send/src/sys/netinet6/send.h#11 edit
.. //depot/projects/soc2009/anchie_send/src/sys/sys/mbuf.h#5 edit
Differences ...
==== //depot/projects/soc2009/anchie_send/src/sys/net/route.h#5 (text+ko) ====
@@ -234,7 +234,6 @@
u_long rtm_inits; /* which metrics we are initializing */
struct rt_metrics rtm_rmx; /* metrics themselves */
};
-
#define RTM_VERSION 5 /* Up the ante and ignore older versions */
/*
@@ -380,7 +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_securendmsg(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#5 (text+ko) ====
@@ -1,4 +1,4 @@
-/*-
+/*
* Copyright (c) 1988, 1991, 1993
* The Regents of the University of California. All rights reserved.
*
@@ -60,12 +60,11 @@
#include <net/route.h>
#include <net/vnet.h>
-#include <netinet6/send.h>
-
#include <netinet/in.h>
#ifdef INET6
#include <netinet6/scope6_var.h>
#endif
+#include <netinet6/send.h>
#if defined(INET) || defined(INET6)
#ifdef SCTP
@@ -106,6 +105,7 @@
static struct mbuf *rt_msg1(int type, struct rt_addrinfo *rtinfo);
static int rt_msg2(int type, struct rt_addrinfo *rtinfo,
caddr_t cp, struct walkarg *w);
+static void rt_msg3(struct mbuf *, void *, size_t);
static int rt_xaddrs(caddr_t cp, caddr_t cplim,
struct rt_addrinfo *rtinfo);
static int sysctl_dumpentry(struct radix_node *rn, void *vw);
@@ -1179,23 +1179,37 @@
* Generation of the routing socket message indicating SeND event.
*/
void
-rt_sndmsg(struct ifnet *ifp, int in, void *data, size_t data_len)
+rt_securendmsg(struct ifnet *ifp, int direction, void *data, size_t data_len)
{
struct mbuf *m;
struct rt_addrinfo info;
- if (in) {
- /* Incoming traffic sent to userspace for SeND validation */
+ switch (direction) {
+ case SEND_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 */
+ break;
+ case SEND_OUT:
+ /* Outgoing traffic sent to userspace for SeND protection. */
m = rt_makeifannouncemsg(ifp, RTM_SND, RTM_SND_OUT, &info);
+ break;
}
+
+ rt_msg3(m, data, data_len);
+}
+
+void
+rt_msg3(struct mbuf *m, void *data, size_t data_len)
+{
if (m != NULL) {
/*
- * Append ND/SeND message to ifannounce hdr.
- * Taken from rt_ieee80211msg().
+ * Append the ieee80211 or ND/SEND data. Try to stick it in the
+ * mbuf containing the ifannounce msg; otherwise allocate
+ * a new mbuf and append.
+ *
+ * NB: we assume m is a single mbuf.
*/
+
if (data_len > M_TRAILINGSPACE(m)) {
struct mbuf *n = m_get(M_NOWAIT, MT_DATA);
if (n == NULL) {
@@ -1228,6 +1242,10 @@
struct rt_addrinfo info;
m = rt_makeifannouncemsg(ifp, RTM_IEEE80211, what, &info);
+
+ rt_msg3(m, data, data_len);
+
+#if 0
if (m != NULL) {
/*
* Append the ieee80211 data. Try to stick it in the
@@ -1254,6 +1272,7 @@
mtod(m, struct if_announcemsghdr *)->ifan_msglen += data_len;
rt_dispatch(m, NULL);
}
+#endif
}
/*
==== //depot/projects/soc2009/anchie_send/src/sys/netinet/icmp6.h#8 (text+ko) ====
==== //depot/projects/soc2009/anchie_send/src/sys/netinet6/icmp6.c#13 (text+ko) ====
@@ -412,8 +412,6 @@
int in;
int ip6len;
- in = 1;
-
ifp = m->m_pkthdr.rcvif;
#ifndef PULLDOWN_TEST
@@ -767,17 +765,18 @@
if ((n = m_copym(m, 0, M_COPYALL, M_DONTWAIT)) == NULL) {
/* give up local */
- /* send incoming SeND-protected/ND packet to sendd */
- if (send_output_hook != NULL) {
- send_output_hook(in, ifp, m, ip6len);
- } else {
+ /* Send incoming SeND-protected/ND packet to user space. */
+ if (send_output_hook != NULL)
+ send_output_hook(m, ifp, SND_IN, ip6len);
+ else {
+ /* give up local */
nd6_rs_input(m, off, icmp6len);
}
m = NULL;
goto freeit;
}
if (send_output_hook != NULL)
- send_output_hook(in, ifp, n, ip6len);
+ send_output_hook(n, ifp, SND_IN, ip6len);
else
nd6_rs_input(n, off, icmp6len);
/* m stays. */
@@ -791,18 +790,16 @@
goto badlen;
if ((n = m_copym(m, 0, M_COPYALL, M_DONTWAIT)) == NULL) {
- /* send incoming SeND-protected/ND packet to sendd */
- if (send_output_hook != NULL) {
- send_output_hook(in, ifp, m, ip6len);
- } else {
- /* give up local */
+ /* Send incoming SeND-protected/ND packet to user space. */
+ if (send_output_hook != NULL)
+ send_output_hook(m, ifp, SND_IN, ip6len);
+ else
nd6_ra_input(m, off, icmp6len);
- }
m = NULL;
goto freeit;
}
if (send_output_hook != NULL)
- send_output_hook(in, ifp, n, ip6len);
+ send_output_hoo(n, ifp, SND_IN, ip6len);
else
nd6_ra_input(n, off, icmp6len);
/* m stays. */
@@ -816,23 +813,20 @@
goto badlen;
if ((n = m_copym(m, 0, M_COPYALL, M_DONTWAIT)) == NULL) {
- /* send incoming SeND-protected/ND packet to sendd */
- if (send_output_hook != NULL) {
- send_output_hook(in, ifp, m, ip6len);
- /* nd6_ns_input() will be called in X_send_input_hook() */
- } else {
+ /* Send incoming SeND-protected/ND packet to user space. */
+ if (send_output_hook != NULL)
+ send_output_hook(m, ifp, SND_IN, ip6len);
+ else {
/* give up local */
nd6_ns_input(m, off, icmp6len);
}
m = NULL;
goto freeit;
}
- if (send_output_hook != NULL) {
- send_output_hook(in, ifp, n, ip6len);
- /* nd6_ns_input() will be called in X_send_input_hook() */
- } else {
+ if (send_output_hook != NULL)
+ send_output_hook(n, ifp, SND_IN, ip6len);
+ else
nd6_ns_input(n, off, icmp6len);
- }
/* m stays. */
break;
@@ -844,10 +838,10 @@
goto badlen;
if ((n = m_copym(m, 0, M_COPYALL, M_DONTWAIT)) == NULL) {
- /* send incoming SeND-protected/ND packet to sendd */
- if (send_output_hook != NULL) {
- send_output_hook(in, ifp, m, ip6len);
- } else {
+ /* Send incoming SeND-protected/ND packet to user space. */
+ if (send_output_hook != NULL)
+ send_output_hook(m, ifp, SND_IN, ip6len);
+ else {
/* give up local */
nd6_na_input(m, off, icmp6len);
}
@@ -855,7 +849,7 @@
goto freeit;
}
if (send_output_hook != NULL)
- send_output_hook(in, ifp, n, ip6len);
+ send_output_hook(n, ifp, SND_IN, ip6len);
else
nd6_na_input(n, off, icmp6len);
/* m stays. */
@@ -869,10 +863,10 @@
goto badlen;
if ((n = m_copym(m, 0, M_COPYALL, M_DONTWAIT)) == NULL) {
- /* send incoming SeND-protected/ND packet to sendd */
- if (send_output_hook != NULL) {
- send_output_hook(in, ifp, m, ip6len);
- } else {
+ /* Send incoming SeND-protected/ND packet to user space. */
+ if (send_output_hook != NULL)
+ send_output_hook(m, ifp, SND_IN, ip6len);
+ else {
/* give up local */
icmp6_redirect_input(m, off);
}
@@ -880,24 +874,12 @@
goto freeit;
}
if (send_output_hook != NULL)
- send_output_hook(in, ifp, n, ip6len);
+ send_output_hook(n, ifp, SND_IN, ip6len);
else
icmp6_redirect_input(n, off);
/* m stays. */
break;
-#if 0
- case SEND_CERT_PATH_SOLICIT:
- /* send CPS packet to sendd */
- send6_cps_input();
- break;
-
- case SEND_CERT_PATH_ADVERT:
- /* send CPA packet to sendd */
- send6_cpa_input();
- break;
-#endif
-
case ICMP6_ROUTER_RENUMBERING:
if (code != ICMP6_ROUTER_RENUMBERING_COMMAND &&
code != ICMP6_ROUTER_RENUMBERING_RESULT)
==== //depot/projects/soc2009/anchie_send/src/sys/netinet6/nd6.c#11 (text+ko) ====
@@ -113,8 +113,8 @@
static struct sockaddr_in6 all1_sa;
-int (*send_output_hook)(int, struct ifnet *, struct mbuf *, int) = NULL;
-int (*send_input_hook)(void) = NULL;
+int (*send_output_hook)(struct mbuf*, struct ifnet *, int, int);
+int (*send_input_hook)(void);
static int nd6_is_new_addr_neighbor __P((struct sockaddr_in6 *,
struct ifnet *));
@@ -1733,7 +1733,7 @@
printf("%s %d\n", __FUNCTION__, __LINE__);
ip6 = mtod(m, struct ip6_hdr *);
- ip6len = ntohs(ip6->ip6_plen) + sizeof(struct ip6_hdr);
+ ip6len = sizeof(struct ip6_hdr) + ntohs(ip6->ip6_plen);
#ifdef INVARIANTS
if (lle != NULL) {
@@ -1910,16 +1910,16 @@
mac_netinet6_nd6_send(ifp, m);
#endif
- /* send outgoing NS/NA/RS/RA/REDIRECT packet to sendd. */
+ /* send outgoing NS/NA/REDIRECT packet to sendd. */
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);
+ return(ENOMSG);
- send_output_hook(0, ifp, m, ip6len);
+ send_output_hook(m, ifp, 0, ip6len);
} else {
/*
@@ -1930,7 +1930,7 @@
* after the lock is dropped
*/
- /* This will be done in the input hook.. */
+ /* This will be done in the input hook. */
if (lle != NULL) {
if (*chain == NULL)
*chain = m;
@@ -1952,7 +1952,8 @@
* or nd6_na_output(). RS, RA, and Redirect do not have such output
* routines. They are handled instead by rtadvd and rtsol daemons.
*
- * if_output() routines together with previous chaining will be called from input hook.
+ * if_output() routines together with previous chaining will be called
+ * from input hook.
*/
if ((ifp->if_flags & IFF_LOOPBACK) != 0) {
==== //depot/projects/soc2009/anchie_send/src/sys/netinet6/nd6_rtr.c#5 (text+ko) ====
@@ -425,27 +425,6 @@
m_freem(m);
}
-#if 0
-/*
- * Receive Certification Path Solicitation [rfc3971].
- */
-void
-send6_cps_input(struct mbuf *m, int off, int icmp6len)
-{
-}
-
-/*
- * Receive Certification Path Advertisement [rfc3971].
- */
-void
-send6_cpa_input(struct mbuf *m, int off, int icmp6len)
-{
-}
-
-/* send6_cps/cpa_output() should be places here as well.. */
-#endif
-
-
/*
* default router list proccessing sub routines
*/
==== //depot/projects/soc2009/anchie_send/src/sys/netinet6/send.c#11 (text+ko) ====
@@ -4,53 +4,48 @@
#include <sys/module.h>
#include <sys/kernel.h>
#include <sys/systm.h>
+#include <sys/socket.h>
-#include <sys/socket.h>
#include <net/route.h>
#include <netinet6/send.h>
-#if 0
-static int X_send_input_hook(void);
-static int X_send_output_hook(int, struct ifnet *, struct mbuf *, int);
-#endif
-#if 0
-int (*send_output_hook)(int, struct ifnet *, struct mbuf *, int);
-int (*send_input_hook)(void);
-#endif
-
static int
-X_send_input_hook(void)
+send_input(void)
{
/*
- * send module is loaded, process incoming packets passed from
- * sendd to kernel. Outgoing packets are sent out using if_output().
+ * Receive incoming (SEND-protected) or outgoing traffic (SEND-validated)
+ * from the SEND user space application.
+ * Outgoing packets are sent out using if_output().
*/
- return 0;
+ return (0);
}
static int
-X_send_output_hook(int in, struct ifnet *ifp, struct mbuf *m, int msglen)
+send_output(int in, struct ifnet *ifp, struct mbuf *m, int msglen)
{
- /* send module is loaded, send incoming or outgoing traffic to sendd */
+
+ /*
+ * Send incoming or outgoing traffic to the user space either to be
+ * protected (outgoing) or validated (incoming) according to rfc3971. */
rt_sndmsg(ifp, in, m, msglen);
- return 0;
+ return (0);
}
static int
send_modevent(module_t mod, int type, void *unused)
{
- int err = 0;
+ int error = 0;
/* Add locking? icmp6.c and nd6.c are maybe using hooks.. */
switch (type) {
case MOD_LOAD:
- send_output_hook = X_send_output_hook;
- send_input_hook = X_send_input_hook;
+ send_output_hook = send_output;
+ send_input_hook = send_input;
break;
case MOD_UNLOAD:
@@ -61,7 +56,7 @@
default:
break;
}
- return err;
+ return (0);
}
static moduledata_t sendmod = {
==== //depot/projects/soc2009/anchie_send/src/sys/netinet6/send.h#11 (text+ko) ====
@@ -1,11 +1,14 @@
/* send.c */
-extern int (*send_output_hook)(int, struct ifnet *, struct mbuf *, int);
+extern int (*send_output_hook)(struct mbuf *, struct ifnet *, int, int);
extern int (*send_input_hook)(void);
-/* Message formats for messages from ND to applications (sendd) via the
+/* Message formats for messages from ND to applications (i.e. sendd) via the
* routing socket. These messages are appended to an if_announcemsghdr
* structure.
*/
-#define RTM_SND_OUT 0 /* outgoing traffic sent to sendd */
-#define RTM_SND_IN 1 /* incoming traffic sent to sendd */
+#define SEND_OUT 0 /* outgoing traffic sent to sendd */
+#define SEND_IN 1
+
+#define RTM_SND_OUT 0 /* outgoing traffic with RTM header sent to sendd */
+#define RTM_SND_IN 1 /* incoming traffic with RTM header sent to sendd */
==== //depot/projects/soc2009/anchie_send/src/sys/sys/mbuf.h#5 (text+ko) ====
@@ -899,7 +899,7 @@
#define PACKET_TAG_IPOPTIONS 27 /* Saved IP options */
#define PACKET_TAG_CARP 28 /* CARP info */
#define PACKET_TAG_IPSEC_NAT_T_PORTS 29 /* two uint16_t */
-#define PACKET_TAG_ND_OUTGOING 30 /* ND outgoing */
+#define PACKET_TAG_ND_OUTGOING 30 /* ND outgoing */
/* Specific cookies and tags. */
More information about the p4-projects
mailing list