Browse Source

ripd, ripngd: add support for route tags

[Forward ported by Cumulus]

Documentation
-------------
All ipv4 and ipv6 static route commands now have a "tag" option
which allows the user to set a tag between 1 and 65535.

quagga(config)# ip route 1.1.1.1/32 10.1.1.1 tag ?
  <1-65535>  Tag value
quagga(config)# ip route 1.1.1.1/32 10.1.1.1 tag 40
quagga(config)#

quagga# show ip route 1.1.1.1/32
Routing entry for 1.1.1.1/32
  Known via "static", distance 1, metric 0, tag 40, best
  * 10.1.1.1, via swp1

quagga#

The route-map parser supports matching on tags and setting tags
!
route-map MATCH_TAG_18 permit 10
  match tag 18
!

!
route-map SET_TAG_22 permit 10
  set tag 22
!

BGP and OSPF support:
- matching on tags when redistribing routes from the RIB into BGP/OSPF.
- setting tags when redistribing routes from the RIB into BGP/OSPF.

BGP also supports setting a tag via a table-map, when installing BGP
routes into the RIB.

Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
Signed-off-by: Piotr Chytla <pch@packetconsulting.pl>
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Piotr Chytła 3 years ago
parent
commit
3b4fb574b4
2 changed files with 22 additions and 9 deletions
  1. 18 5
      ripd/rip_routemap.c
  2. 4 4
      ripngd/ripng_routemap.c

+ 18 - 5
ripd/rip_routemap.c

@@ -485,9 +485,22 @@ static void *
 route_match_tag_compile (const char *arg)
 {
   u_short *tag;
+  u_short tmp;
+
+  /* tag value shoud be integer. */
+  if (! all_digit (arg))
+    return NULL;
+
+  tmp = atoi(arg);
+  if (tmp < 1)
+    return NULL;
 
   tag = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (u_short));
-  *tag = atoi (arg);
+
+  if (!tag)
+    return tag;
+
+  *tag = tmp;
 
   return tag;
 }
@@ -937,7 +950,7 @@ ALIAS (no_match_ip_address_prefix_list,
 
 DEFUN (match_tag, 
        match_tag_cmd,
-       "match tag <0-65535>",
+       "match tag <1-65535>",
        MATCH_STR
        "Match tag of route\n"
        "Metric value\n")
@@ -960,7 +973,7 @@ DEFUN (no_match_tag,
 
 ALIAS (no_match_tag,
        no_match_tag_val_cmd,
-       "no match tag <0-65535>",
+       "no match tag <1-65535>",
        NO_STR
        MATCH_STR
        "Match tag of route\n"
@@ -1060,7 +1073,7 @@ ALIAS (no_set_ip_nexthop,
 
 DEFUN (set_tag,
        set_tag_cmd,
-       "set tag <0-65535>",
+       "set tag <1-65535>",
        SET_STR
        "Tag value for routing protocol\n"
        "Tag value\n")
@@ -1083,7 +1096,7 @@ DEFUN (no_set_tag,
 
 ALIAS (no_set_tag,
        no_set_tag_val_cmd,
-       "no set tag <0-65535>",
+       "no set tag <1-65535>",
        NO_STR
        SET_STR
        "Tag value for routing protocol\n"

+ 4 - 4
ripngd/ripng_routemap.c

@@ -564,7 +564,7 @@ ALIAS (no_match_interface,
 
 DEFUN (match_tag,
        match_tag_cmd,
-       "match tag <0-65535>",
+       "match tag <1-65535>",
        MATCH_STR
        "Match tag of route\n"
        "Metric value\n")
@@ -587,7 +587,7 @@ DEFUN (no_match_tag,
 
 ALIAS (no_match_tag,
        no_match_tag_val_cmd,
-       "no match tag <0-65535>",
+       "no match tag <1-65535>",
        NO_STR
        MATCH_STR
        "Match tag of route\n"
@@ -675,7 +675,7 @@ ALIAS (no_set_ipv6_nexthop_local,
 
 DEFUN (set_tag,
        set_tag_cmd,
-       "set tag <0-65535>",
+       "set tag <1-65535>",
        SET_STR
        "Tag value for routing protocol\n"
        "Tag value\n")
@@ -698,7 +698,7 @@ DEFUN (no_set_tag,
 
 ALIAS (no_set_tag,
        no_set_tag_val_cmd,
-       "no set tag <0-65535>",
+       "no set tag <1-65535>",
        NO_STR
        SET_STR
        "Tag value for routing protocol\n"