From 0f7c421b79c2c0a405d508ca4c8e1b2f4ea29118 Mon Sep 17 00:00:00 2001 From: Mike Karels Date: Tue, 31 May 1988 21:20:33 -0800 Subject: [PATCH] minor fixes, aborted changes, test for imposters claiming to be our loopback address SCCS-vsn: sbin/routed/input.c 5.16 --- usr/src/sbin/routed/input.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/usr/src/sbin/routed/input.c b/usr/src/sbin/routed/input.c index 5deb68912a..d475dc9b6a 100644 --- a/usr/src/sbin/routed/input.c +++ b/usr/src/sbin/routed/input.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1983 Regents of the University of California. + * Copyright (c) 1983, 1988 Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms are permitted @@ -11,7 +11,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)input.c 5.15 (Berkeley) %G%"; +static char sccsid[] = "@(#)input.c 5.16 (Berkeley) %G%"; #endif /* not lint */ /* @@ -121,6 +121,12 @@ rip_input(from, size) /* are we talking to ourselves? */ ifp = if_ifwithaddr(from); if (ifp) { + if (ifp->int_flags & IFF_PASSIVE) { + syslog(LOG_ERR, + "bogus input (from passive interface, %s)", + (*afswitch[from->sa_family].af_format)(from)); + return; + } rt = rtfind(from); if (rt == 0 || ((rt->rt_state & RTS_INTERFACE) == 0) && rt->rt_metric >= ifp->int_metric) @@ -204,33 +210,37 @@ rip_input(from, size) if (rt && rt->rt_state & RTS_SUBNET && (*afp->af_sendroute)(rt, from)) continue; - /* - * Look for an equivalent route that includes - * this one before adding this route. - */ - rt = rtfind(&n->rip_dst); - if (rt && equal(from, &rt->rt_router)) - continue; - if (n->rip_metric < HOPCNT_INFINITY) + if ((unsigned)n->rip_metric < HOPCNT_INFINITY) { + /* + * Look for an equivalent route that + * includes this one before adding + * this route. + */ + rt = rtfind(&n->rip_dst); + if (rt && equal(from, &rt->rt_router)) + continue; rtadd(&n->rip_dst, from, n->rip_metric, 0); + } continue; } /* * Update if from gateway and different, - * shorter, or getting stale and equivalent. + * shorter, or equivalent but old route + * is getting stale. */ if (equal(from, &rt->rt_router)) { if (n->rip_metric != rt->rt_metric) { rtchange(rt, from, n->rip_metric); + rt->rt_timer = 0; if (rt->rt_metric >= HOPCNT_INFINITY) rt->rt_timer = GARBAGE_TIME - EXPIRE_TIME; } else if (rt->rt_metric < HOPCNT_INFINITY) rt->rt_timer = 0; } else if ((unsigned) n->rip_metric < rt->rt_metric || - (rt->rt_timer > (EXPIRE_TIME/2) && - rt->rt_metric == n->rip_metric && + (rt->rt_metric == n->rip_metric && + rt->rt_timer > (EXPIRE_TIME/2) && (unsigned) n->rip_metric < HOPCNT_INFINITY)) { rtchange(rt, from, n->rip_metric); rt->rt_timer = 0; -- 2.20.1