]> git.proxmox.com Git - mirror_frr.git/commitdiff
Merge pull request #874 from opensourcerouting/zebra-static-rework
authorQuentin Young <qlyoung@users.noreply.github.com>
Mon, 31 Jul 2017 14:53:39 +0000 (10:53 -0400)
committerGitHub <noreply@github.com>
Mon, 31 Jul 2017 14:53:39 +0000 (10:53 -0400)
zebra: make static routes great again

16 files changed:
babeld/babel_main.c
babeld/babel_zebra.c
babeld/babeld.c
babeld/babeld.h
bgpd/bgp_evpn_vty.c
bgpd/bgp_mplsvpn.c
bgpd/bgp_route.c
bgpd/bgp_vpn.c
bgpd/rfapi/rfapi_rib.c
doc/Building_FRR_on_CentOS6.md
eigrpd/eigrp_vty.c
ldpd/ldp_vty_cmds.c
ldpd/ldp_vty_conf.c
ospfd/ospf_vty.c
redhat/frr.init
vtysh/vtysh.c

index 517489f15f40b67bc3ea7b8411269367a6cb5db1..54626a4aeb5904c10b89f7ed6d9aa3851e956ebf 100644 (file)
@@ -207,8 +207,6 @@ main(int argc, char **argv)
 
     schedule_neighbours_check(5000, 1);
 
-    zlog_notice ("BABELd %s starting: vty@%d", BABEL_VERSION, babel_vty_port);
-
     frr_config_fork();
     frr_run(master);
 
index 52d7eaee83cd7c4ba30670a5b1b77738fceed246..11b9c5956c24cb1666bc3ac990e544e037028403 100644 (file)
@@ -55,25 +55,6 @@ static struct {
     {0, 0, NULL}
 };
 
