summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhrs <hrs@FreeBSD.org>2013-07-12 12:36:12 +0000
committerhrs <hrs@FreeBSD.org>2013-07-12 12:36:12 +0000
commitef82e58667b9e25aecd0a4343b97b94ce27d137e (patch)
tree8304af862548c2d7d1c830badbde7fc348e58686
parent59e83b64133e8a613e75e88b3c0857bb685708c4 (diff)
downloadFreeBSD-src-ef82e58667b9e25aecd0a4343b97b94ce27d137e.zip
FreeBSD-src-ef82e58667b9e25aecd0a4343b97b94ce27d137e.tar.gz
Add a leaf node CTL_NET.PF_ROUTE.0.AF.NET_RT_DUMP.0.FIB. This returns
routing table with the specified FIB number, not td->td_proc->p_fibnum.
-rw-r--r--lib/libc/gen/sysctl.318
-rw-r--r--sys/net/rtsock.c15
2 files changed, 22 insertions, 11 deletions
diff --git a/lib/libc/gen/sysctl.3 b/lib/libc/gen/sysctl.3
index b3737e2..7b3738d 100644
--- a/lib/libc/gen/sysctl.3
+++ b/lib/libc/gen/sysctl.3
@@ -28,7 +28,7 @@
.\" @(#)sysctl.3 8.4 (Berkeley) 5/9/95
.\" $FreeBSD$
.\"
-.Dd February 11, 2012
+.Dd May 17, 2013
.Dt SYSCTL 3
.Os
.Sh NAME
@@ -547,14 +547,14 @@ The length of each message is contained in the message header.
The third level name is a protocol number, which is currently always 0.
The fourth level name is an address family, which may be set to 0 to
select all address families.
-The fifth and sixth level names are as follows:
-.Bl -column "Fifth level nameXXXXXX" "Sixth level is:XXX" -offset indent
-.It Sy "Fifth level name Sixth level is:"
-.It "NET_RT_FLAGS rtflags"
-.It "NET_RT_DUMP None"
-.It "NET_RT_IFLIST 0 or if_index"
-.It "NET_RT_IFMALIST 0 or if_index"
-.It "NET_RT_IFLISTL 0 or if_index"
+The fifth, sixth, and seventh level names are as follows:
+.Bl -column "Fifth level " "Sixth level " -offset indent
+.It Sy "Fifth level Sixth level Seventh level"
+.It "NET_RT_FLAGS rtflags None"
+.It "NET_RT_DUMP None None or fib number"
+.It "NET_RT_IFLIST 0 or if_index None"
+.It "NET_RT_IFMALIST 0 or if_index None"
+.It "NET_RT_IFLISTL 0 or if_index None"
.El
.Pp
The
diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c
index d665280..928d2ab 100644
--- a/sys/net/rtsock.c
+++ b/sys/net/rtsock.c
@@ -1905,6 +1905,7 @@ sysctl_rtsock(SYSCTL_HANDLER_ARGS)
u_int namelen = arg2;
struct radix_node_head *rnh = NULL; /* silence compiler. */
int i, lim, error = EINVAL;
+ int fib = 0;
u_char af;
struct walkarg w;
@@ -1912,7 +1913,17 @@ sysctl_rtsock(SYSCTL_HANDLER_ARGS)
namelen--;
if (req->newptr)
return (EPERM);
- if (namelen != 3)
+ if (name[1] == NET_RT_DUMP) {
+ if (namelen == 3)
+ fib = req->td->td_proc->p_fibnum;
+ else if (namelen == 4)
+ fib = (name[3] == -1) ?
+ req->td->td_proc->p_fibnum : name[3];
+ else
+ return ((namelen < 3) ? EISDIR : ENOTDIR);
+ if (fib < 0 || fib >= rt_numfibs)
+ return (EINVAL);
+ } else if (namelen != 3)
return ((namelen < 3) ? EISDIR : ENOTDIR);
af = name[0];
if (af > AF_MAX)
@@ -1951,7 +1962,7 @@ sysctl_rtsock(SYSCTL_HANDLER_ARGS)
* take care of routing entries
*/
for (error = 0; error == 0 && i <= lim; i++) {
- rnh = rt_tables_get_rnh(req->td->td_proc->p_fibnum, i);
+ rnh = rt_tables_get_rnh(fib, i);
if (rnh != NULL) {
RADIX_NODE_HEAD_RLOCK(rnh);
error = rnh->rnh_walktree(rnh,
OpenPOWER on IntegriCloud