Source-Changes-HG archive

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

[src/netbsd-1-5]: src/usr.sbin/route6d pullup (approved by releng-1-5)



details:   https://anonhg.NetBSD.org/src/rev/1e52e076bb6a
branches:  netbsd-1-5
changeset: 488530:1e52e076bb6a
user:      itojun <itojun%NetBSD.org@localhost>
date:      Sat Jul 15 08:52:28 2000 +0000

description:
pullup (approved by releng-1-5)

sync with latest kame.
- remove obsolete non-advanced-api support.
- if a routing entry exists for aggregate prefix (-A), do not overwrite
  the routing entry (exit with error).

1.2 -> 1.3      basesrc/usr.sbin/route6d/Makefile
1.14 -> 1.15    basesrc/usr.sbin/route6d/route6d.c

diffstat:

 usr.sbin/route6d/Makefile  |   5 +--
 usr.sbin/route6d/route6d.c |  65 ++++++++++++++++-----------------------------
 2 files changed, 25 insertions(+), 45 deletions(-)

diffs (177 lines):

diff -r 66cc030e7e47 -r 1e52e076bb6a usr.sbin/route6d/Makefile
--- a/usr.sbin/route6d/Makefile Sat Jul 15 02:43:06 2000 +0000
+++ b/usr.sbin/route6d/Makefile Sat Jul 15 08:52:28 2000 +0000
@@ -1,9 +1,8 @@
-# $NetBSD: Makefile,v 1.2 2000/02/25 06:22:05 itojun Exp $
+# $NetBSD: Makefile,v 1.2.4.1 2000/07/15 08:52:28 itojun Exp $
 
 PROG=  route6d
 MAN=   route6d.8
 
-CPPFLAGS+=-Dss_len=__ss_len -Dss_family=__ss_family -DADVAPI -DINET6 \
-       -DHAVE_GETIFADDRS
+CPPFLAGS+=-Dss_len=__ss_len -Dss_family=__ss_family -DINET6 -DHAVE_GETIFADDRS
 
 .include <bsd.prog.mk>
diff -r 66cc030e7e47 -r 1e52e076bb6a usr.sbin/route6d/route6d.c
--- a/usr.sbin/route6d/route6d.c        Sat Jul 15 02:43:06 2000 +0000
+++ b/usr.sbin/route6d/route6d.c        Sat Jul 15 08:52:28 2000 +0000
@@ -1,5 +1,5 @@
-/*     $NetBSD: route6d.c,v 1.13.4.1 2000/07/13 01:12:18 thorpej Exp $ */
-/*     $KAME: route6d.c,v 1.30 2000/06/04 06:48:03 itojun Exp $        */
+/*     $NetBSD: route6d.c,v 1.13.4.2 2000/07/15 08:52:28 itojun Exp $  */
+/*     $KAME: route6d.c,v 1.32 2000/07/15 04:50:43 itojun Exp $        */
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -32,7 +32,7 @@
 
 #include <sys/cdefs.h>
 #ifndef        lint
-__RCSID("$NetBSD: route6d.c,v 1.13.4.1 2000/07/13 01:12:18 thorpej Exp $");
+__RCSID("$NetBSD: route6d.c,v 1.13.4.2 2000/07/15 08:52:28 itojun Exp $");
 #endif
 
 #include <stdio.h>
@@ -58,9 +58,7 @@
 #include <sys/socket.h>
 #include <sys/ioctl.h>
 #include <sys/sysctl.h>
-#ifdef ADVAPI
 #include <sys/uio.h>
-#endif
 #include <net/if.h>
 #if defined(__FreeBSD__) && __FreeBSD__ >= 3
 #include <net/if_var.h>
