Browse Source

ripd: Fix restriction on default RTE that's incompatible with CIDR

* ripd.c: (rip_response_process) A 0 address can still easily have a
  non-zero netmask.  E.g., 0/1 to complement 128/1.  These should be allowed
  through. See bug #903.

  Modify to check for malformed pseudo-default routes, where the netmask is
  0 but the address is non-0, and warn and drop such routes instead.
Jim Carroll 3 years ago
parent
commit
f452d5409a
1 changed files with 12 additions and 10 deletions
  1. 12 10
      ripd/ripd.c

+ 12 - 10
ripd/ripd.c

@@ -1312,17 +1312,19 @@ rip_response_process (struct rip_packet *packet, int size,
 	  rip_peer_bad_route (from);
 	  continue;
 	}
-
-      /* Default route's netmask is ignored. */
+      
+      /* Default route sanity check */
       if (packet->version == RIPv2
-	  && (rte->prefix.s_addr == 0)
-	  && (rte->mask.s_addr != 0))
-	{
-	  if (IS_RIP_DEBUG_EVENT)
-	    zlog_debug ("Default route with non-zero netmask.  Set zero to netmask");
-	  rte->mask.s_addr = 0;
-	}
-	  
+          && (rte->mask.s_addr == 0)
+          && (rte->prefix.s_addr != 0))
+        {
+          if (IS_RIP_DEBUG_EVENT)
+            zlog_warn ("Malformed route, zero netmask "
+                       "with non-zero addr - dropping route!");
+          rip_peer_bad_route (from);
+          continue;
+        }
+      
       /* Routing table updates. */
       rip_rte_process (rte, from, ifc->ifp);
     }