Module Name: src
Committed By: christos
Date: Mon Oct 26 02:53:15 UTC 2009
Modified Files:
src/sbin/routed: defs.h if.c input.c main.c output.c parms.c table.c
src/sbin/routed/rtquery: rtquery.c
Log Message:
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.
To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sbin/routed/defs.h src/sbin/routed/output.c
cvs rdiff -u -r1.27 -r1.28 src/sbin/routed/if.c
cvs rdiff -u -r1.30 -r1.31 src/sbin/routed/input.c
cvs rdiff -u -r1.40 -r1.41 src/sbin/routed/main.c
cvs rdiff -u -r1.23 -r1.24 src/sbin/routed/parms.c src/sbin/routed/table.c
cvs rdiff -u -r1.21 -r1.22 src/sbin/routed/rtquery/rtquery.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sbin/routed/defs.h
diff -u src/sbin/routed/defs.h:1.24 src/sbin/routed/defs.h:1.25
--- src/sbin/routed/defs.h:1.24 Sun Jun 26 21:00:06 2005
+++ src/sbin/routed/defs.h Sun Oct 25 22:53:15 2009
@@ -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 *);
Index: src/sbin/routed/output.c
diff -u src/sbin/routed/output.c:1.24 src/sbin/routed/output.c:1.25
--- src/sbin/routed/output.c:1.24 Tue Mar 21 16:50:44 2006
+++ src/sbin/routed/output.c Sun Oct 25 22:53:15 2009
@@ -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 */
Index: src/sbin/routed/if.c
diff -u src/sbin/routed/if.c:1.27 src/sbin/routed/if.c:1.28
--- src/sbin/routed/if.c:1.27 Sun Dec 28 15:15:21 2008
+++ src/sbin/routed/if.c Sun Oct 25 22:53:15 2009
@@ -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)
Index: src/sbin/routed/input.c
diff -u src/sbin/routed/input.c:1.30 src/sbin/routed/input.c:1.31
--- src/sbin/routed/input.c:1.30 Tue May 9 16:18:09 2006
+++ src/sbin/routed/input.c Sun Oct 25 22:53:15 2009
@@ -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;
Index: src/sbin/routed/main.c
diff -u src/sbin/routed/main.c:1.40 src/sbin/routed/main.c:1.41
--- src/sbin/routed/main.c:1.40 Sat Jul 19 21:20:23 2008
+++ src/sbin/routed/main.c Sun Oct 25 22:53:15 2009
@@ -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:
Index: src/sbin/routed/parms.c
diff -u src/sbin/routed/parms.c:1.23 src/sbin/routed/parms.c:1.24
--- src/sbin/routed/parms.c:1.23 Sat Mar 18 15:25:28 2006
+++ src/sbin/routed/parms.c Sun Oct 25 22:53:15 2009
@@ -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")) {
in.s_addr = RIP_DEFAULT;
} else {
Index: src/sbin/routed/table.c
diff -u src/sbin/routed/table.c:1.23 src/sbin/routed/table.c:1.24
--- src/sbin/routed/table.c:1.23 Sun Dec 28 15:15:21 2008
+++ src/sbin/routed/table.c Sun Oct 25 22:53:15 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: table.c,v 1.23 2008/12/28 20:15:21 christos Exp $ */
+/* $NetBSD: table.c,v 1.24 2009/10/26 02:53:15 christos Exp $ */
/*
* Copyright (c) 1983, 1988, 1993
@@ -36,7 +36,7 @@
#include "defs.h"
#ifdef __NetBSD__
-__RCSID("$NetBSD: table.c,v 1.23 2008/12/28 20:15:21 christos Exp $");
+__RCSID("$NetBSD: table.c,v 1.24 2009/10/26 02:53:15 christos Exp $");
#elif defined(__FreeBSD__)
__RCSID("$FreeBSD$");
#else
@@ -298,7 +298,7 @@
naddr xaddr;
int x;
- NTOHL(dst);
+ dst = ntohl(dst);
/* Punt non-contiguous subnet masks.
*
@@ -1112,12 +1112,17 @@
if (rtm->rtm_flags & RTF_LLINFO)
continue;
-#if defined(RTF_CLONED) && defined(__bsdi__)
/* ignore cloned routes
*/
+#if defined(RTF_CLONED) && defined(__bsdi__)
if (rtm->rtm_flags & RTF_CLONED)
continue;
#endif
+#if defined(RTF_WASCLONED) && defined(__FreeBSD__)
+ if (rtm->rtm_flags & RTF_WASCLONED)
+ continue;
+#endif
+
/* ignore multicast addresses
*/
@@ -1279,6 +1284,12 @@
continue;
}
#endif
+#if defined(RTF_WASCLONED) && defined(__FreeBSD__)
+ if (m.r.rtm.rtm_flags & RTF_WASCLONED) {
+ trace_act("ignore cloned %s", str);
+ continue;
+ }
+#endif
if (get_info_gate(&INFO_GATE(&info), &gate_sin)) {
gate = S_ADDR(INFO_GATE(&info));
@@ -1740,6 +1751,8 @@
rt->rt_poison_metric = HOPCNT_INFINITY;
rt->rt_seqno = update_seqno;
+ if (++total_routes == MAX_ROUTES)
+ msglog("have maximum (%d) routes", total_routes);
if (TRACEACTIONS)
trace_add_del("Add", rt);
@@ -1751,9 +1764,6 @@
msglog("rnh_addaddr() failed for %s mask=%#lx",
naddr_ntoa(dst), (u_long)mask);
free(rt);
- } else {
- if (++total_routes == MAX_ROUTES)
- msglog("have maximum (%d) routes", total_routes);
}
}
Index: src/sbin/routed/rtquery/rtquery.c
diff -u src/sbin/routed/rtquery/rtquery.c:1.21 src/sbin/routed/rtquery/rtquery.c:1.22
--- src/sbin/routed/rtquery/rtquery.c:1.21 Sat Jul 19 21:20:23 2008
+++ src/sbin/routed/rtquery/rtquery.c Sun Oct 25 22:53:15 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: rtquery.c,v 1.21 2008/07/20 01:20:23 lukem Exp $ */
+/* $NetBSD: rtquery.c,v 1.22 2009/10/26 02:53:15 christos Exp $ */
/*-
* Copyright (c) 1982, 1986, 1993
@@ -63,7 +63,7 @@
__COPYRIGHT("@(#) Copyright (c) 1983, 1988, 1993\
The Regents of the University of California. All rights reserved.");
#ifdef __NetBSD__
-__RCSID("$NetBSD: rtquery.c,v 1.21 2008/07/20 01:20:23 lukem Exp $");
+__RCSID("$NetBSD: rtquery.c,v 1.22 2009/10/26 02:53:15 christos Exp $");
#elif defined(__FreeBSD__)
__RCSID("$FreeBSD$");
#else
@@ -354,7 +354,8 @@
perror("bind");
exit(2);
}
- myaddr.sin_port = htons(ntohs(myaddr.sin_port)-1);
+ myaddr.sin_port = ntohs(myaddr.sin_port)-1;
+ myaddr.sin_port = htons(myaddr.sin_port);
}
res = 1;
@@ -796,7 +797,7 @@
static u_int
std_mask(u_int addr) /* in network 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;
@@ -839,7 +840,7 @@
if (nentp != 0) {
in.s_addr = nentp->n_net;
} else if (inet_aton(name, &in) == 1) {
- NTOHL(in.s_addr);
+ in.s_addr = ntohl(in.s_addr);
} else {
return 0;
}