summaryrefslogtreecommitdiff
path: root/zebra/zebra_mpls_vty.c
diff options
context:
space:
mode:
authoranlan_cs <anlan_cs@tom.com>2021-08-18 01:58:54 -0400
committeranlan_cs <anlan_cs@tom.com>2021-08-18 19:34:03 -0400
commit21683186a0ae2eb06f18129fe6557c3ace1e38c7 (patch)
tree360d4ca41d0d3d2e6d8c3a6c767005ccadaa178e /zebra/zebra_mpls_vty.c
parent0512687b30b97f2fed4a6aa0200e2addb1a4b7a0 (diff)
zebra: fix wrong check of mpls command
Maybe with empty nexthop to call zebra_mpls_transit_lsp(): "no mpls lsp (16-1048575)". So just remove this "gate_str" check. If without "gate" in command, "gtype" is set to NEXTHOP_TYPE_BLACKHOLE for subsequent processing. Signed-off-by: anlan_cs <anlan_cs@tom.com>
Diffstat (limited to 'zebra/zebra_mpls_vty.c')
-rw-r--r--zebra/zebra_mpls_vty.c26
1 files changed, 12 insertions, 14 deletions
diff --git a/zebra/zebra_mpls_vty.c b/zebra/zebra_mpls_vty.c
index 1ef70270f8..fd9b1ae387 100644
--- a/zebra/zebra_mpls_vty.c
+++ b/zebra/zebra_mpls_vty.c
@@ -67,11 +67,6 @@ static int zebra_mpls_transit_lsp(struct vty *vty, int add_cmd,
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 */
label = atoi(inlabel_str);
if (!IS_MPLS_UNRESERVED_LABEL(label)) {
@@ -91,18 +86,21 @@ static int zebra_mpls_transit_lsp(struct vty *vty, int add_cmd,
}
in_label = label;
+ gtype = NEXTHOP_TYPE_BLACKHOLE; /* as initialization */
- /* Gateway is a IPv4 or IPv6 nexthop. */
- ret = inet_pton(AF_INET6, gate_str, &gate.ipv6);
- if (ret == 1)
- gtype = NEXTHOP_TYPE_IPV6;
- else {
- ret = inet_pton(AF_INET, gate_str, &gate.ipv4);
+ if (gate_str) {
+ /* Gateway is a IPv4 or IPv6 nexthop. */
+ ret = inet_pton(AF_INET6, gate_str, &gate.ipv6);
if (ret == 1)
- gtype = NEXTHOP_TYPE_IPV4;
+ gtype = NEXTHOP_TYPE_IPV6;
else {
- vty_out(vty, "%% Invalid nexthop\n");
- return CMD_WARNING_CONFIG_FAILED;
+ ret = inet_pton(AF_INET, gate_str, &gate.ipv4);
+ if (ret == 1)
+ gtype = NEXTHOP_TYPE_IPV4;
+ else {
+ vty_out(vty, "%% Invalid nexthop\n");
+ return CMD_WARNING_CONFIG_FAILED;
+ }
}
}