From: Daniel Walton <[email protected]> Add internal support for a route tag to be applied to routes. At this point in time, tags are not being used.
Credit ------ A huge amount of credit for this patch goes to Piotr Chytla for their 'route tags support' patch that was submitted to quagga-dev in June 2007. Signed-off-by: Daniel Walton <[email protected]> Signed-off-by: Piotr Chytla <[email protected]> Signed-off-by: Donald Sharp <[email protected]> --- zebra/rib.h | 14 ++- zebra/zebra_rib.c | 36 ++++--- zebra/zebra_vty.c | 294 ++++++++++++++++++++++++++++-------------------------- 3 files changed, 185 insertions(+), 159 deletions(-) diff --git a/zebra/rib.h b/zebra/rib.h index 6668873..c8bc46d 100644 --- a/zebra/rib.h +++ b/zebra/rib.h @@ -65,6 +65,9 @@ struct rib /* Distance. */ u_char distance; + /* Tag */ + u_short tag; + /* Flags of this route. * This flag's definition is in lib/zebra.h ZEBRA_FLAG_* and is exposed * to clients via Zserv @@ -177,6 +180,9 @@ struct static_route /* Administrative distance. */ u_char distance; + /* Tag */ + u_short tag; + /* Flag for this static route's type. */ u_char type; #define STATIC_IPV4_GATEWAY 1 @@ -443,11 +449,11 @@ extern unsigned long rib_score_proto (u_char proto); extern int static_add_ipv4_safi (safi_t safi, struct prefix *p, struct in_addr *gate, - const char *ifname, u_char flags, u_char distance, + const char *ifname, u_char flags, u_short tag, u_char distance, vrf_id_t vrf_id); extern int static_delete_ipv4_safi (safi_t safi, struct prefix *p, struct in_addr *gate, - const char *ifname, u_char distance, vrf_id_t vrf_id); + const char *ifname, u_short tag, u_char distance, vrf_id_t vrf_id); extern int rib_add_ipv6 (int type, int flags, struct prefix_ipv6 *p, @@ -467,7 +473,7 @@ extern struct route_table *rib_table_ipv6; extern int static_add_ipv6 (struct prefix *p, u_char type, struct in6_addr *gate, - const char *ifname, u_char flags, u_char distance, + const char *ifname, u_char flags, u_short tag, u_char distance, vrf_id_t vrf_id); extern int @@ -475,7 +481,7 @@ rib_add_ipv6_multipath (struct prefix_ipv6 *, struct rib *, safi_t); extern int static_delete_ipv6 (struct prefix *p, u_char type, struct in6_addr *gate, - const char *ifname, u_char distance, vrf_id_t vrf_id); + const char *ifname, u_short tag, u_char distance, vrf_id_t vrf_id); extern int rib_gc_dest (struct route_node *rn); extern struct route_table *rib_tables_iter_next (rib_tables_iter_t *iter); diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index 47acdad..734d57c 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -2254,6 +2254,10 @@ static_install_route (afi_t afi, safi_t safi, struct prefix *p, struct static_ro if (rib) { + /* if tag value changed , update old value in RIB */ + if (rib->tag != si->tag) + rib->tag = si->tag; + /* Same distance static route is there. Update it with new nexthop. */ route_unlock_node (rn); @@ -2291,6 +2295,7 @@ static_install_route (afi_t afi, safi_t safi, struct prefix *p, struct static_ro rib->vrf_id = si->vrf_id; rib->table = zebrad.rtm_table_default; rib->nexthop_num = 0; + rib->tag = si->tag; switch (si->type) { @@ -2376,7 +2381,8 @@ static_uninstall_route (afi_t afi, safi_t safi, struct prefix *p, struct static_ if (CHECK_FLAG (rib->status, RIB_ENTRY_REMOVED)) continue; - if (rib->type == ZEBRA_ROUTE_STATIC && rib->distance == si->distance) + if (rib->type == ZEBRA_ROUTE_STATIC && rib->distance == si->distance && + rib->tag == si->tag) break; } @@ -2415,7 +2421,7 @@ static_uninstall_route (afi_t afi, safi_t safi, struct prefix *p, struct static_ int static_add_ipv4_safi (safi_t safi, struct prefix *p, struct in_addr *gate, - const char *ifname, u_char flags, u_char distance, + const char *ifname, u_char flags, u_short tag, u_char distance, vrf_id_t vrf_id) { u_char type = 0; @@ -2448,7 +2454,8 @@ static_add_ipv4_safi (safi_t safi, struct prefix *p, struct in_addr *gate, && (! gate || IPV4_ADDR_SAME (gate, &si->addr.ipv4)) && (! ifname || strcmp (ifname, si->ifname) == 0)) { - if (distance == si->distance) + if (distance == si->distance && + tag == si->tag) { route_unlock_node (rn); return 0; @@ -2458,15 +2465,16 @@ static_add_ipv4_safi (safi_t safi, struct prefix *p, struct in_addr *gate, } } - /* Distance changed. */ + /* Distance or tag changed. */ if (update) - static_delete_ipv4_safi (safi, p, gate, ifname, update->distance, vrf_id); + static_delete_ipv4_safi (safi, p, gate, ifname, update->tag, update->distance, vrf_id); /* Make new static route structure. */ si = XCALLOC (MTYPE_STATIC_ROUTE, sizeof (struct static_route)); si->type = type; si->distance = distance; + si->tag = tag; si->flags = flags; si->vrf_id = vrf_id; @@ -2510,7 +2518,7 @@ static_add_ipv4_safi (safi_t safi, struct prefix *p, struct in_addr *gate, int static_delete_ipv4_safi (safi_t safi, struct prefix *p, struct in_addr *gate, - const char *ifname, u_char distance, vrf_id_t vrf_id) + const char *ifname, u_short tag, u_char distance, vrf_id_t vrf_id) { u_char type = 0; struct route_node *rn; @@ -2539,7 +2547,8 @@ static_delete_ipv4_safi (safi_t safi, struct prefix *p, struct in_addr *gate, for (si = rn->info; si; si = si->next) if (type == si->type && (! gate || IPV4_ADDR_SAME (gate, &si->addr.ipv4)) - && (! ifname || strcmp (ifname, si->ifname) == 0)) + && (! ifname || strcmp (ifname, si->ifname) == 0) + && (! tag || (tag == si->tag))) break; /* Can't find static route. */ @@ -2894,8 +2903,8 @@ rib_delete_ipv6 (int type, int flags, struct prefix_ipv6 *p, /* Add static route into static route configuration. */ int static_add_ipv6 (struct prefix *p, u_char type, struct in6_addr *gate, - const char *ifname, u_char flags, u_char distance, - vrf_id_t vrf_id) + const char *ifname, u_char flags, u_short tag, + u_char distance, vrf_id_t vrf_id) { struct route_node *rn; struct static_route *si; @@ -2923,6 +2932,7 @@ static_add_ipv6 (struct prefix *p, u_char type, struct in6_addr *gate, for (si = rn->info; si; si = si->next) { if (type == si->type + && tag == si->tag && (! gate || IPV6_ADDR_SAME (gate, &si->addr.ipv6)) && (! ifname || strcmp (ifname, si->ifname) == 0)) { @@ -2937,13 +2947,14 @@ static_add_ipv6 (struct prefix *p, u_char type, struct in6_addr *gate, } if (update) - static_delete_ipv6(p, type, gate, ifname, si->distance, vrf_id); + static_delete_ipv6(p, type, gate, ifname, tag, si->distance, vrf_id); /* Make new static route structure. */ si = XCALLOC (MTYPE_STATIC_ROUTE, sizeof (struct static_route)); si->type = type; si->distance = distance; + si->tag = tag; si->flags = flags; si->vrf_id = vrf_id; @@ -2990,7 +3001,7 @@ static_add_ipv6 (struct prefix *p, u_char type, struct in6_addr *gate, /* Delete static route from static route configuration. */ int static_delete_ipv6 (struct prefix *p, u_char type, struct in6_addr *gate, - const char *ifname, u_char distance, vrf_id_t vrf_id) + const char *ifname, u_short tag, u_char distance, vrf_id_t vrf_id) { struct route_node *rn; struct static_route *si; @@ -3011,7 +3022,8 @@ static_delete_ipv6 (struct prefix *p, u_char type, struct in6_addr *gate, if (distance == si->distance && type == si->type && (! gate || IPV6_ADDR_SAME (gate, &si->addr.ipv6)) - && (! ifname || strcmp (ifname, si->ifname) == 0)) + && (! ifname || strcmp (ifname, si->ifname) == 0) + && (! tag || (tag == si->tag))) break; /* Can't find static route. */ diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index 5aee939..03f4a0a 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -44,7 +44,8 @@ static int zebra_static_ipv4_safi (struct vty *vty, safi_t safi, int add_cmd, const char *dest_str, const char *mask_str, const char *gate_str, const char *flag_str, - const char *distance_str, const char *vrf_id_str) + const char *tag_str, const char *distance_str, + const char *vrf_id_str) { int ret; u_char distance; @@ -53,6 +54,7 @@ zebra_static_ipv4_safi (struct vty *vty, safi_t safi, int add_cmd, struct in_addr mask; const char *ifname; u_char flag = 0; + u_short tag = 0; vrf_id_t vrf_id = VRF_DEFAULT; ret = str2prefix (dest_str, &p); @@ -83,6 +85,10 @@ zebra_static_ipv4_safi (struct vty *vty, safi_t safi, int add_cmd, else distance = ZEBRA_STATIC_DISTANCE_DEFAULT; + /* tag */ + if (tag_str) + tag = atoi (tag_str); + /* VRF id */ if (vrf_id_str) VTY_GET_INTEGER ("VRF ID", vrf_id, vrf_id_str); @@ -96,9 +102,9 @@ zebra_static_ipv4_safi (struct vty *vty, safi_t safi, int add_cmd, return CMD_WARNING; } if (add_cmd) - static_add_ipv4_safi (safi, &p, NULL, NULL, ZEBRA_FLAG_BLACKHOLE, distance, vrf_id); + static_add_ipv4_safi (safi, &p, NULL, NULL, ZEBRA_FLAG_BLACKHOLE, tag, distance, vrf_id); else - static_delete_ipv4_safi (safi, &p, NULL, NULL, distance, vrf_id); + static_delete_ipv4_safi (safi, &p, NULL, NULL, tag, distance, vrf_id); return CMD_SUCCESS; } @@ -122,9 +128,9 @@ zebra_static_ipv4_safi (struct vty *vty, safi_t safi, int add_cmd, if (gate_str == NULL) { if (add_cmd) - static_add_ipv4_safi (safi, &p, NULL, NULL, flag, distance, vrf_id); + static_add_ipv4_safi (safi, &p, NULL, NULL, flag, tag, distance, vrf_id); else - static_delete_ipv4_safi (safi, &p, NULL, NULL, distance, vrf_id); + static_delete_ipv4_safi (safi, &p, NULL, NULL, tag, distance, vrf_id); return CMD_SUCCESS; } @@ -138,23 +144,13 @@ zebra_static_ipv4_safi (struct vty *vty, safi_t safi, int add_cmd, ifname = gate_str; if (add_cmd) - static_add_ipv4_safi (safi, &p, ifname ? NULL : &gate, ifname, flag, distance, vrf_id); + static_add_ipv4_safi (safi, &p, ifname ? NULL : &gate, ifname, flag, tag, distance, vrf_id); else - static_delete_ipv4_safi (safi, &p, ifname ? NULL : &gate, ifname, distance, vrf_id); + static_delete_ipv4_safi (safi, &p, ifname ? NULL : &gate, ifname, tag, distance, vrf_id); return CMD_SUCCESS; } -static int -zebra_static_ipv4 (struct vty *vty, int add_cmd, const char *dest_str, - const char *mask_str, const char *gate_str, - const char *flag_str, const char *distance_str, - const char *vrf_id_str) -{ - return zebra_static_ipv4_safi (vty, SAFI_UNICAST, add_cmd, dest_str, mask_str, - gate_str, flag_str, distance_str, vrf_id_str); -} - /* Static unicast routes for multicast RPF lookup. */ DEFUN (ip_mroute_dist, ip_mroute_dist_cmd, @@ -168,7 +164,7 @@ DEFUN (ip_mroute_dist, { VTY_WARN_EXPERIMENTAL(); return zebra_static_ipv4_safi(vty, SAFI_MULTICAST, 1, argv[0], NULL, argv[1], - NULL, argc > 2 ? argv[2] : NULL, NULL); + NULL, NULL, argc > 2 ? argv[2] : NULL, NULL); } ALIAS (ip_mroute_dist, @@ -193,7 +189,7 @@ DEFUN (ip_mroute_dist_vrf, { VTY_WARN_EXPERIMENTAL(); return zebra_static_ipv4_safi(vty, SAFI_MULTICAST, 1, argv[0], NULL, argv[1], - NULL, argc > 3 ? argv[2] : NULL, + NULL, NULL, argc > 3 ? argv[2] : NULL, argc > 3 ? argv[3] : argv[2]); } @@ -219,7 +215,7 @@ DEFUN (no_ip_mroute_dist, { VTY_WARN_EXPERIMENTAL(); return zebra_static_ipv4_safi(vty, SAFI_MULTICAST, 0, argv[0], NULL, argv[1], - NULL, argc > 2 ? argv[2] : NULL, NULL); + NULL, NULL, argc > 2 ? argv[2] : NULL, NULL); } ALIAS (no_ip_mroute_dist, @@ -245,7 +241,7 @@ DEFUN (no_ip_mroute_dist_vrf, { VTY_WARN_EXPERIMENTAL(); return zebra_static_ipv4_safi(vty, SAFI_MULTICAST, 0, argv[0], NULL, argv[1], - NULL, argc > 3 ? argv[2] : NULL, + NULL, NULL, argc > 3 ? argv[2] : NULL, argc > 3 ? argv[3] : argv[2]); } @@ -469,8 +465,8 @@ DEFUN (ip_route, "IP gateway interface name\n" "Null interface\n") { - return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], NULL, NULL, - NULL); + return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], NULL, argv[1], + NULL, NULL, NULL, NULL); } DEFUN (ip_route_flags, @@ -484,8 +480,8 @@ DEFUN (ip_route_flags, "Emit an ICMP unreachable when matched\n" "Silently discard pkts when matched\n") { - return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], argv[2], NULL, - NULL); + return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], NULL, argv[1], + argv[2], NULL, NULL, NULL); } DEFUN (ip_route_flags2, @@ -497,8 +493,8 @@ DEFUN (ip_route_flags2, "Emit an ICMP unreachable when matched\n" "Silently discard pkts when matched\n") { - return zebra_static_ipv4 (vty, 1, argv[0], NULL, NULL, argv[1], NULL, - NULL); + return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], NULL, + NULL, argv[1], NULL, NULL, NULL); } /* Mask as A.B.C.D format. */ @@ -513,8 +509,8 @@ DEFUN (ip_route_mask, "IP gateway interface name\n" "Null interface\n") { - return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], NULL, NULL, - NULL); + return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], argv[1], + argv[2], NULL, NULL, NULL, NULL); } DEFUN (ip_route_mask_flags, @@ -529,8 +525,8 @@ DEFUN (ip_route_mask_flags, "Emit an ICMP unreachable when matched\n" "Silently discard pkts when matched\n") { - return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL, - NULL); + return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], argv[1], + argv[2], argv[3], NULL, NULL, NULL); } DEFUN (ip_route_mask_flags2, @@ -543,8 +539,8 @@ DEFUN (ip_route_mask_flags2, "Emit an ICMP unreachable when matched\n" "Silently discard pkts when matched\n") { - return zebra_static_ipv4 (vty, 1, argv[0], argv[1], NULL, argv[2], NULL, - NULL); + return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], argv[1], + NULL, argv[2], NULL, NULL, NULL); } /* Distance option value. */ @@ -559,8 +555,8 @@ DEFUN (ip_route_distance, "Null interface\n" "Distance value for this route\n") { - return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], NULL, argv[2], - NULL); + return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], NULL, + argv[1], NULL, NULL, argv[2], NULL); } DEFUN (ip_route_flags_distance, @@ -575,8 +571,8 @@ DEFUN (ip_route_flags_distance, "Silently discard pkts when matched\n" "Distance value for this route\n") { - return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], argv[2], argv[3], - NULL); + return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], NULL, argv[1], + argv[2], NULL, argv[3], NULL); } DEFUN (ip_route_flags_distance2, @@ -589,8 +585,8 @@ DEFUN (ip_route_flags_distance2, "Silently discard pkts when matched\n" "Distance value for this route\n") { - return zebra_static_ipv4 (vty, 1, argv[0], NULL, NULL, argv[1], argv[2], - NULL); + return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], NULL, + NULL, argv[1], NULL, argv[2], NULL); } DEFUN (ip_route_mask_distance, @@ -605,8 +601,8 @@ DEFUN (ip_route_mask_distance, "Null interface\n" "Distance value for this route\n") { - return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3], - NULL); + return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], argv[1], argv[2], + NULL, NULL, argv[3], NULL); } DEFUN (ip_route_mask_flags_distance, @@ -622,8 +618,8 @@ DEFUN (ip_route_mask_flags_distance, "Silently discard pkts when matched\n" "Distance value for this route\n") { - return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4], - NULL); + return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], argv[1], argv[2], + argv[3], NULL, argv[4], NULL); } DEFUN (ip_route_mask_flags_distance2, @@ -637,8 +633,8 @@ DEFUN (ip_route_mask_flags_distance2, "Silently discard pkts when matched\n" "Distance value for this route\n") { - return zebra_static_ipv4 (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3], - NULL); + return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], argv[1], + NULL, argv[2], NULL, argv[3], NULL); } DEFUN (no_ip_route, @@ -652,8 +648,8 @@ DEFUN (no_ip_route, "IP gateway interface name\n" "Null interface\n") { - return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], NULL, NULL, - NULL); + return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], NULL, + argv[1], NULL, NULL, NULL, NULL); } ALIAS (no_ip_route, @@ -678,8 +674,8 @@ DEFUN (no_ip_route_flags2, "Emit an ICMP unreachable when matched\n" "Silently discard pkts when matched\n") { - return zebra_static_ipv4 (vty, 0, argv[0], NULL, NULL, NULL, NULL, - NULL); + return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], NULL, + NULL, NULL, NULL, NULL, NULL); } DEFUN (no_ip_route_mask, @@ -694,8 +690,8 @@ DEFUN (no_ip_route_mask, "IP gateway interface name\n" "Null interface\n") { - return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], NULL, NULL, - NULL); + return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], argv[1], + argv[2], NULL, NULL, NULL, NULL); } ALIAS (no_ip_route_mask, @@ -722,8 +718,8 @@ DEFUN (no_ip_route_mask_flags2, "Emit an ICMP unreachable when matched\n" "Silently discard pkts when matched\n") { - return zebra_static_ipv4 (vty, 0, argv[0], argv[1], NULL, NULL, NULL, - NULL); + return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], argv[1], + NULL, NULL, NULL, NULL, NULL); } DEFUN (no_ip_route_distance, @@ -738,8 +734,8 @@ DEFUN (no_ip_route_distance, "Null interface\n" "Distance value for this route\n") { - return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], NULL, argv[2], - NULL); + return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], NULL, + argv[1], NULL, NULL, argv[2], NULL); } DEFUN (no_ip_route_flags_distance, @@ -755,8 +751,8 @@ DEFUN (no_ip_route_flags_distance, "Silently discard pkts when matched\n" "Distance value for this route\n") { - return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], argv[2], argv[3], - NULL); + return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], NULL, + argv[1], argv[2], NULL, argv[3], NULL); } DEFUN (no_ip_route_flags_distance2, @@ -770,8 +766,8 @@ DEFUN (no_ip_route_flags_distance2, "Silently discard pkts when matched\n" "Distance value for this route\n") { - return zebra_static_ipv4 (vty, 0, argv[0], NULL, NULL, argv[1], argv[2], - NULL); + return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], NULL, NULL, + argv[1], NULL, argv[2], NULL); } DEFUN (no_ip_route_mask_distance, @@ -787,8 +783,8 @@ DEFUN (no_ip_route_mask_distance, "Null interface\n" "Distance value for this route\n") { - return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3], - NULL); + return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], argv[1], + argv[2], NULL, NULL, argv[3], NULL); } DEFUN (no_ip_route_mask_flags_distance, @@ -805,8 +801,8 @@ DEFUN (no_ip_route_mask_flags_distance, "Silently discard pkts when matched\n" "Distance value for this route\n") { - return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], argv[3], argv[4], - NULL); + return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], argv[1], + argv[2], argv[3], NULL, argv[4], NULL); } DEFUN (no_ip_route_mask_flags_distance2, @@ -821,8 +817,8 @@ DEFUN (no_ip_route_mask_flags_distance2, "Silently discard pkts when matched\n" "Distance value for this route\n") { - return zebra_static_ipv4 (vty, 0, argv[0], argv[1], NULL, argv[2], argv[3], - NULL); + return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], argv[1], + NULL, argv[2], NULL, argv[3], NULL); } DEFUN (ip_route_vrf, @@ -836,8 +832,8 @@ DEFUN (ip_route_vrf, "Null interface\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], NULL, NULL, - argv[2]); + return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], NULL, + argv[1], NULL, NULL, NULL, argv[2]); } DEFUN (ip_route_flags_vrf, @@ -852,8 +848,8 @@ DEFUN (ip_route_flags_vrf, "Silently discard pkts when matched\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], argv[2], NULL, - argv[3]); + return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], NULL, + argv[1], argv[2], NULL, NULL, argv[3]); } DEFUN (ip_route_flags2_vrf, @@ -866,8 +862,8 @@ DEFUN (ip_route_flags2_vrf, "Silently discard pkts when matched\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, 1, argv[0], NULL, NULL, argv[1], NULL, - argv[2]); + return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], NULL, + NULL, argv[1], NULL, NULL, argv[2]); } /* Mask as A.B.C.D format. */ @@ -883,8 +879,8 @@ DEFUN (ip_route_mask_vrf, "Null interface\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], NULL, NULL, - argv[3]); + return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], argv[1], + argv[2], NULL, NULL, NULL, argv[3]); } DEFUN (ip_route_mask_flags_vrf, @@ -900,8 +896,8 @@ DEFUN (ip_route_mask_flags_vrf, "Silently discard pkts when matched\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL, - argv[4]); + return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], argv[1], + argv[2], argv[3], NULL, NULL, argv[4]); } DEFUN (ip_route_mask_flags2_vrf, @@ -915,8 +911,8 @@ DEFUN (ip_route_mask_flags2_vrf, "Silently discard pkts when matched\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, 1, argv[0], argv[1], NULL, argv[2], NULL, - argv[3]); + return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], argv[1], + NULL, argv[2], NULL, NULL, argv[3]); } /* Distance option value. */ @@ -932,8 +928,8 @@ DEFUN (ip_route_distance_vrf, "Distance value for this route\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], NULL, argv[2], - argv[3]); + return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], NULL, + argv[1], NULL, NULL, argv[2], argv[3]); } DEFUN (ip_route_flags_distance_vrf, @@ -949,8 +945,8 @@ DEFUN (ip_route_flags_distance_vrf, "Distance value for this route\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, 1, argv[0], NULL, argv[1], argv[2], argv[3], - argv[4]); + return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], NULL, + argv[1], argv[2], NULL, argv[3], argv[4]); } DEFUN (ip_route_flags_distance2_vrf, @@ -964,8 +960,8 @@ DEFUN (ip_route_flags_distance2_vrf, "Distance value for this route\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, 1, argv[0], NULL, NULL, argv[1], argv[2], - argv[3]); + return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], NULL, + NULL, argv[1], NULL, argv[2], argv[3]); } DEFUN (ip_route_mask_distance_vrf, @@ -981,8 +977,8 @@ DEFUN (ip_route_mask_distance_vrf, "Distance value for this route\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3], - argv[4]); + return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], argv[1], + argv[2], NULL, NULL, argv[3], argv[4]); } DEFUN (ip_route_mask_flags_distance_vrf, @@ -999,8 +995,8 @@ DEFUN (ip_route_mask_flags_distance_vrf, "Distance value for this route\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4], - argv[5]); + return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], argv[1], + argv[2], argv[3], NULL, argv[4], argv[5]); } DEFUN (ip_route_mask_flags_distance2_vrf, @@ -1015,8 +1011,8 @@ DEFUN (ip_route_mask_flags_distance2_vrf, "Distance value for this route\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3], - argv[4]); + return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 1, argv[0], argv[1], + NULL, argv[2], NULL, argv[3], argv[4]); } DEFUN (no_ip_route_vrf, @@ -1031,8 +1027,9 @@ DEFUN (no_ip_route_vrf, "Null interface\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], NULL, NULL, - (argc > 3) ? argv[3] : argv[2]); + return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], + NULL, argv[1], NULL, NULL, NULL, + (argc > 3) ? argv[3] : argv[2]); } ALIAS (no_ip_route_vrf, @@ -1059,8 +1056,8 @@ DEFUN (no_ip_route_flags2_vrf, "Silently discard pkts when matched\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, 0, argv[0], NULL, NULL, NULL, NULL, - argv[2]); + return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], + NULL, NULL, NULL, NULL, NULL, argv[2]); } DEFUN (no_ip_route_mask_vrf, @@ -1076,8 +1073,9 @@ DEFUN (no_ip_route_mask_vrf, "Null interface\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], NULL, NULL, - (argc > 4) ? argv[4] : argv[3]); + return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], argv[1], + argv[2], NULL, NULL, NULL, + (argc > 4) ? argv[4] : argv[3]); } ALIAS (no_ip_route_mask_vrf, @@ -1106,8 +1104,8 @@ DEFUN (no_ip_route_mask_flags2_vrf, "Silently discard pkts when matched\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, 0, argv[0], argv[1], NULL, NULL, NULL, - argv[2]); + return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], argv[1], + NULL, NULL, NULL, NULL, argv[2]); } DEFUN (no_ip_route_distance_vrf, @@ -1123,8 +1121,8 @@ DEFUN (no_ip_route_distance_vrf, "Distance value for this route\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], NULL, argv[2], - argv[3]); + return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], NULL, + argv[1], NULL, NULL, argv[2], argv[3]); } DEFUN (no_ip_route_flags_distance_vrf, @@ -1141,8 +1139,8 @@ DEFUN (no_ip_route_flags_distance_vrf, "Distance value for this route\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, 0, argv[0], NULL, argv[1], argv[2], argv[3], - argv[4]); + return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], NULL, argv[1], + argv[2], NULL, argv[3], argv[4]); } DEFUN (no_ip_route_flags_distance2_vrf, @@ -1157,8 +1155,8 @@ DEFUN (no_ip_route_flags_distance2_vrf, "Distance value for this route\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, 0, argv[0], NULL, NULL, argv[1], argv[2], - argv[3]); + return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], NULL, NULL, + argv[1], NULL, argv[2], argv[3]); } DEFUN (no_ip_route_mask_distance_vrf, @@ -1175,8 +1173,8 @@ DEFUN (no_ip_route_mask_distance_vrf, "Distance value for this route\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3], - argv[4]); + return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], argv[1], + argv[2], NULL, NULL, argv[3], argv[4]); } DEFUN (no_ip_route_mask_flags_distance_vrf, @@ -1194,8 +1192,8 @@ DEFUN (no_ip_route_mask_flags_distance_vrf, "Distance value for this route\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, 0, argv[0], argv[1], argv[2], argv[3], argv[4], - argv[5]); + return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], argv[1], argv[2], + argv[3], NULL, argv[4], argv[5]); } DEFUN (no_ip_route_mask_flags_distance2_vrf, @@ -1211,8 +1209,8 @@ DEFUN (no_ip_route_mask_flags_distance2_vrf, "Distance value for this route\n" VRF_CMD_HELP_STR) { - return zebra_static_ipv4 (vty, 0, argv[0], argv[1], NULL, argv[2], argv[3], - argv[4]); + return zebra_static_ipv4_safi (vty, SAFI_UNICAST, 0, argv[0], argv[1], NULL, + argv[2], NULL, argv[3], argv[4]); } extern char *proto_rm[AFI_MAX][ZEBRA_ROUTE_MAX+1]; /* "any" == ZEBRA_ROUTE_MAX */ @@ -1243,6 +1241,7 @@ vty_show_ip_route_detail (struct vty *vty, struct route_node *rn, int mcast) vty_out (vty, ", distance %u, metric %u", rib->distance, rib->metric); if (rib->mtu) vty_out (vty, ", mtu %u", rib->mtu); + vty_out (vty, ", tag %d", rib->tag); vty_out (vty, ", vrf %u", rib->vrf_id); if (CHECK_FLAG (rib->flags, ZEBRA_FLAG_SELECTED)) vty_out (vty, ", best"); @@ -2412,6 +2411,9 @@ static_config_ipv4 (struct vty *vty, safi_t safi, const char *cmd) vty_out (vty, " %s", "blackhole"); } + if (si->tag) + vty_out (vty, " tag %d", si->tag); + if (si->distance != ZEBRA_STATIC_DISTANCE_DEFAULT) vty_out (vty, " %d", si->distance); @@ -2426,13 +2428,12 @@ static_config_ipv4 (struct vty *vty, safi_t safi, const char *cmd) return write; } -#ifdef HAVE_IPV6 /* General fucntion for IPv6 static route. */ static int static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str, const char *gate_str, const char *ifname, - const char *flag_str, const char *distance_str, - const char *vrf_id_str) + const char *flag_str, const char *tag_str, + const char *distance_str, const char *vrf_id_str) { int ret; u_char distance; @@ -2442,6 +2443,7 @@ static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str, u_char type = 0; vrf_id_t vrf_id = VRF_DEFAULT; u_char flag = 0; + u_short tag = 0; ret = str2prefix (dest_str, &p); if (ret <= 0) @@ -2476,6 +2478,10 @@ static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str, else distance = ZEBRA_STATIC_DISTANCE_DEFAULT; + /* tag */ + if (tag_str) + tag = atoi (tag_str); + /* When gateway is valid IPv6 addrees, then gate is treated as nexthop address other case gate is treated as interface name. */ ret = inet_pton (AF_INET6, gate_str, &gate_addr); @@ -2511,9 +2517,9 @@ static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str, VTY_GET_INTEGER ("VRF ID", vrf_id, vrf_id_str); if (add_cmd) - static_add_ipv6 (&p, type, gate, ifname, flag, distance, vrf_id); + static_add_ipv6 (&p, type, gate, ifname, flag, tag, distance, vrf_id); else - static_delete_ipv6 (&p, type, gate, ifname, distance, vrf_id); + static_delete_ipv6 (&p, type, gate, ifname, tag, distance, vrf_id); return CMD_SUCCESS; } @@ -2528,7 +2534,7 @@ DEFUN (ipv6_route, "IPv6 gateway interface name\n") { return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, NULL, - NULL); + NULL, NULL); } DEFUN (ipv6_route_flags, @@ -2543,7 +2549,7 @@ DEFUN (ipv6_route_flags, "Silently discard pkts when matched\n") { return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], NULL, - NULL); + NULL, NULL); } DEFUN (ipv6_route_ifname, @@ -2556,7 +2562,7 @@ DEFUN (ipv6_route_ifname, "IPv6 gateway interface name\n") { return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, NULL, - NULL); + NULL, NULL); } DEFUN (ipv6_route_ifname_flags, @@ -2571,7 +2577,7 @@ DEFUN (ipv6_route_ifname_flags, "Silently discard pkts when matched\n") { return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL, - NULL); + NULL, NULL); } DEFUN (ipv6_route_pref, @@ -2584,7 +2590,7 @@ DEFUN (ipv6_route_pref, "IPv6 gateway interface name\n" "Distance value for this prefix\n") { - return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, argv[2], + return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, NULL, argv[2], NULL); } @@ -2600,7 +2606,7 @@ DEFUN (ipv6_route_flags_pref, "Silently discard pkts when matched\n" "Distance value for this prefix\n") { - return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3], + return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], NULL, argv[3], NULL); } @@ -2614,7 +2620,7 @@ DEFUN (ipv6_route_ifname_pref, "IPv6 gateway interface name\n" "Distance value for this prefix\n") { - return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3], + return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, NULL, argv[3], NULL); } @@ -2630,7 +2636,7 @@ DEFUN (ipv6_route_ifname_flags_pref, "Silently discard pkts when matched\n" "Distance value for this prefix\n") { - return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4], + return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL, argv[4], NULL); } @@ -2644,7 +2650,7 @@ DEFUN (no_ipv6_route, "IPv6 gateway address\n" "IPv6 gateway interface name\n") { - return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, NULL, + return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, NULL, NULL, NULL); } @@ -2670,7 +2676,7 @@ DEFUN (no_ipv6_route_ifname, "IPv6 gateway address\n" "IPv6 gateway interface name\n") { - return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, NULL, + return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, NULL, NULL, NULL); } @@ -2697,7 +2703,7 @@ DEFUN (no_ipv6_route_pref, "IPv6 gateway interface name\n" "Distance value for this prefix\n") { - return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, argv[2], + return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, NULL, argv[2], NULL); } @@ -2715,7 +2721,7 @@ DEFUN (no_ipv6_route_flags_pref, "Distance value for this prefix\n") { /* We do not care about argv[2] */ - return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, argv[2], argv[3], + return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, argv[2], NULL, argv[3], NULL); } @@ -2730,7 +2736,7 @@ DEFUN (no_ipv6_route_ifname_pref, "IPv6 gateway interface name\n" "Distance value for this prefix\n") { - return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3], + return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, NULL, argv[3], NULL); } @@ -2747,7 +2753,7 @@ DEFUN (no_ipv6_route_ifname_flags_pref, "Silently discard pkts when matched\n" "Distance value for this prefix\n") { - return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], argv[3], argv[4], + return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], argv[3], NULL, argv[4], NULL); } @@ -2761,7 +2767,7 @@ DEFUN (ipv6_route_vrf, "IPv6 gateway interface name\n" VRF_CMD_HELP_STR) { - return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, NULL, + return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, NULL, NULL, argv[2]); } @@ -2777,7 +2783,7 @@ DEFUN (ipv6_route_flags_vrf, "Silently discard pkts when matched\n" VRF_CMD_HELP_STR) { - return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], NULL, + return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], NULL, NULL, argv[3]); } @@ -2791,7 +2797,7 @@ DEFUN (ipv6_route_ifname_vrf, "IPv6 gateway interface name\n" VRF_CMD_HELP_STR) { - return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, NULL, + return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, NULL, NULL, argv[3]); } @@ -2807,7 +2813,7 @@ DEFUN (ipv6_route_ifname_flags_vrf, "Silently discard pkts when matched\n" VRF_CMD_HELP_STR) { - return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL, + return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL, NULL, argv[4]); } @@ -2822,7 +2828,7 @@ DEFUN (ipv6_route_pref_vrf, "Distance value for this prefix\n" VRF_CMD_HELP_STR) { - return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, argv[2], + return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, NULL, NULL, argv[2], argv[3]); } @@ -2839,7 +2845,7 @@ DEFUN (ipv6_route_flags_pref_vrf, "Distance value for this prefix\n" VRF_CMD_HELP_STR) { - return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], argv[3], + return static_ipv6_func (vty, 1, argv[0], argv[1], NULL, argv[2], NULL, argv[3], argv[4]); } @@ -2854,7 +2860,7 @@ DEFUN (ipv6_route_ifname_pref_vrf, "Distance value for this prefix\n" VRF_CMD_HELP_STR) { - return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, argv[3], + return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], NULL, NULL, argv[3], argv[4]); } @@ -2871,7 +2877,7 @@ DEFUN (ipv6_route_ifname_flags_pref_vrf, "Distance value for this prefix\n" VRF_CMD_HELP_STR) { - return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], argv[4], + return static_ipv6_func (vty, 1, argv[0], argv[1], argv[2], argv[3], NULL, argv[4], argv[5]); } @@ -2886,7 +2892,7 @@ DEFUN (no_ipv6_route_vrf, "IPv6 gateway interface name\n" VRF_CMD_HELP_STR) { - return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, NULL, + return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, NULL, NULL, (argc > 3) ? argv[3] : argv[2]); } @@ -2914,7 +2920,7 @@ DEFUN (no_ipv6_route_ifname_vrf, "IPv6 gateway interface name\n" VRF_CMD_HELP_STR) { - return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, NULL, + return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, NULL, NULL, (argc > 4) ? argv[4] : argv[3]); } @@ -2943,7 +2949,7 @@ DEFUN (no_ipv6_route_pref_vrf, "Distance value for this prefix\n" VRF_CMD_HELP_STR) { - return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, argv[2], + return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, NULL, NULL, argv[2], argv[3]); } @@ -2962,7 +2968,7 @@ DEFUN (no_ipv6_route_flags_pref_vrf, VRF_CMD_HELP_STR) { /* We do not care about argv[2] */ - return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, argv[2], argv[3], + return static_ipv6_func (vty, 0, argv[0], argv[1], NULL, argv[2], NULL, argv[3], argv[4]); } @@ -2978,7 +2984,7 @@ DEFUN (no_ipv6_route_ifname_pref_vrf, "Distance value for this prefix\n" VRF_CMD_HELP_STR) { - return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, argv[3], + return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], NULL, NULL, argv[3], argv[4]); } @@ -2996,7 +3002,7 @@ DEFUN (no_ipv6_route_ifname_flags_pref_vrf, "Distance value for this prefix\n" VRF_CMD_HELP_STR) { - return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], argv[3], argv[4], + return static_ipv6_func (vty, 0, argv[0], argv[1], argv[2], argv[3], NULL, argv[4], argv[5]); } @@ -3713,6 +3719,9 @@ static_config_ipv6 (struct vty *vty) if (CHECK_FLAG(si->flags, ZEBRA_FLAG_BLACKHOLE)) vty_out (vty, " %s", "blackhole"); + if (si->tag) + vty_out (vty, " tag %d", si->tag); + if (si->distance != ZEBRA_STATIC_DISTANCE_DEFAULT) vty_out (vty, " %d", si->distance); @@ -3726,7 +3735,6 @@ static_config_ipv6 (struct vty *vty) } return write; } -#endif /* HAVE_IPV6 */ /* Static ip route configuration write function. */ static int -- 1.9.1 _______________________________________________ Quagga-dev mailing list [email protected] https://lists.quagga.net/mailman/listinfo/quagga-dev
