diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2010-04-21 11:52:47 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2010-04-21 11:52:47 +0000 |
commit | bcd4275e3c286d594aba601d86cd7abc8577d4d0 (patch) | |
tree | ef84a03d1e45f01e694a9785abf42f95ba5f19e1 | |
parent | df71122422fb3534850dc8927f64c126a80aae22 (diff) |
Implement a way to get information about a rtable. Currently only the rtableid
and rdomainid are returned. This is necessary to know where L2 information
of a table is stored (which will be needed soon by bgpd).
Also while there change the errno for non-existing routing tables to ENOENT.
'Fine' deraadt@
-rw-r--r-- | sys/net/route.h | 10 | ||||
-rw-r--r-- | sys/net/rtsock.c | 17 | ||||
-rw-r--r-- | sys/sys/socket.h | 7 |
3 files changed, 29 insertions, 5 deletions
diff --git a/sys/net/route.h b/sys/net/route.h index ca4940d16e7..72d8927dc8b 100644 --- a/sys/net/route.h +++ b/sys/net/route.h @@ -1,4 +1,4 @@ -/* $OpenBSD: route.h,v 1.66 2010/02/09 16:31:14 claudio Exp $ */ +/* $OpenBSD: route.h,v 1.67 2010/04/21 11:52:46 claudio Exp $ */ /* $NetBSD: route.h,v 1.9 1996/02/13 22:00:49 christos Exp $ */ /* @@ -183,6 +183,14 @@ struct rtstat { }; /* + * Routing Table Info. + */ +struct rt_tableinfo { + u_short rti_tableid; /* routing table id */ + u_short rti_domainid; /* routing domain id */ +}; + +/* * Structures for routing messages. */ struct rt_msghdr { diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index 6d34e851fe7..ac5cfdad10d 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtsock.c,v 1.98 2010/03/23 15:03:25 claudio Exp $ */ +/* $OpenBSD: rtsock.c,v 1.99 2010/04/21 11:52:46 claudio Exp $ */ /* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */ /* @@ -1237,6 +1237,7 @@ sysctl_rtable(int *name, u_int namelen, void *where, size_t *given, void *new, int i, s, error = EINVAL; u_char af; struct walkarg w; + struct rt_tableinfo tableinfo; u_int tableid = 0; if (new) @@ -1254,7 +1255,7 @@ sysctl_rtable(int *name, u_int namelen, void *where, size_t *given, void *new, if (namelen == 4) { tableid = name[3]; if (!rtable_exists(tableid)) - return (EINVAL); + return (ENOENT); } s = splsoftnet(); @@ -1279,6 +1280,18 @@ sysctl_rtable(int *name, u_int namelen, void *where, size_t *given, void *new, &rtstat, sizeof(rtstat)); splx(s); return (error); + case NET_RT_TABLE: + tableid = w.w_arg; + if (!rtable_exists(tableid)) { + splx(s); + return (ENOENT); + } + tableinfo.rti_tableid = tableid; + tableinfo.rti_domainid = rtable_l2(tableid); + error = sysctl_rdstruct(where, given, new, + &tableinfo, sizeof(tableinfo)); + splx(s); + return (error); } splx(s); if (w.w_tmem) diff --git a/sys/sys/socket.h b/sys/sys/socket.h index 140976111bd..559766890af 100644 --- a/sys/sys/socket.h +++ b/sys/sys/socket.h @@ -1,4 +1,4 @@ -/* $OpenBSD: socket.h,v 1.62 2009/11/27 20:05:50 guenther Exp $ */ +/* $OpenBSD: socket.h,v 1.63 2010/04/21 11:52:46 claudio Exp $ */ /* $NetBSD: socket.h,v 1.14 1996/02/09 18:25:36 christos Exp $ */ /* @@ -306,12 +306,14 @@ struct sockcred { * Fifth: type of info, defined below * Sixth: flag(s) to mask with for NET_RT_FLAGS * Seventh: routing table to use (facultative, defaults to 0) + * NET_RT_TABLE has the table id as sixth element. */ #define NET_RT_DUMP 1 /* dump; may limit to a.f. */ #define NET_RT_FLAGS 2 /* by flags, e.g. RESOLVING */ #define NET_RT_IFLIST 3 /* survey interface list */ #define NET_RT_STATS 4 /* routing table statistics */ -#define NET_RT_MAXID 5 +#define NET_RT_TABLE 5 +#define NET_RT_MAXID 6 #define CTL_NET_RT_NAMES { \ { 0, 0 }, \ @@ -319,6 +321,7 @@ struct sockcred { { "flags", CTLTYPE_STRUCT }, \ { "iflist", CTLTYPE_STRUCT }, \ { "stats", CTLTYPE_STRUCT }, \ + { "table", CTLTYPE_STRUCT }, \ } /* |