summaryrefslogtreecommitdiff
path: root/zebra/zebra_vty.c
diff options
context:
space:
mode:
Diffstat (limited to 'zebra/zebra_vty.c')
-rw-r--r--zebra/zebra_vty.c67
1 files changed, 35 insertions, 32 deletions
diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c
index 44f77f84b1..84fc76d7f6 100644
--- a/zebra/zebra_vty.c
+++ b/zebra/zebra_vty.c
@@ -91,6 +91,9 @@ struct static_hold_route {
char *tag_str;
char *distance_str;
char *label_str;
+
+ /* processed & masked destination, used for config display */
+ struct prefix dest;
};
static struct list *static_list;
@@ -160,11 +163,7 @@ static int static_list_compare(void *arg1, void *arg2)
if (ret)
return ret;
- ret = static_list_compare_helper(shr1->dest_str, shr2->dest_str);
- if (ret)
- return ret;
-
- ret = static_list_compare_helper(shr1->mask_str, shr2->mask_str);
+ ret = prefix_cmp(&shr1->dest, &shr2->dest);
if (ret)
return ret;
@@ -198,15 +197,12 @@ static int static_list_compare(void *arg1, void *arg2)
/* General function for static route. */
-static int zebra_static_route_holdem(struct zebra_vrf *zvrf,
- struct zebra_vrf *nh_zvrf,
- afi_t afi, safi_t safi,
- const char *negate, const char *dest_str,
- const char *mask_str, const char *src_str,
- const char *gate_str, const char *ifname,
- const char *flag_str, const char *tag_str,
- const char *distance_str,
- const char *label_str)
+static int zebra_static_route_holdem(
+ struct zebra_vrf *zvrf, struct zebra_vrf *nh_zvrf, afi_t afi,
+ safi_t safi, const char *negate, struct prefix *dest,
+ const char *dest_str, const char *mask_str, const char *src_str,
+ const char *gate_str, const char *ifname, const char *flag_str,
+ const char *tag_str, const char *distance_str, const char *label_str)
{
struct static_hold_route *shr, *lookup;
struct listnode *node;
@@ -216,6 +212,8 @@ static int zebra_static_route_holdem(struct zebra_vrf *zvrf,
shr->nhvrf_name = XSTRDUP(MTYPE_STATIC_ROUTE, nh_zvrf->vrf->name);
shr->afi = afi;
shr->safi = safi;
+ if (dest)
+ prefix_copy(&shr->dest, dest);
if (dest_str)
shr->dest_str = XSTRDUP(MTYPE_STATIC_ROUTE, dest_str);
if (mask_str)
@@ -294,14 +292,6 @@ static int zebra_static_route_leak(
return CMD_WARNING_CONFIG_FAILED;
}
- if (zvrf->vrf->vrf_id == VRF_UNKNOWN
- || nh_zvrf->vrf->vrf_id == VRF_UNKNOWN) {
- vrf_set_user_cfged(zvrf->vrf);
- return zebra_static_route_holdem(
- zvrf, nh_zvrf, afi, safi, negate, dest_str, mask_str,
- src_str, gate_str, ifname, flag_str, tag_str,
- distance_str, label_str);
- }
switch (afi) {
case AFI_IP:
/* Cisco like mask notation. */
@@ -343,6 +333,15 @@ static int zebra_static_route_leak(
/* Apply mask for given prefix. */
apply_mask(&p);
+ if (zvrf->vrf->vrf_id == VRF_UNKNOWN
+ || nh_zvrf->vrf->vrf_id == VRF_UNKNOWN) {
+ vrf_set_user_cfged(zvrf->vrf);
+ return zebra_static_route_holdem(
+ zvrf, nh_zvrf, afi, safi, negate, &p, dest_str,
+ mask_str, src_str, gate_str, ifname, flag_str, tag_str,
+ distance_str, label_str);
+ }
+
/* Administrative distance. */
if (distance_str)
distance = atoi(distance_str);
@@ -1108,7 +1107,10 @@ static void vty_show_ip_route_detail(struct vty *vty, struct route_node *rn,
struct vrf *vrf =
vrf_lookup_by_id(nexthop->vrf_id);
- vty_out(vty, "(vrf %s)", vrf->name);
+ if (vrf)
+ vty_out(vty, "(vrf %s)", vrf->name);
+ else
+ vty_out(vty, "(vrf UKNOWN)");
}
if (CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_DUPLICATE))
@@ -1468,7 +1470,10 @@ static void vty_show_ip_route(struct vty *vty, struct route_node *rn,
if (nexthop->vrf_id != re->vrf_id) {
struct vrf *vrf = vrf_lookup_by_id(nexthop->vrf_id);
- vty_out(vty, "(vrf %s)", vrf->name);
+ if (vrf)
+ vty_out(vty, "(vrf %s)", vrf->name);
+ else
+ vty_out(vty, "(vrf UKNOWN)");
}
if (!CHECK_FLAG(nexthop->flags, NEXTHOP_FLAG_ACTIVE))
@@ -2221,11 +2226,13 @@ int static_config(struct vty *vty, struct zebra_vrf *zvrf, afi_t afi,
if (strcmp(zvrf->vrf->name, shr->vrf_name) != 0)
continue;
+ char dest_str[PREFIX_STRLEN];
+
+ prefix2str(&shr->dest, dest_str, sizeof(dest_str));
+
vty_out(vty, "%s ", spacing);
if (shr->dest_str)
- vty_out(vty, "%s ", shr->dest_str);
- if (shr->mask_str)
- vty_out(vty, "%s ", shr->mask_str);
+ vty_out(vty, "%s ", dest_str);
if (shr->src_str)
vty_out(vty, "from %s ", shr->src_str);
if (shr->gate_str)
@@ -2303,11 +2310,7 @@ int static_config(struct vty *vty, struct zebra_vrf *zvrf, afi_t afi,
sizeof buf, 0));
if (si->nh_vrf_id != si->vrf_id) {
- struct vrf *vrf;
-
- vrf = vrf_lookup_by_id(si->nh_vrf_id);
- vty_out(vty, " nexthop-vrf %s",
- (vrf) ? vrf->name : "Unknown");
+ vty_out(vty, " nexthop-vrf %s", si->nh_vrfname);
}
vty_out(vty, "\n");