diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2006-06-16 16:52:09 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2006-06-16 16:52:09 +0000 |
commit | a2301df6e3c29a4111a860fa0491d261af5e0252 (patch) | |
tree | cdd33a094c633a6763d1bbc79e181c5ffce6878c /sys/net | |
parent | 9812d2fe804b7eef6fe9c72ce9b46280bb295ed0 (diff) |
pass the routing table ID over the routing socket, so we can start to
manipulate alternate tables from userland. new tables are created
implicitely when an RTM_ADD for that table is seen.
ok norby claudio hshoexer
Diffstat (limited to 'sys/net')
-rw-r--r-- | sys/net/route.h | 5 | ||||
-rw-r--r-- | sys/net/rtsock.c | 18 |
2 files changed, 20 insertions, 3 deletions
diff --git a/sys/net/route.h b/sys/net/route.h index ae338488b6f..230b016f51d 100644 --- a/sys/net/route.h +++ b/sys/net/route.h @@ -1,4 +1,4 @@ -/* $OpenBSD: route.h,v 1.44 2006/06/16 16:49:39 henning Exp $ */ +/* $OpenBSD: route.h,v 1.45 2006/06/16 16:52:08 henning Exp $ */ /* $NetBSD: route.h,v 1.9 1996/02/13 22:00:49 christos Exp $ */ /* @@ -82,6 +82,7 @@ struct rt_metrics { }; /* XXX overloading some values that are no longer used. */ #define rmx_refcnt rmx_rttvar /* # held references only used by sysctl */ +#define rmx_rt_tableid rmx_rtt /* routing table ID */ /* * rmx_rtt and rmx_rttvar are stored as microseconds; @@ -182,6 +183,8 @@ struct rt_msghdr { u_long rtm_inits; /* which metrics we are initializing */ struct rt_metrics rtm_rmx; /* metrics themselves */ }; +/* overload no longer used field */ +#define rtm_tableid rtm_rmx.rmx_rt_tableid #define RTM_VERSION 3 /* Up the ante and ignore older versions */ diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index 943fe0e553c..f7822e48064 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtsock.c,v 1.60 2006/06/16 16:49:39 henning Exp $ */ +/* $OpenBSD: rtsock.c,v 1.61 2006/06/16 16:52:08 henning Exp $ */ /* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */ /* @@ -175,7 +175,7 @@ route_output(struct mbuf *m, ...) struct sockaddr_rtlabel sa_rt; const char *label; va_list ap; - u_int tableid = 0; + u_int tableid; va_start(ap, m); so = va_arg(ap, struct socket *); @@ -207,6 +207,19 @@ route_output(struct mbuf *m, ...) } rtm->rtm_pid = curproc->p_pid; + tableid = rtm->rtm_tableid; + if (!rtable_exists(tableid)) { + if (rtm->rtm_type == RTM_ADD) { + if (rtable_add(tableid)) { + error = EINVAL; + goto flush; + } + } else { + error = EINVAL; + goto flush; + } + } + bzero(&info, sizeof(info)); info.rti_addrs = rtm->rtm_addrs; rt_xaddrs((caddr_t)(rtm + 1), len + (caddr_t)rtm, &info); @@ -655,6 +668,7 @@ rt_missmsg(int type, struct rt_addrinfo *rtinfo, int flags, rtm = mtod(m, struct rt_msghdr *); rtm->rtm_flags = RTF_DONE | flags; rtm->rtm_errno = error; + rtm->rtm_tableid = tableid; rtm->rtm_addrs = rtinfo->rti_addrs; if (ifp != NULL) rtm->rtm_index = ifp->if_index; |