-static struct {
-    int str_min_len;
-    const char *str;
-} proto_redistnum_type[ZEBRA_ROUTE_MAX] = {
-    [ZEBRA_ROUTE_BABEL]   = {2, "babel"},
-    [ZEBRA_ROUTE_BGP]     = {2, "bgp"},
-    [ZEBRA_ROUTE_CONNECT] = {1, "connected"},
-    [ZEBRA_ROUTE_HSLS]    = {1, "hsls"},
-    [ZEBRA_ROUTE_ISIS]    = {1, "isis"},
-    [ZEBRA_ROUTE_KERNEL]  = {1, "kernel"},
-    [ZEBRA_ROUTE_OLSR]    = {2, "olsr"},
-    [ZEBRA_ROUTE_OSPF]    = {2, "ospf"},
-    [ZEBRA_ROUTE_OSPF6]   = {5, "ospf6"},
-    [ZEBRA_ROUTE_RIP]     = {1, "rip"},
-    [ZEBRA_ROUTE_RIPNG]   = {4, "ripng"},
-    [ZEBRA_ROUTE_STATIC]  = {2, "static"},
-    [ZEBRA_ROUTE_SYSTEM]  = {2, "system"},
-};
-
 /* Zebra node structure. */
 struct cmd_node zebra_node =
 {
@@ -191,66 +172,46 @@ babel_zebra_read_ipv4 (int command, struct zclient *zclient,
     return 0;
 }
 
-static int
-babel_proto_redistnum(const char *s)
-{
-    int i;
-    if (! s)
-        return -1;
-    int len = strlen(s);
-
-    for (i = 0; i < ZEBRA_ROUTE_MAX; i++) {
-        if (len <= (int)strlen(proto_redistnum_type[i].str) &&
-            strncmp(proto_redistnum_type[i].str, s,
-                    proto_redistnum_type[i].str_min_len) == 0) {
-            return i;
-        }
-    }
-
-    return -1;
-}
-
 /* [Babel Command] */
 DEFUN (babel_redistribute_type,
        babel_redistribute_type_cmd,
-       "redistribute " FRR_REDIST_STR_BABELD,
+       "[no] redistribute <ipv4 " FRR_IP_REDIST_STR_BABELD "|ipv6 " FRR_IP6_REDIST_STR_BABELD ">",
+       NO_STR
        "Redistribute\n"
-       FRR_REDIST_HELP_STR_BABELD)
+       "Redistribute IPv4 routes\n"
+       FRR_IP_REDIST_HELP_STR_BABELD
+       "Redistribute IPv6 routes\n"
+       FRR_IP6_REDIST_HELP_STR_BABELD)
 {
+    int negate = 0;
+    int family;
+    int afi;
     int type;
+    int idx = 0;
 
-    type = babel_proto_redistnum(argv[1]->arg);
-
-    if (type < 0) {
-        vty_out (vty, "Invalid type %s\n", argv[1]->arg);
+    if (argv_find(argv, argc, "no", &idx))
+        negate = 1;
+    argv_find(argv, argc, "redistribute", &idx);
+    family = str2family(argv[idx + 1]->text);
+    if (family < 0)
         return CMD_WARNING_CONFIG_FAILED;
-    }
-
-    zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP, type, 0, VRF_DEFAULT);
-    zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP6, type, 0, VRF_DEFAULT);
-    return CMD_SUCCESS;
-}
-
-/* [Babel Command] */
-DEFUN (no_babel_redistribute_type,
-       no_babel_redistribute_type_cmd,
-       "no redistribute " FRR_REDIST_STR_BABELD,
-       NO_STR
-       "Redistribute\n"
-       FRR_REDIST_HELP_STR_BABELD)
-{
-    int type;
 
-    type = babel_proto_redistnum(argv[2]->arg);
+    afi = family2afi(family);
+    if (!afi)
+        return CMD_WARNING_CONFIG_FAILED;
 
+    type = proto_redistnum(afi, argv[idx + 2]->text);
     if (type < 0) {
-        vty_out (vty, "Invalid type %s\n", argv[2]->arg);
+        vty_out (vty, "Invalid type %s\n", argv[idx + 2]->arg);
         return CMD_WARNING_CONFIG_FAILED;
     }
 
-    zclient_redistribute (ZEBRA_REDISTRIBUTE_DELETE, zclient, AFI_IP, type, 0, VRF_DEFAULT);
-    zclient_redistribute (ZEBRA_REDISTRIBUTE_DELETE, zclient, AFI_IP6, type, 0, VRF_DEFAULT);
-    /* perhaps should we remove xroutes having the same type... */
+    if (!negate)
+        zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, afi, type, 0, VRF_DEFAULT);
+    else {
+        zclient_redistribute (ZEBRA_REDISTRIBUTE_DELETE, zclient, afi, type, 0, VRF_DEFAULT);
+        /* perhaps should we remove xroutes having the same type... */
+    }
     return CMD_SUCCESS;
 }
 
@@ -374,7 +335,6 @@ void babelz_zebra_init(void)
 
     install_node (&zebra_node, zebra_config_write);
     install_element(BABEL_NODE, &babel_redistribute_type_cmd);
-    install_element(BABEL_NODE, &no_babel_redistribute_type_cmd);
     install_element(ENABLE_NODE, &debug_babel_cmd);
     install_element(ENABLE_NODE, &no_debug_babel_cmd);
     install_element(CONFIG_NODE, &debug_babel_cmd);
