diff options
author | 2010-07-03 04:44:50 +0000 | |
---|---|---|
committer | 2010-07-03 04:44:50 +0000 | |
commit | 8bb39f085984c8f31e98e59d88cab46a5aa1548e (patch) | |
tree | 841fb14fb8115333f08970c7eca7ab1ad359933b /sys/netinet/ip_output.c | |
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
Diffstat (limited to 'sys/netinet/ip_output.c')
-rw-r--r-- | sys/netinet/ip_output.c | 31 |
1 files changed, 15 insertions, 16 deletions
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; |