diff options
author | Jun-ichiro itojun Hagino <itojun@cvs.openbsd.org> | 2000-10-11 09:14:16 +0000 |
---|---|---|
committer | Jun-ichiro itojun Hagino <itojun@cvs.openbsd.org> | 2000-10-11 09:14:16 +0000 |
commit | dd485bff222b7e2489457ed806d4fe29619eb415 (patch) | |
tree | 65a3df9145c158867a0eb624e4900c3519fc5b6d /sys | |
parent | 60d99b8926b833934cb89683b494bd5532cda34c (diff) |
nuke inp_flags bits for controlling IPv4 mapped address.
we don't support IPv4 mapped address,
and there are inconsistent bit manipulation code so it's safer to nuke them.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/netinet/in_pcb.c | 31 | ||||
-rw-r--r-- | sys/netinet/in_pcb.h | 8 | ||||
-rw-r--r-- | sys/netinet/tcp_input.c | 12 | ||||
-rw-r--r-- | sys/netinet/udp_usrreq.c | 31 | ||||
-rw-r--r-- | sys/netinet6/in6_pcb.c | 40 | ||||
-rw-r--r-- | sys/netinet6/ip6_output.c | 13 |
6 files changed, 40 insertions, 95 deletions
diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index b8903ab55ea..995034f9e2c 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in_pcb.c,v 1.47 2000/10/10 15:16:01 provos Exp $ */ +/* $OpenBSD: in_pcb.c,v 1.48 2000/10/11 09:14:10 itojun Exp $ */ /* $NetBSD: in_pcb.c,v 1.25 1996/02/13 23:41:53 christos Exp $ */ /* @@ -366,6 +366,8 @@ in_pcbconnect(v, nam) #ifdef INET6 if (sotopf(inp->inp_socket) == PF_INET6) return (in6_pcbconnect(inp, nam)); + if ((inp->inp_flags & INP_IPV6) != 0) + panic("IPv6 pcb passed into in_pcbconnect"); #endif /* INET6 */ if (nam->m_len != sizeof (*sin)) @@ -450,13 +452,7 @@ in_pcbconnect(v, nam) * address of that interface as our source address. */ if (IN_MULTICAST(sin->sin_addr.s_addr) && -#ifdef INET6 - inp->inp_moptions != NULL && - !(inp->inp_flags & INP_IPV6_MCAST)) -#else - inp->inp_moptions != NULL) -#endif - { + inp->inp_moptions != NULL) { struct ip_moptions *imo; struct ifnet *ifp; @@ -510,14 +506,16 @@ in_pcbdisconnect(v) { struct inpcb *inp = v; + switch (sotopf(inp->inp_socket)) { #ifdef INET6 - if (sotopf(inp->inp_socket) == PF_INET6) { + case PF_INET6: inp->inp_faddr6 = in6addr_any; - /* Disconnected AF_INET6 sockets cannot be "v4-mapped" */ - inp->inp_flags &= ~INP_IPV6_MAPPED; - } else + break; #endif + case PF_INET: inp->inp_faddr.s_addr = INADDR_ANY; + break; + } inp->inp_fport = 0; in_pcbrehash(inp); @@ -968,14 +966,7 @@ in_selectsrc(sin, ro, soopts, mopts, errorp) * interface has been set as a multicast option, use the * address of that interface as our source address. */ - if (IN_MULTICAST(sin->sin_addr.s_addr) && -#if 0 /*def INET6*/ - mopts != NULL && - !(inp->inp_flags & INP_IPV6_MCAST)) -#else - mopts != NULL) -#endif - { + if (IN_MULTICAST(sin->sin_addr.s_addr) && mopts != NULL) { struct ip_moptions *imo; struct ifnet *ifp; diff --git a/sys/netinet/in_pcb.h b/sys/netinet/in_pcb.h index dc81e411531..4ea34af3a4b 100644 --- a/sys/netinet/in_pcb.h +++ b/sys/netinet/in_pcb.h @@ -1,4 +1,4 @@ -/* $OpenBSD: in_pcb.h,v 1.28 2000/10/10 15:16:02 provos Exp $ */ +/* $OpenBSD: in_pcb.h,v 1.29 2000/10/11 09:14:11 itojun Exp $ */ /* $NetBSD: in_pcb.h,v 1.14 1996/02/13 23:42:00 christos Exp $ */ /* @@ -168,12 +168,6 @@ struct inpcbtable { * protocol at PRU_BIND, PRU_LISTEN, PRU_CONNECT, etc, or by in_pcb*(). */ #define INP_IPV6 0x100 /* sotopf(inp->inp_socket) == PF_INET6 */ -#define INP_IPV6_UNDEC 0x200 /* PCB is PF_INET6, but listens for V4/V6 */ -#define INP_IPV6_MAPPED 0x400 /* PF_INET6 PCB which is connected to - * an IPv4 host, or is bound to - * an IPv4 address (specified with - * the mapped form of v6 addresses) */ -#define INP_IPV6_MCAST 0x800 /* Set if inp_moptions points to ipv6 ones */ #if 1 /*KAME*/ /* diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index 14c135f7ee5..336361c700b 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_input.c,v 1.77 2000/09/25 09:41:02 provos Exp $ */ +/* $OpenBSD: tcp_input.c,v 1.78 2000/10/11 09:14:11 itojun Exp $ */ /* $NetBSD: tcp_input.c,v 1.23 1996/02/13 23:43:44 christos Exp $ */ /* @@ -120,9 +120,8 @@ extern u_long sb_max; #ifdef INET6 #define ND6_HINT(tp) \ do { \ - if (tp && tp->t_inpcb && (tp->t_inpcb->inp_flags & INP_IPV6) \ - && !(tp->t_inpcb->inp_flags & INP_IPV6_MAPPED) \ - && tp->t_inpcb->inp_route6.ro_rt) { \ + if (tp && tp->t_inpcb && (tp->t_inpcb->inp_flags & INP_IPV6) && \ + tp->t_inpcb->inp_route6.ro_rt) { \ nd6_nud_hint(tp->t_inpcb->inp_route6.ro_rt, NULL, 0); \ } \ } while (0) @@ -762,10 +761,7 @@ findpcb: struct inpcb *oldinpcb = inp; inp = (struct inpcb *)so->so_pcb; - inp->inp_flags |= (flags & (INP_IPV6 | INP_IPV6_UNDEC - | INP_IPV6_MAPPED)); - if (flags & INP_IPV6_MAPPED) - panic("unexpected v4 mapped inpcb"); + inp->inp_flags |= (flags & INP_IPV6); if ((inp->inp_flags & INP_IPV6) != 0) { inp->inp_ipv6.ip6_hlim = oldinpcb->inp_ipv6.ip6_hlim; diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index ce62b662b5e..ceec64207ec 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: udp_usrreq.c,v 1.49 2000/09/22 17:51:46 angelos Exp $ */ +/* $OpenBSD: udp_usrreq.c,v 1.50 2000/10/11 09:14:13 itojun Exp $ */ /* $NetBSD: udp_usrreq.c,v 1.28 1996/03/16 23:54:03 christos Exp $ */ /* @@ -767,8 +767,7 @@ udp_output(m, va_alist) va_end(ap); #ifdef INET6 - v6packet = ((inp->inp_flags & INP_IPV6) && - !(inp->inp_flags & INP_IPV6_MAPPED)); + v6packet = (inp->inp_flags & INP_IPV6); #endif #ifdef INET6 @@ -789,8 +788,7 @@ udp_output(m, va_alist) /* * Save current PCB flags because they may change during - * temporary connection, particularly the INP_IPV6_UNDEC - * flag. + * temporary connection. */ pcbflags = inp->inp_flags; @@ -925,8 +923,7 @@ udp_output(m, va_alist) error = ip6_output(m, inp->inp_outputopts6, &inp->inp_route6, inp->inp_socket->so_options & SO_DONTROUTE, - (inp->inp_flags & INP_IPV6_MCAST)?inp->inp_moptions6:NULL, - NULL); + inp->inp_moptions6, NULL); } else #endif /* INET6 */ { @@ -972,20 +969,10 @@ udp_output(m, va_alist) } udpstat.udps_opackets++; -#ifdef INET6 - if (inp->inp_flags & INP_IPV6_MCAST) { - error = ip_output(m, inp->inp_options, &inp->inp_route, - inp->inp_socket->so_options & - (SO_DONTROUTE | SO_BROADCAST), - NULL, NULL, inp->inp_socket); - } else -#endif /* INET6 */ - { - error = ip_output(m, inp->inp_options, &inp->inp_route, - inp->inp_socket->so_options & - (SO_DONTROUTE | SO_BROADCAST), - inp->inp_moptions, inp, NULL); - } + error = ip_output(m, inp->inp_options, &inp->inp_route, + inp->inp_socket->so_options & + (SO_DONTROUTE | SO_BROADCAST), + inp->inp_moptions, inp, NULL); } bail: @@ -1153,10 +1140,12 @@ udp_usrreq(so, req, m, addr, control) } } else #endif /* INET6 */ + { if (inp->inp_faddr.s_addr == INADDR_ANY) { error = ENOTCONN; break; } + } s = splsoftnet(); in_pcbdisconnect(inp); diff --git a/sys/netinet6/in6_pcb.c b/sys/netinet6/in6_pcb.c index 7283e21ba4a..eeecdc6ea72 100644 --- a/sys/netinet6/in6_pcb.c +++ b/sys/netinet6/in6_pcb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in6_pcb.c,v 1.19 2000/06/18 18:07:49 itojun Exp $ */ +/* $OpenBSD: in6_pcb.c,v 1.20 2000/10/11 09:14:14 itojun Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -189,6 +189,10 @@ in6_pcbbind(inp, nam) lport = sin6->sin6_port; + /* reject IPv4 mapped address, we have no support for it */ + if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) + return EADDRNOTAVAIL; + if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr)) { /* * Treat SO_REUSEADDR as SO_REUSEPORT for multicast; @@ -199,7 +203,9 @@ in6_pcbbind(inp, nam) */ if (so->so_options & SO_REUSEADDR) reuseport = SO_REUSEADDR | SO_REUSEPORT; - } else if (!IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr)) { + } +#if 0 /* we don't support it */ + else if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) { struct sockaddr_in sin; bzero(&sin, sizeof(sin)); @@ -222,6 +228,7 @@ in6_pcbbind(inp, nam) } } } +#endif if (lport) { struct inpcb *t; #if 0 /* we don't support IPv4 mapped address */ @@ -267,26 +274,6 @@ in6_pcbbind(inp, nam) inp->inp_ipv6.ip6_flow = htonl(0x60000000) | (sin6->sin6_flowinfo & htonl(0x0fffffff)); } - - /* - * Unroll first 2 compares of {UNSPEC,V4MAPPED}. - * Mark PF_INET6 socket as undecided (bound to port-only) or - * mapped (INET6 socket talking IPv4) here. I may need to move - * this code out of this if (nam) clause, and put it just before - * function return. - * - * Then again, the only time this function is called with NULL - * nam might be during a *_pcbconnect(), which then sets the - * local address ANYWAY. - */ - if (inp->inp_laddr6.s6_addr32[0] == 0 && - inp->inp_laddr6.s6_addr32[1] == 0) { - if (inp->inp_laddr6.s6_addr32[2] == ntohl(0xffff)) - inp->inp_flags |= INP_IPV6_MAPPED; - if (inp->inp_laddr6.s6_addr32[2] == 0 && - inp->inp_laddr6.s6_addr32[3] == 0) - inp->inp_flags |= INP_IPV6_UNDEC; - } } if (lport == 0) { @@ -439,6 +426,10 @@ in6_pcbconnect(inp, nam) if (sin6->sin6_port == 0) return(EADDRNOTAVAIL); + /* reject IPv4 mapped address, we have no support for it */ + if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) + return EADDRNOTAVAIL; + /* sanity check for mapped address case */ if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) { if (IN6_IS_ADDR_UNSPECIFIED(&inp->inp_laddr6)) @@ -520,11 +511,6 @@ in6_pcbconnect(inp, nam) * but if this line is missing, the garbage value remains. */ inp->inp_ipv6.ip6_flow = sin6->sin6_flowinfo; - /* configure NRL flags properly */ - if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) { - inp->inp_flags |= INP_IPV6_MAPPED; - inp->inp_flags &= ~INP_IPV6_UNDEC; - } in_pcbrehash(inp); return(0); } diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c index a4c55256d61..67a1c044532 100644 --- a/sys/netinet6/ip6_output.c +++ b/sys/netinet6/ip6_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip6_output.c,v 1.16 2000/09/19 03:23:16 angelos Exp $ */ +/* $OpenBSD: ip6_output.c,v 1.17 2000/10/11 09:14:15 itojun Exp $ */ /* $KAME: ip6_output.c,v 1.122 2000/08/19 02:12:02 jinmei Exp $ */ /* @@ -1388,17 +1388,6 @@ ip6_ctloutput(op, so, level, optname, mp) case IPV6_LEAVE_GROUP: error = ip6_setmoptions(optname, &inp->inp_moptions6, m); - /* - * XXX: setting the flag would be redundant - * except at the first time. Also, we - * actually don't have to reset the flag, - * since ip6_freemoptions() would simply - * return when the inp_moptions6 is NULL. - */ - if (inp->inp_moptions6) - inp->inp_flags |= INP_IPV6_MCAST; - else - inp->inp_flags &= ~INP_IPV6_MCAST; break; case IPV6_PORTRANGE: |