diff options
author | 2010-07-03 04:44:50 +0000 | |
---|---|---|
committer | 2010-07-03 04:44:50 +0000 | |
commit | 8bb39f085984c8f31e98e59d88cab46a5aa1548e (patch) | |
tree | 841fb14fb8115333f08970c7eca7ab1ad359933b | |
parent | Regen. (diff) | |
download | wireguard-openbsd-8bb39f085984c8f31e98e59d88cab46a5aa1548e.tar.xz wireguard-openbsd-8bb39f085984c8f31e98e59d88cab46a5aa1548e.zip |
Fix the naming of interfaces and variables for rdomains and rtables
and make it possible to bind sockets (including listening sockets!)
to rtables and not just rdomains. This changes the name of the
system calls, socket option, and ioctl. After building with this
you should remove the files /usr/share/man/cat2/[gs]etrdomain.0.
Since this removes the existing [gs]etrdomain() system calls, the
libc major is bumped.
Written by claudio@, criticized^Wcritiqued by me
52 files changed, 296 insertions, 305 deletions
diff --git a/lib/libc/shlib_version b/lib/libc/shlib_version index edb06f55ccd..ced9f0a5390 100644 --- a/lib/libc/shlib_version +++ b/lib/libc/shlib_version @@ -1,4 +1,4 @@ -major=54 +major=55 minor=0 # note: If changes were made to include/thread_private.h or if system # calls were added/changed then libpthread must also be updated. diff --git a/lib/libc/sys/Makefile.inc b/lib/libc/sys/Makefile.inc index ecfeba72cff..6a6b2b6ef5f 100644 --- a/lib/libc/sys/Makefile.inc +++ b/lib/libc/sys/Makefile.inc @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.inc,v 1.91 2010/07/01 19:15:30 deraadt Exp $ +# $OpenBSD: Makefile.inc,v 1.92 2010/07/03 04:44:51 guenther Exp $ # $NetBSD: Makefile.inc,v 1.35 1995/10/16 23:49:07 jtc Exp $ # @(#)Makefile.inc 8.1 (Berkeley) 6/17/93 @@ -67,7 +67,7 @@ ASM= accept.o access.o acct.o adjfreq.o adjtime.o bind.o chdir.o chflags.o \ utimes.o wait4.o write.o writev.o nnpfspioctl.o __semctl.o \ __syscall.o __sysctl.o __getcwd.o sched_yield.o getthrid.o \ thrsleep.o thrwakeup.o threxit.o thrsigdivert.o \ - setrdomain.o getrdomain.o + setrtable.o getrtable.o GASM= ${ASM:.o=.go} PASM= ${ASM:.o=.po} @@ -219,7 +219,7 @@ MAN+= accept.2 access.2 acct.2 adjfreq.2 adjtime.2 bind.2 brk.2 chdir.2 \ dup.2 execve.2 _exit.2 fcntl.2 fhopen.2 \ flock.2 fork.2 fsync.2 getdirentries.2 \ getfh.2 getfsstat.2 getgid.2 getgroups.2 getitimer.2 getlogin.2 \ - getpeername.2 getpgrp.2 getrdomain.2 \ + getpeername.2 getpgrp.2 getrtable.2 \ getpid.2 getpriority.2 getrlimit.2 getrusage.2 getsid.2 getsockname.2 \ getsockopt.2 gettimeofday.2 getuid.2 intro.2 issetugid.2 ioctl.2 \ kill.2 kqueue.2 ktrace.2 link.2 \ @@ -262,7 +262,7 @@ MLINKS+=getpid.2 getppid.2 MLINKS+=getpriority.2 setpriority.2 MLINKS+=getrlimit.2 setrlimit.2 MLINKS+=getsockopt.2 setsockopt.2 -MLINKS+=getrdomain.2 setrdomain.2 +MLINKS+=getrtable.2 setrtable.2 MLINKS+=gettimeofday.2 settimeofday.2 MLINKS+=getuid.2 geteuid.2 MLINKS+=kqueue.2 kevent.2 kqueue.2 EV_SET.2 diff --git a/lib/libc/sys/getrdomain.2 b/lib/libc/sys/getrtable.2 index d31ad749d77..efda35b89fe 100644 --- a/lib/libc/sys/getrdomain.2 +++ b/lib/libc/sys/getrtable.2 @@ -1,4 +1,4 @@ -.\" $OpenBSD: getrdomain.2,v 1.2 2009/11/27 22:02:55 jmc Exp $ +.\" $OpenBSD: getrtable.2,v 1.1 2010/07/03 04:44:51 guenther Exp $ .\" .\" Copyright (c) 2009 Reyk Floeter <reyk@openbsd.org> .\" @@ -14,25 +14,26 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: November 27 2009 $ -.Dt GETRDOMAIN 2 +.Dd $Mdocdate: July 3 2010 $ +.Dt GETRTABLE 2 .Os .Sh NAME -.Nm getrdomain , -.Nm setrdomain +.Nm getrtable , +.Nm setrtable .Nd "get and set the default routing domain of the current process" .Sh SYNOPSIS .Fd #include <sys/types.h> .Fd #include <sys/socket.h> .Ft int -.Fn getrdomain "void" +.Fn getrtable "void" .Ft int -.Fn setrdomain "int rdomain" +.Fn setrtable "int rtableid" .Sh DESCRIPTION -.Fn getrdomain +.Fn getrtable and -.Fn setrdomain -manipulate the routing domain associated with the current process. +.Fn setrtable +manipulate the routing table and routing domain associated with the current +process. .Pp Only the superuser is allowed to change the process routing domain if it is already set to a non-zero value. @@ -43,8 +44,8 @@ The call succeeds unless: .Bl -tag -width Er .It Bq Er EINVAL The value of the -.Fa rdomain -argument is not a valid routing domain. +.Fa rtableid +argument is not a valid routing table. .It Bq Er EPERM The user is not the superuser and the routing domain of the calling process is already set to a non-zero value. @@ -55,8 +56,8 @@ calling process is already set to a non-zero value. .Xr route 8 .Sh HISTORY The -.Fn getrdomain +.Fn getrtable and -.Fn setrdomain +.Fn setrtable system calls appeared in -.Ox 4.7 . +.Ox 4.8 . diff --git a/sbin/dhclient/dispatch.c b/sbin/dhclient/dispatch.c index 23d0e010386..79bb4664ca5 100644 --- a/sbin/dhclient/dispatch.c +++ b/sbin/dhclient/dispatch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dispatch.c,v 1.47 2010/07/02 22:03:27 deraadt Exp $ */ +/* $OpenBSD: dispatch.c,v 1.48 2010/07/03 04:44:51 guenther Exp $ */ /* * Copyright 2004 Henning Brauer <henning@openbsd.org> @@ -438,7 +438,7 @@ get_rdomain(char *name) bzero(&ifr, sizeof(ifr)); strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); - if (ioctl(s, SIOCGIFRTABLEID, (caddr_t)&ifr) != -1) + if (ioctl(s, SIOCGIFRDOMAIN, (caddr_t)&ifr) != -1) rv = ifr.ifr_rdomainid; close(s); diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index 738cad55f60..6f4c012c272 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ifconfig.c,v 1.238 2010/07/02 22:03:40 deraadt Exp $ */ +/* $OpenBSD: ifconfig.c,v 1.239 2010/07/03 04:44:51 guenther Exp $ */ /* $NetBSD: ifconfig.c,v 1.40 1997/10/01 02:19:43 enami Exp $ */ /* @@ -808,7 +808,7 @@ getinfo(struct ifreq *ifr, int create) mtu = 0; else mtu = ifr->ifr_mtu; - if (ioctl(s, SIOCGIFRTABLEID, (caddr_t)ifr) < 0) + if (ioctl(s, SIOCGIFRDOMAIN, (caddr_t)ifr) < 0) rdomainid = 0; else rdomainid = ifr->ifr_rdomainid; @@ -2671,7 +2671,7 @@ phys_status(int force) printf("\tphysical address inet%s %s --> %s", ver, psrcaddr, pdstaddr); - if (ioctl(s, SIOCGLIFPHYRTABLEID, (caddr_t)&ifr) == 0 && + if (ioctl(s, SIOCGLIFPHYRTABLE, (caddr_t)&ifr) == 0 && (rdomainid != 0 || ifr.ifr_rdomainid != 0)) printf(" rdomain %d", ifr.ifr_rdomainid); printf("\n"); @@ -3129,8 +3129,8 @@ settunnelinst(const char *id, int param) strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); ifr.ifr_rdomainid = rdomainid; - if (ioctl(s, SIOCSLIFPHYRTABLEID, (caddr_t)&ifr) < 0) - warn("SIOCSLIFPHYRTABLEID"); + if (ioctl(s, SIOCSLIFPHYRTABLE, (caddr_t)&ifr) < 0) + warn("SIOCSLIFPHYRTABLE"); } void @@ -4847,7 +4847,7 @@ setinstance(const char *id, int param) strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); ifr.ifr_rdomainid = rdomainid; - if (ioctl(s, SIOCSIFRTABLEID, (caddr_t)&ifr) < 0) - warn("SIOCSIFRTABLEID"); + if (ioctl(s, SIOCSIFRDOMAIN, (caddr_t)&ifr) < 0) + warn("SIOCSIFRDOMAIN"); } #endif diff --git a/sbin/ping/ping.8 b/sbin/ping/ping.8 index de87fb6c532..a34319fd2c5 100644 --- a/sbin/ping/ping.8 +++ b/sbin/ping/ping.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: ping.8,v 1.44 2010/06/26 18:30:03 phessler Exp $ +.\" $OpenBSD: ping.8,v 1.45 2010/07/03 04:44:51 guenther Exp $ .\" $NetBSD: ping.8,v 1.10 1995/12/31 04:55:35 ghudson Exp $ .\" .\" Copyright (c) 1985, 1991, 1993 @@ -30,7 +30,7 @@ .\" .\" @(#)ping.8 8.2 (Berkeley) 12/11/93 .\" -.Dd $Mdocdate: June 26 2010 $ +.Dd $Mdocdate: July 3 2010 $ .Dt PING 8 .Os .Sh NAME @@ -48,7 +48,7 @@ .Op Fl s Ar packetsize .Op Fl T Ar tos .Op Fl t Ar ttl -.Op Fl V Ar rdomain +.Op Fl V Ar rtable .Op Fl w Ar maxwait .Ar host .Ek @@ -184,8 +184,8 @@ when combined with the 8 bytes of ICMP header data. Use the specified type of service. .It Fl t Ar ttl Use the specified time-to-live. -.It Fl V Ar rdomain -Set the routing domain. +.It Fl V Ar rtable +Set the routing table to be used for outgoing packets. The default is 0. .It Fl v Verbose output. diff --git a/sbin/ping/ping.c b/sbin/ping/ping.c index 651bc30cb98..2fac285425a 100644 --- a/sbin/ping/ping.c +++ b/sbin/ping/ping.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ping.c,v 1.87 2010/06/26 18:30:03 phessler Exp $ */ +/* $OpenBSD: ping.c,v 1.88 2010/07/03 04:44:51 guenther Exp $ */ /* $NetBSD: ping.c,v 1.20 1995/08/11 22:37:58 cgd Exp $ */ /* @@ -188,7 +188,7 @@ main(int argc, char *argv[]) fd_set *fdmaskp; size_t fdmasks; uid_t uid; - u_int rdomain; + u_int rtableid; if ((s = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP)) < 0) err(1, "socket"); @@ -306,15 +306,15 @@ main(int argc, char *argv[]) errx(1, "ttl value is %s: %s", errstr, optarg); break; case 'V': - rdomain = (unsigned int)strtonum(optarg, 0, + rtableid = (unsigned int)strtonum(optarg, 0, RT_TABLEID_MAX, &errstr); if (errstr) - errx(1, "rdomain value is %s: %s", + errx(1, "rtable value is %s: %s", errstr, optarg); - if (setsockopt(s, IPPROTO_IP, SO_RDOMAIN, &rdomain, - sizeof(rdomain)) == -1) - err(1, "setsockopt SO_RDOMAIN"); + if (setsockopt(s, IPPROTO_IP, SO_RTABLE, &rtableid, + sizeof(rtableid)) == -1) + err(1, "setsockopt SO_RTABLE"); break; case 'v': options |= F_VERBOSE; @@ -1365,6 +1365,6 @@ usage(void) (void)fprintf(stderr, "usage: ping [-DdEefLnqRrv] [-c count] [-I ifaddr] [-i wait]\n" "\t[-l preload] [-p pattern] [-s packetsize] [-T tos] [-t ttl]\n" - "\t[-V rdomain] [-w maxwait] host\n"); + "\t[-V rtable] [-w maxwait] host\n"); exit(1); } diff --git a/sbin/route/route.c b/sbin/route/route.c index 163a85e157c..3a24b8c77d4 100644 --- a/sbin/route/route.c +++ b/sbin/route/route.c @@ -1,4 +1,4 @@ -/* $OpenBSD: route.c,v 1.145 2010/06/27 07:57:59 guenther Exp $ */ +/* $OpenBSD: route.c,v 1.146 2010/07/03 04:44:51 guenther Exp $ */ /* $NetBSD: route.c,v 1.16 1996/04/15 18:27:05 cgd Exp $ */ /* @@ -1618,8 +1618,8 @@ rdomain(int argc, char **argv) { if (!argc) usage(NULL); - if (setrdomain(tableid) == -1) - err(1, "setrdomain"); + if (setrtable(tableid) == -1) + err(1, "setrtable"); execvp(*argv, argv); warn("%s", argv[0]); return (errno == ENOENT ? 127 : 126); diff --git a/share/man/man4/route.4 b/share/man/man4/route.4 index c88eb57bc49..4498d6c960a 100644 --- a/share/man/man4/route.4 +++ b/share/man/man4/route.4 @@ -1,4 +1,4 @@ -.\" $OpenBSD: route.4,v 1.30 2009/06/05 06:48:32 jmc Exp $ +.\" $OpenBSD: route.4,v 1.31 2010/07/03 04:44:51 guenther Exp $ .\" $NetBSD: route.4,v 1.3 1994/11/30 16:22:31 jtc Exp $ .\" .\" Copyright (c) 1990, 1991, 1993 @@ -30,7 +30,7 @@ .\" .\" @(#)route.4 8.6 (Berkeley) 4/19/94 .\" -.Dd $Mdocdate: June 5 2009 $ +.Dd $Mdocdate: July 3 2010 $ .Dt ROUTE 4 .Os .Sh NAME @@ -186,9 +186,8 @@ by doing a .Xr shutdown 2 system call for further input. .Pp -A process can specify a routing domain by setting the -.Dv SO_RDOMAIN -flag to +A process can specify an alternate routing table by using the +.Dv SO_RTABLE .Xr setsockopt 2 . .Pp A process can specify which route message types it's interested in diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index 4d90750370d..e3d5d4c3ee2 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init_main.c,v 1.168 2010/06/29 20:25:57 guenther Exp $ */ +/* $OpenBSD: init_main.c,v 1.169 2010/07/03 04:44:51 guenther Exp $ */ /* $NetBSD: init_main.c,v 1.84.4.1 1996/06/02 09:08:06 mrg Exp $ */ /* @@ -265,8 +265,8 @@ main(void *framep) process0.ps_refcnt = 1; p->p_p = &process0; - /* Set the default routing domain. */ - process0.ps_rdomain = 0; + /* Set the default routing table/domain. */ + process0.ps_rtableid = 0; LIST_INSERT_HEAD(&allproc, p, p_list); p->p_pgrp = &pgrp0; diff --git a/sys/kern/init_sysent.c b/sys/kern/init_sysent.c index 94adf2c2b6f..3d0d8095f58 100644 --- a/sys/kern/init_sysent.c +++ b/sys/kern/init_sysent.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init_sysent.c,v 1.113 2010/07/01 23:11:11 tedu Exp $ */ +/* $OpenBSD: init_sysent.c,v 1.114 2010/07/03 04:44:51 guenther Exp $ */ /* * System call switch table. @@ -811,9 +811,9 @@ struct sysent sysent[] = { sys_fstatfs }, /* 308 = fstatfs */ { 2, s(struct sys_fhstatfs_args), 0, sys_fhstatfs }, /* 309 = fhstatfs */ - { 1, s(struct sys_setrdomain_args), 0, - sys_setrdomain }, /* 310 = setrdomain */ + { 1, s(struct sys_setrtable_args), 0, + sys_setrtable }, /* 310 = setrtable */ { 0, 0, 0, - sys_getrdomain }, /* 311 = getrdomain */ + sys_getrtable }, /* 311 = getrtable */ }; diff --git a/sys/kern/syscalls.c b/sys/kern/syscalls.c index 1355521ef12..b3128deb54f 100644 --- a/sys/kern/syscalls.c +++ b/sys/kern/syscalls.c @@ -1,4 +1,4 @@ -/* $OpenBSD: syscalls.c,v 1.114 2010/07/01 23:11:11 tedu Exp $ */ +/* $OpenBSD: syscalls.c,v 1.115 2010/07/03 04:44:51 guenther Exp $ */ /* * System call names. @@ -419,6 +419,6 @@ char *syscallnames[] = { "statfs", /* 307 = statfs */ "fstatfs", /* 308 = fstatfs */ "fhstatfs", /* 309 = fhstatfs */ - "setrdomain", /* 310 = setrdomain */ - "getrdomain", /* 311 = getrdomain */ + "setrtable", /* 310 = setrtable */ + "getrtable", /* 311 = getrtable */ }; diff --git a/sys/kern/syscalls.master b/sys/kern/syscalls.master index 279bbc72290..90e52eea635 100644 --- a/sys/kern/syscalls.master +++ b/sys/kern/syscalls.master @@ -1,4 +1,4 @@ -; $OpenBSD: syscalls.master,v 1.101 2010/07/01 23:10:40 tedu Exp $ +; $OpenBSD: syscalls.master,v 1.102 2010/07/03 04:44:51 guenther Exp $ ; $NetBSD: syscalls.master,v 1.32 1996/04/23 10:24:21 mycroft Exp $ ; @(#)syscalls.master 8.2 (Berkeley) 1/13/94 @@ -605,5 +605,5 @@ 308 STD { int sys_fstatfs(int fd, struct statfs *buf); } 309 STD { int sys_fhstatfs(const fhandle_t *fhp, \ struct statfs *buf); } -310 STD { int sys_setrdomain(int rdomain); } -311 STD { int sys_getrdomain(void); } +310 STD { int sys_setrtable(int rtableid); } +311 STD { int sys_getrtable(void); } diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 1f8d93ec1d0..5c2e7448bb0 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_socket.c,v 1.82 2010/07/02 19:57:15 tedu Exp $ */ +/* $OpenBSD: uipc_socket.c,v 1.83 2010/07/03 04:44:51 guenther Exp $ */ /* $NetBSD: uipc_socket.c,v 1.21 1996/02/04 02:17:52 christos Exp $ */ /* @@ -981,7 +981,6 @@ sosetopt(struct socket *so, int level, int optname, struct mbuf *m0) } else { switch (optname) { case SO_BINDANY: - case SO_RDOMAIN: if ((error = suser(curproc, 0)) != 0) /* XXX */ goto bad; break; diff --git a/sys/kern/uipc_syscalls.c b/sys/kern/uipc_syscalls.c index 4a3c9c2166c..533c53595aa 100644 --- a/sys/kern/uipc_syscalls.c +++ b/sys/kern/uipc_syscalls.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_syscalls.c,v 1.75 2010/06/30 19:57:05 deraadt Exp $ */ +/* $OpenBSD: uipc_syscalls.c,v 1.76 2010/07/03 04:44:51 guenther Exp $ */ /* $NetBSD: uipc_syscalls.c,v 1.19 1996/02/09 19:00:48 christos Exp $ */ /* @@ -1096,30 +1096,30 @@ getsock(struct filedesc *fdp, int fdes, struct file **fpp) /* ARGSUSED */ int -sys_setrdomain(struct proc *p, void *v, register_t *retval) +sys_setrtable(struct proc *p, void *v, register_t *retval) { - struct sys_setrdomain_args /* { - syscallarg(int) rdomain; + struct sys_setrtable_args /* { + syscallarg(int) rtableid; } */ *uap = v; - int rdomain, error; + int rtableid, error; - rdomain = SCARG(uap, rdomain); + rtableid = SCARG(uap, rtableid); - if (p->p_p->ps_rdomain == (u_int)rdomain) + if (p->p_p->ps_rtableid == (u_int)rtableid) return (0); - if (p->p_p->ps_rdomain != 0 && (error = suser(p, 0)) != 0) + if (p->p_p->ps_rtableid != 0 && (error = suser(p, 0)) != 0) return (error); - if (rdomain < 0 || !rtable_exists((u_int)rdomain)) + if (rtableid < 0 || !rtable_exists((u_int)rtableid)) return (EINVAL); - p->p_p->ps_rdomain = (u_int)rdomain; + p->p_p->ps_rtableid = (u_int)rtableid; return (0); } /* ARGSUSED */ int -sys_getrdomain(struct proc *p, void *v, register_t *retval) +sys_getrtable(struct proc *p, void *v, register_t *retval) { - *retval = (int)p->p_p->ps_rdomain; + *retval = (int)p->p_p->ps_rtableid; return (0); } diff --git a/sys/net/if.c b/sys/net/if.c index 94f55218045..8e0d467b8ce 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.217 2010/06/29 21:28:37 reyk Exp $ */ +/* $OpenBSD: if.c,v 1.218 2010/07/03 04:44:51 guenther Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -1409,7 +1409,7 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, struct proc *p) case SIOCSIFPHYADDR_IN6: #endif case SIOCSLIFPHYADDR: - case SIOCSLIFPHYRTABLEID: + case SIOCSLIFPHYRTABLE: case SIOCADDMULTI: case SIOCDELMULTI: case SIOCSIFMEDIA: @@ -1419,7 +1419,7 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, struct proc *p) case SIOCGIFPSRCADDR: case SIOCGIFPDSTADDR: case SIOCGLIFPHYADDR: - case SIOCGLIFPHYRTABLEID: + case SIOCGLIFPHYRTABLE: case SIOCGIFMEDIA: if (ifp->if_ioctl == 0) return (EOPNOTSUPP); @@ -1476,11 +1476,11 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, struct proc *p) ifp->if_priority = ifr->ifr_metric; break; - case SIOCGIFRTABLEID: + case SIOCGIFRDOMAIN: ifr->ifr_rdomainid = ifp->if_rdomain; break; - case SIOCSIFRTABLEID: + case SIOCSIFRDOMAIN: if ((error = suser(p, 0)) != 0) return (error); if (ifr->ifr_rdomainid < 0 || diff --git a/sys/net/if_enc.c b/sys/net/if_enc.c index 8ea76cfe231..ee51f84d38a 100644 --- a/sys/net/if_enc.c +++ b/sys/net/if_enc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_enc.c,v 1.51 2010/07/01 02:09:45 reyk Exp $ */ +/* $OpenBSD: if_enc.c,v 1.52 2010/07/03 04:44:51 guenther Exp $ */ /* * Copyright (c) 2010 Reyk Floeter <reyk@vantronix.net> @@ -184,7 +184,7 @@ enc_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) else ifp->if_flags &= ~IFF_RUNNING; break; - case SIOCSIFRTABLEID: + case SIOCSIFRDOMAIN: if ((error = enc_setif(ifp, ifr->ifr_rdomainid)) != 0) return (error); /* FALLTHROUGH */ diff --git a/sys/net/if_gif.c b/sys/net/if_gif.c index cb9ccba73e0..3aab9f40093 100644 --- a/sys/net/if_gif.c +++ b/sys/net/if_gif.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_gif.c,v 1.54 2010/05/11 09:36:07 claudio Exp $ */ +/* $OpenBSD: if_gif.c,v 1.55 2010/07/03 04:44:51 guenther Exp $ */ /* $KAME: if_gif.c,v 1.43 2001/02/20 08:51:07 itojun Exp $ */ /* @@ -649,7 +649,7 @@ gif_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) ifp->if_mtu = ifr->ifr_mtu; break; - case SIOCSLIFPHYRTABLEID: + case SIOCSLIFPHYRTABLE: if (ifr->ifr_rdomainid < 0 || ifr->ifr_rdomainid > RT_TABLEID_MAX || !rtable_exists(ifr->ifr_rdomainid)) { @@ -658,7 +658,7 @@ gif_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) } sc->gif_rtableid = ifr->ifr_rdomainid; break; - case SIOCGLIFPHYRTABLEID: + case SIOCGLIFPHYRTABLE: ifr->ifr_rdomainid = sc->gif_rtableid; break; default: diff --git a/sys/net/if_gre.c b/sys/net/if_gre.c index 6ebf41232db..aa0c8319113 100644 --- a/sys/net/if_gre.c +++ b/sys/net/if_gre.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_gre.c,v 1.50 2010/06/26 22:11:51 claudio Exp $ */ +/* $OpenBSD: if_gre.c,v 1.51 2010/07/03 04:44:51 guenther Exp $ */ /* $NetBSD: if_gre.c,v 1.9 1999/10/25 19:18:11 drochner Exp $ */ /* @@ -637,7 +637,7 @@ recompute: si.sin_addr.s_addr = sc->g_dst.s_addr; memcpy(&lifr->dstaddr, &si, sizeof(si)); break; - case SIOCSLIFPHYRTABLEID: + case SIOCSLIFPHYRTABLE: if ((error = suser(prc, 0)) != 0) break; if (ifr->ifr_rdomainid < 0 || @@ -648,7 +648,7 @@ recompute: } sc->g_rtableid = ifr->ifr_rdomainid; goto recompute; - case SIOCGLIFPHYRTABLEID: + case SIOCGLIFPHYRTABLE: ifr->ifr_rdomainid = sc->g_rtableid; break; default: diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index b57ae431fad..026b74b1502 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in_pcb.c,v 1.112 2010/05/07 13:33:16 claudio Exp $ */ +/* $OpenBSD: in_pcb.c,v 1.113 2010/07/03 04:44:51 guenther Exp $ */ /* $NetBSD: in_pcb.c,v 1.25 1996/02/13 23:41:53 christos Exp $ */ /* @@ -197,13 +197,13 @@ in_pcballoc(so, v) inp->inp_seclevel[SL_ESP_TRANS] = ipsec_esp_trans_default_level; inp->inp_seclevel[SL_ESP_NETWORK] = ipsec_esp_network_default_level; inp->inp_seclevel[SL_IPCOMP] = ipsec_ipcomp_default_level; - inp->inp_rdomain = curproc->p_p->ps_rdomain; + inp->inp_rtableid = curproc->p_p->ps_rtableid; s = splnet(); CIRCLEQ_INSERT_HEAD(&table->inpt_queue, inp, inp_queue); LIST_INSERT_HEAD(INPCBLHASH(table, inp->inp_lport, - inp->inp_rdomain), inp, inp_lhash); + inp->inp_rtableid), inp, inp_lhash); LIST_INSERT_HEAD(INPCBHASH(table, &inp->inp_faddr, inp->inp_fport, - &inp->inp_laddr, inp->inp_lport, inp->inp_rdomain), + &inp->inp_laddr, inp->inp_lport, rtable_l2(inp->inp_rtableid)), inp, inp_hash); splx(s); so->so_pcb = inp; @@ -277,7 +277,7 @@ in_pcbbind(v, nam, p) sin->sin_port = 0; /* yech... */ if (!(so->so_options & SO_BINDANY) && in_iawithaddr(sin->sin_addr, NULL, - inp->inp_rdomain) == 0) + inp->inp_rtableid) == 0) return (EADDRNOTAVAIL); } if (lport) { @@ -290,12 +290,12 @@ in_pcbbind(v, nam, p) if (so->so_euid) { t = in_pcblookup(table, &zeroin_addr, 0, &sin->sin_addr, lport, INPLOOKUP_WILDCARD, - inp->inp_rdomain); + inp->inp_rtableid); if (t && (so->so_euid != t->inp_socket->so_euid)) return (EADDRINUSE); } t = in_pcblookup(table, &zeroin_addr, 0, - &sin->sin_addr, lport, wild, inp->inp_rdomain); + &sin->sin_addr, lport, wild, inp->inp_rtableid); if (t && (reuseport & t->inp_socket->so_options) == 0) return (EADDRINUSE); } @@ -343,7 +343,7 @@ in_pcbbind(v, nam, p) lport = htons(*lastport); } while (in_baddynamic(*lastport, so->so_proto->pr_protocol) || in_pcblookup(table, &zeroin_addr, 0, - &inp->inp_laddr, lport, wild, inp->inp_rdomain)); + &inp->inp_laddr, lport, wild, inp->inp_rtableid)); } else { /* * counting up @@ -361,7 +361,7 @@ in_pcbbind(v, nam, p) lport = htons(*lastport); } while (in_baddynamic(*lastport, so->so_proto->pr_protocol) || in_pcblookup(table, &zeroin_addr, 0, - &inp->inp_laddr, lport, wild, inp->inp_rdomain)); + &inp->inp_laddr, lport, wild, inp->inp_rtableid)); } } inp->inp_lport = lport; @@ -415,7 +415,7 @@ in_pcbconnect(v, nam) int error; ifaddr = in_selectsrc(sin, &inp->inp_route, inp->inp_socket->so_options, inp->inp_moptions, &error, - inp->inp_rdomain); + inp->inp_rtableid); if (ifaddr == NULL) { if (error == 0) error = EADDRNOTAVAIL; @@ -424,7 +424,7 @@ in_pcbconnect(v, nam) } if (in_pcbhashlookup(inp->inp_table, sin->sin_addr, sin->sin_port, inp->inp_laddr.s_addr ? inp->inp_laddr : ifaddr->sin_addr, - inp->inp_lport, inp->inp_rdomain) != 0) + inp->inp_lport, inp->inp_rtableid) != 0) return (EADDRINUSE); if (inp->inp_laddr.s_addr == INADDR_ANY) { if (inp->inp_lport == 0 && @@ -570,12 +570,8 @@ in_setpeeraddr(inp, nam) * Must be called at splsoftnet. */ void -in_pcbnotifyall(table, dst, rdomain, errno, notify) - struct inpcbtable *table; - struct sockaddr *dst; - u_int rdomain; - int errno; - void (*notify)(struct inpcb *, int); +in_pcbnotifyall(struct inpcbtable *table, struct sockaddr *dst, u_int rdomain, + int errno, void (*notify)(struct inpcb *, int)) { struct inpcb *inp, *oinp; struct in_addr faddr; @@ -596,6 +592,7 @@ in_pcbnotifyall(table, dst, rdomain, errno, notify) if (faddr.s_addr == INADDR_ANY) return; + rdomain = rtable_l2(rdomain); for (inp = CIRCLEQ_FIRST(&table->inpt_queue); inp != CIRCLEQ_END(&table->inpt_queue);) { #ifdef INET6 @@ -605,7 +602,7 @@ in_pcbnotifyall(table, dst, rdomain, errno, notify) } #endif if (inp->inp_faddr.s_addr != faddr.s_addr || - inp->inp_rdomain != rdomain || + rtable_l2(inp->inp_rtableid) != rdomain || inp->inp_socket == 0) { inp = CIRCLEQ_NEXT(inp, inp_queue); continue; @@ -638,10 +635,10 @@ in_losing(inp) info.rti_info[RTAX_GATEWAY] = rt->rt_gateway; info.rti_info[RTAX_NETMASK] = rt_mask(rt); rt_missmsg(RTM_LOSING, &info, rt->rt_flags, rt->rt_ifp, 0, - inp->inp_rdomain); + inp->inp_rtableid); if (rt->rt_flags & RTF_DYNAMIC) (void)rtrequest1(RTM_DELETE, &info, rt->rt_priority, - (struct rtentry **)0, inp->inp_rdomain); + (struct rtentry **)0, inp->inp_rtableid); /* * A new route can be allocated * the next time output is attempted. @@ -672,7 +669,8 @@ in_rtchange(inp, errno) } struct inpcb * -in_pcblookup(struct inpcbtable *table, void *faddrp, u_int fport_arg, void *laddrp, u_int lport_arg, int flags, u_int rdomain) +in_pcblookup(struct inpcbtable *table, void *faddrp, u_int fport_arg, + void *laddrp, u_int lport_arg, int flags, u_int rdomain) { struct inpcb *inp, *match = 0; int matchwild = 3, wildcard; @@ -680,10 +678,10 @@ in_pcblookup(struct inpcbtable *table, void *faddrp, u_int fport_arg, void *ladd struct in_addr faddr = *(struct in_addr *)faddrp; struct in_addr laddr = *(struct in_addr *)laddrp; - rdomain = rtable_l2(rdomain); + rdomain = rtable_l2(rdomain); /* convert passed rtableid to rdomain */ for (inp = LIST_FIRST(INPCBLHASH(table, lport, rdomain)); inp; inp = LIST_NEXT(inp, inp_lhash)) { - if (inp->inp_rdomain != rdomain) + if (rtable_l2(inp->inp_rtableid) != rdomain) continue; if (inp->inp_lport != lport) continue; @@ -789,7 +787,7 @@ in_pcbrtentry(inp) break; ro->ro_dst.sa_family = AF_INET; ro->ro_dst.sa_len = sizeof(ro->ro_dst); - ro->ro_tableid = inp->inp_rdomain; + ro->ro_tableid = inp->inp_rtableid; satosin(&ro->ro_dst)->sin_addr = inp->inp_faddr; rtalloc_mpath(ro, &inp->inp_laddr.s_addr); break; @@ -800,7 +798,7 @@ in_pcbrtentry(inp) struct sockaddr_in * in_selectsrc(struct sockaddr_in *sin, struct route *ro, int soopts, - struct ip_moptions *mopts, int *errorp, u_int rdomain) + struct ip_moptions *mopts, int *errorp, u_int rtableid) { struct sockaddr_in *sin2; struct in_ifaddr *ia; @@ -824,7 +822,7 @@ in_selectsrc(struct sockaddr_in *sin, struct route *ro, int soopts, ro->ro_dst.sa_family = AF_INET; ro->ro_dst.sa_len = sizeof(struct sockaddr_in); satosin(&ro->ro_dst)->sin_addr = sin->sin_addr; - ro->ro_tableid = rdomain; + ro->ro_tableid = rtableid; rtalloc_mpath(ro, NULL); /* @@ -846,9 +844,9 @@ in_selectsrc(struct sockaddr_in *sin, struct route *ro, int soopts, u_int16_t fport = sin->sin_port; sin->sin_port = 0; - ia = ifatoia(ifa_ifwithdstaddr(sintosa(sin), rdomain)); + ia = ifatoia(ifa_ifwithdstaddr(sintosa(sin), rtableid)); if (ia == 0) - ia = ifatoia(ifa_ifwithnet(sintosa(sin), rdomain)); + ia = ifatoia(ifa_ifwithnet(sintosa(sin), rtableid)); sin->sin_port = fport; if (ia == 0) ia = TAILQ_FIRST(&in_ifaddr); @@ -890,7 +888,7 @@ in_pcbrehash(inp) s = splnet(); LIST_REMOVE(inp, inp_lhash); - LIST_INSERT_HEAD(INPCBLHASH(table, inp->inp_lport, inp->inp_rdomain), + LIST_INSERT_HEAD(INPCBLHASH(table, inp->inp_lport, inp->inp_rtableid), inp, inp_lhash); LIST_REMOVE(inp, inp_hash); #ifdef INET6 @@ -902,7 +900,7 @@ in_pcbrehash(inp) #endif /* INET6 */ LIST_INSERT_HEAD(INPCBHASH(table, &inp->inp_faddr, inp->inp_fport, &inp->inp_laddr, inp->inp_lport, - inp->inp_rdomain), inp, inp_hash); + rtable_l2(inp->inp_rtableid)), inp, inp_hash); #ifdef INET6 } #endif /* INET6 */ @@ -930,7 +928,7 @@ in_pcbhashlookup(struct inpcbtable *table, struct in_addr faddr, struct inpcb *inp; u_int16_t fport = fport_arg, lport = lport_arg; - rdomain = rtable_l2(rdomain); + rdomain = rtable_l2(rdomain); /* convert passed rtableid to rdomain */ head = INPCBHASH(table, &faddr, fport, &laddr, lport, rdomain); LIST_FOREACH(inp, head, inp_hash) { #ifdef INET6 @@ -941,7 +939,7 @@ in_pcbhashlookup(struct inpcbtable *table, struct in_addr faddr, inp->inp_fport == fport && inp->inp_lport == lport && inp->inp_laddr.s_addr == laddr.s_addr && - inp->inp_rdomain == rdomain) { + rtable_l2(inp->inp_rtableid) == rdomain) { /* * Move this PCB to the head of hash chain so that * repeated accesses are quicker. This is analogous to @@ -1019,7 +1017,7 @@ in_pcblookup_listen(struct inpcbtable *table, struct in_addr laddr, struct inpcb *inp; u_int16_t lport = lport_arg; - rdomain = rtable_l2(rdomain); + rdomain = rtable_l2(rdomain); /* convert passed rtableid to rdomain */ #if NPF > 0 if (m && m->m_pkthdr.pf.flags & PF_TAG_DIVERTED) { struct pf_divert *divert; @@ -1047,7 +1045,7 @@ in_pcblookup_listen(struct inpcbtable *table, struct in_addr laddr, if (inp->inp_lport == lport && inp->inp_fport == 0 && inp->inp_laddr.s_addr == key1->s_addr && inp->inp_faddr.s_addr == INADDR_ANY && - inp->inp_rdomain == rdomain) + rtable_l2(inp->inp_rtableid) == rdomain) break; } if (inp == NULL && key1->s_addr != key2->s_addr) { @@ -1060,7 +1058,7 @@ in_pcblookup_listen(struct inpcbtable *table, struct in_addr laddr, if (inp->inp_lport == lport && inp->inp_fport == 0 && inp->inp_laddr.s_addr == key2->s_addr && inp->inp_faddr.s_addr == INADDR_ANY && - inp->inp_rdomain == rdomain) + rtable_l2(inp->inp_rtableid) == rdomain) break; } } diff --git a/sys/netinet/in_pcb.h b/sys/netinet/in_pcb.h index da1df0acdcc..ac17a6d6a81 100644 --- a/sys/netinet/in_pcb.h +++ b/sys/netinet/in_pcb.h @@ -1,4 +1,4 @@ -/* $OpenBSD: in_pcb.h,v 1.68 2009/11/13 20:54:05 claudio Exp $ */ +/* $OpenBSD: in_pcb.h,v 1.69 2010/07/03 04:44:51 guenther Exp $ */ /* $NetBSD: in_pcb.h,v 1.14 1996/02/13 23:42:00 christos Exp $ */ /* @@ -146,7 +146,7 @@ struct inpcb { #endif struct icmp6_filter *inp_icmp6filt; void *inp_pf_sk; - u_int inp_rdomain; + u_int inp_rtableid; }; struct inpcbtable { diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c index 805a99e339e..44de7acc5ff 100644 --- a/sys/netinet/ip_divert.c +++ b/sys/netinet/ip_divert.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_divert.c,v 1.6 2010/04/20 22:05:43 tedu Exp $ */ +/* $OpenBSD: ip_divert.c,v 1.7 2010/07/03 04:44:51 guenther Exp $ */ /* * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> @@ -94,7 +94,7 @@ divert_output(struct mbuf *m, ...) m->m_pkthdr.rcvif = NULL; m->m_nextpkt = NULL; - m->m_pkthdr.rdomain = inp->inp_rdomain; + m->m_pkthdr.rdomain = inp->inp_rtableid; if (control) m_freem(control); diff --git a/sys/netinet/ip_icmp.c b/sys/netinet/ip_icmp.c index f22005e5fc6..d3512f133a9 100644 --- a/sys/netinet/ip_icmp.c +++ b/sys/netinet/ip_icmp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_icmp.c,v 1.89 2010/05/07 13:33:16 claudio Exp $ */ +/* $OpenBSD: ip_icmp.c,v 1.90 2010/07/03 04:44:51 guenther Exp $ */ /* $NetBSD: ip_icmp.c,v 1.19 1996/02/13 23:42:22 christos Exp $ */ /* @@ -999,6 +999,7 @@ icmp_mtudisc_timeout(struct rtentry *rt, struct rttimer *r) info.rti_flags = rt->rt_flags; sa = *(struct sockaddr_in *)rt_key(rt); + /* XXX this needs the rtableid */ rtrequest1(RTM_DELETE, &info, rt->rt_priority, NULL, 0); /* Notify TCP layer of increased Path MTU estimate */ diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index fc8ebc17d1d..8dca59f9b4d 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_output.c,v 1.208 2010/07/02 02:40:16 blambert Exp $ */ +/* $OpenBSD: ip_output.c,v 1.209 2010/07/03 04:44:51 guenther Exp $ */ /* $NetBSD: ip_output.c,v 1.28 1996/02/13 23:43:07 christos Exp $ */ /* @@ -1162,7 +1162,7 @@ ip_ctloutput(op, so, level, optname, mp) case IP_ADD_MEMBERSHIP: case IP_DROP_MEMBERSHIP: error = ip_setmoptions(optname, &inp->inp_moptions, m, - inp->inp_rdomain); + inp->inp_rtableid); break; case IP_PORTRANGE: @@ -1426,24 +1426,23 @@ ip_ctloutput(op, so, level, optname, mp) } #endif break; - case SO_RDOMAIN: + case SO_RTABLE: if (m == NULL || m->m_len < sizeof(u_int)) { error = EINVAL; break; } rtid = *mtod(m, u_int *); - if (p->p_p->ps_rdomain != 0 && - p->p_p->ps_rdomain != rtid && - (error = suser(p, 0)) != 0) { + /* needs priviledges to switch when already set */ + if (p->p_p->ps_rtableid != 0 && suser(p, 0) != 0) { error = EACCES; break; } - /* table must exist and be a domain */ - if (!rtable_exists(rtid) || rtid != rtable_l2(rtid)) { + /* table must exist */ + if (!rtable_exists(rtid)) { error = EINVAL; break; } - inp->inp_rdomain = rtid; + inp->inp_rtableid = rtid; break; default: error = ENOPROTOOPT; @@ -1638,10 +1637,10 @@ ip_ctloutput(op, so, level, optname, mp) } #endif break; - case SO_RDOMAIN: + case SO_RTABLE: *mp = m = m_get(M_WAIT, MT_SOOPTS); m->m_len = sizeof(u_int); - *mtod(m, u_int *) = inp->inp_rdomain; + *mtod(m, u_int *) = inp->inp_rtableid; break; default: error = ENOPROTOOPT; @@ -1765,7 +1764,7 @@ bad: */ int ip_setmoptions(int optname, struct ip_moptions **imop, struct mbuf *m, - u_int rdomain) + u_int rtableid) { int error = 0; u_char loop; @@ -1822,7 +1821,7 @@ ip_setmoptions(int optname, struct ip_moptions **imop, struct mbuf *m, * IP address. Find the interface and confirm that * it supports multicasting. */ - INADDR_TO_IFP(addr, ifp, rdomain); + INADDR_TO_IFP(addr, ifp, rtableid); if (ifp == NULL || (ifp->if_flags & IFF_MULTICAST) == 0) { error = EADDRNOTAVAIL; break; @@ -1881,7 +1880,7 @@ ip_setmoptions(int optname, struct ip_moptions **imop, struct mbuf *m, if (!(ro.ro_rt && ro.ro_rt->rt_ifp && (ro.ro_rt->rt_flags & RTF_UP))) ro.ro_rt = rtalloc1(&ro.ro_dst, RT_REPORT, - rdomain); + rtableid); if (ro.ro_rt == NULL) { error = EADDRNOTAVAIL; break; @@ -1889,7 +1888,7 @@ ip_setmoptions(int optname, struct ip_moptions **imop, struct mbuf *m, ifp = ro.ro_rt->rt_ifp; rtfree(ro.ro_rt); } else { - INADDR_TO_IFP(mreq->imr_interface, ifp, rdomain); + INADDR_TO_IFP(mreq->imr_interface, ifp, rtableid); } /* * See if we found an interface, and confirm that it @@ -1975,7 +1974,7 @@ ip_setmoptions(int optname, struct ip_moptions **imop, struct mbuf *m, if (mreq->imr_interface.s_addr == INADDR_ANY) ifp = NULL; else { - INADDR_TO_IFP(mreq->imr_interface, ifp, rdomain); + INADDR_TO_IFP(mreq->imr_interface, ifp, rtableid); if (ifp == NULL) { error = EADDRNOTAVAIL; break; diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c index 75af8738b6d..f9f78226aba 100644 --- a/sys/netinet/raw_ip.c +++ b/sys/netinet/raw_ip.c @@ -1,4 +1,4 @@ -/* $OpenBSD: raw_ip.c,v 1.48 2009/11/03 10:59:04 claudio Exp $ */ +/* $OpenBSD: raw_ip.c,v 1.49 2010/07/03 04:44:51 guenther Exp $ */ /* $NetBSD: raw_ip.c,v 1.25 1996/02/18 18:58:33 christos Exp $ */ /* @@ -132,7 +132,8 @@ rip_input(struct mbuf *m, ...) if (inp->inp_flags & INP_IPV6) continue; #endif - if (inp->inp_rdomain != rtable_l2(m->m_pkthdr.rdomain)) + if (rtable_l2(inp->inp_rtableid) != + rtable_l2(m->m_pkthdr.rdomain)) continue; if (inp->inp_ip.ip_p && inp->inp_ip.ip_p != ip->ip_p) @@ -272,7 +273,7 @@ rip_output(struct mbuf *m, ...) */ #endif /* force routing domain */ - m->m_pkthdr.rdomain = inp->inp_rdomain; + m->m_pkthdr.rdomain = inp->inp_rtableid; return (ip_output(m, inp->inp_options, &inp->inp_route, flags, inp->inp_moptions, inp)); @@ -418,7 +419,7 @@ rip_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam, (addr->sin_family != AF_IMPLINK)) || (addr->sin_addr.s_addr && (!(so->so_options & SO_BINDANY) && - in_iawithaddr(addr->sin_addr, NULL, inp->inp_rdomain) == + in_iawithaddr(addr->sin_addr, NULL, inp->inp_rtableid) == 0))) { error = EADDRNOTAVAIL; break; diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index 13c1ca14942..a9716a68433 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_input.c,v 1.232 2010/03/11 00:24:58 sthen Exp $ */ +/* $OpenBSD: tcp_input.c,v 1.233 2010/07/03 04:44:51 guenther Exp $ */ /* $NetBSD: tcp_input.c,v 1.23 1996/02/13 23:43:44 christos Exp $ */ /* @@ -723,7 +723,7 @@ findpcb: if ((tiflags & (TH_RST|TH_ACK|TH_SYN)) != TH_SYN) { if (tiflags & TH_RST) { syn_cache_reset(&src.sa, &dst.sa, th, - inp->inp_rdomain); + inp->inp_rtableid); } else if ((tiflags & (TH_ACK|TH_SYN)) == (TH_ACK|TH_SYN)) { /* @@ -3038,7 +3038,7 @@ tcp_mss(struct tcpcb *tp, int offer) else if (tp->pf == AF_INET) { if (ip_mtudisc) mss = ifp->if_mtu - iphlen - sizeof(struct tcphdr); - else if (inp && in_localaddr(inp->inp_faddr, inp->inp_rdomain)) + else if (inp && in_localaddr(inp->inp_faddr, inp->inp_rtableid)) mss = ifp->if_mtu - iphlen - sizeof(struct tcphdr); } #ifdef INET6 @@ -3564,7 +3564,7 @@ syn_cache_cleanup(struct tcpcb *tp) */ struct syn_cache * syn_cache_lookup(struct sockaddr *src, struct sockaddr *dst, - struct syn_cache_head **headp, u_int rdomain) + struct syn_cache_head **headp, u_int rtableid) { struct syn_cache *sc; struct syn_cache_head *scp; @@ -3582,7 +3582,7 @@ syn_cache_lookup(struct sockaddr *src, struct sockaddr *dst, continue; if (!bcmp(&sc->sc_src, src, src->sa_len) && !bcmp(&sc->sc_dst, dst, dst->sa_len) && - rtable_l2(rdomain) == rtable_l2(sc->sc_rdomain)) { + rtable_l2(rtableid) == rtable_l2(sc->sc_rtableid)) { splx(s); return (sc); } @@ -3628,7 +3628,7 @@ syn_cache_get(struct sockaddr *src, struct sockaddr *dst, struct tcphdr *th, s = splsoftnet(); if ((sc = syn_cache_lookup(src, dst, &scp, - sotoinpcb(so)->inp_rdomain)) == NULL) { + sotoinpcb(so)->inp_rtableid)) == NULL) { splx(s); return (NULL); } @@ -3708,8 +3708,8 @@ syn_cache_get(struct sockaddr *src, struct sockaddr *dst, struct tcphdr *th, inp = (struct inpcb *)so->so_pcb; #endif /* INET6 */ - /* inherit rdomain from listening socket */ - inp->inp_rdomain = sc->sc_rdomain; + /* inherit rtable from listening socket */ + inp->inp_rtableid = sc->sc_rtableid; inp->inp_lport = th->th_dport; switch (src->sa_family) { @@ -3867,13 +3867,13 @@ abort: void syn_cache_reset(struct sockaddr *src, struct sockaddr *dst, struct tcphdr *th, - u_int rdomain) + u_int rtableid) { struct syn_cache *sc; struct syn_cache_head *scp; int s = splsoftnet(); - if ((sc = syn_cache_lookup(src, dst, &scp, rdomain)) == NULL) { + if ((sc = syn_cache_lookup(src, dst, &scp, rtableid)) == NULL) { splx(s); return; } @@ -3890,14 +3890,14 @@ syn_cache_reset(struct sockaddr *src, struct sockaddr *dst, struct tcphdr *th, void syn_cache_unreach(struct sockaddr *src, struct sockaddr *dst, struct tcphdr *th, - u_int rdomain) + u_int rtableid) { struct syn_cache *sc; struct syn_cache_head *scp; int s; s = splsoftnet(); - if ((sc = syn_cache_lookup(src, dst, &scp, rdomain)) == NULL) { + if ((sc = syn_cache_lookup(src, dst, &scp, rtableid)) == NULL) { splx(s); return; } @@ -4005,7 +4005,7 @@ syn_cache_add(struct sockaddr *src, struct sockaddr *dst, struct tcphdr *th, * If we do, resend the SYN,ACK. We do not count this * as a retransmission (XXX though maybe we should). */ - if ((sc = syn_cache_lookup(src, dst, &scp, sotoinpcb(so)->inp_rdomain)) + if ((sc = syn_cache_lookup(src, dst, &scp, sotoinpcb(so)->inp_rtableid)) != NULL) { tcpstat.tcps_sc_dupesyn++; if (ipopts) { @@ -4038,7 +4038,7 @@ syn_cache_add(struct sockaddr *src, struct sockaddr *dst, struct tcphdr *th, */ bcopy(src, &sc->sc_src, src->sa_len); bcopy(dst, &sc->sc_dst, dst->sa_len); - sc->sc_rdomain = sotoinpcb(so)->inp_rdomain; + sc->sc_rtableid = sotoinpcb(so)->inp_rtableid; sc->sc_flags = 0; sc->sc_ipopts = ipopts; sc->sc_irs = th->th_seq; @@ -4166,7 +4166,7 @@ syn_cache_respond(struct syn_cache *sc, struct mbuf *m) m->m_data += max_linkhdr; m->m_len = m->m_pkthdr.len = tlen; m->m_pkthdr.rcvif = NULL; - m->m_pkthdr.rdomain = sc->sc_rdomain; + m->m_pkthdr.rdomain = sc->sc_rtableid; memset(mtod(m, u_char *), 0, tlen); switch (sc->sc_src.sa.sa_family) { diff --git a/sys/netinet/tcp_output.c b/sys/netinet/tcp_output.c index 036c54176cd..cb9964e9e32 100644 --- a/sys/netinet/tcp_output.c +++ b/sys/netinet/tcp_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_output.c,v 1.88 2010/05/28 08:32:41 kettenis Exp $ */ +/* $OpenBSD: tcp_output.c,v 1.89 2010/07/03 04:44:51 guenther Exp $ */ /* $NetBSD: tcp_output.c,v 1.16 1997/06/03 16:17:09 kml Exp $ */ /* @@ -1061,7 +1061,7 @@ send: #endif /* force routing domain */ - m->m_pkthdr.rdomain = tp->t_inpcb->inp_rdomain; + m->m_pkthdr.rdomain = tp->t_inpcb->inp_rtableid; switch (tp->pf) { case 0: /*default to PF_INET*/ diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c index 5cd48cce9c8..3d04fac05ef 100644 --- a/sys/netinet/tcp_subr.c +++ b/sys/netinet/tcp_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_subr.c,v 1.110 2010/01/15 18:20:23 chl Exp $ */ +/* $OpenBSD: tcp_subr.c,v 1.111 2010/07/03 04:44:51 guenther Exp $ */ /* $NetBSD: tcp_subr.c,v 1.22 1996/02/13 23:44:00 christos Exp $ */ /* @@ -318,13 +318,8 @@ tcp_template(tp) /* This function looks hairy, because it was so IPv4-dependent. */ #endif /* INET6 */ void -tcp_respond(tp, template, th0, ack, seq, flags, rdomain) - struct tcpcb *tp; - caddr_t template; - struct tcphdr *th0; - tcp_seq ack, seq; - int flags; - u_int rdomain; +tcp_respond(struct tcpcb *tp, caddr_t template, struct tcphdr *th0, + tcp_seq ack, tcp_seq seq, int flags, u_int rtableid) { int tlen; int win = 0; @@ -412,9 +407,9 @@ tcp_respond(tp, template, th0, ack, seq, flags, rdomain) /* force routing domain */ if (tp) - m->m_pkthdr.rdomain = tp->t_inpcb->inp_rdomain; + m->m_pkthdr.rdomain = tp->t_inpcb->inp_rtableid; else - m->m_pkthdr.rdomain = rdomain; + m->m_pkthdr.rdomain = rtableid; switch (af) { #ifdef INET6 @@ -774,11 +769,7 @@ tcp6_ctlinput(cmd, sa, d) #endif void * -tcp_ctlinput(cmd, sa, rdomain, v) - int cmd; - struct sockaddr *sa; - u_int rdomain; - void *v; +tcp_ctlinput(int cmd, struct sockaddr *sa, u_int rdomain, void *v) { struct ip *ip = v; struct tcphdr *th; @@ -839,7 +830,7 @@ tcp_ctlinput(cmd, sa, rdomain, v) * route (traditional PMTUD). */ tp->t_flags &= ~TF_PMTUD_PEND; - icmp_mtudisc(icp, inp->inp_rdomain); + icmp_mtudisc(icp, inp->inp_rtableid); } else { /* * Record the information got in the ICMP diff --git a/sys/netinet/tcp_timer.c b/sys/netinet/tcp_timer.c index 8253775bfa3..a1dd72aae79 100644 --- a/sys/netinet/tcp_timer.c +++ b/sys/netinet/tcp_timer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_timer.c,v 1.44 2009/11/13 20:54:05 claudio Exp $ */ +/* $OpenBSD: tcp_timer.c,v 1.45 2010/07/03 04:44:51 guenther Exp $ */ /* $NetBSD: tcp_timer.c,v 1.14 1996/02/13 23:44:09 christos Exp $ */ /* @@ -213,14 +213,14 @@ tcp_timer_rexmt(void *arg) icmp.icmp_ip.ip_len = tp->t_pmtud_ip_len; icmp.icmp_ip.ip_hl = tp->t_pmtud_ip_hl; icmpsrc.sin_addr = tp->t_inpcb->inp_faddr; - icmp_mtudisc(&icmp, tp->t_inpcb->inp_rdomain); + icmp_mtudisc(&icmp, tp->t_inpcb->inp_rtableid); /* * Notify all connections to the same peer about * new mss and trigger retransmit. */ in_pcbnotifyall(&tcbtable, sintosa(&icmpsrc), - tp->t_inpcb->inp_rdomain, EMSGSIZE, tcp_mtudisc); + tp->t_inpcb->inp_rtableid, EMSGSIZE, tcp_mtudisc); splx(s); return; } @@ -286,7 +286,7 @@ tcp_timer_rexmt(void *arg) sin.sin_len = sizeof(struct sockaddr_in); sin.sin_addr = inp->inp_faddr; rt = icmp_mtudisc_clone(sintosa(&sin), - inp->inp_rdomain); + inp->inp_rtableid); break; } if (rt != NULL) { diff --git a/sys/netinet/tcp_var.h b/sys/netinet/tcp_var.h index 2650017254f..57cd44fd8ef 100644 --- a/sys/netinet/tcp_var.h +++ b/sys/netinet/tcp_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_var.h,v 1.93 2009/11/13 20:54:05 claudio Exp $ */ +/* $OpenBSD: tcp_var.h,v 1.94 2010/07/03 04:44:51 guenther Exp $ */ /* $NetBSD: tcp_var.h,v 1.17 1996/02/13 23:44:24 christos Exp $ */ /* @@ -274,7 +274,7 @@ struct syn_cache { union syn_cache_sa sc_dst; tcp_seq sc_irs; tcp_seq sc_iss; - u_int sc_rdomain; + u_int sc_rtableid; u_int sc_rxtcur; /* current rxt timeout */ u_int sc_rxttot; /* total time spend on queues */ u_short sc_rxtshift; /* for computing backoff */ diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index 831ff59126a..55bfe45b7ab 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: udp_usrreq.c,v 1.134 2010/04/20 22:05:43 tedu Exp $ */ +/* $OpenBSD: udp_usrreq.c,v 1.135 2010/07/03 04:44:51 guenther Exp $ */ /* $NetBSD: udp_usrreq.c,v 1.28 1996/03/16 23:54:03 christos Exp $ */ /* @@ -444,7 +444,8 @@ udp_input(struct mbuf *m, ...) if (!ip6 && (inp->inp_flags & INP_IPV6)) continue; #endif - if (inp->inp_rdomain != rtable_l2(m->m_pkthdr.rdomain)) + if (rtable_l2(inp->inp_rtableid) != + rtable_l2(m->m_pkthdr.rdomain)) continue; if (inp->inp_lport != uh->uh_dport) continue; @@ -1011,7 +1012,7 @@ udp_output(struct mbuf *m, ...) udpstat.udps_opackets++; /* force routing domain */ - m->m_pkthdr.rdomain = inp->inp_rdomain; + m->m_pkthdr.rdomain = inp->inp_rtableid; error = ip_output(m, inp->inp_options, &inp->inp_route, inp->inp_socket->so_options & diff --git a/sys/netinet6/ip6_divert.c b/sys/netinet6/ip6_divert.c index 8c6a3668107..2894afafa77 100644 --- a/sys/netinet6/ip6_divert.c +++ b/sys/netinet6/ip6_divert.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip6_divert.c,v 1.4 2010/04/20 22:05:44 tedu Exp $ */ +/* $OpenBSD: ip6_divert.c,v 1.5 2010/07/03 04:44:51 guenther Exp $ */ /* * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> @@ -99,7 +99,7 @@ divert6_output(struct mbuf *m, ...) m->m_pkthdr.rcvif = NULL; m->m_nextpkt = NULL; - m->m_pkthdr.rdomain = inp->inp_rdomain; + m->m_pkthdr.rdomain = inp->inp_rtableid; if (control) m_freem(control); diff --git a/sys/sys/proc.h b/sys/sys/proc.h index dc350e3b493..2cb299f285b 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -1,4 +1,4 @@ -/* $OpenBSD: proc.h,v 1.129 2010/06/30 00:40:28 guenther Exp $ */ +/* $OpenBSD: proc.h,v 1.130 2010/07/03 04:44:51 guenther Exp $ */ /* $NetBSD: proc.h,v 1.44 1996/04/22 01:23:21 christos Exp $ */ /*- @@ -154,7 +154,7 @@ struct process { #define ps_startcopy ps_limit struct plimit *ps_limit; /* Process limits. */ - u_int ps_rdomain; /* Process routing domain. */ + u_int ps_rtableid; /* Process routing table/domain. */ /* End area that is copied on creation. */ #define ps_endcopy ps_refcnt diff --git a/sys/sys/socket.h b/sys/sys/socket.h index 91ddae61c1b..ca2dfb3ed1b 100644 --- a/sys/sys/socket.h +++ b/sys/sys/socket.h @@ -1,4 +1,4 @@ -/* $OpenBSD: socket.h,v 1.68 2010/07/02 19:57:15 tedu Exp $ */ +/* $OpenBSD: socket.h,v 1.69 2010/07/03 04:44:51 guenther Exp $ */ /* $NetBSD: socket.h,v 1.14 1996/02/09 18:25:36 christos Exp $ */ /* @@ -85,7 +85,7 @@ #define SO_ERROR 0x1007 /* get error status and clear */ #define SO_TYPE 0x1008 /* get socket type */ #define SO_NETPROC 0x1020 /* multiplex; network processing */ -#define SO_RDOMAIN 0x1021 /* routing domain socket belongs to */ +#define SO_RTABLE 0x1021 /* routing table to be used */ #define SO_PEERCRED 0x1022 /* get connect-time credentials */ /* @@ -498,8 +498,8 @@ int setsockopt(int, int, int, const void *, socklen_t); int shutdown(int, int); int socket(int, int, int); int socketpair(int, int, int, int *); -int getrdomain(void); -int setrdomain(int); +int getrtable(void); +int setrtable(int); __END_DECLS #else # if defined(COMPAT_43) || defined(COMPAT_LINUX) || \ diff --git a/sys/sys/sockio.h b/sys/sys/sockio.h index 3b1996bdaf5..198b7a6c81d 100644 --- a/sys/sys/sockio.h +++ b/sys/sys/sockio.h @@ -1,4 +1,4 @@ -/* $OpenBSD: sockio.h,v 1.47 2010/06/26 19:49:54 claudio Exp $ */ +/* $OpenBSD: sockio.h,v 1.48 2010/07/03 04:44:51 guenther Exp $ */ /* $NetBSD: sockio.h,v 1.5 1995/08/23 00:40:47 thorpej Exp $ */ /*- @@ -173,11 +173,11 @@ #define SIOCSIFXFLAGS _IOW('i', 157, struct ifreq) /* set ifnet xflags */ #define SIOCGIFXFLAGS _IOWR('i', 158, struct ifreq) /* get ifnet xflags */ -#define SIOCSIFRTABLEID _IOW('i', 159, struct ifreq) /* set ifnet VRF id */ -#define SIOCGIFRTABLEID _IOWR('i', 160, struct ifreq) /* get ifnet VRF id */ +#define SIOCSIFRDOMAIN _IOW('i', 159, struct ifreq) /* set ifnet VRF id */ +#define SIOCGIFRDOMAIN _IOWR('i', 160, struct ifreq) /* get ifnet VRF id */ -#define SIOCSLIFPHYRTABLEID _IOW('i', 161, struct ifreq) /* set tunnel VRF id */ -#define SIOCGLIFPHYRTABLEID _IOWR('i', 162, struct ifreq) /* get tunnel id */ +#define SIOCSLIFPHYRTABLE _IOW('i', 161, struct ifreq) /* set tunnel VRF id */ +#define SIOCGLIFPHYRTABLE _IOWR('i', 162, struct ifreq) /* get tunnel VRF id */ #define SIOCSETKALIVE _IOW('i', 163, struct ifkalivereq) #define SIOCGETKALIVE _IOWR('i', 164, struct ifkalivereq) diff --git a/sys/sys/syscall.h b/sys/sys/syscall.h index b2140c38b94..53f064adadb 100644 --- a/sys/sys/syscall.h +++ b/sys/sys/syscall.h @@ -1,4 +1,4 @@ -/* $OpenBSD: syscall.h,v 1.113 2010/07/01 23:11:11 tedu Exp $ */ +/* $OpenBSD: syscall.h,v 1.114 2010/07/03 04:44:51 guenther Exp $ */ /* * System call numbers. @@ -682,10 +682,10 @@ /* syscall: "fhstatfs" ret: "int" args: "const fhandle_t *" "struct statfs *" */ #define SYS_fhstatfs 309 -/* syscall: "setrdomain" ret: "int" args: "int" */ -#define SYS_setrdomain 310 +/* syscall: "setrtable" ret: "int" args: "int" */ +#define SYS_setrtable 310 -/* syscall: "getrdomain" ret: "int" args: */ -#define SYS_getrdomain 311 +/* syscall: "getrtable" ret: "int" args: */ +#define SYS_getrtable 311 #define SYS_MAXSYSCALL 312 diff --git a/sys/sys/syscallargs.h b/sys/sys/syscallargs.h index 768ec01f7be..a5bb5cc2bd5 100644 --- a/sys/sys/syscallargs.h +++ b/sys/sys/syscallargs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: syscallargs.h,v 1.115 2010/07/01 23:11:11 tedu Exp $ */ +/* $OpenBSD: syscallargs.h,v 1.116 2010/07/03 04:44:51 guenther Exp $ */ /* * System call argument lists. @@ -1217,8 +1217,8 @@ struct sys_fhstatfs_args { syscallarg(struct statfs *) buf; }; -struct sys_setrdomain_args { - syscallarg(int) rdomain; +struct sys_setrtable_args { + syscallarg(int) rtableid; }; /* @@ -1531,5 +1531,5 @@ int sys_getfsstat(struct proc *, void *, register_t *); int sys_statfs(struct proc *, void *, register_t *); int sys_fstatfs(struct proc *, void *, register_t *); int sys_fhstatfs(struct proc *, void *, register_t *); -int sys_setrdomain(struct proc *, void *, register_t *); -int sys_getrdomain(struct proc *, void *, register_t *); +int sys_setrtable(struct proc *, void *, register_t *); +int sys_getrtable(struct proc *, void *, register_t *); diff --git a/usr.bin/nc/nc.1 b/usr.bin/nc/nc.1 index 94a2d43cdbb..fa0f76b9543 100644 --- a/usr.bin/nc/nc.1 +++ b/usr.bin/nc/nc.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: nc.1,v 1.53 2010/02/23 23:00:52 schwarze Exp $ +.\" $OpenBSD: nc.1,v 1.54 2010/07/03 04:44:51 guenther Exp $ .\" .\" Copyright (c) 1996 David Sacerdote .\" All rights reserved. @@ -25,7 +25,7 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd $Mdocdate: February 23 2010 $ +.Dd $Mdocdate: July 3 2010 $ .Dt NC 1 .Os .Sh NAME @@ -42,7 +42,7 @@ .Op Fl p Ar source_port .Op Fl s Ar source_ip_address .Op Fl T Ar ToS -.Op Fl V Ar rdomain +.Op Fl V Ar rtable .Op Fl w Ar timeout .Op Fl X Ar proxy_protocol .Oo Xo @@ -179,8 +179,8 @@ Specifies to use sockets. .It Fl u Use UDP instead of the default option of TCP. -.It Fl V Ar rdomain -Set the routing domain. +.It Fl V Ar rtable +Set the routing table to be used. The default is 0. .It Fl v Have diff --git a/usr.bin/nc/netcat.c b/usr.bin/nc/netcat.c index df68805bd9d..e471182b2ad 100644 --- a/usr.bin/nc/netcat.c +++ b/usr.bin/nc/netcat.c @@ -1,4 +1,4 @@ -/* $OpenBSD: netcat.c,v 1.97 2010/04/20 07:28:28 nicm Exp $ */ +/* $OpenBSD: netcat.c,v 1.98 2010/07/03 04:44:51 guenther Exp $ */ /* * Copyright (c) 2001 Eric Jackson <ericj@monkey.org> * @@ -84,7 +84,7 @@ int Iflag; /* TCP receive buffer size */ int Oflag; /* TCP send buffer size */ int Sflag; /* TCP MD5 signature option */ int Tflag = -1; /* IP Type of Service */ -u_int rdomain; +u_int rtableid; int timeout = -1; int family = AF_UNSPEC; @@ -189,10 +189,10 @@ main(int argc, char *argv[]) uflag = 1; break; case 'V': - rdomain = (unsigned int)strtonum(optarg, 0, + rtableid = (unsigned int)strtonum(optarg, 0, RT_TABLEID_MAX, &errstr); if (errstr) - errx(1, "rdomain %s: %s", errstr, optarg); + errx(1, "rtable %s: %s", errstr, optarg); break; case 'v': vflag = 1; @@ -507,10 +507,10 @@ remote_connect(const char *host, const char *port, struct addrinfo hints) res0->ai_protocol)) < 0) continue; - if (rdomain) { - if (setsockopt(s, IPPROTO_IP, SO_RDOMAIN, &rdomain, - sizeof(rdomain)) == -1) - err(1, "setsockopt SO_RDOMAIN"); + if (rtableid) { + if (setsockopt(s, IPPROTO_IP, SO_RTABLE, &rtableid, + sizeof(rtableid)) == -1) + err(1, "setsockopt SO_RTABLE"); } /* Bind to a local port or source address if specified. */ @@ -581,10 +581,10 @@ local_listen(char *host, char *port, struct addrinfo hints) res0->ai_protocol)) < 0) continue; - if (rdomain) { - if (setsockopt(s, IPPROTO_IP, SO_RDOMAIN, &rdomain, - sizeof(rdomain)) == -1) - err(1, "setsockopt SO_RDOMAIN"); + if (rtableid) { + if (setsockopt(s, IPPROTO_IP, SO_RTABLE, &rtableid, + sizeof(rtableid)) == -1) + err(1, "setsockopt SO_RTABLE"); } ret = setsockopt(s, SOL_SOCKET, SO_REUSEPORT, &x, sizeof(x)); @@ -871,7 +871,7 @@ help(void) \t-t Answer TELNET negotiation\n\ \t-U Use UNIX domain socket\n\ \t-u UDP mode\n\ - \t-V rdomain Specify alternate routing domain\n\ + \t-V rtable Specify alternate routing table\n\ \t-v Verbose\n\ \t-w secs\t Timeout for connects and final net reads\n\ \t-X proto Proxy protocol: \"4\", \"5\" (SOCKS) or \"connect\"\n\ @@ -887,7 +887,7 @@ usage(int ret) fprintf(stderr, "usage: nc [-46DdhklnrStUuvz] [-I length] [-i interval] [-O length]\n" "\t [-P proxy_username] [-p source_port] [-s source_ip_address] [-T ToS]\n" - "\t [-V rdomain] [-w timeout] [-X proxy_protocol]\n" + "\t [-V rtable] [-w timeout] [-X proxy_protocol]\n" "\t [-x proxy_address[:port]] [hostname] [port]\n"); if (ret) exit(1); diff --git a/usr.bin/tcpbench/tcpbench.1 b/usr.bin/tcpbench/tcpbench.1 index 1474074e81b..7e37ca82624 100644 --- a/usr.bin/tcpbench/tcpbench.1 +++ b/usr.bin/tcpbench/tcpbench.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: tcpbench.1,v 1.7 2009/08/13 17:38:28 jmc Exp $ +.\" $OpenBSD: tcpbench.1,v 1.8 2010/07/03 04:44:51 guenther Exp $ .\" .\" Copyright (c) 2008 Damien Miller <djm@mindrot.org> .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: August 13 2009 $ +.Dd $Mdocdate: July 3 2010 $ .Os .Dt TCPBENCH 1 .Sh NAME @@ -31,7 +31,7 @@ .Op Fl p Ar port .Op Fl r Ar rate .Op Fl S Ar space -.Op Fl V Ar rdomain +.Op Fl V Ar rtable .Ar hostname .Nm .Bk -words @@ -42,7 +42,7 @@ .Op Fl p Ar port .Op Fl r Ar rate .Op Fl S Ar space -.Op Fl V Ar rdomain +.Op Fl V Ar rtable .Ek .Sh DESCRIPTION .Nm @@ -98,8 +98,8 @@ Place .Nm in server mode, where it will listen on all interfaces for incoming connections. -.It Fl V Ar rdomain -Set the routing domain. +.It Fl V Ar rtable +Set the routing table to be used. The default is 0. .It Fl v Display verbose output. diff --git a/usr.bin/tcpbench/tcpbench.c b/usr.bin/tcpbench/tcpbench.c index 18ff4574a1d..5ae4af080a4 100644 --- a/usr.bin/tcpbench/tcpbench.c +++ b/usr.bin/tcpbench/tcpbench.c @@ -56,7 +56,7 @@ sig_atomic_t done = 0; sig_atomic_t proc_slice = 0; -static u_int rdomain; +static u_int rtableid; static char **kflag; static size_t Bflag; static int Sflag; @@ -137,9 +137,9 @@ usage(void) fprintf(stderr, "usage: tcpbench -l\n" " tcpbench [-v] [-B buf] [-k kvars] [-n connections] [-p port]\n" - " [-r rate] [-S space] [-V rdomain] hostname\n" + " [-r rate] [-S space] [-V rtable] hostname\n" " tcpbench -s [-v] [-B buf] [-k kvars] [-p port]\n" - " [-r rate] [-S space] [-V rdomain]\n"); + " [-r rate] [-S space] [-V rtable]\n"); exit(1); } @@ -552,12 +552,12 @@ serverbind(struct pollfd *pfd, nfds_t max_nfds, struct addrinfo *aitop) warn("socket"); continue; } - if (rdomain && ai->ai_family == AF_INET) { - if (setsockopt(sock, IPPROTO_IP, SO_RDOMAIN, - &rdomain, sizeof(rdomain)) == -1) - err(1, "setsockopt SO_RDOMAIN"); - } else if (rdomain) - warnx("rdomain only supported on AF_INET"); + if (rtableid && ai->ai_family == AF_INET) { + if (setsockopt(sock, IPPROTO_IP, SO_RTABLE, + &rtableid, sizeof(rtableid)) == -1) + err(1, "setsockopt SO_RTABLE"); + } else if (rtableid) + warnx("rtable only supported on AF_INET"); if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) == -1) warn("reuse port"); @@ -757,12 +757,12 @@ clientconnect(struct addrinfo *aitop, struct pollfd *pfd, int nconn) warn("socket"); continue; } - if (rdomain && ai->ai_family == AF_INET) { - if (setsockopt(sock, IPPROTO_IP, SO_RDOMAIN, - &rdomain, sizeof(rdomain)) == -1) - err(1, "setsockopt SO_RDOMAIN"); - } else if (rdomain) - warnx("rdomain only supported on AF_INET"); + if (rtableid && ai->ai_family == AF_INET) { + if (setsockopt(sock, IPPROTO_IP, SO_RTABLE, + &rtableid, sizeof(rtableid)) == -1) + err(1, "setsockopt SO_RTABLE"); + } else if (rtableid) + warnx("rtable only supported on AF_INET"); if (Sflag) { if (setsockopt(sock, SOL_SOCKET, SO_SNDBUF, &Sflag, sizeof(Sflag)) == -1) @@ -891,7 +891,7 @@ main(int argc, char **argv) int nconn = 1; Bflag = DEFAULT_BUF; - Sflag = sflag = vflag = rdomain = 0; + Sflag = sflag = vflag = rtableid = 0; kflag = NULL; rflag = DEFAULT_STATS_INTERVAL; @@ -937,10 +937,10 @@ main(int argc, char **argv) vflag++; break; case 'V': - rdomain = (unsigned int)strtonum(optarg, 0, + rtableid = (unsigned int)strtonum(optarg, 0, RT_TABLEID_MAX, &errstr); if (errstr) - errx(1, "rdomain value is %s: %s", + errx(1, "rtable value is %s: %s", errstr, optarg); break; case 'n': diff --git a/usr.bin/telnet/commands.c b/usr.bin/telnet/commands.c index 9b848f5da22..4d3b7e5bab5 100644 --- a/usr.bin/telnet/commands.c +++ b/usr.bin/telnet/commands.c @@ -1,4 +1,4 @@ -/* $OpenBSD: commands.c,v 1.51 2009/06/05 00:20:46 claudio Exp $ */ +/* $OpenBSD: commands.c,v 1.52 2010/07/03 04:44:51 guenther Exp $ */ /* $NetBSD: commands.c,v 1.14 1996/03/24 22:03:48 jtk Exp $ */ /* @@ -2396,10 +2396,10 @@ tn(argc, argv) if (net < 0) continue; - if (rdomain) { - if (setsockopt(net, IPPROTO_IP, SO_RDOMAIN, &rdomain, - sizeof(rdomain)) == -1) - perror("setsockopt (SO_RDOMAIN)"); + if (rtableid) { + if (setsockopt(net, IPPROTO_IP, SO_RTABLE, &rtableid, + sizeof(rtableid)) == -1) + perror("setsockopt (SO_RTABLE)"); } if (aliasp) { diff --git a/usr.bin/telnet/externs.h b/usr.bin/telnet/externs.h index 8729421c51c..c523ce02c66 100644 --- a/usr.bin/telnet/externs.h +++ b/usr.bin/telnet/externs.h @@ -1,4 +1,4 @@ -/* $OpenBSD: externs.h,v 1.15 2009/06/05 00:20:46 claudio Exp $ */ +/* $OpenBSD: externs.h,v 1.16 2010/07/03 04:44:51 guenther Exp $ */ /* $KTH: externs.h,v 1.16 1997/11/29 02:28:35 joda Exp $ */ /* @@ -108,7 +108,7 @@ extern void (*encrypt_output) (unsigned char *, int); extern int (*decrypt_input) (int); #endif -extern u_int rdomain; /* routing domain to use */ +extern u_int rtableid; /* routing table to use */ /* * We keep track of each side of the option negotiation. diff --git a/usr.bin/telnet/main.c b/usr.bin/telnet/main.c index 7c78d6f8c76..e767663f327 100644 --- a/usr.bin/telnet/main.c +++ b/usr.bin/telnet/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.19 2009/10/27 23:59:44 deraadt Exp $ */ +/* $OpenBSD: main.c,v 1.20 2010/07/03 04:44:51 guenther Exp $ */ /* $NetBSD: main.c,v 1.5 1996/02/28 21:04:05 thorpej Exp $ */ /* @@ -54,7 +54,7 @@ static int default_forward=0; #endif int family = AF_UNSPEC; -u_int rdomain; +u_int rtableid; /* * Initialize variables. @@ -86,7 +86,7 @@ usage() # else "usage: %s [-468acdEFfKLrx] [-b hostalias] [-e escapechar] " "[-k realm]\n" - "\t[-l user] [-n tracefile] [-V rdomain] [-X authtype] " + "\t[-l user] [-n tracefile] [-V rtable] [-X authtype] " "[host [port]]\n", #endif __progname); @@ -326,11 +326,11 @@ main(argc, argv) #endif break; case 'V': - rdomain = (unsigned int)strtonum(optarg, 0, + rtableid = (unsigned int)strtonum(optarg, 0, RT_TABLEID_MAX, &errstr); if (errstr) { - fprintf(stderr, - "%s: Warning: -R ignored, rdomain %s: %s\n", + fprintf(stderr, "%s: Warning: " + "-V ignored, rtable %s: %s\n", prompt, errstr, optarg); } break; diff --git a/usr.bin/telnet/telnet.1 b/usr.bin/telnet/telnet.1 index eae86142678..1730369e72c 100644 --- a/usr.bin/telnet/telnet.1 +++ b/usr.bin/telnet/telnet.1 @@ -1,4 +1,4 @@ -.\" $OpenBSD: telnet.1,v 1.42 2009/06/05 06:47:12 jmc Exp $ +.\" $OpenBSD: telnet.1,v 1.43 2010/07/03 04:44:51 guenther Exp $ .\" $NetBSD: telnet.1,v 1.5 1996/02/28 21:04:12 thorpej Exp $ .\" .\" Copyright (c) 1983, 1990, 1993 @@ -30,7 +30,7 @@ .\" .\" from: @(#)telnet.1 8.4 (Berkeley) 2/3/94 .\" -.Dd $Mdocdate: June 5 2009 $ +.Dd $Mdocdate: July 3 2010 $ .Dt TELNET 1 .Os .Sh NAME @@ -47,7 +47,7 @@ protocol .Op Fl k Ar realm .Op Fl l Ar user .Op Fl n Ar tracefile -.Op Fl V Ar rdomain +.Op Fl V Ar rtable .Op Fl X Ar authtype .Oo .Ar host @@ -186,8 +186,8 @@ mode, the escape character is set to the tilde (~) character, unless modified by the .Fl e option. -.It Fl V Ar rdomain -Set the routing domain. +.It Fl V Ar rtable +Set the routing table to be used. The default is 0. .It Fl X Ar authtype Disables the diff --git a/usr.sbin/dhcpd/dhcpd.c b/usr.sbin/dhcpd/dhcpd.c index dc2fa85a51c..7b8b0500857 100644 --- a/usr.sbin/dhcpd/dhcpd.c +++ b/usr.sbin/dhcpd/dhcpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhcpd.c,v 1.39 2010/04/19 12:22:09 claudio Exp $ */ +/* $OpenBSD: dhcpd.c,v 1.40 2010/07/03 04:44:51 guenther Exp $ */ /* * Copyright (c) 2004 Henning Brauer <henning@cvs.openbsd.org> @@ -172,8 +172,8 @@ main(int argc, char *argv[]) discover_interfaces(&rdomain); if (rdomain != -1) - if (setrdomain(rdomain) == -1) - error("setrdomain (%m)"); + if (setrtable(rdomain) == -1) + error("setrtable (%m)"); icmp_startup(1, lease_pinged); diff --git a/usr.sbin/dhcpd/dispatch.c b/usr.sbin/dhcpd/dispatch.c index ff431c85fcb..2b6970bf48d 100644 --- a/usr.sbin/dhcpd/dispatch.c +++ b/usr.sbin/dhcpd/dispatch.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dispatch.c,v 1.26 2010/04/19 12:22:09 claudio Exp $ */ +/* $OpenBSD: dispatch.c,v 1.27 2010/07/03 04:44:51 guenther Exp $ */ /* * Copyright (c) 1995, 1996, 1997, 1998, 1999 @@ -633,7 +633,7 @@ get_rdomain(char *name) bzero(&ifr, sizeof(ifr)); strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); - if (ioctl(s, SIOCGIFRTABLEID, (caddr_t)&ifr) != -1) + if (ioctl(s, SIOCGIFRDOMAIN, (caddr_t)&ifr) != -1) rv = ifr.ifr_rdomainid; close(s); diff --git a/usr.sbin/dhcrelay/dhcrelay.c b/usr.sbin/dhcrelay/dhcrelay.c index 0799b0b4e98..d9cbccc9cff 100644 --- a/usr.sbin/dhcrelay/dhcrelay.c +++ b/usr.sbin/dhcrelay/dhcrelay.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhcrelay.c,v 1.33 2009/11/03 10:14:09 claudio Exp $ */ +/* $OpenBSD: dhcrelay.c,v 1.34 2010/07/03 04:44:52 guenther Exp $ */ /* * Copyright (c) 2004 Henning Brauer <henning@cvs.openbsd.org> @@ -176,7 +176,7 @@ main(int argc, char *argv[]) if (setsockopt(sp->fd, SOL_SOCKET, SO_REUSEPORT, &opt, sizeof(opt)) == -1) error("setsockopt: %m"); - if (setsockopt(sp->fd, IPPROTO_IP, SO_RDOMAIN, &rdomain, + if (setsockopt(sp->fd, IPPROTO_IP, SO_RTABLE, &rdomain, sizeof(rdomain)) == -1) error("setsockopt: %m"); if (bind(sp->fd, (struct sockaddr *)&laddr, sizeof laddr) == -1) @@ -197,7 +197,7 @@ main(int argc, char *argv[]) if (setsockopt(server_fd, SOL_SOCKET, SO_REUSEPORT, &opt, sizeof(opt)) == -1) error("setsockopt: %m"); - if (setsockopt(server_fd, IPPROTO_IP, SO_RDOMAIN, &rdomain, + if (setsockopt(server_fd, IPPROTO_IP, SO_RTABLE, &rdomain, sizeof(rdomain)) == -1) error("setsockopt: %m"); if (bind(server_fd, (struct sockaddr *)&laddr, @@ -501,7 +501,7 @@ get_rdomain(char *name) bzero(&ifr, sizeof(ifr)); strlcpy(ifr.ifr_name, name, sizeof(ifr.ifr_name)); - if (ioctl(s, SIOCGIFRTABLEID, (caddr_t)&ifr) != -1) + if (ioctl(s, SIOCGIFRDOMAIN, (caddr_t)&ifr) != -1) rv = ifr.ifr_rdomainid; close(s); diff --git a/usr.sbin/ospfd/interface.c b/usr.sbin/ospfd/interface.c index f07ff16bff5..1d787008a51 100644 --- a/usr.sbin/ospfd/interface.c +++ b/usr.sbin/ospfd/interface.c @@ -1,4 +1,4 @@ -/* $OpenBSD: interface.c,v 1.69 2010/05/14 08:30:18 sthen Exp $ */ +/* $OpenBSD: interface.c,v 1.70 2010/07/03 04:44:52 guenther Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -253,11 +253,11 @@ if_init(struct ospfd_conf *xconf, struct iface *iface) iface->fd = xconf->ospf_socket; strlcpy(ifr.ifr_name, iface->name, sizeof(ifr.ifr_name)); - if (ioctl(iface->fd, SIOCGIFRTABLEID, (caddr_t)&ifr) == -1) + if (ioctl(iface->fd, SIOCGIFRDOMAIN, (caddr_t)&ifr) == -1) rdomain = 0; else { rdomain = ifr.ifr_rdomainid; - if (setsockopt(iface->fd, IPPROTO_IP, SO_RDOMAIN, + if (setsockopt(iface->fd, IPPROTO_IP, SO_RTABLE, &rdomain, sizeof(rdomain)) == -1) fatal("failed to set rdomain"); } diff --git a/usr.sbin/ripd/interface.c b/usr.sbin/ripd/interface.c index 1960251ecd2..5df24f922a9 100644 --- a/usr.sbin/ripd/interface.c +++ b/usr.sbin/ripd/interface.c @@ -1,4 +1,4 @@ -/* $OpenBSD: interface.c,v 1.8 2009/09/26 18:24:58 michele Exp $ */ +/* $OpenBSD: interface.c,v 1.9 2010/07/03 04:44:52 guenther Exp $ */ /* * Copyright (c) 2006 Michele Marchetto <mydecay@openbeer.it> @@ -79,11 +79,11 @@ if_init(struct ripd_conf *xconf, struct iface *iface) iface->fd = xconf->rip_socket; strlcpy(ifr.ifr_name, iface->name, sizeof(ifr.ifr_name)); - if (ioctl(iface->fd, SIOCGIFRTABLEID, (caddr_t)&ifr) == -1) + if (ioctl(iface->fd, SIOCGIFRDOMAIN, (caddr_t)&ifr) == -1) rdomain = 0; else { rdomain = ifr.ifr_rdomainid; - if (setsockopt(iface->fd, IPPROTO_IP, SO_RDOMAIN, &rdomain, + if (setsockopt(iface->fd, IPPROTO_IP, SO_RTABLE, &rdomain, sizeof(rdomain)) == -1) fatal("failed to set rdomain"); } diff --git a/usr.sbin/traceroute/traceroute.8 b/usr.sbin/traceroute/traceroute.8 index 022ef6dc3d2..fcc4a417446 100644 --- a/usr.sbin/traceroute/traceroute.8 +++ b/usr.sbin/traceroute/traceroute.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: traceroute.8,v 1.42 2009/07/06 06:50:03 jmc Exp $ +.\" $OpenBSD: traceroute.8,v 1.43 2010/07/03 04:44:52 guenther Exp $ .\" $NetBSD: traceroute.8,v 1.6 1995/10/12 03:05:50 mycroft Exp $ .\" .\" Copyright (c) 1990, 1991, 1993 @@ -33,7 +33,7 @@ .\" .\" @(#)traceroute.8 8.1 (Berkeley) 6/6/93 .\" -.Dd $Mdocdate: July 6 2009 $ +.Dd $Mdocdate: July 3 2010 $ .Dt TRACEROUTE 8 .Os .Sh NAME @@ -51,7 +51,7 @@ .Op Fl q Ar nqueries .Op Fl s Ar src_addr .Op Fl t Ar tos -.Op Fl V Ar rdomain +.Op Fl V Ar rtable .Op Fl w Ar waittime .Ar host .Op Ar packetsize @@ -191,8 +191,8 @@ Useful values are probably (low delay) and .Ql -t 8 (high throughput). -.It Fl V Ar rdomain -Set the routing domain. +.It Fl V Ar rtable +Set the routing table to be used. The default is 0. .It Fl v Verbose output. diff --git a/usr.sbin/traceroute/traceroute.c b/usr.sbin/traceroute/traceroute.c index 274ba3a7369..23ec4b3825f 100644 --- a/usr.sbin/traceroute/traceroute.c +++ b/usr.sbin/traceroute/traceroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: traceroute.c,v 1.68 2009/10/27 23:59:57 deraadt Exp $ */ +/* $OpenBSD: traceroute.c,v 1.69 2010/07/03 04:44:52 guenther Exp $ */ /* $NetBSD: traceroute.c,v 1.10 1995/05/21 15:50:45 mycroft Exp $ */ /*- @@ -295,7 +295,8 @@ main(int argc, char *argv[]) char *ep; const char *errstr; long l; - uid_t uid, rdomain; + uid_t uid; + u_int rtableid; if ((s = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP)) < 0) err(5, "icmp socket"); @@ -424,16 +425,16 @@ main(int argc, char *argv[]) verbose++; break; case 'V': - rdomain = (unsigned int)strtonum(optarg, 0, + rtableid = (unsigned int)strtonum(optarg, 0, RT_TABLEID_MAX, &errstr); if (errstr) - errx(1, "rdomain value is %s: %s", + errx(1, "rtable value is %s: %s", errstr, optarg); - if (setsockopt(sndsock, IPPROTO_IP, SO_RDOMAIN, - &rdomain, sizeof(rdomain)) == -1) + if (setsockopt(sndsock, IPPROTO_IP, SO_RTABLE, + &rtableid, sizeof(rtableid)) == -1) err(1, "setsockopt SO_RDOMAIN"); - if (setsockopt(s, IPPROTO_IP, SO_RDOMAIN, - &rdomain, sizeof(rdomain)) == -1) + if (setsockopt(s, IPPROTO_IP, SO_RTABLE, + &rtableid, sizeof(rtableid)) == -1) err(1, "setsockopt SO_RDOMAIN"); break; case 'w': @@ -1041,6 +1042,6 @@ usage(void) fprintf(stderr, "usage: %s [-cDdIlnrSv] [-f first_ttl] [-g gateway_addr] [-m max_ttl]\n" "\t[-P proto] [-p port] [-q nqueries] [-s src_addr] [-t tos]\n" - "\t[-V rdomain] [-w waittime] host [packetsize]\n", __progname); + "\t[-V rtable] [-w waittime] host [packetsize]\n", __progname); exit(1); } |