try again; can't block subnet 0 with internal "network" route
authorMike Karels <karels@ucbvax.Berkeley.EDU>
Wed, 4 Jun 1986 07:32:35 +0000 (23:32 -0800)
committerMike Karels <karels@ucbvax.Berkeley.EDU>
Wed, 4 Jun 1986 07:32:35 +0000 (23:32 -0800)
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
usr/src/sbin/routed/input.c
usr/src/sbin/routed/startup.c

index f7498ec..ef7c52e 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)inet.c     5.3 (Berkeley) %G%";
+static char sccsid[] = "@(#)inet.c     5.4 (Berkeley) %G%";
 #endif not lint
 
 /*
 #endif not lint
 
 /*
@@ -124,26 +124,29 @@ inet_rtflags(sin)
                host = i & IN_CLASSC_HOST;
        }
 
                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) {
        /*
         * 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_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,
  * 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;
  */
 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 ((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);
                }
        } 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);
                }
        } 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);
        }
 }
        }
 }
index 6eee6d2..e96cfbf 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)input.c    5.5 (Berkeley) %G%";
+static char sccsid[] = "@(#)input.c    5.6 (Berkeley) %G%";
 #endif not lint
 
 /*
 #endif not lint
 
 /*
@@ -164,7 +164,9 @@ rip_input(from, size)
                                continue;
                        }
                        rt = rtlookup(&n->rip_dst);
                                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)
                                rt = rtfind(&n->rip_dst);
                                if (rt && equal(from, &rt->rt_router) &&
                                    rt->rt_metric == n->rip_metric)
index 92ef9b7..a3a4ece 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)startup.c  5.5 (Berkeley) %G%";
+static char sccsid[] = "@(#)startup.c  5.6 (Berkeley) %G%";
 #endif not lint
 
 /*
 #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 ((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,
                        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));
        }
 }
 
        }
 }