summaryrefslogtreecommitdiffstats
path: root/sys/net/rtsock.c
diff options
context:
space:
mode:
authorluigi <luigi@FreeBSD.org>2004-04-12 20:26:01 +0000
committerluigi <luigi@FreeBSD.org>2004-04-12 20:26:01 +0000
commit9d988416166cf2f0711666ddf7a3373864188400 (patch)
treee6cb348d3454d1b5dbe7858f6f33fff7339e71e3 /sys/net/rtsock.c
parent1a6dae835ce85b6f850982743b63c0c36ebe975a (diff)
downloadFreeBSD-src-9d988416166cf2f0711666ddf7a3373864188400.zip
FreeBSD-src-9d988416166cf2f0711666ddf7a3373864188400.tar.gz
remove an almost-duplicate piece of code by setting the loop
limits appropriately.
Diffstat (limited to 'sys/net/rtsock.c')
-rw-r--r--sys/net/rtsock.c26
1 files changed, 10 insertions, 16 deletions
diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c
index 44445eb..7bdd0d7 100644
--- a/sys/net/rtsock.c
+++ b/sys/net/rtsock.c
@@ -1080,8 +1080,8 @@ sysctl_rtsock(SYSCTL_HANDLER_ARGS)
int *name = (int *)arg1;
u_int namelen = arg2;
struct radix_node_head *rnh;
- int i, s, error = EINVAL;
- u_char af;
+ int i, lim, s, error = EINVAL;
+ u_char af;
struct walkarg w;
name ++;
@@ -1103,25 +1103,19 @@ sysctl_rtsock(SYSCTL_HANDLER_ARGS)
case NET_RT_DUMP:
case NET_RT_FLAGS:
- if (af != 0) {
- if ((rnh = rt_tables[af]) != NULL) {
+ if (af == 0) { /* dump all tables */
+ i = 1;
+ lim = AF_MAX;
+ } else /* dump only one table */
+ i = lim = af;
+ for (error = 0; error == 0 && i <= lim; i++)
+ if ((rnh = rt_tables[i]) != NULL) {
/* RADIX_NODE_HEAD_LOCK(rnh); */
error = rnh->rnh_walktree(rnh,
sysctl_dumpentry, &w);/* could sleep XXX */
/* RADIX_NODE_HEAD_UNLOCK(rnh); */
- } else
+ } else if (af != 0)
error = EAFNOSUPPORT;
- } else {
- for (i = 1; i <= AF_MAX; i++)
- if ((rnh = rt_tables[i]) != NULL) {
- /* RADIX_NODE_HEAD_LOCK(rnh); */
- error = rnh->rnh_walktree(rnh,
- sysctl_dumpentry, &w);
- /* RADIX_NODE_HEAD_UNLOCK(rnh); */
- if (error)
- break;
- }
- }
break;
case NET_RT_IFLIST:
OpenPOWER on IntegriCloud