From caa79e368ec2cd0a6c85c7febfc8b6d26779b6c6 Mon Sep 17 00:00:00 2001 From: Bruce M Simpson Date: Wed, 25 Feb 2004 23:20:22 +0000 Subject: [PATCH] Virgin import of rhyolite.com routed v2.27 --- sbin/routed/defs.h | 38 +++++++++++++----- sbin/routed/if.c | 31 ++++++++++----- sbin/routed/input.c | 51 +++++++++++++++--------- sbin/routed/main.c | 48 +++++++++++++--------- sbin/routed/output.c | 53 +++++++++++++++---------- sbin/routed/parms.c | 56 ++++++++++++++++++++------ sbin/routed/pathnames.h | 6 ++- sbin/routed/radix.c | 10 +++-- sbin/routed/rdisc.c | 44 ++++++++++++-------- sbin/routed/routed.8 | 63 +++++++++++++++++++++++------ sbin/routed/rtquery/rtquery.8 | 6 +-- sbin/routed/rtquery/rtquery.c | 51 +++++++++++++++--------- sbin/routed/table.c | 75 +++++++++++++++++++++-------------- sbin/routed/trace.c | 23 ++++++++--- 14 files changed, 375 insertions(+), 180 deletions(-) diff --git a/sbin/routed/defs.h b/sbin/routed/defs.h index 806689efeace..b8cde9248cce 100644 --- a/sbin/routed/defs.h +++ b/sbin/routed/defs.h @@ -33,12 +33,10 @@ * @(#)defs.h 8.1 (Berkeley) 6/5/93 * * $NetBSD$ + * $FreeBSD$ + * "$Revision: 2.27 $" */ -#ifdef sgi -#ident "$Revision: 2.17 $" -#endif - /* Definitions for RIPv2 routing process. * * This code is based on the 4.4BSD `routed` daemon, with extensions to @@ -100,6 +98,12 @@ #define RIPVERSION RIPv2 #include +#ifndef __RCSID +#define __RCSID(_s) static const char rcsid[] UNUSED = _s +#endif +#ifndef __COPYRIGHT +#define __COPYRIGHT(_s) static const char copyright[] UNUSED = _s +#endif /* Type of an IP address. * Some systems do not like to pass structures, so do not use in_addr. @@ -119,11 +123,19 @@ #define _HAVE_SIN_LEN #endif -/* Turn on if IP_DROP_MEMBERSHIP and IP_ADD_MEMBERSHIP do not look at - * the dstaddr of point-to-point interfaces. +/* Turn on if IP_{ADD,DROP}_MEMBERSHIP and IP_MULTICAST_IF considers address + * within 0.0.0.0/8 as interface index. */ #ifdef __NetBSD__ -#define MCAST_PPP_BUG +#define MCAST_IFINDEX +#endif + +/* Turn on if IP_DROP_MEMBERSHIP and IP_ADD_MEMBERSHIP do not look at + * the dstaddr of point-to-point interfaces. + * #define MCAST_PPP_BUG + */ +#ifdef MCAST_IFINDEX +#undef MCAST_PPP_BUG #endif #define DAY (24*60*60) @@ -290,7 +302,9 @@ struct interface { time_t int_query_time; u_short int_transitions; /* times gone up-down */ char int_metric; - char int_d_metric; /* for faked default route */ + u_char int_d_metric; /* for faked default route */ + u_char int_adj_inmetric; /* adjust advertised metrics */ + u_char int_adj_outmetric; /* instead of interface metric */ struct int_data { u_int ipackets; /* previous network stats */ u_int ierrors; @@ -399,7 +413,9 @@ extern struct parm { naddr parm_net; naddr parm_mask; - char parm_d_metric; + u_char parm_d_metric; + u_char parm_adj_inmetric; + char parm_adj_outmetric; u_int parm_int_state; int parm_rdisc_pref; /* signed IRDP preference */ int parm_rdisc_int; /* IRDP advertising interval */ @@ -645,6 +661,9 @@ extern struct interface *iflookup(naddr); extern struct auth *find_auth(struct interface *); extern void end_md5_auth(struct ws_buf *, struct auth *); +#if defined(__FreeBSD__) || defined(__NetBSD__) +#include +#else #define MD5_DIGEST_LEN 16 typedef struct { u_int32_t state[4]; /* state (ABCD) */ @@ -654,3 +673,4 @@ typedef struct { extern void MD5Init(MD5_CTX*); extern void MD5Update(MD5_CTX*, u_char*, u_int); extern void MD5Final(u_char[MD5_DIGEST_LEN], MD5_CTX*); +#endif diff --git a/sbin/routed/if.c b/sbin/routed/if.c index c72c10ed4804..2c8395e9a667 100644 --- a/sbin/routed/if.c +++ b/sbin/routed/if.c @@ -34,13 +34,14 @@ #include "defs.h" #include "pathnames.h" -#if !defined(sgi) && !defined(__NetBSD__) -static char sccsid[] __attribute__((unused)) = "@(#)if.c 8.1 (Berkeley) 6/5/93"; -#elif defined(__NetBSD__) -#include +#ifdef __NetBSD__ __RCSID("$NetBSD$"); +#elif defined(__FreeBSD__) +__RCSID("$FreeBSD$"); +#else +__RCSID("$Revision: 2.27 $"); +#ident "$Revision: 2.27 $" #endif -#ident "$Revision: 2.22 $" struct interface *ifnet; /* all interfaces */ @@ -212,14 +213,14 @@ ifwithname(char *name, /* "ec0" or whatever */ struct interface * -ifwithindex(u_short index, +ifwithindex(u_short ifindex, int rescan_ok) { struct interface *ifp; for (;;) { for (ifp = ifnet; 0 != ifp; ifp = ifp->int_next) { - if (ifp->int_index == index) + if (ifp->int_index == ifindex) return ifp; } @@ -242,6 +243,7 @@ struct interface * iflookup(naddr addr) { struct interface *ifp, *maybe; + int once = 0; maybe = 0; for (;;) { @@ -265,9 +267,9 @@ iflookup(naddr addr) } } - if (maybe != 0 - || IF_RESCAN_DELAY()) + if (maybe != 0 || once || IF_RESCAN_DELAY()) return maybe; + once = 1; /* If there is no known interface, maybe there is a * new interface. So just once look for new interfaces. @@ -404,7 +406,8 @@ check_dup(naddr addr, /* IP address, so network byte order */ /* The local address can only be shared with a point-to-point * link. */ - if (ifp->int_addr == addr + if ((!(ifp->int_state & IS_REMOTE) || !(if_flags & IS_REMOTE)) + && ifp->int_addr == addr && (((if_flags|ifp->int_if_flags) & IFF_POINTOPOINT) == 0)) return ifp; @@ -496,10 +499,14 @@ ifdel(struct interface *ifp) #endif && rip_sock >= 0) { m.imr_multiaddr.s_addr = htonl(INADDR_RIP_GROUP); +#ifdef MCAST_IFINDEX + m.imr_interface.s_addr = htonl(ifp->int_index); +#else m.imr_interface.s_addr = ((ifp->int_if_flags & IFF_POINTOPOINT) ? ifp->int_dstaddr : ifp->int_addr); +#endif if (setsockopt(rip_sock,IPPROTO_IP,IP_DROP_MEMBERSHIP, &m, sizeof(m)) < 0 && errno != EADDRNOTAVAIL @@ -735,6 +742,10 @@ ifinit(void) ifam2 = (struct ifa_msghdr*)((char*)ifam + ifam->ifam_msglen); +#ifdef RTM_OIFINFO + if (ifam->ifam_type == RTM_OIFINFO) + continue; /* just ignore compat message */ +#endif if (ifam->ifam_type == RTM_IFINFO) { struct sockaddr_dl *sdl; diff --git a/sbin/routed/input.c b/sbin/routed/input.c index 55162fcd87be..08872a7b4b02 100644 --- a/sbin/routed/input.c +++ b/sbin/routed/input.c @@ -33,13 +33,14 @@ #include "defs.h" -#if !defined(sgi) && !defined(__NetBSD__) -static char sccsid[] __attribute__((unused)) = "@(#)input.c 8.1 (Berkeley) 6/5/93"; -#elif defined(__NetBSD__) -#include +#ifdef __NetBSD__ __RCSID("$NetBSD$"); +#elif defined(__FreeBSD__) +__RCSID("$FreeBSD$"); +#else +__RCSID("$Revision: 2.26 $"); +#ident "$Revision: 2.26 $" #endif -#ident "$Revision: 2.17 $" static void input(struct sockaddr_in *, struct interface *, struct interface *, struct rip *, int); @@ -326,9 +327,14 @@ input(struct sockaddr_in *from, /* received from this IP address */ v12buf.n->n_family = RIP_AF_INET; v12buf.n->n_dst = RIP_DEFAULT; i = aifp->int_d_metric; - if (0 != (rt = rtget(RIP_DEFAULT, 0))) - i = MIN(i, (rt->rt_metric - +aifp->int_metric+1)); + if (0 != (rt = rtget(RIP_DEFAULT, 0))) { + j = (rt->rt_metric + +aifp->int_metric + +aifp->int_adj_outmetric + +1); + if (i > j) + i = j; + } v12buf.n->n_metric = htonl(i); v12buf.n++; break; @@ -394,11 +400,15 @@ input(struct sockaddr_in *from, /* received from this IP address */ */ v12buf.n->n_family = RIP_AF_INET; v12buf.n->n_dst = dst; - v12buf.n->n_metric = (rt->rt_metric+1 - + ((aifp!=0) - ? aifp->int_metric - : 1)); - if (v12buf.n->n_metric > HOPCNT_INFINITY) + j = rt->rt_metric+1; + if (!aifp) + ++j; + else + j += (aifp->int_metric + + aifp->int_adj_outmetric); + if (j < HOPCNT_INFINITY) + v12buf.n->n_metric = j; + else v12buf.n->n_metric = HOPCNT_INFINITY; if (v12buf.buf->rip_vers != RIPv1) { v12buf.n->n_tag = rt->rt_tag; @@ -482,7 +492,8 @@ input(struct sockaddr_in *from, /* received from this IP address */ if (from->sin_port != ntohs(RIP_PORT)) { msglim(&bad_router, FROM_NADDR, " discard RIP response from unknown port" - " %d", from->sin_port); + " %d on %s", + ntohs(from->sin_port), naddr_ntoa(FROM_NADDR)); return; } @@ -651,7 +662,8 @@ input(struct sockaddr_in *from, /* received from this IP address */ /* Adjust metric according to incoming interface.. */ - n->n_metric += aifp->int_metric; + n->n_metric += (aifp->int_metric + + aifp->int_adj_inmetric); if (n->n_metric > HOPCNT_INFINITY) n->n_metric = HOPCNT_INFINITY; @@ -964,12 +976,12 @@ ck_passwd(struct interface *aifp, */ if (TRACEPACKETS) { if (NA->au.a_md5.md5_auth_len - != RIP_AUTH_MD5_LEN) + != RIP_AUTH_MD5_HASH_LEN) msglim(use_authp, from, "unknown MD5 RIPv2 auth len %#x" " instead of %#x from %s", NA->au.a_md5.md5_auth_len, - RIP_AUTH_MD5_LEN, + RIP_AUTH_MD5_HASH_LEN, naddr_ntoa(from)); if (na2->a_family != RIP_AF_AUTH) msglim(use_authp, from, @@ -986,8 +998,9 @@ ck_passwd(struct interface *aifp, } MD5Init(&md5_ctx); - MD5Update(&md5_ctx, (u_char *)rip, len); - MD5Update(&md5_ctx, ap->key, RIP_AUTH_MD5_LEN); + MD5Update(&md5_ctx, (u_char *)rip, + len + RIP_AUTH_MD5_HASH_XTRA); + MD5Update(&md5_ctx, ap->key, RIP_AUTH_MD5_KEY_LEN); MD5Final(hash, &md5_ctx); if (!memcmp(hash, na2->au.au_pw, sizeof(hash))) return 1; diff --git a/sbin/routed/main.c b/sbin/routed/main.c index 15ad6ef7ea3c..58dbd1459605 100644 --- a/sbin/routed/main.c +++ b/sbin/routed/main.c @@ -40,18 +40,18 @@ #include #include -#if !defined(sgi) && !defined(__NetBSD__) -char copyright[] = -"@(#) Copyright (c) 1983, 1988, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -static char sccsid[] __attribute__((unused)) = "@(#)main.c 8.1 (Berkeley) 6/5/93"; -#elif defined(__NetBSD__) +__COPYRIGHT("@(#) Copyright (c) 1983, 1988, 1993\n" + "The Regents of the University of California." + " All rights reserved.\n"); +#ifdef __NetBSD__ __RCSID("$NetBSD$"); -__COPYRIGHT("@(#) Copyright (c) 1983, 1988, 1993\n\ - The Regents of the University of California. All rights reserved.\n"); +#include +#elif defined(__FreeBSD__) +__RCSID("$FreeBSD$"); +#else +__RCSID("$Revision: 2.27 $"); +#ident "$Revision: 2.27 $" #endif -#ident "$Revision: 2.22 $" - pid_t mypid; @@ -119,7 +119,7 @@ main(int argc, */ signal(SIGHUP, SIG_IGN); - openlog("routed", LOG_PID | LOG_ODELAY, LOG_DAEMON); + openlog("routed", LOG_PID, LOG_DAEMON); ftrace = stdout; gettimeofday(&clk, 0); @@ -221,7 +221,7 @@ main(int argc, case 'v': /* display version */ verbose++; - msglog("version 2.22"); + msglog("version 2.25"); break; default: @@ -294,6 +294,9 @@ usage: BADERR(0,"daemon()"); #endif +#if defined(__NetBSD__) + pidfile(0); +#endif mypid = getpid(); srandom((int)(clk.tv_sec ^ clk.tv_usec ^ mypid)); @@ -638,7 +641,7 @@ static int /* <0 or file descriptor */ get_rip_sock(naddr addr, int serious) /* 1=failure to bind is serious */ { - struct sockaddr_in sin; + struct sockaddr_in rsin; unsigned char ttl; int s; @@ -646,14 +649,14 @@ get_rip_sock(naddr addr, if ((s = socket(AF_INET, SOCK_DGRAM, 0)) < 0) BADERR(1,"rip_sock = socket()"); - memset(&sin, 0, sizeof(sin)); + memset(&rsin, 0, sizeof(rsin)); #ifdef _HAVE_SIN_LEN - sin.sin_len = sizeof(sin); + rsin.sin_len = sizeof(rsin); #endif - sin.sin_family = AF_INET; - sin.sin_port = htons(RIP_PORT); - sin.sin_addr.s_addr = addr; - if (bind(s, (struct sockaddr *)&sin, sizeof(sin)) < 0) { + rsin.sin_family = AF_INET; + rsin.sin_port = htons(RIP_PORT); + rsin.sin_addr.s_addr = addr; + if (bind(s, (struct sockaddr *)&rsin, sizeof(rsin)) < 0) { if (serious) BADERR(errno != EADDRINUSE, "bind(rip_sock)"); return -1; @@ -717,9 +720,13 @@ rip_mcast_on(struct interface *ifp) #endif && !(ifp->int_state & IS_ALIAS)) { m.imr_multiaddr.s_addr = htonl(INADDR_RIP_GROUP); +#ifdef MCAST_IFINDEX + m.imr_interface.s_addr = htonl(ifp->int_index); +#else m.imr_interface.s_addr = ((ifp->int_if_flags & IFF_POINTOPOINT) ? ifp->int_dstaddr : ifp->int_addr); +#endif if (setsockopt(rip_sock,IPPROTO_IP, IP_ADD_MEMBERSHIP, &m, sizeof(m)) < 0) LOGERR("setsockopt(IP_ADD_MEMBERSHIP RIP)"); @@ -861,6 +868,7 @@ msglog(const char *p, ...) (void)vfprintf(ftrace, p, args); (void)fputc('\n', ftrace); } + va_end(args); } @@ -923,6 +931,7 @@ msglim(struct msg_limit *lim, naddr addr, const char *p, ...) (void)vfprintf(ftrace, p, args); (void)fputc('\n', ftrace); } + va_end(args); } @@ -940,6 +949,7 @@ logbad(int dump, const char *p, ...) (void)vfprintf(stderr, p, args); (void)fputs("; giving up\n",stderr); (void)fflush(stderr); + va_end(args); if (dump) abort(); diff --git a/sbin/routed/output.c b/sbin/routed/output.c index 5b601fba01e8..45617f605f46 100644 --- a/sbin/routed/output.c +++ b/sbin/routed/output.c @@ -33,12 +33,14 @@ #include "defs.h" -#if !defined(sgi) && !defined(__NetBSD__) -static char sccsid[] __attribute__((unused)) = "@(#)output.c 8.1 (Berkeley) 6/5/93"; -#elif defined(__NetBSD__) +#ifdef __NetBSD__ __RCSID("$NetBSD$"); +#elif defined(__FreeBSD__) +__RCSID("$FreeBSD$"); +#else +__RCSID("$Revision: 2.27 $"); +#ident "$Revision: 2.27 $" #endif -#ident "$Revision: 2.21 $" u_int update_seqno; @@ -100,7 +102,7 @@ output(enum output_type type, struct rip *buf, int size) /* this many bytes */ { - struct sockaddr_in sin; + struct sockaddr_in osin; int flags; const char *msg; int res; @@ -108,12 +110,12 @@ output(enum output_type type, int soc; int serrno; - sin = *dst; - if (sin.sin_port == 0) - sin.sin_port = htons(RIP_PORT); + osin = *dst; + if (osin.sin_port == 0) + osin.sin_port = htons(RIP_PORT); #ifdef _HAVE_SIN_LEN - if (sin.sin_len == 0) - sin.sin_len = sizeof(sin); + if (osin.sin_len == 0) + osin.sin_len = sizeof(osin); #endif soc = rip_sock; @@ -150,6 +152,10 @@ output(enum output_type type, } else { msg = "Send mcast"; if (rip_sock_mcast != ifp) { +#ifdef MCAST_IFINDEX + /* specify ifindex */ + tgt_mcast = htonl(ifp->int_index); +#else #ifdef MCAST_PPP_BUG /* Do not specify the primary interface * explicitly if we have the multicast @@ -164,6 +170,7 @@ output(enum output_type type, } else #endif tgt_mcast = ifp->int_addr; +#endif if (0 > setsockopt(rip_sock, IPPROTO_IP, IP_MULTICAST_IF, &tgt_mcast, @@ -177,7 +184,7 @@ output(enum output_type type, } rip_sock_mcast = ifp; } - sin.sin_addr.s_addr = htonl(INADDR_RIP_GROUP); + osin.sin_addr.s_addr = htonl(INADDR_RIP_GROUP); } break; @@ -190,18 +197,18 @@ output(enum output_type type, return -1; } - trace_rip(msg, "to", &sin, ifp, buf, size); + trace_rip(msg, "to", &osin, ifp, buf, size); res = sendto(soc, buf, size, flags, - (struct sockaddr *)&sin, sizeof(sin)); + (struct sockaddr *)&osin, sizeof(osin)); if (res < 0 && (ifp == 0 || !(ifp->int_state & IS_BROKE))) { serrno = errno; msglog("%s sendto(%s%s%s.%d): %s", msg, ifp != 0 ? ifp->int_name : "", ifp != 0 ? ", " : "", - inet_ntoa(sin.sin_addr), - ntohs(sin.sin_port), + inet_ntoa(osin.sin_addr), + ntohs(osin.sin_port), strerror(errno)); errno = serrno; } @@ -277,7 +284,7 @@ clr_ws_buf(struct ws_buf *wb, na->a_family = RIP_AF_AUTH; na->a_type = RIP_AUTH_MD5; na->au.a_md5.md5_keyid = ap->keyid; - na->au.a_md5.md5_auth_len = RIP_AUTH_MD5_LEN; + na->au.a_md5.md5_auth_len = RIP_AUTH_MD5_KEY_LEN; na->au.a_md5.md5_seqno = htonl(clk.tv_sec); wb->n++; wb->lim--; /* make room for trailer */ @@ -301,8 +308,8 @@ end_md5_auth(struct ws_buf *wb, na2->a_type = htons(1); na->au.a_md5.md5_pkt_len = htons(len); MD5Init(&md5_ctx); - MD5Update(&md5_ctx, (u_char *)wb->buf, len); - MD5Update(&md5_ctx, ap->key, RIP_AUTH_MD5_LEN); + MD5Update(&md5_ctx, (u_char *)wb->buf, len + RIP_AUTH_MD5_HASH_XTRA); + MD5Update(&md5_ctx, ap->key, RIP_AUTH_MD5_KEY_LEN); MD5Final(na2->au.au_pw, &md5_ctx); wb->n++; } @@ -545,8 +552,7 @@ walk_supply(struct radix_node *rn, * without confusing RIPv1 listeners into thinking the * network routes are host routes. */ - if ((ws.state & WS_ST_AG) - && !(ws.state & WS_ST_RIP2_ALL)) + if ((ws.state & WS_ST_AG) && (ws.state & WS_ST_RIP2_ALL)) ags |= AGS_AGGREGATE; } else { @@ -590,6 +596,11 @@ walk_supply(struct radix_node *rn, * * Notice spare routes with the same metric that we are about to * advertise, to split the horizon on redundant, inactive paths. + * + * Do not suppress advertisements of interface-related addresses on + * non-point-to-point interfaces. This ensures that we have something + * to say every 30 seconds to help detect broken Ethernets or + * other interfaces where one packet every 30 seconds costs nothing. */ if (ws.ifp != 0 && !(ws.state & WS_ST_QUERY) @@ -709,7 +720,7 @@ supply(struct sockaddr_in *dst, /* Adjust the advertised metric by the outgoing interface * metric. */ - ws.metric = ifp->int_metric+1; + ws.metric = ifp->int_metric + 1 + ifp->int_adj_outmetric; } ripv12_buf.rip.rip_vers = vers; diff --git a/sbin/routed/parms.c b/sbin/routed/parms.c index b4a362837750..1274e71c93ae 100644 --- a/sbin/routed/parms.c +++ b/sbin/routed/parms.c @@ -35,12 +35,14 @@ #include "pathnames.h" #include -#if !defined(sgi) && !defined(__NetBSD__) -static char sccsid[] __attribute__((unused)) = "@(#)if.c 8.1 (Berkeley) 6/5/93"; -#elif defined(__NetBSD__) +#ifdef __NetBSD__ __RCSID("$NetBSD$"); +#elif defined(__FreeBSD__) +__RCSID("$FreeBSD$"); +#else +__RCSID("$Revision: 2.26 $"); +#ident "$Revision: 2.26 $" #endif -#ident "$Revision: 2.21 $" struct parm *parms; @@ -83,8 +85,10 @@ get_parms(struct interface *ifp) ifp->int_rdisc_pref = parmp->parm_rdisc_pref; if (parmp->parm_rdisc_int != 0) ifp->int_rdisc_int = parmp->parm_rdisc_int; - if (parmp->parm_d_metric != 0) - ifp->int_d_metric = parmp->parm_d_metric; + if (parmp->parm_adj_inmetric != 0) + ifp->int_adj_inmetric = parmp->parm_adj_inmetric; + if (parmp->parm_adj_outmetric != 0) + ifp->int_adj_outmetric = parmp->parm_adj_outmetric; } } @@ -311,7 +315,7 @@ gwkludge(void) if (state & IS_PASSIVE) state |= IS_NO_RIP; - ifp = check_dup(gate,dst,netmask,0); + ifp = check_dup(gate,dst,netmask,state); if (ifp != 0) { msglog("duplicate "_PATH_GATEWAYS" entry \"%s\"",lptr); continue; @@ -755,7 +759,7 @@ parse_parms(char *line, } else if (PARS("passive")) { CKF((GROUP_IS_SOL_OUT|GROUP_IS_ADV_OUT), IS_NO_RDISC); - parm.parm_int_state |= IS_NO_RIP| IS_PASSIVE; + parm.parm_int_state |= IS_NO_RIP | IS_PASSIVE; } else if (PARSEQ("rdisc_pref")) { if (parm.parm_rdisc_pref != 0 @@ -779,10 +783,24 @@ parse_parms(char *line, } else if (PARSEQ("fake_default")) { if (parm.parm_d_metric != 0 || IS_RIP_OUT_OFF(parm.parm_int_state) - || (parm.parm_d_metric = (int)strtoul(buf,&p,0), - *p != '\0') - || parm.parm_d_metric > HOPCNT_INFINITY-1) + || (i = strtoul(buf,&p,0), *p != '\0') + || i > HOPCNT_INFINITY-1) return bad_str(tgt); + parm.parm_d_metric = i; + + } else if (PARSEQ("adj_inmetric")) { + if (parm.parm_adj_inmetric != 0 + || (i = strtoul(buf,&p,0), *p != '\0') + || i > HOPCNT_INFINITY-1) + return bad_str(tgt); + parm.parm_adj_inmetric = i; + + } else if (PARSEQ("adj_outmetric")) { + if (parm.parm_adj_outmetric != 0 + || (i = strtoul(buf,&p,0), *p != '\0') + || i > HOPCNT_INFINITY-1) + return bad_str(tgt); + parm.parm_adj_outmetric = i; } else if (PARSEQ("trust_gateway")) { /* look for trust_gateway=x.y.z|net/mask|...) */ @@ -892,9 +910,23 @@ check_parms(struct parm *new) return ("conflicting, duplicate poor man's router" " discovery or fake default metric"); } + + if (new->parm_adj_inmetric != 0 + && parmp->parm_adj_inmetric != 0 + && new->parm_adj_inmetric != parmp->parm_adj_inmetric) { + return ("conflicting interface input " + "metric adjustments"); + } + + if (new->parm_adj_outmetric != 0 + && parmp->parm_adj_outmetric != 0 + && new->parm_adj_outmetric != parmp->parm_adj_outmetric) { + return ("conflicting interface output " + "metric adjustments"); + } } - /* link new entry on the so that when the entries are scanned, + /* link new entry on the list so that when the entries are scanned, * they affect the result in the order the operator specified. */ parmp = (struct parm*)rtmalloc(sizeof(*parmp), "check_parms"); diff --git a/sbin/routed/pathnames.h b/sbin/routed/pathnames.h index 317331068aa9..a88e1dee0319 100644 --- a/sbin/routed/pathnames.h +++ b/sbin/routed/pathnames.h @@ -33,6 +33,8 @@ * @(#)pathnames.h 8.1 (Berkeley) 6/5/93 * * $NetBSD$ + * $FreeBSD$ + * $Revision: 2.23 $ */ #include @@ -42,7 +44,9 @@ /* All remotely requested trace files must either start with this prefix * or be the same as the tracefile specified when the daemon was started. * If this is a directory, routed will create log files in it. That - * might be a security problem. + * might be a security problem. However, if bad guys can write in the + * default value, /etc, you have far worse security problems than anything + * this might do. In other words, it makes no sense to turn this off. * * Leave this undefined, and only the trace file originally specified * when routed was started, if any, will be appended to. diff --git a/sbin/routed/radix.c b/sbin/routed/radix.c index e92bcad2c05e..f0f67eced14b 100644 --- a/sbin/routed/radix.c +++ b/sbin/routed/radix.c @@ -39,12 +39,14 @@ #include "defs.h" -#if !defined(sgi) && !defined(__NetBSD__) -static char sccsid[] __attribute__((unused)) = "@(#)rdisc.c 8.1 (Berkeley) x/y/95"; -#elif defined(__NetBSD__) +#ifdef __NetBSD__ __RCSID("$NetBSD$"); +#elif defined(__FreeBSD__) +__RCSID("$FreeBSD$"); +#else +__RCSID("$Revision: 2.23 $"); +#ident "$Revision: 2.23 $" #endif -#ident "$Revision: 2.17 $" #define log(x, msg) syslog(x, msg) #define panic(s) {log(LOG_ERR,s); exit(1);} diff --git a/sbin/routed/rdisc.c b/sbin/routed/rdisc.c index d76041d60c10..113527096883 100644 --- a/sbin/routed/rdisc.c +++ b/sbin/routed/rdisc.c @@ -36,12 +36,14 @@ #include #include -#if !defined(sgi) && !defined(__NetBSD__) -static char sccsid[] __attribute__((unused)) = "@(#)rdisc.c 8.1 (Berkeley) x/y/95"; -#elif defined(__NetBSD__) +#ifdef __NetBSD__ __RCSID("$NetBSD$"); +#elif defined(__FreeBSD__) +__RCSID("$FreeBSD$"); +#else +__RCSID("$Revision: 2.27 $"); +#ident "$Revision: 2.27 $" #endif -#ident "$Revision: 2.22 $" /* router advertisement ICMP packet */ struct icmp_ad { @@ -95,8 +97,9 @@ struct dr { /* accumulated advertisements */ #define UNSIGN_PREF(p) SIGN_PREF(p) /* adjust unsigned preference by interface metric, * without driving it to infinity */ -#define PREF(p, ifp) ((int)(p) <= (ifp)->int_metric ? ((p) != 0 ? 1 : 0) \ - : (p) - ((ifp)->int_metric)) +#define PREF(p, ifp) ((int)(p) <= ((ifp)->int_metric+(ifp)->int_adj_outmetric)\ + ? ((p) != 0 ? 1 : 0) \ + : (p) - ((ifp)->int_metric+(ifp)->int_adj_outmetric)) static void rdisc_sort(void); @@ -189,9 +192,13 @@ set_rdisc_mg(struct interface *ifp, return; #endif memset(&m, 0, sizeof(m)); +#ifdef MCAST_IFINDEX + m.imr_interface.s_addr = htonl(ifp->int_index); +#else m.imr_interface.s_addr = ((ifp->int_if_flags & IFF_POINTOPOINT) ? ifp->int_dstaddr : ifp->int_addr); +#endif if (supplier || (ifp->int_state & IS_NO_ADV_IN) || !on) { @@ -691,17 +698,17 @@ send_rdisc(union ad_u *p, naddr dst, /* 0 or unicast destination */ int type) /* 0=unicast, 1=bcast, 2=mcast */ { - struct sockaddr_in sin; + struct sockaddr_in rsin; int flags; const char *msg; naddr tgt_mcast; - memset(&sin, 0, sizeof(sin)); - sin.sin_addr.s_addr = dst; - sin.sin_family = AF_INET; + memset(&rsin, 0, sizeof(rsin)); + rsin.sin_addr.s_addr = dst; + rsin.sin_family = AF_INET; #ifdef _HAVE_SIN_LEN - sin.sin_len = sizeof(sin); + rsin.sin_len = sizeof(rsin); #endif flags = MSG_DONTROUTE; @@ -714,10 +721,10 @@ send_rdisc(union ad_u *p, case 1: /* broadcast */ if (ifp->int_if_flags & IFF_POINTOPOINT) { msg = "Send pt-to-pt"; - sin.sin_addr.s_addr = ifp->int_dstaddr; + rsin.sin_addr.s_addr = ifp->int_dstaddr; } else { msg = "Send broadcast"; - sin.sin_addr.s_addr = ifp->int_brdaddr; + rsin.sin_addr.s_addr = ifp->int_brdaddr; } break; @@ -731,6 +738,10 @@ send_rdisc(union ad_u *p, } if (rdisc_sock_mcast != ifp) { /* select the right interface. */ +#ifdef MCAST_IFINDEX + /* specify ifindex */ + tgt_mcast = htonl(ifp->int_index); +#else #ifdef MCAST_PPP_BUG /* Do not specify the primary interface explicitly * if we have the multicast point-to-point kernel @@ -744,6 +755,7 @@ send_rdisc(union ad_u *p, } else #endif tgt_mcast = ifp->int_addr; +#endif if (0 > setsockopt(rdisc_sock, IPPROTO_IP, IP_MULTICAST_IF, &tgt_mcast, sizeof(tgt_mcast))) { @@ -761,16 +773,16 @@ send_rdisc(union ad_u *p, if (rdisc_sock < 0) get_rdisc_sock(); - trace_rdisc(msg, ifp->int_addr, sin.sin_addr.s_addr, ifp, + trace_rdisc(msg, ifp->int_addr, rsin.sin_addr.s_addr, ifp, p, p_size); if (0 > sendto(rdisc_sock, p, p_size, flags, - (struct sockaddr *)&sin, sizeof(sin))) { + (struct sockaddr *)&rsin, sizeof(rsin))) { if (ifp == 0 || !(ifp->int_state & IS_BROKE)) msglog("sendto(%s%s%s): %s", ifp != 0 ? ifp->int_name : "", ifp != 0 ? ", " : "", - inet_ntoa(sin.sin_addr), + inet_ntoa(rsin.sin_addr), strerror(errno)); if (ifp != 0) if_sick(ifp); diff --git a/sbin/routed/routed.8 b/sbin/routed/routed.8 index 6f591420f06c..63e8f7f0375c 100644 --- a/sbin/routed/routed.8 +++ b/sbin/routed/routed.8 @@ -1,4 +1,4 @@ -.\" $Revision: 2.19 $ +.\" $Revision: 2.26 $ .\" .\" Copyright (c) 1983, 1991, 1993 .\" The Regents of the University of California. All rights reserved. @@ -114,11 +114,18 @@ The packet generated contains a list of known routes, each marked with a "hop count" metric (a count of 16 or greater is considered "infinite"). -Advertised metrics reflect the metric associated with interface +Th advertised metric for a route reflects the metrics associated +with interfaces (see -.Xr ifconfig 8 ), +.Xr ifconfig 8 ) +though which it is received and sent, so setting the metric on an interface is an effective way to steer traffic. +See also +.Cm adj_inmetric +and +.Cm adj_outmetric +parameters below. .Pp Responses do not include routes with a first hop on the requesting network to implement in part @@ -155,7 +162,7 @@ also periodically checks the routing table entries. If an entry has not been updated for 3 minutes, the entry's metric is set to infinity and marked for deletion. Deletions are delayed until the route has been advertised with -an infinite metric to insure the invalidation +an infinite metric to ensure the invalidation is propagated throughout the local internet. This is a form of .Em poison reverse . @@ -506,6 +513,7 @@ a line starting with .Cm if=alias(Hname) , .Cm if=remote(Hname) , etc. should be used. +.Ss Parameters .Pp Lines that start with neither "net" nor "host" must consist of one or more of the following parameter settings, separated by commas or @@ -558,7 +566,8 @@ all passwords have expired, in which case the password that expired most recently is used, or unless no passwords are valid yet, in which case no password is output. Incoming packets can carry any password that is valid, will -be valid within 24 hours, or that was valid within 24 hours. +be valid within the next 24 hours, or that was valid within the preceding +24 hours. To protect the secrets, the passwd settings are valid only in the .Em /etc/gateways file and only when that file is readable only by UID 0. @@ -645,17 +654,47 @@ 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 adj_inmetric Ns \&= Ns Ar delta +adjusts the hop count or metric of received RIP routes by +.Ar delta . +The metric of every received RIP route is increased by the sum +of two values associated with the interface. +One is the adj_inmetric value and the other is the interface +metric set with +.Xr ifconfig 8 . +.It Cm adj_outmetric Ns \&= Ns Ar delta +adjusts the hop count or metric of advertised RIP routes by +.Ar delta . +The metric of every received RIP route is increased by the metric +associated with the interface by which it was received, or by 1 if +the interface does not have a non-zero metric. +The metric of the received route is then increased by the +adj_outmetric associated with the interface. +Every advertised route is increased by a total of four +values, +the metric set for the interface by which it was received with +.Xr ifconfig 8 , +the +.Cm adj_inmetric Ar delta +of the receiving interface, +the metric set for the interface by which it is transmitted with +.Xr ifconfig 8 , +and the +.Cm adj_outmetric Ar delta +of the transmitting interface. .It Cm trust_gateway Ns \&= Ns Ar rname[|net1/mask1|net2/mask2|...] -causes RIP packets from that router and other routers named in -other +causes RIP packets from router +.Ar rname +and other routers named in other .Cm trust_gateway keywords to be accepted, and packets from other routers to be ignored. If networks are specified, then routes to other networks will be ignored from that router. .It Cm redirect_ok -causes RIP to allow ICMP Redirect messages when the system is acting +allows the kernel to listen ICMP Redirect messages when the system is acting as a router and forwarding packets. -Otherwise, ICMP Redirect messages are overridden. +Otherwise, ICMP Redirect messages are overridden and deleted when the +system is acting as a router. .El .Pp .Sh FILES @@ -666,9 +705,7 @@ for distant gateways .Sh SEE ALSO .Xr icmp 4 , .Xr udp 4 , -.Xr gated 8 , -.Xr htable 8 , -.Xr rtquery 8 . +.Xr rtquery 8 .Rs .%T Internet Transport Protocols .%R XSIS 028112 @@ -682,3 +719,5 @@ The .Nm command appeared in .Bx 4.2 . +\" LocalWords: loopback ICMP rtquery ifconfig multicasting Solicitations RIPv +\" LocalWords: netstat rdisc diff --git a/sbin/routed/rtquery/rtquery.8 b/sbin/routed/rtquery/rtquery.8 index 2cf931eecc60..63d4ac2bd3de 100644 --- a/sbin/routed/rtquery/rtquery.8 +++ b/sbin/routed/rtquery/rtquery.8 @@ -1,4 +1,4 @@ -.\" $Revision: 2.17 $ +.\" $Revision: 2.27 $ .\" $NetBSD: rtquery.8,v 1.14 1999/02/23 10:47:41 christos Exp $ .\" .Dd June 1, 1996 @@ -115,8 +115,8 @@ turns off tracing. dumps the daemon's routing table to the current tracefile. .El .Sh SEE ALSO -.Xr routed 8 , -.Xr gated 8 +.Xr gated 8 , +.Xr routed 8 .br RFC\ 1058 - Routing Information Protocol, RIPv1 .br diff --git a/sbin/routed/rtquery/rtquery.c b/sbin/routed/rtquery/rtquery.c index 2f484384e2e6..e900ae9b9b2a 100644 --- a/sbin/routed/rtquery/rtquery.c +++ b/sbin/routed/rtquery/rtquery.c @@ -31,10 +31,6 @@ * SUCH DAMAGE. */ -char copyright[] = -"@(#) Copyright (c) 1982, 1986, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; - #include #include #include @@ -55,17 +51,32 @@ char copyright[] = #include #endif -#if !defined(sgi) && !defined(__NetBSD__) -static char sccsid[] __attribute__((unused))= "@(#)query.c 8.1 (Berkeley) 6/5/93"; -#elif defined(__NetBSD__) -__RCSID("$NetBSD: rtquery.c,v 1.10 1999/02/23 10:47:41 christos Exp $"); +#define UNUSED __attribute__((unused)) +#ifndef __RCSID +#define __RCSID(_s) static const char rcsid[] UNUSED = _s +#endif +#ifndef __COPYRIGHT +#define __COPYRIGHT(_s) static const char copyright[] UNUSED = _s +#endif +__COPYRIGHT("@(#) Copyright (c) 1983, 1988, 1993\n" + "The Regents of the University of California." + " All rights reserved.\n"); +#ifdef __NetBSD__ +__RCSID("$NetBSD$"); +#elif defined(__FreeBSD__) +__RCSID("$FreeBSD$"); +#else +__RCSID("$Revision: 2.26 $"); +#ident "$Revision: 2.26 $" #endif -#ident "$Revision: 2.17 $" #ifndef sgi #define _HAVE_SIN_LEN #endif +#ifdef __NetBSD__ +#include +#else #define MD5_DIGEST_LEN 16 typedef struct { u_int32_t state[4]; /* state (ABCD) */ @@ -75,6 +86,7 @@ typedef struct { extern void MD5Init(MD5_CTX*); extern void MD5Update(MD5_CTX*, u_char*, u_int); extern void MD5Final(u_char[MD5_DIGEST_LEN], MD5_CTX*); +#endif #define WTIME 15 /* Time to wait for all responses */ @@ -386,7 +398,7 @@ query_loop(char *argv[], int argc) NA0.a_family = RIP_AF_AUTH; NA0.a_type = RIP_AUTH_MD5; NA0.au.a_md5.md5_keyid = (int8_t)keyid; - NA0.au.a_md5.md5_auth_len = RIP_AUTH_MD5_LEN; + NA0.au.a_md5.md5_auth_len = RIP_AUTH_MD5_KEY_LEN; NA0.au.a_md5.md5_seqno = 0; cc = (char *)&NA2-(char *)&OMSG; NA0.au.a_md5.md5_pkt_len = htons(cc); @@ -396,7 +408,7 @@ query_loop(char *argv[], int argc) MD5Update(&md5_ctx, (u_char *)&OMSG, cc); MD5Update(&md5_ctx, - (u_char *)passwd, RIP_AUTH_MD5_LEN); + (u_char *)passwd, RIP_AUTH_MD5_HASH_LEN); MD5Final(NA2.au.au_pw, &md5_ctx); omsg_len += 2*sizeof(OMSG.rip_nets[0]); } @@ -410,7 +422,7 @@ query_loop(char *argv[], int argc) seen = 0; while (0 > out(*argv++)) { if (*argv == 0) - exit(-1); + exit(1); answered++; } @@ -593,7 +605,7 @@ rip_input(struct sockaddr_in *from, struct in_addr in; const char *name; char net_buf[80]; - u_char hash[RIP_AUTH_MD5_LEN]; + u_char hash[RIP_AUTH_MD5_KEY_LEN]; MD5_CTX md5_ctx; u_char md5_authed = 0; u_int mask, dmask; @@ -733,9 +745,10 @@ rip_input(struct sockaddr_in *from, && na->a_type == ntohs(1)) { MD5Init(&md5_ctx); MD5Update(&md5_ctx, (u_char *)&IMSG, - (char *)na-(char *)&IMSG); + (char *)na-(char *)&IMSG + +RIP_AUTH_MD5_HASH_XTRA); MD5Update(&md5_ctx, (u_char *)passwd, - RIP_AUTH_MD5_LEN); + RIP_AUTH_MD5_KEY_LEN); MD5Final(hash, &md5_ctx); (void)printf(" %s hash\n", memcmp(hash, na->au.au_pw, @@ -747,10 +760,10 @@ rip_input(struct sockaddr_in *from, } else { (void)sprintf(net_buf, "(af %#x) %d.%d.%d.%d", ntohs(n->n_family), - (char)(n->n_dst >> 24), - (char)(n->n_dst >> 16), - (char)(n->n_dst >> 8), - (char)n->n_dst); + (u_char)(n->n_dst >> 24), + (u_char)(n->n_dst >> 16), + (u_char)(n->n_dst >> 8), + (u_char)n->n_dst); } (void)printf(" %-18s metric %2d %-10s", diff --git a/sbin/routed/table.c b/sbin/routed/table.c index 325139ff21b0..0c2c37507f7d 100644 --- a/sbin/routed/table.c +++ b/sbin/routed/table.c @@ -33,12 +33,14 @@ #include "defs.h" -#if !defined(sgi) && !defined(__NetBSD__) -static char sccsid[] __attribute__((unused)) = "@(#)tables.c 8.1 (Berkeley) 6/5/93"; -#elif defined(__NetBSD__) +#ifdef __NetBSD__ __RCSID("$NetBSD$"); +#elif defined(__FreeBSD__) +__RCSID("$FreeBSD$"); +#else +__RCSID("$Revision: 2.27 $"); +#ident "$Revision: 2.27 $" #endif -#ident "$Revision: 2.22 $" static struct rt_spare *rts_better(struct rt_entry *); static struct rt_spare rts_empty = {0,0,0,HOPCNT_INFINITY,0,0,0}; @@ -251,8 +253,6 @@ ag_flush(naddr lim_dst_h, /* flush routes to here */ * then mark the suppressor redundant. */ if (ag_cors->ag_pref <= ag->ag_pref) { - if (ag_cors->ag_seqno > ag->ag_seqno) - ag_cors->ag_seqno = ag->ag_seqno; if (AG_IS_REDUN(ag->ag_state) && ag_cors->ag_mask==ag->ag_mask<<1) { if (ag_cors->ag_dst_h == dst_h) @@ -287,7 +287,7 @@ ag_check(naddr dst, naddr nhop, char metric, char pref, - u_int seqno, + u_int new_seqno, u_short tag, u_short state, void (*out)(struct ag_info *)) /* output using this */ @@ -314,7 +314,7 @@ ag_check(naddr dst, nc_ag.ag_pref = pref; nc_ag.ag_tag = tag; nc_ag.ag_state = state; - nc_ag.ag_seqno = seqno; + nc_ag.ag_seqno = new_seqno; out(&nc_ag); return; } @@ -344,8 +344,6 @@ ag_check(naddr dst, && (ag_cors->ag_gate == ag->ag_gate || (ag->ag_state & AGS_FINE_GATE) || (ag_cors->ag_state & AGS_CORS_GATE))) { - if (ag_cors->ag_seqno > ag->ag_seqno) - ag_cors->ag_seqno = ag->ag_seqno; /* If the suppressed target was redundant, * then mark the suppressor redundant. */ @@ -404,17 +402,13 @@ ag_check(naddr dst, ag->ag_tag = tag; ag->ag_metric = metric; ag->ag_pref = pref; + if (ag->ag_seqno < new_seqno) + ag->ag_seqno = new_seqno; x = ag->ag_state; ag->ag_state = state; state = x; } - /* The sequence number controls flash updating, - * and should be the smaller of the two. - */ - if (ag->ag_seqno > seqno) - ag->ag_seqno = seqno; - /* Some bits are set if they are set on either route, * except when the route is for an interface. */ @@ -454,8 +448,8 @@ ag_check(naddr dst, * * Combine and promote (aggregate) the pair of routes. */ - if (seqno > ag->ag_seqno) - seqno = ag->ag_seqno; + if (new_seqno < ag->ag_seqno) + new_seqno = ag->ag_seqno; if (!AG_IS_REDUN(state)) state &= ~AGS_REDUN1; if (AG_IS_REDUN(ag->ag_state)) @@ -516,10 +510,10 @@ ag_check(naddr dst, pref = x; /* take the newest sequence number */ - if (seqno >= ag->ag_seqno) - seqno = ag->ag_seqno; + if (new_seqno <= ag->ag_seqno) + new_seqno = ag->ag_seqno; else - ag->ag_seqno = seqno; + ag->ag_seqno = new_seqno; } else { if (!(state & AGS_AGGREGATE)) @@ -535,10 +529,10 @@ ag_check(naddr dst, if (!AG_IS_REDUN(state)) state &= ~AGS_REDUN1; state &= ~AGS_REDUN0; - if (seqno > ag->ag_seqno) - seqno = ag->ag_seqno; + if (new_seqno < ag->ag_seqno) + new_seqno = ag->ag_seqno; else - ag->ag_seqno = seqno; + ag->ag_seqno = new_seqno; } mask <<= 1; @@ -599,7 +593,7 @@ ag_check(naddr dst, nag->ag_pref = pref; nag->ag_tag = tag; nag->ag_state = state; - nag->ag_seqno = seqno; + nag->ag_seqno = new_seqno; nag->ag_fine = ag; if (ag != 0) @@ -632,6 +626,9 @@ rtm_type_name(u_char type) "RTM_RESOLVE", "RTM_NEWADDR", "RTM_DELADDR", +#ifdef RTM_OIFINFO + "RTM_OIFINFO", +#endif "RTM_IFINFO", "RTM_NEWMADDR", "RTM_DELMADDR" @@ -1011,7 +1008,7 @@ rtm_lose(struct rt_msghdr *rtm, */ static int get_info_gate(struct sockaddr **sap, - struct sockaddr_in *sin) + struct sockaddr_in *rsin) { struct sockaddr_dl *sdl = (struct sockaddr_dl *)*sap; struct interface *ifp; @@ -1027,12 +1024,12 @@ get_info_gate(struct sockaddr **sap, if (ifp == 0) return 0; - sin->sin_addr.s_addr = ifp->int_addr; + rsin->sin_addr.s_addr = ifp->int_addr; #ifdef _HAVE_SA_LEN - sin->sin_len = sizeof(*sin); + rsin->sin_len = sizeof(*rsin); #endif - sin->sin_family = AF_INET; - *sap = (struct sockaddr*)sin; + rsin->sin_family = AF_INET; + *sap = (struct sockaddr*)rsin; return 1; } @@ -1113,6 +1110,13 @@ flush_kern(void) if (rtm->rtm_flags & RTF_LLINFO) continue; +#if defined(RTF_CLONED) && defined(__bsdi__) + /* ignore cloned routes + */ + if (rtm->rtm_flags & RTF_CLONED) + continue; +#endif + /* ignore multicast addresses */ if (IN_MULTICAST(ntohl(S_ADDR(INFO_DST(&info))))) @@ -1220,6 +1224,10 @@ read_rt(void) ifinit_timer.tv_sec = now.tv_sec; continue; } +#ifdef RTM_OIFINFO + if (m.r.rtm.rtm_type == RTM_OIFINFO) + continue; /* ignore compat message */ +#endif strcpy(str, rtm_type_name(m.r.rtm.rtm_type)); strp = &str[strlen(str)]; @@ -1259,6 +1267,13 @@ read_rt(void) continue; } +#if defined(RTF_CLONED) && defined(__bsdi__) + if (m.r.rtm.rtm_flags & RTF_CLONED) { + trace_act("ignore cloned %s", str); + continue; + } +#endif + if (get_info_gate(&INFO_GATE(&info), &gate_sin)) { gate = S_ADDR(INFO_GATE(&info)); strp += sprintf(strp, " --> %s", naddr_ntoa(gate)); diff --git a/sbin/routed/trace.c b/sbin/routed/trace.c index da497a03607a..6394a1660058 100644 --- a/sbin/routed/trace.c +++ b/sbin/routed/trace.c @@ -38,12 +38,14 @@ #include #include -#if !defined(sgi) && !defined(__NetBSD__) -static char sccsid[] __attribute__((unused)) = "@(#)trace.c 8.1 (Berkeley) 6/5/93"; -#elif defined(__NetBSD__) +#ifdef __NetBSD__ __RCSID("$NetBSD$"); +#elif defined(__FreeBSD__) +__RCSID("$FreeBSD$"); +#else +__RCSID("$Revision: 2.27 $"); +#ident "$Revision: 2.27 $" #endif -#ident "$Revision: 2.17 $" #ifdef sgi @@ -186,6 +188,7 @@ tmsg(const char *p, ...) lastlog(); va_start(args, p); vfprintf(ftrace, p, args); + va_end(args); (void)fputc('\n',ftrace); fflush(ftrace); } @@ -239,6 +242,7 @@ trace_off(const char *p, ...) lastlog(); va_start(args, p); vfprintf(ftrace, p, args); + va_end(args); (void)fputc('\n',ftrace); } trace_close(file_trace); @@ -641,9 +645,15 @@ trace_if(const char *act, ifp->int_mask, 1)); if (ifp->int_metric != 0) (void)fprintf(ftrace, "metric=%d ", ifp->int_metric); + if (ifp->int_adj_inmetric != 0) + (void)fprintf(ftrace, "adj_inmetric=%u ", + ifp->int_adj_inmetric); + if (ifp->int_adj_outmetric != 0) + (void)fprintf(ftrace, "adj_outmetric=%u ", + ifp->int_adj_outmetric); if (!IS_RIP_OUT_OFF(ifp->int_state) && ifp->int_d_metric != 0) - (void)fprintf(ftrace, "fake_default=%d ", ifp->int_d_metric); + (void)fprintf(ftrace, "fake_default=%u ", ifp->int_d_metric); trace_bits(if_bits, ifp->int_if_flags, 0); trace_bits(is_bits, ifp->int_state, 0); (void)fputc('\n',ftrace); @@ -721,6 +731,7 @@ trace_misc(const char *p, ...) lastlog(); va_start(args, p); vfprintf(ftrace, p, args); + va_end(args); (void)fputc('\n',ftrace); } @@ -738,6 +749,7 @@ trace_act(const char *p, ...) lastlog(); va_start(args, p); vfprintf(ftrace, p, args); + va_end(args); (void)fputc('\n',ftrace); } @@ -755,6 +767,7 @@ trace_pkt(const char *p, ...) lastlog(); va_start(args, p); vfprintf(ftrace, p, args); + va_end(args); (void)fputc('\n',ftrace); }