summaryrefslogtreecommitdiffstats
path: root/sbin/routed
diff options
context:
space:
mode:
Diffstat (limited to 'sbin/routed')
-rw-r--r--sbin/routed/Makefile10
-rw-r--r--sbin/routed/Makefile.inc1
-rw-r--r--sbin/routed/defs.h98
-rw-r--r--sbin/routed/main.c107
-rw-r--r--sbin/routed/pathnames.h4
-rw-r--r--sbin/routed/routed.879
-rw-r--r--sbin/routed/rtquery/Makefile8
-rw-r--r--sbin/routed/table.c108
8 files changed, 146 insertions, 269 deletions
diff --git a/sbin/routed/Makefile b/sbin/routed/Makefile
new file mode 100644
index 0000000..b17fd70
--- /dev/null
+++ b/sbin/routed/Makefile
@@ -0,0 +1,10 @@
+# From: @(#)Makefile 8.1 (Berkeley) 6/19/93
+# $Id$
+
+PROG= routed
+SRCS= if.c input.c main.c output.c parms.c radix.c rdisc.c table.c trace.c
+MAN8= routed.8
+SUBDIR= rtquery
+#COPTS= -g -DDEBUG -Wall
+
+.include <bsd.prog.mk>
diff --git a/sbin/routed/Makefile.inc b/sbin/routed/Makefile.inc
new file mode 100644
index 0000000..10fa13f
--- /dev/null
+++ b/sbin/routed/Makefile.inc
@@ -0,0 +1 @@
+.include "../../Makefile.inc"
diff --git a/sbin/routed/defs.h b/sbin/routed/defs.h
index 7e023d7..8dcf6ae 100644
--- a/sbin/routed/defs.h
+++ b/sbin/routed/defs.h
@@ -31,12 +31,11 @@
* SUCH DAMAGE.
*
* @(#)defs.h 8.1 (Berkeley) 6/5/93
- *
- * $NetBSD$
+ * $Id$
*/
#ifndef __NetBSD__
-#ident "$Revision: 1.17 $"
+#ident "$Revision: 1.1.1.1 $"
#endif
/* Definitions for RIPv2 routing process.
@@ -95,10 +94,6 @@
#define RIPVERSION RIPv2
#include <protocols/routed.h>
-#ifdef sgi
-#define USE_PASSIFNAME
-#endif
-
/* Type of an IP address.
* Some systems do not like to pass structures, so do not use in_addr.
@@ -135,13 +130,6 @@
#define LIM_SEC(s,l) ((s).tv_sec = MIN((s).tv_sec, (l)))
-/* Metric used for fake default routes. It ought to be 15, but when
- * processing advertised routes, previous versions of `routed` added
- * to the received metric and discarded the route if the total was 16
- * or larger.
- */
-#define FAKE_METRIC (HOPCNT_INFINITY-2)
-
/* Router Discovery parameters */
#ifndef sgi
@@ -162,19 +150,15 @@
#define MAX_SOLICITATIONS 3
-/* Bloated packet size for systems that simply add authentication to
- * full-sized packets
- */
-#define OVER_MAXPACKETSIZE (MAXPACKETSIZE+sizeof(struct netinfo)*2)
/* typical packet buffers */
union pkt_buf {
- char packet[OVER_MAXPACKETSIZE*2];
+ char packet[MAXPACKETSIZE+1];
struct rip rip;
};
-/* No more routes than this, to protect ourself in case something goes
- * whacko and starts broadcasting zillions of bogus routes.
+/* no more routes than this, to protect ourself in case something goes
+ * whacko and starts broadcast zillions of bogus routes.
*/
#define MAX_ROUTES (128*1024)
extern int total_routes;
@@ -258,11 +242,7 @@ struct rt_entry {
* handles "logical" or "IS_REMOTE" interfaces (remote gateways).
*/
struct interface {
- struct interface *int_next, **int_prev;
- struct interface *int_ahash, **int_ahash_prev;
- struct interface *int_bhash, **int_bhash_prev;
- struct interface *int_rlink, **int_rlink_prev;
- struct interface *int_nhash, **int_nhash_prev;
+ struct interface *int_next, *int_prev;
char int_name[IFNAMSIZ+15+1]; /* big enough for IS_REMOTE */
u_short int_index;
naddr int_addr; /* address on this host (net order) */
@@ -278,7 +258,6 @@ struct interface {
int int_if_flags; /* some bits copied from kernel */
u_int int_state;
time_t int_act_time; /* last thought healthy */
- time_t int_query_time;
u_short int_transitions; /* times gone up-down */
char int_metric;
char int_d_metric; /* for faked default route */
@@ -292,15 +271,7 @@ struct interface {
#endif
time_t ts; /* timestamp on network stats */
} int_data;
- struct auth { /* authentication info */
- u_char type;
-# define MAX_AUTH_KEYS 3
- struct auth_key {
- u_char key[RIP_AUTH_PW_LEN];
- u_char keyid;
- time_t start, end;
- } keys[MAX_AUTH_KEYS];
- } int_auth;
+ char int_passwd[RIP_AUTH_PW_LEN]; /* RIPv2 password */
int int_rdisc_pref; /* advertised rdisc preference */
int int_rdisc_int; /* MaxAdvertiseInterval */
int int_rdisc_cnt;
@@ -316,11 +287,11 @@ struct interface {
#define IS_CHECKED 0x0000020 /* still exists */
#define IS_ALL_HOSTS 0x0000040 /* in INADDR_ALLHOSTS_GROUP */
#define IS_ALL_ROUTERS 0x0000080 /* in INADDR_ALLROUTERS_GROUP */
-#define IS_DISTRUST 0x0000100 /* ignore untrusted routers */
+#define IS_RIP_QUERIED 0x0000100 /* query broadcast */
#define IS_BROKE 0x0000200 /* seems to be broken */
#define IS_SICK 0x0000400 /* seems to be broken */
#define IS_DUP 0x0000800 /* has a duplicate address */
-/* 0x0001000 spare */
+#define IS_ACTIVE 0x0001000 /* heard from it at least once */
#define IS_NEED_NET_SYN 0x0002000 /* need RS_NET_SYN route */
#define IS_NO_AG 0x0004000 /* do not aggregate subnets */
#define IS_NO_SUPER_AG 0x0008000 /* do not aggregate networks */
@@ -392,14 +363,14 @@ struct ag_info {
extern struct parm {
struct parm *parm_next;
char parm_name[IFNAMSIZ+1];
- naddr parm_net;
+ naddr parm_addr_h;
naddr parm_mask;
char parm_d_metric;
u_int parm_int_state;
int parm_rdisc_pref;
int parm_rdisc_int;
- struct auth parm_auth;
+ char parm_passwd[RIP_AUTH_PW_LEN+1];
} *parms;
/* authority for internal networks */
@@ -410,23 +381,7 @@ extern struct intnet {
char intnet_metric;
} *intnets;
-/* trusted routers */
-extern struct tgate {
- struct tgate *tgate_next;
- naddr tgate_addr;
-} *tgates;
-enum output_type {OUT_QUERY, OUT_UNICAST, OUT_BROADCAST, OUT_MULTICAST,
- NO_OUT_MULTICAST, NO_OUT_RIPV2};
-
-/* common output buffers */
-extern struct ws_buf {
- struct rip *buf;
- struct netinfo *n;
- struct netinfo *base;
- struct netinfo *lim;
- enum output_type type;
-} v12buf, v2buf;
extern pid_t mypid;
extern naddr myaddr; /* main address of this system */
@@ -449,8 +404,7 @@ extern int mhome; /* 1=want multi-homed host route */
extern int advertise_mhome; /* 1=must continue adverising it */
extern int auth_ok; /* 1=ignore auth if we do not care */
-extern struct timeval clk; /* system clock's idea of time */
-extern struct timeval epoch; /* system clock when started */
+extern struct timeval epoch; /* when started */
extern struct timeval now; /* current idea of time */
extern time_t now_stale;
extern time_t now_expire;
@@ -468,7 +422,6 @@ extern naddr loopaddr; /* our address on loopback */
extern int tot_interfaces; /* # of remote and local interfaces */
extern int rip_interfaces; /* # of interfaces doing RIP */
extern struct interface *ifnet; /* all interfaces */
-extern struct interface *remote_if; /* remote interfaces */
extern int have_ripv1_out; /* have a RIPv1 interface */
extern int have_ripv1_in;
extern int need_flash; /* flash update needed */
@@ -496,21 +449,16 @@ extern void fix_select(void);
extern void rip_off(void);
extern void rip_on(struct interface *);
-extern void bufinit(void);
-extern int output(enum output_type, struct sockaddr_in *,
- struct interface *, struct rip *, int);
-extern void clr_ws_buf(struct ws_buf *, struct auth_key *, struct interface *);
+enum output_type {OUT_QUERY, OUT_UNICAST, OUT_BROADCAST, OUT_MULTICAST,
+ NO_OUT_MULTICAST, NO_OUT_RIPV2};
+extern int output(enum output_type, struct sockaddr_in *,
+ struct interface *, struct rip *, int);
extern void rip_query(void);
extern void rip_bcast(int);
extern void supply(struct sockaddr_in *, struct interface *,
- enum output_type, int, int, int);
+ enum output_type, int, int);
extern void msglog(char *, ...);
-struct msg_limit {
- naddr addr;
- time_t until;
-};
-extern void msglim(struct msg_limit *, naddr, char *, ...);
#define LOGERR(msg) msglog(msg ": %s", strerror(errno))
extern void logbad(int, char *, ...);
#define BADERR(dump,msg) logbad(dump,msg ": %s", strerror(errno))
@@ -536,7 +484,7 @@ extern void lastlog(void);
extern void trace_on(char *, int);
extern void trace_off(char*, ...);
extern void trace_flush(void);
-extern void set_tracelevel(int);
+extern void set_tracelevel(void);
extern void trace_kernel(char *, ...);
extern void trace_act(char *, ...);
extern void trace_pkt(char *, ...);
@@ -605,21 +553,13 @@ 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)
extern int check_dst(naddr);
-extern struct interface *check_dup(naddr, naddr, naddr, int);
-extern int check_remote(struct interface *);
-extern int addrouteforif(register struct interface *);
+extern void addrouteforif(register struct interface *);
extern void ifinit(void);
extern int walk_bad(struct radix_node *, struct walkarg *);
extern int if_ok(struct interface *, char *);
extern void if_sick(struct interface *);
extern void if_bad(struct interface *);
-extern void if_link(struct interface *);
extern struct interface *ifwithaddr(naddr, int, int);
extern struct interface *ifwithname(char *, naddr);
extern struct interface *ifwithindex(u_short);
extern struct interface *iflookup(naddr);
-
-extern struct auth_key *find_auth(struct interface *);
-extern void end_md5_auth(struct ws_buf *, struct auth_key *);
-
-#include <md5.h>
diff --git a/sbin/routed/main.c b/sbin/routed/main.c
index dc0b1d8..4c353ae 100644
--- a/sbin/routed/main.c
+++ b/sbin/routed/main.c
@@ -39,7 +39,7 @@ static char sccsid[] = "@(#)main.c 8.1 (Berkeley) 6/5/93";
#elif defined(__NetBSD__)
static char rcsid[] = "$NetBSD$";
#endif
-#ident "$Revision: 1.18 $"
+#ident "$Revision: 1.1.1.1 $"
#include "defs.h"
#include "pathnames.h"
@@ -97,17 +97,12 @@ main(int argc,
struct timeval wtime, t2;
time_t dt;
fd_set ibits;
- naddr p_net, p_mask;
+ naddr p_addr, p_mask;
struct interface *ifp;
struct parm parm;
char *tracename = 0;
- /* Some shells are badly broken and send SIGHUP to backgrounded
- * processes.
- */
- signal(SIGHUP, SIG_IGN);
-
openlog("routed", LOG_PID | LOG_ODELAY, LOG_DAEMON);
ftrace = stdout;
@@ -124,7 +119,7 @@ main(int argc,
(void)gethostname(myname, sizeof(myname)-1);
(void)gethost(myname, &myaddr);
- while ((n = getopt(argc, argv, "sqdghmpAtT:F:P:")) != EOF) {
+ while ((n = getopt(argc, argv, "sqdghmAtT:F:P:")) != EOF) {
switch (n) {
case 's':
supplier = 1;
@@ -174,7 +169,7 @@ main(int argc,
break;
case 'F': /* minimal routes for SLIP */
- n = FAKE_METRIC;
+ n = HOPCNT_INFINITY-2;
p = strchr(optarg,',');
if (p && *p != '\0') {
n = (int)strtoul(p+1, &q, 0);
@@ -183,13 +178,13 @@ main(int argc,
&& n >= 1)
*p = '\0';
}
- if (!getnet(optarg, &p_net, &p_mask)) {
+ if (!getnet(optarg, &p_addr, &p_mask)) {
msglog("bad network; \"-F %s\"",
optarg);
break;
}
bzero(&parm, sizeof(parm));
- parm.parm_net = p_net;
+ parm.parm_addr_h = ntohl(p_addr);
parm.parm_mask = p_mask;
parm.parm_d_metric = n;
p = check_parms(&parm);
@@ -257,6 +252,8 @@ usage:
signal(SIGALRM, sigalrm);
if (!background)
signal(SIGHUP, sigterm); /* SIGHUP fatal during debugging */
+ else
+ signal(SIGHUP, SIG_IGN);
signal(SIGTERM, sigterm);
signal(SIGINT, sigterm);
signal(SIGUSR1, sigtrace_on);
@@ -301,9 +298,7 @@ usage:
if (new_tracelevel == 0) /* use stdout if file is bad */
new_tracelevel = 1;
}
- set_tracelevel(1);
-
- bufinit();
+ set_tracelevel();
/* initialize radix tree */
rtinit();
@@ -330,7 +325,8 @@ usage:
/* Ask for routes */
rip_query();
- rdisc_sol();
+ if (!supplier)
+ rdisc_sol();
/* Loop forever, listening and broadcasting.
*/
@@ -346,7 +342,7 @@ usage:
dt = t2.tv_sec;
if (dt > 0)
dt -= wtime.tv_sec;
- trace_act("time changed by %d sec", dt);
+ trace_act("time changed by %d sec\n", dt);
epoch.tv_sec += dt;
}
timevalsub(&now, &clk, &epoch);
@@ -355,11 +351,13 @@ usage:
now_garbage = now.tv_sec - GARBAGE_TIME;
/* deal with interrupts that should affect tracing */
- set_tracelevel(0);
+ set_tracelevel();
if (stopint != 0) {
- rip_bcast(0);
- rdisc_adv();
+ if (supplier) {
+ rip_bcast(0);
+ rdisc_adv();
+ }
trace_off("exiting with signal %d\n", stopint);
exit(stopint | 128);
}
@@ -497,7 +495,7 @@ sigalrm(int sig)
* new and broken interfaces.
*/
ifinit_timer.tv_sec = now.tv_sec;
- trace_act("SIGALRM");
+ trace_act("SIGALRM\n");
}
@@ -554,16 +552,10 @@ fix_sock(int sock,
logbad(1, "fcntl(%s) O_NONBLOCK: %s",
name, strerror(errno));
on = 1;
- if (setsockopt(sock, SOL_SOCKET,SO_BROADCAST, &on,sizeof(on)) < 0)
+ if (setsockopt(sock, SOL_SOCKET,SO_BROADCAST,
+ &on,sizeof(on)) < 0)
msglog("setsockopt(%s,SO_BROADCAST): %s",
name, strerror(errno));
-#ifdef USE_PASSIFNAME
- on = 1;
- if (setsockopt(sock, SOL_SOCKET, SO_PASSIFNAME, &on,sizeof(on)) < 0)
- msglog("setsockopt(%s,SO_PASSIFNAME): %s",
- name, strerror(errno));
-#endif
-
if (rbuf >= MIN_SOCKBUF) {
if (setsockopt(sock, SOL_SOCKET, SO_RCVBUF,
&rbuf, sizeof(rbuf)) < 0)
@@ -573,7 +565,7 @@ fix_sock(int sock,
for (rbuf = 60*1024; ; rbuf -= 4096) {
if (setsockopt(sock, SOL_SOCKET, SO_RCVBUF,
&rbuf, sizeof(rbuf)) == 0) {
- trace_act("RCVBUF=%d", rbuf);
+ trace_act("RCVBUF=%d\n", rbuf);
break;
}
if (rbuf < MIN_SOCKBUF) {
@@ -632,7 +624,7 @@ rip_off(void)
if (rip_sock >= 0 && !mhome) {
- trace_act("turn off RIP");
+ trace_act("turn off RIP\n");
(void)close(rip_sock);
rip_sock = -1;
@@ -640,9 +632,8 @@ rip_off(void)
/* get non-broadcast sockets to listen to queries.
*/
for (ifp = ifnet; ifp != 0; ifp = ifp->int_next) {
- if (ifp->int_state & IS_REMOTE)
- continue;
- if (ifp->int_rip_sock < 0) {
+ if (ifp->int_rip_sock < 0
+ && !(ifp->int_state & IS_ALIAS)) {
addr = ((ifp->int_if_flags & IFF_POINTOPOINT)
? ifp->int_dstaddr
: ifp->int_addr);
@@ -695,11 +686,11 @@ rip_on(struct interface *ifp)
return;
}
- /* If the main RIP socket is off and it makes sense to turn it on,
- * then turn it on for all of the interfaces.
+ /* If the main RIP socket is off, and it makes sense to turn it on,
+ * turn it on for all of the interfaces.
*/
if (rip_interfaces > 0 && !rdisc_ok) {
- trace_act("turn on RIP");
+ trace_act("turn on RIP\n");
/* Close all of the query sockets so that we can open
* the main socket. SO_REUSEPORT is not a solution,
@@ -722,21 +713,25 @@ rip_on(struct interface *ifp)
next_bcast.tv_sec = now.tv_sec+MIN_WAITTIME;
for (ifp = ifnet; ifp != 0; ifp = ifp->int_next) {
- ifp->int_query_time = NEVER;
+ if (!IS_RIP_IN_OFF(ifp->int_state))
+ ifp->int_state &= ~IS_RIP_QUERIED;
rip_mcast_on(ifp);
}
+
ifinit_timer.tv_sec = now.tv_sec;
+ fix_select();
+
} else if (ifp != 0
- && !(ifp->int_state & IS_REMOTE)
- && ifp->int_rip_sock < 0) {
+ && ifp->int_rip_sock < 0
+ && !(ifp->int_state & IS_ALIAS)) {
/* RIP is off, so ensure there are sockets on which
* to listen for queries.
*/
ifp->int_rip_sock = get_rip_sock(ifp->int_addr, 0);
- }
- fix_select();
+ fix_select();
+ }
}
@@ -795,8 +790,6 @@ timevalsub(struct timeval *t1,
}
-/* put a message into the system log
- */
void
msglog(char *p, ...)
{
@@ -816,34 +809,6 @@ msglog(char *p, ...)
}
-/* Put a message about a bad router into the system log if
- * we have not complained about it recently.
- */
-void
-msglim(struct msg_limit *lim, naddr addr, char *p, ...)
-{
- va_list args;
- char *p1;
-
- va_start(args, p);
-
- if ( lim->addr != addr || lim->until <= now.tv_sec) {
- lim->addr = addr;
- lim->until = now.tv_sec + 60*60;
-
- trace_flush();
- for (p1 = p; *p1 == ' '; p1++)
- continue;
- vsyslog(LOG_ERR, p1, args);
- }
-
- if (ftrace != 0) {
- (void)vfprintf(ftrace, p, args);
- (void)fputc('\n', ftrace);
- }
-}
-
-
void
logbad(int dump, char *p, ...)
{
diff --git a/sbin/routed/pathnames.h b/sbin/routed/pathnames.h
index 14b721c..eb90433 100644
--- a/sbin/routed/pathnames.h
+++ b/sbin/routed/pathnames.h
@@ -47,4 +47,6 @@
* Leave this undefined, and only the trace file originally specified
* when routed was started, if any, will be appended to.
*/
-#define _PATH_TRACE "/etc/routed.trace"
+#if 0
+#define _PATH_TRACE "/var/log/routed.trace"
+#endif
diff --git a/sbin/routed/routed.8 b/sbin/routed/routed.8
index 3e7a6c9..4d203a7 100644
--- a/sbin/routed/routed.8
+++ b/sbin/routed/routed.8
@@ -39,7 +39,7 @@
.Nd network RIP and router discovery routing daemon
.Sh SYNOPSIS
.Nm
-.Op Fl sqdghmpAt
+.Op Fl sqdghmAt
.Op Fl T Ar tracefile
.Oo
.Fl F
@@ -96,7 +96,7 @@ After transmitting a RIP
and
Router Discovery Advertisements or Solicitations on a new interface,
the daemon enters a loop, listening for
-RIP request and response and Router Discovery packets from other hosts.
+RIP request and response and Router Discover packets from other hosts.
.Pp
When a
.Em request
@@ -137,7 +137,7 @@ When an update is applied,
.Nm
records the change in its own tables and updates the kernel routing table
if the best route to the destination changes.
-The change in the kernel routing table is reflected in the next batch of
+The change in the kernel routing tableis reflected in the next batch of
.Em response
packets sent.
If the next response is not scheduled for a while, a
@@ -199,11 +199,11 @@ If all discovered routers disappear,
the daemon resumes listening to RIP responses.
.Pp
While using Router Discovery (which happens by default when
-the system has a single network interface and a Router Discovery Advertisement
+the system has a single network interface and a Router Discover Advertisement
is received), there is a single default route and a variable number of
redirected host routes in the kernel table.
.Pp
-The Router Discovery standard requires that advertisements
+The Router Discover standard requires that advertisements
have a default "lifetime" of 30 minutes. That means should
something happen, a client can be without a good route for
30 minutes. It is a good idea to reduce the default to 45
@@ -219,23 +219,14 @@ While using Router Discovery (which happens by default when
the system has a single network interface and a Router Discover Advertisement
is received), there is a single default route and a variable number of
redirected host routes in the kernel table.
-On a host with more than one network interface,
-this default route will be via only one of the interfaces.
-Thus, multi-homed hosts running with \f3\-q\f1 might need
-.Cm no_rdisc
-described below.
.Pp
See the
.Cm pm_rdisc
facility described below to support "legacy" systems
that can handle neither RIPv2 nor Router Discovery.
.Pp
-By default, neither Router Discovery advertisements nor solicitations
+By default, neither Router Discovery advertisements nor solicications
are sent over point to point links (e.g. PPP).
-The netmask associated with point-to-point links (such as SLIP
-or PPP, with the IFF_POINTOPOINT flag) is used by
-.Nm routed
-to infer the netmask used by the remote system when RIPv1 is used.
.Pp
Options supported by
@@ -252,7 +243,6 @@ ipforwarding=1.
is the opposite of the
.Fl s
option.
-This is the default when only one interface is present.
.It Fl d
Do not run in the background.
This option is meant for interactive use.
@@ -276,7 +266,7 @@ This is typically used on a gateway to the Internet,
or on a gateway that uses another routing protocol whose routes
are not reported to other local routers.
Notice that because a metric of 1 is used, this feature is
-dangerous. It is more commonly accidentally used to create chaos with routing
+dangerous. It is more commonly accidently used to create chaos with routing
loop than to solve problems.
.It Fl h
This causes host or point-to-point routes to not be advertised,
@@ -411,7 +401,7 @@ are also passive, but are not placed in the kernel
routing table nor are they included in routing updates.
The function of external entries is to indicate
that another routing process
-will install such a route if necessary,
+will install such a route if ncessary,
and that alternate routes to that destination should not be installed
by
.Nm routed .
@@ -514,41 +504,21 @@ specifies a RIPv2 password that will be included on all RIPv2
responses sent and checked on all RIPv2 responses received.
The password must not contain any blanks, tab characters, commas
or '#' characters.
-.It Cm passwd Ns \&= Ns Ar XXX1[|KeyID[start|stop]][XXX2...]
-specifies one or more RIPv2 cleartext passwords that will be included on
-all RIPv2 responses sent, and checked on all RIPv2 responses received.
-Any blanks, tab characters, commas, or '#' or '|' characters in the
-password must be escaped with a backslash (\\).
-The
-.Cm KeyID
-must be unique but is ignored for cleartext passwords.
-If present,
-.Cm start
-and
-.Cm stop
-are timestamps in the form year/month/day@hour:minute.
-They specify when the password is valid.
-The first valid password is used on output packets.
-Incoming packets can carry any password that is valid, will
-be valid within 24 hours, or that was valid within 24 hours.
-.It Cm md5_passwd Ns \&= Ns Ar XXX1|KeyID[start|stop][XXX2...]
-specifes one or more RIPv2 MD5 passwords.
-Except that a
-.Cm KeyID
-is required, this keyword is the similar to
-.Cm passwd .
.It Cm no_ag
turns off aggregation of subnets in RIPv1 and RIPv2 responses.
.It Cm no_super_ag
turns off aggregation of networks into supernets in RIPv2 responses.
.It Cm passive
-marks the interface to not be advertised in updates sent via other
-interfaces, and turns off all RIP and router discovery through the interface.
+is equivalent
+.Cm no_rip Cm no_rdisc .
.It Cm no_rip
disables all RIP processing on the specified interface.
If no interfaces are allowed to process RIP packets,
.Nm
acts purely as a router discovery daemon.
+.Cm No_rip
+is equivalent to
+.Cm no_ripv1_in no_ripv2_in no_ripv1_out no_ripv2_out .
Note that turning off RIP without explicitly turning on router
discovery advertisements with
@@ -557,7 +527,7 @@ or
.Fl s
causes
.Nm routed
-to act as a client router discovery daemon, not advertising.
+to act as a client router discovery daemon, not adveritising.
.It Cm no_ripv1_in
causes RIPv1 received responses to be ignored.
.It Cm no_ripv2_in
@@ -565,15 +535,10 @@ causes RIPv2 received responses to be ignored.
.It Cm ripv2_out
turns off RIPv1 output and causes RIPv2 advertisements to be
multicast when possible.
-.It Cm ripv2
-is equivalent to
-.Cm no_ripv1_in
-and
-.Cm no_ripv1_out .
.It Cm no_rdisc
disables the Internet Router Discovery Protocol.
.It Cm no_solicit
-disables the transmission of Router Discovery Solicitations.
+disables the tranmission of Router Discovery Solicitations.
.It Cm send_solicit
specifies that Router Discovery solicitations should be sent,
even on point-to-point links,
@@ -581,7 +546,7 @@ which by default only listen to Router Discovery messages.
.It Cm no_rdisc_adv
disables the transmission of Router Discovery Advertisements
.It Cm rdisc_adv
-specifies that Router Discovery Advertisements should be sent,
+specifies that Router Discovery advertisements should be sent,
even on point-to-point links,
which by default only listen to Router Discovery messages
.It Cm bcast_rdisc
@@ -595,7 +560,7 @@ sets the nominal interval with which Router Discovery Advertisements
are transmitted to N seconds and their lifetime to 3*N.
.It Cm fake_default Ns \&= Ns Ar metric
has an identical effect to
-.Fl F Ar net[/mask][=metric]
+.Fl F Ar net[/mask][,metric]
with the network and mask coming from the sepcified interface.
.It Cm pm_rdisc
is similar to
@@ -607,13 +572,13 @@ Unless modified with
.Cm fake_default ,
the default route is broadcast with a metric of 14.
That serves as a "poor man's router discovery" protocol.
-.It Cm trust_gateway Ns \&= Ns Ar rname
-causes RIP packets from that router and other routers named in
-other
-.Cm trust_gateway
-keywords to be accept, and packets from other routers to be ignored.
.El
.Pp
+Note that the netmask associated with point-to-point links (such as SLIP
+or PPP, with the IFF_POINTOPOINT flag) is used by
+.Nm routed
+to infer the netmask used by the remote system when RIPv1 is used.
+.Pp
.Sh FILES
.Bl -tag -width /etc/gateways -compact
.It Pa /etc/gateways
diff --git a/sbin/routed/rtquery/Makefile b/sbin/routed/rtquery/Makefile
new file mode 100644
index 0000000..e748e73
--- /dev/null
+++ b/sbin/routed/rtquery/Makefile
@@ -0,0 +1,8 @@
+# From: @(#)Makefile 8.1 (Berkeley) 6/5/93
+# $Id$
+
+PROG= rtquery
+MAN8= rtquery.8
+#COPTS= -g -DDEBUG -Wall
+
+.include <bsd.prog.mk>
diff --git a/sbin/routed/table.c b/sbin/routed/table.c
index bad1da4..cef0f90 100644
--- a/sbin/routed/table.c
+++ b/sbin/routed/table.c
@@ -36,7 +36,7 @@ static char sccsid[] = "@(#)tables.c 8.1 (Berkeley) 6/5/93";
#elif defined(__NetBSD__)
static char rcsid[] = "$NetBSD$";
#endif
-#ident "$Revision: 1.26 $"
+#ident "$Revision: 1.1.1.1 $"
#include "defs.h"
@@ -57,7 +57,6 @@ int stopint;
int total_routes;
-/* zap any old routes through this gateway */
naddr age_bad_gate;
@@ -705,7 +704,7 @@ again:
if (cc < 0) {
if (errno == ESRCH
&& (action == RTM_CHANGE || action == RTM_DELETE)) {
- trace_act("route to %s disappeared before %s",
+ trace_act("route to %s disappeared before %s\n",
addrname(dst, mask, 0),
rtm_type_name(action));
if (action == RTM_CHANGE) {
@@ -832,14 +831,14 @@ rtm_add(struct rt_msghdr *rtm,
} else if (INFO_MASK(info) != 0) {
mask = ntohl(S_ADDR(INFO_MASK(info)));
} else {
- msglog("ignore %s without mask",
+ msglog("punt %s without mask",
rtm_type_name(rtm->rtm_type));
return;
}
if (INFO_GATE(info) == 0
|| INFO_GATE(info)->sa_family != AF_INET) {
- msglog("ignore %s without gateway",
+ msglog("punt %s without gateway",
rtm_type_name(rtm->rtm_type));
return;
}
@@ -868,7 +867,7 @@ rtm_add(struct rt_msghdr *rtm,
k->k_state |= KS_DELETE;
LIM_SEC(need_kern, 0);
trace_act("mark redirected %s --> %s for deletion"
- " since this is a router",
+ " since this is a router\n",
addrname(k->k_dst, k->k_mask, 0),
naddr_ntoa(k->k_gate));
} else {
@@ -890,7 +889,7 @@ rtm_add(struct rt_msghdr *rtm,
/* Put static routes with real metrics into the daemon table so
* they can be advertised.
*
- * Find the interface toward the gateway.
+ * Find the interface concerned
*/
ifp = iflookup(k->k_gate);
if (ifp == 0) {
@@ -917,7 +916,7 @@ rtm_lose(struct rt_msghdr *rtm,
{
if (INFO_GATE(info) == 0
|| INFO_GATE(info)->sa_family != AF_INET) {
- msglog("ignore %s without gateway",
+ msglog("punt %s without gateway",
rtm_type_name(rtm->rtm_type));
return;
}
@@ -1066,12 +1065,12 @@ read_rt(void)
ifp = ifwithindex(m.ifm.ifm_index);
if (ifp == 0)
trace_act("note %s with flags %#x"
- " for index #%d",
+ " for index #%d\n",
rtm_type_name(m.r.rtm.rtm_type),
m.ifm.ifm_flags,
m.ifm.ifm_index);
else
- trace_act("note %s with flags %#x for %s",
+ trace_act("note %s with flags %#x for %s\n",
rtm_type_name(m.r.rtm.rtm_type),
m.ifm.ifm_flags,
ifp->int_name);
@@ -1099,12 +1098,12 @@ read_rt(void)
m.r.rtm.rtm_addrs);
if (INFO_DST(&info) == 0) {
- trace_act("ignore %s without dst", str);
+ trace_act("ignore %s without dst\n", str);
continue;
}
if (INFO_DST(&info)->sa_family != AF_INET) {
- trace_act("ignore %s for AF %d", str,
+ trace_act("ignore %s for AF %d\n", str,
INFO_DST(&info)->sa_family);
continue;
}
@@ -1119,7 +1118,7 @@ read_rt(void)
addrname(S_ADDR(INFO_DST(&info)), mask, 0));
if (IN_MULTICAST(ntohl(S_ADDR(INFO_DST(&info))))) {
- trace_act("ignore multicast %s", str);
+ trace_act("ignore multicast %s\n", str);
continue;
}
@@ -1137,31 +1136,31 @@ read_rt(void)
case RTM_CHANGE:
case RTM_REDIRECT:
if (m.r.rtm.rtm_errno != 0) {
- trace_act("ignore %s with \"%s\" error",
+ trace_act("ignore %s with \"%s\" error\n",
str, strerror(m.r.rtm.rtm_errno));
} else {
- trace_act("%s", str);
+ trace_act("%s\n", str);
rtm_add(&m.r.rtm,&info,0);
}
break;
case RTM_DELETE:
if (m.r.rtm.rtm_errno != 0) {
- trace_act("ignore %s with \"%s\" error",
+ trace_act("ignore %s with \"%s\" error\n",
str, strerror(m.r.rtm.rtm_errno));
} else {
- trace_act("%s", str);
+ trace_act("%s\n", str);
del_static(S_ADDR(INFO_DST(&info)), mask, 1);
}
break;
case RTM_LOSING:
- trace_act("%s", str);
+ trace_act("%s\n", str);
rtm_lose(&m.r.rtm,&info);
break;
default:
- trace_act("ignore %s", str);
+ trace_act("ignore %s\n", str);
break;
}
}
@@ -1269,7 +1268,8 @@ walk_kern(struct radix_node *rn,
* the kernel if is not a alias.
*/
if (RT->rt_ifp == 0
- || (RT->rt_ifp->int_state & IS_REMOTE))
+ || ((RT->rt_ifp->int_state & IS_REMOTE)
+ && RT->rt_ifp->int_metric == 0))
ags |= (AGS_GATEWAY | AGS_SUPPRESS | AGS_PROMOTE);
}
@@ -1431,7 +1431,7 @@ del_redirects(naddr bad_gate,
k->k_state |= KS_DELETE;
k->k_state &= ~KS_DYNAMIC;
need_kern.tv_sec = now.tv_sec;
- trace_act("mark redirected %s --> %s for deletion",
+ trace_act("mark redirected %s --> %s for deletion\n",
addrname(k->k_dst, k->k_mask, 0),
naddr_ntoa(k->k_gate));
}
@@ -1570,8 +1570,15 @@ rtadd(naddr dst,
if (0 == rhead->rnh_addaddr(&rt->rt_dst_sock, &mask_sock,
rhead, rt->rt_nodes)) {
+/*
+ * This will happen if RIP1 and RIP2 routeds talk to one another and
+ * there are variable subnets. This is only good for filling up your
+ * syslog. -jkh
+ */
+#if 0
msglog("rnh_addaddr() failed for %s mask=%#x",
naddr_ntoa(dst), mask);
+#endif
}
}
@@ -1935,46 +1942,29 @@ void
age(naddr bad_gate)
{
struct interface *ifp;
- int need_query = 0;
- /* If not listening to RIP, there is no need to age the routes in
- * the table.
- */
- age_timer.tv_sec = (now.tv_sec
- + ((rip_sock < 0) ? NEVER : SUPPLY_INTERVAL));
-
- /* Check for dead IS_REMOTE interfaces by timing their
- * transmissions.
- */
- for (ifp = ifnet; ifp; ifp = ifp->int_next) {
- if (!(ifp->int_state & IS_REMOTE))
- continue;
- /* ignore unreachable remote interfaces */
- if (!check_remote(ifp))
- continue;
- /* Restore remote interface that has become reachable
- */
- if (ifp->int_state & IS_BROKE)
- if_ok(ifp, "remote ");
-
- if (ifp->int_act_time != NEVER
- && now.tv_sec - ifp->int_act_time > EXPIRE_TIME) {
- msglog("remote interface %s to %s timed out after"
- " %d:%d",
- ifp->int_name,
- naddr_ntoa(ifp->int_dstaddr),
- (now.tv_sec - ifp->int_act_time)/60,
- (now.tv_sec - ifp->int_act_time)%60);
- if_sick(ifp);
- }
+ age_timer.tv_sec = now.tv_sec + (rip_sock < 0
+ ? NEVER
+ : SUPPLY_INTERVAL);
- /* If we have not heard from the other router
- * recently, ask it.
+ for (ifp = ifnet; ifp; ifp = ifp->int_next) {
+ /* Check for dead IS_REMOTE interfaces by timing their
+ * transmissions.
*/
- if (now.tv_sec >= ifp->int_query_time) {
- ifp->int_query_time = NEVER;
- need_query = 1;
+ if ((ifp->int_state & IS_REMOTE)
+ && !(ifp->int_state & IS_PASSIVE)
+ && (ifp->int_state & IS_ACTIVE)) {
+ LIM_SEC(age_timer, now.tv_sec+SUPPLY_INTERVAL);
+
+ if (now.tv_sec - ifp->int_act_time > EXPIRE_TIME
+ && !(ifp->int_state & IS_BROKE)) {
+ msglog("remote interface %s to %s timed out"
+ "--turned off",
+ ifp->int_name,
+ naddr_ntoa(ifp->int_addr));
+ if_bad(ifp);
+ }
}
}
@@ -1984,8 +1974,4 @@ age(naddr bad_gate)
/* Update the kernel routing table. */
fix_kern();
-
- /* poke reticent remote gateways */
- if (need_query)
- rip_query();
}
OpenPOWER on IntegriCloud