Source-Changes-HG archive

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

[src/trunk]: src/sys/netinet6 disallow bind(2) with IPv4 mapped address for n...



details:   https://anonhg.NetBSD.org/src/rev/bbe340020499
branches:  trunk
changeset: 486804:bbe340020499
user:      itojun <itojun%NetBSD.org@localhost>
date:      Mon May 29 00:03:18 2000 +0000

description:
disallow bind(2) with IPv4 mapped address for now.  port number check is
insufficient at this moment and we can bind(2) two sockets listen on same
port number.

for real fix, we need to check inpcb table with in6pcb.  we can't
find inpcb chain from particular in6pcb chain (like finding tcbtable from tcb6)
luckily RFC2553 does not talk about bind(2) behavior for IPv4 mapped.
IPv4 mapped brings in too much complexities...

diffstat:

 sys/netinet6/in6_pcb.c |  12 ++++++++++--
 sys/netinet6/raw_ip6.c |  14 ++++++++++++--
 2 files changed, 22 insertions(+), 4 deletions(-)

diffs (54 lines):

diff -r 836c7d64db67 -r bbe340020499 sys/netinet6/in6_pcb.c
--- a/sys/netinet6/in6_pcb.c    Sun May 28 23:44:30 2000 +0000
+++ b/sys/netinet6/in6_pcb.c    Mon May 29 00:03:18 2000 +0000
@@ -1,5 +1,5 @@
-/*     $NetBSD: in6_pcb.c,v 1.21 2000/03/02 07:15:39 itojun Exp $      */
-/*     $KAME: in6_pcb.c,v 1.35 2000/03/02 06:32:18 itojun Exp $        */
+/*     $NetBSD: in6_pcb.c,v 1.22 2000/05/29 00:03:18 itojun Exp $      */
+/*     $KAME: in6_pcb.c,v 1.43 2000/05/28 23:25:07 itojun Exp $        */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -164,6 +164,14 @@
                        return(EAFNOSUPPORT);
 
                /*
+                * since we do not check port number duplicate with IPv4 space,
+                * we reject it at this moment.  If we leave it, we make normal
+                * user to hijack port number from other users.
+                */
+               if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr))
+                       return(EADDRNOTAVAIL);
+
+               /*
                 * If the scope of the destination is link-local, embed the
                 * interface index in the address.
                 */
diff -r 836c7d64db67 -r bbe340020499 sys/netinet6/raw_ip6.c
--- a/sys/netinet6/raw_ip6.c    Sun May 28 23:44:30 2000 +0000
+++ b/sys/netinet6/raw_ip6.c    Mon May 29 00:03:18 2000 +0000
@@ -1,5 +1,5 @@
-/*     $NetBSD: raw_ip6.c,v 1.22 2000/03/01 12:49:50 itojun Exp $      */
-/*     $KAME: raw_ip6.c,v 1.24 2000/02/28 15:44:12 itojun Exp $        */
+/*     $NetBSD: raw_ip6.c,v 1.23 2000/05/29 00:03:18 itojun Exp $      */
+/*     $KAME: raw_ip6.c,v 1.28 2000/05/28 23:25:07 itojun Exp $        */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -629,6 +629,16 @@
                        error = EINVAL;
                        break;
                }
+
+               /*
+                * we don't support mapped address here, it would confuse
+                * users so reject it
+                */
+               if (IN6_IS_ADDR_V4MAPPED(&addr->sin6_addr)) {
+                       error = EADDRNOTAVAIL;
+                       break;
+               }
+
                if ((ifnet.tqh_first == 0) ||
                   (addr->sin6_family != AF_INET6) ||
                   (!IN6_IS_ADDR_UNSPECIFIED(&addr->sin6_addr) &&



Home | Main Index | Thread Index | Old Index