@@ -517,10 +515,7 @@
 void
 init()
 {
-#ifdef ADVAPI
-       int     i;
-#endif
-       int     int0, int255, error;
+       int     i, int0, int255, error;
        struct  addrinfo hints, *res;
        char    port[10];
 
@@ -552,7 +547,7 @@
        if (setsockopt(ripsock, IPPROTO_IPV6, IPV6_MULTICAST_LOOP,
                &int0, sizeof(int0)) < 0)
                fatal("rip IPV6_MULTICAST_LOOP");
-#ifdef ADVAPI
+
        i = 1;
 #ifdef IPV6_RECVPKTINFO
        if (setsockopt(ripsock, IPPROTO_IPV6, IPV6_RECVPKTINFO, &i,
@@ -563,7 +558,6 @@
                       sizeof(i)) < 0)
                fatal("rip IPV6_PKTINFO");
 #endif 
-#endif /*ADVAPI*/
 
        memset(&hints, 0, sizeof(hints));
        hints.ai_family = PF_INET6;
@@ -832,7 +826,6 @@
         * RIP6_REQUEST message. SO_DONTROUTE has been specified to
         * other sockets.
         */
-#ifdef ADVAPI
        struct msghdr m;
        struct cmsghdr *cm;
        struct iovec iov[2];
@@ -879,13 +872,7 @@
                trace(1, "sendmsg: %s\n", strerror(errno));
                return errno;
        }
-#else
-       if (sendto(ripsock, ripbuf, len, 0 /*MSG_DONTROUTE*/,
-               (struct sockaddr *)sin, sizeof(struct sockaddr_in6)) < 0) {
-               trace(1, "sendto: %s\n", strerror(errno));
-               return errno;
-       }
-#endif
+
        return 0;
 }
 
@@ -903,24 +890,19 @@
        struct  netinfo6 *np, *nq;
        struct  riprt *rrt;
        int     len, nn, need_trigger, index;
-#ifndef ADVAPI
-       int     flen;
-#endif
        char    buf[4 * RIP6_MAXMTU];
        time_t  t;
-#ifdef ADVAPI
        struct msghdr m;
        struct cmsghdr *cm;
        struct iovec iov[2];
        u_char cmsgbuf[256];
        struct in6_pktinfo *pi;
-#endif /*ADVAPI*/
        struct iff *iffp;
        struct in6_addr ia;
        int ok;
 
        need_trigger = 0;
-#ifdef ADVAPI
+
        m.msg_name = (caddr_t)&fsock;
        m.msg_namelen = sizeof(fsock);
        iov[0].iov_base = (caddr_t)buf;
@@ -945,16 +927,6 @@
        }
        if (index && IN6_IS_ADDR_LINKLOCAL(&fsock.sin6_addr))
                SET_IN6_LINKLOCAL_IFINDEX(fsock.sin6_addr, index);
-#else
-       flen = sizeof(struct sockaddr_in6);
-       if ((len = recvfrom(ripsock, buf, sizeof(buf), 0,
-               (struct sockaddr *)&fsock, &flen)) < 0)
-               fatal("recvfrom");
-       if (IN6_IS_ADDR_LINKLOCAL(&fsock.sin6_addr))
-               index = IN6_LINKLOCAL_IFINDEX(fsock.sin6_addr);
-       else
-               index = 0;
-#endif /*ADVAPI*/
 
        nh = fsock.sin6_addr;
        nn = (len - sizeof(struct rip6) + sizeof(struct netinfo6)) /
@@ -2812,6 +2784,22 @@
                rrt->rrt_rflags = RRTF_AGGREGATE;
                rrt->rrt_t = 0;
                rrt->rrt_index = loopifindex;
+               if (getroute(&rrt->rrt_info, &gw)) {
+#if 0
+                       /*
+                        * When the address has already been registered in the
+                        * kernel routing table, it should be removed 
+                        */
+                       delroute(&rrt->rrt_info, &gw);
+#else
+                       /* it is more safe behavior */
+                       errno = EINVAL;
+                       fatal("%s/%u already in routing table, "
+                           "cannot aggregate",
+                           inet6_n2p(&rrt->rrt_info.rip6_dest),
+                           rrt->rrt_info.rip6_plen);
+#endif
+               }
                /* Put the route to the list */
                rrt->rrt_next = riprt;
                riprt = rrt;
@@ -2821,13 +2809,6 @@
                /* Add this route to the kernel */
                if (nflag)      /* do not modify kernel routing table */
                        continue;
-               if (getroute(&rrt->rrt_info, &gw)) {
-                       /*
-                        * When the address has already been registered in the
-                        * kernel routing table, it should be removed 
-                        */
-                       delroute(&rrt->rrt_info, &gw);
-               }
                addroute(rrt, &in6addr_loopback, loopifcp);
        }
 }



Home | Main Index | Thread Index | Old Index