Module Name: src Committed By: ryo Date: Mon Dec 11 05:47:18 UTC 2017
Modified Files: src/sys/netinet: ip_output.c ip_var.h raw_ip.c udp_usrreq.c src/tests/net/net: t_pktinfo_send.c Log Message: As is the case with IPV6_PKTINFO, IP_PKTINFO can be sent without EADDRINUSE even if the UDP address:port in use is specified. To generate a diff of this commit: cvs rdiff -u -r1.285 -r1.286 src/sys/netinet/ip_output.c cvs rdiff -u -r1.120 -r1.121 src/sys/netinet/ip_var.h cvs rdiff -u -r1.166 -r1.167 src/sys/netinet/raw_ip.c cvs rdiff -u -r1.235 -r1.236 src/sys/netinet/udp_usrreq.c cvs rdiff -u -r1.1 -r1.2 src/tests/net/net/t_pktinfo_send.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/netinet/ip_output.c diff -u src/sys/netinet/ip_output.c:1.285 src/sys/netinet/ip_output.c:1.286 --- src/sys/netinet/ip_output.c:1.285 Fri Nov 17 07:37:12 2017 +++ src/sys/netinet/ip_output.c Mon Dec 11 05:47:18 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ip_output.c,v 1.285 2017/11/17 07:37:12 ozaki-r Exp $ */ +/* $NetBSD: ip_output.c,v 1.286 2017/12/11 05:47:18 ryo Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -91,7 +91,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.285 2017/11/17 07:37:12 ozaki-r Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ip_output.c,v 1.286 2017/12/11 05:47:18 ryo Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -1411,9 +1411,8 @@ ip_pktinfo_prepare(const struct in_pktin */ int ip_setpktopts(struct mbuf *control, struct ip_pktopts *pktopts, int *flags, - struct inpcb *inp, kauth_cred_t cred, int uproto) + struct inpcb *inp, kauth_cred_t cred) { - struct inpcb *xinp; struct cmsghdr *cm; struct in_pktinfo *pktinfo; int error; @@ -1453,16 +1452,6 @@ ip_setpktopts(struct mbuf *control, stru cred); if (error != 0) return error; - - if ((uproto == IPPROTO_UDP) && - !in_nullhost(pktopts->ippo_laddr.sin_addr)) { - /* Checking laddr:port already in use? */ - xinp = in_pcblookup_bind(&udbtable, - pktopts->ippo_laddr.sin_addr, - inp->inp_lport); - if ((xinp != NULL) && (xinp != inp)) - return EADDRINUSE; - } break; default: return ENOPROTOOPT; Index: src/sys/netinet/ip_var.h diff -u src/sys/netinet/ip_var.h:1.120 src/sys/netinet/ip_var.h:1.121 --- src/sys/netinet/ip_var.h:1.120 Thu Aug 10 04:31:58 2017 +++ src/sys/netinet/ip_var.h Mon Dec 11 05:47:18 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: ip_var.h,v 1.120 2017/08/10 04:31:58 ryo Exp $ */ +/* $NetBSD: ip_var.h,v 1.121 2017/12/11 05:47:18 ryo Exp $ */ /* * Copyright (c) 1982, 1986, 1993 @@ -215,7 +215,7 @@ void in_init(void); int ip_ctloutput(int, struct socket *, struct sockopt *); int ip_setpktopts(struct mbuf *, struct ip_pktopts *, int *, - struct inpcb *, kauth_cred_t, int); + struct inpcb *, kauth_cred_t); void ip_drain(void); void ip_drainstub(void); void ip_freemoptions(struct ip_moptions *); Index: src/sys/netinet/raw_ip.c diff -u src/sys/netinet/raw_ip.c:1.166 src/sys/netinet/raw_ip.c:1.167 --- src/sys/netinet/raw_ip.c:1.166 Thu Aug 10 04:31:58 2017 +++ src/sys/netinet/raw_ip.c Mon Dec 11 05:47:18 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: raw_ip.c,v 1.166 2017/08/10 04:31:58 ryo Exp $ */ +/* $NetBSD: raw_ip.c,v 1.167 2017/12/11 05:47:18 ryo Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -65,7 +65,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: raw_ip.c,v 1.166 2017/08/10 04:31:58 ryo Exp $"); +__KERNEL_RCSID(0, "$NetBSD: raw_ip.c,v 1.167 2017/12/11 05:47:18 ryo Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -322,8 +322,7 @@ rip_output(struct mbuf *m, struct inpcb /* Setup IP outgoing packet options */ memset(&pktopts, 0, sizeof(pktopts)); - error = ip_setpktopts(control, &pktopts, &flags, inp, cred, - IPPROTO_RAW); + error = ip_setpktopts(control, &pktopts, &flags, inp, cred); if (control != NULL) m_freem(control); if (error != 0) Index: src/sys/netinet/udp_usrreq.c diff -u src/sys/netinet/udp_usrreq.c:1.235 src/sys/netinet/udp_usrreq.c:1.236 --- src/sys/netinet/udp_usrreq.c:1.235 Thu Aug 10 04:31:58 2017 +++ src/sys/netinet/udp_usrreq.c Mon Dec 11 05:47:18 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: udp_usrreq.c,v 1.235 2017/08/10 04:31:58 ryo Exp $ */ +/* $NetBSD: udp_usrreq.c,v 1.236 2017/12/11 05:47:18 ryo Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -66,7 +66,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: udp_usrreq.c,v 1.235 2017/08/10 04:31:58 ryo Exp $"); +__KERNEL_RCSID(0, "$NetBSD: udp_usrreq.c,v 1.236 2017/12/11 05:47:18 ryo Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -804,8 +804,7 @@ udp_output(struct mbuf *m, struct inpcb /* Setup IP outgoing packet options */ memset(&pktopts, 0, sizeof(pktopts)); - error = ip_setpktopts(control, &pktopts, &flags, inp, cred, - IPPROTO_UDP); + error = ip_setpktopts(control, &pktopts, &flags, inp, cred); if (error != 0) goto release; Index: src/tests/net/net/t_pktinfo_send.c diff -u src/tests/net/net/t_pktinfo_send.c:1.1 src/tests/net/net/t_pktinfo_send.c:1.2 --- src/tests/net/net/t_pktinfo_send.c:1.1 Thu Aug 10 04:31:58 2017 +++ src/tests/net/net/t_pktinfo_send.c Mon Dec 11 05:47:18 2017 @@ -1,4 +1,4 @@ -/* $NetBSD: t_pktinfo_send.c,v 1.1 2017/08/10 04:31:58 ryo Exp $ */ +/* $NetBSD: t_pktinfo_send.c,v 1.2 2017/12/11 05:47:18 ryo Exp $ */ /*- * Copyright (c) 2017 Internet Initiative Japan Inc. @@ -27,7 +27,7 @@ * POSSIBILITY OF SUCH DAMAGE. */ #include <sys/cdefs.h> -__RCSID("$NetBSD: t_pktinfo_send.c,v 1.1 2017/08/10 04:31:58 ryo Exp $"); +__RCSID("$NetBSD: t_pktinfo_send.c,v 1.2 2017/12/11 05:47:18 ryo Exp $"); #include <sys/types.h> #include <sys/socket.h> @@ -360,22 +360,8 @@ ATF_TC_BODY(pktinfo_send_bindother, tc) RL(client = rump_sys_socket(AF_INET, SOCK_DGRAM, 0)); RL(rv = sock_bind(client, "127.0.0.3", CLIENTPORT)); - /* - * other socket is bound "127.0.0.2:12345". - * client socket is bound "127.0.0.3:12345". - * client socket sendto w/IP_PKTINFO "127.0.0.2", - * this should be error as EADDRINUSE. - */ - rv = sendto_pktinfo(client, message, strlen(message), 0, - "127.0.0.2", "127.0.0.1", SERVERPORT); - - ATF_REQUIRE_MSG(rv == -1, - "sendmsg with in-use address:port should be error," - " but success"); - ATF_REQUIRE_MSG(errno == EADDRINUSE, - "sendmsg with in-use address:port should be EADDRINUSE," - " but got %s", strerror(errno)); - + /* do sendmsg w/IP_PKTINFO tests */ + do_send_pktinfo_tests(client, server, message, strlen(message)); rump_sys_close(client); rump_sys_close(server);