Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src As is the case with IPV6_PKTINFO, IP_PKTINFO can be sent wit...



details:   https://anonhg.NetBSD.org/src/rev/a7a15e067666
branches:  trunk
changeset: 358098:a7a15e067666
user:      ryo <ryo%NetBSD.org@localhost>
date:      Mon Dec 11 05:47:18 2017 +0000

description:
As is the case with IPV6_PKTINFO, IP_PKTINFO can be sent without EADDRINUSE
even if the UDP address:port in use is specified.

diffstat:

 sys/netinet/ip_output.c        |  17 +++--------------
 sys/netinet/ip_var.h           |   4 ++--
 sys/netinet/raw_ip.c           |   7 +++----
 sys/netinet/udp_usrreq.c       |   7 +++----
 tests/net/net/t_pktinfo_send.c |  22 ++++------------------
 5 files changed, 15 insertions(+), 42 deletions(-)

diffs (163 lines):

diff -r e4c95167d620 -r a7a15e067666 sys/netinet/ip_output.c
--- a/sys/netinet/ip_output.c   Mon Dec 11 03:29:20 2017 +0000
+++ b/sys/netinet/ip_output.c   Mon Dec 11 05:47:18 2017 +0000
@@ -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 @@
  */
 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 @@
                            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;
diff -r e4c95167d620 -r a7a15e067666 sys/netinet/ip_var.h
--- a/sys/netinet/ip_var.h      Mon Dec 11 03:29:20 2017 +0000
+++ b/sys/netinet/ip_var.h      Mon Dec 11 05:47:18 2017 +0000
@@ -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 @@
 
 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 *);
diff -r e4c95167d620 -r a7a15e067666 sys/netinet/raw_ip.c
--- a/sys/netinet/raw_ip.c      Mon Dec 11 03:29:20 2017 +0000
+++ b/sys/netinet/raw_ip.c      Mon Dec 11 05:47:18 2017 +0000
@@ -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 @@
 
        /* 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)
diff -r e4c95167d620 -r a7a15e067666 sys/netinet/udp_usrreq.c
--- a/sys/netinet/udp_usrreq.c  Mon Dec 11 03:29:20 2017 +0000
+++ b/sys/netinet/udp_usrreq.c  Mon Dec 11 05:47:18 2017 +0000
@@ -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 @@
 
        /* 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;
 
diff -r e4c95167d620 -r a7a15e067666 tests/net/net/t_pktinfo_send.c
--- a/tests/net/net/t_pktinfo_send.c    Mon Dec 11 03:29:20 2017 +0000
+++ b/tests/net/net/t_pktinfo_send.c    Mon Dec 11 05:47:18 2017 +0000
@@ -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 @@
        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);



Home | Main Index | Thread Index | Old Index