Source-Changes-HG archive

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

[src/trunk]: src/sys/netinet6 correct manipulation of link-local scoped addre...



details:   https://anonhg.NetBSD.org/src/rev/20f815298c14
branches:  trunk
changeset: 486350:20f815298c14
user:      itojun <itojun%NetBSD.org@localhost>
date:      Fri May 19 20:09:26 2000 +0000

description:
correct manipulation of link-local scoped address on loopback.
now "telnet fe80::1%lo0" should work again.
(we have another bug near here - will attack it soon)

diffstat:

 sys/netinet6/ip6_forward.c |   6 ++--
 sys/netinet6/ip6_input.c   |  62 +++++++++++++++------------------------------
 sys/netinet6/ip6_output.c  |   6 ++--
 3 files changed, 27 insertions(+), 47 deletions(-)

diffs (152 lines):

diff -r 8004a8127c93 -r 20f815298c14 sys/netinet6/ip6_forward.c
--- a/sys/netinet6/ip6_forward.c        Fri May 19 18:57:48 2000 +0000
+++ b/sys/netinet6/ip6_forward.c        Fri May 19 20:09:26 2000 +0000
@@ -1,5 +1,5 @@
-/*     $NetBSD: ip6_forward.c,v 1.10 2000/05/19 01:40:18 itojun Exp $  */
-/*     $KAME: ip6_forward.c,v 1.35 2000/05/18 16:31:27 itojun Exp $    */
+/*     $NetBSD: ip6_forward.c,v 1.11 2000/05/19 20:09:26 itojun Exp $  */
+/*     $KAME: ip6_forward.c,v 1.36 2000/05/19 19:10:06 itojun Exp $    */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -459,7 +459,7 @@
        else
                origifp = rt->rt_ifp;
 #ifndef FAKE_LOOPBACK_IF
-       if ((rt->rt_ifp->if_flags & IFF_LOOPBACK) != 0)
+       if ((rt->rt_ifp->if_flags & IFF_LOOPBACK) == 0)
 #else
        if (1)
 #endif
diff -r 8004a8127c93 -r 20f815298c14 sys/netinet6/ip6_input.c
--- a/sys/netinet6/ip6_input.c  Fri May 19 18:57:48 2000 +0000
+++ b/sys/netinet6/ip6_input.c  Fri May 19 20:09:26 2000 +0000
@@ -1,10 +1,10 @@
-/*     $NetBSD: ip6_input.c,v 1.20 2000/04/12 10:36:45 itojun Exp $    */
-/*     $KAME: ip6_input.c,v 1.72 2000/03/21 09:23:19 itojun Exp $      */
+/*     $NetBSD: ip6_input.c,v 1.21 2000/05/19 20:09:27 itojun Exp $    */
+/*     $KAME: ip6_input.c,v 1.89 2000/05/19 19:59:05 itojun Exp $      */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
  * All rights reserved.
- * 
+ *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
  * are met:
@@ -16,7 +16,7 @@
  * 3. Neither the name of the project nor the names of its contributors
  *    may be used to endorse or promote products derived from this software
  *    without specific prior written permission.
- * 
+ *
  * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -146,13 +146,6 @@
 
 static int ip6_hopopts_input __P((u_int32_t *, u_int32_t *, struct mbuf **, int *));
 
-#ifdef PTR
-extern int             ip6_protocol_tr;
-
-int    ptr_in6         __P((struct mbuf *, struct mbuf **));
-extern void ip_forward __P((struct mbuf *, int));
-#endif
-
 /*
  * IP6 initialization: fill in IP6 protocol switch table.
  * All protocols not implemented in kernel go to raw IP6 protocol handler.
@@ -196,7 +189,7 @@
 {
        /*
         * to route local address of p2p link to loopback,
-        * assign loopback address first. 
+        * assign loopback address first.
         */
        in6_ifattach(&loif[0], NULL);
 
@@ -395,13 +388,12 @@
                }
        }
 
-       if (m->m_pkthdr.rcvif->if_flags & IFF_LOOPBACK) {
-               if (IN6_IS_ADDR_LINKLOCAL(&ip6->ip6_dst)) {
-                       ours = 1;
-                       deliverifp = m->m_pkthdr.rcvif;
-                       goto hbhcheck;
-               }
-       } else {
+#ifndef FAKE_LOOPBACK_IF
+       if ((m->m_pkthdr.rcvif->if_flags & IFF_LOOPBACK) == 0)
+#else
+       if (1)
+#endif
+       {
                if (IN6_IS_SCOPE_LINKLOCAL(&ip6->ip6_src))
                        ip6->ip6_src.s6_addr16[1]
                                = htons(m->m_pkthdr.rcvif->if_index);
@@ -410,32 +402,20 @@
                                = htons(m->m_pkthdr.rcvif->if_index);
        }
 
-#ifdef PTR
        /*
-        *
+        * XXX we need this since we do not have "goto ours" hack route
+        * for some of our ifaddrs on loopback interface.
+        * we should correct it by changing in6_ifattach to install
+        * "goto ours" hack route.
         */
-       if (ip6_protocol_tr)
-       {
-           struct mbuf *m1 = NULL;
-
-           switch (ptr_in6(m, &m1))
-           {
-             case IPPROTO_IP:                                  goto mcastcheck;
-             case IPPROTO_IPV4:        ip_forward(m1, 0);      break;
-             case IPPROTO_IPV6:        ip6_forward(m1, 0);     break;
-             case IPPROTO_MAX:                 /* discard this packet  */
-             default:
-           }
-
-           if (m != m1)
-               m_freem(m);
-
-           return;
+       if ((m->m_pkthdr.rcvif->if_flags & IFF_LOOPBACK) != 0) {
+               if (IN6_IS_ADDR_LINKLOCAL(&ip6->ip6_dst)) {
+                       ours = 1;
+                       deliverifp = m->m_pkthdr.rcvif;
+                       goto hbhcheck;
+               }
        }
 
-  mcastcheck:
-#endif
-
        /*
         * Multicast check
         */
diff -r 8004a8127c93 -r 20f815298c14 sys/netinet6/ip6_output.c
--- a/sys/netinet6/ip6_output.c Fri May 19 18:57:48 2000 +0000
+++ b/sys/netinet6/ip6_output.c Fri May 19 20:09:26 2000 +0000
@@ -1,5 +1,5 @@
-/*     $NetBSD: ip6_output.c,v 1.20 2000/05/19 04:34:43 thorpej Exp $  */
-/*     $KAME: ip6_output.c,v 1.102 2000/05/17 15:31:56 itojun Exp $    */
+/*     $NetBSD: ip6_output.c,v 1.21 2000/05/19 20:09:27 itojun Exp $   */
+/*     $KAME: ip6_output.c,v 1.104 2000/05/19 19:10:07 itojun Exp $    */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -780,7 +780,7 @@
        else
                origifp = ifp;
 #ifndef FAKE_LOOPBACK_IF
-       if ((ifp->if_flags & IFF_LOOPBACK) != 0)
+       if ((ifp->if_flags & IFF_LOOPBACK) == 0)
 #else
        if (1)
 #endif



Home | Main Index | Thread Index | Old Index