summaryrefslogtreecommitdiffstats
path: root/sys/net/rtsock.c
diff options
context:
space:
mode:
authorqingli <qingli@FreeBSD.org>2008-12-26 19:45:24 +0000
committerqingli <qingli@FreeBSD.org>2008-12-26 19:45:24 +0000
commit1d851edfc076189dc55b168c116ce058e169b3b5 (patch)
treeaec8911164bb3c98b5849f1f20b997023e09f88f /sys/net/rtsock.c
parent53844c48501e6f859d33ac8536751f99ac6f1d94 (diff)
downloadFreeBSD-src-1d851edfc076189dc55b168c116ce058e169b3b5.zip
FreeBSD-src-1d851edfc076189dc55b168c116ce058e169b3b5.tar.gz
This checkin addresses a couple of issues:
1. The "route" command allows route insertion through the interface-direct option "-iface". During if_attach(), an sockaddr_dl{} entry is created for the interface and is part of the interface address list. This sockaddr_dl{} entry describes the interface in detail. The "route" command selects this entry as the "gateway" object when the "-iface" option is present. The "arp" and "ndp" commands also interact with the kernel through the routing socket when adding and removing static L2 entries. The static L2 information is also provided through the "gateway" object with an AF_LINK family type, similar to what is provided by the "route" command. In order to differentiate between these two types of operations, a RTF_LLDATA flag is introduced. This flag is set by the "arp" and "ndp" commands when issuing the add and delete commands. This flag is also set in each L2 entry returned by the kernel. The "arp" and "ndp" command follows a convention where a RTM_GET is issued first followed by a RTM_ADD/DELETE. This RTM_GET request fills in the fields for a "rtm" object, which is reinjected into the kernel by a subsequent RTM_ADD/DELETE command. The entry returend from RTM_GET is a prefix route, so the RTF_LLDATA flag must be specified when issuing the RTM_ADD/DELETE messages. 2. Enforce the convention that NET_RT_FLAGS with a 0 w_arg is the specification for retrieving L2 information. Also optimized the code logic. Reviewed by: julian
Diffstat (limited to 'sys/net/rtsock.c')
-rw-r--r--sys/net/rtsock.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c
index 30591c7..3c1436c 100644
--- a/sys/net/rtsock.c
+++ b/sys/net/rtsock.c
@@ -53,6 +53,7 @@
#include <sys/vimage.h>
#include <net/if.h>
+#include <net/if_dl.h>
#include <net/if_llatbl.h>
#include <net/netisr.h>
#include <net/raw_cb.h>
@@ -514,8 +515,10 @@ route_output(struct mbuf *m, struct socket *so)
if (info.rti_info[RTAX_GATEWAY] == NULL)
senderr(EINVAL);
saved_nrt = NULL;
+
/* support for new ARP code */
- if (info.rti_info[RTAX_GATEWAY]->sa_family == AF_LINK) {
+ if (info.rti_info[RTAX_GATEWAY]->sa_family == AF_LINK &&
+ (rtm->rtm_flags & RTF_LLDATA) != 0) {
error = lla_rt_output(rtm, &info);
break;
}
@@ -535,7 +538,8 @@ route_output(struct mbuf *m, struct socket *so)
saved_nrt = NULL;
/* support for new ARP code */
if (info.rti_info[RTAX_GATEWAY] &&
- (info.rti_info[RTAX_GATEWAY]->sa_family == AF_LINK)) {
+ (info.rti_info[RTAX_GATEWAY]->sa_family == AF_LINK) &&
+ (rtm->rtm_flags & RTF_LLDATA) != 0) {
error = lla_rt_output(rtm, &info);
break;
}
@@ -1427,6 +1431,21 @@ sysctl_rtsock(SYSCTL_HANDLER_ARGS)
lim = AF_MAX;
} else /* dump only one table */
i = lim = af;
+
+ /*
+ * take care of llinfo entries, the caller must
+ * specify an AF
+ */
+ if (w.w_op == NET_RT_FLAGS && w.w_arg == 0) {
+ if (af != 0)
+ error = lltable_sysctl_dumparp(af, w.w_req);
+ else
+ error = EINVAL;
+ break;
+ }
+ /*
+ * take care of routing entries
+ */
for (error = 0; error == 0 && i <= lim; i++)
if ((rnh = V_rt_tables[curthread->td_proc->p_fibnum][i]) != NULL) {
RADIX_NODE_HEAD_LOCK(rnh);
@@ -1435,11 +1454,6 @@ sysctl_rtsock(SYSCTL_HANDLER_ARGS)
RADIX_NODE_HEAD_UNLOCK(rnh);
} else if (af != 0)
error = EAFNOSUPPORT;
- /*
- * take care of llinfo entries
- */
- if (w.w_op == NET_RT_FLAGS)
- error = lltable_sysctl_dumparp(af, w.w_req);
break;
case NET_RT_IFLIST:
OpenPOWER on IntegriCloud