]> git.proxmox.com Git - mirror_frr.git/blobdiff - zebra/zebra_mpls_vty.c
zebra: Fix missing VRF flag
[mirror_frr.git] / zebra / zebra_mpls_vty.c
index 1ef70270f82c94caa22e514d5eb11b6f43a377c4..6b8859e0cae348bdf31e46b733e71a4d8251570b 100644 (file)
@@ -1,21 +1,6 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /* Zebra MPLS VTY functions
  * Copyright (C) 2002 Kunihiro Ishiguro
- *
- * This file is part of GNU Zebra.
- *
- * GNU Zebra is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * GNU Zebra is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; see the file COPYING; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include <zebra.h>
@@ -56,7 +41,7 @@ static int zebra_mpls_transit_lsp(struct vty *vty, int add_cmd,
                return CMD_WARNING_CONFIG_FAILED;
        }
 
-       zvrf = vrf_info_lookup(VRF_DEFAULT);
+       zvrf = zebra_vrf_lookup_by_id(VRF_DEFAULT);
        if (!zvrf) {
                vty_out(vty, "%% Default VRF does not exist\n");
                return CMD_WARNING_CONFIG_FAILED;
@@ -67,11 +52,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 +71,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;
+                       }
                }
        }
 
@@ -202,13 +185,13 @@ static int zebra_mpls_bind(struct vty *vty, int add_cmd, const char *prefix,
        uint32_t label;
        int ret;
 
-       zvrf = vrf_info_lookup(VRF_DEFAULT);
+       zvrf = zebra_vrf_lookup_by_id(VRF_DEFAULT);
        if (!zvrf) {
                vty_out(vty, "%% Default VRF does not exist\n");
                return CMD_WARNING_CONFIG_FAILED;
        }
 
-       memset(&p, 0, sizeof(struct prefix));
+       memset(&p, 0, sizeof(p));
        ret = str2prefix(prefix, &p);
        if (ret <= 0) {
                vty_out(vty, "%% Malformed address\n");
@@ -290,7 +273,7 @@ static int zebra_mpls_config(struct vty *vty)
        int write = 0;
        struct zebra_vrf *zvrf;
 
-       zvrf = vrf_info_lookup(VRF_DEFAULT);
+       zvrf = zebra_vrf_lookup_by_id(VRF_DEFAULT);
        if (!zvrf)
                return 0;
 
@@ -313,7 +296,7 @@ DEFUN (show_mpls_fec,
        struct prefix p;
        int ret;
 
-       zvrf = vrf_info_lookup(VRF_DEFAULT);
+       zvrf = zebra_vrf_lookup_by_id(VRF_DEFAULT);
        if (!zvrf)
                return 0;
 
@@ -343,7 +326,7 @@ DEFUN (show_mpls_table,
        struct zebra_vrf *zvrf;
        bool uj = use_json(argc, argv);
 
-       zvrf = vrf_info_lookup(VRF_DEFAULT);
+       zvrf = zebra_vrf_lookup_by_id(VRF_DEFAULT);
        zebra_mpls_print_lsp_table(vty, zvrf, uj);
        return CMD_SUCCESS;
 }
@@ -361,7 +344,7 @@ DEFUN (show_mpls_table_lsp,
        struct zebra_vrf *zvrf;
        bool uj = use_json(argc, argv);
 
-       zvrf = vrf_info_lookup(VRF_DEFAULT);
+       zvrf = zebra_vrf_lookup_by_id(VRF_DEFAULT);
        label = atoi(argv[3]->arg);
        zebra_mpls_print_lsp(vty, zvrf, label, uj);
        return CMD_SUCCESS;