index b2f8176aabeb341bd5b8ca7acf41a978efb8c172..f995745e415c873a1e2a513f9e6ee214b05eb88f 100644 (file)
@@ -76,6 +76,7 @@ static int
 babel_config_write (struct vty *vty)
 {
     int lines = 0;
+    int afi;
     int i;
 
     /* list enabled debug modes */
@@ -108,13 +109,17 @@ babel_config_write (struct vty *vty)
     /* list enabled interfaces */
     lines = 1 + babel_enable_if_config_write (vty);
     /* list redistributed protocols */
-    for (i = 0; i < ZEBRA_ROUTE_MAX; i++)
-        if (i != zclient->redist_default &&
-           vrf_bitmap_check (zclient->redist[AFI_IP][i], VRF_DEFAULT))
-        {
-            vty_out (vty, " redistribute %s\n", zebra_route_string(i));
-            lines++;
+    for (afi = AFI_IP; afi <= AFI_IP6; afi++) {
+        for (i = 0; i < ZEBRA_ROUTE_MAX; i++) {
+            if (i != zclient->redist_default &&
+                vrf_bitmap_check (zclient->redist[afi][i], VRF_DEFAULT)) {
+                vty_out (vty, " redistribute %s %s\n",
+                         (afi == AFI_IP) ? "ipv4" : "ipv6",
+                         zebra_route_string(i));
+                lines++;
+            }
         }
+    }
 
     lines += config_write_distribute (vty);
 
index d933f1880554ee8bbf6d1888d7f471693d256f73..899b4f175c46cca29449a8ff4e21ce67ec39fc53 100644 (file)
@@ -90,7 +90,6 @@ THE SOFTWARE.
 
 #define BABEL_VTY_PORT 2609
 #define BABEL_DEFAULT_CONFIG "babeld.conf"
-#define BABEL_VERSION "0.1 for quagga"
 
 /* Values in milliseconds */
 #define BABEL_DEFAULT_HELLO_INTERVAL 4000
index 4b39ee86270da388dad2c191b4af2bcf01d9a3ca..1225354c0a024ac2255ecadcbc3370a4fbfde579 100644 (file)
@@ -347,6 +347,8 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd,
        if (bgp == NULL) {
                if (!use_json)
                        vty_out(vty, "No BGP process is configured\n");
+               else
+                       vty_out(vty, "{}\n");
                return CMD_WARNING;
        }
 
index 5d2966d1ad5d525978e6628506d9e4f5de6616f4..baf081c815f73b691563fe7ef69625c86344aa0e 100644 (file)
@@ -374,6 +374,8 @@ int bgp_show_mpls_vpn(struct vty *vty, afi_t afi, struct prefix_rd *prd,
        if (bgp == NULL) {
                if (!use_json)
                        vty_out(vty, "No BGP process is configured\n");
+               else
+                       vty_out(vty, "{}\n");
                return CMD_WARNING;
        }
 
index 38ad7a6e0a239edff68e2853275764f5f6a2c211..b554aeb32b5c2b83d76d141c6ba189946629d57f 100644 (file)
@@ -8257,6 +8257,8 @@ static int bgp_show(struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi,
        if (bgp == NULL) {
                if (!use_json)
                        vty_out(vty, "No BGP process is configured\n");
+               else
+                       vty_out(vty, "{}\n");
                return CMD_WARNING;
        }
 
@@ -8617,8 +8619,16 @@ static int bgp_show_route(struct vty *vty, struct bgp *bgp, const char *ip_str,
                          int prefix_check, enum bgp_path_type pathtype,
                          u_char use_json)
 {
-       if (!bgp)
+       if (!bgp) {
                bgp = bgp_get_default();
+               if (!bgp) {
+                       if (!use_json)
+                               vty_out(vty, "No BGP process is configured\n");
+                       else
+                               vty_out(vty, "{}\n");
+                       return CMD_WARNING;
+               }
+       }
 
        /* labeled-unicast routes live in the unicast table */
        if (safi == SAFI_LABELED_UNICAST)
index ca98ff0668a58c869c2a12256632da956496f4f7..4661e195a207c7e0d5a1d67245fb19034172c380 100644 (file)
@@ -51,6 +51,8 @@ int show_adj_route_vpn(struct vty *vty, struct peer *peer,
        if (bgp == NULL) {
                if (!use_json)
                        vty_out(vty, "No BGP process is configured\n");
+               else
+                       vty_out(vty, "{}\n");
                return CMD_WARNING;
        }
 
index a414df1ab4c89c3b17e8fedadfe81a398b976703..791eb4c916ed09f0c8678c056cdd5e382d0f8b51 100644 (file)
@@ -2236,9 +2236,12 @@ void rfapiRibShowResponsesSummary(void *stream)
        struct rfapi_descriptor *rfd;
        struct listnode *node;
 
-
        if (rfapiStream2Vty(stream, &fp, &vty, &out, &vty_newline) == 0)
                return;
+       if (!bgp) {
+               fp(out, "Unable to find default BGP instance\n");
+               return;
+       }
 
        fp(out, "%-24s ", "Responses: (Prefixes)");
        fp(out, "%-8s %-8u ", "Active:", bgp->rfapi->rib_prefix_count_total);
@@ -2388,6 +2391,11 @@ void rfapiRibShowResponses(void *stream, struct prefix *pfx_match,
 
        if (rfapiStream2Vty(stream, &fp, &vty, &out, &vty_newline) == 0)
                return;
+       if (!bgp) {
+               fp(out, "Unable to find default BGP instance\n");
+               return;
+       }
+
        /*
         * loop over NVEs
         */
index 4139daf3161554e0056f7035950b2823bd41e978..b25845c38a2af2588b0e4776318cd589eb8cc9d8 100644 (file)
@@ -17,6 +17,9 @@ CentOS 6 restrictions:
 - Zebra is unable to detect what bridge/vrf an interface is associcated
   with (IFLA_INFO_SLAVE_KIND does not exist in the kernel headers, you
   can use a newer kernel + headers to get this functionality)
+- frr_reload.py will not work, as this requires Python 2.7, and CentOS 6
+  only has 2.6.  You can install Python 2.7 via IUS, but it won't work
+  properly unless you compile and install the ipaddr package for it.
 
 Install required packages
 -------------------------
index d416183f52a4223b02b137b1afa92edb6618f1b9..465007478d940cfe328c187bf200a3196fc93f0e 100644 (file)
@@ -237,6 +237,11 @@ DEFUN (no_router_eigrp,
        struct eigrp *eigrp;
 
        eigrp = eigrp_lookup();
+       if (eigrp == NULL) {
+               vty_out(vty, " EIGRP Routing Process not enabled\n");
+               return CMD_SUCCESS;
+       }
+
        if (eigrp->AS != atoi(argv[3]->arg)) {
                vty_out(vty, "%% Attempting to deconfigure non-existent AS\n");
                return CMD_WARNING_CONFIG_FAILED;
@@ -1000,9 +1005,11 @@ DEFUN (eigrp_redistribute_source_metric,
 
        /* Get distribute source. */
        argv_find(argv, argc, "redistribute", &idx);
-       source = proto_redistnum(AFI_IP, argv[idx + 1]->arg);
-       if (source < 0)
+       source = proto_redistnum(AFI_IP, argv[idx + 1]->text);
+       if (source < 0) {
+               vty_out(vty, "%% Invalid route type\n");
                return CMD_WARNING_CONFIG_FAILED;
+       }
 
        /* Get metrics values */
 
@@ -1029,9 +1036,11 @@ DEFUN (no_eigrp_redistribute_source_metric,
 
        /* Get distribute source. */
        argv_find(argv, argc, "redistribute", &idx);
-       source = proto_redistnum(AFI_IP, argv[idx + 1]->arg);
-       if (source < 0)
+       source = proto_redistnum(AFI_IP, argv[idx + 1]->text);
+       if (source < 0) {
+               vty_out(vty, "%% Invalid route type\n");
                return CMD_WARNING_CONFIG_FAILED;
+       }
 
        /* Get metrics values */
 
index d28424cbb704323bc83345abab222aa4b6021e0e..871905aa8f57490e8907e963b2f03eaf83329eab 100644 (file)
@@ -80,6 +80,16 @@ DEFUN_NOSH(ldp_address_family,
        return (ldp_vty_address_family(vty, negate, af));
 }
 
+DEFUN_NOSH(ldp_exit_address_family,
+       ldp_exit_address_family_cmd,
+       "exit-address-family",
+       "Exit from Address Family configuration mode\n")
+{
+       if (vty->node == LDP_IPV4_NODE || vty->node == LDP_IPV6_NODE)
+               vty->node = LDP_NODE;
+       return CMD_SUCCESS;
+}
+
 DEFUN  (ldp_discovery_holdtime,
        ldp_discovery_holdtime_cmd,
        "[no] discovery <hello|targeted-hello> holdtime (1-65535)",
@@ -1082,6 +1092,7 @@ ldp_vty_init (void)
        install_element(LDP_IPV4_NODE, &ldp_interface_cmd);
        install_element(LDP_IPV4_NODE, &ldp_session_holdtime_cmd);
        install_element(LDP_IPV4_NODE, &ldp_neighbor_ipv4_targeted_cmd);
+       install_element(LDP_IPV4_NODE, &ldp_exit_address_family_cmd);
 
        install_element(LDP_IPV6_NODE, &ldp_discovery_holdtime_cmd);
        install_element(LDP_IPV6_NODE, &ldp_discovery_interval_cmd);
@@ -1095,6 +1106,7 @@ ldp_vty_init (void)
        install_element(LDP_IPV6_NODE, &ldp_interface_cmd);
        install_element(LDP_IPV6_NODE, &ldp_session_holdtime_cmd);
        install_element(LDP_IPV6_NODE, &ldp_neighbor_ipv6_targeted_cmd);
+       install_element(LDP_IPV6_NODE, &ldp_exit_address_family_cmd);
 
        install_element(LDP_IPV4_IFACE_NODE, &ldp_discovery_holdtime_cmd);
        install_element(LDP_IPV4_IFACE_NODE, &ldp_discovery_interval_cmd);
index 4e900ca93e8a32c6d66992140799ee4c515daedd..09eb6a7c55c532fd5dc1cbbaf67ae0212a7f13b1 100644 (file)
@@ -233,7 +233,7 @@ ldp_af_config_write(struct vty *vty, int af, struct ldpd_conf *conf,
 
        ldp_af_iface_config_write(vty, af);
 
-       vty_out (vty, "  !\n");
+       vty_out(vty, " exit-address-family\n");
 }
 
 int
index 55d6c27e8c2d52c429d37dc299eaa92e109c8e66..a8bfb669af423e3a4a4da2d912fd018fb456375a 100644 (file)
@@ -4402,6 +4402,10 @@ static int show_ip_ospf_neighbor_id_common(struct vty *vty, struct ospf *ospf,
        if (!ret) {
                if (!use_json)
                        vty_out(vty, "Please specify Neighbor ID by A.B.C.D\n");
+               else {
+                       vty_out(vty, "{}\n");
+                       json_object_free(json);
+               }
                return CMD_WARNING;
        }
 
@@ -4682,6 +4686,10 @@ static int show_ip_ospf_neighbor_int_detail_common(struct vty *vty,
        if (!ifp) {
                if (!use_json)
                        vty_out(vty, "No such interface.\n");
+               else {
+                       vty_out(vty, "{}\n");
+                       json_object_free(json);
+               }
                return CMD_WARNING;
        }
 
index cf01e4c6e3291a9b3452c1498f329d4d4d1054f4..a62647b258756aea0afd72f088a776affd6cd5f2 100755 (executable)
@@ -515,6 +515,18 @@ case "$1" in
         if [ -z "$dmn" -o "$dmn" = "zebra" ]; then
             echo "Removing all routes made by zebra."
             ip route flush proto zebra
+            # At least in CentOS/RHEL 6, iproute2 doesn't know
+            # about the new protocol names, so we have to flush them
+            # by number (it also doesn't support rt_protos.d
+            ip route flush proto 186
+            ip route flush proto 187
+            ip route flush proto 188
+            ip route flush proto 189
+            ip route flush proto 190
+            ip route flush proto 191
+            ip route flush proto 192
+            ip route flush proto 193
+            ip route flush proto 194
         else
             [ -n "$dmn" ] && eval "${dmn/-/_}=0"
             start_watchfrr
index 666f3049d7c87cf5f96b3cc429f24bf50cc60048..adf47ed57c2feab89fa866c9d352305cd576c93a 100644 (file)
@@ -303,7 +303,9 @@ static int vtysh_execute_func(const char *line, int pager)
                     || saved_node == BGP_IPV4L_NODE
                     || saved_node == BGP_IPV6L_NODE
                     || saved_node == BGP_IPV6M_NODE
-                    || saved_node == BGP_EVPN_NODE)
+                    || saved_node == BGP_EVPN_NODE
+                    || saved_node == LDP_IPV4_NODE
+                    || saved_node == LDP_IPV6_NODE)
                    && (tried == 1)) {
                        vtysh_execute("exit-address-family");
                } else if ((saved_node == BGP_EVPN_VNI_NODE) && (tried == 1)) {
@@ -496,6 +498,29 @@ int vtysh_mark_file(const char *filename)
                strcpy(vty_buf_copy, vty->buf);
                vty_buf_trimmed = trim(vty_buf_copy);
 
+               switch (vty->node) {
+               case LDP_IPV4_IFACE_NODE:
+                       if (strncmp(vty_buf_copy, "   ", 3)) {
+                               fprintf(stdout, "  end\n");
+                               vty->node = LDP_IPV4_NODE;
+                       }
+                       break;
+               case LDP_IPV6_IFACE_NODE:
+                       if (strncmp(vty_buf_copy, "   ", 3)) {
+                               fprintf(stdout, "  end\n");
+                               vty->node = LDP_IPV6_NODE;
+                       }
+                       break;
+               case LDP_PSEUDOWIRE_NODE:
+                       if (strncmp(vty_buf_copy, "  ", 2)) {
+                               fprintf(stdout, " end\n");
+                               vty->node = LDP_L2VPN_NODE;
+                       }
+                       break;
+               default:
+                       break;
+               }
+
                if (vty_buf_trimmed[0] == '!' || vty_buf_trimmed[0] == '#') {
                        fprintf(stdout, "%s", vty->buf);
                        continue;
@@ -1268,6 +1293,14 @@ DEFUNSH(VTYSH_LDPD, ldp_address_family_ipv6, ldp_address_family_ipv6_cmd,
        return CMD_SUCCESS;
 }
 
+DEFUNSH(VTYSH_LDPD, ldp_exit_address_family, ldp_exit_address_family_cmd,
+       "exit-address-family", "Exit from Address Family configuration mode\n")
+{
+       if (vty->node == LDP_IPV4_NODE || vty->node == LDP_IPV6_NODE)
+               vty->node = LDP_NODE;
+       return CMD_SUCCESS;
+}
+
 DEFUNSH(VTYSH_LDPD, ldp_interface_ifname, ldp_interface_ifname_cmd,
        "interface IFNAME",
        "Enable LDP on an interface and enter interface submode\n"
@@ -2945,8 +2978,10 @@ void vtysh_init_vty(void)
        install_element(LDP_NODE, &vtysh_quit_ldpd_cmd);
        install_element(LDP_IPV4_NODE, &vtysh_exit_ldpd_cmd);
        install_element(LDP_IPV4_NODE, &vtysh_quit_ldpd_cmd);
+       install_element(LDP_IPV4_NODE, &ldp_exit_address_family_cmd);
        install_element(LDP_IPV6_NODE, &vtysh_exit_ldpd_cmd);
        install_element(LDP_IPV6_NODE, &vtysh_quit_ldpd_cmd);
+       install_element(LDP_IPV6_NODE, &ldp_exit_address_family_cmd);
        install_element(LDP_IPV4_IFACE_NODE, &vtysh_exit_ldpd_cmd);
        install_element(LDP_IPV4_IFACE_NODE, &vtysh_quit_ldpd_cmd);
        install_element(LDP_IPV6_IFACE_NODE, &vtysh_exit_ldpd_cmd);