Source-Changes-HG archive

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

[src/trunk]: src/sbin/routed merge 2.32 which is actually 2.31. Most importan...



details:   https://anonhg.NetBSD.org/src/rev/ce67e53af7f5
branches:  trunk
changeset: 748519:ce67e53af7f5
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Oct 26 02:53:15 2009 +0000

description:
merge 2.32 which is actually 2.31. Most important change is:
- use multicast over point-to-point (GRE) links as proposed by Dan Lukes.

diffstat:

 sbin/routed/defs.h            |   5 +++--
 sbin/routed/if.c              |   8 ++++----
 sbin/routed/input.c           |  13 +++++++------
 sbin/routed/main.c            |  13 ++++++-------
 sbin/routed/output.c          |  31 +++++++++++++++++++++++--------
 sbin/routed/parms.c           |  14 +++++++-------
 sbin/routed/rtquery/rtquery.c |  11 ++++++-----
 sbin/routed/table.c           |  24 +++++++++++++++++-------
 8 files changed, 73 insertions(+), 46 deletions(-)

diffs (truncated from 426 to 300 lines):

diff -r 15b8ee35ba87 -r ce67e53af7f5 sbin/routed/defs.h
--- a/sbin/routed/defs.h        Mon Oct 26 02:51:01 2009 +0000
+++ b/sbin/routed/defs.h        Mon Oct 26 02:53:15 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: defs.h,v 1.24 2005/06/27 01:00:06 christos Exp $       */
+/*     $NetBSD: defs.h,v 1.25 2009/10/26 02:53:15 christos Exp $       */
 
 /*
  * Copyright (c) 1983, 1988, 1993
@@ -643,7 +643,8 @@
 extern naddr   std_mask(naddr);
 extern naddr   ripv1_mask_net(naddr, struct interface *);
 extern naddr   ripv1_mask_host(naddr,struct interface *);
-#define                on_net(a,net,mask) (((ntohl(a) ^ (net)) & (mask)) == 0)
+#define                on_net_h(a,net,mask) ((((a) ^ (net)) & (mask)) == 0)
+#define                on_net(a,net,mask) on_net_h(ntohl(a),net,mask)
 extern int     check_dst(naddr);
 extern struct interface *check_dup(naddr, naddr, naddr, int);
 extern int     check_remote(struct interface *);
diff -r 15b8ee35ba87 -r ce67e53af7f5 sbin/routed/if.c
--- a/sbin/routed/if.c  Mon Oct 26 02:51:01 2009 +0000
+++ b/sbin/routed/if.c  Mon Oct 26 02:53:15 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if.c,v 1.27 2008/12/28 20:15:21 christos Exp $ */
+/*     $NetBSD: if.c,v 1.28 2009/10/26 02:53:15 christos Exp $ */
 
 /*
  * Copyright (c) 1983, 1993
@@ -37,7 +37,7 @@
 #include "pathnames.h"
 
 #ifdef __NetBSD__
-__RCSID("$NetBSD: if.c,v 1.27 2008/12/28 20:15:21 christos Exp $");
+__RCSID("$NetBSD: if.c,v 1.28 2009/10/26 02:53:15 christos Exp $");
 #elif defined(__FreeBSD__)
 __RCSID("$FreeBSD$");
 #else
@@ -286,7 +286,7 @@
 naddr                                  /* host byte order */
 std_mask(naddr addr)                   /* network byte order */
 {
-       NTOHL(addr);                    /* was a host, not a network */
+       addr = ntohl(addr);             /* was a host, not a network */
 
        if (addr == 0)                  /* default route has mask 0 */
                return 0;
@@ -374,7 +374,7 @@
 int                                    /* 0=bad */
 check_dst(naddr addr)
 {
-       NTOHL(addr);
+       addr = ntohl(addr);
 
        if (IN_CLASSA(addr)) {
                if (addr == 0)
diff -r 15b8ee35ba87 -r ce67e53af7f5 sbin/routed/input.c
--- a/sbin/routed/input.c       Mon Oct 26 02:51:01 2009 +0000
+++ b/sbin/routed/input.c       Mon Oct 26 02:53:15 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: input.c,v 1.30 2006/05/09 20:18:09 mrg Exp $   */
+/*     $NetBSD: input.c,v 1.31 2009/10/26 02:53:15 christos Exp $      */
 
 /*
  * Copyright (c) 1983, 1988, 1993
@@ -36,7 +36,7 @@
 #include "defs.h"
 
 #ifdef __NetBSD__
-__RCSID("$NetBSD: input.c,v 1.30 2006/05/09 20:18:09 mrg Exp $");
+__RCSID("$NetBSD: input.c,v 1.31 2009/10/26 02:53:15 christos Exp $");
 #elif defined(__FreeBSD__)
 __RCSID("$FreeBSD$");
 #else
@@ -279,7 +279,7 @@
                clr_ws_buf(&v12buf, ap);
 
                do {
-                       NTOHL(n->n_metric);
+                       n->n_metric = ntohl(n->n_metric);
 
                        /* A single entry with family RIP_AF_UNSPEC and
                         * metric HOPCNT_INFINITY means "all routes".
@@ -424,7 +424,7 @@
                                            v12buf.n->n_nhop = rt->rt_gate;
                                }
                        }
-                       HTONL(v12buf.n->n_metric);
+                       v12buf.n->n_metric = htonl(v12buf.n->n_metric);
 
                        /* Stop paying attention if we fill the output buffer.
                         */
@@ -604,7 +604,7 @@
                        if (n->n_family == RIP_AF_AUTH)
                                continue;
 
-                       NTOHL(n->n_metric);
+                       n->n_metric = ntohl(n->n_metric);
                        dst = n->n_dst;
                        if (n->n_family != RIP_AF_INET
                            && (n->n_family != RIP_AF_UNSPEC
@@ -762,7 +762,8 @@
                                input_route(dst, mask, &new, n);
                                if (++j > i)
                                        break;
-                               dst = htonl(ntohl(dst) + ddst_h);
+                               dst = ntohl(dst) + ddst_h;
+                               dst = htonl(dst);
                        }
                } while (++n < lim);
                break;
diff -r 15b8ee35ba87 -r ce67e53af7f5 sbin/routed/main.c
--- a/sbin/routed/main.c        Mon Oct 26 02:51:01 2009 +0000
+++ b/sbin/routed/main.c        Mon Oct 26 02:53:15 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.40 2008/07/20 01:20:23 lukem Exp $  */
+/*     $NetBSD: main.c,v 1.41 2009/10/26 02:53:15 christos Exp $       */
 
 /*
  * Copyright (c) 1983, 1988, 1993
@@ -38,6 +38,9 @@
 #ifdef sgi
 #include "math.h"
 #endif
+#if defined(__NetBSD__)
+#include <util.h>
+#endif
 #include <signal.h>
 #include <fcntl.h>
 #include <sys/file.h>
@@ -45,7 +48,7 @@
 __COPYRIGHT("@(#) Copyright (c) 1983, 1988, 1993\
  The Regents of the University of California.  All rights reserved.");
 #ifdef __NetBSD__
-__RCSID("$NetBSD: main.c,v 1.40 2008/07/20 01:20:23 lukem Exp $");
+__RCSID("$NetBSD: main.c,v 1.41 2009/10/26 02:53:15 christos Exp $");
 #elif defined(__FreeBSD__)
 __RCSID("$FreeBSD$");
 #else
@@ -53,10 +56,6 @@
 #ident "Revision: 2.27 "
 #endif
 
-#if defined(__NetBSD__)
-#include <util.h>
-#endif
-
 pid_t  mypid;
 
 naddr  myaddr;                         /* system address */
@@ -225,7 +224,7 @@
                case 'v':
                        /* display version */
                        verbose++;
-                       msglog("version 2.28");
+                       msglog("version 2.32");
                        break;
 
                default:
diff -r 15b8ee35ba87 -r ce67e53af7f5 sbin/routed/output.c
--- a/sbin/routed/output.c      Mon Oct 26 02:51:01 2009 +0000
+++ b/sbin/routed/output.c      Mon Oct 26 02:53:15 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: output.c,v 1.24 2006/03/21 21:50:44 christos Exp $     */
+/*     $NetBSD: output.c,v 1.25 2009/10/26 02:53:15 christos Exp $     */
 
 /*
  * Copyright (c) 1983, 1988, 1993
@@ -36,7 +36,7 @@
 #include "defs.h"
 
 #ifdef __NetBSD__
-__RCSID("$NetBSD: output.c,v 1.24 2006/03/21 21:50:44 christos Exp $");
+__RCSID("$NetBSD: output.c,v 1.25 2009/10/26 02:53:15 christos Exp $");
 #elif defined(__FreeBSD__)
 __RCSID("$FreeBSD$");
 #else
@@ -144,7 +144,8 @@
                flags = MSG_DONTROUTE;
                break;
        case OUT_MULTICAST:
-               if (ifp->int_if_flags & IFF_POINTOPOINT) {
+               if ((ifp->int_if_flags & IFF_POINTOPOINT)
+                   && !(ifp->int_if_flags & IFF_MULTICAST)) {
                        msg = "Send pt-to-pt";
                } else if (ifp->int_state & IS_DUP) {
                        trace_act("abort multicast output via %s"
@@ -426,7 +427,7 @@
                wb->n->n_metric = ((stopint || ag->ag_metric < 1)
                                   ? HOPCNT_INFINITY
                                   : ag->ag_metric);
-               HTONL(wb->n->n_metric);
+               wb->n->n_metric = htonl(wb->n->n_metric);
                /* Any non-zero bits in the supposedly unused RIPv1 fields
                 * cause the old `routed` to ignore the route.
                 * That means the mask and so forth cannot be sent
@@ -869,7 +870,7 @@
                        dst.sin_addr.s_addr = ifp->int_brdaddr;
 
                        if (vers == RIPv2
-                           && !(ifp->int_state  & IS_NO_RIP_MCAST)) {
+                           && !(ifp->int_state & IS_NO_RIP_MCAST)) {
                                type = OUT_MULTICAST;
                        } else {
                                type = OUT_BROADCAST;
@@ -878,7 +879,14 @@
                } else if (ifp->int_if_flags & IFF_POINTOPOINT) {
                        /* point-to-point hardware interface */
                        dst.sin_addr.s_addr = ifp->int_dstaddr;
-                       type = OUT_UNICAST;
+                       /* use multicast if the interface allows (e.g. GRE) */
+                       if (vers == RIPv2
+                           && (ifp->int_if_flags & IFF_MULTICAST)
+                           && !(ifp->int_state & IS_NO_RIP_MCAST)) {
+                               type = OUT_MULTICAST;
+                       } else {
+                               type = OUT_UNICAST;
+                       }
 
                } else if (ifp->int_state & IS_REMOTE) {
                        /* remote interface */
@@ -958,7 +966,7 @@
                         */
                        if (buf.rip_vers == RIPv2
                            && (ifp->int_if_flags & IFF_MULTICAST)
-                           && !(ifp->int_state  & IS_NO_RIP_MCAST)) {
+                           && !(ifp->int_state & IS_NO_RIP_MCAST)) {
                                type = OUT_MULTICAST;
                        } else {
                                type = OUT_BROADCAST;
@@ -967,7 +975,14 @@
                } else if (ifp->int_if_flags & IFF_POINTOPOINT) {
                        /* point-to-point hardware interface */
                        dst.sin_addr.s_addr = ifp->int_dstaddr;
-                       type = OUT_UNICAST;
+                       /* use multicast if the interface allows (e.g. GRE) */
+                       if (buf.rip_vers == RIPv2
+                           && (ifp->int_if_flags & IFF_MULTICAST)
+                           && !(ifp->int_state & IS_NO_RIP_MCAST)) {
+                               type = OUT_MULTICAST;
+                       } else {
+                               type = OUT_UNICAST;
+                       }
 
                } else if (ifp->int_state & IS_REMOTE) {
                        /* remote interface */
diff -r 15b8ee35ba87 -r ce67e53af7f5 sbin/routed/parms.c
--- a/sbin/routed/parms.c       Mon Oct 26 02:51:01 2009 +0000
+++ b/sbin/routed/parms.c       Mon Oct 26 02:53:15 2009 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: parms.c,v 1.23 2006/03/18 20:25:28 christos Exp $      */
+/*     $NetBSD: parms.c,v 1.24 2009/10/26 02:53:15 christos Exp $      */
 
 /*
  * Copyright (c) 1983, 1993
@@ -38,7 +38,7 @@
 #include <sys/stat.h>
 
 #ifdef __NetBSD__
-__RCSID("$NetBSD: parms.c,v 1.23 2006/03/18 20:25:28 christos Exp $");
+__RCSID("$NetBSD: parms.c,v 1.24 2009/10/26 02:53:15 christos Exp $");
 #elif defined(__FreeBSD__)
 __RCSID("$FreeBSD$");
 #else
@@ -253,7 +253,7 @@
                                       dname, lptr);
                                continue;
                        }
-                       HTONL(dst);     /* make network # into IP address */
+                       dst = htonl(dst); /* make network # into IP address */
                } else {
                        msglog("bad \"%s\" in "_PATH_GATEWAYS
                               " entry \"%s\"", net_host, lptr);
@@ -620,7 +620,7 @@
                        free(intnetp);
                        return bad_str(line);
                }
-               HTONL(intnetp->intnet_addr);
+               intnetp->intnet_addr = htonl(intnetp->intnet_addr);
                intnetp->intnet_next = intnets;
                intnets = intnetp;
                return 0;
@@ -884,9 +884,9 @@
             parmpp = &parmp->parm_next) {
                if (strcmp(new->parm_name, parmp->parm_name))
                        continue;
-               if (!on_net(htonl(parmp->parm_net),
+               if (!on_net_h(parmp->parm_net,
                            new->parm_net, new->parm_mask)
-                   && !on_net(htonl(new->parm_net),
+                   && !on_net_h(new->parm_net,
                               parmp->parm_net, parmp->parm_mask))
                        continue;
 
@@ -987,7 +987,7 @@
                if (0 == (in.s_addr & 0xff000000))
                        in.s_addr <<= 8;
        } else if (inet_aton(name, &in) == 1) {
-               NTOHL(in.s_addr);
+               in.s_addr = ntohl(in.s_addr);
        } else if (!mname && !strcasecmp(name,"default")) {



Home | Main Index | Thread Index | Old Index