zebra: Add internal support for route tags
Add internal support for a route tag to be applied to routes.
At this point in time, tags are not being used.
[forward ported by Cumulus]
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com>
Signed-off-by: Piotr Chytła <pch@packetconsulting.pl>
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Edited-by: Paul Jakma <paul.jakma@hpe.com> - rebase conflicts
diff --git a/zebra/rib.h b/zebra/rib.h
index 9773cba..d31db55 100644
--- a/zebra/rib.h
+++ b/zebra/rib.h
@@ -65,6 +65,9 @@
/* 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
@@ -178,6 +181,9 @@
/* Administrative distance. */
u_char distance;
+ /* Tag */
+ u_short tag;
+
/* Flag for this static route's type. */
u_char type;
#define STATIC_IPV4_GATEWAY 1
@@ -444,11 +450,11 @@
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,
@@ -468,7 +474,7 @@
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
@@ -476,7 +482,7 @@
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 a55d358..e57d1af 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -2147,6 +2147,10 @@
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);
@@ -2184,6 +2188,7 @@
rib->vrf_id = si->vrf_id;
rib->table = zebrad.rtm_table_default;
rib->nexthop_num = 0;
+ rib->tag = si->tag;
switch (si->type)
{
@@ -2269,7 +2274,8 @@
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;
}
@@ -2308,7 +2314,7 @@
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;
@@ -2341,7 +2347,8 @@
&& (! 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;
@@ -2351,15 +2358,16 @@
}
}
- /* 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;
@@ -2403,7 +2411,7 @@
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;
@@ -2432,7 +2440,8 @@
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. */
@@ -2788,8 +2797,8 @@
/* 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;
@@ -2817,6 +2826,7 @@
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))
{
@@ -2831,13 +2841,14 @@
}
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;
@@ -2884,7 +2895,7 @@
/* 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;
@@ -2905,7 +2916,8 @@
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 e3ef963..08144cb 100644
--- a/zebra/zebra_vty.c
+++ b/zebra/zebra_vty.c
@@ -44,7 +44,8 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
{
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 @@
{
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 @@
{
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 @@
{
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 @@
"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 @@
"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 @@
"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 @@
"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 @@
"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 @@
"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 @@
"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 @@
"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 @@
"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 @@
"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 @@
"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 @@
"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 @@
"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 @@
"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 @@
"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 @@
"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 @@
"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 @@
"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 @@
"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 @@
"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 @@
"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 @@
"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 @@
"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 @@
"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 @@
"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 @@
"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 @@
"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 @@
"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 @@
"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 @@
"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 @@
"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 @@
"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 @@
"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 @@
"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 @@
"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 @@
"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 @@
"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 @@
"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 @@
"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 @@
"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 @@
"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 @@
"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 @@
"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 @@
"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]);
}
char *proto_rm[AFI_MAX][ZEBRA_ROUTE_MAX+1]; /* "any" == ZEBRA_ROUTE_MAX */
@@ -1294,6 +1292,7 @@
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");
@@ -2468,6 +2467,9 @@
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);
@@ -2511,13 +2513,12 @@
return CMD_SUCCESS;
}
-#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;
@@ -2527,6 +2528,7 @@
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)
@@ -2561,6 +2563,10 @@
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);
@@ -2596,9 +2602,9 @@
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;
}
@@ -2613,7 +2619,7 @@
"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,
@@ -2628,7 +2634,7 @@
"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,
@@ -2641,7 +2647,7 @@
"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,
@@ -2656,7 +2662,7 @@
"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,
@@ -2669,7 +2675,7 @@
"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);
}
@@ -2685,7 +2691,7 @@
"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);
}
@@ -2699,7 +2705,7 @@
"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);
}
@@ -2715,7 +2721,7 @@
"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);
}
@@ -2729,7 +2735,7 @@
"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);
}
@@ -2755,7 +2761,7 @@
"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);
}
@@ -2782,7 +2788,7 @@
"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);
}
@@ -2800,7 +2806,7 @@
"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);
}
@@ -2815,7 +2821,7 @@
"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);
}
@@ -2832,7 +2838,7 @@
"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);
}
@@ -2846,7 +2852,7 @@
"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]);
}
@@ -2862,7 +2868,7 @@
"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]);
}
@@ -2876,7 +2882,7 @@
"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]);
}
@@ -2892,7 +2898,7 @@
"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]);
}
@@ -2907,7 +2913,7 @@
"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]);
}
@@ -2924,7 +2930,7 @@
"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]);
}
@@ -2939,7 +2945,7 @@
"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]);
}
@@ -2956,7 +2962,7 @@
"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]);
}
@@ -2971,7 +2977,7 @@
"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]);
}
@@ -2999,7 +3005,7 @@
"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]);
}
@@ -3028,7 +3034,7 @@
"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]);
}
@@ -3047,7 +3053,7 @@
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]);
}
@@ -3063,7 +3069,7 @@
"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]);
}
@@ -3081,7 +3087,7 @@
"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]);
}
@@ -3798,6 +3804,9 @@
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);
@@ -3811,7 +3820,6 @@
}
return write;
}
-#endif /* HAVE_IPV6 */
/* Static ip route configuration write function. */
static int
@@ -4036,4 +4044,5 @@
install_element (VIEW_NODE, &show_ipv6_mroute_vrf_cmd);
install_element (VIEW_NODE, &show_ipv6_mroute_vrf_all_cmd);
+ install_element (ENABLE_NODE, &show_ipv6_mroute_vrf_all_cmd);
}