From 97cb3618f52ffa5e333e433f13b2c9a9ebffcb27 Mon Sep 17 00:00:00 2001 From: Mike Karels Date: Tue, 3 Jun 1986 23:32:35 -0800 Subject: [PATCH] try again; can't block subnet 0 with internal "network" route SCCS-vsn: sbin/routed/inet.c 5.4 SCCS-vsn: sbin/routed/input.c 5.6 SCCS-vsn: sbin/routed/startup.c 5.6 --- usr/src/sbin/routed/inet.c | 31 ++++++++++++++++++++----------- usr/src/sbin/routed/input.c | 6 ++++-- usr/src/sbin/routed/startup.c | 9 +++++---- 3 files changed, 29 insertions(+), 17 deletions(-) diff --git a/usr/src/sbin/routed/inet.c b/usr/src/sbin/routed/inet.c index f7498eceb0..ef7c52eec8 100644 --- a/usr/src/sbin/routed/inet.c +++ b/usr/src/sbin/routed/inet.c @@ -5,7 +5,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)inet.c 5.3 (Berkeley) %G%"; +static char sccsid[] = "@(#)inet.c 5.4 (Berkeley) %G%"; #endif not lint /* @@ -124,26 +124,29 @@ inet_rtflags(sin) host = i & IN_CLASSC_HOST; } - if (host == 0) - return (0); /* network */ /* * Check whether this network is subnetted; * if so, check whether this is a subnet or a host. */ for (ifp = ifnet; ifp; ifp = ifp->int_next) if (net == ifp->int_net) { - if ((host &~ ifp->int_subnetmask) == 0) + if (host &~ ifp->int_subnetmask) + return (RTF_HOST); + else if (ifp->int_subnetmask != ifp->int_netmask) return (RTF_SUBNET); else - return (RTF_HOST); + return (0); /* network */ } - return (RTF_HOST); + if (host == 0) + return (0); /* network */ + else + return (RTF_HOST); } /* - * Return true if a route to subnet rtsin should be sent to dst. + * Return true if a route to subnet of route rt should be sent to dst. * Send it only if dst is on the same logical network, - * or the route turns out to be for the net (aka subnet 0). + * or the route is the "internal" route for the net. */ inet_sendsubnet(rt, dst) struct rt_entry *rt; @@ -159,20 +162,26 @@ inet_sendsubnet(rt, dst) return ((rt->rt_state & RTS_INTERNAL) == 0); return (1); } - return ((r & IN_CLASSA_HOST) == 0); + if (r & IN_CLASSA_HOST) + return (0); + return ((rt->rt_state & RTS_INTERNAL) != 0); } else if (IN_CLASSB(r)) { if ((r & IN_CLASSB_NET) == (d & IN_CLASSB_NET)) { if ((r & IN_CLASSB_HOST) == 0) return ((rt->rt_state & RTS_INTERNAL) == 0); return (1); } - return ((r & IN_CLASSB_HOST) == 0); + if (r & IN_CLASSB_HOST) + return (0); + return ((rt->rt_state & RTS_INTERNAL) != 0); } else { if ((r & IN_CLASSC_NET) == (d & IN_CLASSC_NET)) { if ((r & IN_CLASSC_HOST) == 0) return ((rt->rt_state & RTS_INTERNAL) == 0); return (1); } - return ((r & IN_CLASSC_HOST) == 0); + if (r & IN_CLASSC_HOST) + return (0); + return ((rt->rt_state & RTS_INTERNAL) != 0); } } diff --git a/usr/src/sbin/routed/input.c b/usr/src/sbin/routed/input.c index 6eee6d2848..e96cfbf6b1 100644 --- a/usr/src/sbin/routed/input.c +++ b/usr/src/sbin/routed/input.c @@ -5,7 +5,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)input.c 5.5 (Berkeley) %G%"; +static char sccsid[] = "@(#)input.c 5.6 (Berkeley) %G%"; #endif not lint /* @@ -164,7 +164,9 @@ rip_input(from, size) continue; } rt = rtlookup(&n->rip_dst); - if (rt == 0) { + if (rt == 0 || + (rt->rt_state & (RTS_INTERNAL|RTS_INTERFACE)) == + (RTS_INTERNAL|RTS_INTERFACE)) { rt = rtfind(&n->rip_dst); if (rt && equal(from, &rt->rt_router) && rt->rt_metric == n->rip_metric) diff --git a/usr/src/sbin/routed/startup.c b/usr/src/sbin/routed/startup.c index 92ef9b7c95..a3a4ece893 100644 --- a/usr/src/sbin/routed/startup.c +++ b/usr/src/sbin/routed/startup.c @@ -5,7 +5,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)startup.c 5.5 (Berkeley) %G%"; +static char sccsid[] = "@(#)startup.c 5.6 (Berkeley) %G%"; #endif not lint /* @@ -193,11 +193,12 @@ addrouteforif(ifp) if ((ifp->int_flags & (IFF_SUBNET|IFF_POINTOPOINT)) == IFF_SUBNET) { net.sin_addr = inet_makeaddr(ifp->int_net, INADDR_ANY); rt = rtfind(dst); - if (rt && (rt->rt_state & RTS_INTERFACE)) + if (rt && (rt->rt_state & (RTS_INTERNAL | RTS_INTERFACE)) == + (RTS_INTERNAL | RTS_INTERFACE)) return; rtadd(dst, &ifp->int_addr, ifp->int_metric, - (ifp->int_flags & (IFF_INTERFACE|IFF_PASSIVE|IFF_REMOTE) | - RTS_INTERNAL | RTS_SUBNET)); + ((ifp->int_flags & (IFF_INTERFACE|IFF_REMOTE)) | + RTS_PASSIVE | RTS_INTERNAL | RTS_SUBNET)); } } -- 2.20.1