mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-13 22:57:45 +00:00
Merge pull request #9380 from mjstapp/fix_static_lsp_cli
zebra: mpls validation and static lsp fixes
This commit is contained in:
commit
1dfa8b8991
@ -1295,6 +1295,9 @@ static zebra_nhlfe_t *nhlfe_alloc(zebra_lsp_t *lsp, enum lsp_types_t lsp_type,
|
|||||||
nexthop->ifindex = ifindex;
|
nexthop->ifindex = ifindex;
|
||||||
break;
|
break;
|
||||||
case NEXTHOP_TYPE_BLACKHOLE:
|
case NEXTHOP_TYPE_BLACKHOLE:
|
||||||
|
if (IS_ZEBRA_DEBUG_MPLS)
|
||||||
|
zlog_debug("%s: invalid: blackhole nexthop", __func__);
|
||||||
|
|
||||||
nexthop_free(nexthop);
|
nexthop_free(nexthop);
|
||||||
XFREE(MTYPE_NHLFE, nhlfe);
|
XFREE(MTYPE_NHLFE, nhlfe);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -1319,6 +1322,14 @@ static zebra_nhlfe_t *nhlfe_add(zebra_lsp_t *lsp, enum lsp_types_t lsp_type,
|
|||||||
if (!lsp)
|
if (!lsp)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
/* Must have labels */
|
||||||
|
if (num_labels == 0 || labels == NULL) {
|
||||||
|
if (IS_ZEBRA_DEBUG_MPLS)
|
||||||
|
zlog_debug("%s: invalid nexthop: no labels", __func__);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
/* Allocate new object */
|
/* Allocate new object */
|
||||||
nhlfe = nhlfe_alloc(lsp, lsp_type, gtype, gate, ifindex, num_labels,
|
nhlfe = nhlfe_alloc(lsp, lsp_type, gtype, gate, ifindex, num_labels,
|
||||||
labels);
|
labels);
|
||||||
@ -1530,8 +1541,13 @@ static json_object *nhlfe_json(zebra_nhlfe_t *nhlfe)
|
|||||||
ifindex2ifname(nexthop->ifindex,
|
ifindex2ifname(nexthop->ifindex,
|
||||||
nexthop->vrf_id));
|
nexthop->vrf_id));
|
||||||
break;
|
break;
|
||||||
case NEXTHOP_TYPE_BLACKHOLE:
|
|
||||||
case NEXTHOP_TYPE_IFINDEX:
|
case NEXTHOP_TYPE_IFINDEX:
|
||||||
|
if (nexthop->ifindex)
|
||||||
|
json_object_string_add(json_nhlfe, "interface",
|
||||||
|
ifindex2ifname(nexthop->ifindex,
|
||||||
|
nexthop->vrf_id));
|
||||||
|
break;
|
||||||
|
case NEXTHOP_TYPE_BLACKHOLE:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1592,8 +1608,13 @@ static void nhlfe_print(zebra_nhlfe_t *nhlfe, struct vty *vty,
|
|||||||
ifindex2ifname(nexthop->ifindex,
|
ifindex2ifname(nexthop->ifindex,
|
||||||
nexthop->vrf_id));
|
nexthop->vrf_id));
|
||||||
break;
|
break;
|
||||||
case NEXTHOP_TYPE_BLACKHOLE:
|
|
||||||
case NEXTHOP_TYPE_IFINDEX:
|
case NEXTHOP_TYPE_IFINDEX:
|
||||||
|
if (nexthop->ifindex)
|
||||||
|
vty_out(vty, " dev %s",
|
||||||
|
ifindex2ifname(nexthop->ifindex,
|
||||||
|
nexthop->vrf_id));
|
||||||
|
break;
|
||||||
|
case NEXTHOP_TYPE_BLACKHOLE:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
vty_out(vty, "%s",
|
vty_out(vty, "%s",
|
||||||
@ -2835,9 +2856,21 @@ static bool ftn_update_znh(bool add_p, enum lsp_types_t type,
|
|||||||
break;
|
break;
|
||||||
success = true;
|
success = true;
|
||||||
break;
|
break;
|
||||||
case NEXTHOP_TYPE_BLACKHOLE:
|
|
||||||
case NEXTHOP_TYPE_IFINDEX:
|
case NEXTHOP_TYPE_IFINDEX:
|
||||||
|
if (znh->type != NEXTHOP_TYPE_IFINDEX)
|
||||||
|
continue;
|
||||||
|
if (nexthop->ifindex != znh->ifindex)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
found = true;
|
||||||
|
|
||||||
|
if (!ftn_update_nexthop(add_p, nexthop, type, znh))
|
||||||
|
break;
|
||||||
|
success = true;
|
||||||
break;
|
break;
|
||||||
|
case NEXTHOP_TYPE_BLACKHOLE:
|
||||||
|
/* Not valid */
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (found)
|
if (found)
|
||||||
@ -3815,8 +3848,13 @@ static char *nhlfe_config_str(const zebra_nhlfe_t *nhlfe, char *buf, int size)
|
|||||||
ifindex2ifname(nh->ifindex, VRF_DEFAULT),
|
ifindex2ifname(nh->ifindex, VRF_DEFAULT),
|
||||||
size);
|
size);
|
||||||
break;
|
break;
|
||||||
case NEXTHOP_TYPE_BLACKHOLE:
|
|
||||||
case NEXTHOP_TYPE_IFINDEX:
|
case NEXTHOP_TYPE_IFINDEX:
|
||||||
|
if (nh->ifindex)
|
||||||
|
strlcat(buf,
|
||||||
|
ifindex2ifname(nh->ifindex, VRF_DEFAULT),
|
||||||
|
size);
|
||||||
|
break;
|
||||||
|
case NEXTHOP_TYPE_BLACKHOLE:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,6 +67,11 @@ static int zebra_mpls_transit_lsp(struct vty *vty, int add_cmd,
|
|||||||
return CMD_WARNING_CONFIG_FAILED;
|
return CMD_WARNING_CONFIG_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (gate_str == NULL) {
|
||||||
|
vty_out(vty, "%% No Nexthop Information\n");
|
||||||
|
return CMD_WARNING_CONFIG_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
out_label = MPLS_LABEL_IMPLICIT_NULL; /* as initialization */
|
out_label = MPLS_LABEL_IMPLICIT_NULL; /* as initialization */
|
||||||
label = atoi(inlabel_str);
|
label = atoi(inlabel_str);
|
||||||
if (!IS_MPLS_UNRESERVED_LABEL(label)) {
|
if (!IS_MPLS_UNRESERVED_LABEL(label)) {
|
||||||
@ -86,21 +91,18 @@ static int zebra_mpls_transit_lsp(struct vty *vty, int add_cmd,
|
|||||||
}
|
}
|
||||||
|
|
||||||
in_label = label;
|
in_label = label;
|
||||||
gtype = NEXTHOP_TYPE_BLACKHOLE; /* as initialization */
|
|
||||||
|
|
||||||
if (gate_str) {
|
/* Gateway is a IPv4 or IPv6 nexthop. */
|
||||||
/* Gateway is a IPv4 or IPv6 nexthop. */
|
ret = inet_pton(AF_INET6, gate_str, &gate.ipv6);
|
||||||
ret = inet_pton(AF_INET6, gate_str, &gate.ipv6);
|
if (ret == 1)
|
||||||
if (ret)
|
gtype = NEXTHOP_TYPE_IPV6;
|
||||||
gtype = NEXTHOP_TYPE_IPV6;
|
else {
|
||||||
|
ret = inet_pton(AF_INET, gate_str, &gate.ipv4);
|
||||||
|
if (ret == 1)
|
||||||
|
gtype = NEXTHOP_TYPE_IPV4;
|
||||||
else {
|
else {
|
||||||
ret = inet_pton(AF_INET, gate_str, &gate.ipv4);
|
vty_out(vty, "%% Invalid nexthop\n");
|
||||||
if (ret)
|
return CMD_WARNING_CONFIG_FAILED;
|
||||||
gtype = NEXTHOP_TYPE_IPV4;
|
|
||||||
else {
|
|
||||||
vty_out(vty, "%% Invalid nexthop\n");
|
|
||||||
return CMD_WARNING_CONFIG_FAILED;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,7 +133,7 @@ static int zebra_mpls_transit_lsp(struct vty *vty, int add_cmd,
|
|||||||
ret = zebra_mpls_static_lsp_del(zvrf, in_label, gtype, &gate,
|
ret = zebra_mpls_static_lsp_del(zvrf, in_label, gtype, &gate,
|
||||||
0);
|
0);
|
||||||
|
|
||||||
if (ret) {
|
if (ret != 0) {
|
||||||
vty_out(vty, "%% LSP cannot be %s\n",
|
vty_out(vty, "%% LSP cannot be %s\n",
|
||||||
add_cmd ? "added" : "deleted");
|
add_cmd ? "added" : "deleted");
|
||||||
return CMD_WARNING_CONFIG_FAILED;
|
return CMD_WARNING_CONFIG_FAILED;
|
||||||
|
Loading…
Reference in New Issue
Block a user