diff options
author | 2014-03-27 13:27:28 +0000 | |
---|---|---|
committer | 2014-03-27 13:27:28 +0000 | |
commit | 8da457310822e8b1189beb909ea6788297cc2213 (patch) | |
tree | 00b05c41d3550fac5fe04e7ca13d25698327f534 | |
parent | +.Xr smtpd 8 (diff) | |
download | wireguard-openbsd-8da457310822e8b1189beb909ea6788297cc2213.tar.xz wireguard-openbsd-8da457310822e8b1189beb909ea6788297cc2213.zip |
Retire kernel support for SO_DONTROUTE, since the plan is to always
use the routing table there's no future for an option that wants to
bypass it. This option has never been implemented for IPv6 anyway,
so let's just remove the IPv4 bits that you weren't aware of.
Tested by florian@, man pages inputs from jmc@, ok benno@
-rw-r--r-- | lib/libc/sys/getsockopt.2 | 13 | ||||
-rw-r--r-- | lib/libc/sys/send.2 | 8 | ||||
-rw-r--r-- | sys/compat/linux/linux_socket.c | 4 | ||||
-rw-r--r-- | sys/kern/uipc_socket.c | 26 | ||||
-rw-r--r-- | sys/netinet/in_pcb.c | 25 | ||||
-rw-r--r-- | sys/netinet/ip_divert.c | 8 | ||||
-rw-r--r-- | sys/netinet/ip_output.c | 40 | ||||
-rw-r--r-- | sys/netinet/ip_var.h | 3 | ||||
-rw-r--r-- | sys/netinet/raw_ip.c | 4 | ||||
-rw-r--r-- | sys/netinet/tcp_output.c | 9 | ||||
-rw-r--r-- | sys/netinet/udp_usrreq.c | 6 | ||||
-rw-r--r-- | sys/netinet6/in6_src.c | 21 | ||||
-rw-r--r-- | sys/netinet6/ip6_divert.c | 5 |
13 files changed, 49 insertions, 123 deletions
diff --git a/lib/libc/sys/getsockopt.2 b/lib/libc/sys/getsockopt.2 index 312aa28396a..cefce112404 100644 --- a/lib/libc/sys/getsockopt.2 +++ b/lib/libc/sys/getsockopt.2 @@ -1,4 +1,4 @@ -.\" $OpenBSD: getsockopt.2,v 1.43 2014/03/06 17:38:28 jmc Exp $ +.\" $OpenBSD: getsockopt.2,v 1.44 2014/03/27 13:27:28 mpi Exp $ .\" $NetBSD: getsockopt.2,v 1.7 1995/02/27 12:33:29 cgd Exp $ .\" .\" Copyright (c) 1983, 1991, 1993 @@ -30,7 +30,7 @@ .\" .\" @(#)getsockopt.2 8.3 (Berkeley) 4/19/94 .\" -.Dd $Mdocdate: March 6 2014 $ +.Dd $Mdocdate: March 27 2014 $ .Dt GETSOCKOPT 2 .Os .Sh NAME @@ -142,7 +142,7 @@ enables duplicate address and port bindings .It Dv SO_KEEPALIVE enables keep connections alive .It Dv SO_DONTROUTE -enables routing bypass for outgoing messages +enables routing bypass; not supported .It Dv SO_LINGER linger on close if data present .It Dv SO_BROADCAST @@ -195,11 +195,6 @@ Should the connected party fail to respond to these messages, the connection is considered broken and processes using the socket are notified via a .Dv SIGPIPE signal when attempting to send data. -.Dv SO_DONTROUTE -indicates that outgoing messages should -bypass the standard routing facilities. -Instead, messages are directed to the appropriate network interface -according to the network portion of the destination address. .Pp .Dv SO_LINGER controls the action taken when unsent messages @@ -471,6 +466,8 @@ The argument is a file, not a socket. .It Bq Er ENOPROTOOPT The option is unknown at the level indicated. +.It Bq Er EOPNOTSUPP +The option is unsupported. .It Bq Er EFAULT The address pointed to by .Fa optval diff --git a/lib/libc/sys/send.2 b/lib/libc/sys/send.2 index d91d2b8053a..2884dd658ed 100644 --- a/lib/libc/sys/send.2 +++ b/lib/libc/sys/send.2 @@ -1,4 +1,4 @@ -.\" $OpenBSD: send.2,v 1.27 2012/10/05 01:30:28 yasuoka Exp $ +.\" $OpenBSD: send.2,v 1.28 2014/03/27 13:27:28 mpi Exp $ .\" $NetBSD: send.2,v 1.6 1996/01/15 01:17:18 thorpej Exp $ .\" .\" Copyright (c) 1983, 1991, 1993 @@ -30,7 +30,7 @@ .\" .\" @(#)send.2 8.2 (Berkeley) 2/21/94 .\" -.Dd $Mdocdate: October 5 2012 $ +.Dd $Mdocdate: March 27 2014 $ .Dt SEND 2 .Os .Sh NAME @@ -99,7 +99,7 @@ parameter may include one or more of the following: .It Dv MSG_OOB process out-of-band data .It Dv MSG_DONTROUTE -bypass routing, use direct interface +bypass routing tables, silently ignored .It Dv MSG_NOSIGNAL don't send .Dv SIGPIPE @@ -116,8 +116,6 @@ data on sockets that support this notion (e.g., the underlying protocol must also support .Dq out-of-band data. -.Dv MSG_DONTROUTE -is usually used only by diagnostic or routing programs. .Dv MSG_NOSIGNAL is used to request not to send the .Dv SIGPIPE diff --git a/sys/compat/linux/linux_socket.c b/sys/compat/linux/linux_socket.c index caab7b4fbcf..8df363627cf 100644 --- a/sys/compat/linux/linux_socket.c +++ b/sys/compat/linux/linux_socket.c @@ -1,4 +1,4 @@ -/* $OpenBSD: linux_socket.c,v 1.49 2014/03/26 05:23:42 guenther Exp $ */ +/* $OpenBSD: linux_socket.c,v 1.50 2014/03/27 13:27:28 mpi Exp $ */ /* $NetBSD: linux_socket.c,v 1.14 1996/04/05 00:01:50 christos Exp $ */ /* @@ -215,8 +215,6 @@ linux_to_bsd_msg_flags(int lflags) flags |= MSG_OOB; if (lflags & LINUX_MSG_PEEK) flags |= MSG_PEEK; - if (lflags & LINUX_MSG_DONTROUTE) - flags |= MSG_DONTROUTE; if (lflags & LINUX_MSG_DONTWAIT) flags |= MSG_DONTWAIT; if (lflags & LINUX_MSG_WAITALL) diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c index 0084c5a020d..22b23951459 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_socket.c,v 1.123 2014/03/18 07:01:21 guenther Exp $ */ +/* $OpenBSD: uipc_socket.c,v 1.124 2014/03/27 13:27:28 mpi Exp $ */ /* $NetBSD: uipc_socket.c,v 1.21 1996/02/04 02:17:52 christos Exp $ */ /* @@ -385,7 +385,7 @@ sosend(struct socket *so, struct mbuf *addr, struct uio *uio, struct mbuf *top, struct mbuf *m; long space, len, mlen, clen = 0; quad_t resid; - int error, s, dontroute; + int error, s; int atomic = sosendallatonce(so) || top; if (uio) @@ -405,9 +405,6 @@ sosend(struct socket *so, struct mbuf *addr, struct uio *uio, struct mbuf *top, error = EINVAL; goto out; } - dontroute = - (flags & MSG_DONTROUTE) && (so->so_options & SO_DONTROUTE) == 0 && - (so->so_proto->pr_flags & PR_ATOMIC); if (uio && uio->uio_procp) uio->uio_procp->p_ru.ru_msgsnd++; if (control) { @@ -522,8 +519,6 @@ nopages: break; } } while (space > 0 && atomic); - if (dontroute) - so->so_options |= SO_DONTROUTE; s = splsoftnet(); /* XXX */ if (resid <= 0) so->so_state &= ~SS_ISSENDING; @@ -531,8 +526,6 @@ nopages: (flags & MSG_OOB) ? PRU_SENDOOB : PRU_SEND, top, addr, control, curproc); splx(s); - if (dontroute) - so->so_options &= ~SO_DONTROUTE; clen = 0; control = 0; top = 0; @@ -1483,7 +1476,6 @@ sosetopt(struct socket *so, int level, int optname, struct mbuf *m0) case SO_BINDANY: case SO_DEBUG: case SO_KEEPALIVE: - case SO_DONTROUTE: case SO_USELOOPBACK: case SO_BROADCAST: case SO_REUSEADDR: @@ -1500,6 +1492,15 @@ sosetopt(struct socket *so, int level, int optname, struct mbuf *m0) so->so_options &= ~optname; break; + case SO_DONTROUTE: + if (m == NULL || m->m_len < sizeof (int)) { + error = EINVAL; + goto bad; + } + if (*mtod(m, int *)) + error = EOPNOTSUPP; + break; + case SO_SNDBUF: case SO_RCVBUF: case SO_SNDLOWAT: @@ -1658,7 +1659,6 @@ sogetopt(struct socket *so, int level, int optname, struct mbuf **mp) case SO_BINDANY: case SO_USELOOPBACK: - case SO_DONTROUTE: case SO_DEBUG: case SO_KEEPALIVE: case SO_REUSEADDR: @@ -1669,6 +1669,10 @@ sogetopt(struct socket *so, int level, int optname, struct mbuf **mp) *mtod(m, int *) = so->so_options & optname; break; + case SO_DONTROUTE: + *mtod(m, int *) = 0; + break; + case SO_TYPE: *mtod(m, int *) = so->so_type; break; diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index 67333ec24d2..28012438f98 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in_pcb.c,v 1.147 2014/01/18 21:14:46 bluhm Exp $ */ +/* $OpenBSD: in_pcb.c,v 1.148 2014/03/27 13:27:28 mpi Exp $ */ /* $NetBSD: in_pcb.c,v 1.25 1996/02/13 23:41:53 christos Exp $ */ /* @@ -817,14 +817,12 @@ in_selectsrc(struct sockaddr_in *sin, struct route *ro, int soopts, * If route is known or can be allocated now, * our src addr is taken from the i/f, else punt. */ - if (ro->ro_rt && (!(ro->ro_rt->rt_flags & RTF_UP) || - (satosin(&ro->ro_dst)->sin_addr.s_addr != sin->sin_addr.s_addr || - soopts & SO_DONTROUTE))) { + if (ro->ro_rt && ((ro->ro_rt->rt_flags & RTF_UP) == 0 || + (satosin(&ro->ro_dst)->sin_addr.s_addr != sin->sin_addr.s_addr))) { RTFREE(ro->ro_rt); ro->ro_rt = NULL; } - if ((soopts & SO_DONTROUTE) == 0 && /*XXX*/ - (ro->ro_rt == NULL || ro->ro_rt->rt_ifp == NULL)) { + if ((ro->ro_rt == NULL || ro->ro_rt->rt_ifp == NULL)) { /* No route yet, so try to acquire one */ ro->ro_dst.sa_family = AF_INET; ro->ro_dst.sa_len = sizeof(struct sockaddr_in); @@ -849,19 +847,8 @@ in_selectsrc(struct sockaddr_in *sin, struct route *ro, int soopts, !(ro->ro_rt->rt_ifp->if_flags & IFF_LOOPBACK)) ia = ifatoia(ro->ro_rt->rt_ifa); if (ia == 0) { - u_int16_t fport = sin->sin_port; - - sin->sin_port = 0; - ia = ifatoia(ifa_ifwithdstaddr(sintosa(sin), rtableid)); - if (ia == 0) - ia = ifatoia(ifa_ifwithnet(sintosa(sin), rtableid)); - sin->sin_port = fport; - if (ia == 0) - ia = TAILQ_FIRST(&in_ifaddr); - if (ia == 0) { - *errorp = EADDRNOTAVAIL; - return NULL; - } + *errorp = EADDRNOTAVAIL; + return (NULL); } return (&ia->ia_addr); } diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c index 5365618f591..947f5205b2e 100644 --- a/sys/netinet/ip_divert.c +++ b/sys/netinet/ip_divert.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_divert.c,v 1.16 2014/01/09 06:29:06 tedu Exp $ */ +/* $OpenBSD: ip_divert.c,v 1.17 2014/03/27 13:27:28 mpi Exp $ */ /* * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> @@ -180,10 +180,8 @@ divert_output(struct mbuf *m, ...) schednetisr(NETISR_IP); splx(s); } else { - error = ip_output(m, (void *)NULL, &inp->inp_route, - ((so->so_options & SO_DONTROUTE) ? IP_ROUTETOIF : 0) - | IP_ALLOWBROADCAST | IP_RAWOUTPUT, (void *)NULL, - (void *)NULL); + error = ip_output(m, NULL, &inp->inp_route, + IP_ALLOWBROADCAST | IP_RAWOUTPUT, NULL, NULL); if (error == EACCES) /* translate pf(4) error for userland */ error = EHOSTUNREACH; } diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index aa8073993c8..6d490bc5700 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_output.c,v 1.257 2014/01/23 23:51:29 henning Exp $ */ +/* $OpenBSD: ip_output.c,v 1.258 2014/03/27 13:27:28 mpi Exp $ */ /* $NetBSD: ip_output.c,v 1.28 1996/02/13 23:43:07 christos Exp $ */ /* @@ -194,23 +194,7 @@ ip_output(struct mbuf *m0, struct mbuf *opt, struct route *ro, int flags, ro->ro_tableid = m->m_pkthdr.rdomain; } - /* - * If routing to interface only, short-circuit routing lookup. - */ - if (flags & IP_ROUTETOIF) { - if ((ia = ifatoia(ifa_ifwithdstaddr(sintosa(dst), - m->m_pkthdr.rdomain))) == 0 && - (ia = ifatoia(ifa_ifwithnet(sintosa(dst), - m->m_pkthdr.rdomain))) == 0) { - ipstat.ips_noroute++; - error = ENETUNREACH; - goto bad; - } - - ifp = ia->ia_ifp; - mtu = ifp->if_mtu; - ip->ip_ttl = 1; - } else if ((IN_MULTICAST(ip->ip_dst.s_addr) || + if ((IN_MULTICAST(ip->ip_dst.s_addr) || (ip->ip_dst.s_addr == INADDR_BROADCAST)) && imo != NULL && imo->imo_multicast_ifp != NULL) { ifp = imo->imo_multicast_ifp; @@ -360,23 +344,7 @@ reroute: ro->ro_tableid = m->m_pkthdr.rdomain; } - /* - * If routing to interface only, short-circuit routing lookup. - */ - if (flags & IP_ROUTETOIF) { - if ((ia = ifatoia(ifa_ifwithdstaddr(sintosa(dst), - m->m_pkthdr.rdomain))) == 0 && - (ia = ifatoia(ifa_ifwithnet(sintosa(dst), - m->m_pkthdr.rdomain))) == 0) { - ipstat.ips_noroute++; - error = ENETUNREACH; - goto bad; - } - - ifp = ia->ia_ifp; - mtu = ifp->if_mtu; - ip->ip_ttl = 1; - } else if ((IN_MULTICAST(ip->ip_dst.s_addr) || + if ((IN_MULTICAST(ip->ip_dst.s_addr) || (ip->ip_dst.s_addr == INADDR_BROADCAST)) && imo != NULL && imo->imo_multicast_ifp != NULL) { ifp = imo->imo_multicast_ifp; @@ -752,7 +720,7 @@ sendit: ipstat.ips_fragmented++; done: - if (ro == &iproute && (flags & IP_ROUTETOIF) == 0 && ro->ro_rt) + if (ro == &iproute && ro->ro_rt) RTFREE(ro->ro_rt); return (error); bad: diff --git a/sys/netinet/ip_var.h b/sys/netinet/ip_var.h index 9507eb0905c..8abdd451a27 100644 --- a/sys/netinet/ip_var.h +++ b/sys/netinet/ip_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_var.h,v 1.52 2014/03/27 10:44:23 mpi Exp $ */ +/* $OpenBSD: ip_var.h,v 1.53 2014/03/27 13:27:28 mpi Exp $ */ /* $NetBSD: ip_var.h,v 1.16 1996/02/13 23:43:20 christos Exp $ */ /* @@ -140,7 +140,6 @@ struct ipq { /* flags passed to ip_output as last parameter */ #define IP_FORWARDING 0x1 /* most of ip header exists */ #define IP_RAWOUTPUT 0x2 /* raw ip header exists */ -#define IP_ROUTETOIF SO_DONTROUTE /* bypass routing tables */ #define IP_ALLOWBROADCAST SO_BROADCAST /* can send broadcast packets */ #define IP_MTUDISC 0x0800 /* pmtu discovery, set DF */ #define IP_ROUTETOETHER 0x1000 /* ether addresses given */ diff --git a/sys/netinet/raw_ip.c b/sys/netinet/raw_ip.c index 43680eba733..3b6cbe590f7 100644 --- a/sys/netinet/raw_ip.c +++ b/sys/netinet/raw_ip.c @@ -1,4 +1,4 @@ -/* $OpenBSD: raw_ip.c,v 1.67 2013/12/20 02:04:08 krw Exp $ */ +/* $OpenBSD: raw_ip.c,v 1.68 2014/03/27 13:27:28 mpi Exp $ */ /* $NetBSD: raw_ip.c,v 1.25 1996/02/18 18:58:33 christos Exp $ */ /* @@ -218,7 +218,7 @@ rip_output(struct mbuf *m, ...) va_end(ap); inp = sotoinpcb(so); - flags = (so->so_options & SO_DONTROUTE) | IP_ALLOWBROADCAST; + flags = IP_ALLOWBROADCAST; /* * If the user handed us a complete IP packet, use it. diff --git a/sys/netinet/tcp_output.c b/sys/netinet/tcp_output.c index 4ef6806d37d..d0633905556 100644 --- a/sys/netinet/tcp_output.c +++ b/sys/netinet/tcp_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_output.c,v 1.101 2013/10/24 11:31:43 mpi Exp $ */ +/* $OpenBSD: tcp_output.c,v 1.102 2014/03/27 13:27:28 mpi Exp $ */ /* $NetBSD: tcp_output.c,v 1.16 1997/06/03 16:17:09 kml Exp $ */ /* @@ -1076,9 +1076,7 @@ send: } error = ip_output(m, tp->t_inpcb->inp_options, &tp->t_inpcb->inp_route, - (ip_mtudisc ? IP_MTUDISC : 0) | - (so->so_options & SO_DONTROUTE), - (void *)NULL, tp->t_inpcb); + (ip_mtudisc ? IP_MTUDISC : 0), NULL, tp->t_inpcb); break; #endif /* INET */ #ifdef INET6 @@ -1099,8 +1097,7 @@ send: } error = ip6_output(m, tp->t_inpcb->inp_outputopts6, &tp->t_inpcb->inp_route6, - (so->so_options & SO_DONTROUTE), NULL, NULL, - tp->t_inpcb); + 0, NULL, NULL, tp->t_inpcb); break; #endif /* INET6 */ } diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index 7779fdaae3e..b85330eeec0 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: udp_usrreq.c,v 1.174 2014/01/24 18:54:58 henning Exp $ */ +/* $OpenBSD: udp_usrreq.c,v 1.175 2014/03/27 13:27:28 mpi Exp $ */ /* $NetBSD: udp_usrreq.c,v 1.28 1996/03/16 23:54:03 christos Exp $ */ /* @@ -1090,8 +1090,8 @@ udp_output(struct mbuf *m, ...) m->m_pkthdr.rdomain = inp->inp_rtableid; error = ip_output(m, inp->inp_options, &inp->inp_route, - (inp->inp_socket->so_options & (SO_DONTROUTE | SO_BROADCAST)) - |IP_IPSECFLOW, inp->inp_moptions, inp, ipsecflowinfo); + (inp->inp_socket->so_options & SO_BROADCAST) | IP_IPSECFLOW, + inp->inp_moptions, inp, ipsecflowinfo); if (error == EACCES) /* translate pf(4) error for userland */ error = EHOSTUNREACH; diff --git a/sys/netinet6/in6_src.c b/sys/netinet6/in6_src.c index 95c12b4e688..5ab4fab4bfe 100644 --- a/sys/netinet6/in6_src.c +++ b/sys/netinet6/in6_src.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in6_src.c,v 1.38 2014/03/12 14:15:09 mpi Exp $ */ +/* $OpenBSD: in6_src.c,v 1.39 2014/03/27 13:27:28 mpi Exp $ */ /* $KAME: in6_src.c,v 1.36 2001/02/06 04:08:17 itojun Exp $ */ /* @@ -286,25 +286,6 @@ in6_selectsrc(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts, if (ia6 == 0) /* xxx scope error ?*/ ia6 = ifatoia6(ro->ro_rt->rt_ifa); } -#if 0 - /* - * xxx The followings are necessary? (kazu) - * I don't think so. - * It's for SO_DONTROUTE option in IPv4.(jinmei) - */ - if (ia6 == 0) { - struct sockaddr_in6 sin6 = {sizeof(sin6), AF_INET6, 0}; - - sin6->sin6_addr = *dst; - - ia6 = ifatoia6(ifa_ifwithdstaddr(sin6tosa(&sin6))); - if (ia6 == 0) - ia6 = ifatoia6(ifa_ifwithnet(sin6tosa(&sin6))); - if (ia6 == 0) - return (0); - return (&ia6->ia_addr.sin6_addr); - } -#endif /* 0 */ if (ia6 == 0) { *errorp = EHOSTUNREACH; /* no route */ return (0); diff --git a/sys/netinet6/ip6_divert.c b/sys/netinet6/ip6_divert.c index d9dc3c0dcec..3d4bdbfab63 100644 --- a/sys/netinet6/ip6_divert.c +++ b/sys/netinet6/ip6_divert.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip6_divert.c,v 1.17 2013/12/20 02:04:09 krw Exp $ */ +/* $OpenBSD: ip6_divert.c,v 1.18 2014/03/27 13:27:28 mpi Exp $ */ /* * Copyright (c) 2009 Michele Marchetto <michele@openbsd.org> @@ -180,8 +180,7 @@ divert6_output(struct mbuf *m, ...) splx(s); } else { error = ip6_output(m, NULL, &inp->inp_route6, - ((so->so_options & SO_DONTROUTE) ? IP_ROUTETOIF : 0) - | IP_ALLOWBROADCAST | IP_RAWOUTPUT, NULL, NULL, NULL); + IP_ALLOWBROADCAST | IP_RAWOUTPUT, NULL, NULL, NULL); } div6stat.divs_opackets++; |