[quagga-dev 7799] route-map set metric issue with rip

Stig Thormodsrud stig at vyatta.com
Sun Feb 14 23:47:26 GMT 2010


I'm debugging a route-map issue and wanted to get some feedback on my fix
from someone more familiar with the route-maps.

The bug:

vyatta# conf t
vyatta(config)# route-map foo permit 10
vyatta(config-route-map)# set metric 20
vyatta(config-route-map)# no set metric
% Can't find rule.


This error message comes from ripd and the reason it can't find the rule
is that when it was added ripd had a compile error since the metric is
larger than 16.  In rip_route_set_add the error is ignored so that the
other deamons can get the route-map.

	case RMAP_COMPILE_ERROR:
	  /* rip, ripng and other protocols share the set metric command
	     but only values from 0 to 16 are valid for rip and ripng
	     if metric is out of range for rip and ripng, it is not for
	     other protocols. Do not return an error */
	  if (strcmp(command, "metric")) {
	     vty_out (vty, "%% Argument is malformed.%s", VTY_NEWLINE);
	     return CMD_WARNING;
	  }

So the error is ignored on add, but not on delete.  Due to the error the
"no set metric" didn't get sent to the other daemons and so it still shows
up in the config:

vyatta# wr t
Building configuration...

Current configuration:
!
interface eth0
 ipv6 nd suppress-ra
 link-detect
!
interface lo
!
route-map foo permit 10
 set metric 20
!
ip forwarding
ipv6 forwarding
!
line vty
!
end



My initial fix was to also ignore the error on delete with:

diff --git a/ripd/rip_routemap.c b/ripd/rip_routemap.c
index cb87ea5..aaf08a2 100644
--- a/ripd/rip_routemap.c
+++ b/ripd/rip_routemap.c
@@ -133,11 +135,17 @@ rip_route_set_delete (struct vty *vty, struct
route_map_index *index,
       switch (ret)
        {
        case RMAP_RULE_MISSING:
-         vty_out (vty, "%% Can't find rule.%s", VTY_NEWLINE);
-         return CMD_WARNING;
+         if (strcmp(command, "metric") != 0) {
+            vty_out (vty, "%% rip4 Can't find rule.%s", VTY_NEWLINE);
+              return CMD_WARNING;
+         } 
        case RMAP_COMPILE_ERROR:
-         vty_out (vty, "%% Argument is malformed.%s", VTY_NEWLINE);
-         return CMD_WARNING;
+         if (strcmp(command, "metric") != 0) {
+           vty_out (vty, "%% Argument is malformed.%s", VTY_NEWLINE);
+           return CMD_WARNING;
+         } 
        }
   

Then I checked if ripng also need the same fix, but ripng takes a
different approach, by just commenting out the compile error.  In
ripng_routemap.c::route_set_metric_compile() we have:

  /* Commented out by Hasso Tepper, to avoid problems in vtysh. */
  /* if (metric < 0 || metric > RIPNG_METRIC_INFINITY) */



So what is the better approach?  In the first case the rule doesn't exist
and in the second it exists with a metric larger than
RIPNG_METRIC_INFINITY.

Thanks,

stig




More information about the Quagga-dev mailing list