Make "route add 0.0.0.0/X <gw>" where X > 0 work again.
authorHasso Tepper <hasso@estpak.ee>
Sun, 18 Jan 2009 13:21:45 +0000 (15:21 +0200)
committerHasso Tepper <hasso@estpak.ee>
Tue, 20 Jan 2009 08:49:43 +0000 (10:49 +0200)
sbin/route/route.c

index 232f671..80552be 100644 (file)
@@ -915,30 +915,26 @@ inet_makenetandmask(u_long net, struct sockaddr_in *in, u_long bits)
        char *cp;
 
        rtm_addrs |= RTA_NETMASK;
-       if (net == 0)
-               mask = addr = 0;
-       else {
-               if (net <= 0xff)
-                       addr = net << 24;
-               else if (net <= 0xffff)
-                       addr = net << 16;
-               else if (net <= 0xffffff)
-                       addr = net << 8;
-               else
-                       addr = net;
+       if (net <= 0xff)
+               addr = net << 24;
+       else if (net <= 0xffff)
+               addr = net << 16;
+       else if (net <= 0xffffff)
+               addr = net << 8;
+       else
+               addr = net;
 
-               if (bits)
-                       mask = 0xffffffff << (32 - bits);
-               else {
-                       if (IN_CLASSA(addr)) {
-                               mask = IN_CLASSA_NET;
-                       } else if (IN_CLASSB(addr)) {
-                               mask = IN_CLASSB_NET;
-                       } else if (IN_CLASSC(addr)) {
-                               mask = IN_CLASSC_NET;
-                       } else
-                               mask = 0xffffffff;
-               }
+       if (bits)
+               mask = 0xffffffff << (32 - bits);
+       else {
+               if (IN_CLASSA(addr)) {
+                       mask = IN_CLASSA_NET;
+               } else if (IN_CLASSB(addr)) {
+                       mask = IN_CLASSB_NET;
+               } else if (IN_CLASSC(addr)) {
+                       mask = IN_CLASSC_NET;
+               } else
+                       mask = 0xffffffff;
        }
        in->sin_addr.s_addr = htonl(addr);
        in = &so_mask.sin;