From: Andrew J. Schorr <aschorr@telemetry-investments.com>
Subject: [zebra 12403] patch for ripd to accept any version of RIP
by default
The default Cisco IOS behavior is to send RIP version 1 packets and receive
version 1 and version 2 packets. But zebra version 0.92a sends and receives
only version 2 packets by default.
I have patched the code to change zebra's default behavior to sending
version 2 packets (same as before) but receiving both versions. While
this is still not identical to Cisco's behavior, it does now accept
packets of both versions and retains backwards compatibility with
zebra configurations.
diff --git a/ripd/ChangeLog b/ripd/ChangeLog
index c80338d..d83714a 100644
--- a/ripd/ChangeLog
+++ b/ripd/ChangeLog
@@ -1,6 +1,11 @@
+2003-06-07 Andrew J. Schorr <aschorr@telemetry-investments.com>
+
+ * Allow ripd to receive RIPv1
+ * add default as valid param to passive-interface command
+
2003-05-25 Vincent Jardin <vjardin@wanadoo.fr>
- * 6Wind patch merge.
+ * 6Wind patch merge.
2003-04-19 Hasso Tepper <hasso@estpak.ee>
diff --git a/ripd/rip_interface.c b/ripd/rip_interface.c
index 3a1d81d..1aec0f0 100644
--- a/ripd/rip_interface.c
+++ b/ripd/rip_interface.c
@@ -269,21 +269,14 @@
/* If there is no version configuration in the interface,
use rip's version setting. */
- if (ri->ri_send == RI_RIP_UNSPEC)
- {
- if (rip->version == RIPv1)
- rip_request_interface_send (ifp, RIPv1);
- else
- rip_request_interface_send (ifp, RIPv2);
- }
- /* If interface has RIP version configuration use it. */
- else
- {
- if (ri->ri_send & RIPv1)
- rip_request_interface_send (ifp, RIPv1);
- if (ri->ri_send & RIPv2)
- rip_request_interface_send (ifp, RIPv2);
- }
+ {
+ int vsend = ((ri->ri_send == RI_RIP_UNSPEC) ?
+ rip->version_send : ri->ri_send);
+ if (vsend & RIPv1)
+ rip_request_interface_send (ifp, RIPv1);
+ if (vsend & RIPv2)
+ rip_request_interface_send (ifp, RIPv2);
+ }
}
/* Send RIP request to the neighbor. */
@@ -296,7 +289,7 @@
to.sin_port = htons (RIP_PORT_DEFAULT);
to.sin_addr = addr;
- rip_request_send (&to, NULL, rip->version);
+ rip_request_send (&to, NULL, rip->version_send);
}
/* Request routes at all interfaces. */
diff --git a/ripd/ripd.c b/ripd/ripd.c
index 31cfe0c..c9289e7 100644
--- a/ripd/ripd.c
+++ b/ripd/ripd.c
@@ -1687,21 +1687,10 @@
/* RIP Version check. */
if (packet->command == RIP_RESPONSE)
{
- if (ri->ri_receive == RI_RIP_UNSPEC)
- {
- if (packet->version != rip->version)
- {
- if (IS_RIP_DEBUG_PACKET)
- zlog_warn (" packet's v%d doesn't fit to my version %d",
- packet->version, rip->version);
- rip_peer_bad_packet (&from);
- return -1;
- }
- }
- else
- {
+ int vrecv = ((ri->ri_receive == RI_RIP_UNSPEC) ?
+ rip->version_recv : ri->ri_receive);
if (packet->version == RIPv1)
- if (! (ri->ri_receive & RIPv1))
+ if (! (vrecv & RIPv1))
{
if (IS_RIP_DEBUG_PACKET)
zlog_warn (" packet's v%d doesn't fit to if version spec",
@@ -1710,7 +1699,7 @@
return -1;
}
if (packet->version == RIPv2)
- if (! (ri->ri_receive & RIPv2))
+ if (! (vrecv & RIPv2))
{
if (IS_RIP_DEBUG_PACKET)
zlog_warn (" packet's v%d doesn't fit to if version spec",
@@ -1718,7 +1707,6 @@
rip_peer_bad_packet (&from);
return -1;
}
- }
}
/* RFC2453 5.2 If the router is not configured to authenticate RIP-2
@@ -2300,7 +2288,7 @@
inet_ntoa (to.sin_addr), ifp->name);
rip_output_process (ifp, connected->address, &to, route_type,
- version);
+ version_send);
}
}
}
@@ -2350,21 +2338,14 @@
/* If there is no version configuration in the interface,
use rip's version setting. */
- if (ri->ri_send == RI_RIP_UNSPEC)
- {
- if (rip->version == RIPv1)
+ {
+ int vsend = ((ri->ri_send == RI_RIP_UNSPEC) ?
+ rip->version_send : ri->ri_send);
+ if (vsend & RIPv1)
rip_update_interface (ifp, RIPv1, route_type);
- else
+ if (vsend & RIPv2)
rip_update_interface (ifp, RIPv2, route_type);
- }
- /* If interface has RIP version configuration use it. */
- else
- {
- if (ri->ri_send & RIPv1)
- rip_update_interface (ifp, RIPv1, route_type);
- if (ri->ri_send & RIPv2)
- rip_update_interface (ifp, RIPv2, route_type);
- }
+ }
}
}
@@ -2534,7 +2515,8 @@
memset (rip, 0, sizeof (struct rip));
/* Set initial value. */
- rip->version = RIPv2;
+ rip->version_send = RI_RIP_VERSION_2;
+ rip->version_recv = RI_RIP_VERSION_1_AND_2;
rip->update_time = RIP_UPDATE_TIMER_DEFAULT;
rip->timeout_time = RIP_TIMEOUT_TIMER_DEFAULT;
rip->garbage_time = RIP_GARBAGE_TIMER_DEFAULT;
@@ -2668,7 +2650,8 @@
VTY_NEWLINE);
return CMD_WARNING;
}
- rip->version = version;
+ rip->version_send = version;
+ rip->version_recv = version;
return CMD_SUCCESS;
}
@@ -2680,7 +2663,8 @@
"Set routing protocol version\n")
{
/* Set RIP version to the default. */
- rip->version = RIPv2;
+ rip->version_send = RI_RIP_VERSION_2;
+ rip->version_recv = RI_RIP_VERSION_1_AND_2;
return CMD_SUCCESS;
}
@@ -3328,9 +3312,13 @@
config_write_rip_redistribute (vty, 0);
vty_out (vty, "%s", VTY_NEWLINE);
- vty_out (vty, " Default version control: send version %d,", rip->version);
- vty_out (vty, " receive version %d %s", rip->version,
- VTY_NEWLINE);
+ vty_out (vty, " Default version control: send version %s,",
+ lookup(ri_version_msg,rip->version_send));
+ if (rip->version_recv == RI_RIP_VERSION_1_AND_2)
+ vty_out (vty, " receive any version %s", VTY_NEWLINE);
+ else
+ vty_out (vty, " receive version %s %s",
+ lookup(ri_version_msg,rip->version_recv), VTY_NEWLINE);
vty_out (vty, " Interface Send Recv Key-chain%s", VTY_NEWLINE);
@@ -3342,12 +3330,12 @@
if (ri->enable_network || ri->enable_interface)
{
if (ri->ri_send == RI_RIP_UNSPEC)
- send_version = lookup (ri_version_msg, rip->version);
+ send_version = lookup (ri_version_msg, rip->version_send);
else
send_version = lookup (ri_version_msg, ri->ri_send);
if (ri->ri_receive == RI_RIP_UNSPEC)
- receive_version = lookup (ri_version_msg, rip->version);
+ receive_version = lookup (ri_version_msg, rip->version_recv);
else
receive_version = lookup (ri_version_msg, ri->ri_receive);
@@ -3405,8 +3393,9 @@
write++;
/* RIP version statement. Default is RIP version 2. */
- if (rip->version != RIPv2)
- vty_out (vty, " version %d%s", rip->version,
+ if (rip->version_send != RI_RIP_VERSION_2
+ || rip->version_recv != RI_RIP_VERSION_1_AND_2)
+ vty_out (vty, " version %d%s", rip->version_send,
VTY_NEWLINE);
/* RIP timer configuration. */
diff --git a/ripd/ripd.h b/ripd/ripd.h
index 23a12c4..c414c76 100644
--- a/ripd/ripd.h
+++ b/ripd/ripd.h
@@ -25,6 +25,9 @@
/* RIP version number. */
#define RIPv1 1
#define RIPv2 2
+/* N.B. stuff will break if
+ (RIPv1 != RI_RIP_VERSION_1) || (RIPv2 != RI_RIP_VERSION_2) */
+
/* RIP command list. */
#define RIP_REQUEST 1
@@ -85,7 +88,8 @@
int sock;
/* Default version of rip instance. */
- u_char version;
+ int version_send; /* version 1 or 2 (but not both) */
+ int version_recv; /* version 1 or 2 or both */
/* Output buffer of RIP. */
struct stream *obuf;
@@ -322,6 +326,8 @@
#define RI_RIP_VERSION_1 1
#define RI_RIP_VERSION_2 2
#define RI_RIP_VERSION_1_AND_2 3
+/* N.B. stuff will break if
+ (RIPv1 != RI_RIP_VERSION_1) || (RIPv2 != RI_RIP_VERSION_2) */
/* Default value for "default-metric" command. */
#define RIP_DEFAULT_METRIC_DEFAULT 1