diff options
-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 | 29 | ||||
-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, 51 insertions, 125 deletions
diff --git a/lib/libc/sys/getsockopt.2 b/lib/libc/sys/getsockopt.2 index 556ae778d73..5cb646f5479 100644 --- a/lib/libc/sys/getsockopt.2 +++ b/lib/libc/sys/getsockopt.2 @@ -1,4 +1,4 @@ -.\" $OpenBSD: getsockopt.2,v 1.45 2014/03/28 08:33:51 sthen Exp $ +.\" $OpenBSD: getsockopt.2,v 1.46 2014/04/07 10:04:17 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 28 2014 $ +.Dd $Mdocdate: April 7 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 53c30094a68..93d2436bfe6 100644 --- a/lib/libc/sys/send.2 +++ b/lib/libc/sys/send.2 @@ -1,4 +1,4 @@ -.\" $OpenBSD: send.2,v 1.29 2014/03/28 08:33:51 sthen Exp $ +.\" $OpenBSD: send.2,v 1.30 2014/04/07 10:04:17 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: March 28 2014 $ +.Dd $Mdocdate: April 7 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 be4a6dd24ef..7f730e5c55e 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.51 2014/03/28 08:33:51 sthen Exp $ */ +/* $OpenBSD: linux_socket.c,v 1.52 2014/04/07 10:04:17 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 64239b2d8a7..f51c7c92780 100644 --- a/sys/kern/uipc_socket.c +++ b/sys/kern/uipc_socket.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uipc_socket.c,v 1.126 2014/03/30 21:54:48 guenther Exp $ */ +/* $OpenBSD: uipc_socket.c,v 1.127 2014/04/07 10:04:17 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 4784d8248b8..a17d6a24030 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in_pcb.c,v 1.151 2014/04/06 17:13:23 chrisz Exp $ */ +/* $OpenBSD: in_pcb.c,v 1.152 2014/04/07 10:04:17 mpi Exp $ */ /* $NetBSD: in_pcb.c,v 1.25 1996/02/13 23:41:53 christos Exp $ */ /* @@ -790,14 +790,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); @@ -814,26 +812,15 @@ in_selectsrc(struct sockaddr_in *sin, struct route *ro, int soopts, } /* * If we found a route, use the address - * corresponding to the outgoing interface - * unless it is the loopback (in case a route - * to our address on another net goes to loopback). + * corresponding to the outgoing interface. */ - if (ro->ro_rt && ro->ro_rt->rt_ifp && - !(ro->ro_rt->rt_ifp->if_flags & IFF_LOOPBACK)) + if (ro->ro_rt && ro->ro_rt->rt_ifp) 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); + ia = TAILQ_FIRST(&in_ifaddr); if (ia == 0) { *errorp = EADDRNOTAVAIL; - return NULL; + return (NULL); } } return (&ia->ia_addr); diff --git a/sys/netinet/ip_divert.c b/sys/netinet/ip_divert.c index 6ac2f0688e2..d29a925c6b7 100644 --- a/sys/netinet/ip_divert.c +++ b/sys/netinet/ip_divert.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_divert.c,v 1.18 2014/03/28 08:33:51 sthen Exp $ */ +/* $OpenBSD: ip_divert.c,v 1.19 2014/04/07 10:04:17 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 03a6a782028..3c5cb18912b 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_output.c,v 1.259 2014/03/28 08:33:51 sthen Exp $ */ +/* $OpenBSD: ip_output.c,v 1.260 2014/04/07 10:04:17 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 0d90a82969c..518eaa9adea 100644 --- a/sys/netinet/ip_var.h +++ b/sys/netinet/ip_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_var.h,v 1.54 2014/03/28 08:33:51 sthen Exp $ */ +/* $OpenBSD: ip_var.h,v 1.55 2014/04/07 10:04:17 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 91d22a49987..3f796d5f29e 100644 --- a/sys/netinet/raw_ip.c +++ b/sys/netinet/raw_ip.c @@ -1,4 +1,4 @@ -/* $OpenBSD: raw_ip.c,v 1.69 2014/03/28 08:33:51 sthen Exp $ */ +/* $OpenBSD: raw_ip.c,v 1.70 2014/04/07 10:04:17 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 7eec9e2d4c6..caacc1d8233 100644 --- a/sys/netinet/tcp_output.c +++ b/sys/netinet/tcp_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_output.c,v 1.103 2014/03/28 08:33:51 sthen Exp $ */ +/* $OpenBSD: tcp_output.c,v 1.104 2014/04/07 10:04:17 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 0426ae0cf4c..070f9486380 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: udp_usrreq.c,v 1.177 2014/04/06 17:40:36 chrisz Exp $ */ +/* $OpenBSD: udp_usrreq.c,v 1.178 2014/04/07 10:04:17 mpi Exp $ */ /* $NetBSD: udp_usrreq.c,v 1.28 1996/03/16 23:54:03 christos Exp $ */ /* @@ -1095,8 +1095,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 127471aa920..7ca882e4ab2 100644 --- a/sys/netinet6/in6_src.c +++ b/sys/netinet6/in6_src.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in6_src.c,v 1.40 2014/03/28 08:33:51 sthen Exp $ */ +/* $OpenBSD: in6_src.c,v 1.41 2014/04/07 10:04:17 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 46b555ae124..8d41b8485e4 100644 --- a/sys/netinet6/ip6_divert.c +++ b/sys/netinet6/ip6_divert.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip6_divert.c,v 1.19 2014/03/28 08:33:51 sthen Exp $ */ +/* $OpenBSD: ip6_divert.c,v 1.20 2014/04/07 10:04:17 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++; |