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.
diff --git a/ripd/ripd.c b/ripd/ripd.c
index 4ce5cc3..dd3ca5b 100644
--- a/ripd/ripd.c
+++ b/ripd/ripd.c
@@ -1312,17 +1312,19 @@
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);
}