From 942e4486d8b0b60b6f5cc9e9495246c4360677c7 Mon Sep 17 00:00:00 2001 From: Christian Franke Date: Mon, 21 Nov 2016 19:39:10 +0100 Subject: [PATCH 001/107] lib: fix prefix2str return value and assert Signed-off-by: Christian Franke --- lib/prefix.c | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/lib/prefix.c b/lib/prefix.c index 112dae5822..bc6afcf9f8 100644 --- a/lib/prefix.c +++ b/lib/prefix.c @@ -893,29 +893,22 @@ const char * prefix2str (union prefix46constptr pu, char *str, int size) { const struct prefix *p = pu.p; - char buf[PREFIX2STR_BUFFER]; - if (p->family == AF_ETHERNET) { - int i; - char *s = str; - - assert(size > (3*ETHER_ADDR_LEN) + 1 /* slash */ + 3 /* plen */ ); - for (i = 0; i < ETHER_ADDR_LEN; ++i) { - sprintf(s, "%02x", p->u.prefix_eth.octet[i]); - if (i < (ETHER_ADDR_LEN - 1)) { - *(s+2) = ':'; - s += 3; - } else { - s += 2; - } + if (p->family == AF_ETHERNET) + { + snprintf(str, size, "%02x:%02x:%02x:%02x:%02x:%02x/%d", + p->u.prefix_eth.octet[0], p->u.prefix_eth.octet[1], + p->u.prefix_eth.octet[2], p->u.prefix_eth.octet[3], + p->u.prefix_eth.octet[4], p->u.prefix_eth.octet[5], + p->prefixlen); + } + else + { + char buf[PREFIX2STR_BUFFER]; + inet_ntop(p->family, &p->u.prefix, buf, sizeof(buf)); + snprintf(str, size, "%s/%d", buf, p->prefixlen); } - sprintf(s, "/%d", p->prefixlen); - return 0; - } - snprintf (str, size, "%s/%d", - inet_ntop (p->family, &p->u.prefix, buf, PREFIX2STR_BUFFER), - p->prefixlen); return str; } From 7b6a4c46458b9e5699cdc1d51fa765a3929b1c0e Mon Sep 17 00:00:00 2001 From: Christian Franke Date: Thu, 8 Dec 2016 13:51:35 +0100 Subject: [PATCH 002/107] bgpd/rfp: ignore rfptest binary Signed-off-by: Christian Franke --- bgpd/rfp-example/rfptest/.gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 bgpd/rfp-example/rfptest/.gitignore diff --git a/bgpd/rfp-example/rfptest/.gitignore b/bgpd/rfp-example/rfptest/.gitignore new file mode 100644 index 0000000000..d3d7c0a165 --- /dev/null +++ b/bgpd/rfp-example/rfptest/.gitignore @@ -0,0 +1 @@ +/rfptest From c43ac31c18316b393a61de552fcb367730e25bad Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 7 Dec 2016 15:28:44 -0500 Subject: [PATCH 003/107] vtysh: Fix static compilation When compiling vtysh with --enable-static and --disasble-shared we get linker errors with duplicate function names. This commit addresses this issue. Signed-off-by: Donald Sharp Signed-off-by: David Lamparter (cherry picked from commit dd2ecdedf88eb612759617ba044e4c29353088de) --- vtysh/vtysh.c | 14 +++++++------- vtysh/vtysh_user.c | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index 6c00058c18..a90915e1ac 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -1457,8 +1457,8 @@ DEFUNSH (VTYSH_ISISD, } DEFUNSH (VTYSH_RMAP, - route_map, - route_map_cmd, + vtysh_route_map, + vtysh_route_map_cmd, "route-map WORD (deny|permit) <1-65535>", "Create route-map or enter route-map command mode\n" "Route map tag\n" @@ -1867,13 +1867,13 @@ ALIAS (vtysh_exit_vrf, /* TODO Implement interface description commands in ripngd, ospf6d * and isisd. */ DEFSH (VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_OSPFD|VTYSH_LDPD, - interface_desc_cmd, + vtysh_interface_desc_cmd, "description .LINE", "Interface specific description\n" "Characters describing this interface\n") DEFSH (VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_OSPFD, - no_interface_desc_cmd, + vtysh_no_interface_desc_cmd, "no description", NO_STR "Interface specific description\n") @@ -3295,8 +3295,8 @@ vtysh_init_vty (void) install_element (RMAP_NODE, &vtysh_end_all_cmd); install_element (VTY_NODE, &vtysh_end_all_cmd); - install_element (INTERFACE_NODE, &interface_desc_cmd); - install_element (INTERFACE_NODE, &no_interface_desc_cmd); + install_element (INTERFACE_NODE, &vtysh_interface_desc_cmd); + install_element (INTERFACE_NODE, &vtysh_no_interface_desc_cmd); install_element (INTERFACE_NODE, &vtysh_end_all_cmd); install_element (INTERFACE_NODE, &vtysh_exit_interface_cmd); install_element (LINK_PARAMS_NODE, &exit_link_params_cmd); @@ -3361,7 +3361,7 @@ vtysh_init_vty (void) install_element (BGP_VNC_L2_GROUP_NODE, &exit_vnc_config_cmd); install_element (CONFIG_NODE, &key_chain_cmd); - install_element (CONFIG_NODE, &route_map_cmd); + install_element (CONFIG_NODE, &vtysh_route_map_cmd); install_element (CONFIG_NODE, &vtysh_line_vty_cmd); install_element (KEYCHAIN_NODE, &key_cmd); install_element (KEYCHAIN_NODE, &key_chain_cmd); diff --git a/vtysh/vtysh_user.c b/vtysh/vtysh_user.c index 1886ba3a67..da2ed1569e 100644 --- a/vtysh/vtysh_user.c +++ b/vtysh/vtysh_user.c @@ -165,8 +165,8 @@ user_get (const char *name) return user; } -DEFUN (banner_motd_file, - banner_motd_file_cmd, +DEFUN (vtysh_banner_motd_file, + vtysh_banner_motd_file_cmd, "banner motd file FILE", "Set banner\n" "Banner for motd\n" @@ -229,5 +229,5 @@ vtysh_user_init (void) { userlist = list_new (); install_element (CONFIG_NODE, &username_nopassword_cmd); - install_element (CONFIG_NODE, &banner_motd_file_cmd); + install_element (CONFIG_NODE, &vtysh_banner_motd_file_cmd); } From 5c3cc3ae96885f2671a0c520ee93d724bd51da50 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 9 Dec 2016 08:03:13 -0500 Subject: [PATCH 004/107] bgp: Modify output to be a bit clearer Modify the 'show ip bgp ...' output to be a bit clearer on what work it did. Modify: root@dell-s6000-02 ~/quagga# vtysh -c "show ip bgp" BGP table version is 7, local router ID is 6.0.0.9 Status codes: s suppressed, d damped, h history, * valid, > best, = multipath, i internal, r RIB-failure, S Stale, R Removed Origin codes: i - IGP, e - EGP, ? - incomplete Network Next Hop Metric LocPrf Weight Path *> 6.0.0.5/32 169.254.0.1 0 0 65101 ? *> 6.0.0.6/32 169.254.0.17 0 0 65101 ? *> 6.0.0.7/32 169.254.0.33 0 0 65104 ? *> 6.0.0.8/32 169.254.0.49 0 0 65104 ? *> 6.0.0.9/32 0.0.0.0 0 32768 ? *= 6.0.0.10/32 169.254.0.49 0 65104 65200 ? *= 169.254.0.33 0 65104 65200 ? *= 169.254.0.17 0 65101 65200 ? *> 169.254.0.1 0 65101 65200 ? Displayed 6 out of 9 total prefixes To ..... Displayed 6 routes and 9 total paths Issue #11 Signed-off-by: Donald Sharp Signed-off-by: David Lamparter --- bgpd/bgp_encap.c | 2 +- bgpd/bgp_mplsvpn.c | 2 +- bgpd/bgp_route.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bgpd/bgp_encap.c b/bgpd/bgp_encap.c index 533a306975..69f6c6157e 100644 --- a/bgpd/bgp_encap.c +++ b/bgpd/bgp_encap.c @@ -461,7 +461,7 @@ bgp_show_encap ( vty_out (vty, "No prefixes displayed, %ld exist%s", total_count, VTY_NEWLINE); } else - vty_out (vty, "%sDisplayed %ld out of %ld total prefixes%s", + vty_out (vty, "%sDisplayed %ld routes and %ld total paths%s", VTY_NEWLINE, output_count, total_count, VTY_NEWLINE); return CMD_SUCCESS; diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c index 39cb41d74a..d55acdd512 100644 --- a/bgpd/bgp_mplsvpn.c +++ b/bgpd/bgp_mplsvpn.c @@ -878,7 +878,7 @@ bgp_show_mpls_vpn (struct vty *vty, afi_t afi, struct prefix_rd *prd, if (output_count == 0) vty_out (vty, "No prefixes displayed, %ld exist%s", total_count, VTY_NEWLINE); else - vty_out (vty, "%sDisplayed %ld out of %ld total prefixes%s", + vty_out (vty, "%sDisplayed %ld routes and %ld total paths%s", VTY_NEWLINE, output_count, total_count, VTY_NEWLINE); } diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 090d633662..a61899447a 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -7792,7 +7792,7 @@ bgp_show_table (struct vty *vty, struct bgp *bgp, struct bgp_table *table, vty_out (vty, "No BGP prefixes displayed, %ld exist%s", total_count, VTY_NEWLINE); } else - vty_out (vty, "%sDisplayed %ld out of %ld total prefixes%s", + vty_out (vty, "%sDisplayed %ld routes and %ld total paths%s", VTY_NEWLINE, output_count, total_count, VTY_NEWLINE); } From 8eefe200e02ba99c1c32bf9fd565e0da1dee69cf Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 15 Dec 2016 20:39:46 -0500 Subject: [PATCH 005/107] lib: Ensure ptrs are NULL on free There exists a possibility that when we cleanup for shutdown that we may attempt to access them again. Found via valgrind, stopped showing up in there. Signed-off-by: Donald Sharp --- lib/routemap.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/routemap.c b/lib/routemap.c index 7b07499533..ace4961f72 100644 --- a/lib/routemap.c +++ b/lib/routemap.c @@ -1845,9 +1845,13 @@ route_map_finish (void) } for (i = 1; i < ROUTE_MAP_DEP_MAX; i++) - hash_free(route_map_dep_hash[i]); + { + hash_free(route_map_dep_hash[i]); + route_map_dep_hash[i] = NULL; + } hash_free (route_map_master_hash); + route_map_master_hash = NULL; } /* Initialization of route map vector. */ From 26acb92b840a169e52ab8e2fdae2536292e841ee Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 15 Dec 2016 20:41:47 -0500 Subject: [PATCH 006/107] bgpd: Cleanup double read of free'd data Valgrind found this issue. This cleans it up from happening. Signed-off-by: Donald Sharp --- bgpd/bgp_updgrp_adv.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bgpd/bgp_updgrp_adv.c b/bgpd/bgp_updgrp_adv.c index a95a11b620..8a3f4567ca 100644 --- a/bgpd/bgp_updgrp_adv.c +++ b/bgpd/bgp_updgrp_adv.c @@ -573,8 +573,9 @@ subgroup_clear_table (struct update_subgroup *subgrp) SUBGRP_FOREACH_ADJ_SAFE (subgrp, aout, taout) { - bgp_adj_out_remove_subgroup (aout->rn, aout, subgrp); - bgp_unlock_node (aout->rn); + struct bgp_node *rn = aout->rn; + bgp_adj_out_remove_subgroup (rn, aout, subgrp); + bgp_unlock_node (rn); } } From c9d5bd27c10b620571985ffc99e839883f9a7551 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 15 Dec 2016 21:28:51 -0500 Subject: [PATCH 007/107] bgpd: Fix 'show ip bgp summary' variable output being wrong The first time through calling 'show ip bgp summary' we were always calculating the variable hostname field size incorrectly. Signed-off-by: Donald Sharp --- bgpd/bgp_vty.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 5dafac1e06..b0d96150a8 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -10317,6 +10317,10 @@ bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi, if (peer->afc[afi][safi]) { + memset(dn_flag, '\0', sizeof(dn_flag)); + if (peer_dynamic_neighbor(peer)) + dn_flag[0] = '*'; + if (peer->hostname && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME)) sprintf(neighbor_buf, "%s%s(%s) ", dn_flag, peer->hostname, peer->host); else From 6d681bd874dc7dee4300a5d3a5ced8bb1a679643 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Fri, 16 Dec 2016 05:39:44 +0000 Subject: [PATCH 008/107] all: use ->text when parsing protocol argument and match on full protocol name in proto_redistnum() Signed-off-by: Quentin Young --- bgpd/bgp_vty.c | 52 +++++++++++------------- isisd/isis_redist.c | 8 ++-- lib/log.c | 40 +++++++++---------- ospf6d/ospf6_asbr.c | 15 ++++--- ospfd/ospf_vty.c | 89 +++++++++++++++++++---------------------- ripd/rip_zebra.c | 95 +++++++++++++++++++------------------------- ripngd/ripng_zebra.c | 11 +++-- vtysh/vtysh.c | 2 +- zebra/zebra_vty.c | 38 ++++++++---------- 9 files changed, 163 insertions(+), 187 deletions(-) diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 1c2cc037f9..c52682240b 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -9104,8 +9104,8 @@ DEFUN (bgp_redistribute_ipv4, int idx_protocol = 1; int type; - type = proto_redistnum (AFI_IP, argv[idx_protocol]->arg); - if (type < 0 || type == ZEBRA_ROUTE_BGP) + type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); + if (type < 0) { vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); return CMD_WARNING; @@ -9128,8 +9128,8 @@ DEFUN (bgp_redistribute_ipv4_rmap, int type; struct bgp_redist *red; - type = proto_redistnum (AFI_IP, argv[idx_protocol]->arg); - if (type < 0 || type == ZEBRA_ROUTE_BGP) + type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); + if (type < 0) { vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); return CMD_WARNING; @@ -9155,8 +9155,8 @@ DEFUN (bgp_redistribute_ipv4_metric, u_int32_t metric; struct bgp_redist *red; - type = proto_redistnum (AFI_IP, argv[idx_protocol]->arg); - if (type < 0 || type == ZEBRA_ROUTE_BGP) + type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); + if (type < 0) { vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); return CMD_WARNING; @@ -9186,8 +9186,8 @@ DEFUN (bgp_redistribute_ipv4_rmap_metric, u_int32_t metric; struct bgp_redist *red; - type = proto_redistnum (AFI_IP, argv[idx_protocol]->arg); - if (type < 0 || type == ZEBRA_ROUTE_BGP) + type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); + if (type < 0) { vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); return CMD_WARNING; @@ -9218,8 +9218,8 @@ DEFUN (bgp_redistribute_ipv4_metric_rmap, u_int32_t metric; struct bgp_redist *red; - type = proto_redistnum (AFI_IP, argv[idx_protocol]->arg); - if (type < 0 || type == ZEBRA_ROUTE_BGP) + type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); + if (type < 0) { vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); return CMD_WARNING; @@ -9433,8 +9433,8 @@ DEFUN (no_bgp_redistribute_ipv4, int idx_protocol = 2; int type; - type = proto_redistnum (AFI_IP, argv[idx_protocol]->arg); - if (type < 0 || type == ZEBRA_ROUTE_BGP) + type = proto_redistnum (AFI_IP, argv[idx_protocol]->text); + if (type < 0) { vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); return CMD_WARNING; @@ -9453,8 +9453,8 @@ DEFUN (bgp_redistribute_ipv6, int idx_protocol = 1; int type; - type = proto_redistnum (AFI_IP6, argv[idx_protocol]->arg); - if (type < 0 || type == ZEBRA_ROUTE_BGP) + type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); + if (type < 0) { vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); return CMD_WARNING; @@ -9478,8 +9478,8 @@ DEFUN (bgp_redistribute_ipv6_rmap, int type; struct bgp_redist *red; - type = proto_redistnum (AFI_IP6, argv[idx_protocol]->arg); - if (type < 0 || type == ZEBRA_ROUTE_BGP) + type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); + if (type < 0) { vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); return CMD_WARNING; @@ -9505,8 +9505,8 @@ DEFUN (bgp_redistribute_ipv6_metric, u_int32_t metric; struct bgp_redist *red; - type = proto_redistnum (AFI_IP6, argv[idx_protocol]->arg); - if (type < 0 || type == ZEBRA_ROUTE_BGP) + type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); + if (type < 0) { vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); return CMD_WARNING; @@ -9536,8 +9536,8 @@ DEFUN (bgp_redistribute_ipv6_rmap_metric, u_int32_t metric; struct bgp_redist *red; - type = proto_redistnum (AFI_IP6, argv[idx_protocol]->arg); - if (type < 0 || type == ZEBRA_ROUTE_BGP) + type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); + if (type < 0) { vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); return CMD_WARNING; @@ -9568,8 +9568,8 @@ DEFUN (bgp_redistribute_ipv6_metric_rmap, u_int32_t metric; struct bgp_redist *red; - type = proto_redistnum (AFI_IP6, argv[idx_protocol]->arg); - if (type < 0 || type == ZEBRA_ROUTE_BGP) + type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); + if (type < 0) { vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); return CMD_WARNING; @@ -9597,8 +9597,8 @@ DEFUN (no_bgp_redistribute_ipv6, int idx_protocol = 2; int type; - type = proto_redistnum (AFI_IP6, argv[idx_protocol]->arg); - if (type < 0 || type == ZEBRA_ROUTE_BGP) + type = proto_redistnum (AFI_IP6, argv[idx_protocol]->text); + if (type < 0) { vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE); return CMD_WARNING; @@ -9606,10 +9606,6 @@ DEFUN (no_bgp_redistribute_ipv6, return bgp_redistribute_unset (bgp, AFI_IP6, type, 0); } - - - - #endif /* HAVE_IPV6 */ int diff --git a/isisd/isis_redist.c b/isisd/isis_redist.c index 045c7daa32..f636d7f156 100644 --- a/isisd/isis_redist.c +++ b/isisd/isis_redist.c @@ -564,7 +564,7 @@ DEFUN (isis_redistribute, unsigned long metric; const char *routemap = NULL; - family = str2family(argv[idx_afi]->arg); + family = str2family(argv[idx_afi]->text); if (family < 0) return CMD_WARNING; @@ -572,8 +572,8 @@ DEFUN (isis_redistribute, if (!afi) return CMD_WARNING; - type = proto_redistnum(afi, argv[idx_protocol]->arg); - if (type < 0 || type == ZEBRA_ROUTE_ISIS) + type = proto_redistnum(afi, argv[idx_protocol]->text); + if (type < 0) return CMD_WARNING; if (!strcmp("level-1", argv[idx_level]->arg)) @@ -637,7 +637,7 @@ DEFUN (no_isis_redistribute, return CMD_WARNING; type = proto_redistnum(afi, argv[idx_protocol]->text); - if (type < 0 || type == ZEBRA_ROUTE_ISIS) + if (type < 0) return CMD_WARNING; level = strmatch ("level-1", argv[idx_level]->text) ? 1 : 2; diff --git a/lib/log.c b/lib/log.c index f9877300b4..3ed41c75e8 100644 --- a/lib/log.c +++ b/lib/log.c @@ -1061,48 +1061,48 @@ proto_redistnum(int afi, const char *s) if (afi == AFI_IP) { - if (strncmp (s, "k", 1) == 0) + if (strmatch (s, "kernel")) return ZEBRA_ROUTE_KERNEL; - else if (strncmp (s, "c", 1) == 0) + else if (strmatch (s, "connected")) return ZEBRA_ROUTE_CONNECT; - else if (strncmp (s, "s", 1) == 0) + else if (strmatch (s, "static")) return ZEBRA_ROUTE_STATIC; - else if (strncmp (s, "r", 1) == 0) + else if (strmatch (s, "rip")) return ZEBRA_ROUTE_RIP; - else if (strncmp (s, "o", 1) == 0) + else if (strmatch (s, "ospf")) return ZEBRA_ROUTE_OSPF; - else if (strncmp (s, "i", 1) == 0) + else if (strmatch (s, "isis")) return ZEBRA_ROUTE_ISIS; - else if (strncmp (s, "bg", 2) == 0) + else if (strmatch (s, "bgp")) return ZEBRA_ROUTE_BGP; - else if (strncmp (s, "ta", 2) == 0) + else if (strmatch (s, "table")) return ZEBRA_ROUTE_TABLE; - else if (strncmp (s, "v", 1) == 0) + else if (strmatch (s, "vnc")) return ZEBRA_ROUTE_VNC; - else if (strncmp (s, "vd", 1) == 0) + else if (strmatch (s, "vd")) return ZEBRA_ROUTE_VNC_DIRECT; } if (afi == AFI_IP6) { - if (strncmp (s, "k", 1) == 0) + if (strmatch (s, "kernel")) return ZEBRA_ROUTE_KERNEL; - else if (strncmp (s, "c", 1) == 0) + else if (strmatch (s, "connected")) return ZEBRA_ROUTE_CONNECT; - else if (strncmp (s, "s", 1) == 0) + else if (strmatch (s, "static")) return ZEBRA_ROUTE_STATIC; - else if (strncmp (s, "r", 1) == 0) + else if (strmatch (s, "ripng")) return ZEBRA_ROUTE_RIPNG; - else if (strncmp (s, "o", 1) == 0) + else if (strmatch (s, "ospf6")) return ZEBRA_ROUTE_OSPF6; - else if (strncmp (s, "i", 1) == 0) + else if (strmatch (s, "isis")) return ZEBRA_ROUTE_ISIS; - else if (strncmp (s, "bg", 2) == 0) + else if (strmatch (s, "bgp")) return ZEBRA_ROUTE_BGP; - else if (strncmp (s, "ta", 2) == 0) + else if (strmatch (s, "table")) return ZEBRA_ROUTE_TABLE; - else if (strncmp (s, "v", 1) == 0) + else if (strmatch (s, "vnc")) return ZEBRA_ROUTE_VNC; - else if (strncmp (s, "vd", 1) == 0) + else if (strmatch (s, "vd")) return ZEBRA_ROUTE_VNC_DIRECT; } return -1; diff --git a/ospf6d/ospf6_asbr.c b/ospf6d/ospf6_asbr.c index d31b4b95b4..f962669e8d 100644 --- a/ospf6d/ospf6_asbr.c +++ b/ospf6d/ospf6_asbr.c @@ -692,8 +692,9 @@ DEFUN (ospf6_redistribute, { int type; - type = proto_redistnum(AFI_IP6, argv[2]->arg); - if (type < 0 || type == ZEBRA_ROUTE_OSPF6) + char *proto = argv[argc - 1]->text; + type = proto_redistnum(AFI_IP6, proto); + if (type < 0) return CMD_WARNING; ospf6_asbr_redistribute_unset (type); @@ -713,8 +714,9 @@ DEFUN (ospf6_redistribute_routemap, int idx_word = 3; int type; - type = proto_redistnum(AFI_IP6, argv[idx_protocol]->arg); - if (type < 0 || type == ZEBRA_ROUTE_OSPF6) + char *proto = argv[idx_protocol]->text; + type = proto_redistnum(AFI_IP6, proto); + if (type < 0) return CMD_WARNING; ospf6_asbr_redistribute_unset (type); @@ -735,8 +737,9 @@ DEFUN (no_ospf6_redistribute, int idx_protocol = 2; int type; - type = proto_redistnum(AFI_IP6, argv[idx_protocol]->text); - if (type < 0 || type == ZEBRA_ROUTE_OSPF6) + char *proto = argv[idx_protocol]->text; + type = proto_redistnum(AFI_IP6, proto); + if (type < 0) return CMD_WARNING; ospf6_asbr_redistribute_unset (type); diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index c2999ca02a..adfaa33afa 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -7108,40 +7108,36 @@ DEFUN (ospf_redistribute_source, { VTY_DECLVAR_CONTEXT(ospf, ospf); int idx_protocol = 1; - int idx_redist_param = 2; int source; int type = -1; int metric = -1; struct ospf_redist *red; - - if (!ospf) - return CMD_SUCCESS; - - if (argc < 4) - return CMD_WARNING; /* should not happen */ + int idx = 0; if (!ospf) return CMD_SUCCESS; /* Get distribute source. */ - source = proto_redistnum(AFI_IP, argv[idx_protocol]->arg); - if (source < 0 || source == ZEBRA_ROUTE_OSPF) + source = proto_redistnum(AFI_IP, argv[idx_protocol]->text); + if (source < 0) return CMD_WARNING; - /* Get metric value. */ - if (strcmp (argv[idx_redist_param]->arg, "metric") == 0) - if (!str2metric (argv[idx_redist_param+1]->arg, &metric)) - return CMD_WARNING; - - /* Get metric type. */ - if (strcmp (argv[idx_redist_param]->arg, "metric-type") == 0) - if (!str2metric_type (argv[idx_redist_param+1]->arg, &type)) - return CMD_WARNING; - red = ospf_redist_add(ospf, source, 0); - if (strcmp (argv[idx_redist_param]->arg, "route-map") == 0) - ospf_routemap_set (red, argv[idx_redist_param+1]->arg); + /* Get metric value. */ + if (argv_find (argv, argc, "(0-16777214)", &idx)) { + if (!str2metric (argv[idx]->arg, &metric)) + return CMD_WARNING; + } + /* Get metric type. */ + else if (argv_find (argv, argc, "(1-2)", &idx)) { + if (!str2metric_type (argv[idx]->arg, &type)) + return CMD_WARNING; + } + /* Get route-map */ + else if (argv_find (argv, argc, "WORD", &idx)) { + ospf_routemap_set (red, argv[idx]->arg); + } else ospf_routemap_unset (red); @@ -7167,8 +7163,8 @@ DEFUN (no_ospf_redistribute_source, int source; struct ospf_redist *red; - source = proto_redistnum(AFI_IP, argv[idx_protocol]->arg); - if (source < 0 || source == ZEBRA_ROUTE_OSPF) + source = proto_redistnum(AFI_IP, argv[idx_protocol]->text); + if (source < 0) return CMD_WARNING; red = ospf_redist_lookup(ospf, source, 0); @@ -7207,10 +7203,7 @@ DEFUN (ospf_redistribute_instance_source, if (!ospf) return CMD_SUCCESS; - if (strncmp(argv[idx_ospf_table]->arg, "o", 1) == 0) - source = ZEBRA_ROUTE_OSPF; - else - source = ZEBRA_ROUTE_TABLE; + source = proto_redistnum (AFI_IP, argv[idx_ospf_table]->text); VTY_GET_INTEGER ("Instance ID", instance, argv[idx_number]->arg); @@ -7315,9 +7308,11 @@ DEFUN (ospf_distribute_list_out, int idx_word = 1; int source; + char *proto = argv[argc - 1]->text; + /* Get distribute source. */ - source = proto_redistnum(AFI_IP, argv[4]->arg); - if (source < 0 || source == ZEBRA_ROUTE_OSPF) + source = proto_redistnum(AFI_IP, proto); + if (source < 0) return CMD_WARNING; return ospf_distribute_list_out_set (ospf, source, argv[idx_word]->arg); @@ -7336,8 +7331,9 @@ DEFUN (no_ospf_distribute_list_out, int idx_word = 2; int source; - source = proto_redistnum(AFI_IP, argv[5]->arg); - if (source < 0 || source == ZEBRA_ROUTE_OSPF) + char *proto = argv[argc - 1]->text; + source = proto_redistnum(AFI_IP, proto); + if (source < 0) return CMD_WARNING; return ospf_distribute_list_out_unset (ospf, source, argv[idx_word]->arg); @@ -7359,33 +7355,30 @@ DEFUN (ospf_default_information_originate, "Pointer to route-map entries\n") { VTY_DECLVAR_CONTEXT(ospf, ospf); - int idx_redist_param = 2; int default_originate = DEFAULT_ORIGINATE_ZEBRA; int type = -1; int metric = -1; struct ospf_redist *red; - - if (argc < 4) - return CMD_WARNING; /* this should not happen */ - - /* Check whether "always" was specified */ - if (argv[idx_redist_param]->arg != NULL) - default_originate = DEFAULT_ORIGINATE_ALWAYS; + int idx = 0; red = ospf_redist_add(ospf, DEFAULT_ROUTE, 0); - /* Get metric value. */ - if (strcmp (argv[idx_redist_param]->arg, "metric") == 0) - if (!str2metric (argv[idx_redist_param+1]->arg, &metric)) + /* Check whether "always" was specified */ + if (argv_find (argv, argc, "always", &idx)) + default_originate = DEFAULT_ORIGINATE_ALWAYS; + /* Get metric value */ + else if (argv_find (argv, argc, "(0-16777214)", &idx)) { + if (!str2metric (argv[idx]->arg, &metric)) return CMD_WARNING; - + } /* Get metric type. */ - if (strcmp (argv[idx_redist_param]->arg, "metric-type") == 0) - if (!str2metric_type (argv[idx_redist_param+1]->arg, &type)) + else if (argv_find (argv, argc, "(1-2)", &idx)) { + if (!str2metric_type (argv[idx]->arg, &type)) return CMD_WARNING; - - if (strcmp (argv[idx_redist_param]->arg, "route-map") == 0) - ospf_routemap_set (red, argv[idx_redist_param+1]->arg); + } + /* Get route-map */ + else if (argv_find (argv, argc, "WORD", &idx)) + ospf_routemap_set (red, argv[idx]->arg); else ospf_routemap_unset (red); diff --git a/ripd/rip_zebra.c b/ripd/rip_zebra.c index 5aea4f5222..40c25f4c73 100644 --- a/ripd/rip_zebra.c +++ b/ripd/rip_zebra.c @@ -394,8 +394,7 @@ DEFUN (rip_redistribute_type_routemap, int i; for (i = 0; redist_type[i].str; i++) { - if (strncmp(redist_type[i].str, argv[idx_protocol]->arg, - redist_type[i].str_min_len) == 0) + if (strmatch (redist_type[i].str, argv[idx_protocol]->text)) { rip_routemap_set (redist_type[i].type, argv[idx_word]->arg); zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP, @@ -404,8 +403,7 @@ DEFUN (rip_redistribute_type_routemap, } } - vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->arg, - VTY_NEWLINE); + vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->text, VTY_NEWLINE); return CMD_WARNING; } @@ -423,20 +421,17 @@ DEFUN (no_rip_redistribute_type_routemap, int idx_word = 4; int i; - for (i = 0; redist_type[i].str; i++) - { - if (strncmp(redist_type[i].str, argv[idx_protocol]->arg, - redist_type[i].str_min_len) == 0) - { - if (rip_routemap_unset (redist_type[i].type,argv[idx_word]->arg)) - return CMD_WARNING; - rip_redistribute_unset (redist_type[i].type); - return CMD_SUCCESS; - } - } + for (i = 0; redist_type[i].str; i++) { + if (strmatch (redist_type[i].str, argv[idx_protocol]->text)) + { + if (rip_routemap_unset (redist_type[i].type,argv[idx_word]->arg)) + return CMD_WARNING; + rip_redistribute_unset (redist_type[i].type); + return CMD_SUCCESS; + } + } - vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->arg, - VTY_NEWLINE); + vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->text, VTY_NEWLINE); return CMD_WARNING; } @@ -457,8 +452,7 @@ DEFUN (rip_redistribute_type_metric, metric = atoi (argv[idx_number]->arg); for (i = 0; redist_type[i].str; i++) { - if (strncmp(redist_type[i].str, argv[idx_protocol]->arg, - redist_type[i].str_min_len) == 0) + if (strmatch (redist_type[i].str, argv[idx_protocol]->text)) { rip_redistribute_metric_set (redist_type[i].type, metric); zclient_redistribute (ZEBRA_REDISTRIBUTE_ADD, zclient, AFI_IP, @@ -467,8 +461,7 @@ DEFUN (rip_redistribute_type_metric, } } - vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->arg, - VTY_NEWLINE); + vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->text, VTY_NEWLINE); return CMD_WARNING; } @@ -486,20 +479,17 @@ DEFUN (no_rip_redistribute_type_metric, int idx_number = 4; int i; - for (i = 0; redist_type[i].str; i++) - { - if (strncmp(redist_type[i].str, argv[idx_protocol]->arg, - redist_type[i].str_min_len) == 0) - { - if (rip_metric_unset (redist_type[i].type, atoi(argv[idx_number]->arg))) - return CMD_WARNING; - rip_redistribute_unset (redist_type[i].type); - return CMD_SUCCESS; - } - } + for (i = 0; redist_type[i].str; i++) { + if (strmatch (redist_type[i].str, argv[idx_protocol]->text)) + { + if (rip_metric_unset (redist_type[i].type, atoi(argv[idx_number]->arg))) + return CMD_WARNING; + rip_redistribute_unset (redist_type[i].type); + return CMD_SUCCESS; + } + } - vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->arg, - VTY_NEWLINE); + vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->text, VTY_NEWLINE); return CMD_WARNING; } @@ -523,8 +513,7 @@ DEFUN (rip_redistribute_type_metric_routemap, metric = atoi (argv[idx_number]->arg); for (i = 0; redist_type[i].str; i++) { - if (strncmp(redist_type[i].str, argv[idx_protocol]->arg, - redist_type[i].str_min_len) == 0) + if (strmatch (redist_type[i].str, argv[idx_protocol]->text)) { rip_redistribute_metric_set (redist_type[i].type, metric); rip_routemap_set (redist_type[i].type, argv[idx_word]->arg); @@ -534,8 +523,7 @@ DEFUN (rip_redistribute_type_metric_routemap, } } - vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->arg, - VTY_NEWLINE); + vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->text, VTY_NEWLINE); return CMD_WARNING; } @@ -557,25 +545,22 @@ DEFUN (no_rip_redistribute_type_metric_routemap, int idx_word = 6; int i; - for (i = 0; redist_type[i].str; i++) - { - if (strncmp(redist_type[i].str, argv[idx_protocol]->arg, - redist_type[i].str_min_len) == 0) - { - if (rip_metric_unset (redist_type[i].type, atoi(argv[idx_number]->arg))) - return CMD_WARNING; - if (rip_routemap_unset (redist_type[i].type, argv[idx_word]->arg)) - { - rip_redistribute_metric_set(redist_type[i].type, atoi(argv[idx_number]->arg)); - return CMD_WARNING; - } - rip_redistribute_unset (redist_type[i].type); - return CMD_SUCCESS; - } + for (i = 0; redist_type[i].str; i++) { + if (strmatch (redist_type[i].str, argv[idx_protocol]->text)) + { + if (rip_metric_unset (redist_type[i].type, atoi(argv[idx_number]->arg))) + return CMD_WARNING; + if (rip_routemap_unset (redist_type[i].type, argv[idx_word]->arg)) + { + rip_redistribute_metric_set(redist_type[i].type, atoi(argv[idx_number]->arg)); + return CMD_WARNING; + } + rip_redistribute_unset (redist_type[i].type); + return CMD_SUCCESS; + } } - vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->arg, - VTY_NEWLINE); + vty_out(vty, "Invalid type %s%s", argv[idx_protocol]->text, VTY_NEWLINE); return CMD_WARNING; } diff --git a/ripngd/ripng_zebra.c b/ripngd/ripng_zebra.c index 09472683d7..7daa3a8875 100644 --- a/ripngd/ripng_zebra.c +++ b/ripngd/ripng_zebra.c @@ -321,11 +321,12 @@ DEFUN (ripng_redistribute_type, { int type; - type = proto_redistnum(AFI_IP6, argv[2]->arg); + char *proto = argv[argc - 1]->text; + type = proto_redistnum(AFI_IP6, proto); if (type < 0) { - vty_out(vty, "Invalid type %s%s", argv[2]->arg, VTY_NEWLINE); + vty_out(vty, "Invalid type %s%s", proto, VTY_NEWLINE); return CMD_WARNING; } @@ -345,11 +346,13 @@ DEFUN (no_ripng_redistribute_type, "Pointer to route-map entries\n") { int type; - type = proto_redistnum(AFI_IP6, argv[2]->text); + + char *proto = argv[2]->text; + type = proto_redistnum(AFI_IP6, proto); if (type < 0) { - vty_out(vty, "Invalid type %s%s", argv[2]->text, VTY_NEWLINE); + vty_out(vty, "Invalid type %s%s", proto, VTY_NEWLINE); return CMD_WARNING; } diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index f67fc1f31d..f045b8bc39 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -1913,7 +1913,7 @@ DEFUN (vtysh_show_work_queues_daemon, for (i = 0; i < array_size(vtysh_client); i++) { - if (begins_with(vtysh_client[i].name, argv[idx_protocol]->arg)) + if (strmatch(vtysh_client[i].name, argv[idx_protocol]->text)) break; } diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index e5f9b17e81..2f0fefdc67 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -1482,15 +1482,12 @@ DEFUN (show_ip_route_protocol, int first = 1; vrf_id_t vrf_id = VRF_DEFAULT; - if (strmatch(argv[3]->text, "vrf")) - { - type = proto_redistnum (AFI_IP, argv[5]->arg); - VRF_GET_ID (vrf_id, argv[4]->arg); - } - else - { - type = proto_redistnum (AFI_IP, argv[3]->arg); - } + int idx = 0; + if (argv_find (argv, argc, "NAME", &idx)) + VRF_GET_ID (vrf_id, argv[idx]->arg); + + char *proto = argv[argc - 1]->text; + type = proto_redistnum (AFI_IP, proto); if (type < 0) { @@ -2083,7 +2080,9 @@ DEFUN (show_ip_route_vrf_all_protocol, int first = 1; int vrf_header = 1; - type = proto_redistnum (AFI_IP, argv[6]->arg); + char *proto = argv[argc - 1]->text; + type = proto_redistnum (AFI_IP, proto); + if (type < 0) { vty_out (vty, "Unknown route type%s", VTY_NEWLINE); @@ -2965,16 +2964,12 @@ DEFUN (show_ipv6_route_protocol, int first = 1; vrf_id_t vrf_id = VRF_DEFAULT; - char *vrfname = (argc == 6) ? argv[4]->arg : NULL; - char *proto = argv[argc - 1]->text; + int idx = 0; + if (argv_find (argv, argc, "NAME", &idx)) + VRF_GET_ID (vrf_id, argv[idx]->arg); - if (vrfname) - { - VRF_GET_ID (vrf_id, vrfname); - type = proto_redistnum (AFI_IP6, proto); - } - else - type = proto_redistnum (AFI_IP6, proto); + char *proto = argv[argc - 1]->text; + type = proto_redistnum (AFI_IP, proto); if (type < 0) { @@ -3358,7 +3353,6 @@ DEFUN (show_ipv6_route_vrf_all_protocol, VRF_ALL_CMD_HELP_STR QUAGGA_IP6_REDIST_HELP_STR_ZEBRA) { - int idx_protocol = 5; int type; struct route_table *table; struct route_node *rn; @@ -3368,7 +3362,9 @@ DEFUN (show_ipv6_route_vrf_all_protocol, int first = 1; int vrf_header = 1; - type = proto_redistnum (AFI_IP6, argv[idx_protocol]->arg); + char *proto = argv[argc - 1]->text; + type = proto_redistnum (AFI_IP, proto); + if (type < 0) { vty_out (vty, "Unknown route type%s", VTY_NEWLINE); From 19c7f43feb43290ee945fb965e88a9b03722dbf8 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 16 Dec 2016 15:35:14 -0500 Subject: [PATCH 009/107] frr: Modify doc to talk about cli Add some verbiage to the COMMUNITY.md to talk about the philosophy of what cli should do. Signed-off-by: Donald Sharp --- COMMUNITY.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/COMMUNITY.md b/COMMUNITY.md index 7d08ed58dc..52777da968 100644 --- a/COMMUNITY.md +++ b/COMMUNITY.md @@ -300,4 +300,11 @@ at scale and in ways that can be unexpected for the original implementor. As such debugs MUST be guarded in such a way that they can be turned off. This PROJECT has the ability to turn on/off debugs from the CLI and it is expected that the developer will use this convention to allow control -of their debugs. \ No newline at end of file +of their debugs. + +### CLI-Changes + +CLI's are a complicated ugly beast. Additions or changes to the CLI +should use a DEFUN to encapsulate one setting as much as is possible. +Additionally as new DEFUN's are added to the system, documentation +should be provided for the new commands. \ No newline at end of file From 4f4354b872a32c4f0e86d131d9d31e077f535758 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 15 Dec 2016 21:28:51 -0500 Subject: [PATCH 010/107] bgpd: Fix 'show ip bgp summary' variable output being wrong The first time through calling 'show ip bgp summary' we were always calculating the variable hostname field size incorrectly. Ticket: CM-13900 Signed-off-by: Donald Sharp --- bgpd/bgp_vty.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 5dafac1e06..b0d96150a8 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -10317,6 +10317,10 @@ bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi, if (peer->afc[afi][safi]) { + memset(dn_flag, '\0', sizeof(dn_flag)); + if (peer_dynamic_neighbor(peer)) + dn_flag[0] = '*'; + if (peer->hostname && bgp_flag_check(bgp, BGP_FLAG_SHOW_HOSTNAME)) sprintf(neighbor_buf, "%s%s(%s) ", dn_flag, peer->hostname, peer->host); else From a8e4ddd408bd6bd689bc88551a2a461cc81b432a Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Sun, 18 Dec 2016 05:39:21 +0000 Subject: [PATCH 011/107] lib: Initialize ->allowrepeat Signed-off-by: Quentin Young --- lib/command.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/command.c b/lib/command.c index a93f3a55e8..7ad4441bb2 100644 --- a/lib/command.c +++ b/lib/command.c @@ -2404,12 +2404,13 @@ cmd_init (int terminal) struct cmd_token * new_cmd_token (enum cmd_token_type type, u_char attr, char *text, char *desc) { - struct cmd_token *token = XMALLOC (MTYPE_CMD_TOKENS, sizeof (struct cmd_token)); + struct cmd_token *token = XCALLOC (MTYPE_CMD_TOKENS, sizeof (struct cmd_token)); token->type = type; token->attr = attr; token->text = text; token->desc = desc; token->arg = NULL; + token->allowrepeat = false; return token; } From c01d03a6587b18722e5a7381084591e01eca64b5 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Tue, 20 Dec 2016 03:12:32 +0000 Subject: [PATCH 012/107] bgpd, lib: fix a few scan-build catches Fixes a couple null pointer derefs and uninit'd values. Signed-off-by: Quentin Young --- bgpd/bgp_route.c | 2 +- lib/command.c | 3 +++ lib/command_match.c | 2 +- lib/routemap.c | 23 ++++++++++++----------- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index cfc4ec3407..67ea4db2d1 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -9497,7 +9497,7 @@ DEFUN (show_ip_bgp_instance_neighbor_advertised_route, char *vrf = NULL; char *rmap_name = NULL; char *peerstr = NULL; - int rcvd; + int rcvd = 0; struct peer *peer; diff --git a/lib/command.c b/lib/command.c index ca0d0c001b..3cce4584e9 100644 --- a/lib/command.c +++ b/lib/command.c @@ -304,6 +304,9 @@ cmd_concat_strvec (vector v) if (vector_slot (v, i)) strsize += strlen ((char *) vector_slot (v, i)) + 1; + if (strsize == 0) + return XSTRDUP (MTYPE_TMP, ""); + char *concatenated = calloc (sizeof (char), strsize); for (unsigned int i = 0; i < vector_active (v); i++) { diff --git a/lib/command_match.c b/lib/command_match.c index 62905a4f7f..d228563240 100644 --- a/lib/command_match.c +++ b/lib/command_match.c @@ -482,7 +482,7 @@ add_nexthops (struct list *list, struct graph_node *node, child = vector_slot (node->to, i); size_t j; struct cmd_token *token = child->data; - if (!token->allowrepeat) + if (!token->allowrepeat && stack) { for (j = 0; j < stackpos; j++) if (child == stack[j]) diff --git a/lib/routemap.c b/lib/routemap.c index 5f2b2c0dfb..ce84942545 100644 --- a/lib/routemap.c +++ b/lib/routemap.c @@ -989,9 +989,11 @@ vty_show_route_map_entry (struct vty *vty, struct route_map *map) /* Print the name of the protocol */ if (zlog_default) + { vty_out (vty, "%s", zlog_proto_names[zlog_default->protocol]); - if (zlog_default->instance) - vty_out (vty, " %d", zlog_default->instance); + if (zlog_default->instance) + vty_out (vty, " %d", zlog_default->instance); + } vty_out (vty, ":%s", VTY_NEWLINE); for (index = map->head; index; index = index->next) @@ -2766,17 +2768,16 @@ DEFUN (rmap_call, struct route_map_index *index = VTY_GET_CONTEXT (route_map_index); const char *rmap = argv[idx_word]->arg; - if (index) + assert(index); + + if (index->nextrm) { - if (index->nextrm) - { - route_map_upd8_dependency (RMAP_EVENT_CALL_DELETED, - index->nextrm, - index->map->name); - XFREE (MTYPE_ROUTE_MAP_NAME, index->nextrm); - } - index->nextrm = XSTRDUP (MTYPE_ROUTE_MAP_NAME, rmap); + route_map_upd8_dependency (RMAP_EVENT_CALL_DELETED, + index->nextrm, + index->map->name); + XFREE (MTYPE_ROUTE_MAP_NAME, index->nextrm); } + index->nextrm = XSTRDUP (MTYPE_ROUTE_MAP_NAME, rmap); /* Execute event hook. */ route_map_upd8_dependency (RMAP_EVENT_CALL_ADDED, From 8ef0791cb6fa5eefd075661d0bcff0ff743cc3b3 Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Wed, 14 Dec 2016 19:14:04 +0100 Subject: [PATCH 013/107] build: remove $Format tags Signed-off-by: David Lamparter --- README.NetBSD | 2 -- bgpd/bgp_mpath.c | 3 +-- bgpd/bgp_mpath.h | 3 +-- pimd/AUTHORS | 2 -- pimd/CAVEATS | 2 -- pimd/COMMANDS | 2 -- pimd/DEBUG | 2 -- pimd/LINUX_KERNEL_MROUTE_MFC | 2 -- pimd/Makefile.am | 1 - pimd/README | 4 ---- pimd/TODO | 2 -- pimd/pim_assert.c | 2 -- pimd/pim_assert.h | 2 -- pimd/pim_cmd.c | 2 -- pimd/pim_cmd.h | 2 -- pimd/pim_hello.c | 2 -- pimd/pim_hello.h | 2 -- pimd/pim_iface.c | 2 -- pimd/pim_iface.h | 2 -- pimd/pim_ifchannel.c | 2 -- pimd/pim_ifchannel.h | 2 -- pimd/pim_igmp.c | 2 -- pimd/pim_igmp.h | 2 -- pimd/pim_igmp_join.h | 2 -- pimd/pim_igmpv3.c | 2 -- pimd/pim_igmpv3.h | 2 -- pimd/pim_int.c | 2 -- pimd/pim_int.h | 2 -- pimd/pim_join.c | 2 -- pimd/pim_join.h | 2 -- pimd/pim_macro.c | 2 -- pimd/pim_macro.h | 2 -- pimd/pim_main.c | 2 -- pimd/pim_mroute.c | 2 -- pimd/pim_mroute.h | 2 -- pimd/pim_msg.c | 2 -- pimd/pim_msg.h | 2 -- pimd/pim_neighbor.c | 2 -- pimd/pim_neighbor.h | 2 -- pimd/pim_oil.c | 2 -- pimd/pim_oil.h | 2 -- pimd/pim_pim.c | 2 -- pimd/pim_pim.h | 2 -- pimd/pim_rpf.c | 2 -- pimd/pim_rpf.h | 2 -- pimd/pim_signals.c | 2 -- pimd/pim_signals.h | 2 -- pimd/pim_sock.c | 2 -- pimd/pim_sock.h | 2 -- pimd/pim_ssmpingd.c | 2 -- pimd/pim_ssmpingd.h | 2 -- pimd/pim_static.c | 2 -- pimd/pim_static.h | 2 -- pimd/pim_str.c | 2 -- pimd/pim_str.h | 2 -- pimd/pim_time.c | 2 -- pimd/pim_time.h | 2 -- pimd/pim_tlv.c | 2 -- pimd/pim_tlv.h | 2 -- pimd/pim_upstream.c | 2 -- pimd/pim_upstream.h | 2 -- pimd/pim_util.c | 2 -- pimd/pim_util.h | 2 -- pimd/pim_version.c | 2 -- pimd/pim_version.h | 2 -- pimd/pim_vty.c | 2 -- pimd/pim_vty.h | 2 -- pimd/pim_zebra.c | 2 -- pimd/pim_zebra.h | 2 -- pimd/pim_zlookup.c | 2 -- pimd/pim_zlookup.h | 2 -- pimd/pimd.c | 2 -- pimd/pimd.conf.sample | 1 - pimd/pimd.h | 2 -- pimd/test_igmpv3_join.c | 2 -- tests/bgp_mpath_test.c | 3 +-- tests/table_test.c | 3 +-- zebra/client_main.c | 2 -- 78 files changed, 4 insertions(+), 156 deletions(-) diff --git a/README.NetBSD b/README.NetBSD index 6bbc680b95..6e454533e5 100755 --- a/README.NetBSD +++ b/README.NetBSD @@ -1,7 +1,5 @@ #!/bin/sh -# $QuaggaId: Format:%an, %ai, %h$ $ - # This file is helpful for building quagga from cvs on NetBSD, and # probably on any system using pkgsrc. # One should have readline installed already (pkgsrc/devel/readline). diff --git a/bgpd/bgp_mpath.c b/bgpd/bgp_mpath.c index e7272cc0aa..c9af8419f2 100644 --- a/bgpd/bgp_mpath.c +++ b/bgpd/bgp_mpath.c @@ -1,5 +1,4 @@ -/* $QuaggaId: Format:%an, %ai, %h$ $ - * +/* * BGP Multipath * Copyright (C) 2010 Google Inc. * diff --git a/bgpd/bgp_mpath.h b/bgpd/bgp_mpath.h index 0a51c98d06..9a38b5943d 100644 --- a/bgpd/bgp_mpath.h +++ b/bgpd/bgp_mpath.h @@ -1,5 +1,4 @@ -/* $QuaggaId: Format:%an, %ai, %h$ $ - * +/* * BGP Multipath * Copyright (C) 2010 Google Inc. * diff --git a/pimd/AUTHORS b/pimd/AUTHORS index f6135a410e..08869ff6fb 100644 --- a/pimd/AUTHORS +++ b/pimd/AUTHORS @@ -1,5 +1,3 @@ -# $QuaggaId: $Format:%an, %ai, %h$ $ - # Everton da Silva Marques $ more ~/.gitconfig [user] diff --git a/pimd/CAVEATS b/pimd/CAVEATS index 9f07bda666..43dd823ae5 100644 --- a/pimd/CAVEATS +++ b/pimd/CAVEATS @@ -1,5 +1,3 @@ -# $QuaggaId: $Format:%an, %ai, %h$ $ - C1 IGMPv3 backward compatibility with IGMPv1 and IGMPv2 is not implemented. See RFC 3376, 7.3. Multicast Router Behavior. That's because only Source-Specific Multicast is currently targeted. diff --git a/pimd/COMMANDS b/pimd/COMMANDS index 425ac82297..c545eca56e 100644 --- a/pimd/COMMANDS +++ b/pimd/COMMANDS @@ -1,5 +1,3 @@ -# $QuaggaId: $Format:%an, %ai, %h$ $ - global configuration commands: pimd: ip multicast-routing Enable IP multicast forwarding diff --git a/pimd/DEBUG b/pimd/DEBUG index 72fb8264b9..a6ad260e82 100644 --- a/pimd/DEBUG +++ b/pimd/DEBUG @@ -1,5 +1,3 @@ -# $QuaggaId: $Format:%an, %ai, %h$ $ - DEBUG HINTS - Check the source is issuing multicast packets with TTL high enough diff --git a/pimd/LINUX_KERNEL_MROUTE_MFC b/pimd/LINUX_KERNEL_MROUTE_MFC index e87e567f9d..3e482465f1 100644 --- a/pimd/LINUX_KERNEL_MROUTE_MFC +++ b/pimd/LINUX_KERNEL_MROUTE_MFC @@ -1,5 +1,3 @@ -# $QuaggaId: $Format:%an, %ai, %h$ $ - # # The Linux Kernel MFC (Multicast Forwarding Cache) # diff --git a/pimd/Makefile.am b/pimd/Makefile.am index eba05076d5..bc28aa1e92 100644 --- a/pimd/Makefile.am +++ b/pimd/Makefile.am @@ -1,5 +1,4 @@ ## Process this file with automake to produce Makefile.in. -## $QuaggaId: $Format:%an, %ai, %h$ $ # qpimd - pimd for quagga # Copyright (C) 2008 Everton da Silva Marques diff --git a/pimd/README b/pimd/README index 1e3f72c838..c8997808b6 100644 --- a/pimd/README +++ b/pimd/README @@ -1,7 +1,3 @@ -# -# $QuaggaId: $Format:%an, %ai, %h$ $ -# - INTRODUCTION qpimd aims to implement a PIM (Protocol Independent Multicast) diff --git a/pimd/TODO b/pimd/TODO index 2308573b87..4c0f183100 100644 --- a/pimd/TODO +++ b/pimd/TODO @@ -1,5 +1,3 @@ -# $QuaggaId: $Format:%an, %ai, %h$ $ - T1 DONE Implement debug command test pim receive join diff --git a/pimd/pim_assert.c b/pimd/pim_assert.c index d3df6a1102..f09540ea00 100644 --- a/pimd/pim_assert.c +++ b/pimd/pim_assert.c @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #include diff --git a/pimd/pim_assert.h b/pimd/pim_assert.h index bd3fb3e253..ec18cab85e 100644 --- a/pimd/pim_assert.h +++ b/pimd/pim_assert.h @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #ifndef PIM_ASSERT_H diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index 430fc738d5..3901992361 100644 --- a/pimd/pim_cmd.c +++ b/pimd/pim_cmd.c @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #include diff --git a/pimd/pim_cmd.h b/pimd/pim_cmd.h index 26191cd0b6..e6fbfa310c 100644 --- a/pimd/pim_cmd.h +++ b/pimd/pim_cmd.h @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #ifndef PIM_CMD_H diff --git a/pimd/pim_hello.c b/pimd/pim_hello.c index 21d0e5b85c..1cd44f2539 100644 --- a/pimd/pim_hello.c +++ b/pimd/pim_hello.c @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #include diff --git a/pimd/pim_hello.h b/pimd/pim_hello.h index b5e272d5de..3a6d3361ba 100644 --- a/pimd/pim_hello.h +++ b/pimd/pim_hello.h @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #ifndef PIM_HELLO_H diff --git a/pimd/pim_iface.c b/pimd/pim_iface.c index a8a1d08805..bac9692caa 100644 --- a/pimd/pim_iface.c +++ b/pimd/pim_iface.c @@ -15,8 +15,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #include diff --git a/pimd/pim_iface.h b/pimd/pim_iface.h index 790afabea1..e56559ca46 100644 --- a/pimd/pim_iface.h +++ b/pimd/pim_iface.h @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #ifndef PIM_IFACE_H diff --git a/pimd/pim_ifchannel.c b/pimd/pim_ifchannel.c index abfa5cc2b7..7afb7a5bdf 100644 --- a/pimd/pim_ifchannel.c +++ b/pimd/pim_ifchannel.c @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #include diff --git a/pimd/pim_ifchannel.h b/pimd/pim_ifchannel.h index e6f1c2947c..ce753222ee 100644 --- a/pimd/pim_ifchannel.h +++ b/pimd/pim_ifchannel.h @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #ifndef PIM_IFCHANNEL_H diff --git a/pimd/pim_igmp.c b/pimd/pim_igmp.c index 3b63b10e0d..ef1b3cbac0 100644 --- a/pimd/pim_igmp.c +++ b/pimd/pim_igmp.c @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #include diff --git a/pimd/pim_igmp.h b/pimd/pim_igmp.h index c6685c2837..eb0377ce8c 100644 --- a/pimd/pim_igmp.h +++ b/pimd/pim_igmp.h @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #ifndef PIM_IGMP_H diff --git a/pimd/pim_igmp_join.h b/pimd/pim_igmp_join.h index 1700276de8..ba80db0696 100644 --- a/pimd/pim_igmp_join.h +++ b/pimd/pim_igmp_join.h @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #ifndef PIM_IGMP_JOIN_H diff --git a/pimd/pim_igmpv3.c b/pimd/pim_igmpv3.c index 7300e6c6b4..bdaf2bb270 100644 --- a/pimd/pim_igmpv3.c +++ b/pimd/pim_igmpv3.c @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #include diff --git a/pimd/pim_igmpv3.h b/pimd/pim_igmpv3.h index bb7e92672a..db7895f9be 100644 --- a/pimd/pim_igmpv3.h +++ b/pimd/pim_igmpv3.h @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #ifndef PIM_IGMPV3_H diff --git a/pimd/pim_int.c b/pimd/pim_int.c index 208075190f..44b8386a3d 100644 --- a/pimd/pim_int.c +++ b/pimd/pim_int.c @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #include diff --git a/pimd/pim_int.h b/pimd/pim_int.h index d64b103277..a6349b5b3d 100644 --- a/pimd/pim_int.h +++ b/pimd/pim_int.h @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #ifndef PIM_INT_H diff --git a/pimd/pim_join.c b/pimd/pim_join.c index 3852b423f0..6a5fb851d6 100644 --- a/pimd/pim_join.c +++ b/pimd/pim_join.c @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #include diff --git a/pimd/pim_join.h b/pimd/pim_join.h index 37ec0f4525..dcdca00359 100644 --- a/pimd/pim_join.h +++ b/pimd/pim_join.h @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #ifndef PIM_JOIN_H diff --git a/pimd/pim_macro.c b/pimd/pim_macro.c index 39098df526..622bef4439 100644 --- a/pimd/pim_macro.c +++ b/pimd/pim_macro.c @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #include diff --git a/pimd/pim_macro.h b/pimd/pim_macro.h index 472fa9b4e7..3079ca80cc 100644 --- a/pimd/pim_macro.h +++ b/pimd/pim_macro.h @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #ifndef PIM_MACRO_H diff --git a/pimd/pim_main.c b/pimd/pim_main.c index aa3db3d5b2..8476964669 100644 --- a/pimd/pim_main.c +++ b/pimd/pim_main.c @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #include diff --git a/pimd/pim_mroute.c b/pimd/pim_mroute.c index 56f49d62f5..3fbed88800 100644 --- a/pimd/pim_mroute.c +++ b/pimd/pim_mroute.c @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #include diff --git a/pimd/pim_mroute.h b/pimd/pim_mroute.h index 176fb81cbc..f385ce09f4 100644 --- a/pimd/pim_mroute.h +++ b/pimd/pim_mroute.h @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #ifndef PIM_MROUTE_H diff --git a/pimd/pim_msg.c b/pimd/pim_msg.c index aa0433a2e2..9d0fc0ad8f 100644 --- a/pimd/pim_msg.c +++ b/pimd/pim_msg.c @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #include diff --git a/pimd/pim_msg.h b/pimd/pim_msg.h index a884fc84d9..96a89659e6 100644 --- a/pimd/pim_msg.h +++ b/pimd/pim_msg.h @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #ifndef PIM_MSG_H diff --git a/pimd/pim_neighbor.c b/pimd/pim_neighbor.c index 7e7cbc0d11..04792eb35e 100644 --- a/pimd/pim_neighbor.c +++ b/pimd/pim_neighbor.c @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #include diff --git a/pimd/pim_neighbor.h b/pimd/pim_neighbor.h index 5b2172dfc1..e023a7f1ef 100644 --- a/pimd/pim_neighbor.h +++ b/pimd/pim_neighbor.h @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #ifndef PIM_NEIGHBOR_H diff --git a/pimd/pim_oil.c b/pimd/pim_oil.c index 96f9ef2b62..ebbc6e19f9 100644 --- a/pimd/pim_oil.c +++ b/pimd/pim_oil.c @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #include diff --git a/pimd/pim_oil.h b/pimd/pim_oil.h index c63c026c0f..540acce3a3 100644 --- a/pimd/pim_oil.h +++ b/pimd/pim_oil.h @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #ifndef PIM_OIL_H diff --git a/pimd/pim_pim.c b/pimd/pim_pim.c index 0dfd39cd16..0f41a43315 100644 --- a/pimd/pim_pim.c +++ b/pimd/pim_pim.c @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #include diff --git a/pimd/pim_pim.h b/pimd/pim_pim.h index 4b378fb2c3..5692a37938 100644 --- a/pimd/pim_pim.h +++ b/pimd/pim_pim.h @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #ifndef PIM_PIM_H diff --git a/pimd/pim_rpf.c b/pimd/pim_rpf.c index 11d8464486..8d6e7b70c1 100644 --- a/pimd/pim_rpf.c +++ b/pimd/pim_rpf.c @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #include diff --git a/pimd/pim_rpf.h b/pimd/pim_rpf.h index 72cc7ba215..4d55bd6881 100644 --- a/pimd/pim_rpf.h +++ b/pimd/pim_rpf.h @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #ifndef PIM_RPF_H diff --git a/pimd/pim_signals.c b/pimd/pim_signals.c index 0344aa81d4..bd4d9e4857 100644 --- a/pimd/pim_signals.c +++ b/pimd/pim_signals.c @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #include diff --git a/pimd/pim_signals.h b/pimd/pim_signals.h index 62523c038b..7b25608c10 100644 --- a/pimd/pim_signals.h +++ b/pimd/pim_signals.h @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #ifndef PIM_SIGNALS_H diff --git a/pimd/pim_sock.c b/pimd/pim_sock.c index 231efd0f22..54816d126b 100644 --- a/pimd/pim_sock.c +++ b/pimd/pim_sock.c @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #include diff --git a/pimd/pim_sock.h b/pimd/pim_sock.h index cd29543fa0..f905c661dd 100644 --- a/pimd/pim_sock.h +++ b/pimd/pim_sock.h @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #ifndef PIM_SOCK_H diff --git a/pimd/pim_ssmpingd.c b/pimd/pim_ssmpingd.c index fba563a6f8..ece644a861 100644 --- a/pimd/pim_ssmpingd.c +++ b/pimd/pim_ssmpingd.c @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #include diff --git a/pimd/pim_ssmpingd.h b/pimd/pim_ssmpingd.h index 4bef20b209..54f787e2a3 100644 --- a/pimd/pim_ssmpingd.h +++ b/pimd/pim_ssmpingd.h @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #ifndef PIM_SSMPINGD_H diff --git a/pimd/pim_static.c b/pimd/pim_static.c index 5882142b32..565d6fe728 100644 --- a/pimd/pim_static.c +++ b/pimd/pim_static.c @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #include diff --git a/pimd/pim_static.h b/pimd/pim_static.h index 07d31d59b7..c288aa7ff4 100644 --- a/pimd/pim_static.h +++ b/pimd/pim_static.h @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #ifndef PIM_STATIC_H_ diff --git a/pimd/pim_str.c b/pimd/pim_str.c index 3a8353cd8c..c817045697 100644 --- a/pimd/pim_str.c +++ b/pimd/pim_str.c @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #include diff --git a/pimd/pim_str.h b/pimd/pim_str.h index 925f17f732..d2af0110a4 100644 --- a/pimd/pim_str.h +++ b/pimd/pim_str.h @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #ifndef PIM_STR_H diff --git a/pimd/pim_time.c b/pimd/pim_time.c index 4e5832cc65..75f767fef1 100644 --- a/pimd/pim_time.c +++ b/pimd/pim_time.c @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #include diff --git a/pimd/pim_time.h b/pimd/pim_time.h index 2984d9a8df..8ccc6a9207 100644 --- a/pimd/pim_time.h +++ b/pimd/pim_time.h @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #ifndef PIM_TIME_H diff --git a/pimd/pim_tlv.c b/pimd/pim_tlv.c index 38f6de9fea..546ceb86e1 100644 --- a/pimd/pim_tlv.c +++ b/pimd/pim_tlv.c @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #include diff --git a/pimd/pim_tlv.h b/pimd/pim_tlv.h index 8556e931ab..16c5aa4b97 100644 --- a/pimd/pim_tlv.h +++ b/pimd/pim_tlv.h @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #ifndef PIM_TLV_H diff --git a/pimd/pim_upstream.c b/pimd/pim_upstream.c index 8267885756..059de3b62e 100644 --- a/pimd/pim_upstream.c +++ b/pimd/pim_upstream.c @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #include diff --git a/pimd/pim_upstream.h b/pimd/pim_upstream.h index ea44707c54..f10c8feb3b 100644 --- a/pimd/pim_upstream.h +++ b/pimd/pim_upstream.h @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #ifndef PIM_UPSTREAM_H diff --git a/pimd/pim_util.c b/pimd/pim_util.c index 57a8488eca..f5b6a8210a 100644 --- a/pimd/pim_util.c +++ b/pimd/pim_util.c @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #include diff --git a/pimd/pim_util.h b/pimd/pim_util.h index a8613e2b97..d780bfbc27 100644 --- a/pimd/pim_util.h +++ b/pimd/pim_util.h @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #ifndef PIM_UTIL_H diff --git a/pimd/pim_version.c b/pimd/pim_version.c index f3a5ee3359..a43c27d5b5 100644 --- a/pimd/pim_version.c +++ b/pimd/pim_version.c @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #include diff --git a/pimd/pim_version.h b/pimd/pim_version.h index ef9f370c73..64e07862d6 100644 --- a/pimd/pim_version.h +++ b/pimd/pim_version.h @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #ifndef PIM_VERSION_H diff --git a/pimd/pim_vty.c b/pimd/pim_vty.c index 037a00c4da..07c65e4e53 100644 --- a/pimd/pim_vty.c +++ b/pimd/pim_vty.c @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #include diff --git a/pimd/pim_vty.h b/pimd/pim_vty.h index 904ee55302..18a632e016 100644 --- a/pimd/pim_vty.h +++ b/pimd/pim_vty.h @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #ifndef PIM_VTY_H diff --git a/pimd/pim_zebra.c b/pimd/pim_zebra.c index 1822de2299..f2195960c4 100644 --- a/pimd/pim_zebra.c +++ b/pimd/pim_zebra.c @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #include diff --git a/pimd/pim_zebra.h b/pimd/pim_zebra.h index 8e8f09551a..257c9b896f 100644 --- a/pimd/pim_zebra.h +++ b/pimd/pim_zebra.h @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #ifndef PIM_ZEBRA_H diff --git a/pimd/pim_zlookup.c b/pimd/pim_zlookup.c index 86d7edbd01..af561a0b62 100644 --- a/pimd/pim_zlookup.c +++ b/pimd/pim_zlookup.c @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #include diff --git a/pimd/pim_zlookup.h b/pimd/pim_zlookup.h index f2be6d4fa0..dbce92647b 100644 --- a/pimd/pim_zlookup.h +++ b/pimd/pim_zlookup.h @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #ifndef PIM_ZLOOKUP_H diff --git a/pimd/pimd.c b/pimd/pimd.c index 91d8d56afc..15e52afc1d 100644 --- a/pimd/pimd.c +++ b/pimd/pimd.c @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #include diff --git a/pimd/pimd.conf.sample b/pimd/pimd.conf.sample index 67530856b6..de1da6b838 100644 --- a/pimd/pimd.conf.sample +++ b/pimd/pimd.conf.sample @@ -1,6 +1,5 @@ ! ! pimd sample configuration file -! $QuaggaId: $Format:%an, %ai, %h$ $ ! hostname quagga-pimd-router password zebra diff --git a/pimd/pimd.h b/pimd/pimd.h index 8855a2ab3f..2230a6ce91 100644 --- a/pimd/pimd.h +++ b/pimd/pimd.h @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #ifndef PIMD_H diff --git a/pimd/test_igmpv3_join.c b/pimd/test_igmpv3_join.c index 5c4574024b..29143f362e 100644 --- a/pimd/test_igmpv3_join.c +++ b/pimd/test_igmpv3_join.c @@ -16,8 +16,6 @@ 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 - - $QuaggaId: $Format:%an, %ai, %h$ $ */ #include diff --git a/tests/bgp_mpath_test.c b/tests/bgp_mpath_test.c index 723f2977d5..f9eb1534f3 100644 --- a/tests/bgp_mpath_test.c +++ b/tests/bgp_mpath_test.c @@ -1,5 +1,4 @@ -/* $QuaggaId: Format:%an, %ai, %h$ $ - * +/* * BGP Multipath Unit Test * Copyright (C) 2010 Google Inc. * diff --git a/tests/table_test.c b/tests/table_test.c index ee81927073..4042e1aaa2 100644 --- a/tests/table_test.c +++ b/tests/table_test.c @@ -1,5 +1,4 @@ -/* $QuaggaId: Format:%an, %ai, %h$ $ - * +/* * Routing table test * Copyright (C) 2012 OSR. * diff --git a/zebra/client_main.c b/zebra/client_main.c index 24bfa56d02..8290eafc4d 100644 --- a/zebra/client_main.c +++ b/zebra/client_main.c @@ -1,6 +1,4 @@ /* - * $Quagga: $Format:%an, %ai, %h$ $ - * * GNU Zebra client test main routine. * Copyright (C) 1997 Kunihiro Ishiguro * From 461c7bee694297e7588d062e5e8ced37c12299ee Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Wed, 14 Dec 2016 20:24:34 +0100 Subject: [PATCH 014/107] doc: rename manpages to ".in" for autoconf The manpages contain references to installation paths and thus should be preprocessed by ./configure to get the actual paths. This commit is an exact-rename so the changes for the preprocessing are easier to review (diffs in renames are hard to read...) Signed-off-by: David Lamparter --- configure.ac | 13 +++++++++++++ doc/Makefile.am | 17 +++++++++++++++-- doc/{bgpd.8 => bgpd.8.in} | 0 doc/{isisd.8 => isisd.8.in} | 0 doc/{ldpd.8 => ldpd.8.in} | 0 doc/{ospf6d.8 => ospf6d.8.in} | 0 doc/{ospfclient.8 => ospfclient.8.in} | 0 doc/{ospfd.8 => ospfd.8.in} | 0 doc/{pimd.8 => pimd.8.in} | 0 doc/{quagga.1 => quagga.1.in} | 0 doc/{ripd.8 => ripd.8.in} | 0 doc/{ripngd.8 => ripngd.8.in} | 0 doc/{vtysh.1 => vtysh.1.in} | 0 doc/{watchquagga.8 => watchquagga.8.in} | 0 doc/{zebra.8 => zebra.8.in} | 0 15 files changed, 28 insertions(+), 2 deletions(-) rename doc/{bgpd.8 => bgpd.8.in} (100%) rename doc/{isisd.8 => isisd.8.in} (100%) rename doc/{ldpd.8 => ldpd.8.in} (100%) rename doc/{ospf6d.8 => ospf6d.8.in} (100%) rename doc/{ospfclient.8 => ospfclient.8.in} (100%) rename doc/{ospfd.8 => ospfd.8.in} (100%) rename doc/{pimd.8 => pimd.8.in} (100%) rename doc/{quagga.1 => quagga.1.in} (100%) rename doc/{ripd.8 => ripd.8.in} (100%) rename doc/{ripngd.8 => ripngd.8.in} (100%) rename doc/{vtysh.1 => vtysh.1.in} (100%) rename doc/{watchquagga.8 => watchquagga.8.in} (100%) rename doc/{zebra.8 => zebra.8.in} (100%) diff --git a/configure.ac b/configure.ac index 99b23c5609..0eeeb627ba 100755 --- a/configure.ac +++ b/configure.ac @@ -1602,6 +1602,19 @@ AC_CONFIG_FILES([Makefile lib/Makefile qpb/Makefile zebra/Makefile ripd/Makefile redhat/quagga.spec lib/version.h doc/defines.texi + doc/bgpd.8 + doc/isisd.8 + doc/ospf6d.8 + doc/ospfclient.8 + doc/ospfd.8 + doc/ldpd.8 + doc/ripd.8 + doc/ripngd.8 + doc/pimd.8 + doc/vtysh.1 + doc/watchquagga.8 + doc/zebra.8 + doc/quagga.1 pkgsrc/bgpd.sh pkgsrc/ospf6d.sh pkgsrc/ospfd.sh pkgsrc/ripd.sh pkgsrc/ripngd.sh pkgsrc/zebra.sh]) diff --git a/doc/Makefile.am b/doc/Makefile.am index d5db6cf497..ab2657bba4 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -124,8 +124,21 @@ man_MANS += zebra.8 endif EXTRA_DIST = BGP-TypeCode draft-zebra-00.ms draft-zebra-00.txt \ - bgpd.8 isisd.8 ospf6d.8 ospfclient.8 ospfd.8 ldpd.8 ripd.8 \ - ripngd.8 pimd.8 vtysh.1 watchquagga.8 zebra.8 quagga.1 \ + \ + bgpd.8.in \ + isisd.8.in \ + ospf6d.8.in \ + ospfclient.8.in \ + ospfd.8.in \ + ldpd.8.in \ + ripd.8.in \ + ripngd.8.in \ + pimd.8.in \ + vtysh.1.in \ + watchquagga.8.in \ + zebra.8.in \ + quagga.1.in \ + \ mpls/ChangeLog.opaque.txt mpls/cli_summary.txt \ mpls/opaque_lsa.txt mpls/ospfd.conf \ $(figures_sources) $(figures_png) $(figures_txt) diff --git a/doc/bgpd.8 b/doc/bgpd.8.in similarity index 100% rename from doc/bgpd.8 rename to doc/bgpd.8.in diff --git a/doc/isisd.8 b/doc/isisd.8.in similarity index 100% rename from doc/isisd.8 rename to doc/isisd.8.in diff --git a/doc/ldpd.8 b/doc/ldpd.8.in similarity index 100% rename from doc/ldpd.8 rename to doc/ldpd.8.in diff --git a/doc/ospf6d.8 b/doc/ospf6d.8.in similarity index 100% rename from doc/ospf6d.8 rename to doc/ospf6d.8.in diff --git a/doc/ospfclient.8 b/doc/ospfclient.8.in similarity index 100% rename from doc/ospfclient.8 rename to doc/ospfclient.8.in diff --git a/doc/ospfd.8 b/doc/ospfd.8.in similarity index 100% rename from doc/ospfd.8 rename to doc/ospfd.8.in diff --git a/doc/pimd.8 b/doc/pimd.8.in similarity index 100% rename from doc/pimd.8 rename to doc/pimd.8.in diff --git a/doc/quagga.1 b/doc/quagga.1.in similarity index 100% rename from doc/quagga.1 rename to doc/quagga.1.in diff --git a/doc/ripd.8 b/doc/ripd.8.in similarity index 100% rename from doc/ripd.8 rename to doc/ripd.8.in diff --git a/doc/ripngd.8 b/doc/ripngd.8.in similarity index 100% rename from doc/ripngd.8 rename to doc/ripngd.8.in diff --git a/doc/vtysh.1 b/doc/vtysh.1.in similarity index 100% rename from doc/vtysh.1 rename to doc/vtysh.1.in diff --git a/doc/watchquagga.8 b/doc/watchquagga.8.in similarity index 100% rename from doc/watchquagga.8 rename to doc/watchquagga.8.in diff --git a/doc/zebra.8 b/doc/zebra.8.in similarity index 100% rename from doc/zebra.8 rename to doc/zebra.8.in From a07169b1f687e993359a3033dc6bbeea48464ead Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Wed, 14 Dec 2016 20:22:25 +0100 Subject: [PATCH 015/107] doc: use config values from configure in manpages This makes the actual change to the manpages to get ./configure effects applied into them. Signed-off-by: David Lamparter --- configure.ac | 17 +++++++++++++++++ doc/bgpd.8.in | 25 ++++++++++++------------- doc/defines.texi.in | 8 +++++--- doc/isisd.8.in | 22 +++++++++++----------- doc/ldpd.8.in | 24 ++++++++++++------------ doc/ospf6d.8.in | 24 ++++++++++++------------ doc/ospfclient.8.in | 2 +- doc/ospfd.8.in | 24 ++++++++++++------------ doc/pimd.8.in | 24 ++++++++++++------------ doc/quagga.1.in | 10 +++++----- doc/ripd.8.in | 24 ++++++++++++------------ doc/ripngd.8.in | 24 ++++++++++++------------ doc/vtysh.1.in | 26 +++++++++++++------------- doc/watchquagga.8.in | 2 +- doc/zebra.8.in | 22 +++++++++++----------- 15 files changed, 148 insertions(+), 130 deletions(-) diff --git a/configure.ac b/configure.ac index 0eeeb627ba..04478f255b 100755 --- a/configure.ac +++ b/configure.ac @@ -8,8 +8,13 @@ AC_PREREQ(2.60) AC_INIT(Quagga, 2.0-rc0, [https://bugzilla.quagga.net]) +PACKAGE_URL="http://www.quagga.net" +PACKAGE_FULLNAME="Quagga" +AC_SUBST(PACKAGE_FULLNAME) + CONFIG_ARGS="$ac_configure_args" AC_SUBST(CONFIG_ARGS) + AC_CONFIG_SRCDIR(lib/zebra.h) AC_CONFIG_MACRO_DIR([m4]) @@ -1568,6 +1573,18 @@ for I in 1 2 3 4 5 6 7 8 9 10; do done AC_DEFINE_UNQUOTED(VTYSH_BIN_PATH, "$vtysh_bin",path to vtysh binary) +CFG_SYSCONF="$sysconfdir" +CFG_SBIN="$sbindir" +CFG_STATE="$frr_statedir" +for I in 1 2 3 4 5 6 7 8 9 10; do + eval CFG_SYSCONF="\"$CFG_SYSCONF\"" + eval CFG_SBIN="\"$CFG_SBIN\"" + eval CFG_STATE="\"$CFG_STATE\"" +done +AC_SUBST(CFG_SYSCONF) +AC_SUBST(CFG_SBIN) +AC_SUBST(CFG_STATE) + dnl ------------------------------- dnl Quagga sources should always be dnl current wrt interfaces. Dont diff --git a/doc/bgpd.8.in b/doc/bgpd.8.in index 7e90eaec5b..7047744635 100644 --- a/doc/bgpd.8.in +++ b/doc/bgpd.8.in @@ -1,7 +1,6 @@ -.TH BGPD 8 "25 November 2004" "Quagga BGPD daemon" "Version 0.97.3" +.TH BGPD 8 "25 November 2004" "@PACKAGE_FULLNAME@ BGPD daemon" "Version @PACKAGE_VERSION@" .SH NAME -bgpd \- a BGPv4, BGPv4\+, BGPv4\- routing engine for use with Quagga routing -software +bgpd \- a BGPv4, BGPv4\+, BGPv4\- routing engine for use with @PACKAGE_FULLNAME@. .SH SYNOPSIS .B bgpd @@ -32,7 +31,7 @@ software .SH DESCRIPTION .B bgpd is a routing component that works with the -.B Quagga +.B @PACKAGE_FULLNAME@ routing engine. .SH OPTIONS Options available for the @@ -44,10 +43,10 @@ Runs in daemon mode, forking and exiting from tty. .TP \fB\-f\fR, \fB\-\-config-file \fR\fIconfig-file\fR Specifies the config file to use for startup. If not specified this -option will likely default to \fB\fI/usr/local/etc/bgpd.conf\fR. +option will default to \fB\fI@CFG_SYSCONF@/bgpd.conf\fR. .TP \fB\-g\fR, \fB\-\-group \fR\fIgroup\fR -Specify the group to run as. Default is \fIquagga\fR. +Specify the group to run as. Default is \fI@enable_group@\fR. .TP \fB\-h\fR, \fB\-\-help\fR A brief message. @@ -55,7 +54,7 @@ A brief message. \fB\-i\fR, \fB\-\-pid_file \fR\fIpid-file\fR When bgpd starts its process identifier is written to \fB\fIpid-file\fR. The init system uses the recorded PID to stop or -restart bgpd. The likely default is \fB\fI/var/run/bgpd.pid\fR. +restart bgpd. The default is \fB\fI@CFG_STATE@/bgpd.pid\fR. .TP \fB\-p\fR, \fB\-\-bgp_port \fR\fIbgp-port-number\fR Set the port that bgpd will listen to for bgp data. @@ -69,7 +68,7 @@ Specify the address that the bgpd VTY will listen on. Default is all interfaces. .TP \fB\-u\fR, \fB\-\-user \fR\fIuser\fR -Specify the user to run as. Default is \fIquagga\fR. +Specify the user to run as. Default is \fI@enable_user@\fR. .TP \fB\-r\fR, \fB\-\-retain\fR When the program terminates, retain routes added by \fBbgpd\fR. @@ -81,12 +80,12 @@ Skip setting the process effective user and group. Print the version and exit. .SH FILES .TP -.BI /usr/lib/quagga/bgpd +.BI @CFG_SBIN@/bgpd The default location of the .B bgpd binary. .TP -.BI /etc/quagga/bgpd.conf +.BI @CFG_SYSCONF@/bgpd.conf The default location of the .B bgpd config file. @@ -98,7 +97,7 @@ process is config'd to output logs to a file, then you will find this file in the directory where you started \fBbgpd\fR. .SH WARNING This man page is intended to be a quick reference for command line -options. The definitive document is the Info file \fBQuagga\fR. +options. The definitive document is the Info file \fB@PACKAGE_NAME@\fR. .SH DIAGNOSTICS The bgpd process may log to standard output, to a VTY, to a log file, or through syslog to the system logs. \fBbgpd\fR supports many @@ -114,11 +113,11 @@ debugging options, see the Info file, or the source for details. .SH BUGS .B bgpd eats bugs for breakfast. If you have food for the maintainers try -.BI http://bugzilla.quagga.net +.BI @PACKAGE_BUGREPORT@ .SH AUTHORS See .BI http://www.zebra.org and -.BI http://www.quagga.net +.BI @PACKAGE_URL@ or the Info file for an accurate list of authors. diff --git a/doc/defines.texi.in b/doc/defines.texi.in index 5436f20c36..43d7442939 100644 --- a/doc/defines.texi.in +++ b/doc/defines.texi.in @@ -10,7 +10,9 @@ @set COPYRIGHT_STR Copyright @copyright{} @value{COPYRIGHT_YEAR} @value{AUTHORS} @c These may vary with installation environment. -@set INSTALL_PREFIX_ETC /etc/quagga -@set INSTALL_PREFIX_SBIN /usr/sbin -@set INSTALL_PREFIX_STATE /var/run/quagga +@set INSTALL_PREFIX_ETC @CFG_SYSCONF@ +@set INSTALL_PREFIX_SBIN @CFG_SBIN@ +@set INSTALL_PREFIX_STATE @CFG_STATE@ +@set INSTALL_USER @enable_user@ +@set INSTALL_GROUP @enable_group@ @set INSTALL_VTY_GROUP @enable_vty_group@ diff --git a/doc/isisd.8.in b/doc/isisd.8.in index 83ac99d57a..9ffcbc618d 100644 --- a/doc/isisd.8.in +++ b/doc/isisd.8.in @@ -1,6 +1,6 @@ -.TH IS-IS 8 "25 November 2004" "Quagga IS-IS daemon" "Version 0.97.3" +.TH IS-IS 8 "25 November 2004" "@PACKAGE_FULLNAME@ IS-IS daemon" "Version @PACKAGE_VERSION@" .SH NAME -isisd \- an IS-IS routing engine for use with Quagga routing software. +isisd \- an IS-IS routing engine for use with @PACKAGE_FULLNAME@. .SH SYNOPSIS .B isisd [ @@ -27,7 +27,7 @@ isisd \- an IS-IS routing engine for use with Quagga routing software. .SH DESCRIPTION .B isisd is a routing component that works with the -.B Quagga +.B @PACKAGE_FULLNAME@ routing engine. .SH OPTIONS Options available for the @@ -39,10 +39,10 @@ Runs in daemon mode, forking and exiting from tty. .TP \fB\-f\fR, \fB\-\-config-file \fR\fIconfig-file\fR Specifies the config file to use for startup. If not specified this -option will likely default to \fB\fI/usr/local/etc/isisd.conf\fR. +option will default to \fB\fI@CFG_SYSCONF@/isisd.conf\fR. .TP \fB\-g\fR, \fB\-\-group \fR\fIgroup\fR -Specify the group to run as. Default is \fIquagga\fR. +Specify the group to run as. Default is \fI@enable_group@\fR. .TP \fB\-h\fR, \fB\-\-help\fR A brief message. @@ -50,7 +50,7 @@ A brief message. \fB\-i\fR, \fB\-\-pid_file \fR\fIpid-file\fR When isisd starts its process identifier is written to \fB\fIpid-file\fR. The init system uses the recorded PID to stop or -restart isisd. The likely default is \fB\fI/var/run/isisd.pid\fR. +restart isisd. The default is \fB\fI@CFG_STATE@/isisd.pid\fR. .TP \fB\-P\fR, \fB\-\-vty_port \fR\fIport-number\fR Specify the port that the isisd VTY will listen on. This defaults to @@ -61,18 +61,18 @@ Specify the address that the isisd VTY will listen on. Default is all interfaces. .TP \fB\-u\fR, \fB\-\-user \fR\fIuser\fR -Specify the user to run as. Default is \fIquagga\fR. +Specify the user to run as. Default is \fI@enable_user@\fR. .TP \fB\-v\fR, \fB\-\-version\fR Print the version and exit. .SH FILES .TP -.BI /usr/lib/quagga/isisd +.BI @CFG_SBIN@/isisd The default location of the .B isisd binary. .TP -.BI /etc/quagga/isisd.conf +.BI @CFG_SYSCONF@/isisd.conf The default location of the .B isisd config file. @@ -84,7 +84,7 @@ process is config'd to output logs to a file, then you will find this file in the directory where you started \fBisisd\fR. .SH WARNING This man page is intended to be a quick reference for command line -options. The definitive document is the Info file \fBQuagga\fR. +options. The definitive document is the Info file \fB@PACKAGE_NAME@\fR. .SH DIAGNOSTICS The isisd process may log to standard output, to a VTY, to a log file, or through syslog to the system logs. \fBisisd\fR supports many @@ -103,7 +103,7 @@ production use. .B isisd eats bugs for breakfast. If you have food for the maintainers try -.BI http://bugzilla.quagga.net +.BI @PACKAGE_BUGREPORT@ .SH AUTHORS See .BI http://isisd.sourceforge.net diff --git a/doc/ldpd.8.in b/doc/ldpd.8.in index 092ff39d49..1683de46ca 100644 --- a/doc/ldpd.8.in +++ b/doc/ldpd.8.in @@ -1,6 +1,6 @@ -.TH LDPD 8 "29 March 2016" "Quagga LDP daemon" "Version 1.0.20160309" +.TH LDPD 8 "29 March 2016" "@PACKAGE_FULLNAME@ LDP daemon" "Version @PACKAGE_VERSION@" .SH NAME -ldpd \- an LDP engine for use with Quagga routing software. +ldpd \- an LDP engine for use with @PACKAGE_FULLNAME@. .SH SYNOPSIS .B ldpd [ @@ -27,7 +27,7 @@ ldpd \- an LDP engine for use with Quagga routing software. .SH DESCRIPTION .B ldpd is a component that works with the -.B Quagga +.B @PACKAGE_FULLNAME@ routing engine. .SH OPTIONS Options available for the @@ -39,10 +39,10 @@ Runs in daemon mode, forking and exiting from tty. .TP \fB\-f\fR, \fB\-\-config-file \fR\fIconfig-file\fR Specifies the config file to use for startup. If not specified this -option will likely default to \fB\fI/usr/local/etc/ldpd.conf\fR. +option will default to \fB\fI@CFG_SYSCONF@/ldpd.conf\fR. .TP \fB\-g\fR, \fB\-\-group \fR\fIgroup\fR -Specify the group to run as. Default is \fIquagga\fR. +Specify the group to run as. Default is \fI@enable_group@\fR. .TP \fB\-h\fR, \fB\-\-help\fR A brief message. @@ -50,7 +50,7 @@ A brief message. \fB\-i\fR, \fB\-\-pid_file \fR\fIpid-file\fR When ldpd starts its process identifier is written to \fB\fIpid-file\fR. The init system uses the recorded PID to stop or -restart ldpd. The likely default is \fB\fI/var/run/ldpd.pid\fR. +restart ldpd. The default is \fB\fI@CFG_STATE@/ldpd.pid\fR. .TP \fB\-P\fR, \fB\-\-vty_port \fR\fIport-number\fR Specify the port that the ldpd VTY will listen on. This defaults to @@ -61,18 +61,18 @@ Specify the address that the ldpd VTY will listen on. Default is all interfaces. .TP \fB\-u\fR, \fB\-\-user \fR\fIuser\fR -Specify the user to run as. Default is \fIquagga\fR. +Specify the user to run as. Default is \fI@enable_user@\fR. .TP \fB\-v\fR, \fB\-\-version\fR Print the version and exit. .SH FILES .TP -.BI /usr/local/sbin/ldpd +.BI @CFG_SBIN@/ldpd The default location of the .B ldpd binary. .TP -.BI /usr/local/etc/ldpd.conf +.BI @CFG_SYSCONF@/ldpd.conf The default location of the .B ldpd config file. @@ -84,7 +84,7 @@ process is config'd to output logs to a file, then you will find this file in the directory where you started \fBldpd\fR. .SH WARNING This man page is intended to be a quick reference for command line -options. The definitive document is the Info file \fBQuagga\fR. +options. The definitive document is the Info file \fB@PACKAGE_NAME@\fR. .SH DIAGNOSTICS The ldpd process may log to standard output, to a VTY, to a log file, or through syslog to the system logs. \fBldpd\fR supports many @@ -101,9 +101,9 @@ debugging options, see the Info file, or the source for details. .SH BUGS .B ldpd eats bugs for breakfast. If you have food for the maintainers try -.BI http://bugzilla.quagga.net +.BI @PACKAGE_BUGREPORT@ .SH AUTHORS See -.BI http://www.quagga.net +.BI @PACKAGE_URL@ or the Info file for an accurate list of authors. diff --git a/doc/ospf6d.8.in b/doc/ospf6d.8.in index 630b20afdd..7f94782bea 100644 --- a/doc/ospf6d.8.in +++ b/doc/ospf6d.8.in @@ -1,6 +1,6 @@ -.TH OSPF6D 8 "25 November 2004" "Quagga OSPFv3 daemon" "Version 0.97.3" +.TH OSPF6D 8 "25 November 2004" "@PACKAGE_FULLNAME@ OSPFv3 daemon" "Version @PACKAGE_VERSION@" .SH NAME -ospf6d \- an OSPFv3 routing engine for use with Quagga routing software. +ospf6d \- an OSPFv3 routing engine for use with @PACKAGE_FULLNAME@. .SH SYNOPSIS .B ospf6d [ @@ -27,7 +27,7 @@ ospf6d \- an OSPFv3 routing engine for use with Quagga routing software. .SH DESCRIPTION .B ospf6d is a routing component that works with the -.B Quagga +.B @PACKAGE_FULLNAME@ routing engine. .SH OPTIONS Options available for the @@ -40,10 +40,10 @@ Runs in daemon mode, forking and exiting from tty. .TP \fB\-f\fR, \fB\-\-config-file \fR\fIconfig-file\fR Specifies the config file to use for startup. If not specified this -option will likely default to \fB\fI/usr/local/etc/ospf6d.conf\fR. +option will default to \fB\fI@CFG_SYSCONF@/ospf6d.conf\fR. .TP \fB\-g\fR, \fB\-\-group \fR\fIgroup\fR -Specify the group to run as. Default is \fIquagga\fR. +Specify the group to run as. Default is \fI@enable_group@\fR. .TP \fB\-h\fR, \fB\-\-help\fR A brief message. @@ -51,7 +51,7 @@ A brief message. \fB\-i\fR, \fB\-\-pid_file \fR\fIpid-file\fR When ospf6d starts its process identifier is written to \fB\fIpid-file\fR. The init system uses the recorded PID to stop or -restart ospf6d. The likely default is \fB\fI/var/run/ospf6d.pid\fR. +restart ospf6d. The default is \fB\fI@CFG_STATE@/ospf6d.pid\fR. .TP \fB\-P\fR, \fB\-\-vty_port \fR\fIport-number\fR Specify the port that the ospf6d VTY will listen on. This defaults to @@ -62,18 +62,18 @@ Specify the address that the ospf6d VTY will listen on. Default is all interfaces. .TP \fB\-u\fR, \fB\-\-user \fR\fIuser\fR -Specify the user to run as. Default is \fIquagga\fR. +Specify the user to run as. Default is \fI@enable_user@\fR. .TP \fB\-v\fR, \fB\-\-version\fR Print the version and exit. .SH FILES .TP -.BI /usr/lib/quagga/ospf6d +.BI @CFG_SBIN@/ospf6d The default location of the .B ospf6d binary. .TP -.BI /etc/quagga/ospf6d.conf +.BI @CFG_SYSCONF@/ospf6d.conf The default location of the .B ospf6d config file. @@ -85,7 +85,7 @@ process is config'd to output logs to a file, then you will find this file in the directory where you started \fBospf6d\fR. .SH WARNING This man page is intended to be a quick reference for command line -options. The definitive document is the Info file \fBQuagga\fR. +options. The definitive document is the Info file \fB@PACKAGE_NAME@\fR. .SH DIAGNOSTICS The ospf6d process may log to standard output, to a VTY, to a log file, or through syslog to the system logs. \fBospf6d\fR supports many @@ -101,11 +101,11 @@ debugging options, see the Info file, or the source for details. .SH BUGS .B ospf6d eats bugs for breakfast. If you have food for the maintainers try -.BI http://bugzilla.quagga.net +.BI @PACKAGE_BUGREPORT@ .SH AUTHORS See .BI http://www.zebra.org and -.BI http://www.quagga.net +.BI @PACKAGE_URL@ or the Info file for an accurate list of authors. diff --git a/doc/ospfclient.8.in b/doc/ospfclient.8.in index ccfad1aad0..fb996a541f 100644 --- a/doc/ospfclient.8.in +++ b/doc/ospfclient.8.in @@ -39,4 +39,4 @@ Area in the IP address format for type 10, otherwise it will be ignored. .SH "SEE ALSO" .BR ospfd (8). .SH AUTHORS -See the project homepage at . +See the project homepage at <@PACKAGE_URL@>. diff --git a/doc/ospfd.8.in b/doc/ospfd.8.in index ba8848affa..1b86551ca5 100644 --- a/doc/ospfd.8.in +++ b/doc/ospfd.8.in @@ -1,6 +1,6 @@ -.TH OSPFD 8 "25 November 2004" "Quagga OSPFv2 daemon" "Version 0.97.3" +.TH OSPFD 8 "25 November 2004" "@PACKAGE_FULLNAME@ OSPFv2 daemon" "Version @PACKAGE_VERSION@" .SH NAME -ospfd \- an OSPFv2 routing engine for use with Quagga routing software. +ospfd \- an OSPFv2 routing engine for use with @PACKAGE_FULLNAME@. .SH SYNOPSIS .B ospfd [ @@ -27,7 +27,7 @@ ospfd \- an OSPFv2 routing engine for use with Quagga routing software. .SH DESCRIPTION .B ospfd is a routing component that works with the -.B Quagga +.B @PACKAGE_FULLNAME@ routing engine. .SH OPTIONS Options available for the @@ -39,10 +39,10 @@ Runs in daemon mode, forking and exiting from tty. .TP \fB\-f\fR, \fB\-\-config-file \fR\fIconfig-file\fR Specifies the config file to use for startup. If not specified this -option will likely default to \fB\fI/usr/local/etc/ospfd.conf\fR. +option will default to \fB\fI@CFG_SYSCONF@/ospfd.conf\fR. .TP \fB\-g\fR, \fB\-\-group \fR\fIgroup\fR -Specify the group to run as. Default is \fIquagga\fR. +Specify the group to run as. Default is \fI@enable_group@\fR. .TP \fB\-h\fR, \fB\-\-help\fR A brief message. @@ -50,7 +50,7 @@ A brief message. \fB\-i\fR, \fB\-\-pid_file \fR\fIpid-file\fR When ospfd starts its process identifier is written to \fB\fIpid-file\fR. The init system uses the recorded PID to stop or -restart ospfd. The likely default is \fB\fI/var/run/ospfd.pid\fR. +restart ospfd. The default is \fB\fI@CFG_STATE@/ospfd.pid\fR. .TP \fB\-P\fR, \fB\-\-vty_port \fR\fIport-number\fR Specify the port that the ospfd VTY will listen on. This defaults to @@ -61,7 +61,7 @@ Specify the address that the ospfd VTY will listen on. Default is all interfaces. .TP \fB\-u\fR, \fB\-\-user \fR\fIuser\fR -Specify the user to run as. Default is \fIquagga\fR. +Specify the user to run as. Default is \fI@enable_user@\fR. .TP \fB\-a\fR, \fB\-\-apiserver \fR Enable OSPF apiserver. Default is disabled. @@ -70,12 +70,12 @@ Enable OSPF apiserver. Default is disabled. Print the version and exit. .SH FILES .TP -.BI /usr/lib/quagga/ospfd +.BI @CFG_SBIN@/ospfd The default location of the .B ospfd binary. .TP -.BI /etc/quagga/ospfd.conf +.BI @CFG_SYSCONF@/ospfd.conf The default location of the .B ospfd config file. @@ -87,7 +87,7 @@ process is config'd to output logs to a file, then you will find this file in the directory where you started \fBospfd\fR. .SH WARNING This man page is intended to be a quick reference for command line -options. The definitive document is the Info file \fBQuagga\fR. +options. The definitive document is the Info file \fB@PACKAGE_NAME@\fR. .SH DIAGNOSTICS The ospfd process may log to standard output, to a VTY, to a log file, or through syslog to the system logs. \fBospfd\fR supports many @@ -103,11 +103,11 @@ debugging options, see the Info file, or the source for details. .SH BUGS .B ospfd eats bugs for breakfast. If you have food for the maintainers try -.BI http://bugzilla.quagga.net +.BI @PACKAGE_BUGREPORT@ .SH AUTHORS See .BI http://www.zebra.org and -.BI http://www.quagga.net +.BI @PACKAGE_URL@ or the Info file for an accurate list of authors. diff --git a/doc/pimd.8.in b/doc/pimd.8.in index 0dd170a2cd..60b844b1e7 100644 --- a/doc/pimd.8.in +++ b/doc/pimd.8.in @@ -1,6 +1,6 @@ -.TH PIM 8 "10 December 2008" "Quagga PIM daemon" "Version 0.99.11" +.TH PIM 8 "10 December 2008" "@PACKAGE_FULLNAME@ PIM daemon" "Version @PACKAGE_VERSION@" .SH NAME -pimd \- a PIM routing for use with Quagga Routing Suite. +pimd \- a PIM routing for use with @PACKAGE_FULLNAME@. .SH SYNOPSIS .B pimd [ @@ -30,7 +30,7 @@ pimd \- a PIM routing for use with Quagga Routing Suite. .SH DESCRIPTION .B pimd is a protocol-independent multicast component that works with the -.B Quagga +.B @PACKAGE_FULLNAME@ Routing Suite. .SH OPTIONS Options available for the @@ -42,10 +42,10 @@ Runs in daemon mode, forking and exiting from tty. .TP \fB\-f\fR, \fB\-\-config-file \fR\fIconfig-file\fR Specifies the config file to use for startup. If not specified this -option will likely default to \fB\fI/usr/local/etc/pimd.conf\fR. +option will default to \fB\fI@CFG_SYSCONF@/pimd.conf\fR. .TP \fB\-g\fR, \fB\-\-group \fR\fIgroup\fR -Specify the group to run as. Default is \fIquagga\fR. +Specify the group to run as. Default is \fI@enable_group@\fR. .TP \fB\-h\fR, \fB\-\-help\fR A brief message. @@ -53,11 +53,11 @@ A brief message. \fB\-i\fR, \fB\-\-pid_file \fR\fIpid-file\fR When pimd starts its process identifier is written to \fB\fIpid-file\fR. The init system uses the recorded PID to stop or -restart pimd. The likely default is \fB\fI/var/run/pimd.pid\fR. +restart pimd. The default is \fB\fI@CFG_STATE@/pimd.pid\fR. .TP \fB\-z\fR, \fB\-\-socket \fR\fIpath\fR Specify the socket path for contacting the zebra daemon. -The likely default is \fB\fI/var/run/zserv.api\fR. +The default is \fB\fI@CFG_STATE@/zserv.api\fR. .TP \fB\-P\fR, \fB\-\-vty_port \fR\fIport-number\fR Specify the port that the pimd VTY will listen on. This defaults to @@ -68,7 +68,7 @@ Specify the address that the pimd VTY will listen on. Default is all interfaces. .TP \fB\-u\fR, \fB\-\-user \fR\fIuser\fR -Specify the user to run as. Default is \fIquagga\fR. +Specify the user to run as. Default is \fI@enable_user@\fR. .TP \fB\-v\fR, \fB\-\-version\fR Print the version and exit. @@ -77,22 +77,22 @@ Print the version and exit. Enable logging information for zclient debugging. .SH FILES .TP -.BI /usr/local/sbin/pimd +.BI @CFG_SBIN@/pimd The default location of the .B pimd binary. .TP -.BI /usr/local/etc/pimd.conf +.BI @CFG_SYSCONF@/pimd.conf The default location of the .B pimd config file. .TP -.BI /var/run/pimd.pid +.BI @CFG_STATE@/pimd.pid The default location of the .B pimd pid file. .TP -.BI /var/run/zserv.api +.BI @CFG_STATE@/zserv.api The default location of the .B zebra unix socket file. diff --git a/doc/quagga.1.in b/doc/quagga.1.in index 35e8b30bf5..040187200f 100644 --- a/doc/quagga.1.in +++ b/doc/quagga.1.in @@ -1,4 +1,4 @@ -.TH Quagga 1 "27 July 2006" "Quagga Systemd Script" "Version 0.99.23.1" +.TH Quagga 1 "27 July 2006" "@PACKAGE_FULLNAME@ Systemd Script" "Version @PACKAGE_VERSION@" .SH NAME quagga \- a systemd interaction script .SH SYNOPSIS @@ -28,9 +28,9 @@ quagga \- a systemd interaction script ] .br .SH DESCRIPTION -.B Quagga +.B @PACKAGE_NAME@ is a systemd interaction script for the -.B Quagga +.B @PACKAGE_FULLNAME@ routing engine. .SH OPTIONS Options available for the @@ -57,9 +57,9 @@ Status of all the daemons .SH BUGS .B quagga eats bugs for breakfast. If you have food for the maintainers try -.BI http://bugzilla.quagga.net +.BI @PACKAGE_BUGREPORT@ .SH AUTHORS See -.BI http://www.quagga.net +.BI @PACKAGE_URL@ or the Info file for an accurate list of authors. diff --git a/doc/ripd.8.in b/doc/ripd.8.in index f042af228b..6db5ac3649 100644 --- a/doc/ripd.8.in +++ b/doc/ripd.8.in @@ -1,6 +1,6 @@ -.TH RIPD 8 "25 November 2004" "Quagga RIP daemon" "Version 0.97.3" +.TH RIPD 8 "25 November 2004" "@PACKAGE_FULLNAME@ RIP daemon" "Version @PACKAGE_VERSION@" .SH NAME -ripd \- a RIP routing engine for use with Quagga routing software. +ripd \- a RIP routing engine for use with @PACKAGE_FULLNAME@. .SH SYNOPSIS .B ripd [ @@ -27,7 +27,7 @@ ripd \- a RIP routing engine for use with Quagga routing software. .SH DESCRIPTION .B ripd is a routing component that works with the -.B Quagga +.B @PACKAGE_FULLNAME@ routing engine. .SH OPTIONS Options available for the @@ -40,10 +40,10 @@ Runs in daemon mode, forking and exiting from tty. .TP \fB\-f\fR, \fB\-\-config-file \fR\fIconfig-file\fR Specifies the config file to use for startup. If not specified this -option will likely default to \fB\fI/usr/local/etc/ripd.conf\fR. +option will default to \fB\fI@CFG_SYSCONF@/ripd.conf\fR. .TP \fB\-g\fR, \fB\-\-group \fR\fIgroup\fR -Specify the group to run as. Default is \fIquagga\fR. +Specify the group to run as. Default is \fI@enable_group@\fR. .TP \fB\-h\fR, \fB\-\-help\fR A brief message. @@ -51,7 +51,7 @@ A brief message. \fB\-i\fR, \fB\-\-pid_file \fR\fIpid-file\fR When ripd starts its process identifier is written to \fB\fIpid-file\fR. The init system uses the recorded PID to stop or -restart ripd. The likely default is \fB\fI/var/run/ripd.pid\fR. +restart ripd. The default is \fB\fI@CFG_STATE@/ripd.pid\fR. .TP \fB\-P\fR, \fB\-\-vty_port \fR\fIport-number\fR Specify the port that the ripd VTY will listen on. This defaults to @@ -62,7 +62,7 @@ Specify the address that the ripd VTY will listen on. Default is all interfaces. .TP \fB\-u\fR, \fB\-\-user \fR\fIuser\fR -Specify the user to run as. Default is \fIquagga\fR. +Specify the user to run as. Default is \fI@enable_user@\fR. .TP \fB\-r\fR, \fB\-\-retain\fR When the program terminates, retain routes added by \fBripd\fR. @@ -71,12 +71,12 @@ When the program terminates, retain routes added by \fBripd\fR. Print the version and exit. .SH FILES .TP -.BI /usr/lib/quagga/ripd +.BI @CFG_SBIN@/ripd The default location of the .B ripd binary. .TP -.BI /etc/quagga/ripd.conf +.BI @CFG_SYSCONF@/ripd.conf The default location of the .B ripd config file. @@ -88,7 +88,7 @@ process is config'd to output logs to a file, then you will find this file in the directory where you started \fBripd\fR. .SH WARNING This man page is intended to be a quick reference for command line -options. The definitive document is the Info file \fBQuagga\fR. +options. The definitive document is the Info file \fB@PACKAGE_NAME@\fR. .SH DIAGNOSTICS The ripd process may log to standard output, to a VTY, to a log file, or through syslog to the system logs. \fBripd\fR supports many @@ -104,10 +104,10 @@ debugging options, see the Info file, or the source for details. .SH BUGS .B ripd eats bugs for breakfast. If you have food for the maintainers try -.BI http://bugzilla.quagga.net +.BI @PACKAGE_BUGREPORT@ .SH AUTHORS See .BI http://www.zebra.org and -.BI http://www.quagga.net +.BI @PACKAGE_URL@ or the Info file for an accurate list of authors. diff --git a/doc/ripngd.8.in b/doc/ripngd.8.in index e4504fde46..4c5f2bb114 100644 --- a/doc/ripngd.8.in +++ b/doc/ripngd.8.in @@ -1,6 +1,6 @@ -.TH RIPNGD 8 "25 November 2004" "Quagga RIPNG daemon" "Version 0.97.3" +.TH RIPNGD 8 "25 November 2004" "@PACKAGE_FULLNAME@ RIPNG daemon" "Version @PACKAGE_VERSION@" .SH NAME -ripngd \- a RIPNG routing engine for use with Quagga routing software. +ripngd \- a RIPNG routing engine for use with @PACKAGE_FULLNAME@. .SH SYNOPSIS .B ripngd [ @@ -27,7 +27,7 @@ ripngd \- a RIPNG routing engine for use with Quagga routing software. .SH DESCRIPTION .B ripngd is a routing component that works with the -.B Quagga +.B @PACKAGE_FULLNAME@ routing engine. .SH OPTIONS Options available for the @@ -40,10 +40,10 @@ Runs in daemon mode, forking and exiting from tty. .TP \fB\-f\fR, \fB\-\-config-file \fR\fIconfig-file\fR Specifies the config file to use for startup. If not specified this -option will likely default to \fB\fI/usr/local/etc/ripngd.conf\fR. +option will default to \fB\fI@CFG_SYSCONF@/ripngd.conf\fR. .TP \fB\-g\fR, \fB\-\-group \fR\fIgroup\fR -Specify the group to run as. Default is \fIquagga\fR. +Specify the group to run as. Default is \fI@enable_group@\fR. .TP \fB\-h\fR, \fB\-\-help\fR A brief message. @@ -51,7 +51,7 @@ A brief message. \fB\-i\fR, \fB\-\-pid_file \fR\fIpid-file\fR When ripngd starts its process identifier is written to \fB\fIpid-file\fR. The init system uses the recorded PID to stop or -restart ripngd. The likely default is \fB\fI/var/run/ripngd.pid\fR. +restart ripngd. The default is \fB\fI@CFG_STATE@/ripngd.pid\fR. .TP \fB\-P\fR, \fB\-\-vty_port \fR\fIport-number\fR Specify the port that the ripngd VTY will listen on. This defaults to @@ -62,7 +62,7 @@ Specify the address that the ripngd VTY will listen on. Default is all interfaces. .TP \fB\-u\fR, \fB\-\-user \fR\fIuser\fR -Specify the user to run as. Default is \fIquagga\fR. +Specify the user to run as. Default is \fI@enable_user@\fR. .TP \fB\-r\fR, \fB\-\-retain\fR When the program terminates, retain routes added by \fBripd\fR. @@ -71,12 +71,12 @@ When the program terminates, retain routes added by \fBripd\fR. Print the version and exit. .SH FILES .TP -.BI /usr/lib/quagga/ripngd +.BI @CFG_SBIN@/ripngd The default location of the .B ripngd binary. .TP -.BI /etc/quagga/ripngd.conf +.BI @CFG_SYSCONF@/ripngd.conf The default location of the .B ripngd config file. @@ -88,7 +88,7 @@ process is config'd to output logs to a file, then you will find this file in the directory where you started \fBripngd\fR. .SH WARNING This man page is intended to be a quick reference for command line -options. The definitive document is the Info file \fBQuagga\fR. +options. The definitive document is the Info file \fB@PACKAGE_NAME@\fR. .SH DIAGNOSTICS The ripngd process may log to standard output, to a VTY, to a log file, or through syslog to the system logs. \fBripngd\fR supports many @@ -104,11 +104,11 @@ debugging options, see the Info file, or the source for details. .SH BUGS .B ripngd eats bugs for breakfast. If you have food for the maintainers try -.BI http://bugzilla.quagga.net +.BI @PACKAGE_BUGREPORT@ .SH AUTHORS See .BI http://www.zebra.org and -.BI http://www.quagga.net +.BI @PACKAGE_URL@ or the Info file for an accurate list of authors. diff --git a/doc/vtysh.1.in b/doc/vtysh.1.in index d144cb6421..35a05709eb 100644 --- a/doc/vtysh.1.in +++ b/doc/vtysh.1.in @@ -1,6 +1,6 @@ -.TH VTYSH 1 "27 July 2006" "Quagga VTY shell" "Version 0.96.5" +.TH VTYSH 1 "27 July 2006" "@PACKAGE_FULLNAME@ VTY shell" "Version @PACKAGE_VERSION@" .SH NAME -vtysh \- a integrated shell for Quagga routing software +vtysh \- a integrated shell for @PACKAGE_FULLNAME@. .SH SYNOPSIS .B vtysh [ @@ -21,7 +21,7 @@ vtysh \- a integrated shell for Quagga routing software .SH DESCRIPTION .B vtysh is a integrated shell for -.B Quagga +.B @PACKAGE_FULLNAME@ routing engine. .SH OPTIONS Options available for the @@ -29,8 +29,8 @@ Options available for the command: .IP "\fB\-b, \-\-boot\fP" Execute boot startup configuration. It makes sense only if integrated config -file is in use (not default in Quagga). See Info file \fBQuagga\fR for more -info. +file is in use (not default in @PACKAGE_FULLNAME@). See Info file +\fB@PACKAGE_NAME@\fR for more info. .IP "\fB\-c, \-\-command \fIcommand\fP" Specify command to be executed under batch mode. It behaves like -c option in any other shell - @@ -39,7 +39,7 @@ is executed and .B vtysh exits. -It's useful for gathering info from Quagga routing software or reconfiguring +It's useful for gathering info from @PACKAGE_FULLNAME@ daemons or reconfiguring daemons from inside shell scripts, etc. Note that multiple commands may be executed by using more than one -c option and/or embedding linefeed characters inside the @@ -48,7 +48,7 @@ string. .IP "\fB\-d, \-\-daemon \fIdaemon_name\fP" Specify which daemon to connect to. By default, .B vtysh -attempts to connect to all Quagga daemons running on the system. With this +attempts to connect to all @PACKAGE_FULLNAME@ daemons running on the system. With this flag, one can specify a single daemon to connect to instead. For example, specifying '-d ospfd' will connect only to ospfd. This can be particularly useful inside scripts with -c where the command is targeted for a single daemon. @@ -68,20 +68,20 @@ Display a usage message on standard output and exit. This should be the name of the pager to use. Default is \fBmore\fR. .SH FILES .TP -.BI /etc/quagga/vtysh.conf +.BI @CFG_SYSCONF@/vtysh.conf The default location of the .B vtysh config file. .TP -.BI /etc/quagga/Quagga.conf -The default location of the integrated Quagga routing engine config file +.BI @CFG_SYSCONF@/Quagga.conf +The default location of the integrated @PACKAGE_FULLNAME@ routing engine config file if integrated config file is in use (not default). .TP .BI ${HOME}/.history_quagga Location of history of commands entered via cli .SH WARNING This man page is intended to be a quick reference for command line -options. The definitive document is the Info file \fBQuagga\fR. +options. The definitive document is the Info file \fB@PACKAGE_NAME@\fR. .SH "SEE ALSO" .BR bgpd (8), .BR ripd (8), @@ -93,11 +93,11 @@ options. The definitive document is the Info file \fBQuagga\fR. .SH BUGS .B vtysh eats bugs for breakfast. If you have food for the maintainers try -.BI http://bugzilla.quagga.net +.BI @PACKAGE_BUGREPORT@ .SH AUTHORS See .BI http://www.zebra.org and -.BI http://www.quagga.net +.BI @PACKAGE_URL@ or the Info file for an accurate list of authors. diff --git a/doc/watchquagga.8.in b/doc/watchquagga.8.in index ca9916461e..a7249b8376 100644 --- a/doc/watchquagga.8.in +++ b/doc/watchquagga.8.in @@ -226,6 +226,6 @@ Display the usage information and exit. .BR ripd (8), .BR ripngd (8) .PP -See the project homepage at . +See the project homepage at <@PACKAGE_URL@>. .SH AUTHORS Copyright 2004 Andrew J. Schorr diff --git a/doc/zebra.8.in b/doc/zebra.8.in index cb431da0aa..e7d00e10a3 100644 --- a/doc/zebra.8.in +++ b/doc/zebra.8.in @@ -1,6 +1,6 @@ -.TH ZEBRA 8 "25 November 2004" "Zebra daemon" "Version 0.97.3" +.TH ZEBRA 8 "25 November 2004" "Zebra daemon" "Version @PACKAGE_VERSION@" .SH NAME -zebra \- a routing manager for use with associated Quagga components. +zebra \- a routing manager for use with associated @PACKAGE_FULLNAME@ components. .SH SYNOPSIS .B zebra [ @@ -44,10 +44,10 @@ Runs in daemon mode, forking and exiting from tty. .TP \fB\-f\fR, \fB\-\-config-file \fR\fIconfig-file\fR Specifies the config file to use for startup. If not specified this -option will likely default to \fB\fI/usr/local/etc/zebra.conf\fR. +option will default to \fB\fI@CFG_SYSCONF@/zebra.conf\fR. .TP \fB\-g\fR, \fB\-\-group \fR\fIgroup\fR -Specify the group to run as. Default is \fIquagga\fR. +Specify the group to run as. Default is \fI@enable_group@\fR. .TP \fB\-h\fR, \fB\-\-help\fR A brief message. @@ -55,7 +55,7 @@ A brief message. \fB\-i\fR, \fB\-\-pid_file \fR\fIpid-file\fR When zebra starts its process identifier is written to \fB\fIpid-file\fR. The init system uses the recorded PID to stop or -restart zebra. The likely default is \fB\fI/var/run/zebra.pid\fR. +restart zebra. The default is \fB\fI@CFG_STATE@/zebra.pid\fR. .TP \fB\-k\fR, \fB\-\-keep_kernel\fR On startup, don't delete self inserted routes. @@ -69,7 +69,7 @@ Specify the address that the zebra VTY will listen on. Default is all interfaces. .TP \fB\-u\fR, \fB\-\-user \fR\fIuser\fR -Specify the user to run as. Default is \fIquagga\fR. +Specify the user to run as. Default is \fI@enable_user@\fR. .TP \fB\-r\fR, \fB\-\-retain\fR When the program terminates, retain routes added by \fBzebra\fR. @@ -90,12 +90,12 @@ Note that this affects Linux only. Print the version and exit. .SH FILES .TP -.BI /usr/lib/quagga/zebra +.BI @CFG_SBIN@/zebra The default location of the .B zebra binary. .TP -.BI /etc/quagga/zebra.conf +.BI @CFG_SYSCONF@/zebra.conf The default location of the .B zebra config file. @@ -107,7 +107,7 @@ process is config'd to output logs to a file, then you will find this file in the directory where you started \fBzebra\fR. .SH WARNING This man page is intended to be a quick reference for command line -options. The definitive document is the Info file \fBQuagga\fR. +options. The definitive document is the Info file \fB@PACKAGE_NAME@\fR. .SH DIAGNOSTICS The zebra process may log to standard output, to a VTY, to a log file, or through syslog to the system logs. \fBzebra\fR supports many @@ -123,11 +123,11 @@ debugging options, see the Info file, or the source for details. .SH BUGS .B zebra eats bugs for breakfast. If you have food for the maintainers try -.BI http://bugzilla.quagga.net +.BI @PACKAGE_BUGREPORT@ .SH AUTHORS See .BI http://www.zebra.org and -.BI http://www.quagga.net +.BI @PACKAGE_URL@ or the Info file for an accurate list of authors. From b2f361571b2ada8e820ad8ab87c023479e3af90a Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Wed, 14 Dec 2016 19:30:44 +0100 Subject: [PATCH 016/107] build: rename (1 of ?): configure.ac + preproc This replaces Quagga -> FRR in most configure.ac settings as well as a handful of preprocessor macros in the source code. Signed-off-by: David Lamparter --- .gitignore | 5 +- bgpd/bgp_btoa.c | 6 +- bgpd/bgp_main.c | 10 +-- configure.ac | 140 +++++++++++++++++++------------------- isisd/isis_main.c | 12 ++-- ldpd/lde.c | 6 +- ldpd/ldpd.c | 10 +-- ldpd/ldpe.c | 6 +- lib/command.c | 20 +++--- lib/smux.c | 2 +- lib/version.h.in | 21 +++--- ospf6d/ospf6_main.c | 12 ++-- ospfd/ospf_main.c | 10 +-- pimd/pim_main.c | 12 ++-- ripd/rip_main.c | 12 ++-- ripngd/ripng_main.c | 12 ++-- tests/main.c | 2 +- tests/test-privs.c | 8 +-- vtysh/vtysh.c | 8 +-- vtysh/vtysh_main.c | 2 +- vtysh/vtysh_user.c | 2 +- watchquagga/watchquagga.c | 4 +- zebra/main.c | 10 +-- zebra/test_main.c | 4 +- 24 files changed, 167 insertions(+), 169 deletions(-) diff --git a/.gitignore b/.gitignore index ddaf6e240e..30006f7e28 100644 --- a/.gitignore +++ b/.gitignore @@ -25,9 +25,8 @@ conftest conftest.err aclocal.m4 Makefile.in -zebra-[0-9.][0-9.][0-9.]*.tar.gz -quagga-[0-9.][0-9.][0-9.]*.tar.gz -quagga-[0-9.][0-9.][0-9.]*.tar.gz.asc +*.tar.gz +*.tar.gz.asc .nfs* libtool .arch-inventory diff --git a/bgpd/bgp_btoa.c b/bgpd/bgp_btoa.c index cd52c94b1f..37bef9b85d 100644 --- a/bgpd/bgp_btoa.c +++ b/bgpd/bgp_btoa.c @@ -44,9 +44,9 @@ static zebra_capabilities_t _caps_p [] = struct zebra_privs_t bgpd_privs = { -#if defined(QUAGGA_USER) && defined(QUAGGA_GROUP) - .user = QUAGGA_USER, - .group = QUAGGA_GROUP, +#if defined(FRR_USER) && defined(FRR_GROUP) + .user = FRR_USER, + .group = FRR_GROUP, #endif #ifdef VTY_GROUP .vty_group = VTY_GROUP, diff --git a/bgpd/bgp_main.c b/bgpd/bgp_main.c index 91eacc9320..33191f0a98 100644 --- a/bgpd/bgp_main.c +++ b/bgpd/bgp_main.c @@ -134,9 +134,9 @@ static zebra_capabilities_t _caps_p [] = struct zebra_privs_t bgpd_privs = { -#if defined(QUAGGA_USER) && defined(QUAGGA_GROUP) - .user = QUAGGA_USER, - .group = QUAGGA_GROUP, +#if defined(FRR_USER) && defined(FRR_GROUP) + .user = FRR_USER, + .group = FRR_GROUP, #endif #ifdef VTY_GROUP .vty_group = VTY_GROUP, @@ -174,7 +174,7 @@ redistribution between different routing protocols.\n\n\ -C, --dryrun Check configuration for validity and exit\n\ -h, --help Display this help and exit\n\ \n\ -Report bugs to %s\n", progname, ZEBRA_BUG_ADDRESS); +Report bugs to %s\n", progname, FRR_BUG_ADDRESS); } exit (status); @@ -547,7 +547,7 @@ main (int argc, char **argv) vty_serv_sock (vty_addr, vty_port, BGP_VTYSH_PATH); /* Print banner. */ - zlog_notice ("BGPd %s starting: vty@%d, bgp@%s:%d", QUAGGA_VERSION, + zlog_notice ("BGPd %s starting: vty@%d, bgp@%s:%d", FRR_COPYRIGHT, vty_port, (bm->address ? bm->address : ""), bm->port); diff --git a/configure.ac b/configure.ac index 04478f255b..05d0f96d10 100755 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ ## -## Configure template file for Quagga. +## Configure template file for FreeRangeRouting. ## autoconf will generate configure script. ## ## Copyright (c) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro @@ -7,9 +7,9 @@ ## AC_PREREQ(2.60) -AC_INIT(Quagga, 2.0-rc0, [https://bugzilla.quagga.net]) -PACKAGE_URL="http://www.quagga.net" -PACKAGE_FULLNAME="Quagga" +AC_INIT(frr, 2.0-rc0, [https://bugzilla.quagga.net]) +PACKAGE_URL="https://freerangerouting.org/" +PACKAGE_FULLNAME="FreeRangeRouting" AC_SUBST(PACKAGE_FULLNAME) CONFIG_ARGS="$ac_configure_args" @@ -239,9 +239,9 @@ AC_ARG_ENABLE(ospfclient, AC_ARG_ENABLE(multipath, AS_HELP_STRING([--enable-multipath=ARG], [enable multipath function, ARG must be digit])) AC_ARG_ENABLE(user, - AS_HELP_STRING([--enable-user=USER], [user to run Quagga suite as (default quagga)])) + AS_HELP_STRING([--enable-user=USER], [user to run FRR suite as (default frr)])) AC_ARG_ENABLE(group, - AS_HELP_STRING([--enable-group=GROUP], [group to run Quagga suite as (default quagga)])) + AS_HELP_STRING([--enable-group=GROUP], [group to run FRR suite as (default frr)])) AC_ARG_ENABLE(vty_group, AS_HELP_STRING([--enable-vty-group=ARG], [set vty sockets to have specified group as owner])) AC_ARG_ENABLE(configfile_mask, @@ -427,18 +427,18 @@ if test x"${enable_user}" = x"no"; then enable_user="" else if test x"${enable_user}" = x"yes" || test x"${enable_user}" = x""; then - enable_user="quagga" + enable_user="frr" fi - AC_DEFINE_UNQUOTED(QUAGGA_USER, "${enable_user}", Quagga User) + AC_DEFINE_UNQUOTED(FRR_USER, "${enable_user}", frr User) fi if test x"${enable_group}" = x"no"; then enable_group="" else if test x"${enable_group}" = x"yes" || test x"${enable_group}" = x""; then - enable_group="quagga" + enable_group="frr" fi - AC_DEFINE_UNQUOTED(QUAGGA_GROUP, "${enable_group}", Quagga Group) + AC_DEFINE_UNQUOTED(FRR_GROUP, "${enable_group}", frr Group) fi if test x"${enable_vty_group}" = x"yes" ; then @@ -887,25 +887,25 @@ main() dnl ------------------------------ dnl check kernel route read method dnl ------------------------------ -AC_CACHE_CHECK([route read method], [quagga_cv_rtread_method], +AC_CACHE_CHECK([route read method], [frr_cv_rtread_method], [if test "x$netlink" = xyes; then - quagga_cv_rtread_method="netlink" + frr_cv_rtread_method="netlink" else -for quagga_cv_rtread_method in /dev/ip /dev/null; +for frr_cv_rtread_method in /dev/ip /dev/null; do - test x`ls $quagga_cv_rtread_method 2>/dev/null` = x"$quagga_cv_rtread_method" && break + test x`ls $frr_cv_rtread_method 2>/dev/null` = x"$frr_cv_rtread_method" && break done -case $quagga_cv_rtread_method in +case $frr_cv_rtread_method in "/dev/ip") case "$host" in - *-freebsd*) quagga_cv_rtread_method="sysctl";; - *) quagga_cv_rtread_method="getmsg";; + *-freebsd*) frr_cv_rtread_method="sysctl";; + *) frr_cv_rtread_method="getmsg";; esac;; *) - quagga_cv_rtread_method="sysctl";; + frr_cv_rtread_method="sysctl";; esac fi]) -RTREAD_METHOD=rtread_${quagga_cv_rtread_method}.o +RTREAD_METHOD=rtread_${frr_cv_rtread_method}.o AC_SUBST(RTREAD_METHOD) dnl ----------------------------- @@ -1035,29 +1035,29 @@ fi dnl ----------------------------- dnl check ipforward detect method dnl ----------------------------- -AC_CACHE_CHECK([ipforward method], [quagga_cv_ipforward_method], +AC_CACHE_CHECK([ipforward method], [frr_cv_ipforward_method], [if test x$cross_compiling = xyes; then if test x"$opsys" = x"gnu-linux"; then - quagga_cv_ipforward_method=/proc/net/snmp + frr_cv_ipforward_method=/proc/net/snmp else - quagga_cv_ipforward_method=/dev/ip + frr_cv_ipforward_method=/dev/ip fi else - for quagga_cv_ipforward_method in /proc/net/snmp /dev/ip /dev/null; + for frr_cv_ipforward_method in /proc/net/snmp /dev/ip /dev/null; do - test x`ls $quagga_cv_ipforward_method 2>/dev/null` = x"$quagga_cv_ipforward_method" && break + test x`ls $frr_cv_ipforward_method 2>/dev/null` = x"$frr_cv_ipforward_method" && break done fi -case $quagga_cv_ipforward_method in - "/proc/net/snmp") quagga_cv_ipforward_method="proc";; +case $frr_cv_ipforward_method in + "/proc/net/snmp") frr_cv_ipforward_method="proc";; "/dev/ip") case "$host" in - *-freebsd*) quagga_cv_ipforward_method="sysctl";; - *) quagga_cv_ipforward_method="solaris";; + *-freebsd*) frr_cv_ipforward_method="sysctl";; + *) frr_cv_ipforward_method="solaris";; esac;; - *) quagga_cv_ipforward_method="sysctl";; + *) frr_cv_ipforward_method="sysctl";; esac]) -IPFORWARD=ipforward_${quagga_cv_ipforward_method}.o +IPFORWARD=ipforward_${frr_cv_ipforward_method}.o AC_SUBST(IPFORWARD) dnl ---------------------------------------------------------------------------- @@ -1513,14 +1513,14 @@ dnl set paths for state directory dnl ------------------------------ AC_MSG_CHECKING(directory to use for state file) if test "${prefix}" = "NONE"; then - quagga_statedir_prefix=""; + frr_statedir_prefix=""; else - quagga_statedir_prefix=${prefix} + frr_statedir_prefix=${prefix} fi if test "${localstatedir}" = '${prefix}/var'; then - for QUAGGA_STATE_DIR in ${quagga_statedir_prefix}/var/run dnl - ${quagga_statedir_prefix}/var/adm dnl - ${quagga_statedir_prefix}/etc dnl + for QUAGGA_STATE_DIR in ${frr_statedir_prefix}/var/run dnl + ${frr_statedir_prefix}/var/adm dnl + ${frr_statedir_prefix}/etc dnl /var/run dnl /var/adm dnl /etc dnl @@ -1528,39 +1528,39 @@ if test "${localstatedir}" = '${prefix}/var'; then do test -d $QUAGGA_STATE_DIR && break done - quagga_statedir=$QUAGGA_STATE_DIR + frr_statedir=$QUAGGA_STATE_DIR else - quagga_statedir=${localstatedir} + frr_statedir=${localstatedir} fi -if test $quagga_statedir = "/dev/null"; then +if test $frr_statedir = "/dev/null"; then AC_MSG_ERROR('STATE DIRECTORY NOT FOUND! FIX OR SPECIFY --localstatedir!') fi -AC_MSG_RESULT(${quagga_statedir}) -AC_SUBST(quagga_statedir) +AC_MSG_RESULT(${frr_statedir}) +AC_SUBST(frr_statedir) -AC_DEFINE_UNQUOTED(PATH_ZEBRA_PID, "$quagga_statedir/zebra.pid",zebra PID) -AC_DEFINE_UNQUOTED(PATH_RIPD_PID, "$quagga_statedir/ripd.pid",ripd PID) -AC_DEFINE_UNQUOTED(PATH_RIPNGD_PID, "$quagga_statedir/ripngd.pid",ripngd PID) -AC_DEFINE_UNQUOTED(PATH_BGPD_PID, "$quagga_statedir/bgpd.pid",bgpd PID) -AC_DEFINE_UNQUOTED(PATH_OSPFD_PID, "$quagga_statedir/ospfd.pid",ospfd PID) -AC_DEFINE_UNQUOTED(PATH_OSPF6D_PID, "$quagga_statedir/ospf6d.pid",ospf6d PID) -AC_DEFINE_UNQUOTED(PATH_LDPD_PID, "$quagga_statedir/ldpd.pid",ldpd PID) -AC_DEFINE_UNQUOTED(LDPD_SOCKET, "$quagga_statedir/ldpd.sock",ldpd control socket) -AC_DEFINE_UNQUOTED(PATH_ISISD_PID, "$quagga_statedir/isisd.pid",isisd PID) -AC_DEFINE_UNQUOTED(PATH_PIMD_PID, "$quagga_statedir/pimd.pid",pimd PID) -AC_DEFINE_UNQUOTED(PATH_WATCHQUAGGA_PID, "$quagga_statedir/watchquagga.pid",watchquagga PID) -AC_DEFINE_UNQUOTED(ZEBRA_SERV_PATH, "$quagga_statedir/zserv.api",zebra api socket) -AC_DEFINE_UNQUOTED(ZEBRA_VTYSH_PATH, "$quagga_statedir/zebra.vty",zebra vty socket) -AC_DEFINE_UNQUOTED(RIP_VTYSH_PATH, "$quagga_statedir/ripd.vty",rip vty socket) -AC_DEFINE_UNQUOTED(RIPNG_VTYSH_PATH, "$quagga_statedir/ripngd.vty",ripng vty socket) -AC_DEFINE_UNQUOTED(BGP_VTYSH_PATH, "$quagga_statedir/bgpd.vty",bgpd vty socket) -AC_DEFINE_UNQUOTED(OSPF_VTYSH_PATH, "$quagga_statedir/ospfd.vty",ospfd vty socket) -AC_DEFINE_UNQUOTED(OSPF6_VTYSH_PATH, "$quagga_statedir/ospf6d.vty",ospf6d vty socket) -AC_DEFINE_UNQUOTED(LDP_VTYSH_PATH, "$quagga_statedir/ldpd.vty",ldpd vty socket) -AC_DEFINE_UNQUOTED(ISIS_VTYSH_PATH, "$quagga_statedir/isisd.vty",isisd vty socket) -AC_DEFINE_UNQUOTED(PIM_VTYSH_PATH, "$quagga_statedir/pimd.vty",pimd vty socket) -AC_DEFINE_UNQUOTED(WATCHQUAGGA_VTYSH_PATH, "$quagga_statedir/watchquagga.vty",watchquagga vty socket) -AC_DEFINE_UNQUOTED(DAEMON_VTY_DIR, "$quagga_statedir",daemon vty directory) +AC_DEFINE_UNQUOTED(PATH_ZEBRA_PID, "$frr_statedir/zebra.pid",zebra PID) +AC_DEFINE_UNQUOTED(PATH_RIPD_PID, "$frr_statedir/ripd.pid",ripd PID) +AC_DEFINE_UNQUOTED(PATH_RIPNGD_PID, "$frr_statedir/ripngd.pid",ripngd PID) +AC_DEFINE_UNQUOTED(PATH_BGPD_PID, "$frr_statedir/bgpd.pid",bgpd PID) +AC_DEFINE_UNQUOTED(PATH_OSPFD_PID, "$frr_statedir/ospfd.pid",ospfd PID) +AC_DEFINE_UNQUOTED(PATH_OSPF6D_PID, "$frr_statedir/ospf6d.pid",ospf6d PID) +AC_DEFINE_UNQUOTED(PATH_LDPD_PID, "$frr_statedir/ldpd.pid",ldpd PID) +AC_DEFINE_UNQUOTED(LDPD_SOCKET, "$frr_statedir/ldpd.sock",ldpd control socket) +AC_DEFINE_UNQUOTED(PATH_ISISD_PID, "$frr_statedir/isisd.pid",isisd PID) +AC_DEFINE_UNQUOTED(PATH_PIMD_PID, "$frr_statedir/pimd.pid",pimd PID) +AC_DEFINE_UNQUOTED(PATH_WATCHQUAGGA_PID, "$frr_statedir/watchquagga.pid",watchquagga PID) +AC_DEFINE_UNQUOTED(ZEBRA_SERV_PATH, "$frr_statedir/zserv.api",zebra api socket) +AC_DEFINE_UNQUOTED(ZEBRA_VTYSH_PATH, "$frr_statedir/zebra.vty",zebra vty socket) +AC_DEFINE_UNQUOTED(RIP_VTYSH_PATH, "$frr_statedir/ripd.vty",rip vty socket) +AC_DEFINE_UNQUOTED(RIPNG_VTYSH_PATH, "$frr_statedir/ripngd.vty",ripng vty socket) +AC_DEFINE_UNQUOTED(BGP_VTYSH_PATH, "$frr_statedir/bgpd.vty",bgpd vty socket) +AC_DEFINE_UNQUOTED(OSPF_VTYSH_PATH, "$frr_statedir/ospfd.vty",ospfd vty socket) +AC_DEFINE_UNQUOTED(OSPF6_VTYSH_PATH, "$frr_statedir/ospf6d.vty",ospf6d vty socket) +AC_DEFINE_UNQUOTED(LDP_VTYSH_PATH, "$frr_statedir/ldpd.vty",ldpd vty socket) +AC_DEFINE_UNQUOTED(ISIS_VTYSH_PATH, "$frr_statedir/isisd.vty",isisd vty socket) +AC_DEFINE_UNQUOTED(PIM_VTYSH_PATH, "$frr_statedir/pimd.vty",pimd vty socket) +AC_DEFINE_UNQUOTED(WATCHQUAGGA_VTYSH_PATH, "$frr_statedir/watchquagga.vty",watchquagga vty socket) +AC_DEFINE_UNQUOTED(DAEMON_VTY_DIR, "$frr_statedir",daemon vty directory) dnl autoconf does this, but it does it too late... test "x$prefix" = xNONE && prefix=$ac_default_prefix @@ -1652,21 +1652,21 @@ AC_CONFIG_FILES([vtysh/extract.pl],[chmod +x vtysh/extract.pl]) AC_OUTPUT echo " -Quagga configuration --------------------- -quagga version : ${PACKAGE_VERSION} +FreeRangeRouting configuration +------------------------------ +FRR version : ${PACKAGE_VERSION} host operating system : ${host_os} source code location : ${srcdir} compiler : ${CC} compiler flags : ${CFLAGS} make : ${MAKE-make} linker flags : ${LDFLAGS} ${LIBS} ${LIBCAP} ${LIBREADLINE} ${LIBM} -state file directory : ${quagga_statedir} +state file directory : ${frr_statedir} config file directory : `eval echo \`echo ${sysconfdir}\`` example directory : `eval echo \`echo ${exampledir}\`` -user to run as : ${enable_user} -group to run as : ${enable_group} -group for vty sockets : ${enable_vty_group} +user to run as : ${enable_user} +group to run as : ${enable_group} +group for vty sockets : ${enable_vty_group} config file mask : ${enable_configfile_mask} log file mask : ${enable_logfile_mask} zebra protobuf enabled : ${have_protobuf:-no} diff --git a/isisd/isis_main.c b/isisd/isis_main.c index 84ebf8ceaa..f34be99eca 100644 --- a/isisd/isis_main.c +++ b/isisd/isis_main.c @@ -66,11 +66,11 @@ zebra_capabilities_t _caps_p[] = { }; struct zebra_privs_t isisd_privs = { -#if defined(QUAGGA_USER) - .user = QUAGGA_USER, +#if defined(FRR_USER) + .user = FRR_USER, #endif -#if defined QUAGGA_GROUP - .group = QUAGGA_GROUP, +#if defined FRR_GROUP + .group = FRR_GROUP, #endif #ifdef VTY_GROUP .vty_group = VTY_GROUP, @@ -150,7 +150,7 @@ Daemon which manages IS-IS routing\n\n\ -C, --dryrun Check configuration for validity and exit\n\ -h, --help Display this help and exit\n\ \n\ -Report bugs to %s\n", progname, ZEBRA_BUG_ADDRESS); +Report bugs to %s\n", progname, FRR_BUG_ADDRESS); } exit (status); @@ -382,7 +382,7 @@ main (int argc, char **argv, char **envp) vty_serv_sock (vty_addr, vty_port, ISIS_VTYSH_PATH); /* Print banner. */ - zlog_notice ("Quagga-ISISd %s starting: vty@%d", QUAGGA_VERSION, vty_port); + zlog_notice ("Quagga-ISISd %s starting: vty@%d", FRR_VERSION, vty_port); /* Start finite state machine. */ while (thread_fetch (master, &thread)) diff --git a/ldpd/lde.c b/ldpd/lde.c index 904d0f8d9a..29c9590908 100644 --- a/ldpd/lde.c +++ b/ldpd/lde.c @@ -69,9 +69,9 @@ static zebra_capabilities_t _caps_p [] = static struct zebra_privs_t lde_privs = { -#if defined(QUAGGA_USER) && defined(QUAGGA_GROUP) - .user = QUAGGA_USER, - .group = QUAGGA_GROUP, +#if defined(FRR_USER) && defined(FRR_GROUP) + .user = FRR_USER, + .group = FRR_GROUP, #endif #if defined(VTY_GROUP) .vty_group = VTY_GROUP, diff --git a/ldpd/ldpd.c b/ldpd/ldpd.c index aa1dc57a7b..8a9847bdfd 100644 --- a/ldpd/ldpd.c +++ b/ldpd/ldpd.c @@ -103,9 +103,9 @@ static zebra_capabilities_t _caps_p [] = struct zebra_privs_t ldpd_privs = { -#if defined(QUAGGA_USER) && defined(QUAGGA_GROUP) - .user = QUAGGA_USER, - .group = QUAGGA_GROUP, +#if defined(FRR_USER) && defined(FRR_GROUP) + .user = FRR_USER, + .group = FRR_GROUP, #endif #if defined(VTY_GROUP) .vty_group = VTY_GROUP, @@ -154,7 +154,7 @@ Daemon which manages LDP.\n\n\ -C, --dryrun Check configuration for validity and exit\n\ -h, --help Display this help and exit\n\ \n\ -Report bugs to %s\n", progname, ZEBRA_BUG_ADDRESS); +Report bugs to %s\n", progname, FRR_BUG_ADDRESS); } exit(status); @@ -413,7 +413,7 @@ main(int argc, char *argv[]) vty_serv_sock(vty_addr, vty_port, LDP_VTYSH_PATH); /* Print banner. */ - log_notice("LDPd %s starting: vty@%d", QUAGGA_VERSION, vty_port); + log_notice("LDPd %s starting: vty@%d", FRR_VERSION, vty_port); /* Fetch next active thread. */ while (thread_fetch(master, &thread)) diff --git a/ldpd/ldpe.c b/ldpd/ldpe.c index aef33c8e37..37a3d79a28 100644 --- a/ldpd/ldpe.c +++ b/ldpd/ldpe.c @@ -66,9 +66,9 @@ static zebra_capabilities_t _caps_p [] = struct zebra_privs_t ldpe_privs = { -#if defined(QUAGGA_USER) && defined(QUAGGA_GROUP) - .user = QUAGGA_USER, - .group = QUAGGA_GROUP, +#if defined(FRR_USER) && defined(FRR_GROUP) + .user = FRR_USER, + .group = FRR_GROUP, #endif #if defined(VTY_GROUP) .vty_group = VTY_GROUP, diff --git a/lib/command.c b/lib/command.c index 0b0614b806..399252777f 100644 --- a/lib/command.c +++ b/lib/command.c @@ -117,12 +117,7 @@ static struct cmd_node config_node = }; /* Default motd string. */ -static const char *default_motd = -"\r\n\ -Hello, this is " QUAGGA_PROGNAME " (version " QUAGGA_VERSION ").\r\n\ -" QUAGGA_COPYRIGHT "\r\n\ -" GIT_INFO "\r\n"; - +static const char *default_motd = FRR_DEFAULT_MOTD; static const struct facility_map { int facility; @@ -191,9 +186,9 @@ level_match(const char *s) void print_version (const char *progname) { - printf ("%s version %s\n", progname, QUAGGA_VERSION); - printf ("%s\n", QUAGGA_COPYRIGHT); - printf ("configured with:\n\t%s\n", QUAGGA_CONFIG_ARGS); + printf ("%s version %s\n", progname, FRR_VERSION); + printf ("%s\n", FRR_COPYRIGHT); + printf ("configured with:\n\t%s\n", FRR_CONFIG_ARGS); } @@ -3077,11 +3072,12 @@ DEFUN (show_version, SHOW_STR "Displays zebra version\n") { - vty_out (vty, "Quagga %s (%s).%s", QUAGGA_VERSION, host.name?host.name:"", + vty_out (vty, "%s %s (%s).%s", FRR_FULL_NAME, FRR_VERSION, + host.name ? host.name : "", VTY_NEWLINE); - vty_out (vty, "%s%s%s", QUAGGA_COPYRIGHT, GIT_INFO, VTY_NEWLINE); + vty_out (vty, "%s%s%s", FRR_COPYRIGHT, GIT_INFO, VTY_NEWLINE); vty_out (vty, "configured with:%s %s%s", VTY_NEWLINE, - QUAGGA_CONFIG_ARGS, VTY_NEWLINE); + FRR_CONFIG_ARGS, VTY_NEWLINE); return CMD_SUCCESS; } diff --git a/lib/smux.c b/lib/smux.c index 5012e8d95e..a9c99e1545 100644 --- a/lib/smux.c +++ b/lib/smux.c @@ -922,7 +922,7 @@ smux_open (int sock) u_char *ptr; size_t len; long version; - const char progname[] = QUAGGA_PROGNAME "-" QUAGGA_VERSION; + const char progname[] = FRR_SMUX_NAME "-" FRR_VERSION; if (debug_smux) { diff --git a/lib/version.h.in b/lib/version.h.in index 1f95f0c5f0..c41d44e0a4 100644 --- a/lib/version.h.in +++ b/lib/version.h.in @@ -35,17 +35,20 @@ #define GIT_INFO "" #endif -#define QUAGGA_PROGNAME "@PACKAGE_NAME@" +#define FRR_PAM_NAME "@PACKAGE_NAME@" +#define FRR_SMUX_NAME "@PACKAGE_NAME@" -#define QUAGGA_VERSION "@PACKAGE_VERSION@" GIT_SUFFIX +#define FRR_FULL_NAME "FreeRangeRouting" +#define FRR_VERSION "@PACKAGE_VERSION@" GIT_SUFFIX +#define FRR_BUG_ADDRESS "@PACKAGE_BUGREPORT@" +#define FRR_COPYRIGHT "Copyright 1996-2005 Kunihiro Ishiguro, et al." +#define FRR_CONFIG_ARGS "@CONFIG_ARGS@" -#define ZEBRA_BUG_ADDRESS "@PACKAGE_BUGREPORT@" - -#define QUAGGA_URL "http://www.quagga.net" - -#define QUAGGA_COPYRIGHT "Copyright 1996-2005 Kunihiro Ishiguro, et al." - -#define QUAGGA_CONFIG_ARGS "@CONFIG_ARGS@" +#define FRR_DEFAULT_MOTD \ + "\r\n" \ + "Hello, this is " FRR_FULL_NAME " (version " FRR_VERSION ").\r\n" \ + FRR_COPYRIGHT "\r\n" \ + GIT_INFO "\r\n" pid_t pid_output (const char *); diff --git a/ospf6d/ospf6_main.c b/ospf6d/ospf6_main.c index 11a77059be..bd3a2faa5d 100644 --- a/ospf6d/ospf6_main.c +++ b/ospf6d/ospf6_main.c @@ -63,11 +63,11 @@ zebra_capabilities_t _caps_p [] = struct zebra_privs_t ospf6d_privs = { -#if defined(QUAGGA_USER) - .user = QUAGGA_USER, +#if defined(FRR_USER) + .user = FRR_USER, #endif -#if defined QUAGGA_GROUP - .group = QUAGGA_GROUP, +#if defined FRR_GROUP + .group = FRR_GROUP, #endif #ifdef VTY_GROUP .vty_group = VTY_GROUP, @@ -131,7 +131,7 @@ Daemon which manages OSPF version 3.\n\n\ -C, --dryrun Check configuration for validity and exit\n\ -h, --help Display this help and exit\n\ \n\ -Report bugs to %s\n", progname, ZEBRA_BUG_ADDRESS); +Report bugs to %s\n", progname, FRR_BUG_ADDRESS); } exit (status); @@ -361,7 +361,7 @@ main (int argc, char *argv[], char *envp[]) /* Print start message */ zlog_notice ("OSPF6d (Quagga-%s ospf6d-%s) starts: vty@%d", - QUAGGA_VERSION, OSPF6_DAEMON_VERSION,vty_port); + FRR_VERSION, OSPF6_DAEMON_VERSION,vty_port); /* Start finite state machine, here we go! */ while (thread_fetch (master, &thread)) diff --git a/ospfd/ospf_main.c b/ospfd/ospf_main.c index 43aa683fa4..5309af5bf9 100644 --- a/ospfd/ospf_main.c +++ b/ospfd/ospf_main.c @@ -63,9 +63,9 @@ zebra_capabilities_t _caps_p [] = struct zebra_privs_t ospfd_privs = { -#if defined(QUAGGA_USER) && defined(QUAGGA_GROUP) - .user = QUAGGA_USER, - .group = QUAGGA_GROUP, +#if defined(FRR_USER) && defined(FRR_GROUP) + .user = FRR_USER, + .group = FRR_GROUP, #endif #if defined(VTY_GROUP) .vty_group = VTY_GROUP, @@ -133,7 +133,7 @@ Daemon which manages OSPF.\n\n\ -C, --dryrun Check configuration for validity and exit\n\ -h, --help Display this help and exit\n\ \n\ -Report bugs to %s\n", progname, ZEBRA_BUG_ADDRESS); +Report bugs to %s\n", progname, FRR_BUG_ADDRESS); } exit (status); } @@ -373,7 +373,7 @@ main (int argc, char **argv) vty_serv_sock (vty_addr, vty_port, vty_path); /* Print banner. */ - zlog_notice ("OSPFd %s starting: vty@%d, %s", QUAGGA_VERSION, vty_port, vty_path); + zlog_notice ("OSPFd %s starting: vty@%d, %s", FRR_VERSION, vty_port, vty_path); /* Fetch next active thread. */ while (thread_fetch (master, &thread)) diff --git a/pimd/pim_main.c b/pimd/pim_main.c index 8476964669..29432ea230 100644 --- a/pimd/pim_main.c +++ b/pimd/pim_main.c @@ -75,9 +75,9 @@ zebra_capabilities_t _caps_p [] = /* pimd privileges to run with */ struct zebra_privs_t pimd_privs = { -#if defined(QUAGGA_USER) && defined(QUAGGA_GROUP) - .user = QUAGGA_USER, - .group = QUAGGA_GROUP, +#if defined(FRR_USER) && defined(FRR_GROUP) + .user = FRR_USER, + .group = FRR_GROUP, #endif #ifdef VTY_GROUP .vty_group = VTY_GROUP, @@ -174,7 +174,7 @@ int main(int argc, char** argv, char** envp) { break; case 'v': printf(PIMD_PROGNAME " version %s\n", PIMD_VERSION); - print_version(QUAGGA_PROGNAME); + print_version(progname); exit (0); break; #ifdef PIM_ZCLIENT_DEBUG @@ -194,7 +194,7 @@ int main(int argc, char** argv, char** envp) { master = thread_master_create(); zlog_notice("Quagga %s " PIMD_PROGNAME " %s starting", - QUAGGA_VERSION, PIMD_VERSION); + FRR_VERSION, PIMD_VERSION); /* * Initializations @@ -241,7 +241,7 @@ int main(int argc, char** argv, char** envp) { vty_serv_sock(vty_addr, vty_port, PIM_VTYSH_PATH); zlog_notice("Quagga %s " PIMD_PROGNAME " %s starting, VTY interface at port TCP %d", - QUAGGA_VERSION, PIMD_VERSION, vty_port); + FRR_VERSION, PIMD_VERSION, vty_port); #ifdef PIM_DEBUG_BYDEFAULT zlog_notice("PIM_DEBUG_BYDEFAULT: Enabling all debug commands"); diff --git a/ripd/rip_main.c b/ripd/rip_main.c index 796647c3e5..cfcb60168a 100644 --- a/ripd/rip_main.c +++ b/ripd/rip_main.c @@ -65,11 +65,11 @@ zebra_capabilities_t _caps_p [] = struct zebra_privs_t ripd_privs = { -#if defined(QUAGGA_USER) - .user = QUAGGA_USER, +#if defined(FRR_USER) + .user = FRR_USER, #endif -#if defined QUAGGA_GROUP - .group = QUAGGA_GROUP, +#if defined FRR_GROUP + .group = FRR_GROUP, #endif #ifdef VTY_GROUP .vty_group = VTY_GROUP, @@ -123,7 +123,7 @@ Daemon which manages RIP version 1 and 2.\n\n\ -v, --version Print program version\n\ -h, --help Display this help and exit\n\ \n\ -Report bugs to %s\n", progname, ZEBRA_BUG_ADDRESS); +Report bugs to %s\n", progname, FRR_BUG_ADDRESS); } exit (status); @@ -314,7 +314,7 @@ main (int argc, char **argv) vty_serv_sock (vty_addr, vty_port, RIP_VTYSH_PATH); /* Print banner. */ - zlog_notice ("RIPd %s starting: vty@%d", QUAGGA_VERSION, vty_port); + zlog_notice ("RIPd %s starting: vty@%d", FRR_VERSION, vty_port); /* Execute each thread. */ while (thread_fetch (master, &thread)) diff --git a/ripngd/ripng_main.c b/ripngd/ripng_main.c index e7ecbf9690..14711a1a65 100644 --- a/ripngd/ripng_main.c +++ b/ripngd/ripng_main.c @@ -70,11 +70,11 @@ zebra_capabilities_t _caps_p [] = struct zebra_privs_t ripngd_privs = { -#if defined(QUAGGA_USER) - .user = QUAGGA_USER, +#if defined(FRR_USER) + .user = FRR_USER, #endif -#if defined QUAGGA_GROUP - .group = QUAGGA_GROUP, +#if defined FRR_GROUP + .group = FRR_GROUP, #endif #ifdef VTY_GROUP .vty_group = VTY_GROUP, @@ -125,7 +125,7 @@ Daemon which manages RIPng.\n\n\ -C, --dryrun Check configuration for validity and exit\n\ -h, --help Display this help and exit\n\ \n\ -Report bugs to %s\n", progname, ZEBRA_BUG_ADDRESS); +Report bugs to %s\n", progname, FRR_BUG_ADDRESS); } exit (status); } @@ -309,7 +309,7 @@ main (int argc, char **argv) pid_output (pid_file); /* Print banner. */ - zlog_notice ("RIPNGd %s starting: vty@%d", QUAGGA_VERSION, vty_port); + zlog_notice ("RIPNGd %s starting: vty@%d", FRR_VERSION, vty_port); /* Fetch next active thread. */ while (thread_fetch (master, &thread)) diff --git a/tests/main.c b/tests/main.c index 885b8a2923..b3e6e706ff 100644 --- a/tests/main.c +++ b/tests/main.c @@ -92,7 +92,7 @@ Daemon which does 'slow' things.\n\n\ -v, --version Print program version\n\ -h, --help Display this help and exit\n\ \n\ -Report bugs to %s\n", progname, ZEBRA_BUG_ADDRESS); +Report bugs to %s\n", progname, FRR_BUG_ADDRESS); } exit (status); } diff --git a/tests/test-privs.c b/tests/test-privs.c index e0118a881c..c6ccc28e7a 100644 --- a/tests/test-privs.c +++ b/tests/test-privs.c @@ -37,9 +37,9 @@ zebra_capabilities_t _caps_p [] = struct zebra_privs_t test_privs = { -#if defined(QUAGGA_USER) && defined(QUAGGA_GROUP) - .user = QUAGGA_USER, - .group = QUAGGA_GROUP, +#if defined(FRR_USER) && defined(FRR_GROUP) + .user = FRR_USER, + .group = FRR_GROUP, #endif #if defined(VTY_GROUP) .vty_group = VTY_GROUP, @@ -71,7 +71,7 @@ Daemon which does 'slow' things.\n\n\ -g, --group Group to run as\n\ -h, --help Display this help and exit\n\ \n\ -Report bugs to %s\n", progname, ZEBRA_BUG_ADDRESS); +Report bugs to %s\n", progname, FRR_BUG_ADDRESS); } exit (status); } diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index a90915e1ac..82d0f437df 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -2509,21 +2509,21 @@ vtysh_write_config_integrated(void) err++; } - pwentry = getpwnam (QUAGGA_USER); + pwentry = getpwnam (FRR_USER); if (pwentry) uid = pwentry->pw_uid; else { - printf ("%% Warning: could not look up user \"%s\"\n", QUAGGA_USER); + printf ("%% Warning: could not look up user \"%s\"\n", FRR_USER); err++; } - grentry = getgrnam (QUAGGA_GROUP); + grentry = getgrnam (FRR_GROUP); if (grentry) gid = grentry->gr_gid; else { - printf ("%% Warning: could not look up group \"%s\"\n", QUAGGA_GROUP); + printf ("%% Warning: could not look up group \"%s\"\n", FRR_GROUP); err++; } diff --git a/vtysh/vtysh_main.c b/vtysh/vtysh_main.c index 999d90ab22..6b33fca39b 100644 --- a/vtysh/vtysh_main.c +++ b/vtysh/vtysh_main.c @@ -150,7 +150,7 @@ usage (int status) "Note that multiple commands may be executed from the command\n" \ "line by passing multiple -c args, or by embedding linefeed\n" \ "characters in one or more of the commands.\n\n" \ - "Report bugs to %s\n", progname, ZEBRA_BUG_ADDRESS); + "Report bugs to %s\n", progname, FRR_BUG_ADDRESS); exit (status); } diff --git a/vtysh/vtysh_user.c b/vtysh/vtysh_user.c index da2ed1569e..3a64ae0a96 100644 --- a/vtysh/vtysh_user.c +++ b/vtysh/vtysh_user.c @@ -67,7 +67,7 @@ vtysh_pam (const char *user) pam_handle_t *pamh = NULL; /* Start PAM. */ - ret = pam_start(QUAGGA_PROGNAME, user, &conv, &pamh); + ret = pam_start(FRR_PAM_NAME, user, &conv, &pamh); /* printf ("ret %d\n", ret); */ /* Is user really user? */ diff --git a/watchquagga/watchquagga.c b/watchquagga/watchquagga.c index 16b398030e..98e9129567 100644 --- a/watchquagga/watchquagga.c +++ b/watchquagga/watchquagga.c @@ -1266,7 +1266,7 @@ main(int argc, char **argv) gs.unresponsive_restart = 1; break; case 'v': - printf ("%s version %s\n", progname, QUAGGA_VERSION); + printf ("%s version %s\n", progname, FRR_VERSION); puts("Copyright 2004 Andrew J. Schorr"); return 0; case 'h': @@ -1422,7 +1422,7 @@ main(int argc, char **argv) p += strlen(p); } zlog_notice("%s %s watching [%s], mode [%s]", - progname, QUAGGA_VERSION, buf, mode_str[gs.mode]); + progname, FRR_VERSION, buf, mode_str[gs.mode]); } } diff --git a/zebra/main.c b/zebra/main.c index 4fea0104f5..9abc8f87ff 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -111,9 +111,9 @@ zebra_capabilities_t _caps_p [] = /* zebra privileges to run with */ struct zebra_privs_t zserv_privs = { -#if defined(QUAGGA_USER) && defined(QUAGGA_GROUP) - .user = QUAGGA_USER, - .group = QUAGGA_GROUP, +#if defined(FRR_USER) && defined(FRR_GROUP) + .user = FRR_USER, + .group = FRR_GROUP, #endif #ifdef VTY_GROUP .vty_group = VTY_GROUP, @@ -162,7 +162,7 @@ usage (char *progname, int status) printf ("-v, --version Print program version\n"\ "-h, --help Display this help and exit\n"\ "\n"\ - "Report bugs to %s\n", ZEBRA_BUG_ADDRESS); + "Report bugs to %s\n", FRR_BUG_ADDRESS); } exit (status); @@ -466,7 +466,7 @@ main (int argc, char **argv) vty_serv_sock (vty_addr, vty_port, ZEBRA_VTYSH_PATH); /* Print banner. */ - zlog_notice ("Zebra %s starting: vty@%d", QUAGGA_VERSION, vty_port); + zlog_notice ("Zebra %s starting: vty@%d", FRR_VERSION, vty_port); while (thread_fetch (zebrad.master, &thread)) thread_call (&thread); diff --git a/zebra/test_main.c b/zebra/test_main.c index 828b61af91..76ce92c370 100644 --- a/zebra/test_main.c +++ b/zebra/test_main.c @@ -108,7 +108,7 @@ usage (char *progname, int status) "-v, --version Print program version\n"\ "-h, --help Display this help and exit\n"\ "\n"\ - "Report bugs to %s\n", progname, ZEBRA_BUG_ADDRESS); + "Report bugs to %s\n", progname, FRR_BUG_ADDRESS); } exit (status); @@ -332,7 +332,7 @@ main (int argc, char **argv) vty_serv_sock (vty_addr, vty_port, "/tmp/test_zebra"); /* Print banner. */ - zlog_notice ("Zebra %s starting: vty@%d", QUAGGA_VERSION, vty_port); + zlog_notice ("Zebra %s starting: vty@%d", FRR_VERSION, vty_port); while (thread_fetch (zebrad.master, &thread)) thread_call (&thread); From 8e4da10b0a5f02bc45638be901bae4b6e931cf2c Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Wed, 14 Dec 2016 20:22:59 +0100 Subject: [PATCH 017/107] build: more renaming in configure.ac --- configure.ac | 82 ++++++++++++++++++++++++++-------------------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/configure.ac b/configure.ac index 05d0f96d10..d0d5fbb19b 100755 --- a/configure.ac +++ b/configure.ac @@ -516,7 +516,7 @@ AC_CHECK_HEADERS([stropts.h sys/ksym.h \ sys/cdefs.h]) dnl Utility macro to avoid retyping includes all the time -m4_define([QUAGGA_INCLUDES], +m4_define([FRR_INCLUDES], [#ifdef SUNOS_5 #define _XPG4_2 #define __EXTENSIONS__ @@ -543,10 +543,10 @@ dnl Same applies for HAVE_NET_IF_VAR_H, which HAVE_NETINET6_ND6_H and dnl HAVE_NETINET_IN_VAR_H depend upon. But if_var.h depends on if.h, hence dnl an additional round for it. -AC_CHECK_HEADERS([net/if_var.h], [], [], QUAGGA_INCLUDES) +AC_CHECK_HEADERS([net/if_var.h], [], [], FRR_INCLUDES) -m4_define([QUAGGA_INCLUDES], -QUAGGA_INCLUDES +m4_define([FRR_INCLUDES], +FRR_INCLUDES [#if HAVE_NET_IF_VAR_H # include #endif @@ -556,13 +556,13 @@ AC_CHECK_HEADERS([netinet/in_var.h \ net/if_dl.h net/netopt.h \ inet/nd.h netinet/ip_icmp.h \ sys/sysctl.h sys/sockio.h kvm.h sys/conf.h], - [], [], QUAGGA_INCLUDES) + [], [], FRR_INCLUDES) AC_CHECK_HEADERS([ucontext.h], [], [], [#ifndef __USE_GNU #define __USE_GNU #endif /* __USE_GNU */ -QUAGGA_INCLUDES +FRR_INCLUDES ]) m4_define([UCONTEXT_INCLUDES], @@ -577,8 +577,8 @@ AC_CHECK_MEMBERS([ucontext_t.uc_mcontext.regs], AC_CHECK_MEMBERS([ucontext_t.uc_mcontext.gregs], [], [], [UCONTEXT_INCLUDES]) -m4_define([QUAGGA_INCLUDES], -QUAGGA_INCLUDES +m4_define([FRR_INCLUDES], +FRR_INCLUDES [ #include #include @@ -706,13 +706,13 @@ if test "$with_libpam" = "yes"; then AC_DEFINE(PAM_CONV_FUNC,misc_conv,Have misc_conv) pam_conv_func="misc_conv" ], - [], QUAGGA_INCLUDES) + [], FRR_INCLUDES) AC_CHECK_HEADER([security/openpam.h], [AC_DEFINE(HAVE_OPENPAM_H,,Have openpam.h) AC_DEFINE(PAM_CONV_FUNC,openpam_ttyconv,Have openpam_ttyconv) pam_conv_func="openpam_ttyconv" ], - [], QUAGGA_INCLUDES[#include ]) + [], FRR_INCLUDES[#include ]) if test -z "$ac_cv_header_security_pam_misc_h$ac_cv_header_security_openpam_h" ; then AC_MSG_WARN([*** pam support will not be built ***]) with_libpam="no" @@ -800,7 +800,7 @@ AC_CHECK_FUNCS([ \ AC_CHECK_HEADER([asm-generic/unistd.h], [AC_CHECK_DECL(__NR_setns, AC_DEFINE(HAVE_NETNS,, Have netns),, - QUAGGA_INCLUDES [#include + FRR_INCLUDES [#include ]) AC_CHECK_FUNCS(setns)] ) @@ -940,7 +940,7 @@ AC_SUBST(IOCTL_METHOD) dnl --------------------------------------------------------------- dnl figure out how to specify an interface in multicast sockets API dnl --------------------------------------------------------------- -AC_CHECK_MEMBERS([struct ip_mreqn.imr_ifindex], [], [], QUAGGA_INCLUDES) +AC_CHECK_MEMBERS([struct ip_mreqn.imr_ifindex], [], [], FRR_INCLUDES) AC_CHECK_HEADERS([linux/mroute.h], [], [],[ #include @@ -949,8 +949,8 @@ AC_CHECK_HEADERS([linux/mroute.h], [], [],[ #include ]) -m4_define([QUAGGA_INCLUDES], -QUAGGA_INCLUDES +m4_define([FRR_INCLUDES], +FRR_INCLUDES [#if HAVE_LINUX_MROUTE_H # include #endif @@ -963,8 +963,8 @@ AC_CHECK_HEADERS([netinet/ip_mroute.h], [], [],[ #include ]) -m4_define([QUAGGA_INCLUDES], -QUAGGA_INCLUDES +m4_define([FRR_INCLUDES], +FRR_INCLUDES [#if HAVE_NETINET_IP_MROUTE_H # include #endif @@ -994,14 +994,14 @@ dnl figure out how to check link-state dnl --------------------------------------------------------------- AC_CHECK_HEADER( [net/if_media.h], [m4_define([LINK_DETECT_INCLUDES], - QUAGGA_INCLUDES + FRR_INCLUDES [#include ]) AC_CHECK_MEMBERS( [struct ifmediareq.ifm_status], AC_DEFINE(HAVE_BSD_LINK_DETECT,,[BSD link-detect]), [], LINK_DETECT_INCLUDES)], [], - QUAGGA_INCLUDES) + FRR_INCLUDES) dnl --------------------------------------------------------------- dnl Additional, newer way to check link-state using ifi_link_state. @@ -1009,7 +1009,7 @@ dnl Not available in all BSD's when ifmediareq available dnl --------------------------------------------------------------- AC_CHECK_MEMBERS([struct if_data.ifi_link_state], AC_DEFINE(HAVE_BSD_IFI_LINK_STATE,,[BSD ifi_link_state available]), - [], QUAGGA_INCLUDES) + [], FRR_INCLUDES) dnl ------------------------ dnl TCP_MD5SIG socket option @@ -1017,16 +1017,16 @@ dnl ------------------------ AC_CHECK_HEADER([netinet/tcp.h], [m4_define([MD5_INCLUDES], - QUAGGA_INCLUDES + FRR_INCLUDES [#include ]) AC_CHECK_DECLS([TCP_MD5SIG], [], [], MD5_INCLUDES)], [], - QUAGGA_INCLUDES) + FRR_INCLUDES) if test $ac_cv_have_decl_TCP_MD5SIG = no; then AC_CHECK_HEADER([linux/tcp.h], [m4_define([MD5_INCLUDES], - QUAGGA_INCLUDES + FRR_INCLUDES [#include ]) AC_CHECK_DECLS([TCP_MD5SIG], [], [], MD5_INCLUDES)]) @@ -1105,10 +1105,10 @@ dnl IPv6 header checks dnl ------------------ AC_CHECK_HEADERS([netinet6/in6.h netinet/in6_var.h \ netinet6/in6_var.h netinet6/nd6.h], [], [], - QUAGGA_INCLUDES) + FRR_INCLUDES) -m4_define([QUAGGA_INCLUDES],dnl -QUAGGA_INCLUDES +m4_define([FRR_INCLUDES],dnl +FRR_INCLUDES [#if HAVE_NETINET6_IN6_H #include #endif @@ -1318,14 +1318,14 @@ AC_CHECK_TYPES([ struct ifaliasreq, struct if6_aliasreq, struct in6_aliasreq, struct nd_opt_adv_interval, struct rt_addrinfo, struct nd_opt_homeagent_info, struct nd_opt_adv_interval], - [], [], QUAGGA_INCLUDES) + [], [], FRR_INCLUDES) AC_CHECK_MEMBERS([struct sockaddr.sa_len, struct sockaddr_in.sin_len, struct sockaddr_un.sun_len, struct sockaddr_dl.sdl_len, struct if6_aliasreq.ifra_lifetime, struct nd_opt_adv_interval.nd_opt_ai_type], - [], [], QUAGGA_INCLUDES) + [], [], FRR_INCLUDES) dnl --------------------------- dnl IRDP/pktinfo/icmphdr checks @@ -1337,10 +1337,10 @@ AC_CHECK_TYPES([struct in_pktinfo], fi], [if test "${enable_irdp}" = "yes"; then AC_MSG_ERROR(['IRDP requires in_pktinfo at the moment!']) - fi], [QUAGGA_INCLUDES])], + fi], [FRR_INCLUDES])], [if test "${enable_irdp}" = "yes"; then AC_MSG_ERROR(['IRDP requires in_pktinfo at the moment!']) - fi], [QUAGGA_INCLUDES]) + fi], [FRR_INCLUDES]) dnl ----------------------- dnl checking for IP_PKTINFO @@ -1413,7 +1413,7 @@ dnl -------------------------------------- AC_CHECK_DECL(CLOCK_MONOTONIC, [AC_CHECK_LIB(rt, clock_gettime, [LIBS="$LIBS -lrt"]) AC_DEFINE(HAVE_CLOCK_MONOTONIC,, Have monotonic clock) -], [AC_MSG_RESULT(no)], [QUAGGA_INCLUDES]) +], [AC_MSG_RESULT(no)], [FRR_INCLUDES]) dnl ------------------- dnl capabilities checks @@ -1423,17 +1423,17 @@ if test "${enable_capabilities}" != "no"; then AC_TRY_COMPILE([#include ],[prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0);], [AC_MSG_RESULT(yes) AC_DEFINE(HAVE_PR_SET_KEEPCAPS,,prctl) - quagga_ac_keepcaps="yes"], + frr_ac_keepcaps="yes"], AC_MSG_RESULT(no) ) - if test x"${quagga_ac_keepcaps}" = x"yes"; then + if test x"${frr_ac_keepcaps}" = x"yes"; then AC_CHECK_HEADERS(sys/capability.h) fi if test x"${ac_cv_header_sys_capability_h}" = x"yes"; then AC_CHECK_LIB(cap, cap_init, [AC_DEFINE(HAVE_LCAPS,1,Capabilities) LIBCAP="-lcap" - quagga_ac_lcaps="yes"] + frr_ac_lcaps="yes"] ) else AC_CHECK_HEADERS(priv.h, @@ -1441,14 +1441,14 @@ if test "${enable_capabilities}" != "no"; then AC_TRY_COMPILE([#include ],[getpflags(PRIV_AWARE);], [AC_MSG_RESULT(yes) AC_DEFINE(HAVE_SOLARIS_CAPABILITIES,1,getpflags) - quagga_ac_scaps="yes"], + frr_ac_scaps="yes"], AC_MSG_RESULT(no) ) ] ) fi - if test x"${quagga_ac_scaps}" = x"yes" \ - -o x"${quagga_ac_lcaps}" = x"yes"; then + if test x"${frr_ac_scaps}" = x"yes" \ + -o x"${frr_ac_lcaps}" = x"yes"; then AC_DEFINE(HAVE_CAPABILITIES,1,capabilities) fi fi @@ -1488,7 +1488,7 @@ AC_CHECK_HEADER([malloc.h], AC_DEFINE(HAVE_MALLINFO,,mallinfo)], AC_MSG_RESULT(no) ) - ], [], QUAGGA_INCLUDES) + ], [], FRR_INCLUDES) dnl ---------- dnl configure date @@ -1518,7 +1518,7 @@ else frr_statedir_prefix=${prefix} fi if test "${localstatedir}" = '${prefix}/var'; then - for QUAGGA_STATE_DIR in ${frr_statedir_prefix}/var/run dnl + for FRR_STATE_DIR in ${frr_statedir_prefix}/var/run dnl ${frr_statedir_prefix}/var/adm dnl ${frr_statedir_prefix}/etc dnl /var/run dnl @@ -1526,9 +1526,9 @@ if test "${localstatedir}" = '${prefix}/var'; then /etc dnl /dev/null; do - test -d $QUAGGA_STATE_DIR && break + test -d $FRR_STATE_DIR && break done - frr_statedir=$QUAGGA_STATE_DIR + frr_statedir=$FRR_STATE_DIR else frr_statedir=${localstatedir} fi @@ -1598,7 +1598,7 @@ dnl Check htonl works correctly dnl --------------------------- AC_MSG_CHECKING(for working htonl) AC_CACHE_VAL(ac_cv_htonl_works, - [AC_LINK_IFELSE([AC_LANG_PROGRAM([QUAGGA_INCLUDES],[htonl (0);])], + [AC_LINK_IFELSE([AC_LANG_PROGRAM([FRR_INCLUDES],[htonl (0);])], [ac_cv_htonl_works=yes], [ac_cv_htonl_works=no]) ] ) From 3bd82ffb70f1a18d2a2cddeb91101c183176a0fa Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Tue, 20 Dec 2016 17:59:13 +0100 Subject: [PATCH 018/107] build: remove INSTALL.quagga.txt It's horribly outdated & wrong info is worse than none. doc/install.texi should probably be updated instead. Signed-off-by: David Lamparter --- INSTALL.quagga.txt | 111 --------------------------------------------- Makefile.am | 2 +- README | 6 +-- 3 files changed, 3 insertions(+), 116 deletions(-) delete mode 100644 INSTALL.quagga.txt diff --git a/INSTALL.quagga.txt b/INSTALL.quagga.txt deleted file mode 100644 index b414d94861..0000000000 --- a/INSTALL.quagga.txt +++ /dev/null @@ -1,111 +0,0 @@ --------------------------------------------------------------------------- -Building and Installing Quagga from releases or snapshots: - -The 'INSTALL' file contains generic instructions on how to use 'configure' -scripts. - -Quagga requires a C compiler (and associated header files and -libraries) supporting the C99 standard. - -Quagga requires a reasonable make. It is considered a bug if quagga -does not compile with the system make on recent FreeBSD, NetBSD or -OpenBSD, and a very serious bug if it does not compile with GNU make. - -Quagga expects a POSIX.2 compliant system, more or less. Clean -workarounds for POSIX non-compliance are welcome. - -It is considered a bug if Quagga fails to build and run on any of the -following systems (where .x indicates the most recent release), or -such systems "-current" versions. Or, it might be that this list is -out of date and will be updated. (Note that considering it a bug is -not a guarantee of support, merely "we agree that it is broken".) - - Dragonfly ? - FreeBSD (stable branches currently supported, plus perhaps one) - FreeBSD-current - Linux [kernel/distribution information needed] - NetBSD 4.x - NetBSD 5.x - NetBSD 6.x - NetBSD-current - OpenBSD ? [info needed on what should work] - Solaris (modern/supported versions, including OpenSolaris forks) - -On BSD systems, installing libexecinfo is strongly recommended in order -to get backtrace support. - -For further Quagga specific information on 'configure' and build-time -configuration of the software, please read the Quagga info -documentation, (doc/quagga.info). To read the info page included with -the Quagga sources without first installing Quagga: - - cd doc - # one of the following, depending on your info viewer preferences - info quagga.info - pinfo -r quagga.info - emacs -eval '(info "quagga.info")' - -The Quagga website (http://www.quagga.net) currently has the info -files available in various formats. - --------------------------------------------------------------------------- -Building Quagga from git checkouts: - -In order to build from git, you will need recent versions of several GNU -tools, particularly autoconf, automake, libtool, GNU awk and texinfo. Note -that the CVS snapshots on the Quagga website should not require these tools; -everything is already setup ready to run 'configure'. If you have trouble -building from CVS checkout it is recommended that you try a CVS snapshot -instead. - -We declare that the following versions should work for building from -CVS checkouts. Earlier versions may work, but failure to do so is not -a bug. Required versions can be moved earlier if no problems, or -later after a judgement that a system without a higher version is -deficient is made. - - [TODO: this list is out of date as of 2013-07] - automake: 1.9.6 (released 2005-07-10) - autoconf: 2.59 (2.60 on 2006-06-26 is too recent to require) - libtool: 1.5.22 (released 2005-12-18) - texinfo: 4.7 (released 2004-04-10; 4.8 is not yet common) - -For running tests, one also needs: - - DejaGnu: - -[TODO: texinfo 4.6 is now ancient and this should be revisited/fixed] -Because some systems provide texinfo 4.6 (4.7 is new), quagga.info is -checked in so that texinfo will generally not be invoked. When -texinfo 4.7 is widespread, quagga.info will be removed from CVS and -texinfo will become required again. (4.7 has figure support, needed -for the route server docs, which is why 4.6 doesn't work.) - -In order to create PostScript or PDF versions of the Texinfo documentation, -you will need the convert utility, from the ImageMagick toolset installed, -and epstopdf from the TeTeX suite. - -To create the required autotools files (Makefile.in, configure, etc.), -run "./bootstrap.sh". After this you may run configure as for a -snapshot or release. - -Please refer to "Building and Installing Quagga" above for further -instructions. - --------------------------------------------------------------------------- -Notes on required versions: - -The general goal is to use a modern baseline of tools, while not -imposing pain on those tracking supported (or almost supported) stable -distributions. The notes below explain what versions are present in -various environments. - -NetBSD 4 provides texinfo 4.7. -NetBSD 5 and 6 provides texinfo 4.8 - -Fedora Core ? provides autoconf 2.59. - -OpenBSD 3.6 provides texinfo 4.2. -OpenBSD [3.6] ports provides automake 1.4-p6 autoconf 2.5.9 libtool 1.5.8 - --------------------------------------------------------------------------- diff --git a/Makefile.am b/Makefile.am index 7a2cc29bd5..d8b9844ffc 100644 --- a/Makefile.am +++ b/Makefile.am @@ -9,7 +9,7 @@ DIST_SUBDIRS = lib qpb fpm zebra bgpd ripd ripngd ospfd ospf6d ldpd \ isisd watchquagga vtysh ospfclient doc m4 pkgsrc redhat tests \ solaris pimd @LIBRFP@ @RFPTEST@ tools cumulus -EXTRA_DIST = aclocal.m4 SERVICES REPORTING-BUGS INSTALL.quagga.txt \ +EXTRA_DIST = aclocal.m4 SERVICES REPORTING-BUGS \ update-autotools \ vtysh/Makefile.in vtysh/Makefile.am \ tools/rrcheck.pl tools/rrlookup.pl tools/zc.pl \ diff --git a/README b/README index 91a1d8d0fb..4476947490 100644 --- a/README +++ b/README @@ -3,9 +3,7 @@ protocols. Currently Quagga supports BGP4, BGP4+, OSPFv2, OSPFv3, RIPv1, RIPv2, RIPng, PIM-SSM and LDP as well as very early support for IS-IS. - -See the file INSTALL.quagga.txt for building and installation instructions. - + See the file REPORTING-BUGS to report bugs. - + Quagga is free software. See the file COPYING for copying conditions. From ae435b1972ab95b647e816da6a2dbb9951628218 Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Tue, 20 Dec 2016 18:10:30 +0100 Subject: [PATCH 019/107] build: replace some hardcoding with ./configure Several places have paths and names that can change hardcoded, e.g. the package name and the /var/run path. This fixes a few of them, there's still some to do. Signed-off-by: David Lamparter --- lib/agentx.c | 5 +++-- lib/version.h.in | 1 + ospfd/ospf_main.c | 4 ++-- vtysh/vtysh.c | 9 +++++---- watchquagga/watchquagga.c | 2 +- zebra/zebra_ptm.c | 3 ++- 6 files changed, 14 insertions(+), 10 deletions(-) diff --git a/lib/agentx.c b/lib/agentx.c index 5996b34a0f..4175e7ba92 100644 --- a/lib/agentx.c +++ b/lib/agentx.c @@ -31,6 +31,7 @@ #include "smux.h" #include "memory.h" #include "linklist.h" +#include "version.h" static int agentx_enabled = 0; @@ -175,7 +176,7 @@ DEFUN (agentx_enable, { if (!agentx_enabled) { - init_snmp("quagga"); + init_snmp(FRR_SMUX_NAME); events = list_new(); agentx_events_update (); agentx_enabled = 1; @@ -209,7 +210,7 @@ smux_init (struct thread_master *tm) SNMP_CALLBACK_LOGGING, agentx_log_callback, NULL); - init_agent ("quagga"); + init_agent (FRR_SMUX_NAME); install_node (&agentx_node, config_write_agentx); install_element (CONFIG_NODE, &agentx_enable_cmd); diff --git a/lib/version.h.in b/lib/version.h.in index c41d44e0a4..adc8278189 100644 --- a/lib/version.h.in +++ b/lib/version.h.in @@ -37,6 +37,7 @@ #define FRR_PAM_NAME "@PACKAGE_NAME@" #define FRR_SMUX_NAME "@PACKAGE_NAME@" +#define FRR_PTM_NAME "@PACKAGE_NAME@" #define FRR_FULL_NAME "FreeRangeRouting" #define FRR_VERSION "@PACKAGE_VERSION@" GIT_SUFFIX diff --git a/ospfd/ospf_main.c b/ospfd/ospf_main.c index 5309af5bf9..e0719b397a 100644 --- a/ospfd/ospf_main.c +++ b/ospfd/ospf_main.c @@ -360,8 +360,8 @@ main (int argc, char **argv) /* Create VTY socket */ if (instance) { - sprintf(pid_file, "/var/run/quagga/ospfd-%d.pid", instance); - sprintf(vty_path, "/var/run/quagga/ospfd-%d.vty", instance); + sprintf(pid_file, "%s/ospfd-%d.pid", DAEMON_VTY_DIR, instance); + sprintf(vty_path, "%s/ospfd-%d.vty", DAEMON_VTY_DIR, instance); } else { diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index 82d0f437df..a4f108e447 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -2999,8 +2999,8 @@ vtysh_update_all_insances(struct vtysh_client * head_client) if (head_client->flag != VTYSH_OSPFD) return; - /* ls /var/run/quagga/ and look for all files ending in .vty */ - dir = opendir("/var/run/quagga/"); + /* ls DAEMON_VTY_DIR and look for all files ending in .vty */ + dir = opendir(DAEMON_VTY_DIR "/"); if (dir) { while ((file = readdir(dir)) != NULL) @@ -3010,7 +3010,8 @@ vtysh_update_all_insances(struct vtysh_client * head_client) if (n == MAXIMUM_INSTANCES) { fprintf(stderr, - "Parsing /var/run/quagga/, client limit(%d) reached!\n", n); + "Parsing %s/, client limit(%d) reached!\n", + DAEMON_VTY_DIR, n); break; } client = (struct vtysh_client *) malloc(sizeof(struct vtysh_client)); @@ -3018,7 +3019,7 @@ vtysh_update_all_insances(struct vtysh_client * head_client) client->name = "ospfd"; client->flag = VTYSH_OSPFD; ptr = (char *) malloc(100); - sprintf(ptr, "/var/run/quagga/%s", file->d_name); + sprintf(ptr, "%s/%s", DAEMON_VTY_DIR, file->d_name); client->path = (const char *)ptr; client->next = NULL; vtysh_client_sorted_insert(head_client, client); diff --git a/watchquagga/watchquagga.c b/watchquagga/watchquagga.c index 98e9129567..a70070bef7 100644 --- a/watchquagga/watchquagga.c +++ b/watchquagga/watchquagga.c @@ -706,7 +706,7 @@ daemon_send_ready (void) #if defined (HAVE_CUMULUS) FILE *fp; - fp = fopen("/var/run/quagga/watchquagga.started", "w"); + fp = fopen(DAEMON_VTY_DIR "/watchquagga.started", "w"); fclose(fp); #endif zlog_notice ("Watchquagga: Notifying Systemd we are up and running"); diff --git a/zebra/zebra_ptm.c b/zebra/zebra_ptm.c index e6d13b5070..c5223199a4 100644 --- a/zebra/zebra_ptm.c +++ b/zebra/zebra_ptm.c @@ -38,6 +38,7 @@ #include "vrf.h" #include "rib.h" #include "zebra_vrf.h" +#include "version.h" #define ZEBRA_PTM_RECONNECT_TIME_INITIAL 1 /* initial reconnect is 1s */ #define ZEBRA_PTM_RECONNECT_TIME_MAX 300 @@ -119,7 +120,7 @@ zebra_ptm_init (void) ptm_cb.pid = getpid(); zebra_ptm_install_commands(); - sprintf(buf, "%s", "quagga"); + sprintf(buf, "%s", FRR_PTM_NAME); ptm_hdl = ptm_lib_register(buf, NULL, zebra_ptm_handle_msg_cb, zebra_ptm_handle_msg_cb); ptm_cb.wb = buffer_new(0); From ab0181eed3d118fc46e693c68e5bbc0248c7bfe5 Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Tue, 20 Dec 2016 18:31:42 +0100 Subject: [PATCH 020/107] build: rename (2 of ?): route_types macros All of the autogenerated macros in lib/route_types.pl are now called FRR_* instead of QUAGGA_*. Signed-off-by: David Lamparter --- bgpd/bgp_vty.c | 80 +++++++++++++++++++++--------------------- isisd/isis_redist.c | 8 ++--- lib/log.c | 2 +- lib/route_types.pl | 34 +++++++++--------- ospf6d/ospf6_asbr.c | 16 ++++----- ospfd/ospf_vty.c | 16 ++++----- ripd/rip_zebra.c | 32 ++++++++--------- ripngd/ripng_zebra.c | 32 ++++++++--------- zebra/zebra_routemap.c | 48 ++++++++++++------------- zebra/zebra_vty.c | 24 ++++++------- 10 files changed, 146 insertions(+), 146 deletions(-) diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 5dafac1e06..8ccc4e2a90 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -13813,9 +13813,9 @@ DEFUN (show_ip_bgp_instance_peer_group, DEFUN (bgp_redistribute_ipv4, bgp_redistribute_ipv4_cmd, - "redistribute " QUAGGA_IP_REDIST_STR_BGPD, + "redistribute " FRR_IP_REDIST_STR_BGPD, "Redistribute information from another routing protocol\n" - QUAGGA_IP_REDIST_HELP_STR_BGPD) + FRR_IP_REDIST_HELP_STR_BGPD) { int type; @@ -13831,9 +13831,9 @@ DEFUN (bgp_redistribute_ipv4, DEFUN (bgp_redistribute_ipv4_rmap, bgp_redistribute_ipv4_rmap_cmd, - "redistribute " QUAGGA_IP_REDIST_STR_BGPD " route-map WORD", + "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", "Redistribute information from another routing protocol\n" - QUAGGA_IP_REDIST_HELP_STR_BGPD + FRR_IP_REDIST_HELP_STR_BGPD "Route map reference\n" "Pointer to route-map entries\n") { @@ -13854,9 +13854,9 @@ DEFUN (bgp_redistribute_ipv4_rmap, DEFUN (bgp_redistribute_ipv4_metric, bgp_redistribute_ipv4_metric_cmd, - "redistribute " QUAGGA_IP_REDIST_STR_BGPD " metric <0-4294967295>", + "redistribute " FRR_IP_REDIST_STR_BGPD " metric <0-4294967295>", "Redistribute information from another routing protocol\n" - QUAGGA_IP_REDIST_HELP_STR_BGPD + FRR_IP_REDIST_HELP_STR_BGPD "Metric for redistributed routes\n" "Default metric\n") { @@ -13879,9 +13879,9 @@ DEFUN (bgp_redistribute_ipv4_metric, DEFUN (bgp_redistribute_ipv4_rmap_metric, bgp_redistribute_ipv4_rmap_metric_cmd, - "redistribute " QUAGGA_IP_REDIST_STR_BGPD " route-map WORD metric <0-4294967295>", + "redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD metric <0-4294967295>", "Redistribute information from another routing protocol\n" - QUAGGA_IP_REDIST_HELP_STR_BGPD + FRR_IP_REDIST_HELP_STR_BGPD "Route map reference\n" "Pointer to route-map entries\n" "Metric for redistributed routes\n" @@ -13907,9 +13907,9 @@ DEFUN (bgp_redistribute_ipv4_rmap_metric, DEFUN (bgp_redistribute_ipv4_metric_rmap, bgp_redistribute_ipv4_metric_rmap_cmd, - "redistribute " QUAGGA_IP_REDIST_STR_BGPD " metric <0-4294967295> route-map WORD", + "redistribute " FRR_IP_REDIST_STR_BGPD " metric <0-4294967295> route-map WORD", "Redistribute information from another routing protocol\n" - QUAGGA_IP_REDIST_HELP_STR_BGPD + FRR_IP_REDIST_HELP_STR_BGPD "Metric for redistributed routes\n" "Default metric\n" "Route map reference\n" @@ -14141,10 +14141,10 @@ ALIAS (no_bgp_redistribute_ipv4_ospf, DEFUN (no_bgp_redistribute_ipv4, no_bgp_redistribute_ipv4_cmd, - "no redistribute " QUAGGA_IP_REDIST_STR_BGPD, + "no redistribute " FRR_IP_REDIST_STR_BGPD, NO_STR "Redistribute information from another routing protocol\n" - QUAGGA_IP_REDIST_HELP_STR_BGPD) + FRR_IP_REDIST_HELP_STR_BGPD) { int type; @@ -14159,28 +14159,28 @@ DEFUN (no_bgp_redistribute_ipv4, ALIAS (no_bgp_redistribute_ipv4, no_bgp_redistribute_ipv4_rmap_cmd, - "no redistribute " QUAGGA_IP_REDIST_STR_BGPD " route-map WORD", + "no redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD", NO_STR "Redistribute information from another routing protocol\n" - QUAGGA_IP_REDIST_HELP_STR_BGPD + FRR_IP_REDIST_HELP_STR_BGPD "Route map reference\n" "Pointer to route-map entries\n") ALIAS (no_bgp_redistribute_ipv4, no_bgp_redistribute_ipv4_metric_cmd, - "no redistribute " QUAGGA_IP_REDIST_STR_BGPD " metric <0-4294967295>", + "no redistribute " FRR_IP_REDIST_STR_BGPD " metric <0-4294967295>", NO_STR "Redistribute information from another routing protocol\n" - QUAGGA_IP_REDIST_HELP_STR_BGPD + FRR_IP_REDIST_HELP_STR_BGPD "Metric for redistributed routes\n" "Default metric\n") ALIAS (no_bgp_redistribute_ipv4, no_bgp_redistribute_ipv4_rmap_metric_cmd, - "no redistribute " QUAGGA_IP_REDIST_STR_BGPD " route-map WORD metric <0-4294967295>", + "no redistribute " FRR_IP_REDIST_STR_BGPD " route-map WORD metric <0-4294967295>", NO_STR "Redistribute information from another routing protocol\n" - QUAGGA_IP_REDIST_HELP_STR_BGPD + FRR_IP_REDIST_HELP_STR_BGPD "Route map reference\n" "Pointer to route-map entries\n" "Metric for redistributed routes\n" @@ -14188,10 +14188,10 @@ ALIAS (no_bgp_redistribute_ipv4, ALIAS (no_bgp_redistribute_ipv4, no_bgp_redistribute_ipv4_metric_rmap_cmd, - "no redistribute " QUAGGA_IP_REDIST_STR_BGPD " metric <0-4294967295> route-map WORD", + "no redistribute " FRR_IP_REDIST_STR_BGPD " metric <0-4294967295> route-map WORD", NO_STR "Redistribute information from another routing protocol\n" - QUAGGA_IP_REDIST_HELP_STR_BGPD + FRR_IP_REDIST_HELP_STR_BGPD "Metric for redistributed routes\n" "Default metric\n" "Route map reference\n" @@ -14200,9 +14200,9 @@ ALIAS (no_bgp_redistribute_ipv4, #ifdef HAVE_IPV6 DEFUN (bgp_redistribute_ipv6, bgp_redistribute_ipv6_cmd, - "redistribute " QUAGGA_IP6_REDIST_STR_BGPD, + "redistribute " FRR_IP6_REDIST_STR_BGPD, "Redistribute information from another routing protocol\n" - QUAGGA_IP6_REDIST_HELP_STR_BGPD) + FRR_IP6_REDIST_HELP_STR_BGPD) { int type; @@ -14219,9 +14219,9 @@ DEFUN (bgp_redistribute_ipv6, DEFUN (bgp_redistribute_ipv6_rmap, bgp_redistribute_ipv6_rmap_cmd, - "redistribute " QUAGGA_IP6_REDIST_STR_BGPD " route-map WORD", + "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD", "Redistribute information from another routing protocol\n" - QUAGGA_IP6_REDIST_HELP_STR_BGPD + FRR_IP6_REDIST_HELP_STR_BGPD "Route map reference\n" "Pointer to route-map entries\n") { @@ -14242,9 +14242,9 @@ DEFUN (bgp_redistribute_ipv6_rmap, DEFUN (bgp_redistribute_ipv6_metric, bgp_redistribute_ipv6_metric_cmd, - "redistribute " QUAGGA_IP6_REDIST_STR_BGPD " metric <0-4294967295>", + "redistribute " FRR_IP6_REDIST_STR_BGPD " metric <0-4294967295>", "Redistribute information from another routing protocol\n" - QUAGGA_IP6_REDIST_HELP_STR_BGPD + FRR_IP6_REDIST_HELP_STR_BGPD "Metric for redistributed routes\n" "Default metric\n") { @@ -14267,9 +14267,9 @@ DEFUN (bgp_redistribute_ipv6_metric, DEFUN (bgp_redistribute_ipv6_rmap_metric, bgp_redistribute_ipv6_rmap_metric_cmd, - "redistribute " QUAGGA_IP6_REDIST_STR_BGPD " route-map WORD metric <0-4294967295>", + "redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD metric <0-4294967295>", "Redistribute information from another routing protocol\n" - QUAGGA_IP6_REDIST_HELP_STR_BGPD + FRR_IP6_REDIST_HELP_STR_BGPD "Route map reference\n" "Pointer to route-map entries\n" "Metric for redistributed routes\n" @@ -14295,9 +14295,9 @@ DEFUN (bgp_redistribute_ipv6_rmap_metric, DEFUN (bgp_redistribute_ipv6_metric_rmap, bgp_redistribute_ipv6_metric_rmap_cmd, - "redistribute " QUAGGA_IP6_REDIST_STR_BGPD " metric <0-4294967295> route-map WORD", + "redistribute " FRR_IP6_REDIST_STR_BGPD " metric <0-4294967295> route-map WORD", "Redistribute information from another routing protocol\n" - QUAGGA_IP6_REDIST_HELP_STR_BGPD + FRR_IP6_REDIST_HELP_STR_BGPD "Metric for redistributed routes\n" "Default metric\n" "Route map reference\n" @@ -14323,10 +14323,10 @@ DEFUN (bgp_redistribute_ipv6_metric_rmap, DEFUN (no_bgp_redistribute_ipv6, no_bgp_redistribute_ipv6_cmd, - "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD, + "no redistribute " FRR_IP6_REDIST_STR_BGPD, NO_STR "Redistribute information from another routing protocol\n" - QUAGGA_IP6_REDIST_HELP_STR_BGPD) + FRR_IP6_REDIST_HELP_STR_BGPD) { int type; @@ -14342,28 +14342,28 @@ DEFUN (no_bgp_redistribute_ipv6, ALIAS (no_bgp_redistribute_ipv6, no_bgp_redistribute_ipv6_rmap_cmd, - "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD " route-map WORD", + "no redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD", NO_STR "Redistribute information from another routing protocol\n" - QUAGGA_IP6_REDIST_HELP_STR_BGPD + FRR_IP6_REDIST_HELP_STR_BGPD "Route map reference\n" "Pointer to route-map entries\n") ALIAS (no_bgp_redistribute_ipv6, no_bgp_redistribute_ipv6_metric_cmd, - "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD " metric <0-4294967295>", + "no redistribute " FRR_IP6_REDIST_STR_BGPD " metric <0-4294967295>", NO_STR "Redistribute information from another routing protocol\n" - QUAGGA_IP6_REDIST_HELP_STR_BGPD + FRR_IP6_REDIST_HELP_STR_BGPD "Metric for redistributed routes\n" "Default metric\n") ALIAS (no_bgp_redistribute_ipv6, no_bgp_redistribute_ipv6_rmap_metric_cmd, - "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD " route-map WORD metric <0-4294967295>", + "no redistribute " FRR_IP6_REDIST_STR_BGPD " route-map WORD metric <0-4294967295>", NO_STR "Redistribute information from another routing protocol\n" - QUAGGA_IP6_REDIST_HELP_STR_BGPD + FRR_IP6_REDIST_HELP_STR_BGPD "Route map reference\n" "Pointer to route-map entries\n" "Metric for redistributed routes\n" @@ -14371,10 +14371,10 @@ ALIAS (no_bgp_redistribute_ipv6, ALIAS (no_bgp_redistribute_ipv6, no_bgp_redistribute_ipv6_metric_rmap_cmd, - "no redistribute " QUAGGA_IP6_REDIST_STR_BGPD " metric <0-4294967295> route-map WORD", + "no redistribute " FRR_IP6_REDIST_STR_BGPD " metric <0-4294967295> route-map WORD", NO_STR "Redistribute information from another routing protocol\n" - QUAGGA_IP6_REDIST_HELP_STR_BGPD + FRR_IP6_REDIST_HELP_STR_BGPD "Metric for redistributed routes\n" "Default metric\n" "Route map reference\n" diff --git a/isisd/isis_redist.c b/isisd/isis_redist.c index 21daaa7794..8282591a49 100644 --- a/isisd/isis_redist.c +++ b/isisd/isis_redist.c @@ -540,12 +540,12 @@ isis_redist_area_finish(struct isis_area *area) DEFUN (isis_redistribute, isis_redistribute_cmd, - "redistribute (ipv4|ipv6) " QUAGGA_REDIST_STR_ISISD + "redistribute (ipv4|ipv6) " FRR_REDIST_STR_ISISD " (level-1|level-2) {metric <0-16777215>|route-map WORD}", REDIST_STR "Redistribute IPv4 routes\n" "Redistribute IPv6 routes\n" - QUAGGA_REDIST_HELP_STR_ISISD + FRR_REDIST_HELP_STR_ISISD "Redistribute into level-1\n" "Redistribute into level-2\n" "Metric for redistributed routes\n" @@ -609,13 +609,13 @@ DEFUN (isis_redistribute, DEFUN (no_isis_redistribute, no_isis_redistribute_cmd, - "no redistribute (ipv4|ipv6) " QUAGGA_REDIST_STR_ISISD + "no redistribute (ipv4|ipv6) " FRR_REDIST_STR_ISISD " (level-1|level-2)", NO_STR REDIST_STR "Redistribute IPv4 routes\n" "Redistribute IPv6 routes\n" - QUAGGA_REDIST_HELP_STR_ISISD + FRR_REDIST_HELP_STR_ISISD "Redistribute into level-1\n" "Redistribute into level-2\n") { diff --git a/lib/log.c b/lib/log.c index f9877300b4..fb9d02a301 100644 --- a/lib/log.c +++ b/lib/log.c @@ -20,7 +20,7 @@ * 02111-1307, USA. */ -#define QUAGGA_DEFINE_DESC_TABLE +#define FRR_DEFINE_DESC_TABLE #include diff --git a/lib/route_types.pl b/lib/route_types.pl index d44cb12b23..ffe9bec04b 100755 --- a/lib/route_types.pl +++ b/lib/route_types.pl @@ -86,8 +86,8 @@ printf <{"ipv4"} && $daemons{$daemon}->{"ipv6"}) { my ($names, $help) = collect($daemon, 1, 1, 0); - printf "#define QUAGGA_REDIST_STR_%s \\\n %s\n", uc $daemon, $names; - printf "#define QUAGGA_REDIST_HELP_STR_%s \\\n%s\n", uc $daemon, $help; + printf "#define FRR_REDIST_STR_%s \\\n %s\n", uc $daemon, $names; + printf "#define FRR_REDIST_HELP_STR_%s \\\n%s\n", uc $daemon, $help; ($names, $help) = collect($daemon, 1, 0, 0); - printf "#define QUAGGA_IP_REDIST_STR_%s \\\n %s\n", uc $daemon, $names; - printf "#define QUAGGA_IP_REDIST_HELP_STR_%s \\\n%s\n", uc $daemon, $help; + printf "#define FRR_IP_REDIST_STR_%s \\\n %s\n", uc $daemon, $names; + printf "#define FRR_IP_REDIST_HELP_STR_%s \\\n%s\n", uc $daemon, $help; ($names, $help) = collect($daemon, 0, 1, 0); - printf "#define QUAGGA_IP6_REDIST_STR_%s \\\n %s\n", uc $daemon, $names; - printf "#define QUAGGA_IP6_REDIST_HELP_STR_%s \\\n%s\n", uc $daemon, $help; + printf "#define FRR_IP6_REDIST_STR_%s \\\n %s\n", uc $daemon, $names; + printf "#define FRR_IP6_REDIST_HELP_STR_%s \\\n%s\n", uc $daemon, $help; if ($daemon eq "zebra") { ($names, $help) = collect($daemon, 1, 0, 1); - printf "#define QUAGGA_IP_PROTOCOL_MAP_STR_%s \\\n %s\n", uc $daemon, $names; - printf "#define QUAGGA_IP_PROTOCOL_MAP_HELP_STR_%s \\\n%s\n", uc $daemon, $help; + printf "#define FRR_IP_PROTOCOL_MAP_STR_%s \\\n %s\n", uc $daemon, $names; + printf "#define FRR_IP_PROTOCOL_MAP_HELP_STR_%s \\\n%s\n", uc $daemon, $help; ($names, $help) = collect($daemon, 0, 1, 1); - printf "#define QUAGGA_IP6_PROTOCOL_MAP_STR_%s \\\n %s\n", uc $daemon, $names; - printf "#define QUAGGA_IP6_PROTOCOL_MAP_HELP_STR_%s \\\n%s\n", uc $daemon, $help; + printf "#define FRR_IP6_PROTOCOL_MAP_STR_%s \\\n %s\n", uc $daemon, $names; + printf "#define FRR_IP6_PROTOCOL_MAP_HELP_STR_%s \\\n%s\n", uc $daemon, $help; } } else { my ($names, $help) = collect($daemon, $daemons{$daemon}->{"ipv4"}, $daemons{$daemon}->{"ipv6"}, 0); - printf "#define QUAGGA_REDIST_STR_%s \\\n %s\n", uc $daemon, $names; - printf "#define QUAGGA_REDIST_HELP_STR_%s \\\n%s\n", uc $daemon, $help; + printf "#define FRR_REDIST_STR_%s \\\n %s\n", uc $daemon, $names; + printf "#define FRR_REDIST_HELP_STR_%s \\\n%s\n", uc $daemon, $help; } print "\n"; } print <|metric-type (1|2)|route-map WORD}", REDIST_STR - QUAGGA_REDIST_HELP_STR_OSPFD + FRR_REDIST_HELP_STR_OSPFD "Metric for redistributed routes\n" "OSPF default metric\n" "OSPF exterior metric type for redistributed routes\n" @@ -8117,11 +8117,11 @@ DEFUN (ospf_redistribute_source, DEFUN (no_ospf_redistribute_source, no_ospf_redistribute_source_cmd, - "no redistribute " QUAGGA_REDIST_STR_OSPFD + "no redistribute " FRR_REDIST_STR_OSPFD " {metric <0-16777214>|metric-type (1|2)|route-map WORD}", NO_STR REDIST_STR - QUAGGA_REDIST_HELP_STR_OSPFD + FRR_REDIST_HELP_STR_OSPFD "Metric for redistributed routes\n" "OSPF default metric\n" "OSPF exterior metric type for redistributed routes\n" @@ -8273,11 +8273,11 @@ DEFUN (no_ospf_redistribute_instance_source, DEFUN (ospf_distribute_list_out, ospf_distribute_list_out_cmd, - "distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD, + "distribute-list WORD out " FRR_REDIST_STR_OSPFD, "Filter networks in routing updates\n" "Access-list name\n" OUT_STR - QUAGGA_REDIST_HELP_STR_OSPFD) + FRR_REDIST_HELP_STR_OSPFD) { struct ospf *ospf = vty->index; int source; @@ -8295,12 +8295,12 @@ DEFUN (ospf_distribute_list_out, DEFUN (no_ospf_distribute_list_out, no_ospf_distribute_list_out_cmd, - "no distribute-list WORD out " QUAGGA_REDIST_STR_OSPFD, + "no distribute-list WORD out " FRR_REDIST_STR_OSPFD, NO_STR "Filter networks in routing updates\n" "Access-list name\n" OUT_STR - QUAGGA_REDIST_HELP_STR_OSPFD) + FRR_REDIST_HELP_STR_OSPFD) { struct ospf *ospf = vty->index; int source; diff --git a/ripd/rip_zebra.c b/ripd/rip_zebra.c index 3f7c7a3e4d..44fc1cd8f9 100644 --- a/ripd/rip_zebra.c +++ b/ripd/rip_zebra.c @@ -371,9 +371,9 @@ DEFUN (no_rip_redistribute_rip, DEFUN (rip_redistribute_type, rip_redistribute_type_cmd, - "redistribute " QUAGGA_REDIST_STR_RIPD, + "redistribute " FRR_REDIST_STR_RIPD, REDIST_STR - QUAGGA_REDIST_HELP_STR_RIPD) + FRR_REDIST_HELP_STR_RIPD) { int i; @@ -396,10 +396,10 @@ DEFUN (rip_redistribute_type, DEFUN (no_rip_redistribute_type, no_rip_redistribute_type_cmd, - "no redistribute " QUAGGA_REDIST_STR_RIPD, + "no redistribute " FRR_REDIST_STR_RIPD, NO_STR REDIST_STR - QUAGGA_REDIST_HELP_STR_RIPD) + FRR_REDIST_HELP_STR_RIPD) { int i; @@ -423,9 +423,9 @@ DEFUN (no_rip_redistribute_type, DEFUN (rip_redistribute_type_routemap, rip_redistribute_type_routemap_cmd, - "redistribute " QUAGGA_REDIST_STR_RIPD " route-map WORD", + "redistribute " FRR_REDIST_STR_RIPD " route-map WORD", REDIST_STR - QUAGGA_REDIST_HELP_STR_RIPD + FRR_REDIST_HELP_STR_RIPD "Route map reference\n" "Pointer to route-map entries\n") { @@ -450,10 +450,10 @@ DEFUN (rip_redistribute_type_routemap, DEFUN (no_rip_redistribute_type_routemap, no_rip_redistribute_type_routemap_cmd, - "no redistribute " QUAGGA_REDIST_STR_RIPD " route-map WORD", + "no redistribute " FRR_REDIST_STR_RIPD " route-map WORD", NO_STR REDIST_STR - QUAGGA_REDIST_HELP_STR_RIPD + FRR_REDIST_HELP_STR_RIPD "Route map reference\n" "Pointer to route-map entries\n") { @@ -479,9 +479,9 @@ DEFUN (no_rip_redistribute_type_routemap, DEFUN (rip_redistribute_type_metric, rip_redistribute_type_metric_cmd, - "redistribute " QUAGGA_REDIST_STR_RIPD " metric <0-16>", + "redistribute " FRR_REDIST_STR_RIPD " metric <0-16>", REDIST_STR - QUAGGA_REDIST_HELP_STR_RIPD + FRR_REDIST_HELP_STR_RIPD "Metric\n" "Metric value\n") { @@ -509,10 +509,10 @@ DEFUN (rip_redistribute_type_metric, DEFUN (no_rip_redistribute_type_metric, no_rip_redistribute_type_metric_cmd, - "no redistribute " QUAGGA_REDIST_STR_RIPD " metric <0-16>", + "no redistribute " FRR_REDIST_STR_RIPD " metric <0-16>", NO_STR REDIST_STR - QUAGGA_REDIST_HELP_STR_RIPD + FRR_REDIST_HELP_STR_RIPD "Metric\n" "Metric value\n") { @@ -538,9 +538,9 @@ DEFUN (no_rip_redistribute_type_metric, DEFUN (rip_redistribute_type_metric_routemap, rip_redistribute_type_metric_routemap_cmd, - "redistribute " QUAGGA_REDIST_STR_RIPD " metric <0-16> route-map WORD", + "redistribute " FRR_REDIST_STR_RIPD " metric <0-16> route-map WORD", REDIST_STR - QUAGGA_REDIST_HELP_STR_RIPD + FRR_REDIST_HELP_STR_RIPD "Metric\n" "Metric value\n" "Route map reference\n" @@ -572,11 +572,11 @@ DEFUN (rip_redistribute_type_metric_routemap, DEFUN (no_rip_redistribute_type_metric_routemap, no_rip_redistribute_type_metric_routemap_cmd, - "no redistribute " QUAGGA_REDIST_STR_RIPD + "no redistribute " FRR_REDIST_STR_RIPD " metric <0-16> route-map WORD", NO_STR REDIST_STR - QUAGGA_REDIST_HELP_STR_RIPD + FRR_REDIST_HELP_STR_RIPD "Metric\n" "Metric value\n" "Route map reference\n" diff --git a/ripngd/ripng_zebra.c b/ripngd/ripng_zebra.c index d05b5dbad8..67337caf28 100644 --- a/ripngd/ripng_zebra.c +++ b/ripngd/ripng_zebra.c @@ -339,9 +339,9 @@ DEFUN (no_ripng_redistribute_ripng, DEFUN (ripng_redistribute_type, ripng_redistribute_type_cmd, - "redistribute " QUAGGA_REDIST_STR_RIPNGD, + "redistribute " FRR_REDIST_STR_RIPNGD, "Redistribute\n" - QUAGGA_REDIST_HELP_STR_RIPNGD) + FRR_REDIST_HELP_STR_RIPNGD) { int type; @@ -359,10 +359,10 @@ DEFUN (ripng_redistribute_type, DEFUN (no_ripng_redistribute_type, no_ripng_redistribute_type_cmd, - "no redistribute " QUAGGA_REDIST_STR_RIPNGD, + "no redistribute " FRR_REDIST_STR_RIPNGD, NO_STR "Redistribute\n" - QUAGGA_REDIST_HELP_STR_RIPNGD) + FRR_REDIST_HELP_STR_RIPNGD) { int type; @@ -382,9 +382,9 @@ DEFUN (no_ripng_redistribute_type, DEFUN (ripng_redistribute_type_metric, ripng_redistribute_type_metric_cmd, - "redistribute " QUAGGA_REDIST_STR_RIPNGD " metric <0-16>", + "redistribute " FRR_REDIST_STR_RIPNGD " metric <0-16>", "Redistribute\n" - QUAGGA_REDIST_HELP_STR_RIPNGD + FRR_REDIST_HELP_STR_RIPNGD "Metric\n" "Metric value\n") { @@ -408,18 +408,18 @@ DEFUN (ripng_redistribute_type_metric, ALIAS (no_ripng_redistribute_type, no_ripng_redistribute_type_metric_cmd, - "no redistribute " QUAGGA_REDIST_STR_RIPNGD " metric <0-16>", + "no redistribute " FRR_REDIST_STR_RIPNGD " metric <0-16>", NO_STR "Redistribute\n" - QUAGGA_REDIST_HELP_STR_RIPNGD + FRR_REDIST_HELP_STR_RIPNGD "Metric\n" "Metric value\n") DEFUN (ripng_redistribute_type_routemap, ripng_redistribute_type_routemap_cmd, - "redistribute " QUAGGA_REDIST_STR_RIPNGD " route-map WORD", + "redistribute " FRR_REDIST_STR_RIPNGD " route-map WORD", "Redistribute\n" - QUAGGA_REDIST_HELP_STR_RIPNGD + FRR_REDIST_HELP_STR_RIPNGD "Route map reference\n" "Pointer to route-map entries\n") { @@ -441,18 +441,18 @@ DEFUN (ripng_redistribute_type_routemap, ALIAS (no_ripng_redistribute_type, no_ripng_redistribute_type_routemap_cmd, - "no redistribute " QUAGGA_REDIST_STR_RIPNGD " route-map WORD", + "no redistribute " FRR_REDIST_STR_RIPNGD " route-map WORD", NO_STR "Redistribute\n" - QUAGGA_REDIST_HELP_STR_RIPNGD + FRR_REDIST_HELP_STR_RIPNGD "Route map reference\n" "Pointer to route-map entries\n") DEFUN (ripng_redistribute_type_metric_routemap, ripng_redistribute_type_metric_routemap_cmd, - "redistribute " QUAGGA_REDIST_STR_RIPNGD " metric <0-16> route-map WORD", + "redistribute " FRR_REDIST_STR_RIPNGD " metric <0-16> route-map WORD", "Redistribute\n" - QUAGGA_REDIST_HELP_STR_RIPNGD + FRR_REDIST_HELP_STR_RIPNGD "Metric\n" "Metric value\n" "Route map reference\n" @@ -478,10 +478,10 @@ DEFUN (ripng_redistribute_type_metric_routemap, ALIAS (no_ripng_redistribute_type, no_ripng_redistribute_type_metric_routemap_cmd, - "no redistribute " QUAGGA_REDIST_STR_RIPNGD " metric <0-16> route-map WORD", + "no redistribute " FRR_REDIST_STR_RIPNGD " metric <0-16> route-map WORD", NO_STR "Redistribute\n" - QUAGGA_REDIST_HELP_STR_RIPNGD + FRR_REDIST_HELP_STR_RIPNGD "Route map reference\n" "Pointer to route-map entries\n") diff --git a/zebra/zebra_routemap.c b/zebra/zebra_routemap.c index 3075a61c4a..041f67826b 100644 --- a/zebra/zebra_routemap.c +++ b/zebra/zebra_routemap.c @@ -730,10 +730,10 @@ ALIAS (no_zebra_route_map_timer, DEFUN (ip_protocol, ip_protocol_cmd, - "ip protocol " QUAGGA_IP_PROTOCOL_MAP_STR_ZEBRA " route-map ROUTE-MAP", + "ip protocol " FRR_IP_PROTOCOL_MAP_STR_ZEBRA " route-map ROUTE-MAP", IP_STR "Filter routing info exchanged between zebra and protocol\n" - QUAGGA_IP_PROTOCOL_MAP_HELP_STR_ZEBRA + FRR_IP_PROTOCOL_MAP_HELP_STR_ZEBRA "Route map name\n") { int i; @@ -767,11 +767,11 @@ DEFUN (ip_protocol, DEFUN (no_ip_protocol, no_ip_protocol_cmd, - "no ip protocol " QUAGGA_IP_PROTOCOL_MAP_STR_ZEBRA, + "no ip protocol " FRR_IP_PROTOCOL_MAP_STR_ZEBRA, NO_STR IP_STR "Stop filtering routing info between zebra and protocol\n" - QUAGGA_IP_PROTOCOL_MAP_HELP_STR_ZEBRA + FRR_IP_PROTOCOL_MAP_HELP_STR_ZEBRA "Protocol from which to stop filtering routes\n") { int i; @@ -805,11 +805,11 @@ DEFUN (no_ip_protocol, ALIAS (no_ip_protocol, no_ip_protocol_val_cmd, - "no ip protocol " QUAGGA_IP_PROTOCOL_MAP_STR_ZEBRA " route-map ROUTE-MAP", + "no ip protocol " FRR_IP_PROTOCOL_MAP_STR_ZEBRA " route-map ROUTE-MAP", NO_STR IP_STR "Stop filtering routing info between zebra and protocol\n" - QUAGGA_IP_PROTOCOL_MAP_HELP_STR_ZEBRA + FRR_IP_PROTOCOL_MAP_HELP_STR_ZEBRA "route map name") DEFUN (show_ip_protocol, @@ -843,10 +843,10 @@ DEFUN (show_ip_protocol, DEFUN (ipv6_protocol, ipv6_protocol_cmd, - "ipv6 protocol " QUAGGA_IP6_PROTOCOL_MAP_STR_ZEBRA " route-map ROUTE-MAP", + "ipv6 protocol " FRR_IP6_PROTOCOL_MAP_STR_ZEBRA " route-map ROUTE-MAP", IP6_STR "Filter IPv6 routing info exchanged between zebra and protocol\n" - QUAGGA_IP6_PROTOCOL_MAP_HELP_STR_ZEBRA + FRR_IP6_PROTOCOL_MAP_HELP_STR_ZEBRA "Route map name\n") { int i; @@ -880,11 +880,11 @@ DEFUN (ipv6_protocol, DEFUN (no_ipv6_protocol, no_ipv6_protocol_cmd, - "no ipv6 protocol " QUAGGA_IP6_PROTOCOL_MAP_STR_ZEBRA, + "no ipv6 protocol " FRR_IP6_PROTOCOL_MAP_STR_ZEBRA, NO_STR IP6_STR "Stop filtering IPv6 routing info between zebra and protocol\n" - QUAGGA_IP6_PROTOCOL_MAP_HELP_STR_ZEBRA + FRR_IP6_PROTOCOL_MAP_HELP_STR_ZEBRA "Protocol from which to stop filtering routes\n") { int i; @@ -919,11 +919,11 @@ DEFUN (no_ipv6_protocol, ALIAS (no_ipv6_protocol, no_ipv6_protocol_val_cmd, - "no ipv6 protocol " QUAGGA_IP6_PROTOCOL_MAP_STR_ZEBRA " route-map ROUTE-MAP", + "no ipv6 protocol " FRR_IP6_PROTOCOL_MAP_STR_ZEBRA " route-map ROUTE-MAP", NO_STR IP6_STR "Stop filtering IPv6 routing info between zebra and protocol\n" - QUAGGA_IP6_PROTOCOL_MAP_HELP_STR_ZEBRA + FRR_IP6_PROTOCOL_MAP_HELP_STR_ZEBRA "route map name") DEFUN (show_ipv6_protocol, @@ -957,10 +957,10 @@ DEFUN (show_ipv6_protocol, DEFUN (ip_protocol_nht_rmap, ip_protocol_nht_rmap_cmd, - "ip nht " QUAGGA_IP_PROTOCOL_MAP_STR_ZEBRA " route-map ROUTE-MAP", + "ip nht " FRR_IP_PROTOCOL_MAP_STR_ZEBRA " route-map ROUTE-MAP", IP_STR "Filter Next Hop tracking route resolution\n" - QUAGGA_IP_PROTOCOL_MAP_HELP_STR_ZEBRA + FRR_IP_PROTOCOL_MAP_HELP_STR_ZEBRA "Route map name\n") { int i; @@ -991,11 +991,11 @@ DEFUN (ip_protocol_nht_rmap, DEFUN (no_ip_protocol_nht_rmap, no_ip_protocol_nht_rmap_cmd, - "no ip nht " QUAGGA_IP_PROTOCOL_MAP_STR_ZEBRA, + "no ip nht " FRR_IP_PROTOCOL_MAP_STR_ZEBRA, NO_STR IP_STR "Filter Next Hop tracking route resolution\n" - QUAGGA_IP_PROTOCOL_MAP_HELP_STR_ZEBRA) + FRR_IP_PROTOCOL_MAP_HELP_STR_ZEBRA) { int i; @@ -1024,10 +1024,10 @@ DEFUN (no_ip_protocol_nht_rmap, ALIAS (no_ip_protocol_nht_rmap, no_ip_protocol_nht_rmap_val_cmd, - "no ip nht " QUAGGA_IP_PROTOCOL_MAP_STR_ZEBRA " route-map ROUTE-MAP", + "no ip nht " FRR_IP_PROTOCOL_MAP_STR_ZEBRA " route-map ROUTE-MAP", IP_STR "Filter Next Hop tracking route resolution\n" - QUAGGA_IP_PROTOCOL_MAP_HELP_STR_ZEBRA + FRR_IP_PROTOCOL_MAP_HELP_STR_ZEBRA "Route map name\n") DEFUN (show_ip_protocol_nht, @@ -1061,10 +1061,10 @@ DEFUN (show_ip_protocol_nht, DEFUN (ipv6_protocol_nht_rmap, ipv6_protocol_nht_rmap_cmd, - "ipv6 nht " QUAGGA_IP6_PROTOCOL_MAP_STR_ZEBRA " route-map ROUTE-MAP", + "ipv6 nht " FRR_IP6_PROTOCOL_MAP_STR_ZEBRA " route-map ROUTE-MAP", IP6_STR "Filter Next Hop tracking route resolution\n" - QUAGGA_IP6_PROTOCOL_MAP_HELP_STR_ZEBRA + FRR_IP6_PROTOCOL_MAP_HELP_STR_ZEBRA "Route map name\n") { int i; @@ -1089,11 +1089,11 @@ DEFUN (ipv6_protocol_nht_rmap, DEFUN (no_ipv6_protocol_nht_rmap, no_ipv6_protocol_nht_rmap_cmd, - "no ipv6 nht " QUAGGA_IP6_PROTOCOL_MAP_STR_ZEBRA, + "no ipv6 nht " FRR_IP6_PROTOCOL_MAP_STR_ZEBRA, NO_STR IP6_STR "Filter Next Hop tracking route resolution\n" - QUAGGA_IP6_PROTOCOL_MAP_HELP_STR_ZEBRA) + FRR_IP6_PROTOCOL_MAP_HELP_STR_ZEBRA) { int i; @@ -1127,11 +1127,11 @@ DEFUN (no_ipv6_protocol_nht_rmap, ALIAS (no_ipv6_protocol_nht_rmap, no_ipv6_protocol_nht_rmap_val_cmd, - "no ipv6 nht " QUAGGA_IP6_PROTOCOL_MAP_STR_ZEBRA " route-map ROUTE-MAP", + "no ipv6 nht " FRR_IP6_PROTOCOL_MAP_STR_ZEBRA " route-map ROUTE-MAP", NO_STR IP6_STR "Filter Next Hop tracking route resolution\n" - QUAGGA_IP6_PROTOCOL_MAP_HELP_STR_ZEBRA + FRR_IP6_PROTOCOL_MAP_HELP_STR_ZEBRA "Route map name\n") DEFUN (show_ipv6_protocol_nht, diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index 84106e7ff9..98c20270c3 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -2858,11 +2858,11 @@ ALIAS (show_ip_route_supernets, DEFUN (show_ip_route_protocol, show_ip_route_protocol_cmd, - "show ip route " QUAGGA_IP_REDIST_STR_ZEBRA, + "show ip route " FRR_IP_REDIST_STR_ZEBRA, SHOW_STR IP_STR "IP routing table\n" - QUAGGA_IP_REDIST_HELP_STR_ZEBRA) + FRR_IP_REDIST_HELP_STR_ZEBRA) { int type; struct route_table *table; @@ -2906,12 +2906,12 @@ DEFUN (show_ip_route_protocol, ALIAS (show_ip_route_protocol, show_ip_route_vrf_protocol_cmd, - "show ip route " VRF_CMD_STR " " QUAGGA_IP_REDIST_STR_ZEBRA, + "show ip route " VRF_CMD_STR " " FRR_IP_REDIST_STR_ZEBRA, SHOW_STR IP_STR "IP routing table\n" VRF_CMD_HELP_STR - QUAGGA_IP_REDIST_HELP_STR_ZEBRA) + FRR_IP_REDIST_HELP_STR_ZEBRA) DEFUN (show_ip_route_ospf_instance, show_ip_route_ospf_instance_cmd, @@ -3487,12 +3487,12 @@ DEFUN (show_ip_route_vrf_all_supernets, DEFUN (show_ip_route_vrf_all_protocol, show_ip_route_vrf_all_protocol_cmd, - "show ip route " VRF_ALL_CMD_STR " " QUAGGA_IP_REDIST_STR_ZEBRA, + "show ip route " VRF_ALL_CMD_STR " " FRR_IP_REDIST_STR_ZEBRA, SHOW_STR IP_STR "IP routing table\n" VRF_ALL_CMD_HELP_STR - QUAGGA_IP_REDIST_HELP_STR_ZEBRA"\n") + FRR_IP_REDIST_HELP_STR_ZEBRA"\n") { int type; struct route_table *table; @@ -5124,11 +5124,11 @@ ALIAS (show_ipv6_route_prefix_longer, DEFUN (show_ipv6_route_protocol, show_ipv6_route_protocol_cmd, - "show ipv6 route " QUAGGA_IP6_REDIST_STR_ZEBRA, + "show ipv6 route " FRR_IP6_REDIST_STR_ZEBRA, SHOW_STR IP_STR "IP routing table\n" - QUAGGA_IP6_REDIST_HELP_STR_ZEBRA) + FRR_IP6_REDIST_HELP_STR_ZEBRA) { int type; struct route_table *table; @@ -5172,12 +5172,12 @@ DEFUN (show_ipv6_route_protocol, ALIAS (show_ipv6_route_protocol, show_ipv6_route_vrf_protocol_cmd, - "show ipv6 route " VRF_CMD_STR " " QUAGGA_IP6_REDIST_STR_ZEBRA, + "show ipv6 route " VRF_CMD_STR " " FRR_IP6_REDIST_STR_ZEBRA, SHOW_STR IP_STR "IP routing table\n" VRF_CMD_HELP_STR - QUAGGA_IP6_REDIST_HELP_STR_ZEBRA) + FRR_IP6_REDIST_HELP_STR_ZEBRA) DEFUN (show_ipv6_route_addr, show_ipv6_route_addr_cmd, @@ -5562,12 +5562,12 @@ DEFUN (show_ipv6_route_vrf_all_prefix_longer, DEFUN (show_ipv6_route_vrf_all_protocol, show_ipv6_route_vrf_all_protocol_cmd, - "show ipv6 route " VRF_ALL_CMD_STR " " QUAGGA_IP6_REDIST_STR_ZEBRA, + "show ipv6 route " VRF_ALL_CMD_STR " " FRR_IP6_REDIST_STR_ZEBRA, SHOW_STR IP_STR "IP routing table\n" VRF_ALL_CMD_HELP_STR - QUAGGA_IP6_REDIST_HELP_STR_ZEBRA) + FRR_IP6_REDIST_HELP_STR_ZEBRA) { int type; struct route_table *table; From 2f49a5942b3003023c51a0426725d9e440deccfa Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Tue, 13 Dec 2016 22:51:41 -0200 Subject: [PATCH 021/107] ldpd: fix segfault when configuring multiple pseudowires Signed-off-by: Renato Westphal --- ldpd/ldp_vty_conf.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ldpd/ldp_vty_conf.c b/ldpd/ldp_vty_conf.c index f2b21d8175..dd70365f3d 100644 --- a/ldpd/ldp_vty_conf.c +++ b/ldpd/ldp_vty_conf.c @@ -1250,7 +1250,7 @@ ldp_vty_l2vpn(struct vty *vty, struct vty_arg *args[]) l2vpn->type = L2VPN_TYPE_VPLS; LIST_INSERT_HEAD(&vty_conf->l2vpn_list, l2vpn, entry); - ldp_reload(vty_conf); + ldp_reload_ref(vty_conf, (void **)&l2vpn); VTY_PUSH_CONTEXT(LDP_L2VPN_NODE, l2vpn); return (CMD_SUCCESS); @@ -1432,7 +1432,7 @@ ldp_vty_l2vpn_pseudowire(struct vty *vty, struct vty_arg *args[]) } if (pw) { - VTY_PUSH_CONTEXT(LDP_PSEUDOWIRE_NODE, pw); + VTY_PUSH_CONTEXT_SUB(LDP_PSEUDOWIRE_NODE, pw); goto cancel; } @@ -1454,7 +1454,7 @@ ldp_vty_l2vpn_pseudowire(struct vty *vty, struct vty_arg *args[]) LIST_INSERT_HEAD(&l2vpn->pw_inactive_list, pw, entry); ldp_reload_ref(vty_conf, (void **)&pw); - VTY_PUSH_CONTEXT(LDP_PSEUDOWIRE_NODE, pw); + VTY_PUSH_CONTEXT_SUB(LDP_PSEUDOWIRE_NODE, pw); return (CMD_SUCCESS); @@ -1474,7 +1474,7 @@ ldp_vty_l2vpn_pw_cword(struct vty *vty, struct vty_arg *args[]) disable = (vty_get_arg_value(args, "no")) ? 1 : 0; preference_str = vty_get_arg_value(args, "preference"); - pw = VTY_GET_CONTEXT(l2vpn_pw); + pw = VTY_GET_CONTEXT_SUB(l2vpn_pw); vty_conf = ldp_dup_config_ref(ldpd_conf, (void **)&pw); if (disable) @@ -1510,7 +1510,7 @@ ldp_vty_l2vpn_pw_nbr_addr(struct vty *vty, struct vty_arg *args[]) return (CMD_WARNING); } - pw = VTY_GET_CONTEXT(l2vpn_pw); + pw = VTY_GET_CONTEXT_SUB(l2vpn_pw); vty_conf = ldp_dup_config_ref(ldpd_conf, (void **)&pw); if (disable) { @@ -1546,7 +1546,7 @@ ldp_vty_l2vpn_pw_nbr_id(struct vty *vty, struct vty_arg *args[]) return (CMD_WARNING); } - pw = VTY_GET_CONTEXT(l2vpn_pw); + pw = VTY_GET_CONTEXT_SUB(l2vpn_pw); vty_conf = ldp_dup_config_ref(ldpd_conf, (void **)&pw); if (disable) @@ -1578,7 +1578,7 @@ ldp_vty_l2vpn_pw_pwid(struct vty *vty, struct vty_arg *args[]) return (CMD_WARNING); } - pw = VTY_GET_CONTEXT(l2vpn_pw); + pw = VTY_GET_CONTEXT_SUB(l2vpn_pw); vty_conf = ldp_dup_config_ref(ldpd_conf, (void **)&pw); if (disable) @@ -1600,7 +1600,7 @@ ldp_vty_l2vpn_pw_pwstatus(struct vty *vty, struct vty_arg *args[]) disable = (vty_get_arg_value(args, "no")) ? 1 : 0; - pw = VTY_GET_CONTEXT(l2vpn_pw); + pw = VTY_GET_CONTEXT_SUB(l2vpn_pw); vty_conf = ldp_dup_config_ref(ldpd_conf, (void **)&pw); if (disable) From 9c0b0e6753b110a7e0ba4229873a6c10cd8c6bd5 Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Wed, 14 Dec 2016 19:20:10 -0200 Subject: [PATCH 022/107] ldpd: allow multiple link adjacencies with unnumbered interfaces Now we can have two different adjacencies coming from the same source address. Check for the adjacency's interface on adj_find() to disambiguate them. Signed-off-by: Renato Westphal --- ldpd/adjacency.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ldpd/adjacency.c b/ldpd/adjacency.c index 3607ee96b3..d1a6facb30 100644 --- a/ldpd/adjacency.c +++ b/ldpd/adjacency.c @@ -117,6 +117,10 @@ adj_find(struct hello_source *source) switch (source->type) { case HELLO_LINK: + if (strcmp(source->link.ia->iface->name, + adj->source.link.ia->iface->name)) + continue; + if (ldp_addrcmp(source->link.ia->af, &adj->source.link.src_addr, &source->link.src_addr) == 0) From 6e2e5d4108bf01828c27a4056de0579cb93c4bec Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Fri, 23 Dec 2016 01:58:29 +0000 Subject: [PATCH 023/107] vtysh: add `logical-router ...` to extract.pl ignore list Signed-off-by: Quentin Young --- vtysh/extract.pl.in | 1 + 1 file changed, 1 insertion(+) diff --git a/vtysh/extract.pl.in b/vtysh/extract.pl.in index fc5a5147f1..9540ffab5f 100755 --- a/vtysh/extract.pl.in +++ b/vtysh/extract.pl.in @@ -81,6 +81,7 @@ $ignore{'"show history"'} = "ignore"; $ignore{'"router ospf [(1-65535)]"'} = "ignore"; $ignore{'"address-family vpnv6 [unicast]"'} = "ignore"; $ignore{'"address-family vpnv4 [unicast]"'} = "ignore"; +$ignore{'"logical-router (1-65535) ns NAME"'} = "ignore"; my $cli_stomp = 0; From 949ae9ba1531be3629da0b5be47ff4dae763baa0 Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Fri, 16 Dec 2016 10:48:37 -0200 Subject: [PATCH 024/107] zebra: fix FIB route updates on *BSD On *BSD, we update a route in the FIB by removing the old one and then installing the new version. With that said, on kernel_route_rib() we need to provide a pointer to both the old version and the new version of the route. We were, however, passing a pointer to the new version to both the 'old' and 'new' parameters. This is not a problem on Linux, which uses NLM_F_REPLACE to update routes, but it breaks route updates on *BSD because the 'old' parameter points to a route that is not installed in the kernel. The kernel_route_rib() function then fails to uninstall the supposedly 'old' route and can fail to install the new version as well if the kernel doesn't support ECMP (e.g. FreeBSD with default configuration). Signed-off-by: Renato Westphal --- zebra/rib.h | 2 +- zebra/zebra_rib.c | 12 ++++++------ zebra/zebra_static.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/zebra/rib.h b/zebra/rib.h index 30929f1beb..a30c093fba 100644 --- a/zebra/rib.h +++ b/zebra/rib.h @@ -335,7 +335,7 @@ extern int zebra_check_addr (struct prefix *p); extern void rib_addnode (struct route_node *rn, struct rib *rib, int process); extern void rib_delnode (struct route_node *rn, struct rib *rib); -extern int rib_install_kernel (struct route_node *rn, struct rib *rib, int update); +extern int rib_install_kernel (struct route_node *rn, struct rib *rib, struct rib *old); extern int rib_uninstall_kernel (struct route_node *rn, struct rib *rib); /* NOTE: diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index c573f6bd5c..a792bcc657 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -1212,7 +1212,7 @@ nexthop_active_update (struct route_node *rn, struct rib *rib, int set) * is only used for IPv4. */ int -rib_install_kernel (struct route_node *rn, struct rib *rib, int update) +rib_install_kernel (struct route_node *rn, struct rib *rib, struct rib *old) { int ret = 0; struct nexthop *nexthop, *tnexthop; @@ -1231,7 +1231,7 @@ rib_install_kernel (struct route_node *rn, struct rib *rib, int update) * the kernel. */ zfpm_trigger_update (rn, "installing in kernel"); - ret = kernel_route_rib (&rn->p, update ? rib : NULL, rib); + ret = kernel_route_rib (&rn->p, old, rib); /* If install succeeds, update FIB flag for nexthops. */ if (!ret) @@ -1388,7 +1388,7 @@ rib_process_add_fib(struct zebra_vrf *zvrf, struct route_node *rn, if (!RIB_SYSTEM_ROUTE (new)) { - if (rib_install_kernel (rn, new, 0)) + if (rib_install_kernel (rn, new, NULL)) { inet_ntop (rn->p.family, &rn->p.u.prefix, buf, INET6_ADDRSTRLEN); zlog_warn ("%u:%s/%d: Route install failed", @@ -1470,7 +1470,7 @@ rib_process_update_fib (struct zebra_vrf *zvrf, struct route_node *rn, /* Non-system route should be installed. */ if (!RIB_SYSTEM_ROUTE (new)) { - if (rib_install_kernel (rn, new, 1)) + if (rib_install_kernel (rn, new, old)) { installed = 0; inet_ntop (rn->p.family, &rn->p.u.prefix, buf, INET6_ADDRSTRLEN); @@ -1542,7 +1542,7 @@ rib_process_update_fib (struct zebra_vrf *zvrf, struct route_node *rn, break; } if (!in_fib) - rib_install_kernel (rn, new, 0); + rib_install_kernel (rn, new, NULL); } } @@ -2779,7 +2779,7 @@ rib_delete (afi_t afi, safi_t safi, vrf_id_t vrf_id, int type, u_short instance, { /* This means someone else, other than Zebra, has deleted * a Zebra router from the kernel. We will add it back */ - rib_install_kernel(rn, fib, 0); + rib_install_kernel(rn, fib, NULL); } } else diff --git a/zebra/zebra_static.c b/zebra/zebra_static.c index a7a68bd0de..5894a8955b 100644 --- a/zebra/zebra_static.c +++ b/zebra/zebra_static.c @@ -322,7 +322,7 @@ static_uninstall_route (afi_t afi, safi_t safi, struct prefix *p, struct static_ { /* Update route in kernel if it's in fib */ if (CHECK_FLAG(rib->status, RIB_ENTRY_SELECTED_FIB)) - rib_install_kernel (rn, rib, 1); + rib_install_kernel (rn, rib, rib); /* Update redistribution if it's selected */ if (CHECK_FLAG(rib->flags, ZEBRA_FLAG_SELECTED)) redistribute_update (&rn->p, rib, NULL); From cc1e9ed2ab71bb792818ebc84f352f88503cb542 Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Thu, 15 Dec 2016 16:24:54 -0200 Subject: [PATCH 025/107] doc: add the ldpd vty port to the SERVICES file Signed-off-by: Renato Westphal --- SERVICES | 1 + 1 file changed, 1 insertion(+) diff --git a/SERVICES b/SERVICES index c69d0c1a77..ee242ca6a2 100644 --- a/SERVICES +++ b/SERVICES @@ -18,3 +18,4 @@ ospf6d 2606/tcp ospfapi 2607/tcp isisd 2608/tcp pimd 2611/tcp +ldpd 2612/tcp From e3edd1d1d4c118acdcd6424a43d57fd7d7584aa7 Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Fri, 16 Dec 2016 12:51:07 -0200 Subject: [PATCH 026/107] zebra: remove unused variable It looks like 'nexthop_fib_num' has been lingering around since 2003 without any use. Remove it. Signed-off-by: Renato Westphal --- zebra/rib.h | 1 - zebra/zebra_rib.c | 5 ++--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/zebra/rib.h b/zebra/rib.h index a30c093fba..d80ea6cbd8 100644 --- a/zebra/rib.h +++ b/zebra/rib.h @@ -93,7 +93,6 @@ struct rib /* Nexthop information. */ u_char nexthop_num; u_char nexthop_active_num; - u_char nexthop_fib_num; }; /* meta-queue structure: diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index a792bcc657..e48da0479b 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -2459,11 +2459,10 @@ void _rib_dump (const char * func, ); zlog_debug ( - "%s: nexthop_num == %u, nexthop_active_num == %u, nexthop_fib_num == %u", + "%s: nexthop_num == %u, nexthop_active_num == %u", func, rib->nexthop_num, - rib->nexthop_active_num, - rib->nexthop_fib_num + rib->nexthop_active_num ); for (ALL_NEXTHOPS_RO(rib->nexthop, nexthop, tnexthop, recursing)) From 271ad8d53f41f35b22ee7c7aa4dbf4b16903f533 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Thu, 29 Dec 2016 05:44:49 +0000 Subject: [PATCH 027/107] bgpd, ospfd, zebra: remove duplicate cli installs Signed-off-by: Quentin Young --- bgpd/bgp_route.c | 11 ----------- bgpd/bgp_vty.c | 28 ++++++++-------------------- ospfd/ospf_dump.c | 5 ----- zebra/zebra_vty.c | 1 - 4 files changed, 8 insertions(+), 37 deletions(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index cfc4ec3407..6f03ac0df0 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -10556,17 +10556,6 @@ bgp_route_init (void) install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd); install_element (VIEW_NODE, &show_ip_bgp_route_cmd); install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd); - - install_element (VIEW_NODE, &show_ip_bgp_instance_neighbor_advertised_route_cmd); - install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd); - install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); - install_element (VIEW_NODE, &show_ip_bgp_dampening_params_cmd); - install_element (VIEW_NODE, &show_ip_bgp_ipv4_dampening_parameters_cmd); - - /* Restricted node: VIEW_NODE - (set of dangerous commands) */ - install_element (VIEW_NODE, &show_ip_bgp_instance_all_cmd); - install_element (VIEW_NODE, &show_ip_bgp_ipv4_cmd); - install_element (VIEW_NODE, &show_ip_bgp_route_cmd); install_element (VIEW_NODE, &show_ip_bgp_instance_neighbor_advertised_route_cmd); install_element (VIEW_NODE, &show_ip_bgp_neighbor_routes_cmd); install_element (VIEW_NODE, &show_ip_bgp_neighbor_received_prefix_filter_cmd); diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 1c2cc037f9..a74f7cf8f5 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -10602,33 +10602,21 @@ bgp_vty_init (void) install_element (ENABLE_NODE, &clear_bgp_instance_ipv6_safi_prefix_cmd); /* "show [ip] bgp summary" commands. */ - install_element (VIEW_NODE, &show_ip_bgp_summary_cmd); - install_element (VIEW_NODE, &show_ip_bgp_updgrps_cmd); install_element (VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); - install_element (VIEW_NODE, &show_ip_bgp_updgrps_adj_cmd); - install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_cmd); - install_element (VIEW_NODE, &show_bgp_updgrps_adj_cmd); install_element (VIEW_NODE, &show_bgp_instance_updgrps_adj_cmd); - install_element (VIEW_NODE, &show_bgp_updgrps_afi_adj_cmd); - install_element (VIEW_NODE, &show_ip_bgp_updgrps_adj_s_cmd); - install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); - install_element (VIEW_NODE, &show_bgp_updgrps_adj_s_cmd); install_element (VIEW_NODE, &show_bgp_instance_updgrps_adj_s_cmd); - install_element (VIEW_NODE, &show_bgp_updgrps_afi_adj_s_cmd); - install_element (VIEW_NODE, &show_ip_bgp_updgrps_cmd); - install_element (VIEW_NODE, &show_bgp_instance_all_ipv6_updgrps_cmd); - install_element (VIEW_NODE, &show_ip_bgp_updgrps_adj_cmd); - install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_cmd); + install_element (VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); install_element (VIEW_NODE, &show_bgp_updgrps_adj_cmd); - install_element (VIEW_NODE, &show_bgp_instance_updgrps_adj_cmd); - install_element (VIEW_NODE, &show_bgp_updgrps_afi_adj_cmd); - install_element (VIEW_NODE, &show_ip_bgp_updgrps_adj_s_cmd); - install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); install_element (VIEW_NODE, &show_bgp_updgrps_adj_s_cmd); - install_element (VIEW_NODE, &show_bgp_instance_updgrps_adj_s_cmd); + install_element (VIEW_NODE, &show_bgp_updgrps_afi_adj_cmd); install_element (VIEW_NODE, &show_bgp_updgrps_afi_adj_s_cmd); install_element (VIEW_NODE, &show_bgp_updgrps_stats_cmd); - install_element (VIEW_NODE, &show_bgp_instance_updgrps_stats_cmd); + install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_cmd); + install_element (VIEW_NODE, &show_ip_bgp_instance_updgrps_adj_s_cmd); + install_element (VIEW_NODE, &show_ip_bgp_summary_cmd); + install_element (VIEW_NODE, &show_ip_bgp_updgrps_adj_cmd); + install_element (VIEW_NODE, &show_ip_bgp_updgrps_adj_s_cmd); + install_element (VIEW_NODE, &show_ip_bgp_updgrps_cmd); /* "show [ip] bgp neighbors" commands. */ install_element (VIEW_NODE, &show_ip_bgp_neighbors_cmd); diff --git a/ospfd/ospf_dump.c b/ospfd/ospf_dump.c index 93baac5988..4e9797184d 100644 --- a/ospfd/ospf_dump.c +++ b/ospfd/ospf_dump.c @@ -1979,8 +1979,6 @@ debug_init () install_element (ENABLE_NODE, &show_debugging_ospf_instance_cmd); install_element (ENABLE_NODE, &debug_ospf_packet_cmd); install_element (ENABLE_NODE, &no_debug_ospf_packet_cmd); - install_element (ENABLE_NODE, &debug_ospf_ism_cmd); - install_element (ENABLE_NODE, &no_debug_ospf_ism_cmd); install_element (ENABLE_NODE, &debug_ospf_instance_nsm_cmd); install_element (ENABLE_NODE, &debug_ospf_instance_lsa_cmd); @@ -1994,8 +1992,6 @@ debug_init () install_element (ENABLE_NODE, &no_debug_ospf_instance_nssa_cmd); install_element (ENABLE_NODE, &no_debug_ospf_cmd); - - install_element (CONFIG_NODE, &debug_ospf_packet_cmd); install_element (CONFIG_NODE, &no_debug_ospf_packet_cmd); install_element (CONFIG_NODE, &debug_ospf_ism_cmd); @@ -2007,7 +2003,6 @@ debug_init () install_element (CONFIG_NODE, &debug_ospf_event_cmd); install_element (CONFIG_NODE, &debug_ospf_nssa_cmd); install_element (CONFIG_NODE, &debug_ospf_te_cmd); - install_element (CONFIG_NODE, &no_debug_ospf_ism_cmd); install_element (CONFIG_NODE, &no_debug_ospf_nsm_cmd); install_element (CONFIG_NODE, &no_debug_ospf_lsa_cmd); install_element (CONFIG_NODE, &no_debug_ospf_zebra_cmd); diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index e5f9b17e81..44335f72a1 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -3858,7 +3858,6 @@ zebra_vty_init (void) install_element (CONFIG_NODE, &no_ip_route_flags_cmd); install_element (CONFIG_NODE, &no_ip_route_mask_flags_cmd); - install_element (VIEW_NODE, &show_ip_route_vrf_cmd); install_element (VIEW_NODE, &show_ip_route_vrf_cmd); install_element (VIEW_NODE, &show_ip_route_vrf_all_cmd); From 45cc0c76a71a288b64603a60148962f689c042a0 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Thu, 29 Dec 2016 07:01:05 +0000 Subject: [PATCH 028/107] zebra: check route flags when deciding whether to update existing route Signed-off-by: Quentin Young --- zebra/zebra_static.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/zebra/zebra_static.c b/zebra/zebra_static.c index e6ae9c71d4..200a55a7ec 100644 --- a/zebra/zebra_static.c +++ b/zebra/zebra_static.c @@ -401,7 +401,8 @@ static_add_route (afi_t afi, safi_t safi, u_char type, struct prefix *p, && (! ifindex || ifindex == si->ifindex)) { if ((distance == si->distance) && (tag == si->tag) && - !memcmp (&si->snh_label, snh_label, sizeof (struct static_nh_label))) + !memcmp (&si->snh_label, snh_label, sizeof (struct static_nh_label)) && + si->flags == flags) { route_unlock_node (rn); return 0; From 21ab852483058ac6df5dee63b2cb8fabc7d58e49 Mon Sep 17 00:00:00 2001 From: Lou Berger Date: Mon, 7 Nov 2016 07:33:15 -0500 Subject: [PATCH 029/107] prefix.c: replace free with XFREE for memory allocated with XMALLOC Signed-off-by: Lou Berger --- lib/prefix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/prefix.c b/lib/prefix.c index bc6afcf9f8..84a04c5300 100644 --- a/lib/prefix.c +++ b/lib/prefix.c @@ -665,7 +665,7 @@ str2prefix_ipv6 (const char *str, struct prefix_ipv6 *p) strncpy (cp, str, pnt - str); *(cp + (pnt - str)) = '\0'; ret = inet_pton (AF_INET6, cp, &p->prefix); - free (cp); + XFREE (MTYPE_TMP, cp); if (ret == 0) return 0; plen = (u_char) atoi (++pnt); From 53a7a0651975a325ce56d7933aeab467f193bb65 Mon Sep 17 00:00:00 2001 From: Lou Berger Date: Sat, 17 Dec 2016 13:20:59 -0500 Subject: [PATCH 030/107] bgpd: fix unitialized value check id'ed by valgrind Signed-off-by: Lou Berger --- bgpd/bgp_route.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index a61899447a..f645da3f2a 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -631,8 +631,9 @@ bgp_info_cmp (struct bgp *bgp, struct bgp_info *new, struct bgp_info *exist, { if (peer_sort (new->peer) == BGP_PEER_IBGP && peer_sort (exist->peer) == BGP_PEER_IBGP - && CHECK_FLAG (mpath_cfg->ibgp_flags, - BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN)) + && (mpath_cfg == NULL || + CHECK_FLAG (mpath_cfg->ibgp_flags, + BGP_FLAG_IBGP_MULTIPATH_SAME_CLUSTERLEN))) { newm = BGP_CLUSTER_LIST_LENGTH(new->attr); existm = BGP_CLUSTER_LIST_LENGTH(exist->attr); @@ -868,9 +869,8 @@ bgp_info_cmp_compatible (struct bgp *bgp, struct bgp_info *new, struct bgp_info afi_t afi, safi_t safi) { int paths_eq; - struct bgp_maxpaths_cfg mpath_cfg; int ret; - ret = bgp_info_cmp (bgp, new, exist, &paths_eq, &mpath_cfg, 0, __func__); + ret = bgp_info_cmp (bgp, new, exist, &paths_eq, NULL, 0, __func__); if (paths_eq) ret = 0; From 271a0c25483ae2072427557d0207e0e642a9ba04 Mon Sep 17 00:00:00 2001 From: Lou Berger Date: Sat, 17 Dec 2016 13:26:03 -0500 Subject: [PATCH 031/107] lib/command.c: fix leak id'ed by valgrind Signed-off-by: Lou Berger --- lib/command.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/lib/command.c b/lib/command.c index 0b0614b806..0cabe32e6c 100644 --- a/lib/command.c +++ b/lib/command.c @@ -1066,6 +1066,7 @@ cmd_ipv6_prefix_match (const char *str) const char *delim = "/\0"; char *dupe, *prefix, *mask, *context, *endptr; int nmask = -1; + enum match_type ret; if (str == NULL) return partly_match; @@ -1079,21 +1080,26 @@ cmd_ipv6_prefix_match (const char *str) prefix = strtok_r(dupe, delim, &context); mask = strtok_r(NULL, delim, &context); + ret = exact_match; if (!mask) - return partly_match; - - /* validate prefix */ - if (inet_pton(AF_INET6, prefix, &sin6_dummy.sin6_addr) != 1) - return no_match; - - /* validate mask */ - nmask = strtol (mask, &endptr, 10); - if (*endptr != '\0' || nmask < 0 || nmask > 128) - return no_match; + ret = partly_match; + else + { + /* validate prefix */ + if (inet_pton(AF_INET6, prefix, &sin6_dummy.sin6_addr) != 1) + ret = no_match; + else + { + /* validate mask */ + nmask = strtol (mask, &endptr, 10); + if (*endptr != '\0' || nmask < 0 || nmask > 128) + ret = no_match; + } + } XFREE(MTYPE_TMP, dupe); - return exact_match; + return ret; } #endif /* HAVE_IPV6 */ From 5ee62c66a95b9358275e8c883aed5c68b644dcca Mon Sep 17 00:00:00 2001 From: "G. Paul Ziemba" Date: Fri, 4 Nov 2016 09:47:36 -0700 Subject: [PATCH 032/107] BGP: deal with vnc related string ambiguities (issue #9) - "redist foo" parsing modified to check for foo==vnc and foo==vnc-direct instead of just leading 'v' character - string designating ZEBRA_ROUTE_VNC_DIRECT changed from "vpn" to "vnc-direct" - route_types.pl parser recognizes 7th field to restrict availability of a route type in the redist command to specific daemons - restrict "vnc-direct" to bgpd only (doesn't make sense elsewhere) - vnc documentation updated to match Signed-off-by: Lou Berger --- doc/vnc.texi | 4 ++-- lib/log.c | 12 ++++++------ lib/route_types.pl | 5 ++++- lib/route_types.txt | 8 ++++---- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/doc/vnc.texi b/doc/vnc.texi index 341cbfcce8..b0d2829cae 100644 --- a/doc/vnc.texi +++ b/doc/vnc.texi @@ -726,7 +726,7 @@ provided to other protocols, either via zebra or directly to BGP. It is important to note that when exporting routes to other protocols, the downstream protocol must also be configured to import the routes. For example, when VNC routes are exported to unicast BGP, the BGP -configuration must include a corresponding @code{redistribute vpn} +configuration must include a corresponding @code{redistribute vnc-direct} statement. @deffn {VNC} {export bgp|zebra mode none|group-nve|registering-nve|ce} @@ -1115,7 +1115,7 @@ The configuration for @code{VNC-GW 1} is shown below. router bgp 64512 bgp router-id 192.168.1.101 bgp cluster-id 1.2.3.4 - redistribute vpn + redistribute vnc-direct neighbor 192.168.1.102 remote-as 64512 no neighbor 192.168.1.102 activate neighbor 192.168.1.103 remote-as 64512 diff --git a/lib/log.c b/lib/log.c index f9877300b4..a0902b5d0d 100644 --- a/lib/log.c +++ b/lib/log.c @@ -1077,10 +1077,10 @@ proto_redistnum(int afi, const char *s) return ZEBRA_ROUTE_BGP; else if (strncmp (s, "ta", 2) == 0) return ZEBRA_ROUTE_TABLE; - else if (strncmp (s, "v", 1) == 0) - return ZEBRA_ROUTE_VNC; - else if (strncmp (s, "vd", 1) == 0) + else if (strcmp (s, "vnc-direct") == 0) return ZEBRA_ROUTE_VNC_DIRECT; + else if (strcmp (s, "vnc") == 0) + return ZEBRA_ROUTE_VNC; } if (afi == AFI_IP6) { @@ -1100,10 +1100,10 @@ proto_redistnum(int afi, const char *s) return ZEBRA_ROUTE_BGP; else if (strncmp (s, "ta", 2) == 0) return ZEBRA_ROUTE_TABLE; - else if (strncmp (s, "v", 1) == 0) - return ZEBRA_ROUTE_VNC; - else if (strncmp (s, "vd", 1) == 0) + else if (strcmp (s, "vnc-direct") == 0) return ZEBRA_ROUTE_VNC_DIRECT; + else if (strcmp (s, "vnc") == 0) + return ZEBRA_ROUTE_VNC; } return -1; } diff --git a/lib/route_types.pl b/lib/route_types.pl index d44cb12b23..7e99fdde09 100755 --- a/lib/route_types.pl +++ b/lib/route_types.pl @@ -56,7 +56,7 @@ while () { # else: 7-field line my @f = split(/,/, $_); - unless (@f == 7) { + unless (@f == 7 || @f == 8) { die "invalid input on route_types line $.\n"; } @@ -73,6 +73,7 @@ while () { "ipv4" => int($f[4]), "ipv6" => int($f[5]), "shorthelp" => $f[6], + "restrict2" => $f[7], }; push @protos, $proto; $daemons{$f[2]} = { @@ -137,6 +138,8 @@ sub collect { my (@names, @help) = ((), ()); for my $p (@protos) { next if ($protodetail{$p}->{"daemon"} eq $daemon && $daemon ne "zebra"); + next if ($protodetail{$p}->{"restrict2"} ne "" && + $protodetail{$p}->{"restrict2"} ne $daemon); next unless (($ipv4 && $protodetail{$p}->{"ipv4"}) || ($ipv6 && $protodetail{$p}->{"ipv6"})); push @names, $protodetail{$p}->{"cname"}; diff --git a/lib/route_types.txt b/lib/route_types.txt index 54572450b5..154f03f01c 100644 --- a/lib/route_types.txt +++ b/lib/route_types.txt @@ -64,9 +64,9 @@ ZEBRA_ROUTE_LDP, ldp, ldpd, 'L', 0, 0, "LDP" #vnc when sent to zebra ZEBRA_ROUTE_VNC, vnc, NULL, 'v', 1, 1, "VNC" # vnc when sent to bgp -ZEBRA_ROUTE_VNC_DIRECT, vpn, NULL, 'V', 1, 1, "VPN" -# vnc when sent to bgp (remote next hop?) -ZEBRA_ROUTE_VNC_DIRECT_RH, vpn-rh, NULL, 'V', 0, 0, "VPN" +ZEBRA_ROUTE_VNC_DIRECT, vnc-direct,NULL, 'V', 1, 1, "VNC-Direct", bgpd +# vnc when sent to bgp (resolve NVE mode) +ZEBRA_ROUTE_VNC_DIRECT_RH, vnc-rn, NULL, 'V', 0, 0, "VNC-RN" # bgp unicast -> vnc ZEBRA_ROUTE_BGP_DIRECT, bgp-direct, NULL, 'b', 0, 0, "BGP-Direct" # bgp unicast -> vnc @@ -90,4 +90,4 @@ ZEBRA_ROUTE_VNC, "Virtual Network Control (VNC)" ZEBRA_ROUTE_OLSR, "Optimised Link State Routing (OLSR)" ZEBRA_ROUTE_TABLE, "Non-main Kernel Routing Table" ZEBRA_ROUTE_LDP, "Label Distribution Protocol (LDP)" -ZEBRA_ROUTE_VNC_DIRECT, "VPN routes(VPN)" +ZEBRA_ROUTE_VNC_DIRECT, "VNC direct (not via zebra) routes" From ccbb332a37bad94fe0418de1b0115b79a4171c5b Mon Sep 17 00:00:00 2001 From: Lou Berger Date: Sun, 18 Dec 2016 13:45:20 -0500 Subject: [PATCH 033/107] bgp: first pass at restoring missing vpn&encap show commands (issue#14) Signed-off-by: Lou Berger --- bgpd/bgp_route.c | 314 ++++++++++++++++++++++++----------------------- bgpd/bgp_vty.c | 154 +++++++++-------------- bgpd/bgp_vty.h | 10 ++ 3 files changed, 229 insertions(+), 249 deletions(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index f645da3f2a..e4e321ad05 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -4479,7 +4479,6 @@ bgp_config_write_table_map (struct vty *vty, struct bgp *bgp, afi_t afi, return 0; } - DEFUN (bgp_table_map, bgp_table_map_cmd, "table-map WORD", @@ -8167,12 +8166,10 @@ DEFUN (show_ip_bgp_ipv4, "JavaScript Object Notation\n") { u_char uj = use_json(argc, argv); - - if (strncmp (argv[0], "m", 1) == 0) - return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_normal, - NULL, uj); - return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, bgp_show_type_normal, NULL, uj); + return bgp_show (vty, NULL, AFI_IP, + bgp_vty_safi_from_arg(argv[0]), + bgp_show_type_normal, NULL, uj); } ALIAS (show_ip_bgp_ipv4, @@ -8218,12 +8215,10 @@ DEFUN (show_ip_bgp_route_pathtype, DEFUN (show_bgp_ipv4_safi_route_pathtype, show_bgp_ipv4_safi_route_pathtype_cmd, - "show bgp ipv4 (unicast|multicast) A.B.C.D (bestpath|multipath) {json}", + "show bgp ipv4 (unicast|multicast|vpn|encap) A.B.C.D (bestpath|multipath) {json}", SHOW_STR BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + AFI_SAFI_STR "IP prefix /, e.g., 35.0.0.0/8\n" "Display only the bestpath\n" "Display only multipaths\n" @@ -8231,16 +8226,14 @@ DEFUN (show_bgp_ipv4_safi_route_pathtype, { u_char uj = use_json(argc, argv); - if (strncmp (argv[0], "m", 1) == 0) - if (strncmp (argv[2], "b", 1) == 0) - return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_BESTPATH, uj); - else - return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); + if (strncmp (argv[2], "b", 1) == 0) + return bgp_show_route (vty, NULL, argv[1], AFI_IP, + bgp_vty_safi_from_arg(argv[0]), + NULL, 0, BGP_PATH_BESTPATH, uj); else - if (strncmp (argv[2], "b", 1) == 0) - return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH, uj); - else - return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); + return bgp_show_route (vty, NULL, argv[1], AFI_IP, + bgp_vty_safi_from_arg(argv[0]), + NULL, 0, BGP_PATH_MULTIPATH, uj); } DEFUN (show_bgp_ipv4_prefix, @@ -8281,32 +8274,27 @@ DEFUN (show_bgp_ipv6_prefix, DEFUN (show_ip_bgp_ipv4_route, show_ip_bgp_ipv4_route_cmd, - "show ip bgp ipv4 (unicast|multicast) A.B.C.D {json}", + "show ip bgp ipv4 (unicast|multicast|vpn|encap) A.B.C.D {json}", SHOW_STR IP_STR BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + AFI_SAFI_STR "Network in the BGP routing table to display\n" "JavaScript Object Notation\n") { u_char uj = use_json(argc, argv); - if (strncmp (argv[0], "m", 1) == 0) - return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 0, BGP_PATH_ALL, uj); - - return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, uj); + return bgp_show_route (vty, NULL, argv[1], AFI_IP, + bgp_vty_safi_from_arg(argv[0]), + NULL, 0, BGP_PATH_ALL, uj); } ALIAS (show_ip_bgp_ipv4_route, show_bgp_ipv4_safi_route_cmd, - "show bgp ipv4 (unicast|multicast) A.B.C.D {json}", + "show bgp ipv4 (unicast|multicast|vpn|encap) A.B.C.D {json}", SHOW_STR BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + AFI_SAFI_STR "Network in the BGP routing table to display\n" "JavaScript Object Notation\n") @@ -8324,78 +8312,123 @@ DEFUN (show_ip_bgp_vpnv4_all_route, return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); } -DEFUN (show_bgp_ipv4_vpn_route, - show_bgp_ipv4_vpn_route_cmd, - "show bgp ipv4 vpn A.B.C.D {json}", +DEFUN (show_bgp_ipv4_safi_rd_route, + show_bgp_ipv4_safi_rd_route_cmd, + "show bgp ipv4 (encap|vpn) rd ASN:nn_or_IP-address:nn A.B.C.D {json}", SHOW_STR BGP_STR "Address Family\n" - "Display VPN NLRI specific information\n" - "Network in the BGP routing table to display\n" - JSON_STR) -{ - return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0, BGP_PATH_ALL, use_json (argc, argv)); -} - -DEFUN (show_bgp_ipv6_vpn_route, - show_bgp_ipv6_vpn_route_cmd, - "show bgp ipv6 vpn X:X::X:X {json}", - SHOW_STR - BGP_STR - "Address Family\n" - "Display VPN NLRI specific information\n" - "Network in the BGP routing table to display\n" - JSON_STR) -{ - return bgp_show_route (vty, NULL, argv[0], AFI_IP6, SAFI_MPLS_VPN, NULL, 0, BGP_PATH_ALL, use_json (argc, argv)); -} - -DEFUN (show_bgp_ipv4_vpn_rd_route, - show_bgp_ipv4_vpn_rd_route_cmd, - "show bgp ipv4 vpn rd ASN:nn_or_IP-address:nn A.B.C.D {json}", - SHOW_STR - BGP_STR - IP_STR - "Display VPN NLRI specific information\n" + "Address Family Modifier\n" + "Address Family Modifier\n" "Display information for a route distinguisher\n" - "VPN Route Distinguisher\n" - "Network in the BGP routing table to display\n" - JSON_STR) + "ENCAP Route Distinguisher\n" + "Network in the BGP routing table to display\n") { int ret; struct prefix_rd prd; + safi_t safi; - ret = str2prefix_rd (argv[0], &prd); + if (bgp_parse_safi(argv[0], &safi)) { + vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); + return CMD_WARNING; + } + ret = str2prefix_rd (argv[1], &prd); if (! ret) { vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); return CMD_WARNING; } - return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL, use_json (argc, argv)); + return bgp_show_route (vty, NULL, argv[2], AFI_IP, safi, &prd, 0, BGP_PATH_ALL, use_json (argc, argv)); } -DEFUN (show_bgp_ipv6_vpn_rd_route, - show_bgp_ipv6_vpn_rd_route_cmd, - "show bgp ipv6 vpn rd ASN:nn_or_IP-address:nn X:X::X:X {json}", +DEFUN (show_bgp_ipv6_safi_rd_route, + show_bgp_ipv6_safi_rd_route_cmd, + "show bgp ipv6 (encap|vpn) rd ASN:nn_or_IP-address:nn X:X::X:X {json}", SHOW_STR BGP_STR "Address Family\n" - "Display VPN NLRI specific information\n" + "Address Family Modifier\n" + "Address Family Modifier\n" "Display information for a route distinguisher\n" - "VPN Route Distinguisher\n" - "Network in the BGP routing table to display\n" - JSON_STR) + "ENCAP Route Distinguisher\n" + "Network in the BGP routing table to display\n") { int ret; struct prefix_rd prd; + safi_t safi; - ret = str2prefix_rd (argv[0], &prd); + if (bgp_parse_safi(argv[0], &safi)) { + vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); + return CMD_WARNING; + } + ret = str2prefix_rd (argv[1], &prd); if (! ret) { vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); return CMD_WARNING; } - return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL, use_json (argc, argv)); + return bgp_show_route (vty, NULL, argv[2], AFI_IP6, SAFI_ENCAP, &prd, 0, BGP_PATH_ALL, use_json (argc, argv)); +} + + +DEFUN (show_bgp_ipv4_safi_rd_prefix, + show_bgp_ipv4_safi_rd_prefix_cmd, + "show bgp ipv4 (encap|vpn) rd ASN:nn_or_IP-address:nn A.B.C.D/M {json}", + SHOW_STR + BGP_STR + "Address Family\n" + "Address Family Modifier\n" + "Address Family Modifier\n" + "Display information for a route distinguisher\n" + "ENCAP Route Distinguisher\n" + "IP prefix /, e.g., 35.0.0.0/8\n") +{ + int ret; + struct prefix_rd prd; + safi_t safi; + + if (bgp_parse_safi(argv[0], &safi)) { + vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); + return CMD_WARNING; + } + + ret = str2prefix_rd (argv[1], &prd); + if (! ret) + { + vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); + return CMD_WARNING; + } + return bgp_show_route (vty, NULL, argv[2], AFI_IP, safi, &prd, 1, BGP_PATH_ALL, use_json (argc, argv)); +} + +DEFUN (show_bgp_ipv6_safi_rd_prefix, + show_bgp_ipv6_safi_rd_prefix_cmd, + "show bgp ipv6 (encap|vpn) rd ASN:nn_or_IP-address:nn X:X::X:X/M {json}", + SHOW_STR + BGP_STR + "Address Family\n" + "Address Family Modifier\n" + "Address Family Modifier\n" + "Display information for a route distinguisher\n" + "ENCAP Route Distinguisher\n" + "IP prefix /, e.g., 35.0.0.0/8\n") +{ + int ret; + struct prefix_rd prd; + safi_t safi; + + if (bgp_parse_safi(argv[0], &safi)) { + vty_out (vty, "Error: Bad SAFI: %s%s", argv[0], VTY_NEWLINE); + return CMD_WARNING; + } + + ret = str2prefix_rd (argv[1], &prd); + if (! ret) + { + vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); + return CMD_WARNING; + } + return bgp_show_route (vty, NULL, argv[2], AFI_IP6, safi, &prd, 1, BGP_PATH_ALL, use_json (argc, argv)); } DEFUN (show_ip_bgp_vpnv4_rd_route, @@ -8455,44 +8488,37 @@ DEFUN (show_ip_bgp_prefix_pathtype, DEFUN (show_ip_bgp_ipv4_prefix, show_ip_bgp_ipv4_prefix_cmd, - "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M {json}", + "show ip bgp ipv4 (unicast|multicast|vpn|encap) A.B.C.D/M {json}", SHOW_STR IP_STR BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + AFI_SAFI_STR "IP prefix /, e.g., 35.0.0.0/8\n" "JavaScript Object Notation\n") { u_char uj = use_json(argc, argv); - if (strncmp (argv[0], "m", 1) == 0) - return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_ALL, uj); - - return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, uj); + return bgp_show_route (vty, NULL, argv[1], AFI_IP, + bgp_vty_safi_from_arg(argv[0]), + NULL, 1, BGP_PATH_ALL, uj); } ALIAS (show_ip_bgp_ipv4_prefix, show_bgp_ipv4_safi_prefix_cmd, - "show bgp ipv4 (unicast|multicast) A.B.C.D/M {json}", + "show bgp ipv4 (unicast|multicast|vpn|encap) A.B.C.D/M {json}", SHOW_STR BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + AFI_SAFI_STR "IP prefix /, e.g., 35.0.0.0/8\n" "JavaScript Object Notation\n") DEFUN (show_ip_bgp_ipv4_prefix_pathtype, show_ip_bgp_ipv4_prefix_pathtype_cmd, - "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M (bestpath|multipath) {json}", + "show ip bgp ipv4 (unicast|multicast|vpn|encap) A.B.C.D/M (bestpath|multipath) {json}", SHOW_STR IP_STR BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + AFI_SAFI_STR "IP prefix /, e.g., 35.0.0.0/8\n" "Display only the bestpath\n" "Display only multipaths\n" @@ -8500,26 +8526,22 @@ DEFUN (show_ip_bgp_ipv4_prefix_pathtype, { u_char uj = use_json(argc, argv); - if (strncmp (argv[0], "m", 1) == 0) - if (strncmp (argv[2], "b", 1) == 0) - return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_BESTPATH, uj); - else - return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); + if (strncmp (argv[2], "b", 1) == 0) + return bgp_show_route (vty, NULL, argv[1], AFI_IP, + bgp_vty_safi_from_arg(argv[0]), + NULL, 1, BGP_PATH_BESTPATH, uj); else - if (strncmp (argv[2], "b", 1) == 0) - return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH, uj); - else - return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); + return bgp_show_route (vty, NULL, argv[1], AFI_IP, + bgp_vty_safi_from_arg(argv[0]), + NULL, 1, BGP_PATH_MULTIPATH, uj); } ALIAS (show_ip_bgp_ipv4_prefix_pathtype, show_bgp_ipv4_safi_prefix_pathtype_cmd, - "show bgp ipv4 (unicast|multicast) A.B.C.D/M (bestpath|multipath) {json}", + "show bgp ipv4 (unicast|multicast|vpn|encap) A.B.C.D/M (bestpath|multipath) {json}", SHOW_STR BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + AFI_SAFI_STR "IP prefix /, e.g., 35.0.0.0/8\n" "Display only the bestpath\n" "Display only multipaths\n" @@ -8693,14 +8715,14 @@ DEFUN (show_bgp_ipv6_safi, "Address family\n" "Address Family modifier\n" "Address Family modifier\n" + AFI_SAFI_STR "JavaScript Object Notation\n") { u_char uj = use_json(argc, argv); - if (strncmp (argv[0], "m", 1) == 0) - return bgp_show (vty, NULL, AFI_IP6, SAFI_MULTICAST, bgp_show_type_normal, - NULL, uj); - return bgp_show (vty, NULL, AFI_IP6, SAFI_UNICAST, bgp_show_type_normal, NULL, uj); + return bgp_show (vty, NULL, AFI_IP6, + bgp_vty_safi_from_arg(argv[0]), + bgp_show_type_normal, NULL, uj); } static void @@ -8738,20 +8760,18 @@ DEFUN (show_bgp_route, DEFUN (show_bgp_ipv6_safi_route, show_bgp_ipv6_safi_route_cmd, - "show bgp ipv6 (unicast|multicast) X:X::X:X {json}", + "show bgp ipv6 (unicast|multicast|vpn|encap) X:X::X:X {json}", SHOW_STR BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + AFI_SAFI_STR "Network in the BGP routing table to display\n" "JavaScript Object Notation\n") { u_char uj = use_json(argc, argv); - if (strncmp (argv[0], "m", 1) == 0) - return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_ALL, uj); - return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_ALL, uj); + return bgp_show_route (vty, NULL, argv[1], AFI_IP6, + bgp_vty_safi_from_arg(argv[0]), + NULL, 0, BGP_PATH_ALL, uj); } DEFUN (show_bgp_route_pathtype, @@ -8784,28 +8804,24 @@ ALIAS (show_bgp_route_pathtype, DEFUN (show_bgp_ipv6_safi_route_pathtype, show_bgp_ipv6_safi_route_pathtype_cmd, - "show bgp ipv6 (unicast|multicast) X:X::X:X (bestpath|multipath) {json}", + "show bgp ipv6 (unicast|multicast|vpn|encap) X:X::X:X (bestpath|multipath) {json}", SHOW_STR BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + AFI_SAFI_STR "Network in the BGP routing table to display\n" "Display only the bestpath\n" "Display only multipaths\n" "JavaScript Object Notation\n") { u_char uj = use_json(argc, argv); - if (strncmp (argv[0], "m", 1) == 0) - if (strncmp (argv[2], "b", 1) == 0) - return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_BESTPATH, uj); - else - return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); + if (strncmp (argv[2], "b", 1) == 0) + return bgp_show_route (vty, NULL, argv[1], AFI_IP6, + bgp_vty_safi_from_arg(argv[0]), + NULL, 0, BGP_PATH_BESTPATH, uj); else - if (strncmp (argv[2], "b", 1) == 0) - return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_BESTPATH, uj); - else - return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 0, BGP_PATH_MULTIPATH, uj); + return bgp_show_route (vty, NULL, argv[1], AFI_IP6, + bgp_vty_safi_from_arg(argv[0]), + NULL, 0, BGP_PATH_MULTIPATH, uj); } /* old command */ @@ -8835,20 +8851,18 @@ DEFUN (show_bgp_prefix, DEFUN (show_bgp_ipv6_safi_prefix, show_bgp_ipv6_safi_prefix_cmd, - "show bgp ipv6 (unicast|multicast) X:X::X:X/M {json}", + "show bgp ipv6 (unicast|multicast|vpn|encap) X:X::X:X/M {json}", SHOW_STR BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + AFI_SAFI_STR "IPv6 prefix /, e.g., 3ffe::/16\n" "JavaScript Object Notation\n") { u_char uj = use_json(argc, argv); - if (strncmp (argv[0], "m", 1) == 0) - return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_ALL, uj); - return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_ALL, uj); + return bgp_show_route (vty, NULL, argv[1], AFI_IP6, + bgp_vty_safi_from_arg(argv[0]), + NULL, 1, BGP_PATH_ALL, uj); } DEFUN (show_bgp_prefix_pathtype, @@ -8881,28 +8895,23 @@ ALIAS (show_bgp_prefix_pathtype, DEFUN (show_bgp_ipv6_safi_prefix_pathtype, show_bgp_ipv6_safi_prefix_pathtype_cmd, - "show bgp ipv6 (unicast|multicast) X:X::X:X/M (bestpath|multipath) {json}", + "show bgp ipv6 (unicast|multicast|vpn|encap) X:X::X:X/M (bestpath|multipath) {json}", SHOW_STR BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + AFI_SAFI_STR "IPv6 prefix /, e.g., 3ffe::/16\n" "Display only the bestpath\n" "Display only multipaths\n" "JavaScript Object Notation\n") { u_char uj = use_json(argc, argv); - if (strncmp (argv[0], "m", 1) == 0) - if (strncmp (argv[2], "b", 1) == 0) - return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_BESTPATH, uj); - else - return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); + if (strncmp (argv[2], "b", 1) == 0) + return bgp_show_route (vty, NULL, argv[1], AFI_IP6, + bgp_vty_safi_from_arg(argv[0]), + NULL, 1, BGP_PATH_BESTPATH, uj); else - if (strncmp (argv[2], "b", 1) == 0) - return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_BESTPATH, uj); - else - return bgp_show_route (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL, 1, BGP_PATH_MULTIPATH, uj); + return bgp_show_route (vty, NULL, argv[1], AFI_IP6, + bgp_vty_safi_from_arg(argv[0]), NULL, 1, BGP_PATH_MULTIPATH, uj); } /* old command */ @@ -14983,11 +14992,10 @@ bgp_route_init (void) install_element (VIEW_NODE, &show_ip_bgp_neighbor_damp_cmd); install_element (VIEW_NODE, &show_bgp_ipv4_prefix_cmd); - install_element (VIEW_NODE, &show_bgp_ipv4_vpn_rd_route_cmd); - install_element (VIEW_NODE, &show_bgp_ipv4_vpn_route_cmd); - - install_element (VIEW_NODE, &show_bgp_ipv6_vpn_rd_route_cmd); - install_element (VIEW_NODE, &show_bgp_ipv6_vpn_route_cmd); + install_element (VIEW_NODE, &show_bgp_ipv4_safi_rd_route_cmd); + install_element (VIEW_NODE, &show_bgp_ipv6_safi_rd_route_cmd); + install_element (VIEW_NODE, &show_bgp_ipv4_safi_rd_prefix_cmd); + install_element (VIEW_NODE, &show_bgp_ipv6_safi_rd_prefix_cmd); /* BGP dampening clear commands */ install_element (ENABLE_NODE, &clear_ip_bgp_dampening_cmd); diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index b0d96150a8..99d78f38b8 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -123,25 +123,29 @@ bgp_parse_afi(const char *str, afi_t *afi) return -1; } +/* supports (unicast|multicast|vpn|encap) */ +safi_t +bgp_vty_safi_from_arg(const char *safi_str) +{ + safi_t safi = SAFI_MAX; /* unknown */ + if (strncmp (safi_str, "m", 1) == 0) + safi = SAFI_MULTICAST; + else if (strncmp (safi_str, "u", 1) == 0) + safi = SAFI_UNICAST; + else if (strncmp (safi_str, "e", 1) == 0) + safi = SAFI_ENCAP; + else if (strncmp (safi_str, "v", 1) == 0) + safi = SAFI_MPLS_VPN; + return safi; +} + int bgp_parse_safi(const char *str, safi_t *safi) { - if (!strcmp(str, "encap")) { - *safi = SAFI_ENCAP; - return 0; - } - if (!strcmp(str, "multicast")) { - *safi = SAFI_MULTICAST; - return 0; - } - if (!strcmp(str, "unicast")) { - *safi = SAFI_UNICAST; - return 0; - } - if (!strcmp(str, "vpn")) { - *safi = SAFI_MPLS_VPN; - return 0; - } + *safi = bgp_vty_safi_from_arg(str); + if (*safi != SAFI_MAX) + return 0; + else return -1; } @@ -6050,14 +6054,24 @@ DEFUN (address_family_ipv4_safi, address_family_ipv4_safi_cmd, "address-family ipv4 (unicast|multicast)", "Enter Address Family command mode\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n") + AFI_SAFI_STR) { - if (strncmp (argv[0], "m", 1) == 0) - vty->node = BGP_IPV4M_NODE; - else - vty->node = BGP_IPV4_NODE; + switch (bgp_vty_safi_from_arg(argv[0])) + { + case SAFI_MULTICAST: + vty->node = BGP_IPV4M_NODE; + break; + case SAFI_ENCAP: + vty->node = BGP_ENCAP_NODE; + break; + case SAFI_MPLS_VPN: + vty->node = BGP_VPNV4_NODE; + break; + case SAFI_UNICAST: + default: + vty->node = BGP_IPV4_NODE; + break; + } return CMD_SUCCESS; } @@ -10755,60 +10769,27 @@ DEFUN (show_ip_bgp_instance_all_summary, DEFUN (show_ip_bgp_ipv4_summary, show_ip_bgp_ipv4_summary_cmd, - "show ip bgp ipv4 (unicast|multicast) summary {json}", + "show ip bgp ipv4 (unicast|multicast|vpn|encap) summary {json}", SHOW_STR IP_STR BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + AFI_SAFI_STR "Summary of BGP neighbor status\n" "JavaScript Object Notation\n") { u_char uj = use_json(argc, argv); - if (strncmp (argv[0], "m", 1) == 0) - return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, uj); - return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST, uj); + return bgp_show_summary_vty (vty, NULL, AFI_IP, bgp_vty_safi_from_arg(argv[0]), uj); } ALIAS (show_ip_bgp_ipv4_summary, show_bgp_ipv4_safi_summary_cmd, - "show bgp ipv4 (unicast|multicast) summary {json}", + "show bgp ipv4 (unicast|multicast|vpn|encap) summary {json}", SHOW_STR BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + AFI_SAFI_STR "Summary of BGP neighbor status\n") -DEFUN (show_bgp_ipv4_vpn_summary, - show_bgp_ipv4_vpn_summary_cmd, - "show bgp ipv4 vpn summary {json}", - SHOW_STR - BGP_STR - "IPv4\n" - "Display VPN NLRI specific information\n" - "Summary of BGP neighbor status\n" - JSON_STR) -{ - return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, use_json (argc, argv)); -} - -/* `show ip bgp summary' commands. */ -DEFUN (show_bgp_ipv6_vpn_summary, - show_bgp_ipv6_vpn_summary_cmd, - "show bgp ipv6 vpn summary {json}", - SHOW_STR - BGP_STR - "IPv6\n" - "Display VPN NLRI specific information\n" - "Summary of BGP neighbor status\n" - JSON_STR) -{ - return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_MPLS_VPN, use_json (argc, argv)); -} - DEFUN (show_ip_bgp_instance_ipv4_summary, show_ip_bgp_instance_ipv4_summary_cmd, "show ip bgp view WORD ipv4 (unicast|multicast) summary {json}", @@ -10837,9 +10818,7 @@ ALIAS (show_ip_bgp_instance_ipv4_summary, BGP_STR "BGP view\n" "View name\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + AFI_SAFI_STR "Summary of BGP neighbor status\n") DEFUN (show_ip_bgp_vpnv4_all_summary, @@ -10941,20 +10920,16 @@ ALIAS (show_bgp_instance_summary, DEFUN (show_bgp_ipv6_safi_summary, show_bgp_ipv6_safi_summary_cmd, - "show bgp ipv6 (unicast|multicast) summary {json}", + "show bgp ipv6 (unicast|multicast|vpn|encap) summary {json}", SHOW_STR BGP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + AFI_SAFI_STR "Summary of BGP neighbor status\n" "JavaScript Object Notation\n") { u_char uj = use_json(argc, argv); - if (strncmp (argv[0], "m", 1) == 0) - return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_MULTICAST, uj); - return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, uj); + return bgp_show_summary_vty (vty, NULL, AFI_IP6, bgp_vty_safi_from_arg(argv[0]), uj); } DEFUN (show_bgp_instance_ipv6_safi_summary, @@ -10963,9 +10938,7 @@ DEFUN (show_bgp_instance_ipv6_safi_summary, SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + AFI_SAFI_STR "Summary of BGP neighbor status\n" "JavaScript Object Notation\n") { @@ -13249,7 +13222,7 @@ DEFUN (show_bgp_instance_all_ipv6_updgrps, DEFUN (show_bgp_updgrps, show_bgp_updgrps_cmd, - "show bgp (ipv4|ipv6) (unicast|multicast) update-groups", + "show bgp (ipv4|ipv6) (unicast|multicast|vpn|encap) update-groups", SHOW_STR BGP_STR "Address family\n" @@ -13262,7 +13235,7 @@ DEFUN (show_bgp_updgrps, safi_t safi; afi = (strcmp(argv[0], "ipv4") == 0) ? AFI_IP : AFI_IP6; - safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; + safi = bgp_vty_safi_from_arg(argv[1]); return (bgp_show_update_groups(vty, NULL, afi, safi, 0)); } @@ -13327,13 +13300,11 @@ DEFUN (show_bgp_instance_ipv6_updgrps_s, DEFUN (show_bgp_updgrps_s, show_bgp_updgrps_s_cmd, - "show bgp (ipv4|ipv6) (unicast|multicast) update-groups SUBGROUP-ID", + "show bgp (ipv4|ipv6) (unicast|multicast|vpn|encap) update-groups SUBGROUP-ID", SHOW_STR BGP_STR "Address family\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + AFI_SAFI_STR "Detailed info about v6 dynamic update groups\n" "Specific subgroup to display detailed info for") { @@ -13342,8 +13313,7 @@ DEFUN (show_bgp_updgrps_s, uint64_t subgrp_id; afi = (strcmp(argv[0], "ipv4") == 0) ? AFI_IP : AFI_IP6; - safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; - + safi = bgp_vty_safi_from_arg(argv[1]); VTY_GET_ULL("subgroup-id", subgrp_id, argv[2]); return(bgp_show_update_groups(vty, NULL, afi, safi, subgrp_id)); } @@ -13441,13 +13411,11 @@ DEFUN (show_ip_bgp_instance_updgrps_adj, DEFUN (show_bgp_updgrps_afi_adj, show_bgp_updgrps_afi_adj_cmd, - "show bgp (ipv4|ipv6) (unicast|multicast) update-groups (advertise-queue|advertised-routes|packet-queue)", + "show bgp (ipv4|ipv6) (unicast|multicast|vpn|encap) update-groups (advertise-queue|advertised-routes|packet-queue)", SHOW_STR BGP_STR "Address family\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + AFI_SAFI_STR "BGP update groups\n" "Advertisement queue\n" "Announced routes\n" @@ -13458,7 +13426,7 @@ DEFUN (show_bgp_updgrps_afi_adj, safi_t safi; afi = (strcmp(argv[0], "ipv4") == 0) ? AFI_IP : AFI_IP6; - safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; + safi = bgp_vty_safi_from_arg(argv[1]); show_bgp_updgrps_adj_info_aux(vty, NULL, afi, safi, argv[2], 0); return CMD_SUCCESS; } @@ -13537,13 +13505,11 @@ DEFUN (show_ip_bgp_instance_updgrps_adj_s, DEFUN (show_bgp_updgrps_afi_adj_s, show_bgp_updgrps_afi_adj_s_cmd, - "show bgp (ipv4|ipv6) (unicast|multicast) update-groups SUBGROUP-ID (advertise-queue|advertised-routes|packet-queue)", + "show bgp (ipv4|ipv6) (unicast|multicast|vpn|encap) update-groups SUBGROUP-ID (advertise-queue|advertised-routes|packet-queue)", SHOW_STR BGP_STR "Address family\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + AFI_SAFI_STR "BGP update groups\n" "Specific subgroup to display info for\n" "Advertisement queue\n" @@ -13556,7 +13522,7 @@ DEFUN (show_bgp_updgrps_afi_adj_s, uint64_t subgrp_id; afi = (strcmp(argv[0], "ipv4") == 0) ? AFI_IP : AFI_IP6; - safi = (strncmp (argv[1], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; + safi = bgp_vty_safi_from_arg(argv[1]); VTY_GET_ULL("subgroup-id", subgrp_id, argv[2]); show_bgp_updgrps_adj_info_aux(vty, NULL, afi, safi, argv[3], subgrp_id); @@ -16023,10 +15989,6 @@ bgp_vty_init (void) install_element (VIEW_NODE, &show_bgp_instance_ipv6_safi_summary_cmd); #endif /* HAVE_IPV6 */ - install_element (VIEW_NODE, &show_bgp_ipv4_vpn_summary_cmd); - - install_element (VIEW_NODE, &show_bgp_ipv6_vpn_summary_cmd); - /* "show ip bgp neighbors" commands. */ install_element (VIEW_NODE, &show_ip_bgp_neighbors_cmd); install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbors_cmd); diff --git a/bgpd/bgp_vty.h b/bgpd/bgp_vty.h index 573e8c7072..6b4e51bc50 100644 --- a/bgpd/bgp_vty.h +++ b/bgpd/bgp_vty.h @@ -30,6 +30,13 @@ struct bgp; #define BGP_INSTANCE_ALL_CMD "(view|vrf) all" #define BGP_INSTANCE_ALL_HELP_STR "BGP view\nBGP VRF\nAll Views/VRFs\n" +#define AFI_SAFI_STR \ + "Address family\n" \ + "Address Family modifier\n" \ + "Address Family modifier\n" \ + "Address Family modifier\n" \ + "Address Family modifier\n" + extern void bgp_vty_init (void); extern const char *afi_safi_print (afi_t, safi_t); extern int bgp_config_write_update_delay (struct vty *, struct bgp *); @@ -46,4 +53,7 @@ bgp_parse_afi(const char *str, afi_t *afi); extern int bgp_parse_safi(const char *str, safi_t *safi); +extern safi_t +bgp_vty_safi_from_arg(const char *safi_str); + #endif /* _QUAGGA_BGP_VTY_H */ From 7979998755ea7802041978ae1497528179e11abb Mon Sep 17 00:00:00 2001 From: Lou Berger Date: Fri, 4 Nov 2016 09:30:07 -0400 Subject: [PATCH 034/107] rfapi: pickup recent changes expose bgp_rfapi_get_group_by_lni_label for use by rfp add EVPN Ethernet Tag (VID) RT ensure as is init'ed fix spelling of information Signed-off-by: Lou Berger --- bgpd/rfapi/bgp_rfapi_cfg.c | 2 +- bgpd/rfapi/bgp_rfapi_cfg.h | 6 +++ bgpd/rfapi/rfapi.c | 28 ++++++++++++- bgpd/rfapi/rfapi.h | 1 + bgpd/rfapi/rfapi_import.c | 45 ++++++++++++++++++++ bgpd/rfapi/rfapi_import.h | 3 ++ bgpd/rfapi/rfapi_rib.c | 2 + bgpd/rfapi/rfapi_vty.c | 84 +++++++++++++++++++------------------- 8 files changed, 127 insertions(+), 44 deletions(-) diff --git a/bgpd/rfapi/bgp_rfapi_cfg.c b/bgpd/rfapi/bgp_rfapi_cfg.c index b27febbbeb..202abc61d1 100644 --- a/bgpd/rfapi/bgp_rfapi_cfg.c +++ b/bgpd/rfapi/bgp_rfapi_cfg.c @@ -3778,7 +3778,7 @@ static struct cmd_node bgp_vnc_l2_group_node = { 1 }; -static struct rfapi_l2_group_cfg * +struct rfapi_l2_group_cfg * bgp_rfapi_get_group_by_lni_label ( struct bgp *bgp, uint32_t logical_net_id, diff --git a/bgpd/rfapi/bgp_rfapi_cfg.h b/bgpd/rfapi/bgp_rfapi_cfg.h index 50ab3e27aa..897b4be764 100644 --- a/bgpd/rfapi/bgp_rfapi_cfg.h +++ b/bgpd/rfapi/bgp_rfapi_cfg.h @@ -300,6 +300,12 @@ bgp_rfapi_show_summary (struct bgp *bgp, struct vty *vty); extern struct rfapi_cfg * bgp_rfapi_get_config (struct bgp *bgp); +extern struct rfapi_l2_group_cfg * +bgp_rfapi_get_group_by_lni_label ( + struct bgp *bgp, + uint32_t logical_net_id, + uint32_t label); + extern struct ecommunity * bgp_rfapi_get_ecommunity_by_lni_label ( struct bgp *bgp, diff --git a/bgpd/rfapi/rfapi.c b/bgpd/rfapi/rfapi.c index 3e97b73538..5945eb09e6 100644 --- a/bgpd/rfapi/rfapi.c +++ b/bgpd/rfapi/rfapi.c @@ -2842,13 +2842,39 @@ rfapi_register ( * If mac address is set, add an RT based on the registered LNI */ memset ((char *) &ecom_value, 0, sizeof (ecom_value)); - ecom_value.val[1] = 0x02; + ecom_value.val[1] = ECOMMUNITY_ROUTE_TARGET; ecom_value.val[5] = (l2o->logical_net_id >> 16) & 0xff; ecom_value.val[6] = (l2o->logical_net_id >> 8) & 0xff; ecom_value.val[7] = (l2o->logical_net_id >> 0) & 0xff; rtlist = ecommunity_new(); ecommunity_add_val (rtlist, &ecom_value); } + if (l2o->tag_id) + { + as_t as = bgp->as; + uint16_t val = l2o->tag_id; + memset ((char *) &ecom_value, 0, sizeof (ecom_value)); + ecom_value.val[1] = ECOMMUNITY_ROUTE_TARGET; + if (as > BGP_AS_MAX) + { + ecom_value.val[0] = ECOMMUNITY_ENCODE_AS4; + ecom_value.val[2] = (as >>24) & 0xff; + ecom_value.val[3] = (as >>16) & 0xff; + ecom_value.val[4] = (as >>8) & 0xff; + ecom_value.val[5] = as & 0xff; + } + else + { + ecom_value.val[0] = ECOMMUNITY_ENCODE_AS; + ecom_value.val[2] = (as >>8) & 0xff; + ecom_value.val[3] = as & 0xff; + } + ecom_value.val[6] = (val >> 8) & 0xff; + ecom_value.val[7] = val & 0xff; + if (rtlist == NULL) + rtlist = ecommunity_new(); + ecommunity_add_val (rtlist, &ecom_value); + } } /* diff --git a/bgpd/rfapi/rfapi.h b/bgpd/rfapi/rfapi.h index 7d108432ae..420c6e0d71 100644 --- a/bgpd/rfapi/rfapi.h +++ b/bgpd/rfapi/rfapi.h @@ -89,6 +89,7 @@ struct rfapi_l2address_option uint32_t logical_net_id; /* ~= EVPN Ethernet Segment Id, must not be zero for mac regis. */ uint8_t local_nve_id; + uint16_t tag_id; /* EVPN Ethernet Tag ID, 0 = none */ }; typedef enum diff --git a/bgpd/rfapi/rfapi_import.c b/bgpd/rfapi/rfapi_import.c index 0b46702bb0..4c3274c2cf 100644 --- a/bgpd/rfapi/rfapi_import.c +++ b/bgpd/rfapi/rfapi_import.c @@ -1130,6 +1130,49 @@ rfapiEcommunityGetLNI (struct ecommunity *ecom, uint32_t * lni) return ENOENT; } +int +rfapiEcommunityGetEthernetTag (struct ecommunity *ecom, uint16_t * tag_id) +{ + struct bgp *bgp = bgp_get_default (); + *tag_id = 0; /* default to untagged */ + if (ecom) + { + int i; + for (i = 0; i < ecom->size; ++i) + { + as_t as = 0; + int encode = 0; + uint8_t *p = ecom->val + (i * ECOMMUNITY_SIZE); + + /* High-order octet of type. */ + encode = *p++; + + if (*p++ == ECOMMUNITY_ROUTE_TARGET) { + if (encode == ECOMMUNITY_ENCODE_AS4) + { + as = (*p++ << 24); + as |= (*p++ << 16); + as |= (*p++ << 8); + as |= (*p++); + } + else if (encode == ECOMMUNITY_ENCODE_AS) + { + as = (*p++ << 8); + as |= (*p++); + p += 2; /* skip next two, tag/vid always in lowest bytes */ + } + if (as == bgp->as) + { + *tag_id = *p++ << 8; + *tag_id |= (*p++); + return 0; + } + } + } + } + return ENOENT; +} + static int rfapiVpnBiNhEqualsPt (struct bgp_info *bi, struct rfapi_ip_addr *hpt) { @@ -1377,6 +1420,8 @@ rfapiRouteInfo2NextHopEntry ( { (void) rfapiEcommunityGetLNI (bi->attr->extra->ecommunity, &vo->v.l2addr.logical_net_id); + (void) rfapiEcommunityGetEthernetTag (bi->attr->extra->ecommunity, + &vo->v.l2addr.tag_id); } /* local_nve_id comes from lower byte of RD type */ diff --git a/bgpd/rfapi/rfapi_import.h b/bgpd/rfapi/rfapi_import.h index 3a1ae3573e..3cf55462a1 100644 --- a/bgpd/rfapi/rfapi_import.h +++ b/bgpd/rfapi/rfapi_import.h @@ -203,6 +203,9 @@ extern int rfapiEcommunityGetLNI ( struct ecommunity *ecom, uint32_t *lni); +extern int rfapiEcommunityGetEthernetTag ( + struct ecommunity *ecom, + uint16_t * tag_id); /* enable for debugging; disable for performance */ #if 0 diff --git a/bgpd/rfapi/rfapi_rib.c b/bgpd/rfapi/rfapi_rib.c index daedbeedef..6aae35e635 100644 --- a/bgpd/rfapi/rfapi_rib.c +++ b/bgpd/rfapi/rfapi_rib.c @@ -707,6 +707,8 @@ rfapiRibBi2Ri( { (void) rfapiEcommunityGetLNI (bi->attr->extra->ecommunity, &vo->v.l2addr.logical_net_id); + (void) rfapiEcommunityGetEthernetTag (bi->attr->extra->ecommunity, + &vo->v.l2addr.tag_id); } /* local_nve_id comes from RD */ diff --git a/bgpd/rfapi/rfapi_vty.c b/bgpd/rfapi/rfapi_vty.c index 9b12ad3f7e..fe9b8a3f50 100644 --- a/bgpd/rfapi/rfapi_vty.c +++ b/bgpd/rfapi/rfapi_vty.c @@ -2546,7 +2546,7 @@ DEFUN (add_vnc_prefix_cost_life_lnh, "add vnc prefix (A.B.C.D/M|X:X::X:X/M) vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) cost <0-255> lifetime <1-4294967295> .LNH_OPTIONS", "Add registration\n" "VNC Information\n" - "Add/modify prefix related infomation\n" + "Add/modify prefix related information\n" "IPv4 prefix\n" "IPv6 prefix\n" "VN address of NVE\n" @@ -2572,7 +2572,7 @@ DEFUN (add_vnc_prefix_life_cost_lnh, "add vnc prefix (A.B.C.D/M|X:X::X:X/M) vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) lifetime <1-4294967295> cost <0-255> .LNH_OPTIONS", "Add registration\n" "VNC Information\n" - "Add/modify prefix related infomation\n" + "Add/modify prefix related information\n" "IPv4 prefix\n" "IPv6 prefix\n" "VN address of NVE\n" @@ -2598,7 +2598,7 @@ DEFUN (add_vnc_prefix_cost_lnh, "add vnc prefix (A.B.C.D/M|X:X::X:X/M) vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) cost <0-255> .LNH_OPTIONS", "Add registration\n" "VNC Information\n" - "Add/modify prefix related infomation\n" + "Add/modify prefix related information\n" "IPv4 prefix\n" "IPv6 prefix\n" "VN address of NVE\n" @@ -2622,7 +2622,7 @@ DEFUN (add_vnc_prefix_life_lnh, "add vnc prefix (A.B.C.D/M|X:X::X:X/M) vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) lifetime <1-4294967295> .LNH_OPTIONS", "Add registration\n" "VNC Information\n" - "Add/modify prefix related infomation\n" + "Add/modify prefix related information\n" "IPv4 prefix\n" "IPv6 prefix\n" "VN address of NVE\n" @@ -2646,7 +2646,7 @@ DEFUN (add_vnc_prefix_lnh, "add vnc prefix (A.B.C.D/M|X:X::X:X/M) vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) .LNH_OPTIONS", "Add registration\n" "VNC Information\n" - "Add/modify prefix related infomation\n" + "Add/modify prefix related information\n" "IPv4 prefix\n" "IPv6 prefix\n" "VN address of NVE\n" @@ -2671,7 +2671,7 @@ DEFUN (add_vnc_prefix_cost_life, "add vnc prefix (A.B.C.D/M|X:X::X:X/M) vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) cost <0-255> lifetime <1-4294967295>", "Add registration\n" "VNC Information\n" - "Add/modify prefix related infomation\n" + "Add/modify prefix related information\n" "IPv4 prefix\n" "IPv6 prefix\n" "VN address of NVE\n" @@ -2697,7 +2697,7 @@ DEFUN (add_vnc_prefix_life_cost, "add vnc prefix (A.B.C.D/M|X:X::X:X/M) vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) lifetime <1-4294967295> cost <0-255>", "Add registration\n" "VNC Information\n" - "Add/modify prefix related infomation\n" + "Add/modify prefix related information\n" "IPv4 prefix\n" "IPv6 prefix\n" "VN address of NVE\n" @@ -2723,7 +2723,7 @@ DEFUN (add_vnc_prefix_cost, "add vnc prefix (A.B.C.D/M|X:X::X:X/M) vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) cost <0-255>", "Add registration\n" "VNC Information\n" - "Add/modify prefix related infomation\n" + "Add/modify prefix related information\n" "IPv4 prefix\n" "IPv6 prefix\n" "VN address of NVE\n" @@ -2747,7 +2747,7 @@ DEFUN (add_vnc_prefix_life, "add vnc prefix (A.B.C.D/M|X:X::X:X/M) vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) lifetime <1-4294967295>", "Add registration\n" "VNC Information\n" - "Add/modify prefix related infomation\n" + "Add/modify prefix related information\n" "IPv4 prefix\n" "IPv6 prefix\n" "VN address of NVE\n" @@ -2771,7 +2771,7 @@ DEFUN (add_vnc_prefix, "add vnc prefix (A.B.C.D/M|X:X::X:X/M) vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X)", "Add registration\n" "VNC Information\n" - "Add/modify prefix related infomation\n" + "Add/modify prefix related information\n" "IPv4 prefix\n" "IPv6 prefix\n" "VN address of NVE\n" @@ -2796,7 +2796,7 @@ DEFUN (add_vnc_mac_vni_prefix_cost_life, "add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier <1-4294967295> vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) prefix (A.B.C.D/M|X:X::X:X/M) cost <0-255> lifetime <1-4294967295>", "Add registration\n" "VNC Information\n" - "Add/modify mac address infomation\n" + "Add/modify mac address information\n" "MAC address\n" "Virtual Network Identifier follows\n" "Virtual Network Identifier\n" @@ -2806,7 +2806,7 @@ DEFUN (add_vnc_mac_vni_prefix_cost_life, "UN address of NVE\n" "UN IPv4 interface address\n" "UN IPv6 interface address\n" - "Add/modify prefix related infomation\n" + "Add/modify prefix related information\n" "IPv4 prefix\n" "IPv6 prefix\n" "Administrative cost [default: 255]\n" @@ -2826,7 +2826,7 @@ DEFUN (add_vnc_mac_vni_prefix_life, "add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier <1-4294967295> vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) prefix (A.B.C.D/M|X:X::X:X/M) lifetime <1-4294967295>", "Add registration\n" "VNC Information\n" - "Add/modify mac address infomation\n" + "Add/modify mac address information\n" "MAC address\n" "Virtual Network Identifier follows\n" "Virtual Network Identifier\n" @@ -2836,7 +2836,7 @@ DEFUN (add_vnc_mac_vni_prefix_life, "UN address of NVE\n" "UN IPv4 interface address\n" "UN IPv6 interface address\n" - "Add/modify prefix related infomation\n" + "Add/modify prefix related information\n" "IPv4 prefix\n" "IPv6 prefix\n" "Registration lifetime [default: infinite]\n" @@ -2853,7 +2853,7 @@ DEFUN (add_vnc_mac_vni_prefix_cost, "add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier <1-4294967295> vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) prefix (A.B.C.D/M|X:X::X:X/M) cost <0-255>", "Add registration\n" "VNC Information\n" - "Add/modify mac address infomation\n" + "Add/modify mac address information\n" "MAC address\n" "Virtual Network Identifier follows\n" "Virtual Network Identifier\n" @@ -2863,7 +2863,7 @@ DEFUN (add_vnc_mac_vni_prefix_cost, "UN address of NVE\n" "UN IPv4 interface address\n" "UN IPv6 interface address\n" - "Add/modify prefix related infomation\n" + "Add/modify prefix related information\n" "IPv4 prefix\n" "IPv6 prefix\n" "Administrative cost [default: 255]\n" "Administrative cost\n") @@ -2879,7 +2879,7 @@ DEFUN (add_vnc_mac_vni_prefix, "add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier <1-4294967295> vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) prefix (A.B.C.D/M|X:X::X:X/M)", "Add registration\n" "VNC Information\n" - "Add/modify mac address infomation\n" + "Add/modify mac address information\n" "MAC address\n" "Virtual Network Identifier follows\n" "Virtual Network Identifier\n" @@ -2889,7 +2889,7 @@ DEFUN (add_vnc_mac_vni_prefix, "UN address of NVE\n" "UN IPv4 interface address\n" "UN IPv6 interface address\n" - "Add/modify prefix related infomation\n" + "Add/modify prefix related information\n" "IPv4 prefix\n" "IPv6 prefix\n") { /* pfx vn un cost life */ @@ -2903,7 +2903,7 @@ DEFUN (add_vnc_mac_vni_cost_life, "add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier <1-4294967295> vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) cost <0-255> lifetime <1-4294967295>", "Add registration\n" "VNC Information\n" - "Add/modify mac address infomation\n" + "Add/modify mac address information\n" "MAC address\n" "Virtual Network Identifier follows\n" "Virtual Network Identifier\n" @@ -2930,7 +2930,7 @@ DEFUN (add_vnc_mac_vni_cost, "add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier <1-4294967295> vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) cost <0-255>", "Add registration\n" "VNC Information\n" - "Add/modify mac address infomation\n" + "Add/modify mac address information\n" "MAC address\n" "Virtual Network Identifier follows\n" "Virtual Network Identifier\n" @@ -2954,7 +2954,7 @@ DEFUN (add_vnc_mac_vni_life, "add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier <1-4294967295> vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X) lifetime <1-4294967295>", "Add registration\n" "VNC Information\n" - "Add/modify mac address infomation\n" + "Add/modify mac address information\n" "MAC address\n" "Virtual Network Identifier follows\n" "Virtual Network Identifier\n" @@ -2979,7 +2979,7 @@ DEFUN (add_vnc_mac_vni, "add vnc mac YY:YY:YY:YY:YY:YY virtual-network-identifier <1-4294967295> vn (A.B.C.D|X:X::X:X) un (A.B.C.D|X:X::X:X)", "Add registration\n" "VNC Information\n" - "Add/modify mac address infomation\n" + "Add/modify mac address information\n" "MAC address\n" "Virtual Network Identifier follows\n" "Virtual Network Identifier\n" @@ -3723,7 +3723,7 @@ DEFUN (clear_vnc_nve_vn_un, "clear vnc nve vn (*|A.B.C.D|X:X::X:X) un (*|A.B.C.D|X:X::X:X)", "clear\n" "VNC Information\n" - "Clear prefix registration infomation\n" + "Clear prefix registration information\n" "VN address of NVE\n" "VN IPv4 interface address\n" "VN IPv6 interface address\n" @@ -3753,7 +3753,7 @@ DEFUN (clear_vnc_nve_un_vn, "clear vnc nve un (*|A.B.C.D|X:X::X:X) vn (*|A.B.C.D|X:X::X:X)", "clear\n" "VNC Information\n" - "Clear prefix registration infomation\n" + "Clear prefix registration information\n" "UN address of NVE\n" "UN IPv4 interface address\n" "UN IPv6 interface address\n" @@ -3783,7 +3783,7 @@ DEFUN (clear_vnc_nve_vn, "clear vnc nve vn (*|A.B.C.D|X:X::X:X)", "clear\n" "VNC Information\n" - "Clear prefix registration infomation\n" + "Clear prefix registration information\n" "VN address of NVE\n" "VN IPv4 interface address\n" "VN IPv6 interface address\n") { @@ -3808,7 +3808,7 @@ DEFUN (clear_vnc_nve_un, "clear vnc nve un (*|A.B.C.D|X:X::X:X)", "clear\n" "VNC Information\n" - "Clear prefix registration infomation\n" + "Clear prefix registration information\n" "UN address of NVE\n" "UN IPv4 interface address\n" "UN IPv6 interface address\n") { @@ -3841,7 +3841,7 @@ DEFUN (clear_vnc_prefix_vn_un, "clear vnc prefix (*|A.B.C.D/M|X:X::X:X/M) vn (*|A.B.C.D|X:X::X:X) un (*|A.B.C.D|X:X::X:X)", "clear\n" "VNC Information\n" - "Clear prefix registration infomation\n" + "Clear prefix registration information\n" "All prefixes\n" "IPv4 prefix\n" "IPv6 prefix\n" @@ -3871,7 +3871,7 @@ DEFUN (clear_vnc_prefix_un_vn, "clear vnc prefix (*|A.B.C.D/M|X:X::X:X/M) un (*|A.B.C.D|X:X::X:X) vn (*|A.B.C.D|X:X::X:X)", "clear\n" "VNC Information\n" - "Clear prefix registration infomation\n" + "Clear prefix registration information\n" "All prefixes\n" "IPv4 prefix\n" "IPv6 prefix\n" @@ -3901,7 +3901,7 @@ DEFUN (clear_vnc_prefix_un, "clear vnc prefix (*|A.B.C.D/M|X:X::X:X/M) un (*|A.B.C.D|X:X::X:X)", "clear\n" "VNC Information\n" - "Clear prefix registration infomation\n" + "Clear prefix registration information\n" "All prefixes\n" "IPv4 prefix\n" "IPv6 prefix\n" @@ -3927,7 +3927,7 @@ DEFUN (clear_vnc_prefix_vn, "clear vnc prefix (*|A.B.C.D/M|X:X::X:X/M) vn (*|A.B.C.D|X:X::X:X)", "clear\n" "VNC Information\n" - "Clear prefix registration infomation\n" + "Clear prefix registration information\n" "All prefixes\n" "IPv4 prefix\n" "IPv6 prefix\n" @@ -3953,7 +3953,7 @@ DEFUN (clear_vnc_prefix_all, "clear vnc prefix (*|A.B.C.D/M|X:X::X:X/M) *", "clear\n" "VNC Information\n" - "Clear prefix registration infomation\n" + "Clear prefix registration information\n" "All prefixes\n" "IPv4 prefix\n" "IPv6 prefix\n" @@ -3983,7 +3983,7 @@ DEFUN (clear_vnc_mac_vn_un, "clear vnc mac (*|YY:YY:YY:YY:YY:YY) virtual-network-identifier (*|<1-4294967295>) vn (*|A.B.C.D|X:X::X:X) un (*|A.B.C.D|X:X::X:X)", "clear\n" "VNC Information\n" - "Clear mac registration infomation\n" + "Clear mac registration information\n" "All macs\n" "MAC address\n" "VNI keyword\n" @@ -4018,7 +4018,7 @@ DEFUN (clear_vnc_mac_un_vn, "clear vnc mac (*|YY:YY:YY:YY:YY:YY) virtual-network-identifier (*|<1-4294967295>) un (*|A.B.C.D|X:X::X:X) vn (*|A.B.C.D|X:X::X:X)", "clear\n" "VNC Information\n" - "Clear mac registration infomation\n" + "Clear mac registration information\n" "All macs\n" "MAC address\n" "VNI keyword\n" @@ -4052,7 +4052,7 @@ DEFUN (clear_vnc_mac_un, "clear vnc mac (*|YY:YY:YY:YY:YY:YY) virtual-network-identifier (*|<1-4294967295>) un (*|A.B.C.D|X:X::X:X)", "clear\n" "VNC Information\n" - "Clear mac registration infomation\n" + "Clear mac registration information\n" "All macs\n" "MAC address\n" "VNI keyword\n" @@ -4081,7 +4081,7 @@ DEFUN (clear_vnc_mac_vn, "clear vnc mac (*|YY:YY:YY:YY:YY:YY) virtual-network-identifier (*|<1-4294967295>) vn (*|A.B.C.D|X:X::X:X)", "clear\n" "VNC Information\n" - "Clear mac registration infomation\n" + "Clear mac registration information\n" "All macs\n" "MAC address\n" "VNI keyword\n" @@ -4110,7 +4110,7 @@ DEFUN (clear_vnc_mac_all, "clear vnc mac (*|YY:YY:YY:YY:YY:YY) virtual-network-identifier (*|<1-4294967295>) *", "clear\n" "VNC Information\n" - "Clear mac registration infomation\n" + "Clear mac registration information\n" "All macs\n" "MAC address\n" "VNI keyword\n" @@ -4140,7 +4140,7 @@ DEFUN (clear_vnc_mac_vn_un_prefix, "clear vnc mac (*|YY:YY:YY:YY:YY:YY) virtual-network-identifier (*|<1-4294967295>) vn (*|A.B.C.D|X:X::X:X) un (*|A.B.C.D|X:X::X:X) prefix (*|A.B.C.D/M|X:X::X:X/M)", "clear\n" "VNC Information\n" - "Clear mac registration infomation\n" + "Clear mac registration information\n" "All macs\n" "MAC address\n" "VNI keyword\n" @@ -4155,7 +4155,7 @@ DEFUN (clear_vnc_mac_vn_un_prefix, "All UN addresses\n" "UN IPv4 interface address\n" "UN IPv6 interface address\n" - "Clear prefix registration infomation\n" + "Clear prefix registration information\n" "All prefixes\n" "IPv4 prefix\n" "IPv6 prefix\n") @@ -4179,7 +4179,7 @@ DEFUN (clear_vnc_mac_un_vn_prefix, "clear vnc mac (*|YY:YY:YY:YY:YY:YY) virtual-network-identifier (*|<1-4294967295>) un (*|A.B.C.D|X:X::X:X) vn (*|A.B.C.D|X:X::X:X) prefix (*|A.B.C.D/M|X:X::X:X/M) prefix (*|A.B.C.D/M|X:X::X:X/M)", "clear\n" "VNC Information\n" - "Clear mac registration infomation\n" + "Clear mac registration information\n" "All macs\n" "MAC address\n" "VNI keyword\n" @@ -4213,7 +4213,7 @@ DEFUN (clear_vnc_mac_un_prefix, "clear vnc mac (*|YY:YY:YY:YY:YY:YY) virtual-network-identifier (*|<1-4294967295>) un (*|A.B.C.D|X:X::X:X) prefix (*|A.B.C.D/M|X:X::X:X/M)", "clear\n" "VNC Information\n" - "Clear mac registration infomation\n" + "Clear mac registration information\n" "All macs\n" "MAC address\n" "VNI keyword\n" @@ -4243,7 +4243,7 @@ DEFUN (clear_vnc_mac_vn_prefix, "clear vnc mac (*|YY:YY:YY:YY:YY:YY) virtual-network-identifier (*|<1-4294967295>) vn (*|A.B.C.D|X:X::X:X) prefix (*|A.B.C.D/M|X:X::X:X/M)", "clear\n" "VNC Information\n" - "Clear mac registration infomation\n" + "Clear mac registration information\n" "All macs\n" "MAC address\n" "VNI keyword\n" @@ -4273,7 +4273,7 @@ DEFUN (clear_vnc_mac_all_prefix, "clear vnc mac (*|YY:YY:YY:YY:YY:YY) virtual-network-identifier (*|<1-4294967295>) prefix (*|A.B.C.D/M|X:X::X:X/M)", "clear\n" "VNC Information\n" - "Clear mac registration infomation\n" + "Clear mac registration information\n" "All macs\n" "MAC address\n" "VNI keyword\n" From bede77445018ed62042f677adc82654ab32ba4c9 Mon Sep 17 00:00:00 2001 From: Lou Berger Date: Sat, 17 Dec 2016 17:58:33 -0500 Subject: [PATCH 035/107] bgp: Use intern/unintern for encap to fix valgrind identified memory leak Signed-off-by: Lou Berger --- bgpd/bgp_attr.c | 223 ++++++++++++++++++++++++++++-------- bgpd/bgp_attr.h | 2 + bgpd/bgp_route.c | 1 + bgpd/rfapi/rfapi_import.c | 4 + bgpd/rfapi/vnc_export_bgp.c | 1 - 5 files changed, 183 insertions(+), 48 deletions(-) diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c index 827e4610f4..2115fb5efc 100644 --- a/bgpd/bgp_attr.c +++ b/bgpd/bgp_attr.c @@ -220,6 +220,11 @@ cluster_finish (void) cluster_hash = NULL; } +static struct hash *encap_hash = NULL; +#if ENABLE_BGP_VNC +static struct hash *vnc_hash = NULL; +#endif + struct bgp_attr_encap_subtlv * encap_tlv_dup(struct bgp_attr_encap_subtlv *orig) { @@ -287,14 +292,10 @@ encap_same(struct bgp_attr_encap_subtlv *h1, struct bgp_attr_encap_subtlv *h2) struct bgp_attr_encap_subtlv *p; struct bgp_attr_encap_subtlv *q; - if (!h1 && !h2) - return 1; - if (h1 && !h2) - return 0; - if (!h1 && h2) - return 0; if (h1 == h2) return 1; + if (h1 == NULL || h2 == NULL) + return 0; for (p = h1; p; p = p->next) { for (q = h2; q; q = q->next) { @@ -325,6 +326,96 @@ encap_same(struct bgp_attr_encap_subtlv *h1, struct bgp_attr_encap_subtlv *h2) return 1; } +static void * +encap_hash_alloc (void *p) +{ + /* Encap structure is already allocated. */ + return p; +} + +typedef enum +{ + ENCAP_SUBTLV_TYPE, +#if ENABLE_BGP_VNC + VNC_SUBTLV_TYPE +#endif +} encap_subtlv_type; + +static struct bgp_attr_encap_subtlv * +encap_intern (struct bgp_attr_encap_subtlv *encap, encap_subtlv_type type) +{ + struct bgp_attr_encap_subtlv *find; + struct hash *hash = encap_hash; +#if ENABLE_BGP_VNC + if (type == VNC_SUBTLV_TYPE) + hash = vnc_hash; +#endif + + find = hash_get (hash, encap, encap_hash_alloc); + if (find != encap) + encap_free (encap); + find->refcnt++; + + return find; +} + +static void +encap_unintern (struct bgp_attr_encap_subtlv **encapp, encap_subtlv_type type) +{ + struct bgp_attr_encap_subtlv *encap = *encapp; + if (encap->refcnt) + encap->refcnt--; + + if (encap->refcnt == 0) + { + struct hash *hash = encap_hash; +#if ENABLE_BGP_VNC + if (type == VNC_SUBTLV_TYPE) + hash = vnc_hash; +#endif + hash_release (hash, encap); + encap_free (encap); + *encapp = NULL; + } +} + +static unsigned int +encap_hash_key_make (void *p) +{ + const struct bgp_attr_encap_subtlv * encap = p; + + return jhash(encap->value, encap->length, 0); +} + +static int +encap_hash_cmp (const void *p1, const void *p2) +{ + return encap_same((struct bgp_attr_encap_subtlv *)p1, + (struct bgp_attr_encap_subtlv *)p2); +} + +static void +encap_init (void) +{ + encap_hash = hash_create (encap_hash_key_make, encap_hash_cmp); +#if ENABLE_BGP_VNC + vnc_hash = hash_create (encap_hash_key_make, encap_hash_cmp); +#endif +} + +static void +encap_finish (void) +{ + hash_clean (encap_hash, (void (*)(void *))encap_free); + hash_free (encap_hash); + encap_hash = NULL; +#if ENABLE_BGP_VNC + hash_clean (vnc_hash, (void (*)(void *))encap_free); + hash_free (vnc_hash); + vnc_hash = NULL; +#endif +} + /* Unknown transit attribute. */ static struct hash *transit_hash; @@ -433,16 +524,6 @@ bgp_attr_extra_free (struct attr *attr) { if (attr->extra) { - if (attr->extra->encap_subtlvs) { - encap_free(attr->extra->encap_subtlvs); - attr->extra->encap_subtlvs = NULL; - } -#if ENABLE_BGP_VNC - if (attr->extra->vnc_subtlvs) { - encap_free(attr->extra->vnc_subtlvs); - attr->extra->vnc_subtlvs = NULL; - } -#endif XFREE (MTYPE_ATTR_EXTRA, attr->extra); attr->extra = NULL; } @@ -480,28 +561,12 @@ bgp_attr_dup (struct attr *new, struct attr *orig) memset(new->extra, 0, sizeof(struct attr_extra)); if (orig->extra) { *new->extra = *orig->extra; - if (orig->extra->encap_subtlvs) { - new->extra->encap_subtlvs = encap_tlv_dup(orig->extra->encap_subtlvs); - } -#if ENABLE_BGP_VNC - if (orig->extra->vnc_subtlvs) { - new->extra->vnc_subtlvs = encap_tlv_dup(orig->extra->vnc_subtlvs); - } -#endif } } else if (orig->extra) { new->extra = bgp_attr_extra_new(); *new->extra = *orig->extra; - if (orig->extra->encap_subtlvs) { - new->extra->encap_subtlvs = encap_tlv_dup(orig->extra->encap_subtlvs); - } -#if ENABLE_BGP_VNC - if (orig->extra->vnc_subtlvs) { - new->extra->vnc_subtlvs = encap_tlv_dup(orig->extra->vnc_subtlvs); - } -#endif } } @@ -522,6 +587,12 @@ bgp_attr_deep_dup (struct attr *new, struct attr *orig) new->extra->cluster = cluster_dup(orig->extra->cluster); if (orig->extra->transit) new->extra->transit = transit_dup(orig->extra->transit); + if (orig->extra->encap_subtlvs) + new->extra->encap_subtlvs = encap_tlv_dup(orig->extra->encap_subtlvs); +#if ENABLE_BGP_VNC + if (orig->extra->vnc_subtlvs) + new->extra->vnc_subtlvs = encap_tlv_dup(orig->extra->vnc_subtlvs); +#endif } } @@ -542,6 +613,12 @@ bgp_attr_deep_free (struct attr *attr) cluster_free(attr->extra->cluster); if (attr->extra->transit) transit_free(attr->extra->transit); + if (attr->extra->encap_subtlvs) + encap_free(attr->extra->encap_subtlvs); +#if ENABLE_BGP_VNC + if (attr->extra->vnc_subtlvs) + encap_free(attr->extra->vnc_subtlvs); +#endif } } @@ -598,7 +675,12 @@ attrhash_key_make (void *p) MIX(cluster_hash_key_make (extra->cluster)); if (extra->transit) MIX(transit_hash_key_make (extra->transit)); - + if (extra->encap_subtlvs) + MIX(encap_hash_key_make (extra->encap_subtlvs)); +#if ENABLE_BGP_VNC + if (extra->vnc_subtlvs) + MIX(encap_hash_key_make (extra->vnc_subtlvs)); +#endif #ifdef HAVE_IPV6 MIX(extra->mp_nexthop_len); key = jhash(extra->mp_nexthop_global.s6_addr, IPV6_MAX_BYTELEN, key); @@ -711,13 +793,12 @@ bgp_attr_hash_alloc (void *p) { attr->extra = bgp_attr_extra_new (); *attr->extra = *val->extra; - - if (attr->extra->encap_subtlvs) { - attr->extra->encap_subtlvs = encap_tlv_dup(attr->extra->encap_subtlvs); + if (val->extra->encap_subtlvs) { + val->extra->encap_subtlvs = NULL; } #if ENABLE_BGP_VNC - if (attr->extra->vnc_subtlvs) { - attr->extra->vnc_subtlvs = encap_tlv_dup(attr->extra->vnc_subtlvs); + if (val->extra->vnc_subtlvs) { + val->extra->vnc_subtlvs = NULL; } #endif } @@ -772,11 +853,27 @@ bgp_attr_intern (struct attr *attr) else attre->transit->refcnt++; } + if (attre->encap_subtlvs) + { + if (! attre->encap_subtlvs->refcnt) + attre->encap_subtlvs = encap_intern (attre->encap_subtlvs, ENCAP_SUBTLV_TYPE); + else + attre->encap_subtlvs->refcnt++; + } +#if ENABLE_BGP_VNC + if (attre->vnc_subtlvs) + { + if (! attre->vnc_subtlvs->refcnt) + attre->vnc_subtlvs = encap_intern (attre->vnc_subtlvs, VNC_SUBTLV_TYPE); + else + attre->vnc_subtlvs->refcnt++; + } +#endif } find = (struct attr *) hash_get (attrhash, attr, bgp_attr_hash_alloc); find->refcnt++; - + return find; } @@ -810,6 +907,14 @@ bgp_attr_refcount (struct attr *attr) if (attre->transit) attre->transit->refcnt++; + + if (attre->encap_subtlvs) + attre->encap_subtlvs->refcnt++; + +#if ENABLE_BGP_VNC + if (attre->vnc_subtlvs) + attre->vnc_subtlvs->refcnt++; +#endif } attr->refcnt++; return attr; @@ -935,6 +1040,14 @@ bgp_attr_unintern_sub (struct attr *attr) if (attr->extra->transit) transit_unintern (attr->extra->transit); + + if (attr->extra->encap_subtlvs) + encap_unintern (&attr->extra->encap_subtlvs, ENCAP_SUBTLV_TYPE); + +#if ENABLE_BGP_VNC + if (attr->extra->vnc_subtlvs) + encap_unintern (&attr->extra->vnc_subtlvs, VNC_SUBTLV_TYPE); +#endif } } @@ -1000,11 +1113,17 @@ bgp_attr_flush (struct attr *attr) transit_free (attre->transit); attre->transit = NULL; } - encap_free(attre->encap_subtlvs); - attre->encap_subtlvs = NULL; + if (attre->encap_subtlvs && ! attre->encap_subtlvs->refcnt) + { + encap_free(attre->encap_subtlvs); + attre->encap_subtlvs = NULL; + } #if ENABLE_BGP_VNC - encap_free(attre->vnc_subtlvs); - attre->vnc_subtlvs = NULL; + if (attre->vnc_subtlvs && ! attre->vnc_subtlvs->refcnt) + { + encap_free(attre->vnc_subtlvs); + attre->vnc_subtlvs = NULL; + } #endif } } @@ -2492,10 +2611,18 @@ bgp_attr_parse (struct peer *peer, struct attr *attr, bgp_size_t size, if (ret != BGP_ATTR_PARSE_PROCEED) return ret; } - - /* Finally intern unknown attribute. */ - if (attr->extra && attr->extra->transit) - attr->extra->transit = transit_intern (attr->extra->transit); + if (attr->extra) + { + /* Finally intern unknown attribute. */ + if (attr->extra->transit) + attr->extra->transit = transit_intern (attr->extra->transit); + if (attr->extra->encap_subtlvs) + attr->extra->encap_subtlvs = encap_intern (attr->extra->encap_subtlvs, ENCAP_SUBTLV_TYPE); +#if ENABLE_BGP_VNC + if (attr->extra->vnc_subtlvs) + attr->extra->vnc_subtlvs = encap_intern (attr->extra->vnc_subtlvs, VNC_SUBTLV_TYPE); +#endif + } return BGP_ATTR_PARSE_PROCEED; } @@ -3183,6 +3310,7 @@ bgp_attr_init (void) ecommunity_init (); cluster_init (); transit_init (); + encap_init (); } void @@ -3194,6 +3322,7 @@ bgp_attr_finish (void) ecommunity_finish (); cluster_finish (); transit_finish (); + encap_finish (); } /* Make attribute packet. */ diff --git a/bgpd/bgp_attr.h b/bgpd/bgp_attr.h index d4f45ba60a..6e639078d6 100644 --- a/bgpd/bgp_attr.h +++ b/bgpd/bgp_attr.h @@ -58,6 +58,8 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA struct bgp_attr_encap_subtlv { struct bgp_attr_encap_subtlv *next; /* for chaining */ + /* Reference count of this attribute. */ + unsigned long refcnt; uint16_t type; uint16_t length; uint8_t value[1]; /* will be extended */ diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index e4e321ad05..c717a930b1 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -1800,6 +1800,7 @@ subgroup_process_announce_selected (struct update_subgroup *subgrp, PEER_STATUS_ORF_WAIT_REFRESH)) return 0; + memset(&extra, 0, sizeof(struct attr_extra)); /* It's initialized in bgp_announce_check() */ attr.extra = &extra; diff --git a/bgpd/rfapi/rfapi_import.c b/bgpd/rfapi/rfapi_import.c index 4c3274c2cf..25c05e65f8 100644 --- a/bgpd/rfapi/rfapi_import.c +++ b/bgpd/rfapi/rfapi_import.c @@ -2151,6 +2151,7 @@ rfapiBgpInfoAttachSorted ( info_new->next = next; if (next) next->prev = info_new; + bgp_attr_intern (info_new->attr); } static void @@ -2159,6 +2160,7 @@ rfapiBgpInfoDetach (struct route_node *rn, struct bgp_info *bi) /* * Remove the route (doubly-linked) */ + // bgp_attr_unintern (&bi->attr); if (bi->next) bi->next->prev = bi->prev; if (bi->prev) @@ -2509,6 +2511,7 @@ rfapiMonitorEncapAdd ( __func__, import_table, vpn_bi, afi, rn, m); RFAPI_CHECK_REFCOUNT (rn, SAFI_ENCAP, 0); + bgp_attr_intern (vpn_bi->attr); } static void @@ -3011,6 +3014,7 @@ rfapiBiStartWithdrawTimer ( wcb->node = rn; wcb->info = bi; wcb->import_table = import_table; + bgp_attr_intern (bi->attr); if (VNC_DEBUG(VERBOSE)) { diff --git a/bgpd/rfapi/vnc_export_bgp.c b/bgpd/rfapi/vnc_export_bgp.c index bcfa145c67..f20e9ed674 100644 --- a/bgpd/rfapi/vnc_export_bgp.c +++ b/bgpd/rfapi/vnc_export_bgp.c @@ -76,7 +76,6 @@ encap_attr_export_ce ( memset (new, 0, sizeof (struct attr)); bgp_attr_dup (new, orig); bgp_attr_extra_get (new); - bgp_attr_flush_encap (new); /* * Set nexthop From 7bae2fb913ed56e3e559c8fbec2be7f0f85c60c2 Mon Sep 17 00:00:00 2001 From: Lou Berger Date: Fri, 30 Dec 2016 16:48:29 -0500 Subject: [PATCH 036/107] bgpd: fix ecommunity hash related leak Signed-off-by: Lou Berger --- bgpd/bgp_ecommunity.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bgpd/bgp_ecommunity.c b/bgpd/bgp_ecommunity.c index 6c72aa36d9..65415dcee2 100644 --- a/bgpd/bgp_ecommunity.c +++ b/bgpd/bgp_ecommunity.c @@ -54,6 +54,13 @@ ecommunity_free (struct ecommunity **ecom) ecom = NULL; } +static void +ecommunity_hash_free (struct ecommunity *ecom) +{ + ecommunity_free(&ecom); +} + + /* Add a new Extended Communities value to Extended Communities Attribute structure. When the value is already exists in the structure, we don't add the value. Newly added value is sorted by @@ -282,6 +289,7 @@ ecommunity_init (void) void ecommunity_finish (void) { + hash_clean (ecomhash, (void (*)(void *))ecommunity_hash_free); hash_free (ecomhash); ecomhash = NULL; } From ff9eb96a93cdb5509a45f84bc557eb6dc9122c27 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Mon, 12 Dec 2016 07:59:16 -0500 Subject: [PATCH 037/107] lib: Partial Revert of 4ecc09d and modify zclient connect behavior Commit 43cc09d has been shown to cause several issues with clients connecting. Partial revert, since I wanted to keep the debug logs added for that commit, as well remove the piece of code that stops attempting to connect to zebra. If we've failed a bunch of times, there is nothing wrong with continuing to do so once every 60 seconds. I've debug guarded the connect failure for those people running bgp without zebra. Signed-off-by: Donald Sharp Signed-off-by: Renato Westphal --- lib/zclient.c | 28 +++++++++------------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/lib/zclient.c b/lib/zclient.c index 894e0d19ef..440de3635f 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -216,7 +216,9 @@ zclient_socket(void) ret = connect (sock, (struct sockaddr *) &serv, sizeof (serv)); if (ret < 0) { - zlog_warn ("%s connect failure: %d", __PRETTY_FUNCTION__, errno); + if (zclient_debug) + zlog_warn ("%s connect failure: %d(%s)", __PRETTY_FUNCTION__, + errno, safe_strerror (errno)); close (sock); return -1; } @@ -252,7 +254,9 @@ zclient_socket_un (const char *path) ret = connect (sock, (struct sockaddr *) &addr, len); if (ret < 0) { - zlog_warn ("%s connect failure: %d", __PRETTY_FUNCTION__, errno); + if (zclient_debug) + zlog_warn ("%s connect failure: %d(%s)", __PRETTY_FUNCTION__, + errno, safe_strerror (errno)); close (sock); return -1; } @@ -572,23 +576,11 @@ zclient_start (struct zclient *zclient) if (zclient->t_connect) return 0; - /* - * If we fail to connect to the socket on initialization, - * Let's wait a second and see if we can reconnect. - * Cause if we don't connect, we never attempt to - * reconnect. On startup if zebra is slow we - * can get into this situation. - */ - while (zclient_socket_connect(zclient) < 0 && zclient->fail < 5) + if (zclient_socket_connect(zclient) < 0) { if (zclient_debug) zlog_debug ("zclient connection fail"); zclient->fail++; - sleep (1); - } - - if (zclient->sock < 0) - { zclient_event (ZCLIENT_CONNECT, zclient); return -1; } @@ -1727,11 +1719,9 @@ zclient_event (enum event event, struct zclient *zclient) thread_add_event (zclient->master, zclient_connect, zclient, 0); break; case ZCLIENT_CONNECT: - if (zclient->fail >= 10) - return; if (zclient_debug) - zlog_debug ("zclient connect schedule interval is %d", - zclient->fail < 3 ? 10 : 60); + zlog_debug ("zclient connect failures: %d schedule interval is now %d", + zclient->fail, zclient->fail < 3 ? 10 : 60); if (! zclient->t_connect) zclient->t_connect = thread_add_timer (zclient->master, zclient_connect, zclient, From 54c8d91e5d79004d812ac816bf0785c8edd6c0cd Mon Sep 17 00:00:00 2001 From: Don Slice Date: Fri, 16 Dec 2016 08:53:30 -0800 Subject: [PATCH 038/107] ospf6d: resolve problem with area range lsid creation The problem reported was that routers downstream from the ABR would have prefixes in the IPv6 rib that should have been summarized. Testing showed that the prefixes were absent in the lsdb but not removed from the rib. The problem (and others) stemmed from determining the link-state id to use for the area-range statement only from other entries in the range-table. Since the area range statement creates inter-prefix LSAs (summaries) which are in all aspects identical to other inter-prefix LSAs, the number space for the lsid needs to be unique across all inter-prefix LSAs, not just unique between area range statements. This fix removes the use of range-table specific lsids and acquires the lsid just as any other inter-prefix LSA. Ticket: CM-13626 Signed-off-by: Don Slice Reviewed By: CCR-5489 Testing Done: Manual testing, repeated runs of the test that previously failed, ospf-smoke --- ospf6d/ospf6_abr.c | 9 +++------ ospf6d/ospf6_area.c | 4 ---- ospf6d/ospf6_lsdb.c | 18 ------------------ ospf6d/ospf6_lsdb.h | 3 --- 4 files changed, 3 insertions(+), 31 deletions(-) diff --git a/ospf6d/ospf6_abr.c b/ospf6d/ospf6_abr.c index 527d2ecfa7..f75a35fa50 100644 --- a/ospf6d/ospf6_abr.c +++ b/ospf6d/ospf6_abr.c @@ -424,12 +424,9 @@ ospf6_abr_originate_summary_to_area (struct ospf6_route *route, else { summary->path.origin.type = htons (OSPF6_LSTYPE_INTER_PREFIX); - if (route->type == OSPF6_DEST_TYPE_RANGE) - summary->path.origin.id = route->linkstate_id; - else - summary->path.origin.id = - ospf6_new_ls_id (summary->path.origin.type, - summary->path.origin.adv_router, area->lsdb); + summary->path.origin.id = + ospf6_new_ls_id (summary->path.origin.type, + summary->path.origin.adv_router, area->lsdb); } summary = ospf6_route_add (summary, summary_table); } diff --git a/ospf6d/ospf6_area.c b/ospf6d/ospf6_area.c index 685be58324..bbab8598b8 100644 --- a/ospf6d/ospf6_area.c +++ b/ospf6d/ospf6_area.c @@ -465,8 +465,6 @@ DEFUN (area_range, range->prefix = prefix; range->path.area_id = oa->area_id; range->path.cost = OSPF_AREA_RANGE_COST_UNSPEC; - range->linkstate_id = - (u_int32_t) htonl(ospf6_new_range_ls_id (oa->range_table)); } if (argc > 2) @@ -577,8 +575,6 @@ DEFUN (no_area_range, /* purge the old aggregated summary LSA */ ospf6_abr_originate_summary(range); } - ospf6_release_range_ls_id(oa->range_table, - (u_int32_t) ntohl(range->linkstate_id)); ospf6_route_remove (range, oa->range_table); return CMD_SUCCESS; diff --git a/ospf6d/ospf6_lsdb.c b/ospf6d/ospf6_lsdb.c index 04bea84ae5..1d4b557cd5 100644 --- a/ospf6d/ospf6_lsdb.c +++ b/ospf6d/ospf6_lsdb.c @@ -547,24 +547,6 @@ ospf6_lsdb_show (struct vty *vty, enum ospf_lsdb_show_level level, } } -/* Decide new Link State ID to originate for the range. */ -u_int32_t -ospf6_new_range_ls_id (struct ospf6_route_table *range_table) -{ - u_int32_t id; - - bf_assign_index(range_table->idspace, id); - return (id); -} - -/* Release the LS ID back to the ID pool */ -void -ospf6_release_range_ls_id (struct ospf6_route_table *range_table, - u_int32_t id) -{ - bf_release_index(range_table->idspace, id); -} - u_int32_t ospf6_new_ls_id (u_int16_t type, u_int32_t adv_router, struct ospf6_lsdb *lsdb) diff --git a/ospf6d/ospf6_lsdb.h b/ospf6d/ospf6_lsdb.h index a8bfcae882..b21d9ee282 100644 --- a/ospf6d/ospf6_lsdb.h +++ b/ospf6d/ospf6_lsdb.h @@ -81,9 +81,6 @@ extern void ospf6_lsdb_show (struct vty *vty, extern u_int32_t ospf6_new_ls_id (u_int16_t type, u_int32_t adv_router, struct ospf6_lsdb *lsdb); -extern u_int32_t ospf6_new_range_ls_id (struct ospf6_route_table *range_table); -extern void ospf6_release_range_ls_id (struct ospf6_route_table *range_table, - u_int32_t id); extern u_int32_t ospf6_new_ls_seqnum (u_int16_t type, u_int32_t id, u_int32_t adv_router, struct ospf6_lsdb *lsdb); From 07bc3833841ec104b10f48d936da18aaf6ddcf29 Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Mon, 19 Dec 2016 14:07:28 -0200 Subject: [PATCH 039/107] ldpd: add missing privilege dropping on error path Signed-off-by: Renato Westphal --- ldpd/socket.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ldpd/socket.c b/ldpd/socket.c index 1bb0837401..eaea9973a0 100644 --- a/ldpd/socket.c +++ b/ldpd/socket.c @@ -85,6 +85,8 @@ ldp_create_socket(int af, enum socket_type type) if (ldpd_privs.change(ZPRIVS_RAISE)) log_warn("%s: could not raise privs", __func__); if (sock_set_reuse(fd, 1) == -1) { + if (ldpd_privs.change(ZPRIVS_LOWER)) + log_warn("%s: could not lower privs", __func__); close(fd); return (-1); } From 6bfae35e5c7b020a7ffca41dbe0eefc77ff003c2 Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Mon, 19 Dec 2016 14:43:25 -0200 Subject: [PATCH 040/107] ospf6d: fix broken indentation in "show ipv6 ospf6 neighbor" In the State/IfState column, we were reserving only 6 characters to print the state of each neighbor, but this is not enough for cases like "Loading" (7 characters) and "ExChange" (8 characters). Increase the width of this field to 8 to fix the broken indendation. ospf6d's output before this patch: ubuntu# show ipv6 ospf6 neighbor Neighbor ID Pri DeadTime State/IfState Duration I/F[State] 2.2.2.2 1 00:00:35 ExChange/DR 00:01:15 rt1-eth0[BDR] 3.3.3.3 1 00:00:35 Loading/DR 00:01:15 rt1-eth1[BDR] 4.4.4.4 1 00:00:35 Full/DR 00:01:15 rt1-eth2[BDR] 5.5.5.5 1 00:00:35 None/DR 00:01:10 rt1-eth3[BDR] 6.6.6.6 1 00:00:35 Down/DR 00:01:15 rt1-eth4[BDR] 7.7.7.7 1 00:00:35 Attempt/DR 00:01:15 rt1-eth5[BDR] 8.8.8.8 1 00:00:35 Init/DR 00:01:10 rt1-eth6[BDR] 9.9.9.9 1 00:00:35 Twoway/DR 00:01:14 rt1-eth7[BDR] 10.10.10.10 1 00:00:35 ExStart/DR 00:01:10 rt1-eth8[BDR] ospf6d's output with this patch: ubuntu# show ipv6 ospf6 neighbor Neighbor ID Pri DeadTime State/IfState Duration I/F[State] 2.2.2.2 1 00:00:36 ExChange/DR 00:00:44 rt1-eth0[BDR] 3.3.3.3 1 00:00:36 Loading/DR 00:00:39 rt1-eth1[BDR] 4.4.4.4 1 00:00:35 Full/DR 00:00:39 rt1-eth2[BDR] 5.5.5.5 1 00:00:36 None/DR 00:00:44 rt1-eth3[BDR] 6.6.6.6 1 00:00:36 Down/DR 00:00:39 rt1-eth4[BDR] 7.7.7.7 1 00:00:36 Attempt/DR 00:00:39 rt1-eth5[BDR] 8.8.8.8 1 00:00:36 Init/DR 00:00:39 rt1-eth6[BDR] 9.9.9.9 1 00:00:35 Twoway/DR 00:00:40 rt1-eth7[BDR] 10.10.10.10 1 00:00:36 ExStart/DR 00:00:39 rt1-eth8[BDR] Signed-off-by: Renato Westphal --- ospf6d/ospf6_neighbor.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ospf6d/ospf6_neighbor.c b/ospf6d/ospf6_neighbor.c index f24ee84c8e..e9bb2493ff 100644 --- a/ospf6d/ospf6_neighbor.c +++ b/ospf6d/ospf6_neighbor.c @@ -682,7 +682,7 @@ ospf6_neighbor_show (struct vty *vty, struct ospf6_neighbor *on) "I/F", "State", VNL); */ - vty_out (vty, "%-15s %3d %11s %6s/%-12s %11s %s[%s]%s", + vty_out (vty, "%-15s %3d %11s %8s/%-12s %11s %s[%s]%s", router_id, on->priority, deadtime, ospf6_neighbor_state_str[on->state], nstate, duration, on->ospf6_if->interface->name, @@ -711,7 +711,7 @@ ospf6_neighbor_show_drchoice (struct vty *vty, struct ospf6_neighbor *on) timersub (&now, &on->last_changed, &res); timerstring (&res, duration, sizeof (duration)); - vty_out (vty, "%-15s %6s/%-11s %-15s %-15s %s[%s]%s", + vty_out (vty, "%-15s %8s/%-11s %-15s %-15s %s[%s]%s", router_id, ospf6_neighbor_state_str[on->state], duration, drouter, bdrouter, on->ospf6_if->interface->name, ospf6_interface_state_str[on->ospf6_if->state], @@ -856,11 +856,11 @@ DEFUN (show_ipv6_ospf6_neighbor, } if (showfunc == ospf6_neighbor_show) - vty_out (vty, "%-15s %3s %11s %6s/%-12s %11s %s[%s]%s", + vty_out (vty, "%-15s %3s %11s %8s/%-12s %11s %s[%s]%s", "Neighbor ID", "Pri", "DeadTime", "State", "IfState", "Duration", "I/F", "State", VNL); else if (showfunc == ospf6_neighbor_show_drchoice) - vty_out (vty, "%-15s %6s/%-11s %-15s %-15s %s[%s]%s", + vty_out (vty, "%-15s %8s/%-11s %-15s %-15s %s[%s]%s", "RouterID", "State", "Duration", "DR", "BDR", "I/F", "State", VNL); From bdcf7abf820d36089feb3000d630227df744858e Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Mon, 19 Dec 2016 18:30:59 -0200 Subject: [PATCH 041/107] tools: teach xml2cli.pl the "[]" notation for optional arguments Requested by Daniel Walton. Signed-off-by: Renato Westphal --- tools/xml2cli.pl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/xml2cli.pl b/tools/xml2cli.pl index 1b45e7f726..e0980421bd 100755 --- a/tools/xml2cli.pl +++ b/tools/xml2cli.pl @@ -141,6 +141,8 @@ sub generate_arguments { # argument is the name of the node if ($node{'input'} or $node{'type'} eq "select") { $arg_value = "argv[" . $argc . "]->arg"; + } elsif ($node{'optional'}) { + $arg_value = "(argc > " . $argc . " ? argv[" . $argc. "]->arg : NULL)"; } else { $arg_value = '"' . $node{'name'} . '"'; } @@ -196,7 +198,11 @@ sub generate_code { $helpstr .= $::options{$options_name}{'help'}; } else { $funcname .= $node{'name'} . " "; - $cmdstr .= $node{'name'} . " "; + if ($node{'optional'}) { + $cmdstr .= "[" . $node{'name'} . "] "; + } else { + $cmdstr .= $node{'name'} . " "; + } $helpstr .= "\n \"" . $node{'help'} . "\\n\""; } @@ -279,6 +285,7 @@ sub parse_tree { $node{'help'} = $xml_node->findvalue('./@help'); $node{'function'} = $xml_node->findvalue('./@function'); $node{'ifdef'} = $xml_node->findvalue('./@ifdef'); + $node{'optional'} = $xml_node->findvalue('./@optional'); # push node to stack push (@nodes, \%node); From 607c1cbfd290e4e19c983c43dae22bd9a0ab827f Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Mon, 19 Dec 2016 23:29:49 -0200 Subject: [PATCH 042/107] build/ldpd: auto-generate ldp_vty_cmds.c from ldp_vty.xml Having ldp_vty_cmds.c around as part of the git repository was being a major source of confusion. Since this file is auto-generated from ldp_vty.xml, remove it from this git repository and make it be generated on demand by adding a make target for it. This patch adds another dependency to build Quagga, namely the LibXML Perl module, which can be installed with this command: $ sudo cpan XML::LibXML Signed-off-by: Renato Westphal --- ldpd/.gitignore | 2 +- ldpd/Makefile.am | 5 + ldpd/ldp_vty_cmds.c | 1726 ------------------------------------------- 3 files changed, 6 insertions(+), 1727 deletions(-) delete mode 100644 ldpd/ldp_vty_cmds.c diff --git a/ldpd/.gitignore b/ldpd/.gitignore index be90d42119..e4ee82587a 100644 --- a/ldpd/.gitignore +++ b/ldpd/.gitignore @@ -15,4 +15,4 @@ TAGS .arch-ids *~ *.loT - +ldp_vty_cmds.c diff --git a/ldpd/Makefile.am b/ldpd/Makefile.am index c292adf6fc..e7da216a65 100644 --- a/ldpd/Makefile.am +++ b/ldpd/Makefile.am @@ -9,6 +9,8 @@ AM_CFLAGS = $(WERROR) noinst_LIBRARIES = libldp.a sbin_PROGRAMS = ldpd +BUILT_SOURCES = ldp_vty_cmds.c + libldp_a_SOURCES = \ accept.c address.c adjacency.c control.c hello.c init.c interface.c \ keepalive.c l2vpn.c labelmapping.c lde.c lde_lib.c ldpd.c \ @@ -19,6 +21,9 @@ libldp_a_SOURCES = \ noinst_HEADERS = \ control.h lde.h ldpd.h ldpe.h ldp.h log.h ldp_debug.h ldp_vty.h +ldp_vty_cmds.c: $(srcdir)/ldp_vty.xml $(srcdir)/../tools/xml2cli.pl + @PERL@ $(srcdir)/../tools/xml2cli.pl $(srcdir)/ldp_vty.xml > $@ + ldpd_SOURCES = ldpd.c ldpd_LDADD = libldp.a ../lib/libzebra.la @LIBCAP@ diff --git a/ldpd/ldp_vty_cmds.c b/ldpd/ldp_vty_cmds.c deleted file mode 100644 index 8aa593cf2c..0000000000 --- a/ldpd/ldp_vty_cmds.c +++ /dev/null @@ -1,1726 +0,0 @@ -/* Auto-generated from ldp_vty.xml. */ -/* Do not edit! */ - -#include - -#include "command.h" -#include "vty.h" -#include "ldp_vty.h" - -DEFUN (ldp_mpls_ldp, - ldp_mpls_ldp_cmd, - "mpls ldp", - "Global MPLS configuration subcommands\n" - "Label Distribution Protocol\n") -{ - struct vty_arg *args[] = { NULL }; - return ldp_vty_mpls_ldp (vty, args); -} - -DEFUN (ldp_l2vpn_word_type_vpls, - ldp_l2vpn_word_type_vpls_cmd, - "l2vpn WORD type vpls", - "Configure l2vpn commands\n" - "L2VPN name\n" - "L2VPN type\n" - "Virtual Private LAN Service\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "name", .value = argv[1]->arg }, - NULL - }; - return ldp_vty_l2vpn (vty, args); -} - -DEFUN (ldp_no_mpls_ldp, - ldp_no_mpls_ldp_cmd, - "no mpls ldp", - "Negate a command or set its defaults\n" - "Global MPLS configuration subcommands\n" - "Label Distribution Protocol\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "no", .value = "no" }, - NULL - }; - return ldp_vty_mpls_ldp (vty, args); -} - -DEFUN (ldp_no_l2vpn_word_type_vpls, - ldp_no_l2vpn_word_type_vpls_cmd, - "no l2vpn WORD type vpls", - "Negate a command or set its defaults\n" - "Configure l2vpn commands\n" - "L2VPN name\n" - "L2VPN type\n" - "Virtual Private LAN Service\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "no", .value = "no" }, - &(struct vty_arg) { .name = "name", .value = argv[2]->arg }, - NULL - }; - return ldp_vty_l2vpn (vty, args); -} - -DEFUN (ldp_address_family_ipv4, - ldp_address_family_ipv4_cmd, - "address-family ipv4", - "Configure Address Family and its parameters\n" - "IPv4\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "address-family", .value = "ipv4" }, - NULL - }; - return ldp_vty_address_family (vty, args); -} - -DEFUN (ldp_address_family_ipv6, - ldp_address_family_ipv6_cmd, - "address-family ipv6", - "Configure Address Family and its parameters\n" - "IPv6\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "address-family", .value = "ipv6" }, - NULL - }; - return ldp_vty_address_family (vty, args); -} - -DEFUN (ldp_discovery_hello_holdtime_disc_time, - ldp_discovery_hello_holdtime_disc_time_cmd, - "discovery hello holdtime (1-65535)", - "Configure discovery parameters\n" - "LDP Link Hellos\n" - "Hello holdtime\n" - "Time (seconds) - 65535 implies infinite\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "hello_type", .value = "hello" }, - &(struct vty_arg) { .name = "seconds", .value = argv[3]->arg }, - NULL - }; - return ldp_vty_disc_holdtime (vty, args); -} - -DEFUN (ldp_discovery_hello_interval_disc_time, - ldp_discovery_hello_interval_disc_time_cmd, - "discovery hello interval (1-65535)", - "Configure discovery parameters\n" - "LDP Link Hellos\n" - "Hello interval\n" - "Time (seconds)\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "hello_type", .value = "hello" }, - &(struct vty_arg) { .name = "seconds", .value = argv[3]->arg }, - NULL - }; - return ldp_vty_disc_interval (vty, args); -} - -DEFUN (ldp_discovery_targeted_hello_holdtime_disc_time, - ldp_discovery_targeted_hello_holdtime_disc_time_cmd, - "discovery targeted-hello holdtime (1-65535)", - "Configure discovery parameters\n" - "LDP Targeted Hellos\n" - "Targeted hello holdtime\n" - "Time (seconds) - 65535 implies infinite\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "hello_type", .value = "targeted-hello" }, - &(struct vty_arg) { .name = "seconds", .value = argv[3]->arg }, - NULL - }; - return ldp_vty_disc_holdtime (vty, args); -} - -DEFUN (ldp_discovery_targeted_hello_interval_disc_time, - ldp_discovery_targeted_hello_interval_disc_time_cmd, - "discovery targeted-hello interval (1-65535)", - "Configure discovery parameters\n" - "LDP Targeted Hellos\n" - "Targeted hello interval\n" - "Time (seconds)\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "hello_type", .value = "targeted-hello" }, - &(struct vty_arg) { .name = "seconds", .value = argv[3]->arg }, - NULL - }; - return ldp_vty_disc_interval (vty, args); -} - -DEFUN (ldp_dual_stack_transport_connection_prefer_ipv4, - ldp_dual_stack_transport_connection_prefer_ipv4_cmd, - "dual-stack transport-connection prefer ipv4", - "Configure dual stack parameters\n" - "Configure TCP transport parameters\n" - "Configure prefered address family for TCP transport connection with neighbor\n" - "IPv4\n") -{ - struct vty_arg *args[] = { NULL }; - return ldp_vty_trans_pref_ipv4 (vty, args); -} - -DEFUN (ldp_dual_stack_cisco_interop, - ldp_dual_stack_cisco_interop_cmd, - "dual-stack cisco-interop", - "Configure dual stack parameters\n" - "Use Cisco non-compliant format to send and interpret the Dual-Stack capability TLV\n") -{ - struct vty_arg *args[] = { NULL }; - return ldp_vty_ds_cisco_interop (vty, args); -} - -DEFUN (ldp_neighbor_ipv4_password_word, - ldp_neighbor_ipv4_password_word_cmd, - "neighbor A.B.C.D password WORD", - "Configure neighbor parameters\n" - "LDP Id of neighbor\n" - "Configure password for MD5 authentication\n" - "The password\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "lsr_id", .value = argv[1]->arg }, - &(struct vty_arg) { .name = "password", .value = argv[3]->arg }, - NULL - }; - return ldp_vty_neighbor_password (vty, args); -} - -DEFUN (ldp_neighbor_ipv4_session_holdtime_session_time, - ldp_neighbor_ipv4_session_holdtime_session_time_cmd, - "neighbor A.B.C.D session holdtime (15-65535)", - "Configure neighbor parameters\n" - "LDP Id of neighbor\n" - "Configure session parameters\n" - "Configure session holdtime\n" - "Time (seconds)\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "lsr_id", .value = argv[1]->arg }, - &(struct vty_arg) { .name = "seconds", .value = argv[4]->arg }, - NULL - }; - return ldp_vty_session_holdtime (vty, args); -} - -DEFUN (ldp_neighbor_ipv4_ttl_security_disable, - ldp_neighbor_ipv4_ttl_security_disable_cmd, - "neighbor A.B.C.D ttl-security disable", - "Configure neighbor parameters\n" - "LDP Id of neighbor\n" - "LDP ttl security check\n" - "Disable ttl security\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "lsr_id", .value = argv[1]->arg }, - NULL - }; - return ldp_vty_neighbor_ttl_security (vty, args); -} - -DEFUN (ldp_neighbor_ipv4_ttl_security_hops_hops, - ldp_neighbor_ipv4_ttl_security_hops_hops_cmd, - "neighbor A.B.C.D ttl-security hops (1-254)", - "Configure neighbor parameters\n" - "LDP Id of neighbor\n" - "LDP ttl security check\n" - "IP hops\n" - "maximum number of hops\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "lsr_id", .value = argv[1]->arg }, - &(struct vty_arg) { .name = "hops", .value = argv[4]->arg }, - NULL - }; - return ldp_vty_neighbor_ttl_security (vty, args); -} - -DEFUN (ldp_router_id_ipv4, - ldp_router_id_ipv4_cmd, - "router-id A.B.C.D", - "Configure router Id\n" - "LSR Id (in form of an IPv4 address)\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "addr", .value = argv[1]->arg }, - NULL - }; - return ldp_vty_router_id (vty, args); -} - -DEFUN (ldp_no_address_family_ipv4, - ldp_no_address_family_ipv4_cmd, - "no address-family ipv4", - "Negate a command or set its defaults\n" - "Configure Address Family and its parameters\n" - "IPv4\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "no", .value = "no" }, - &(struct vty_arg) { .name = "address-family", .value = "ipv4" }, - NULL - }; - return ldp_vty_address_family (vty, args); -} - -DEFUN (ldp_no_address_family_ipv6, - ldp_no_address_family_ipv6_cmd, - "no address-family ipv6", - "Negate a command or set its defaults\n" - "Configure Address Family and its parameters\n" - "IPv6\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "no", .value = "no" }, - &(struct vty_arg) { .name = "address-family", .value = "ipv6" }, - NULL - }; - return ldp_vty_address_family (vty, args); -} - -DEFUN (ldp_no_discovery_hello_holdtime_disc_time, - ldp_no_discovery_hello_holdtime_disc_time_cmd, - "no discovery hello holdtime (1-65535)", - "Negate a command or set its defaults\n" - "Configure discovery parameters\n" - "LDP Link Hellos\n" - "Hello holdtime\n" - "Time (seconds) - 65535 implies infinite\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "no", .value = "no" }, - &(struct vty_arg) { .name = "hello_type", .value = "hello" }, - &(struct vty_arg) { .name = "seconds", .value = argv[4]->arg }, - NULL - }; - return ldp_vty_disc_holdtime (vty, args); -} - -DEFUN (ldp_no_discovery_hello_interval_disc_time, - ldp_no_discovery_hello_interval_disc_time_cmd, - "no discovery hello interval (1-65535)", - "Negate a command or set its defaults\n" - "Configure discovery parameters\n" - "LDP Link Hellos\n" - "Hello interval\n" - "Time (seconds)\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "no", .value = "no" }, - &(struct vty_arg) { .name = "hello_type", .value = "hello" }, - &(struct vty_arg) { .name = "seconds", .value = argv[4]->arg }, - NULL - }; - return ldp_vty_disc_interval (vty, args); -} - -DEFUN (ldp_no_discovery_targeted_hello_holdtime_disc_time, - ldp_no_discovery_targeted_hello_holdtime_disc_time_cmd, - "no discovery targeted-hello holdtime (1-65535)", - "Negate a command or set its defaults\n" - "Configure discovery parameters\n" - "LDP Targeted Hellos\n" - "Targeted hello holdtime\n" - "Time (seconds) - 65535 implies infinite\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "no", .value = "no" }, - &(struct vty_arg) { .name = "hello_type", .value = "targeted-hello" }, - &(struct vty_arg) { .name = "seconds", .value = argv[4]->arg }, - NULL - }; - return ldp_vty_disc_holdtime (vty, args); -} - -DEFUN (ldp_no_discovery_targeted_hello_interval_disc_time, - ldp_no_discovery_targeted_hello_interval_disc_time_cmd, - "no discovery targeted-hello interval (1-65535)", - "Negate a command or set its defaults\n" - "Configure discovery parameters\n" - "LDP Targeted Hellos\n" - "Targeted hello interval\n" - "Time (seconds)\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "no", .value = "no" }, - &(struct vty_arg) { .name = "hello_type", .value = "targeted-hello" }, - &(struct vty_arg) { .name = "seconds", .value = argv[4]->arg }, - NULL - }; - return ldp_vty_disc_interval (vty, args); -} - -DEFUN (ldp_no_dual_stack_transport_connection_prefer_ipv4, - ldp_no_dual_stack_transport_connection_prefer_ipv4_cmd, - "no dual-stack transport-connection prefer ipv4", - "Negate a command or set its defaults\n" - "Configure dual stack parameters\n" - "Configure TCP transport parameters\n" - "Configure prefered address family for TCP transport connection with neighbor\n" - "IPv4\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "no", .value = "no" }, - NULL - }; - return ldp_vty_trans_pref_ipv4 (vty, args); -} - -DEFUN (ldp_no_dual_stack_cisco_interop, - ldp_no_dual_stack_cisco_interop_cmd, - "no dual-stack cisco-interop", - "Negate a command or set its defaults\n" - "Configure dual stack parameters\n" - "Use Cisco non-compliant format to send and interpret the Dual-Stack capability TLV\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "no", .value = "no" }, - NULL - }; - return ldp_vty_ds_cisco_interop (vty, args); -} - -DEFUN (ldp_no_neighbor_ipv4_password_word, - ldp_no_neighbor_ipv4_password_word_cmd, - "no neighbor A.B.C.D password WORD", - "Negate a command or set its defaults\n" - "Configure neighbor parameters\n" - "LDP Id of neighbor\n" - "Configure password for MD5 authentication\n" - "The password\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "no", .value = "no" }, - &(struct vty_arg) { .name = "lsr_id", .value = argv[2]->arg }, - &(struct vty_arg) { .name = "password", .value = argv[4]->arg }, - NULL - }; - return ldp_vty_neighbor_password (vty, args); -} - -DEFUN (ldp_no_neighbor_ipv4_session_holdtime_session_time, - ldp_no_neighbor_ipv4_session_holdtime_session_time_cmd, - "no neighbor A.B.C.D session holdtime (15-65535)", - "Negate a command or set its defaults\n" - "Configure neighbor parameters\n" - "LDP Id of neighbor\n" - "Configure session parameters\n" - "Configure session holdtime\n" - "Time (seconds)\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "no", .value = "no" }, - &(struct vty_arg) { .name = "lsr_id", .value = argv[2]->arg }, - &(struct vty_arg) { .name = "seconds", .value = argv[5]->arg }, - NULL - }; - return ldp_vty_session_holdtime (vty, args); -} - -DEFUN (ldp_no_neighbor_ipv4_ttl_security_disable, - ldp_no_neighbor_ipv4_ttl_security_disable_cmd, - "no neighbor A.B.C.D ttl-security disable", - "Negate a command or set its defaults\n" - "Configure neighbor parameters\n" - "LDP Id of neighbor\n" - "LDP ttl security check\n" - "Disable ttl security\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "no", .value = "no" }, - &(struct vty_arg) { .name = "lsr_id", .value = argv[2]->arg }, - NULL - }; - return ldp_vty_neighbor_ttl_security (vty, args); -} - -DEFUN (ldp_no_neighbor_ipv4_ttl_security_hops_hops, - ldp_no_neighbor_ipv4_ttl_security_hops_hops_cmd, - "no neighbor A.B.C.D ttl-security hops (1-254)", - "Negate a command or set its defaults\n" - "Configure neighbor parameters\n" - "LDP Id of neighbor\n" - "LDP ttl security check\n" - "IP hops\n" - "maximum number of hops\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "no", .value = "no" }, - &(struct vty_arg) { .name = "lsr_id", .value = argv[2]->arg }, - &(struct vty_arg) { .name = "hops", .value = argv[5]->arg }, - NULL - }; - return ldp_vty_neighbor_ttl_security (vty, args); -} - -DEFUN (ldp_no_router_id_ipv4, - ldp_no_router_id_ipv4_cmd, - "no router-id A.B.C.D", - "Negate a command or set its defaults\n" - "Configure router Id\n" - "LSR Id (in form of an IPv4 address)\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "no", .value = "no" }, - &(struct vty_arg) { .name = "addr", .value = argv[2]->arg }, - NULL - }; - return ldp_vty_router_id (vty, args); -} - -DEFUN (ldp_discovery_targeted_hello_accept, - ldp_discovery_targeted_hello_accept_cmd, - "discovery targeted-hello accept", - "Configure discovery parameters\n" - "LDP Targeted Hellos\n" - "Accept and respond to targeted hellos\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "hello_type", .value = "targeted-hello" }, - NULL - }; - return ldp_vty_targeted_hello_accept (vty, args); -} - -DEFUN (ldp_label_local_advertise_explicit_null, - ldp_label_local_advertise_explicit_null_cmd, - "label local advertise explicit-null", - "Configure label control and policies\n" - "Configure local label control and policies\n" - "Configure outbound label advertisement control\n" - "Configure explicit-null advertisement\n") -{ - struct vty_arg *args[] = { NULL }; - return ldp_vty_explicit_null (vty, args); -} - -DEFUN (ldp_ttl_security_disable, - ldp_ttl_security_disable_cmd, - "ttl-security disable", - "LDP ttl security check\n" - "Disable ttl security\n") -{ - struct vty_arg *args[] = { NULL }; - return ldp_vty_ttl_security (vty, args); -} - -DEFUN (ldp_session_holdtime_session_time, - ldp_session_holdtime_session_time_cmd, - "session holdtime (15-65535)", - "Configure session parameters\n" - "Configure session holdtime\n" - "Time (seconds)\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "seconds", .value = argv[2]->arg }, - NULL - }; - return ldp_vty_session_holdtime (vty, args); -} - -DEFUN (ldp_interface_ifname, - ldp_interface_ifname_cmd, - "interface IFNAME", - "Enable LDP on an interface and enter interface submode\n" - "Interface's name\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "ifname", .value = argv[1]->arg }, - NULL - }; - return ldp_vty_interface (vty, args); -} - -DEFUN (ldp_discovery_transport_address_ipv4, - ldp_discovery_transport_address_ipv4_cmd, - "discovery transport-address A.B.C.D", - "Configure discovery parameters\n" - "Specify transport address for TCP connection\n" - "IP address to be used as transport address\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "addr", .value = argv[2]->arg }, - NULL - }; - return ldp_vty_trans_addr (vty, args); -} - -DEFUN (ldp_neighbor_ipv4_targeted, - ldp_neighbor_ipv4_targeted_cmd, - "neighbor A.B.C.D targeted", - "Configure neighbor parameters\n" - "IP address of neighbor\n" - "Establish targeted session\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "addr", .value = argv[1]->arg }, - NULL - }; - return ldp_vty_neighbor_targeted (vty, args); -} - -DEFUN (ldp_no_discovery_targeted_hello_accept, - ldp_no_discovery_targeted_hello_accept_cmd, - "no discovery targeted-hello accept", - "Negate a command or set its defaults\n" - "Configure discovery parameters\n" - "LDP Targeted Hellos\n" - "Accept and respond to targeted hellos\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "no", .value = "no" }, - &(struct vty_arg) { .name = "hello_type", .value = "targeted-hello" }, - NULL - }; - return ldp_vty_targeted_hello_accept (vty, args); -} - -DEFUN (ldp_no_label_local_advertise_explicit_null, - ldp_no_label_local_advertise_explicit_null_cmd, - "no label local advertise explicit-null", - "Negate a command or set its defaults\n" - "Configure label control and policies\n" - "Configure local label control and policies\n" - "Configure outbound label advertisement control\n" - "Configure explicit-null advertisement\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "no", .value = "no" }, - NULL - }; - return ldp_vty_explicit_null (vty, args); -} - -DEFUN (ldp_no_ttl_security_disable, - ldp_no_ttl_security_disable_cmd, - "no ttl-security disable", - "Negate a command or set its defaults\n" - "LDP ttl security check\n" - "Disable ttl security\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "no", .value = "no" }, - NULL - }; - return ldp_vty_ttl_security (vty, args); -} - -DEFUN (ldp_no_session_holdtime_session_time, - ldp_no_session_holdtime_session_time_cmd, - "no session holdtime (15-65535)", - "Negate a command or set its defaults\n" - "Configure session parameters\n" - "Configure session holdtime\n" - "Time (seconds)\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "no", .value = "no" }, - &(struct vty_arg) { .name = "seconds", .value = argv[3]->arg }, - NULL - }; - return ldp_vty_session_holdtime (vty, args); -} - -DEFUN (ldp_no_interface_ifname, - ldp_no_interface_ifname_cmd, - "no interface IFNAME", - "Negate a command or set its defaults\n" - "Enable LDP on an interface and enter interface submode\n" - "Interface's name\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "no", .value = "no" }, - &(struct vty_arg) { .name = "ifname", .value = argv[2]->arg }, - NULL - }; - return ldp_vty_interface (vty, args); -} - -DEFUN (ldp_no_discovery_transport_address_ipv4, - ldp_no_discovery_transport_address_ipv4_cmd, - "no discovery transport-address A.B.C.D", - "Negate a command or set its defaults\n" - "Configure discovery parameters\n" - "Specify transport address for TCP connection\n" - "IP address to be used as transport address\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "no", .value = "no" }, - &(struct vty_arg) { .name = "addr", .value = argv[3]->arg }, - NULL - }; - return ldp_vty_trans_addr (vty, args); -} - -DEFUN (ldp_no_neighbor_ipv4_targeted, - ldp_no_neighbor_ipv4_targeted_cmd, - "no neighbor A.B.C.D targeted", - "Negate a command or set its defaults\n" - "Configure neighbor parameters\n" - "IP address of neighbor\n" - "Establish targeted session\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "no", .value = "no" }, - &(struct vty_arg) { .name = "addr", .value = argv[2]->arg }, - NULL - }; - return ldp_vty_neighbor_targeted (vty, args); -} - -DEFUN (ldp_discovery_transport_address_ipv6, - ldp_discovery_transport_address_ipv6_cmd, - "discovery transport-address X:X::X:X", - "Configure discovery parameters\n" - "Specify transport address for TCP connection\n" - "IPv6 address to be used as transport address\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "addr", .value = argv[2]->arg }, - NULL - }; - return ldp_vty_trans_addr (vty, args); -} - -DEFUN (ldp_neighbor_ipv6_targeted, - ldp_neighbor_ipv6_targeted_cmd, - "neighbor X:X::X:X targeted", - "Configure neighbor parameters\n" - "IPv6 address of neighbor\n" - "Establish targeted session\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "addr", .value = argv[1]->arg }, - NULL - }; - return ldp_vty_neighbor_targeted (vty, args); -} - -DEFUN (ldp_no_discovery_transport_address_ipv6, - ldp_no_discovery_transport_address_ipv6_cmd, - "no discovery transport-address X:X::X:X", - "Negate a command or set its defaults\n" - "Configure discovery parameters\n" - "Specify transport address for TCP connection\n" - "IPv6 address to be used as transport address\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "no", .value = "no" }, - &(struct vty_arg) { .name = "addr", .value = argv[3]->arg }, - NULL - }; - return ldp_vty_trans_addr (vty, args); -} - -DEFUN (ldp_no_neighbor_ipv6_targeted, - ldp_no_neighbor_ipv6_targeted_cmd, - "no neighbor X:X::X:X targeted", - "Negate a command or set its defaults\n" - "Configure neighbor parameters\n" - "IPv6 address of neighbor\n" - "Establish targeted session\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "no", .value = "no" }, - &(struct vty_arg) { .name = "addr", .value = argv[2]->arg }, - NULL - }; - return ldp_vty_neighbor_targeted (vty, args); -} - -DEFUN (ldp_bridge_ifname, - ldp_bridge_ifname_cmd, - "bridge IFNAME", - "Bridge interface\n" - "Interface's name\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "ifname", .value = argv[1]->arg }, - NULL - }; - return ldp_vty_l2vpn_bridge (vty, args); -} - -DEFUN (ldp_mtu_mtu, - ldp_mtu_mtu_cmd, - "mtu (1500-9180)", - "set Maximum Transmission Unit\n" - "Maximum Transmission Unit value\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "mtu", .value = argv[1]->arg }, - NULL - }; - return ldp_vty_l2vpn_mtu (vty, args); -} - -DEFUN (ldp_member_interface_ifname, - ldp_member_interface_ifname_cmd, - "member interface IFNAME", - "L2VPN member configuration\n" - "Local interface\n" - "Interface's name\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "ifname", .value = argv[2]->arg }, - NULL - }; - return ldp_vty_l2vpn_interface (vty, args); -} - -DEFUN (ldp_member_pseudowire_ifname, - ldp_member_pseudowire_ifname_cmd, - "member pseudowire IFNAME", - "L2VPN member configuration\n" - "Pseudowire interface\n" - "Interface's name\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "ifname", .value = argv[2]->arg }, - NULL - }; - return ldp_vty_l2vpn_pseudowire (vty, args); -} - -DEFUN (ldp_vc_type_pwtype, - ldp_vc_type_pwtype_cmd, - "vc type ", - "Virtual Circuit options\n" - "Virtual Circuit type to use\n" - "Ethernet (type 5)\n" - "Ethernet-tagged (type 4)\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "type", .value = argv[2]->arg }, - NULL - }; - return ldp_vty_l2vpn_pwtype (vty, args); -} - -DEFUN (ldp_no_bridge_ifname, - ldp_no_bridge_ifname_cmd, - "no bridge IFNAME", - "Negate a command or set its defaults\n" - "Bridge interface\n" - "Interface's name\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "no", .value = "no" }, - &(struct vty_arg) { .name = "ifname", .value = argv[2]->arg }, - NULL - }; - return ldp_vty_l2vpn_bridge (vty, args); -} - -DEFUN (ldp_no_mtu_mtu, - ldp_no_mtu_mtu_cmd, - "no mtu (1500-9180)", - "Negate a command or set its defaults\n" - "set Maximum Transmission Unit\n" - "Maximum Transmission Unit value\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "no", .value = "no" }, - &(struct vty_arg) { .name = "mtu", .value = argv[2]->arg }, - NULL - }; - return ldp_vty_l2vpn_mtu (vty, args); -} - -DEFUN (ldp_no_member_interface_ifname, - ldp_no_member_interface_ifname_cmd, - "no member interface IFNAME", - "Negate a command or set its defaults\n" - "L2VPN member configuration\n" - "Local interface\n" - "Interface's name\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "no", .value = "no" }, - &(struct vty_arg) { .name = "ifname", .value = argv[3]->arg }, - NULL - }; - return ldp_vty_l2vpn_interface (vty, args); -} - -DEFUN (ldp_no_member_pseudowire_ifname, - ldp_no_member_pseudowire_ifname_cmd, - "no member pseudowire IFNAME", - "Negate a command or set its defaults\n" - "L2VPN member configuration\n" - "Pseudowire interface\n" - "Interface's name\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "no", .value = "no" }, - &(struct vty_arg) { .name = "ifname", .value = argv[3]->arg }, - NULL - }; - return ldp_vty_l2vpn_pseudowire (vty, args); -} - -DEFUN (ldp_no_vc_type_pwtype, - ldp_no_vc_type_pwtype_cmd, - "no vc type ", - "Negate a command or set its defaults\n" - "Virtual Circuit options\n" - "Virtual Circuit type to use\n" - "Ethernet (type 5)\n" - "Ethernet-tagged (type 4)\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "no", .value = "no" }, - &(struct vty_arg) { .name = "type", .value = argv[3]->arg }, - NULL - }; - return ldp_vty_l2vpn_pwtype (vty, args); -} - -DEFUN (ldp_control_word_cword, - ldp_control_word_cword_cmd, - "control-word ", - "Control-word options\n" - "Exclude control-word in pseudowire packets\n" - "Include control-word in pseudowire packets\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "preference", .value = argv[1]->arg }, - NULL - }; - return ldp_vty_l2vpn_pw_cword (vty, args); -} - -DEFUN (ldp_neighbor_address_addr, - ldp_neighbor_address_addr_cmd, - "neighbor address ", - "Remote endpoint configuration\n" - "Specify the IPv4 or IPv6 address of the remote endpoint\n" - "IPv4 address\n" - "IPv6 address\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "addr", .value = argv[2]->arg }, - NULL - }; - return ldp_vty_l2vpn_pw_nbr_addr (vty, args); -} - -DEFUN (ldp_neighbor_lsr_id_ipv4, - ldp_neighbor_lsr_id_ipv4_cmd, - "neighbor lsr-id A.B.C.D", - "Remote endpoint configuration\n" - "Specify the LSR-ID of the remote endpoint\n" - "IPv4 address\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "lsr-id", .value = argv[2]->arg }, - NULL - }; - return ldp_vty_l2vpn_pw_nbr_id (vty, args); -} - -DEFUN (ldp_pw_id_pwid, - ldp_pw_id_pwid_cmd, - "pw-id (1-4294967295)", - "Set the Virtual Circuit ID\n" - "Virtual Circuit ID value\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "pwid", .value = argv[1]->arg }, - NULL - }; - return ldp_vty_l2vpn_pw_pwid (vty, args); -} - -DEFUN (ldp_pw_status_disable, - ldp_pw_status_disable_cmd, - "pw-status disable", - "Configure PW status\n" - "Disable PW status\n") -{ - struct vty_arg *args[] = { NULL }; - return ldp_vty_l2vpn_pw_pwstatus (vty, args); -} - -DEFUN (ldp_no_control_word_cword, - ldp_no_control_word_cword_cmd, - "no control-word ", - "Negate a command or set its defaults\n" - "Control-word options\n" - "Exclude control-word in pseudowire packets\n" - "Include control-word in pseudowire packets\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "no", .value = "no" }, - &(struct vty_arg) { .name = "preference", .value = argv[2]->arg }, - NULL - }; - return ldp_vty_l2vpn_pw_cword (vty, args); -} - -DEFUN (ldp_no_neighbor_address_addr, - ldp_no_neighbor_address_addr_cmd, - "no neighbor address ", - "Negate a command or set its defaults\n" - "Remote endpoint configuration\n" - "Specify the IPv4 or IPv6 address of the remote endpoint\n" - "IPv4 address\n" - "IPv6 address\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "no", .value = "no" }, - &(struct vty_arg) { .name = "addr", .value = argv[3]->arg }, - NULL - }; - return ldp_vty_l2vpn_pw_nbr_addr (vty, args); -} - -DEFUN (ldp_no_neighbor_lsr_id_ipv4, - ldp_no_neighbor_lsr_id_ipv4_cmd, - "no neighbor lsr-id A.B.C.D", - "Negate a command or set its defaults\n" - "Remote endpoint configuration\n" - "Specify the LSR-ID of the remote endpoint\n" - "IPv4 address\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "no", .value = "no" }, - &(struct vty_arg) { .name = "lsr-id", .value = argv[3]->arg }, - NULL - }; - return ldp_vty_l2vpn_pw_nbr_id (vty, args); -} - -DEFUN (ldp_no_pw_id_pwid, - ldp_no_pw_id_pwid_cmd, - "no pw-id (1-4294967295)", - "Negate a command or set its defaults\n" - "Set the Virtual Circuit ID\n" - "Virtual Circuit ID value\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "no", .value = "no" }, - &(struct vty_arg) { .name = "pwid", .value = argv[2]->arg }, - NULL - }; - return ldp_vty_l2vpn_pw_pwid (vty, args); -} - -DEFUN (ldp_no_pw_status_disable, - ldp_no_pw_status_disable_cmd, - "no pw-status disable", - "Negate a command or set its defaults\n" - "Configure PW status\n" - "Disable PW status\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "no", .value = "no" }, - NULL - }; - return ldp_vty_l2vpn_pw_pwstatus (vty, args); -} - -DEFUN (ldp_show_mpls_ldp_neighbor, - ldp_show_mpls_ldp_neighbor_cmd, - "show mpls ldp neighbor", - "Show running system information\n" - "MPLS information\n" - "Label Distribution Protocol\n" - "Neighbor information\n") -{ - struct vty_arg *args[] = { NULL }; - return ldp_vty_show_neighbor (vty, args); -} - -DEFUN (ldp_show_mpls_ldp_binding, - ldp_show_mpls_ldp_binding_cmd, - "show mpls ldp binding", - "Show running system information\n" - "MPLS information\n" - "Label Distribution Protocol\n" - "Label Information Base (LIB) information\n") -{ - struct vty_arg *args[] = { NULL }; - return ldp_vty_show_binding (vty, args); -} - -DEFUN (ldp_show_mpls_ldp_discovery, - ldp_show_mpls_ldp_discovery_cmd, - "show mpls ldp discovery", - "Show running system information\n" - "MPLS information\n" - "Label Distribution Protocol\n" - "Discovery Hello Information\n") -{ - struct vty_arg *args[] = { NULL }; - return ldp_vty_show_discovery (vty, args); -} - -DEFUN (ldp_show_mpls_ldp_interface, - ldp_show_mpls_ldp_interface_cmd, - "show mpls ldp interface", - "Show running system information\n" - "MPLS information\n" - "Label Distribution Protocol\n" - "interface information\n") -{ - struct vty_arg *args[] = { NULL }; - return ldp_vty_show_interface (vty, args); -} - -DEFUN (ldp_show_mpls_ldp_address_family_binding, - ldp_show_mpls_ldp_address_family_binding_cmd, - "show mpls ldp binding", - "Show running system information\n" - "MPLS information\n" - "Label Distribution Protocol\n" - "IPv4 Address Family\n" - "IPv6 Address Family\n" - "Label Information Base (LIB) information\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "address-family", .value = argv[3]->arg }, - NULL - }; - return ldp_vty_show_binding (vty, args); -} - -DEFUN (ldp_show_mpls_ldp_address_family_discovery, - ldp_show_mpls_ldp_address_family_discovery_cmd, - "show mpls ldp discovery", - "Show running system information\n" - "MPLS information\n" - "Label Distribution Protocol\n" - "IPv4 Address Family\n" - "IPv6 Address Family\n" - "Discovery Hello Information\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "address-family", .value = argv[3]->arg }, - NULL - }; - return ldp_vty_show_discovery (vty, args); -} - -DEFUN (ldp_show_mpls_ldp_address_family_interface, - ldp_show_mpls_ldp_address_family_interface_cmd, - "show mpls ldp interface", - "Show running system information\n" - "MPLS information\n" - "Label Distribution Protocol\n" - "IPv4 Address Family\n" - "IPv6 Address Family\n" - "interface information\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "address-family", .value = argv[3]->arg }, - NULL - }; - return ldp_vty_show_interface (vty, args); -} - -DEFUN (ldp_show_l2vpn_atom_binding, - ldp_show_l2vpn_atom_binding_cmd, - "show l2vpn atom binding", - "Show running system information\n" - "Show information about Layer2 VPN\n" - "Show Any Transport over MPLS information\n" - "Show AToM label binding information\n") -{ - struct vty_arg *args[] = { NULL }; - return ldp_vty_show_atom_binding (vty, args); -} - -DEFUN (ldp_show_l2vpn_atom_vc, - ldp_show_l2vpn_atom_vc_cmd, - "show l2vpn atom vc", - "Show running system information\n" - "Show information about Layer2 VPN\n" - "Show Any Transport over MPLS information\n" - "Show AToM virtual circuit information\n") -{ - struct vty_arg *args[] = { NULL }; - return ldp_vty_show_atom_vc (vty, args); -} - -DEFUN (ldp_show_debugging_mpls_ldp, - ldp_show_debugging_mpls_ldp_cmd, - "show debugging mpls ldp", - "Show running system information\n" - "Debugging functions\n" - "MPLS information\n" - "Label Distribution Protocol\n") -{ - struct vty_arg *args[] = { NULL }; - return ldp_vty_show_debugging (vty, args); -} - -DEFUN (ldp_clear_mpls_ldp_neighbor, - ldp_clear_mpls_ldp_neighbor_cmd, - "clear mpls ldp neighbor", - "Reset functions\n" - "Reset MPLS statistical information\n" - "Clear LDP state\n" - "Clear LDP neighbor sessions\n") -{ - struct vty_arg *args[] = { NULL }; - return ldp_vty_clear_nbr (vty, args); -} - -DEFUN (ldp_clear_mpls_ldp_neighbor_addr, - ldp_clear_mpls_ldp_neighbor_addr_cmd, - "clear mpls ldp neighbor ", - "Reset functions\n" - "Reset MPLS statistical information\n" - "Clear LDP state\n" - "Clear LDP neighbor sessions\n" - "IPv4 address\n" - "IPv6 address\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "addr", .value = argv[4]->arg }, - NULL - }; - return ldp_vty_clear_nbr (vty, args); -} - -DEFUN (ldp_debug_mpls_ldp_discovery_hello_dir, - ldp_debug_mpls_ldp_discovery_hello_dir_cmd, - "debug mpls ldp discovery hello ", - "Debugging functions\n" - "MPLS information\n" - "Label Distribution Protocol\n" - "Discovery messages\n" - "Discovery hello message\n" - "Received messages\n" - "Sent messages\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "type", .value = "discovery" }, - &(struct vty_arg) { .name = "dir", .value = argv[5]->arg }, - NULL - }; - return ldp_vty_debug (vty, args); -} - -DEFUN (ldp_debug_mpls_ldp_errors, - ldp_debug_mpls_ldp_errors_cmd, - "debug mpls ldp errors", - "Debugging functions\n" - "MPLS information\n" - "Label Distribution Protocol\n" - "Errors\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "type", .value = "errors" }, - NULL - }; - return ldp_vty_debug (vty, args); -} - -DEFUN (ldp_debug_mpls_ldp_event, - ldp_debug_mpls_ldp_event_cmd, - "debug mpls ldp event", - "Debugging functions\n" - "MPLS information\n" - "Label Distribution Protocol\n" - "LDP event information\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "type", .value = "event" }, - NULL - }; - return ldp_vty_debug (vty, args); -} - -DEFUN (ldp_debug_mpls_ldp_messages_recv, - ldp_debug_mpls_ldp_messages_recv_cmd, - "debug mpls ldp messages recv", - "Debugging functions\n" - "MPLS information\n" - "Label Distribution Protocol\n" - "Messages\n" - "Received messages, excluding periodic Keep Alives\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "type", .value = "messages" }, - &(struct vty_arg) { .name = "dir", .value = "recv" }, - NULL - }; - return ldp_vty_debug (vty, args); -} - -DEFUN (ldp_debug_mpls_ldp_messages_recv_all, - ldp_debug_mpls_ldp_messages_recv_all_cmd, - "debug mpls ldp messages recv all", - "Debugging functions\n" - "MPLS information\n" - "Label Distribution Protocol\n" - "Messages\n" - "Received messages, excluding periodic Keep Alives\n" - "Received messages, including periodic Keep Alives\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "type", .value = "messages" }, - &(struct vty_arg) { .name = "dir", .value = "recv" }, - &(struct vty_arg) { .name = "all", .value = "all" }, - NULL - }; - return ldp_vty_debug (vty, args); -} - -DEFUN (ldp_debug_mpls_ldp_messages_sent, - ldp_debug_mpls_ldp_messages_sent_cmd, - "debug mpls ldp messages sent", - "Debugging functions\n" - "MPLS information\n" - "Label Distribution Protocol\n" - "Messages\n" - "Sent messages, excluding periodic Keep Alives\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "type", .value = "messages" }, - &(struct vty_arg) { .name = "dir", .value = "sent" }, - NULL - }; - return ldp_vty_debug (vty, args); -} - -DEFUN (ldp_debug_mpls_ldp_messages_sent_all, - ldp_debug_mpls_ldp_messages_sent_all_cmd, - "debug mpls ldp messages sent all", - "Debugging functions\n" - "MPLS information\n" - "Label Distribution Protocol\n" - "Messages\n" - "Sent messages, excluding periodic Keep Alives\n" - "Sent messages, including periodic Keep Alives\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "type", .value = "messages" }, - &(struct vty_arg) { .name = "dir", .value = "sent" }, - &(struct vty_arg) { .name = "all", .value = "all" }, - NULL - }; - return ldp_vty_debug (vty, args); -} - -DEFUN (ldp_debug_mpls_ldp_zebra, - ldp_debug_mpls_ldp_zebra_cmd, - "debug mpls ldp zebra", - "Debugging functions\n" - "MPLS information\n" - "Label Distribution Protocol\n" - "LDP zebra information\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "type", .value = "zebra" }, - NULL - }; - return ldp_vty_debug (vty, args); -} - -DEFUN (ldp_no_debug_mpls_ldp_discovery_hello_dir, - ldp_no_debug_mpls_ldp_discovery_hello_dir_cmd, - "no debug mpls ldp discovery hello ", - "Negate a command or set its defaults\n" - "Debugging functions\n" - "MPLS information\n" - "Label Distribution Protocol\n" - "Discovery messages\n" - "Discovery hello message\n" - "Received messages\n" - "Sent messages\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "no", .value = "no" }, - &(struct vty_arg) { .name = "type", .value = "discovery" }, - &(struct vty_arg) { .name = "dir", .value = argv[6]->arg }, - NULL - }; - return ldp_vty_debug (vty, args); -} - -DEFUN (ldp_no_debug_mpls_ldp_errors, - ldp_no_debug_mpls_ldp_errors_cmd, - "no debug mpls ldp errors", - "Negate a command or set its defaults\n" - "Debugging functions\n" - "MPLS information\n" - "Label Distribution Protocol\n" - "Errors\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "no", .value = "no" }, - &(struct vty_arg) { .name = "type", .value = "errors" }, - NULL - }; - return ldp_vty_debug (vty, args); -} - -DEFUN (ldp_no_debug_mpls_ldp_event, - ldp_no_debug_mpls_ldp_event_cmd, - "no debug mpls ldp event", - "Negate a command or set its defaults\n" - "Debugging functions\n" - "MPLS information\n" - "Label Distribution Protocol\n" - "LDP event information\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "no", .value = "no" }, - &(struct vty_arg) { .name = "type", .value = "event" }, - NULL - }; - return ldp_vty_debug (vty, args); -} - -DEFUN (ldp_no_debug_mpls_ldp_messages_recv, - ldp_no_debug_mpls_ldp_messages_recv_cmd, - "no debug mpls ldp messages recv", - "Negate a command or set its defaults\n" - "Debugging functions\n" - "MPLS information\n" - "Label Distribution Protocol\n" - "Messages\n" - "Received messages, excluding periodic Keep Alives\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "no", .value = "no" }, - &(struct vty_arg) { .name = "type", .value = "messages" }, - &(struct vty_arg) { .name = "dir", .value = "recv" }, - NULL - }; - return ldp_vty_debug (vty, args); -} - -DEFUN (ldp_no_debug_mpls_ldp_messages_recv_all, - ldp_no_debug_mpls_ldp_messages_recv_all_cmd, - "no debug mpls ldp messages recv all", - "Negate a command or set its defaults\n" - "Debugging functions\n" - "MPLS information\n" - "Label Distribution Protocol\n" - "Messages\n" - "Received messages, excluding periodic Keep Alives\n" - "Received messages, including periodic Keep Alives\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "no", .value = "no" }, - &(struct vty_arg) { .name = "type", .value = "messages" }, - &(struct vty_arg) { .name = "dir", .value = "recv" }, - &(struct vty_arg) { .name = "all", .value = "all" }, - NULL - }; - return ldp_vty_debug (vty, args); -} - -DEFUN (ldp_no_debug_mpls_ldp_messages_sent, - ldp_no_debug_mpls_ldp_messages_sent_cmd, - "no debug mpls ldp messages sent", - "Negate a command or set its defaults\n" - "Debugging functions\n" - "MPLS information\n" - "Label Distribution Protocol\n" - "Messages\n" - "Sent messages, excluding periodic Keep Alives\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "no", .value = "no" }, - &(struct vty_arg) { .name = "type", .value = "messages" }, - &(struct vty_arg) { .name = "dir", .value = "sent" }, - NULL - }; - return ldp_vty_debug (vty, args); -} - -DEFUN (ldp_no_debug_mpls_ldp_messages_sent_all, - ldp_no_debug_mpls_ldp_messages_sent_all_cmd, - "no debug mpls ldp messages sent all", - "Negate a command or set its defaults\n" - "Debugging functions\n" - "MPLS information\n" - "Label Distribution Protocol\n" - "Messages\n" - "Sent messages, excluding periodic Keep Alives\n" - "Sent messages, including periodic Keep Alives\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "no", .value = "no" }, - &(struct vty_arg) { .name = "type", .value = "messages" }, - &(struct vty_arg) { .name = "dir", .value = "sent" }, - &(struct vty_arg) { .name = "all", .value = "all" }, - NULL - }; - return ldp_vty_debug (vty, args); -} - -DEFUN (ldp_no_debug_mpls_ldp_zebra, - ldp_no_debug_mpls_ldp_zebra_cmd, - "no debug mpls ldp zebra", - "Negate a command or set its defaults\n" - "Debugging functions\n" - "MPLS information\n" - "Label Distribution Protocol\n" - "LDP zebra information\n") -{ - struct vty_arg *args[] = - { - &(struct vty_arg) { .name = "no", .value = "no" }, - &(struct vty_arg) { .name = "type", .value = "zebra" }, - NULL - }; - return ldp_vty_debug (vty, args); -} - -void -ldp_vty_init (void) -{ - install_element (CONFIG_NODE, &ldp_mpls_ldp_cmd); - install_element (CONFIG_NODE, &ldp_l2vpn_word_type_vpls_cmd); - install_element (CONFIG_NODE, &ldp_no_mpls_ldp_cmd); - install_element (CONFIG_NODE, &ldp_no_l2vpn_word_type_vpls_cmd); - install_element (CONFIG_NODE, &ldp_debug_mpls_ldp_discovery_hello_dir_cmd); - install_element (CONFIG_NODE, &ldp_debug_mpls_ldp_errors_cmd); - install_element (CONFIG_NODE, &ldp_debug_mpls_ldp_event_cmd); - install_element (CONFIG_NODE, &ldp_debug_mpls_ldp_messages_recv_cmd); - install_element (CONFIG_NODE, &ldp_debug_mpls_ldp_messages_recv_all_cmd); - install_element (CONFIG_NODE, &ldp_debug_mpls_ldp_messages_sent_cmd); - install_element (CONFIG_NODE, &ldp_debug_mpls_ldp_messages_sent_all_cmd); - install_element (CONFIG_NODE, &ldp_debug_mpls_ldp_zebra_cmd); - install_element (CONFIG_NODE, &ldp_no_debug_mpls_ldp_discovery_hello_dir_cmd); - install_element (CONFIG_NODE, &ldp_no_debug_mpls_ldp_errors_cmd); - install_element (CONFIG_NODE, &ldp_no_debug_mpls_ldp_event_cmd); - install_element (CONFIG_NODE, &ldp_no_debug_mpls_ldp_messages_recv_cmd); - install_element (CONFIG_NODE, &ldp_no_debug_mpls_ldp_messages_recv_all_cmd); - install_element (CONFIG_NODE, &ldp_no_debug_mpls_ldp_messages_sent_cmd); - install_element (CONFIG_NODE, &ldp_no_debug_mpls_ldp_messages_sent_all_cmd); - install_element (CONFIG_NODE, &ldp_no_debug_mpls_ldp_zebra_cmd); - install_node (&ldp_node, ldp_config_write); - install_default (LDP_NODE); - install_element (LDP_NODE, &ldp_address_family_ipv4_cmd); - install_element (LDP_NODE, &ldp_address_family_ipv6_cmd); - install_element (LDP_NODE, &ldp_discovery_hello_holdtime_disc_time_cmd); - install_element (LDP_NODE, &ldp_discovery_hello_interval_disc_time_cmd); - install_element (LDP_NODE, &ldp_discovery_targeted_hello_holdtime_disc_time_cmd); - install_element (LDP_NODE, &ldp_discovery_targeted_hello_interval_disc_time_cmd); - install_element (LDP_NODE, &ldp_dual_stack_transport_connection_prefer_ipv4_cmd); - install_element (LDP_NODE, &ldp_dual_stack_cisco_interop_cmd); - install_element (LDP_NODE, &ldp_neighbor_ipv4_password_word_cmd); - install_element (LDP_NODE, &ldp_neighbor_ipv4_session_holdtime_session_time_cmd); - install_element (LDP_NODE, &ldp_neighbor_ipv4_ttl_security_disable_cmd); - install_element (LDP_NODE, &ldp_neighbor_ipv4_ttl_security_hops_hops_cmd); - install_element (LDP_NODE, &ldp_router_id_ipv4_cmd); - install_element (LDP_NODE, &ldp_no_address_family_ipv4_cmd); - install_element (LDP_NODE, &ldp_no_address_family_ipv6_cmd); - install_element (LDP_NODE, &ldp_no_discovery_hello_holdtime_disc_time_cmd); - install_element (LDP_NODE, &ldp_no_discovery_hello_interval_disc_time_cmd); - install_element (LDP_NODE, &ldp_no_discovery_targeted_hello_holdtime_disc_time_cmd); - install_element (LDP_NODE, &ldp_no_discovery_targeted_hello_interval_disc_time_cmd); - install_element (LDP_NODE, &ldp_no_dual_stack_transport_connection_prefer_ipv4_cmd); - install_element (LDP_NODE, &ldp_no_dual_stack_cisco_interop_cmd); - install_element (LDP_NODE, &ldp_no_neighbor_ipv4_password_word_cmd); - install_element (LDP_NODE, &ldp_no_neighbor_ipv4_session_holdtime_session_time_cmd); - install_element (LDP_NODE, &ldp_no_neighbor_ipv4_ttl_security_disable_cmd); - install_element (LDP_NODE, &ldp_no_neighbor_ipv4_ttl_security_hops_hops_cmd); - install_element (LDP_NODE, &ldp_no_router_id_ipv4_cmd); - install_node (&ldp_ipv4_node, NULL); - install_default (LDP_IPV4_NODE); - install_element (LDP_IPV4_NODE, &ldp_discovery_hello_holdtime_disc_time_cmd); - install_element (LDP_IPV4_NODE, &ldp_discovery_hello_interval_disc_time_cmd); - install_element (LDP_IPV4_NODE, &ldp_discovery_targeted_hello_holdtime_disc_time_cmd); - install_element (LDP_IPV4_NODE, &ldp_discovery_targeted_hello_interval_disc_time_cmd); - install_element (LDP_IPV4_NODE, &ldp_discovery_targeted_hello_accept_cmd); - install_element (LDP_IPV4_NODE, &ldp_label_local_advertise_explicit_null_cmd); - install_element (LDP_IPV4_NODE, &ldp_ttl_security_disable_cmd); - install_element (LDP_IPV4_NODE, &ldp_session_holdtime_session_time_cmd); - install_element (LDP_IPV4_NODE, &ldp_interface_ifname_cmd); - install_element (LDP_IPV4_NODE, &ldp_discovery_transport_address_ipv4_cmd); - install_element (LDP_IPV4_NODE, &ldp_neighbor_ipv4_targeted_cmd); - install_element (LDP_IPV4_NODE, &ldp_no_discovery_hello_holdtime_disc_time_cmd); - install_element (LDP_IPV4_NODE, &ldp_no_discovery_hello_interval_disc_time_cmd); - install_element (LDP_IPV4_NODE, &ldp_no_discovery_targeted_hello_holdtime_disc_time_cmd); - install_element (LDP_IPV4_NODE, &ldp_no_discovery_targeted_hello_interval_disc_time_cmd); - install_element (LDP_IPV4_NODE, &ldp_no_discovery_targeted_hello_accept_cmd); - install_element (LDP_IPV4_NODE, &ldp_no_label_local_advertise_explicit_null_cmd); - install_element (LDP_IPV4_NODE, &ldp_no_ttl_security_disable_cmd); - install_element (LDP_IPV4_NODE, &ldp_no_session_holdtime_session_time_cmd); - install_element (LDP_IPV4_NODE, &ldp_no_interface_ifname_cmd); - install_element (LDP_IPV4_NODE, &ldp_no_discovery_transport_address_ipv4_cmd); - install_element (LDP_IPV4_NODE, &ldp_no_neighbor_ipv4_targeted_cmd); - install_node (&ldp_ipv6_node, NULL); - install_default (LDP_IPV6_NODE); - install_element (LDP_IPV6_NODE, &ldp_discovery_hello_holdtime_disc_time_cmd); - install_element (LDP_IPV6_NODE, &ldp_discovery_hello_interval_disc_time_cmd); - install_element (LDP_IPV6_NODE, &ldp_discovery_targeted_hello_holdtime_disc_time_cmd); - install_element (LDP_IPV6_NODE, &ldp_discovery_targeted_hello_interval_disc_time_cmd); - install_element (LDP_IPV6_NODE, &ldp_discovery_targeted_hello_accept_cmd); - install_element (LDP_IPV6_NODE, &ldp_label_local_advertise_explicit_null_cmd); - install_element (LDP_IPV6_NODE, &ldp_ttl_security_disable_cmd); - install_element (LDP_IPV6_NODE, &ldp_session_holdtime_session_time_cmd); - install_element (LDP_IPV6_NODE, &ldp_interface_ifname_cmd); - install_element (LDP_IPV6_NODE, &ldp_discovery_transport_address_ipv6_cmd); - install_element (LDP_IPV6_NODE, &ldp_neighbor_ipv6_targeted_cmd); - install_element (LDP_IPV6_NODE, &ldp_no_discovery_hello_holdtime_disc_time_cmd); - install_element (LDP_IPV6_NODE, &ldp_no_discovery_hello_interval_disc_time_cmd); - install_element (LDP_IPV6_NODE, &ldp_no_discovery_targeted_hello_holdtime_disc_time_cmd); - install_element (LDP_IPV6_NODE, &ldp_no_discovery_targeted_hello_interval_disc_time_cmd); - install_element (LDP_IPV6_NODE, &ldp_no_discovery_targeted_hello_accept_cmd); - install_element (LDP_IPV6_NODE, &ldp_no_label_local_advertise_explicit_null_cmd); - install_element (LDP_IPV6_NODE, &ldp_no_ttl_security_disable_cmd); - install_element (LDP_IPV6_NODE, &ldp_no_session_holdtime_session_time_cmd); - install_element (LDP_IPV6_NODE, &ldp_no_interface_ifname_cmd); - install_element (LDP_IPV6_NODE, &ldp_no_discovery_transport_address_ipv6_cmd); - install_element (LDP_IPV6_NODE, &ldp_no_neighbor_ipv6_targeted_cmd); - install_node (&ldp_ipv4_iface_node, NULL); - install_default (LDP_IPV4_IFACE_NODE); - install_element (LDP_IPV4_IFACE_NODE, &ldp_discovery_hello_holdtime_disc_time_cmd); - install_element (LDP_IPV4_IFACE_NODE, &ldp_discovery_hello_interval_disc_time_cmd); - install_element (LDP_IPV4_IFACE_NODE, &ldp_no_discovery_hello_holdtime_disc_time_cmd); - install_element (LDP_IPV4_IFACE_NODE, &ldp_no_discovery_hello_interval_disc_time_cmd); - install_node (&ldp_ipv6_iface_node, NULL); - install_default (LDP_IPV6_IFACE_NODE); - install_element (LDP_IPV6_IFACE_NODE, &ldp_discovery_hello_holdtime_disc_time_cmd); - install_element (LDP_IPV6_IFACE_NODE, &ldp_discovery_hello_interval_disc_time_cmd); - install_element (LDP_IPV6_IFACE_NODE, &ldp_no_discovery_hello_holdtime_disc_time_cmd); - install_element (LDP_IPV6_IFACE_NODE, &ldp_no_discovery_hello_interval_disc_time_cmd); - install_node (&ldp_l2vpn_node, ldp_l2vpn_config_write); - install_default (LDP_L2VPN_NODE); - install_element (LDP_L2VPN_NODE, &ldp_bridge_ifname_cmd); - install_element (LDP_L2VPN_NODE, &ldp_mtu_mtu_cmd); - install_element (LDP_L2VPN_NODE, &ldp_member_interface_ifname_cmd); - install_element (LDP_L2VPN_NODE, &ldp_member_pseudowire_ifname_cmd); - install_element (LDP_L2VPN_NODE, &ldp_vc_type_pwtype_cmd); - install_element (LDP_L2VPN_NODE, &ldp_no_bridge_ifname_cmd); - install_element (LDP_L2VPN_NODE, &ldp_no_mtu_mtu_cmd); - install_element (LDP_L2VPN_NODE, &ldp_no_member_interface_ifname_cmd); - install_element (LDP_L2VPN_NODE, &ldp_no_member_pseudowire_ifname_cmd); - install_element (LDP_L2VPN_NODE, &ldp_no_vc_type_pwtype_cmd); - install_node (&ldp_pseudowire_node, NULL); - install_default (LDP_PSEUDOWIRE_NODE); - install_element (LDP_PSEUDOWIRE_NODE, &ldp_control_word_cword_cmd); - install_element (LDP_PSEUDOWIRE_NODE, &ldp_neighbor_address_addr_cmd); - install_element (LDP_PSEUDOWIRE_NODE, &ldp_neighbor_lsr_id_ipv4_cmd); - install_element (LDP_PSEUDOWIRE_NODE, &ldp_pw_id_pwid_cmd); - install_element (LDP_PSEUDOWIRE_NODE, &ldp_pw_status_disable_cmd); - install_element (LDP_PSEUDOWIRE_NODE, &ldp_no_control_word_cword_cmd); - install_element (LDP_PSEUDOWIRE_NODE, &ldp_no_neighbor_address_addr_cmd); - install_element (LDP_PSEUDOWIRE_NODE, &ldp_no_neighbor_lsr_id_ipv4_cmd); - install_element (LDP_PSEUDOWIRE_NODE, &ldp_no_pw_id_pwid_cmd); - install_element (LDP_PSEUDOWIRE_NODE, &ldp_no_pw_status_disable_cmd); - install_node (&ldp_debug_node, ldp_debug_config_write); - install_element (ENABLE_NODE, &ldp_debug_mpls_ldp_discovery_hello_dir_cmd); - install_element (ENABLE_NODE, &ldp_debug_mpls_ldp_errors_cmd); - install_element (ENABLE_NODE, &ldp_debug_mpls_ldp_event_cmd); - install_element (ENABLE_NODE, &ldp_debug_mpls_ldp_messages_recv_cmd); - install_element (ENABLE_NODE, &ldp_debug_mpls_ldp_messages_recv_all_cmd); - install_element (ENABLE_NODE, &ldp_debug_mpls_ldp_messages_sent_cmd); - install_element (ENABLE_NODE, &ldp_debug_mpls_ldp_messages_sent_all_cmd); - install_element (ENABLE_NODE, &ldp_debug_mpls_ldp_zebra_cmd); - install_element (ENABLE_NODE, &ldp_no_debug_mpls_ldp_discovery_hello_dir_cmd); - install_element (ENABLE_NODE, &ldp_no_debug_mpls_ldp_errors_cmd); - install_element (ENABLE_NODE, &ldp_no_debug_mpls_ldp_event_cmd); - install_element (ENABLE_NODE, &ldp_no_debug_mpls_ldp_messages_recv_cmd); - install_element (ENABLE_NODE, &ldp_no_debug_mpls_ldp_messages_recv_all_cmd); - install_element (ENABLE_NODE, &ldp_no_debug_mpls_ldp_messages_sent_cmd); - install_element (ENABLE_NODE, &ldp_no_debug_mpls_ldp_messages_sent_all_cmd); - install_element (ENABLE_NODE, &ldp_no_debug_mpls_ldp_zebra_cmd); - install_element (VIEW_NODE, &ldp_show_mpls_ldp_neighbor_cmd); - install_element (VIEW_NODE, &ldp_show_mpls_ldp_binding_cmd); - install_element (VIEW_NODE, &ldp_show_mpls_ldp_discovery_cmd); - install_element (VIEW_NODE, &ldp_show_mpls_ldp_interface_cmd); - install_element (VIEW_NODE, &ldp_show_mpls_ldp_address_family_binding_cmd); - install_element (VIEW_NODE, &ldp_show_mpls_ldp_address_family_discovery_cmd); - install_element (VIEW_NODE, &ldp_show_mpls_ldp_address_family_interface_cmd); - install_element (VIEW_NODE, &ldp_show_l2vpn_atom_binding_cmd); - install_element (VIEW_NODE, &ldp_show_l2vpn_atom_vc_cmd); - install_element (VIEW_NODE, &ldp_show_debugging_mpls_ldp_cmd); - install_element (VIEW_NODE, &ldp_clear_mpls_ldp_neighbor_cmd); - install_element (VIEW_NODE, &ldp_clear_mpls_ldp_neighbor_addr_cmd); -} \ No newline at end of file From d3e1887ad6b5ae2199710b3278c277838e6ef913 Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Sat, 3 Dec 2016 21:14:44 -0200 Subject: [PATCH 043/107] ldpd: use red-black trees to store 'lde_map' elements Using red-black trees instead of linked lists brings the following benefits: 1 - Elements are naturally ordered (no need to reorder anything before outputting data to the user); 2 - Faster lookups/deletes: O(log n) time complexity against O(n). The insert operation with red-black trees is more expensive though, but that's not a big issue since lookups are much more frequent. Signed-off-by: Renato Westphal --- ldpd/l2vpn.c | 4 ++-- ldpd/lde.c | 17 ++++++++++++++--- ldpd/lde.h | 9 ++++++--- ldpd/lde_lib.c | 18 +++++++++--------- 4 files changed, 31 insertions(+), 17 deletions(-) diff --git a/ldpd/l2vpn.c b/ldpd/l2vpn.c index 851ff77b73..c0f6586854 100644 --- a/ldpd/l2vpn.c +++ b/ldpd/l2vpn.c @@ -459,7 +459,7 @@ l2vpn_binding_ctl(pid_t pid) fn = (struct fec_node *)f; if (fn->local_label == NO_LABEL && - LIST_EMPTY(&fn->downstream)) + RB_EMPTY(&fn->downstream)) continue; memset(&pwctl, 0, sizeof(pwctl)); @@ -477,7 +477,7 @@ l2vpn_binding_ctl(pid_t pid) } else pwctl.local_label = NO_LABEL; - LIST_FOREACH(me, &fn->downstream, entry) + RB_FOREACH(me, lde_map_head, &fn->downstream) if (f->u.pwid.lsr_id.s_addr == me->nexthop->id.s_addr) break; diff --git a/ldpd/lde.c b/ldpd/lde.c index 67ed982ec5..a1309c6448 100644 --- a/ldpd/lde.c +++ b/ldpd/lde.c @@ -45,12 +45,14 @@ static struct lde_nbr *lde_nbr_find(uint32_t); static void lde_nbr_clear(void); static void lde_nbr_addr_update(struct lde_nbr *, struct lde_addr *, int); +static __inline int lde_map_compare(struct lde_map *, struct lde_map *); static void lde_map_free(void *); static int lde_address_add(struct lde_nbr *, struct lde_addr *); static int lde_address_del(struct lde_nbr *, struct lde_addr *); static void lde_address_list_free(struct lde_nbr *); RB_GENERATE(nbr_tree, lde_nbr, entry, lde_nbr_compare) +RB_GENERATE(lde_map_head, lde_map, entry, lde_map_compare) struct ldpd_conf *ldeconf; struct nbr_tree lde_nbrs = RB_INITIALIZER(&lde_nbrs); @@ -1141,6 +1143,13 @@ lde_nbr_addr_update(struct lde_nbr *ln, struct lde_addr *lde_addr, int removed) } } +static __inline int +lde_map_compare(struct lde_map *a, struct lde_map *b) +{ + return (ldp_addrcmp(AF_INET, (union ldpd_addr *)&a->nexthop->id, + (union ldpd_addr *)&b->nexthop->id)); +} + struct lde_map * lde_map_add(struct lde_nbr *ln, struct fec_node *fn, int sent) { @@ -1154,13 +1163,15 @@ lde_map_add(struct lde_nbr *ln, struct fec_node *fn, int sent) me->nexthop = ln; if (sent) { - LIST_INSERT_HEAD(&fn->upstream, me, entry); + RB_INSERT(lde_map_head, &fn->upstream, me); + me->head = &fn->upstream; if (fec_insert(&ln->sent_map, &me->fec)) log_warnx("failed to add %s to sent map", log_fec(&me->fec)); /* XXX on failure more cleanup is needed */ } else { - LIST_INSERT_HEAD(&fn->downstream, me, entry); + RB_INSERT(lde_map_head, &fn->downstream, me); + me->head = &fn->downstream; if (fec_insert(&ln->recv_map, &me->fec)) log_warnx("failed to add %s to recv map", log_fec(&me->fec)); @@ -1185,7 +1196,7 @@ lde_map_free(void *ptr) { struct lde_map *map = ptr; - LIST_REMOVE(map, entry); + RB_REMOVE(lde_map_head, map->head, map); free(map); } diff --git a/ldpd/lde.h b/ldpd/lde.h index 5f5d37defb..fe90b2c852 100644 --- a/ldpd/lde.h +++ b/ldpd/lde.h @@ -62,10 +62,13 @@ struct lde_req { /* mapping entries */ struct lde_map { struct fec fec; - LIST_ENTRY(lde_map) entry; + struct lde_map_head *head; /* fec_node's upstream/downstream */ + RB_ENTRY(lde_map) entry; struct lde_nbr *nexthop; struct map map; }; +RB_HEAD(lde_map_head, lde_map); +RB_PROTOTYPE(lde_map_head, lde_map, entry, lde_map_cmp); /* withdraw entries */ struct lde_wdraw { @@ -112,8 +115,8 @@ struct fec_node { struct fec fec; LIST_HEAD(, fec_nh) nexthops; /* fib nexthops */ - LIST_HEAD(, lde_map) downstream; /* recv mappings */ - LIST_HEAD(, lde_map) upstream; /* sent mappings */ + struct lde_map_head downstream; /* recv mappings */ + struct lde_map_head upstream; /* sent mappings */ uint32_t local_label; void *data; /* fec specific data */ diff --git a/ldpd/lde_lib.c b/ldpd/lde_lib.c index 14ac592af9..df65edad1a 100644 --- a/ldpd/lde_lib.c +++ b/ldpd/lde_lib.c @@ -159,7 +159,7 @@ rt_dump(pid_t pid) RB_FOREACH(f, fec_tree, &ft) { fn = (struct fec_node *)f; if (fn->local_label == NO_LABEL && - LIST_EMPTY(&fn->downstream)) + RB_EMPTY(&fn->downstream)) continue; rtctl.first = 1; @@ -179,7 +179,7 @@ rt_dump(pid_t pid) } rtctl.local_label = fn->local_label; - LIST_FOREACH(me, &fn->downstream, entry) { + RB_FOREACH(me, lde_map_head, &fn->downstream) { rtctl.in_use = lde_nbr_is_nexthop(fn, me->nexthop); rtctl.nexthop = me->nexthop->id; rtctl.remote_label = me->map.label; @@ -188,7 +188,7 @@ rt_dump(pid_t pid) &rtctl, sizeof(rtctl)); rtctl.first = 0; } - if (LIST_EMPTY(&fn->downstream)) { + if (RB_EMPTY(&fn->downstream)) { rtctl.in_use = 0; rtctl.nexthop.s_addr = INADDR_ANY; rtctl.remote_label = NO_LABEL; @@ -224,10 +224,10 @@ fec_free(void *arg) while ((fnh = LIST_FIRST(&fn->nexthops))) fec_nh_del(fnh); - if (!LIST_EMPTY(&fn->downstream)) + if (!RB_EMPTY(&fn->downstream)) log_warnx("%s: fec %s downstream list not empty", __func__, log_fec(&fn->fec)); - if (!LIST_EMPTY(&fn->upstream)) + if (!RB_EMPTY(&fn->upstream)) log_warnx("%s: fec %s upstream list not empty", __func__, log_fec(&fn->fec)); @@ -251,8 +251,8 @@ fec_add(struct fec *fec) fn->fec = *fec; fn->local_label = NO_LABEL; - LIST_INIT(&fn->upstream); - LIST_INIT(&fn->downstream); + RB_INIT(&fn->upstream); + RB_INIT(&fn->downstream); LIST_INIT(&fn->nexthops); if (fec_insert(&ft, &fn->fec)) @@ -774,8 +774,8 @@ lde_gc_timer(struct thread *thread) fn = (struct fec_node *) fec; if (!LIST_EMPTY(&fn->nexthops) || - !LIST_EMPTY(&fn->downstream) || - !LIST_EMPTY(&fn->upstream)) + !RB_EMPTY(&fn->downstream) || + !RB_EMPTY(&fn->upstream)) continue; fec_remove(&ft, &fn->fec); From 7d3d7491a0bc4b04ee6f65e26ae5f115df5a34f1 Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Tue, 13 Dec 2016 15:29:35 -0200 Subject: [PATCH 044/107] ldpd: use red-black trees to store 'iface' elements Using red-black trees instead of linked lists brings the following benefits: 1 - Elements are naturally ordered (no need to reorder anything before outputting data to the user); 2 - Faster lookups/deletes: O(log n) time complexity against O(n). The insert operation with red-black trees is more expensive though, but that's not a big issue since lookups are much more frequent. Signed-off-by: Renato Westphal --- ldpd/interface.c | 37 +++++++++++++++++++++---------------- ldpd/lde.c | 4 ++-- ldpd/ldp_debug.c | 4 ++-- ldpd/ldp_vty_conf.c | 10 +++++----- ldpd/ldpd.c | 32 ++++++++++++++++---------------- ldpd/ldpd.h | 11 +++++++---- ldpd/ldpe.c | 8 ++++---- 7 files changed, 57 insertions(+), 49 deletions(-) diff --git a/ldpd/interface.c b/ldpd/interface.c index b6472fe5e8..06d36fef72 100644 --- a/ldpd/interface.c +++ b/ldpd/interface.c @@ -26,6 +26,7 @@ #include "sockopt.h" +static __inline int iface_compare(struct iface *, struct iface *); static struct if_addr *if_addr_new(struct kaddr *); static struct if_addr *if_addr_lookup(struct if_addr_head *, struct kaddr *); static int if_start(struct iface *, int); @@ -39,6 +40,14 @@ static int if_leave_ipv4_group(struct iface *, struct in_addr *); static int if_join_ipv6_group(struct iface *, struct in6_addr *); static int if_leave_ipv6_group(struct iface *, struct in6_addr *); +RB_GENERATE(iface_head, iface, entry, iface_compare) + +static __inline int +iface_compare(struct iface *a, struct iface *b) +{ + return (strcmp(a->name, b->name)); +} + struct iface * if_new(struct kif *kif) { @@ -69,18 +78,6 @@ if_new(struct kif *kif) return (iface); } -struct iface * -if_lookup(struct ldpd_conf *xconf, unsigned short ifindex) -{ - struct iface *iface; - - LIST_FOREACH(iface, &xconf->iface_list, entry) - if (iface->ifindex == ifindex) - return (iface); - - return (NULL); -} - void if_exit(struct iface *iface) { @@ -100,17 +97,25 @@ if_exit(struct iface *iface) } struct iface * -if_lookup_name(struct ldpd_conf *xconf, const char *ifname) +if_lookup(struct ldpd_conf *xconf, unsigned short ifindex) { struct iface *iface; - LIST_FOREACH(iface, &xconf->iface_list, entry) - if (strcmp(iface->name, ifname) == 0) + RB_FOREACH(iface, iface_head, &xconf->iface_tree) + if (iface->ifindex == ifindex) return (iface); return (NULL); } +struct iface * +if_lookup_name(struct ldpd_conf *xconf, const char *ifname) +{ + struct iface iface; + strlcpy(iface.name, ifname, sizeof(iface.name)); + return (RB_FIND(iface_head, &xconf->iface_tree, &iface)); +} + void if_update_info(struct iface *iface, struct kif *kif) { @@ -380,7 +385,7 @@ if_update_all(int af) { struct iface *iface; - LIST_FOREACH(iface, &leconf->iface_list, entry) + RB_FOREACH(iface, iface_head, &leconf->iface_tree) if_update(iface, af); } diff --git a/ldpd/lde.c b/ldpd/lde.c index a1309c6448..1e362185d2 100644 --- a/ldpd/lde.c +++ b/ldpd/lde.c @@ -473,7 +473,7 @@ lde_dispatch_parent(struct thread *thread) fatal(NULL); memcpy(nconf, imsg.data, sizeof(struct ldpd_conf)); - LIST_INIT(&nconf->iface_list); + RB_INIT(&nconf->iface_tree); LIST_INIT(&nconf->tnbr_list); LIST_INIT(&nconf->nbrp_list); LIST_INIT(&nconf->l2vpn_list); @@ -489,7 +489,7 @@ lde_dispatch_parent(struct thread *thread) niface->ipv4.iface = niface; niface->ipv6.iface = niface; - LIST_INSERT_HEAD(&nconf->iface_list, niface, entry); + RB_INSERT(iface_head, &nconf->iface_tree, niface); break; case IMSG_RECONF_TNBR: if ((ntnbr = malloc(sizeof(struct tnbr))) == NULL) diff --git a/ldpd/ldp_debug.c b/ldpd/ldp_debug.c index 15dd06a0f3..86b679d8aa 100644 --- a/ldpd/ldp_debug.c +++ b/ldpd/ldp_debug.c @@ -74,7 +74,7 @@ ldp_vty_debug(struct vty *vty, struct vty_arg *args[]) DEBUG_OFF(event, EVENT); else DEBUG_ON(event, EVENT); - } else if (strcmp(type_str, "messages") == 0) { + } else if (strcmp(type_str, "messages") == 0) { all = (vty_get_arg_value(args, "all")) ? 1 : 0; dir_str = vty_get_arg_value(args, "dir"); if (dir_str == NULL) @@ -99,7 +99,7 @@ ldp_vty_debug(struct vty *vty, struct vty_arg *args[]) DEBUG_ON(msg, MSG_SEND_ALL); } } - } else if (strcmp(type_str, "zebra") == 0) { + } else if (strcmp(type_str, "zebra") == 0) { if (disable) DEBUG_OFF(zebra, ZEBRA); else diff --git a/ldpd/ldp_vty_conf.c b/ldpd/ldp_vty_conf.c index dd70365f3d..689554d857 100644 --- a/ldpd/ldp_vty_conf.c +++ b/ldpd/ldp_vty_conf.c @@ -142,7 +142,7 @@ ldp_af_iface_config_write(struct vty *vty, int af) struct iface *iface; struct iface_af *ia; - LIST_FOREACH(iface, &ldpd_conf->iface_list, entry) { + RB_FOREACH(iface, iface_head, &ldpd_conf->iface_tree) { ia = iface_af_get(iface, af); if (!ia->enabled) continue; @@ -857,7 +857,7 @@ ldp_vty_interface(struct vty *vty, struct vty_arg *args[]) ia = iface_af_get(iface, af); ia->enabled = 1; - LIST_INSERT_HEAD(&vty_conf->iface_list, iface, entry); + RB_INSERT(iface_head, &vty_conf->iface_tree, iface); ldp_reload_ref(vty_conf, (void **)&iface); } else { memset(&kif, 0, sizeof(kif)); @@ -1641,14 +1641,14 @@ iface_new_api(struct ldpd_conf *conf, const char *name) } iface = if_new(&kif); - LIST_INSERT_HEAD(&conf->iface_list, iface, entry); + RB_INSERT(iface_head, &conf->iface_tree, iface); return (iface); } void -iface_del_api(struct iface *iface) +iface_del_api(struct ldpd_conf *conf, struct iface *iface) { - LIST_REMOVE(iface, entry); + RB_REMOVE(iface_head, &conf->iface_tree, iface); free(iface); } diff --git a/ldpd/ldpd.c b/ldpd/ldpd.c index aa1dc57a7b..14cfaffbb9 100644 --- a/ldpd/ldpd.c +++ b/ldpd/ldpd.c @@ -850,7 +850,7 @@ main_imsg_send_config(struct ldpd_conf *xconf) sizeof(*xconf)) == -1) return (-1); - LIST_FOREACH(iface, &xconf->iface_list, entry) { + RB_FOREACH(iface, iface_head, &xconf->iface_tree) { if (main_imsg_compose_both(IMSG_RECONF_IFACE, iface, sizeof(*iface)) == -1) return (-1); @@ -954,10 +954,10 @@ ldp_config_reset_main(struct ldpd_conf *conf, void **ref) struct iface *iface; struct nbr_params *nbrp; - while ((iface = LIST_FIRST(&conf->iface_list)) != NULL) { + while ((iface = RB_ROOT(&conf->iface_tree)) != NULL) { if (ref && *ref == iface) *ref = NULL; - LIST_REMOVE(iface, entry); + RB_REMOVE(iface_head, &conf->iface_tree, iface); free(iface); } @@ -987,7 +987,7 @@ ldp_config_reset_af(struct ldpd_conf *conf, int af, void **ref) struct iface_af *ia; struct tnbr *tnbr, *ttmp; - LIST_FOREACH(iface, &conf->iface_list, entry) { + RB_FOREACH(iface, iface_head, &conf->iface_tree) { ia = iface_af_get(iface, af); ia->enabled = 0; } @@ -1032,16 +1032,16 @@ ldp_dup_config_ref(struct ldpd_conf *conf, void **ref) } while (0) COPY(xconf, conf); - LIST_INIT(&xconf->iface_list); + RB_INIT(&xconf->iface_tree); LIST_INIT(&xconf->tnbr_list); LIST_INIT(&xconf->nbrp_list); LIST_INIT(&xconf->l2vpn_list); - LIST_FOREACH(iface, &conf->iface_list, entry) { + RB_FOREACH(iface, iface_head, &conf->iface_tree) { COPY(xi, iface); xi->ipv4.iface = xi; xi->ipv6.iface = xi; - LIST_INSERT_HEAD(&xconf->iface_list, xi, entry); + RB_INSERT(iface_head, &xconf->iface_tree, xi); } LIST_FOREACH(tnbr, &conf->tnbr_list, entry) { COPY(xt, tnbr); @@ -1093,8 +1093,8 @@ ldp_clear_config(struct ldpd_conf *xconf) struct nbr_params *nbrp; struct l2vpn *l2vpn; - while ((iface = LIST_FIRST(&xconf->iface_list)) != NULL) { - LIST_REMOVE(iface, entry); + while ((iface = RB_ROOT(&xconf->iface_tree)) != NULL) { + RB_REMOVE(iface_head, &xconf->iface_tree, iface); free(iface); } while ((tnbr = LIST_FIRST(&xconf->tnbr_list)) != NULL) { @@ -1236,10 +1236,10 @@ merge_ifaces(struct ldpd_conf *conf, struct ldpd_conf *xconf, void **ref) { struct iface *iface, *itmp, *xi; - LIST_FOREACH_SAFE(iface, &conf->iface_list, entry, itmp) { + RB_FOREACH_SAFE(iface, iface_head, &conf->iface_tree, itmp) { /* find deleted interfaces */ if ((xi = if_lookup_name(xconf, iface->name)) == NULL) { - LIST_REMOVE(iface, entry); + RB_REMOVE(iface_head, &conf->iface_tree, iface); switch (ldpd_process) { case PROC_LDE_ENGINE: @@ -1254,11 +1254,11 @@ merge_ifaces(struct ldpd_conf *conf, struct ldpd_conf *xconf, void **ref) free(iface); } } - LIST_FOREACH_SAFE(xi, &xconf->iface_list, entry, itmp) { + RB_FOREACH_SAFE(xi, iface_head, &xconf->iface_tree, itmp) { /* find new interfaces */ if ((iface = if_lookup_name(conf, xi->name)) == NULL) { - LIST_REMOVE(xi, entry); - LIST_INSERT_HEAD(&conf->iface_list, xi, entry); + RB_REMOVE(iface_head, &xconf->iface_tree, xi); + RB_INSERT(iface_head, &conf->iface_tree, xi); if (ldpd_process == PROC_MAIN) { QOBJ_REG (xi, iface); @@ -1271,7 +1271,7 @@ merge_ifaces(struct ldpd_conf *conf, struct ldpd_conf *xconf, void **ref) /* update existing interfaces */ merge_iface_af(&iface->ipv4, &xi->ipv4); merge_iface_af(&iface->ipv6, &xi->ipv6); - LIST_REMOVE(xi, entry); + RB_REMOVE(iface_head, &xconf->iface_tree, xi); if (ref && *ref == xi) *ref = iface; free(xi); @@ -1770,7 +1770,7 @@ config_new_empty(void) if (xconf == NULL) fatal(NULL); - LIST_INIT(&xconf->iface_list); + RB_INIT(&xconf->iface_tree); LIST_INIT(&xconf->tnbr_list); LIST_INIT(&xconf->nbrp_list); LIST_INIT(&xconf->l2vpn_list); diff --git a/ldpd/ldpd.h b/ldpd/ldpd.h index 630b192489..2c516c013b 100644 --- a/ldpd/ldpd.h +++ b/ldpd/ldpd.h @@ -264,7 +264,7 @@ struct iface_af { }; struct iface { - LIST_ENTRY(iface) entry; + RB_ENTRY(iface) entry; char name[IF_NAMESIZE]; unsigned int ifindex; struct if_addr_head addr_list; @@ -275,6 +275,8 @@ struct iface { struct iface_af ipv6; QOBJ_FIELDS }; +RB_HEAD(iface_head, iface); +RB_PROTOTYPE(iface_head, iface, entry, iface_compare); DECLARE_QOBJ_TYPE(iface) /* source of targeted hellos */ @@ -404,7 +406,7 @@ struct ldpd_conf { struct in_addr rtr_id; struct ldpd_af_conf ipv4; struct ldpd_af_conf ipv6; - LIST_HEAD(, iface) iface_list; + struct iface_head iface_tree; LIST_HEAD(, tnbr) tnbr_list; LIST_HEAD(, nbr_params) nbrp_list; LIST_HEAD(, l2vpn) l2vpn_list; @@ -627,9 +629,10 @@ void config_clear(struct ldpd_conf *); /* ldp_vty_conf.c */ /* NOTE: the parameters' names should be preserved because of codegen */ -struct iface *iface_new_api(struct ldpd_conf *cfg, +struct iface *iface_new_api(struct ldpd_conf *conf, const char *name); -void iface_del_api(struct iface *iface); +void iface_del_api(struct ldpd_conf *conf, + struct iface *iface); struct tnbr *tnbr_new_api(struct ldpd_conf *cfg, int af, union ldpd_addr *addr); void tnbr_del_api(struct tnbr *tnbr); diff --git a/ldpd/ldpe.c b/ldpd/ldpe.c index aef33c8e37..16910a3cc8 100644 --- a/ldpd/ldpe.c +++ b/ldpd/ldpe.c @@ -414,7 +414,7 @@ ldpe_dispatch_main(struct thread *thread) fatal(NULL); memcpy(nconf, imsg.data, sizeof(struct ldpd_conf)); - LIST_INIT(&nconf->iface_list); + RB_INIT(&nconf->iface_tree); LIST_INIT(&nconf->tnbr_list); LIST_INIT(&nconf->nbrp_list); LIST_INIT(&nconf->l2vpn_list); @@ -430,7 +430,7 @@ ldpe_dispatch_main(struct thread *thread) niface->ipv4.iface = niface; niface->ipv6.iface = niface; - LIST_INSERT_HEAD(&nconf->iface_list, niface, entry); + RB_INSERT(iface_head, &nconf->iface_tree, niface); break; case IMSG_RECONF_TNBR: if ((ntnbr = malloc(sizeof(struct tnbr))) == NULL) @@ -772,7 +772,7 @@ ldpe_iface_af_ctl(struct ctl_conn *c, int af, unsigned int idx) struct iface_af *ia; struct ctl_iface *ictl; - LIST_FOREACH(iface, &leconf->iface_list, entry) { + RB_FOREACH(iface, iface_head, &leconf->iface_tree) { if (idx == 0 || idx == iface->ifindex) { ia = iface_af_get(iface, af); if (!ia->enabled) @@ -805,7 +805,7 @@ ldpe_adj_ctl(struct ctl_conn *c) imsg_compose_event(&c->iev, IMSG_CTL_SHOW_DISCOVERY, 0, 0, -1, NULL, 0); - LIST_FOREACH(iface, &leconf->iface_list, entry) { + RB_FOREACH(iface, iface_head, &leconf->iface_tree) { memset(&ictl, 0, sizeof(ictl)); ictl.active_v4 = (iface->ipv4.state == IF_STA_ACTIVE); ictl.active_v6 = (iface->ipv6.state == IF_STA_ACTIVE); From 7989cdba45f631fb14d1bcaf7103c9db25605971 Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Tue, 13 Dec 2016 16:19:15 -0200 Subject: [PATCH 045/107] ldpd: use red-black trees to store 'tnbr' elements Using red-black trees instead of linked lists brings the following benefits: 1 - Elements are naturally ordered (no need to reorder anything before outputting data to the user); 2 - Faster lookups/deletes: O(log n) time complexity against O(n). The insert operation with red-black trees is more expensive though, but that's not a big issue since lookups are much more frequent. Signed-off-by: Renato Westphal --- ldpd/adjacency.c | 40 +++++++++++++++++++++++++--------------- ldpd/hello.c | 4 ++-- ldpd/l2vpn.c | 4 ++-- ldpd/lde.c | 4 ++-- ldpd/ldp_vty_conf.c | 12 ++++++------ ldpd/ldpd.c | 34 +++++++++++++++++----------------- ldpd/ldpd.h | 10 ++++++---- ldpd/ldpe.c | 10 +++++----- ldpd/ldpe.h | 2 +- 9 files changed, 66 insertions(+), 54 deletions(-) diff --git a/ldpd/adjacency.c b/ldpd/adjacency.c index d1a6facb30..3f478df38a 100644 --- a/ldpd/adjacency.c +++ b/ldpd/adjacency.c @@ -26,11 +26,14 @@ #include "log.h" static int adj_itimer(struct thread *); -static void tnbr_del(struct tnbr *); +static __inline int tnbr_compare(struct tnbr *, struct tnbr *); +static void tnbr_del(struct ldpd_conf *, struct tnbr *); static int tnbr_hello_timer(struct thread *); static void tnbr_start_hello_timer(struct tnbr *); static void tnbr_stop_hello_timer(struct tnbr *); +RB_GENERATE(tnbr_head, tnbr, entry, tnbr_compare) + struct adj * adj_new(struct in_addr lsr_id, struct hello_source *source, union ldpd_addr *addr) @@ -165,7 +168,7 @@ adj_itimer(struct thread *thread) if (!(adj->source.target->flags & F_TNBR_CONFIGURED) && adj->source.target->pw_count == 0) { /* remove dynamic targeted neighbor */ - tnbr_del(adj->source.target); + tnbr_del(leconf, adj->source.target); return (0); } adj->source.target->adj = NULL; @@ -192,6 +195,17 @@ adj_stop_itimer(struct adj *adj) /* targeted neighbors */ +static __inline int +tnbr_compare(struct tnbr *a, struct tnbr *b) +{ + if (a->af < b->af) + return (-1); + if (a->af > b->af) + return (1); + + return (ldp_addrcmp(a->af, &a->addr, &b->addr)); +} + struct tnbr * tnbr_new(int af, union ldpd_addr *addr) { @@ -208,34 +222,30 @@ tnbr_new(int af, union ldpd_addr *addr) } static void -tnbr_del(struct tnbr *tnbr) +tnbr_del(struct ldpd_conf *xconf, struct tnbr *tnbr) { tnbr_stop_hello_timer(tnbr); if (tnbr->adj) adj_del(tnbr->adj, S_SHUTDOWN); - LIST_REMOVE(tnbr, entry); + RB_REMOVE(tnbr_head, &xconf->tnbr_tree, tnbr); free(tnbr); } struct tnbr * tnbr_find(struct ldpd_conf *xconf, int af, union ldpd_addr *addr) { - struct tnbr *tnbr; - - LIST_FOREACH(tnbr, &xconf->tnbr_list, entry) - if (af == tnbr->af && - ldp_addrcmp(af, addr, &tnbr->addr) == 0) - return (tnbr); - - return (NULL); + struct tnbr tnbr; + tnbr.af = af; + tnbr.addr = *addr; + return (RB_FIND(tnbr_head, &xconf->tnbr_tree, &tnbr)); } struct tnbr * -tnbr_check(struct tnbr *tnbr) +tnbr_check(struct ldpd_conf *xconf, struct tnbr *tnbr) { if (!(tnbr->flags & (F_TNBR_CONFIGURED|F_TNBR_DYNAMIC)) && tnbr->pw_count == 0) { - tnbr_del(tnbr); + tnbr_del(xconf, tnbr); return (NULL); } @@ -280,7 +290,7 @@ tnbr_update_all(int af) struct tnbr *tnbr; /* update targeted neighbors */ - LIST_FOREACH(tnbr, &leconf->tnbr_list, entry) + RB_FOREACH(tnbr, tnbr_head, &leconf->tnbr_tree) if (tnbr->af == af || af == AF_UNSPEC) tnbr_update(tnbr); } diff --git a/ldpd/hello.c b/ldpd/hello.c index 755b25aa85..0833ebbafb 100644 --- a/ldpd/hello.c +++ b/ldpd/hello.c @@ -261,7 +261,7 @@ recv_hello(struct in_addr lsr_id, struct ldp_msg *msg, int af, if (tnbr && (tnbr->flags & F_TNBR_DYNAMIC) && !((flags & F_HELLO_REQ_TARG))) { tnbr->flags &= ~F_TNBR_DYNAMIC; - tnbr = tnbr_check(tnbr); + tnbr = tnbr_check(leconf, tnbr); } if (!tnbr) { @@ -273,7 +273,7 @@ recv_hello(struct in_addr lsr_id, struct ldp_msg *msg, int af, tnbr = tnbr_new(af, src); tnbr->flags |= F_TNBR_DYNAMIC; tnbr_update(tnbr); - LIST_INSERT_HEAD(&leconf->tnbr_list, tnbr, entry); + RB_INSERT(tnbr_head, &leconf->tnbr_tree, tnbr); } source.type = HELLO_TARGETED; diff --git a/ldpd/l2vpn.c b/ldpd/l2vpn.c index c0f6586854..dc9879ef23 100644 --- a/ldpd/l2vpn.c +++ b/ldpd/l2vpn.c @@ -530,7 +530,7 @@ ldpe_l2vpn_pw_init(struct l2vpn_pw *pw) if (tnbr == NULL) { tnbr = tnbr_new(pw->af, &pw->addr); tnbr_update(tnbr); - LIST_INSERT_HEAD(&leconf->tnbr_list, tnbr, entry); + RB_INSERT(tnbr_head, &leconf->tnbr_tree, tnbr); } tnbr->pw_count++; @@ -544,6 +544,6 @@ ldpe_l2vpn_pw_exit(struct l2vpn_pw *pw) tnbr = tnbr_find(leconf, pw->af, &pw->addr); if (tnbr) { tnbr->pw_count--; - tnbr_check(tnbr); + tnbr_check(leconf, tnbr); } } diff --git a/ldpd/lde.c b/ldpd/lde.c index 1e362185d2..4b957c55e7 100644 --- a/ldpd/lde.c +++ b/ldpd/lde.c @@ -474,7 +474,7 @@ lde_dispatch_parent(struct thread *thread) memcpy(nconf, imsg.data, sizeof(struct ldpd_conf)); RB_INIT(&nconf->iface_tree); - LIST_INIT(&nconf->tnbr_list); + RB_INIT(&nconf->tnbr_tree); LIST_INIT(&nconf->nbrp_list); LIST_INIT(&nconf->l2vpn_list); break; @@ -496,7 +496,7 @@ lde_dispatch_parent(struct thread *thread) fatal(NULL); memcpy(ntnbr, imsg.data, sizeof(struct tnbr)); - LIST_INSERT_HEAD(&nconf->tnbr_list, ntnbr, entry); + RB_INSERT(tnbr_head, &nconf->tnbr_tree, ntnbr); break; case IMSG_RECONF_NBRP: if ((nnbrp = malloc(sizeof(struct nbr_params))) == NULL) diff --git a/ldpd/ldp_vty_conf.c b/ldpd/ldp_vty_conf.c index 689554d857..f5c98eb1ff 100644 --- a/ldpd/ldp_vty_conf.c +++ b/ldpd/ldp_vty_conf.c @@ -213,7 +213,7 @@ ldp_af_config_write(struct vty *vty, int af, struct ldpd_conf *conf, vty_out(vty, " session holdtime %u%s", af_conf->keepalive, VTY_NEWLINE); - LIST_FOREACH(tnbr, &ldpd_conf->tnbr_list, entry) { + RB_FOREACH(tnbr, tnbr_head, &ldpd_conf->tnbr_tree) { if (tnbr->af == af) { vty_out(vty, " !%s", VTY_NEWLINE); vty_out(vty, " neighbor %s targeted%s", @@ -955,7 +955,7 @@ ldp_vty_neighbor_targeted(struct vty *vty, struct vty_arg *args[]) if (tnbr == NULL) goto cancel; - LIST_REMOVE(tnbr, entry); + RB_REMOVE(tnbr_head, &vty_conf->tnbr_tree, tnbr); free(tnbr); ldp_reload(vty_conf); return (CMD_SUCCESS); @@ -966,7 +966,7 @@ ldp_vty_neighbor_targeted(struct vty *vty, struct vty_arg *args[]) tnbr = tnbr_new(af, &addr); tnbr->flags |= F_TNBR_CONFIGURED; - LIST_INSERT_HEAD(&vty_conf->tnbr_list, tnbr, entry); + RB_INSERT(tnbr_head, &vty_conf->tnbr_tree, tnbr); ldp_reload(vty_conf); @@ -1665,14 +1665,14 @@ tnbr_new_api(struct ldpd_conf *conf, int af, union ldpd_addr *addr) tnbr = tnbr_new(af, addr); tnbr->flags |= F_TNBR_CONFIGURED; - LIST_INSERT_HEAD(&conf->tnbr_list, tnbr, entry); + RB_INSERT(tnbr_head, &conf->tnbr_tree, tnbr); return (tnbr); } void -tnbr_del_api(struct tnbr *tnbr) +tnbr_del_api(struct ldpd_conf *conf, struct tnbr *tnbr) { - LIST_REMOVE(tnbr, entry); + RB_REMOVE(tnbr_head, &conf->tnbr_tree, tnbr); free(tnbr); } diff --git a/ldpd/ldpd.c b/ldpd/ldpd.c index 14cfaffbb9..cf793f58c3 100644 --- a/ldpd/ldpd.c +++ b/ldpd/ldpd.c @@ -856,7 +856,7 @@ main_imsg_send_config(struct ldpd_conf *xconf) return (-1); } - LIST_FOREACH(tnbr, &xconf->tnbr_list, entry) { + RB_FOREACH(tnbr, tnbr_head, &xconf->tnbr_tree) { if (main_imsg_compose_both(IMSG_RECONF_TNBR, tnbr, sizeof(*tnbr)) == -1) return (-1); @@ -992,13 +992,13 @@ ldp_config_reset_af(struct ldpd_conf *conf, int af, void **ref) ia->enabled = 0; } - LIST_FOREACH_SAFE(tnbr, &conf->tnbr_list, entry, ttmp) { + RB_FOREACH_SAFE(tnbr, tnbr_head, &conf->tnbr_tree, ttmp) { if (tnbr->af != af) continue; if (ref && *ref == tnbr) *ref = NULL; - LIST_REMOVE(tnbr, entry); + RB_REMOVE(tnbr_head, &conf->tnbr_tree, tnbr); free(tnbr); } @@ -1033,7 +1033,7 @@ ldp_dup_config_ref(struct ldpd_conf *conf, void **ref) COPY(xconf, conf); RB_INIT(&xconf->iface_tree); - LIST_INIT(&xconf->tnbr_list); + RB_INIT(&xconf->tnbr_tree); LIST_INIT(&xconf->nbrp_list); LIST_INIT(&xconf->l2vpn_list); @@ -1043,9 +1043,9 @@ ldp_dup_config_ref(struct ldpd_conf *conf, void **ref) xi->ipv6.iface = xi; RB_INSERT(iface_head, &xconf->iface_tree, xi); } - LIST_FOREACH(tnbr, &conf->tnbr_list, entry) { + RB_FOREACH(tnbr, tnbr_head, &conf->tnbr_tree) { COPY(xt, tnbr); - LIST_INSERT_HEAD(&xconf->tnbr_list, xt, entry); + RB_INSERT(tnbr_head, &xconf->tnbr_tree, xt); } LIST_FOREACH(nbrp, &conf->nbrp_list, entry) { COPY(xn, nbrp); @@ -1097,8 +1097,8 @@ ldp_clear_config(struct ldpd_conf *xconf) RB_REMOVE(iface_head, &xconf->iface_tree, iface); free(iface); } - while ((tnbr = LIST_FIRST(&xconf->tnbr_list)) != NULL) { - LIST_REMOVE(tnbr, entry); + while ((tnbr = RB_ROOT(&xconf->tnbr_tree)) != NULL) { + RB_REMOVE(tnbr_head, &xconf->tnbr_tree, tnbr); free(tnbr); } while ((nbrp = LIST_FIRST(&xconf->nbrp_list)) != NULL) { @@ -1295,7 +1295,7 @@ merge_tnbrs(struct ldpd_conf *conf, struct ldpd_conf *xconf, void **ref) { struct tnbr *tnbr, *ttmp, *xt; - LIST_FOREACH_SAFE(tnbr, &conf->tnbr_list, entry, ttmp) { + RB_FOREACH_SAFE(tnbr, tnbr_head, &conf->tnbr_tree, ttmp) { if (!(tnbr->flags & F_TNBR_CONFIGURED)) continue; @@ -1303,26 +1303,26 @@ merge_tnbrs(struct ldpd_conf *conf, struct ldpd_conf *xconf, void **ref) if ((xt = tnbr_find(xconf, tnbr->af, &tnbr->addr)) == NULL) { switch (ldpd_process) { case PROC_LDE_ENGINE: - LIST_REMOVE(tnbr, entry); + RB_REMOVE(tnbr_head, &conf->tnbr_tree, tnbr); free(tnbr); break; case PROC_LDP_ENGINE: tnbr->flags &= ~F_TNBR_CONFIGURED; - tnbr_check(tnbr); + tnbr_check(conf, tnbr); break; case PROC_MAIN: - LIST_REMOVE(tnbr, entry); + RB_REMOVE(tnbr_head, &conf->tnbr_tree, tnbr); QOBJ_UNREG (tnbr); free(tnbr); break; } } } - LIST_FOREACH_SAFE(xt, &xconf->tnbr_list, entry, ttmp) { + RB_FOREACH_SAFE(xt, tnbr_head, &xconf->tnbr_tree, ttmp) { /* find new tnbrs */ if ((tnbr = tnbr_find(conf, xt->af, &xt->addr)) == NULL) { - LIST_REMOVE(xt, entry); - LIST_INSERT_HEAD(&conf->tnbr_list, xt, entry); + RB_REMOVE(tnbr_head, &xconf->tnbr_tree, xt); + RB_INSERT(tnbr_head, &conf->tnbr_tree, xt); switch (ldpd_process) { case PROC_LDE_ENGINE: @@ -1340,7 +1340,7 @@ merge_tnbrs(struct ldpd_conf *conf, struct ldpd_conf *xconf, void **ref) /* update existing tnbrs */ if (!(tnbr->flags & F_TNBR_CONFIGURED)) tnbr->flags |= F_TNBR_CONFIGURED; - LIST_REMOVE(xt, entry); + RB_REMOVE(tnbr_head, &xconf->tnbr_tree, xt); if (ref && *ref == xt) *ref = tnbr; free(xt); @@ -1771,7 +1771,7 @@ config_new_empty(void) fatal(NULL); RB_INIT(&xconf->iface_tree); - LIST_INIT(&xconf->tnbr_list); + RB_INIT(&xconf->tnbr_tree); LIST_INIT(&xconf->nbrp_list); LIST_INIT(&xconf->l2vpn_list); diff --git a/ldpd/ldpd.h b/ldpd/ldpd.h index 2c516c013b..7e5b4248a2 100644 --- a/ldpd/ldpd.h +++ b/ldpd/ldpd.h @@ -281,7 +281,7 @@ DECLARE_QOBJ_TYPE(iface) /* source of targeted hellos */ struct tnbr { - LIST_ENTRY(tnbr) entry; + RB_ENTRY(tnbr) entry; struct thread *hello_timer; struct adj *adj; int af; @@ -291,6 +291,8 @@ struct tnbr { uint8_t flags; QOBJ_FIELDS }; +RB_HEAD(tnbr_head, tnbr); +RB_PROTOTYPE(tnbr_head, tnbr, entry, tnbr_compare); DECLARE_QOBJ_TYPE(tnbr) #define F_TNBR_CONFIGURED 0x01 #define F_TNBR_DYNAMIC 0x02 @@ -407,7 +409,7 @@ struct ldpd_conf { struct ldpd_af_conf ipv4; struct ldpd_af_conf ipv6; struct iface_head iface_tree; - LIST_HEAD(, tnbr) tnbr_list; + struct tnbr_head tnbr_tree; LIST_HEAD(, nbr_params) nbrp_list; LIST_HEAD(, l2vpn) l2vpn_list; uint16_t lhello_holdtime; @@ -633,9 +635,9 @@ struct iface *iface_new_api(struct ldpd_conf *conf, const char *name); void iface_del_api(struct ldpd_conf *conf, struct iface *iface); -struct tnbr *tnbr_new_api(struct ldpd_conf *cfg, int af, +struct tnbr *tnbr_new_api(struct ldpd_conf *conf, int af, union ldpd_addr *addr); -void tnbr_del_api(struct tnbr *tnbr); +void tnbr_del_api(struct ldpd_conf *conf, struct tnbr *tnbr); struct nbr_params *nbrp_new_api(struct ldpd_conf *cfg, struct in_addr lsr_id); void nbrp_del_api(struct nbr_params *nbrp); diff --git a/ldpd/ldpe.c b/ldpd/ldpe.c index 16910a3cc8..699ce502f5 100644 --- a/ldpd/ldpe.c +++ b/ldpd/ldpe.c @@ -415,7 +415,7 @@ ldpe_dispatch_main(struct thread *thread) memcpy(nconf, imsg.data, sizeof(struct ldpd_conf)); RB_INIT(&nconf->iface_tree); - LIST_INIT(&nconf->tnbr_list); + RB_INIT(&nconf->tnbr_tree); LIST_INIT(&nconf->nbrp_list); LIST_INIT(&nconf->l2vpn_list); break; @@ -437,7 +437,7 @@ ldpe_dispatch_main(struct thread *thread) fatal(NULL); memcpy(ntnbr, imsg.data, sizeof(struct tnbr)); - LIST_INSERT_HEAD(&nconf->tnbr_list, ntnbr, entry); + RB_INSERT(tnbr_head, &nconf->tnbr_tree, ntnbr); break; case IMSG_RECONF_NBRP: if ((nnbrp = malloc(sizeof(struct nbr_params))) == NULL) @@ -743,12 +743,12 @@ ldpe_remove_dynamic_tnbrs(int af) { struct tnbr *tnbr, *safe; - LIST_FOREACH_SAFE(tnbr, &leconf->tnbr_list, entry, safe) { + RB_FOREACH_SAFE(tnbr, tnbr_head, &leconf->tnbr_tree, safe) { if (tnbr->af != af) continue; tnbr->flags &= ~F_TNBR_DYNAMIC; - tnbr_check(tnbr); + tnbr_check(leconf, tnbr); } } @@ -832,7 +832,7 @@ ldpe_adj_ctl(struct ctl_conn *c) } } - LIST_FOREACH(tnbr, &leconf->tnbr_list, entry) { + RB_FOREACH(tnbr, tnbr_head, &leconf->tnbr_tree) { memset(&tctl, 0, sizeof(tctl)); tctl.af = tnbr->af; tctl.addr = tnbr->addr; diff --git a/ldpd/ldpe.h b/ldpd/ldpe.h index aab1a7fd9b..52899fd85c 100644 --- a/ldpd/ldpe.h +++ b/ldpd/ldpe.h @@ -225,7 +225,7 @@ void adj_start_itimer(struct adj *); void adj_stop_itimer(struct adj *); struct tnbr *tnbr_new(int, union ldpd_addr *); struct tnbr *tnbr_find(struct ldpd_conf *, int, union ldpd_addr *); -struct tnbr *tnbr_check(struct tnbr *); +struct tnbr *tnbr_check(struct ldpd_conf *, struct tnbr *); void tnbr_update(struct tnbr *); void tnbr_update_all(int); uint16_t tnbr_get_hello_holdtime(struct tnbr *); From 76c4abd19f322288394be872c9198c7d17cfac10 Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Wed, 14 Dec 2016 09:14:52 -0200 Subject: [PATCH 046/107] ldpd: use red-black trees to store 'nbr_params' elements Using red-black trees instead of linked lists brings the following benefits: 1 - Elements are naturally ordered (no need to reorder anything before outputting data to the user); 2 - Faster lookups/deletes: O(log n) time complexity against O(n). The insert operation with red-black trees is more expensive though, but that's not a big issue since lookups are much more frequent. Signed-off-by: Renato Westphal --- ldpd/lde.c | 4 ++-- ldpd/ldp_vty_conf.c | 14 +++++++------- ldpd/ldpd.c | 30 +++++++++++++++--------------- ldpd/ldpd.h | 11 +++++++---- ldpd/ldpe.c | 4 ++-- ldpd/neighbor.c | 19 ++++++++++++------- 6 files changed, 45 insertions(+), 37 deletions(-) diff --git a/ldpd/lde.c b/ldpd/lde.c index 4b957c55e7..80557ed4ef 100644 --- a/ldpd/lde.c +++ b/ldpd/lde.c @@ -475,7 +475,7 @@ lde_dispatch_parent(struct thread *thread) RB_INIT(&nconf->iface_tree); RB_INIT(&nconf->tnbr_tree); - LIST_INIT(&nconf->nbrp_list); + RB_INIT(&nconf->nbrp_tree); LIST_INIT(&nconf->l2vpn_list); break; case IMSG_RECONF_IFACE: @@ -503,7 +503,7 @@ lde_dispatch_parent(struct thread *thread) fatal(NULL); memcpy(nnbrp, imsg.data, sizeof(struct nbr_params)); - LIST_INSERT_HEAD(&nconf->nbrp_list, nnbrp, entry); + RB_INSERT(nbrp_head, &nconf->nbrp_tree, nnbrp); break; case IMSG_RECONF_L2VPN: if ((nl2vpn = malloc(sizeof(struct l2vpn))) == NULL) diff --git a/ldpd/ldp_vty_conf.c b/ldpd/ldp_vty_conf.c index f5c98eb1ff..95b0971e64 100644 --- a/ldpd/ldp_vty_conf.c +++ b/ldpd/ldp_vty_conf.c @@ -265,7 +265,7 @@ ldp_config_write(struct vty *vty) if (ldpd_conf->flags & F_LDPD_DS_CISCO_INTEROP) vty_out(vty, " dual-stack cisco-interop%s", VTY_NEWLINE); - LIST_FOREACH(nbrp, &ldpd_conf->nbrp_list, entry) { + RB_FOREACH(nbrp, nbrp_head, &ldpd_conf->nbrp_tree) { if (nbrp->flags & F_NBRP_KEEPALIVE) vty_out(vty, " neighbor %s session holdtime %u%s", inet_ntoa(nbrp->lsr_id), nbrp->keepalive, @@ -740,7 +740,7 @@ ldp_vty_nbr_session_holdtime(struct vty *vty, struct vty_arg *args[]) } else { if (nbrp == NULL) { nbrp = nbr_params_new(lsr_id); - LIST_INSERT_HEAD(&vty_conf->nbrp_list, nbrp, entry); + RB_INSERT(nbrp_head, &vty_conf->nbrp_tree, nbrp); } else if (nbrp->keepalive == secs) goto cancel; @@ -1129,7 +1129,7 @@ ldp_vty_neighbor_password(struct vty *vty, struct vty_arg *args[]) } else { if (nbrp == NULL) { nbrp = nbr_params_new(lsr_id); - LIST_INSERT_HEAD(&vty_conf->nbrp_list, nbrp, entry); + RB_INSERT(nbrp_head, &vty_conf->nbrp_tree, nbrp); } else if (nbrp->auth.method == AUTH_MD5SIG && strcmp(nbrp->auth.md5key, password_str) == 0) goto cancel; @@ -1195,7 +1195,7 @@ ldp_vty_neighbor_ttl_security(struct vty *vty, struct vty_arg *args[]) } else { if (nbrp == NULL) { nbrp = nbr_params_new(lsr_id); - LIST_INSERT_HEAD(&vty_conf->nbrp_list, nbrp, entry); + RB_INSERT(nbrp_head, &vty_conf->nbrp_tree, nbrp); } nbrp->flags |= F_NBRP_GTSM; @@ -1685,14 +1685,14 @@ nbrp_new_api(struct ldpd_conf *conf, struct in_addr lsr_id) return (NULL); nbrp = nbr_params_new(lsr_id); - LIST_INSERT_HEAD(&conf->nbrp_list, nbrp, entry); + RB_INSERT(nbrp_head, &conf->nbrp_tree, nbrp); return (nbrp); } void -nbrp_del_api(struct nbr_params *nbrp) +nbrp_del_api(struct ldpd_conf *conf, struct nbr_params *nbrp) { - LIST_REMOVE(nbrp, entry); + RB_REMOVE(nbrp_head, &conf->nbrp_tree, nbrp); free(nbrp); } diff --git a/ldpd/ldpd.c b/ldpd/ldpd.c index cf793f58c3..37cc0dec16 100644 --- a/ldpd/ldpd.c +++ b/ldpd/ldpd.c @@ -862,7 +862,7 @@ main_imsg_send_config(struct ldpd_conf *xconf) return (-1); } - LIST_FOREACH(nbrp, &xconf->nbrp_list, entry) { + RB_FOREACH(nbrp, nbrp_head, &xconf->nbrp_tree) { if (main_imsg_compose_both(IMSG_RECONF_NBRP, nbrp, sizeof(*nbrp)) == -1) return (-1); @@ -961,10 +961,10 @@ ldp_config_reset_main(struct ldpd_conf *conf, void **ref) free(iface); } - while ((nbrp = LIST_FIRST(&conf->nbrp_list)) != NULL) { + while ((nbrp = RB_ROOT(&conf->nbrp_tree)) != NULL) { if (ref && *ref == nbrp) *ref = NULL; - LIST_REMOVE(nbrp, entry); + RB_REMOVE(nbrp_head, &conf->nbrp_tree, nbrp); free(nbrp); } @@ -1034,7 +1034,7 @@ ldp_dup_config_ref(struct ldpd_conf *conf, void **ref) COPY(xconf, conf); RB_INIT(&xconf->iface_tree); RB_INIT(&xconf->tnbr_tree); - LIST_INIT(&xconf->nbrp_list); + RB_INIT(&xconf->nbrp_tree); LIST_INIT(&xconf->l2vpn_list); RB_FOREACH(iface, iface_head, &conf->iface_tree) { @@ -1047,9 +1047,9 @@ ldp_dup_config_ref(struct ldpd_conf *conf, void **ref) COPY(xt, tnbr); RB_INSERT(tnbr_head, &xconf->tnbr_tree, xt); } - LIST_FOREACH(nbrp, &conf->nbrp_list, entry) { + RB_FOREACH(nbrp, nbrp_head, &conf->nbrp_tree) { COPY(xn, nbrp); - LIST_INSERT_HEAD(&xconf->nbrp_list, xn, entry); + RB_INSERT(nbrp_head, &xconf->nbrp_tree, xn); } LIST_FOREACH(l2vpn, &conf->l2vpn_list, entry) { COPY(xl, l2vpn); @@ -1101,8 +1101,8 @@ ldp_clear_config(struct ldpd_conf *xconf) RB_REMOVE(tnbr_head, &xconf->tnbr_tree, tnbr); free(tnbr); } - while ((nbrp = LIST_FIRST(&xconf->nbrp_list)) != NULL) { - LIST_REMOVE(nbrp, entry); + while ((nbrp = RB_ROOT(&xconf->nbrp_tree)) != NULL) { + RB_REMOVE(nbrp_head, &xconf->nbrp_tree, nbrp); free(nbrp); } while ((l2vpn = LIST_FIRST(&xconf->l2vpn_list)) != NULL) { @@ -1354,7 +1354,7 @@ merge_nbrps(struct ldpd_conf *conf, struct ldpd_conf *xconf, void **ref) struct nbr *nbr; int nbrp_changed; - LIST_FOREACH_SAFE(nbrp, &conf->nbrp_list, entry, ntmp) { + RB_FOREACH_SAFE(nbrp, nbrp_head, &conf->nbrp_tree, ntmp) { /* find deleted nbrps */ if ((xn = nbr_params_find(xconf, nbrp->lsr_id)) == NULL) { switch (ldpd_process) { @@ -1380,15 +1380,15 @@ merge_nbrps(struct ldpd_conf *conf, struct ldpd_conf *xconf, void **ref) QOBJ_UNREG (nbrp); break; } - LIST_REMOVE(nbrp, entry); + RB_REMOVE(nbrp_head, &conf->nbrp_tree, nbrp); free(nbrp); } } - LIST_FOREACH_SAFE(xn, &xconf->nbrp_list, entry, ntmp) { + RB_FOREACH_SAFE(xn, nbrp_head, &xconf->nbrp_tree, ntmp) { /* find new nbrps */ if ((nbrp = nbr_params_find(conf, xn->lsr_id)) == NULL) { - LIST_REMOVE(xn, entry); - LIST_INSERT_HEAD(&conf->nbrp_list, xn, entry); + RB_REMOVE(nbrp_head, &xconf->nbrp_tree, xn); + RB_INSERT(nbrp_head, &conf->nbrp_tree, xn); switch (ldpd_process) { case PROC_LDE_ENGINE: @@ -1455,7 +1455,7 @@ merge_nbrps(struct ldpd_conf *conf, struct ldpd_conf *xconf, void **ref) nbr_establish_connection(nbr); } } - LIST_REMOVE(xn, entry); + RB_REMOVE(nbrp_head, &xconf->nbrp_tree, xn); if (ref && *ref == xn) *ref = nbrp; free(xn); @@ -1772,7 +1772,7 @@ config_new_empty(void) RB_INIT(&xconf->iface_tree); RB_INIT(&xconf->tnbr_tree); - LIST_INIT(&xconf->nbrp_list); + RB_INIT(&xconf->nbrp_tree); LIST_INIT(&xconf->l2vpn_list); return (xconf); diff --git a/ldpd/ldpd.h b/ldpd/ldpd.h index 7e5b4248a2..d8f75a0eec 100644 --- a/ldpd/ldpd.h +++ b/ldpd/ldpd.h @@ -304,7 +304,7 @@ enum auth_method { /* neighbor specific parameters */ struct nbr_params { - LIST_ENTRY(nbr_params) entry; + RB_ENTRY(nbr_params) entry; struct in_addr lsr_id; uint16_t keepalive; int gtsm_enabled; @@ -317,6 +317,8 @@ struct nbr_params { uint8_t flags; QOBJ_FIELDS }; +RB_HEAD(nbrp_head, nbr_params); +RB_PROTOTYPE(nbrp_head, nbr_params, entry, nbr_params_compare); DECLARE_QOBJ_TYPE(nbr_params) #define F_NBRP_KEEPALIVE 0x01 #define F_NBRP_GTSM 0x02 @@ -410,7 +412,7 @@ struct ldpd_conf { struct ldpd_af_conf ipv6; struct iface_head iface_tree; struct tnbr_head tnbr_tree; - LIST_HEAD(, nbr_params) nbrp_list; + struct nbrp_head nbrp_tree; LIST_HEAD(, l2vpn) l2vpn_list; uint16_t lhello_holdtime; uint16_t lhello_interval; @@ -638,9 +640,10 @@ void iface_del_api(struct ldpd_conf *conf, struct tnbr *tnbr_new_api(struct ldpd_conf *conf, int af, union ldpd_addr *addr); void tnbr_del_api(struct ldpd_conf *conf, struct tnbr *tnbr); -struct nbr_params *nbrp_new_api(struct ldpd_conf *cfg, +struct nbr_params *nbrp_new_api(struct ldpd_conf *conf, struct in_addr lsr_id); -void nbrp_del_api(struct nbr_params *nbrp); +void nbrp_del_api(struct ldpd_conf *conf, + struct nbr_params *nbrp); struct l2vpn *l2vpn_new_api(struct ldpd_conf *cfg, const char *name); void l2vpn_del_api(struct l2vpn *l2vpn); struct l2vpn_if *l2vpn_if_new_api(struct ldpd_conf *conf, diff --git a/ldpd/ldpe.c b/ldpd/ldpe.c index 699ce502f5..e9e45f8fe3 100644 --- a/ldpd/ldpe.c +++ b/ldpd/ldpe.c @@ -416,7 +416,7 @@ ldpe_dispatch_main(struct thread *thread) RB_INIT(&nconf->iface_tree); RB_INIT(&nconf->tnbr_tree); - LIST_INIT(&nconf->nbrp_list); + RB_INIT(&nconf->nbrp_tree); LIST_INIT(&nconf->l2vpn_list); break; case IMSG_RECONF_IFACE: @@ -444,7 +444,7 @@ ldpe_dispatch_main(struct thread *thread) fatal(NULL); memcpy(nnbrp, imsg.data, sizeof(struct nbr_params)); - LIST_INSERT_HEAD(&nconf->nbrp_list, nnbrp, entry); + RB_INSERT(nbrp_head, &nconf->nbrp_tree, nnbrp); break; case IMSG_RECONF_L2VPN: if ((nl2vpn = malloc(sizeof(struct l2vpn))) == NULL) diff --git a/ldpd/neighbor.c b/ldpd/neighbor.c index 8376a01549..5addc4dda2 100644 --- a/ldpd/neighbor.c +++ b/ldpd/neighbor.c @@ -39,10 +39,13 @@ static void nbr_start_itimeout(struct nbr *); static int nbr_idtimer(struct thread *); static int nbr_act_session_operational(struct nbr *); static void nbr_send_labelmappings(struct nbr *); +static __inline int nbr_params_compare(struct nbr_params *, + struct nbr_params *); RB_GENERATE(nbr_id_head, nbr, id_tree, nbr_id_compare) RB_GENERATE(nbr_addr_head, nbr, addr_tree, nbr_addr_compare) RB_GENERATE(nbr_pid_head, nbr, pid_tree, nbr_pid_compare) +RB_GENERATE(nbrp_head, nbr_params, entry, nbr_params_compare) struct { int state; @@ -752,6 +755,12 @@ nbr_send_labelmappings(struct nbr *nbr) NULL, 0); } +static __inline int +nbr_params_compare(struct nbr_params *a, struct nbr_params *b) +{ + return (ntohl(a->lsr_id.s_addr) - ntohl(b->lsr_id.s_addr)); +} + struct nbr_params * nbr_params_new(struct in_addr lsr_id) { @@ -769,13 +778,9 @@ nbr_params_new(struct in_addr lsr_id) struct nbr_params * nbr_params_find(struct ldpd_conf *xconf, struct in_addr lsr_id) { - struct nbr_params *nbrp; - - LIST_FOREACH(nbrp, &xconf->nbrp_list, entry) - if (nbrp->lsr_id.s_addr == lsr_id.s_addr) - return (nbrp); - - return (NULL); + struct nbr_params nbrp; + nbrp.lsr_id = lsr_id; + return (RB_FIND(nbrp_head, &xconf->nbrp_tree, &nbrp)); } uint16_t From 90d7e7bd8b68530a80293e8d1c5c894c99b7a434 Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Wed, 14 Dec 2016 10:42:45 -0200 Subject: [PATCH 047/107] ldpd: use red-black trees to store 'l2vpn' elements Using red-black trees instead of linked lists brings the following benefits: 1 - Elements are naturally ordered (no need to reorder anything before outputting data to the user); 2 - Faster lookups/deletes: O(log n) time complexity against O(n). The insert operation with red-black trees is more expensive though, but that's not a big issue since lookups are much more frequent. Signed-off-by: Renato Westphal --- ldpd/l2vpn.c | 25 +++++++++++++++---------- ldpd/lde.c | 4 ++-- ldpd/ldp_vty_conf.c | 14 +++++++------- ldpd/ldpd.c | 28 ++++++++++++++-------------- ldpd/ldpd.h | 11 +++++++---- ldpd/ldpe.c | 4 ++-- 6 files changed, 47 insertions(+), 39 deletions(-) diff --git a/ldpd/l2vpn.c b/ldpd/l2vpn.c index dc9879ef23..b339c9ce6b 100644 --- a/ldpd/l2vpn.c +++ b/ldpd/l2vpn.c @@ -26,7 +26,16 @@ #include "lde.h" #include "log.h" -static void l2vpn_pw_fec(struct l2vpn_pw *, struct fec *); +static void l2vpn_pw_fec(struct l2vpn_pw *, struct fec *); +static __inline int l2vpn_compare(struct l2vpn *, struct l2vpn *); + +RB_GENERATE(l2vpn_head, l2vpn, entry, l2vpn_compare) + +static __inline int +l2vpn_compare(struct l2vpn *a, struct l2vpn *b) +{ + return (strcmp(a->name, b->name)); +} struct l2vpn * l2vpn_new(const char *name) @@ -52,13 +61,9 @@ l2vpn_new(const char *name) struct l2vpn * l2vpn_find(struct ldpd_conf *xconf, const char *name) { - struct l2vpn *l2vpn; - - LIST_FOREACH(l2vpn, &xconf->l2vpn_list, entry) - if (strcmp(l2vpn->name, name) == 0) - return (l2vpn); - - return (NULL); + struct l2vpn l2vpn; + strlcpy(l2vpn.name, name, sizeof(l2vpn.name)); + return (RB_FIND(l2vpn_head, &xconf->l2vpn_tree, &l2vpn)); } void @@ -399,7 +404,7 @@ l2vpn_sync_pws(int af, union ldpd_addr *addr) struct fec_node *fn; struct fec_nh *fnh; - LIST_FOREACH(l2vpn, &ldeconf->l2vpn_list, entry) { + RB_FOREACH(l2vpn, l2vpn_head, &ldeconf->l2vpn_tree) { LIST_FOREACH(pw, &l2vpn->pw_list, entry) { if (af != pw->af || ldp_addrcmp(af, &pw->addr, addr)) continue; @@ -428,7 +433,7 @@ l2vpn_pw_ctl(pid_t pid) struct l2vpn_pw *pw; static struct ctl_pw pwctl; - LIST_FOREACH(l2vpn, &ldeconf->l2vpn_list, entry) + RB_FOREACH(l2vpn, l2vpn_head, &ldeconf->l2vpn_tree) LIST_FOREACH(pw, &l2vpn->pw_list, entry) { memset(&pwctl, 0, sizeof(pwctl)); strlcpy(pwctl.l2vpn_name, pw->l2vpn->name, diff --git a/ldpd/lde.c b/ldpd/lde.c index 80557ed4ef..3feb27d168 100644 --- a/ldpd/lde.c +++ b/ldpd/lde.c @@ -476,7 +476,7 @@ lde_dispatch_parent(struct thread *thread) RB_INIT(&nconf->iface_tree); RB_INIT(&nconf->tnbr_tree); RB_INIT(&nconf->nbrp_tree); - LIST_INIT(&nconf->l2vpn_list); + RB_INIT(&nconf->l2vpn_tree); break; case IMSG_RECONF_IFACE: if ((niface = malloc(sizeof(struct iface))) == NULL) @@ -514,7 +514,7 @@ lde_dispatch_parent(struct thread *thread) LIST_INIT(&nl2vpn->pw_list); LIST_INIT(&nl2vpn->pw_inactive_list); - LIST_INSERT_HEAD(&nconf->l2vpn_list, nl2vpn, entry); + RB_INSERT(l2vpn_head, &nconf->l2vpn_tree, nl2vpn); break; case IMSG_RECONF_L2VPN_IF: if ((nlif = malloc(sizeof(struct l2vpn_if))) == NULL) diff --git a/ldpd/ldp_vty_conf.c b/ldpd/ldp_vty_conf.c index 95b0971e64..b66d8d4698 100644 --- a/ldpd/ldp_vty_conf.c +++ b/ldpd/ldp_vty_conf.c @@ -341,7 +341,7 @@ ldp_l2vpn_config_write(struct vty *vty) struct l2vpn_if *lif; struct l2vpn_pw *pw; - LIST_FOREACH(l2vpn, &ldpd_conf->l2vpn_list, entry) { + RB_FOREACH(l2vpn, l2vpn_head, &ldpd_conf->l2vpn_tree) { vty_out(vty, "l2vpn %s type vpls%s", l2vpn->name, VTY_NEWLINE); if (l2vpn->pw_type != DEFAULT_PW_TYPE) @@ -393,7 +393,7 @@ ldp_iface_is_configured(struct ldpd_conf *xconf, const char *ifname) if (if_lookup_name(xconf, ifname)) return (1); - LIST_FOREACH(l2vpn, &xconf->l2vpn_list, entry) { + RB_FOREACH(l2vpn, l2vpn_head, &xconf->l2vpn_tree) { if (l2vpn_if_find_name(l2vpn, ifname)) return (1); if (l2vpn_pw_find_name(l2vpn, ifname)) @@ -1235,7 +1235,7 @@ ldp_vty_l2vpn(struct vty *vty, struct vty_arg *args[]) if (l2vpn == NULL) goto cancel; - LIST_REMOVE(l2vpn, entry); + RB_REMOVE(l2vpn_head, &vty_conf->l2vpn_tree, l2vpn); l2vpn_del(l2vpn); ldp_reload(vty_conf); return (CMD_SUCCESS); @@ -1248,7 +1248,7 @@ ldp_vty_l2vpn(struct vty *vty, struct vty_arg *args[]) l2vpn = l2vpn_new(name_str); l2vpn->type = L2VPN_TYPE_VPLS; - LIST_INSERT_HEAD(&vty_conf->l2vpn_list, l2vpn, entry); + RB_INSERT(l2vpn_head, &vty_conf->l2vpn_tree, l2vpn); ldp_reload_ref(vty_conf, (void **)&l2vpn); VTY_PUSH_CONTEXT(LDP_L2VPN_NODE, l2vpn); @@ -1706,12 +1706,12 @@ l2vpn_new_api(struct ldpd_conf *conf, const char *name) l2vpn = l2vpn_new(name); l2vpn->type = L2VPN_TYPE_VPLS; - LIST_INSERT_HEAD(&conf->l2vpn_list, l2vpn, entry); + RB_INSERT(l2vpn_head, &conf->l2vpn_tree, l2vpn); return (l2vpn); } void -l2vpn_del_api(struct l2vpn *l2vpn) +l2vpn_del_api(struct ldpd_conf *conf, struct l2vpn *l2vpn) { struct l2vpn_if *lif; struct l2vpn_pw *pw; @@ -1728,7 +1728,7 @@ l2vpn_del_api(struct l2vpn *l2vpn) LIST_REMOVE(pw, entry); free(pw); } - LIST_REMOVE(l2vpn, entry); + RB_REMOVE(l2vpn_head, &conf->l2vpn_tree, l2vpn); free(l2vpn); } diff --git a/ldpd/ldpd.c b/ldpd/ldpd.c index 37cc0dec16..dab761db7f 100644 --- a/ldpd/ldpd.c +++ b/ldpd/ldpd.c @@ -868,7 +868,7 @@ main_imsg_send_config(struct ldpd_conf *xconf) return (-1); } - LIST_FOREACH(l2vpn, &xconf->l2vpn_list, entry) { + RB_FOREACH(l2vpn, l2vpn_head, &xconf->l2vpn_tree) { if (main_imsg_compose_both(IMSG_RECONF_L2VPN, l2vpn, sizeof(*l2vpn)) == -1) return (-1); @@ -930,7 +930,7 @@ ldp_config_normalize(struct ldpd_conf *xconf, void **ref) ldp_config_reset_af(xconf, AF_INET6, ref); } - LIST_FOREACH(l2vpn, &xconf->l2vpn_list, entry) { + RB_FOREACH(l2vpn, l2vpn_head, &xconf->l2vpn_tree) { LIST_FOREACH(pw, &l2vpn->pw_list, entry) { if (pw->flags & F_PW_STATIC_NBR_ADDR) continue; @@ -1035,7 +1035,7 @@ ldp_dup_config_ref(struct ldpd_conf *conf, void **ref) RB_INIT(&xconf->iface_tree); RB_INIT(&xconf->tnbr_tree); RB_INIT(&xconf->nbrp_tree); - LIST_INIT(&xconf->l2vpn_list); + RB_INIT(&xconf->l2vpn_tree); RB_FOREACH(iface, iface_head, &conf->iface_tree) { COPY(xi, iface); @@ -1051,12 +1051,12 @@ ldp_dup_config_ref(struct ldpd_conf *conf, void **ref) COPY(xn, nbrp); RB_INSERT(nbrp_head, &xconf->nbrp_tree, xn); } - LIST_FOREACH(l2vpn, &conf->l2vpn_list, entry) { + RB_FOREACH(l2vpn, l2vpn_head, &conf->l2vpn_tree) { COPY(xl, l2vpn); LIST_INIT(&xl->if_list); LIST_INIT(&xl->pw_list); LIST_INIT(&xl->pw_inactive_list); - LIST_INSERT_HEAD(&xconf->l2vpn_list, xl, entry); + RB_INSERT(l2vpn_head, &xconf->l2vpn_tree, xl); LIST_FOREACH(lif, &l2vpn->if_list, entry) { COPY(xf, lif); @@ -1105,8 +1105,8 @@ ldp_clear_config(struct ldpd_conf *xconf) RB_REMOVE(nbrp_head, &xconf->nbrp_tree, nbrp); free(nbrp); } - while ((l2vpn = LIST_FIRST(&xconf->l2vpn_list)) != NULL) { - LIST_REMOVE(l2vpn, entry); + while ((l2vpn = RB_ROOT(&xconf->l2vpn_tree)) != NULL) { + RB_REMOVE(l2vpn_head, &xconf->l2vpn_tree, l2vpn); l2vpn_del(l2vpn); } @@ -1469,10 +1469,10 @@ merge_l2vpns(struct ldpd_conf *conf, struct ldpd_conf *xconf, void **ref) struct l2vpn_if *lif; struct l2vpn_pw *pw; - LIST_FOREACH_SAFE(l2vpn, &conf->l2vpn_list, entry, ltmp) { + RB_FOREACH_SAFE(l2vpn, l2vpn_head, &conf->l2vpn_tree, ltmp) { /* find deleted l2vpns */ if ((xl = l2vpn_find(xconf, l2vpn->name)) == NULL) { - LIST_REMOVE(l2vpn, entry); + RB_REMOVE(l2vpn_head, &conf->l2vpn_tree, l2vpn); switch (ldpd_process) { case PROC_LDE_ENGINE: @@ -1494,11 +1494,11 @@ merge_l2vpns(struct ldpd_conf *conf, struct ldpd_conf *xconf, void **ref) l2vpn_del(l2vpn); } } - LIST_FOREACH_SAFE(xl, &xconf->l2vpn_list, entry, ltmp) { + RB_FOREACH_SAFE(xl, l2vpn_head, &xconf->l2vpn_tree, ltmp) { /* find new l2vpns */ if ((l2vpn = l2vpn_find(conf, xl->name)) == NULL) { - LIST_REMOVE(xl, entry); - LIST_INSERT_HEAD(&conf->l2vpn_list, xl, entry); + RB_REMOVE(l2vpn_head, &xconf->l2vpn_tree, xl); + RB_INSERT(l2vpn_head, &conf->l2vpn_tree, xl); switch (ldpd_process) { case PROC_LDE_ENGINE: @@ -1516,7 +1516,7 @@ merge_l2vpns(struct ldpd_conf *conf, struct ldpd_conf *xconf, void **ref) /* update existing l2vpns */ merge_l2vpn(conf, l2vpn, xl, ref); - LIST_REMOVE(xl, entry); + RB_REMOVE(l2vpn_head, &xconf->l2vpn_tree, xl); if (ref && *ref == xl) *ref = l2vpn; free(xl); @@ -1773,7 +1773,7 @@ config_new_empty(void) RB_INIT(&xconf->iface_tree); RB_INIT(&xconf->tnbr_tree); RB_INIT(&xconf->nbrp_tree); - LIST_INIT(&xconf->l2vpn_list); + RB_INIT(&xconf->l2vpn_tree); return (xconf); } diff --git a/ldpd/ldpd.h b/ldpd/ldpd.h index d8f75a0eec..72e5dc5bcf 100644 --- a/ldpd/ldpd.h +++ b/ldpd/ldpd.h @@ -358,7 +358,7 @@ DECLARE_QOBJ_TYPE(l2vpn_pw) #define F_PW_STATIC_NBR_ADDR 0x20 /* static neighbor address configured */ struct l2vpn { - LIST_ENTRY(l2vpn) entry; + RB_ENTRY(l2vpn) entry; char name[L2VPN_NAME_LEN]; int type; int pw_type; @@ -370,6 +370,8 @@ struct l2vpn { LIST_HEAD(, l2vpn_pw) pw_inactive_list; QOBJ_FIELDS }; +RB_HEAD(l2vpn_head, l2vpn); +RB_PROTOTYPE(l2vpn_head, l2vpn, entry, l2vpn_compare); DECLARE_QOBJ_TYPE(l2vpn) #define L2VPN_TYPE_VPWS 1 #define L2VPN_TYPE_VPLS 2 @@ -413,7 +415,7 @@ struct ldpd_conf { struct iface_head iface_tree; struct tnbr_head tnbr_tree; struct nbrp_head nbrp_tree; - LIST_HEAD(, l2vpn) l2vpn_list; + struct l2vpn_head l2vpn_tree; uint16_t lhello_holdtime; uint16_t lhello_interval; uint16_t thello_holdtime; @@ -644,8 +646,9 @@ struct nbr_params *nbrp_new_api(struct ldpd_conf *conf, struct in_addr lsr_id); void nbrp_del_api(struct ldpd_conf *conf, struct nbr_params *nbrp); -struct l2vpn *l2vpn_new_api(struct ldpd_conf *cfg, const char *name); -void l2vpn_del_api(struct l2vpn *l2vpn); +struct l2vpn *l2vpn_new_api(struct ldpd_conf *conf, const char *name); +void l2vpn_del_api(struct ldpd_conf *conf, + struct l2vpn *l2vpn); struct l2vpn_if *l2vpn_if_new_api(struct ldpd_conf *conf, struct l2vpn *l2vpn, const char *ifname); void l2vpn_if_del_api(struct l2vpn_if *lif); diff --git a/ldpd/ldpe.c b/ldpd/ldpe.c index e9e45f8fe3..6edd180a43 100644 --- a/ldpd/ldpe.c +++ b/ldpd/ldpe.c @@ -417,7 +417,7 @@ ldpe_dispatch_main(struct thread *thread) RB_INIT(&nconf->iface_tree); RB_INIT(&nconf->tnbr_tree); RB_INIT(&nconf->nbrp_tree); - LIST_INIT(&nconf->l2vpn_list); + RB_INIT(&nconf->l2vpn_tree); break; case IMSG_RECONF_IFACE: if ((niface = malloc(sizeof(struct iface))) == NULL) @@ -455,7 +455,7 @@ ldpe_dispatch_main(struct thread *thread) LIST_INIT(&nl2vpn->pw_list); LIST_INIT(&nl2vpn->pw_inactive_list); - LIST_INSERT_HEAD(&nconf->l2vpn_list, nl2vpn, entry); + RB_INSERT(l2vpn_head, &nconf->l2vpn_tree, nl2vpn); break; case IMSG_RECONF_L2VPN_IF: if ((nlif = malloc(sizeof(struct l2vpn_if))) == NULL) From 029c195854a229067a4c4374f17f8fa54fc1c56b Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Wed, 14 Dec 2016 12:34:57 -0200 Subject: [PATCH 048/107] ldpd: use red-black trees to store 'l2vpn_if' elements Using red-black trees instead of linked lists brings the following benefits: 1 - Elements are naturally ordered (no need to reorder anything before outputting data to the user); 2 - Faster lookups/deletes: O(log n) time complexity against O(n). The insert operation with red-black trees is more expensive though, but that's not a big issue since lookups are much more frequent. Signed-off-by: Renato Westphal --- ldpd/l2vpn.c | 26 +++++++++++++++----------- ldpd/lde.c | 4 ++-- ldpd/ldp_vty_conf.c | 16 ++++++++-------- ldpd/ldpd.c | 22 +++++++++++----------- ldpd/ldpd.h | 9 ++++++--- ldpd/ldpe.c | 4 ++-- 6 files changed, 44 insertions(+), 37 deletions(-) diff --git a/ldpd/l2vpn.c b/ldpd/l2vpn.c index b339c9ce6b..02f25e18b0 100644 --- a/ldpd/l2vpn.c +++ b/ldpd/l2vpn.c @@ -28,8 +28,10 @@ static void l2vpn_pw_fec(struct l2vpn_pw *, struct fec *); static __inline int l2vpn_compare(struct l2vpn *, struct l2vpn *); +static __inline int l2vpn_if_compare(struct l2vpn_if *, struct l2vpn_if *); RB_GENERATE(l2vpn_head, l2vpn, entry, l2vpn_compare) +RB_GENERATE(l2vpn_if_head, l2vpn_if, entry, l2vpn_if_compare) static __inline int l2vpn_compare(struct l2vpn *a, struct l2vpn *b) @@ -51,7 +53,7 @@ l2vpn_new(const char *name) l2vpn->mtu = DEFAULT_L2VPN_MTU; l2vpn->pw_type = DEFAULT_PW_TYPE; - LIST_INIT(&l2vpn->if_list); + RB_INIT(&l2vpn->if_tree); LIST_INIT(&l2vpn->pw_list); LIST_INIT(&l2vpn->pw_inactive_list); @@ -72,8 +74,8 @@ l2vpn_del(struct l2vpn *l2vpn) struct l2vpn_if *lif; struct l2vpn_pw *pw; - while ((lif = LIST_FIRST(&l2vpn->if_list)) != NULL) { - LIST_REMOVE(lif, entry); + while ((lif = RB_ROOT(&l2vpn->if_tree)) != NULL) { + RB_REMOVE(l2vpn_if_head, &l2vpn->if_tree, lif); free(lif); } while ((pw = LIST_FIRST(&l2vpn->pw_list)) != NULL) { @@ -106,6 +108,12 @@ l2vpn_exit(struct l2vpn *l2vpn) l2vpn_pw_exit(pw); } +static __inline int +l2vpn_if_compare(struct l2vpn_if *a, struct l2vpn_if *b) +{ + return (strcmp(a->ifname, b->ifname)); +} + struct l2vpn_if * l2vpn_if_new(struct l2vpn *l2vpn, struct kif *kif) { @@ -127,7 +135,7 @@ l2vpn_if_find(struct l2vpn *l2vpn, unsigned int ifindex) { struct l2vpn_if *lif; - LIST_FOREACH(lif, &l2vpn->if_list, entry) + RB_FOREACH(lif, l2vpn_if_head, &l2vpn->if_tree) if (lif->ifindex == ifindex) return (lif); @@ -137,13 +145,9 @@ l2vpn_if_find(struct l2vpn *l2vpn, unsigned int ifindex) struct l2vpn_if * l2vpn_if_find_name(struct l2vpn *l2vpn, const char *ifname) { - struct l2vpn_if *lif; - - LIST_FOREACH(lif, &l2vpn->if_list, entry) - if (strcmp(lif->ifname, ifname) == 0) - return (lif); - - return (NULL); + struct l2vpn_if lif; + strlcpy(lif.ifname, ifname, sizeof(lif.ifname)); + return (RB_FIND(l2vpn_if_head, &l2vpn->if_tree, &lif)); } diff --git a/ldpd/lde.c b/ldpd/lde.c index 3feb27d168..522650cdc6 100644 --- a/ldpd/lde.c +++ b/ldpd/lde.c @@ -510,7 +510,7 @@ lde_dispatch_parent(struct thread *thread) fatal(NULL); memcpy(nl2vpn, imsg.data, sizeof(struct l2vpn)); - LIST_INIT(&nl2vpn->if_list); + RB_INIT(&nl2vpn->if_tree); LIST_INIT(&nl2vpn->pw_list); LIST_INIT(&nl2vpn->pw_inactive_list); @@ -522,7 +522,7 @@ lde_dispatch_parent(struct thread *thread) memcpy(nlif, imsg.data, sizeof(struct l2vpn_if)); nlif->l2vpn = nl2vpn; - LIST_INSERT_HEAD(&nl2vpn->if_list, nlif, entry); + RB_INSERT(l2vpn_if_head, &nl2vpn->if_tree, nlif); break; case IMSG_RECONF_L2VPN_PW: if ((npw = malloc(sizeof(struct l2vpn_pw))) == NULL) diff --git a/ldpd/ldp_vty_conf.c b/ldpd/ldp_vty_conf.c index b66d8d4698..b97964228d 100644 --- a/ldpd/ldp_vty_conf.c +++ b/ldpd/ldp_vty_conf.c @@ -354,7 +354,7 @@ ldp_l2vpn_config_write(struct vty *vty) vty_out(vty, " bridge %s%s", l2vpn->br_ifname, VTY_NEWLINE); - LIST_FOREACH(lif, &l2vpn->if_list, entry) + RB_FOREACH(lif, l2vpn_if_head, &l2vpn->if_tree) vty_out(vty, " member interface %s%s", lif->ifname, VTY_NEWLINE); @@ -1369,7 +1369,7 @@ ldp_vty_l2vpn_interface(struct vty *vty, struct vty_arg *args[]) if (lif == NULL) goto cancel; - LIST_REMOVE(lif, entry); + RB_REMOVE(l2vpn_if_head, &l2vpn->if_tree, lif); free(lif); ldp_reload(vty_conf); return (CMD_SUCCESS); @@ -1392,7 +1392,7 @@ ldp_vty_l2vpn_interface(struct vty *vty, struct vty_arg *args[]) } lif = l2vpn_if_new(l2vpn, &kif); - LIST_INSERT_HEAD(&l2vpn->if_list, lif, entry); + RB_INSERT(l2vpn_if_head, &l2vpn->if_tree, lif); ldp_reload_ref(vty_conf, (void **)&l2vpn); @@ -1716,8 +1716,8 @@ l2vpn_del_api(struct ldpd_conf *conf, struct l2vpn *l2vpn) struct l2vpn_if *lif; struct l2vpn_pw *pw; - while ((lif = LIST_FIRST(&l2vpn->if_list)) != NULL) { - LIST_REMOVE(lif, entry); + while ((lif = RB_ROOT(&l2vpn->if_tree)) != NULL) { + RB_REMOVE(l2vpn_if_head, &l2vpn->if_tree, lif); free(lif); } while ((pw = LIST_FIRST(&l2vpn->pw_list)) != NULL) { @@ -1752,14 +1752,14 @@ l2vpn_if_new_api(struct ldpd_conf *conf, struct l2vpn *l2vpn, } lif = l2vpn_if_new(l2vpn, &kif); - LIST_INSERT_HEAD(&l2vpn->if_list, lif, entry); + RB_INSERT(l2vpn_if_head, &l2vpn->if_tree, lif); return (lif); } void -l2vpn_if_del_api(struct l2vpn_if *lif) +l2vpn_if_del_api(struct l2vpn *l2vpn, struct l2vpn_if *lif) { - LIST_REMOVE(lif, entry); + RB_REMOVE(l2vpn_if_head, &l2vpn->if_tree, lif); free(lif); } diff --git a/ldpd/ldpd.c b/ldpd/ldpd.c index dab761db7f..0df9bbd61d 100644 --- a/ldpd/ldpd.c +++ b/ldpd/ldpd.c @@ -873,7 +873,7 @@ main_imsg_send_config(struct ldpd_conf *xconf) sizeof(*l2vpn)) == -1) return (-1); - LIST_FOREACH(lif, &l2vpn->if_list, entry) { + RB_FOREACH(lif, l2vpn_if_head, &l2vpn->if_tree) { if (main_imsg_compose_both(IMSG_RECONF_L2VPN_IF, lif, sizeof(*lif)) == -1) return (-1); @@ -1053,15 +1053,15 @@ ldp_dup_config_ref(struct ldpd_conf *conf, void **ref) } RB_FOREACH(l2vpn, l2vpn_head, &conf->l2vpn_tree) { COPY(xl, l2vpn); - LIST_INIT(&xl->if_list); + RB_INIT(&xl->if_tree); LIST_INIT(&xl->pw_list); LIST_INIT(&xl->pw_inactive_list); RB_INSERT(l2vpn_head, &xconf->l2vpn_tree, xl); - LIST_FOREACH(lif, &l2vpn->if_list, entry) { + RB_FOREACH(lif, l2vpn_if_head, &l2vpn->if_tree) { COPY(xf, lif); xf->l2vpn = xl; - LIST_INSERT_HEAD(&xl->if_list, xf, entry); + RB_INSERT(l2vpn_if_head, &xl->if_tree, xf); } LIST_FOREACH(pw, &l2vpn->pw_list, entry) { COPY(xp, pw); @@ -1482,7 +1482,7 @@ merge_l2vpns(struct ldpd_conf *conf, struct ldpd_conf *xconf, void **ref) ldpe_l2vpn_exit(l2vpn); break; case PROC_MAIN: - LIST_FOREACH(lif, &l2vpn->if_list, entry) + RB_FOREACH(lif, l2vpn_if_head, &l2vpn->if_tree) QOBJ_UNREG (lif); LIST_FOREACH(pw, &l2vpn->pw_list, entry) QOBJ_UNREG (pw); @@ -1537,27 +1537,27 @@ merge_l2vpn(struct ldpd_conf *xconf, struct l2vpn *l2vpn, struct l2vpn *xl, void previous_mtu = l2vpn->mtu; /* merge intefaces */ - LIST_FOREACH_SAFE(lif, &l2vpn->if_list, entry, ftmp) { + RB_FOREACH_SAFE(lif, l2vpn_if_head, &l2vpn->if_tree, ftmp) { /* find deleted interfaces */ if ((xf = l2vpn_if_find_name(xl, lif->ifname)) == NULL) { if (ldpd_process == PROC_MAIN) QOBJ_UNREG (lif); - LIST_REMOVE(lif, entry); + RB_REMOVE(l2vpn_if_head, &l2vpn->if_tree, lif); free(lif); } } - LIST_FOREACH_SAFE(xf, &xl->if_list, entry, ftmp) { + RB_FOREACH_SAFE(xf, l2vpn_if_head, &xl->if_tree, ftmp) { /* find new interfaces */ if ((lif = l2vpn_if_find_name(l2vpn, xf->ifname)) == NULL) { - LIST_REMOVE(xf, entry); - LIST_INSERT_HEAD(&l2vpn->if_list, xf, entry); + RB_REMOVE(l2vpn_if_head, &xl->if_tree, xf); + RB_INSERT(l2vpn_if_head, &l2vpn->if_tree, xf); xf->l2vpn = l2vpn; if (ldpd_process == PROC_MAIN) QOBJ_REG (xf, l2vpn_if); continue; } - LIST_REMOVE(xf, entry); + RB_REMOVE(l2vpn_if_head, &xl->if_tree, xf); if (ref && *ref == xf) *ref = lif; free(xf); diff --git a/ldpd/ldpd.h b/ldpd/ldpd.h index 72e5dc5bcf..0a21856347 100644 --- a/ldpd/ldpd.h +++ b/ldpd/ldpd.h @@ -325,13 +325,15 @@ DECLARE_QOBJ_TYPE(nbr_params) #define F_NBRP_GTSM_HOPS 0x04 struct l2vpn_if { - LIST_ENTRY(l2vpn_if) entry; + RB_ENTRY(l2vpn_if) entry; struct l2vpn *l2vpn; char ifname[IF_NAMESIZE]; unsigned int ifindex; uint16_t flags; QOBJ_FIELDS }; +RB_HEAD(l2vpn_if_head, l2vpn_if); +RB_PROTOTYPE(l2vpn_if_head, l2vpn_if, entry, l2vpn_if_compare); DECLARE_QOBJ_TYPE(l2vpn_if) struct l2vpn_pw { @@ -365,7 +367,7 @@ struct l2vpn { int mtu; char br_ifname[IF_NAMESIZE]; unsigned int br_ifindex; - LIST_HEAD(, l2vpn_if) if_list; + struct l2vpn_if_head if_tree; LIST_HEAD(, l2vpn_pw) pw_list; LIST_HEAD(, l2vpn_pw) pw_inactive_list; QOBJ_FIELDS @@ -651,7 +653,8 @@ void l2vpn_del_api(struct ldpd_conf *conf, struct l2vpn *l2vpn); struct l2vpn_if *l2vpn_if_new_api(struct ldpd_conf *conf, struct l2vpn *l2vpn, const char *ifname); -void l2vpn_if_del_api(struct l2vpn_if *lif); +void l2vpn_if_del_api(struct l2vpn *l2vpn, + struct l2vpn_if *lif); struct l2vpn_pw *l2vpn_pw_new_api(struct ldpd_conf *conf, struct l2vpn *l2vpn, const char *ifname); void l2vpn_pw_del_api(struct l2vpn_pw *pw); diff --git a/ldpd/ldpe.c b/ldpd/ldpe.c index 6edd180a43..2a9fb4c1d8 100644 --- a/ldpd/ldpe.c +++ b/ldpd/ldpe.c @@ -451,7 +451,7 @@ ldpe_dispatch_main(struct thread *thread) fatal(NULL); memcpy(nl2vpn, imsg.data, sizeof(struct l2vpn)); - LIST_INIT(&nl2vpn->if_list); + RB_INIT(&nl2vpn->if_tree); LIST_INIT(&nl2vpn->pw_list); LIST_INIT(&nl2vpn->pw_inactive_list); @@ -463,7 +463,7 @@ ldpe_dispatch_main(struct thread *thread) memcpy(nlif, imsg.data, sizeof(struct l2vpn_if)); nlif->l2vpn = nl2vpn; - LIST_INSERT_HEAD(&nl2vpn->if_list, nlif, entry); + RB_INSERT(l2vpn_if_head, &nl2vpn->if_tree, nlif); break; case IMSG_RECONF_L2VPN_PW: if ((npw = malloc(sizeof(struct l2vpn_pw))) == NULL) From 20bacaeba2381b7b199166e006576606defbaf0f Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Wed, 14 Dec 2016 13:53:07 -0200 Subject: [PATCH 049/107] ldpd: use red-black trees to store 'l2vpn_pw' elements Using red-black trees instead of linked lists brings the following benefits: 1 - Elements are naturally ordered (no need to reorder anything before outputting data to the user); 2 - Faster lookups/deletes: O(log n) time complexity against O(n). The insert operation with red-black trees is more expensive though, but that's not a big issue since lookups are much more frequent. Signed-off-by: Renato Westphal --- ldpd/l2vpn.c | 49 ++++++++++++++++++--------------- ldpd/lde.c | 8 +++--- ldpd/ldp_vty_conf.c | 22 +++++++-------- ldpd/ldpd.c | 66 ++++++++++++++++++++++----------------------- ldpd/ldpd.h | 11 +++++--- ldpd/ldpe.c | 8 +++--- 6 files changed, 86 insertions(+), 78 deletions(-) diff --git a/ldpd/l2vpn.c b/ldpd/l2vpn.c index 02f25e18b0..c1d0437fba 100644 --- a/ldpd/l2vpn.c +++ b/ldpd/l2vpn.c @@ -29,9 +29,11 @@ static void l2vpn_pw_fec(struct l2vpn_pw *, struct fec *); static __inline int l2vpn_compare(struct l2vpn *, struct l2vpn *); static __inline int l2vpn_if_compare(struct l2vpn_if *, struct l2vpn_if *); +static __inline int l2vpn_pw_compare(struct l2vpn_pw *, struct l2vpn_pw *); RB_GENERATE(l2vpn_head, l2vpn, entry, l2vpn_compare) RB_GENERATE(l2vpn_if_head, l2vpn_if, entry, l2vpn_if_compare) +RB_GENERATE(l2vpn_pw_head, l2vpn_pw, entry, l2vpn_pw_compare) static __inline int l2vpn_compare(struct l2vpn *a, struct l2vpn *b) @@ -54,8 +56,8 @@ l2vpn_new(const char *name) l2vpn->pw_type = DEFAULT_PW_TYPE; RB_INIT(&l2vpn->if_tree); - LIST_INIT(&l2vpn->pw_list); - LIST_INIT(&l2vpn->pw_inactive_list); + RB_INIT(&l2vpn->pw_tree); + RB_INIT(&l2vpn->pw_inactive_tree); return (l2vpn); } @@ -78,12 +80,12 @@ l2vpn_del(struct l2vpn *l2vpn) RB_REMOVE(l2vpn_if_head, &l2vpn->if_tree, lif); free(lif); } - while ((pw = LIST_FIRST(&l2vpn->pw_list)) != NULL) { - LIST_REMOVE(pw, entry); + while ((pw = RB_ROOT(&l2vpn->pw_tree)) != NULL) { + RB_REMOVE(l2vpn_pw_head, &l2vpn->pw_tree, pw); free(pw); } - while ((pw = LIST_FIRST(&l2vpn->pw_inactive_list)) != NULL) { - LIST_REMOVE(pw, entry); + while ((pw = RB_ROOT(&l2vpn->pw_inactive_tree)) != NULL) { + RB_REMOVE(l2vpn_pw_head, &l2vpn->pw_inactive_tree, pw); free(pw); } @@ -95,7 +97,7 @@ l2vpn_init(struct l2vpn *l2vpn) { struct l2vpn_pw *pw; - LIST_FOREACH(pw, &l2vpn->pw_list, entry) + RB_FOREACH(pw, l2vpn_pw_head, &l2vpn->pw_tree) l2vpn_pw_init(pw); } @@ -104,7 +106,7 @@ l2vpn_exit(struct l2vpn *l2vpn) { struct l2vpn_pw *pw; - LIST_FOREACH(pw, &l2vpn->pw_list, entry) + RB_FOREACH(pw, l2vpn_pw_head, &l2vpn->pw_tree) l2vpn_pw_exit(pw); } @@ -150,6 +152,11 @@ l2vpn_if_find_name(struct l2vpn *l2vpn, const char *ifname) return (RB_FIND(l2vpn_if_head, &l2vpn->if_tree, &lif)); } +static __inline int +l2vpn_pw_compare(struct l2vpn_pw *a, struct l2vpn_pw *b) +{ + return (strcmp(a->ifname, b->ifname)); +} struct l2vpn_pw * l2vpn_pw_new(struct l2vpn *l2vpn, struct kif *kif) @@ -171,10 +178,10 @@ l2vpn_pw_find(struct l2vpn *l2vpn, unsigned int ifindex) { struct l2vpn_pw *pw; - LIST_FOREACH(pw, &l2vpn->pw_list, entry) + RB_FOREACH(pw, l2vpn_pw_head, &l2vpn->pw_tree) if (pw->ifindex == ifindex) return (pw); - LIST_FOREACH(pw, &l2vpn->pw_inactive_list, entry) + RB_FOREACH(pw, l2vpn_pw_head, &l2vpn->pw_inactive_tree) if (pw->ifindex == ifindex) return (pw); @@ -185,15 +192,13 @@ struct l2vpn_pw * l2vpn_pw_find_name(struct l2vpn *l2vpn, const char *ifname) { struct l2vpn_pw *pw; + struct l2vpn_pw s; - LIST_FOREACH(pw, &l2vpn->pw_list, entry) - if (strcmp(pw->ifname, ifname) == 0) - return (pw); - LIST_FOREACH(pw, &l2vpn->pw_inactive_list, entry) - if (strcmp(pw->ifname, ifname) == 0) - return (pw); - - return (NULL); + strlcpy(s.ifname, ifname, sizeof(s.ifname)); + pw = RB_FIND(l2vpn_pw_head, &l2vpn->pw_tree, &s); + if (pw) + return (pw); + return (RB_FIND(l2vpn_pw_head, &l2vpn->pw_inactive_tree, &s)); } void @@ -409,7 +414,7 @@ l2vpn_sync_pws(int af, union ldpd_addr *addr) struct fec_nh *fnh; RB_FOREACH(l2vpn, l2vpn_head, &ldeconf->l2vpn_tree) { - LIST_FOREACH(pw, &l2vpn->pw_list, entry) { + RB_FOREACH(pw, l2vpn_pw_head, &l2vpn->pw_tree) { if (af != pw->af || ldp_addrcmp(af, &pw->addr, addr)) continue; @@ -438,7 +443,7 @@ l2vpn_pw_ctl(pid_t pid) static struct ctl_pw pwctl; RB_FOREACH(l2vpn, l2vpn_head, &ldeconf->l2vpn_tree) - LIST_FOREACH(pw, &l2vpn->pw_list, entry) { + RB_FOREACH(pw, l2vpn_pw_head, &l2vpn->pw_tree) { memset(&pwctl, 0, sizeof(pwctl)); strlcpy(pwctl.l2vpn_name, pw->l2vpn->name, sizeof(pwctl.l2vpn_name)); @@ -517,7 +522,7 @@ ldpe_l2vpn_init(struct l2vpn *l2vpn) { struct l2vpn_pw *pw; - LIST_FOREACH(pw, &l2vpn->pw_list, entry) + RB_FOREACH(pw, l2vpn_pw_head, &l2vpn->pw_tree) ldpe_l2vpn_pw_init(pw); } @@ -526,7 +531,7 @@ ldpe_l2vpn_exit(struct l2vpn *l2vpn) { struct l2vpn_pw *pw; - LIST_FOREACH(pw, &l2vpn->pw_list, entry) + RB_FOREACH(pw, l2vpn_pw_head, &l2vpn->pw_tree) ldpe_l2vpn_pw_exit(pw); } diff --git a/ldpd/lde.c b/ldpd/lde.c index 522650cdc6..aa83ef0aba 100644 --- a/ldpd/lde.c +++ b/ldpd/lde.c @@ -511,8 +511,8 @@ lde_dispatch_parent(struct thread *thread) memcpy(nl2vpn, imsg.data, sizeof(struct l2vpn)); RB_INIT(&nl2vpn->if_tree); - LIST_INIT(&nl2vpn->pw_list); - LIST_INIT(&nl2vpn->pw_inactive_list); + RB_INIT(&nl2vpn->pw_tree); + RB_INIT(&nl2vpn->pw_inactive_tree); RB_INSERT(l2vpn_head, &nconf->l2vpn_tree, nl2vpn); break; @@ -530,7 +530,7 @@ lde_dispatch_parent(struct thread *thread) memcpy(npw, imsg.data, sizeof(struct l2vpn_pw)); npw->l2vpn = nl2vpn; - LIST_INSERT_HEAD(&nl2vpn->pw_list, npw, entry); + RB_INSERT(l2vpn_pw_head, &nl2vpn->pw_tree, npw); break; case IMSG_RECONF_L2VPN_IPW: if ((npw = malloc(sizeof(struct l2vpn_pw))) == NULL) @@ -538,7 +538,7 @@ lde_dispatch_parent(struct thread *thread) memcpy(npw, imsg.data, sizeof(struct l2vpn_pw)); npw->l2vpn = nl2vpn; - LIST_INSERT_HEAD(&nl2vpn->pw_inactive_list, npw, entry); + RB_INSERT(l2vpn_pw_head, &nl2vpn->pw_inactive_tree, npw); break; case IMSG_RECONF_END: merge_config(ldeconf, nconf); diff --git a/ldpd/ldp_vty_conf.c b/ldpd/ldp_vty_conf.c index b97964228d..e408abb091 100644 --- a/ldpd/ldp_vty_conf.c +++ b/ldpd/ldp_vty_conf.c @@ -358,9 +358,9 @@ ldp_l2vpn_config_write(struct vty *vty) vty_out(vty, " member interface %s%s", lif->ifname, VTY_NEWLINE); - LIST_FOREACH(pw, &l2vpn->pw_list, entry) + RB_FOREACH(pw, l2vpn_pw_head, &l2vpn->pw_tree) ldp_l2vpn_pw_config_write(vty, pw); - LIST_FOREACH(pw, &l2vpn->pw_inactive_list, entry) + RB_FOREACH(pw, l2vpn_pw_head, &l2vpn->pw_inactive_tree) ldp_l2vpn_pw_config_write(vty, pw); vty_out(vty, " !%s", VTY_NEWLINE); @@ -1425,7 +1425,7 @@ ldp_vty_l2vpn_pseudowire(struct vty *vty, struct vty_arg *args[]) if (pw == NULL) goto cancel; - LIST_REMOVE(pw, entry); + RB_REMOVE(l2vpn_pw_head, &l2vpn->pw_inactive_tree, pw); free(pw); ldp_reload(vty_conf); return (CMD_SUCCESS); @@ -1451,7 +1451,7 @@ ldp_vty_l2vpn_pseudowire(struct vty *vty, struct vty_arg *args[]) pw = l2vpn_pw_new(l2vpn, &kif); pw->flags = F_PW_STATUSTLV_CONF|F_PW_CWORD_CONF; - LIST_INSERT_HEAD(&l2vpn->pw_inactive_list, pw, entry); + RB_INSERT(l2vpn_pw_head, &l2vpn->pw_inactive_tree, pw); ldp_reload_ref(vty_conf, (void **)&pw); VTY_PUSH_CONTEXT_SUB(LDP_PSEUDOWIRE_NODE, pw); @@ -1720,12 +1720,12 @@ l2vpn_del_api(struct ldpd_conf *conf, struct l2vpn *l2vpn) RB_REMOVE(l2vpn_if_head, &l2vpn->if_tree, lif); free(lif); } - while ((pw = LIST_FIRST(&l2vpn->pw_list)) != NULL) { - LIST_REMOVE(pw, entry); + while ((pw = RB_ROOT(&l2vpn->pw_tree)) != NULL) { + RB_REMOVE(l2vpn_pw_head, &l2vpn->pw_tree, pw); free(pw); } - while ((pw = LIST_FIRST(&l2vpn->pw_inactive_list)) != NULL) { - LIST_REMOVE(pw, entry); + while ((pw = RB_ROOT(&l2vpn->pw_inactive_tree)) != NULL) { + RB_REMOVE(l2vpn_pw_head, &l2vpn->pw_inactive_tree, pw); free(pw); } RB_REMOVE(l2vpn_head, &conf->l2vpn_tree, l2vpn); @@ -1784,13 +1784,13 @@ l2vpn_pw_new_api(struct ldpd_conf *conf, struct l2vpn *l2vpn, pw = l2vpn_pw_new(l2vpn, &kif); pw->flags = F_PW_STATUSTLV_CONF|F_PW_CWORD_CONF; - LIST_INSERT_HEAD(&l2vpn->pw_inactive_list, pw, entry); + RB_INSERT(l2vpn_pw_head, &l2vpn->pw_inactive_tree, pw); return (pw); } void -l2vpn_pw_del_api(struct l2vpn_pw *pw) +l2vpn_pw_del_api(struct l2vpn *l2vpn, struct l2vpn_pw *pw) { - LIST_REMOVE(pw, entry); + RB_REMOVE(l2vpn_pw_head, &l2vpn->pw_inactive_tree, pw); free(pw); } diff --git a/ldpd/ldpd.c b/ldpd/ldpd.c index 0df9bbd61d..943129f513 100644 --- a/ldpd/ldpd.c +++ b/ldpd/ldpd.c @@ -878,12 +878,12 @@ main_imsg_send_config(struct ldpd_conf *xconf) sizeof(*lif)) == -1) return (-1); } - LIST_FOREACH(pw, &l2vpn->pw_list, entry) { + RB_FOREACH(pw, l2vpn_pw_head, &l2vpn->pw_tree) { if (main_imsg_compose_both(IMSG_RECONF_L2VPN_PW, pw, sizeof(*pw)) == -1) return (-1); } - LIST_FOREACH(pw, &l2vpn->pw_inactive_list, entry) { + RB_FOREACH(pw, l2vpn_pw_head, &l2vpn->pw_inactive_tree) { if (main_imsg_compose_both(IMSG_RECONF_L2VPN_IPW, pw, sizeof(*pw)) == -1) return (-1); @@ -931,14 +931,14 @@ ldp_config_normalize(struct ldpd_conf *xconf, void **ref) } RB_FOREACH(l2vpn, l2vpn_head, &xconf->l2vpn_tree) { - LIST_FOREACH(pw, &l2vpn->pw_list, entry) { + RB_FOREACH(pw, l2vpn_pw_head, &l2vpn->pw_tree) { if (pw->flags & F_PW_STATIC_NBR_ADDR) continue; pw->af = AF_INET; pw->addr.v4 = pw->lsr_id; } - LIST_FOREACH(pw, &l2vpn->pw_inactive_list, entry) { + RB_FOREACH(pw, l2vpn_pw_head, &l2vpn->pw_inactive_tree) { if (pw->flags & F_PW_STATIC_NBR_ADDR) continue; @@ -1054,8 +1054,8 @@ ldp_dup_config_ref(struct ldpd_conf *conf, void **ref) RB_FOREACH(l2vpn, l2vpn_head, &conf->l2vpn_tree) { COPY(xl, l2vpn); RB_INIT(&xl->if_tree); - LIST_INIT(&xl->pw_list); - LIST_INIT(&xl->pw_inactive_list); + RB_INIT(&xl->pw_tree); + RB_INIT(&xl->pw_inactive_tree); RB_INSERT(l2vpn_head, &xconf->l2vpn_tree, xl); RB_FOREACH(lif, l2vpn_if_head, &l2vpn->if_tree) { @@ -1063,15 +1063,15 @@ ldp_dup_config_ref(struct ldpd_conf *conf, void **ref) xf->l2vpn = xl; RB_INSERT(l2vpn_if_head, &xl->if_tree, xf); } - LIST_FOREACH(pw, &l2vpn->pw_list, entry) { + RB_FOREACH(pw, l2vpn_pw_head, &l2vpn->pw_tree) { COPY(xp, pw); xp->l2vpn = xl; - LIST_INSERT_HEAD(&xl->pw_list, xp, entry); + RB_INSERT(l2vpn_pw_head, &xl->pw_tree, xp); } - LIST_FOREACH(pw, &l2vpn->pw_inactive_list, entry) { + RB_FOREACH(pw, l2vpn_pw_head, &l2vpn->pw_inactive_tree) { COPY(xp, pw); xp->l2vpn = xl; - LIST_INSERT_HEAD(&xl->pw_inactive_list, xp, entry); + RB_INSERT(l2vpn_pw_head, &xl->pw_inactive_tree, xp); } } #undef COPY @@ -1484,9 +1484,9 @@ merge_l2vpns(struct ldpd_conf *conf, struct ldpd_conf *xconf, void **ref) case PROC_MAIN: RB_FOREACH(lif, l2vpn_if_head, &l2vpn->if_tree) QOBJ_UNREG (lif); - LIST_FOREACH(pw, &l2vpn->pw_list, entry) + RB_FOREACH(pw, l2vpn_pw_head, &l2vpn->pw_tree) QOBJ_UNREG (pw); - LIST_FOREACH(pw, &l2vpn->pw_inactive_list, entry) + RB_FOREACH(pw, l2vpn_pw_head, &l2vpn->pw_inactive_tree) QOBJ_UNREG (pw); QOBJ_UNREG (l2vpn); break; @@ -1530,7 +1530,7 @@ merge_l2vpn(struct ldpd_conf *xconf, struct l2vpn *l2vpn, struct l2vpn *xl, void struct l2vpn_pw *pw, *ptmp, *xp; struct nbr *nbr; int reset_nbr, reinstall_pwfec, reinstall_tnbr; - LIST_HEAD(, l2vpn_pw) pw_aux_list; + struct l2vpn_pw_head pw_aux_list; int previous_pw_type, previous_mtu; previous_pw_type = l2vpn->pw_type; @@ -1564,8 +1564,8 @@ merge_l2vpn(struct ldpd_conf *xconf, struct l2vpn *l2vpn, struct l2vpn *xl, void } /* merge active pseudowires */ - LIST_INIT(&pw_aux_list); - LIST_FOREACH_SAFE(pw, &l2vpn->pw_list, entry, ptmp) { + RB_INIT(&pw_aux_list); + RB_FOREACH_SAFE(pw, l2vpn_pw_head, &l2vpn->pw_tree, ptmp) { /* find deleted active pseudowires */ if ((xp = l2vpn_pw_find_name(xl, pw->ifname)) == NULL) { switch (ldpd_process) { @@ -1580,15 +1580,15 @@ merge_l2vpn(struct ldpd_conf *xconf, struct l2vpn *l2vpn, struct l2vpn *xl, void break; } - LIST_REMOVE(pw, entry); + RB_REMOVE(l2vpn_pw_head, &l2vpn->pw_tree, pw); free(pw); } } - LIST_FOREACH_SAFE(xp, &xl->pw_list, entry, ptmp) { + RB_FOREACH_SAFE(xp, l2vpn_pw_head, &xl->pw_tree, ptmp) { /* find new active pseudowires */ if ((pw = l2vpn_pw_find_name(l2vpn, xp->ifname)) == NULL) { - LIST_REMOVE(xp, entry); - LIST_INSERT_HEAD(&l2vpn->pw_list, xp, entry); + RB_REMOVE(l2vpn_pw_head, &xl->pw_tree, xp); + RB_INSERT(l2vpn_pw_head, &l2vpn->pw_tree, xp); xp->l2vpn = l2vpn; switch (ldpd_process) { @@ -1644,8 +1644,8 @@ merge_l2vpn(struct ldpd_conf *xconf, struct l2vpn *l2vpn, struct l2vpn *xl, void } /* remove from active list */ - LIST_REMOVE(pw, entry); - LIST_INSERT_HEAD(&pw_aux_list, pw, entry); + RB_REMOVE(l2vpn_pw_head, &l2vpn->pw_tree, pw); + RB_INSERT(l2vpn_pw_head, &pw_aux_list, pw); } if (ldpd_process == PROC_LDP_ENGINE) { @@ -1689,27 +1689,27 @@ merge_l2vpn(struct ldpd_conf *xconf, struct l2vpn *l2vpn, struct l2vpn *xl, void l2vpn->mtu = previous_mtu; } - LIST_REMOVE(xp, entry); + RB_REMOVE(l2vpn_pw_head, &xl->pw_tree, xp); if (ref && *ref == xp) *ref = pw; free(xp); } /* merge inactive pseudowires */ - LIST_FOREACH_SAFE(pw, &l2vpn->pw_inactive_list, entry, ptmp) { + RB_FOREACH_SAFE(pw, l2vpn_pw_head, &l2vpn->pw_inactive_tree, ptmp) { /* find deleted inactive pseudowires */ if ((xp = l2vpn_pw_find_name(xl, pw->ifname)) == NULL) { - LIST_REMOVE(pw, entry); + RB_REMOVE(l2vpn_pw_head, &l2vpn->pw_inactive_tree, pw); if (ldpd_process == PROC_MAIN) QOBJ_UNREG (pw); free(pw); } } - LIST_FOREACH_SAFE(xp, &xl->pw_inactive_list, entry, ptmp) { + RB_FOREACH_SAFE(xp, l2vpn_pw_head, &xl->pw_inactive_tree, ptmp) { /* find new inactive pseudowires */ if ((pw = l2vpn_pw_find_name(l2vpn, xp->ifname)) == NULL) { - LIST_REMOVE(xp, entry); - LIST_INSERT_HEAD(&l2vpn->pw_inactive_list, xp, entry); + RB_REMOVE(l2vpn_pw_head, &xl->pw_inactive_tree, xp); + RB_INSERT(l2vpn_pw_head, &l2vpn->pw_inactive_tree, xp); xp->l2vpn = l2vpn; if (ldpd_process == PROC_MAIN) QOBJ_REG (xp, l2vpn_pw); @@ -1728,8 +1728,8 @@ merge_l2vpn(struct ldpd_conf *xconf, struct l2vpn *l2vpn, struct l2vpn *xl, void /* check if the pseudowire should be activated */ if (pw->lsr_id.s_addr != INADDR_ANY && pw->pwid != 0) { /* remove from inactive list */ - LIST_REMOVE(pw, entry); - LIST_INSERT_HEAD(&l2vpn->pw_list, pw, entry); + RB_REMOVE(l2vpn_pw_head, &l2vpn->pw_inactive_tree, pw); + RB_INSERT(l2vpn_pw_head, &l2vpn->pw_tree, pw); switch (ldpd_process) { case PROC_LDE_ENGINE: @@ -1743,16 +1743,16 @@ merge_l2vpn(struct ldpd_conf *xconf, struct l2vpn *l2vpn, struct l2vpn *xl, void } } - LIST_REMOVE(xp, entry); + RB_REMOVE(l2vpn_pw_head, &xl->pw_inactive_tree, xp); if (ref && *ref == xp) *ref = pw; free(xp); } /* insert pseudowires that were disabled in the inactive list */ - LIST_FOREACH_SAFE(pw, &pw_aux_list, entry, ptmp) { - LIST_REMOVE(pw, entry); - LIST_INSERT_HEAD(&l2vpn->pw_inactive_list, pw, entry); + RB_FOREACH_SAFE(pw, l2vpn_pw_head, &pw_aux_list, ptmp) { + RB_REMOVE(l2vpn_pw_head, &l2vpn->pw_tree, pw); + RB_INSERT(l2vpn_pw_head, &l2vpn->pw_inactive_tree, pw); } l2vpn->pw_type = xl->pw_type; diff --git a/ldpd/ldpd.h b/ldpd/ldpd.h index 0a21856347..6836920bc9 100644 --- a/ldpd/ldpd.h +++ b/ldpd/ldpd.h @@ -337,7 +337,7 @@ RB_PROTOTYPE(l2vpn_if_head, l2vpn_if, entry, l2vpn_if_compare); DECLARE_QOBJ_TYPE(l2vpn_if) struct l2vpn_pw { - LIST_ENTRY(l2vpn_pw) entry; + RB_ENTRY(l2vpn_pw) entry; struct l2vpn *l2vpn; struct in_addr lsr_id; int af; @@ -351,6 +351,8 @@ struct l2vpn_pw { uint8_t flags; QOBJ_FIELDS }; +RB_HEAD(l2vpn_pw_head, l2vpn_pw); +RB_PROTOTYPE(l2vpn_pw_head, l2vpn_pw, entry, l2vpn_pw_compare); DECLARE_QOBJ_TYPE(l2vpn_pw) #define F_PW_STATUSTLV_CONF 0x01 /* status tlv configured */ #define F_PW_STATUSTLV 0x02 /* status tlv negotiated */ @@ -368,8 +370,8 @@ struct l2vpn { char br_ifname[IF_NAMESIZE]; unsigned int br_ifindex; struct l2vpn_if_head if_tree; - LIST_HEAD(, l2vpn_pw) pw_list; - LIST_HEAD(, l2vpn_pw) pw_inactive_list; + struct l2vpn_pw_head pw_tree; + struct l2vpn_pw_head pw_inactive_tree; QOBJ_FIELDS }; RB_HEAD(l2vpn_head, l2vpn); @@ -657,7 +659,8 @@ void l2vpn_if_del_api(struct l2vpn *l2vpn, struct l2vpn_if *lif); struct l2vpn_pw *l2vpn_pw_new_api(struct ldpd_conf *conf, struct l2vpn *l2vpn, const char *ifname); -void l2vpn_pw_del_api(struct l2vpn_pw *pw); +void l2vpn_pw_del_api(struct l2vpn *l2vpn, + struct l2vpn_pw *pw); /* socket.c */ int ldp_create_socket(int, enum socket_type); diff --git a/ldpd/ldpe.c b/ldpd/ldpe.c index 2a9fb4c1d8..c3640d4131 100644 --- a/ldpd/ldpe.c +++ b/ldpd/ldpe.c @@ -452,8 +452,8 @@ ldpe_dispatch_main(struct thread *thread) memcpy(nl2vpn, imsg.data, sizeof(struct l2vpn)); RB_INIT(&nl2vpn->if_tree); - LIST_INIT(&nl2vpn->pw_list); - LIST_INIT(&nl2vpn->pw_inactive_list); + RB_INIT(&nl2vpn->pw_tree); + RB_INIT(&nl2vpn->pw_inactive_tree); RB_INSERT(l2vpn_head, &nconf->l2vpn_tree, nl2vpn); break; @@ -471,7 +471,7 @@ ldpe_dispatch_main(struct thread *thread) memcpy(npw, imsg.data, sizeof(struct l2vpn_pw)); npw->l2vpn = nl2vpn; - LIST_INSERT_HEAD(&nl2vpn->pw_list, npw, entry); + RB_INSERT(l2vpn_pw_head, &nl2vpn->pw_tree, npw); break; case IMSG_RECONF_L2VPN_IPW: if ((npw = malloc(sizeof(struct l2vpn_pw))) == NULL) @@ -479,7 +479,7 @@ ldpe_dispatch_main(struct thread *thread) memcpy(npw, imsg.data, sizeof(struct l2vpn_pw)); npw->l2vpn = nl2vpn; - LIST_INSERT_HEAD(&nl2vpn->pw_inactive_list, npw, entry); + RB_INSERT(l2vpn_pw_head, &nl2vpn->pw_inactive_tree, npw); break; case IMSG_RECONF_END: merge_config(leconf, nconf); From 057d48bd58776c31db20ec8cf3044cb1d20140d5 Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Wed, 14 Dec 2016 17:39:28 -0200 Subject: [PATCH 050/107] ldpd: use red-black trees to store 'adj' elements Using red-black trees instead of linked lists brings the following benefits: 1 - Elements are naturally ordered (no need to reorder anything before outputting data to the user); 2 - Faster lookups/deletes: O(log n) time complexity against O(n). The insert operation with red-black trees is more expensive though, but that's not a big issue since lookups are much more frequent. Signed-off-by: Renato Westphal --- ldpd/adjacency.c | 80 +++++++++++++++++++++++++++++------------------- ldpd/hello.c | 2 +- ldpd/interface.c | 8 ++--- ldpd/lde.c | 4 +-- ldpd/ldpd.h | 9 ++++-- ldpd/ldpe.c | 18 +++++------ ldpd/ldpe.h | 12 +++++--- ldpd/neighbor.c | 10 +++--- 8 files changed, 84 insertions(+), 59 deletions(-) diff --git a/ldpd/adjacency.c b/ldpd/adjacency.c index 3f478df38a..2e7b43296a 100644 --- a/ldpd/adjacency.c +++ b/ldpd/adjacency.c @@ -25,6 +25,7 @@ #include "ldpe.h" #include "log.h" +static __inline int adj_compare(struct adj *, struct adj *); static int adj_itimer(struct thread *); static __inline int tnbr_compare(struct tnbr *, struct tnbr *); static void tnbr_del(struct ldpd_conf *, struct tnbr *); @@ -32,8 +33,47 @@ static int tnbr_hello_timer(struct thread *); static void tnbr_start_hello_timer(struct tnbr *); static void tnbr_stop_hello_timer(struct tnbr *); +RB_GENERATE(global_adj_head, adj, global_entry, adj_compare) +RB_GENERATE(nbr_adj_head, adj, nbr_entry, adj_compare) +RB_GENERATE(ia_adj_head, adj, ia_entry, adj_compare) RB_GENERATE(tnbr_head, tnbr, entry, tnbr_compare) +static __inline int +adj_compare(struct adj *a, struct adj *b) +{ + if (a->source.type < b->source.type) + return (-1); + if (a->source.type > b->source.type) + return (1); + + switch (a->source.type) { + case HELLO_LINK: + if (strcmp(a->source.link.ia->iface->name, + b->source.link.ia->iface->name) < 0) + return (-1); + if (strcmp(a->source.link.ia->iface->name, + b->source.link.ia->iface->name) > 0) + return (1); + if (a->source.link.ia->af < b->source.link.ia->af) + return (-1); + if (a->source.link.ia->af > b->source.link.ia->af) + return (1); + return (ldp_addrcmp(a->source.link.ia->af, + &a->source.link.src_addr, &b->source.link.src_addr)); + case HELLO_TARGETED: + if (a->source.target->af < b->source.target->af) + return (-1); + if (a->source.target->af > b->source.target->af) + return (1); + return (ldp_addrcmp(a->source.target->af, + &a->source.target->addr, &b->source.target->addr)); + default: + fatalx("adj_get_af: unknown hello type"); + } + + return (0); +} + struct adj * adj_new(struct in_addr lsr_id, struct hello_source *source, union ldpd_addr *addr) @@ -51,11 +91,11 @@ adj_new(struct in_addr lsr_id, struct hello_source *source, adj->source = *source; adj->trans_addr = *addr; - LIST_INSERT_HEAD(&global.adj_list, adj, global_entry); + RB_INSERT(global_adj_head, &global.adj_tree, adj); switch (source->type) { case HELLO_LINK: - LIST_INSERT_HEAD(&source->link.ia->adj_list, adj, ia_entry); + RB_INSERT(ia_adj_head, &source->link.ia->adj_tree, adj); break; case HELLO_TARGETED: source->target->adj = adj; @@ -73,12 +113,12 @@ adj_del_single(struct adj *adj) adj_stop_itimer(adj); - LIST_REMOVE(adj, global_entry); + RB_REMOVE(global_adj_head, &global.adj_tree, adj); if (adj->nbr) - LIST_REMOVE(adj, nbr_entry); + RB_REMOVE(nbr_adj_head, &adj->nbr->adj_tree, adj); switch (adj->source.type) { case HELLO_LINK: - LIST_REMOVE(adj, ia_entry); + RB_REMOVE(ia_adj_head, &adj->source.link.ia->adj_tree, adj); break; case HELLO_TARGETED: adj->source.target->adj = NULL; @@ -102,7 +142,7 @@ adj_del(struct adj *adj, uint32_t notif_status) * then delete it. */ if (nbr && nbr_adj_count(nbr, nbr->af) == 0) { - LIST_FOREACH_SAFE(adj, &nbr->adj_list, nbr_entry, atmp) + RB_FOREACH_SAFE(adj, nbr_adj_head, &nbr->adj_tree, atmp) adj_del_single(adj); session_shutdown(nbr, notif_status, 0, 0); nbr_del(nbr); @@ -112,31 +152,9 @@ adj_del(struct adj *adj, uint32_t notif_status) struct adj * adj_find(struct hello_source *source) { - struct adj *adj; - - LIST_FOREACH(adj, &global.adj_list, global_entry) { - if (adj->source.type != source->type) - continue; - - switch (source->type) { - case HELLO_LINK: - if (strcmp(source->link.ia->iface->name, - adj->source.link.ia->iface->name)) - continue; - - if (ldp_addrcmp(source->link.ia->af, - &adj->source.link.src_addr, - &source->link.src_addr) == 0) - return (adj); - break; - case HELLO_TARGETED: - if (adj->source.target == source->target) - return (adj); - break; - } - } - - return (NULL); + struct adj adj; + adj.source = *source; + return (RB_FIND(global_adj_head, &global.adj_tree, &adj)); } int diff --git a/ldpd/hello.c b/ldpd/hello.c index 0833ebbafb..95be1d5111 100644 --- a/ldpd/hello.c +++ b/ldpd/hello.c @@ -364,7 +364,7 @@ recv_hello(struct in_addr lsr_id, struct ldp_msg *msg, int af, adj = adj_new(lsr_id, &source, &trans_addr); if (nbr) { adj->nbr = nbr; - LIST_INSERT_HEAD(&nbr->adj_list, adj, nbr_entry); + RB_INSERT(nbr_adj_head, &nbr->adj_tree, adj); } } diff --git a/ldpd/interface.c b/ldpd/interface.c index 06d36fef72..8fea91b878 100644 --- a/ldpd/interface.c +++ b/ldpd/interface.c @@ -66,14 +66,14 @@ if_new(struct kif *kif) iface->ipv4.iface = iface; iface->ipv4.enabled = 0; iface->ipv4.state = IF_STA_DOWN; - LIST_INIT(&iface->ipv4.adj_list); + RB_INIT(&iface->ipv4.adj_tree); /* ipv6 */ iface->ipv6.af = AF_INET6; iface->ipv6.iface = iface; iface->ipv6.enabled = 0; iface->ipv6.state = IF_STA_DOWN; - LIST_INIT(&iface->ipv6.adj_list); + RB_INIT(&iface->ipv6.adj_tree); return (iface); } @@ -293,7 +293,7 @@ if_reset(struct iface *iface, int af) ia = iface_af_get(iface, af); if_stop_hello_timer(ia); - while ((adj = LIST_FIRST(&ia->adj_list)) != NULL) + while ((adj = RB_ROOT(&ia->adj_tree)) != NULL) adj_del(adj, S_SHUTDOWN); /* try to cleanup */ @@ -465,7 +465,7 @@ if_to_ctl(struct iface_af *ia) ictl.uptime = 0; ictl.adj_cnt = 0; - LIST_FOREACH(adj, &ia->adj_list, ia_entry) + RB_FOREACH(adj, ia_adj_head, &ia->adj_tree) ictl.adj_cnt++; return (&ictl); diff --git a/ldpd/lde.c b/ldpd/lde.c index aa83ef0aba..5b2ae00fe6 100644 --- a/ldpd/lde.c +++ b/ldpd/lde.c @@ -484,8 +484,8 @@ lde_dispatch_parent(struct thread *thread) memcpy(niface, imsg.data, sizeof(struct iface)); LIST_INIT(&niface->addr_list); - LIST_INIT(&niface->ipv4.adj_list); - LIST_INIT(&niface->ipv6.adj_list); + RB_INIT(&niface->ipv4.adj_tree); + RB_INIT(&niface->ipv6.adj_tree); niface->ipv4.iface = niface; niface->ipv6.iface = niface; diff --git a/ldpd/ldpd.h b/ldpd/ldpd.h index 6836920bc9..4d575597ae 100644 --- a/ldpd/ldpd.h +++ b/ldpd/ldpd.h @@ -196,7 +196,10 @@ enum nbr_action { NBR_ACT_CLOSE_SESSION }; -TAILQ_HEAD(mapping_head, mapping_entry); +/* forward declarations */ +RB_HEAD(global_adj_head, adj); +RB_HEAD(nbr_adj_head, adj); +RB_HEAD(ia_adj_head, adj); struct map { uint8_t type; @@ -256,7 +259,7 @@ struct iface_af { int af; int enabled; int state; - LIST_HEAD(, adj) adj_list; + struct ia_adj_head adj_tree; time_t uptime; struct thread *hello_timer; uint16_t hello_holdtime; @@ -450,7 +453,7 @@ struct ldpd_global { uint32_t conf_seqnum; int pfkeysock; struct if_addr_head addr_list; - LIST_HEAD(, adj) adj_list; + struct global_adj_head adj_tree; struct in_addr mcast_addr_v4; struct in6_addr mcast_addr_v6; TAILQ_HEAD(, pending_conn) pending_conns; diff --git a/ldpd/ldpe.c b/ldpd/ldpe.c index c3640d4131..c960acf3b1 100644 --- a/ldpd/ldpe.c +++ b/ldpd/ldpe.c @@ -111,7 +111,7 @@ ldpe(const char *user, const char *group) ldpd_process = PROC_LDP_ENGINE; LIST_INIT(&global.addr_list); - LIST_INIT(&global.adj_list); + RB_INIT(&global.adj_tree); TAILQ_INIT(&global.pending_conns); if (inet_pton(AF_INET, AllRouters_v4, &global.mcast_addr_v4) != 1) fatal("inet_pton"); @@ -209,7 +209,7 @@ ldpe_shutdown(void) LIST_REMOVE(if_addr, entry); free(if_addr); } - while ((adj = LIST_FIRST(&global.adj_list)) != NULL) + while ((adj = RB_ROOT(&global.adj_tree)) != NULL) adj_del(adj, S_SHUTDOWN); /* clean up */ @@ -425,8 +425,8 @@ ldpe_dispatch_main(struct thread *thread) memcpy(niface, imsg.data, sizeof(struct iface)); LIST_INIT(&niface->addr_list); - LIST_INIT(&niface->ipv4.adj_list); - LIST_INIT(&niface->ipv6.adj_list); + RB_INIT(&niface->ipv4.adj_tree); + RB_INIT(&niface->ipv6.adj_tree); niface->ipv4.iface = niface; niface->ipv6.iface = niface; @@ -814,18 +814,18 @@ ldpe_adj_ctl(struct ctl_conn *c) continue; strlcpy(ictl.name, iface->name, sizeof(ictl.name)); - if (LIST_EMPTY(&iface->ipv4.adj_list) && - LIST_EMPTY(&iface->ipv6.adj_list)) + if (RB_EMPTY(&iface->ipv4.adj_tree) && + RB_EMPTY(&iface->ipv6.adj_tree)) ictl.no_adj = 1; imsg_compose_event(&c->iev, IMSG_CTL_SHOW_DISC_IFACE, 0, 0, -1, &ictl, sizeof(ictl)); - LIST_FOREACH(adj, &iface->ipv4.adj_list, ia_entry) { + RB_FOREACH(adj, ia_adj_head, &iface->ipv4.adj_tree) { actl = adj_to_ctl(adj); imsg_compose_event(&c->iev, IMSG_CTL_SHOW_DISC_ADJ, 0, 0, -1, actl, sizeof(struct ctl_adj)); } - LIST_FOREACH(adj, &iface->ipv6.adj_list, ia_entry) { + RB_FOREACH(adj, ia_adj_head, &iface->ipv6.adj_tree) { actl = adj_to_ctl(adj); imsg_compose_event(&c->iev, IMSG_CTL_SHOW_DISC_ADJ, 0, 0, -1, actl, sizeof(struct ctl_adj)); @@ -869,7 +869,7 @@ ldpe_nbr_ctl(struct ctl_conn *c) imsg_compose_event(&c->iev, IMSG_CTL_SHOW_NBR, 0, 0, -1, nctl, sizeof(struct ctl_nbr)); - LIST_FOREACH(adj, &nbr->adj_list, nbr_entry) { + RB_FOREACH(adj, nbr_adj_head, &nbr->adj_tree) { actl = adj_to_ctl(adj); imsg_compose_event(&c->iev, IMSG_CTL_SHOW_NBR_DISC, 0, 0, -1, actl, sizeof(struct ctl_adj)); diff --git a/ldpd/ldpe.h b/ldpd/ldpe.h index 52899fd85c..81add63836 100644 --- a/ldpd/ldpe.h +++ b/ldpd/ldpe.h @@ -32,6 +32,9 @@ #define min(x,y) ((x) <= (y) ? (x) : (y)) #define max(x,y) ((x) > (y) ? (x) : (y)) +/* forward declarations */ +TAILQ_HEAD(mapping_head, mapping_entry); + struct hello_source { enum hello_type type; struct { @@ -42,9 +45,7 @@ struct hello_source { }; struct adj { - LIST_ENTRY(adj) global_entry; - LIST_ENTRY(adj) nbr_entry; - LIST_ENTRY(adj) ia_entry; + RB_ENTRY(adj) global_entry, nbr_entry, ia_entry; struct in_addr lsr_id; struct nbr *nbr; int ds_tlv; @@ -53,6 +54,9 @@ struct adj { uint16_t holdtime; union ldpd_addr trans_addr; }; +RB_PROTOTYPE(global_adj_head, adj, global_entry, adj_compare) +RB_PROTOTYPE(nbr_adj_head, adj, nbr_entry, adj_compare) +RB_PROTOTYPE(ia_adj_head, adj, ia_entry, adj_compare) struct tcp_conn { struct nbr *nbr; @@ -67,7 +71,7 @@ struct tcp_conn { struct nbr { RB_ENTRY(nbr) id_tree, addr_tree, pid_tree; struct tcp_conn *tcp; - LIST_HEAD(, adj) adj_list; /* adjacencies */ + struct nbr_adj_head adj_tree; /* adjacencies */ struct thread *ev_connect; struct thread *keepalive_timer; struct thread *keepalive_timeout; diff --git a/ldpd/neighbor.c b/ldpd/neighbor.c index 5addc4dda2..d24ceb1229 100644 --- a/ldpd/neighbor.c +++ b/ldpd/neighbor.c @@ -229,7 +229,7 @@ nbr_new(struct in_addr id, int af, int ds_tlv, union ldpd_addr *addr, if ((nbr = calloc(1, sizeof(*nbr))) == NULL) fatal(__func__); - LIST_INIT(&nbr->adj_list); + RB_INIT(&nbr->adj_tree); nbr->state = NBR_STA_PRESENT; nbr->peerid = 0; nbr->af = af; @@ -244,10 +244,10 @@ nbr_new(struct in_addr id, int af, int ds_tlv, union ldpd_addr *addr, nbr->raddr_scope = scope_id; nbr->conf_seqnum = 0; - LIST_FOREACH(adj, &global.adj_list, global_entry) { + RB_FOREACH(adj, global_adj_head, &global.adj_tree) { if (adj->lsr_id.s_addr == nbr->id.s_addr) { adj->nbr = nbr; - LIST_INSERT_HEAD(&nbr->adj_list, adj, nbr_entry); + RB_INSERT(nbr_adj_head, &nbr->adj_tree, adj); } } @@ -366,7 +366,7 @@ nbr_adj_count(struct nbr *nbr, int af) struct adj *adj; int total = 0; - LIST_FOREACH(adj, &nbr->adj_list, nbr_entry) + RB_FOREACH(adj, nbr_adj_head, &nbr->adj_tree) if (adj_get_af(adj) == af) total++; @@ -624,7 +624,7 @@ nbr_establish_connection(struct nbr *nbr) * Send an extra hello to guarantee that the remote peer has formed * an adjacency as well. */ - LIST_FOREACH(adj, &nbr->adj_list, nbr_entry) + RB_FOREACH(adj, nbr_adj_head, &nbr->adj_tree) send_hello(adj->source.type, adj->source.link.ia, adj->source.target); From 9473e340520626244678e59169547a27b1b257ad Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Tue, 3 Jan 2017 20:13:02 -0500 Subject: [PATCH 051/107] watchfrr: Rename watchquagga -> watchfrr Signed-off-by: Donald Sharp --- Makefile.am | 4 +- configure.ac | 22 +++--- cumulus/etc/quagga/daemons | 2 +- cumulus/etc/quagga/debian.conf | 4 +- debian/quagga.install | 2 +- debian/quagga.manpages | 2 +- debian/watchquagga.rc | 6 +- doc/Makefile.am | 6 +- doc/vtysh.texi | 8 +-- doc/{watchquagga.8.in => watchfrr.8.in} | 28 ++++---- lib/command.c | 2 +- lib/log.c | 2 +- lib/log.h | 2 +- lib/vty.c | 2 +- redhat/Makefile.am | 2 +- redhat/README.rpm_build.md | 12 ++-- redhat/quagga.spec.in | 72 +++++++++---------- redhat/quagga.sysconfig | 2 +- redhat/watchquagga.init | 14 ++-- solaris/prototype.daemons.in | 2 +- tools/quagga | 54 +++++++------- vtysh/Makefile.am | 2 +- vtysh/vtysh.c | 6 +- vtysh/vtysh.h | 4 +- {watchquagga => watchfrr}/.gitignore | 2 +- {watchquagga => watchfrr}/Makefile.am | 8 +-- .../watchquagga.c => watchfrr/watchfrr.c | 28 ++++---- .../watchquagga.h => watchfrr/watchfrr.h | 10 +-- .../watchfrr_vty.c | 10 +-- 29 files changed, 160 insertions(+), 160 deletions(-) rename doc/{watchquagga.8.in => watchfrr.8.in} (90%) rename {watchquagga => watchfrr}/.gitignore (89%) rename {watchquagga => watchfrr}/Makefile.am (55%) rename watchquagga/watchquagga.c => watchfrr/watchfrr.c (98%) rename watchquagga/watchquagga.h => watchfrr/watchfrr.h (82%) rename watchquagga/watchquagga_vty.c => watchfrr/watchfrr_vty.c (94%) diff --git a/Makefile.am b/Makefile.am index d8b9844ffc..d9b57a5eae 100644 --- a/Makefile.am +++ b/Makefile.am @@ -2,11 +2,11 @@ SUBDIRS = lib qpb fpm @ZEBRA@ @LIBRFP@ @RFPTEST@ \ @BGPD@ @RIPD@ @RIPNGD@ @OSPFD@ @OSPF6D@ @LDPD@ \ - @ISISD@ @PIMD@ @WATCHQUAGGA@ @VTYSH@ @OSPFCLIENT@ @DOC@ m4 @pkgsrcdir@ \ + @ISISD@ @PIMD@ @WATCHFRR@ @VTYSH@ @OSPFCLIENT@ @DOC@ m4 @pkgsrcdir@ \ redhat @SOLARIS@ tests tools cumulus DIST_SUBDIRS = lib qpb fpm zebra bgpd ripd ripngd ospfd ospf6d ldpd \ - isisd watchquagga vtysh ospfclient doc m4 pkgsrc redhat tests \ + isisd watchfrr vtysh ospfclient doc m4 pkgsrc redhat tests \ solaris pimd @LIBRFP@ @RFPTEST@ tools cumulus EXTRA_DIST = aclocal.m4 SERVICES REPORTING-BUGS \ diff --git a/configure.ac b/configure.ac index d0d5fbb19b..7b27cbd8db 100755 --- a/configure.ac +++ b/configure.ac @@ -213,8 +213,8 @@ AC_ARG_ENABLE(ospf6d, AS_HELP_STRING([--disable-ospf6d], [do not build ospf6d])) AC_ARG_ENABLE(ldpd, AS_HELP_STRING([--enable-ldpd], [build ldpd])) -AC_ARG_ENABLE(watchquagga, - AS_HELP_STRING([--disable-watchquagga], [do not build watchquagga])) +AC_ARG_ENABLE(watchfrr, + AS_HELP_STRING([--disable-watchfrr], [do not build watchfrr])) AC_ARG_ENABLE(isisd, AS_HELP_STRING([--disable-isisd], [do not build isisd])) AC_ARG_ENABLE(pimd, @@ -1170,12 +1170,12 @@ else fi AM_CONDITIONAL(LDPD, test "x$LDPD" = "xldpd") -if test "${enable_watchquagga}" = "no";then - WATCHQUAGGA="" +if test "${enable_watchfrr}" = "no";then + WATCHFRR="" else - WATCHQUAGGA="watchquagga" + WATCHFRR="watchfrr" fi -AM_CONDITIONAL(WATCHQUAGGA, test "x$WATCHQUAGGA" = "xwatchquagga") +AM_CONDITIONAL(WATCHFRR, test "x$WATCHFRR" = "xwatchfrr") OSPFCLIENT="" if test "${enable_ospfapi}" != "no";then @@ -1250,7 +1250,7 @@ AC_SUBST(RIPNGD) AC_SUBST(OSPFD) AC_SUBST(OSPF6D) AC_SUBST(LDPD) -AC_SUBST(WATCHQUAGGA) +AC_SUBST(WATCHFRR) AC_SUBST(ISISD) AC_SUBST(PIMD) AC_SUBST(SOLARIS) @@ -1548,7 +1548,7 @@ AC_DEFINE_UNQUOTED(PATH_LDPD_PID, "$frr_statedir/ldpd.pid",ldpd PID) AC_DEFINE_UNQUOTED(LDPD_SOCKET, "$frr_statedir/ldpd.sock",ldpd control socket) AC_DEFINE_UNQUOTED(PATH_ISISD_PID, "$frr_statedir/isisd.pid",isisd PID) AC_DEFINE_UNQUOTED(PATH_PIMD_PID, "$frr_statedir/pimd.pid",pimd PID) -AC_DEFINE_UNQUOTED(PATH_WATCHQUAGGA_PID, "$frr_statedir/watchquagga.pid",watchquagga PID) +AC_DEFINE_UNQUOTED(PATH_WATCHFRR_PID, "$frr_statedir/watchfrr.pid",watchfrr PID) AC_DEFINE_UNQUOTED(ZEBRA_SERV_PATH, "$frr_statedir/zserv.api",zebra api socket) AC_DEFINE_UNQUOTED(ZEBRA_VTYSH_PATH, "$frr_statedir/zebra.vty",zebra vty socket) AC_DEFINE_UNQUOTED(RIP_VTYSH_PATH, "$frr_statedir/ripd.vty",rip vty socket) @@ -1559,7 +1559,7 @@ AC_DEFINE_UNQUOTED(OSPF6_VTYSH_PATH, "$frr_statedir/ospf6d.vty",ospf6d vty socke AC_DEFINE_UNQUOTED(LDP_VTYSH_PATH, "$frr_statedir/ldpd.vty",ldpd vty socket) AC_DEFINE_UNQUOTED(ISIS_VTYSH_PATH, "$frr_statedir/isisd.vty",isisd vty socket) AC_DEFINE_UNQUOTED(PIM_VTYSH_PATH, "$frr_statedir/pimd.vty",pimd vty socket) -AC_DEFINE_UNQUOTED(WATCHQUAGGA_VTYSH_PATH, "$frr_statedir/watchquagga.vty",watchquagga vty socket) +AC_DEFINE_UNQUOTED(WATCHFRR_VTYSH_PATH, "$frr_statedir/watchfrr.vty",watchfrr vty socket) AC_DEFINE_UNQUOTED(DAEMON_VTY_DIR, "$frr_statedir",daemon vty directory) dnl autoconf does this, but it does it too late... @@ -1605,7 +1605,7 @@ AC_CACHE_VAL(ac_cv_htonl_works, AC_MSG_RESULT($ac_cv_htonl_works) AC_CONFIG_FILES([Makefile lib/Makefile qpb/Makefile zebra/Makefile ripd/Makefile - ripngd/Makefile bgpd/Makefile ospfd/Makefile watchquagga/Makefile + ripngd/Makefile bgpd/Makefile ospfd/Makefile watchfrr/Makefile ospf6d/Makefile ldpd/Makefile isisd/Makefile vtysh/Makefile doc/Makefile ospfclient/Makefile tests/Makefile m4/Makefile pimd/Makefile @@ -1629,7 +1629,7 @@ AC_CONFIG_FILES([Makefile lib/Makefile qpb/Makefile zebra/Makefile ripd/Makefile doc/ripngd.8 doc/pimd.8 doc/vtysh.1 - doc/watchquagga.8 + doc/watchfrr.8 doc/zebra.8 doc/quagga.1 pkgsrc/bgpd.sh pkgsrc/ospf6d.sh pkgsrc/ospfd.sh diff --git a/cumulus/etc/quagga/daemons b/cumulus/etc/quagga/daemons index dd0e23914b..c7b8496a4e 100644 --- a/cumulus/etc/quagga/daemons +++ b/cumulus/etc/quagga/daemons @@ -18,7 +18,7 @@ # When using "vtysh" such a config file is also needed. It should be owned by # group "quaggavty" and set to ug=rw,o= though. Check /etc/pam.d/quagga, too. # -# The watchquagga daemon is always started. Per default in monitoring-only but +# The watchfrr daemon is always started. Per default in monitoring-only but # that can be changed via /etc/quagga/debian.conf. # zebra=no diff --git a/cumulus/etc/quagga/debian.conf b/cumulus/etc/quagga/debian.conf index 88df9424e2..bd1fcecf9f 100644 --- a/cumulus/etc/quagga/debian.conf +++ b/cumulus/etc/quagga/debian.conf @@ -14,5 +14,5 @@ isisd_options=" --daemon -A 127.0.0.1" pimd_options=" --daemon -A 127.0.0.1" # The list of daemons to watch is automatically generated by the init script. -watchquagga_enable=yes -watchquagga_options=(-adz -r /usr/sbin/servicebBquaggabBrestartbB%s -s /usr/sbin/servicebBquaggabBstartbB%s -k /usr/sbin/servicebBquaggabBstopbB%s -b bB -t 30) +watchfrr_enable=yes +watchfrr_options=(-adz -r /usr/sbin/servicebBquaggabBrestartbB%s -s /usr/sbin/servicebBquaggabBstartbB%s -k /usr/sbin/servicebBquaggabBstopbB%s -b bB -t 30) diff --git a/debian/quagga.install b/debian/quagga.install index 6a70be9925..022bd94ec7 100644 --- a/debian/quagga.install +++ b/debian/quagga.install @@ -15,7 +15,7 @@ usr/share/man/man8/ripd.8 usr/share/man/man8/ripngd.8 usr/share/man/man8/zebra.8 usr/share/man/man8/isisd.8 -usr/share/man/man8/watchquagga.8 +usr/share/man/man8/watchfrr.8 usr/share/snmp/mibs/ cumulus/etc/* etc/ tools/*.service lib/systemd/system diff --git a/debian/quagga.manpages b/debian/quagga.manpages index 194b13af66..17a128b7e3 100644 --- a/debian/quagga.manpages +++ b/debian/quagga.manpages @@ -6,4 +6,4 @@ doc/ripngd.8 doc/vtysh.1 doc/zebra.8 doc/isisd.8 -doc/watchquagga.8 +doc/watchfrr.8 diff --git a/debian/watchquagga.rc b/debian/watchquagga.rc index e3b6340dce..81a00393d2 100644 --- a/debian/watchquagga.rc +++ b/debian/watchquagga.rc @@ -1,4 +1,4 @@ -check process watchquagga with pidfile /var/run/quagga/watchquagga.pid - start program = "/etc/init.d/quagga start watchquagga" with timeout 120 seconds - stop program = "/etc/init.d/quagga stop watchquagga" +check process watchfrr with pidfile /var/run/quagga/watchfrr.pid + start program = "/etc/init.d/quagga start watchfrr" with timeout 120 seconds + stop program = "/etc/init.d/quagga stop watchfrr" if 3 restarts within 10 cycles then timeout diff --git a/doc/Makefile.am b/doc/Makefile.am index ab2657bba4..a9c0cc221d 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -115,8 +115,8 @@ if VTYSH man_MANS += vtysh.1 endif -if WATCHQUAGGA -man_MANS += watchquagga.8 +if WATCHFRR +man_MANS += watchfrr.8 endif if ZEBRA @@ -135,7 +135,7 @@ EXTRA_DIST = BGP-TypeCode draft-zebra-00.ms draft-zebra-00.txt \ ripngd.8.in \ pimd.8.in \ vtysh.1.in \ - watchquagga.8.in \ + watchfrr.8.in \ zebra.8.in \ quagga.1.in \ \ diff --git a/doc/vtysh.texi b/doc/vtysh.texi index 69b7acd3b7..920b39d7f5 100644 --- a/doc/vtysh.texi +++ b/doc/vtysh.texi @@ -87,12 +87,12 @@ lost after doing a configuration save. @end quotation Since the @command{vtysh} command may be running as ordinary user on the -system, configuration writes will be tried through @command{watchquagga}, +system, configuration writes will be tried through @command{watchfrr}, using the @command{write integrated} command internally. Since -@command{watchquagga} is running as superuser, @command{vtysh} is able to +@command{watchfrr} is running as superuser, @command{vtysh} is able to ensure correct ownership and permissions on @file{Quagga.conf}. -If @command{watchquagga} is not running or the configuration write fails, +If @command{watchfrr} is not running or the configuration write fails, @command{vtysh} will attempt to directly write to the file. This is likely to fail if running as unprivileged user; alternatively it may leave the file with incorrect owner or permissions. @@ -147,7 +147,7 @@ installations. Unconditionally (regardless of @command{service integrated-vtysh-config} setting) write out integrated @file{Quagga.conf} file through -@command{watchquagga}. If @command{watchquagga} is not running, this command +@command{watchfrr}. If @command{watchfrr} is not running, this command is unavailable. @end deffn diff --git a/doc/watchquagga.8.in b/doc/watchfrr.8.in similarity index 90% rename from doc/watchquagga.8.in rename to doc/watchfrr.8.in index a7249b8376..813f87abd3 100644 --- a/doc/watchquagga.8.in +++ b/doc/watchfrr.8.in @@ -1,37 +1,37 @@ .\" This file was originally generated by help2man 1.36. -.TH WATCHQUAGGA 8 "July 2010" +.TH WATCHFRR 8 "July 2010" .SH NAME -watchquagga \- a program to monitor the status of quagga daemons +watchfrr \- a program to monitor the status of frr daemons .SH SYNOPSIS -.B watchquagga +.B watchfrr .RI [ option ...] .IR daemon ... .br -.B watchquagga +.B watchfrr .BR \-h " | " \-v .SH DESCRIPTION -.B watchquagga -is a watchdog program that monitors the status of supplied quagga +.B watchfrr +is a watchdog program that monitors the status of supplied frr .IR daemon s and tries to restart them in case they become unresponsive or shut down. .PP To determine whether a daemon is running, it tries to connect to the daemon's VTY UNIX stream socket, and send echo commands to ensure the daemon responds. When the daemon crashes, EOF is received from the socket, -so that watchquagga can react immediately. +so that watchfrr can react immediately. .PP This program can run in one of the following 5 modes: .TP .B Mode 0: monitor In this mode, the program serves as a monitor and reports status changes. .IP -Example usage: watchquagga \-d zebra ospfd bgpd +Example usage: watchfrr \-d zebra ospfd bgpd .TP .B Mode 1: global restart In this mode, whenever a daemon hangs or crashes, the given command is used to restart all watched daemons. .IP -Example usage: watchquagga \-dz \e +Example usage: watchfrr \-dz \e .br -R '/sbin/service zebra restart; /sbin/service ospfd restart' \e .br @@ -41,7 +41,7 @@ zebra ospfd In this mode, whenever a single daemon hangs or crashes, the given command is used to restart this daemon only. .IP -Example usage: watchquagga \-dz \-r '/sbin/service %s restart' \e +Example usage: watchfrr \-dz \-r '/sbin/service %s restart' \e .br zebra ospfd bgpd .TP @@ -52,7 +52,7 @@ daemon; in this case, the following steps are taken: (1) all other daemons are stopped, (2) zebra is restarted, and (3) other daemons are started again. .IP -Example usage: watchquagga \-adz \-r '/sbin/service %s restart' \e +Example usage: watchfrr \-adz \-r '/sbin/service %s restart' \e .br \-s '/sbin/service %s start' \e .br @@ -63,7 +63,7 @@ In this mode, whenever a single daemon hangs or crashes, the following steps are taken: (1) all other daemons are stopped, (2) zebra is restarted, and (3) other daemons are started again. .IP -Example usage: watchquagga \-Adz \-r '/sbin/service %s restart' \e +Example usage: watchfrr \-Adz \-r '/sbin/service %s restart' \e .br \-s '/sbin/service %s start' \e .br @@ -95,7 +95,7 @@ instead of standard output (stdout). .BI \-S " directory" "\fR, \fB\-\-statedir " directory Set the VTY socket .I directory -(the default value is "/var/run/quagga"). +(the default value is "/var/run/frr"). .TP .BR \-e ", " \-\-no\-echo Do not ping the daemons to test whether they respond. This option is @@ -196,7 +196,7 @@ options to be specified. .BI \-p " filename" "\fR, \fB\-\-pid\-file " filename Set the process identifier .I filename -(the default value is "/var/run/quagga/watchquagga.pid"). +(the default value is "/var/run/frr/watchfrr.pid"). .TP .BI \-b " string" "\fR, \fB\-\-blank\-string " string When the supplied diff --git a/lib/command.c b/lib/command.c index bc816dedea..1dcb232c32 100644 --- a/lib/command.c +++ b/lib/command.c @@ -4220,7 +4220,7 @@ install_default (enum node_type node) * * terminal = 0 -- vtysh / no logging, no config control * terminal = 1 -- normal daemon - * terminal = -1 -- watchquagga / no logging, but minimal config control */ + * terminal = -1 -- watchfrr / no logging, but minimal config control */ void cmd_init (int terminal) { diff --git a/lib/log.c b/lib/log.c index b3a124fd6f..6a3ce07799 100644 --- a/lib/log.c +++ b/lib/log.c @@ -59,7 +59,7 @@ const char *zlog_proto_names[] = "ISIS", "PIM", "RFP", - "WATCHQUAGGA", + "WATCHFRR", NULL, }; diff --git a/lib/log.h b/lib/log.h index feb1e1852d..cb6379cb2a 100644 --- a/lib/log.h +++ b/lib/log.h @@ -59,7 +59,7 @@ typedef enum ZLOG_ISIS, ZLOG_PIM, ZLOG_RFP, - ZLOG_WATCHQUAGGA, + ZLOG_WATCHFRR, } zlog_proto_t; /* If maxlvl is set to ZLOG_DISABLED, then no messages will be sent diff --git a/lib/vty.c b/lib/vty.c index b25a4eeffd..5919e5220a 100644 --- a/lib/vty.c +++ b/lib/vty.c @@ -2240,7 +2240,7 @@ vtysh_read (struct thread *thread) if (ret == CMD_SUSPEND) break; - /* warning: watchquagga hardcodes this result write */ + /* warning: watchfrr hardcodes this result write */ header[3] = ret; buffer_put(vty->obuf, header, 4); diff --git a/redhat/Makefile.am b/redhat/Makefile.am index 96870689dc..c70e71fef6 100644 --- a/redhat/Makefile.am +++ b/redhat/Makefile.am @@ -3,6 +3,6 @@ EXTRA_DIST = bgpd.init isisd.init \ ospf6d.init ospfd.init ldpd.init \ quagga.logrotate quagga.pam quagga.spec \ quagga.sysconfig ripd.init ripngd.init \ - watchquagga.init pimd.init zebra.init \ + watchfrr.init pimd.init zebra.init \ README.rpm_build.md diff --git a/redhat/README.rpm_build.md b/redhat/README.rpm_build.md index 05a0bdc591..c164d740b9 100644 --- a/redhat/README.rpm_build.md +++ b/redhat/README.rpm_build.md @@ -59,7 +59,7 @@ Building your own Quagga RPM %{!?quagga_user: %global quagga_user quagga } %{!?vty_group: %global vty_group quaggavt } %{!?with_fpm: %global with_fpm 0 } - %{!?with_watchquagga: %global with_watchquagga 1 } + %{!?with_watchfrr: %global with_watchfrr 1 } 6. Build the RPM @@ -84,11 +84,11 @@ Enabling daemons after installation of the package: chkconfig bgpd on ... etc -2. If you want to run `watchquagga`, then configure `/etc/sysconfig/quagga` - and uncomment the line with the daemons for `watchquagga` to monitor, - then enable watchquagga +2. If you want to run `watchfrr`, then configure `/etc/sysconfig/quagga` + and uncomment the line with the daemons for `watchfrr` to monitor, + then enable watchfrr - chkconfig watchquagga on + chkconfig watchfrr on 3. Check your firewall / IPtables to make sure the routing protocols are allowed. @@ -113,7 +113,7 @@ Configuration is stored in `/etc/quagga/*.conf` files. systemctl enable bgpd ... etc - Note: There is no watchquagga on systemd based systems. Systemd contains + Note: There is no watchfrr on systemd based systems. Systemd contains the functionality of monitoring and restarting daemons. 2. Check your firewall / IPtables to make sure the routing protocols are diff --git a/redhat/quagga.spec.in b/redhat/quagga.spec.in index 207889d923..752b70fca5 100644 --- a/redhat/quagga.spec.in +++ b/redhat/quagga.spec.in @@ -23,7 +23,7 @@ %{!?quagga_user: %global quagga_user quagga } %{!?vty_group: %global vty_group quaggavty } %{!?with_fpm: %global with_fpm 0 } -%{!?with_watchquagga: %global with_watchquagga 1 } +%{!?with_watchfrr: %global with_watchfrr 1 } %{!?with_bgp_vnc: %global with_bgp_vnc 0 } # path defines @@ -52,13 +52,13 @@ # Check for init.d (upstart) as used in CentOS 6 or systemd (ie CentOS 7) %{expand: %%global initsystem %(if [[ `/sbin/init --version 2> /dev/null` =~ upstart ]]; then echo upstart; elif [[ `systemctl` =~ -\.mount ]]; then echo systemd; fi)} # -# If init system is systemd, then always disable watchquagga +# If init system is systemd, then always disable watchfrr # %if "%{initsystem}" == "systemd" - # Note: For systems with systemd, watchquagga will NOT be built. Systemd + # Note: For systems with systemd, watchfrr will NOT be built. Systemd # takes over the role of restarting crashed processes. Value will # be overwritten with 0 below for systemd independent on the setting here - %global with_watchquagga 1 + %global with_watchfrr 1 %endif # if FPM is enabled, then enable tcp_zebra as well @@ -80,13 +80,13 @@ %define daemon_ldpd "" %endif -%if %{with_watchquagga} -%define daemon_watchquagga watchquagga +%if %{with_watchfrr} +%define daemon_watchfrr watchfrr %else -%define daemon_watchquagga "" +%define daemon_watchfrr "" %endif -%define all_daemons %{daemon_list} %{daemon_ldpd} %{daemon_watchquagga} +%define all_daemons %{daemon_list} %{daemon_ldpd} %{daemon_watchfrr} # allow build dir to be kept %{!?keep_build: %global keep_build 0 } @@ -232,10 +232,10 @@ developing OSPF-API and quagga applications. %else --disable-fpm \ %endif -%if %{with_watchquagga} - --enable-watchquagga \ +%if %{with_watchfrr} + --enable-watchfrr \ %else - --disable-watchquagga \ + --disable-watchfrr \ %endif %if %{with_bgp_vnc} --enable-bgp-vnc \ @@ -371,9 +371,9 @@ for daemon in %{all_daemons} ; do %endif fi done -%if %{with_watchquagga} - # No config for watchquagga - this is part of /etc/sysconfig/quagga - rm -f %{_sysconfdir}/watchquagga.* +%if %{with_watchfrr} + # No config for watchfrr - this is part of /etc/sysconfig/quagga + rm -f %{_sysconfdir}/watchfrr.* %endif if [ ! -e %{_sysconfdir}/vtysh.conf ]; then @@ -397,16 +397,16 @@ if [ "$1" -ge 1 ]; then # Rename restart flags for daemons handled specially. running_zebra="$restart_zebra" restart_zebra=no - %if %{with_watchquagga} - running_watchquagga="$restart_watchquagga" - restart_watchquagga=no + %if %{with_watchfrr} + running_watchfrr="$restart_watchfrr" + restart_watchfrr=no %endif %if "%{initsystem}" == "systemd" ## ## Systemd Version ## - # No watchquagga for systemd version + # No watchfrr for systemd version # # Stop all daemons other than zebra. for daemon in %all_daemons ; do @@ -427,12 +427,12 @@ if [ "$1" -ge 1 ]; then ## ## init.d Version ## - %if %{with_watchquagga} - # Stop watchquagga first. - [ "$running_watchquagga" = yes ] && \ - /etc/rc.d/init.d/watchquagga stop >/dev/null 2>&1 + %if %{with_watchfrr} + # Stop watchfrr first. + [ "$running_watchfrr" = yes ] && \ + /etc/rc.d/init.d/watchfrr stop >/dev/null 2>&1 %endif - # Stop all daemons other than zebra and watchquagga. + # Stop all daemons other than zebra and watchfrr. for daemon in %all_daemons ; do eval restart=\$restart_${daemon} [ "$restart" = yes ] && \ @@ -441,18 +441,18 @@ if [ "$1" -ge 1 ]; then # Restart zebra. [ "$running_zebra" = yes ] && \ /etc/rc.d/init.d/zebra restart >/dev/null 2>&1 - # Start all daemons other than zebra and watchquagga. + # Start all daemons other than zebra and watchfrr. for daemon in %all_daemons ; do eval restart=\$restart_${daemon} [ "$restart" = yes ] && \ /etc/rc.d/init.d/${daemon} start >/dev/null 2>&1 done - %if %{with_watchquagga} - # Start watchquagga last. - # Avoid postun scriptlet error if watchquagga is not running. - [ "$running_watchquagga" = yes ] && \ - /etc/rc.d/init.d/watchquagga start >/dev/null 2>&1 || : - %endif + %if %{with_watchfrr} + # Start watchfrr last. + # Avoid postun scriptlet error if watchfrr is not running. + [ "$running_watchfrr" = yes ] && \ + /etc/rc.d/init.d/watchfrr start >/dev/null 2>&1 || : + %endif %endif fi @@ -513,8 +513,8 @@ rm -rf %{buildroot} %{_sbindir}/quagga-reload.py %{_sbindir}/quagga-reload.pyc %{_sbindir}/quagga-reload.pyo -%if %{with_watchquagga} - %{_sbindir}/watchquagga +%if %{with_watchfrr} + %{_sbindir}/watchfrr %endif %{_sbindir}/ripngd %{_sbindir}/ospf6d @@ -533,8 +533,8 @@ rm -rf %{buildroot} %config %{_unitdir}/quagga.service %else %config /etc/rc.d/init.d/zebra - %if %{with_watchquagga} - %config /etc/rc.d/init.d/watchquagga + %if %{with_watchfrr} + %config /etc/rc.d/init.d/watchfrr %endif %config /etc/rc.d/init.d/ripd %config /etc/rc.d/init.d/ospfd @@ -586,7 +586,7 @@ rm -rf %{buildroot} - Add conditional logic to only build tex footnotes with supported texi2html - Added pimd to files section and fix double listing of /var/lib*/quagga - Numerous fixes to unify upstart/systemd startup into same spec file -- Only allow use of watchquagga for non-systemd systems. no need with systemd +- Only allow use of watchfrr for non-systemd systems. no need with systemd * Fri Sep 4 2015 Paul Jakma - buildreq updates @@ -607,7 +607,7 @@ rm -rf %{buildroot} - daemonv6_list should contain only IPv6 daemons * Wed Dec 22 2004 Andrew J. Schorr -- watchquagga added +- watchfrr added - on upgrade, all daemons should be condrestart'ed - on removal, all daemons should be stopped diff --git a/redhat/quagga.sysconfig b/redhat/quagga.sysconfig index 0cc6acfbae..97c28c807d 100644 --- a/redhat/quagga.sysconfig +++ b/redhat/quagga.sysconfig @@ -11,7 +11,7 @@ ZEBRA_OPTS="-A 127.0.0.1" PIMD_OPTS="-A 127.0.0.1" LDPD_OPTS="-A 127.0.0.1" -# Watchquagga configuration for LSB initscripts +# Watchfrr configuration for LSB initscripts # # (Not needed with systemd: the service files are configured to automatically # restart any daemon on failure. If zebra fails, all running daemons will be diff --git a/redhat/watchquagga.init b/redhat/watchquagga.init index dda3506621..51259edc05 100644 --- a/redhat/watchquagga.init +++ b/redhat/watchquagga.init @@ -2,9 +2,9 @@ # chkconfig: 2345 17 83 ### BEGIN INIT INFO -# Provides: watchquagga -# Short-Description: Quagga watchdog -# Description: Quagga watchdog for use with Zebra +# Provides: watchfrr +# Short-Description: Frr watchdog +# Description: Frr watchdog for use with Zebra ### END INIT INFO # source function library @@ -13,13 +13,13 @@ # Get network config . /etc/sysconfig/network -# quagga command line options +# frr command line options . /etc/sysconfig/quagga RETVAL=0 -PROG="watchquagga" -cmd=watchquagga -LOCK_FILE=/var/lock/subsys/watchquagga +PROG="watchfrr" +cmd=watchfrr +LOCK_FILE=/var/lock/subsys/watchfrr case "$1" in start) diff --git a/solaris/prototype.daemons.in b/solaris/prototype.daemons.in index ce65d5e350..8a906c9d0a 100644 --- a/solaris/prototype.daemons.in +++ b/solaris/prototype.daemons.in @@ -8,7 +8,7 @@ f none @sbindir@/ripd=$DESTDIR/@sbindir@/ripd 0755 root bin f none @sbindir@/ripngd=$DESTDIR/@sbindir@/ripngd 0755 root bin f none @sbindir@/ospfd=$DESTDIR/@sbindir@/ospfd 0755 root bin f none @sbindir@/ospf6d=$DESTDIR/@sbindir@/ospf6d 0755 root bin -f none @sbindir@/watchquagga=$DESTDIR/@sbindir@/watchquagga 0755 root bin +f none @sbindir@/watchfrr=$DESTDIR/@sbindir@/watchfrr 0755 root bin d none @sysconfdir@=$DESTDIR/@sysconfdir@ 0711 @enable_user@ @enable_group@ f none @sysconfdir@/zebra.conf.sample=$DESTDIR/@sysconfdir@/zebra.conf.sample 0644 root bin f none @sysconfdir@/bgpd.conf.sample=$DESTDIR/@sysconfdir@/bgpd.conf.sample 0644 root bin diff --git a/tools/quagga b/tools/quagga index e8595d7877..87f1ce5c5e 100755 --- a/tools/quagga +++ b/tools/quagga @@ -20,7 +20,7 @@ V_PATH=/var/run/quagga # Local Daemon selection may be done by using /etc/quagga/daemons. # See /usr/share/doc/quagga/README.Debian.gz for further information. -# Keep zebra first and do not list watchquagga! +# Keep zebra first and do not list watchfrr! DAEMONS="zebra bgpd ripd ripngd ospfd ospf6d isisd babeld pimd" MAX_INSTANCES=5 RELOAD_SCRIPT=/usr/lib/quagga/quagga-reload.py @@ -79,7 +79,7 @@ check_daemon() # vtysh_enable has no config file nor binary so skip check. # (Not sure why vtysh_enable is in this list but does not hurt) - if [ $1 != "watchquagga" -a $1 != "vtysh_enable" ]; then + if [ $1 != "watchfrr" -a $1 != "vtysh_enable" ]; then # check for daemon binary if [ ! -x "$D_PATH/$1" ]; then return 1; fi @@ -102,29 +102,29 @@ check_daemon() start() { ulimit -n $MAX_FDS - if [ "$1" = "watchquagga" ]; then + if [ "$1" = "watchfrr" ]; then - # We may need to restart watchquagga if new daemons are added and/or + # We may need to restart watchfrr if new daemons are added and/or # removed if started "$1" ; then - stop watchquagga + stop watchfrr else - # Echo only once. watchquagga is printed in the stop above + # Echo only once. watchfrr is printed in the stop above echo -n " $1" fi - if [ -e /var/run/quagga/watchquagga.started ] ; then - rm /var/run/quagga/watchquagga.started + if [ -e /var/run/quagga/watchfrr.started ] ; then + rm /var/run/quagga/watchfrr.started fi ${SSD} \ --start \ --pidfile=`pidfile $1` \ --exec "$D_PATH/$1" \ -- \ - "${watchquagga_options[@]}" + "${watchfrr_options[@]}" for i in `seq 1 10`; do - if [ -e /var/run/quagga/watchquagga.started ] ; then + if [ -e /var/run/quagga/watchfrr.started ] ; then break else sleep 1 @@ -203,7 +203,7 @@ stop() # Converts values from /etc/quagga/daemons to all-numeric values. convert_daemon_prios() { - for name in $DAEMONS zebra vtysh_enable watchquagga_enable; do + for name in $DAEMONS zebra vtysh_enable watchfrr_enable; do # First, assign the value set by the user to $value eval value=\${${name}:0:3} @@ -224,8 +224,8 @@ convert_daemon_prios() done } -# Starts watchquagga for all wanted daemons. -start_watchquagga() +# Starts watchfrr for all wanted daemons. +start_watchfrr() { local daemon_name local daemon_prio @@ -233,14 +233,14 @@ start_watchquagga() local daemon_inst # Start the monitor daemon only if desired. - if [ 0 -eq "$watchquagga_enable" ]; then + if [ 0 -eq "$watchfrr_enable" ]; then return fi # Check variable type - if ! declare -p watchquagga_options | grep -q '^declare \-a'; then + if ! declare -p watchfrr_options | grep -q '^declare \-a'; then echo - echo "ERROR: The variable watchquagga_options from /etc/quagga/debian.cnf must be a BASH array!" + echo "ERROR: The variable watchfrr_options from /etc/quagga/debian.cnf must be a BASH array!" echo "ERROR: Please convert config file and restart!" exit 1 fi @@ -256,13 +256,13 @@ start_watchquagga() eval "inst_disable=\${${daemon_name}_${inst}}" if [ -z ${inst_disable} ] || [ ${inst_disable} != 0 ]; then if check_daemon $daemon_name $inst; then - watchquagga_options+=("${daemon_name}-${inst}") + watchfrr_options+=("${daemon_name}-${inst}") fi fi done else if check_daemon $daemon_name; then - watchquagga_options+=($daemon_name) + watchfrr_options+=($daemon_name) fi fi found_one=1 @@ -272,16 +272,16 @@ start_watchquagga() # Start if at least one daemon is activated. if [ $found_one -eq 1 ]; then echo -n "Starting Quagga monitor daemon:" - start watchquagga + start watchfrr echo "." fi } -# Stopps watchquagga. -stop_watchquagga() +# Stopps watchfrr. +stop_watchfrr() { echo -n "Stopping Quagga monitor daemon:" - stop watchquagga + stop watchfrr echo "." } @@ -509,10 +509,10 @@ case "$1" in # Start all daemons cd $C_PATH/ - if [ "$2" != "watchquagga" ]; then + if [ "$2" != "watchfrr" ]; then start_prio 10 $dmn fi - start_watchquagga + start_watchfrr vtysh_b ;; @@ -525,8 +525,8 @@ case "$1" in stop|0) # Stop all daemons at level '0' or 'stop' - stop_watchquagga - if [ "$dmn" != "watchquagga" ]; then + stop_watchfrr + if [ "$dmn" != "watchfrr" ]; then [ -n "${dmn}" ] && eval "${dmn/-/_}=0" stop_prio 0 $dmn fi @@ -536,7 +536,7 @@ case "$1" in ip route flush proto zebra else [ -n "$dmn" ] && eval "${dmn/-/_}=0" - start_watchquagga + start_watchfrr fi ;; diff --git a/vtysh/Makefile.am b/vtysh/Makefile.am index 0ff2d738f0..090382b99b 100644 --- a/vtysh/Makefile.am +++ b/vtysh/Makefile.am @@ -86,7 +86,7 @@ vtysh_cmd_FILES = $(vtysh_scan) \ $(top_srcdir)/zebra/zebra_fpm.c \ $(top_srcdir)/zebra/zebra_ptm.c \ $(top_srcdir)/zebra/zebra_mpls_vty.c \ - $(top_srcdir)/watchquagga/watchquagga_vty.c \ + $(top_srcdir)/watchfrr/watchfrr_vty.c \ $(BGP_VNC_RFAPI_SRC) $(BGP_VNC_RFP_SRC) vtysh_cmd.c: $(vtysh_cmd_FILES) extract.pl diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index a4f108e447..6d6fe61306 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -73,7 +73,7 @@ struct vtysh_client vtysh_client[] = { .fd = -1, .name = "bgpd", .flag = VTYSH_BGPD, .path = BGP_VTYSH_PATH, .next = NULL}, { .fd = -1, .name = "isisd", .flag = VTYSH_ISISD, .path = ISIS_VTYSH_PATH, .next = NULL}, { .fd = -1, .name = "pimd", .flag = VTYSH_PIMD, .path = PIM_VTYSH_PATH, .next = NULL}, - { .fd = -1, .name = "watchquagga", .flag = VTYSH_WATCHQUAGGA, .path = WATCHQUAGGA_VTYSH_PATH, .next = NULL}, + { .fd = -1, .name = "watchfrr", .flag = VTYSH_WATCHFRR, .path = WATCHFRR_VTYSH_PATH, .next = NULL}, }; enum vtysh_write_integrated vtysh_write_integrated = WRITE_INTEGRATED_UNSPECIFIED; @@ -2592,7 +2592,7 @@ DEFUN (vtysh_write_memory, { ret = CMD_WARNING; for (i = 0; i < array_size(vtysh_client); i++) - if (vtysh_client[i].flag == VTYSH_WATCHQUAGGA) + if (vtysh_client[i].flag == VTYSH_WATCHFRR) break; if (i < array_size(vtysh_client) && vtysh_client[i].fd != -1) ret = vtysh_client_execute (&vtysh_client[i], "write integrated", stdout); @@ -2600,7 +2600,7 @@ DEFUN (vtysh_write_memory, if (ret != CMD_SUCCESS) { printf("\nWarning: attempting direct configuration write without " - "watchquagga.\nFile permissions and ownership may be " + "watchfrr.\nFile permissions and ownership may be " "incorrect, or write may fail.\n\n"); ret = vtysh_write_config_integrated(); } diff --git a/vtysh/vtysh.h b/vtysh/vtysh.h index dade049ad7..46ed001919 100644 --- a/vtysh/vtysh.h +++ b/vtysh/vtysh.h @@ -34,11 +34,11 @@ DECLARE_MGROUP(MVTYSH) #define VTYSH_ISISD 0x40 #define VTYSH_PIMD 0x100 #define VTYSH_LDPD 0x200 -#define VTYSH_WATCHQUAGGA 0x400 +#define VTYSH_WATCHFRR 0x400 /* commands in REALLYALL are crucial to correct vtysh operation */ #define VTYSH_REALLYALL ~0U -/* watchquagga is not in ALL since library CLI functions should not be +/* watchfrr is not in ALL since library CLI functions should not be * run on it (logging & co. should stay in a fixed/frozen config, and * things like prefix lists are not even initialised) */ #define VTYSH_ALL VTYSH_ZEBRA|VTYSH_RIPD|VTYSH_RIPNGD|VTYSH_OSPFD|VTYSH_OSPF6D|VTYSH_LDPD|VTYSH_BGPD|VTYSH_ISISD|VTYSH_PIMD diff --git a/watchquagga/.gitignore b/watchfrr/.gitignore similarity index 89% rename from watchquagga/.gitignore rename to watchfrr/.gitignore index b6226d53d3..d3b038feb5 100644 --- a/watchquagga/.gitignore +++ b/watchfrr/.gitignore @@ -1,7 +1,7 @@ Makefile Makefile.in *.o -watchquagga +watchfrr tags TAGS .deps diff --git a/watchquagga/Makefile.am b/watchfrr/Makefile.am similarity index 55% rename from watchquagga/Makefile.am rename to watchfrr/Makefile.am index 43f743eba2..51851b0165 100644 --- a/watchquagga/Makefile.am +++ b/watchfrr/Makefile.am @@ -5,9 +5,9 @@ DEFS = @DEFS@ -DSTATEDIR=\"$(localstatedir)/\" AM_CFLAGS = $(WERROR) -sbin_PROGRAMS = watchquagga +sbin_PROGRAMS = watchfrr -noinst_HEADERS = watchquagga.h +noinst_HEADERS = watchfrr.h -watchquagga_SOURCES = watchquagga.c watchquagga_vty.c -watchquagga_LDADD = ../lib/libzebra.la @LIBCAP@ +watchfrr_SOURCES = watchfrr.c watchfrr_vty.c +watchfrr_LDADD = ../lib/libzebra.la @LIBCAP@ diff --git a/watchquagga/watchquagga.c b/watchfrr/watchfrr.c similarity index 98% rename from watchquagga/watchquagga.c rename to watchfrr/watchfrr.c index a70070bef7..903e2bbe91 100644 --- a/watchquagga/watchquagga.c +++ b/watchfrr/watchfrr.c @@ -1,5 +1,5 @@ /* - Monitor status of quagga daemons and restart if necessary. + Monitor status of frr daemons and restart if necessary. Copyright (C) 2004 Andrew J. Schorr @@ -33,7 +33,7 @@ #include #include -#include "watchquagga.h" +#include "watchfrr.h" #ifndef MIN #define MIN(X,Y) (((X) <= (Y)) ? (X) : (Y)) @@ -49,10 +49,10 @@ #define DEFAULT_LOGLEVEL LOG_INFO #define DEFAULT_MIN_RESTART 60 #define DEFAULT_MAX_RESTART 600 -#ifdef PATH_WATCHQUAGGA_PID -#define DEFAULT_PIDFILE PATH_WATCHQUAGGA_PID +#ifdef PATH_WATCHFRR_PID +#define DEFAULT_PIDFILE PATH_WATCHFRR_PID #else -#define DEFAULT_PIDFILE STATEDIR "/watchquagga.pid" +#define DEFAULT_PIDFILE STATEDIR "/watchfrr.pid" #endif #ifdef DAEMON_VTY_DIR #define VTYDIR DAEMON_VTY_DIR @@ -223,7 +223,7 @@ usage(const char *progname, int status) else { printf("Usage : %s [OPTION...] ...\n\n\ -Watchdog program to monitor status of quagga daemons and try to restart\n\ +Watchdog program to monitor status of frr daemons and try to restart\n\ them if they are down or unresponsive. It determines whether a daemon is\n\ up based on whether it can connect to the daemon's vty unix stream socket.\n\ It then repeatedly sends echo commands over that socket to determine whether\n\ @@ -706,10 +706,10 @@ daemon_send_ready (void) #if defined (HAVE_CUMULUS) FILE *fp; - fp = fopen(DAEMON_VTY_DIR "/watchquagga.started", "w"); + fp = fopen(DAEMON_VTY_DIR "/watchfrr.started", "w"); fclose(fp); #endif - zlog_notice ("Watchquagga: Notifying Systemd we are up and running"); + zlog_notice ("Watchfrr: Notifying Systemd we are up and running"); systemd_send_started(master, 0); sent = 1; } @@ -1062,7 +1062,7 @@ translate_blanks(const char *cmd, const char *blankstr) return res; } -struct zebra_privs_t watchquagga_privs = +struct zebra_privs_t watchfrr_privs = { #ifdef VTY_GROUP .vty_group = VTY_GROUP, @@ -1325,14 +1325,14 @@ main(int argc, char **argv) gs.restart.interval = gs.min_restart_interval; - zprivs_init (&watchquagga_privs); + zprivs_init (&watchfrr_privs); master = thread_master_create(); cmd_init(-1); memory_init(); vty_init(master); - watchquagga_vty_init(); - vty_serv_sock(NULL, 0, WATCHQUAGGA_VTYSH_PATH); + watchfrr_vty_init(); + vty_serv_sock(NULL, 0, WATCHFRR_VTYSH_PATH); signal_init (master, array_size(my_signals), my_signals); srandom(time(NULL)); @@ -1384,7 +1384,7 @@ main(int argc, char **argv) return usage(progname,1); } - zlog_default = openzlog(progname, ZLOG_WATCHQUAGGA, 0, + zlog_default = openzlog(progname, ZLOG_WATCHFRR, 0, LOG_CONS|LOG_NDELAY|LOG_PID, LOG_DAEMON); zlog_set_level(NULL, ZLOG_DEST_MONITOR, ZLOG_DISABLED); if (daemon_mode) @@ -1392,7 +1392,7 @@ main(int argc, char **argv) zlog_set_level(NULL, ZLOG_DEST_SYSLOG, MIN(gs.loglevel,LOG_DEBUG)); if (daemon (0, 0) < 0) { - fprintf(stderr, "Watchquagga daemon failed: %s", strerror(errno)); + fprintf(stderr, "Watchfrr daemon failed: %s", strerror(errno)); exit (1); } } diff --git a/watchquagga/watchquagga.h b/watchfrr/watchfrr.h similarity index 82% rename from watchquagga/watchquagga.h rename to watchfrr/watchfrr.h index ecadf22c56..4a479c72e6 100644 --- a/watchquagga/watchquagga.h +++ b/watchfrr/watchfrr.h @@ -1,5 +1,5 @@ /* - Common definitions for watchquagga API socket. + Common definitions for watchfrr API socket. Copyright (C) 2016 David Lamparter for NetDEF, Inc. @@ -18,12 +18,12 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -#ifndef QUAGGA_WATCHQUAGGA_H -#define QUAGGA_WATCHQUAGGA_H +#ifndef FRR_WATCHFRR_H +#define FRR_WATCHFRR_H -extern void watchquagga_vty_init(void); +extern void watchfrr_vty_init(void); extern pid_t integrated_write_pid; extern void integrated_write_sigchld(int status); -#endif /* QUAGGA_WATCHQUAGGA_H */ +#endif /* FRR_WATCHFRR_H */ diff --git a/watchquagga/watchquagga_vty.c b/watchfrr/watchfrr_vty.c similarity index 94% rename from watchquagga/watchquagga_vty.c rename to watchfrr/watchfrr_vty.c index b96011b760..4fffb020d7 100644 --- a/watchquagga/watchquagga_vty.c +++ b/watchfrr/watchfrr_vty.c @@ -1,5 +1,5 @@ /* - watchquagga CLI functions. + watchfrr CLI functions. Copyright (C) 2016 David Lamparter for NetDEF, Inc. @@ -26,7 +26,7 @@ #include "vty.h" #include "command.h" -#include "watchquagga.h" +#include "watchfrr.h" pid_t integrated_write_pid; static int integrated_result_fd; @@ -35,7 +35,7 @@ DEFUN (config_write_integrated, config_write_integrated_cmd, "write integrated", "Write running configuration to memory, network, or terminal\n" - "Write integrated all-daemon Quagga.conf file\n") + "Write integrated all-daemon Frr.conf file\n") { pid_t child; sigset_t oldmask, sigmask; @@ -69,7 +69,7 @@ DEFUN (config_write_integrated, /* note: the VTY won't write a command return value to vtysh; the * session temporarily enters an intentional "hang" state. This is * to make sure latency in vtysh doing the config write (several - * seconds is not rare to see) does not interfere with watchquagga's + * seconds is not rare to see) does not interfere with watchfrr's * supervisor job. * * The fd is duplicated here so we don't need to hold a vty pointer @@ -127,7 +127,7 @@ void integrated_write_sigchld(int status) integrated_write_pid = -1; } -void watchquagga_vty_init(void) +void watchfrr_vty_init(void) { integrated_write_pid = -1; install_element(ENABLE_NODE, &config_write_integrated_cmd); From 438f5286d419b2d59f8d0761b504c0a5e4a5f803 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 4 Jan 2017 07:53:30 -0500 Subject: [PATCH 052/107] doc: Fixup quagga -> frr Modify the documentation so that it talks about FRR instead of Quagga. Signed-off-by: Donald Sharp --- configure.ac | 2 +- doc/.gitignore | 12 +- doc/Makefile.am | 18 +-- doc/basic.texi | 4 +- doc/bgpd.texi | 26 ++--- ...or.dia => fig-vnc-frr-route-reflector.dia} | 0 ...or.png => fig-vnc-frr-route-reflector.png} | Bin ...or.txt => fig-vnc-frr-route-reflector.txt} | 0 doc/filter.texi | 2 +- doc/{quagga.1.in => frr.1.in} | 22 ++-- doc/{quagga.texi => frr.texi} | 24 ++-- doc/install.texi | 32 +++--- doc/ipv6.texi | 6 +- doc/kernel.texi | 6 +- doc/ldpd-basic-test-setup.md | 8 +- doc/main.texi | 12 +- doc/next-hop-tracking.txt | 14 +-- doc/ospfd.texi | 8 +- doc/overview.texi | 104 +++++++++--------- doc/protocol.texi | 2 +- doc/ripd.texi | 12 +- doc/ripngd.texi | 4 +- doc/routeserver.texi | 18 +-- doc/snmp.texi | 42 +++---- doc/snmptrap.texi | 6 +- doc/vnc.texi | 32 +++--- doc/vtysh.1.in | 6 +- doc/vtysh.texi | 32 +++--- 28 files changed, 228 insertions(+), 226 deletions(-) rename doc/{fig-vnc-quagga-route-reflector.dia => fig-vnc-frr-route-reflector.dia} (100%) rename doc/{fig-vnc-quagga-route-reflector.png => fig-vnc-frr-route-reflector.png} (100%) rename doc/{fig-vnc-quagga-route-reflector.txt => fig-vnc-frr-route-reflector.txt} (100%) rename doc/{quagga.1.in => frr.1.in} (74%) rename doc/{quagga.texi => frr.texi} (78%) diff --git a/configure.ac b/configure.ac index 7b27cbd8db..c62857c325 100755 --- a/configure.ac +++ b/configure.ac @@ -1631,7 +1631,7 @@ AC_CONFIG_FILES([Makefile lib/Makefile qpb/Makefile zebra/Makefile ripd/Makefile doc/vtysh.1 doc/watchfrr.8 doc/zebra.8 - doc/quagga.1 + doc/frr.1 pkgsrc/bgpd.sh pkgsrc/ospf6d.sh pkgsrc/ospfd.sh pkgsrc/ripd.sh pkgsrc/ripngd.sh pkgsrc/zebra.sh]) diff --git a/doc/.gitignore b/doc/.gitignore index 66c43c73e6..57c66cb4ac 100644 --- a/doc/.gitignore +++ b/doc/.gitignore @@ -2,17 +2,17 @@ Makefile Makefile.in mdate-sh draft-zebra-00.txt -quagga.info-* +frr.info-* zebra.html defines.texi version.texi texinfo.tex -quagga.html -quagga.info +frr.html +frr.info *.pdf *.eps -quagga.ps -quagga.dvi +frr.ps +frr.dvi stamp-vti .nfs* *.aux @@ -28,6 +28,8 @@ stamp-vti *.toc *.tp *.vr +*.8 +*.1 .arch-inventory .arch-ids *~ diff --git a/doc/Makefile.am b/doc/Makefile.am index a9c0cc221d..04389c63ac 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -7,7 +7,7 @@ # # Here we use 'convert' from the well known 'ImageMagick' package # to do conversion from png to eps/pdf for figures. -# PDF form is required for quagga.pdf, using PDFTex at least. +# PDF form is required for frr.pdf, using PDFTex at least. # # TeX implementation, which we depend on already anyway. # @@ -20,7 +20,7 @@ PNGTOPDF = $(PNGTOEPS) EPSTOPDF = epstopdf VNCFIGURES_PNG = -VNCFIGURES_DIA = -vnc-mesh -vnc-quagga-route-reflector \ +VNCFIGURES_DIA = -vnc-mesh -vnc-frr-route-reflector \ -vnc-commercial-route-reflector -vnc-redundant-route-reflectors \ -vnc-gw -vnc-gw-rr @@ -40,7 +40,7 @@ figures_eps = $(figures_names_parts:%=fig%.eps) $(VNCFIGURES_PNG:%.png=%.eps) figures_txt = $(figures_names_parts:%=fig%.txt) # rather twisted logic because we have to build PDFs of the EPS figures for -# PDFTex and yet build one PDF, quagga.pdf, from texi source. Which means we +# PDFTex and yet build one PDF, frr.pdf, from texi source. Which means we # cant rely on a single automatic rule for *.pdf, eg the one automatically # provided by automake. If you are an automake wizard, please feel free to # compact it somehow. @@ -48,16 +48,16 @@ figures_txt = $(figures_names_parts:%=fig%.txt) # Built from defines.texi.in BUILT_SOURCES = defines.texi -info_TEXINFOS = quagga.texi +info_TEXINFOS = frr.texi -# Have to manually specify the quagga.pdf rule in order to allow +# Have to manually specify the frr.pdf rule in order to allow # us to have a generic automatic .pdf rule to build the figure sources # because it cant just work from the png's directly it seems - contrary # to the documentation... -quagga.pdf: $(info_TEXINFOS) $(figures_pdf) $(quagga_TEXINFOS) +frr.pdf: $(info_TEXINFOS) $(figures_pdf) $(frr_TEXINFOS) $(TEXI2PDF) -o "$@" $< || true -quagga_TEXINFOS = appendix.texi basic.texi bgpd.texi isisd.texi filter.texi \ +frr_TEXINFOS = appendix.texi basic.texi bgpd.texi isisd.texi filter.texi \ vnc.texi \ install.texi ipv6.texi kernel.texi main.texi ospf6d.texi ospfd.texi \ overview.texi protocol.texi ripd.texi ripngd.texi routemap.texi \ @@ -73,7 +73,7 @@ quagga_TEXINFOS = appendix.texi basic.texi bgpd.texi isisd.texi filter.texi \ .dia.png: $(DIATOPNG) "$@" $< -man_MANS = quagga.1 +man_MANS = frr.1 if PIMD man_MANS += pimd.8 @@ -137,7 +137,7 @@ EXTRA_DIST = BGP-TypeCode draft-zebra-00.ms draft-zebra-00.txt \ vtysh.1.in \ watchfrr.8.in \ zebra.8.in \ - quagga.1.in \ + frr.1.in \ \ mpls/ChangeLog.opaque.txt mpls/cli_summary.txt \ mpls/opaque_lsa.txt mpls/ospfd.conf \ diff --git a/doc/basic.texi b/doc/basic.texi index 4485665afa..cea33eaa81 100644 --- a/doc/basic.texi +++ b/doc/basic.texi @@ -110,7 +110,7 @@ with severity @code{errors}. If you want to log into a file, please specify @code{filename} as in this example: @example -log file /var/log/quagga/bgpd.log informational +log file /var/log/frr/bgpd.log informational @end example If the optional second argument specifying the logging level is not present, the default logging level (typically debugging, @@ -119,7 +119,7 @@ The @code{no} form of the command disables logging to a file. Note: if you do not configure any file logging, and a daemon crashes due to a signal or an assertion failure, it will attempt to save the crash -information in a file named /var/tmp/quagga..crashlog. +information in a file named /var/tmp/frr..crashlog. For security reasons, this will not happen if the file exists already, so it is important to delete the file after reporting the crash information. @end deffn diff --git a/doc/bgpd.texi b/doc/bgpd.texi index 54bed102f3..08cd4149a4 100644 --- a/doc/bgpd.texi +++ b/doc/bgpd.texi @@ -1,9 +1,9 @@ @c -*-texinfo-*- -@c This is part of the Quagga Manual. +@c This is part of the Frr Manual. @c @value{COPYRIGHT_STR} @c Portions: @c Copyright @copyright{} 2015 Hewlett Packard Enterprise Development LP -@c See file quagga.texi for copying conditions. +@c See file frr.texi for copying conditions. @node BGP @chapter BGP @@ -114,7 +114,7 @@ This command set distance value to @node BGP decision process @subsection BGP decision process -The decision process Quagga BGP uses to select routes is as follows: +The decision process Frr BGP uses to select routes is as follows: @table @asis @item 1. Weight check @@ -240,7 +240,7 @@ The BGP MED (Multi_Exit_Discriminator) attribute has properties which can cause subtle convergence problems in BGP. These properties and problems have proven to be hard to understand, at least historically, and may still not be widely understood. The following attempts to collect together and -present what is known about MED, to help operators and Quagga users in +present what is known about MED, to help operators and Frr users in designing and configuring their networks. The BGP @acronym{MED, Multi_Exit_Discriminator} attribute is intended to @@ -263,7 +263,7 @@ MED values to those of AS X. The MED values have been set by different administrators, with different frames of reference. The default behaviour of BGP therefore is to not compare MED values across -routes received from different neighbouring ASes. In Quagga this is done by +routes received from different neighbouring ASes. In Frr this is done by comparing the neighbouring, left-most AS in the received AS_PATHs of the routes and only comparing MED if those are the same. @@ -341,7 +341,7 @@ in response to the most common sequence of received updates. A deterministic order of evaluation tends to imply an additional overhead of sorting over any set of n routes to a destination. The implementation of -deterministic MED in Quagga scales significantly worse than most sorting +deterministic MED in Frr scales significantly worse than most sorting algorithms at present, with the number of paths to a given destination. That number is often low enough to not cause any issues, but where there are many paths, the deterministic comparison may quickly become increasingly @@ -408,7 +408,7 @@ preferences between the routes: This particular type of oscillation in full-mesh iBGP topologies can be avoided by speakers preferring already selected, external routes rather than choosing to update to new a route based on a post-MED metric (e.g. -router-ID), at the cost of a non-deterministic selection process. Quagga +router-ID), at the cost of a non-deterministic selection process. Frr implements this, as do many other implementations, so long as it is not overridden by setting @ref{bgp bestpath compare-routerid}, and see also @ref{BGP decision process}, . @@ -480,7 +480,7 @@ with MED may be determined largely by the order that routes were received in. Setting this option will have a performance cost that may be noticeable when -there are many routes for each destination. Currently in Quagga it is +there are many routes for each destination. Currently in Frr it is implemented in a way that scales poorly as the number of routes per destination increases. @@ -1478,11 +1478,11 @@ unicast neighbor, @command{bgpd} does not send these Capability Negotiation packets (at least not unless other optional BGP features require capability negotation). -By default, Quagga will bring up peering with minimal common capability +By default, Frr will bring up peering with minimal common capability for the both sides. For example, local router has unicast and multicast capabilitie and remote router has unicast capability. In this case, the local router will establish the connection with unicast -only capability. When there are no common capabilities, Quagga sends +only capability. When there are no common capabilities, Frr sends Unsupported Capability error and then resets the connection. If you want to completely match capabilities with remote peer. Please @@ -1588,10 +1588,10 @@ When bgp config-type cisco is specified, ``network'' and ``aggregate-address'' argument is displayed as ``A.B.C.D M.M.M.M'' -Quagga: network 10.0.0.0/8 +Frr: network 10.0.0.0/8 Cisco: network 10.0.0.0 -Quagga: aggregate-address 192.168.0.0/24 +Frr: aggregate-address 192.168.0.0/24 Cisco: aggregate-address 192.168.0.0 255.255.255.0 Community attribute handling is also different. If there is no @@ -1615,7 +1615,7 @@ router bgp 1 @end example @deffn {Command} {bgp config-type zebra} {} -Quagga style BGP configuration. This is default. +Frr style BGP configuration. This is default. @end deffn @node BGP instance and view diff --git a/doc/fig-vnc-quagga-route-reflector.dia b/doc/fig-vnc-frr-route-reflector.dia similarity index 100% rename from doc/fig-vnc-quagga-route-reflector.dia rename to doc/fig-vnc-frr-route-reflector.dia diff --git a/doc/fig-vnc-quagga-route-reflector.png b/doc/fig-vnc-frr-route-reflector.png similarity index 100% rename from doc/fig-vnc-quagga-route-reflector.png rename to doc/fig-vnc-frr-route-reflector.png diff --git a/doc/fig-vnc-quagga-route-reflector.txt b/doc/fig-vnc-frr-route-reflector.txt similarity index 100% rename from doc/fig-vnc-quagga-route-reflector.txt rename to doc/fig-vnc-frr-route-reflector.txt diff --git a/doc/filter.texi b/doc/filter.texi index 5a9a15ee99..a494043659 100644 --- a/doc/filter.texi +++ b/doc/filter.texi @@ -2,7 +2,7 @@ @comment node-name, next, previous, up @chapter Filtering -Quagga provides many very flexible filtering features. Filtering is used +Frr provides many very flexible filtering features. Filtering is used for both input and output of the routing information. Once filtering is defined, it can be applied in any direction. diff --git a/doc/quagga.1.in b/doc/frr.1.in similarity index 74% rename from doc/quagga.1.in rename to doc/frr.1.in index 040187200f..528358a8d0 100644 --- a/doc/quagga.1.in +++ b/doc/frr.1.in @@ -1,28 +1,28 @@ -.TH Quagga 1 "27 July 2006" "@PACKAGE_FULLNAME@ Systemd Script" "Version @PACKAGE_VERSION@" +.TH Frr 1 "27 July 2006" "@PACKAGE_FULLNAME@ Systemd Script" "Version @PACKAGE_VERSION@" .SH NAME -quagga \- a systemd interaction script +frr \- a systemd interaction script .SH SYNOPSIS -.B quagga +.B frr [ .B start ] .br -.B quagga +.B frr [ .B stop ] .br -.B quagga +.B frr [ .B reload ] .br -.B quagga +.B frr [ .B restart ] .br -.B quagga +.B frr [ .B status ] @@ -34,12 +34,12 @@ is a systemd interaction script for the routing engine. .SH OPTIONS Options available for the -.B quagga +.B frr command: .IP start -Start enabled Quagga daemons +Start enabled Frr daemons .IP stop -Stop enabled Quagga daemons +Stop enabled Frr daemons .IP reload Reload modified configuration files .IP restart @@ -55,7 +55,7 @@ Status of all the daemons .BR isisd (8), .BR zebra (8) .SH BUGS -.B quagga +.B frr eats bugs for breakfast. If you have food for the maintainers try .BI @PACKAGE_BUGREPORT@ .SH AUTHORS diff --git a/doc/quagga.texi b/doc/frr.texi similarity index 78% rename from doc/quagga.texi rename to doc/frr.texi index 13b885b69c..360acebe16 100644 --- a/doc/quagga.texi +++ b/doc/frr.texi @@ -4,10 +4,10 @@ @include defines.texi @c %**start of header -@setfilename quagga.info +@setfilename frr.info @c Set variables - sourced from defines.texi @include defines.texi -@settitle @uref{http://www.quagga.net,,@value{PACKAGE_NAME}} +@settitle @uref{http://www.freerangerouting.net,,@value{PACKAGE_NAME}} @c %**end of header @c automake will automatically generate version.texi @@ -38,26 +38,26 @@ approved by Kunihiro Ishiguro. @c Info entry @dircategory Routing Software: @direntry -* @value{PACKAGE_NAME}: (quagga). The Quagga Software Routing Suite +* @value{PACKAGE_NAME}: (frr). The Frr Suite @end direntry @c @smallbook @ifinfo -This file documents the Quagga Software Routing Suite which manages common +This file documents the Frr Software Routing Suite which manages common TCP/IP routing protocols. This is Edition @value{EDITION}, last updated @value{UPDATED} of -@cite{The Quagga Manual}, for @uref{http://www.quagga.net/,,@value{PACKAGE_NAME}} +@cite{The Frr Manual}, for @uref{http://www.freerangerouting.net/,,@value{PACKAGE_NAME}} Version @value{VERSION}. @insertcopying @end ifinfo @titlepage -@title @uref{http://www.quagga.net,,Quagga} +@title @uref{http://www.freerangerouting.net,,Frr} @subtitle A routing software package for TCP/IP networks -@subtitle @uref{http://www.quagga.net,,@value{PACKAGE_NAME}} @value{VERSION} +@subtitle @uref{http://www.freerangerouting.net,,@value{PACKAGE_NAME}} @value{VERSION} @subtitle @value{UPDATED-MONTH} @author @value{AUTHORS} @@ -70,12 +70,12 @@ Version @value{VERSION}. @ifnottex @node Top -@top Quagga -- With Virtual Network Control +@top Frr -- With Virtual Network Control -@uref{http://www.quagga.net,,Quagga} is an advanced routing software package +@uref{http://www.freerangerouting.net,,Frr} is an advanced routing software package that provides a suite of TCP/IP based routing protocols. This is the Manual -for @value{PACKAGE_STRING}. @uref{http://www.quagga.net,,Quagga} is a fork of -@uref{http://www.zebra.org,,GNU Zebra}. +for @value{PACKAGE_STRING}. @uref{http://www.freerangerouting.net,,Frr} is a fork of +@uref{http://www.quagga.net,,Quagga}. @insertcopying @end ifnottex @@ -91,7 +91,7 @@ for @value{PACKAGE_STRING}. @uref{http://www.quagga.net,,Quagga} is a fork of * OSPFv3:: * ISIS:: * BGP:: -* Configuring Quagga as a Route Server:: +* Configuring Frr as a Route Server:: * VNC and VNC-GW:: * VTY shell:: * Filtering:: diff --git a/doc/install.texi b/doc/install.texi index 3ace7d6a0c..8c501ed45d 100644 --- a/doc/install.texi +++ b/doc/install.texi @@ -1,11 +1,11 @@ @node Installation @chapter Installation -@cindex How to install Quagga +@cindex How to install Frr @cindex Installation -@cindex Installing Quagga +@cindex Installing Frr @cindex Building the system -@cindex Making Quagga +@cindex Making Frr There are three steps for installing the software: configuration, compilation, and installation. @@ -16,7 +16,7 @@ compilation, and installation. * Install the Software:: @end menu -The easiest way to get Quagga running is to issue the following +The easiest way to get Frr running is to issue the following commands: @example @@ -43,7 +43,7 @@ commands: @cindex Distribution configuration @cindex Options to @code{./configure} -Quagga has an excellent configure script which automatically detects most +Frr has an excellent configure script which automatically detects most host configurations. There are several additional configure options to customize the build to include or exclude specific features and dependencies. @@ -122,13 +122,13 @@ This command will configure zebra and the routing daemons. @node Least-Privilege support @subsection Least-Privilege support -@cindex Quagga Least-Privileges -@cindex Quagga Privileges +@cindex Frr Least-Privileges +@cindex Frr Privileges Additionally, you may configure zebra to drop its elevated privileges shortly after startup and switch to another user. The configure script will automatically try to configure this support. There are three configure -options to control the behaviour of Quagga daemons. +options to control the behaviour of Frr daemons. @table @option @item --enable-user=@var{user} @@ -145,29 +145,29 @@ delegate this group to individual users, or to run vtysh setgid to this group. @end table -The default user and group which will be configured is 'quagga' if no user +The default user and group which will be configured is 'frr' if no user or group is specified. Note that this user or group requires write access to the local state directory (see --localstatedir) and requires at least read access, and write access if you wish to allow daemons to write out their configuration, to the configuration directory (see --sysconfdir). On systems which have the 'libcap' capabilities manipulation library -(currently only linux), the quagga system will retain only minimal +(currently only linux), the frr system will retain only minimal capabilities required, further it will only raise these capabilities for -brief periods. On systems without libcap, quagga will run as the user +brief periods. On systems without libcap, frr will run as the user specified and only raise its uid back to uid 0 for brief periods. @node Linux notes @subsection Linux Notes -@cindex Configuring Quagga +@cindex Configuring Frr @cindex Building on Linux boxes @cindex Linux configurations There are several options available only to @sc{gnu}/Linux systems: @footnote{@sc{gnu}/Linux has very flexible kernel configuration features}. If you use @sc{gnu}/Linux, make sure that the current kernel configuration is -what you want. Quagga will run with any kernel configuration but some +what you want. Frr will run with any kernel configuration but some recommendations do exist. @table @var @@ -190,7 +190,7 @@ This option should be specified when you use @command{ripd} (@pxref{RIP}) or @end table IPv6 support has been added in @sc{gnu}/Linux kernel version 2.2. If you -try to use the Quagga IPv6 feature on a @sc{gnu}/Linux kernel, please +try to use the Frr IPv6 feature on a @sc{gnu}/Linux kernel, please make sure the following libraries have been installed. Please note that these libraries will not be needed when you uses @sc{gnu} C library 2.1 or upper. @@ -244,7 +244,7 @@ programs and supporting files to a standard location. After the installation process has completed, these files have been copied from your work directory to @file{/usr/local/bin}, and @file{/usr/local/etc}. -To install the Quagga suite, issue the following command at your shell +To install the Frr suite, issue the following command at your shell prompt: @command{make install}. @example @@ -253,7 +253,7 @@ prompt: @command{make install}. % @end example -Quagga daemons have their own terminal interface or VTY. After +Frr daemons have their own terminal interface or VTY. After installation, you have to setup each beast's port number to connect to them. Please add the following entries to @file{/etc/services}. diff --git a/doc/ipv6.texi b/doc/ipv6.texi index e08759ab03..859f6a960e 100644 --- a/doc/ipv6.texi +++ b/doc/ipv6.texi @@ -1,14 +1,14 @@ @node IPv6 Support @chapter IPv6 Support -Quagga fully supports IPv6 routing. As described so far, Quagga supports +Frr fully supports IPv6 routing. As described so far, Frr supports RIPng, OSPFv3, and BGP-4+. You can give IPv6 addresses to an interface -and configure static IPv6 routing information. Quagga IPv6 also provides +and configure static IPv6 routing information. Frr IPv6 also provides automatic address configuration via a feature called @code{address auto configuration}. To do it, the router must send router advertisement messages to the all nodes that exist on the network. -Previous versions of Quagga could be built without IPv6 support. This is +Previous versions of Frr could be built without IPv6 support. This is no longer possible. @menu diff --git a/doc/kernel.texi b/doc/kernel.texi index 67fbb5e360..e58ade5a85 100644 --- a/doc/kernel.texi +++ b/doc/kernel.texi @@ -31,7 +31,7 @@ information. @item netlink On recent Linux kernels (2.0.x and 2.2.x), there is a kernel/user communication support called @code{netlink}. It makes asynchronous -communication between kernel and Quagga possible, similar to a routing +communication between kernel and Frr possible, similar to a routing socket on BSD systems. Before you use this feature, be sure to select (in kernel configuration) @@ -41,7 +41,7 @@ the kernel/netlink support option 'Kernel/User network link driver' and Today, the /dev/route special device file is obsolete. Netlink communication is done by reading/writing over netlink socket. -After the kernel configuration, please reconfigure and rebuild Quagga. -You can use netlink as a dynamic routing update channel between Quagga +After the kernel configuration, please reconfigure and rebuild Frr. +You can use netlink as a dynamic routing update channel between Frr and the kernel. @end table diff --git a/doc/ldpd-basic-test-setup.md b/doc/ldpd-basic-test-setup.md index e5e987f9e3..b25a2b6d4b 100644 --- a/doc/ldpd-basic-test-setup.md +++ b/doc/ldpd-basic-test-setup.md @@ -103,7 +103,7 @@ just to show how the VPLS configuration should look like in the future. # ip -6 route add 3:3:3::3/128 via 2001:db8:4::3 ``` -6 - Edit /etc/quagga/ospfd.conf: +6 - Edit /etc/frr/ospfd.conf: ``` router ospf network 4.4.4.4/32 area 0.0.0.0 @@ -112,7 +112,7 @@ router ospf ! ``` -7 - Edit /etc/quagga/ldpd.conf: +7 - Edit /etc/frr/ldpd.conf: ``` debug mpls ldp messages recv debug mpls ldp messages sent @@ -207,7 +207,7 @@ LDPv6 but the IOS-XR implementation is not RFC compliant in this regard. # route -n add 2:2:2::2/128 2001:db8:2::2 ``` -6 - Edit /etc/quagga/ospfd.conf: +6 - Edit /etc/frr/ospfd.conf: ``` router ospf network 10.0.2.3/24 area 0 @@ -216,7 +216,7 @@ router ospf ! ``` -7 - Edit /etc/quagga/ldpd.conf: +7 - Edit /etc/frr/ldpd.conf: ``` debug mpls ldp messages recv debug mpls ldp messages sent diff --git a/doc/main.texi b/doc/main.texi index 5302c9687d..2e50457628 100644 --- a/doc/main.texi +++ b/doc/main.texi @@ -258,7 +258,7 @@ addresses but unicast addresses. This table is fully separate from the default unicast table. However, RPF lookup can include the unicast table. -WARNING: RPF lookup results are non-responsive in this version of Quagga, +WARNING: RPF lookup results are non-responsive in this version of Frr, i.e. multicast routing does not actively react to changes in underlying unicast topology! @@ -330,7 +330,7 @@ Multicast RIB instead of the Unicast RIB. @node zebra Route Filtering @section zebra Route Filtering Zebra supports @command{prefix-list} and @command{route-map} to match -routes received from other quagga components. The +routes received from other frr components. The @command{permit}/@command{deny} facilities provided by these commands can be used to filter which routes zebra will install in the kernel. @@ -374,16 +374,16 @@ ip protocol rip route-map RM1 @section zebra FIB push interface Zebra supports a 'FIB push' interface that allows an external -component to learn the forwarding information computed by the Quagga +component to learn the forwarding information computed by the Frr routing suite. -In Quagga, the Routing Information Base (RIB) resides inside +In Frr, the Routing Information Base (RIB) resides inside zebra. Routing protocols communicate their best routes to zebra, and zebra computes the best route across protocols for each prefix. This latter information makes up the Forwarding Information Base (FIB). Zebra feeds the FIB to the kernel, which allows the IP stack in the kernel to forward packets according to the routes computed by -Quagga. The kernel FIB is updated in an OS-specific way. For example, +Frr. The kernel FIB is updated in an OS-specific way. For example, the @code{netlink} interface is used on Linux, and route sockets are used on FreeBSD. @@ -408,7 +408,7 @@ interaction of zebra with the kernel remains unchanged -- that is, the kernel continues to receive FIB updates as before. The encapsulation header for the messages exchanged with the FPM is -defined by the file @file{fpm/fpm.h} in the quagga tree. The routes +defined by the file @file{fpm/fpm.h} in the frr tree. The routes themselves are encoded in netlink or protobuf format, with netlink being the default. diff --git a/doc/next-hop-tracking.txt b/doc/next-hop-tracking.txt index d157866e8a..d64433e2fe 100644 --- a/doc/next-hop-tracking.txt +++ b/doc/next-hop-tracking.txt @@ -1,7 +1,7 @@ 0. Introduction This is the design specification for next hop tracking feature in -Quagga. +Frr. 1. Background @@ -259,7 +259,7 @@ rnh table: 5. User interface changes -quagga# show ip nht +frr# show ip nht 3.3.3.3 resolved via kernel via 11.0.0.6, swp1 @@ -277,7 +277,7 @@ quagga# show ip nht via 10.0.1.2, eth0 Client list: bgp(fd 12) -quagga# show ip bgp nexthop +frr# show ip bgp nexthop Current BGP nexthop cache: 3.3.3.3 valid [IGP metric 0], #paths 3 Last update: Wed Oct 16 04:43:49 2013 @@ -291,11 +291,11 @@ Current BGP nexthop cache: 11.11.11.11 valid [IGP metric 0], #paths 1 Last update: Wed Oct 16 04:43:47 2013 -quagga# show ipv6 nht -quagga# show ip bgp nexthop detail +frr# show ipv6 nht +frr# show ip bgp nexthop detail -quagga# debug bgp nht -quagga# debug zebra nht +frr# debug bgp nht +frr# debug zebra nht 6. Sample test cases diff --git a/doc/ospfd.texi b/doc/ospfd.texi index 7b9df8e78e..7ff78e67cf 100644 --- a/doc/ospfd.texi +++ b/doc/ospfd.texi @@ -77,7 +77,7 @@ which still can reach the backbone - this restriction exists primarily to ensure routing-loops are avoided. With the "Cisco" or "IBM" ABR type, the default in this release of -Quagga, this restriction is lifted, allowing an ABR to consider +Frr, this restriction is lifted, allowing an ABR to consider summaries learnt from other ABRs through non-backbone areas, and hence route via non-backbone areas as a last resort when, and only when, backbone links are down. @@ -169,7 +169,7 @@ calculations will always be seperated by between 400ms to 10s, the hold-time increasing by 400ms each time an SPF-triggering event occurs within the hold-time of the previous SPF calculation. -This command supercedes the @command{timers spf} command in previous Quagga +This command supercedes the @command{timers spf} command in previous Frr releases. @end deffn @@ -259,7 +259,7 @@ Summarize intra area paths from specified area into one Type-3 summary-LSA announced to other areas. This command can be used only in ABR and ONLY router-LSAs (Type-1) and network-LSAs (Type-2) (ie. LSAs with scope area) can be summarized. Type-5 AS-external-LSAs can't be summarized - their scope is AS. -Summarizing Type-7 AS-external-LSAs isn't supported yet by Quagga. +Summarizing Type-7 AS-external-LSAs isn't supported yet by Frr. @example @group @@ -784,7 +784,7 @@ of networks between the areas: @group ! password ABCDEF -log file /var/log/quagga/ospfd.log +log file /var/log/frr/ospfd.log service advanced-vty ! interface eth0 diff --git a/doc/overview.texi b/doc/overview.texi index 2301c4b7fe..d1e8ea48b2 100644 --- a/doc/overview.texi +++ b/doc/overview.texi @@ -2,73 +2,73 @@ @chapter Overview @cindex Overview - @uref{http://www.quagga.net,,Quagga} is a routing software package that + @uref{http://www.freerangerouting.net,,Frr} is a routing software package that provides TCP/IP based routing services with routing protocols support such as RIPv1, RIPv2, RIPng, OSPFv2, OSPFv3, IS-IS, BGP-4, and BGP-4+ (@pxref{Supported -RFCs}). Quagga also supports special BGP Route Reflector and Route Server -behavior. In addition to traditional IPv4 routing protocols, Quagga also +RFCs}). Frr also supports special BGP Route Reflector and Route Server +behavior. In addition to traditional IPv4 routing protocols, Frr also supports IPv6 routing protocols. With SNMP daemon which supports SMUX and AgentX -protocol, Quagga provides routing protocol MIBs (@pxref{SNMP Support}). +protocol, Frr provides routing protocol MIBs (@pxref{SNMP Support}). - Quagga uses an advanced software architecture to provide you with a high -quality, multi server routing engine. Quagga has an interactive user + Frr uses an advanced software architecture to provide you with a high +quality, multi server routing engine. Frr has an interactive user interface for each routing protocol and supports common client commands. -Due to this design, you can add new protocol daemons to Quagga easily. You -can use Quagga library as your program's client user interface. +Due to this design, you can add new protocol daemons to Frr easily. You +can use Frr library as your program's client user interface. - Quagga is distributed under the @sc{gnu} General Public License. + Frr is distributed under the @sc{gnu} General Public License. @menu -* About Quagga:: Basic information about Quagga -* System Architecture:: The Quagga system architecture +* About Frr:: Basic information about Frr +* System Architecture:: The Frr system architecture * Supported Platforms:: Supported platforms and future plans * Supported RFCs:: Supported RFCs -* How to get Quagga:: +* How to get Frr:: * Mailing List:: Mailing list information * Bug Reports:: Mail address for bug data @end menu -@node About Quagga +@node About Frr @comment node-name, next, previous, up -@section About Quagga -@cindex About Quagga +@section About Frr +@cindex About Frr Today, TCP/IP networks are covering all of the world. The Internet has been deployed in many countries, companies, and to the home. When you connect to the Internet your packet will pass many routers which have TCP/IP routing functionality. - A system with Quagga installed acts as a dedicated router. With Quagga, + A system with Frr installed acts as a dedicated router. With Frr, your machine exchanges routing information with other routers using routing -protocols. Quagga uses this information to update the kernel routing table +protocols. Frr uses this information to update the kernel routing table so that the right data goes to the right place. You can dynamically change -the configuration and you may view routing table information from the Quagga +the configuration and you may view routing table information from the Frr terminal interface. - Adding to routing protocol support, Quagga can setup interface's flags, + Adding to routing protocol support, Frr can setup interface's flags, interface's address, static routes and so on. If you have a small network, -or a stub network, or xDSL connection, configuring the Quagga routing +or a stub network, or xDSL connection, configuring the Frr routing software is very easy. The only thing you have to do is to set up the interfaces and put a few commands about static routes and/or default routes. If the network is rather large, or if the network structure changes -frequently, you will want to take advantage of Quagga's dynamic routing +frequently, you will want to take advantage of Frr's dynamic routing protocol support for protocols such as RIP, OSPF, IS-IS or BGP. Traditionally, UNIX based router configuration is done by @command{ifconfig} and @command{route} commands. Status of routing table is displayed by @command{netstat} utility. Almost of these commands -work only if the user has root privileges. Quagga has a different system -administration method. There are two user modes in Quagga. One is normal +work only if the user has root privileges. Frr has a different system +administration method. There are two user modes in Frr. One is normal mode, the other is enable mode. Normal mode user can only view system status, enable mode user can change system configuration. This UNIX account independent feature will be great help to the router administrator. - Currently, Quagga supports common unicast routing protocols, that is BGP, + Currently, Frr supports common unicast routing protocols, that is BGP, OSPF, RIP and IS-IS. Upcoming for MPLS support, an implementation of LDP is currently being prepared for merging. Implementations of BFD and PIM-SSM (IPv4) also exist, but are not actively being worked on. - The ultimate goal of the Quagga project is making a productive, quality, free + The ultimate goal of the Frr project is making a productive, quality, free TCP/IP routing software package. @node System Architecture @@ -79,7 +79,7 @@ TCP/IP routing software package. @cindex Software internals Traditional routing software is made as a one process program which -provides all of the routing protocol functionalities. Quagga takes a +provides all of the routing protocol functionalities. Frr takes a different approach. It is made from a collection of several daemons that work together to build the routing table. There may be several protocol-specific routing daemons and zebra the kernel routing manager. @@ -110,7 +110,7 @@ architecture creates new possibilities for the routing system. | | +------------------------------+ - Quagga System Architecture + Frr System Architecture @end group @end example @@ -120,11 +120,11 @@ and terminal interfaces. Each daemon has it's own configuration file and terminal interface. When you configure a static route, it must be done in @command{zebra} configuration file. When you configure BGP network it must be done in @command{bgpd} configuration file. This can be a very annoying -thing. To resolve the problem, Quagga provides integrated user interface +thing. To resolve the problem, Frr provides integrated user interface shell called @command{vtysh}. @command{vtysh} connects to each daemon with UNIX domain socket and then works as a proxy for user input. -Quagga was planned to use multi-threaded mechanism when it runs with a +Frr was planned to use multi-threaded mechanism when it runs with a kernel that supports multi-threads. But at the moment, the thread library which comes with @sc{gnu}/Linux or FreeBSD has some problems with running reliable services such as routing software, so we don't use threads at all. @@ -136,18 +136,18 @@ events. @section Supported Platforms @cindex Supported platforms -@cindex Quagga on other systems +@cindex Frr on other systems @cindex Compatibility with other systems -@cindex Operating systems that support Quagga +@cindex Operating systems that support Frr -Currently Quagga supports @sc{gnu}/Linux and BSD. Porting Quagga +Currently Frr supports @sc{gnu}/Linux and BSD. Porting Frr to other platforms is not too difficult as platform dependent code should most be limited to the @command{zebra} daemon. Protocol daemons are mostly -platform independent. Please let us know when you find out Quagga runs on a +platform independent. Please let us know when you find out Frr runs on a platform which is not listed below. The list of officially supported platforms are listed below. Note that -Quagga may run correctly on other platforms, and may run with partial +Frr may run correctly on other platforms, and may run with partial functionality on further platforms. @sp 1 @@ -176,7 +176,7 @@ Mac OSX @end itemize Also note that, in particular regarding proprietary platforms, compiler -and C library choice will affect Quagga. Only recent versions of the +and C library choice will affect Frr. Only recent versions of the following C compilers are well-tested: @sp 1 @@ -269,39 +269,39 @@ November 1995.} @end table -@node How to get Quagga +@node How to get Frr @comment node-name, next, previous, up -@section How to get Quagga +@section How to get Frr -The official Quagga web-site is located at: +The official Frr web-site is located at: -@uref{http://www.quagga.net/} +@uref{http://www.freerangerouting.net/} and contains further information, as well as links to additional resources. -@uref{http://www.quagga.net/,Quagga} is a fork of GNU Zebra, whose +@uref{http://www.freerangerouting.net/,Frr} is a fork of Quagga, whose web-site is located at: -@uref{http://www.zebra.org/}. +@uref{http://www.quagga.net/}. @node Mailing List @comment node-name, next, previous, up @section Mailing List -@cindex How to get in touch with Quagga -@cindex Mailing Quagga +@cindex How to get in touch with Frr +@cindex Mailing Frr @cindex Contact information @cindex Mailing lists -There is a mailing list for discussions about Quagga. If you have any -comments or suggestions to Quagga, please subscribe to: +There is a mailing list for discussions about Frr. If you have any +comments or suggestions to Frr, please subscribe to: -@uref{http://lists.quagga.net/mailman/listinfo/quagga-users}. +@uref{http://lists.nox.tf/listinfo/frr-users}. -The @uref{http://www.quagga.net/,,Quagga} site has further information on +The @uref{http://www.freerangerouting.net/,,Frr} site has further information on the available mailing lists, see: - @uref{http://www.quagga.net/lists.php} + @uref{http://lists.nox.tf/lists.php} @node Bug Reports @section Bug Reports @@ -315,7 +315,7 @@ the available mailing lists, see: If you think you have found a bug, please send a bug report to: -@uref{http://bugzilla.quagga.net} +@uref{http://github.com/freerangerouting/frr/issues} When you send a bug report, please be careful about the points below. @@ -332,6 +332,6 @@ Please send your configuration file with the report. If you specify arguments to the configure script please note that too. @end itemize - Bug reports are very important for us to improve the quality of Quagga. -Quagga is still in the development stage, but please don't hesitate to -send a bug report to @uref{http://bugzilla.quagga.net}. + Bug reports are very important for us to improve the quality of Frr. +Frr is still in the development stage, but please don't hesitate to +send a bug report to @uref{http://github.com/freerangerouting/frr/issues}. diff --git a/doc/protocol.texi b/doc/protocol.texi index 602768a786..f2c8da4301 100644 --- a/doc/protocol.texi +++ b/doc/protocol.texi @@ -26,7 +26,7 @@ seperate commands. Version 0 is used by all versions of GNU Zebra as of this writing, and versions of Quagga up to and including Quagga 0.98. Version 1 will be -used as of Quagga 1.0. +used as of Quagga 1.0. Version 2 will be used as of Frr 2.0. @appendixsection Zebra Protocol Definition @appendixsubsec Zebra Protocol Header (version 0) diff --git a/doc/ripd.texi b/doc/ripd.texi index 78d63eed4c..da0f596afd 100644 --- a/doc/ripd.texi +++ b/doc/ripd.texi @@ -1,7 +1,7 @@ @c -*-texinfo-*- -@c This is part of the Quagga Manual. +@c This is part of the Frr Manual. @c @value{COPYRIGHT_STR} -@c See file quagga.texi for copying conditions. +@c See file frr.texi for copying conditions. @node RIP @chapter RIP @@ -97,7 +97,7 @@ to the packet on the basis of the interface that received the packet. Version 2 of RIP supports a variable length subnet mask (VLSM). By extending the subnet mask, the mask can be divided and reused. Each subnet can be used for different purposes such as large to middle size -LANs and WAN links. Quagga @command{ripd} does not support the non-sequential +LANs and WAN links. Frr @command{ripd} does not support the non-sequential netmasks that are included in RIP Version 2. In a case of similar information with the same prefix and metric, the @@ -294,10 +294,10 @@ If you want to specify RIP only static routes: @deffn {RIP command} {route @var{a.b.c.d/m}} {} @deffnx {RIP command} {no route @var{a.b.c.d/m}} {} -This command is specific to Quagga. The @code{route} command makes a static +This command is specific to Frr. The @code{route} command makes a static route only inside RIP. This command should be used only by advanced users who are particularly knowledgeable about the RIP protocol. In -most cases, we recommend creating a static route in Quagga and +most cases, we recommend creating a static route in Frr and redistributing it in RIP using @code{redistribute static}. @end deffn @@ -399,7 +399,7 @@ redistribute connected [route-map MAP_NAME] @end example Cisco applies route-map _before_ routes will exported to rip route table. -In current Quagga's test implementation, @command{ripd} applies route-map +In current Frr's test implementation, @command{ripd} applies route-map after routes are listed in the route table and before routes will be announced to an interface (something like output filter). I think it is not so clear, but it is draft and it may be changed at future. diff --git a/doc/ripngd.texi b/doc/ripngd.texi index 0e58de6da3..1adda69433 100644 --- a/doc/ripngd.texi +++ b/doc/ripngd.texi @@ -1,7 +1,7 @@ @c -*-texinfo-*- -@c This is part of the Quagga Manual. +@c This is part of the Frr Manual. @c @value{COPYRIGHT_STR} -@c See file quagga.texi for copying conditions. +@c See file frr.texi for copying conditions. @node RIPng @chapter RIPng diff --git a/doc/routeserver.texi b/doc/routeserver.texi index f4a4546214..b25800107d 100644 --- a/doc/routeserver.texi +++ b/doc/routeserver.texi @@ -1,12 +1,12 @@ @c -*-texinfo-*- @c @value{COPYRIGHT_STR} -@c See file quagga.texi for copying conditions. +@c See file frr.texi for copying conditions. @c @c This file is a modified version of Jose Luis Rubio's TeX sources @c of his RS-Manual document -@node Configuring Quagga as a Route Server -@chapter Configuring Quagga as a Route Server +@node Configuring Frr as a Route Server +@chapter Configuring Frr as a Route Server The purpose of a Route Server is to centralize the peerings between BGP speakers. For example if we have an exchange point scenario with four BGP @@ -15,9 +15,9 @@ speakers, each of which maintaining a BGP peering with the other three each of the four establishes a single BGP peering against the Route Server (@pxref{fig:route-server}). -We will first describe briefly the Route Server model implemented by Quagga. +We will first describe briefly the Route Server model implemented by Frr. We will explain the commands that have been added for configuring that -model. And finally we will show a full example of Quagga configured as Route +model. And finally we will show a full example of Frr configured as Route Server. @menu @@ -148,7 +148,7 @@ It is also common to demand from a route server that it does not modify some BGP attributes (next-hop, as-path and MED) that are usually modified by standard BGP speakers before announcing a route. -The announcement processing model implemented by Quagga is shown in +The announcement processing model implemented by Frr is shown in @ref{fig:rs-processing}. The figure shows a mixture of RS-clients (B, C and D) with normal BGP peers (A). There are some details that worth additional comments: @@ -180,7 +180,7 @@ they do not hurt anybody (they can always be left empty). @node Commands for configuring a Route Server @section Commands for configuring a Route Server -Now we will describe the commands that have been added to quagga +Now we will describe the commands that have been added to frr in order to support the route server features. @deffn {Route-Server} {neighbor @var{peer-group} route-server-client} {} @@ -189,7 +189,7 @@ in order to support the route server features. This command configures the peer given by @var{peer}, @var{A.B.C.D} or @var{X:X::X:X} as an RS-client. -Actually this command is not new, it already existed in standard Quagga. It +Actually this command is not new, it already existed in standard Frr. It enables the transparent mode for the specified peer. This means that some BGP attributes (as-path, next-hop and MED) of the routes announced to that peer are not modified. @@ -235,7 +235,7 @@ any normal (in or out) route-map. @node Example of Route Server Configuration @section Example of Route Server Configuration -Finally we are going to show how to configure a Quagga daemon to act as a +Finally we are going to show how to configure a Frr daemon to act as a Route Server. For this purpose we are going to present a scenario without route server, and then we will show how to use the configurations of the BGP routers to generate the configuration of the route server. diff --git a/doc/snmp.texi b/doc/snmp.texi index 0918a462f9..c2c889de76 100644 --- a/doc/snmp.texi +++ b/doc/snmp.texi @@ -3,7 +3,7 @@ @acronym{SNMP,Simple Network Managing Protocol} is a widely implemented feature for collecting network information from router and/or host. -Quagga itself does not support SNMP agent (server daemon) functionality +Frr itself does not support SNMP agent (server daemon) functionality but is able to connect to a SNMP agent using the SMUX protocol (@cite{RFC1227}) or the AgentX protocol (@cite{RFC2741}) and make the routing protocol MIBs available through it. @@ -24,7 +24,7 @@ version of @code{net-snmp} which was formerly known as @code{ucd-snmp}. It is free and open software and available at @uref{http://www.net-snmp.org/} and as binary package for most Linux distributions. @code{net-snmp} has to be compiled with @code{--with-mib-modules=agentx} to -be able to accept connections from Quagga using AgentX protocol or with +be able to accept connections from Frr using AgentX protocol or with @code{--with-mib-modules=smux} to use SMUX protocol. Nowadays, SMUX is a legacy protocol. The AgentX protocol should be @@ -33,11 +33,11 @@ preferred for any new deployment. Both protocols have the same coverage. @node AgentX configuration @section AgentX configuration -To enable AgentX protocol support, Quagga must have been build with the +To enable AgentX protocol support, Frr must have been build with the @code{--enable-snmp} or @code{--enable-snmp=agentx} option. Both the -master SNMP agent (snmpd) and each of the Quagga daemons must be +master SNMP agent (snmpd) and each of the Frr daemons must be configured. In @code{/etc/snmp/snmpd.conf}, @code{master agentx} -directive should be added. In each of the Quagga daemons, @code{agentx} +directive should be added. In each of the Frr daemons, @code{agentx} command will enable AgentX support. @example @@ -54,7 +54,7 @@ command will enable AgentX support. # master agentx -/etc/quagga/ospfd.conf: +/etc/frr/ospfd.conf: ! ... the rest of ospfd.conf has been omitted for clarity ... ! agentx @@ -62,7 +62,7 @@ command will enable AgentX support. @end example Upon successful connection, you should get something like this in the -log of each Quagga daemons: +log of each Frr daemons: @example 2012/05/25 11:39:08 ZEBRA: snmp[info]: NET-SNMP version 5.4.3 AgentX subagent connected @@ -78,11 +78,11 @@ OSPF-MIB::ospfRouterId.0 = IpAddress: 192.168.42.109 The AgentX protocol can be transported over a Unix socket or using TCP or UDP. It usually defaults to a Unix socket and depends on how NetSNMP -was built. If need to configure Quagga to use another transport, you can -configure it through @code{/etc/snmp/quagga.conf}: +was built. If need to configure Frr to use another transport, you can +configure it through @code{/etc/snmp/frr.conf}: @example -/etc/snmp/quagga.conf: +/etc/snmp/frr.conf: [snmpd] # Use a remote master agent agentXSocket tcp:192.168.15.12:705 @@ -91,17 +91,17 @@ configure it through @code{/etc/snmp/quagga.conf}: @node SMUX configuration @section SMUX configuration -To enable SMUX protocol support, Quagga must have been build with the +To enable SMUX protocol support, Frr must have been build with the @code{--enable-snmp=smux} option. A separate connection has then to be established between the -SNMP agent (snmpd) and each of the Quagga daemons. This connections +SNMP agent (snmpd) and each of the Frr daemons. This connections each use different OID numbers and passwords. Be aware that this OID number is not the one that is used in queries by clients, it is solely used for the intercommunication of the daemons. In the following example the ospfd daemon will be connected to the -snmpd daemon using the password "quagga_ospfd". For testing it is +snmpd daemon using the password "frr_ospfd". For testing it is recommending to take exactly the below snmpd.conf as wrong access restrictions can be hard to debug. @@ -115,24 +115,24 @@ restrictions can be hard to debug. view all included .1 80 access MyROGroup "" any noauth exact all none none # - # the following line is relevant for Quagga + # the following line is relevant for Frr # - smuxpeer .1.3.6.1.4.1.3317.1.2.5 quagga_ospfd + smuxpeer .1.3.6.1.4.1.3317.1.2.5 frr_ospfd -/etc/quagga/ospf: +/etc/frr/ospf: ! ... the rest of ospfd.conf has been omitted for clarity ... ! - smux peer .1.3.6.1.4.1.3317.1.2.5 quagga_ospfd + smux peer .1.3.6.1.4.1.3317.1.2.5 frr_ospfd ! @end example -After restarting snmpd and quagga, a successful connection can be verified in +After restarting snmpd and frr, a successful connection can be verified in the syslog and by querying the SNMP daemon: @example snmpd[12300]: [smux_accept] accepted fd 12 from 127.0.0.1:36255 snmpd[12300]: accepted smux peer: \ - oid GNOME-PRODUCT-ZEBRA-MIB::ospfd, quagga-0.96.5 + oid GNOME-PRODUCT-ZEBRA-MIB::ospfd, frr-0.96.5 # snmpwalk -c public -v1 localhost .1.3.6.1.2.1.14.1.1 OSPF-MIB::ospfRouterId.0 = IpAddress: 192.168.42.109 @@ -148,7 +148,7 @@ troublesome @code{snmp_log()} line in the function @section MIB and command reference The following OID numbers are used for the interprocess communication of snmpd and -the Quagga daemons with SMUX only. +the Frr daemons with SMUX only. @example (OIDs below .iso.org.dod.internet.private.enterprises) zebra .1.3.6.1.4.1.3317.1.2.1 .gnome.gnomeProducts.zebra.zserv @@ -168,7 +168,7 @@ ripd .1.3.6.1.2.1.23 .iso.org.dot.internet.mgmt.mib-2.rip2 ospf6d .1.3.6.1.3.102 .iso.org.dod.internet.experimental.ospfv3 @end example -The following syntax is understood by the Quagga daemons for configuring SNMP using SMUX: +The following syntax is understood by the Frr daemons for configuring SNMP using SMUX: @deffn {Command} {smux peer @var{oid}} {} @deffnx {Command} {no smux peer @var{oid}} {} @end deffn diff --git a/doc/snmptrap.texi b/doc/snmptrap.texi index 31145639c2..0dd3a703af 100644 --- a/doc/snmptrap.texi +++ b/doc/snmptrap.texi @@ -1,11 +1,11 @@ -@c Documentation on configuring Quagga and snmpd for SNMP traps +@c Documentation on configuring Frr and snmpd for SNMP traps @c contributed by Jeroen Simonetti, jsimonetti@denit.net @node Handling SNMP Traps @section Handling SNMP Traps -To handle snmp traps make sure your snmp setup of quagga works -correctly as described in the quagga documentation in @xref{SNMP Support}. +To handle snmp traps make sure your snmp setup of frr works +correctly as described in the frr documentation in @xref{SNMP Support}. The BGP4 mib will send traps on peer up/down events. These should be visible in your snmp logs with a message similar to: diff --git a/doc/vnc.texi b/doc/vnc.texi index b0d2829cae..f375d3a7df 100644 --- a/doc/vnc.texi +++ b/doc/vnc.texi @@ -1,7 +1,7 @@ @c -*-texinfo-*- -@c This is part of the Quagga Manual. +@c This is part of the Frr Manual. @c @value{COPYRIGHT_STR} -@c See file quagga.texi for copying conditions. +@c See file frr.texi for copying conditions. @node VNC and VNC-GW @chapter VNC and VNC-GW @@ -97,8 +97,8 @@ configured. The default is @code{encap-attr}. The protocol that is used to communicate routing and Ethernet / L2 forwarding information between NVAs and NVEs is referred to as the Remote Forwarder Protocol (RFP). Currently, only a simple example RFP -is included in Quagga. Developers may use this example as a starting -point to integrate Quagga with an RFP of their choosing, e.g., +is included in Frr. Developers may use this example as a starting +point to integrate Frr with an RFP of their choosing, e.g., @code{OpenFlow}. The example code includes the following sample configuration: @@ -966,7 +966,7 @@ Print the number of memory items allocated by the NVA. @menu * Mesh NVA Configuration:: * Mesh NVA and VNC-GW Configuration:: -* VNC with Quagga Route Reflector Configuration:: +* VNC with Frr Route Reflector Configuration:: * VNC with Commercial Route Reflector Configuration:: * VNC with Redundant Route Reflectors Configuration:: @c * Interfacing VNC to an IGP:: @@ -1090,10 +1090,10 @@ VNC-GWs, each supporting two CE routers physically attached to the four NVEs. Note that this example is showing a more complex configuration where VNC-GW is separated from normal NVA functions; it is equally possible to simplify the configuration and combine NVA and VNC-GW -functions in a single quagga instance. +functions in a single frr instance. @float Figure,fig:fig-vnc-gw -@center @image{fig-vnc-gw,400pt,,Quagga VNC Gateway} +@center @image{fig-vnc-gw,400pt,,Frr VNC Gateway} @caption{Meshed NVEs and VNC-GWs} @end float @@ -1177,7 +1177,7 @@ router bgp 64512 @c TBD make this its own example: @c @c @float Figure,fig:fig-vnc-gw-rr -@c @center @image{fig-vnc-gw-rr,400pt,,Quagga VNC Gateway with RR} +@c @center @image{fig-vnc-gw-rr,400pt,,Frr VNC Gateway with RR} @c @end float @c An NVA can also import unicast routes from BGP without advertising the @c imported routes as VPN routes. Such imported routes, while not @@ -1195,17 +1195,17 @@ router bgp 64512 @c vnc redistribute ipv4 bgp-direct-to-nve-groups @c @end verbatim -@node VNC with Quagga Route Reflector Configuration -@subsection VNC with Quagga Route Reflector Configuration +@node VNC with Frr Route Reflector Configuration +@subsection VNC with Frr Route Reflector Configuration A route reflector eliminates the need for a fully meshed NVA network by acting as the hub between NVAs. -@ref{fig:fig-vnc-quagga-route-reflector} shows BGP route reflector +@ref{fig:fig-vnc-frr-route-reflector} shows BGP route reflector @code{BGP Route Reflector 1} (192.168.1.100) as a route reflector for NVAs @code{NVA 2}(192.168.1.101) and @code{NVA 3} (192.168.1.102). -@float Figure,fig:fig-vnc-quagga-route-reflector -@center @image{fig-vnc-quagga-route-reflector,400pt,,Quagga Route Reflector} +@float Figure,fig:fig-vnc-frr-route-reflector +@center @image{fig-vnc-frr-route-reflector,400pt,,Frr Route Reflector} @caption{Two NVAs and a BGP Route Reflector} @end float @@ -1298,7 +1298,7 @@ While not shown, an NVA can also be configured as a route reflector. @node VNC with Commercial Route Reflector Configuration @subsection VNC with Commercial Route Reflector Configuration -This example is identical to @ref{VNC with Quagga Route Reflector +This example is identical to @ref{VNC with Frr Route Reflector Configuration} with the exception that the route reflector is a commercial router. Only the VNC-relevant configuration is provided. @@ -1408,7 +1408,7 @@ exit @node VNC with Redundant Route Reflectors Configuration @subsection VNC with Redundant Route Reflectors Configuration -This example combines the previous two (@ref{VNC with Quagga Route +This example combines the previous two (@ref{VNC with Frr Route Reflector Configuration} and @ref{VNC with Commercial Route Reflector Configuration}) into a redundant route reflector configuration. BGP route reflectors @code{BGP Route Reflector 1} and @code{Commercial Router} @@ -1418,7 +1418,7 @@ route reflectors. @float Figure,fig:fig-vnc-redundant-route-reflectors @center @image{fig-vnc-redundant-route-reflectors,400pt,,Redundant Route Reflectors} -@caption{Quagga-based NVA with redundant route reflectors} +@caption{Frr-based NVA with redundant route reflectors} @end float @file{bgpd.conf} for @code{Bgpd Route Reflector 1} on 192.168.1.100: diff --git a/doc/vtysh.1.in b/doc/vtysh.1.in index 35a05709eb..7b5d4f132e 100644 --- a/doc/vtysh.1.in +++ b/doc/vtysh.1.in @@ -54,7 +54,7 @@ specifying '-d ospfd' will connect only to ospfd. This can be particularly useful inside scripts with -c where the command is targeted for a single daemon. .IP "\fB\-e, \-\-execute \fIcommand\fP" Alias for -c. It's here only for compatibility with Zebra routing software and -older Quagga versions. This will be removed in future. +older Frr versions. This will be removed in future. .IP "\fB\-E, \-\-echo\fP" When the -c option is being used, this flag will cause the standard .B vtysh @@ -73,11 +73,11 @@ The default location of the .B vtysh config file. .TP -.BI @CFG_SYSCONF@/Quagga.conf +.BI @CFG_SYSCONF@/Frr.conf The default location of the integrated @PACKAGE_FULLNAME@ routing engine config file if integrated config file is in use (not default). .TP -.BI ${HOME}/.history_quagga +.BI ${HOME}/.history_frr Location of history of commands entered via cli .SH WARNING This man page is intended to be a quick reference for command line diff --git a/doc/vtysh.texi b/doc/vtysh.texi index 920b39d7f5..f3ebc26a12 100644 --- a/doc/vtysh.texi +++ b/doc/vtysh.texi @@ -5,7 +5,7 @@ * Integrated configuration mode:: @end menu -@command{vtysh} provides a combined frontend to all Quagga daemons in a +@command{vtysh} provides a combined frontend to all Frr daemons in a single combined session. It is enabled by default at build time, but can be disabled through the @option{--disable-vtysh} option to @command{./configure}. @@ -30,7 +30,7 @@ that directory, plus membership in the @emph{@value{INSTALL_VTY_GROUP}} group (which is the group that the daemons will change ownership of their sockets to). -To restrict access to Quagga configuration, make sure no unauthorized users +To restrict access to Frr configuration, make sure no unauthorized users are members of the @emph{@value{INSTALL_VTY_GROUP}} group. @subsection PAM support (experimental) @@ -61,13 +61,13 @@ at all. @section Integrated configuration mode Integrated configuration mode uses a single configuration file, -@file{Quagga.conf}, for all daemons. This replaces the individual files like +@file{Frr.conf}, for all daemons. This replaces the individual files like @file{zebra.conf} or @file{bgpd.conf}. -@file{Quagga.conf} is located in @file{@value{INSTALL_PREFIX_ETC}}. All +@file{Frr.conf} is located in @file{@value{INSTALL_PREFIX_ETC}}. All daemons check for the existence of this file at startup, and if it exists will not load their individual configuration files. Instead, -@command{vtysh -b} must be invoked to process @file{Quagga.conf} and apply +@command{vtysh -b} must be invoked to process @file{Frr.conf} and apply its settings to the individual daemons. @quotation Warning @@ -76,7 +76,7 @@ its settings to the individual daemons. @subsection Configuration saving, file ownership and permissions -The @file{Quagga.conf} file is not written by any of the daemons; instead +The @file{Frr.conf} file is not written by any of the daemons; instead @command{vtysh} contains the neccessary logic to collect configuration from all of the daemons, combine it and write it out. @@ -90,7 +90,7 @@ Since the @command{vtysh} command may be running as ordinary user on the system, configuration writes will be tried through @command{watchfrr}, using the @command{write integrated} command internally. Since @command{watchfrr} is running as superuser, @command{vtysh} is able to -ensure correct ownership and permissions on @file{Quagga.conf}. +ensure correct ownership and permissions on @file{Frr.conf}. If @command{watchfrr} is not running or the configuration write fails, @command{vtysh} will attempt to directly write to the file. This is likely @@ -99,10 +99,10 @@ file with incorrect owner or permissions. Writing the configuration can be triggered directly by invoking @command{vtysh -w}. This may be useful for scripting. Note this command -should be run as either the superuser or the Quagga user. +should be run as either the superuser or the Frr user. We recommend you do not mix the use of the two types of files. Further, it -is better not to use the integrated Quagga.conf file, as any syntax error in +is better not to use the integrated Frr.conf file, as any syntax error in it can lead to /all/ of your daemons being unable to start up. Per daemon files are more robust as impact of errors in configuration are limited to the daemon in whose file the error is made. @@ -110,11 +110,11 @@ the daemon in whose file the error is made. @deffn {Command} {service integrated-vtysh-config} {} @deffnx {Command} {no service integrated-vtysh-config} {} -Control whether integrated @file{Quagga.conf} file is written when +Control whether integrated @file{Frr.conf} file is written when 'write file' is issued. These commands need to be placed in @file{vtysh.conf} to have any effect. -Note that since @file{vtysh.conf} is not written by Quagga itself, they +Note that since @file{vtysh.conf} is not written by Frr itself, they therefore need to be manually placed in that file. This command has 3 states: @@ -122,18 +122,18 @@ This command has 3 states: @item @command{service integrated-vtysh-config} -@command{vtysh} will always write @file{Quagga.conf}. +@command{vtysh} will always write @file{Frr.conf}. @item @command{no service integrated-vtysh-config} -@command{vtysh} will never write @file{Quagga.conf}; instead it will ask +@command{vtysh} will never write @file{Frr.conf}; instead it will ask daemons to write their individual configuration files. @item Neither option present (default) -@command{vtysh} will check whether @file{Quagga.conf} exists. If it does, +@command{vtysh} will check whether @file{Frr.conf} exists. If it does, configuration writes will update that file. Otherwise, writes are performed through the individual daemons. @end itemize @@ -146,7 +146,7 @@ installations. @deffn {Command} {write integrated} {} Unconditionally (regardless of @command{service integrated-vtysh-config} -setting) write out integrated @file{Quagga.conf} file through +setting) write out integrated @file{Frr.conf} file through @command{watchfrr}. If @command{watchfrr} is not running, this command is unavailable. @@ -156,6 +156,6 @@ is unavailable. Configuration changes made while some daemon is not running will be invisible to that daemon. The daemon will start up with its saved configuration -(either in its individual configuration file, or in @file{Quagga.conf}). +(either in its individual configuration file, or in @file{Frr.conf}). This is particularly troublesome for route-maps and prefix lists, which would otherwise be synchronized between daemons. From 80e71dcd1fffe1126954d30c13897d90512329fa Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 4 Jan 2017 08:03:14 -0500 Subject: [PATCH 053/107] lib: Update ZAPI to version 4 and HEADER_MARKER to 254 Update the ZEBRA_HEADER_MARKER to 254. This will differentiate ourselves from Quagga. Zebra should not listen to people not properly using the right programs now. Update the ZAPI version number to 4. Signed-off-by: Donald Sharp --- doc/protocol.texi | 7 +++++-- lib/zclient.h | 2 +- lib/zebra.h | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/doc/protocol.texi b/doc/protocol.texi index f2c8da4301..7e8a96dc5d 100644 --- a/doc/protocol.texi +++ b/doc/protocol.texi @@ -25,8 +25,11 @@ enough to allow for future extensions to done compatibly through seperate commands. Version 0 is used by all versions of GNU Zebra as of this writing, and -versions of Quagga up to and including Quagga 0.98. Version 1 will be -used as of Quagga 1.0. Version 2 will be used as of Frr 2.0. +versions of Quagga up to and including Quagga 0.98. Version 2 was created +for 0.99.21 of Quagga. Version 3 designates VRF compatibility and was +released in 1.0. Version 4 will be used as of Frr 2.0 to indicate that +we are a different Routing Suite now and to hopefully prevent accidental +Quagga <-> FRR issues. @appendixsection Zebra Protocol Definition @appendixsubsec Zebra Protocol Header (version 0) diff --git a/lib/zclient.h b/lib/zclient.h index 7ea5bc963a..4312cdc83c 100644 --- a/lib/zclient.h +++ b/lib/zclient.h @@ -123,7 +123,7 @@ struct zserv_header * always set to 255 in new zserv. */ uint8_t version; -#define ZSERV_VERSION 3 +#define ZSERV_VERSION 4 vrf_id_t vrf_id; uint16_t command; }; diff --git a/lib/zebra.h b/lib/zebra.h index a67713c30d..420f237176 100644 --- a/lib/zebra.h +++ b/lib/zebra.h @@ -411,7 +411,7 @@ typedef enum { * the command value in the old zserv header. To allow old and new * Zserv headers to be distinguished from each other. */ -#define ZEBRA_HEADER_MARKER 255 +#define ZEBRA_HEADER_MARKER 254 /* Zebra route's types are defined in route_types.h */ #include "route_types.h" From d8e4c43827fab188dcfd98fe18bc75d8479d723e Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Wed, 4 Jan 2017 09:25:20 -0500 Subject: [PATCH 054/107] debian: Convert Quagga -> Frr Signed-off-by: Donald Sharp --- debian/README.Debian | 50 ++++++------- debian/README.Maintainer | 16 ++--- debian/changelog | 4 ++ debian/control | 30 ++++---- debian/copyright | 6 +- debian/{quagga-doc.docs => frr-doc.docs} | 0 debian/frr-doc.info | 1 + .../{quagga-doc.install => frr-doc.install} | 0 debian/frr-doc.lintian-overrides | 1 + debian/frr.conf | 2 + debian/{quagga.config => frr.config} | 0 debian/frr.dirs | 7 ++ debian/{quagga.docs => frr.docs} | 0 debian/{quagga.install => frr.install} | 14 ++-- debian/frr.lintian-overrides | 4 ++ debian/{quagga.logrotate => frr.logrotate} | 8 +-- debian/{quagga.manpages => frr.manpages} | 0 debian/{quagga.pam => frr.pam} | 2 +- debian/frr.postinst | 41 +++++++++++ debian/{quagga.postrm => frr.postrm} | 4 +- debian/{quagga.preinst => frr.preinst} | 54 +++++++------- debian/{quagga.prerm => frr.prerm} | 2 +- debian/quagga-doc.info | 1 - debian/quagga-doc.lintian-overrides | 1 - debian/quagga.conf | 2 - debian/quagga.dirs | 7 -- debian/quagga.lintian-overrides | 4 -- debian/quagga.postinst | 41 ----------- debian/rules | 38 +++++----- debian/tests/control | 2 +- debian/tests/daemons | 10 +-- debian/watch | 2 +- debian/watchfrr.rc | 4 ++ debian/watchquagga.rc | 4 -- redhat/quagga.spec.in | 14 ++-- tools/Makefile.am | 4 +- tools/{quagga => frr} | 72 +++++++++---------- tools/{quagga-reload.py => frr-reload.py} | 66 ++++++++--------- tools/{quagga.service => frr.service} | 10 +-- 39 files changed, 264 insertions(+), 264 deletions(-) rename debian/{quagga-doc.docs => frr-doc.docs} (100%) create mode 100644 debian/frr-doc.info rename debian/{quagga-doc.install => frr-doc.install} (100%) create mode 100644 debian/frr-doc.lintian-overrides create mode 100644 debian/frr.conf rename debian/{quagga.config => frr.config} (100%) create mode 100644 debian/frr.dirs rename debian/{quagga.docs => frr.docs} (100%) rename debian/{quagga.install => frr.install} (66%) create mode 100644 debian/frr.lintian-overrides rename debian/{quagga.logrotate => frr.logrotate} (59%) rename debian/{quagga.manpages => frr.manpages} (100%) rename debian/{quagga.pam => frr.pam} (91%) create mode 100644 debian/frr.postinst rename debian/{quagga.postrm => frr.postrm} (70%) rename debian/{quagga.preinst => frr.preinst} (56%) rename debian/{quagga.prerm => frr.prerm} (89%) delete mode 100644 debian/quagga-doc.info delete mode 100644 debian/quagga-doc.lintian-overrides delete mode 100644 debian/quagga.conf delete mode 100644 debian/quagga.dirs delete mode 100644 debian/quagga.lintian-overrides delete mode 100644 debian/quagga.postinst create mode 100644 debian/watchfrr.rc delete mode 100644 debian/watchquagga.rc rename tools/{quagga => frr} (88%) rename tools/{quagga-reload.py => frr-reload.py} (93%) rename tools/{quagga.service => frr.service} (56%) diff --git a/debian/README.Debian b/debian/README.Debian index 7bec53230f..fb481eb456 100644 --- a/debian/README.Debian +++ b/debian/README.Debian @@ -2,34 +2,34 @@ ================== Please consider setting this package "on hold" by typing - echo "quagga hold" | dpkg --set-selections + echo "frr hold" | dpkg --set-selections and verifying this using dpkg --get-selections | grep 'hold$' Setting a package "on hold" means that it will not automatically be upgraded. Instead apt-get only displays a warning saying that a new version would be -available forcing you to explicitly type "apt-get install quagga" to upgrade it. +available forcing you to explicitly type "apt-get install frr" to upgrade it. -* What is quagga? +* What is frr? ================= -http://www.quagga.net/ -> Quagga is a routing software suite, providing implementations of OSPFv2, +http://www.freerangerouting.net/ +> Frr is a routing software suite, providing implementations of OSPFv2, > OSPFv3, RIP v1 and v2, RIPv3 and BGPv4 for Unix platforms, particularly -> FreeBSD and Linux and also NetBSD, to mention a few. Quagga is a fork of GNU +> FreeBSD and Linux and also NetBSD, to mention a few. Frr is a fork of GNU > Zebra which was developed by Kunihiro Ishiguro. Development of GNU Zebra > slowed dramatically to the point where eventually GNU Zebra was forked into -> Quagga. +> Frr. -> The Quagga tree is an attempt to provide a zebra tree with at least the +> The Frr tree is an attempt to provide a zebra tree with at least the > bug-fixes, which have accumulated, applied, while tracking any significant > changes made to the zebra.org tree. Ultimately, this tree hopes to revitalise > development of this code base. -I packaged zebra-pj which was then renamed to quagga to get people used to it +I packaged zebra-pj which was then renamed to frr to get people used to it and offer Debian users the choice which versions they like to use. I hope this -brings quagga some feedback and helps it evolving to a good successor of the +brings frr some feedback and helps it evolving to a good successor of the orphaned zebra. -- Christian Hammers , Jul/Aug 2003 @@ -37,16 +37,16 @@ orphaned zebra. * Why has SNMP support been disabled? ===================================== -Quagga used to link against the NetSNMP libraries to provide SNMP +Frr used to link against the NetSNMP libraries to provide SNMP support. Those libraries sadly link against the OpenSSL libraries to provide crypto support for SNMPv3 among others. OpenSSL now is not compatible with the GNU GENERAL PUBLIC LICENSE (GPL) -licence that Quagga is distributed under. For more explanation read: +licence that Frr is distributed under. For more explanation read: http://www.gnome.org/~markmc/openssl-and-the-gpl.html http://www.gnu.org/licenses/gpl-faq.html#GPLIncompatibleLibs Updating the licence to explecitly allow linking against OpenSSL would requite the affirmation of all people that ever contributed -a significant part to Zebra or Quagga and thus are the collective +a significant part to Zebra or Frr and thus are the collective "copyright holder". That's too much work. Using a shrinked down version of NetSNMP without OpenSSL or convincing the NetSNMP people to change to GnuTLS are maybe good solutions but not reachable @@ -55,17 +55,17 @@ during the last days before the Sarge release :-( *BUT* It is allowed by the used licence mix that you fetch the sources and -build Quagga yourself with SNMP with - +build Frr yourself with SNMP with + # export WANT_SNMP=1 - # apt-get -b source quagga + # apt-get -b source frr Just distributing it in binary form, linked against OpenSSL, is forbidden. * Daemon selection: =================== -The Debian package uses /etc/quagga/daemons to tell the +The Debian package uses /etc/frr/daemons to tell the initscript which daemons to start. It's in the format = with no spaces (it's simply source-d into the initscript). @@ -73,13 +73,13 @@ Default is not to start anything, since it can hose your system's routing table if not set up properly. Priorities were suggested by Dancer . -They're used to start the Quagga daemons in more than one step +They're used to start the Frr daemons in more than one step (for example start one or two at network initialization and the -rest later). The number of Quagga daemons being small, priorities +rest later). The number of Frr daemons being small, priorities must be between 1 and 9, inclusive (or the initscript has to be -changed). /etc/init.d/quagga then can be started as +changed). /etc/init.d/frr then can be started as -/etc/init.d/quagga > +/etc/init.d/frr > where priority 0 is the same as 'stop', priority 10 or 'start' means 'start all' @@ -96,15 +96,15 @@ into the kernel. ===================================================================== If this message occurs the receive buffer should be increased by adding the -following to /etc/sysctl.conf and "--nl-bufsize" to /etc/quagga/debian.conf. +following to /etc/sysctl.conf and "--nl-bufsize" to /etc/frr/debian.conf. > net.core.rmem_default = 262144 > net.core.rmem_max = 262144 -See message #4525 from 2005-05-09 in the quagga-users mailing list. +See message #4525 from 2005-05-09 in the frr-users mailing list. * vtysh immediately exists: =========================== -Check /etc/pam.d/quagga, it probably denies access to your user. The passwords -configured in /etc/quagga/Quagga.conf are only for telnet access. +Check /etc/pam.d/frr, it probably denies access to your user. The passwords +configured in /etc/frr/Frr.conf are only for telnet access. diff --git a/debian/README.Maintainer b/debian/README.Maintainer index b0b1e62b34..aa8ac0cf35 100644 --- a/debian/README.Maintainer +++ b/debian/README.Maintainer @@ -4,19 +4,19 @@ for i in debian/patches/*.diff; do echo -e "#\n# $i\n#"; patch --fuzz=3 --dry-run -p1 < $i; done # -# Filename transition from zebra to quagga +# Filename transition from zebra to frr # Files that keep their names /usr/bin/vtysh Files that got an -pj suffix - /etc/default/zebra -> /etc/quagga/debian.conf - /etc/init.d/zebra -> /etc/init.d/quagga - /etc/zebra/ -> /etc/quagga/ - /usr/share/doc/zebra/ -> /usr/share/doc/quagga/ - /var/log/zebra/ -> /var/log/quagga/ - /var/run/ -> /var/run/quagga/ + /etc/default/zebra -> /etc/frr/debian.conf + /etc/init.d/zebra -> /etc/init.d/frr + /etc/zebra/ -> /etc/frr/ + /usr/share/doc/zebra/ -> /usr/share/doc/frr/ + /var/log/zebra/ -> /var/log/frr/ + /var/run/ -> /var/run/frr/ Files that were moved - /usr/sbin/* -> /usr/lib/quagga/ + /usr/sbin/* -> /usr/lib/frr/ diff --git a/debian/changelog b/debian/changelog index f17f89eaff..ef019b4d23 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,7 @@ +frr (2.0) Released; urgency=medium + + * Switchover to FRR + quagga (0.99.24+cl3u5) RELEASED; urgency=medium * Closes: CM-12846 - Resolve Memory leaks in 'show ip bgp neighbor json' diff --git a/debian/control b/debian/control index dd0013e82f..578795d998 100644 --- a/debian/control +++ b/debian/control @@ -1,14 +1,14 @@ -Source: quagga +Source: frr Section: net Priority: optional Maintainer: Christian Hammers Uploaders: Florian Weimer Build-Depends: debhelper (>= 7.0.50~), libncurses5-dev, libreadline-dev, texlive-latex-base, texlive-generic-recommended, libpam0g-dev | libpam-dev, libcap-dev, texinfo (>= 4.7), imagemagick, ghostscript, groff, po-debconf, autotools-dev, hardening-wrapper, libpcre3-dev, gawk, chrpath, libsnmp-dev, git, dh-autoreconf, libjson0, libjson0-dev, dh-systemd, libsystemd-dev, python-ipaddr Standards-Version: 3.9.6 -Homepage: http://www.quagga.net/ +Homepage: http://www.frr.net/ XS-Testsuite: autopkgtest -Package: quagga +Package: frr Architecture: any Depends: ${shlibs:Depends}, logrotate (>= 3.2-11), iproute, ${misc:Depends} Pre-Depends: adduser @@ -16,37 +16,33 @@ Conflicts: zebra, zebra-pj Replaces: zebra, zebra-pj Suggests: snmpd Description: BGP/OSPF/RIP routing daemon - GNU Quagga is free software which manages TCP/IP based routing protocols. + Frr is free software which manages TCP/IP based routing protocols. It supports BGP4, BGP4+, OSPFv2, OSPFv3, IS-IS, RIPv1, RIPv2, and RIPng as well as the IPv6 versions of these. . - As the precessor Zebra has been considered orphaned, the Quagga project - has been formed by members of the zebra mailing list and the former - zebra-pj project to continue developing. - . - Quagga uses threading if the kernel supports it, but can also run on + Frr uses threading if the kernel supports it, but can also run on kernels that do not support threading. Each protocol has its own daemon. . It is more than a routed replacement, it can be used as a Route Server and a Route Reflector. -Package: quagga-dbg +Package: frr-dbg Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, quagga (= ${binary:Version}) +Depends: ${shlibs:Depends}, ${misc:Depends}, frr (= ${binary:Version}) Priority: extra Section: debug Description: BGP/OSPF/RIP routing daemon (debug symbols) This package provides debugging symbols for all binary packages built from - quagga source package. It's highly recommended to have this package installed - before reporting any Quagga crashes to either Quagga developers or Debian + frr source package. It's highly recommended to have this package installed + before reporting any Frr crashes to either Frr developers or Debian package maintainers. -Package: quagga-doc +Package: frr-doc Section: net Architecture: all Depends: ${misc:Depends} -Suggests: quagga -Description: documentation files for quagga - This package includes info files for quagga, a free software which manages +Suggests: frr +Description: documentation files for frr + This package includes info files for frr, a free software which manages TCP/IP based routing protocols. It supports BGP4, BGP4+, OSPFv2, OSPFv3, IS-IS, RIPv1, RIPv2, and RIPng as well as the IPv6 versions of these. diff --git a/debian/copyright b/debian/copyright index 22434fb255..ab392027c8 100644 --- a/debian/copyright +++ b/debian/copyright @@ -1,7 +1,7 @@ Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ -Upstream-Name: Quagga -Upstream-Contact: maintainers@quagga.net, security@quagga.net -Source: http://www.quagga.net/ +Upstream-Name: Frr +Upstream-Contact: maintainers@freerangerouting.net, security@freerangerouting.net +Source: http://www.freerangerouting.net/ Files: * Copyright: 1996-2003 by the original Zebra authors: diff --git a/debian/quagga-doc.docs b/debian/frr-doc.docs similarity index 100% rename from debian/quagga-doc.docs rename to debian/frr-doc.docs diff --git a/debian/frr-doc.info b/debian/frr-doc.info new file mode 100644 index 0000000000..c4f181cdb0 --- /dev/null +++ b/debian/frr-doc.info @@ -0,0 +1 @@ +doc/frr.info* diff --git a/debian/quagga-doc.install b/debian/frr-doc.install similarity index 100% rename from debian/quagga-doc.install rename to debian/frr-doc.install diff --git a/debian/frr-doc.lintian-overrides b/debian/frr-doc.lintian-overrides new file mode 100644 index 0000000000..1fe64ffd53 --- /dev/null +++ b/debian/frr-doc.lintian-overrides @@ -0,0 +1 @@ +frr-doc: wrong-section-according-to-package-name frr-doc => doc diff --git a/debian/frr.conf b/debian/frr.conf new file mode 100644 index 0000000000..dee3cd849a --- /dev/null +++ b/debian/frr.conf @@ -0,0 +1,2 @@ +# Create the /run/frr directory at boot or from systemd-tmpfiles on install +d /run/frr 0755 frr frr diff --git a/debian/quagga.config b/debian/frr.config similarity index 100% rename from debian/quagga.config rename to debian/frr.config diff --git a/debian/frr.dirs b/debian/frr.dirs new file mode 100644 index 0000000000..58290080d0 --- /dev/null +++ b/debian/frr.dirs @@ -0,0 +1,7 @@ +etc/logrotate.d/ +etc/frr/ +usr/share/doc/frr/ +usr/share/doc/frr/examples/ +usr/share/lintian/overrides/ +usr/share/snmp/mibs/ +var/log/frr/ diff --git a/debian/quagga.docs b/debian/frr.docs similarity index 100% rename from debian/quagga.docs rename to debian/frr.docs diff --git a/debian/quagga.install b/debian/frr.install similarity index 66% rename from debian/quagga.install rename to debian/frr.install index 022bd94ec7..45b3b973be 100644 --- a/debian/quagga.install +++ b/debian/frr.install @@ -1,12 +1,12 @@ -etc/quagga/ +etc/frr/ usr/bin/vtysh -usr/include/quagga/ +usr/include/frr/ usr/lib/ -tools/quagga-reload.py usr/lib/quagga/ -tools/quagga usr/lib/quagga -usr/share/doc/quagga/ +tools/frr-reload.py usr/lib/frr/ +tools/frr usr/lib/frr +usr/share/doc/frr/ usr/share/man/man1/vtysh.1 -usr/share/man/man1/quagga.1 +usr/share/man/man1/frr.1 usr/share/man/man8 usr/share/man/man8/bgpd.8 usr/share/man/man8/ospf6d.8 @@ -19,4 +19,4 @@ usr/share/man/man8/watchfrr.8 usr/share/snmp/mibs/ cumulus/etc/* etc/ tools/*.service lib/systemd/system -debian/quagga.conf usr/lib/tmpfiles.d +debian/frr.conf usr/lib/tmpfiles.d diff --git a/debian/frr.lintian-overrides b/debian/frr.lintian-overrides new file mode 100644 index 0000000000..42a51b5e69 --- /dev/null +++ b/debian/frr.lintian-overrides @@ -0,0 +1,4 @@ +frr: non-dev-pkg-with-shlib-symlink usr/lib/libospfapiclient.so.0.0.0 usr/lib/libospfapiclient.so +frr: non-dev-pkg-with-shlib-symlink usr/lib/libospf.so.0.0.0 usr/lib/libospf.so +frr: non-dev-pkg-with-shlib-symlink usr/lib/libzebra.so.0.0.0 usr/lib/libzebra.so +frr: package-name-doesnt-match-sonames libospf0 libospfapiclient0 libzebra0 diff --git a/debian/quagga.logrotate b/debian/frr.logrotate similarity index 59% rename from debian/quagga.logrotate rename to debian/frr.logrotate index 77e015d725..0dd68fb257 100644 --- a/debian/quagga.logrotate +++ b/debian/frr.logrotate @@ -1,15 +1,15 @@ -/var/log/quagga/*.log { +/var/log/frr/*.log { size 500k sharedscripts missingok compress rotate 14 - create 640 quagga quaggavty + create 640 frr frrvty postrotate for i in zebra bgpd ripd ospfd ripngd ospf6d isisd pimd; do - if [ -e /var/run/quagga/$i.pid ] ; then - kill -USR1 `cat /var/run/quagga/$i.pid` + if [ -e /var/run/frr/$i.pid ] ; then + kill -USR1 `cat /var/run/frr/$i.pid` fi done diff --git a/debian/quagga.manpages b/debian/frr.manpages similarity index 100% rename from debian/quagga.manpages rename to debian/frr.manpages diff --git a/debian/quagga.pam b/debian/frr.pam similarity index 91% rename from debian/quagga.pam rename to debian/frr.pam index 093e172946..2b106d43bc 100644 --- a/debian/quagga.pam +++ b/debian/frr.pam @@ -1,3 +1,3 @@ -# Any user may call vtysh but only those belonging to the group quaggavty can +# Any user may call vtysh but only those belonging to the group frrvty can # actually connect to the socket and use the program. auth sufficient pam_permit.so diff --git a/debian/frr.postinst b/debian/frr.postinst new file mode 100644 index 0000000000..43d3ffa9e0 --- /dev/null +++ b/debian/frr.postinst @@ -0,0 +1,41 @@ +#!/bin/bash -e + +###################### +PASSWDFILE=/etc/passwd +GROUPFILE=/etc/group + +frruid=`egrep "^frr:" $PASSWDFILE | awk -F ":" '{ print $3 }'` +frrgid=`egrep "^frr:" $GROUPFILE | awk -F ":" '{ print $3 }'` +frrvtygid=`egrep "^frrvty:" $GROUPFILE | awk -F ":" '{ print $3 }'` + +[ -n ${frruid} ] || (echo "No uid for frr in ${PASSWDFILE}" && /bin/false) +[ -n ${frrgid} ] || (echo "No gid for frr in ${GROUPFILE}" && /bin/false) +[ -n ${frrVTYgid} ] || (echo "No gid for frrvty in ${GROUPFILE}" && /bin/false) + +chown -R ${frruid}:${frrgid} /etc/frr +touch /etc/frr/vtysh.conf +chgrp ${frrvtygid} /etc/frr/vtysh* +chmod 440 /etc/sudoers.d/frr_sudoers +chmod 644 /etc/frr/* + +ENVIRONMENTFILE=/etc/environment +if ! grep --quiet VTYSH_PAGER=/bin/cat ${ENVIRONMENTFILE}; then + echo "VTYSH_PAGER=/bin/cat" >> ${ENVIRONMENTFILE} +fi +################################################## + +if [ -n "$DEBIAN_SCRIPT_DEBUG" ]; then set -v -x; DEBIAN_SCRIPT_TRACE=1; fi +${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*"} + +# This is most likely due to the answer "no" to the "really stop the server" +# question in the prerm script. +if [ "$1" = "abort-upgrade" ]; then + exit 0 +fi + +. /usr/share/debconf/confmodule + +db_stop + +#DEBHELPER# + diff --git a/debian/quagga.postrm b/debian/frr.postrm similarity index 70% rename from debian/quagga.postrm rename to debian/frr.postrm index 1c69e4899d..26576fd136 100644 --- a/debian/quagga.postrm +++ b/debian/frr.postrm @@ -5,8 +5,8 @@ ${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*"} # set -u not because of debhelper if [ "$1" = "purge" ]; then - rm -rf /etc/quagga /var/run/quagga /var/log/quagga - userdel quagga >/dev/null 2>&1 || true + rm -rf /etc/frr /var/run/frr /var/log/frr + userdel frr >/dev/null 2>&1 || true fi #DEBHELPER# diff --git a/debian/quagga.preinst b/debian/frr.preinst similarity index 56% rename from debian/quagga.preinst rename to debian/frr.preinst index 1af0b5ba63..abdaa7277b 100644 --- a/debian/quagga.preinst +++ b/debian/frr.preinst @@ -5,73 +5,73 @@ ${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*"} set -e set -u -# creating quaggavty group if it isn't already there -if ! getent group quaggavty >/dev/null; then - addgroup --system quaggavty >/dev/null +# creating frrvty group if it isn't already there +if ! getent group frrvty >/dev/null; then + addgroup --system frrvty >/dev/null fi -# creating quagga group if it isn't already there -if ! getent group quagga >/dev/null; then - addgroup --system quagga >/dev/null +# creating frr group if it isn't already there +if ! getent group frr >/dev/null; then + addgroup --system frr >/dev/null fi -# creating quagga user if he isn't already there -if ! getent passwd quagga >/dev/null; then +# creating frr user if he isn't already there +if ! getent passwd frr >/dev/null; then adduser \ --system \ - --ingroup quagga \ - --home /var/run/quagga/ \ - --gecos "Quagga routing suite" \ + --ingroup frr \ + --home /var/run/frr/ \ + --gecos "Frr routing suite" \ --shell /bin/false \ - quagga >/dev/null + frr >/dev/null fi # We may be installing over an older version of -# quagga and as such we need to intelligently -# check to see if the quagga user is in the quaggavty +# frr and as such we need to intelligently +# check to see if the frr user is in the frrvty # group. -if ! /usr/bin/id quagga | grep &>/dev/null 'quaggavty'; then - usermod -a -G quaggavty quagga >/dev/null +if ! /usr/bin/id frr | grep &>/dev/null 'frrvty'; then + usermod -a -G frrvty frr >/dev/null fi # Do not change permissions when upgrading as it would violate policy. if [ "$1" = "install" ]; then - # Logfiles are group readable in case users were put into the quagga group. - d=/var/log/quagga/ + # Logfiles are group readable in case users were put into the frr group. + d=/var/log/frr/ mkdir -p $d - chown -R quagga:quagga $d + chown -R frr:frr $d chmod u=rwx,go=rx $d find $d -type f -print0 | xargs -0 --no-run-if-empty chmod u=rw,g=r,o= # Strict permissions for the sockets. - d=/var/run/quagga/ + d=/var/run/frr/ mkdir -p $d - chown -R quagga:quagga $d + chown -R frr:frr $d chmod u=rwx,go=rx $d find $d -type f -print0 | xargs -0 --no-run-if-empty chmod u=rw,go= # Config files. Vtysh does not have access to the individual daemons config file - d=/etc/quagga/ + d=/etc/frr/ mkdir -p $d - chown quagga:quaggavty $d + chown frr:frrvty $d chmod ug=rwx,o=rx $d - find $d -type f -print0 | xargs -0 --no-run-if-empty chown quagga:quagga + find $d -type f -print0 | xargs -0 --no-run-if-empty chown frr:frr find $d -type f -print0 | xargs -0 --no-run-if-empty chmod u=rw,g=r,o= # Exceptions for vtysh. f=$d/vtysh.conf if [ -f $f ]; then - chown quagga:quaggavty $f + chown frr:frrvty $f chmod u=rw,g=r,o= $f fi # Exceptions for vtysh. - f=$d/Quagga.conf + f=$d/Frr.conf if [ -f $d/Zebra.conf ]; then mv $d/Zebra.conf $f fi if [ -f $f ]; then - chown quagga:quaggavty $f + chown frr:frrvty $f chmod u=rw,g=r,o= $f fi fi diff --git a/debian/quagga.prerm b/debian/frr.prerm similarity index 89% rename from debian/quagga.prerm rename to debian/frr.prerm index 9775412253..e0df24e10f 100644 --- a/debian/quagga.prerm +++ b/debian/frr.prerm @@ -15,7 +15,7 @@ case $1 in ;; failed-upgrade) - # If quagga/really_stop was negated then this script exits with return + # If frr/really_stop was negated then this script exits with return # code 1 and is called again with "failed-upgrade". Well, exit again. exit 1 ;; diff --git a/debian/quagga-doc.info b/debian/quagga-doc.info deleted file mode 100644 index c9ff0f55fc..0000000000 --- a/debian/quagga-doc.info +++ /dev/null @@ -1 +0,0 @@ -doc/quagga.info* diff --git a/debian/quagga-doc.lintian-overrides b/debian/quagga-doc.lintian-overrides deleted file mode 100644 index afa3c64ad3..0000000000 --- a/debian/quagga-doc.lintian-overrides +++ /dev/null @@ -1 +0,0 @@ -quagga-doc: wrong-section-according-to-package-name quagga-doc => doc diff --git a/debian/quagga.conf b/debian/quagga.conf deleted file mode 100644 index 04d8eea57f..0000000000 --- a/debian/quagga.conf +++ /dev/null @@ -1,2 +0,0 @@ -# Create the /run/quagga directory at boot or from systemd-tmpfiles on install -d /run/quagga 0755 quagga quagga diff --git a/debian/quagga.dirs b/debian/quagga.dirs deleted file mode 100644 index 581074f8fc..0000000000 --- a/debian/quagga.dirs +++ /dev/null @@ -1,7 +0,0 @@ -etc/logrotate.d/ -etc/quagga/ -usr/share/doc/quagga/ -usr/share/doc/quagga/examples/ -usr/share/lintian/overrides/ -usr/share/snmp/mibs/ -var/log/quagga/ diff --git a/debian/quagga.lintian-overrides b/debian/quagga.lintian-overrides deleted file mode 100644 index aee52a1eba..0000000000 --- a/debian/quagga.lintian-overrides +++ /dev/null @@ -1,4 +0,0 @@ -quagga: non-dev-pkg-with-shlib-symlink usr/lib/libospfapiclient.so.0.0.0 usr/lib/libospfapiclient.so -quagga: non-dev-pkg-with-shlib-symlink usr/lib/libospf.so.0.0.0 usr/lib/libospf.so -quagga: non-dev-pkg-with-shlib-symlink usr/lib/libzebra.so.0.0.0 usr/lib/libzebra.so -quagga: package-name-doesnt-match-sonames libospf0 libospfapiclient0 libzebra0 diff --git a/debian/quagga.postinst b/debian/quagga.postinst deleted file mode 100644 index 4611313c1d..0000000000 --- a/debian/quagga.postinst +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash -e - -###################### -PASSWDFILE=/etc/passwd -GROUPFILE=/etc/group - -quaggauid=`egrep "^quagga:" $PASSWDFILE | awk -F ":" '{ print $3 }'` -quaggagid=`egrep "^quagga:" $GROUPFILE | awk -F ":" '{ print $3 }'` -quaggavtygid=`egrep "^quaggavty:" $GROUPFILE | awk -F ":" '{ print $3 }'` - -[ -n ${quaggauid} ] || (echo "No uid for quagga in ${PASSWDFILE}" && /bin/false) -[ -n ${quaggagid} ] || (echo "No gid for quagga in ${GROUPFILE}" && /bin/false) -[ -n ${quaggaVTYgid} ] || (echo "No gid for quaggavty in ${GROUPFILE}" && /bin/false) - -chown -R ${quaggauid}:${quaggagid} /etc/quagga -touch /etc/quagga/vtysh.conf -chgrp ${quaggavtygid} /etc/quagga/vtysh* -chmod 440 /etc/sudoers.d/quagga_sudoers -chmod 644 /etc/quagga/* - -ENVIRONMENTFILE=/etc/environment -if ! grep --quiet VTYSH_PAGER=/bin/cat ${ENVIRONMENTFILE}; then - echo "VTYSH_PAGER=/bin/cat" >> ${ENVIRONMENTFILE} -fi -################################################## - -if [ -n "$DEBIAN_SCRIPT_DEBUG" ]; then set -v -x; DEBIAN_SCRIPT_TRACE=1; fi -${DEBIAN_SCRIPT_TRACE:+ echo "#42#DEBUG# RUNNING $0 $*"} - -# This is most likely due to the answer "no" to the "really stop the server" -# question in the prerm script. -if [ "$1" = "abort-upgrade" ]; then - exit 0 -fi - -. /usr/share/debconf/confmodule - -db_stop - -#DEBHELPER# - diff --git a/debian/rules b/debian/rules index b100813182..42c0d5f63a 100755 --- a/debian/rules +++ b/debian/rules @@ -20,10 +20,10 @@ MAKEFLAGS += -j$(DEBIAN_JOBS) endif %: - dh $@ --with=systemd,autoreconf --parallel --dbg-package=quagga-dbg --list-missing + dh $@ --with=systemd,autoreconf --parallel --dbg-package=frr-dbg --list-missing override_dh_auto_configure: - # Quagga needs /proc to check some BSD vs Linux specific stuff. + # Frr needs /proc to check some BSD vs Linux specific stuff. # Else it fails with an obscure error message pointing out that # IPCTL_FORWARDING is an undefined symbol which is not very helpful. @if ! [ -d /proc/1 ]; then \ @@ -33,18 +33,18 @@ override_dh_auto_configure: if ! [ -e config.status ]; then \ dh_auto_configure -- \ - --enable-exampledir=/usr/share/doc/quagga/examples/ \ - --localstatedir=/var/run/quagga \ - --sbindir=/usr/lib/quagga \ - --sysconfdir=/etc/quagga \ + --enable-exampledir=/usr/share/doc/frr/examples/ \ + --localstatedir=/var/run/frr \ + --sbindir=/usr/lib/frr \ + --sysconfdir=/etc/frr \ $(USE_SNMP) \ --enable-ospfapi=yes \ --enable-vtysh=yes \ --enable-isisd=yes \ --enable-multipath=256 \ - --enable-user=quagga \ - --enable-group=quagga \ - --enable-vty-group=quaggavty \ + --enable-user=frr \ + --enable-group=frr \ + --enable-vty-group=frrvty \ --enable-configfile-mask=0640 \ --enable-logfile-mask=0640 \ --enable-werror \ @@ -53,7 +53,7 @@ override_dh_auto_configure: --enable-systemd=yes \ --enable-poll=yes \ --enable-cumulus=yes \ - --enable-pimd=no \ + --enable-pimd=yes \ --enable-dependency-tracking \ --enable-bgp-vnc=no; \ fi @@ -66,11 +66,11 @@ override_dh_auto_build: # doc/ is a bit crazy ifeq ($(GENERATE_PDF), 1) - dh_auto_build -- -C doc quagga.pdf || true # pdfetex fails with exit code 1 but still produces a good looking .pdf + dh_auto_build -- -C doc frr.pdf || true # pdfetex fails with exit code 1 but still produces a good looking .pdf endif - rm -vf doc/quagga.info - dh_auto_build -- -C doc quagga.info - rm -vf doc/quagga.info.html* + rm -vf doc/frr.info + dh_auto_build -- -C doc frr.info + rm -vf doc/frr.info.html* override_dh_auto_test: @@ -81,18 +81,18 @@ override_dh_auto_install: rm -f debian/tmp/usr/share/info/dir* # install config files - mkdir -p debian/tmp/etc/quagga/ - perl -pi -e 's#^!log file #!log file /var/log/quagga/#' debian/tmp/usr/share/doc/quagga/examples/*sample* + mkdir -p debian/tmp/etc/frr/ + perl -pi -e 's#^!log file #!log file /var/log/frr/#' debian/tmp/usr/share/doc/frr/examples/*sample* - # installing the Quagga specific SNMP MIB + # installing the Frr specific SNMP MIB install -D -m 644 ./zebra/GNOME-PRODUCT-ZEBRA-MIB debian/tmp/usr/share/snmp/mibs/GNOME-PRODUCT-ZEBRA-MIB # cleaning .la files sed -i "/dependency_libs/ s/'.*'/''/" debian/tmp/usr/lib/*.la override_dh_systemd_start: - dh_systemd_start quagga.service + dh_systemd_start frr.service override_dh_systemd_enable: - dh_systemd_enable quagga.service + dh_systemd_enable frr.service diff --git a/debian/tests/control b/debian/tests/control index 1993e371f0..53fd537e2e 100644 --- a/debian/tests/control +++ b/debian/tests/control @@ -1,3 +1,3 @@ Tests: daemons -Depends: quagga +Depends: frr Restrictions: needs-root diff --git a/debian/tests/daemons b/debian/tests/daemons index 52c156a1d6..ac35ecd950 100644 --- a/debian/tests/daemons +++ b/debian/tests/daemons @@ -1,21 +1,21 @@ #!/bin/bash #--------------- -# Testing quagga +# Testing frr #--------------- set -e # modify config file to enable all daemons and copy config files -CONFIG_FILE=/etc/quagga/daemons +CONFIG_FILE=/etc/frr/daemons DAEMONS=("zebra" "bgpd" "ospfd" "ospf6d" "ripd" "ripngd" "isisd" "pimd") for daemon in "${DAEMONS[@]}" do sed -i -e "s/${daemon}=no/${daemon}=yes/g" $CONFIG_FILE - cp /usr/share/doc/quagga/examples/${daemon}.conf.sample /etc/quagga/${daemon}.conf + cp /usr/share/doc/frr/examples/${daemon}.conf.sample /etc/frr/${daemon}.conf done -# reload quagga -/etc/init.d/quagga restart > /dev/null 2>&1 +# reload frr +/etc/init.d/frr restart > /dev/null 2>&1 # check daemons for daemon in "${DAEMONS[@]}" diff --git a/debian/watch b/debian/watch index bc6d91dab5..46ff1c7dab 100644 --- a/debian/watch +++ b/debian/watch @@ -4,5 +4,5 @@ # Site Directory Pattern Version Script version=3 opts=uversionmangle=s/(\d)[_\.\-\+]?((RC|rc|pre|dev|beta|alpha|b|a)[\-\.]?\d*)$/$1~$2/ \ - http://download.savannah.gnu.org/releases/quagga/quagga-(\d.*)\.(?:tgz|tar\.(?:gz|bz2|xz)) + http://download.savannah.gnu.org/releases/frr/quagga-(\d.*)\.(?:tgz|tar\.(?:gz|bz2|xz)) # Bart Martens Fri, 25 Jan 2013 06:38:53 +0000 diff --git a/debian/watchfrr.rc b/debian/watchfrr.rc new file mode 100644 index 0000000000..4110b86399 --- /dev/null +++ b/debian/watchfrr.rc @@ -0,0 +1,4 @@ +check process watchfrr with pidfile /var/run/frr/watchfrr.pid + start program = "/etc/init.d/frr start watchfrr" with timeout 120 seconds + stop program = "/etc/init.d/frr stop watchfrr" + if 3 restarts within 10 cycles then timeout diff --git a/debian/watchquagga.rc b/debian/watchquagga.rc deleted file mode 100644 index 81a00393d2..0000000000 --- a/debian/watchquagga.rc +++ /dev/null @@ -1,4 +0,0 @@ -check process watchfrr with pidfile /var/run/quagga/watchfrr.pid - start program = "/etc/init.d/quagga start watchfrr" with timeout 120 seconds - stop program = "/etc/init.d/quagga stop watchfrr" - if 3 restarts within 10 cycles then timeout diff --git a/redhat/quagga.spec.in b/redhat/quagga.spec.in index 752b70fca5..5a5d4c4c7c 100644 --- a/redhat/quagga.spec.in +++ b/redhat/quagga.spec.in @@ -269,8 +269,8 @@ rm -rf %{buildroot}/usr/share/info/dir # install /etc sources %if "%{initsystem}" == "systemd" mkdir -p %{buildroot}%{_unitdir} -install %{quagga_tools}/quagga.service \ - %{buildroot}%{_unitdir}/quagga.service +install %{quagga_tools}/frr.service \ + %{buildroot}%{_unitdir}/frr.service %else mkdir -p %{buildroot}/etc/rc.d/init.d for daemon in %{all_daemons} ; do @@ -345,7 +345,7 @@ zebra_spec_add_service ldpd 2612/tcp "LDPd vty" %if "%{initsystem}" == "systemd" for daemon in %all_daemons ; do - %systemd_post quagga.service + %systemd_post frr.service done %else for daemon in %all_daemons ; do @@ -510,9 +510,9 @@ rm -rf %{buildroot} %{_sbindir}/bgpd %{_sbindir}/ssd %{_sbindir}/quagga -%{_sbindir}/quagga-reload.py -%{_sbindir}/quagga-reload.pyc -%{_sbindir}/quagga-reload.pyo +%{_sbindir}/frr-reload.py +%{_sbindir}/frr-reload.pyc +%{_sbindir}/frr-reload.pyo %if %{with_watchfrr} %{_sbindir}/watchfrr %endif @@ -530,7 +530,7 @@ rm -rf %{buildroot} %{_bindir}/* %config /etc/quagga/[!v]* %if "%{initsystem}" == "systemd" - %config %{_unitdir}/quagga.service + %config %{_unitdir}/frr.service %else %config /etc/rc.d/init.d/zebra %if %{with_watchfrr} diff --git a/tools/Makefile.am b/tools/Makefile.am index 125bfee2c2..2f1bfc0604 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -1,4 +1,4 @@ -sbin_SCRIPTS = quagga-reload.py quagga +sbin_SCRIPTS = frr-reload.py frr -EXTRA_DIST = quagga.service quagga-reload.py quagga +EXTRA_DIST = frr.service frr-reload.py frr diff --git a/tools/quagga b/tools/frr similarity index 88% rename from tools/quagga rename to tools/frr index 87f1ce5c5e..2ecaadbb53 100755 --- a/tools/quagga +++ b/tools/frr @@ -1,34 +1,34 @@ #!/bin/bash # ### BEGIN INIT INFO -# Provides: quagga +# Provides: frr # Required-Start: $local_fs $network $remote_fs $syslog # Required-Stop: $local_fs $network $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 -# Short-Description: start and stop the Quagga routing suite -# Description: Quagga is a routing suite for IP routing protocols like +# Short-Description: start and stop the Frr routing suite +# Description: Frr is a routing suite for IP routing protocols like # BGP, OSPF, RIP and others. This script contols the main -# daemon "quagga" as well as the individual protocol daemons. +# daemon "frr" as well as the individual protocol daemons. ### END INIT INFO # PATH=/bin:/usr/bin:/sbin:/usr/sbin -D_PATH=/usr/lib/quagga -C_PATH=/etc/quagga -V_PATH=/var/run/quagga +D_PATH=/usr/lib/frr +C_PATH=/etc/frr +V_PATH=/var/run/frr -# Local Daemon selection may be done by using /etc/quagga/daemons. -# See /usr/share/doc/quagga/README.Debian.gz for further information. +# Local Daemon selection may be done by using /etc/frr/daemons. +# See /usr/share/doc/frr/README.Debian.gz for further information. # Keep zebra first and do not list watchfrr! DAEMONS="zebra bgpd ripd ripngd ospfd ospf6d isisd babeld pimd" MAX_INSTANCES=5 -RELOAD_SCRIPT=/usr/lib/quagga/quagga-reload.py +RELOAD_SCRIPT=/usr/lib/frr/frr-reload.py . /lib/lsb/init-functions -if [ -f /usr/lib/quagga/ssd ]; then - SSD=/usr/lib/quagga/ssd +if [ -f /usr/lib/frr/ssd ]; then + SSD=/usr/lib/frr/ssd else SSD=`which start-stop-daemon` fi @@ -61,7 +61,7 @@ started() vtysh_b () { # Rember, that all variables have been incremented by 1 in convert_daemon_prios() - if [ "$vtysh_enable" = 2 -a -f $C_PATH/Quagga.conf ]; then + if [ "$vtysh_enable" = 2 -a -f $C_PATH/Frr.conf ]; then /usr/bin/vtysh -b -n fi } @@ -73,7 +73,7 @@ vtysh_b () check_daemon() { # If the integrated config file is used the others are not checked. - if [ -r "$C_PATH/Quagga.conf" ]; then + if [ -r "$C_PATH/Frr.conf" ]; then return 0 fi @@ -87,18 +87,18 @@ check_daemon() if [ -n "$2" ]; then if [ ! -r "$C_PATH/$1-$2.conf" ]; then touch "$C_PATH/$1-$2.conf" - chown quagga:quagga "$C_PATH/$1-$2.conf" + chown frr:frr "$C_PATH/$1-$2.conf" fi elif [ ! -r "$C_PATH/$1.conf" ]; then touch "$C_PATH/$1.conf" - chown quagga:quagga "$C_PATH/$1.conf" + chown frr:frr "$C_PATH/$1.conf" fi fi return 0 } # Starts the server if it's not alrady running according to the pid file. -# The Quagga daemons creates the pidfile when starting. +# The Frr daemons creates the pidfile when starting. start() { ulimit -n $MAX_FDS @@ -113,8 +113,8 @@ start() echo -n " $1" fi - if [ -e /var/run/quagga/watchfrr.started ] ; then - rm /var/run/quagga/watchfrr.started + if [ -e /var/run/frr/watchfrr.started ] ; then + rm /var/run/frr/watchfrr.started fi ${SSD} \ --start \ @@ -124,7 +124,7 @@ start() "${watchfrr_options[@]}" for i in `seq 1 10`; do - if [ -e /var/run/quagga/watchfrr.started ] ; then + if [ -e /var/run/frr/watchfrr.started ] ; then break else sleep 1 @@ -200,7 +200,7 @@ stop() fi } -# Converts values from /etc/quagga/daemons to all-numeric values. +# Converts values from /etc/frr/daemons to all-numeric values. convert_daemon_prios() { for name in $DAEMONS zebra vtysh_enable watchfrr_enable; do @@ -240,7 +240,7 @@ start_watchfrr() # Check variable type if ! declare -p watchfrr_options | grep -q '^declare \-a'; then echo - echo "ERROR: The variable watchfrr_options from /etc/quagga/debian.cnf must be a BASH array!" + echo "ERROR: The variable watchfrr_options from /etc/frr/debian.cnf must be a BASH array!" echo "ERROR: Please convert config file and restart!" exit 1 fi @@ -271,7 +271,7 @@ start_watchfrr() # Start if at least one daemon is activated. if [ $found_one -eq 1 ]; then - echo -n "Starting Quagga monitor daemon:" + echo -n "Starting Frr monitor daemon:" start watchfrr echo "." fi @@ -280,7 +280,7 @@ start_watchfrr() # Stopps watchfrr. stop_watchfrr() { - echo -n "Stopping Quagga monitor daemon:" + echo -n "Stopping Frr monitor daemon:" stop watchfrr echo "." } @@ -305,7 +305,7 @@ stop_prio() wanted_prio=$1 daemon_list=${daemon:-$DAEMONS} - echo -n "Stopping Quagga daemons (prio:$wanted_prio):" + echo -n "Stopping Frr daemons (prio:$wanted_prio):" for prio_i in `seq 10 -1 $wanted_prio`; do for daemon_name in $daemon_list; do @@ -331,7 +331,7 @@ stop_prio() echo "." if [ -z "$inst" ]; then # Now stop other daemons that're prowling, coz the daemons file changed - echo -n "Stopping other quagga daemons" + echo -n "Stopping other frr daemons" if [ -n "$daemon" ]; then eval "file_list_suffix="$V_PATH"/"$daemon*"" else @@ -374,7 +374,7 @@ start_prio() wanted_prio=$1 daemon_list=${daemon:-$DAEMONS} - echo -n "Starting Quagga daemons (prio:$wanted_prio):" + echo -n "Starting Frr daemons (prio:$wanted_prio):" for prio_i in `seq 1 $wanted_prio`; do for daemon_name in $daemon_list; do @@ -479,7 +479,7 @@ check_status() . "$C_PATH/debian.conf" # Read configuration variable file if it is present -[ -r /etc/default/quagga ] && . /etc/default/quagga +[ -r /etc/default/frr ] && . /etc/default/frr MAX_INSTANCES=${MAX_INSTANCES:=5} @@ -489,7 +489,7 @@ convert_daemon_prios if [ ! -d $V_PATH ]; then echo "Creating $V_PATH" mkdir -p $V_PATH - chown quagga:quagga $V_PATH + chown frr:frr $V_PATH chmod 755 /$V_PATH fi @@ -542,11 +542,11 @@ case "$1" in reload) # Just apply the commands that have changed, no restart necessary - [ ! -x "$RELOAD_SCRIPT" ] && echo "quagga-reload script not available" && exit 0 - NEW_CONFIG_FILE="${2:-$C_PATH/Quagga.conf}" + [ ! -x "$RELOAD_SCRIPT" ] && echo "frr-reload script not available" && exit 0 + NEW_CONFIG_FILE="${2:-$C_PATH/Frr.conf}" [ ! -r $NEW_CONFIG_FILE ] && echo "Unable to read new configuration file $NEW_CONFIG_FILE" && exit 1 - echo "Applying only incremental changes to running configuration from Quagga.conf" - "$RELOAD_SCRIPT" --reload /etc/quagga/Quagga.conf + echo "Applying only incremental changes to running configuration from Frr.conf" + "$RELOAD_SCRIPT" --reload /etc/frr/Frr.conf exit $? ;; @@ -562,11 +562,11 @@ case "$1" in ;; *) - echo "Usage: /etc/init.d/quagga {start|stop|status|reload|restart|force-reload|} [daemon]" - echo " E.g. '/etc/init.d/quagga 5' would start all daemons with a prio 1-5." + echo "Usage: /etc/init.d/frr {start|stop|status|reload|restart|force-reload|} [daemon]" + echo " E.g. '/etc/init.d/frr 5' would start all daemons with a prio 1-5." echo " reload applies only modifications from the running config to all daemons." echo " reload neither restarts starts any daemon nor starts any new ones." - echo " Read /usr/share/doc/quagga/README.Debian for details." + echo " Read /usr/share/doc/frr/README.Debian for details." exit 1 ;; esac diff --git a/tools/quagga-reload.py b/tools/frr-reload.py similarity index 93% rename from tools/quagga-reload.py rename to tools/frr-reload.py index 4d6e9259fd..463784de11 100755 --- a/tools/quagga-reload.py +++ b/tools/frr-reload.py @@ -1,30 +1,30 @@ #!/usr/bin/python -# Quagga Reloader +# Frr Reloader # Copyright (C) 2014 Cumulus Networks, Inc. # -# This file is part of Quagga. +# This file is part of Frr. # -# Quagga is free software; you can redistribute it and/or modify it +# Frr 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. # -# Quagga is distributed in the hope that it will be useful, but +# Frr 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 Quagga; see the file COPYING. If not, write to the Free +# along with Frr; see the file COPYING. If not, write to the Free # Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. # """ This program -- reads a quagga configuration text file -- reads quagga's current running configuration via "vtysh -c 'show running'" +- reads a frr configuration text file +- reads frr's current running configuration via "vtysh -c 'show running'" - compares the two configs and determines what commands to execute to - synchronize quagga's running configuration with the configuation in the + synchronize frr's running configuration with the configuation in the text file """ @@ -52,7 +52,7 @@ class VtyshMarkException(Exception): class Context(object): """ - A Context object represents a section of quagga configuration such as: + A Context object represents a section of frr configuration such as: ! interface swp3 description swp3 -> r8's swp1 @@ -91,7 +91,7 @@ ip forwarding class Config(object): """ - A quagga configuration is stored in a Config object. A Config object + A frr configuration is stored in a Config object. A Config object contains a dictionary of Context objects where the Context keys ('router ospf' for example) are our dictionary key. """ @@ -394,7 +394,7 @@ def line_to_vtysh_conft(ctx_keys, line, delete): def line_for_vtysh_file(ctx_keys, line, delete): """ - Return the command as it would appear in Quagga.conf + Return the command as it would appear in Frr.conf """ cmd = [] @@ -435,7 +435,7 @@ def line_for_vtysh_file(ctx_keys, line, delete): def get_normalized_ipv6_line(line): """ - Return a normalized IPv6 line as produced by quagga, + Return a normalized IPv6 line as produced by frr, with all letters in lower case and trailing and leading zeros removed """ @@ -473,14 +473,14 @@ def ignore_delete_re_add_lines(lines_to_add, lines_to_del): if ctx_keys[0].startswith('router bgp') and line and line.startswith('neighbor '): """ BGP changed how it displays swpX peers that are part of peer-group. Older - versions of quagga would display these on separate lines: + versions of frr would display these on separate lines: neighbor swp1 interface neighbor swp1 peer-group FOO but today we display via a single line neighbor swp1 interface peer-group FOO - This change confuses quagga-reload.py so check to see if we are deleting + This change confuses frr-reload.py so check to see if we are deleting neighbor swp1 interface peer-group FOO and adding @@ -531,7 +531,7 @@ def ignore_delete_re_add_lines(lines_to_add, lines_to_del): """ In 3.0.1 we changed how we display neighbor interface command. Older - versions of quagga would display the following: + versions of frr would display the following: neighbor swp1 interface neighbor swp1 remote-as external neighbor swp1 capability extended-nexthop @@ -542,7 +542,7 @@ def ignore_delete_re_add_lines(lines_to_add, lines_to_del): and capability extended-nexthop is no longer needed because we automatically enable it when the neighbor is of type interface. - This change confuses quagga-reload.py so check to see if we are deleting + This change confuses frr-reload.py so check to see if we are deleting neighbor swp1 interface remote-as (external|internal|ASNUM) and adding @@ -689,19 +689,19 @@ def compare_context_objects(newconf, running): if __name__ == '__main__': # Command line options - parser = argparse.ArgumentParser(description='Dynamically apply diff in quagga configs') + parser = argparse.ArgumentParser(description='Dynamically apply diff in frr configs') parser.add_argument('--input', help='Read running config from file instead of "show running"') group = parser.add_mutually_exclusive_group(required=True) group.add_argument('--reload', action='store_true', help='Apply the deltas', default=False) group.add_argument('--test', action='store_true', help='Show the deltas', default=False) parser.add_argument('--debug', action='store_true', help='Enable debugs', default=False) parser.add_argument('--stdout', action='store_true', help='Log to STDOUT', default=False) - parser.add_argument('filename', help='Location of new quagga config file') + parser.add_argument('filename', help='Location of new frr config file') args = parser.parse_args() # Logging # For --test log to stdout - # For --reload log to /var/log/quagga/quagga-reload.log + # For --reload log to /var/log/frr/frr-reload.log if args.test or args.stdout: logging.basicConfig(level=logging.INFO, format='%(asctime)s %(levelname)5s: %(message)s') @@ -711,10 +711,10 @@ if __name__ == '__main__': logging.addLevelName(logging.WARNING, "\033[91m%s\033[0m" % logging.getLevelName(logging.WARNING)) elif args.reload: - if not os.path.isdir('/var/log/quagga/'): - os.makedirs('/var/log/quagga/') + if not os.path.isdir('/var/log/frr/'): + os.makedirs('/var/log/frr/') - logging.basicConfig(filename='/var/log/quagga/quagga-reload.log', + logging.basicConfig(filename='/var/log/frr/frr-reload.log', level=logging.INFO, format='%(asctime)s %(levelname)5s: %(message)s') @@ -733,7 +733,7 @@ if __name__ == '__main__': sys.exit(1) # Verify that 'service integrated-vtysh-config' is configured - vtysh_filename = '/etc/quagga/vtysh.conf' + vtysh_filename = '/etc/frr/vtysh.conf' service_integrated_vtysh_config = True if os.path.isfile(vtysh_filename): @@ -746,7 +746,7 @@ if __name__ == '__main__': break if not service_integrated_vtysh_config: - print "'service integrated-vtysh-config' is not configured, this is required for 'service quagga reload'" + print "'service integrated-vtysh-config' is not configured, this is required for 'service frr reload'" sys.exit(1) if args.debug: @@ -799,7 +799,7 @@ if __name__ == '__main__': elif args.reload: - log.debug('New Quagga Config\n%s', newconf.get_lines()) + log.debug('New Frr Config\n%s', newconf.get_lines()) # This looks a little odd but we have to do this twice...here is why # If the user had this running bgp config: @@ -826,7 +826,7 @@ if __name__ == '__main__': for x in range(2): running = Config() running.load_from_show_running() - log.debug('Running Quagga Config (Pass #%d)\n%s', x, running.get_lines()) + log.debug('Running Frr Config (Pass #%d)\n%s', x, running.get_lines()) (lines_to_add, lines_to_del) = compare_context_objects(newconf, running) @@ -842,19 +842,19 @@ if __name__ == '__main__': cmd = line_to_vtysh_conft(ctx_keys, line, True) original_cmd = cmd - # Some commands in quagga are picky about taking a "no" of the entire line. + # Some commands in frr are picky about taking a "no" of the entire line. # OSPF is bad about this, you can't "no" the entire line, you have to "no" # only the beginning. If we hit one of these command an exception will be # thrown. Catch it and remove the last '-c', 'FOO' from cmd and try again. # # Example: - # quagga(config-if)# ip ospf authentication message-digest 1.1.1.1 - # quagga(config-if)# no ip ospf authentication message-digest 1.1.1.1 + # frr(config-if)# ip ospf authentication message-digest 1.1.1.1 + # frr(config-if)# no ip ospf authentication message-digest 1.1.1.1 # % Unknown command. - # quagga(config-if)# no ip ospf authentication message-digest + # frr(config-if)# no ip ospf authentication message-digest # % Unknown command. - # quagga(config-if)# no ip ospf authentication - # quagga(config-if)# + # frr(config-if)# no ip ospf authentication + # frr(config-if)# while True: try: @@ -895,7 +895,7 @@ if __name__ == '__main__': string.ascii_uppercase + string.digits) for _ in range(6)) - filename = "/var/run/quagga/reload-%s.txt" % random_string + filename = "/var/run/frr/reload-%s.txt" % random_string log.info("%s content\n%s" % (filename, pformat(lines_to_configure))) with open(filename, 'w') as fh: diff --git a/tools/quagga.service b/tools/frr.service similarity index 56% rename from tools/quagga.service rename to tools/frr.service index a2c1df38d7..efc23ece88 100644 --- a/tools/quagga.service +++ b/tools/frr.service @@ -1,11 +1,11 @@ [Unit] -Description=Cumulus Linux Quagga +Description=Cumulus Linux FRR After=syslog.target networking.service OnFailure=heartbeat-failed@%n.service [Service] Nice=-5 -EnvironmentFile=/etc/default/quagga +EnvironmentFile=/etc/default/frr Type=forking NotifyAccess=all StartLimitInterval=3m @@ -15,8 +15,8 @@ WatchdogSec=60s RestartSec=5 Restart=on-abnormal LimitNOFILE=1024 -ExecStart=/usr/lib/quagga/quagga start -ExecStop=/usr/lib/quagga/quagga stop -ExecReload=/usr/lib/quagga/quagga-reload.py --reload /etc/quagga/Quagga.conf +ExecStart=/usr/lib/frr/frr start +ExecStop=/usr/lib/frr/frr stop +ExecReload=/usr/lib/frr/frr-reload.py --reload /etc/frr/Frr.conf [Install] WantedBy=network-online.target From e60eb8c4edd718bf7361f8ec500d755d0f664dac Mon Sep 17 00:00:00 2001 From: Julien Courtat Date: Fri, 20 May 2016 12:08:28 +0200 Subject: [PATCH 055/107] bgpd: set Graceful Restart R bit for vpnv4 address family Signed-off-by: Julien Courtat --- bgpd/bgp_open.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bgpd/bgp_open.c b/bgpd/bgp_open.c index 02026a004a..4c698562be 100644 --- a/bgpd/bgp_open.c +++ b/bgpd/bgp_open.c @@ -1536,7 +1536,7 @@ bgp_open_capability (struct stream *s, struct peer *peer) if (peer->afc[afi][safi]) { stream_putw (s, afi); - stream_putc (s, safi); + stream_putc (s, (safi == SAFI_MPLS_VPN) ? SAFI_MPLS_LABELED_VPN : safi); stream_putc (s, 0); //Forwarding is not retained as of now. } } From 268fef65f965242757975908379c93002200fbaa Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Wed, 21 Dec 2016 08:16:06 +0100 Subject: [PATCH 056/107] lib: add SAFI_RESERVED_4 value This value is used to limit certain feature to the safi values until that reserved value. Signed-off-by: Philippe Guibert --- lib/zebra.h | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/zebra.h b/lib/zebra.h index 5bb3590abd..345d3e2d8a 100644 --- a/lib/zebra.h +++ b/lib/zebra.h @@ -473,6 +473,7 @@ typedef enum { #define SAFI_MULTICAST 2 #define SAFI_RESERVED_3 3 #define SAFI_MPLS_VPN 4 +#define SAFI_RESERVED_4 4 #define SAFI_ENCAP 7 /* per IANA */ #define SAFI_MAX 8 From db19215a73cd429f04543f75f80ffb989b54d8c3 Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Wed, 21 Dec 2016 08:21:02 +0100 Subject: [PATCH 057/107] lib: remove SAFI_RESERVED_3 and move SAFI_MPLS to that value Because SAFI_RESERVED_3 value is no more used, the SAFI_MPLS value is lowered to that value. Signed-off-by: Philippe Guibert --- lib/zebra.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/zebra.h b/lib/zebra.h index 345d3e2d8a..f9cf21984f 100644 --- a/lib/zebra.h +++ b/lib/zebra.h @@ -471,8 +471,7 @@ typedef enum { /* Subsequent Address Family Identifier. */ #define SAFI_UNICAST 1 #define SAFI_MULTICAST 2 -#define SAFI_RESERVED_3 3 -#define SAFI_MPLS_VPN 4 +#define SAFI_MPLS_VPN 3 #define SAFI_RESERVED_4 4 #define SAFI_ENCAP 7 /* per IANA */ #define SAFI_MAX 8 From 4d5b4f7bd9d12f4755caf31ce8df3570d55d8575 Mon Sep 17 00:00:00 2001 From: Julien Courtat Date: Wed, 25 May 2016 17:28:31 +0200 Subject: [PATCH 058/107] bgpd: graceful restart for vpnv4 address family This patch enable the support of graceful restart for routes sets with vpnv4 address family format. In this specific case, data model is slightly different and some additional processing must be done when accessing bgp tables and nodes. The clearing stale algorithm takes into account the specificity where the 2 node level for MPLS has to be reached. Signed-off-by: Julien Courtat Signed-off-by: Philippe Guibert --- bgpd/bgp_fsm.c | 8 ++++---- bgpd/bgp_route.c | 40 ++++++++++++++++++++++++++++++---------- bgpd/bgpd.c | 2 +- lib/zebra.h | 1 + 4 files changed, 36 insertions(+), 15 deletions(-) diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c index 60a6475330..a71364381e 100644 --- a/bgpd/bgp_fsm.c +++ b/bgpd/bgp_fsm.c @@ -509,7 +509,7 @@ bgp_graceful_restart_timer_expire (struct thread *thread) /* NSF delete stale route */ for (afi = AFI_IP ; afi < AFI_MAX ; afi++) - for (safi = SAFI_UNICAST ; safi < SAFI_RESERVED_3 ; safi++) + for (safi = SAFI_UNICAST ; safi < SAFI_RESERVED_4 ; safi++) if (peer->nsf[afi][safi]) bgp_clear_stale_route (peer, afi, safi); @@ -542,7 +542,7 @@ bgp_graceful_stale_timer_expire (struct thread *thread) /* NSF delete stale route */ for (afi = AFI_IP ; afi < AFI_MAX ; afi++) - for (safi = SAFI_UNICAST ; safi < SAFI_RESERVED_3 ; safi++) + for (safi = SAFI_UNICAST ; safi < SAFI_RESERVED_4 ; safi++) if (peer->nsf[afi][safi]) bgp_clear_stale_route (peer, afi, safi); @@ -1051,7 +1051,7 @@ bgp_stop (struct peer *peer) UNSET_FLAG (peer->sflags, PEER_STATUS_NSF_MODE); for (afi = AFI_IP ; afi < AFI_MAX ; afi++) - for (safi = SAFI_UNICAST ; safi < SAFI_RESERVED_3 ; safi++) + for (safi = SAFI_UNICAST ; safi < SAFI_RESERVED_4 ; safi++) peer->nsf[afi][safi] = 0; } @@ -1468,7 +1468,7 @@ bgp_establish (struct peer *peer) /* graceful restart */ UNSET_FLAG (peer->sflags, PEER_STATUS_NSF_WAIT); for (afi = AFI_IP ; afi < AFI_MAX ; afi++) - for (safi = SAFI_UNICAST ; safi < SAFI_RESERVED_3 ; safi++) + for (safi = SAFI_UNICAST ; safi < SAFI_RESERVED_4 ; safi++) { if (peer->afc_nego[afi][safi] && CHECK_FLAG (peer->cap, PEER_CAP_RESTART_ADV) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index cfc4ec3407..1e9aa4bb2a 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -3307,17 +3307,37 @@ bgp_clear_stale_route (struct peer *peer, afi_t afi, safi_t safi) struct bgp_info *ri; struct bgp_table *table; - table = peer->bgp->rib[afi][safi]; - - for (rn = bgp_table_top (table); rn; rn = bgp_route_next (rn)) + if ( safi == SAFI_MPLS_VPN) { - for (ri = rn->info; ri; ri = ri->next) - if (ri->peer == peer) - { - if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) - bgp_rib_remove (rn, ri, peer, afi, safi); - break; - } + for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; rn = bgp_route_next (rn)) + { + struct bgp_node *rm; + struct bgp_info *ri; + + /* look for neighbor in tables */ + if ((table = rn->info) != NULL) + { + for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm)) + for (ri = rm->info; ri; ri = ri->next) + if (ri->peer == peer) + { + if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) + bgp_rib_remove (rm, ri, peer, afi, safi); + break; + } + } + } + } + else + { + for (rn = bgp_table_top (peer->bgp->rib[afi][safi]); rn; rn = bgp_route_next (rn)) + for (ri = rn->info; ri; ri = ri->next) + if (ri->peer == peer) + { + if (CHECK_FLAG (ri->flags, BGP_INFO_STALE)) + bgp_rib_remove (rn, ri, peer, afi, safi); + break; + } } } diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 30f6e0d859..68ad6bbe11 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -1902,7 +1902,7 @@ peer_nsf_stop (struct peer *peer) UNSET_FLAG (peer->sflags, PEER_STATUS_NSF_MODE); for (afi = AFI_IP ; afi < AFI_MAX ; afi++) - for (safi = SAFI_UNICAST ; safi < SAFI_RESERVED_3 ; safi++) + for (safi = SAFI_UNICAST ; safi < SAFI_RESERVED_4 ; safi++) peer->nsf[afi][safi] = 0; if (peer->t_gr_restart) diff --git a/lib/zebra.h b/lib/zebra.h index f9cf21984f..fd1aa3cf7d 100644 --- a/lib/zebra.h +++ b/lib/zebra.h @@ -474,6 +474,7 @@ typedef enum { #define SAFI_MPLS_VPN 3 #define SAFI_RESERVED_4 4 #define SAFI_ENCAP 7 /* per IANA */ +#define SAFI_RESERVED_5 5 #define SAFI_MAX 8 /* Default Administrative Distance of each protocol. */ From 440129913d3205eb4a081d6c1249f448521aa876 Mon Sep 17 00:00:00 2001 From: Julien Courtat Date: Fri, 17 Jun 2016 15:31:09 +0200 Subject: [PATCH 059/107] bgpd: support End-Of-Rib of VPNv4 address family After graceful restart procedure, when BGP speaker has finished to send its VPNv4 routes to the restarting peer, it also sends End-Of-Rib message for afi=AFI_IPv4 safi=SAFI_MPLS_VPN. Signed-off-by: Julien Courtat --- bgpd/bgp_packet.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c index 796a57f054..dffca37dd3 100644 --- a/bgpd/bgp_packet.c +++ b/bgpd/bgp_packet.c @@ -175,7 +175,7 @@ bgp_update_packet_eor (struct peer *peer, afi_t afi, safi_t safi) stream_putc (s, BGP_ATTR_MP_UNREACH_NLRI); stream_putc (s, 3); stream_putw (s, afi); - stream_putc (s, safi); + stream_putc (s, (safi == SAFI_MPLS_VPN) ? SAFI_MPLS_LABELED_VPN : safi); } bgp_packet_set_size (s); @@ -240,8 +240,7 @@ bgp_write_packet (struct peer *peer) if (!(PAF_SUBGRP(paf))->t_coalesce && peer->afc_nego[afi][safi] && peer->synctime && ! CHECK_FLAG (peer->af_sflags[afi][safi], - PEER_STATUS_EOR_SEND) - && safi != SAFI_MPLS_VPN) + PEER_STATUS_EOR_SEND)) { SET_FLAG (peer->af_sflags[afi][safi], PEER_STATUS_EOR_SEND); From daf0a4d29cdb24ca0125c6bd15a52be153fbbde3 Mon Sep 17 00:00:00 2001 From: Olivier Dugeon Date: Tue, 20 Dec 2016 15:02:34 +0100 Subject: [PATCH 060/107] Rationalize Link Parameters flags * lib/if.h: Remove LP_TE as Link Parameters is set if different from 0 See IS_LINK_PARAMS_SET macro and use LP_TE_METRIC to determine if TE metric is set or not * lib/if.c: replace LP_TE by LP_TE_METRIC in default LP status * zebra/interface.c: replace LP_TE by LP_TE_METRIC and check if TE metric is equal to standard metric or not * ospfd/ospf_te.c: replace LP_TE by LP_TE_METRIC * isisd/isis_te.c: replace LP_TE by LP_TE_METRIC Signed-off-by: Olivier Dugeon --- isisd/isis_te.c | 2 +- lib/if.c | 4 ++-- lib/if.h | 9 ++++++--- ospfd/ospf_te.c | 2 +- zebra/interface.c | 8 ++++---- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/isisd/isis_te.c b/isisd/isis_te.c index 109f5e4574..34cd8397f4 100644 --- a/isisd/isis_te.c +++ b/isisd/isis_te.c @@ -591,7 +591,7 @@ isis_link_params_update (struct isis_circuit *circuit, struct interface *ifp) else SUBTLV_TYPE(mtc->unrsv_bw) = 0; - if (IS_PARAM_SET(ifp->link_params, LP_TE)) + if (IS_PARAM_SET(ifp->link_params, LP_TE_METRIC)) set_circuitparams_te_metric(mtc, ifp->link_params->te_metric); else SUBTLV_TYPE(mtc->te_metric) = 0; diff --git a/lib/if.c b/lib/if.c index fb12f201b2..0a1a8f6a26 100644 --- a/lib/if.c +++ b/lib/if.c @@ -1302,7 +1302,7 @@ if_link_params_get (struct interface *ifp) sizeof (struct if_link_params)); if (iflp == NULL) return NULL; - /* Set TE metric == standard metric */ + /* Set TE metric equal to standard metric */ iflp->te_metric = ifp->metric; /* Compute default bandwidth based on interface */ @@ -1316,7 +1316,7 @@ if_link_params_get (struct interface *ifp) iflp->unrsv_bw[i] = iflp->default_bw; /* Update Link parameters status */ - iflp->lp_status = LP_TE | LP_MAX_BW | LP_MAX_RSV_BW | LP_UNRSV_BW; + iflp->lp_status = LP_TE_METRIC | LP_MAX_BW | LP_MAX_RSV_BW | LP_UNRSV_BW; /* Finally attach newly created Link Parameters */ ifp->link_params = iflp; diff --git a/lib/if.h b/lib/if.h index e8a3b9d7b5..cfa376d1ea 100644 --- a/lib/if.h +++ b/lib/if.h @@ -146,9 +146,13 @@ struct if_stats #define MAX_CLASS_TYPE 8 #define MAX_PKT_LOSS 50.331642 -/* Link Parameters Status: 0: unset, 1: set, */ +/* + * Link Parameters Status: + * equal to 0: unset + * different from 0: set + */ #define LP_UNSET 0x0000 -#define LP_TE 0x0001 +#define LP_TE_METRIC 0x0001 #define LP_MAX_BW 0x0002 #define LP_MAX_RSV_BW 0x0004 #define LP_UNRSV_BW 0x0008 @@ -161,7 +165,6 @@ struct if_stats #define LP_RES_BW 0x0400 #define LP_AVA_BW 0x0800 #define LP_USE_BW 0x1000 -#define LP_TE_METRIC 0x2000 #define IS_PARAM_UNSET(lp, st) !(lp->lp_status & st) #define IS_PARAM_SET(lp, st) (lp->lp_status & st) diff --git a/ospfd/ospf_te.c b/ospfd/ospf_te.c index c691aac040..4c5862e84a 100644 --- a/ospfd/ospf_te.c +++ b/ospfd/ospf_te.c @@ -746,7 +746,7 @@ update_linkparams(struct mpls_te_link *lp) else TLV_TYPE(lp->unrsv_bw) = 0; - if (IS_PARAM_SET(ifp->link_params, LP_TE)) + if (IS_PARAM_SET(ifp->link_params, LP_TE_METRIC)) set_linkparams_te_metric(lp, ifp->link_params->te_metric); else TLV_TYPE(lp->te_metric) = 0; diff --git a/zebra/interface.c b/zebra/interface.c index 8eddd3062a..4a0409702f 100644 --- a/zebra/interface.c +++ b/zebra/interface.c @@ -1107,7 +1107,7 @@ if_dump_vty (struct vty *vty, struct interface *ifp) int i; struct if_link_params *iflp = ifp->link_params; vty_out(vty, " Traffic Engineering Link Parameters:%s", VTY_NEWLINE); - if (IS_PARAM_SET(iflp, LP_TE)) + if (IS_PARAM_SET(iflp, LP_TE_METRIC)) vty_out(vty, " TE metric %u%s",iflp->te_metric, VTY_NEWLINE); if (IS_PARAM_SET(iflp, LP_MAX_BW)) vty_out(vty, " Maximum Bandwidth %g (Byte/s)%s", iflp->max_bw, VTY_NEWLINE); @@ -1785,7 +1785,7 @@ DEFUN (link_params_metric, VTY_GET_ULONG("metric", metric, argv[idx_number]->arg); /* Update TE metric if needed */ - link_param_cmd_set_uint32 (ifp, &iflp->te_metric, LP_TE | LP_TE_METRIC, metric); + link_param_cmd_set_uint32 (ifp, &iflp->te_metric, LP_TE_METRIC, metric); return CMD_SUCCESS; } @@ -1799,7 +1799,7 @@ DEFUN (no_link_params_metric, VTY_DECLVAR_CONTEXT (interface, ifp); /* Unset TE Metric */ - link_param_cmd_unset(ifp, LP_TE | LP_TE_METRIC); + link_param_cmd_unset(ifp, LP_TE_METRIC); return CMD_SUCCESS; } @@ -2737,7 +2737,7 @@ link_params_config_write (struct vty *vty, struct interface *ifp) vty_out (vty, " link-params%s", VTY_NEWLINE); vty_out(vty, " enable%s", VTY_NEWLINE); - if (IS_PARAM_SET(iflp, LP_TE) && IS_PARAM_SET(iflp, LP_TE_METRIC)) + if (IS_PARAM_SET(iflp, LP_TE_METRIC) && iflp->te_metric != ifp->metric) vty_out(vty, " metric %u%s",iflp->te_metric, VTY_NEWLINE); if (IS_PARAM_SET(iflp, LP_MAX_BW) && iflp->max_bw != iflp->default_bw) vty_out(vty, " max-bw %g%s", iflp->max_bw, VTY_NEWLINE); From 4fedc05c8895ae5400a13c17b7d75b9689bf5c88 Mon Sep 17 00:00:00 2001 From: Christian Franke Date: Thu, 5 Jan 2017 20:22:31 +0100 Subject: [PATCH 061/107] isisd: don't generate LSPs with LSP-ID zero on is-type change Signed-off-by: Christian Franke --- isisd/isisd.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/isisd/isisd.c b/isisd/isisd.c index c22be5fa8b..61a5ad0d66 100644 --- a/isisd/isisd.c +++ b/isisd/isisd.c @@ -1780,10 +1780,13 @@ isis_area_is_type_set(struct isis_area *area, int is_type) spftree_area_init (area); - if (is_type & IS_LEVEL_1) - lsp_generate (area, IS_LEVEL_1); - if (is_type & IS_LEVEL_2) - lsp_generate (area, IS_LEVEL_2); + if (listcount (area->area_addrs) > 0) + { + if (is_type & IS_LEVEL_1) + lsp_generate (area, IS_LEVEL_1); + if (is_type & IS_LEVEL_2) + lsp_generate (area, IS_LEVEL_2); + } lsp_regenerate_schedule (area, IS_LEVEL_1 | IS_LEVEL_2, 1); return; From 41c17d61a274d3e565de6ff2e0d6a33f1db08f71 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 5 Jan 2017 12:44:23 -0500 Subject: [PATCH 062/107] lib: Stop potential uninitialized memory access VRF_UNKNOWN = MAX_INT16_T The vrf macros to determine where in the bitmap something belongs assume that the valid values of a vrf are 0 - (MAX_INT16 - 1) so when they attempt to determine where to look in the bitmap for VRF_DEFAULT, we can get invalid reads of memory. This happens because bgp can create vrf's with VRF_UNKNOWN when we get configuration for a vrf before we've been actually created in zebra. Ticket: CM-14090 Signed-off-by: Donald Sharp --- lib/vrf.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/vrf.c b/lib/vrf.c index 39d8a89a7c..61b278dabf 100644 --- a/lib/vrf.c +++ b/lib/vrf.c @@ -381,7 +381,7 @@ vrf_bitmap_set (vrf_bitmap_t bmap, vrf_id_t vrf_id) u_char group = VRF_BITMAP_GROUP (vrf_id); u_char offset = VRF_BITMAP_BIT_OFFSET (vrf_id); - if (bmap == VRF_BITMAP_NULL) + if (bmap == VRF_BITMAP_NULL || vrf_id == VRF_UNKNOWN) return; if (bm->groups[group] == NULL) @@ -399,7 +399,8 @@ vrf_bitmap_unset (vrf_bitmap_t bmap, vrf_id_t vrf_id) u_char group = VRF_BITMAP_GROUP (vrf_id); u_char offset = VRF_BITMAP_BIT_OFFSET (vrf_id); - if (bmap == VRF_BITMAP_NULL || bm->groups[group] == NULL) + if (bmap == VRF_BITMAP_NULL || vrf_id == VRF_UNKNOWN || + bm->groups[group] == NULL) return; UNSET_FLAG (bm->groups[group][VRF_BITMAP_INDEX_IN_GROUP (offset)], @@ -413,7 +414,8 @@ vrf_bitmap_check (vrf_bitmap_t bmap, vrf_id_t vrf_id) u_char group = VRF_BITMAP_GROUP (vrf_id); u_char offset = VRF_BITMAP_BIT_OFFSET (vrf_id); - if (bmap == VRF_BITMAP_NULL || bm->groups[group] == NULL) + if (bmap == VRF_BITMAP_NULL || vrf_id == VRF_UNKNOWN || + bm->groups[group] == NULL) return 0; return CHECK_FLAG (bm->groups[group][VRF_BITMAP_INDEX_IN_GROUP (offset)], From 36da066554254ffe8d6224f2b3938ba2c0c3a2e0 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Thu, 5 Jan 2017 12:52:18 -0500 Subject: [PATCH 063/107] ospfd: Stop attempt to read beyond end of argv When unconfiguring certain commands in ospf, you can run into situations where we attempt to read beyond the end of a argv[] vector created. On certain platforms this will crash it. Ticket: CM-14090 Signed-off-by: Donald Sharp --- ospfd/ospf_vty.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index 1b7c43147c..2c3aaa6808 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -1290,10 +1290,15 @@ DEFUN (no_ospf_area_vlink, /* message-digest-key */ /* Delete one key */ i++; - vl_config.crypto_key_id = strtol (argv[i], NULL, 10); - if (vl_config.crypto_key_id < 0) + if (i < argc) + { + vl_config.crypto_key_id = strtol (argv[i], NULL, 10); + if (vl_config.crypto_key_id < 0) + return CMD_WARNING; + vl_config.md5_key = NULL; + } + else return CMD_WARNING; - vl_config.md5_key = NULL; break; case 'h': From 6a9a3cde582277e37ff024b72b6022efcf1a5884 Mon Sep 17 00:00:00 2001 From: Julien Courtat Date: Fri, 20 May 2016 12:10:07 +0200 Subject: [PATCH 064/107] bgpd: enable send of Graceful Restart Preserve State F bit Enhance struct bgp to add a new flag BGP_FLAG_GR_PRESERVE_FWD, which allow to set the Preserve State F bit of Graceful Restart capability in OPEN messages. Signed-off-by: Julien Courtat --- bgpd/bgp_open.c | 5 ++++- bgpd/bgpd.h | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/bgpd/bgp_open.c b/bgpd/bgp_open.c index 4c698562be..af3c0486e5 100644 --- a/bgpd/bgp_open.c +++ b/bgpd/bgp_open.c @@ -1537,7 +1537,10 @@ bgp_open_capability (struct stream *s, struct peer *peer) { stream_putw (s, afi); stream_putc (s, (safi == SAFI_MPLS_VPN) ? SAFI_MPLS_LABELED_VPN : safi); - stream_putc (s, 0); //Forwarding is not retained as of now. + if (bgp_flag_check(peer->bgp, BGP_FLAG_GR_PRESERVE_FWD)) + stream_putc (s, RESTART_F_BIT); + else + stream_putc (s, 0); } } diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index 86fa207b6b..b82cf9dde9 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -289,6 +289,7 @@ struct bgp #define BGP_FLAG_MULTIPATH_RELAX_AS_SET (1 << 17) #define BGP_FLAG_FORCE_STATIC_PROCESS (1 << 18) #define BGP_FLAG_SHOW_HOSTNAME (1 << 19) +#define BGP_FLAG_GR_PRESERVE_FWD (1 << 20) /* BGP Per AF flags */ u_int16_t af_flags[AFI_MAX][SAFI_MAX]; From 43fc21b363e2657c444fe85bef1f72cf00fb0d4a Mon Sep 17 00:00:00 2001 From: Julien Courtat Date: Tue, 17 May 2016 16:26:22 +0200 Subject: [PATCH 065/107] bgpd: configure preserve forwarding state from vty Preserve forwarding state bit can be set in OPEN message with the use of new vty commands bgp graceful-restart preserve-fw-state no bgp graceful-restart preserve-fw-state This must be set before activating the connection to a peer, since it is for forging graceful restart capability of OPEN messages. Signed-off-by: Julien Courtat --- bgpd/bgp_vty.c | 28 ++++++++++++++++++++++++++++ bgpd/bgpd.c | 4 ++++ 2 files changed, 32 insertions(+) diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 1c2cc037f9..683c09bf61 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -1673,6 +1673,31 @@ DEFUN (no_bgp_graceful_restart_restart_time, return CMD_SUCCESS; } +DEFUN (bgp_graceful_restart_preserve_fw, + bgp_graceful_restart_preserve_fw_cmd, + "bgp graceful-restart preserve-fw-state", + "BGP specific commands\n" + "Graceful restart capability parameters\n" + "Sets F-bit indication that fib is preserved while doing Graceful Restart\n") +{ + VTY_DECLVAR_CONTEXT(bgp, bgp); + bgp_flag_set(bgp, BGP_FLAG_GR_PRESERVE_FWD); + return CMD_SUCCESS; +} + +DEFUN (no_bgp_graceful_restart_preserve_fw, + no_bgp_graceful_restart_preserve_fw_cmd, + "no bgp graceful-restart preserve-fw-state", + NO_STR + "BGP specific commands\n" + "Graceful restart capability parameters\n" + "Unsets F-bit indication that fib is preserved while doing Graceful Restart\n") +{ + VTY_DECLVAR_CONTEXT(bgp, bgp); + bgp_flag_unset(bgp, BGP_FLAG_GR_PRESERVE_FWD); + return CMD_SUCCESS; +} + /* "bgp fast-external-failover" configuration. */ DEFUN (bgp_fast_external_failover, bgp_fast_external_failover_cmd, @@ -9852,6 +9877,9 @@ bgp_vty_init (void) install_element (BGP_NODE, &bgp_graceful_restart_restart_time_cmd); install_element (BGP_NODE, &no_bgp_graceful_restart_restart_time_cmd); + install_element (BGP_NODE, &bgp_graceful_restart_preserve_fw_cmd); + install_element (BGP_NODE, &no_bgp_graceful_restart_preserve_fw_cmd); + /* "bgp fast-external-failover" commands */ install_element (BGP_NODE, &bgp_fast_external_failover_cmd); install_element (BGP_NODE, &no_bgp_fast_external_failover_cmd); diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 68ad6bbe11..f9c3f9af4b 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -7371,6 +7371,10 @@ bgp_config_write (struct vty *vty) if (bgp_flag_check (bgp, BGP_FLAG_GRACEFUL_RESTART)) vty_out (vty, " bgp graceful-restart%s", VTY_NEWLINE); + /* BGP graceful-restart Preserve State F bit. */ + if (bgp_flag_check (bgp, BGP_FLAG_GR_PRESERVE_FWD)) + vty_out (vty, " bgp graceful-restart preserve-fw-state%s", VTY_NEWLINE); + /* BGP bestpath method. */ if (bgp_flag_check (bgp, BGP_FLAG_ASPATH_IGNORE)) vty_out (vty, " bgp bestpath as-path ignore%s", VTY_NEWLINE); From c115e4a4b49cdc03d9e8090db0cff548868e0538 Mon Sep 17 00:00:00 2001 From: Martin Winter Date: Fri, 6 Jan 2017 23:45:13 +0700 Subject: [PATCH 066/107] redhat: rename project from Quagga to FRR Rename all instances of Quagga to FRR in red hat package files Signed-off-by: Martin Winter --- redhat/Makefile.am | 4 +- redhat/README.rpm_build.md | 30 ++-- redhat/bgpd.init | 8 +- redhat/frr.logrotate | 63 +++++++++ redhat/{quagga.pam => frr.pam} | 4 +- redhat/{quagga.spec.in => frr.spec.in} | 155 +++++++++++---------- redhat/{quagga.sysconfig => frr.sysconfig} | 0 redhat/isisd.init | 8 +- redhat/ldpd.init | 8 +- redhat/ospf6d.init | 8 +- redhat/ospfd.init | 8 +- redhat/pimd.init | 8 +- redhat/quagga.logrotate | 63 --------- redhat/ripd.init | 8 +- redhat/ripngd.init | 8 +- redhat/{watchquagga.init => watchfrr.init} | 2 +- redhat/zebra.init | 8 +- 17 files changed, 197 insertions(+), 196 deletions(-) create mode 100644 redhat/frr.logrotate rename redhat/{quagga.pam => frr.pam} (88%) rename redhat/{quagga.spec.in => frr.spec.in} (83%) rename redhat/{quagga.sysconfig => frr.sysconfig} (100%) delete mode 100644 redhat/quagga.logrotate rename redhat/{watchquagga.init => watchfrr.init} (97%) diff --git a/redhat/Makefile.am b/redhat/Makefile.am index c70e71fef6..f7a143ff73 100644 --- a/redhat/Makefile.am +++ b/redhat/Makefile.am @@ -1,8 +1,8 @@ EXTRA_DIST = bgpd.init isisd.init \ ospf6d.init ospfd.init ldpd.init \ - quagga.logrotate quagga.pam quagga.spec \ - quagga.sysconfig ripd.init ripngd.init \ + frr.logrotate frr.pam frr.spec \ + frr.sysconfig ripd.init ripngd.init \ watchfrr.init pimd.init zebra.init \ README.rpm_build.md diff --git a/redhat/README.rpm_build.md b/redhat/README.rpm_build.md index c164d740b9..db3c7d45c8 100644 --- a/redhat/README.rpm_build.md +++ b/redhat/README.rpm_build.md @@ -1,5 +1,5 @@ -Building your own Quagga RPM -============================ +Building your own FreeRangeRouting RPM +====================================== (Tested on CentOS 6, CentOS 7 and Fedora 22.) 1. Install the following packages to build the RPMs: @@ -10,13 +10,13 @@ Building your own Quagga RPM (use `dnf install` on new Fedora instead of `yum install `) -2. Checkout Quagga under a **unpriviledged** user account +2. Checkout FRR under a **unpriviledged** user account - git clone git://git.savannah.nongnu.org/quagga.git quagga + git clone https://github.com/freerangerouting/frr.git frr 3. Run Bootstrap and make distribution tar.gz - cd quagga + cd frr ./bootstrap.sh ./configure --with-pkg-extra-version=-MyRPMVersion make dist @@ -31,13 +31,13 @@ Building your own Quagga RPM mkdir rpmbuild/SOURCES mkdir rpmbuild/SPECS cp redhat/*.spec rpmbuild/SPECS/ - cp quagga*.tar.gz rpmbuild/SOURCES/ + cp frr*.tar.gz rpmbuild/SOURCES/ -5. Edit rpm/SPECS/quagga.spec with configuration as needed +5. Edit rpm/SPECS/frr.spec with configuration as needed Look at the beginning of the file and adjust the following parameters to enable or disable features as required: - ################# Quagga configure options #################### + ################# frr configure options #################### # with-feature options %{!?with_snmp: %global with_snmp 1 } %{!?with_vtysh: %global with_vtysh 1 } @@ -56,14 +56,14 @@ Building your own Quagga RPM %{!?with_ldpd: %global with_ldpd 0 } %{!?with_shared: %global with_shared 1 } %{!?with_multipath: %global with_multipath 64 } - %{!?quagga_user: %global quagga_user quagga } - %{!?vty_group: %global vty_group quaggavt } + %{!?frr_user: %global frr_user frr } + %{!?vty_group: %global vty_group frrvt } %{!?with_fpm: %global with_fpm 0 } - %{!?with_watchfrr: %global with_watchfrr 1 } + %{!?with_watchfrr: %global with_watchfrr 1 } 6. Build the RPM - rpmbuild --define "_topdir `pwd`/rpmbuild" -ba rpmbuild/SPECS/quagga.spec + rpmbuild --define "_topdir `pwd`/rpmbuild" -ba rpmbuild/SPECS/frr.spec DONE. @@ -84,7 +84,7 @@ Enabling daemons after installation of the package: chkconfig bgpd on ... etc -2. If you want to run `watchfrr`, then configure `/etc/sysconfig/quagga` +2. If you want to run `watchfrr`, then configure `/etc/sysconfig/frr` and uncomment the line with the daemons for `watchfrr` to monitor, then enable watchfrr @@ -100,7 +100,7 @@ allowed. service ospfd start ... etc -Configuration is stored in `/etc/quagga/*.conf` files. +Configuration is stored in `/etc/frr/*.conf` files. ### systemd based systems (ie CentOS 7, Fedora 22) @@ -126,5 +126,5 @@ allowed. systemctl start ospfd ... etc -Configuration is stored in `/etc/quagga/*.conf` files. +Configuration is stored in `/etc/frr/*.conf` files. diff --git a/redhat/bgpd.init b/redhat/bgpd.init index e18511a038..d200b0baaa 100644 --- a/redhat/bgpd.init +++ b/redhat/bgpd.init @@ -1,6 +1,6 @@ #!/bin/bash # chkconfig: - 16 84 -# config: /etc/quagga/bgpd.conf +# config: /etc/frr/bgpd.conf ### BEGIN INIT INFO # Provides: bgpd @@ -14,14 +14,14 @@ # Get network config . /etc/sysconfig/network -# quagga command line options -. /etc/sysconfig/quagga +# frr command line options +. /etc/sysconfig/frr RETVAL=0 PROG="bgpd" cmd=bgpd LOCK_FILE=/var/lock/subsys/bgpd -CONF_FILE=/etc/quagga/bgpd.conf +CONF_FILE=/etc/frr/bgpd.conf case "$1" in start) diff --git a/redhat/frr.logrotate b/redhat/frr.logrotate new file mode 100644 index 0000000000..2db3af63dd --- /dev/null +++ b/redhat/frr.logrotate @@ -0,0 +1,63 @@ +/var/log/frr/zebra.log { + notifempty + missingok + postrotate + /bin/kill -USR1 `cat /var/run/frr/zebra.pid 2> /dev/null` 2> /dev/null || true + endscript +} + +/var/log/frr/bgpd.log { + notifempty + missingok + postrotate + /bin/kill -USR1 `cat /var/run/frr/bgpd.pid 2> /dev/null` 2> /dev/null || true + endscript +} + +/var/log/frr/isisd.log { + notifempty + missingok + postrotate + /bin/kill -USR1 `cat /var/run/frr/isisd.pid 2> /dev/null` 2> /dev/null || true + endscript +} + +/var/log/frr/ospfd.log { + notifempty + missingok + postrotate + /bin/kill -USR1 `cat /var/run/frr/ospfd.pid 2> /dev/null` 2> /dev/null || true + endscript +} + +/var/log/frr/ospf6d.log { + notifempty + missingok + postrotate + /bin/kill -USR1 `cat /var/run/frr/ospf6d.pid 2> /dev/null` 2> /dev/null || true + endscript +} + +/var/log/frr/ripd.log { + notifempty + missingok + postrotate + /bin/kill -USR1 `cat /var/run/frr/ripd.pid 2> /dev/null` 2> /dev/null || true + endscript +} + +/var/log/frr/ripngd.log { + notifempty + missingok + postrotate + /bin/kill -USR1 `cat /var/run/frr/ripngd.pid 2> /dev/null` 2> /dev/null || true + endscript +} + +/var/log/frr/ldpd.log { + notifempty + missingok + postrotate + /bin/kill -USR1 `cat /var/run/frr/ldpd.pid 2> /dev/null` 2> /dev/null || true + endscript +} diff --git a/redhat/quagga.pam b/redhat/frr.pam similarity index 88% rename from redhat/quagga.pam rename to redhat/frr.pam index 9a91ad852f..5cef5d9d74 100644 --- a/redhat/quagga.pam +++ b/redhat/frr.pam @@ -1,7 +1,7 @@ #%PAM-1.0 # -##### if running quagga as root: +##### if running frr as root: # Only allow root (and possibly wheel) to use this because enable access # is unrestricted. auth sufficient pam_rootok.so @@ -12,7 +12,7 @@ auth sufficient pam_rootok.so #auth required pam_wheel.so use_uid ########################################################### -# If using quagga privileges and with a seperate group for vty access, then +# If using frr privileges and with a seperate group for vty access, then # access can be controlled via the vty access group, and pam can simply # check for valid user/password, eg: # diff --git a/redhat/quagga.spec.in b/redhat/frr.spec.in similarity index 83% rename from redhat/quagga.spec.in rename to redhat/frr.spec.in index 5a5d4c4c7c..a815e151df 100644 --- a/redhat/quagga.spec.in +++ b/redhat/frr.spec.in @@ -8,7 +8,7 @@ # rpms again and again on the same day, so the newer rpms can be installed. # bumping the number each time. -####################### Quagga configure options ######################### +####################### FreeRangeRouting (FRR) configure options ######################### # with-feature options %{!?with_tcp_zebra: %global with_tcp_zebra 0 } %{!?with_pam: %global with_pam 0 } @@ -20,29 +20,29 @@ %{!?with_ldpd: %global with_ldpd 0 } %{!?with_shared: %global with_shared 1 } %{!?with_multipath: %global with_multipath 256 } -%{!?quagga_user: %global quagga_user quagga } -%{!?vty_group: %global vty_group quaggavty } +%{!?frr_user: %global frr_user frr } +%{!?vty_group: %global vty_group frrvty } %{!?with_fpm: %global with_fpm 0 } %{!?with_watchfrr: %global with_watchfrr 1 } %{!?with_bgp_vnc: %global with_bgp_vnc 0 } # path defines -%define _sysconfdir /etc/quagga -%define _sbindir /usr/lib/quagga -%define zeb_src %{_builddir}/%{name}-%{quaggaversion} +%define _sysconfdir /etc/frr +%define _sbindir /usr/lib/frr +%define zeb_src %{_builddir}/%{name}-%{frrversion} %define zeb_rh_src %{zeb_src}/redhat %define zeb_docs %{zeb_src}/doc -%define quagga_tools %{zeb_src}/tools +%define frr_tools %{zeb_src}/tools %define cumulus_dir %{zeb_src}/cumulus/etc # defines for configure -%define _localstatedir /var/run/quagga +%define _localstatedir /var/run/frr ############################################################################ #### Version String tweak # Remove invalid characters form version string and replace with _ %{expand: %%global rpmversion %(echo '@VERSION@' | tr [:blank:]- _ )} -%define quaggaversion @VERSION@ +%define frrversion @VERSION@ #### Check version of texi2html # Old versions don't support "--number-footnotes" option. @@ -68,8 +68,8 @@ %endif # misc internal defines -%{!?quagga_uid: %global quagga_uid 92 } -%{!?quagga_gid: %global quagga_gid 92 } +%{!?frr_uid: %global frr_uid 92 } +%{!?frr_gid: %global frr_gid 92 } %{!?vty_gid: %global vty_gid 85 } %define daemon_list zebra ripd ospfd bgpd isisd pimd ripngd ospfd6d @@ -95,19 +95,20 @@ %{!?release_rev: %global release_rev 01 } Summary: Routing daemon -Name: quagga +Name: frr Version: %{rpmversion} Release: @CONFDATE@%{release_rev}%{?dist} License: GPLv2+ Group: System Environment/Daemons -Source0: http://download.savannah.gnu.org/releases/quagga/%{name}-%{quaggaversion}.tar.gz -URL: http://www.quagga.net -Requires: ncurses +Source0: http://www.freerangerouting.org/releases/frr/%{name}-%{frrversion}.tar.gz +URL: http://www.freerangerouting.org +Requires: ncurses json-c Requires(pre): /sbin/install-info Requires(preun): /sbin/install-info Requires(post): /sbin/install-info -BuildRequires: texi2html texinfo autoconf patch libcap-devel groff +BuildRequires: texi2html texinfo autoconf patch libcap-devel groff BuildRequires: readline readline-devel ncurses ncurses-devel +BuildRequires: json-c-devel bison flex Requires: ncurses initscripts %if %{with_pam} BuildRequires: pam-devel @@ -124,39 +125,36 @@ Requires(pre): initscripts >= 5.60 %endif Provides: routingdaemon = %{version}-%{release} BuildRoot: %{_tmppath}/%{name}-%{version}-root -Obsoletes: bird gated mrt zebra quagga-sysvinit +Obsoletes: bird gated mrt zebra frr-sysvinit %description -Quagga is a free software that manages TCP/IP based routing +FreeRangeRouting is a free software that manages TCP/IP based routing protocol. It takes multi-server and multi-thread approach to resolve the current complexity of the Internet. -Quagga supports BGP4, OSPFv2, OSPFv3, ISIS, RIP, RIPng and PIM. +FreeRangeRouting supports BGP4, OSPFv2, OSPFv3, ISIS, RIP, RIPng, PIM +and LDP -Quagga is intended to be used as a Route Server and a Route Reflector. It is -not a toolkit, it provides full routing power under a new architecture. -Quagga by design has a process for each protocol. - -Quagga is a fork of GNU Zebra. +FreeRangeRouting is a fork of Quagga. %package contrib -Summary: contrib tools for quagga +Summary: contrib tools for frr Group: System Environment/Daemons %description contrib -Contributed/3rd party tools which may be of use with quagga. +Contributed/3rd party tools which may be of use with frr. %package devel -Summary: Header and object files for quagga development +Summary: Header and object files for frr development Group: System Environment/Daemons Requires: %{name} = %{version}-%{release} %description devel -The quagga-devel package contains the header and object files neccessary for -developing OSPF-API and quagga applications. +The frr-devel package contains the header and object files neccessary for +developing OSPF-API and frr applications. %prep -%setup -q -n quagga-%{quaggaversion} +%setup -q -n frr-%{frrversion} %build @@ -220,9 +218,9 @@ developing OSPF-API and quagga applications. %if %{with_pam} --with-libpam \ %endif -%if 0%{?quagga_user:1} - --enable-user=%quagga_user \ - --enable-group=%quagga_user \ +%if 0%{?frr_user:1} + --enable-user=%frr_user \ + --enable-group=%frr_user \ %endif %if 0%{?vty_group:1} --enable-vty-group=%vty_group \ @@ -251,15 +249,15 @@ make %{?_smp_mflags} MAKEINFO="makeinfo --no-split" pushd doc %if %{texi2htmlversion} < 5 -texi2html --number-sections quagga.texi +texi2html --number-sections frr.texi %else -texi2html --number-footnotes --number-sections quagga.texi +texi2html --number-footnotes --number-sections frr.texi %endif popd %install -mkdir -p %{buildroot}/etc/{quagga,sysconfig,logrotate.d,pam.d,default} \ - %{buildroot}/var/log/quagga %{buildroot}%{_infodir} +mkdir -p %{buildroot}/etc/{frr,sysconfig,logrotate.d,pam.d,default} \ + %{buildroot}/var/log/frr %{buildroot}%{_infodir} make DESTDIR=%{buildroot} INSTALL="install -p" CP="cp -p" install # Remove this file, as it is uninstalled and causes errors when building on RH9 @@ -269,7 +267,7 @@ rm -rf %{buildroot}/usr/share/info/dir # install /etc sources %if "%{initsystem}" == "systemd" mkdir -p %{buildroot}%{_unitdir} -install %{quagga_tools}/frr.service \ +install %{frr_tools}/frr.service \ %{buildroot}%{_unitdir}/frr.service %else mkdir -p %{buildroot}/etc/rc.d/init.d @@ -281,14 +279,14 @@ for daemon in %{all_daemons} ; do done %endif -install %{cumulus_dir}/quagga/debian.conf %{buildroot}/etc/quagga -install %{cumulus_dir}/quagga/daemons %{buildroot}/etc/quagga -install -m644 %{cumulus_dir}/default/quagga %{buildroot}/etc/default -install -m644 %{zeb_rh_src}/quagga.pam \ - %{buildroot}/etc/pam.d/quagga -install -m644 %{zeb_rh_src}/quagga.logrotate \ - %{buildroot}/etc/logrotate.d/quagga -install -d -m750 %{buildroot}/var/run/quagga +install %{cumulus_dir}/frr/debian.conf %{buildroot}/etc/frr +install %{cumulus_dir}/frr/daemons %{buildroot}/etc/frr +install -m644 %{cumulus_dir}/default/frr %{buildroot}/etc/default +install -m644 %{zeb_rh_src}/frr.pam \ + %{buildroot}/etc/pam.d/frr +install -m644 %{zeb_rh_src}/frr.logrotate \ + %{buildroot}/etc/logrotate.d/frr +install -d -m750 %{buildroot}/var/run/frr %pre # add vty_group @@ -297,19 +295,19 @@ if getent group %vty_group > /dev/null ; then : ; else \ /usr/sbin/groupadd -r -g %vty_gid %vty_group > /dev/null || : ; fi %endif -# add quagga user and group -%if 0%{?quagga_user:1} -# Ensure that quagga_gid gets correctly allocated -if getent group %quagga_user >/dev/null; then : ; else \ - /usr/sbin/groupadd -g %quagga_gid %quagga_user > /dev/null || : ; \ +# add frr user and group +%if 0%{?frr_user:1} +# Ensure that frr_gid gets correctly allocated +if getent group %frr_user >/dev/null; then : ; else \ + /usr/sbin/groupadd -g %frr_gid %frr_user > /dev/null || : ; \ fi -if getent passwd %quagga_user >/dev/null ; then : ; else \ - /usr/sbin/useradd -u %quagga_uid -g %quagga_gid \ - -M -r -s /sbin/nologin -c "Quagga routing suite" \ - -d %_localstatedir %quagga_user 2> /dev/null || : ; \ +if getent passwd %frr_user >/dev/null ; then : ; else \ + /usr/sbin/useradd -u %frr_uid -g %frr_gid \ + -M -r -s /sbin/nologin -c "FreeRangeRouting suite" \ + -d %_localstatedir %frr_user 2> /dev/null || : ; \ fi %if 0%{?vty_group:1} -/usr/sbin/usermod -a -G %vty_group %quagga_user +/usr/sbin/usermod -a -G %vty_group %frr_user %endif %endif @@ -353,26 +351,26 @@ for daemon in %all_daemons ; do done %endif -/sbin/install-info %{_infodir}/quagga.info.gz %{_infodir}/dir +/sbin/install-info %{_infodir}/frr.info.gz %{_infodir}/dir # Create dummy files if they don't exist so basic functions can be used. if [ ! -e %{_sysconfdir}/zebra.conf ]; then echo "hostname `hostname`" > %{_sysconfdir}/zebra.conf -%if 0%{?quagga_user:1} - chown %quagga_user:%quagga_user %{_sysconfdir}/zebra.conf* +%if 0%{?frr_user:1} + chown %frr_user:%frr_user %{_sysconfdir}/zebra.conf* %endif chmod 640 %{_sysconfdir}/zebra.conf fi for daemon in %{all_daemons} ; do if [ ! -e %{_sysconfdir}/${daemon}.conf ]; then touch %{_sysconfdir}/${daemon}.conf - %if 0%{?quagga_user:1} - chown %quagga_user:%quagga_user %{_sysconfdir}/${daemon}.conf* + %if 0%{?frr_user:1} + chown %frr_user:%frr_user %{_sysconfdir}/${daemon}.conf* %endif fi done %if %{with_watchfrr} - # No config for watchfrr - this is part of /etc/sysconfig/quagga + # No config for watchfrr - this is part of /etc/sysconfig/frr rm -f %{_sysconfdir}/watchfrr.* %endif @@ -380,7 +378,7 @@ if [ ! -e %{_sysconfdir}/vtysh.conf ]; then touch %{_sysconfdir}/vtysh.conf chmod 640 %{_sysconfdir}/vtysh.conf %if 0%{?vty_group:1} - chown quagga:%{vty_group} %{_sysconfdir}/vtysh.conf* + chown frr:%{vty_group} %{_sysconfdir}/vtysh.conf* %endif fi @@ -477,7 +475,7 @@ fi done fi %endif -/sbin/install-info --delete %{_infodir}/quagga.info.gz %{_infodir}/dir +/sbin/install-info --delete %{_infodir}/frr.info.gz %{_infodir}/dir %clean %if !0%{?keep_build:1} @@ -487,29 +485,29 @@ rm -rf %{buildroot} %files %defattr(-,root,root) %doc */*.sample* AUTHORS COPYING -%doc doc/quagga.html +%doc doc/frr.html %doc doc/mpls %doc ChangeLog INSTALL NEWS README REPORTING-BUGS SERVICES -%if 0%{?quagga_user:1} -%dir %attr(751,%quagga_user,%quagga_user) %{_sysconfdir} -%dir %attr(750,%quagga_user,%quagga_user) /var/log/quagga -%dir %attr(751,%quagga_user,%quagga_user) /var/run/quagga +%if 0%{?frr_user:1} +%dir %attr(751,%frr_user,%frr_user) %{_sysconfdir} +%dir %attr(750,%frr_user,%frr_user) /var/log/frr +%dir %attr(751,%frr_user,%frr_user) /var/run/frr %else %dir %attr(750,root,root) %{_sysconfdir} -%dir %attr(750,root,root) /var/log/quagga -%dir %attr(750,root,root) /var/run/quagga +%dir %attr(750,root,root) /var/log/frr +%dir %attr(750,root,root) /var/run/frr %endif %if 0%{?vty_group:1} -%attr(750,%quagga_user,%vty_group) %{_sysconfdir}/vtysh.conf.sample +%attr(750,%frr_user,%vty_group) %{_sysconfdir}/vtysh.conf.sample %endif -%{_infodir}/quagga.info.gz +%{_infodir}/frr.info.gz %{_mandir}/man*/* %{_sbindir}/zebra %{_sbindir}/ospfd %{_sbindir}/ripd %{_sbindir}/bgpd %{_sbindir}/ssd -%{_sbindir}/quagga +%{_sbindir}/frr %{_sbindir}/frr-reload.py %{_sbindir}/frr-reload.pyc %{_sbindir}/frr-reload.pyo @@ -528,7 +526,7 @@ rm -rf %{buildroot} %attr(755,root,root) %{_libdir}/lib*.so.* %endif %{_bindir}/* -%config /etc/quagga/[!v]* +%config /etc/frr/[!v]* %if "%{initsystem}" == "systemd" %config %{_unitdir}/frr.service %else @@ -547,8 +545,8 @@ rm -rf %{buildroot} %config /etc/rc.d/init.d/ldpd %endif %endif -%config(noreplace) /etc/default/quagga -%config(noreplace) /etc/pam.d/quagga +%config(noreplace) /etc/default/frr +%config(noreplace) /etc/pam.d/frr %config(noreplace) %attr(640,root,root) /etc/logrotate.d/* %files contrib @@ -572,6 +570,9 @@ rm -rf %{buildroot} %endif %changelog +* Fri Jan 6 2017 Martin Winter +- Renamed to frr for FreeRangeRouting fork of Quagga + * Thu Feb 11 2016 Paul Jakma - %{version} - remove with_ipv6 conditionals, always build v6 - Fix UTF-8 char in spec changelog diff --git a/redhat/quagga.sysconfig b/redhat/frr.sysconfig similarity index 100% rename from redhat/quagga.sysconfig rename to redhat/frr.sysconfig diff --git a/redhat/isisd.init b/redhat/isisd.init index 9e805300d3..b309e07542 100644 --- a/redhat/isisd.init +++ b/redhat/isisd.init @@ -1,6 +1,6 @@ #!/bin/bash # chkconfig: - 16 84 -# config: /etc/quagga/isisd.conf +# config: /etc/frr/isisd.conf ### BEGIN INIT INFO # Provides: isisd @@ -14,14 +14,14 @@ # Get network config . /etc/sysconfig/network -# quagga command line options -. /etc/sysconfig/quagga +# frr command line options +. /etc/sysconfig/frr RETVAL=0 PROG="isisd" cmd=isisd LOCK_FILE=/var/lock/subsys/isisd -CONF_FILE=/etc/quagga/isisd.conf +CONF_FILE=/etc/frr/isisd.conf case "$1" in start) diff --git a/redhat/ldpd.init b/redhat/ldpd.init index b9b9538cb8..3ade9bfe9f 100644 --- a/redhat/ldpd.init +++ b/redhat/ldpd.init @@ -1,6 +1,6 @@ #!/bin/bash # chkconfig: - 16 84 -# config: /etc/quagga/ldpd.conf +# config: /etc/frr/ldpd.conf ### BEGIN INIT INFO # Provides: ldpd @@ -14,14 +14,14 @@ # Get network config . /etc/sysconfig/network -# quagga command line options -. /etc/sysconfig/quagga +# frr command line options +. /etc/sysconfig/frr RETVAL=0 PROG="ldpd" cmd=ldpd LOCK_FILE=/var/lock/subsys/ldpd -CONF_FILE=/etc/quagga/ldpd.conf +CONF_FILE=/etc/frr/ldpd.conf case "$1" in start) diff --git a/redhat/ospf6d.init b/redhat/ospf6d.init index 4133b4a14b..5c5a2af236 100644 --- a/redhat/ospf6d.init +++ b/redhat/ospf6d.init @@ -1,6 +1,6 @@ #!/bin/bash # chkconfig: - 16 84 -# config: /etc/quagga/ospf6d.conf +# config: /etc/frr/ospf6d.conf ### BEGIN INIT INFO # Provides: ospf6d @@ -14,14 +14,14 @@ # Get network config . /etc/sysconfig/network -# quagga command line options -. /etc/sysconfig/quagga +# frr command line options +. /etc/sysconfig/frr RETVAL=0 PROG="ospf6d" cmd=ospf6d LOCK_FILE=/var/lock/subsys/ospf6d -CONF_FILE=/etc/quagga/ospf6d.conf +CONF_FILE=/etc/frr/ospf6d.conf case "$1" in start) diff --git a/redhat/ospfd.init b/redhat/ospfd.init index d964f38dff..e9cbbc739c 100644 --- a/redhat/ospfd.init +++ b/redhat/ospfd.init @@ -1,6 +1,6 @@ #!/bin/bash # chkconfig: - 16 84 -# config: /etc/quagga/ospfd.conf +# config: /etc/frr/ospfd.conf ### BEGIN INIT INFO # Provides: ospfd @@ -14,14 +14,14 @@ # Get network config . /etc/sysconfig/network -# quagga command line options -. /etc/sysconfig/quagga +# frr command line options +. /etc/sysconfig/frr RETVAL=0 PROG="ospfd" cmd=ospfd LOCK_FILE=/var/lock/subsys/ospfd -CONF_FILE=/etc/quagga/ospfd.conf +CONF_FILE=/etc/frr/ospfd.conf case "$1" in start) diff --git a/redhat/pimd.init b/redhat/pimd.init index 49f90755d2..85cbf8d2b1 100644 --- a/redhat/pimd.init +++ b/redhat/pimd.init @@ -1,6 +1,6 @@ #!/bin/bash # chkconfig: - 16 84 -# config: /etc/quagga/pimd.conf +# config: /etc/frr/pimd.conf ### BEGIN INIT INFO # Provides: pimd @@ -14,14 +14,14 @@ # Get network config . /etc/sysconfig/network -# quagga command line options -. /etc/sysconfig/quagga +# frr command line options +. /etc/sysconfig/frr RETVAL=0 PROG="pimd" cmd=pimd LOCK_FILE=/var/lock/subsys/pimd -CONF_FILE=/etc/quagga/pimd.conf +CONF_FILE=/etc/frr/pimd.conf case "$1" in start) diff --git a/redhat/quagga.logrotate b/redhat/quagga.logrotate deleted file mode 100644 index 1f1baead0b..0000000000 --- a/redhat/quagga.logrotate +++ /dev/null @@ -1,63 +0,0 @@ -/var/log/quagga/zebra.log { - notifempty - missingok - postrotate - /bin/kill -USR1 `cat /var/run/quagga/zebra.pid 2> /dev/null` 2> /dev/null || true - endscript -} - -/var/log/quagga/bgpd.log { - notifempty - missingok - postrotate - /bin/kill -USR1 `cat /var/run/quagga/bgpd.pid 2> /dev/null` 2> /dev/null || true - endscript -} - -/var/log/quagga/isisd.log { - notifempty - missingok - postrotate - /bin/kill -USR1 `cat /var/run/quagga/isisd.pid 2> /dev/null` 2> /dev/null || true - endscript -} - -/var/log/quagga/ospfd.log { - notifempty - missingok - postrotate - /bin/kill -USR1 `cat /var/run/quagga/ospfd.pid 2> /dev/null` 2> /dev/null || true - endscript -} - -/var/log/quagga/ospf6d.log { - notifempty - missingok - postrotate - /bin/kill -USR1 `cat /var/run/quagga/ospf6d.pid 2> /dev/null` 2> /dev/null || true - endscript -} - -/var/log/quagga/ripd.log { - notifempty - missingok - postrotate - /bin/kill -USR1 `cat /var/run/quagga/ripd.pid 2> /dev/null` 2> /dev/null || true - endscript -} - -/var/log/quagga/ripngd.log { - notifempty - missingok - postrotate - /bin/kill -USR1 `cat /var/run/quagga/ripngd.pid 2> /dev/null` 2> /dev/null || true - endscript -} - -/var/log/quagga/ldpd.log { - notifempty - missingok - postrotate - /bin/kill -USR1 `cat /var/run/quagga/ldpd.pid 2> /dev/null` 2> /dev/null || true - endscript -} diff --git a/redhat/ripd.init b/redhat/ripd.init index 9b412cb965..8e25a83f4b 100644 --- a/redhat/ripd.init +++ b/redhat/ripd.init @@ -1,6 +1,6 @@ #!/bin/bash # chkconfig: - 16 84 -# config: /etc/quagga/ripd.conf +# config: /etc/frr/ripd.conf ### BEGIN INIT INFO # Provides: ripd @@ -14,14 +14,14 @@ # Get network config . /etc/sysconfig/network -# quagga command line options -. /etc/sysconfig/quagga +# frr command line options +. /etc/sysconfig/frr RETVAL=0 PROG="ripd" cmd=ripd LOCK_FILE=/var/lock/subsys/ripd -CONF_FILE=/etc/quagga/ripd.conf +CONF_FILE=/etc/frr/ripd.conf case "$1" in start) diff --git a/redhat/ripngd.init b/redhat/ripngd.init index 88f346f86d..7b9fde4085 100644 --- a/redhat/ripngd.init +++ b/redhat/ripngd.init @@ -1,6 +1,6 @@ #!/bin/bash # chkconfig: - 16 84 -# config: /etc/quagga/ripngd.conf +# config: /etc/frr/ripngd.conf ### BEGIN INIT INFO # Provides: ripngd @@ -14,14 +14,14 @@ # Get network config . /etc/sysconfig/network -# quagga command line options -. /etc/sysconfig/quagga +# frr command line options +. /etc/sysconfig/frr RETVAL=0 PROG="ripngd" cmd=ripngd LOCK_FILE=/var/lock/subsys/ripngd -CONF_FILE=/etc/quagga/ripngd.conf +CONF_FILE=/etc/frr/ripngd.conf case "$1" in start) diff --git a/redhat/watchquagga.init b/redhat/watchfrr.init similarity index 97% rename from redhat/watchquagga.init rename to redhat/watchfrr.init index 51259edc05..bc83415167 100644 --- a/redhat/watchquagga.init +++ b/redhat/watchfrr.init @@ -14,7 +14,7 @@ . /etc/sysconfig/network # frr command line options -. /etc/sysconfig/quagga +. /etc/sysconfig/frr RETVAL=0 PROG="watchfrr" diff --git a/redhat/zebra.init b/redhat/zebra.init index 4242b16c43..1afb785431 100644 --- a/redhat/zebra.init +++ b/redhat/zebra.init @@ -1,6 +1,6 @@ #!/bin/bash # chkconfig: - 15 85 -# config: /etc/quagga/zebra.conf +# config: /etc/frr/zebra.conf ### BEGIN INIT INFO # Provides: zebra @@ -14,14 +14,14 @@ # Get network config . /etc/sysconfig/network -# quagga command line options -. /etc/sysconfig/quagga +# frr command line options +. /etc/sysconfig/frr RETVAL=0 PROG="zebra" cmd=zebra LOCK_FILE=/var/lock/subsys/zebra -CONF_FILE=/etc/quagga/zebra.conf +CONF_FILE=/etc/frr/zebra.conf case "$1" in start) From c97ef3822361668a9dd917b3e0f7c4ca8e2e82d8 Mon Sep 17 00:00:00 2001 From: Martin Winter Date: Sat, 7 Jan 2017 00:10:57 +0700 Subject: [PATCH 067/107] cumulus files: Rename Project from Quagga to FRR Default files used by redhat package scripts Signed-off-by: Martin Winter --- cumulus/Makefile.am | 2 +- cumulus/etc/default/{quagga => frr} | 0 cumulus/etc/frr/Frr.conf | 2 ++ cumulus/etc/{quagga => frr}/daemons | 14 +++++++------- cumulus/etc/{quagga => frr}/debian.conf | 6 +++--- cumulus/etc/{quagga => frr}/vtysh.conf | 0 cumulus/etc/quagga/Quagga.conf | 2 -- .../etc/sudoers.d/{quagga_sudoers => frr_sudoers} | 6 +++--- 8 files changed, 16 insertions(+), 16 deletions(-) rename cumulus/etc/default/{quagga => frr} (100%) create mode 100644 cumulus/etc/frr/Frr.conf rename cumulus/etc/{quagga => frr}/daemons (61%) rename cumulus/etc/{quagga => frr}/debian.conf (63%) rename cumulus/etc/{quagga => frr}/vtysh.conf (100%) delete mode 100644 cumulus/etc/quagga/Quagga.conf rename cumulus/etc/sudoers.d/{quagga_sudoers => frr_sudoers} (70%) diff --git a/cumulus/Makefile.am b/cumulus/Makefile.am index 852af344af..027862314c 100644 --- a/cumulus/Makefile.am +++ b/cumulus/Makefile.am @@ -1,5 +1,5 @@ sbin_PROGRAMS = ssd -EXTRA_DIST = etc/quagga/debian.conf etc/quagga/daemons etc/default/quagga +EXTRA_DIST = etc/frr/debian.conf etc/frr/daemons etc/default/frr ssd_SOURCES = start-stop-daemon.c diff --git a/cumulus/etc/default/quagga b/cumulus/etc/default/frr similarity index 100% rename from cumulus/etc/default/quagga rename to cumulus/etc/default/frr diff --git a/cumulus/etc/frr/Frr.conf b/cumulus/etc/frr/Frr.conf new file mode 100644 index 0000000000..2cd05bf803 --- /dev/null +++ b/cumulus/etc/frr/Frr.conf @@ -0,0 +1,2 @@ +log file /var/log/frr/frr.log +log timestamp precision 6 diff --git a/cumulus/etc/quagga/daemons b/cumulus/etc/frr/daemons similarity index 61% rename from cumulus/etc/quagga/daemons rename to cumulus/etc/frr/daemons index c7b8496a4e..cf03cd9de1 100644 --- a/cumulus/etc/quagga/daemons +++ b/cumulus/etc/frr/daemons @@ -1,25 +1,25 @@ -# This file tells the quagga package which daemons to start. +# This file tells the frr package which daemons to start. # # Entries are in the format: =(yes|no|priority) # 0, "no" = disabled # 1, "yes" = highest priority # 2 .. 10 = lower priorities -# Read /usr/share/doc/quagga/README.Debian for details. +# Read /usr/share/doc/frr/README.Debian for details. # # Sample configurations for these daemons can be found in -# /usr/share/doc/quagga/examples/. +# /usr/share/doc/frr/examples/. # # ATTENTION: # # When activation a daemon at the first time, a config file, even if it is -# empty, has to be present *and* be owned by the user and group "quagga", else -# the daemon will not be started by /etc/init.d/quagga. The permissions should +# empty, has to be present *and* be owned by the user and group "frr", else +# the daemon will not be started by /etc/init.d/frr. The permissions should # be u=rw,g=r,o=. # When using "vtysh" such a config file is also needed. It should be owned by -# group "quaggavty" and set to ug=rw,o= though. Check /etc/pam.d/quagga, too. +# group "frrvty" and set to ug=rw,o= though. Check /etc/pam.d/frr, too. # # The watchfrr daemon is always started. Per default in monitoring-only but -# that can be changed via /etc/quagga/debian.conf. +# that can be changed via /etc/frr/debian.conf. # zebra=no bgpd=no diff --git a/cumulus/etc/quagga/debian.conf b/cumulus/etc/frr/debian.conf similarity index 63% rename from cumulus/etc/quagga/debian.conf rename to cumulus/etc/frr/debian.conf index bd1fcecf9f..8f3e1c1db6 100644 --- a/cumulus/etc/quagga/debian.conf +++ b/cumulus/etc/frr/debian.conf @@ -1,7 +1,7 @@ # -# If this option is set the /etc/init.d/quagga script automatically loads +# If this option is set the /etc/init.d/frr script automatically loads # the config via "vtysh -b" when the servers are started. -# Check /etc/pam.d/quagga if you intend to use "vtysh"! +# Check /etc/pam.d/frr if you intend to use "vtysh"! # vtysh_enable=yes zebra_options=" -s 90000000 --daemon -A 127.0.0.1" @@ -15,4 +15,4 @@ pimd_options=" --daemon -A 127.0.0.1" # The list of daemons to watch is automatically generated by the init script. watchfrr_enable=yes -watchfrr_options=(-adz -r /usr/sbin/servicebBquaggabBrestartbB%s -s /usr/sbin/servicebBquaggabBstartbB%s -k /usr/sbin/servicebBquaggabBstopbB%s -b bB -t 30) +watchfrr_options=(-adz -r /usr/sbin/servicebBfrrbBrestartbB%s -s /usr/sbin/servicebBfrrbBstartbB%s -k /usr/sbin/servicebBfrrbBstopbB%s -b bB -t 30) diff --git a/cumulus/etc/quagga/vtysh.conf b/cumulus/etc/frr/vtysh.conf similarity index 100% rename from cumulus/etc/quagga/vtysh.conf rename to cumulus/etc/frr/vtysh.conf diff --git a/cumulus/etc/quagga/Quagga.conf b/cumulus/etc/quagga/Quagga.conf deleted file mode 100644 index e52f3f8aab..0000000000 --- a/cumulus/etc/quagga/Quagga.conf +++ /dev/null @@ -1,2 +0,0 @@ -log file /var/log/quagga/quagga.log -log timestamp precision 6 diff --git a/cumulus/etc/sudoers.d/quagga_sudoers b/cumulus/etc/sudoers.d/frr_sudoers similarity index 70% rename from cumulus/etc/sudoers.d/quagga_sudoers rename to cumulus/etc/sudoers.d/frr_sudoers index 4375d7e5fa..4a42fb24f4 100644 --- a/cumulus/etc/sudoers.d/quagga_sudoers +++ b/cumulus/etc/sudoers.d/frr_sudoers @@ -1,7 +1,7 @@ Defaults env_keep += VTYSH_PAGER -# Allow user in group quagga to run vtysh show commands -# without a password by uncommenting the "%quagga" line below. +# Allow user in group frr to run vtysh show commands +# without a password by uncommenting the "%frr" line below. # Subshell commands need to be disallowed, including # preventing the user passing command line args like 'start-shell' @@ -11,5 +11,5 @@ Defaults env_keep += VTYSH_PAGER # Instead, use NOEXEC, to prevent any exec'ed commands. Cmnd_Alias VTY_SHOW = /usr/bin/vtysh -c show * -# %quagga ALL = (root) NOPASSWD:NOEXEC: VTY_SHOW +# %frr ALL = (root) NOPASSWD:NOEXEC: VTY_SHOW From 8b0cdbb8aaf0d80ef74a468430fa28ae3144245c Mon Sep 17 00:00:00 2001 From: Martin Winter Date: Sat, 7 Jan 2017 00:12:16 +0700 Subject: [PATCH 068/107] configure.ac: rename red hat spec from quagga.spec to frr.spec Signed-off-by: Martin Winter --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index c62857c325..6375e5d78a 100755 --- a/configure.ac +++ b/configure.ac @@ -1616,7 +1616,7 @@ AC_CONFIG_FILES([Makefile lib/Makefile qpb/Makefile zebra/Makefile ripd/Makefile cumulus/Makefile pkgsrc/Makefile fpm/Makefile - redhat/quagga.spec + redhat/frr.spec lib/version.h doc/defines.texi doc/bgpd.8 From e14fda0fb4de174090a953e09fb677f1cfeddcbb Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 6 Jan 2017 12:24:03 -0500 Subject: [PATCH 069/107] bgpd: Allow 'neighbor X local-as Y' to have large values On ARM platforms specifying a local-as greater than 2 billion causes issues due to atoi usage. Ticket: CM-14019 Signed-off-by: Donald Sharp --- bgpd/bgp_vty.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 29649c5b24..b435543e39 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -3237,12 +3237,13 @@ DEFUN (neighbor_local_as, { struct peer *peer; int ret; - + as_t as; peer = peer_and_group_lookup_vty (vty, argv[0]); if (! peer) return CMD_WARNING; - ret = peer_local_as_set (peer, atoi (argv[1]), 0, 0); + VTY_GET_INTEGER_RANGE ("Local AS", as, argv[1], 1, BGP_AS4_MAX); + ret = peer_local_as_set (peer, as, 0, 0); return bgp_vty_return (vty, ret); } @@ -3257,12 +3258,14 @@ DEFUN (neighbor_local_as_no_prepend, { struct peer *peer; int ret; + as_t as; peer = peer_and_group_lookup_vty (vty, argv[0]); if (! peer) return CMD_WARNING; - ret = peer_local_as_set (peer, atoi (argv[1]), 1, 0); + VTY_GET_INTEGER_RANGE ("Local AS", as, argv[1], 1, BGP_AS4_MAX); + ret = peer_local_as_set (peer, as, 1, 0); return bgp_vty_return (vty, ret); } @@ -3278,12 +3281,14 @@ DEFUN (neighbor_local_as_no_prepend_replace_as, { struct peer *peer; int ret; + as_t as; peer = peer_and_group_lookup_vty (vty, argv[0]); if (! peer) return CMD_WARNING; - ret = peer_local_as_set (peer, atoi (argv[1]), 1, 1); + VTY_GET_INTEGER_RANGE ("Local AS", as, argv[1], 1, BGP_AS4_MAX); + ret = peer_local_as_set (peer, as, 1, 1); return bgp_vty_return (vty, ret); } From ec91182539f592ddd4d19228d728e5ec7623c196 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 6 Jan 2017 12:25:55 -0500 Subject: [PATCH 070/107] zebra: Allow tag values greater than 2 billion on arm Due to the usage of atol, values that are larger than 2 billion on arm for tag are not converted correctly. Ticket: CM-14099 Signed-off-by: Donald Sharp --- zebra/zebra_vty.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index 98c20270c3..5088198624 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -104,7 +104,7 @@ zebra_static_ipv4 (struct vty *vty, safi_t safi, int add_cmd, /* tag */ if (tag_str) - tag = atol(tag_str); + VTY_GET_INTEGER_RANGE("tag", tag, tag_str, 0, 4294967295); /* VRF id */ zvrf = zebra_vrf_lookup_by_name (vrf_id_str); @@ -2707,11 +2707,11 @@ DEFUN (show_ip_route_tag, if (argc > 1) { - tag = atol(argv[1]); + VTY_GET_INTEGER_RANGE("tag", tag, argv[1], 0, 4294967295); VRF_GET_ID (vrf_id, argv[0]); } else - tag = atol(argv[0]); + VTY_GET_INTEGER_RANGE("tag", tag, argv[0], 0, 4294967295); table = zebra_vrf_table (AFI_IP, SAFI_UNICAST, vrf_id); if (! table) @@ -3341,7 +3341,7 @@ DEFUN (show_ip_route_vrf_all_tag, route_tag_t tag = 0; if (argv[0]) - tag = atol(argv[0]); + VTY_GET_INTEGER_RANGE("tag", tag, argv[0], 0, 4294967295); RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) { @@ -3777,7 +3777,7 @@ static_ipv6_func (struct vty *vty, int add_cmd, const char *dest_str, /* tag */ if (tag_str) - tag = atol(tag_str); + VTY_GET_INTEGER_RANGE("tag", tag, tag_str, 0, 4294967295); /* When gateway is valid IPv6 addrees, then gate is treated as nexthop address other case gate is treated as interface name. */ @@ -5026,10 +5026,10 @@ DEFUN (show_ipv6_route_tag, if (argc > 1) { VRF_GET_ID (vrf_id, argv[0]); - tag = atol(argv[1]); + VTY_GET_INTEGER_RANGE("tag", tag, argv[1], 0, 4294967295); } else - tag = atol(argv[0]); + VTY_GET_INTEGER_RANGE("tag", tag, argv[0], 0, 4294967295); table = zebra_vrf_table (AFI_IP6, SAFI_UNICAST, vrf_id); if (! table) @@ -5469,7 +5469,7 @@ DEFUN (show_ipv6_route_vrf_all_tag, route_tag_t tag = 0; if (argv[0]) - tag = atol(argv[0]); + VTY_GET_INTEGER_RANGE("tag", tag, argv[0], 0, 4294967295); RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) { From 07f2fb1374661390f48bc1fd748b5a72ecd4f60b Mon Sep 17 00:00:00 2001 From: Christian Franke Date: Fri, 6 Jan 2017 20:19:40 +0100 Subject: [PATCH 071/107] isisd: clean up own LSPs correctly on update Signed-off-by: Christian Franke --- isisd/isis_lsp.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/isisd/isis_lsp.c b/isisd/isis_lsp.c index dedf2a71dd..c13bcc5d8a 100644 --- a/isisd/isis_lsp.c +++ b/isisd/isis_lsp.c @@ -550,6 +550,14 @@ lsp_update (struct isis_lsp *lsp, struct stream *stream, if (dnode) dnode_destroy (dict_delete (area->lspdb[level - 1], dnode)); + if (lsp->own_lsp) + { + zlog_err("ISIS-Upd (%s): BUG updating LSP %s still marked as own LSP", + area->area_tag, rawlspid_print(lsp->lsp_header->lsp_id)); + lsp_clear_data(lsp); + lsp->own_lsp = 0; + } + /* rebuild the lsp data */ lsp_update_data (lsp, stream, area, level); From 46f296b4029da9fe165953d432fb589c7070bfc9 Mon Sep 17 00:00:00 2001 From: Lou Berger Date: Fri, 6 Jan 2017 10:50:31 -0500 Subject: [PATCH 072/107] bgpd: restore some missing afi/safi commands (Issue #14) Added defines and parse utility functions Fix vty code that treated vpn&encap as AFIs and some other related vty printing/handline issues --- bgpd/bgp_route.c | 37 ++---- bgpd/bgp_vty.c | 285 +++++++++++++++++++++++------------------------ bgpd/bgp_vty.h | 23 +++- 3 files changed, 167 insertions(+), 178 deletions(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 511cb882bb..0df3a0c800 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -8804,39 +8804,20 @@ bgp_table_stats_vty (struct vty *vty, const char *name, vty_out (vty, "%% No such BGP instance exist%s", VTY_NEWLINE); return CMD_WARNING; } - if (strncmp (afi_str, "ipv", 3) == 0) - { - if (strncmp (afi_str, "ipv4", 4) == 0) - afi = AFI_IP; - else if (strncmp (afi_str, "ipv6", 4) == 0) - afi = AFI_IP6; - else - { - vty_out (vty, "%% Invalid address family %s%s", - afi_str, VTY_NEWLINE); - return CMD_WARNING; - } - if (strncmp (safi_str, "m", 1) == 0) - safi = SAFI_MULTICAST; - else if (strncmp (safi_str, "u", 1) == 0) - safi = SAFI_UNICAST; - else if (strncmp (safi_str, "e", 1) == 0) - safi = SAFI_ENCAP; - else if (strncmp (safi_str, "vpnv4", 5) == 0 || strncmp (safi_str, "vpnv6", 5) == 0) - safi = SAFI_MPLS_VPN; - else - { - vty_out (vty, "%% Invalid subsequent address family %s%s", - safi_str, VTY_NEWLINE); - return CMD_WARNING; - } - } - else + afi = bgp_vty_afi_from_arg(afi_str); + if (afi == AFI_MAX) { vty_out (vty, "%% Invalid address family \"%s\"%s", afi_str, VTY_NEWLINE); return CMD_WARNING; } + safi = bgp_vty_safi_from_arg(safi_str); + if (safi == SAFI_MAX) + { + vty_out (vty, "%% Invalid subsequent address family %s%s", + safi_str, VTY_NEWLINE); + return CMD_WARNING; + } return bgp_table_stats (vty, bgp, afi, safi); } diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index a86908f199..d39df63a18 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -107,23 +107,52 @@ bgp_node_safi (struct vty *vty) return safi; } +/* supports */ +afi_t +bgp_vty_afi_from_arg(const char *afi_str) +{ + afi_t afi = AFI_MAX; /* unknown */ + if (!strcmp(afi_str, "ipv4")) { + afi = AFI_IP; + } +#ifdef HAVE_IPV6 + else if (!strcmp(afi_str, "ipv6")) { + afi = AFI_IP6; + } +#endif /* HAVE_IPV6 */ + return afi; +} + int bgp_parse_afi(const char *str, afi_t *afi) { - if (!strcmp(str, "ipv4")) { - *afi = AFI_IP; - return 0; - } -#ifdef HAVE_IPV6 - if (!strcmp(str, "ipv6")) { - *afi = AFI_IP6; - return 0; - } -#endif /* HAVE_IPV6 */ + *afi = bgp_vty_afi_from_arg(str); + if (*afi != AFI_MAX) + return 0; + else return -1; } -/* supports (unicast|multicast|vpn|encap) */ +int +argv_find_and_parse_afi(struct cmd_token **argv, int argc, int *index, afi_t *afi) +{ + int ret = 0; + if (argv_find (argv, argc, "ipv4", index)) + { + ret = 1; + if (afi) + *afi = AFI_IP; + } + else if (argv_find (argv, argc, "ipv6", index)) + { + ret = 1; + if (afi) + *afi = AFI_IP6; + } + return ret; +} + +/* supports */ safi_t bgp_vty_safi_from_arg(const char *safi_str) { @@ -135,7 +164,7 @@ bgp_vty_safi_from_arg(const char *safi_str) else if (strncmp (safi_str, "e", 1) == 0) safi = SAFI_ENCAP; else if (strncmp (safi_str, "v", 1) == 0) - safi = SAFI_MPLS_VPN; + safi = SAFI_MPLS_VPN; return safi; } @@ -149,6 +178,37 @@ bgp_parse_safi(const char *str, safi_t *safi) return -1; } +int +argv_find_and_parse_safi(struct cmd_token **argv, int argc, int *index, safi_t *safi) +{ + int ret = 0; + if (argv_find (argv, argc, "unicast", index)) + { + ret = 1; + if (safi) + *safi = SAFI_UNICAST; + } + else if (argv_find (argv, argc, "multicast", index)) + { + ret = 1; + if (safi) + *safi = SAFI_MULTICAST; + } + else if (argv_find (argv, argc, "vpn", index)) + { + ret = 1; + if (safi) + *safi = SAFI_MPLS_VPN; + } + else if (argv_find (argv, argc, "encap", index)) + { + ret = 1; + if (safi) + *safi = SAFI_ENCAP; + } + return ret; +} + static int peer_address_self_check (struct bgp *bgp, union sockunion *su) { @@ -363,10 +423,8 @@ bgp_clear_vty_error (struct vty *vty, struct peer *peer, afi_t afi, { case BGP_ERR_AF_UNCONFIGURED: vty_out (vty, - "%%BGP: Enable %s %s address family for the neighbor %s%s", - afi == AFI_IP6 ? "IPv6" : safi == SAFI_MPLS_VPN ? "VPNv4" : "IPv4", - safi == SAFI_MULTICAST ? "Multicast" : "Unicast", - peer->host, VTY_NEWLINE); + "%%BGP: Enable %s address family for the neighbor %s%s", + afi_safi_print(afi, safi), peer->host, VTY_NEWLINE); break; case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: vty_out (vty, "%%BGP: Inbound soft reconfig for %s not possible as it%s has neither refresh capability, nor inbound soft reconfig%s", peer->host, VTY_NEWLINE, VTY_NEWLINE); @@ -5440,13 +5498,10 @@ DEFUN (address_family_ipv4, DEFUN (address_family_ipv4_safi, address_family_ipv4_safi_cmd, - "address-family ipv4 ", + "address-family ipv4 "BGP_SAFI_CMD_STR, "Enter Address Family command mode\n" "Address Family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family modifier\n") + BGP_SAFI_HELP_STR) { int idx_safi = 2; switch (bgp_vty_safi_from_arg(argv[idx_safi]->arg)) @@ -5481,19 +5536,28 @@ DEFUN (address_family_ipv6, DEFUN (address_family_ipv6_safi, address_family_ipv6_safi_cmd, - "address-family ipv6 ", + "address-family ipv6 "BGP_SAFI_CMD_STR, "Enter Address Family command mode\n" "Address Family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family modifier\n") + BGP_SAFI_HELP_STR) { int idx_safi = 2; - if (strncmp (argv[idx_safi]->arg, "m", 1) == 0) - vty->node = BGP_IPV6M_NODE; - else - vty->node = BGP_IPV6_NODE; + switch (bgp_vty_safi_from_arg(argv[idx_safi]->arg)) + { + case SAFI_MULTICAST: + vty->node = BGP_IPV6M_NODE; + break; + case SAFI_ENCAP: + vty->node = BGP_ENCAPV6_NODE; + break; + case SAFI_MPLS_VPN: + vty->node = BGP_VPNV6_NODE; + break; + case SAFI_UNICAST: + default: + vty->node = BGP_IPV6_NODE; + break; + } return CMD_SUCCESS; } @@ -5643,7 +5707,7 @@ bgp_clear_prefix (struct vty *vty, const char *view_name, const char *ip_str, /* one clear bgp command to rule them all */ DEFUN (clear_ip_bgp_all, clear_ip_bgp_all_cmd, - "clear [ip] bgp [ WORD] []|ipv6 []] <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> []|in [prefix-filter]|out>]", + "clear [ip] bgp [ WORD] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] <*|A.B.C.D|X:X::X:X|WORD|(1-4294967295)|external|peer-group WORD> []|in [prefix-filter]|out>]", CLEAR_STR IP_STR BGP_STR @@ -5656,20 +5720,8 @@ DEFUN (clear_ip_bgp_all, "Clear all external peers\n" "Clear all members of peer-group\n" "BGP peer-group name\n" - "Address Family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family\n" - "Address Family modifier\n" - "Address Family\n" - "Address Family modifier\n" + BGP_AFI_HELP_STR + BGP_SAFI_HELP_STR BGP_SOFT_STR BGP_SOFT_IN_STR BGP_SOFT_OUT_STR @@ -5746,19 +5798,10 @@ DEFUN (clear_ip_bgp_all, { clr_sort = clear_external; } - /* []|ipv6 []|encap [unicast]||vpnv4 [unicast]>] */ - if (argv_find (argv, argc, "ipv4", &idx) || argv_find (argv, argc, "ipv6", &idx)) + /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ + if (argv_find_and_parse_afi (argv, argc, &idx, &afi)) { - afi = strmatch(argv[idx]->text, "ipv6") ? AFI_IP6 : AFI_IP; - if (argv_find (argv, argc, "unicast", &idx) || argv_find (argv, argc, "multicast", &idx)) - safi = bgp_vty_safi_from_arg (argv[idx]->text); - } - else if (argv_find (argv, argc, "encap", &idx) || argv_find (argv, argc, "vpnv4", &idx)) - { - afi = AFI_IP; - safi = bgp_vty_safi_from_arg (argv[idx]->text); - // advance idx if necessary - argv_find (argv, argc, "unicast", &idx); + argv_find_and_parse_safi (argv, argc, &idx, &safi); } /* []|in [prefix-filter]|out>] */ if (argv_find (argv, argc, "soft", &idx)) @@ -5808,44 +5851,38 @@ DEFUN (clear_ip_bgp_prefix, DEFUN (clear_bgp_ipv6_safi_prefix, clear_bgp_ipv6_safi_prefix_cmd, - "clear [ip] bgp ipv6 prefix X:X::X:X/M", + "clear [ip] bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", CLEAR_STR IP_STR BGP_STR "Address Family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR "Clear bestpath and re-advertise\n" "IPv6 prefix\n") { int idx_safi = 3; int idx_ipv6_prefixlen = 5; - safi_t safi = bgp_vty_safi_from_arg (argv[idx_safi]->arg); - return bgp_clear_prefix (vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, safi, NULL); + return bgp_clear_prefix (vty, NULL, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, + bgp_vty_safi_from_arg(argv[idx_safi]->arg), NULL); } DEFUN (clear_bgp_instance_ipv6_safi_prefix, clear_bgp_instance_ipv6_safi_prefix_cmd, - "clear [ip] bgp WORD ipv6 prefix X:X::X:X/M", + "clear [ip] bgp WORD ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", CLEAR_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR "Address Family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR "Clear bestpath and re-advertise\n" "IPv6 prefix\n") { int idx_word = 3; int idx_safi = 5; int idx_ipv6_prefixlen = 7; - safi_t safi = bgp_vty_safi_from_arg (argv[idx_safi]->text); - return bgp_clear_prefix (vty, argv[idx_word]->arg, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, safi, NULL); + return bgp_clear_prefix (vty, argv[idx_word]->arg, argv[idx_ipv6_prefixlen]->arg, AFI_IP6, + bgp_vty_safi_from_arg(argv[idx_safi]->arg), NULL); } DEFUN (show_bgp_views, @@ -6465,10 +6502,10 @@ bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi, { if (use_json) vty_out(vty, "{\"error\": {\"message\": \"No %s neighbor configured\"}}%s", - afi == AFI_IP ? "IPv4" : "IPv6", VTY_NEWLINE); + afi_safi_print(afi, safi), VTY_NEWLINE); else vty_out (vty, "No %s neighbor is configured%s", - afi == AFI_IP ? "IPv4" : "IPv6", VTY_NEWLINE); + afi_safi_print(afi, safi), VTY_NEWLINE); } if (dn_count && ! use_json) @@ -6566,30 +6603,18 @@ bgp_show_summary_vty (struct vty *vty, const char *name, /* `show [ip] bgp summary' commands. */ DEFUN (show_ip_bgp_summary, show_ip_bgp_summary_cmd, - "show [ip] bgp [ WORD] []|ipv6 []|vpnv4 >] summary [json]", + "show [ip] bgp [ WORD] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] summary [json]", SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR - "Address Family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family\n" - "Display information about all VPNv4 NLRIs\n" - "Display information for a route distinguisher\n" - "VPN Route Distinguisher\n" + BGP_AFI_HELP_STR + BGP_SAFI_HELP_STR "Summary of BGP neighbor status\n" JSON_STR) { char *vrf = NULL; - afi_t afi = AFI_IP6; + afi_t afi = AFI_IP6; /* why default to v6? */ safi_t safi = SAFI_UNICAST; int idx = 0; @@ -6600,23 +6625,10 @@ DEFUN (show_ip_bgp_summary, /* [ WORD] */ if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx)) vrf = argv[++idx]->arg; - /* []|ipv6 []|encap [unicast]|vpnv4 [unicast]>] */ - if (argv_find (argv, argc, "ipv4", &idx) || argv_find (argv, argc, "ipv6", &idx)) + /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ + if (argv_find_and_parse_afi (argv, argc, &idx, &afi)) { - afi = strmatch(argv[idx]->text, "ipv6") ? AFI_IP6 : AFI_IP; - if (argv_find (argv, argc, "unicast", &idx) || argv_find (argv, argc, "multicast", &idx)) - safi = bgp_vty_safi_from_arg (argv[idx]->text); - } - else if (argv_find (argv, argc, "encap", &idx)) - { - afi = AFI_IP; - safi = SAFI_ENCAP; - } - else if (argv_find (argv, argc, "vpnv4", &idx)) - { - // we show the same thing regardless of rd and all - afi = AFI_IP; - safi = SAFI_MPLS_VPN; + argv_find_and_parse_safi (argv, argc, &idx, &safi); } int uj = use_json (argc, argv); @@ -6632,17 +6644,17 @@ afi_safi_print (afi_t afi, safi_t safi) else if (afi == AFI_IP && safi == SAFI_MULTICAST) return "IPv4 Multicast"; else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) - return "VPN-IPv4 Unicast"; + return "IPv4 VPN"; else if (afi == AFI_IP && safi == SAFI_ENCAP) - return "ENCAP-IPv4 Unicast"; + return "IPv4 Encap"; else if (afi == AFI_IP6 && safi == SAFI_UNICAST) return "IPv6 Unicast"; else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) return "IPv6 Multicast"; else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) - return "VPN-IPv6 Unicast"; + return "IPv6 VPN"; else if (afi == AFI_IP6 && safi == SAFI_ENCAP) - return "ENCAP-IPv6 Unicast"; + return "IPv6 Encap"; else return "Unknown"; } @@ -8507,14 +8519,11 @@ DEFUN (show_ip_bgp_neighbors, same.*/ DEFUN (show_ip_bgp_paths, show_ip_bgp_paths_cmd, - "show [ip] bgp [] paths", + "show [ip] bgp ["BGP_SAFI_CMD_STR"] paths", SHOW_STR IP_STR BGP_STR - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR "Path information\n") { vty_out (vty, "Address Refcnt Path%s", VTY_NEWLINE); @@ -8612,16 +8621,15 @@ bgp_show_update_groups(struct vty *vty, const char *name, DEFUN (show_ip_bgp_updgrps, show_ip_bgp_updgrps_cmd, - "show [ip] bgp [ WORD] []|ipv6 []|vpnv4 [unicast]>] update-groups [SUBGROUP-ID]", + "show [ip] bgp [ WORD] [] update-groups [SUBGROUP-ID]", SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR "Address Family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR + "Address Family\n" + BGP_SAFI_HELP_STR "Address Family\n" "Address Family modifier\n" "Address Family modifier\n" @@ -8645,7 +8653,7 @@ DEFUN (show_ip_bgp_updgrps, /* [ WORD] */ if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx)) vrf = argv[++idx]->arg; - /* []|ipv6 []|encap [unicast]|vpnv4 [unicast]>] */ + /* [] */ if (argv_find (argv, argc, "ipv4", &idx) || argv_find (argv, argc, "ipv6", &idx)) { afi = strmatch(argv[idx]->text, "ipv6") ? AFI_IP6 : AFI_IP; @@ -8780,16 +8788,11 @@ DEFUN (show_ip_bgp_instance_updgrps_adj, DEFUN (show_bgp_updgrps_afi_adj, show_bgp_updgrps_afi_adj_cmd, - "show [ip] bgp update-groups ", + "show [ip] bgp "BGP_AFI_SAFI_CMD_STR" update-groups ", SHOW_STR IP_STR BGP_STR - "Address Family\n" - "Address Family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_AFI_SAFI_HELP_STR "Detailed info about dynamic update groups\n" "Advertisement queue\n" "Announced routes\n" @@ -8799,12 +8802,10 @@ DEFUN (show_bgp_updgrps_afi_adj, int idx_afi = 2; int idx_safi = 3; int idx_type = 5; - afi_t afi; - safi_t safi; - - afi = (strcmp(argv[idx_afi]->arg, "ipv4") == 0) ? AFI_IP : AFI_IP6; - safi = bgp_vty_safi_from_arg(argv[idx_safi]->arg); - show_bgp_updgrps_adj_info_aux(vty, NULL, afi, safi, argv[idx_type]->arg, 0); + show_bgp_updgrps_adj_info_aux(vty, NULL, + bgp_vty_afi_from_arg(argv[idx_afi]->arg), + bgp_vty_safi_from_arg(argv[idx_safi]->arg), + argv[idx_type]->arg, 0); return CMD_SUCCESS; } @@ -8892,16 +8893,11 @@ DEFUN (show_ip_bgp_instance_updgrps_adj_s, DEFUN (show_bgp_updgrps_afi_adj_s, show_bgp_updgrps_afi_adj_s_cmd, - "show [ip] bgp update-groups SUBGROUP-ID ", + "show [ip] bgp "BGP_AFI_SAFI_CMD_STR" update-groups SUBGROUP-ID ", SHOW_STR IP_STR BGP_STR - "Address Family\n" - "Address Family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_AFI_SAFI_HELP_STR "Detailed info about dynamic update groups\n" "Specific subgroup to display info for\n" "Advertisement queue\n" @@ -8913,15 +8909,14 @@ DEFUN (show_bgp_updgrps_afi_adj_s, int idx_safi = 3; int idx_subgroup_id = 5; int idx_type = 6; - afi_t afi; - safi_t safi; uint64_t subgrp_id; - afi = (strmatch(argv[idx_afi]->text, "ipv4")) ? AFI_IP : AFI_IP6; - safi = bgp_vty_safi_from_arg(argv[idx_safi]->text); VTY_GET_ULL("subgroup-id", subgrp_id, argv[idx_subgroup_id]->arg); - show_bgp_updgrps_adj_info_aux(vty, NULL, afi, safi, argv[idx_type]->arg, subgrp_id); + show_bgp_updgrps_adj_info_aux(vty, NULL, + bgp_vty_afi_from_arg(argv[idx_afi]->arg), + bgp_vty_safi_from_arg(argv[idx_safi]->arg), + argv[idx_type]->arg, subgrp_id); return CMD_SUCCESS; } diff --git a/bgpd/bgp_vty.h b/bgpd/bgp_vty.h index 51b7280664..0fd2ae1be2 100644 --- a/bgpd/bgp_vty.h +++ b/bgpd/bgp_vty.h @@ -26,12 +26,16 @@ struct bgp; #define BGP_INSTANCE_HELP_STR "BGP view\nBGP VRF\nView/VRF name\n" #define BGP_INSTANCE_ALL_HELP_STR "BGP view\nBGP VRF\nAll Views/VRFs\n" -#define AFI_SAFI_STR \ - "Address family\n" \ - "Address Family modifier\n" \ - "Address Family modifier\n" \ - "Address Family modifier\n" \ +#define BGP_AFI_CMD_STR "" +#define BGP_AFI_HELP_STR "Address Family\nAddress Family\n" +#define BGP_SAFI_CMD_STR "" +#define BGP_SAFI_HELP_STR \ + "Address Family modifier\n" \ + "Address Family modifier\n" \ + "Address Family modifier\n" \ "Address Family modifier\n" +#define BGP_AFI_SAFI_CMD_STR BGP_AFI_CMD_STR" "BGP_SAFI_CMD_STR +#define BGP_AFI_SAFI_HELP_STR BGP_AFI_HELP_STR BGP_SAFI_HELP_STR extern void bgp_vty_init (void); extern const char *afi_safi_print (afi_t, safi_t); @@ -49,7 +53,16 @@ bgp_parse_afi(const char *str, afi_t *afi); extern int bgp_parse_safi(const char *str, safi_t *safi); +extern afi_t +bgp_vty_afi_from_arg(const char *afi_str); + extern safi_t bgp_vty_safi_from_arg(const char *safi_str); +extern int +argv_find_and_parse_afi(struct cmd_token **argv, int argc, int *index, afi_t *afi); + +extern int +argv_find_and_parse_safi(struct cmd_token **argv, int argc, int *index, safi_t *safi); + #endif /* _QUAGGA_BGP_VTY_H */ From 271627344c6c095f3ec70605660eb03dc1213e80 Mon Sep 17 00:00:00 2001 From: Lou Berger Date: Fri, 6 Jan 2017 18:25:56 -0500 Subject: [PATCH 073/107] bgpd: restore wildcard handling in show summary (Issue#14) --- bgpd/bgp_vty.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++--- bgpd/bgp_vty.h | 1 + 2 files changed, 85 insertions(+), 5 deletions(-) diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index d39df63a18..94598d6578 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -6520,6 +6520,62 @@ bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi, return CMD_SUCCESS; } +static void +bgp_show_summary_afi_safi (struct vty *vty, struct bgp *bgp, int afi, int safi, + u_char use_json, json_object *json) +{ + int is_first = 1; + int afi_wildcard = (afi == AFI_MAX); + int safi_wildcard = (safi == SAFI_MAX); + int is_wildcard = (afi_wildcard || safi_wildcard); + if (use_json && is_wildcard) + vty_out (vty, "{%s", VTY_NEWLINE); + if (afi_wildcard) + afi = 1; /* AFI_IP */ + while (afi < AFI_MAX) + { + if (safi_wildcard) + safi = 1; /* SAFI_UNICAST */ + while (safi < SAFI_MAX) + { + if (is_wildcard) + { + if (use_json) + { + json = json_object_new_object(); + + if (! is_first) + vty_out (vty, ",%s", VTY_NEWLINE); + else + is_first = 0; + + vty_out(vty, "\"%s\":", afi_safi_json(afi, safi)); + } + else + { + vty_out (vty, "%s%s Summary:%s", + VTY_NEWLINE, afi_safi_print(afi, safi), VTY_NEWLINE); + } + } + bgp_show_summary (vty, bgp, afi, safi, use_json, json); + if (safi == SAFI_MPLS_VPN) /* handle special cases to match zebra.h */ + safi = SAFI_ENCAP; + else + safi++; + if (! safi_wildcard) + safi = SAFI_MAX; + } + afi++; + if (! afi_wildcard || + afi == AFI_ETHER) /* special case, not handled yet */ + afi = AFI_MAX; + } + + if (use_json && is_wildcard) + vty_out (vty, "}%s", VTY_NEWLINE); + +} + static void bgp_show_all_instances_summary_vty (struct vty *vty, afi_t afi, safi_t safi, u_char use_json) @@ -6553,7 +6609,7 @@ bgp_show_all_instances_summary_vty (struct vty *vty, afi_t afi, safi_t safi, (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) ? "Default" : bgp->name, VTY_NEWLINE); } - bgp_show_summary (vty, bgp, afi, safi, use_json, json); + bgp_show_summary_afi_safi (vty, bgp, afi, safi, use_json, json); } if (use_json) @@ -6587,7 +6643,7 @@ bgp_show_summary_vty (struct vty *vty, const char *name, return CMD_WARNING; } - bgp_show_summary (vty, bgp, afi, safi, use_json, NULL); + bgp_show_summary_afi_safi (vty, bgp, afi, safi, use_json, NULL); return CMD_SUCCESS; } } @@ -6595,7 +6651,7 @@ bgp_show_summary_vty (struct vty *vty, const char *name, bgp = bgp_get_default (); if (bgp) - bgp_show_summary (vty, bgp, afi, safi, use_json, NULL); + bgp_show_summary_afi_safi (vty, bgp, afi, safi, use_json, NULL); return CMD_SUCCESS; } @@ -6614,8 +6670,8 @@ DEFUN (show_ip_bgp_summary, JSON_STR) { char *vrf = NULL; - afi_t afi = AFI_IP6; /* why default to v6? */ - safi_t safi = SAFI_UNICAST; + afi_t afi = AFI_MAX; + safi_t safi = SAFI_MAX; int idx = 0; @@ -6659,6 +6715,29 @@ afi_safi_print (afi_t afi, safi_t safi) return "Unknown"; } +const char * +afi_safi_json (afi_t afi, safi_t safi) +{ + if (afi == AFI_IP && safi == SAFI_UNICAST) + return "IPv4Unicast"; + else if (afi == AFI_IP && safi == SAFI_MULTICAST) + return "IPv4Multicast"; + else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) + return "IPv4VPN"; + else if (afi == AFI_IP && safi == SAFI_ENCAP) + return "IPv4Encap"; + else if (afi == AFI_IP6 && safi == SAFI_UNICAST) + return "IPv6Unicast"; + else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) + return "IPv6Multicast"; + else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) + return "IPv6VPN"; + else if (afi == AFI_IP6 && safi == SAFI_ENCAP) + return "IPv6Encap"; + else + return "Unknown"; +} + /* Show BGP peer's information. */ enum show_type { diff --git a/bgpd/bgp_vty.h b/bgpd/bgp_vty.h index 0fd2ae1be2..40c1723218 100644 --- a/bgpd/bgp_vty.h +++ b/bgpd/bgp_vty.h @@ -39,6 +39,7 @@ struct bgp; extern void bgp_vty_init (void); extern const char *afi_safi_print (afi_t, safi_t); +extern const char *afi_safi_json (afi_t, safi_t); extern int bgp_config_write_update_delay (struct vty *, struct bgp *); extern int bgp_config_write_wpkt_quanta(struct vty *vty, struct bgp *bgp); extern int bgp_config_write_listen(struct vty *vty, struct bgp *bgp); From c9e571b47c3eef8ddb13db3499e0db91ff996b34 Mon Sep 17 00:00:00 2001 From: Lou Berger Date: Sat, 7 Jan 2017 13:41:33 -0500 Subject: [PATCH 074/107] bgpd: fixup safi as afi confusion in show update-groups --- bgpd/bgp_vty.c | 32 +++++++------------------------- 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 94598d6578..5129c0ecff 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -8700,22 +8700,13 @@ bgp_show_update_groups(struct vty *vty, const char *name, DEFUN (show_ip_bgp_updgrps, show_ip_bgp_updgrps_cmd, - "show [ip] bgp [ WORD] [] update-groups [SUBGROUP-ID]", + "show [ip] bgp [ WORD] ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] update-groups [SUBGROUP-ID]", SHOW_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR - "Address Family\n" + BGP_AFI_HELP_STR BGP_SAFI_HELP_STR - "Address Family\n" - BGP_SAFI_HELP_STR - "Address Family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family\n" - "Address Family modifier\n" "Detailed info about dynamic update groups\n" "Specific subgroup to display detailed info for\n") { @@ -8732,20 +8723,11 @@ DEFUN (show_ip_bgp_updgrps, /* [ WORD] */ if (argv_find (argv, argc, "view", &idx) || argv_find (argv, argc, "vrf", &idx)) vrf = argv[++idx]->arg; - /* [] */ - if (argv_find (argv, argc, "ipv4", &idx) || argv_find (argv, argc, "ipv6", &idx)) - { - afi = strmatch(argv[idx]->text, "ipv6") ? AFI_IP6 : AFI_IP; - if (argv_find (argv, argc, "unicast", &idx) || argv_find (argv, argc, "multicast", &idx)) - safi = bgp_vty_safi_from_arg (argv[idx]->text); - } - else if (argv_find (argv, argc, "encap", &idx) || argv_find (argv, argc, "vpnv4", &idx)) - { - afi = AFI_IP; - safi = bgp_vty_safi_from_arg (argv[idx]->text); - // advance idx if necessary - argv_find (argv, argc, "unicast", &idx); - } + /* ["BGP_AFI_CMD_STR" ["BGP_SAFI_CMD_STR"]] */ + if (argv_find_and_parse_afi (argv, argc, &idx, &afi)) + { + argv_find_and_parse_safi (argv, argc, &idx, &safi); + } /* get subgroup id, if provided */ idx = argc - 1; From 37335ee22a5d2022c28e1ff276515e5f0360af6b Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Sat, 7 Jan 2017 19:21:21 -0500 Subject: [PATCH 075/107] pimd: Remove knowledge of HAVE_CLOCK_MONOTONIC thread.c fails to build if we do not have CLOCK_MONOTONIC no need to have pim have any knowledge of it. Signed-off-by: Donald Sharp --- pimd/pim_main.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/pimd/pim_main.c b/pimd/pim_main.c index aa3db3d5b2..5e7f4bfa96 100644 --- a/pimd/pim_main.c +++ b/pimd/pim_main.c @@ -272,12 +272,6 @@ int main(int argc, char** argv, char** envp) { zlog_notice("PIM_UNEXPECTED_KERNEL_UPCALL: report unexpected kernel upcall"); #endif -#ifdef HAVE_CLOCK_MONOTONIC - zlog_notice("HAVE_CLOCK_MONOTONIC"); -#else - zlog_notice("!HAVE_CLOCK_MONOTONIC"); -#endif - while (thread_fetch(master, &thread)) thread_call(&thread); From 3814903108e9f1440a56b9bbf7fb90f2f781284b Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Sat, 7 Jan 2017 19:23:50 -0500 Subject: [PATCH 076/107] bgpd: Remove knowledge of HAVE_CLOCK_MONTONIC thread.c fails to build properly on systems that do not have a CLOCK_MONOTONIC. Therefore there is no need for bgp to have knowledge of it. Signed-off-by: Donald Sharp --- bgpd/bgp_dump.c | 4 ---- bgpd/bgp_nexthop.c | 4 ---- bgpd/bgp_route.c | 14 -------------- bgpd/bgpd.h | 4 ---- 4 files changed, 26 deletions(-) diff --git a/bgpd/bgp_dump.c b/bgpd/bgp_dump.c index add653193c..8dd753d272 100644 --- a/bgpd/bgp_dump.c +++ b/bgpd/bgp_dump.c @@ -364,11 +364,7 @@ bgp_dump_route_node_record (int afi, struct bgp_node *rn, stream_putw (obuf, info->peer->table_dump_index); /* Originated */ -#ifdef HAVE_CLOCK_MONOTONIC stream_putl (obuf, time(NULL) - (bgp_clock() - info->uptime)); -#else - stream_putl (obuf, info->uptime); -#endif /* HAVE_CLOCK_MONOTONIC */ /* Dump attribute. */ /* Skip prefix & AFI/SAFI for MP_NLRI */ diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c index 0a72d09228..2cbcc37d67 100644 --- a/bgpd/bgp_nexthop.c +++ b/bgpd/bgp_nexthop.c @@ -450,12 +450,8 @@ bgp_show_nexthops (struct vty *vty, struct bgp *bgp, int detail) if (CHECK_FLAG(bnc->flags, BGP_NEXTHOP_CONNECTED)) vty_out (vty, " Must be Connected%s", VTY_NEWLINE); } -#ifdef HAVE_CLOCK_MONOTONIC tbuf = time(NULL) - (bgp_clock() - bnc->last_update); vty_out (vty, " Last update: %s", ctime(&tbuf)); -#else - vty_out (vty, " Last update: %s", ctime(&bnc->uptime)); -#endif /* HAVE_CLOCK_MONOTONIC */ vty_out(vty, "%s", VTY_NEWLINE); } } diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index cfc4ec3407..c0cea6261c 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -6537,9 +6537,7 @@ route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, char buf1[BUFSIZ]; struct attr *attr; int sockunion_vty_out (struct vty *, union sockunion *); -#ifdef HAVE_CLOCK_MONOTONIC time_t tbuf; -#endif json_object *json_bestpath = NULL; json_object *json_cluster_list = NULL; json_object *json_cluster_list_list = NULL; @@ -7164,7 +7162,6 @@ route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, } /* Line 8 display Uptime */ -#ifdef HAVE_CLOCK_MONOTONIC tbuf = time(NULL) - (bgp_clock() - binfo->uptime); if (json_paths) { @@ -7175,17 +7172,6 @@ route_vty_out_detail (struct vty *vty, struct bgp *bgp, struct prefix *p, } else vty_out (vty, " Last update: %s", ctime(&tbuf)); -#else - if (json_paths) - { - json_last_update = json_object_new_object(); - json_object_int_add(json_last_update, "epoch", tbuf); - json_object_string_add(json_last_update, "string", ctime(&binfo->uptime)); - json_object_object_add(json_path, "lastUpdate", json_last_update); - } - else - vty_out (vty, " Last update: %s", ctime(&binfo->uptime)); -#endif /* HAVE_CLOCK_MONOTONIC */ } /* We've constructed the json object for this path, add it to the json diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index 86fa207b6b..7e2ed18c26 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -1458,13 +1458,9 @@ peer_group_af_configured (struct peer_group *group) static inline char * timestamp_string (time_t ts) { -#ifdef HAVE_CLOCK_MONOTONIC time_t tbuf; tbuf = time(NULL) - (bgp_clock() - ts); return ctime(&tbuf); -#else - return ctime(&ts); -#endif /* HAVE_CLOCK_MONOTONIC */ } static inline int From d92c729ba55d7f99228a37902811a764414602d1 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Mon, 9 Jan 2017 01:35:41 +0000 Subject: [PATCH 077/107] lib: make interface metric a uint32_t Signed-off-by: Quentin Young --- lib/if.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/if.h b/lib/if.h index cfa376d1ea..32e5d92a97 100644 --- a/lib/if.h +++ b/lib/if.h @@ -227,7 +227,7 @@ struct interface uint64_t flags; /* Interface metric */ - int metric; + uint32_t metric; /* Interface MTU. */ unsigned int mtu; /* IPv4 MTU */ From 46a9496b7e6476cf6369d4d47a21184d1f781242 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Mon, 9 Jan 2017 02:36:53 +0000 Subject: [PATCH 078/107] redhat: update .gitignore Signed-off-by: Quentin Young --- redhat/.gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redhat/.gitignore b/redhat/.gitignore index e399bd8114..a38f1c06e3 100644 --- a/redhat/.gitignore +++ b/redhat/.gitignore @@ -1,5 +1,5 @@ zebra.spec -quagga.spec +frr.spec Makefile Makefile.in .nfs* From 95f5922d277c9f4ab983545c0a99fb80c4c1655a Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Mon, 9 Jan 2017 12:35:57 -0200 Subject: [PATCH 079/107] build: check if the LibXML perl module is available Signed-off-by: Renato Westphal --- .gitignore | 1 + configure.ac | 2 + m4/ax_prog_perl_modules.m4 | 77 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+) create mode 100644 m4/ax_prog_perl_modules.m4 diff --git a/.gitignore b/.gitignore index 546faf6926..507b193b4b 100644 --- a/.gitignore +++ b/.gitignore @@ -41,6 +41,7 @@ build m4/*.m4 !m4/ax_sys_weak_alias.m4 !m4/ax_compare_version.m4 +!m4/ax_prog_perl_modules.m4 debian/autoreconf.after debian/autoreconf.before debian/files diff --git a/configure.ac b/configure.ac index d883063ddb..af9fa1ceb1 100755 --- a/configure.ac +++ b/configure.ac @@ -292,6 +292,8 @@ if test $ac_cv_lib_json_c_json_object_get = no; then fi fi +AX_PROG_PERL_MODULES(XML::LibXML, , AC_MSG_ERROR(XML::LibXML perl module is needed to compile)) + AC_ARG_ENABLE([dev_build], AS_HELP_STRING([--enable-dev-build], [build for development])) diff --git a/m4/ax_prog_perl_modules.m4 b/m4/ax_prog_perl_modules.m4 new file mode 100644 index 0000000000..11a326c930 --- /dev/null +++ b/m4/ax_prog_perl_modules.m4 @@ -0,0 +1,77 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_prog_perl_modules.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PROG_PERL_MODULES([MODULES], [ACTION-IF-TRUE], [ACTION-IF-FALSE]) +# +# DESCRIPTION +# +# Checks to see if the given perl modules are available. If true the shell +# commands in ACTION-IF-TRUE are executed. If not the shell commands in +# ACTION-IF-FALSE are run. Note if $PERL is not set (for example by +# calling AC_CHECK_PROG, or AC_PATH_PROG), AC_CHECK_PROG(PERL, perl, perl) +# will be run. +# +# MODULES is a space separated list of module names. To check for a +# minimum version of a module, append the version number to the module +# name, separated by an equals sign. +# +# Example: +# +# AX_PROG_PERL_MODULES( Text::Wrap Net::LDAP=1.0.3, , +# AC_MSG_WARN(Need some Perl modules) +# +# LICENSE +# +# Copyright (c) 2009 Dean Povey +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 7 + +AU_ALIAS([AC_PROG_PERL_MODULES], [AX_PROG_PERL_MODULES]) +AC_DEFUN([AX_PROG_PERL_MODULES],[dnl + +m4_define([ax_perl_modules]) +m4_foreach([ax_perl_module], m4_split(m4_normalize([$1])), + [ + m4_append([ax_perl_modules], + [']m4_bpatsubst(ax_perl_module,=,[ ])[' ]) + ]) + +# Make sure we have perl +if test -z "$PERL"; then +AC_CHECK_PROG(PERL,perl,perl) +fi + +if test "x$PERL" != x; then + ax_perl_modules_failed=0 + for ax_perl_module in ax_perl_modules; do + AC_MSG_CHECKING(for perl module $ax_perl_module) + + # Would be nice to log result here, but can't rely on autoconf internals + $PERL -e "use $ax_perl_module; exit" > /dev/null 2>&1 + if test $? -ne 0; then + AC_MSG_RESULT(no); + ax_perl_modules_failed=1 + else + AC_MSG_RESULT(ok); + fi + done + + # Run optional shell commands + if test "$ax_perl_modules_failed" = 0; then + : + $2 + else + : + $3 + fi +else + AC_MSG_WARN(could not find perl) +fi])dnl From 2af38873d89e20bd039255418366c1601aa99e64 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Tue, 10 Jan 2017 23:33:50 +0000 Subject: [PATCH 080/107] lib: limit size of vty buffer to 4096 bytes This removes the automatic resizing of the vty input buffer and places a hard size cap of 4096 bytes. It also fixes a potentially unsafe strcpy. Signed-off-by: Quentin Young --- lib/vty.c | 98 ++++++++++++++++++++++++++++--------------------------- lib/vty.h | 2 +- 2 files changed, 51 insertions(+), 49 deletions(-) diff --git a/lib/vty.c b/lib/vty.c index 1fe2e5d296..9b42eb5383 100644 --- a/lib/vty.c +++ b/lib/vty.c @@ -508,18 +508,6 @@ vty_write (struct vty *vty, const char *buf, size_t nbytes) buffer_put (vty->obuf, buf, nbytes); } -/* Ensure length of input buffer. Is buffer is short, double it. */ -static void -vty_ensure (struct vty *vty, int length) -{ - if (vty->max <= length) - { - vty->max *= 2; - vty->buf = XREALLOC (MTYPE_VTY, vty->buf, vty->max); - vty->error_buf = XREALLOC (MTYPE_VTY, vty->error_buf, vty->max); - } -} - /* Basic function to insert character into vty. */ static void vty_self_insert (struct vty *vty, char c) @@ -527,7 +515,9 @@ vty_self_insert (struct vty *vty, char c) int i; int length; - vty_ensure (vty, vty->length + 1); + if (vty->length + 1 > VTY_BUFSIZ) + return; + length = vty->length - vty->cp; memmove (&vty->buf[vty->cp + 1], &vty->buf[vty->cp], length); vty->buf[vty->cp] = c; @@ -544,26 +534,29 @@ vty_self_insert (struct vty *vty, char c) static void vty_self_insert_overwrite (struct vty *vty, char c) { - vty_ensure (vty, vty->length + 1); + if (vty->cp == vty->length) + { + vty_self_insert (vty, c); + return; + } + vty->buf[vty->cp++] = c; - - if (vty->cp > vty->length) - vty->length++; - - if ((vty->node == AUTH_NODE) || (vty->node == AUTH_ENABLE_NODE)) - return; - vty_write (vty, &c, 1); } -/* Insert a word into vty interface with overwrite mode. */ +/** + * Insert a string into vty->buf at the current cursor position. + * + * If the resultant string would be larger than VTY_BUFSIZ it is + * truncated to fit. + */ static void vty_insert_word_overwrite (struct vty *vty, char *str) { - int len = strlen (str); - vty_write (vty, str, len); - strcpy (&vty->buf[vty->cp], str); - vty->cp += len; + size_t nwrite = MIN ((int) strlen (str), VTY_BUFSIZ - vty->cp); + vty_write (vty, str, nwrite); + strncpy (&vty->buf[vty->cp], str, nwrite); + vty->cp += nwrite; vty->length = vty->cp; } @@ -2223,36 +2216,45 @@ vtysh_read (struct thread *thread) printf ("line: %.*s\n", nbytes, buf); #endif /* VTYSH_DEBUG */ - for (p = buf; p < buf+nbytes; p++) + if (vty->length + nbytes > VTY_BUFSIZ) { - vty_ensure(vty, vty->length+1); - vty->buf[vty->length++] = *p; - if (*p == '\0') + /* Clear command line buffer. */ + vty->cp = vty->length = 0; + vty_clear_buf (vty); + vty_out (vty, "%% Command is too long.%s", VTY_NEWLINE); + } + else + { + for (p = buf; p < buf+nbytes; p++) { - /* Pass this line to parser. */ - ret = vty_execute (vty); - /* Note that vty_execute clears the command buffer and resets - vty->length to 0. */ + vty->buf[vty->length++] = *p; + if (*p == '\0') + { + /* Pass this line to parser. */ + ret = vty_execute (vty); + /* Note that vty_execute clears the command buffer and resets + vty->length to 0. */ - /* Return result. */ + /* Return result. */ #ifdef VTYSH_DEBUG - printf ("result: %d\n", ret); - printf ("vtysh node: %d\n", vty->node); + printf ("result: %d\n", ret); + printf ("vtysh node: %d\n", vty->node); #endif /* VTYSH_DEBUG */ - /* hack for asynchronous "write integrated" - * - other commands in "buf" will be ditched - * - input during pending config-write is "unsupported" */ - if (ret == CMD_SUSPEND) - break; + /* hack for asynchronous "write integrated" + * - other commands in "buf" will be ditched + * - input during pending config-write is "unsupported" */ + if (ret == CMD_SUSPEND) + break; - /* warning: watchfrr hardcodes this result write */ - header[3] = ret; - buffer_put(vty->obuf, header, 4); + /* warning: watchquagga hardcodes this result write */ + header[3] = ret; + buffer_put(vty->obuf, header, 4); - if (!vty->t_write && (vtysh_flush(vty) < 0)) - /* Try to flush results; exit if a write error occurs. */ - return 0; + if (!vty->t_write && (vtysh_flush(vty) < 0)) + /* Try to flush results; exit if a write error occurs. */ + return 0; + } } } diff --git a/lib/vty.h b/lib/vty.h index 24bdcd1817..f0b833d4d8 100644 --- a/lib/vty.h +++ b/lib/vty.h @@ -26,7 +26,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #include "sockunion.h" #include "qobj.h" -#define VTY_BUFSIZ 512 +#define VTY_BUFSIZ 4096 #define VTY_MAXHIST 20 /* VTY struct. */ From d02fbbdb088ebaf1eb350887879739cd70094001 Mon Sep 17 00:00:00 2001 From: Lou Berger Date: Fri, 6 Jan 2017 10:50:31 -0500 Subject: [PATCH 081/107] bgpd: restore some missing afi/safi commands (Issue #14) Added defines and parse utility functions Fix vty code that treated vpn&encap as AFIs and some other related vty printing/handline issues Note: Includes branch specific changes (due to new parser) Signed-off-by: Lou Berger --- bgpd/bgp_route.c | 472 +++++++++++----------------- bgpd/bgp_vty.c | 778 ++++++++++++++++++++--------------------------- bgpd/bgp_vty.h | 17 +- 3 files changed, 524 insertions(+), 743 deletions(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index c717a930b1..e31c745e56 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -8157,13 +8157,12 @@ DEFUN (show_ip_bgp, DEFUN (show_ip_bgp_ipv4, show_ip_bgp_ipv4_cmd, - "show ip bgp ipv4 (unicast|multicast) {json}", + "show ip bgp ipv4 "BGP_SAFI_CMD_STR" {json}", SHOW_STR IP_STR BGP_STR "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR "JavaScript Object Notation\n") { u_char uj = use_json(argc, argv); @@ -8175,12 +8174,11 @@ DEFUN (show_ip_bgp_ipv4, ALIAS (show_ip_bgp_ipv4, show_bgp_ipv4_safi_cmd, - "show bgp ipv4 (unicast|multicast) {json}", + "show bgp ipv4 "BGP_SAFI_CMD_STR" {json}", SHOW_STR BGP_STR "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR "JavaScript Object Notation\n") DEFUN (show_ip_bgp_route, @@ -8216,10 +8214,10 @@ DEFUN (show_ip_bgp_route_pathtype, DEFUN (show_bgp_ipv4_safi_route_pathtype, show_bgp_ipv4_safi_route_pathtype_cmd, - "show bgp ipv4 (unicast|multicast|vpn|encap) A.B.C.D (bestpath|multipath) {json}", + "show bgp ipv4 "BGP_SAFI_CMD_STR" A.B.C.D (bestpath|multipath) {json}", SHOW_STR BGP_STR - AFI_SAFI_STR + BGP_AFI_SAFI_HELP_STR "IP prefix /, e.g., 35.0.0.0/8\n" "Display only the bestpath\n" "Display only multipaths\n" @@ -8275,11 +8273,11 @@ DEFUN (show_bgp_ipv6_prefix, DEFUN (show_ip_bgp_ipv4_route, show_ip_bgp_ipv4_route_cmd, - "show ip bgp ipv4 (unicast|multicast|vpn|encap) A.B.C.D {json}", + "show ip bgp ipv4 "BGP_SAFI_CMD_STR" A.B.C.D {json}", SHOW_STR IP_STR BGP_STR - AFI_SAFI_STR + BGP_AFI_SAFI_HELP_STR "Network in the BGP routing table to display\n" "JavaScript Object Notation\n") { @@ -8292,10 +8290,10 @@ DEFUN (show_ip_bgp_ipv4_route, ALIAS (show_ip_bgp_ipv4_route, show_bgp_ipv4_safi_route_cmd, - "show bgp ipv4 (unicast|multicast|vpn|encap) A.B.C.D {json}", + "show bgp ipv4 "BGP_SAFI_CMD_STR" A.B.C.D {json}", SHOW_STR BGP_STR - AFI_SAFI_STR + BGP_AFI_SAFI_HELP_STR "Network in the BGP routing table to display\n" "JavaScript Object Notation\n") @@ -8489,11 +8487,11 @@ DEFUN (show_ip_bgp_prefix_pathtype, DEFUN (show_ip_bgp_ipv4_prefix, show_ip_bgp_ipv4_prefix_cmd, - "show ip bgp ipv4 (unicast|multicast|vpn|encap) A.B.C.D/M {json}", + "show ip bgp ipv4 "BGP_SAFI_CMD_STR" A.B.C.D/M {json}", SHOW_STR IP_STR BGP_STR - AFI_SAFI_STR + BGP_AFI_SAFI_HELP_STR "IP prefix /, e.g., 35.0.0.0/8\n" "JavaScript Object Notation\n") { @@ -8506,20 +8504,20 @@ DEFUN (show_ip_bgp_ipv4_prefix, ALIAS (show_ip_bgp_ipv4_prefix, show_bgp_ipv4_safi_prefix_cmd, - "show bgp ipv4 (unicast|multicast|vpn|encap) A.B.C.D/M {json}", + "show bgp ipv4 "BGP_SAFI_CMD_STR" A.B.C.D/M {json}", SHOW_STR BGP_STR - AFI_SAFI_STR + BGP_AFI_SAFI_HELP_STR "IP prefix /, e.g., 35.0.0.0/8\n" "JavaScript Object Notation\n") DEFUN (show_ip_bgp_ipv4_prefix_pathtype, show_ip_bgp_ipv4_prefix_pathtype_cmd, - "show ip bgp ipv4 (unicast|multicast|vpn|encap) A.B.C.D/M (bestpath|multipath) {json}", + "show ip bgp ipv4 "BGP_SAFI_CMD_STR" A.B.C.D/M (bestpath|multipath) {json}", SHOW_STR IP_STR BGP_STR - AFI_SAFI_STR + BGP_AFI_SAFI_HELP_STR "IP prefix /, e.g., 35.0.0.0/8\n" "Display only the bestpath\n" "Display only multipaths\n" @@ -8539,10 +8537,10 @@ DEFUN (show_ip_bgp_ipv4_prefix_pathtype, ALIAS (show_ip_bgp_ipv4_prefix_pathtype, show_bgp_ipv4_safi_prefix_pathtype_cmd, - "show bgp ipv4 (unicast|multicast|vpn|encap) A.B.C.D/M (bestpath|multipath) {json}", + "show bgp ipv4 "BGP_SAFI_CMD_STR" A.B.C.D/M (bestpath|multipath) {json}", SHOW_STR BGP_STR - AFI_SAFI_STR + BGP_AFI_SAFI_HELP_STR "IP prefix /, e.g., 35.0.0.0/8\n" "Display only the bestpath\n" "Display only multipaths\n" @@ -8710,13 +8708,11 @@ ALIAS (show_bgp, DEFUN (show_bgp_ipv6_safi, show_bgp_ipv6_safi_cmd, - "show bgp ipv6 (unicast|multicast) {json}", + "show bgp ipv6 "BGP_SAFI_CMD_STR" {json}", SHOW_STR BGP_STR "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - AFI_SAFI_STR + BGP_SAFI_HELP_STR "JavaScript Object Notation\n") { u_char uj = use_json(argc, argv); @@ -8761,10 +8757,10 @@ DEFUN (show_bgp_route, DEFUN (show_bgp_ipv6_safi_route, show_bgp_ipv6_safi_route_cmd, - "show bgp ipv6 (unicast|multicast|vpn|encap) X:X::X:X {json}", + "show bgp ipv6 "BGP_SAFI_CMD_STR" X:X::X:X {json}", SHOW_STR BGP_STR - AFI_SAFI_STR + BGP_AFI_SAFI_HELP_STR "Network in the BGP routing table to display\n" "JavaScript Object Notation\n") { @@ -8805,10 +8801,10 @@ ALIAS (show_bgp_route_pathtype, DEFUN (show_bgp_ipv6_safi_route_pathtype, show_bgp_ipv6_safi_route_pathtype_cmd, - "show bgp ipv6 (unicast|multicast|vpn|encap) X:X::X:X (bestpath|multipath) {json}", + "show bgp ipv6 "BGP_SAFI_CMD_STR" X:X::X:X (bestpath|multipath) {json}", SHOW_STR BGP_STR - AFI_SAFI_STR + BGP_AFI_SAFI_HELP_STR "Network in the BGP routing table to display\n" "Display only the bestpath\n" "Display only multipaths\n" @@ -8852,10 +8848,10 @@ DEFUN (show_bgp_prefix, DEFUN (show_bgp_ipv6_safi_prefix, show_bgp_ipv6_safi_prefix_cmd, - "show bgp ipv6 (unicast|multicast|vpn|encap) X:X::X:X/M {json}", + "show bgp ipv6 "BGP_SAFI_CMD_STR" X:X::X:X/M {json}", SHOW_STR BGP_STR - AFI_SAFI_STR + BGP_AFI_SAFI_HELP_STR "IPv6 prefix /, e.g., 3ffe::/16\n" "JavaScript Object Notation\n") { @@ -8896,10 +8892,10 @@ ALIAS (show_bgp_prefix_pathtype, DEFUN (show_bgp_ipv6_safi_prefix_pathtype, show_bgp_ipv6_safi_prefix_pathtype_cmd, - "show bgp ipv6 (unicast|multicast|vpn|encap) X:X::X:X/M (bestpath|multipath) {json}", + "show bgp ipv6 "BGP_SAFI_CMD_STR" X:X::X:X/M (bestpath|multipath) {json}", SHOW_STR BGP_STR - AFI_SAFI_STR + BGP_AFI_SAFI_HELP_STR "IPv6 prefix /, e.g., 3ffe::/16\n" "Display only the bestpath\n" "Display only multipaths\n" @@ -9322,22 +9318,19 @@ ALIAS (show_ip_bgp_flap_regexp, DEFUN (show_ip_bgp_ipv4_regexp, show_ip_bgp_ipv4_regexp_cmd, - "show ip bgp ipv4 (unicast|multicast) regexp .LINE", + "show ip bgp ipv4 "BGP_SAFI_CMD_STR" regexp .LINE", SHOW_STR IP_STR BGP_STR "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR "Display routes matching the AS path regular expression\n" "A regular-expression to match the BGP AS paths\n") { - if (strncmp (argv[0], "m", 1) == 0) - return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST, - bgp_show_type_regexp); - - return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, - bgp_show_type_regexp); + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[0]); + return bgp_show_regexp (vty, argc, argv, AFI_IP, safi, + bgp_show_type_regexp); } #ifdef HAVE_IPV6 @@ -9472,22 +9465,19 @@ ALIAS (show_ip_bgp_flap_prefix_list, DEFUN (show_ip_bgp_ipv4_prefix_list, show_ip_bgp_ipv4_prefix_list_cmd, - "show ip bgp ipv4 (unicast|multicast) prefix-list WORD", + "show ip bgp ipv4 "BGP_SAFI_CMD_STR" prefix-list WORD", SHOW_STR IP_STR BGP_STR "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR "Display routes conforming to the prefix-list\n" "IP prefix-list name\n") { - if (strncmp (argv[0], "m", 1) == 0) - return bgp_show_prefix_list (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, - bgp_show_type_prefix_list); - - return bgp_show_prefix_list (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, - bgp_show_type_prefix_list); + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[0]); + return bgp_show_prefix_list (vty, NULL, argv[1], AFI_IP, safi, + bgp_show_type_prefix_list); } #ifdef HAVE_IPV6 @@ -9621,22 +9611,19 @@ ALIAS (show_ip_bgp_flap_filter_list, DEFUN (show_ip_bgp_ipv4_filter_list, show_ip_bgp_ipv4_filter_list_cmd, - "show ip bgp ipv4 (unicast|multicast) filter-list WORD", + "show ip bgp ipv4 "BGP_SAFI_CMD_STR" filter-list WORD", SHOW_STR IP_STR BGP_STR "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR "Display routes conforming to the filter-list\n" "Regular expression access list name\n") { - if (strncmp (argv[0], "m", 1) == 0) - return bgp_show_filter_list (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, - bgp_show_type_filter_list); - - return bgp_show_filter_list (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, - bgp_show_type_filter_list); + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[0]); + return bgp_show_filter_list (vty, NULL, argv[1], AFI_IP, safi, + bgp_show_type_filter_list); } #ifdef HAVE_IPV6 @@ -9707,61 +9694,53 @@ DEFUN (show_ip_bgp_dampening_info, DEFUN (show_ip_bgp_ipv4_dampening_parameters, show_ip_bgp_ipv4_dampening_parameters_cmd, - "show ip bgp ipv4 (unicast|multicast) dampening parameters", + "show ip bgp ipv4 "BGP_SAFI_CMD_STR" dampening parameters", SHOW_STR IP_STR BGP_STR "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR "Display detailed information about dampening\n" "Display detail of configured dampening parameters\n") { - if (strncmp(argv[0], "m", 1) == 0) - return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_MULTICAST); - - return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_UNICAST); + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[0]); + return bgp_show_dampening_parameters (vty, AFI_IP, safi); } DEFUN (show_ip_bgp_ipv4_dampening_flap_stats, show_ip_bgp_ipv4_dampening_flap_stats_cmd, - "show ip bgp ipv4 (unicast|multicast) dampening flap-statistics", + "show ip bgp ipv4 "BGP_SAFI_CMD_STR" dampening flap-statistics", SHOW_STR IP_STR BGP_STR "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR "Display detailed information about dampening\n" "Display flap statistics of routes\n") { - if (strncmp(argv[0], "m", 1) == 0) - return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[0]); + return bgp_show (vty, NULL, AFI_IP, safi, bgp_show_type_flap_statistics, NULL, 0); - - return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, - bgp_show_type_flap_statistics, NULL, 0); } DEFUN (show_ip_bgp_ipv4_dampening_dampd_paths, show_ip_bgp_ipv4_dampening_dampd_paths_cmd, - "show ip bgp ipv4 (unicast|multicast) dampening dampened-paths", + "show ip bgp ipv4 "BGP_SAFI_CMD_STR" dampening dampened-paths", SHOW_STR IP_STR BGP_STR "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR "Display detailed information about dampening\n" "Display paths suppressed due to dampening\n") { - if (strncmp(argv[0], "m", 1) == 0) - return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[0]); + return bgp_show (vty, NULL, AFI_IP, safi, bgp_show_type_dampend_paths, NULL, 0); - - return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, - bgp_show_type_dampend_paths, NULL, 0); } static int @@ -9843,22 +9822,19 @@ ALIAS (show_ip_bgp_flap_route_map, DEFUN (show_ip_bgp_ipv4_route_map, show_ip_bgp_ipv4_route_map_cmd, - "show ip bgp ipv4 (unicast|multicast) route-map WORD", + "show ip bgp ipv4 "BGP_SAFI_CMD_STR" route-map WORD", SHOW_STR IP_STR BGP_STR "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR "Display routes matching the route-map\n" "A route-map to match on\n") { - if (strncmp (argv[0], "m", 1) == 0) - return bgp_show_route_map (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, - bgp_show_type_route_map); - - return bgp_show_route_map (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, - bgp_show_type_route_map); + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[0]); + return bgp_show_route_map (vty, NULL, argv[1], AFI_IP, safi, + bgp_show_type_route_map); } DEFUN (show_bgp_route_map, @@ -9919,21 +9895,18 @@ ALIAS (show_ip_bgp_flap_cidr_only, DEFUN (show_ip_bgp_ipv4_cidr_only, show_ip_bgp_ipv4_cidr_only_cmd, - "show ip bgp ipv4 (unicast|multicast) cidr-only", + "show ip bgp ipv4 "BGP_SAFI_CMD_STR" cidr-only", SHOW_STR IP_STR BGP_STR "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR "Display only routes with non-natural netmasks\n") { - if (strncmp (argv[0], "m", 1) == 0) - return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, - bgp_show_type_cidr_only, NULL, 0); - - return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, - bgp_show_type_cidr_only, NULL, 0); + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[0]); + return bgp_show (vty, NULL, AFI_IP, safi, + bgp_show_type_cidr_only, NULL, 0); } DEFUN (show_ip_bgp_community_all, @@ -9950,21 +9923,18 @@ DEFUN (show_ip_bgp_community_all, DEFUN (show_ip_bgp_ipv4_community_all, show_ip_bgp_ipv4_community_all_cmd, - "show ip bgp ipv4 (unicast|multicast) community", + "show ip bgp ipv4 "BGP_SAFI_CMD_STR" community", SHOW_STR IP_STR BGP_STR "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR "Display routes matching the communities\n") { - if (strncmp (argv[0], "m", 1) == 0) - return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, - bgp_show_type_community_all, NULL, 0); - - return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, - bgp_show_type_community_all, NULL, 0); + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[0]); + return bgp_show (vty, NULL, AFI_IP, safi, + bgp_show_type_community_all, NULL, 0); } #ifdef HAVE_IPV6 @@ -10156,34 +10126,31 @@ ALIAS (show_ip_bgp_community, DEFUN (show_ip_bgp_ipv4_community, show_ip_bgp_ipv4_community_cmd, - "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", + "show ip bgp ipv4 "BGP_SAFI_CMD_STR" community (AA:NN|local-AS|no-advertise|no-export)", SHOW_STR IP_STR BGP_STR "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR "Display routes matching the communities\n" COMMUNITY_AANN_STR "Do not send outside local AS (well-known community)\n" "Do not advertise to any peer (well-known community)\n" "Do not export to next AS (well-known community)\n") { - if (strncmp (argv[0], "m", 1) == 0) - return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST); - - return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[0]); + return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, safi); } ALIAS (show_ip_bgp_ipv4_community, show_ip_bgp_ipv4_community2_cmd, - "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", + "show ip bgp ipv4 "BGP_SAFI_CMD_STR" community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", SHOW_STR IP_STR BGP_STR "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR "Display routes matching the communities\n" COMMUNITY_AANN_STR "Do not send outside local AS (well-known community)\n" @@ -10196,13 +10163,12 @@ ALIAS (show_ip_bgp_ipv4_community, ALIAS (show_ip_bgp_ipv4_community, show_ip_bgp_ipv4_community3_cmd, - "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", + "show ip bgp ipv4 "BGP_SAFI_CMD_STR" community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", SHOW_STR IP_STR BGP_STR "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR "Display routes matching the communities\n" COMMUNITY_AANN_STR "Do not send outside local AS (well-known community)\n" @@ -10219,13 +10185,12 @@ ALIAS (show_ip_bgp_ipv4_community, ALIAS (show_ip_bgp_ipv4_community, show_ip_bgp_ipv4_community4_cmd, - "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", + "show ip bgp ipv4 "BGP_SAFI_CMD_STR" community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", SHOW_STR IP_STR BGP_STR "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR "Display routes matching the communities\n" COMMUNITY_AANN_STR "Do not send outside local AS (well-known community)\n" @@ -10246,14 +10211,11 @@ ALIAS (show_ip_bgp_ipv4_community, DEFUN (show_bgp_instance_afi_safi_community_all, show_bgp_instance_afi_safi_community_all_cmd, - "show bgp " BGP_INSTANCE_CMD " (ipv4|ipv6) (unicast|multicast) community", + "show bgp " BGP_INSTANCE_CMD " "BGP_AFI_SAFI_CMD_STR" community", SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR - "Address family\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_AFI_SAFI_HELP_STR "Display routes matching the communities\n") { int afi; @@ -10268,14 +10230,14 @@ DEFUN (show_bgp_instance_afi_safi_community_all, return CMD_WARNING; } - afi = (strncmp (argv[2], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; - safi = (strncmp (argv[3], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; + afi = bgp_vty_safi_from_arg(argv[2]); + safi = bgp_vty_safi_from_arg(argv[3]); return bgp_show (vty, bgp, afi, safi, bgp_show_type_community_all, NULL, 0); } DEFUN (show_bgp_instance_afi_safi_community, show_bgp_instance_afi_safi_community_cmd, - "show bgp " BGP_INSTANCE_CMD " (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", + "show bgp " BGP_INSTANCE_CMD " "BGP_AFI_SAFI_CMD_STR" community (AA:NN|local-AS|no-advertise|no-export)", SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR @@ -10292,14 +10254,14 @@ DEFUN (show_bgp_instance_afi_safi_community, int afi; int safi; - afi = (strncmp (argv[2], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; - safi = (strncmp (argv[3], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; + afi = bgp_vty_safi_from_arg(argv[2]); + safi = bgp_vty_safi_from_arg(argv[3]); return bgp_show_community (vty, argv[1], argc-4, &argv[4], 0, afi, safi); } ALIAS (show_bgp_instance_afi_safi_community, show_bgp_instance_afi_safi_community2_cmd, - "show bgp " BGP_INSTANCE_CMD " (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", + "show bgp " BGP_INSTANCE_CMD " "BGP_AFI_SAFI_CMD_STR" community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR @@ -10319,7 +10281,7 @@ ALIAS (show_bgp_instance_afi_safi_community, ALIAS (show_bgp_instance_afi_safi_community, show_bgp_instance_afi_safi_community3_cmd, - "show bgp " BGP_INSTANCE_CMD " (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", + "show bgp " BGP_INSTANCE_CMD " "BGP_AFI_SAFI_CMD_STR" community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR @@ -10343,7 +10305,7 @@ ALIAS (show_bgp_instance_afi_safi_community, ALIAS (show_bgp_instance_afi_safi_community, show_bgp_instance_afi_safi_community4_cmd, - "show bgp " BGP_INSTANCE_CMD " (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", + "show bgp " BGP_INSTANCE_CMD " "BGP_AFI_SAFI_CMD_STR" community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR @@ -10450,13 +10412,12 @@ ALIAS (show_ip_bgp_community_exact, DEFUN (show_ip_bgp_ipv4_community_exact, show_ip_bgp_ipv4_community_exact_cmd, - "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match", + "show ip bgp ipv4 "BGP_SAFI_CMD_STR" community (AA:NN|local-AS|no-advertise|no-export) exact-match", SHOW_STR IP_STR BGP_STR "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR "Display routes matching the communities\n" COMMUNITY_AANN_STR "Do not send outside local AS (well-known community)\n" @@ -10464,21 +10425,19 @@ DEFUN (show_ip_bgp_ipv4_community_exact, "Do not export to next AS (well-known community)\n" "Exact match of the communities") { - if (strncmp (argv[0], "m", 1) == 0) - return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST); - - return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[0]); + return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, safi); } ALIAS (show_ip_bgp_ipv4_community_exact, show_ip_bgp_ipv4_community2_exact_cmd, - "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", + "show ip bgp ipv4 "BGP_SAFI_CMD_STR" community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", SHOW_STR IP_STR BGP_STR "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR "Display routes matching the communities\n" COMMUNITY_AANN_STR "Do not send outside local AS (well-known community)\n" @@ -10492,13 +10451,12 @@ ALIAS (show_ip_bgp_ipv4_community_exact, ALIAS (show_ip_bgp_ipv4_community_exact, show_ip_bgp_ipv4_community3_exact_cmd, - "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", + "show ip bgp ipv4 "BGP_SAFI_CMD_STR" community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", SHOW_STR IP_STR BGP_STR "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR "Display routes matching the communities\n" COMMUNITY_AANN_STR "Do not send outside local AS (well-known community)\n" @@ -10516,13 +10474,12 @@ ALIAS (show_ip_bgp_ipv4_community_exact, ALIAS (show_ip_bgp_ipv4_community_exact, show_ip_bgp_ipv4_community4_exact_cmd, - "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", + "show ip bgp ipv4 "BGP_SAFI_CMD_STR" community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", SHOW_STR IP_STR BGP_STR "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR "Display routes matching the communities\n" COMMUNITY_AANN_STR "Do not send outside local AS (well-known community)\n" @@ -11222,21 +11179,19 @@ DEFUN (show_ip_bgp_instance_community_list, DEFUN (show_ip_bgp_ipv4_community_list, show_ip_bgp_ipv4_community_list_cmd, - "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)", + "show ip bgp ipv4 "BGP_SAFI_CMD_STR" community-list (<1-500>|WORD)", SHOW_STR IP_STR BGP_STR "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR "Display routes matching the community-list\n" "community-list number\n" "community-list name\n") { - if (strncmp (argv[0], "m", 1) == 0) - return bgp_show_community_list (vty, NULL, argv[1], 0, AFI_IP, SAFI_MULTICAST); - - return bgp_show_community_list (vty, NULL, argv[1], 0, AFI_IP, SAFI_UNICAST); + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[0]); + return bgp_show_community_list (vty, NULL, argv[1], 0, AFI_IP, safi); } DEFUN (show_ip_bgp_community_list_exact, @@ -11255,22 +11210,20 @@ DEFUN (show_ip_bgp_community_list_exact, DEFUN (show_ip_bgp_ipv4_community_list_exact, show_ip_bgp_ipv4_community_list_exact_cmd, - "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match", + "show ip bgp ipv4 "BGP_SAFI_CMD_STR" community-list (<1-500>|WORD) exact-match", SHOW_STR IP_STR BGP_STR "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR "Display routes matching the community-list\n" "community-list number\n" "community-list name\n" "Exact match of the communities\n") { - if (strncmp (argv[0], "m", 1) == 0) - return bgp_show_community_list (vty, NULL, argv[1], 1, AFI_IP, SAFI_MULTICAST); - - return bgp_show_community_list (vty, NULL, argv[1], 1, AFI_IP, SAFI_UNICAST); + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[0]); + return bgp_show_community_list (vty, NULL, argv[1], 1, AFI_IP, safi); } #ifdef HAVE_IPV6 @@ -11462,22 +11415,19 @@ ALIAS (show_ip_bgp_flap_prefix_longer, DEFUN (show_ip_bgp_ipv4_prefix_longer, show_ip_bgp_ipv4_prefix_longer_cmd, - "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes", + "show ip bgp ipv4 "BGP_SAFI_CMD_STR" A.B.C.D/M longer-prefixes", SHOW_STR IP_STR BGP_STR "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR "IP prefix /, e.g., 35.0.0.0/8\n" "Display route and more specific routes\n") { - if (strncmp (argv[0], "m", 1) == 0) - return bgp_show_prefix_longer (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, - bgp_show_type_prefix_longer); - - return bgp_show_prefix_longer (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, - bgp_show_type_prefix_longer); + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[0]); + return bgp_show_prefix_longer (vty, NULL, argv[1], AFI_IP, safi, + bgp_show_type_prefix_longer); } DEFUN (show_ip_bgp_flap_address, @@ -11939,54 +11889,30 @@ bgp_table_stats_vty (struct vty *vty, const char *name, vty_out (vty, "%% No such BGP instance exists%s", VTY_NEWLINE); return CMD_WARNING; } - if (strncmp (afi_str, "ipv", 3) == 0) - { - if (strncmp (afi_str, "ipv4", 4) == 0) - afi = AFI_IP; - else if (strncmp (afi_str, "ipv6", 4) == 0) - afi = AFI_IP6; - else - { - vty_out (vty, "%% Invalid address family %s%s", - afi_str, VTY_NEWLINE); - return CMD_WARNING; - } - if (strncmp (safi_str, "m", 1) == 0) - safi = SAFI_MULTICAST; - else if (strncmp (safi_str, "u", 1) == 0) - safi = SAFI_UNICAST; - else if (strncmp (safi_str, "e", 1) == 0) - safi = SAFI_ENCAP; - else if (strncmp (safi_str, "vpnv4", 5) == 0 || strncmp (safi_str, "vpnv6", 5) == 0) - safi = SAFI_MPLS_VPN; - else - { - vty_out (vty, "%% Invalid subsequent address family %s%s", - safi_str, VTY_NEWLINE); - return CMD_WARNING; - } - } - else + afi = bgp_vty_afi_from_arg(afi_str); + if (afi == AFI_MAX) { vty_out (vty, "%% Invalid address family \"%s\"%s", afi_str, VTY_NEWLINE); return CMD_WARNING; } + safi = bgp_vty_safi_from_arg(safi_str); + if (safi == SAFI_MAX) + { + vty_out (vty, "%% Invalid subsequent address family %s%s", + safi_str, VTY_NEWLINE); + return CMD_WARNING; + } return bgp_table_stats (vty, bgp, afi, safi); } DEFUN (show_bgp_statistics, show_bgp_statistics_cmd, - "show bgp (ipv4|ipv6) (encap|multicast|unicast|vpn) statistics", + "show bgp "BGP_AFI_SAFI_CMD_STR" statistics", SHOW_STR BGP_STR - "Address family\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_INSTANCE_HELP_STR "BGP RIB advertisement statistics\n") { return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); @@ -11994,16 +11920,11 @@ DEFUN (show_bgp_statistics, DEFUN (show_bgp_statistics_view, show_bgp_statistics_view_cmd, - "show bgp " BGP_INSTANCE_CMD " (ipv4|ipv6) (unicast|multicast|vpn|encap) statistics", + "show bgp " BGP_INSTANCE_CMD " "BGP_AFI_SAFI_CMD_STR" statistics", SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR - "Address family\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_AFI_SAFI_HELP_STR "BGP RIB advertisement statistics\n") { return bgp_table_stats_vty (vty, NULL, argv[1], argv[2]); @@ -12296,13 +12217,12 @@ DEFUN (show_bgp_instance_ipv6_neighbor_prefix_counts, DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts, show_ip_bgp_ipv4_neighbor_prefix_counts_cmd, - "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}", + "show ip bgp ipv4 "BGP_SAFI_CMD_STR" neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}", SHOW_STR IP_STR BGP_STR "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR "Detailed information on TCP and BGP neighbor connections\n" "Neighbor to display information about\n" "Neighbor to display information about\n" @@ -12317,10 +12237,9 @@ DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts, if (! peer) return CMD_WARNING; - if (strncmp (argv[0], "m", 1) == 0) - return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MULTICAST, uj); - - return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST, uj); + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[0]); + return bgp_peer_counts (vty, peer, AFI_IP, safi, uj); } DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts, @@ -12330,8 +12249,7 @@ DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts, IP_STR BGP_STR "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR "Detailed information on TCP and BGP neighbor connections\n" "Neighbor to display information about\n" "Neighbor to display information about\n" @@ -12674,13 +12592,12 @@ ALIAS (show_ip_bgp_instance_neighbor_advertised_route, "JavaScript Object Notation\n") DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route, show_ip_bgp_ipv4_neighbor_advertised_route_cmd, - "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}", + "show ip bgp ipv4 "BGP_SAFI_CMD_STR" neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}", SHOW_STR IP_STR BGP_STR "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR "Detailed information on TCP and BGP neighbor connections\n" "Neighbor to display information about\n" "Neighbor to display information about\n" @@ -12690,6 +12607,8 @@ DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route, { struct peer *peer; const char *rmap_name = NULL; + safi_t safi; + u_char uj = use_json(argc, argv); peer = peer_lookup_in_view (vty, NULL, argv[1], uj); @@ -12699,21 +12618,18 @@ DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route, if ((argc == 4) || (argc == 3 && argv[2] && strcmp(argv[2], "json") != 0)) rmap_name = argv[2]; - if (strncmp (argv[0], "m", 1) == 0) - return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0, rmap_name, uj); - else - return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0, rmap_name, uj); + safi = bgp_vty_safi_from_arg(argv[0]); + return peer_adj_routes (vty, peer, AFI_IP, safi, 0, rmap_name, uj); } ALIAS (show_ip_bgp_ipv4_neighbor_advertised_route, show_ip_bgp_ipv4_neighbor_advertised_route_rmap_cmd, - "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}", + "show ip bgp ipv4 "BGP_SAFI_CMD_STR" neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}", SHOW_STR IP_STR BGP_STR "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR "Detailed information on TCP and BGP neighbor connections\n" "Neighbor to display information about\n" "Neighbor to display information about\n" @@ -12965,13 +12881,12 @@ ALIAS (show_ip_bgp_instance_neighbor_received_routes, DEFUN (show_ip_bgp_ipv4_neighbor_received_routes, show_ip_bgp_ipv4_neighbor_received_routes_cmd, - "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}", + "show ip bgp ipv4 "BGP_SAFI_CMD_STR" neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}", SHOW_STR IP_STR BGP_STR "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR "Detailed information on TCP and BGP neighbor connections\n" "Neighbor to display information about\n" "Neighbor to display information about\n" @@ -12981,6 +12896,7 @@ DEFUN (show_ip_bgp_ipv4_neighbor_received_routes, { struct peer *peer; const char *rmap_name = NULL; + safi_t safi; u_char uj = use_json(argc, argv); peer = peer_lookup_in_view (vty, NULL, argv[1], uj); @@ -12990,21 +12906,18 @@ DEFUN (show_ip_bgp_ipv4_neighbor_received_routes, if (argc == 4 || (argc == 3 && argv[2] && strcmp(argv[2], "json") != 0)) rmap_name = argv[2]; - if (strncmp (argv[0], "m", 1) == 0) - return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1, rmap_name, uj); - else - return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1, rmap_name, uj); + safi = bgp_vty_safi_from_arg(argv[0]); + return peer_adj_routes (vty, peer, AFI_IP, safi, 1, rmap_name, uj); } ALIAS (show_ip_bgp_ipv4_neighbor_received_routes, show_ip_bgp_ipv4_neighbor_received_routes_rmap_cmd, - "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {json}", + "show ip bgp ipv4 "BGP_SAFI_CMD_STR" neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {json}", SHOW_STR IP_STR BGP_STR "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR "Detailed information on TCP and BGP neighbor connections\n" "Neighbor to display information about\n" "Neighbor to display information about\n" @@ -13014,14 +12927,11 @@ ALIAS (show_ip_bgp_ipv4_neighbor_received_routes, DEFUN (show_bgp_instance_afi_safi_neighbor_adv_recd_routes, show_bgp_instance_afi_safi_neighbor_adv_recd_routes_cmd, - "show bgp " BGP_INSTANCE_CMD " (ipv4|ipv6) (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) (advertised-routes|received-routes) {json}", + "show bgp " BGP_INSTANCE_CMD " "BGP_AFI_SAFI_CMD_STR" neighbors (A.B.C.D|X:X::X:X|WORD) (advertised-routes|received-routes) {json}", SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR - "Address family\n" - "Address family\n" - "Address family modifier\n" - "Address family modifier\n" + BGP_AFI_SAFI_HELP_STR "Detailed information on TCP and BGP neighbor connections\n" "Neighbor to display information about\n" "Neighbor to display information about\n" @@ -13041,8 +12951,8 @@ DEFUN (show_bgp_instance_afi_safi_neighbor_adv_recd_routes, if (! peer) return CMD_WARNING; - afi = (strncmp (argv[2], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; - safi = (strncmp (argv[3], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; + afi = bgp_vty_safi_from_arg(argv[2]); + safi = bgp_vty_safi_from_arg(argv[3]); in = (strncmp (argv[5], "r", 1) == 0) ? 1 : 0; return peer_adj_routes (vty, peer, afi, safi, in, NULL, uj); @@ -13137,13 +13047,12 @@ DEFUN (show_ip_bgp_neighbor_received_prefix_filter, DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter, show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd, - "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}", + "show ip bgp ipv4 "BGP_SAFI_CMD_STR" neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}", SHOW_STR IP_STR BGP_STR "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR "Detailed information on TCP and BGP neighbor connections\n" "Neighbor to display information about\n" "Neighbor to display information about\n" @@ -13200,38 +13109,16 @@ DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter, } } - if (strncmp (argv[0], "m", 1) == 0) { - sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST); + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[0]); + sprintf (name, "%s.%d.%d", peer->host, AFI_IP, safi); count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name, uj); if (count) { if (!uj) - vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE); - prefix_bgp_show_prefix_list (vty, AFI_IP, name, uj); - } - else - { - if (uj) - { - json_object *json_no = NULL; - json_no = json_object_new_object(); - json_object_boolean_true_add(json_no, "noFuntionalOutput"); - vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); - json_object_free(json_no); - } - else - vty_out (vty, "No functional output%s", VTY_NEWLINE); - } - } - else - { - sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); - count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name, uj); - if (count) - { - if (!uj) - vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); + vty_out (vty, "Address family: %s%s", + afi_safi_print (AFI_IP, safi), VTY_NEWLINE); prefix_bgp_show_prefix_list (vty, AFI_IP, name, uj); } else @@ -13660,13 +13547,12 @@ DEFUN (show_ip_bgp_neighbor_damp, DEFUN (show_ip_bgp_ipv4_neighbor_routes, show_ip_bgp_ipv4_neighbor_routes_cmd, - "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}", + "show ip bgp ipv4 "BGP_SAFI_CMD_STR" neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}", SHOW_STR IP_STR BGP_STR "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR "Detailed information on TCP and BGP neighbor connections\n" "Neighbor to display information about\n" "Neighbor to display information about\n" @@ -13675,18 +13561,16 @@ DEFUN (show_ip_bgp_ipv4_neighbor_routes, "JavaScript Object Notation\n") { struct peer *peer; + safi_t safi; u_char uj = use_json(argc, argv); peer = peer_lookup_in_view (vty, NULL, argv[1], uj); if (! peer) return CMD_WARNING; - if (strncmp (argv[0], "m", 1) == 0) - return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST, - bgp_show_type_neighbor, uj); - - return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, - bgp_show_type_neighbor, uj); + safi = bgp_vty_safi_from_arg(argv[0]); + return bgp_show_neighbor_route (vty, peer, AFI_IP, safi, + bgp_show_type_neighbor, uj); } #ifdef HAVE_IPV6 diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index b435543e39..1b8b135f66 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -107,22 +107,33 @@ bgp_node_safi (struct vty *vty) return safi; } +/* supports (ipv4|ipv6) */ +afi_t +bgp_vty_afi_from_arg(const char *afi_str) +{ + afi_t afi = AFI_MAX; /* unknown */ + if (!strcmp(afi_str, "ipv4")) { + afi = AFI_IP; + } +#ifdef HAVE_IPV6 + else if (!strcmp(afi_str, "ipv6")) { + afi = AFI_IP6; + } +#endif /* HAVE_IPV6 */ + return afi; +} + int bgp_parse_afi(const char *str, afi_t *afi) { - if (!strcmp(str, "ipv4")) { - *afi = AFI_IP; - return 0; - } -#ifdef HAVE_IPV6 - if (!strcmp(str, "ipv6")) { - *afi = AFI_IP6; - return 0; - } -#endif /* HAVE_IPV6 */ + *afi = bgp_vty_afi_from_arg(str); + if (*afi != AFI_MAX) + return 0; + else return -1; } + /* supports (unicast|multicast|vpn|encap) */ safi_t bgp_vty_safi_from_arg(const char *safi_str) @@ -135,7 +146,7 @@ bgp_vty_safi_from_arg(const char *safi_str) else if (strncmp (safi_str, "e", 1) == 0) safi = SAFI_ENCAP; else if (strncmp (safi_str, "v", 1) == 0) - safi = SAFI_MPLS_VPN; + safi = SAFI_MPLS_VPN; return safi; } @@ -359,10 +370,8 @@ bgp_clear_vty_error (struct vty *vty, struct peer *peer, afi_t afi, { case BGP_ERR_AF_UNCONFIGURED: vty_out (vty, - "%%BGP: Enable %s %s address family for the neighbor %s%s", - afi == AFI_IP6 ? "IPv6" : safi == SAFI_MPLS_VPN ? "VPNv4" : "IPv4", - safi == SAFI_MULTICAST ? "Multicast" : "Unicast", - peer->host, VTY_NEWLINE); + "%%BGP: Enable %s address family for the neighbor %s%s", + afi_safi_print(afi, safi), peer->host, VTY_NEWLINE); break; case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: vty_out (vty, "%%BGP: Inbound soft reconfig for %s not possible as it%s has neither refresh capability, nor inbound soft reconfig%s", peer->host, VTY_NEWLINE, VTY_NEWLINE); @@ -6057,9 +6066,10 @@ DEFUN (address_family_ipv4, DEFUN (address_family_ipv4_safi, address_family_ipv4_safi_cmd, - "address-family ipv4 (unicast|multicast)", + "address-family ipv4 "BGP_SAFI_CMD_STR, "Enter Address Family command mode\n" - AFI_SAFI_STR) + "Address Family\n" + BGP_SAFI_HELP_STR) { switch (bgp_vty_safi_from_arg(argv[0])) { @@ -6093,16 +6103,28 @@ DEFUN (address_family_ipv6, DEFUN (address_family_ipv6_safi, address_family_ipv6_safi_cmd, - "address-family ipv6 (unicast|multicast)", + "address-family ipv6 "BGP_SAFI_CMD_STR, "Enter Address Family command mode\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n") + "Address Family\n" + BGP_SAFI_HELP_STR) { - if (strncmp (argv[0], "m", 1) == 0) - vty->node = BGP_IPV6M_NODE; - else - vty->node = BGP_IPV6_NODE; + int idx_safi = 0; + switch (bgp_vty_safi_from_arg(argv[idx_safi])) + { + case SAFI_MULTICAST: + vty->node = BGP_IPV6M_NODE; + break; + case SAFI_ENCAP: + vty->node = BGP_ENCAPV6_NODE; + break; + case SAFI_MPLS_VPN: + vty->node = BGP_VPNV6_NODE; + break; + case SAFI_UNICAST: + default: + vty->node = BGP_IPV6_NODE; + break; + } return CMD_SUCCESS; } @@ -6651,69 +6673,61 @@ ALIAS (clear_ip_bgp_all_soft_out, DEFUN (clear_ip_bgp_all_ipv4_soft_out, clear_ip_bgp_all_ipv4_soft_out_cmd, - "clear ip bgp * ipv4 (unicast|multicast) soft out", + "clear ip bgp * ipv4 "BGP_SAFI_CMD_STR" soft out", CLEAR_STR IP_STR BGP_STR "Clear all peers\n" "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR BGP_SOFT_STR BGP_SOFT_OUT_STR) { - if (strncmp (argv[0], "m", 1) == 0) - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all, - BGP_CLEAR_SOFT_OUT, NULL); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all, - BGP_CLEAR_SOFT_OUT, NULL); + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[0]); + return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_all, + BGP_CLEAR_SOFT_OUT, NULL); } DEFUN (clear_ip_bgp_instance_all_ipv4_soft_out, clear_ip_bgp_instance_all_ipv4_soft_out_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " * ipv4 (unicast|multicast) soft out", + "clear ip bgp " BGP_INSTANCE_CMD " * ipv4 "BGP_SAFI_CMD_STR" soft out", CLEAR_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR "Clear all peers\n" "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR BGP_SOFT_OUT_STR) { - if (strncmp (argv[2], "m", 1) == 0) - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_all, - BGP_CLEAR_SOFT_OUT, NULL); - - return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all, + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[2]); + return bgp_clear_vty (vty, argv[1], AFI_IP, safi, clear_all, BGP_CLEAR_SOFT_OUT, NULL); } ALIAS (clear_ip_bgp_all_ipv4_soft_out, clear_ip_bgp_all_ipv4_out_cmd, - "clear ip bgp * ipv4 (unicast|multicast) out", + "clear ip bgp * ipv4 "BGP_SAFI_CMD_STR" out", CLEAR_STR IP_STR BGP_STR "Clear all peers\n" "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR BGP_SOFT_OUT_STR) ALIAS (clear_ip_bgp_instance_all_ipv4_soft_out, clear_ip_bgp_instance_all_ipv4_out_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " * ipv4 (unicast|multicast) out", + "clear ip bgp " BGP_INSTANCE_CMD " * ipv4 "BGP_SAFI_CMD_STR" out", CLEAR_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR "Clear all peers\n" "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR BGP_SOFT_OUT_STR) DEFUN (clear_ip_bgp_all_vpnv4_soft_out, @@ -6856,7 +6870,7 @@ ALIAS (clear_bgp_all_soft_out, DEFUN (clear_bgp_ipv6_safi_prefix, clear_bgp_ipv6_safi_prefix_cmd, - "clear bgp ipv6 (unicast|multicast) prefix X:X::X:X/M", + "clear bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", CLEAR_STR BGP_STR "Address family\n" @@ -6864,15 +6878,14 @@ DEFUN (clear_bgp_ipv6_safi_prefix, "Clear bestpath and re-advertise\n" "IPv6 prefix /, e.g., 3ffe::/16\n") { - if (strncmp (argv[0], "m", 1) == 0) - return bgp_clear_prefix (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL); - else - return bgp_clear_prefix (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL); + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[0]); + return bgp_clear_prefix (vty, NULL, argv[1], AFI_IP6, safi, NULL); } DEFUN (clear_bgp_instance_ipv6_safi_prefix, clear_bgp_instance_ipv6_safi_prefix_cmd, - "clear bgp " BGP_INSTANCE_CMD " ipv6 (unicast|multicast) prefix X:X::X:X/M", + "clear bgp " BGP_INSTANCE_CMD " ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", CLEAR_STR BGP_STR BGP_INSTANCE_HELP_STR @@ -6881,10 +6894,9 @@ DEFUN (clear_bgp_instance_ipv6_safi_prefix, "Clear bestpath and re-advertise\n" "IPv6 prefix /, e.g., 3ffe::/16\n") { - if (strncmp (argv[2], "m", 1) == 0) - return bgp_clear_prefix (vty, argv[1], argv[3], AFI_IP6, SAFI_MULTICAST, NULL); - else - return bgp_clear_prefix (vty, argv[1], argv[3], AFI_IP6, SAFI_UNICAST, NULL); + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[2]); + return bgp_clear_prefix (vty, argv[1], argv[3], AFI_IP6, safi, NULL); } DEFUN (clear_ip_bgp_peer_soft_out, @@ -6941,29 +6953,26 @@ ALIAS (clear_ip_bgp_peer_soft_out, DEFUN (clear_ip_bgp_peer_ipv4_soft_out, clear_ip_bgp_peer_ipv4_soft_out_cmd, - "clear ip bgp (A.B.C.D|WORD) ipv4 (unicast|multicast) soft out", + "clear ip bgp (A.B.C.D|WORD) ipv4 "BGP_SAFI_CMD_STR" soft out", CLEAR_STR IP_STR BGP_STR "BGP neighbor address to clear\n" "BGP neighbor on interface to clear\n" "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR BGP_SOFT_STR BGP_SOFT_OUT_STR) { - if (strncmp (argv[1], "m", 1) == 0) - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer, - BGP_CLEAR_SOFT_OUT, argv[0]); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer, - BGP_CLEAR_SOFT_OUT, argv[0]); + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[1]); + return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_peer, + BGP_CLEAR_SOFT_OUT, argv[0]); } DEFUN (clear_ip_bgp_instance_peer_ipv4_soft_out, clear_ip_bgp_instance_peer_ipv4_soft_out_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) ipv4 (unicast|multicast) soft out", + "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) ipv4 "BGP_SAFI_CMD_STR" soft out", CLEAR_STR IP_STR BGP_STR @@ -6971,35 +6980,31 @@ DEFUN (clear_ip_bgp_instance_peer_ipv4_soft_out, "BGP neighbor address to clear\n" "BGP neighbor on interface to clear\n" "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR BGP_SOFT_STR BGP_SOFT_OUT_STR) { - if (strncmp (argv[3], "m", 1) == 0) - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_peer, - BGP_CLEAR_SOFT_OUT, argv[2]); - - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_peer, - BGP_CLEAR_SOFT_OUT, argv[2]); + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[3]); + return bgp_clear_vty (vty, argv[1], AFI_IP, safi, clear_peer, + BGP_CLEAR_SOFT_OUT, argv[2]); } ALIAS (clear_ip_bgp_peer_ipv4_soft_out, clear_ip_bgp_peer_ipv4_out_cmd, - "clear ip bgp (A.B.C.D|WORD) ipv4 (unicast|multicast) out", + "clear ip bgp (A.B.C.D|WORD) ipv4 "BGP_SAFI_CMD_STR" out", CLEAR_STR IP_STR BGP_STR "BGP neighbor address to clear\n" "BGP neighbor on interface to clear\n" "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR BGP_SOFT_OUT_STR) ALIAS (clear_ip_bgp_instance_peer_ipv4_soft_out, clear_ip_bgp_instance_peer_ipv4_out_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) ipv4 (unicast|multicast) out", + "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) ipv4 "BGP_SAFI_CMD_STR" out", CLEAR_STR IP_STR BGP_STR @@ -7007,8 +7012,7 @@ ALIAS (clear_ip_bgp_instance_peer_ipv4_soft_out, "BGP neighbor address to clear\n" "BGP neighbor on interface to clear\n" "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR BGP_SOFT_OUT_STR) /* NOTE: WORD peers have not been tested for vpnv4 */ @@ -7222,29 +7226,26 @@ ALIAS (clear_ip_bgp_peer_group_soft_out, DEFUN (clear_ip_bgp_peer_group_ipv4_soft_out, clear_ip_bgp_peer_group_ipv4_soft_out_cmd, - "clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft out", + "clear ip bgp peer-group WORD ipv4 "BGP_SAFI_CMD_STR" soft out", CLEAR_STR IP_STR BGP_STR "Clear all members of peer-group\n" "BGP peer-group name\n" "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR BGP_SOFT_STR BGP_SOFT_OUT_STR) { - if (strncmp (argv[1], "m", 1) == 0) - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group, - BGP_CLEAR_SOFT_OUT, argv[0]); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group, - BGP_CLEAR_SOFT_OUT, argv[0]); + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[1]); + return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_group, + BGP_CLEAR_SOFT_OUT, argv[0]); } DEFUN (clear_ip_bgp_instance_peer_group_ipv4_soft_out, clear_ip_bgp_instance_peer_group_ipv4_soft_out_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD ipv4 (unicast|multicast) soft out", + "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD ipv4 "BGP_SAFI_CMD_STR" soft out", CLEAR_STR IP_STR BGP_STR @@ -7252,35 +7253,31 @@ DEFUN (clear_ip_bgp_instance_peer_group_ipv4_soft_out, "Clear all members of peer-group\n" "BGP peer-group name\n" "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR BGP_SOFT_STR BGP_SOFT_OUT_STR) { - if (strncmp (argv[3], "m", 1) == 0) - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_group, - BGP_CLEAR_SOFT_OUT, argv[2]); - - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_group, - BGP_CLEAR_SOFT_OUT, argv[2]); + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[3]); + return bgp_clear_vty (vty, argv[1], AFI_IP, safi, clear_group, + BGP_CLEAR_SOFT_OUT, argv[2]); } ALIAS (clear_ip_bgp_peer_group_ipv4_soft_out, clear_ip_bgp_peer_group_ipv4_out_cmd, - "clear ip bgp peer-group WORD ipv4 (unicast|multicast) out", + "clear ip bgp peer-group WORD ipv4 "BGP_SAFI_CMD_STR" out", CLEAR_STR IP_STR BGP_STR "Clear all members of peer-group\n" "BGP peer-group name\n" "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR BGP_SOFT_OUT_STR) ALIAS (clear_ip_bgp_instance_peer_group_ipv4_soft_out, clear_ip_bgp_instance_peer_group_ipv4_out_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD ipv4 (unicast|multicast) out", + "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD ipv4 "BGP_SAFI_CMD_STR" out", CLEAR_STR IP_STR BGP_STR @@ -7288,8 +7285,7 @@ ALIAS (clear_ip_bgp_instance_peer_group_ipv4_soft_out, "Clear all members of peer-group\n" "BGP peer-group name\n" "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR BGP_SOFT_OUT_STR) DEFUN (clear_bgp_peer_group_soft_out, @@ -7434,70 +7430,62 @@ ALIAS (clear_ip_bgp_external_soft_out, DEFUN (clear_ip_bgp_external_ipv4_soft_out, clear_ip_bgp_external_ipv4_soft_out_cmd, - "clear ip bgp external ipv4 (unicast|multicast) soft out", + "clear ip bgp external ipv4 "BGP_SAFI_CMD_STR" soft out", CLEAR_STR IP_STR BGP_STR "Clear all external peers\n" "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR BGP_SOFT_STR BGP_SOFT_OUT_STR) { - if (strncmp (argv[0], "m", 1) == 0) - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external, - BGP_CLEAR_SOFT_OUT, NULL); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external, - BGP_CLEAR_SOFT_OUT, NULL); + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[0]); + return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_external, + BGP_CLEAR_SOFT_OUT, NULL); } DEFUN (clear_ip_bgp_instance_external_ipv4_soft_out, clear_ip_bgp_instance_external_ipv4_soft_out_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " external ipv4 (unicast|multicast) soft out", + "clear ip bgp " BGP_INSTANCE_CMD " external ipv4 "BGP_SAFI_CMD_STR" soft out", CLEAR_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR "Clear all external peers\n" "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR BGP_SOFT_STR BGP_SOFT_OUT_STR) { - if (strncmp (argv[2], "m", 1) == 0) - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_external, - BGP_CLEAR_SOFT_OUT, NULL); - - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_external, - BGP_CLEAR_SOFT_OUT, NULL); + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[2]); + return bgp_clear_vty (vty, argv[1], AFI_IP, safi, clear_external, + BGP_CLEAR_SOFT_OUT, NULL); } ALIAS (clear_ip_bgp_external_ipv4_soft_out, clear_ip_bgp_external_ipv4_out_cmd, - "clear ip bgp external ipv4 (unicast|multicast) out", + "clear ip bgp external ipv4 "BGP_SAFI_CMD_STR" out", CLEAR_STR IP_STR BGP_STR "Clear all external peers\n" "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR BGP_SOFT_OUT_STR) ALIAS (clear_ip_bgp_instance_external_ipv4_soft_out, clear_ip_bgp_instance_external_ipv4_out_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " external ipv4 (unicast|multicast) out", + "clear ip bgp " BGP_INSTANCE_CMD " external ipv4 "BGP_SAFI_CMD_STR" out", CLEAR_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR "Clear all external peers\n" "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR BGP_SOFT_OUT_STR) DEFUN (clear_bgp_external_soft_out, @@ -7634,70 +7622,62 @@ ALIAS (clear_ip_bgp_as_soft_out, DEFUN (clear_ip_bgp_as_ipv4_soft_out, clear_ip_bgp_as_ipv4_soft_out_cmd, - "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) soft out", + "clear ip bgp " CMD_AS_RANGE " ipv4 "BGP_SAFI_CMD_STR" soft out", CLEAR_STR IP_STR BGP_STR "Clear peers with the AS number\n" "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR BGP_SOFT_STR BGP_SOFT_OUT_STR) { - if (strncmp (argv[1], "m", 1) == 0) - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as, - BGP_CLEAR_SOFT_OUT, argv[0]); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as, - BGP_CLEAR_SOFT_OUT, argv[0]); + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[1]); + return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_as, + BGP_CLEAR_SOFT_OUT, argv[0]); } DEFUN (clear_ip_bgp_instance_as_ipv4_soft_out, clear_ip_bgp_instance_as_ipv4_soft_out_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " ipv4 (unicast|multicast) soft out", + "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " ipv4 "BGP_SAFI_CMD_STR" soft out", CLEAR_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR "Clear peers with the AS number\n" "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR BGP_SOFT_STR BGP_SOFT_OUT_STR) { - if (strncmp (argv[3], "m", 1) == 0) - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_as, - BGP_CLEAR_SOFT_OUT, argv[2]); - - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_as, - BGP_CLEAR_SOFT_OUT, argv[2]); + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[3]); + return bgp_clear_vty (vty, argv[1], AFI_IP, safi, clear_as, + BGP_CLEAR_SOFT_OUT, argv[2]); } ALIAS (clear_ip_bgp_as_ipv4_soft_out, clear_ip_bgp_as_ipv4_out_cmd, - "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) out", + "clear ip bgp " CMD_AS_RANGE " ipv4 "BGP_SAFI_CMD_STR" out", CLEAR_STR IP_STR BGP_STR "Clear peers with the AS number\n" "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR BGP_SOFT_OUT_STR) ALIAS (clear_ip_bgp_instance_as_ipv4_soft_out, clear_ip_bgp_instance_as_ipv4_out_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " ipv4 (unicast|multicast) out", + "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " ipv4 "BGP_SAFI_CMD_STR" out", CLEAR_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR "Clear peers with the AS number\n" "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR BGP_SOFT_OUT_STR) DEFUN (clear_ip_bgp_as_vpnv4_soft_out, @@ -7907,91 +7887,80 @@ DEFUN (clear_ip_bgp_all_in_prefix_filter, DEFUN (clear_ip_bgp_all_ipv4_soft_in, clear_ip_bgp_all_ipv4_soft_in_cmd, - "clear ip bgp * ipv4 (unicast|multicast) soft in", + "clear ip bgp * ipv4 "BGP_SAFI_CMD_STR" soft in", CLEAR_STR IP_STR BGP_STR "Clear all peers\n" "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR BGP_SOFT_STR BGP_SOFT_IN_STR) { - if (strncmp (argv[0], "m", 1) == 0) - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all, - BGP_CLEAR_SOFT_IN, NULL); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all, - BGP_CLEAR_SOFT_IN, NULL); + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[0]); + return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_all, + BGP_CLEAR_SOFT_IN, NULL); } DEFUN (clear_ip_bgp_instance_all_ipv4_soft_in, clear_ip_bgp_instance_all_ipv4_soft_in_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " * ipv4 (unicast|multicast) soft in", + "clear ip bgp " BGP_INSTANCE_CMD " * ipv4 "BGP_SAFI_CMD_STR" soft in", CLEAR_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR "Clear all peers\n" "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR BGP_SOFT_STR BGP_SOFT_IN_STR) { - if (strncmp (argv[2], "m", 1) == 0) - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_all, - BGP_CLEAR_SOFT_IN, NULL); - - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_all, + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[2]); + return bgp_clear_vty (vty, argv[1], AFI_IP, safi, clear_all, BGP_CLEAR_SOFT_IN, NULL); } ALIAS (clear_ip_bgp_all_ipv4_soft_in, clear_ip_bgp_all_ipv4_in_cmd, - "clear ip bgp * ipv4 (unicast|multicast) in", + "clear ip bgp * ipv4 "BGP_SAFI_CMD_STR" in", CLEAR_STR IP_STR BGP_STR "Clear all peers\n" "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR BGP_SOFT_IN_STR) ALIAS (clear_ip_bgp_instance_all_ipv4_soft_in, clear_ip_bgp_instance_all_ipv4_in_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " * ipv4 (unicast|multicast) in", + "clear ip bgp " BGP_INSTANCE_CMD " * ipv4 "BGP_SAFI_CMD_STR" in", CLEAR_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR "Clear all peers\n" "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR BGP_SOFT_IN_STR) DEFUN (clear_ip_bgp_all_ipv4_in_prefix_filter, clear_ip_bgp_all_ipv4_in_prefix_filter_cmd, - "clear ip bgp * ipv4 (unicast|multicast) in prefix-filter", + "clear ip bgp * ipv4 "BGP_SAFI_CMD_STR" in prefix-filter", CLEAR_STR IP_STR BGP_STR "Clear all peers\n" "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR BGP_SOFT_IN_STR "Push out prefix-list ORF and do inbound soft reconfig\n") { - if (strncmp (argv[0], "m", 1) == 0) - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all, - BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all, - BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL); + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[0]); + return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_all, + BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL); } DEFUN (clear_ip_bgp_all_vpnv4_soft_in, @@ -8224,29 +8193,26 @@ DEFUN (clear_ip_bgp_peer_in_prefix_filter, DEFUN (clear_ip_bgp_peer_ipv4_soft_in, clear_ip_bgp_peer_ipv4_soft_in_cmd, - "clear ip bgp (A.B.C.D|WORD) ipv4 (unicast|multicast) soft in", + "clear ip bgp (A.B.C.D|WORD) ipv4 "BGP_SAFI_CMD_STR" soft in", CLEAR_STR IP_STR BGP_STR "BGP neighbor address to clear\n" "BGP neighbor on interface to clear\n" "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR BGP_SOFT_STR BGP_SOFT_IN_STR) { - if (strncmp (argv[1], "m", 1) == 0) - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer, - BGP_CLEAR_SOFT_IN, argv[0]); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer, - BGP_CLEAR_SOFT_IN, argv[0]); + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[1]); + return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_peer, + BGP_CLEAR_SOFT_IN, argv[0]); } DEFUN (clear_ip_bgp_instance_peer_ipv4_soft_in, clear_ip_bgp_instance_peer_ipv4_soft_in_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) ipv4 (unicast|multicast) soft in", + "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) ipv4 "BGP_SAFI_CMD_STR" soft in", CLEAR_STR IP_STR BGP_STR @@ -8254,35 +8220,31 @@ DEFUN (clear_ip_bgp_instance_peer_ipv4_soft_in, "BGP neighbor address to clear\n" "BGP neighbor on interface to clear\n" "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR BGP_SOFT_STR BGP_SOFT_IN_STR) { - if (strncmp (argv[3], "m", 1) == 0) - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_peer, - BGP_CLEAR_SOFT_IN, argv[2]); - - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_peer, - BGP_CLEAR_SOFT_IN, argv[2]); + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[3]); + return bgp_clear_vty (vty, argv[1], AFI_IP, safi, clear_peer, + BGP_CLEAR_SOFT_IN, argv[2]); } ALIAS (clear_ip_bgp_peer_ipv4_soft_in, clear_ip_bgp_peer_ipv4_in_cmd, - "clear ip bgp (A.B.C.D|WORD) ipv4 (unicast|multicast) in", + "clear ip bgp (A.B.C.D|WORD) ipv4 "BGP_SAFI_CMD_STR" in", CLEAR_STR IP_STR BGP_STR "BGP neighbor address to clear\n" "BGP neighbor on interface to clear\n" "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR BGP_SOFT_IN_STR) ALIAS (clear_ip_bgp_instance_peer_ipv4_soft_in, clear_ip_bgp_instance_peer_ipv4_in_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) ipv4 (unicast|multicast) in", + "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) ipv4 "BGP_SAFI_CMD_STR" in", CLEAR_STR IP_STR BGP_STR @@ -8290,30 +8252,26 @@ ALIAS (clear_ip_bgp_instance_peer_ipv4_soft_in, "BGP neighbor address to clear\n" "BGP neighbor on interface to clear\n" "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR BGP_SOFT_IN_STR) DEFUN (clear_ip_bgp_peer_ipv4_in_prefix_filter, clear_ip_bgp_peer_ipv4_in_prefix_filter_cmd, - "clear ip bgp (A.B.C.D|WORD) ipv4 (unicast|multicast) in prefix-filter", + "clear ip bgp (A.B.C.D|WORD) ipv4 "BGP_SAFI_CMD_STR" in prefix-filter", CLEAR_STR IP_STR BGP_STR "BGP neighbor address to clear\n" "BGP neighbor on interface to clear\n" "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR BGP_SOFT_IN_STR "Push out the existing ORF prefix-list\n") { - if (strncmp (argv[1], "m", 1) == 0) - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer, - BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer, - BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]); + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[1]); + return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_peer, + BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]); } DEFUN (clear_ip_bgp_peer_vpnv4_soft_in, @@ -8568,29 +8526,26 @@ DEFUN (clear_ip_bgp_peer_group_in_prefix_filter, DEFUN (clear_ip_bgp_peer_group_ipv4_soft_in, clear_ip_bgp_peer_group_ipv4_soft_in_cmd, - "clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft in", + "clear ip bgp peer-group WORD ipv4 "BGP_SAFI_CMD_STR" soft in", CLEAR_STR IP_STR BGP_STR "Clear all members of peer-group\n" "BGP peer-group name\n" "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR BGP_SOFT_STR BGP_SOFT_IN_STR) { - if (strncmp (argv[1], "m", 1) == 0) - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group, - BGP_CLEAR_SOFT_IN, argv[0]); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group, - BGP_CLEAR_SOFT_IN, argv[0]); + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[1]); + return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_group, + BGP_CLEAR_SOFT_IN, argv[0]); } DEFUN (clear_ip_bgp_instance_peer_group_ipv4_soft_in, clear_ip_bgp_instance_peer_group_ipv4_soft_in_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD ipv4 (unicast|multicast) soft in", + "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD ipv4 "BGP_SAFI_CMD_STR" soft in", CLEAR_STR IP_STR BGP_STR @@ -8598,35 +8553,31 @@ DEFUN (clear_ip_bgp_instance_peer_group_ipv4_soft_in, "Clear all members of peer-group\n" "BGP peer-group name\n" "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR BGP_SOFT_STR BGP_SOFT_IN_STR) { - if (strncmp (argv[3], "m", 1) == 0) - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_group, - BGP_CLEAR_SOFT_IN, argv[2]); - - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_group, - BGP_CLEAR_SOFT_IN, argv[2]); + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[3]); + return bgp_clear_vty (vty, argv[1], AFI_IP, safi, clear_group, + BGP_CLEAR_SOFT_IN, argv[2]); } ALIAS (clear_ip_bgp_peer_group_ipv4_soft_in, clear_ip_bgp_peer_group_ipv4_in_cmd, - "clear ip bgp peer-group WORD ipv4 (unicast|multicast) in", + "clear ip bgp peer-group WORD ipv4 "BGP_SAFI_CMD_STR" in", CLEAR_STR IP_STR BGP_STR "Clear all members of peer-group\n" "BGP peer-group name\n" "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR BGP_SOFT_IN_STR) ALIAS (clear_ip_bgp_instance_peer_group_ipv4_soft_in, clear_ip_bgp_instance_peer_group_ipv4_in_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD ipv4 (unicast|multicast) in", + "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD ipv4 "BGP_SAFI_CMD_STR" in", CLEAR_STR IP_STR BGP_STR @@ -8634,30 +8585,26 @@ ALIAS (clear_ip_bgp_instance_peer_group_ipv4_soft_in, "Clear all members of peer-group\n" "BGP peer-group name\n" "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR BGP_SOFT_IN_STR) DEFUN (clear_ip_bgp_peer_group_ipv4_in_prefix_filter, clear_ip_bgp_peer_group_ipv4_in_prefix_filter_cmd, - "clear ip bgp peer-group WORD ipv4 (unicast|multicast) in prefix-filter", + "clear ip bgp peer-group WORD ipv4 "BGP_SAFI_CMD_STR" in prefix-filter", CLEAR_STR IP_STR BGP_STR "Clear all members of peer-group\n" "BGP peer-group name\n" "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR BGP_SOFT_IN_STR "Push out prefix-list ORF and do inbound soft reconfig\n") { - if (strncmp (argv[1], "m", 1) == 0) - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group, - BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group, - BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]); + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[1]); + return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_group, + BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]); } DEFUN (clear_bgp_peer_group_soft_in, @@ -8841,91 +8788,80 @@ DEFUN (clear_ip_bgp_external_in_prefix_filter, DEFUN (clear_ip_bgp_external_ipv4_soft_in, clear_ip_bgp_external_ipv4_soft_in_cmd, - "clear ip bgp external ipv4 (unicast|multicast) soft in", + "clear ip bgp external ipv4 "BGP_SAFI_CMD_STR" soft in", CLEAR_STR IP_STR BGP_STR "Clear all external peers\n" "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR BGP_SOFT_STR BGP_SOFT_IN_STR) { - if (strncmp (argv[0], "m", 1) == 0) - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external, - BGP_CLEAR_SOFT_IN, NULL); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external, - BGP_CLEAR_SOFT_IN, NULL); + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[0]); + return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_external, + BGP_CLEAR_SOFT_IN, NULL); } DEFUN (clear_ip_bgp_instance_external_ipv4_soft_in, clear_ip_bgp_instance_external_ipv4_soft_in_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " external ipv4 (unicast|multicast) soft in", + "clear ip bgp " BGP_INSTANCE_CMD " external ipv4 "BGP_SAFI_CMD_STR" soft in", CLEAR_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR "Clear all external peers\n" "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR BGP_SOFT_STR BGP_SOFT_IN_STR) { - if (strncmp (argv[2], "m", 1) == 0) - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_external, - BGP_CLEAR_SOFT_IN, NULL); - - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_external, - BGP_CLEAR_SOFT_IN, NULL); + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[2]); + return bgp_clear_vty (vty, argv[1], AFI_IP, safi, clear_external, + BGP_CLEAR_SOFT_IN, NULL); } ALIAS (clear_ip_bgp_external_ipv4_soft_in, clear_ip_bgp_external_ipv4_in_cmd, - "clear ip bgp external ipv4 (unicast|multicast) in", + "clear ip bgp external ipv4 "BGP_SAFI_CMD_STR" in", CLEAR_STR IP_STR BGP_STR "Clear all external peers\n" "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR BGP_SOFT_IN_STR) ALIAS (clear_ip_bgp_instance_external_ipv4_soft_in, clear_ip_bgp_instance_external_ipv4_in_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " external ipv4 (unicast|multicast) in", + "clear ip bgp " BGP_INSTANCE_CMD " external ipv4 "BGP_SAFI_CMD_STR" in", CLEAR_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR "Clear all external peers\n" "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR BGP_SOFT_IN_STR) DEFUN (clear_ip_bgp_external_ipv4_in_prefix_filter, clear_ip_bgp_external_ipv4_in_prefix_filter_cmd, - "clear ip bgp external ipv4 (unicast|multicast) in prefix-filter", + "clear ip bgp external ipv4 "BGP_SAFI_CMD_STR" in prefix-filter", CLEAR_STR IP_STR BGP_STR "Clear all external peers\n" "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR BGP_SOFT_IN_STR "Push out prefix-list ORF and do inbound soft reconfig\n") { - if (strncmp (argv[0], "m", 1) == 0) - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external, - BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external, - BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL); + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[0]); + return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_external, + BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL); } DEFUN (clear_bgp_external_soft_in, @@ -9099,91 +9035,80 @@ DEFUN (clear_ip_bgp_as_in_prefix_filter, DEFUN (clear_ip_bgp_as_ipv4_soft_in, clear_ip_bgp_as_ipv4_soft_in_cmd, - "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) soft in", + "clear ip bgp " CMD_AS_RANGE " ipv4 "BGP_SAFI_CMD_STR" soft in", CLEAR_STR IP_STR BGP_STR "Clear peers with the AS number\n" "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR BGP_SOFT_STR BGP_SOFT_IN_STR) { - if (strncmp (argv[1], "m", 1) == 0) - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as, - BGP_CLEAR_SOFT_IN, argv[0]); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as, - BGP_CLEAR_SOFT_IN, argv[0]); + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[1]); + return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_as, + BGP_CLEAR_SOFT_IN, argv[0]); } DEFUN (clear_ip_bgp_instance_as_ipv4_soft_in, clear_ip_bgp_instance_as_ipv4_soft_in_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " ipv4 (unicast|multicast) soft in", + "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " ipv4 "BGP_SAFI_CMD_STR" soft in", CLEAR_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR "Clear peers with the AS number\n" "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR BGP_SOFT_STR BGP_SOFT_IN_STR) { - if (strncmp (argv[3], "m", 1) == 0) - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_as, - BGP_CLEAR_SOFT_IN, argv[2]); - - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_as, - BGP_CLEAR_SOFT_IN, argv[2]); + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[3]); + return bgp_clear_vty (vty, argv[1], AFI_IP, safi, clear_as, + BGP_CLEAR_SOFT_IN, argv[2]); } ALIAS (clear_ip_bgp_as_ipv4_soft_in, clear_ip_bgp_as_ipv4_in_cmd, - "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) in", + "clear ip bgp " CMD_AS_RANGE " ipv4 "BGP_SAFI_CMD_STR" in", CLEAR_STR IP_STR BGP_STR "Clear peers with the AS number\n" "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR BGP_SOFT_IN_STR) ALIAS (clear_ip_bgp_instance_as_ipv4_soft_in, clear_ip_bgp_instance_as_ipv4_in_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " ipv4 (unicast|multicast) in", + "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " ipv4 "BGP_SAFI_CMD_STR" in", CLEAR_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR "Clear peers with the AS number\n" "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR BGP_SOFT_IN_STR) DEFUN (clear_ip_bgp_as_ipv4_in_prefix_filter, clear_ip_bgp_as_ipv4_in_prefix_filter_cmd, - "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) in prefix-filter", + "clear ip bgp " CMD_AS_RANGE " ipv4 "BGP_SAFI_CMD_STR" in prefix-filter", CLEAR_STR IP_STR BGP_STR "Clear peers with the AS number\n" "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR BGP_SOFT_IN_STR "Push out prefix-list ORF and do inbound soft reconfig\n") { - if (strncmp (argv[1], "m", 1) == 0) - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as, - BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as, - BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]); + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[1]); + return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_as, + BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]); } DEFUN (clear_ip_bgp_as_vpnv4_soft_in, @@ -9378,7 +9303,7 @@ ALIAS (clear_ip_bgp_all_soft, DEFUN (clear_ip_bgp_all_ipv4_soft, clear_ip_bgp_all_ipv4_soft_cmd, - "clear ip bgp * ipv4 (unicast|multicast) soft", + "clear ip bgp * ipv4 "BGP_SAFI_CMD_STR" soft", CLEAR_STR IP_STR BGP_STR @@ -9388,17 +9313,15 @@ DEFUN (clear_ip_bgp_all_ipv4_soft, "Address Family Modifier\n" BGP_SOFT_STR) { - if (strncmp (argv[0], "m", 1) == 0) - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all, - BGP_CLEAR_SOFT_BOTH, NULL); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all, - BGP_CLEAR_SOFT_BOTH, NULL); + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[0]); + return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_all, + BGP_CLEAR_SOFT_BOTH, NULL); } DEFUN (clear_ip_bgp_instance_all_ipv4_soft, clear_ip_bgp_instance_all_ipv4_soft_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " * ipv4 (unicast|multicast) soft", + "clear ip bgp " BGP_INSTANCE_CMD " * ipv4 "BGP_SAFI_CMD_STR" soft", CLEAR_STR IP_STR BGP_STR @@ -9409,11 +9332,9 @@ DEFUN (clear_ip_bgp_instance_all_ipv4_soft, "Address Family Modifier\n" BGP_SOFT_STR) { - if (strncmp (argv[2], "m", 1) == 0) - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_all, - BGP_CLEAR_SOFT_BOTH, NULL); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all, + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[2]); + return bgp_clear_vty (vty, argv[1], AFI_IP, safi, clear_all, BGP_CLEAR_SOFT_BOTH, NULL); } @@ -9522,7 +9443,7 @@ ALIAS (clear_ip_bgp_peer_soft, DEFUN (clear_ip_bgp_peer_ipv4_soft, clear_ip_bgp_peer_ipv4_soft_cmd, - "clear ip bgp (A.B.C.D|WORD) ipv4 (unicast|multicast) soft", + "clear ip bgp (A.B.C.D|WORD) ipv4 "BGP_SAFI_CMD_STR" soft", CLEAR_STR IP_STR BGP_STR @@ -9533,17 +9454,15 @@ DEFUN (clear_ip_bgp_peer_ipv4_soft, "Address Family Modifier\n" BGP_SOFT_STR) { - if (strncmp (argv[1], "m", 1) == 0) - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer, - BGP_CLEAR_SOFT_BOTH, argv[0]); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer, - BGP_CLEAR_SOFT_BOTH, argv[0]); + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[1]); + return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_peer, + BGP_CLEAR_SOFT_BOTH, argv[0]); } DEFUN (clear_ip_bgp_instance_peer_ipv4_soft, clear_ip_bgp_instance_peer_ipv4_soft_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) ipv4 (unicast|multicast) soft", + "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) ipv4 "BGP_SAFI_CMD_STR" soft", CLEAR_STR IP_STR BGP_STR @@ -9555,12 +9474,10 @@ DEFUN (clear_ip_bgp_instance_peer_ipv4_soft, "Address Family Modifier\n" BGP_SOFT_STR) { - if (strncmp (argv[3], "m", 1) == 0) - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_peer, - BGP_CLEAR_SOFT_BOTH, argv[2]); - - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_peer, - BGP_CLEAR_SOFT_BOTH, argv[2]); + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[3]); + return bgp_clear_vty (vty, argv[1], AFI_IP, safi, clear_peer, + BGP_CLEAR_SOFT_BOTH, argv[2]); } DEFUN (clear_ip_bgp_peer_vpnv4_soft, @@ -9677,28 +9594,25 @@ ALIAS (clear_ip_bgp_peer_group_soft, DEFUN (clear_ip_bgp_peer_group_ipv4_soft, clear_ip_bgp_peer_group_ipv4_soft_cmd, - "clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft", + "clear ip bgp peer-group WORD ipv4 "BGP_SAFI_CMD_STR" soft", CLEAR_STR IP_STR BGP_STR "Clear all members of peer-group\n" "BGP peer-group name\n" "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR BGP_SOFT_STR) { - if (strncmp (argv[1], "m", 1) == 0) - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group, - BGP_CLEAR_SOFT_BOTH, argv[0]); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group, - BGP_CLEAR_SOFT_BOTH, argv[0]); + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[1]); + return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_group, + BGP_CLEAR_SOFT_BOTH, argv[0]); } DEFUN (clear_ip_bgp_instance_peer_group_ipv4_soft, clear_ip_bgp_instance_peer_group_ipv4_soft_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD ipv4 (unicast|multicast) soft", + "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD ipv4 "BGP_SAFI_CMD_STR" soft", CLEAR_STR IP_STR BGP_STR @@ -9706,16 +9620,13 @@ DEFUN (clear_ip_bgp_instance_peer_group_ipv4_soft, "Clear all members of peer-group\n" "BGP peer-group name\n" "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR BGP_SOFT_STR) { - if (strncmp (argv[3], "m", 1) == 0) - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_group, - BGP_CLEAR_SOFT_BOTH, argv[2]); - - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_group, - BGP_CLEAR_SOFT_BOTH, argv[2]); + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[3]); + return bgp_clear_vty (vty, argv[1], AFI_IP, safi, clear_group, + BGP_CLEAR_SOFT_BOTH, argv[2]); } DEFUN (clear_bgp_peer_group_soft, @@ -9795,43 +9706,37 @@ ALIAS (clear_ip_bgp_external_soft, DEFUN (clear_ip_bgp_external_ipv4_soft, clear_ip_bgp_external_ipv4_soft_cmd, - "clear ip bgp external ipv4 (unicast|multicast) soft", + "clear ip bgp external ipv4 "BGP_SAFI_CMD_STR" soft", CLEAR_STR IP_STR BGP_STR "Clear all external peers\n" "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR BGP_SOFT_STR) { - if (strncmp (argv[0], "m", 1) == 0) - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external, - BGP_CLEAR_SOFT_BOTH, NULL); - - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external, - BGP_CLEAR_SOFT_BOTH, NULL); + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[0]); + return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_external, + BGP_CLEAR_SOFT_BOTH, NULL); } DEFUN (clear_ip_bgp_instance_external_ipv4_soft, clear_ip_bgp_instance_external_ipv4_soft_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " external ipv4 (unicast|multicast) soft", + "clear ip bgp " BGP_INSTANCE_CMD " external ipv4 "BGP_SAFI_CMD_STR" soft", CLEAR_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR "Clear all external peers\n" "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR BGP_SOFT_STR) { - if (strncmp (argv[2], "m", 1) == 0) - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_external, + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[2]); + return bgp_clear_vty (vty, argv[1], AFI_IP, safi, clear_external, BGP_CLEAR_SOFT_BOTH, NULL); - - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_external, - BGP_CLEAR_SOFT_BOTH, NULL); } DEFUN (clear_bgp_external_soft, @@ -9907,7 +9812,7 @@ ALIAS (clear_ip_bgp_as_soft, DEFUN (clear_ip_bgp_as_ipv4_soft, clear_ip_bgp_as_ipv4_soft_cmd, - "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) soft", + "clear ip bgp " CMD_AS_RANGE " ipv4 "BGP_SAFI_CMD_STR" soft", CLEAR_STR IP_STR BGP_STR @@ -9917,17 +9822,15 @@ DEFUN (clear_ip_bgp_as_ipv4_soft, "Address Family Modifier\n" BGP_SOFT_STR) { - if (strncmp (argv[1], "m", 1) == 0) - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as, - BGP_CLEAR_SOFT_BOTH, argv[0]); - - return bgp_clear_vty (vty, NULL,AFI_IP, SAFI_UNICAST, clear_as, - BGP_CLEAR_SOFT_BOTH, argv[0]); + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[1]); + return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_as, + BGP_CLEAR_SOFT_BOTH, argv[0]); } DEFUN (clear_ip_bgp_instance_as_ipv4_soft, clear_ip_bgp_instance_as_ipv4_soft_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " ipv4 (unicast|multicast) soft", + "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " ipv4 "BGP_SAFI_CMD_STR" soft", CLEAR_STR IP_STR BGP_STR @@ -9938,12 +9841,10 @@ DEFUN (clear_ip_bgp_instance_as_ipv4_soft, "Address Family Modifier\n" BGP_SOFT_STR) { - if (strncmp (argv[3], "m", 1) == 0) - return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_as, - BGP_CLEAR_SOFT_BOTH, argv[2]); - - return bgp_clear_vty (vty, argv[1],AFI_IP, SAFI_UNICAST, clear_as, - BGP_CLEAR_SOFT_BOTH, argv[2]); + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[3]); + return bgp_clear_vty (vty, argv[1], AFI_IP, safi, clear_as, + BGP_CLEAR_SOFT_BOTH, argv[2]); } DEFUN (clear_ip_bgp_as_vpnv4_soft, @@ -10634,10 +10535,10 @@ bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi, { if (use_json) vty_out(vty, "{\"error\": {\"message\": \"No %s neighbor configured\"}}%s", - afi == AFI_IP ? "IPv4" : "IPv6", VTY_NEWLINE); + afi_safi_print(afi, safi), VTY_NEWLINE); else vty_out (vty, "No %s neighbor is configured%s", - afi == AFI_IP ? "IPv4" : "IPv6", VTY_NEWLINE); + afi_safi_print(afi, safi), VTY_NEWLINE); } if (dn_count && ! use_json) @@ -10778,7 +10679,7 @@ DEFUN (show_ip_bgp_ipv4_summary, SHOW_STR IP_STR BGP_STR - AFI_SAFI_STR + BGP_AFI_SAFI_HELP_STR "Summary of BGP neighbor status\n" "JavaScript Object Notation\n") { @@ -10792,38 +10693,36 @@ ALIAS (show_ip_bgp_ipv4_summary, "show bgp ipv4 (unicast|multicast|vpn|encap) summary {json}", SHOW_STR BGP_STR - AFI_SAFI_STR + BGP_AFI_SAFI_HELP_STR "Summary of BGP neighbor status\n") DEFUN (show_ip_bgp_instance_ipv4_summary, show_ip_bgp_instance_ipv4_summary_cmd, - "show ip bgp view WORD ipv4 (unicast|multicast) summary {json}", + "show ip bgp view WORD ipv4 "BGP_SAFI_CMD_STR" summary {json}", SHOW_STR IP_STR BGP_STR "BGP view\n" "View name\n" "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR "Summary of BGP neighbor status\n" "JavaScript Object Notation\n") { u_char uj = use_json(argc, argv); - if (strncmp (argv[1], "m", 1) == 0) - return bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST, uj); - else - return bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, uj); + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[1]); + return bgp_show_summary_vty (vty, argv[0], AFI_IP, safi, uj); } ALIAS (show_ip_bgp_instance_ipv4_summary, show_bgp_instance_ipv4_safi_summary_cmd, - "show bgp view WORD ipv4 (unicast|multicast) summary {json}", + "show bgp view WORD ipv4 "BGP_SAFI_CMD_STR" summary {json}", SHOW_STR BGP_STR "BGP view\n" "View name\n" - AFI_SAFI_STR + BGP_AFI_SAFI_HELP_STR "Summary of BGP neighbor status\n") DEFUN (show_ip_bgp_vpnv4_all_summary, @@ -10928,7 +10827,7 @@ DEFUN (show_bgp_ipv6_safi_summary, "show bgp ipv6 (unicast|multicast|vpn|encap) summary {json}", SHOW_STR BGP_STR - AFI_SAFI_STR + BGP_AFI_SAFI_HELP_STR "Summary of BGP neighbor status\n" "JavaScript Object Notation\n") { @@ -10939,19 +10838,18 @@ DEFUN (show_bgp_ipv6_safi_summary, DEFUN (show_bgp_instance_ipv6_safi_summary, show_bgp_instance_ipv6_safi_summary_cmd, - "show bgp " BGP_INSTANCE_CMD " ipv6 (unicast|multicast) summary {json}", + "show bgp " BGP_INSTANCE_CMD " ipv6 "BGP_SAFI_CMD_STR" summary {json}", SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR - AFI_SAFI_STR + BGP_AFI_SAFI_HELP_STR "Summary of BGP neighbor status\n" "JavaScript Object Notation\n") { u_char uj = use_json(argc, argv); - if (strncmp (argv[2], "m", 1) == 0) - return bgp_show_summary_vty (vty, argv[1], AFI_IP6, SAFI_MULTICAST, uj); - - return bgp_show_summary_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, uj); + safi_t safi; + safi = bgp_vty_safi_from_arg(argv[2]); + return bgp_show_summary_vty (vty, argv[1], AFI_IP6, safi, uj); } /* old command */ @@ -10991,17 +10889,17 @@ afi_safi_print (afi_t afi, safi_t safi) else if (afi == AFI_IP && safi == SAFI_MULTICAST) return "IPv4 Multicast"; else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) - return "VPN-IPv4 Unicast"; + return "IPv4 VPN"; else if (afi == AFI_IP && safi == SAFI_ENCAP) - return "ENCAP-IPv4 Unicast"; + return "IPv4 Encap"; else if (afi == AFI_IP6 && safi == SAFI_UNICAST) return "IPv6 Unicast"; else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) return "IPv6 Multicast"; else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) - return "VPN-IPv6 Unicast"; + return "IPv6 VPN"; else if (afi == AFI_IP6 && safi == SAFI_ENCAP) - return "ENCAP-IPv6 Unicast"; + return "IPv6 Encap"; else return "Unknown"; } @@ -12826,13 +12724,12 @@ DEFUN (show_ip_bgp_neighbors, ALIAS (show_ip_bgp_neighbors, show_ip_bgp_ipv4_neighbors_cmd, - "show ip bgp ipv4 (unicast|multicast) neighbors {json}", + "show ip bgp ipv4 "BGP_SAFI_CMD_STR" neighbors {json}", SHOW_STR IP_STR BGP_STR "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR "Detailed information on TCP and BGP neighbor connections\n" "JavaScript Object Notation\n") @@ -12895,13 +12792,12 @@ DEFUN (show_ip_bgp_neighbors_peer, ALIAS (show_ip_bgp_neighbors_peer, show_ip_bgp_ipv4_neighbors_peer_cmd, - "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) {json}", + "show ip bgp ipv4 "BGP_SAFI_CMD_STR" neighbors (A.B.C.D|X:X::X:X|WORD) {json}", SHOW_STR IP_STR BGP_STR "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR "Detailed information on TCP and BGP neighbor connections\n" "Neighbor to display information about\n" "Neighbor to display information about\n" @@ -13066,13 +12962,12 @@ DEFUN (show_ip_bgp_paths, DEFUN (show_ip_bgp_ipv4_paths, show_ip_bgp_ipv4_paths_cmd, - "show ip bgp ipv4 (unicast|multicast) paths", + "show ip bgp ipv4 "BGP_SAFI_CMD_STR" paths", SHOW_STR IP_STR BGP_STR "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_SAFI_HELP_STR "Path information\n") { vty_out (vty, "Address Refcnt Path\r\n"); @@ -13227,19 +13122,16 @@ DEFUN (show_bgp_instance_all_ipv6_updgrps, DEFUN (show_bgp_updgrps, show_bgp_updgrps_cmd, - "show bgp (ipv4|ipv6) (unicast|multicast|vpn|encap) update-groups", + "show bgp "BGP_AFI_SAFI_CMD_STR" update-groups", SHOW_STR BGP_STR - "Address family\n" - "Address family\n" - "Address Family modifier\n" - "Address Family modifier\n" + BGP_AFI_SAFI_HELP_STR "Detailed info about dynamic update groups\n") { afi_t afi; safi_t safi; - afi = (strcmp(argv[0], "ipv4") == 0) ? AFI_IP : AFI_IP6; + afi = bgp_vty_safi_from_arg(argv[0]); safi = bgp_vty_safi_from_arg(argv[1]); return (bgp_show_update_groups(vty, NULL, afi, safi, 0)); } @@ -13305,11 +13197,11 @@ DEFUN (show_bgp_instance_ipv6_updgrps_s, DEFUN (show_bgp_updgrps_s, show_bgp_updgrps_s_cmd, - "show bgp (ipv4|ipv6) (unicast|multicast|vpn|encap) update-groups SUBGROUP-ID", + "show bgp "BGP_AFI_SAFI_CMD_STR" update-groups SUBGROUP-ID", SHOW_STR BGP_STR "Address family\n" - AFI_SAFI_STR + BGP_AFI_SAFI_HELP_STR "Detailed info about v6 dynamic update groups\n" "Specific subgroup to display detailed info for") { @@ -13317,7 +13209,7 @@ DEFUN (show_bgp_updgrps_s, safi_t safi; uint64_t subgrp_id; - afi = (strcmp(argv[0], "ipv4") == 0) ? AFI_IP : AFI_IP6; + afi = bgp_vty_safi_from_arg(argv[0]); safi = bgp_vty_safi_from_arg(argv[1]); VTY_GET_ULL("subgroup-id", subgrp_id, argv[2]); return(bgp_show_update_groups(vty, NULL, afi, safi, subgrp_id)); @@ -13416,11 +13308,10 @@ DEFUN (show_ip_bgp_instance_updgrps_adj, DEFUN (show_bgp_updgrps_afi_adj, show_bgp_updgrps_afi_adj_cmd, - "show bgp (ipv4|ipv6) (unicast|multicast|vpn|encap) update-groups (advertise-queue|advertised-routes|packet-queue)", + "show bgp "BGP_AFI_SAFI_CMD_STR" update-groups (advertise-queue|advertised-routes|packet-queue)", SHOW_STR BGP_STR - "Address family\n" - AFI_SAFI_STR + BGP_AFI_SAFI_HELP_STR "BGP update groups\n" "Advertisement queue\n" "Announced routes\n" @@ -13430,7 +13321,7 @@ DEFUN (show_bgp_updgrps_afi_adj, afi_t afi; safi_t safi; - afi = (strcmp(argv[0], "ipv4") == 0) ? AFI_IP : AFI_IP6; + afi = bgp_vty_safi_from_arg(argv[0]); safi = bgp_vty_safi_from_arg(argv[1]); show_bgp_updgrps_adj_info_aux(vty, NULL, afi, safi, argv[2], 0); return CMD_SUCCESS; @@ -13510,11 +13401,10 @@ DEFUN (show_ip_bgp_instance_updgrps_adj_s, DEFUN (show_bgp_updgrps_afi_adj_s, show_bgp_updgrps_afi_adj_s_cmd, - "show bgp (ipv4|ipv6) (unicast|multicast|vpn|encap) update-groups SUBGROUP-ID (advertise-queue|advertised-routes|packet-queue)", + "show bgp "BGP_AFI_SAFI_CMD_STR" update-groups SUBGROUP-ID (advertise-queue|advertised-routes|packet-queue)", SHOW_STR BGP_STR - "Address family\n" - AFI_SAFI_STR + BGP_AFI_SAFI_HELP_STR "BGP update groups\n" "Specific subgroup to display info for\n" "Advertisement queue\n" @@ -13526,7 +13416,7 @@ DEFUN (show_bgp_updgrps_afi_adj_s, safi_t safi; uint64_t subgrp_id; - afi = (strcmp(argv[0], "ipv4") == 0) ? AFI_IP : AFI_IP6; + afi = bgp_vty_safi_from_arg(argv[0]); safi = bgp_vty_safi_from_arg(argv[1]); VTY_GET_ULL("subgroup-id", subgrp_id, argv[2]); diff --git a/bgpd/bgp_vty.h b/bgpd/bgp_vty.h index 6b4e51bc50..53914e622b 100644 --- a/bgpd/bgp_vty.h +++ b/bgpd/bgp_vty.h @@ -30,12 +30,16 @@ struct bgp; #define BGP_INSTANCE_ALL_CMD "(view|vrf) all" #define BGP_INSTANCE_ALL_HELP_STR "BGP view\nBGP VRF\nAll Views/VRFs\n" -#define AFI_SAFI_STR \ - "Address family\n" \ - "Address Family modifier\n" \ - "Address Family modifier\n" \ - "Address Family modifier\n" \ +#define BGP_AFI_CMD_STR "(ipv4|ipv6)" +#define BGP_AFI_HELP_STR "Address Family\nAddress Family\n" +#define BGP_SAFI_CMD_STR "(unicast|multicast|vpn|encap)" +#define BGP_SAFI_HELP_STR \ + "Address Family modifier\n" \ + "Address Family modifier\n" \ + "Address Family modifier\n" \ "Address Family modifier\n" +#define BGP_AFI_SAFI_CMD_STR BGP_AFI_CMD_STR" "BGP_SAFI_CMD_STR +#define BGP_AFI_SAFI_HELP_STR BGP_AFI_HELP_STR BGP_SAFI_HELP_STR extern void bgp_vty_init (void); extern const char *afi_safi_print (afi_t, safi_t); @@ -53,6 +57,9 @@ bgp_parse_afi(const char *str, afi_t *afi); extern int bgp_parse_safi(const char *str, safi_t *safi); +extern afi_t +bgp_vty_afi_from_arg(const char *afi_str); + extern safi_t bgp_vty_safi_from_arg(const char *safi_str); From bbe820a858c7e856a97b9309f1aa595fc2aca11e Mon Sep 17 00:00:00 2001 From: Lou Berger Date: Fri, 6 Jan 2017 18:25:56 -0500 Subject: [PATCH 082/107] bgpd: restore wildcard handling in show summary (Issue#14) Includes more branch specific afi/safi changes Signed-off-by: Lou Berger --- bgpd/bgp_vty.c | 133 +++++++++++++++++++++++++++++++++++++++++-------- bgpd/bgp_vty.h | 1 + 2 files changed, 113 insertions(+), 21 deletions(-) diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 1b8b135f66..fad2d7ac1c 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -10553,6 +10553,62 @@ bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi, return CMD_SUCCESS; } +static void +bgp_show_summary_afi_safi (struct vty *vty, struct bgp *bgp, int afi, int safi, + u_char use_json, json_object *json) +{ + int is_first = 1; + int afi_wildcard = (afi == AFI_MAX); + int safi_wildcard = (safi == SAFI_MAX); + int is_wildcard = (afi_wildcard || safi_wildcard); + if (use_json && is_wildcard) + vty_out (vty, "{%s", VTY_NEWLINE); + if (afi_wildcard) + afi = 1; /* AFI_IP */ + while (afi < AFI_MAX) + { + if (safi_wildcard) + safi = 1; /* SAFI_UNICAST */ + while (safi < SAFI_MAX) + { + if (is_wildcard) + { + if (use_json) + { + json = json_object_new_object(); + + if (! is_first) + vty_out (vty, ",%s", VTY_NEWLINE); + else + is_first = 0; + + vty_out(vty, "\"%s\":", afi_safi_json(afi, safi)); + } + else + { + vty_out (vty, "%s%s Summary:%s", + VTY_NEWLINE, afi_safi_print(afi, safi), VTY_NEWLINE); + } + } + bgp_show_summary (vty, bgp, afi, safi, use_json, json); + if (safi == SAFI_MPLS_VPN) /* handle special cases to match zebra.h */ + safi = SAFI_ENCAP; + else + safi++; + if (! safi_wildcard) + safi = SAFI_MAX; + } + afi++; + if (! afi_wildcard || + afi == AFI_ETHER) /* special case, not handled yet */ + afi = AFI_MAX; + } + + if (use_json && is_wildcard) + vty_out (vty, "}%s", VTY_NEWLINE); + +} + static int bgp_show_summary_vty (struct vty *vty, const char *name, afi_t afi, safi_t safi, u_char use_json) @@ -10569,14 +10625,14 @@ bgp_show_summary_vty (struct vty *vty, const char *name, return CMD_WARNING; } - bgp_show_summary (vty, bgp, afi, safi, use_json, NULL); + bgp_show_summary_afi_safi (vty, bgp, afi, safi, use_json, NULL); return CMD_SUCCESS; } bgp = bgp_get_default (); if (bgp) - bgp_show_summary (vty, bgp, afi, safi, use_json, NULL); + bgp_show_summary_afi_safi (vty, bgp, afi, safi, use_json, NULL); return CMD_SUCCESS; } @@ -10621,7 +10677,7 @@ bgp_show_all_instances_summary_vty (struct vty *vty, afi_t afi, safi_t safi, (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) ? "Default" : bgp->name, VTY_NEWLINE); } - bgp_show_summary (vty, bgp, afi, safi, use_json, json); + bgp_show_summary_afi_safi (vty, bgp, afi, safi, use_json, json); } if (use_json) @@ -10640,7 +10696,7 @@ DEFUN (show_ip_bgp_summary, "JavaScript Object Notation\n") { u_char uj = use_json(argc, argv); - return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST, uj); + return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MAX, uj); } DEFUN (show_ip_bgp_instance_summary, @@ -10654,7 +10710,7 @@ DEFUN (show_ip_bgp_instance_summary, "JavaScript Object Notation\n") { u_char uj = use_json(argc, argv); - return bgp_show_summary_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, uj); + return bgp_show_summary_vty (vty, argv[1], AFI_IP, SAFI_MAX, uj); } DEFUN (show_ip_bgp_instance_all_summary, @@ -10669,17 +10725,18 @@ DEFUN (show_ip_bgp_instance_all_summary, { u_char uj = use_json(argc, argv); - bgp_show_all_instances_summary_vty (vty, AFI_IP, SAFI_UNICAST, uj); + bgp_show_all_instances_summary_vty (vty, AFI_IP, SAFI_MAX, uj); return CMD_SUCCESS; } DEFUN (show_ip_bgp_ipv4_summary, show_ip_bgp_ipv4_summary_cmd, - "show ip bgp ipv4 (unicast|multicast|vpn|encap) summary {json}", + "show ip bgp ipv4 "BGP_SAFI_CMD_STR" summary {json}", SHOW_STR IP_STR BGP_STR - BGP_AFI_SAFI_HELP_STR + "Address family\n" + BGP_SAFI_HELP_STR "Summary of BGP neighbor status\n" "JavaScript Object Notation\n") { @@ -10690,10 +10747,11 @@ DEFUN (show_ip_bgp_ipv4_summary, ALIAS (show_ip_bgp_ipv4_summary, show_bgp_ipv4_safi_summary_cmd, - "show bgp ipv4 (unicast|multicast|vpn|encap) summary {json}", + "show bgp ipv4 "BGP_SAFI_CMD_STR" summary {json}", SHOW_STR BGP_STR - BGP_AFI_SAFI_HELP_STR + "Address family\n" + BGP_SAFI_HELP_STR "Summary of BGP neighbor status\n") DEFUN (show_ip_bgp_instance_ipv4_summary, @@ -10775,7 +10833,7 @@ DEFUN (show_bgp_summary, "Summary of BGP neighbor status\n" "JavaScript Object Notation\n") { - return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, use_json(argc, argv)); + return bgp_show_summary_vty (vty, NULL, AFI_MAX, SAFI_MAX, use_json(argc, argv)); } DEFUN (show_bgp_instance_summary, @@ -10787,7 +10845,7 @@ DEFUN (show_bgp_instance_summary, "Summary of BGP neighbor status\n" "JavaScript Object Notation\n") { - return bgp_show_summary_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, use_json(argc, argv)); + return bgp_show_summary_vty (vty, argv[1], AFI_MAX, SAFI_MAX, use_json(argc, argv)); } DEFUN (show_bgp_instance_all_summary, @@ -10801,19 +10859,22 @@ DEFUN (show_bgp_instance_all_summary, { u_char uj = use_json(argc, argv); - bgp_show_all_instances_summary_vty (vty, AFI_IP6, SAFI_UNICAST, uj); + bgp_show_all_instances_summary_vty (vty, AFI_MAX, SAFI_MAX, uj); return CMD_SUCCESS; } -ALIAS (show_bgp_summary, +DEFUN (show_bgp_ipv6_summary, show_bgp_ipv6_summary_cmd, "show bgp ipv6 summary {json}", SHOW_STR BGP_STR "Address family\n" "Summary of BGP neighbor status\n") +{ + return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_MAX, use_json(argc, argv)); +} -ALIAS (show_bgp_instance_summary, +DEFUN (show_bgp_instance_ipv6__summary, show_bgp_instance_ipv6_summary_cmd, "show bgp " BGP_INSTANCE_CMD " ipv6 summary {json}", SHOW_STR @@ -10821,13 +10882,17 @@ ALIAS (show_bgp_instance_summary, BGP_INSTANCE_HELP_STR "Address family\n" "Summary of BGP neighbor status\n") +{ + return bgp_show_summary_vty (vty, argv[1], AFI_IP6, SAFI_MAX, use_json(argc, argv)); +} DEFUN (show_bgp_ipv6_safi_summary, show_bgp_ipv6_safi_summary_cmd, - "show bgp ipv6 (unicast|multicast|vpn|encap) summary {json}", + "show bgp ipv6 "BGP_SAFI_CMD_STR" summary {json}", SHOW_STR BGP_STR - BGP_AFI_SAFI_HELP_STR + "Address family\n" + BGP_SAFI_HELP_STR "Summary of BGP neighbor status\n" "JavaScript Object Notation\n") { @@ -10863,7 +10928,7 @@ DEFUN (show_ipv6_bgp_summary, "JavaScript Object Notation\n") { u_char uj = use_json(argc, argv); - return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, uj); + return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_MAX, uj); } /* old command */ @@ -10904,6 +10969,29 @@ afi_safi_print (afi_t afi, safi_t safi) return "Unknown"; } +const char * +afi_safi_json (afi_t afi, safi_t safi) +{ + if (afi == AFI_IP && safi == SAFI_UNICAST) + return "IPv4Unicast"; + else if (afi == AFI_IP && safi == SAFI_MULTICAST) + return "IPv4Multicast"; + else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) + return "IPv4VPN"; + else if (afi == AFI_IP && safi == SAFI_ENCAP) + return "IPv4Encap"; + else if (afi == AFI_IP6 && safi == SAFI_UNICAST) + return "IPv6Unicast"; + else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) + return "IPv6Multicast"; + else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) + return "IPv6VPN"; + else if (afi == AFI_IP6 && safi == SAFI_ENCAP) + return "IPv6Encap"; + else + return "Unknown"; +} + /* Show BGP peer's information. */ enum show_type { @@ -13125,7 +13213,8 @@ DEFUN (show_bgp_updgrps, "show bgp "BGP_AFI_SAFI_CMD_STR" update-groups", SHOW_STR BGP_STR - BGP_AFI_SAFI_HELP_STR + "Address family\n" + BGP_SAFI_HELP_STR "Detailed info about dynamic update groups\n") { afi_t afi; @@ -13311,7 +13400,8 @@ DEFUN (show_bgp_updgrps_afi_adj, "show bgp "BGP_AFI_SAFI_CMD_STR" update-groups (advertise-queue|advertised-routes|packet-queue)", SHOW_STR BGP_STR - BGP_AFI_SAFI_HELP_STR + "Address family\n" + BGP_SAFI_HELP_STR "BGP update groups\n" "Advertisement queue\n" "Announced routes\n" @@ -13404,7 +13494,8 @@ DEFUN (show_bgp_updgrps_afi_adj_s, "show bgp "BGP_AFI_SAFI_CMD_STR" update-groups SUBGROUP-ID (advertise-queue|advertised-routes|packet-queue)", SHOW_STR BGP_STR - BGP_AFI_SAFI_HELP_STR + "Address family\n" + BGP_SAFI_HELP_STR "BGP update groups\n" "Specific subgroup to display info for\n" "Advertisement queue\n" diff --git a/bgpd/bgp_vty.h b/bgpd/bgp_vty.h index 53914e622b..e3a51ac450 100644 --- a/bgpd/bgp_vty.h +++ b/bgpd/bgp_vty.h @@ -43,6 +43,7 @@ struct bgp; extern void bgp_vty_init (void); extern const char *afi_safi_print (afi_t, safi_t); +extern const char *afi_safi_json (afi_t, safi_t); extern int bgp_config_write_update_delay (struct vty *, struct bgp *); extern int bgp_config_write_wpkt_quanta(struct vty *vty, struct bgp *bgp); extern int bgp_config_write_listen(struct vty *vty, struct bgp *bgp); From ec3484d972e109daa140f1a24877977a55ae242f Mon Sep 17 00:00:00 2001 From: Lou Berger Date: Tue, 10 Jan 2017 15:53:03 -0500 Subject: [PATCH 083/107] bgpd: conditionally compile out old vpnv4 syntax (Issue #61) (under ifdef KEEP_OLD_VPNV4_COMMANDS) Signed-off-by: Lou Berger --- bgpd/bgp_mplsvpn.c | 17 ++++++++++++----- bgpd/bgp_route.c | 14 ++++++++++++++ bgpd/bgp_routemap.c | 37 ++++++++++++++++++++++--------------- bgpd/bgp_vty.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 90 insertions(+), 20 deletions(-) diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c index d55acdd512..02febf8630 100644 --- a/bgpd/bgp_mplsvpn.c +++ b/bgpd/bgp_mplsvpn.c @@ -198,7 +198,7 @@ bgp_nlri_parse_vpn (struct peer *peer, struct attr *attr, if (prefixlen < VPN_PREFIXLEN_MIN_BYTES*8) { - zlog_err ("%s [Error] Update packet error / VPNv4 (prefix length %d less than VPNv4 min length)", + zlog_err ("%s [Error] Update packet error / VPN (prefix length %d less than VPN min length)", peer->host, prefixlen); return -1; } @@ -206,7 +206,7 @@ bgp_nlri_parse_vpn (struct peer *peer, struct attr *attr, /* sanity check against packet data */ if ((pnt + psize) > lim) { - zlog_err ("%s [Error] Update packet error / VPNv4 (prefix length %d exceeds packet size %u)", + zlog_err ("%s [Error] Update packet error / VPN (prefix length %d exceeds packet size %u)", peer->host, prefixlen, (uint)(lim-pnt)); return -1; @@ -215,7 +215,7 @@ bgp_nlri_parse_vpn (struct peer *peer, struct attr *attr, /* sanity check against storage for the IP address portion */ if ((psize - VPN_PREFIXLEN_MIN_BYTES) > (ssize_t) sizeof(p.u)) { - zlog_err ("%s [Error] Update packet error / VPNv4 (psize %d exceeds storage size %zu)", + zlog_err ("%s [Error] Update packet error / VPN (psize %d exceeds storage size %zu)", peer->host, prefixlen - VPN_PREFIXLEN_MIN_BYTES*8, sizeof(p.u)); return -1; @@ -224,7 +224,7 @@ bgp_nlri_parse_vpn (struct peer *peer, struct attr *attr, /* Sanity check against max bitlen of the address family */ if ((psize - VPN_PREFIXLEN_MIN_BYTES) > prefix_blen (&p)) { - zlog_err ("%s [Error] Update packet error / VPNv4 (psize %d exceeds family (%u) max byte len %u)", + zlog_err ("%s [Error] Update packet error / VPN (psize %d exceeds family (%u) max byte len %u)", peer->host, prefixlen - VPN_PREFIXLEN_MIN_BYTES*8, p.family, prefix_blen (&p)); @@ -295,7 +295,7 @@ bgp_nlri_parse_vpn (struct peer *peer, struct attr *attr, /* Packet length consistency check. */ if (pnt != lim) { - zlog_err ("%s [Error] Update packet error / VPNv4 (%zu data remaining after parsing)", + zlog_err ("%s [Error] Update packet error / VPN (%zu data remaining after parsing)", peer->host, lim - pnt); return -1; } @@ -484,6 +484,7 @@ DEFUN (no_vpnv4_network, return bgp_static_unset_safi (SAFI_MPLS_VPN, vty, argv[0], argv[1], argv[2]); } +#ifdef KEEP_OLD_VPNV4_COMMANDS static int show_adj_route_vpn (struct vty *vty, struct peer *peer, struct prefix_rd *prd, u_char use_json) { @@ -650,6 +651,7 @@ show_adj_route_vpn (struct vty *vty, struct peer *peer, struct prefix_rd *prd, u } return CMD_SUCCESS; } +#endif /* KEEP_OLD_VPNV4_COMMANDS */ enum bgp_show_type { @@ -954,6 +956,7 @@ DEFUN (show_bgp_ipv6_vpn_rd, return bgp_show_mpls_vpn (vty, AFI_IP6, &prd, bgp_show_type_normal, NULL, 0, use_json (argc, argv)); } +#ifdef KEEP_OLD_VPNV4_COMMANDS DEFUN (show_ip_bgp_vpnv4_all, show_ip_bgp_vpnv4_all_cmd, "show ip bgp vpnv4 all", @@ -1269,6 +1272,7 @@ DEFUN (show_ip_bgp_vpnv4_rd_neighbor_advertised_routes, return show_adj_route_vpn (vty, peer, &prd, uj); } +#endif /* KEEP_OLD_VPNV4_COMMANDS */ void bgp_mplsvpn_init (void) @@ -1281,6 +1285,7 @@ bgp_mplsvpn_init (void) install_element (VIEW_NODE, &show_bgp_ipv4_vpn_rd_cmd); install_element (VIEW_NODE, &show_bgp_ipv6_vpn_cmd); install_element (VIEW_NODE, &show_bgp_ipv6_vpn_rd_cmd); +#ifdef KEEP_OLD_VPNV4_COMMANDS install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_cmd); install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_cmd); install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_tags_cmd); @@ -1289,4 +1294,6 @@ bgp_mplsvpn_init (void) install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_neighbor_routes_cmd); install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_neighbor_advertised_routes_cmd); install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_neighbor_advertised_routes_cmd); +#endif /* KEEP_OLD_VPNV4_COMMANDS */ + } diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index e31c745e56..2320c08b1f 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -8297,6 +8297,7 @@ ALIAS (show_ip_bgp_ipv4_route, "Network in the BGP routing table to display\n" "JavaScript Object Notation\n") +#ifdef KEEP_OLD_VPNV4_COMMANDS DEFUN (show_ip_bgp_vpnv4_all_route, show_ip_bgp_vpnv4_all_route_cmd, "show ip bgp vpnv4 all A.B.C.D {json}", @@ -8310,6 +8311,7 @@ DEFUN (show_ip_bgp_vpnv4_all_route, { return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); } +#endif /* KEEP_OLD_VPNV4_COMMANDS */ DEFUN (show_bgp_ipv4_safi_rd_route, show_bgp_ipv4_safi_rd_route_cmd, @@ -8430,6 +8432,7 @@ DEFUN (show_bgp_ipv6_safi_rd_prefix, return bgp_show_route (vty, NULL, argv[2], AFI_IP6, safi, &prd, 1, BGP_PATH_ALL, use_json (argc, argv)); } +#ifdef KEEP_OLD_VPNV4_COMMANDS DEFUN (show_ip_bgp_vpnv4_rd_route, show_ip_bgp_vpnv4_rd_route_cmd, "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D {json}", @@ -8454,6 +8457,7 @@ DEFUN (show_ip_bgp_vpnv4_rd_route, } return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL, uj); } +#endif /* KEEP_OLD_VPNV4_COMMANDS */ DEFUN (show_ip_bgp_prefix, show_ip_bgp_prefix_cmd, @@ -8546,6 +8550,7 @@ ALIAS (show_ip_bgp_ipv4_prefix_pathtype, "Display only multipaths\n" "JavaScript Object Notation\n") +#ifdef KEEP_OLD_VPNV4_COMMANDS DEFUN (show_ip_bgp_vpnv4_all_prefix, show_ip_bgp_vpnv4_all_prefix_cmd, "show ip bgp vpnv4 all A.B.C.D/M {json}", @@ -8583,6 +8588,7 @@ DEFUN (show_ip_bgp_vpnv4_rd_prefix, } return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL, use_json(argc, argv)); } +#endif /* KEEP_OLD_VPNV4_COMMANDS */ DEFUN (show_ip_bgp_view, show_ip_bgp_instance_cmd, @@ -12242,6 +12248,7 @@ DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts, return bgp_peer_counts (vty, peer, AFI_IP, safi, uj); } +#ifdef KEEP_OLD_VPNV4_COMMANDS DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts, show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd, "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}", @@ -12266,6 +12273,7 @@ DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts, return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MPLS_VPN, uj); } +#endif /* KEEP_OLD_VPNV4_COMMANDS */ static void show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, @@ -14776,8 +14784,10 @@ bgp_route_init (void) install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_pathtype_cmd); install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd); install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_cmd); +#ifdef KEEP_OLD_VPNV4_COMMANDS install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd); install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); +#endif /* KEEP_OLD_VPNV4_COMMANDS */ install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd); install_element (VIEW_NODE, &show_ip_bgp_instance_prefix_cmd); install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd); @@ -14786,8 +14796,10 @@ bgp_route_init (void) install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_cmd); install_element (VIEW_NODE, &show_ip_bgp_prefix_pathtype_cmd); install_element (VIEW_NODE, &show_ip_bgp_instance_prefix_pathtype_cmd); +#ifdef KEEP_OLD_VPNV4_COMMANDS install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); +#endif /* KEEP_OLD_VPNV4_COMMANDS */ install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd); install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd); @@ -14892,7 +14904,9 @@ bgp_route_init (void) install_element (ENABLE_NODE, &show_ip_bgp_neighbor_prefix_counts_cmd); install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbor_prefix_counts_cmd); install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd); +#ifdef KEEP_OLD_VPNV4_COMMANDS install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd); +#endif /* KEEP_OLD_VPNV4_COMMANDS */ #ifdef HAVE_IPV6 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_prefix_counts_cmd); install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbor_prefix_counts_cmd); diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c index ea42cb57c9..61435ce207 100644 --- a/bgpd/bgp_routemap.c +++ b/bgpd/bgp_routemap.c @@ -2342,8 +2342,8 @@ struct route_map_rule_cmd route_set_ipv6_nexthop_peer_cmd = #endif /* HAVE_IPV6 */ -/* `set vpnv4 nexthop A.B.C.D' */ - +#ifdef KEEP_OLD_VPNV4_COMMANDS +/* `set ip vpn nexthop A.B.C.D' */ static route_map_result_t route_set_vpnv4_nexthop (void *rule, struct prefix *prefix, route_map_object_t type, void *object) @@ -2393,11 +2393,12 @@ route_set_vpnv4_nexthop_free (void *rule) /* Route map commands for ip nexthop set. */ struct route_map_rule_cmd route_set_vpnv4_nexthop_cmd = { - "vpnv4 next-hop", + "ip vpn next-hop", route_set_vpnv4_nexthop, route_set_vpnv4_nexthop_compile, route_set_vpnv4_nexthop_free }; +#endif /* KEEP_OLD_VPNV4_COMMANDS */ /* `set originator-id' */ @@ -4500,39 +4501,41 @@ ALIAS (no_set_ipv6_nexthop_local, "IPv6 address of next hop\n") #endif /* HAVE_IPV6 */ +#ifdef KEEP_OLD_VPNV4_COMMANDS DEFUN (set_vpnv4_nexthop, set_vpnv4_nexthop_cmd, - "set vpnv4 next-hop A.B.C.D", + "set ip vpn next-hop A.B.C.D", SET_STR - "VPNv4 information\n" - "VPNv4 next-hop address\n" + "IP VPN information\n" + "IP VPN next-hop address\n" "IP address of next hop\n") { - return bgp_route_set_add (vty, vty->index, "vpnv4 next-hop", argv[0]); + return bgp_route_set_add (vty, vty->index, "ip vpn next-hop", argv[0]); } DEFUN (no_set_vpnv4_nexthop, no_set_vpnv4_nexthop_cmd, - "no set vpnv4 next-hop", + "no set ip vpn next-hop", NO_STR SET_STR - "VPNv4 information\n" - "VPNv4 next-hop address\n") + "IP VPN information\n" + "IP VPN next-hop address\n") { if (argc == 0) - return bgp_route_set_delete (vty, vty->index, "vpnv4 next-hop", NULL); + return bgp_route_set_delete (vty, vty->index, "ip vpn next-hop", NULL); - return bgp_route_set_delete (vty, vty->index, "vpnv4 next-hop", argv[0]); + return bgp_route_set_delete (vty, vty->index, "ip vpn next-hop", argv[0]); } ALIAS (no_set_vpnv4_nexthop, no_set_vpnv4_nexthop_val_cmd, - "no set vpnv4 next-hop A.B.C.D", + "no set ip vpn next-hop A.B.C.D", NO_STR SET_STR - "VPNv4 information\n" - "VPNv4 next-hop address\n" + "IP VPN information\n" + "IP VPN next-hop address\n" "IP address of next hop\n") +#endif /* KEEP_OLD_VPNV4_COMMANDS */ DEFUN (set_originator_id, set_originator_id_cmd, @@ -4604,7 +4607,9 @@ bgp_route_map_init (void) route_map_install_set (&route_set_aggregator_as_cmd); route_map_install_set (&route_set_community_cmd); route_map_install_set (&route_set_community_delete_cmd); +#ifdef KEEP_OLD_VPNV4_COMMANDS route_map_install_set (&route_set_vpnv4_nexthop_cmd); +#endif /* KEEP_OLD_VPNV4_COMMANDS */ route_map_install_set (&route_set_originator_id_cmd); route_map_install_set (&route_set_ecommunity_rt_cmd); route_map_install_set (&route_set_ecommunity_soo_cmd); @@ -4710,9 +4715,11 @@ bgp_route_map_init (void) install_element (RMAP_NODE, &set_ecommunity_soo_cmd); install_element (RMAP_NODE, &no_set_ecommunity_soo_cmd); install_element (RMAP_NODE, &no_set_ecommunity_soo_val_cmd); +#ifdef KEEP_OLD_VPNV4_COMMANDS install_element (RMAP_NODE, &set_vpnv4_nexthop_cmd); install_element (RMAP_NODE, &no_set_vpnv4_nexthop_cmd); install_element (RMAP_NODE, &no_set_vpnv4_nexthop_val_cmd); +#endif /* KEEP_OLD_VPNV4_COMMANDS */ install_element (RMAP_NODE, &set_originator_id_cmd); install_element (RMAP_NODE, &no_set_originator_id_cmd); install_element (RMAP_NODE, &no_set_originator_id_val_cmd); diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index fad2d7ac1c..f2190c8303 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -6139,12 +6139,14 @@ DEFUN (address_family_vpnv4, return CMD_SUCCESS; } +#ifdef KEEP_OLD_VPNV4_COMMANDS ALIAS (address_family_vpnv4, address_family_vpnv4_unicast_cmd, "address-family vpnv4 unicast", "Enter Address Family command mode\n" "Address family\n" "Address Family Modifier\n") +#endif /* KEEP_OLD_VPNV4_COMMANDS */ DEFUN (address_family_vpnv6, address_family_vpnv6_cmd, @@ -6156,12 +6158,14 @@ DEFUN (address_family_vpnv6, return CMD_SUCCESS; } +#ifdef KEEP_OLD_VPNV4_COMMANDS ALIAS (address_family_vpnv6, address_family_vpnv6_unicast_cmd, "address-family vpnv6 unicast", "Enter Address Family command mode\n" "Address family\n" "Address Family Modifier\n") +#endif /* KEEP_OLD_VPNV4_COMMANDS */ DEFUN (address_family_encap, address_family_encap_cmd, @@ -6730,6 +6734,7 @@ ALIAS (clear_ip_bgp_instance_all_ipv4_soft_out, BGP_SAFI_HELP_STR BGP_SOFT_OUT_STR) +#ifdef KEEP_OLD_VPNV4_COMMANDS DEFUN (clear_ip_bgp_all_vpnv4_soft_out, clear_ip_bgp_all_vpnv4_soft_out_cmd, "clear ip bgp * vpnv4 unicast soft out", @@ -6783,6 +6788,7 @@ ALIAS (clear_ip_bgp_all_encap_soft_out, "Address family\n" "Address Family Modifier\n" "Soft reconfig outbound update\n") +#endif /* KEEP_OLD_VPNV4_COMMANDS */ DEFUN (clear_bgp_all_soft_out, clear_bgp_all_soft_out_cmd, @@ -7015,6 +7021,7 @@ ALIAS (clear_ip_bgp_instance_peer_ipv4_soft_out, BGP_SAFI_HELP_STR BGP_SOFT_OUT_STR) +#ifdef KEEP_OLD_VPNV4_COMMANDS /* NOTE: WORD peers have not been tested for vpnv4 */ DEFUN (clear_ip_bgp_peer_vpnv4_soft_out, clear_ip_bgp_peer_vpnv4_soft_out_cmd, @@ -7071,6 +7078,7 @@ ALIAS (clear_ip_bgp_peer_encap_soft_out, "Address family\n" "Address Family Modifier\n" "Soft reconfig outbound update\n") +#endif /* KEEP_OLD_VPNV4_COMMANDS */ DEFUN (clear_bgp_peer_soft_out, clear_bgp_peer_soft_out_cmd, @@ -7680,6 +7688,7 @@ ALIAS (clear_ip_bgp_instance_as_ipv4_soft_out, BGP_SAFI_HELP_STR BGP_SOFT_OUT_STR) +#ifdef KEEP_OLD_VPNV4_COMMANDS DEFUN (clear_ip_bgp_as_vpnv4_soft_out, clear_ip_bgp_as_vpnv4_soft_out_cmd, "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast soft out", @@ -7733,6 +7742,7 @@ ALIAS (clear_ip_bgp_as_encap_soft_out, "Address family\n" "Address Family modifier\n" "Soft reconfig outbound update\n") +#endif /* KEEP_OLD_VPNV4_COMMANDS */ DEFUN (clear_bgp_as_soft_out, clear_bgp_as_soft_out_cmd, @@ -7963,6 +7973,7 @@ DEFUN (clear_ip_bgp_all_ipv4_in_prefix_filter, BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL); } +#ifdef KEEP_OLD_VPNV4_COMMANDS DEFUN (clear_ip_bgp_all_vpnv4_soft_in, clear_ip_bgp_all_vpnv4_soft_in_cmd, "clear ip bgp * vpnv4 unicast soft in", @@ -8016,6 +8027,7 @@ ALIAS (clear_ip_bgp_all_encap_soft_in, "Address family\n" "Address Family Modifier\n" "Soft reconfig inbound update\n") +#endif /* KEEP_OLD_VPNV4_COMMANDS */ DEFUN (clear_bgp_all_soft_in, clear_bgp_all_soft_in_cmd, @@ -8274,6 +8286,7 @@ DEFUN (clear_ip_bgp_peer_ipv4_in_prefix_filter, BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]); } +#ifdef KEEP_OLD_VPNV4_COMMANDS DEFUN (clear_ip_bgp_peer_vpnv4_soft_in, clear_ip_bgp_peer_vpnv4_soft_in_cmd, "clear ip bgp (A.B.C.D|WORD) vpnv4 unicast soft in", @@ -8329,6 +8342,7 @@ ALIAS (clear_ip_bgp_peer_encap_soft_in, "Address family\n" "Address Family Modifier\n" "Soft reconfig inbound update\n") +#endif /* KEEP_OLD_VPNV4_COMMANDS */ DEFUN (clear_bgp_peer_soft_in, clear_bgp_peer_soft_in_cmd, @@ -9111,6 +9125,7 @@ DEFUN (clear_ip_bgp_as_ipv4_in_prefix_filter, BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]); } +#ifdef KEEP_OLD_VPNV4_COMMANDS DEFUN (clear_ip_bgp_as_vpnv4_soft_in, clear_ip_bgp_as_vpnv4_soft_in_cmd, "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast soft in", @@ -9164,6 +9179,7 @@ ALIAS (clear_ip_bgp_as_encap_soft_in, "Address family\n" "Address Family modifier\n" "Soft reconfig inbound update\n") +#endif /* KEEP_OLD_VPNV4_COMMANDS */ DEFUN (clear_bgp_as_soft_in, clear_bgp_as_soft_in_cmd, @@ -9338,6 +9354,7 @@ DEFUN (clear_ip_bgp_instance_all_ipv4_soft, BGP_CLEAR_SOFT_BOTH, NULL); } +#ifdef KEEP_OLD_VPNV4_COMMANDS DEFUN (clear_ip_bgp_all_vpnv4_soft, clear_ip_bgp_all_vpnv4_soft_cmd, "clear ip bgp * vpnv4 unicast soft", @@ -9367,6 +9384,7 @@ DEFUN (clear_ip_bgp_all_encap_soft, return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_all, BGP_CLEAR_SOFT_BOTH, argv[0]); } +#endif /* KEEP_OLD_VPNV4_COMMANDS */ DEFUN (clear_bgp_all_soft, clear_bgp_all_soft_cmd, @@ -9480,6 +9498,7 @@ DEFUN (clear_ip_bgp_instance_peer_ipv4_soft, BGP_CLEAR_SOFT_BOTH, argv[2]); } +#ifdef KEEP_OLD_VPNV4_COMMANDS DEFUN (clear_ip_bgp_peer_vpnv4_soft, clear_ip_bgp_peer_vpnv4_soft_cmd, "clear ip bgp (A.B.C.D|WORD) vpnv4 unicast soft", @@ -9510,6 +9529,7 @@ DEFUN (clear_ip_bgp_peer_encap_soft, return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_peer, BGP_CLEAR_SOFT_BOTH, argv[0]); } +#endif /* KEEP_OLD_VPNV4_COMMANDS */ DEFUN (clear_bgp_peer_soft, clear_bgp_peer_soft_cmd, @@ -9847,6 +9867,7 @@ DEFUN (clear_ip_bgp_instance_as_ipv4_soft, BGP_CLEAR_SOFT_BOTH, argv[2]); } +#ifdef KEEP_OLD_VPNV4_COMMANDS DEFUN (clear_ip_bgp_as_vpnv4_soft, clear_ip_bgp_as_vpnv4_soft_cmd, "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast soft", @@ -9876,6 +9897,7 @@ DEFUN (clear_ip_bgp_as_encap_soft, return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_as, BGP_CLEAR_SOFT_BOTH, argv[0]); } +#endif /* KEEP_OLD_VPNV4_COMMANDS */ DEFUN (clear_bgp_as_soft, clear_bgp_as_soft_cmd, @@ -10783,6 +10805,7 @@ ALIAS (show_ip_bgp_instance_ipv4_summary, BGP_AFI_SAFI_HELP_STR "Summary of BGP neighbor status\n") +#ifdef KEEP_OLD_VPNV4_COMMANDS DEFUN (show_ip_bgp_vpnv4_all_summary, show_ip_bgp_vpnv4_all_summary_cmd, "show ip bgp vpnv4 all summary {json}", @@ -10823,6 +10846,7 @@ DEFUN (show_ip_bgp_vpnv4_rd_summary, return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, uj); } +#endif /* KEEP_OLD_VPNV4_COMMANDS */ #ifdef HAVE_IPV6 DEFUN (show_bgp_summary, @@ -12821,6 +12845,7 @@ ALIAS (show_ip_bgp_neighbors, "Detailed information on TCP and BGP neighbor connections\n" "JavaScript Object Notation\n") +#ifdef KEEP_OLD_VPNV4_COMMANDS ALIAS (show_ip_bgp_neighbors, show_ip_bgp_vpnv4_all_neighbors_cmd, "show ip bgp vpnv4 all neighbors {json}", @@ -12843,6 +12868,7 @@ ALIAS (show_ip_bgp_neighbors, "VPN Route Distinguisher\n" "Detailed information on TCP and BGP neighbor connections\n" "JavaScript Object Notation\n") +#endif /* KEEP_OLD_VPNV4_COMMANDS */ ALIAS (show_ip_bgp_neighbors, show_bgp_neighbors_cmd, @@ -12892,6 +12918,7 @@ ALIAS (show_ip_bgp_neighbors_peer, "Neighbor on bgp configured interface\n" "JavaScript Object Notation\n") +#ifdef KEEP_OLD_VPNV4_COMMANDS ALIAS (show_ip_bgp_neighbors_peer, show_ip_bgp_vpnv4_all_neighbors_peer_cmd, "show ip bgp vpnv4 all neighbors A.B.C.D {json}", @@ -12915,6 +12942,7 @@ ALIAS (show_ip_bgp_neighbors_peer, "Detailed information on TCP and BGP neighbor connections\n" "Neighbor to display information about\n" "JavaScript Object Notation\n") +#endif /* KEEP_OLD_VPNV4_COMMANDS */ ALIAS (show_ip_bgp_neighbors_peer, show_bgp_neighbors_peer_cmd, @@ -15617,10 +15645,14 @@ bgp_vty_init (void) install_element (BGP_NODE, &address_family_ipv6_safi_cmd); #endif /* HAVE_IPV6 */ install_element (BGP_NODE, &address_family_vpnv4_cmd); +#ifdef KEEP_OLD_VPNV4_COMMANDS install_element (BGP_NODE, &address_family_vpnv4_unicast_cmd); +#endif /* KEEP_OLD_VPNV4_COMMANDS */ install_element (BGP_NODE, &address_family_vpnv6_cmd); +#ifdef KEEP_OLD_VPNV4_COMMANDS install_element (BGP_NODE, &address_family_vpnv6_unicast_cmd); +#endif /* KEEP_OLD_VPNV4_COMMANDS */ install_element (BGP_NODE, &address_family_encap_cmd); install_element (BGP_NODE, &address_family_encapv4_cmd); @@ -15722,6 +15754,7 @@ bgp_vty_init (void) install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_in_cmd); install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_ipv4_in_cmd); install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_in_prefix_filter_cmd); +#ifdef KEEP_OLD_VPNV4_COMMANDS install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_in_cmd); install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_in_cmd); install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_in_cmd); @@ -15734,6 +15767,7 @@ bgp_vty_init (void) install_element (ENABLE_NODE, &clear_ip_bgp_peer_encap_in_cmd); install_element (ENABLE_NODE, &clear_ip_bgp_as_encap_soft_in_cmd); install_element (ENABLE_NODE, &clear_ip_bgp_as_encap_in_cmd); +#endif /* KEEP_OLD_VPNV4_COMMANDS */ install_element (ENABLE_NODE, &clear_bgp_all_soft_in_cmd); install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_in_cmd); install_element (ENABLE_NODE, &clear_bgp_all_in_cmd); @@ -15832,6 +15866,7 @@ bgp_vty_init (void) install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_ipv4_soft_out_cmd); install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_out_cmd); install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_ipv4_out_cmd); +#ifdef KEEP_OLD_VPNV4_COMMANDS install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_out_cmd); install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_out_cmd); install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_out_cmd); @@ -15844,6 +15879,7 @@ bgp_vty_init (void) install_element (ENABLE_NODE, &clear_ip_bgp_peer_encap_out_cmd); install_element (ENABLE_NODE, &clear_ip_bgp_as_encap_soft_out_cmd); install_element (ENABLE_NODE, &clear_ip_bgp_as_encap_out_cmd); +#endif /* KEEP_OLD_VPNV4_COMMANDS */ install_element (ENABLE_NODE, &clear_bgp_all_soft_out_cmd); install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_out_cmd); install_element (ENABLE_NODE, &clear_bgp_all_out_cmd); @@ -15906,12 +15942,14 @@ bgp_vty_init (void) install_element (ENABLE_NODE, &clear_ip_bgp_instance_external_ipv4_soft_cmd); install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_soft_cmd); install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_ipv4_soft_cmd); +#ifdef KEEP_OLD_VPNV4_COMMANDS install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_cmd); install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_cmd); install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_soft_cmd); install_element (ENABLE_NODE, &clear_ip_bgp_all_encap_soft_cmd); install_element (ENABLE_NODE, &clear_ip_bgp_peer_encap_soft_cmd); install_element (ENABLE_NODE, &clear_ip_bgp_as_encap_soft_cmd); +#endif /* KEEP_OLD_VPNV4_COMMANDS */ install_element (ENABLE_NODE, &clear_bgp_all_soft_cmd); install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_cmd); install_element (ENABLE_NODE, &clear_bgp_peer_soft_cmd); @@ -15963,8 +16001,10 @@ bgp_vty_init (void) install_element (VIEW_NODE, &show_bgp_ipv4_safi_summary_cmd); install_element (VIEW_NODE, &show_ip_bgp_instance_ipv4_summary_cmd); install_element (VIEW_NODE, &show_bgp_instance_ipv4_safi_summary_cmd); +#ifdef KEEP_OLD_VPNV4_COMMANDS install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_summary_cmd); install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_summary_cmd); +#endif /* KEEP_OLD_VPNV4_COMMANDS */ #ifdef HAVE_IPV6 install_element (VIEW_NODE, &show_bgp_summary_cmd); install_element (VIEW_NODE, &show_bgp_instance_summary_cmd); @@ -15980,10 +16020,12 @@ bgp_vty_init (void) install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbors_cmd); install_element (VIEW_NODE, &show_ip_bgp_neighbors_peer_cmd); install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbors_peer_cmd); +#ifdef KEEP_OLD_VPNV4_COMMANDS install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_neighbors_cmd); install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_neighbors_cmd); install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_neighbors_peer_cmd); install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_neighbors_peer_cmd); +#endif /* KEEP_OLD_VPNV4_COMMANDS */ install_element (VIEW_NODE, &show_ip_bgp_instance_neighbors_cmd); install_element (VIEW_NODE, &show_ip_bgp_instance_all_neighbors_cmd); install_element (VIEW_NODE, &show_ip_bgp_instance_neighbors_peer_cmd); From 9cabb64b320a946b401daa3f6ee7adcefe1548b6 Mon Sep 17 00:00:00 2001 From: vivek Date: Wed, 15 Jun 2016 10:25:35 -0700 Subject: [PATCH 084/107] Quagga: AFI/SAFI mappings IANA to/from internal values Introduce internal and IANA defintions for AFI/SAFI and mapping functions and modify code to use these. This refactoring will facilitate adding support for other AFI/SAFI whose IANA values won't be suitable for internal data structure definitions (e.g., they are not contiguous). The commit adds some fixes related to afi/safi testing with 'make check ' command. Signed-off-by: Vivek Venkatraman Reviewed-by: Donald Sharp Signed-off-by: Philippe Guibert Ticket: CM-11416 Reviewed By: CCR-3594 (mpls branch) Testing Done: Not tested now, tested earlier on mpls branch --- bgpd/bgp_attr.c | 62 ++++++-- bgpd/bgp_open.c | 273 +++++++++++++----------------------- bgpd/bgp_open.h | 1 - bgpd/bgp_packet.c | 101 ++++++------- bgpd/bgp_route.c | 15 +- bgpd/bgpd.c | 29 ++++ bgpd/bgpd.h | 11 +- bgpd/rfapi/rfapi_import.c | 5 +- lib/zebra.h | 67 ++++++++- tests/bgp_capability_test.c | 30 ++-- tests/bgp_mp_attr_test.c | 68 +++++---- 11 files changed, 347 insertions(+), 315 deletions(-) diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c index 534a0323c4..9e0212b74c 100644 --- a/bgpd/bgp_attr.c +++ b/bgpd/bgp_attr.c @@ -1857,8 +1857,8 @@ int bgp_mp_reach_parse (struct bgp_attr_parser_args *args, struct bgp_nlri *mp_update) { - afi_t afi; - safi_t safi; + afi_t pkt_afi, afi; + safi_t pkt_safi, safi; bgp_size_t nlri_len; size_t start; struct stream *s; @@ -1882,8 +1882,20 @@ bgp_mp_reach_parse (struct bgp_attr_parser_args *args, } /* Load AFI, SAFI. */ - afi = stream_getw (s); - safi = stream_getc (s); + pkt_afi = stream_getw (s); + pkt_safi = stream_getc (s); + + /* Convert AFI, SAFI to internal values, check. */ + if (bgp_map_afi_safi_iana2int (pkt_afi, pkt_safi, &afi, &safi)) + { + /* Log if AFI or SAFI is unrecognized. This is not an error unless + * the attribute is otherwise malformed. + */ + if (bgp_debug_update(peer, NULL, NULL, 0)) + zlog_debug ("%s: MP_REACH received AFI %u or SAFI %u is unrecognized", + peer->host, pkt_afi, pkt_safi); + return BGP_ATTR_PARSE_ERROR; + } /* Get nexthop length. */ attre->mp_nexthop_len = stream_getc (s); @@ -1998,8 +2010,8 @@ bgp_mp_unreach_parse (struct bgp_attr_parser_args *args, struct bgp_nlri *mp_withdraw) { struct stream *s; - afi_t afi; - safi_t safi; + afi_t pkt_afi, afi; + safi_t pkt_safi, safi; u_int16_t withdraw_len; struct peer *const peer = args->peer; struct attr *const attr = args->attr; @@ -2011,9 +2023,21 @@ bgp_mp_unreach_parse (struct bgp_attr_parser_args *args, if ((length > STREAM_READABLE(s)) || (length < BGP_MP_UNREACH_MIN_SIZE)) return BGP_ATTR_PARSE_ERROR_NOTIFYPLS; - afi = stream_getw (s); - safi = stream_getc (s); - + pkt_afi = stream_getw (s); + pkt_safi = stream_getc (s); + + /* Convert AFI, SAFI to internal values, check. */ + if (bgp_map_afi_safi_iana2int (pkt_afi, pkt_safi, &afi, &safi)) + { + /* Log if AFI or SAFI is unrecognized. This is not an error unless + * the attribute is otherwise malformed. + */ + if (bgp_debug_update(peer, NULL, NULL, 0)) + zlog_debug ("%s: MP_UNREACH received AFI %u or SAFI %u is unrecognized", + peer->host, pkt_afi, pkt_safi); + return BGP_ATTR_PARSE_ERROR; + } + withdraw_len = length - BGP_MP_UNREACH_MIN_SIZE; mp_withdraw->afi = afi; @@ -2634,6 +2658,8 @@ bgp_packet_mpattr_start (struct stream *s, afi_t afi, safi_t safi, afi_t nh_afi, struct attr *attr) { size_t sizep; + afi_t pkt_afi; + safi_t pkt_safi; /* Set extended bit always to encode the attribute length as 2 bytes */ stream_putc (s, BGP_ATTR_FLAG_OPTIONAL|BGP_ATTR_FLAG_EXTLEN); @@ -2641,8 +2667,12 @@ bgp_packet_mpattr_start (struct stream *s, afi_t afi, safi_t safi, afi_t nh_afi, sizep = stream_get_endp (s); stream_putw (s, 0); /* Marker: Attribute length. */ - stream_putw (s, afi); - stream_putc (s, (safi == SAFI_MPLS_VPN) ? SAFI_MPLS_LABELED_VPN : safi); + + /* Convert AFI, SAFI to values for packet. */ + bgp_map_afi_safi_int2iana (afi, safi, &pkt_afi, &pkt_safi); + + stream_putw (s, pkt_afi); /* AFI */ + stream_putc (s, pkt_safi); /* SAFI */ /* Nexthop */ switch (nh_afi) @@ -3261,6 +3291,8 @@ size_t bgp_packet_mpunreach_start (struct stream *s, afi_t afi, safi_t safi) { unsigned long attrlen_pnt; + afi_t pkt_afi; + safi_t pkt_safi; /* Set extended bit always to encode the attribute length as 2 bytes */ stream_putc (s, BGP_ATTR_FLAG_OPTIONAL|BGP_ATTR_FLAG_EXTLEN); @@ -3269,8 +3301,12 @@ bgp_packet_mpunreach_start (struct stream *s, afi_t afi, safi_t safi) attrlen_pnt = stream_get_endp (s); stream_putw (s, 0); /* Length of this attribute. */ - stream_putw (s, afi); - stream_putc (s, (safi == SAFI_MPLS_VPN) ? SAFI_MPLS_LABELED_VPN : safi); + /* Convert AFI, SAFI to values for packet. */ + bgp_map_afi_safi_int2iana (afi, safi, &pkt_afi, &pkt_safi); + + stream_putw (s, pkt_afi); + stream_putc (s, pkt_safi); + return attrlen_pnt; } diff --git a/bgpd/bgp_open.c b/bgpd/bgp_open.c index af3c0486e5..4a06881041 100644 --- a/bgpd/bgp_open.c +++ b/bgpd/bgp_open.c @@ -79,9 +79,13 @@ bgp_capability_vty_out (struct vty *vty, struct peer *peer, u_char use_json, jso if (hdr->code == CAPABILITY_CODE_MP) { + afi_t afi; + safi_t safi; + + bgp_map_afi_safi_iana2int (ntohs(mpc.afi), mpc.safi, &afi, &safi); if (use_json) { - switch (ntohs (mpc.afi)) + switch (afi) { case AFI_IP: json_object_string_add(json_cap, "capabilityErrorMultiProtocolAfi", "IPv4"); @@ -93,7 +97,7 @@ bgp_capability_vty_out (struct vty *vty, struct peer *peer, u_char use_json, jso json_object_int_add(json_cap, "capabilityErrorMultiProtocolAfiUnknown", ntohs (mpc.afi)); break; } - switch (mpc.safi) + switch (safi) { case SAFI_UNICAST: json_object_string_add(json_cap, "capabilityErrorMultiProtocolSafi", "unicast"); @@ -101,7 +105,7 @@ bgp_capability_vty_out (struct vty *vty, struct peer *peer, u_char use_json, jso case SAFI_MULTICAST: json_object_string_add(json_cap, "capabilityErrorMultiProtocolSafi", "multicast"); break; - case SAFI_MPLS_LABELED_VPN: + case SAFI_MPLS_VPN: json_object_string_add(json_cap, "capabilityErrorMultiProtocolSafi", "MPLS-labeled VPN"); break; case SAFI_ENCAP: @@ -115,7 +119,7 @@ bgp_capability_vty_out (struct vty *vty, struct peer *peer, u_char use_json, jso else { vty_out (vty, " Capability error for: Multi protocol "); - switch (ntohs (mpc.afi)) + switch (afi) { case AFI_IP: vty_out (vty, "AFI IPv4, "); @@ -127,7 +131,7 @@ bgp_capability_vty_out (struct vty *vty, struct peer *peer, u_char use_json, jso vty_out (vty, "AFI Unknown %d, ", ntohs (mpc.afi)); break; } - switch (mpc.safi) + switch (safi) { case SAFI_UNICAST: vty_out (vty, "SAFI Unicast"); @@ -135,7 +139,7 @@ bgp_capability_vty_out (struct vty *vty, struct peer *peer, u_char use_json, jso case SAFI_MULTICAST: vty_out (vty, "SAFI Multicast"); break; - case SAFI_MPLS_LABELED_VPN: + case SAFI_MPLS_VPN: vty_out (vty, "SAFI MPLS-labeled VPN"); break; case SAFI_ENCAP: @@ -178,35 +182,6 @@ bgp_capability_mp_data (struct stream *s, struct capability_mp_data *mpc) mpc->safi = stream_getc (s); } -int -bgp_afi_safi_valid_indices (afi_t afi, safi_t *safi) -{ - switch (afi) - { - case AFI_IP: - case AFI_IP6: - switch (*safi) - { - /* BGP MPLS-labeled VPN SAFI isn't contigious with others, remap */ - case SAFI_MPLS_LABELED_VPN: - *safi = SAFI_MPLS_VPN; - case SAFI_UNICAST: - case SAFI_MULTICAST: - case SAFI_MPLS_VPN: - case SAFI_ENCAP: - return 1; - } - break; - case AFI_ETHER: - default: - break; - } - - zlog_debug ("unknown afi/safi (%u/%u)", afi, *safi); - - return 0; -} - /* Set negotiated capability value. */ static int bgp_capability_mp (struct peer *peer, struct capability_header *hdr) @@ -228,7 +203,8 @@ bgp_capability_mp (struct peer *peer, struct capability_header *hdr) zlog_debug ("%s OPEN has MP_EXT CAP for afi/safi: %u/%u", peer->host, mpc.afi, mpc.safi); - if (!bgp_afi_safi_valid_indices (mpc.afi, &mpc.safi)) + /* Convert AFI, SAFI to internal values, check. */ + if (bgp_map_afi_safi_iana2int (mpc.afi, mpc.safi, &mpc.afi, &mpc.safi)) return -1; /* Now safi remapped, and afi/safi are valid array indices */ @@ -271,8 +247,8 @@ bgp_capability_orf_entry (struct peer *peer, struct capability_header *hdr) { struct stream *s = BGP_INPUT (peer); struct capability_orf_entry entry; - afi_t afi; - safi_t safi; + afi_t pkt_afi, afi; + safi_t pkt_safi, safi; u_char type; u_char mode; u_int16_t sm_cap = 0; /* capability send-mode receive */ @@ -282,22 +258,25 @@ bgp_capability_orf_entry (struct peer *peer, struct capability_header *hdr) /* ORF Entry header */ bgp_capability_mp_data (s, &entry.mpc); entry.num = stream_getc (s); - afi = entry.mpc.afi; - safi = entry.mpc.safi; + pkt_afi = entry.mpc.afi; + pkt_safi = entry.mpc.safi; if (bgp_debug_neighbor_events(peer)) zlog_debug ("%s ORF Cap entry for afi/safi: %u/%u", peer->host, entry.mpc.afi, entry.mpc.safi); - /* Check AFI and SAFI. */ - if (!bgp_afi_safi_valid_indices (entry.mpc.afi, &safi)) + /* Convert AFI, SAFI to internal values, check. */ + if (bgp_map_afi_safi_iana2int (pkt_afi, pkt_safi, &afi, &safi)) { zlog_info ("%s Addr-family %d/%d not supported." " Ignoring the ORF capability", - peer->host, entry.mpc.afi, entry.mpc.safi); + peer->host, pkt_afi, pkt_safi); return 0; } + entry.mpc.afi = afi; + entry.mpc.safi = safi; + /* validate number field */ if (CAPABILITY_CODE_ORF_LEN + (entry.num * 2) > hdr->length) { @@ -321,7 +300,7 @@ bgp_capability_orf_entry (struct peer *peer, struct capability_header *hdr) case ORF_MODE_RECEIVE: break; default: - bgp_capability_orf_not_support (peer, afi, safi, type, mode); + bgp_capability_orf_not_support (peer, pkt_afi, pkt_safi, type, mode); continue; } /* ORF Type and afi/safi error checks */ @@ -334,7 +313,7 @@ bgp_capability_orf_entry (struct peer *peer, struct capability_header *hdr) case ORF_TYPE_PREFIX: break; default: - bgp_capability_orf_not_support (peer, afi, safi, type, mode); + bgp_capability_orf_not_support (peer, pkt_afi, pkt_safi, type, mode); continue; } break; @@ -344,12 +323,12 @@ bgp_capability_orf_entry (struct peer *peer, struct capability_header *hdr) case ORF_TYPE_PREFIX_OLD: break; default: - bgp_capability_orf_not_support (peer, afi, safi, type, mode); + bgp_capability_orf_not_support (peer, pkt_afi, pkt_safi, type, mode); continue; } break; default: - bgp_capability_orf_not_support (peer, afi, safi, type, mode); + bgp_capability_orf_not_support (peer, pkt_afi, pkt_safi, type, mode); continue; } @@ -358,7 +337,7 @@ bgp_capability_orf_entry (struct peer *peer, struct capability_header *hdr) || (afi == AFI_IP && safi == SAFI_MULTICAST) || (afi == AFI_IP6 && safi == SAFI_UNICAST))) { - bgp_capability_orf_not_support (peer, afi, safi, type, mode); + bgp_capability_orf_not_support (peer, pkt_afi, pkt_safi, type, mode); continue; } @@ -367,7 +346,7 @@ bgp_capability_orf_entry (struct peer *peer, struct capability_header *hdr) " as %s for afi/safi: %d/%d", peer->host, LOOKUP (orf_type_str, type), LOOKUP (orf_mode_str, mode), - entry.mpc.afi, safi); + pkt_afi, pkt_safi); if (hdr->code == CAPABILITY_CODE_ORF) { @@ -381,7 +360,7 @@ bgp_capability_orf_entry (struct peer *peer, struct capability_header *hdr) } else { - bgp_capability_orf_not_support (peer, afi, safi, type, mode); + bgp_capability_orf_not_support (peer, pkt_afi, pkt_safi, type, mode); continue; } @@ -437,23 +416,26 @@ bgp_capability_restart (struct peer *peer, struct capability_header *caphdr) while (stream_get_getp (s) + 4 <= end) { - afi_t afi = stream_getw (s); - safi_t safi = stream_getc (s); + afi_t afi; + safi_t safi; + afi_t pkt_afi = stream_getw (s); + safi_t pkt_safi = stream_getc (s); u_char flag = stream_getc (s); - if (!bgp_afi_safi_valid_indices (afi, &safi)) + /* Convert AFI, SAFI to internal values, check. */ + if (bgp_map_afi_safi_iana2int (pkt_afi, pkt_safi, &afi, &safi)) { if (bgp_debug_neighbor_events(peer)) zlog_debug ("%s Addr-family %d/%d(afi/safi) not supported." " Ignore the Graceful Restart capability for this AFI/SAFI", - peer->host, afi, safi); + peer->host, pkt_afi, pkt_safi); } else if (!peer->afc[afi][safi]) { if (bgp_debug_neighbor_events(peer)) zlog_debug ("%s Addr-family %d/%d(afi/safi) not enabled." " Ignore the Graceful Restart capability", - peer->host, afi, safi); + peer->host, pkt_afi, pkt_safi); } else { @@ -512,22 +494,25 @@ bgp_capability_addpath (struct peer *peer, struct capability_header *hdr) while (stream_get_getp (s) + 4 <= end) { - afi_t afi = stream_getw (s); - safi_t safi = stream_getc (s); + afi_t afi; + safi_t safi; + afi_t pkt_afi = stream_getw (s); + safi_t pkt_safi = stream_getc (s); u_char send_receive = stream_getc (s); if (bgp_debug_neighbor_events(peer)) zlog_debug ("%s OPEN has AddPath CAP for afi/safi: %u/%u%s%s", - peer->host, afi, safi, + peer->host, pkt_afi, pkt_safi, (send_receive & BGP_ADDPATH_RX) ? ", receive" : "", (send_receive & BGP_ADDPATH_TX) ? ", transmit" : ""); - if (!bgp_afi_safi_valid_indices (afi, &safi)) + /* Convert AFI, SAFI to internal values, check. */ + if (bgp_map_afi_safi_iana2int (pkt_afi, pkt_safi, &afi, &safi)) { if (bgp_debug_neighbor_events(peer)) zlog_debug ("%s Addr-family %d/%d(afi/safi) not supported." " Ignore the Addpath Attribute for this AFI/SAFI", - peer->host, afi, safi); + peer->host, pkt_afi, pkt_safi); continue; } else if (!peer->afc[afi][safi]) @@ -535,7 +520,7 @@ bgp_capability_addpath (struct peer *peer, struct capability_header *hdr) if (bgp_debug_neighbor_events(peer)) zlog_debug ("%s Addr-family %d/%d(afi/safi) not enabled." " Ignore the AddPath capability for this AFI/SAFI", - peer->host, afi, safi); + peer->host, pkt_afi, pkt_safi); continue; } @@ -565,20 +550,21 @@ bgp_capability_enhe (struct peer *peer, struct capability_header *hdr) while (stream_get_getp (s) + 6 <= end) { - afi_t afi = stream_getw (s); - safi_t safi = stream_getw (s); - afi_t nh_afi = stream_getw (s); + afi_t afi, pkt_afi = stream_getw (s); + safi_t safi, pkt_safi = stream_getw (s); + afi_t nh_afi, pkt_nh_afi = stream_getw (s); if (bgp_debug_neighbor_events(peer)) zlog_debug ("%s Received with afi/safi/next-hop afi: %u/%u/%u", - peer->host, afi, safi, nh_afi); + peer->host, pkt_afi, pkt_safi, pkt_nh_afi); - if (!bgp_afi_safi_valid_indices (afi, &safi)) + /* Convert AFI, SAFI to internal values, check. */ + if (bgp_map_afi_safi_iana2int (pkt_afi, pkt_safi, &afi, &safi)) { if (bgp_debug_neighbor_events(peer)) zlog_debug ("%s Addr-family %d/%d(afi/safi) not supported." " Ignore the ENHE Attribute for this AFI/SAFI", - peer->host, afi, safi); + peer->host, pkt_afi, pkt_safi); continue; } @@ -587,11 +573,13 @@ bgp_capability_enhe (struct peer *peer, struct capability_header *hdr) * possibilities, so we ignore other values with a log. Also, only * Unicast SAFI is currently supported (and expected). */ + nh_afi = afi_iana2int (pkt_nh_afi); + if (afi != AFI_IP || safi != SAFI_UNICAST || nh_afi != AFI_IP6) { zlog_warn ("%s Unexpected afi/safi/next-hop afi: %u/%u/%u " "in Extended Next-hop capability, ignoring", - peer->host, afi, safi, nh_afi); + peer->host, pkt_afi, pkt_safi, pkt_nh_afi); continue; } @@ -1174,9 +1162,11 @@ bgp_open_capability_orf (struct stream *s, struct peer *peer, unsigned long orfp; unsigned long numberp; int number_of_orfs = 0; + afi_t pkt_afi; + safi_t pkt_safi; - if (safi == SAFI_MPLS_VPN) - safi = SAFI_MPLS_LABELED_VPN; + /* Convert AFI, SAFI to values for packet. */ + bgp_map_afi_safi_int2iana (afi, safi, &pkt_afi, &pkt_safi); stream_putc (s, BGP_OPEN_OPT_CAP); capp = stream_get_endp (s); /* Set Capability Len Pointer */ @@ -1184,9 +1174,9 @@ bgp_open_capability_orf (struct stream *s, struct peer *peer, stream_putc (s, code); /* Capability Code */ orfp = stream_get_endp (s); /* Set ORF Len Pointer */ stream_putc (s, 0); /* ORF Length */ - stream_putw (s, afi); + stream_putw (s, pkt_afi); stream_putc (s, 0); - stream_putc (s, safi); + stream_putc (s, pkt_safi); numberp = stream_get_endp (s); /* Set Number Pointer */ stream_putc (s, 0); /* Number of ORFs */ @@ -1235,8 +1225,8 @@ bgp_open_capability (struct stream *s, struct peer *peer) { u_char len; unsigned long cp, capp, rcapp; - afi_t afi; - safi_t safi; + afi_t afi, pkt_afi; + safi_t safi, pkt_safi; as_t local_as; u_int32_t restart_time; u_char afi_safi_count = 0; @@ -1254,56 +1244,29 @@ bgp_open_capability (struct stream *s, struct peer *peer) || CHECK_FLAG (peer->flags, PEER_FLAG_DONT_CAPABILITY)) return; - /* IPv4 unicast. */ - if (peer->afc[AFI_IP][SAFI_UNICAST]) - { - peer->afc_adv[AFI_IP][SAFI_UNICAST] = 1; - stream_putc (s, BGP_OPEN_OPT_CAP); - stream_putc (s, CAPABILITY_CODE_MP_LEN + 2); - stream_putc (s, CAPABILITY_CODE_MP); - stream_putc (s, CAPABILITY_CODE_MP_LEN); - stream_putw (s, AFI_IP); - stream_putc (s, 0); - stream_putc (s, SAFI_UNICAST); - } - /* IPv4 multicast. */ - if (peer->afc[AFI_IP][SAFI_MULTICAST]) - { - peer->afc_adv[AFI_IP][SAFI_MULTICAST] = 1; - stream_putc (s, BGP_OPEN_OPT_CAP); - stream_putc (s, CAPABILITY_CODE_MP_LEN + 2); - stream_putc (s, CAPABILITY_CODE_MP); - stream_putc (s, CAPABILITY_CODE_MP_LEN); - stream_putw (s, AFI_IP); - stream_putc (s, 0); - stream_putc (s, SAFI_MULTICAST); - } - /* IPv4 VPN */ - if (peer->afc[AFI_IP][SAFI_MPLS_VPN]) - { - peer->afc_adv[AFI_IP][SAFI_MPLS_VPN] = 1; - stream_putc (s, BGP_OPEN_OPT_CAP); - stream_putc (s, CAPABILITY_CODE_MP_LEN + 2); - stream_putc (s, CAPABILITY_CODE_MP); - stream_putc (s, CAPABILITY_CODE_MP_LEN); - stream_putw (s, AFI_IP); - stream_putc (s, 0); - stream_putc (s, SAFI_MPLS_LABELED_VPN); - } - /* ENCAP */ - if (peer->afc[AFI_IP][SAFI_ENCAP]) - { - peer->afc_adv[AFI_IP][SAFI_ENCAP] = 1; - stream_putc (s, BGP_OPEN_OPT_CAP); - stream_putc (s, CAPABILITY_CODE_MP_LEN + 2); - stream_putc (s, CAPABILITY_CODE_MP); - stream_putc (s, CAPABILITY_CODE_MP_LEN); - stream_putw (s, AFI_IP); - stream_putc (s, 0); - stream_putc (s, SAFI_ENCAP); - } -#ifdef HAVE_IPV6 - /* Currently supporting RFC-5549 for Link-Local peering only */ + /* MP capability for configured AFI, SAFI */ + for (afi = AFI_IP ; afi < AFI_MAX ; afi++) + for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) + { + if (peer->afc[afi][safi]) + { + /* Convert AFI, SAFI to values for packet. */ + bgp_map_afi_safi_int2iana (afi, safi, &pkt_afi, &pkt_safi); + + peer->afc_adv[afi][safi] = 1; + stream_putc (s, BGP_OPEN_OPT_CAP); + stream_putc (s, CAPABILITY_CODE_MP_LEN + 2); + stream_putc (s, CAPABILITY_CODE_MP); + stream_putc (s, CAPABILITY_CODE_MP_LEN); + stream_putw (s, pkt_afi); + stream_putc (s, 0); + stream_putc (s, pkt_safi); + } + } + + /* Extended nexthop capability - currently supporting RFC-5549 for + * Link-Local peering only + */ if (CHECK_FLAG (peer->flags, PEER_FLAG_CAPABILITY_ENHE) && peer->su.sa.sa_family == AF_INET6 && IN6_IS_ADDR_LINKLOCAL(&peer->su.sin6.sin6_addr)) @@ -1323,55 +1286,6 @@ bgp_open_capability (struct stream *s, struct peer *peer) if (CHECK_FLAG (peer->af_cap[AFI_IP][SAFI_UNICAST], PEER_CAP_ENHE_AF_RCV)) SET_FLAG (peer->af_cap[AFI_IP][SAFI_UNICAST], PEER_CAP_ENHE_AF_NEGO); } - /* IPv6 unicast. */ - if (peer->afc[AFI_IP6][SAFI_UNICAST]) - { - peer->afc_adv[AFI_IP6][SAFI_UNICAST] = 1; - stream_putc (s, BGP_OPEN_OPT_CAP); - stream_putc (s, CAPABILITY_CODE_MP_LEN + 2); - stream_putc (s, CAPABILITY_CODE_MP); - stream_putc (s, CAPABILITY_CODE_MP_LEN); - stream_putw (s, AFI_IP6); - stream_putc (s, 0); - stream_putc (s, SAFI_UNICAST); - } - /* IPv6 multicast. */ - if (peer->afc[AFI_IP6][SAFI_MULTICAST]) - { - peer->afc_adv[AFI_IP6][SAFI_MULTICAST] = 1; - stream_putc (s, BGP_OPEN_OPT_CAP); - stream_putc (s, CAPABILITY_CODE_MP_LEN + 2); - stream_putc (s, CAPABILITY_CODE_MP); - stream_putc (s, CAPABILITY_CODE_MP_LEN); - stream_putw (s, AFI_IP6); - stream_putc (s, 0); - stream_putc (s, SAFI_MULTICAST); - } - /* IPv6 VPN. */ - if (peer->afc[AFI_IP6][SAFI_MPLS_VPN]) - { - peer->afc_adv[AFI_IP6][SAFI_MPLS_VPN] = 1; - stream_putc (s, BGP_OPEN_OPT_CAP); - stream_putc (s, CAPABILITY_CODE_MP_LEN + 2); - stream_putc (s, CAPABILITY_CODE_MP); - stream_putc (s, CAPABILITY_CODE_MP_LEN); - stream_putw (s, AFI_IP6); - stream_putc (s, 0); - stream_putc (s, SAFI_MPLS_LABELED_VPN); - } - /* IPv6 ENCAP. */ - if (peer->afc[AFI_IP6][SAFI_ENCAP]) - { - peer->afc_adv[AFI_IP6][SAFI_ENCAP] = 1; - stream_putc (s, BGP_OPEN_OPT_CAP); - stream_putc (s, CAPABILITY_CODE_MP_LEN + 2); - stream_putc (s, CAPABILITY_CODE_MP); - stream_putc (s, CAPABILITY_CODE_MP_LEN); - stream_putw (s, AFI_IP6); - stream_putc (s, 0); - stream_putc (s, SAFI_ENCAP); - } -#endif /* HAVE_IPV6 */ /* Route refresh. */ SET_FLAG (peer->cap, PEER_CAP_REFRESH_ADV); @@ -1420,8 +1334,11 @@ bgp_open_capability (struct stream *s, struct peer *peer) for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) if (peer->afc[afi][safi]) { - stream_putw (s, afi); - stream_putc (s, safi); + /* Convert AFI, SAFI to values for packet. */ + bgp_map_afi_safi_int2iana (afi, safi, &pkt_afi, &pkt_safi); + + stream_putw (s, pkt_afi); + stream_putc (s, pkt_safi); if (adv_addpath_tx) { @@ -1535,8 +1452,10 @@ bgp_open_capability (struct stream *s, struct peer *peer) for (safi = SAFI_UNICAST ; safi < SAFI_MAX ; safi++) if (peer->afc[afi][safi]) { - stream_putw (s, afi); - stream_putc (s, (safi == SAFI_MPLS_VPN) ? SAFI_MPLS_LABELED_VPN : safi); + /* Convert AFI, SAFI to values for packet. */ + bgp_map_afi_safi_int2iana (afi, safi, &pkt_afi, &pkt_safi); + stream_putw (s, pkt_afi); + stream_putc (s, pkt_safi); if (bgp_flag_check(peer->bgp, BGP_FLAG_GR_PRESERVE_FWD)) stream_putc (s, RESTART_F_BIT); else diff --git a/bgpd/bgp_open.h b/bgpd/bgp_open.h index 8ec0a5416b..b0a396ec11 100644 --- a/bgpd/bgp_open.h +++ b/bgpd/bgp_open.h @@ -115,6 +115,5 @@ extern int bgp_open_option_parse (struct peer *, u_char, int *); extern void bgp_open_capability (struct stream *, struct peer *); extern void bgp_capability_vty_out (struct vty *, struct peer *, u_char, json_object *); extern as_t peek_for_as4_capability (struct peer *, u_char); -extern int bgp_afi_safi_valid_indices (afi_t, safi_t *); #endif /* _QUAGGA_BGP_OPEN_H */ diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c index dffca37dd3..38470a3c7e 100644 --- a/bgpd/bgp_packet.c +++ b/bgpd/bgp_packet.c @@ -147,6 +147,8 @@ static struct stream * bgp_update_packet_eor (struct peer *peer, afi_t afi, safi_t safi) { struct stream *s; + afi_t pkt_afi; + safi_t pkt_safi; if (DISABLE_BGP_ANNOUNCE) return NULL; @@ -169,13 +171,16 @@ bgp_update_packet_eor (struct peer *peer, afi_t afi, safi_t safi) } else { + /* Convert AFI, SAFI to values for packet. */ + bgp_map_afi_safi_int2iana (afi, safi, &pkt_afi, &pkt_safi); + /* Total Path Attribute Length */ stream_putw (s, 6); stream_putc (s, BGP_ATTR_FLAG_OPTIONAL); stream_putc (s, BGP_ATTR_MP_UNREACH_NLRI); stream_putc (s, 3); - stream_putw (s, afi); - stream_putc (s, (safi == SAFI_MPLS_VPN) ? SAFI_MPLS_LABELED_VPN : safi); + stream_putw (s, pkt_afi); + stream_putc (s, pkt_safi); } bgp_packet_set_size (s); @@ -690,15 +695,16 @@ bgp_route_refresh_send (struct peer *peer, afi_t afi, safi_t safi, struct stream *s; struct bgp_filter *filter; int orf_refresh = 0; + afi_t pkt_afi; + safi_t pkt_safi; if (DISABLE_BGP_ANNOUNCE) return; filter = &peer->filter[afi][safi]; - /* Adjust safi code. */ - if (safi == SAFI_MPLS_VPN) - safi = SAFI_MPLS_LABELED_VPN; + /* Convert AFI, SAFI to values for packet. */ + bgp_map_afi_safi_int2iana (afi, safi, &pkt_afi, &pkt_safi); s = stream_new (BGP_MAX_PACKET_SIZE); @@ -709,9 +715,9 @@ bgp_route_refresh_send (struct peer *peer, afi_t afi, safi_t safi, bgp_packet_set_marker (s, BGP_MSG_ROUTE_REFRESH_OLD); /* Encode Route Refresh message. */ - stream_putw (s, afi); + stream_putw (s, pkt_afi); stream_putc (s, 0); - stream_putc (s, safi); + stream_putc (s, pkt_safi); if (orf_type == ORF_TYPE_PREFIX || orf_type == ORF_TYPE_PREFIX_OLD) @@ -734,7 +740,7 @@ bgp_route_refresh_send (struct peer *peer, afi_t afi, safi_t safi, zlog_debug ("%s sending REFRESH_REQ to remove ORF(%d) (%s) for afi/safi: %d/%d", peer->host, orf_type, (when_to_refresh == REFRESH_DEFER ? "defer" : "immediate"), - afi, safi); + pkt_afi, pkt_safi); } else { @@ -746,7 +752,7 @@ bgp_route_refresh_send (struct peer *peer, afi_t afi, safi_t safi, zlog_debug ("%s sending REFRESH_REQ with pfxlist ORF(%d) (%s) for afi/safi: %d/%d", peer->host, orf_type, (when_to_refresh == REFRESH_DEFER ? "defer" : "immediate"), - afi, safi); + pkt_afi, pkt_safi); } /* Total ORF Entry Len. */ @@ -761,7 +767,7 @@ bgp_route_refresh_send (struct peer *peer, afi_t afi, safi_t safi, { if (! orf_refresh) zlog_debug ("%s sending REFRESH_REQ for afi/safi: %d/%d", - peer->host, afi, safi); + peer->host, pkt_afi, pkt_safi); } /* Add packet to the peer. */ @@ -776,10 +782,11 @@ bgp_capability_send (struct peer *peer, afi_t afi, safi_t safi, int capability_code, int action) { struct stream *s; + afi_t pkt_afi; + safi_t pkt_safi; - /* Adjust safi code. */ - if (safi == SAFI_MPLS_VPN) - safi = SAFI_MPLS_LABELED_VPN; + /* Convert AFI, SAFI to values for packet. */ + bgp_map_afi_safi_int2iana (afi, safi, &pkt_afi, &pkt_safi); s = stream_new (BGP_MAX_PACKET_SIZE); @@ -792,14 +799,14 @@ bgp_capability_send (struct peer *peer, afi_t afi, safi_t safi, stream_putc (s, action); stream_putc (s, CAPABILITY_CODE_MP); stream_putc (s, CAPABILITY_CODE_MP_LEN); - stream_putw (s, afi); + stream_putw (s, pkt_afi); stream_putc (s, 0); - stream_putc (s, safi); + stream_putc (s, pkt_safi); if (bgp_debug_neighbor_events(peer)) zlog_debug ("%s sending CAPABILITY has %s MP_EXT CAP for afi/safi: %d/%d", peer->host, action == CAPABILITY_ACTION_SET ? - "Advertising" : "Removing", afi, safi); + "Advertising" : "Removing", pkt_afi, pkt_safi); } /* Set packet size. */ @@ -1329,7 +1336,6 @@ bgp_nlri_parse (struct peer *peer, struct attr *attr, struct bgp_nlri *packet) case SAFI_MULTICAST: return bgp_nlri_parse_ip (peer, attr, packet); case SAFI_MPLS_VPN: - case SAFI_MPLS_LABELED_VPN: return bgp_nlri_parse_vpn (peer, attr, packet); case SAFI_ENCAP: return bgp_nlri_parse_encap (peer, attr, packet); @@ -1508,26 +1514,6 @@ bgp_update_receive (struct peer *peer, bgp_size_t size) if (!nlris[i].nlri) continue; - /* We use afi and safi as indices into tables and what not. It would - * be impossible, at this time, to support unknown afi/safis. And - * anyway, the peer needs to be configured to enable the afi/safi - * explicitly which requires UI support. - * - * Ignore unknown afi/safi NLRIs. - * - * Note: This means nlri[x].afi/safi still can not be trusted for - * indexing later in this function! - * - * Note2: This will also remap the wire code-point for VPN safi to the - * internal safi_t point, as needs be. - */ - if(!bgp_afi_safi_valid_indices (nlris[i].afi, &nlris[i].safi)) - { - zlog_info ("%s [Info] UPDATE with unsupported AFI/SAFI %u/%u", - peer->host, nlris[i].afi, nlris[i].safi); - continue; - } - /* NLRI is processed iff the peer if configured for the specific afi/safi */ if (!peer->afc[nlris[i].afi][nlris[i].safi]) { @@ -1586,9 +1572,7 @@ bgp_update_receive (struct peer *peer, bgp_size_t size) safi = SAFI_UNICAST; } else if (attr.flag & ATTR_FLAG_BIT (BGP_ATTR_MP_UNREACH_NLRI) - && nlris[NLRI_MP_WITHDRAW].length == 0 - && bgp_afi_safi_valid_indices (nlris[NLRI_MP_WITHDRAW].afi, - &nlris[NLRI_MP_WITHDRAW].safi)) + && nlris[NLRI_MP_WITHDRAW].length == 0) { afi = nlris[NLRI_MP_WITHDRAW].afi; safi = nlris[NLRI_MP_WITHDRAW].safi; @@ -1727,8 +1711,8 @@ bgp_keepalive_receive (struct peer *peer, bgp_size_t size) static void bgp_route_refresh_receive (struct peer *peer, bgp_size_t size) { - afi_t afi; - safi_t safi; + afi_t pkt_afi, afi; + safi_t pkt_safi, safi; struct stream *s; struct peer_af *paf; struct update_group *updgrp; @@ -1757,28 +1741,22 @@ bgp_route_refresh_receive (struct peer *peer, bgp_size_t size) s = peer->ibuf; /* Parse packet. */ - afi = stream_getw (s); + pkt_afi = stream_getw (s); (void)stream_getc (s); - safi = stream_getc (s); + pkt_safi = stream_getc (s); if (bgp_debug_update(peer, NULL, NULL, 0)) zlog_debug ("%s rcvd REFRESH_REQ for afi/safi: %d/%d", - peer->host, afi, safi); + peer->host, pkt_afi, pkt_safi); - /* Check AFI and SAFI. */ - if ((afi != AFI_IP && afi != AFI_IP6) - || (safi != SAFI_UNICAST && safi != SAFI_MULTICAST - && safi != SAFI_MPLS_LABELED_VPN)) + /* Convert AFI, SAFI to internal values and check. */ + if (bgp_map_afi_safi_iana2int (pkt_afi, pkt_safi, &afi, &safi)) { zlog_info ("%s REFRESH_REQ for unrecognized afi/safi: %d/%d - ignored", - peer->host, afi, safi); + peer->host, pkt_afi, pkt_safi); return; } - /* Adjust safi code. */ - if (safi == SAFI_MPLS_LABELED_VPN) - safi = SAFI_MPLS_VPN; - if (size != BGP_MSG_ROUTE_REFRESH_MIN_SIZE - BGP_HEADER_SIZE) { u_char *end; @@ -1954,8 +1932,8 @@ bgp_capability_msg_parse (struct peer *peer, u_char *pnt, bgp_size_t length) struct capability_mp_data mpc; struct capability_header *hdr; u_char action; - afi_t afi; - safi_t safi; + afi_t pkt_afi, afi; + safi_t pkt_safi, safi; end = pnt + length; @@ -1999,18 +1977,19 @@ bgp_capability_msg_parse (struct peer *peer, u_char *pnt, bgp_size_t length) /* We know MP Capability Code. */ if (hdr->code == CAPABILITY_CODE_MP) { - afi = ntohs (mpc.afi); - safi = mpc.safi; + pkt_afi = ntohs (mpc.afi); + pkt_safi = mpc.safi; /* Ignore capability when override-capability is set. */ if (CHECK_FLAG (peer->flags, PEER_FLAG_OVERRIDE_CAPABILITY)) continue; - if (!bgp_afi_safi_valid_indices (afi, &safi)) + /* Convert AFI, SAFI to internal values. */ + if (bgp_map_afi_safi_iana2int (pkt_afi, pkt_safi, &afi, &safi)) { if (bgp_debug_neighbor_events(peer)) zlog_debug ("%s Dynamic Capability MP_EXT afi/safi invalid " - "(%u/%u)", peer->host, afi, safi); + "(%u/%u)", peer->host, pkt_afi, pkt_safi); continue; } @@ -2020,7 +1999,7 @@ bgp_capability_msg_parse (struct peer *peer, u_char *pnt, bgp_size_t length) peer->host, action == CAPABILITY_ACTION_SET ? "Advertising" : "Removing", - ntohs(mpc.afi) , mpc.safi); + pkt_afi, pkt_safi); if (action == CAPABILITY_ACTION_SET) { diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 6d8f721bfb..0040c7a144 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -2119,6 +2119,9 @@ int bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi, safi_t safi, int always) { + afi_t pkt_afi; + safi_t pkt_safi; + if (!CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX)) return 0; @@ -2136,15 +2139,15 @@ bgp_maximum_prefix_overflow (struct peer *peer, afi_t afi, if (CHECK_FLAG (peer->af_flags[afi][safi], PEER_FLAG_MAX_PREFIX_WARNING)) return 0; + /* Convert AFI, SAFI to values for packet. */ + pkt_afi = afi_int2iana (afi); + pkt_safi = safi_int2iana (safi); { u_int8_t ndata[7]; - if (safi == SAFI_MPLS_VPN) - safi = SAFI_MPLS_LABELED_VPN; - - ndata[0] = (afi >> 8); - ndata[1] = afi; - ndata[2] = safi; + ndata[0] = (pkt_afi >> 8); + ndata[1] = pkt_afi; + ndata[2] = pkt_safi; ndata[3] = (peer->pmax[afi][safi] >> 24); ndata[4] = (peer->pmax[afi][safi] >> 16); ndata[5] = (peer->pmax[afi][safi] >> 8); diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index f9c3f9af4b..5457822f3b 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -651,6 +651,35 @@ bgp_listen_limit_unset (struct bgp *bgp) return 0; } +int +bgp_map_afi_safi_iana2int (afi_t pkt_afi, safi_t pkt_safi, + afi_t *afi, safi_t *safi) +{ + /* Map from IANA values to internal values, return error if + * values are unrecognized. + */ + *afi = afi_iana2int (pkt_afi); + *safi = safi_iana2int (pkt_safi); + if (*afi == AFI_MAX || *safi == SAFI_MAX) + return -1; + + return 0; +} + +int +bgp_map_afi_safi_int2iana (afi_t afi, safi_t safi, + afi_t *pkt_afi, safi_t *pkt_safi) +{ + /* Map from internal values to IANA values, return error if + * internal values are bad (unexpected). + */ + if (afi == AFI_MAX || safi == SAFI_MAX) + return -1; + *pkt_afi = afi_int2iana (afi); + *pkt_safi = safi_int2iana (safi); + return 0; +} + struct peer_af * peer_af_create (struct peer *peer, afi_t afi, safi_t safi) { diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index 76e19ac535..9a4d92715e 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -1080,10 +1080,6 @@ struct bgp_nlri #define BGP_DEFAULT_RESTART_TIME 120 #define BGP_DEFAULT_STALEPATH_TIME 360 -/* RFC4364 */ -#define SAFI_MPLS_LABELED_VPN 128 -#define BGP_SAFI_VPN 128 - /* BGP uptime string length. */ #define BGP_UPTIME_LEN 25 @@ -1360,6 +1356,13 @@ extern void bgp_route_map_terminate(void); extern int peer_cmp (struct peer *p1, struct peer *p2); +extern int +bgp_map_afi_safi_iana2int (afi_t pkt_afi, safi_t pkt_safi, + afi_t *afi, safi_t *safi); +extern int +bgp_map_afi_safi_int2iana (afi_t afi, safi_t safi, + afi_t *pkt_afi, safi_t *pkt_safi); + extern struct peer_af * peer_af_create (struct peer *, afi_t, safi_t); extern struct peer_af * peer_af_find (struct peer *, afi_t, safi_t); extern int peer_af_delete (struct peer *, afi_t, safi_t); diff --git a/bgpd/rfapi/rfapi_import.c b/bgpd/rfapi/rfapi_import.c index 25c05e65f8..716a1fb537 100644 --- a/bgpd/rfapi/rfapi_import.c +++ b/bgpd/rfapi/rfapi_import.c @@ -4086,7 +4086,6 @@ rfapiBgpInfoFilteredImportFunction (safi_t safi) switch (safi) { case SAFI_MPLS_VPN: - case BGP_SAFI_VPN: return rfapiBgpInfoFilteredImportVPN; case SAFI_ENCAP: @@ -4203,7 +4202,7 @@ rfapiProcessUpdate ( label); } - if (safi == SAFI_MPLS_VPN || safi == BGP_SAFI_VPN) + if (safi == SAFI_MPLS_VPN) { vnc_direct_bgp_rh_add_route (bgp, afi, p, peer, attr); } @@ -4332,7 +4331,7 @@ rfapiProcessWithdraw ( } /* TBD the deletion should happen after the lifetime expires */ - if (safi == SAFI_MPLS_VPN || safi == BGP_SAFI_VPN) + if (safi == SAFI_MPLS_VPN) vnc_direct_bgp_rh_del_route (bgp, afi, p, peer); if (safi == SAFI_MPLS_VPN) diff --git a/lib/zebra.h b/lib/zebra.h index 3a9ad15bf4..5a58cf8e6e 100644 --- a/lib/zebra.h +++ b/lib/zebra.h @@ -473,9 +473,28 @@ typedef enum { #define SAFI_MULTICAST 2 #define SAFI_MPLS_VPN 3 #define SAFI_RESERVED_4 4 -#define SAFI_ENCAP 7 /* per IANA */ +#define SAFI_ENCAP 5 #define SAFI_RESERVED_5 5 -#define SAFI_MAX 8 +#define SAFI_MAX 6 + +/* + * The above AFI and SAFI definitions are for internal use. The protocol + * definitions (IANA values) as for example used in BGP protocol packets + * are defined below and these will get mapped to/from the internal values + * in the appropriate places. + * The rationale is that the protocol (IANA) values may be sparse and are + * not optimal for use in data-structure sizing. + * Note: Only useful (i.e., supported) values are defined below. + */ +#define IANA_AFI_RESERVED 0 +#define IANA_AFI_IPV4 1 +#define IANA_AFI_IPV6 2 + +#define IANA_SAFI_RESERVED 0 +#define IANA_SAFI_UNICAST 1 +#define IANA_SAFI_MULTICAST 2 +#define IANA_SAFI_ENCAP 7 +#define IANA_SAFI_MPLS_VPN 128 /* Default Administrative Distance of each protocol. */ #define ZEBRA_KERNEL_DISTANCE_DEFAULT 0 @@ -509,4 +528,48 @@ typedef uint32_t route_tag_t; #define ROUTE_TAG_MAX UINT32_MAX #define ROUTE_TAG_PRI PRIu32 +static inline afi_t afi_iana2int (afi_t afi) +{ + if (afi == IANA_AFI_IPV4) + return AFI_IP; + if (afi == IANA_AFI_IPV6) + return AFI_IP6; + return AFI_MAX; +} + +static inline afi_t afi_int2iana (afi_t afi) +{ + if (afi == AFI_IP) + return IANA_AFI_IPV4; + if (afi == AFI_IP6) + return IANA_AFI_IPV6; + return IANA_AFI_RESERVED; +} + +static inline safi_t safi_iana2int (safi_t safi) +{ + if (safi == IANA_SAFI_UNICAST) + return SAFI_UNICAST; + if (safi == IANA_SAFI_MULTICAST) + return SAFI_MULTICAST; + if (safi == IANA_SAFI_MPLS_VPN) + return SAFI_MPLS_VPN; + if (safi == IANA_SAFI_ENCAP) + return SAFI_ENCAP; + return SAFI_MAX; +} + +static inline safi_t safi_int2iana (safi_t safi) +{ + if (safi == SAFI_UNICAST) + return IANA_SAFI_UNICAST; + if (safi == SAFI_MULTICAST) + return IANA_SAFI_MULTICAST; + if (safi == SAFI_MPLS_VPN) + return IANA_SAFI_MPLS_VPN; + if (safi == SAFI_ENCAP) + return IANA_SAFI_ENCAP; + return IANA_SAFI_RESERVED; +} + #endif /* _ZEBRA_H */ diff --git a/tests/bgp_capability_test.c b/tests/bgp_capability_test.c index 7fa4be5611..3ee6a121e4 100644 --- a/tests/bgp_capability_test.c +++ b/tests/bgp_capability_test.c @@ -124,21 +124,21 @@ static struct test_segment mp_segments[] = "MP IP6/MPLS-labeled VPN", { CAPABILITY_CODE_MP, 0x4, 0x0, 0x2, 0x0, 0x80 }, 6, SHOULD_PARSE, 0, - 1, AFI_IP6, SAFI_MPLS_LABELED_VPN, VALID_AFI, + 1, AFI_IP6, IANA_SAFI_MPLS_VPN, VALID_AFI, }, /* 7 */ { "MP5", "MP IP6/MPLS-VPN", { CAPABILITY_CODE_MP, 0x4, 0x0, 0x2, 0x0, 0x4 }, 6, SHOULD_PARSE, 0, - 1, AFI_IP6, SAFI_MPLS_VPN, VALID_AFI, + 1, AFI_IP6, IANA_SAFI_MPLS_VPN, VALID_AFI, }, /* 8 */ { "MP6", "MP IP4/MPLS-laveled VPN", { CAPABILITY_CODE_MP, 0x4, 0x0, 0x1, 0x0, 0x80 }, 6, SHOULD_PARSE, 0, - 1, AFI_IP, SAFI_MPLS_LABELED_VPN, VALID_AFI, + 1, AFI_IP, IANA_SAFI_MPLS_VPN, VALID_AFI, }, /* 10 */ { "MP8", @@ -585,22 +585,26 @@ parse_test (struct peer *peer, struct test_segment *t, int type) if (!ret && t->validate_afi) { - safi_t safi = t->safi; + afi_t afi; + safi_t safi; - if (bgp_afi_safi_valid_indices (t->afi, &safi) != t->afi_valid) - failed++; - - printf ("MP: %u/%u (%u): recv %u, nego %u\n", - t->afi, t->safi, safi, - peer->afc_recv[t->afi][safi], - peer->afc_nego[t->afi][safi]); + /* Convert AFI, SAFI to internal values, check. */ + if (bgp_map_afi_safi_iana2int (t->afi, t->safi, &afi, &safi)) + { + if (t->afi_valid == VALID_AFI) + failed++; + } + printf ("MP: %u(%u)/%u(%u): recv %u, nego %u\n", + t->afi, afi, t->safi, safi, + peer->afc_recv[afi][safi], + peer->afc_nego[afi][safi]); if (t->afi_valid == VALID_AFI) { - if (!peer->afc_recv[t->afi][safi]) + if (!peer->afc_recv[afi][safi]) failed++; - if (!peer->afc_nego[t->afi][safi]) + if (!peer->afc_nego[afi][safi]) failed++; } } diff --git a/tests/bgp_mp_attr_test.c b/tests/bgp_mp_attr_test.c index dfb8ed9f7a..f7c2af4405 100644 --- a/tests/bgp_mp_attr_test.c +++ b/tests/bgp_mp_attr_test.c @@ -317,7 +317,7 @@ static struct test_segment { { "IPv4-VPNv4", "IPv4/VPNv4 MP Reach, RD, Nexthop, 2 NLRIs", { - /* AFI / SAFI */ 0x0, AFI_IP, SAFI_MPLS_LABELED_VPN, + /* AFI / SAFI */ 0x0, AFI_IP, IANA_SAFI_MPLS_VPN, /* nexthop bytes */ 12, /* RD */ 0, 0, 0, 0, /* RD defined to be 0 */ 0, 0, 0, 0, @@ -338,12 +338,12 @@ static struct test_segment { }, (4 + 12 + 1 + (1+3+8+2) + (1+3+8+3)), SHOULD_PARSE, - AFI_IP, SAFI_MPLS_LABELED_VPN, VALID_AFI, + AFI_IP, IANA_SAFI_MPLS_VPN, VALID_AFI, }, { "IPv4-VPNv4-bogus-plen", "IPv4/MPLS-labeled VPN MP Reach, RD, Nexthop, NLRI / bogus p'len", { - /* AFI / SAFI */ 0x0, AFI_IP, SAFI_MPLS_LABELED_VPN, + /* AFI / SAFI */ 0x0, AFI_IP, IANA_SAFI_MPLS_VPN, /* nexthop bytes */ 12, /* RD */ 0, 0, 1, 2, 0, 0xff, 3, 4, @@ -355,12 +355,12 @@ static struct test_segment { }, (3 + 1 + 3*4 + 1 + 3 + 4 + 1), SHOULD_ERR, - AFI_IP, SAFI_MPLS_LABELED_VPN, VALID_AFI, + AFI_IP, IANA_SAFI_MPLS_VPN, VALID_AFI, }, { "IPv4-VPNv4-plen1-short", "IPv4/VPNv4 MP Reach, RD, Nexthop, 2 NLRIs, 1st plen short", { - /* AFI / SAFI */ 0x0, AFI_IP, SAFI_MPLS_LABELED_VPN, + /* AFI / SAFI */ 0x0, AFI_IP, IANA_SAFI_MPLS_VPN, /* nexthop bytes */ 12, /* RD */ 0, 0, 0, 0, /* RD defined to be 0 */ 0, 0, 0, 0, @@ -381,12 +381,12 @@ static struct test_segment { }, (4 + 12 + 1 + (1+3+8+2) + (1+3+8+3)), SHOULD_ERR, - AFI_IP, SAFI_MPLS_LABELED_VPN, VALID_AFI, + AFI_IP, IANA_SAFI_MPLS_VPN, VALID_AFI, }, { "IPv4-VPNv4-plen1-long", "IPv4/VPNv4 MP Reach, RD, Nexthop, 2 NLRIs, 1st plen long", { - /* AFI / SAFI */ 0x0, AFI_IP, SAFI_MPLS_LABELED_VPN, + /* AFI / SAFI */ 0x0, AFI_IP, IANA_SAFI_MPLS_VPN, /* nexthop bytes */ 12, /* RD */ 0, 0, 0, 0, /* RD defined to be 0 */ 0, 0, 0, 0, @@ -407,12 +407,12 @@ static struct test_segment { }, (4 + 12 + 1 + (1+3+8+2) + (1+3+8+3)), SHOULD_ERR, - AFI_IP, SAFI_MPLS_LABELED_VPN, VALID_AFI, + AFI_IP, IANA_SAFI_MPLS_VPN, VALID_AFI, }, { "IPv4-VPNv4-plenn-long", "IPv4/VPNv4 MP Reach, RD, Nexthop, 3 NLRIs, last plen long", { - /* AFI / SAFI */ 0x0, AFI_IP, SAFI_MPLS_LABELED_VPN, + /* AFI / SAFI */ 0x0, AFI_IP, IANA_SAFI_MPLS_VPN, /* nexthop bytes */ 12, /* RD */ 0, 0, 0, 0, /* RD defined to be 0 */ 0, 0, 0, 0, @@ -434,12 +434,12 @@ static struct test_segment { }, (4 + 12 + 1 + (1+3+8+2) + (1+3+8+3) + 1), SHOULD_ERR, - AFI_IP, SAFI_MPLS_LABELED_VPN, VALID_AFI, + AFI_IP, IANA_SAFI_MPLS_VPN, VALID_AFI, }, { "IPv4-VPNv4-plenn-short", "IPv4/VPNv4 MP Reach, RD, Nexthop, 2 NLRIs, last plen short", { - /* AFI / SAFI */ 0x0, AFI_IP, SAFI_MPLS_LABELED_VPN, + /* AFI / SAFI */ 0x0, AFI_IP, IANA_SAFI_MPLS_VPN, /* nexthop bytes */ 12, /* RD */ 0, 0, 0, 0, /* RD defined to be 0 */ 0, 0, 0, 0, @@ -460,12 +460,12 @@ static struct test_segment { }, (4 + 12 + 1 + (1+3+8+2) + (1+3+8+3)), SHOULD_ERR, - AFI_IP, SAFI_MPLS_LABELED_VPN, VALID_AFI, + AFI_IP, IANA_SAFI_MPLS_VPN, VALID_AFI, }, { "IPv4-VPNv4-bogus-rd-type", "IPv4/VPNv4 MP Reach, RD, NH, 2 NLRI, unknown RD in 1st (log, but parse)", { - /* AFI / SAFI */ 0x0, AFI_IP, SAFI_MPLS_LABELED_VPN, + /* AFI / SAFI */ 0x0, AFI_IP, IANA_SAFI_MPLS_VPN, /* nexthop bytes */ 12, /* RD */ 0, 0, 0, 0, /* RD defined to be 0 */ 0, 0, 0, 0, @@ -486,12 +486,12 @@ static struct test_segment { }, (4 + 12 + 1 + (1+3+8+2) + (1+3+8+3)), SHOULD_PARSE, - AFI_IP, SAFI_MPLS_LABELED_VPN, VALID_AFI, + AFI_IP, IANA_SAFI_MPLS_VPN, VALID_AFI, }, { "IPv4-VPNv4-0-nlri", "IPv4/VPNv4 MP Reach, RD, Nexthop, 3 NLRI, 3rd 0 bogus", { - /* AFI / SAFI */ 0x0, AFI_IP, SAFI_MPLS_LABELED_VPN, + /* AFI / SAFI */ 0x0, AFI_IP, IANA_SAFI_MPLS_VPN, /* nexthop bytes */ 12, /* RD */ 0, 0, 0, 0, /* RD defined to be 0 */ 0, 0, 0, 0, @@ -513,7 +513,7 @@ static struct test_segment { }, (4 + 12 + 1 + (1+3+8+2) + (1+3+8+3) + 1), SHOULD_ERR, - AFI_IP, SAFI_MPLS_LABELED_VPN, VALID_AFI, + AFI_IP, IANA_SAFI_MPLS_VPN, VALID_AFI, }, /* From bug #385 */ @@ -625,7 +625,7 @@ static struct test_segment mp_unreach_segments [] = { "IPv4-unreach-VPNv4", "IPv4/MPLS-labeled VPN MP Unreach, RD, 3 NLRIs", { - /* AFI / SAFI */ 0x0, AFI_IP, SAFI_MPLS_LABELED_VPN, + /* AFI / SAFI */ 0x0, AFI_IP, IANA_SAFI_MPLS_VPN, /* NLRI tuples */ 88 + 16, 0, 1, 2, /* tag */ /* rd, 8 octets */ @@ -641,7 +641,7 @@ static struct test_segment mp_unreach_segments [] = }, (3 + (1+3+8+2) + (1+3+8+3)), SHOULD_PARSE, - AFI_IP, SAFI_MPLS_LABELED_VPN, VALID_AFI, + AFI_IP, IANA_SAFI_MPLS_VPN, VALID_AFI, }, { NULL, NULL, {0}, 0, 0} }; @@ -656,19 +656,6 @@ handle_result (struct peer *peer, struct test_segment *t, { int oldfailed = failed; - if (!parse_ret) - { - safi_t safi = t->safi; - - if (bgp_afi_safi_valid_indices (t->afi, &safi) != t->afi_valid) - failed++; - - printf ("MP: %u/%u (%u): recv %u, nego %u\n", - t->afi, t->safi, safi, - peer->afc_recv[t->afi][safi], - peer->afc_nego[t->afi][safi]); - } - printf ("mp attr parsed?: %s\n", parse_ret ? "no" : "yes"); if (!parse_ret) printf ("nrli parsed?: %s\n", nlri_ret ? "no" : "yes"); @@ -720,9 +707,20 @@ parse_test (struct peer *peer, struct test_segment *t, int type) parse_ret = bgp_mp_reach_parse (&attr_args, &nlri); else parse_ret = bgp_mp_unreach_parse (&attr_args, &nlri); - - if (parse_ret == 0 && t->afi_valid == VALID_AFI) - assert (nlri.afi == t->afi && nlri.safi == t->safi); + if (!parse_ret) + { + afi_t pkt_afi; + safi_t pkt_safi; + + /* Convert AFI, SAFI to internal values, check. */ + if (bgp_map_afi_safi_int2iana (nlri.afi, nlri.safi, &pkt_afi, &pkt_safi)) + assert (0); + + printf ("MP: %u(%u)/%u(%u): recv %u, nego %u\n", + nlri.afi , pkt_afi, nlri.safi, pkt_safi, + peer->afc_recv[nlri.afi][nlri.safi], + peer->afc_nego[nlri.afi][nlri.safi]); + } if (!parse_ret) { @@ -731,7 +729,7 @@ parse_test (struct peer *peer, struct test_segment *t, int type) else nlri_ret = bgp_nlri_parse (peer, NULL, &nlri); } - + zlog_err("xxxxxxxxxxxxxxxx nlri ret %u", nlri_ret); handle_result (peer, t, parse_ret, nlri_ret); } From 8c90786c956cbb2535d184dea684c935c204fc22 Mon Sep 17 00:00:00 2001 From: Lou Berger Date: Thu, 12 Jan 2017 08:54:22 -0500 Subject: [PATCH 085/107] bgpd: remove code contained by ifdef KEEP_OLD_VPNV4_COMMANDS Signed-off-by: Lou Berger --- bgpd/bgp_route.c | 120 --------- bgpd/bgp_routemap.c | 102 -------- bgpd/bgp_vty.c | 604 -------------------------------------------- 3 files changed, 826 deletions(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 2320c08b1f..7d423be631 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -8297,22 +8297,6 @@ ALIAS (show_ip_bgp_ipv4_route, "Network in the BGP routing table to display\n" "JavaScript Object Notation\n") -#ifdef KEEP_OLD_VPNV4_COMMANDS -DEFUN (show_ip_bgp_vpnv4_all_route, - show_ip_bgp_vpnv4_all_route_cmd, - "show ip bgp vpnv4 all A.B.C.D {json}", - SHOW_STR - IP_STR - BGP_STR - "Display VPNv4 NLRI specific information\n" - "Display information about all VPNv4 NLRIs\n" - "Network in the BGP routing table to display\n" - "JavaScript Object Notation\n") -{ - return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); -} -#endif /* KEEP_OLD_VPNV4_COMMANDS */ - DEFUN (show_bgp_ipv4_safi_rd_route, show_bgp_ipv4_safi_rd_route_cmd, "show bgp ipv4 (encap|vpn) rd ASN:nn_or_IP-address:nn A.B.C.D {json}", @@ -8432,33 +8416,6 @@ DEFUN (show_bgp_ipv6_safi_rd_prefix, return bgp_show_route (vty, NULL, argv[2], AFI_IP6, safi, &prd, 1, BGP_PATH_ALL, use_json (argc, argv)); } -#ifdef KEEP_OLD_VPNV4_COMMANDS -DEFUN (show_ip_bgp_vpnv4_rd_route, - show_ip_bgp_vpnv4_rd_route_cmd, - "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D {json}", - SHOW_STR - IP_STR - BGP_STR - "Display VPNv4 NLRI specific information\n" - "Display information for a route distinguisher\n" - "VPN Route Distinguisher\n" - "Network in the BGP routing table to display\n" - "JavaScript Object Notation\n") -{ - int ret; - struct prefix_rd prd; - u_char uj= use_json(argc, argv); - - ret = str2prefix_rd (argv[0], &prd); - if (! ret) - { - vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); - return CMD_WARNING; - } - return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL, uj); -} -#endif /* KEEP_OLD_VPNV4_COMMANDS */ - DEFUN (show_ip_bgp_prefix, show_ip_bgp_prefix_cmd, "show ip bgp A.B.C.D/M {json}", @@ -8550,45 +8507,6 @@ ALIAS (show_ip_bgp_ipv4_prefix_pathtype, "Display only multipaths\n" "JavaScript Object Notation\n") -#ifdef KEEP_OLD_VPNV4_COMMANDS -DEFUN (show_ip_bgp_vpnv4_all_prefix, - show_ip_bgp_vpnv4_all_prefix_cmd, - "show ip bgp vpnv4 all A.B.C.D/M {json}", - SHOW_STR - IP_STR - BGP_STR - "Display VPNv4 NLRI specific information\n" - "Display information about all VPNv4 NLRIs\n" - "IP prefix /, e.g., 35.0.0.0/8\n" - "JavaScript Object Notation\n") -{ - return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1, BGP_PATH_ALL, use_json(argc, argv)); -} - -DEFUN (show_ip_bgp_vpnv4_rd_prefix, - show_ip_bgp_vpnv4_rd_prefix_cmd, - "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M {json}", - SHOW_STR - IP_STR - BGP_STR - "Display VPNv4 NLRI specific information\n" - "Display information for a route distinguisher\n" - "VPN Route Distinguisher\n" - "IP prefix /, e.g., 35.0.0.0/8\n" - "JavaScript Object Notation\n") -{ - int ret; - struct prefix_rd prd; - - ret = str2prefix_rd (argv[0], &prd); - if (! ret) - { - vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); - return CMD_WARNING; - } - return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL, use_json(argc, argv)); -} -#endif /* KEEP_OLD_VPNV4_COMMANDS */ DEFUN (show_ip_bgp_view, show_ip_bgp_instance_cmd, @@ -12248,33 +12166,6 @@ DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts, return bgp_peer_counts (vty, peer, AFI_IP, safi, uj); } -#ifdef KEEP_OLD_VPNV4_COMMANDS -DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts, - show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd, - "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}", - SHOW_STR - IP_STR - BGP_STR - "Address family\n" - BGP_SAFI_HELP_STR - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Neighbor on bgp configured interface\n" - "Display detailed prefix count information\n" - "JavaScript Object Notation\n") -{ - struct peer *peer; - u_char uj = use_json(argc, argv); - - peer = peer_lookup_in_view (vty, NULL, argv[0], uj); - if (! peer) - return CMD_WARNING; - - return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MPLS_VPN, uj); -} -#endif /* KEEP_OLD_VPNV4_COMMANDS */ - static void show_adj_route (struct vty *vty, struct peer *peer, afi_t afi, safi_t safi, int in, const char *rmap_name, u_char use_json, json_object *json) @@ -14784,10 +14675,6 @@ bgp_route_init (void) install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_pathtype_cmd); install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd); install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_cmd); -#ifdef KEEP_OLD_VPNV4_COMMANDS - install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd); - install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); -#endif /* KEEP_OLD_VPNV4_COMMANDS */ install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd); install_element (VIEW_NODE, &show_ip_bgp_instance_prefix_cmd); install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd); @@ -14796,10 +14683,6 @@ bgp_route_init (void) install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_cmd); install_element (VIEW_NODE, &show_ip_bgp_prefix_pathtype_cmd); install_element (VIEW_NODE, &show_ip_bgp_instance_prefix_pathtype_cmd); -#ifdef KEEP_OLD_VPNV4_COMMANDS - install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); - install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); -#endif /* KEEP_OLD_VPNV4_COMMANDS */ install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd); install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd); @@ -14904,9 +14787,6 @@ bgp_route_init (void) install_element (ENABLE_NODE, &show_ip_bgp_neighbor_prefix_counts_cmd); install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbor_prefix_counts_cmd); install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd); -#ifdef KEEP_OLD_VPNV4_COMMANDS - install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd); -#endif /* KEEP_OLD_VPNV4_COMMANDS */ #ifdef HAVE_IPV6 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_prefix_counts_cmd); install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbor_prefix_counts_cmd); diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c index 61435ce207..d0cce4a955 100644 --- a/bgpd/bgp_routemap.c +++ b/bgpd/bgp_routemap.c @@ -2342,64 +2342,6 @@ struct route_map_rule_cmd route_set_ipv6_nexthop_peer_cmd = #endif /* HAVE_IPV6 */ -#ifdef KEEP_OLD_VPNV4_COMMANDS -/* `set ip vpn nexthop A.B.C.D' */ -static route_map_result_t -route_set_vpnv4_nexthop (void *rule, struct prefix *prefix, - route_map_object_t type, void *object) -{ - struct in_addr *address; - struct bgp_info *bgp_info; - - if (type == RMAP_BGP) - { - /* Fetch routemap's rule information. */ - address = rule; - bgp_info = object; - - /* Set next hop value. */ - (bgp_attr_extra_get (bgp_info->attr))->mp_nexthop_global_in = *address; - (bgp_attr_extra_get (bgp_info->attr))->mp_nexthop_len = 4; - } - - return RMAP_OKAY; -} - -static void * -route_set_vpnv4_nexthop_compile (const char *arg) -{ - int ret; - struct in_addr *address; - - address = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (struct in_addr)); - - ret = inet_aton (arg, address); - - if (ret == 0) - { - XFREE (MTYPE_ROUTE_MAP_COMPILED, address); - return NULL; - } - - return address; -} - -static void -route_set_vpnv4_nexthop_free (void *rule) -{ - XFREE (MTYPE_ROUTE_MAP_COMPILED, rule); -} - -/* Route map commands for ip nexthop set. */ -struct route_map_rule_cmd route_set_vpnv4_nexthop_cmd = -{ - "ip vpn next-hop", - route_set_vpnv4_nexthop, - route_set_vpnv4_nexthop_compile, - route_set_vpnv4_nexthop_free -}; -#endif /* KEEP_OLD_VPNV4_COMMANDS */ - /* `set originator-id' */ /* For origin set. */ @@ -4501,42 +4443,6 @@ ALIAS (no_set_ipv6_nexthop_local, "IPv6 address of next hop\n") #endif /* HAVE_IPV6 */ -#ifdef KEEP_OLD_VPNV4_COMMANDS -DEFUN (set_vpnv4_nexthop, - set_vpnv4_nexthop_cmd, - "set ip vpn next-hop A.B.C.D", - SET_STR - "IP VPN information\n" - "IP VPN next-hop address\n" - "IP address of next hop\n") -{ - return bgp_route_set_add (vty, vty->index, "ip vpn next-hop", argv[0]); -} - -DEFUN (no_set_vpnv4_nexthop, - no_set_vpnv4_nexthop_cmd, - "no set ip vpn next-hop", - NO_STR - SET_STR - "IP VPN information\n" - "IP VPN next-hop address\n") -{ - if (argc == 0) - return bgp_route_set_delete (vty, vty->index, "ip vpn next-hop", NULL); - - return bgp_route_set_delete (vty, vty->index, "ip vpn next-hop", argv[0]); -} - -ALIAS (no_set_vpnv4_nexthop, - no_set_vpnv4_nexthop_val_cmd, - "no set ip vpn next-hop A.B.C.D", - NO_STR - SET_STR - "IP VPN information\n" - "IP VPN next-hop address\n" - "IP address of next hop\n") -#endif /* KEEP_OLD_VPNV4_COMMANDS */ - DEFUN (set_originator_id, set_originator_id_cmd, "set originator-id A.B.C.D", @@ -4607,9 +4513,6 @@ bgp_route_map_init (void) route_map_install_set (&route_set_aggregator_as_cmd); route_map_install_set (&route_set_community_cmd); route_map_install_set (&route_set_community_delete_cmd); -#ifdef KEEP_OLD_VPNV4_COMMANDS - route_map_install_set (&route_set_vpnv4_nexthop_cmd); -#endif /* KEEP_OLD_VPNV4_COMMANDS */ route_map_install_set (&route_set_originator_id_cmd); route_map_install_set (&route_set_ecommunity_rt_cmd); route_map_install_set (&route_set_ecommunity_soo_cmd); @@ -4715,11 +4618,6 @@ bgp_route_map_init (void) install_element (RMAP_NODE, &set_ecommunity_soo_cmd); install_element (RMAP_NODE, &no_set_ecommunity_soo_cmd); install_element (RMAP_NODE, &no_set_ecommunity_soo_val_cmd); -#ifdef KEEP_OLD_VPNV4_COMMANDS - install_element (RMAP_NODE, &set_vpnv4_nexthop_cmd); - install_element (RMAP_NODE, &no_set_vpnv4_nexthop_cmd); - install_element (RMAP_NODE, &no_set_vpnv4_nexthop_val_cmd); -#endif /* KEEP_OLD_VPNV4_COMMANDS */ install_element (RMAP_NODE, &set_originator_id_cmd); install_element (RMAP_NODE, &no_set_originator_id_cmd); install_element (RMAP_NODE, &no_set_originator_id_val_cmd); diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index f2190c8303..a27a5f6b26 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -6139,15 +6139,6 @@ DEFUN (address_family_vpnv4, return CMD_SUCCESS; } -#ifdef KEEP_OLD_VPNV4_COMMANDS -ALIAS (address_family_vpnv4, - address_family_vpnv4_unicast_cmd, - "address-family vpnv4 unicast", - "Enter Address Family command mode\n" - "Address family\n" - "Address Family Modifier\n") -#endif /* KEEP_OLD_VPNV4_COMMANDS */ - DEFUN (address_family_vpnv6, address_family_vpnv6_cmd, "address-family vpnv6", @@ -6158,15 +6149,6 @@ DEFUN (address_family_vpnv6, return CMD_SUCCESS; } -#ifdef KEEP_OLD_VPNV4_COMMANDS -ALIAS (address_family_vpnv6, - address_family_vpnv6_unicast_cmd, - "address-family vpnv6 unicast", - "Enter Address Family command mode\n" - "Address family\n" - "Address Family Modifier\n") -#endif /* KEEP_OLD_VPNV4_COMMANDS */ - DEFUN (address_family_encap, address_family_encap_cmd, "address-family encap", @@ -6734,62 +6716,6 @@ ALIAS (clear_ip_bgp_instance_all_ipv4_soft_out, BGP_SAFI_HELP_STR BGP_SOFT_OUT_STR) -#ifdef KEEP_OLD_VPNV4_COMMANDS -DEFUN (clear_ip_bgp_all_vpnv4_soft_out, - clear_ip_bgp_all_vpnv4_soft_out_cmd, - "clear ip bgp * vpnv4 unicast soft out", - CLEAR_STR - IP_STR - BGP_STR - "Clear all peers\n" - "Address family\n" - "Address Family Modifier\n" - BGP_SOFT_STR - BGP_SOFT_OUT_STR) -{ - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all, - BGP_CLEAR_SOFT_OUT, NULL); -} - -ALIAS (clear_ip_bgp_all_vpnv4_soft_out, - clear_ip_bgp_all_vpnv4_out_cmd, - "clear ip bgp * vpnv4 unicast out", - CLEAR_STR - IP_STR - BGP_STR - "Clear all peers\n" - "Address family\n" - "Address Family Modifier\n" - BGP_SOFT_OUT_STR) - -DEFUN (clear_ip_bgp_all_encap_soft_out, - clear_ip_bgp_all_encap_soft_out_cmd, - "clear ip bgp * encap unicast soft out", - CLEAR_STR - IP_STR - BGP_STR - "Clear all peers\n" - "Address family\n" - "Address Family Modifier\n" - "Soft reconfig\n" - "Soft reconfig outbound update\n") -{ - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_all, - BGP_CLEAR_SOFT_OUT, NULL); -} - -ALIAS (clear_ip_bgp_all_encap_soft_out, - clear_ip_bgp_all_encap_out_cmd, - "clear ip bgp * encap unicast out", - CLEAR_STR - IP_STR - BGP_STR - "Clear all peers\n" - "Address family\n" - "Address Family Modifier\n" - "Soft reconfig outbound update\n") -#endif /* KEEP_OLD_VPNV4_COMMANDS */ - DEFUN (clear_bgp_all_soft_out, clear_bgp_all_soft_out_cmd, "clear bgp * soft out", @@ -7021,65 +6947,6 @@ ALIAS (clear_ip_bgp_instance_peer_ipv4_soft_out, BGP_SAFI_HELP_STR BGP_SOFT_OUT_STR) -#ifdef KEEP_OLD_VPNV4_COMMANDS -/* NOTE: WORD peers have not been tested for vpnv4 */ -DEFUN (clear_ip_bgp_peer_vpnv4_soft_out, - clear_ip_bgp_peer_vpnv4_soft_out_cmd, - "clear ip bgp (A.B.C.D|WORD) vpnv4 unicast soft out", - CLEAR_STR - IP_STR - BGP_STR - "BGP neighbor address to clear\n" - "BGP neighbor on interface to clear\n" - "Address family\n" - "Address Family Modifier\n" - BGP_SOFT_STR - BGP_SOFT_OUT_STR) -{ - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer, - BGP_CLEAR_SOFT_OUT, argv[0]); -} - -ALIAS (clear_ip_bgp_peer_vpnv4_soft_out, - clear_ip_bgp_peer_vpnv4_out_cmd, - "clear ip bgp (A.B.C.D|WORD) vpnv4 unicast out", - CLEAR_STR - IP_STR - BGP_STR - "BGP neighbor address to clear\n" - "BGP neighbor on interface to clear\n" - "Address family\n" - "Address Family Modifier\n" - BGP_SOFT_OUT_STR) - -DEFUN (clear_ip_bgp_peer_encap_soft_out, - clear_ip_bgp_peer_encap_soft_out_cmd, - "clear ip bgp A.B.C.D encap unicast soft out", - CLEAR_STR - IP_STR - BGP_STR - "BGP neighbor address to clear\n" - "Address family\n" - "Address Family Modifier\n" - "Soft reconfig\n" - "Soft reconfig outbound update\n") -{ - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_peer, - BGP_CLEAR_SOFT_OUT, argv[0]); -} - -ALIAS (clear_ip_bgp_peer_encap_soft_out, - clear_ip_bgp_peer_encap_out_cmd, - "clear ip bgp A.B.C.D encap unicast out", - CLEAR_STR - IP_STR - BGP_STR - "BGP neighbor address to clear\n" - "Address family\n" - "Address Family Modifier\n" - "Soft reconfig outbound update\n") -#endif /* KEEP_OLD_VPNV4_COMMANDS */ - DEFUN (clear_bgp_peer_soft_out, clear_bgp_peer_soft_out_cmd, "clear bgp (A.B.C.D|X:X::X:X|WORD) soft out", @@ -7688,62 +7555,6 @@ ALIAS (clear_ip_bgp_instance_as_ipv4_soft_out, BGP_SAFI_HELP_STR BGP_SOFT_OUT_STR) -#ifdef KEEP_OLD_VPNV4_COMMANDS -DEFUN (clear_ip_bgp_as_vpnv4_soft_out, - clear_ip_bgp_as_vpnv4_soft_out_cmd, - "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast soft out", - CLEAR_STR - IP_STR - BGP_STR - "Clear peers with the AS number\n" - "Address family\n" - "Address Family modifier\n" - BGP_SOFT_STR - BGP_SOFT_OUT_STR) -{ - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as, - BGP_CLEAR_SOFT_OUT, argv[0]); -} - -ALIAS (clear_ip_bgp_as_vpnv4_soft_out, - clear_ip_bgp_as_vpnv4_out_cmd, - "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast out", - CLEAR_STR - IP_STR - BGP_STR - "Clear peers with the AS number\n" - "Address family\n" - "Address Family modifier\n" - BGP_SOFT_OUT_STR) - -DEFUN (clear_ip_bgp_as_encap_soft_out, - clear_ip_bgp_as_encap_soft_out_cmd, - "clear ip bgp " CMD_AS_RANGE " encap unicast soft out", - CLEAR_STR - IP_STR - BGP_STR - "Clear peers with the AS number\n" - "Address family\n" - "Address Family modifier\n" - "Soft reconfig\n" - "Soft reconfig outbound update\n") -{ - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_as, - BGP_CLEAR_SOFT_OUT, argv[0]); -} - -ALIAS (clear_ip_bgp_as_encap_soft_out, - clear_ip_bgp_as_encap_out_cmd, - "clear ip bgp " CMD_AS_RANGE " encap unicast out", - CLEAR_STR - IP_STR - BGP_STR - "Clear peers with the AS number\n" - "Address family\n" - "Address Family modifier\n" - "Soft reconfig outbound update\n") -#endif /* KEEP_OLD_VPNV4_COMMANDS */ - DEFUN (clear_bgp_as_soft_out, clear_bgp_as_soft_out_cmd, "clear bgp " CMD_AS_RANGE " soft out", @@ -7973,62 +7784,6 @@ DEFUN (clear_ip_bgp_all_ipv4_in_prefix_filter, BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL); } -#ifdef KEEP_OLD_VPNV4_COMMANDS -DEFUN (clear_ip_bgp_all_vpnv4_soft_in, - clear_ip_bgp_all_vpnv4_soft_in_cmd, - "clear ip bgp * vpnv4 unicast soft in", - CLEAR_STR - IP_STR - BGP_STR - "Clear all peers\n" - "Address family\n" - "Address Family Modifier\n" - BGP_SOFT_STR - BGP_SOFT_IN_STR) -{ - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all, - BGP_CLEAR_SOFT_IN, NULL); -} - -ALIAS (clear_ip_bgp_all_vpnv4_soft_in, - clear_ip_bgp_all_vpnv4_in_cmd, - "clear ip bgp * vpnv4 unicast in", - CLEAR_STR - IP_STR - BGP_STR - "Clear all peers\n" - "Address family\n" - "Address Family Modifier\n" - BGP_SOFT_IN_STR) - -DEFUN (clear_ip_bgp_all_encap_soft_in, - clear_ip_bgp_all_encap_soft_in_cmd, - "clear ip bgp * encap unicast soft in", - CLEAR_STR - IP_STR - BGP_STR - "Clear all peers\n" - "Address family\n" - "Address Family Modifier\n" - "Soft reconfig\n" - "Soft reconfig inbound update\n") -{ - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_all, - BGP_CLEAR_SOFT_IN, NULL); -} - -ALIAS (clear_ip_bgp_all_encap_soft_in, - clear_ip_bgp_all_encap_in_cmd, - "clear ip bgp * encap unicast in", - CLEAR_STR - IP_STR - BGP_STR - "Clear all peers\n" - "Address family\n" - "Address Family Modifier\n" - "Soft reconfig inbound update\n") -#endif /* KEEP_OLD_VPNV4_COMMANDS */ - DEFUN (clear_bgp_all_soft_in, clear_bgp_all_soft_in_cmd, "clear bgp * soft in", @@ -8286,64 +8041,6 @@ DEFUN (clear_ip_bgp_peer_ipv4_in_prefix_filter, BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]); } -#ifdef KEEP_OLD_VPNV4_COMMANDS -DEFUN (clear_ip_bgp_peer_vpnv4_soft_in, - clear_ip_bgp_peer_vpnv4_soft_in_cmd, - "clear ip bgp (A.B.C.D|WORD) vpnv4 unicast soft in", - CLEAR_STR - IP_STR - BGP_STR - "BGP neighbor address to clear\n" - "BGP neighbor on interface to clear\n" - "Address family\n" - "Address Family Modifier\n" - BGP_SOFT_STR - BGP_SOFT_IN_STR) -{ - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer, - BGP_CLEAR_SOFT_IN, argv[0]); -} - -ALIAS (clear_ip_bgp_peer_vpnv4_soft_in, - clear_ip_bgp_peer_vpnv4_in_cmd, - "clear ip bgp (A.B.C.D|WORD) vpnv4 unicast in", - CLEAR_STR - IP_STR - BGP_STR - "BGP neighbor address to clear\n" - "BGP neighbor on interface to clear\n" - "Address family\n" - "Address Family Modifier\n" - BGP_SOFT_IN_STR) - -DEFUN (clear_ip_bgp_peer_encap_soft_in, - clear_ip_bgp_peer_encap_soft_in_cmd, - "clear ip bgp A.B.C.D encap unicast soft in", - CLEAR_STR - IP_STR - BGP_STR - "BGP neighbor address to clear\n" - "Address family\n" - "Address Family Modifier\n" - "Soft reconfig\n" - "Soft reconfig inbound update\n") -{ - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_peer, - BGP_CLEAR_SOFT_IN, argv[0]); -} - -ALIAS (clear_ip_bgp_peer_encap_soft_in, - clear_ip_bgp_peer_encap_in_cmd, - "clear ip bgp A.B.C.D encap unicast in", - CLEAR_STR - IP_STR - BGP_STR - "BGP neighbor address to clear\n" - "Address family\n" - "Address Family Modifier\n" - "Soft reconfig inbound update\n") -#endif /* KEEP_OLD_VPNV4_COMMANDS */ - DEFUN (clear_bgp_peer_soft_in, clear_bgp_peer_soft_in_cmd, "clear bgp (A.B.C.D|X:X::X:X|WORD) soft in", @@ -9125,62 +8822,6 @@ DEFUN (clear_ip_bgp_as_ipv4_in_prefix_filter, BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]); } -#ifdef KEEP_OLD_VPNV4_COMMANDS -DEFUN (clear_ip_bgp_as_vpnv4_soft_in, - clear_ip_bgp_as_vpnv4_soft_in_cmd, - "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast soft in", - CLEAR_STR - IP_STR - BGP_STR - "Clear peers with the AS number\n" - "Address family\n" - "Address Family modifier\n" - BGP_SOFT_STR - BGP_SOFT_IN_STR) -{ - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as, - BGP_CLEAR_SOFT_IN, argv[0]); -} - -ALIAS (clear_ip_bgp_as_vpnv4_soft_in, - clear_ip_bgp_as_vpnv4_in_cmd, - "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast in", - CLEAR_STR - IP_STR - BGP_STR - "Clear peers with the AS number\n" - "Address family\n" - "Address Family modifier\n" - BGP_SOFT_IN_STR) - -DEFUN (clear_ip_bgp_as_encap_soft_in, - clear_ip_bgp_as_encap_soft_in_cmd, - "clear ip bgp " CMD_AS_RANGE " encap unicast soft in", - CLEAR_STR - IP_STR - BGP_STR - "Clear peers with the AS number\n" - "Address family\n" - "Address Family modifier\n" - "Soft reconfig\n" - "Soft reconfig inbound update\n") -{ - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_as, - BGP_CLEAR_SOFT_IN, argv[0]); -} - -ALIAS (clear_ip_bgp_as_encap_soft_in, - clear_ip_bgp_as_encap_in_cmd, - "clear ip bgp " CMD_AS_RANGE " encap unicast in", - CLEAR_STR - IP_STR - BGP_STR - "Clear peers with the AS number\n" - "Address family\n" - "Address Family modifier\n" - "Soft reconfig inbound update\n") -#endif /* KEEP_OLD_VPNV4_COMMANDS */ - DEFUN (clear_bgp_as_soft_in, clear_bgp_as_soft_in_cmd, "clear bgp " CMD_AS_RANGE " soft in", @@ -9354,38 +8995,6 @@ DEFUN (clear_ip_bgp_instance_all_ipv4_soft, BGP_CLEAR_SOFT_BOTH, NULL); } -#ifdef KEEP_OLD_VPNV4_COMMANDS -DEFUN (clear_ip_bgp_all_vpnv4_soft, - clear_ip_bgp_all_vpnv4_soft_cmd, - "clear ip bgp * vpnv4 unicast soft", - CLEAR_STR - IP_STR - BGP_STR - "Clear all peers\n" - "Address family\n" - "Address Family Modifier\n" - BGP_SOFT_STR) -{ - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all, - BGP_CLEAR_SOFT_BOTH, argv[0]); -} - -DEFUN (clear_ip_bgp_all_encap_soft, - clear_ip_bgp_all_encap_soft_cmd, - "clear ip bgp * encap unicast soft", - CLEAR_STR - IP_STR - BGP_STR - "Clear all peers\n" - "Address family\n" - "Address Family Modifier\n" - "Soft reconfig\n") -{ - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_all, - BGP_CLEAR_SOFT_BOTH, argv[0]); -} -#endif /* KEEP_OLD_VPNV4_COMMANDS */ - DEFUN (clear_bgp_all_soft, clear_bgp_all_soft_cmd, "clear bgp * soft", @@ -9498,39 +9107,6 @@ DEFUN (clear_ip_bgp_instance_peer_ipv4_soft, BGP_CLEAR_SOFT_BOTH, argv[2]); } -#ifdef KEEP_OLD_VPNV4_COMMANDS -DEFUN (clear_ip_bgp_peer_vpnv4_soft, - clear_ip_bgp_peer_vpnv4_soft_cmd, - "clear ip bgp (A.B.C.D|WORD) vpnv4 unicast soft", - CLEAR_STR - IP_STR - BGP_STR - "BGP neighbor address to clear\n" - "BGP neighbor on interface to clear\n" - "Address family\n" - "Address Family Modifier\n" - BGP_SOFT_STR) -{ - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer, - BGP_CLEAR_SOFT_BOTH, argv[0]); -} - -DEFUN (clear_ip_bgp_peer_encap_soft, - clear_ip_bgp_peer_encap_soft_cmd, - "clear ip bgp A.B.C.D encap unicast soft", - CLEAR_STR - IP_STR - BGP_STR - "BGP neighbor address to clear\n" - "Address family\n" - "Address Family Modifier\n" - "Soft reconfig\n") -{ - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_peer, - BGP_CLEAR_SOFT_BOTH, argv[0]); -} -#endif /* KEEP_OLD_VPNV4_COMMANDS */ - DEFUN (clear_bgp_peer_soft, clear_bgp_peer_soft_cmd, "clear bgp (A.B.C.D|X:X::X:X|WORD) soft", @@ -9867,38 +9443,6 @@ DEFUN (clear_ip_bgp_instance_as_ipv4_soft, BGP_CLEAR_SOFT_BOTH, argv[2]); } -#ifdef KEEP_OLD_VPNV4_COMMANDS -DEFUN (clear_ip_bgp_as_vpnv4_soft, - clear_ip_bgp_as_vpnv4_soft_cmd, - "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast soft", - CLEAR_STR - IP_STR - BGP_STR - "Clear peers with the AS number\n" - "Address family\n" - "Address Family Modifier\n" - BGP_SOFT_STR) -{ - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as, - BGP_CLEAR_SOFT_BOTH, argv[0]); -} - -DEFUN (clear_ip_bgp_as_encap_soft, - clear_ip_bgp_as_encap_soft_cmd, - "clear ip bgp " CMD_AS_RANGE " encap unicast soft", - CLEAR_STR - IP_STR - BGP_STR - "Clear peers with the AS number\n" - "Address family\n" - "Address Family Modifier\n" - "Soft reconfig\n") -{ - return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_as, - BGP_CLEAR_SOFT_BOTH, argv[0]); -} -#endif /* KEEP_OLD_VPNV4_COMMANDS */ - DEFUN (clear_bgp_as_soft, clear_bgp_as_soft_cmd, "clear bgp " CMD_AS_RANGE " soft", @@ -10805,49 +10349,6 @@ ALIAS (show_ip_bgp_instance_ipv4_summary, BGP_AFI_SAFI_HELP_STR "Summary of BGP neighbor status\n") -#ifdef KEEP_OLD_VPNV4_COMMANDS -DEFUN (show_ip_bgp_vpnv4_all_summary, - show_ip_bgp_vpnv4_all_summary_cmd, - "show ip bgp vpnv4 all summary {json}", - SHOW_STR - IP_STR - BGP_STR - "Display VPNv4 NLRI specific information\n" - "Display information about all VPNv4 NLRIs\n" - "Summary of BGP neighbor status\n" - "JavaScript Object Notation\n") -{ - u_char uj = use_json(argc, argv); - return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, uj); -} - -DEFUN (show_ip_bgp_vpnv4_rd_summary, - show_ip_bgp_vpnv4_rd_summary_cmd, - "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn summary {json}", - SHOW_STR - IP_STR - BGP_STR - "Display VPNv4 NLRI specific information\n" - "Display information for a route distinguisher\n" - "VPN Route Distinguisher\n" - "Summary of BGP neighbor status\n" - "JavaScript Object Notation\n") -{ - int ret; - struct prefix_rd prd; - u_char uj = use_json(argc, argv); - - ret = str2prefix_rd (argv[0], &prd); - if (! ret) - { - vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); - return CMD_WARNING; - } - - return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, uj); -} -#endif /* KEEP_OLD_VPNV4_COMMANDS */ - #ifdef HAVE_IPV6 DEFUN (show_bgp_summary, show_bgp_summary_cmd, @@ -12845,31 +12346,6 @@ ALIAS (show_ip_bgp_neighbors, "Detailed information on TCP and BGP neighbor connections\n" "JavaScript Object Notation\n") -#ifdef KEEP_OLD_VPNV4_COMMANDS -ALIAS (show_ip_bgp_neighbors, - show_ip_bgp_vpnv4_all_neighbors_cmd, - "show ip bgp vpnv4 all neighbors {json}", - SHOW_STR - IP_STR - BGP_STR - "Display VPNv4 NLRI specific information\n" - "Display information about all VPNv4 NLRIs\n" - "Detailed information on TCP and BGP neighbor connections\n" - "JavaScript Object Notation\n") - -ALIAS (show_ip_bgp_neighbors, - show_ip_bgp_vpnv4_rd_neighbors_cmd, - "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors {json}", - SHOW_STR - IP_STR - BGP_STR - "Display VPNv4 NLRI specific information\n" - "Display information for a route distinguisher\n" - "VPN Route Distinguisher\n" - "Detailed information on TCP and BGP neighbor connections\n" - "JavaScript Object Notation\n") -#endif /* KEEP_OLD_VPNV4_COMMANDS */ - ALIAS (show_ip_bgp_neighbors, show_bgp_neighbors_cmd, "show bgp neighbors {json}", @@ -12918,32 +12394,6 @@ ALIAS (show_ip_bgp_neighbors_peer, "Neighbor on bgp configured interface\n" "JavaScript Object Notation\n") -#ifdef KEEP_OLD_VPNV4_COMMANDS -ALIAS (show_ip_bgp_neighbors_peer, - show_ip_bgp_vpnv4_all_neighbors_peer_cmd, - "show ip bgp vpnv4 all neighbors A.B.C.D {json}", - SHOW_STR - IP_STR - BGP_STR - "Display VPNv4 NLRI specific information\n" - "Display information about all VPNv4 NLRIs\n" - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "JavaScript Object Notation\n") - -ALIAS (show_ip_bgp_neighbors_peer, - show_ip_bgp_vpnv4_rd_neighbors_peer_cmd, - "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors A.B.C.D {json}", - SHOW_STR - IP_STR - BGP_STR - "Display VPNv4 NLRI specific information\n" - "Display information about all VPNv4 NLRIs\n" - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "JavaScript Object Notation\n") -#endif /* KEEP_OLD_VPNV4_COMMANDS */ - ALIAS (show_ip_bgp_neighbors_peer, show_bgp_neighbors_peer_cmd, "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) {json}", @@ -15645,15 +15095,7 @@ bgp_vty_init (void) install_element (BGP_NODE, &address_family_ipv6_safi_cmd); #endif /* HAVE_IPV6 */ install_element (BGP_NODE, &address_family_vpnv4_cmd); -#ifdef KEEP_OLD_VPNV4_COMMANDS - install_element (BGP_NODE, &address_family_vpnv4_unicast_cmd); -#endif /* KEEP_OLD_VPNV4_COMMANDS */ - install_element (BGP_NODE, &address_family_vpnv6_cmd); -#ifdef KEEP_OLD_VPNV4_COMMANDS - install_element (BGP_NODE, &address_family_vpnv6_unicast_cmd); -#endif /* KEEP_OLD_VPNV4_COMMANDS */ - install_element (BGP_NODE, &address_family_encap_cmd); install_element (BGP_NODE, &address_family_encapv4_cmd); #ifdef HAVE_IPV6 @@ -15754,20 +15196,6 @@ bgp_vty_init (void) install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_in_cmd); install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_ipv4_in_cmd); install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_in_prefix_filter_cmd); -#ifdef KEEP_OLD_VPNV4_COMMANDS - install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_soft_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_all_encap_soft_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_all_encap_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_peer_encap_soft_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_peer_encap_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_as_encap_soft_in_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_as_encap_in_cmd); -#endif /* KEEP_OLD_VPNV4_COMMANDS */ install_element (ENABLE_NODE, &clear_bgp_all_soft_in_cmd); install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_in_cmd); install_element (ENABLE_NODE, &clear_bgp_all_in_cmd); @@ -15866,20 +15294,6 @@ bgp_vty_init (void) install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_ipv4_soft_out_cmd); install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_out_cmd); install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_ipv4_out_cmd); -#ifdef KEEP_OLD_VPNV4_COMMANDS - install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_soft_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_all_encap_soft_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_all_encap_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_peer_encap_soft_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_peer_encap_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_as_encap_soft_out_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_as_encap_out_cmd); -#endif /* KEEP_OLD_VPNV4_COMMANDS */ install_element (ENABLE_NODE, &clear_bgp_all_soft_out_cmd); install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_out_cmd); install_element (ENABLE_NODE, &clear_bgp_all_out_cmd); @@ -15942,14 +15356,6 @@ bgp_vty_init (void) install_element (ENABLE_NODE, &clear_ip_bgp_instance_external_ipv4_soft_cmd); install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_soft_cmd); install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_ipv4_soft_cmd); -#ifdef KEEP_OLD_VPNV4_COMMANDS - install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_soft_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_all_encap_soft_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_peer_encap_soft_cmd); - install_element (ENABLE_NODE, &clear_ip_bgp_as_encap_soft_cmd); -#endif /* KEEP_OLD_VPNV4_COMMANDS */ install_element (ENABLE_NODE, &clear_bgp_all_soft_cmd); install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_cmd); install_element (ENABLE_NODE, &clear_bgp_peer_soft_cmd); @@ -16001,10 +15407,6 @@ bgp_vty_init (void) install_element (VIEW_NODE, &show_bgp_ipv4_safi_summary_cmd); install_element (VIEW_NODE, &show_ip_bgp_instance_ipv4_summary_cmd); install_element (VIEW_NODE, &show_bgp_instance_ipv4_safi_summary_cmd); -#ifdef KEEP_OLD_VPNV4_COMMANDS - install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_summary_cmd); - install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_summary_cmd); -#endif /* KEEP_OLD_VPNV4_COMMANDS */ #ifdef HAVE_IPV6 install_element (VIEW_NODE, &show_bgp_summary_cmd); install_element (VIEW_NODE, &show_bgp_instance_summary_cmd); @@ -16020,12 +15422,6 @@ bgp_vty_init (void) install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbors_cmd); install_element (VIEW_NODE, &show_ip_bgp_neighbors_peer_cmd); install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbors_peer_cmd); -#ifdef KEEP_OLD_VPNV4_COMMANDS - install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_neighbors_cmd); - install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_neighbors_cmd); - install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_neighbors_peer_cmd); - install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_neighbors_peer_cmd); -#endif /* KEEP_OLD_VPNV4_COMMANDS */ install_element (VIEW_NODE, &show_ip_bgp_instance_neighbors_cmd); install_element (VIEW_NODE, &show_ip_bgp_instance_all_neighbors_cmd); install_element (VIEW_NODE, &show_ip_bgp_instance_neighbors_peer_cmd); From 912e52346f7f2f3b7289ddcae508414e56eb1111 Mon Sep 17 00:00:00 2001 From: Lou Berger Date: Thu, 12 Jan 2017 09:36:24 -0500 Subject: [PATCH 086/107] bgpd: convert 'show_ip_bgp_vpnv4' to afi/safi form (Issue #61) --- bgpd/bgp_mplsvpn.c | 274 +++++++++++++++++++++++---------------------- bgpd/bgp_route.c | 19 ++-- 2 files changed, 149 insertions(+), 144 deletions(-) diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c index 02febf8630..b710e0b03b 100644 --- a/bgpd/bgp_mplsvpn.c +++ b/bgpd/bgp_mplsvpn.c @@ -35,6 +35,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #include "bgpd/bgp_attr.h" #include "bgpd/bgp_mplsvpn.h" #include "bgpd/bgp_packet.h" +#include "bgpd/bgp_vty.h" #if ENABLE_BGP_VNC #include "bgpd/rfapi/rfapi_backend.h" @@ -484,9 +485,8 @@ DEFUN (no_vpnv4_network, return bgp_static_unset_safi (SAFI_MPLS_VPN, vty, argv[0], argv[1], argv[2]); } -#ifdef KEEP_OLD_VPNV4_COMMANDS static int -show_adj_route_vpn (struct vty *vty, struct peer *peer, struct prefix_rd *prd, u_char use_json) +show_adj_route_vpn (struct vty *vty, struct peer *peer, afi_t afi, struct prefix_rd *prd, u_char use_json) { struct bgp *bgp; struct bgp_table *table; @@ -529,7 +529,7 @@ show_adj_route_vpn (struct vty *vty, struct peer *peer, struct prefix_rd *prd, u json_object_string_add(json_ocode, "incomplete", "?"); } - for (rn = bgp_table_top (bgp->rib[AFI_IP][SAFI_MPLS_VPN]); rn; + for (rn = bgp_table_top (bgp->rib[afi][SAFI_MPLS_VPN]); rn; rn = bgp_route_next (rn)) { if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) @@ -651,7 +651,6 @@ show_adj_route_vpn (struct vty *vty, struct peer *peer, struct prefix_rd *prd, u } return CMD_SUCCESS; } -#endif /* KEEP_OLD_VPNV4_COMMANDS */ enum bgp_show_type { @@ -956,26 +955,25 @@ DEFUN (show_bgp_ipv6_vpn_rd, return bgp_show_mpls_vpn (vty, AFI_IP6, &prd, bgp_show_type_normal, NULL, 0, use_json (argc, argv)); } -#ifdef KEEP_OLD_VPNV4_COMMANDS -DEFUN (show_ip_bgp_vpnv4_all, - show_ip_bgp_vpnv4_all_cmd, - "show ip bgp vpnv4 all", +DEFUN (show_bgp_ip_vpn_all, + show_bgp_ip_vpn_all_cmd, + "show bgp "BGP_AFI_CMD_STR" vpn all", SHOW_STR IP_STR BGP_STR - "Display VPNv4 NLRI specific information\n" - "Display information about all VPNv4 NLRIs\n") + BGP_AFI_HELP_STR + "Display information about all VPN NLRIs\n") { - return bgp_show_mpls_vpn (vty, AFI_IP, NULL, bgp_show_type_normal, NULL, 0, 0); + return bgp_show_mpls_vpn (vty, bgp_vty_afi_from_arg(argv[0]), NULL, bgp_show_type_normal, NULL, 0, 0); } -DEFUN (show_ip_bgp_vpnv4_rd, - show_ip_bgp_vpnv4_rd_cmd, - "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn", +DEFUN (show_bgp_ip_vpn_rd, + show_bgp_ip_vpn_rd_cmd, + "show bgp "BGP_AFI_CMD_STR" vpn rd ASN:nn_or_IP-address:nn", SHOW_STR IP_STR BGP_STR - "Display VPNv4 NLRI specific information\n" + BGP_AFI_HELP_STR "Display information for a route distinguisher\n" "VPN Route Distinguisher\n") { @@ -988,29 +986,29 @@ DEFUN (show_ip_bgp_vpnv4_rd, vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); return CMD_WARNING; } - return bgp_show_mpls_vpn (vty, AFI_IP, &prd, bgp_show_type_normal, NULL, 0, 0); + return bgp_show_mpls_vpn (vty, bgp_vty_afi_from_arg(argv[0]), &prd, bgp_show_type_normal, NULL, 0, 0); } -DEFUN (show_ip_bgp_vpnv4_all_tags, - show_ip_bgp_vpnv4_all_tags_cmd, - "show ip bgp vpnv4 all tags", +DEFUN (show_bgp_ip_vpn_all_tags, + show_bgp_ip_vpn_all_tags_cmd, + "show bgp "BGP_AFI_CMD_STR" vpn all tags", SHOW_STR IP_STR BGP_STR - "Display VPNv4 NLRI specific information\n" + BGP_AFI_HELP_STR "Display information about all VPNv4 NLRIs\n" "Display BGP tags for prefixes\n") { - return bgp_show_mpls_vpn (vty, AFI_IP, NULL, bgp_show_type_normal, NULL, 1, 0); + return bgp_show_mpls_vpn (vty, bgp_vty_afi_from_arg(argv[0]), NULL, bgp_show_type_normal, NULL, 1, 0); } -DEFUN (show_ip_bgp_vpnv4_rd_tags, - show_ip_bgp_vpnv4_rd_tags_cmd, - "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn tags", +DEFUN (show_bgp_ip_vpn_rd_tags, + show_bgp_ip_vpn_rd_tags_cmd, + "show bgp "BGP_AFI_CMD_STR" vpn rd ASN:nn_or_IP-address:nn tags", SHOW_STR IP_STR BGP_STR - "Display VPNv4 NLRI specific information\n" + BGP_AFI_HELP_STR "Display information for a route distinguisher\n" "VPN Route Distinguisher\n" "Display BGP tags for prefixes\n") @@ -1018,103 +1016,34 @@ DEFUN (show_ip_bgp_vpnv4_rd_tags, int ret; struct prefix_rd prd; - ret = str2prefix_rd (argv[0], &prd); + ret = str2prefix_rd (argv[1], &prd); if (! ret) { vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); return CMD_WARNING; } - return bgp_show_mpls_vpn (vty, AFI_IP, &prd, bgp_show_type_normal, NULL, 1, 0); + return bgp_show_mpls_vpn (vty, bgp_vty_afi_from_arg(argv[0]), &prd, bgp_show_type_normal, NULL, 1, 0); } -DEFUN (show_ip_bgp_vpnv4_all_neighbor_routes, - show_ip_bgp_vpnv4_all_neighbor_routes_cmd, - "show ip bgp vpnv4 all neighbors A.B.C.D routes {json}", +DEFUN (show_bgp_ip_vpn_all_neighbor_routes, + show_bgp_ip_vpn_all_neighbor_routes_cmd, + "show bgp "BGP_AFI_CMD_STR" vpn all neighbors (A.B.C.D|X:X::X:X) routes {json}", SHOW_STR IP_STR BGP_STR - "Display VPNv4 NLRI specific information\n" + BGP_AFI_HELP_STR "Display information about all VPNv4 NLRIs\n" "Detailed information on TCP and BGP neighbor connections\n" "Neighbor to display information about\n" - "Display routes learned from neighbor\n" - "JavaScript Object Notation\n") -{ - union sockunion su; - struct peer *peer; - int ret; - u_char uj = use_json(argc, argv); - - ret = str2sockunion (argv[0], &su); - if (ret < 0) - { - if (uj) - { - json_object *json_no = NULL; - json_no = json_object_new_object(); - json_object_string_add(json_no, "warning", "Malformed address"); - vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); - json_object_free(json_no); - } - else - vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE); - return CMD_WARNING; - } - - peer = peer_lookup (NULL, &su); - if (! peer || ! peer->afc[AFI_IP][SAFI_MPLS_VPN]) - { - if (uj) - { - json_object *json_no = NULL; - json_no = json_object_new_object(); - json_object_string_add(json_no, "warning", "No such neighbor or address family"); - vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); - json_object_free(json_no); - } - else - vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); - return CMD_WARNING; - } - - return bgp_show_mpls_vpn (vty, AFI_IP, NULL, bgp_show_type_neighbor, &su, 0, uj); -} - -DEFUN (show_ip_bgp_vpnv4_rd_neighbor_routes, - show_ip_bgp_vpnv4_rd_neighbor_routes_cmd, - "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors A.B.C.D routes {json}", - SHOW_STR - IP_STR - BGP_STR - "Display VPNv4 NLRI specific information\n" - "Display information for a route distinguisher\n" - "VPN Route Distinguisher\n" - "Detailed information on TCP and BGP neighbor connections\n" "Neighbor to display information about\n" "Display routes learned from neighbor\n" "JavaScript Object Notation\n") { - int ret; union sockunion su; struct peer *peer; - struct prefix_rd prd; + int ret; u_char uj = use_json(argc, argv); - - ret = str2prefix_rd (argv[0], &prd); - if (! ret) - { - if (uj) - { - json_object *json_no = NULL; - json_no = json_object_new_object(); - json_object_string_add(json_no, "warning", "Malformed Route Distinguisher"); - vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); - json_object_free(json_no); - } - else - vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); - return CMD_WARNING; - } + afi_t afi = bgp_vty_afi_from_arg(argv[0]); ret = str2sockunion (argv[1], &su); if (ret < 0) @@ -1133,7 +1062,7 @@ DEFUN (show_ip_bgp_vpnv4_rd_neighbor_routes, } peer = peer_lookup (NULL, &su); - if (! peer || ! peer->afc[AFI_IP][SAFI_MPLS_VPN]) + if (! peer || ! peer->afc[afi][SAFI_MPLS_VPN]) { if (uj) { @@ -1148,28 +1077,48 @@ DEFUN (show_ip_bgp_vpnv4_rd_neighbor_routes, return CMD_WARNING; } - return bgp_show_mpls_vpn (vty, AFI_IP, &prd, bgp_show_type_neighbor, &su, 0, uj); + return bgp_show_mpls_vpn (vty, afi, NULL, bgp_show_type_neighbor, &su, 0, uj); } -DEFUN (show_ip_bgp_vpnv4_all_neighbor_advertised_routes, - show_ip_bgp_vpnv4_all_neighbor_advertised_routes_cmd, - "show ip bgp vpnv4 all neighbors A.B.C.D advertised-routes {json}", +DEFUN (show_bgp_ip_vpn_rd_neighbor_routes, + show_bgp_ip_vpn_rd_neighbor_routes_cmd, + "show bgp "BGP_AFI_CMD_STR" vpn rd ASN:nn_or_IP-address:nn neighbors (A.B.C.D|X:X::X:X) routes {json}", SHOW_STR IP_STR BGP_STR - "Display VPNv4 NLRI specific information\n" - "Display information about all VPNv4 NLRIs\n" + BGP_AFI_HELP_STR + "Display information for a route distinguisher\n" + "VPN Route Distinguisher\n" "Detailed information on TCP and BGP neighbor connections\n" "Neighbor to display information about\n" - "Display the routes advertised to a BGP neighbor\n" + "Neighbor to display information about\n" + "Display routes learned from neighbor\n" "JavaScript Object Notation\n") { int ret; - struct peer *peer; union sockunion su; + struct peer *peer; + struct prefix_rd prd; u_char uj = use_json(argc, argv); + afi_t afi = bgp_vty_afi_from_arg(argv[0]); - ret = str2sockunion (argv[0], &su); + ret = str2prefix_rd (argv[1], &prd); + if (! ret) + { + if (uj) + { + json_object *json_no = NULL; + json_no = json_object_new_object(); + json_object_string_add(json_no, "warning", "Malformed Route Distinguisher"); + vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); + json_object_free(json_no); + } + else + vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); + return CMD_WARNING; + } + + ret = str2sockunion (argv[2], &su); if (ret < 0) { if (uj) @@ -1184,8 +1133,9 @@ DEFUN (show_ip_bgp_vpnv4_all_neighbor_advertised_routes, vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE); return CMD_WARNING; } + peer = peer_lookup (NULL, &su); - if (! peer || ! peer->afc[AFI_IP][SAFI_MPLS_VPN]) + if (! peer || ! peer->afc[afi][SAFI_MPLS_VPN]) { if (uj) { @@ -1200,28 +1150,28 @@ DEFUN (show_ip_bgp_vpnv4_all_neighbor_advertised_routes, return CMD_WARNING; } - return show_adj_route_vpn (vty, peer, NULL, uj); + return bgp_show_mpls_vpn (vty, afi, &prd, bgp_show_type_neighbor, &su, 0, uj); } -DEFUN (show_ip_bgp_vpnv4_rd_neighbor_advertised_routes, - show_ip_bgp_vpnv4_rd_neighbor_advertised_routes_cmd, - "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors A.B.C.D advertised-routes {json}", +DEFUN (show_bgp_ip_vpn_all_neighbor_advertised_routes, + show_bgp_ip_vpn_all_neighbor_advertised_routes_cmd, + "show bgp "BGP_AFI_CMD_STR" vpn all neighbors (A.B.C.D|X:X::X:X) advertised-routes {json}", SHOW_STR IP_STR BGP_STR - "Display VPNv4 NLRI specific information\n" - "Display information for a route distinguisher\n" - "VPN Route Distinguisher\n" + BGP_AFI_HELP_STR + "Display information about all VPN NLRIs\n" "Detailed information on TCP and BGP neighbor connections\n" "Neighbor to display information about\n" + "Neighbor to display information about\n" "Display the routes advertised to a BGP neighbor\n" "JavaScript Object Notation\n") { int ret; struct peer *peer; - struct prefix_rd prd; union sockunion su; u_char uj = use_json(argc, argv); + afi_t afi = bgp_vty_afi_from_arg(argv[0]); ret = str2sockunion (argv[1], &su); if (ret < 0) @@ -1239,7 +1189,7 @@ DEFUN (show_ip_bgp_vpnv4_rd_neighbor_advertised_routes, return CMD_WARNING; } peer = peer_lookup (NULL, &su); - if (! peer || ! peer->afc[AFI_IP][SAFI_MPLS_VPN]) + if (! peer || ! peer->afc[afi][SAFI_MPLS_VPN]) { if (uj) { @@ -1254,7 +1204,63 @@ DEFUN (show_ip_bgp_vpnv4_rd_neighbor_advertised_routes, return CMD_WARNING; } - ret = str2prefix_rd (argv[0], &prd); + return show_adj_route_vpn (vty, peer, afi, NULL, uj); +} + +DEFUN (show_bgp_ip_vpn_rd_neighbor_advertised_routes, + show_bgp_ip_vpn_rd_neighbor_advertised_routes_cmd, + "show bgp "BGP_AFI_CMD_STR" vpn rd ASN:nn_or_IP-address:nn neighbors (A.B.C.D|X:X::X:X) advertised-routes {json}", + SHOW_STR + IP_STR + BGP_STR + BGP_AFI_HELP_STR + "Display information for a route distinguisher\n" + "VPN Route Distinguisher\n" + "Detailed information on TCP and BGP neighbor connections\n" + "Neighbor to display information about\n" + "Neighbor to display information about\n" + "Display the routes advertised to a BGP neighbor\n" + "JavaScript Object Notation\n") +{ + int ret; + struct peer *peer; + struct prefix_rd prd; + union sockunion su; + u_char uj = use_json(argc, argv); + afi_t afi = bgp_vty_afi_from_arg(argv[0]); + + ret = str2sockunion (argv[2], &su); + if (ret < 0) + { + if (uj) + { + json_object *json_no = NULL; + json_no = json_object_new_object(); + json_object_string_add(json_no, "warning", "Malformed address"); + vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); + json_object_free(json_no); + } + else + vty_out (vty, "Malformed address: %s%s", argv[2], VTY_NEWLINE); + return CMD_WARNING; + } + peer = peer_lookup (NULL, &su); + if (! peer || ! peer->afc[afi][SAFI_MPLS_VPN]) + { + if (uj) + { + json_object *json_no = NULL; + json_no = json_object_new_object(); + json_object_string_add(json_no, "warning", "No such neighbor or address family"); + vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); + json_object_free(json_no); + } + else + vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); + return CMD_WARNING; + } + + ret = str2prefix_rd (argv[1], &prd); if (! ret) { if (uj) @@ -1270,9 +1276,8 @@ DEFUN (show_ip_bgp_vpnv4_rd_neighbor_advertised_routes, return CMD_WARNING; } - return show_adj_route_vpn (vty, peer, &prd, uj); + return show_adj_route_vpn (vty, peer, afi, &prd, uj); } -#endif /* KEEP_OLD_VPNV4_COMMANDS */ void bgp_mplsvpn_init (void) @@ -1285,15 +1290,12 @@ bgp_mplsvpn_init (void) install_element (VIEW_NODE, &show_bgp_ipv4_vpn_rd_cmd); install_element (VIEW_NODE, &show_bgp_ipv6_vpn_cmd); install_element (VIEW_NODE, &show_bgp_ipv6_vpn_rd_cmd); -#ifdef KEEP_OLD_VPNV4_COMMANDS - install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_cmd); - install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_cmd); - install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_tags_cmd); - install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_tags_cmd); - install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_neighbor_routes_cmd); - install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_neighbor_routes_cmd); - install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_neighbor_advertised_routes_cmd); - install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_neighbor_advertised_routes_cmd); -#endif /* KEEP_OLD_VPNV4_COMMANDS */ - + install_element (VIEW_NODE, &show_bgp_ip_vpn_all_cmd); + install_element (VIEW_NODE, &show_bgp_ip_vpn_rd_cmd); + install_element (VIEW_NODE, &show_bgp_ip_vpn_all_tags_cmd); + install_element (VIEW_NODE, &show_bgp_ip_vpn_rd_tags_cmd); + install_element (VIEW_NODE, &show_bgp_ip_vpn_all_neighbor_routes_cmd); + install_element (VIEW_NODE, &show_bgp_ip_vpn_rd_neighbor_routes_cmd); + install_element (VIEW_NODE, &show_bgp_ip_vpn_all_neighbor_advertised_routes_cmd); + install_element (VIEW_NODE, &show_bgp_ip_vpn_rd_neighbor_advertised_routes_cmd); } diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 7d423be631..9e1ae854d4 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -6416,7 +6416,8 @@ route_vty_out_tmp (struct vty *vty, struct prefix *p, struct attr *attr, safi_t safi == SAFI_ENCAP || !BGP_ATTR_NEXTHOP_AFI_IP6(attr))) { - if (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP) + if (attr->extra && + (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP)) vty_out (vty, "%-16s", inet_ntoa (attr->extra->mp_nexthop_global_in)); else @@ -6427,13 +6428,15 @@ route_vty_out_tmp (struct vty *vty, struct prefix *p, struct attr *attr, safi_t { int len; char buf[BUFSIZ]; - - assert (attr->extra); - - len = vty_out (vty, "%s", - inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, - buf, BUFSIZ)); - len = 16 - len; + if (attr->extra) + { + len = vty_out (vty, "%s", + inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, + buf, BUFSIZ)); + len = 16 - len; + } + else + len = 0; if (len < 1) vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); else From 903c7f556e6631e5f20f2d720e35ce39ffb599eb Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Thu, 12 Jan 2017 13:10:48 -0500 Subject: [PATCH 087/107] apply rename to readme.md --- README | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README b/README index 4476947490..95aa5eb248 100644 --- a/README +++ b/README @@ -1,9 +1,9 @@ -Quagga is free software that manages various IPv4 and IPv6 routing +Free Range Routing is free software that manages various IPv4 and IPv6 routing protocols. -Currently Quagga supports BGP4, BGP4+, OSPFv2, OSPFv3, RIPv1, +Currently Free Range Routing supports BGP4, BGP4+, OSPFv2, OSPFv3, RIPv1, RIPv2, RIPng, PIM-SSM and LDP as well as very early support for IS-IS. See the file REPORTING-BUGS to report bugs. -Quagga is free software. See the file COPYING for copying conditions. +Free Range Routing is free software. See the file COPYING for copying conditions. From 2f9a659926f5d91683f740bd527c4e9fe1cdda5c Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Fri, 13 Jan 2017 11:23:18 +0100 Subject: [PATCH 088/107] tests: ignore stderr for expect expect redirects both stdout and stderr to its input. This causes serious problems when libzebra prints log messages to stderr, which are then asynchronously inserted in the middle of lines of stdout test output. Ultimately this makes testbgpmpattr fail on FreeBSD. (The stdio buffering seems to be slightly different on FreeBSD, triggering the bug.) Just ignore stderr for expect. Signed-off-by: David Lamparter --- tests/bgpd.tests/aspathtest.exp | 2 +- tests/bgpd.tests/ecommtest.exp | 2 +- tests/bgpd.tests/testbgpcap.exp | 2 +- tests/bgpd.tests/testbgpmpath.exp | 2 +- tests/bgpd.tests/testbgpmpattr.exp | 2 +- tests/libzebra.tests/tabletest.exp | 2 +- tests/libzebra.tests/test-timer-correctness.exp | 2 +- tests/libzebra.tests/testnexthopiter.exp | 2 +- tests/libzebra.tests/teststream.exp | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/bgpd.tests/aspathtest.exp b/tests/bgpd.tests/aspathtest.exp index dfecec7801..f5f262f80a 100644 --- a/tests/bgpd.tests/aspathtest.exp +++ b/tests/bgpd.tests/aspathtest.exp @@ -3,7 +3,7 @@ set testprefix "aspathtest " set aborted 0 set color 1 -spawn "./aspathtest" +spawn sh -c "exec ./aspathtest 2>/dev/null" # proc onetest { test_name note start } { # proc headerline { line } { diff --git a/tests/bgpd.tests/ecommtest.exp b/tests/bgpd.tests/ecommtest.exp index 074952fab8..cbeb03af52 100644 --- a/tests/bgpd.tests/ecommtest.exp +++ b/tests/bgpd.tests/ecommtest.exp @@ -3,7 +3,7 @@ set testprefix "ecommtest " set aborted 0 set color 0 -spawn "./ecommtest" +spawn sh -c "exec ./ecommtest 2>/dev/null" # proc simpletest { start } { diff --git a/tests/bgpd.tests/testbgpcap.exp b/tests/bgpd.tests/testbgpcap.exp index 2572623f06..aba6906bc0 100644 --- a/tests/bgpd.tests/testbgpcap.exp +++ b/tests/bgpd.tests/testbgpcap.exp @@ -3,7 +3,7 @@ set testprefix "testbgpcap " set aborted 0 set color 1 -spawn "./testbgpcap" +spawn sh -c "exec ./testbgpcap 2>/dev/null" # proc simpletest { start } { diff --git a/tests/bgpd.tests/testbgpmpath.exp b/tests/bgpd.tests/testbgpmpath.exp index 96a51e390c..6820f636a4 100644 --- a/tests/bgpd.tests/testbgpmpath.exp +++ b/tests/bgpd.tests/testbgpmpath.exp @@ -3,7 +3,7 @@ set testprefix "testbgpmpath " set aborted 0 set color 1 -spawn "./testbgpmpath" +spawn sh -c "exec ./testbgpmpath 2>/dev/null" # proc simpletest { start } { diff --git a/tests/bgpd.tests/testbgpmpattr.exp b/tests/bgpd.tests/testbgpmpattr.exp index e6d7305a68..1abce3fc9a 100644 --- a/tests/bgpd.tests/testbgpmpattr.exp +++ b/tests/bgpd.tests/testbgpmpattr.exp @@ -3,7 +3,7 @@ set testprefix "testbgpmpattr " set aborted 0 set color 1 -spawn "./testbgpmpattr" +spawn sh -c "exec ./testbgpmpattr 2>/dev/null" # proc simpletest { start } { diff --git a/tests/libzebra.tests/tabletest.exp b/tests/libzebra.tests/tabletest.exp index 5838d4fc7c..7496994b7f 100644 --- a/tests/libzebra.tests/tabletest.exp +++ b/tests/libzebra.tests/tabletest.exp @@ -2,7 +2,7 @@ set timeout 10 set testprefix "tabletest " set aborted 0 -spawn "./tabletest" +spawn sh -c "exec ./tabletest 2>/dev/null" for {set i 0} {$i < 6} {incr i 1} { onesimple "cmp $i" "Verifying cmp"; } for {set i 0} {$i < 11} {incr i 1} { onesimple "succ $i" "Verifying successor"; } diff --git a/tests/libzebra.tests/test-timer-correctness.exp b/tests/libzebra.tests/test-timer-correctness.exp index 83531c7df8..570150cd51 100644 --- a/tests/libzebra.tests/test-timer-correctness.exp +++ b/tests/libzebra.tests/test-timer-correctness.exp @@ -2,6 +2,6 @@ set timeout 10 set testprefix "test-timer-correctness" set aborted 0 -spawn "./test-timer-correctness" +spawn sh -c "exec ./test-timer-correctness 2>/dev/null" onesimple "" "Expected output and actual output match." diff --git a/tests/libzebra.tests/testnexthopiter.exp b/tests/libzebra.tests/testnexthopiter.exp index be35a0a2b8..777b753995 100644 --- a/tests/libzebra.tests/testnexthopiter.exp +++ b/tests/libzebra.tests/testnexthopiter.exp @@ -2,7 +2,7 @@ set timeout 10 set testprefix "testnexthopiter " set aborted 0 -spawn "./testnexthopiter" +spawn sh -c "exec ./testnexthopiter 2>/dev/null" onesimple "simple" "Simple test passed." onesimple "prng" "PRNG test passed." diff --git a/tests/libzebra.tests/teststream.exp b/tests/libzebra.tests/teststream.exp index ca602e305b..c977bb4417 100644 --- a/tests/libzebra.tests/teststream.exp +++ b/tests/libzebra.tests/teststream.exp @@ -1,5 +1,5 @@ set timeout 10 -spawn "./teststream" +spawn sh -c "exec ./teststream 2>/dev/null" expect { "endp: 15, readable: 15, writeable: 1009" { } From 9d8927ee1f97a2d52bb80f1494666e46c2f0edf3 Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Fri, 16 Dec 2016 00:09:46 +0100 Subject: [PATCH 089/107] tests: fix exit <> return mix-up in dejagnu exit 0 exits the entire testrunner... Oops. Also, "unresolved" breaks too many things, so make this a pass. Signed-off-by: David Lamparter [cherry-picked from master e988dfd35b0d9df437ac043a613472437c8842e6] --- tests/libzebra.tests/testcommands.exp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/libzebra.tests/testcommands.exp b/tests/libzebra.tests/testcommands.exp index d4bfc8231f..c5d5a00730 100644 --- a/tests/libzebra.tests/testcommands.exp +++ b/tests/libzebra.tests/testcommands.exp @@ -5,8 +5,8 @@ if {![info exists env(QUAGGA_TEST_COMMANDS)]} { # sadly, the test randomly fails when configure parameters differ from # what was used to create testcommands.refout. this can be fixed by # shipping a matching vtysh_cmd.c, which we'll add after 0.99.23 - unresolved "$test_name" - exit 0 + pass "$test_name" + return 0 } spawn sh -c "./testcommands -e 0 < $env(srcdir)/testcommands.in | diff -au - $env(srcdir)/testcommands.refout" From 81f28d26247891ffe348b195911472ea65d8ea83 Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Fri, 16 Dec 2016 00:14:55 +0100 Subject: [PATCH 090/107] tests: fix mis-fixed format string PRIu64 is "u", we need "x", so PRIx64... Signed-off-by: David Lamparter Cc: Donald Sharp [cherry-picked from master eed831e065694b3746896b126f6ad47548ea9dc0] --- tests/test-stream.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test-stream.c b/tests/test-stream.c index 7ef6374756..3ac45eb203 100644 --- a/tests/test-stream.c +++ b/tests/test-stream.c @@ -70,7 +70,7 @@ main (void) printf ("c: 0x%hhx\n", stream_getc (s)); printf ("w: 0x%hx\n", stream_getw (s)); printf ("l: 0x%x\n", stream_getl (s)); - printf ("q: 0x%" PRIu64 "\n", stream_getq (s)); + printf ("q: 0x%" PRIx64 "\n", stream_getq (s)); return 0; } From 56c1f7d852de98aa5d752f9c7777ece660c26fdb Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 13 Jan 2017 07:57:57 -0500 Subject: [PATCH 091/107] frr: Remove HAVE_IPV6 from code base Signed-off-by: Donald Sharp --- bgpd/bgp_attr.c | 20 +-------- bgpd/bgp_bfd.c | 4 -- bgpd/bgp_debug.c | 2 - bgpd/bgp_encap.c | 26 ++++-------- bgpd/bgp_mpath.c | 6 --- bgpd/bgp_network.c | 51 ----------------------- bgpd/bgp_nexthop.c | 4 -- bgpd/bgp_nht.c | 4 -- bgpd/bgp_route.c | 26 ------------ bgpd/bgp_routemap.c | 7 ---- bgpd/bgp_table.h | 4 -- bgpd/bgp_updgrp_adv.c | 4 -- bgpd/bgp_updgrp_packet.c | 4 -- bgpd/bgp_vty.c | 18 -------- bgpd/bgp_zebra.c | 15 +------ bgpd/bgp_zebra.h | 2 - bgpd/bgpd.h | 2 - configure.ac | 3 -- isisd/isis_adjacency.c | 10 ----- isisd/isis_adjacency.h | 2 - isisd/isis_circuit.c | 12 ------ isisd/isis_circuit.h | 2 - isisd/isis_lsp.c | 26 +----------- isisd/isis_pdu.c | 22 ---------- isisd/isis_route.c | 23 ---------- isisd/isis_route.h | 4 -- isisd/isis_spf.c | 42 ------------------- isisd/isis_spf.h | 7 +--- isisd/isis_tlv.c | 8 ---- isisd/isis_tlv.h | 6 --- isisd/isis_zebra.c | 13 ------ isisd/isisd.c | 20 --------- isisd/isisd.h | 6 --- lib/bfd.c | 6 --- lib/filter.c | 21 ---------- lib/if.c | 2 - lib/plist.c | 14 ------- lib/prefix.c | 29 ------------- lib/prefix.h | 7 ---- lib/smux.c | 42 ------------------- lib/sockopt.c | 8 ---- lib/sockopt.h | 7 ---- lib/sockunion.c | 43 ------------------- lib/sockunion.h | 4 -- lib/table.c | 2 - lib/table.h | 2 - lib/vty.c | 88 +-------------------------------------- lib/zclient.c | 2 - lib/zclient.h | 2 - vtysh/extract.pl.in | 2 +- zebra/client_main.c | 2 - zebra/connected.c | 4 -- zebra/connected.h | 3 -- zebra/if_ioctl.c | 6 +-- zebra/if_ioctl_solaris.c | 11 ----- zebra/if_netlink.c | 9 +--- zebra/interface.c | 8 ---- zebra/ioctl.c | 6 --- zebra/ioctl.h | 2 - zebra/ioctl_solaris.c | 8 ---- zebra/ipforward.h | 2 - zebra/ipforward_proc.c | 7 ++-- zebra/ipforward_solaris.c | 2 - zebra/ipforward_sysctl.c | 3 -- zebra/kernel_socket.c | 14 +------ zebra/redistribute.c | 2 - zebra/rt_netlink.c | 2 - zebra/rtadv.c | 4 +- zebra/zebra_fpm_netlink.c | 13 +++--- zebra/zebra_ptm.c | 24 ++--------- zebra/zebra_rnh.c | 2 - zebra/zebra_routemap.c | 7 +--- zebra/zserv.c | 7 ---- 73 files changed, 34 insertions(+), 800 deletions(-) diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c index 534a0323c4..0e03392faf 100644 --- a/bgpd/bgp_attr.c +++ b/bgpd/bgp_attr.c @@ -682,11 +682,9 @@ attrhash_key_make (void *p) if (extra->vnc_subtlvs) MIX(encap_hash_key_make (extra->vnc_subtlvs)); #endif -#ifdef HAVE_IPV6 MIX(extra->mp_nexthop_len); key = jhash(extra->mp_nexthop_global.s6_addr, IPV6_MAX_BYTELEN, key); key = jhash(extra->mp_nexthop_local.s6_addr, IPV6_MAX_BYTELEN, key); -#endif /* HAVE_IPV6 */ } return key; @@ -715,11 +713,9 @@ attrhash_cmp (const void *p1, const void *p2) && ae1->aggregator_addr.s_addr == ae2->aggregator_addr.s_addr && ae1->weight == ae2->weight && ae1->tag == ae2->tag -#ifdef HAVE_IPV6 && ae1->mp_nexthop_len == ae2->mp_nexthop_len && IPV6_ADDR_SAME (&ae1->mp_nexthop_global, &ae2->mp_nexthop_global) && IPV6_ADDR_SAME (&ae1->mp_nexthop_local, &ae2->mp_nexthop_local) -#endif /* HAVE_IPV6 */ && IPV4_ADDR_SAME (&ae1->mp_nexthop_global_in, &ae2->mp_nexthop_global_in) && ae1->ecommunity == ae2->ecommunity && ae1->cluster == ae2->cluster @@ -935,9 +931,7 @@ bgp_attr_default_set (struct attr *attr, u_char origin) attr->extra->weight = BGP_ATTR_DEFAULT_WEIGHT; attr->extra->tag = 0; attr->flag |= ATTR_FLAG_BIT (BGP_ATTR_NEXT_HOP); -#ifdef HAVE_IPV6 attr->extra->mp_nexthop_len = IPV6_MAX_BYTELEN; -#endif return attr; } @@ -998,9 +992,7 @@ bgp_attr_aggregate_intern (struct bgp *bgp, u_char origin, } attre.weight = BGP_ATTR_DEFAULT_WEIGHT; -#ifdef HAVE_IPV6 attre.mp_nexthop_len = IPV6_MAX_BYTELEN; -#endif if (! as_set || atomic_aggregate) attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_ATOMIC_AGGREGATE); attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_AGGREGATOR); @@ -1909,7 +1901,6 @@ bgp_mp_reach_parse (struct bgp_attr_parser_args *args, stream_getl (s); /* RD low */ stream_get (&attre->mp_nexthop_global_in, s, IPV4_MAX_BYTELEN); break; -#ifdef HAVE_IPV6 case BGP_ATTR_NHLEN_IPV6_GLOBAL: case BGP_ATTR_NHLEN_VPNV6_GLOBAL: if (attre->mp_nexthop_len == BGP_ATTR_NHLEN_VPNV6_GLOBAL) @@ -1949,7 +1940,6 @@ bgp_mp_reach_parse (struct bgp_attr_parser_args *args, attre->mp_nexthop_len = IPV6_MAX_BYTELEN; } break; -#endif /* HAVE_IPV6 */ default: zlog_info ("%s: (%s) Wrong multiprotocol next hop length: %d", __func__, peer->host, attre->mp_nexthop_len); @@ -2671,7 +2661,6 @@ bgp_packet_mpattr_start (struct stream *s, afi_t afi, safi_t safi, afi_t nh_afi, break; } break; -#ifdef HAVE_IPV6 case AFI_IP6: switch (safi) { @@ -2718,7 +2707,6 @@ bgp_packet_mpattr_start (struct stream *s, afi_t afi, safi_t safi, afi_t nh_afi, break; } break; -#endif /*HAVE_IPV6*/ default: break; } @@ -3361,11 +3349,7 @@ bgp_dump_routes_attr (struct stream *s, struct attr *attr, /* Nexthop attribute. */ /* If it's an IPv6 prefix, don't dump the IPv4 nexthop to save space */ - if(prefix != NULL -#ifdef HAVE_IPV6 - && prefix->family != AF_INET6 -#endif /* HAVE_IPV6 */ - ) + if(prefix != NULL && prefix->family != AF_INET6) { stream_putc (s, BGP_ATTR_FLAG_TRANS); stream_putc (s, BGP_ATTR_NEXT_HOP); @@ -3428,7 +3412,6 @@ bgp_dump_routes_attr (struct stream *s, struct attr *attr, stream_put (s, attr->community->val, attr->community->size * 4); } -#ifdef HAVE_IPV6 /* Add a MP_NLRI attribute to dump the IPv6 next hop */ if (prefix != NULL && prefix->family == AF_INET6 && attr->extra && (attr->extra->mp_nexthop_len == BGP_ATTR_NHLEN_IPV6_GLOBAL || @@ -3461,7 +3444,6 @@ bgp_dump_routes_attr (struct stream *s, struct attr *attr, /* Set MP attribute length. */ stream_putc_at (s, sizep, (stream_get_endp (s) - sizep) - 1); } -#endif /* HAVE_IPV6 */ /* Return total size of attribute. */ len = stream_get_endp (s) - cp - 2; diff --git a/bgpd/bgp_bfd.c b/bgpd/bgp_bfd.c index f2393dedd9..7892005f08 100644 --- a/bgpd/bgp_bfd.c +++ b/bgpd/bgp_bfd.c @@ -339,7 +339,6 @@ bgp_bfd_dest_update (int command, struct zclient *zclient, if (dp.u.prefix4.s_addr != peer->su.sin.sin_addr.s_addr) continue; } -#ifdef HAVE_IPV6 else if ((dp.family == AF_INET6) && (peer->su.sa.sa_family == AF_INET6)) { @@ -347,7 +346,6 @@ bgp_bfd_dest_update (int command, struct zclient *zclient, sizeof (struct in6_addr))) continue; } -#endif else continue; @@ -366,7 +364,6 @@ bgp_bfd_dest_update (int command, struct zclient *zclient, if (sp.u.prefix4.s_addr != peer->su_local->sin.sin_addr.s_addr) continue; } -#ifdef HAVE_IPV6 else if ((sp.family == AF_INET6) && (peer->su_local->sa.sa_family == AF_INET6)) { @@ -374,7 +371,6 @@ bgp_bfd_dest_update (int command, struct zclient *zclient, sizeof (struct in6_addr))) continue; } -#endif else continue; diff --git a/bgpd/bgp_debug.c b/bgpd/bgp_debug.c index de175de5a0..ab05878210 100644 --- a/bgpd/bgp_debug.c +++ b/bgpd/bgp_debug.c @@ -392,7 +392,6 @@ bgp_dump_attr (struct peer *peer, struct attr *attr, char *buf, size_t size) snprintf (buf + strlen (buf), size - strlen (buf), ", origin %s", bgp_origin_str[attr->origin]); -#ifdef HAVE_IPV6 if (attr->extra) { char addrbuf[BUFSIZ]; @@ -409,7 +408,6 @@ bgp_dump_attr (struct peer *peer, struct attr *attr, char *buf, size_t size) inet_ntop (AF_INET6, &attr->extra->mp_nexthop_local, addrbuf, BUFSIZ)); } -#endif /* HAVE_IPV6 */ if (CHECK_FLAG (attr->flag, ATTR_FLAG_BIT (BGP_ATTR_LOCAL_PREF))) snprintf (buf + strlen (buf), size - strlen (buf), ", localpref %u", diff --git a/bgpd/bgp_encap.c b/bgpd/bgp_encap.c index 37e9166388..75a348e3fe 100644 --- a/bgpd/bgp_encap.c +++ b/bgpd/bgp_encap.c @@ -484,7 +484,7 @@ DEFUN (show_bgp_ipv4_encap, { return bgp_show_encap (vty, AFI_IP, NULL, bgp_show_type_normal, NULL, 0); } -#ifdef HAVE_IPV6 + DEFUN (show_bgp_ipv6_encap, show_bgp_ipv6_encap_cmd, "show [ip] bgp ipv6 encap", @@ -496,7 +496,6 @@ DEFUN (show_bgp_ipv6_encap, { return bgp_show_encap (vty, AFI_IP6, NULL, bgp_show_type_normal, NULL, 0); } -#endif DEFUN (show_bgp_ipv4_encap_rd, show_bgp_ipv4_encap_rd_cmd, @@ -521,7 +520,7 @@ DEFUN (show_bgp_ipv4_encap_rd, } return bgp_show_encap (vty, AFI_IP, &prd, bgp_show_type_normal, NULL, 0); } -#ifdef HAVE_IPV6 + DEFUN (show_bgp_ipv6_encap_rd, show_bgp_ipv6_encap_rd_cmd, "show [ip] bgp ipv6 encap rd ASN:nn_or_IP-address:nn", @@ -546,7 +545,6 @@ DEFUN (show_bgp_ipv6_encap_rd, } return bgp_show_encap (vty, AFI_IP6, &prd, bgp_show_type_normal, NULL, 0); } -#endif DEFUN (show_bgp_ipv4_encap_tags, show_bgp_ipv4_encap_tags_cmd, @@ -560,7 +558,7 @@ DEFUN (show_bgp_ipv4_encap_tags, { return bgp_show_encap (vty, AFI_IP, NULL, bgp_show_type_normal, NULL, 1); } -#ifdef HAVE_IPV6 + DEFUN (show_bgp_ipv6_encap_tags, show_bgp_ipv6_encap_tags_cmd, "show [ip] bgp ipv6 encap tags", @@ -573,7 +571,6 @@ DEFUN (show_bgp_ipv6_encap_tags, { return bgp_show_encap (vty, AFI_IP6, NULL, bgp_show_type_normal, NULL, 1); } -#endif DEFUN (show_bgp_ipv4_encap_rd_tags, show_bgp_ipv4_encap_rd_tags_cmd, @@ -599,7 +596,7 @@ DEFUN (show_bgp_ipv4_encap_rd_tags, } return bgp_show_encap (vty, AFI_IP, &prd, bgp_show_type_normal, NULL, 1); } -#ifdef HAVE_IPV6 + DEFUN (show_bgp_ipv6_encap_rd_tags, show_bgp_ipv6_encap_rd_tags_cmd, "show [ip] bgp ipv6 encap rd ASN:nn_or_IP-address:nn tags", @@ -624,7 +621,6 @@ DEFUN (show_bgp_ipv6_encap_rd_tags, } return bgp_show_encap (vty, AFI_IP6, &prd, bgp_show_type_normal, NULL, 1); } -#endif DEFUN (show_bgp_ipv4_encap_neighbor_routes, show_bgp_ipv4_encap_neighbor_routes_cmd, @@ -657,7 +653,7 @@ DEFUN (show_bgp_ipv4_encap_neighbor_routes, return bgp_show_encap (vty, AFI_IP, NULL, bgp_show_type_neighbor, &su, 0); } -#ifdef HAVE_IPV6 + DEFUN (show_bgp_ipv6_encap_neighbor_routes, show_bgp_ipv6_encap_neighbor_routes_cmd, "show [ip] bgp ipv6 encap neighbors A.B.C.D routes", @@ -689,7 +685,6 @@ DEFUN (show_bgp_ipv6_encap_neighbor_routes, return bgp_show_encap (vty, AFI_IP6, NULL, bgp_show_type_neighbor, &su, 0); } -#endif DEFUN (show_bgp_ipv4_encap_rd_neighbor_routes, show_bgp_ipv4_encap_rd_neighbor_routes_cmd, @@ -735,7 +730,7 @@ DEFUN (show_bgp_ipv4_encap_rd_neighbor_routes, return bgp_show_encap (vty, AFI_IP, &prd, bgp_show_type_neighbor, &su, 0); } -#ifdef HAVE_IPV6 + DEFUN (show_bgp_ipv6_encap_rd_neighbor_routes, show_bgp_ipv6_encap_rd_neighbor_routes_cmd, "show [ip] bgp ipv6 encap rd ASN:nn_or_IP-address:nn neighbors routes", @@ -780,7 +775,6 @@ DEFUN (show_bgp_ipv6_encap_rd_neighbor_routes, return bgp_show_encap (vty, AFI_IP6, &prd, bgp_show_type_neighbor, &su, 0); } -#endif DEFUN (show_bgp_ipv4_encap_neighbor_advertised_routes, show_bgp_ipv4_encap_neighbor_advertised_routes_cmd, @@ -814,7 +808,7 @@ DEFUN (show_bgp_ipv4_encap_neighbor_advertised_routes, return show_adj_route_encap (vty, peer, NULL); } -#ifdef HAVE_IPV6 + DEFUN (show_bgp_ipv6_encap_neighbor_advertised_routes, show_bgp_ipv6_encap_neighbor_advertised_routes_cmd, "show [ip] bgp ipv6 encap neighbors A.B.C.D advertised-routes", @@ -847,7 +841,6 @@ DEFUN (show_bgp_ipv6_encap_neighbor_advertised_routes, return show_adj_route_encap (vty, peer, NULL); } -#endif DEFUN (show_bgp_ipv4_encap_rd_neighbor_advertised_routes, show_bgp_ipv4_encap_rd_neighbor_advertised_routes_cmd, @@ -893,7 +886,7 @@ DEFUN (show_bgp_ipv4_encap_rd_neighbor_advertised_routes, return show_adj_route_encap (vty, peer, &prd); } -#ifdef HAVE_IPV6 + DEFUN (show_bgp_ipv6_encap_rd_neighbor_advertised_routes, show_bgp_ipv6_encap_rd_neighbor_advertised_routes_cmd, "show [ip] bgp ipv6 encap rd ASN:nn_or_IP-address:nn neighbors advertised-routes", @@ -938,7 +931,6 @@ DEFUN (show_bgp_ipv6_encap_rd_neighbor_advertised_routes, return show_adj_route_encap (vty, peer, &prd); } -#endif void bgp_encap_init (void) @@ -955,7 +947,6 @@ bgp_encap_init (void) install_element (VIEW_NODE, &show_bgp_ipv4_encap_neighbor_advertised_routes_cmd); install_element (VIEW_NODE, &show_bgp_ipv4_encap_rd_neighbor_advertised_routes_cmd); -#ifdef HAVE_IPV6 install_element (VIEW_NODE, &show_bgp_ipv6_encap_cmd); install_element (VIEW_NODE, &show_bgp_ipv6_encap_rd_cmd); install_element (VIEW_NODE, &show_bgp_ipv6_encap_tags_cmd); @@ -964,5 +955,4 @@ bgp_encap_init (void) install_element (VIEW_NODE, &show_bgp_ipv6_encap_rd_neighbor_routes_cmd); install_element (VIEW_NODE, &show_bgp_ipv6_encap_neighbor_advertised_routes_cmd); install_element (VIEW_NODE, &show_bgp_ipv6_encap_rd_neighbor_advertised_routes_cmd); -#endif } diff --git a/bgpd/bgp_mpath.c b/bgpd/bgp_mpath.c index c9af8419f2..208f676f1a 100644 --- a/bgpd/bgp_mpath.c +++ b/bgpd/bgp_mpath.c @@ -125,7 +125,6 @@ bgp_info_nexthop_cmp (struct bgp_info *bi1, struct bgp_info *bi2) compare = IPV4_ADDR_CMP (&ae1->mp_nexthop_global_in, &ae2->mp_nexthop_global_in); break; -#ifdef HAVE_IPV6 case BGP_ATTR_NHLEN_IPV6_GLOBAL: compare = IPV6_ADDR_CMP (&ae1->mp_nexthop_global, &ae2->mp_nexthop_global); @@ -137,11 +136,9 @@ bgp_info_nexthop_cmp (struct bgp_info *bi1, struct bgp_info *bi2) compare = IPV6_ADDR_CMP (&ae1->mp_nexthop_local, &ae2->mp_nexthop_local); break; -#endif /* HAVE_IPV6 */ } } -#ifdef HAVE_IPV6 /* This can happen if one IPv6 peer sends you global and link-local * nexthops but another IPv6 peer only sends you global */ @@ -158,7 +155,6 @@ bgp_info_nexthop_cmp (struct bgp_info *bi1, struct bgp_info *bi2) compare = 1; } } -#endif /* HAVE_IPV6 */ } return compare; @@ -755,10 +751,8 @@ bgp_info_mpath_aggregate_update (struct bgp_info *new_best, /* Zap multipath attr nexthop so we set nexthop to self */ attr.nexthop.s_addr = 0; -#ifdef HAVE_IPV6 if (attr.extra) memset (&attr.extra->mp_nexthop_global, 0, sizeof (struct in6_addr)); -#endif /* HAVE_IPV6 */ /* TODO: should we set ATOMIC_AGGREGATE and AGGREGATOR? */ } diff --git a/bgpd/bgp_network.c b/bgpd/bgp_network.c index 9a49051a96..1358ebc5ef 100644 --- a/bgpd/bgp_network.c +++ b/bgpd/bgp_network.c @@ -598,10 +598,8 @@ bgp_connect (struct peer *peer) zlog_err ("%s: could not raise privs", __func__); if (sockunion_family (&peer->su) == AF_INET) setsockopt_ipv4_tos (peer->fd, IPTOS_PREC_INTERNETCONTROL); -# ifdef HAVE_IPV6 else if (sockunion_family (&peer->su) == AF_INET6) setsockopt_ipv6_tclass (peer->fd, IPTOS_PREC_INTERNETCONTROL); -# endif if (bgpd_privs.change (ZPRIVS_LOWER)) zlog_err ("%s: could not lower privs", __func__); #endif @@ -618,10 +616,8 @@ bgp_connect (struct peer *peer) return connect_error; } -#ifdef HAVE_IPV6 if (peer->conf_if || peer->ifname) ifindex = ifname2ifindex (peer->conf_if ? peer->conf_if : peer->ifname); -#endif /* HAVE_IPV6 */ if (bgp_debug_neighbor_events(peer)) zlog_debug ("%s [Event] Connect start to %s fd %d", @@ -681,10 +677,8 @@ bgp_listener (int sock, struct sockaddr *sa, socklen_t salen) #ifdef IPTOS_PREC_INTERNETCONTROL if (sa->sa_family == AF_INET) setsockopt_ipv4_tos (sock, IPTOS_PREC_INTERNETCONTROL); -# ifdef HAVE_IPV6 else if (sa->sa_family == AF_INET6) setsockopt_ipv6_tclass (sock, IPTOS_PREC_INTERNETCONTROL); -# endif #endif sockopt_v6only (sa->sa_family, sock); @@ -717,7 +711,6 @@ bgp_listener (int sock, struct sockaddr *sa, socklen_t salen) } /* IPv6 supported version of BGP server socket setup. */ -#ifdef HAVE_IPV6 int bgp_socket (unsigned short port, const char *address) { @@ -774,50 +767,6 @@ bgp_socket (unsigned short port, const char *address) return 0; } -#else -/* Traditional IPv4 only version. */ -int -bgp_socket (unsigned short port, const char *address) -{ - int sock; - int socklen; - struct sockaddr_in sin; - int ret; - - sock = socket (AF_INET, SOCK_STREAM, 0); - if (sock < 0) - { - zlog_err ("socket: %s", safe_strerror (errno)); - return sock; - } - - /* if we intend to implement ttl-security, this socket needs ttl=255 */ - sockopt_ttl (AF_INET, sock, MAXTTL); - - memset (&sin, 0, sizeof (struct sockaddr_in)); - sin.sin_family = AF_INET; - sin.sin_port = htons (port); - socklen = sizeof (struct sockaddr_in); - - if (address && ((ret = inet_aton(address, &sin.sin_addr)) < 1)) - { - zlog_err("bgp_socket: could not parse ip address %s: %s", - address, safe_strerror (errno)); - return ret; - } -#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN - sin.sin_len = socklen; -#endif /* HAVE_STRUCT_SOCKADDR_IN_SIN_LEN */ - - ret = bgp_listener (sock, (struct sockaddr *) &sin, socklen); - if (ret < 0) - { - close (sock); - return ret; - } - return sock; -} -#endif /* HAVE_IPV6 */ void bgp_close (void) diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c index 2cbcc37d67..0a9747b526 100644 --- a/bgpd/bgp_nexthop.c +++ b/bgpd/bgp_nexthop.c @@ -243,7 +243,6 @@ bgp_connected_add (struct bgp *bgp, struct connected *ifc) } } } -#ifdef HAVE_IPV6 else if (addr->family == AF_INET6) { apply_mask_ipv6 ((struct prefix_ipv6 *) &p); @@ -267,7 +266,6 @@ bgp_connected_add (struct bgp *bgp, struct connected *ifc) rn->info = bc; } } -#endif /* HAVE_IPV6 */ } void @@ -304,7 +302,6 @@ bgp_connected_delete (struct bgp *bgp, struct connected *ifc) bgp_unlock_node (rn); bgp_unlock_node (rn); } -#ifdef HAVE_IPV6 else if (addr->family == AF_INET6) { apply_mask_ipv6 ((struct prefix_ipv6 *) &p); @@ -329,7 +326,6 @@ bgp_connected_delete (struct bgp *bgp, struct connected *ifc) bgp_unlock_node (rn); bgp_unlock_node (rn); } -#endif /* HAVE_IPV6 */ } int diff --git a/bgpd/bgp_nht.c b/bgpd/bgp_nht.c index 1ca0483678..057e2ace76 100644 --- a/bgpd/bgp_nht.c +++ b/bgpd/bgp_nht.c @@ -509,7 +509,6 @@ make_prefix (int afi, struct bgp_info *ri, struct prefix *p) p->prefixlen = IPV4_MAX_BITLEN; } break; -#ifdef HAVE_IPV6 case AFI_IP6: /* We don't register link local NH */ if (ri->attr->extra->mp_nexthop_len != BGP_ATTR_NHLEN_IPV6_GLOBAL @@ -529,7 +528,6 @@ make_prefix (int afi, struct bgp_info *ri, struct prefix *p) p->prefixlen = IPV6_MAX_BITLEN; } break; -#endif default: if (BGP_DEBUG(nht, NHT)) { @@ -582,11 +580,9 @@ sendmsg_zebra_rnh (struct bgp_nexthop_cache *bnc, int command) case AF_INET: stream_put_in_addr (s, &p->u.prefix4); break; -#ifdef HAVE_IPV6 case AF_INET6: stream_put(s, &(p->u.prefix6), 16); break; -#endif default: break; } diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 6d8f721bfb..09d5a84988 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -1172,10 +1172,8 @@ subgroup_announce_reset_nhop (u_char family, struct attr *attr) { if (family == AF_INET) attr->nexthop.s_addr = 0; -#ifdef HAVE_IPV6 if (family == AF_INET6) memset (&attr->extra->mp_nexthop_global, 0, IPV6_MAX_BYTELEN); -#endif } int @@ -1266,10 +1264,8 @@ subgroup_announce_check (struct bgp_info *ri, struct update_subgroup *subgrp, { if (p->family == AF_INET && p->u.prefix4.s_addr == INADDR_ANY) return 0; -#ifdef HAVE_IPV6 else if (p->family == AF_INET6 && p->prefixlen == 0) return 0; -#endif /* HAVE_IPV6 */ } /* Transparency check. */ @@ -1432,7 +1428,6 @@ subgroup_announce_check (struct bgp_info *ri, struct update_subgroup *subgrp, if (reflect) SET_FLAG(attr->rmap_change_flags, BATTR_REFLECTED); -#ifdef HAVE_IPV6 #define NEXTHOP_IS_V6 (\ (safi != SAFI_ENCAP && \ (p->family == AF_INET6 || peer_cap_enhe(peer))) || \ @@ -1463,7 +1458,6 @@ subgroup_announce_check (struct bgp_info *ri, struct update_subgroup *subgrp, PEER_FLAG_NEXTHOP_LOCAL_UNCHANGED))) memset (&attr->extra->mp_nexthop_local, 0, IPV6_MAX_BYTELEN); } -#endif /* HAVE_IPV6 */ bgp_peer_remove_private_as(bgp, afi, safi, peer, attr); bgp_peer_as_override(bgp, afi, safi, peer, attr); @@ -2317,14 +2311,12 @@ bgp_update_martian_nexthop (struct bgp *bgp, afi_t afi, safi_t safi, struct attr IPV4_CLASS_DE (ntohl (attre->mp_nexthop_global_in.s_addr))); break; -#ifdef HAVE_IPV6 case BGP_ATTR_NHLEN_IPV6_GLOBAL: case BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL: ret = (IN6_IS_ADDR_UNSPECIFIED(&attre->mp_nexthop_global) || IN6_IS_ADDR_LOOPBACK(&attre->mp_nexthop_global) || IN6_IS_ADDR_MULTICAST(&attre->mp_nexthop_global)); break; -#endif /* HAVE_IPV6 */ default: ret = 1; @@ -3523,7 +3515,6 @@ bgp_nlri_parse_ip (struct peer *peer, struct attr *attr, } } -#ifdef HAVE_IPV6 /* Check address. */ if (afi == AFI_IP6 && safi == SAFI_UNICAST) { @@ -3546,7 +3537,6 @@ bgp_nlri_parse_ip (struct peer *peer, struct attr *attr, continue; } } -#endif /* HAVE_IPV6 */ /* Normal process. */ if (attr) @@ -4029,14 +4019,12 @@ bgp_static_set (struct vty *vty, const char *ip_str, vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); return CMD_WARNING; } -#ifdef HAVE_IPV6 if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) { vty_out (vty, "%% Malformed prefix (link-local address)%s", VTY_NEWLINE); return CMD_WARNING; } -#endif /* HAVE_IPV6 */ apply_mask (&p); @@ -4118,14 +4106,12 @@ bgp_static_unset (struct vty *vty, const char *ip_str, vty_out (vty, "%% Malformed prefix%s", VTY_NEWLINE); return CMD_WARNING; } -#ifdef HAVE_IPV6 if (afi == AFI_IP6 && IN6_IS_ADDR_LINKLOCAL (&p.u.prefix6)) { vty_out (vty, "%% Malformed prefix (link-local address)%s", VTY_NEWLINE); return CMD_WARNING; } -#endif /* HAVE_IPV6 */ apply_mask (&p); @@ -5551,14 +5537,12 @@ bgp_redistribute_add (struct bgp *bgp, struct prefix *p, const struct in_addr *n attr.nexthop = *nexthop; attr.nh_ifindex = ifindex; -#ifdef HAVE_IPV6 if (nexthop6) { struct attr_extra *extra = bgp_attr_extra_get(&attr); extra->mp_nexthop_global = *nexthop6; extra->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL; } -#endif attr.med = metric; attr.flag |= ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC); @@ -5887,12 +5871,10 @@ route_vty_out (struct vty *vty, struct prefix *p, vty_out (vty, "%s", inet_ntop(af, &attr->extra->mp_nexthop_global_in, buf, BUFSIZ)); break; -#if HAVE_IPV6 case AF_INET6: vty_out (vty, "%s", inet_ntop(af, &attr->extra->mp_nexthop_global, buf, BUFSIZ)); break; -#endif default: vty_out(vty, "?"); break; @@ -6139,7 +6121,6 @@ route_vty_out_tmp (struct vty *vty, struct prefix *p, struct attr *attr, safi_t else json_object_string_add(json_net, "nextHop", inet_ntoa (attr->nexthop)); } -#ifdef HAVE_IPV6 else if (p->family == AF_INET6 || BGP_ATTR_NEXTHOP_AFI_IP6(attr)) { char buf[BUFSIZ]; @@ -6147,7 +6128,6 @@ route_vty_out_tmp (struct vty *vty, struct prefix *p, struct attr *attr, safi_t json_object_string_add(json_net, "netHopGloabal", inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, buf, BUFSIZ)); } -#endif /* HAVE_IPV6 */ if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) json_object_int_add(json_net, "metric", attr->med); @@ -6180,7 +6160,6 @@ route_vty_out_tmp (struct vty *vty, struct prefix *p, struct attr *attr, safi_t else vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); } -#ifdef HAVE_IPV6 else if (p->family == AF_INET6 || BGP_ATTR_NEXTHOP_AFI_IP6(attr)) { int len; @@ -6197,7 +6176,6 @@ route_vty_out_tmp (struct vty *vty, struct prefix *p, struct attr *attr, safi_t else vty_out (vty, "%*s", len, " "); } -#endif /* HAVE_IPV6 */ if (attr->flag & ATTR_FLAG_BIT (BGP_ATTR_MULTI_EXIT_DISC)) vty_out (vty, "%10u", attr->med); else @@ -6278,7 +6256,6 @@ route_vty_out_tag (struct vty *vty, struct prefix *p, vty_out (vty, "%-16s", inet_ntoa (attr->nexthop)); } } -#ifdef HAVE_IPV6 else if (p->family == AF_INET6 || BGP_ATTR_NEXTHOP_AFI_IP6(attr)) { assert (attr->extra); @@ -6315,7 +6292,6 @@ route_vty_out_tag (struct vty *vty, struct prefix *p, } } -#endif /* HAVE_IPV6 */ } label = decode_label (binfo->extra->tag); @@ -10565,7 +10541,6 @@ bgp_route_init (void) install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbor_prefix_counts_cmd); install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd); install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd); -#ifdef HAVE_IPV6 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_prefix_counts_cmd); install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbor_prefix_counts_cmd); @@ -10585,7 +10560,6 @@ bgp_route_init (void) /* Statistics */ install_element (ENABLE_NODE, &show_bgp_statistics_cmd); install_element (ENABLE_NODE, &show_bgp_statistics_view_cmd); -#endif /* HAVE_IPV6 */ install_element (BGP_NODE, &bgp_distance_cmd); install_element (BGP_NODE, &no_bgp_distance_cmd); diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c index e3e018c07f..4f7f51fbbb 100644 --- a/bgpd/bgp_routemap.c +++ b/bgpd/bgp_routemap.c @@ -1916,7 +1916,6 @@ static struct route_map_rule_cmd route_set_tag_cmd = }; -#ifdef HAVE_IPV6 /* `match ipv6 address IP_ACCESS_LIST' */ static route_map_result_t @@ -2341,8 +2340,6 @@ struct route_map_rule_cmd route_set_ipv6_nexthop_peer_cmd = route_set_ipv6_nexthop_peer_free }; -#endif /* HAVE_IPV6 */ - /* `set vpnv4 nexthop A.B.C.D' */ static route_map_result_t @@ -3755,7 +3752,6 @@ DEFUN (no_set_aggregator_as, return ret; } -#ifdef HAVE_IPV6 DEFUN (match_ipv6_next_hop, match_ipv6_next_hop_cmd, "match ipv6 next-hop X:X::X:X", @@ -3884,7 +3880,6 @@ DEFUN (no_set_ipv6_nexthop_global, return generic_set_delete (vty, VTY_GET_CONTEXT(route_map_index), "ipv6 next-hop global", argv[idx_ipv6]->arg); } -#endif /* HAVE_IPV6 */ DEFUN (set_vpnv4_nexthop, set_vpnv4_nexthop_cmd, @@ -4085,7 +4080,6 @@ bgp_route_map_init (void) install_element (RMAP_NODE, &set_originator_id_cmd); install_element (RMAP_NODE, &no_set_originator_id_cmd); -#ifdef HAVE_IPV6 route_map_install_match (&route_match_ipv6_address_cmd); route_map_install_match (&route_match_ipv6_next_hop_cmd); route_map_install_match (&route_match_ipv6_address_prefix_list_cmd); @@ -4102,7 +4096,6 @@ bgp_route_map_init (void) install_element (RMAP_NODE, &no_set_ipv6_nexthop_prefer_global_cmd); install_element (RMAP_NODE, &set_ipv6_nexthop_peer_cmd); install_element (RMAP_NODE, &no_set_ipv6_nexthop_peer_cmd); -#endif /* HAVE_IPV6 */ } void diff --git a/bgpd/bgp_table.h b/bgpd/bgp_table.h index 2f839c4af7..3c96dac617 100644 --- a/bgpd/bgp_table.h +++ b/bgpd/bgp_table.h @@ -222,8 +222,6 @@ bgp_node_match_ipv4 (const struct bgp_table *table, struct in_addr *addr) addr)); } -#ifdef HAVE_IPV6 - /* * bgp_node_match_ipv6 */ @@ -234,8 +232,6 @@ bgp_node_match_ipv6 (const struct bgp_table *table, struct in6_addr *addr) addr)); } -#endif /* HAVE_IPV6 */ - static inline unsigned long bgp_table_count (const struct bgp_table *const table) { diff --git a/bgpd/bgp_updgrp_adv.c b/bgpd/bgp_updgrp_adv.c index df154d9761..48f56a29b2 100644 --- a/bgpd/bgp_updgrp_adv.c +++ b/bgpd/bgp_updgrp_adv.c @@ -711,7 +711,6 @@ subgroup_default_originate (struct update_subgroup *subgrp, int withdraw) if (afi == AFI_IP) str2prefix ("0.0.0.0/0", &p); -#ifdef HAVE_IPV6 else if (afi == AFI_IP6) { struct attr_extra *ae = attr.extra; @@ -727,7 +726,6 @@ subgroup_default_originate (struct update_subgroup *subgrp, int withdraw) && !IN6_IS_ADDR_UNSPECIFIED (&peer->nexthop.v6_local)) ae->mp_nexthop_len = BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL; } -#endif /* HAVE_IPV6 */ if (peer->default_rmap[afi][safi].name) { @@ -785,10 +783,8 @@ subgroup_default_originate (struct update_subgroup *subgrp, int withdraw) */ if (afi == AFI_IP) str2prefix ("0.0.0.0/0", &p); -#ifdef HAVE_IPV6 else str2prefix ("::/0", &p); -#endif /* HAVE_IPV6 */ rn = bgp_afi_node_get (bgp->rib[afi][safi], afi, safi, &p, NULL); bgp_adj_out_unset_subgroup (rn, subgrp, 0, BGP_ADDPATH_TX_ID_FOR_DEFAULT_ORIGINATE); diff --git a/bgpd/bgp_updgrp_packet.c b/bgpd/bgp_updgrp_packet.c index e18ba235c7..cb05cf0a80 100644 --- a/bgpd/bgp_updgrp_packet.c +++ b/bgpd/bgp_updgrp_packet.c @@ -988,10 +988,8 @@ subgroup_default_update_packet (struct update_subgroup *subgrp, if (afi == AFI_IP) str2prefix ("0.0.0.0/0", &p); -#ifdef HAVE_IPV6 else str2prefix ("::/0", &p); -#endif /* HAVE_IPV6 */ /* Logging the attribute. */ if (bgp_debug_update(NULL, &p, subgrp->update_group, 0)) @@ -1066,10 +1064,8 @@ subgroup_default_withdraw_packet (struct update_subgroup *subgrp) if (afi == AFI_IP) str2prefix ("0.0.0.0/0", &p); -#ifdef HAVE_IPV6 else str2prefix ("::/0", &p); -#endif /* HAVE_IPV6 */ if (bgp_debug_update(NULL, &p, subgrp->update_group, 0)) { diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 5129c0ecff..95b7250d33 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -115,11 +115,9 @@ bgp_vty_afi_from_arg(const char *afi_str) if (!strcmp(afi_str, "ipv4")) { afi = AFI_IP; } -#ifdef HAVE_IPV6 else if (!strcmp(afi_str, "ipv6")) { afi = AFI_IP6; } -#endif /* HAVE_IPV6 */ return afi; } @@ -216,11 +214,9 @@ peer_address_self_check (struct bgp *bgp, union sockunion *su) if (su->sa.sa_family == AF_INET) ifp = if_lookup_by_ipv4_exact (&su->sin.sin_addr, bgp->vrf_id); -#ifdef HAVE_IPV6 else if (su->sa.sa_family == AF_INET6) ifp = if_lookup_by_ipv6_exact (&su->sin6.sin6_addr, su->sin6.sin6_scope_id, bgp->vrf_id); -#endif /* HAVE IPV6 */ if (ifp) return 1; @@ -7518,7 +7514,6 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js || p->afc_recv[AFI_IP][SAFI_UNICAST] || p->afc_adv[AFI_IP][SAFI_MULTICAST] || p->afc_recv[AFI_IP][SAFI_MULTICAST] -#ifdef HAVE_IPV6 || p->afc_adv[AFI_IP6][SAFI_UNICAST] || p->afc_recv[AFI_IP6][SAFI_UNICAST] || p->afc_adv[AFI_IP6][SAFI_MULTICAST] @@ -7527,7 +7522,6 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js || p->afc_recv[AFI_IP6][SAFI_MPLS_VPN] || p->afc_adv[AFI_IP6][SAFI_ENCAP] || p->afc_recv[AFI_IP6][SAFI_ENCAP] -#endif /* HAVE_IPV6 */ || p->afc_adv[AFI_IP][SAFI_ENCAP] || p->afc_recv[AFI_IP][SAFI_ENCAP] || p->afc_adv[AFI_IP][SAFI_MPLS_VPN] @@ -8277,21 +8271,18 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js if (use_json) { json_object_string_add(json_neigh, "nexthop", inet_ntop (AF_INET, &p->nexthop.v4, buf1, BUFSIZ)); -#ifdef HAVE_IPV6 json_object_string_add(json_neigh, "nexthopGlobal", inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, BUFSIZ)); json_object_string_add(json_neigh, "nexthopLocal", inet_ntop (AF_INET6, &p->nexthop.v6_local, buf1, BUFSIZ)); if (p->shared_network) json_object_string_add(json_neigh, "bgpConnection", "sharedNetwork"); else json_object_string_add(json_neigh, "bgpConnection", "nonSharedNetwork"); -#endif /* HAVE_IPV6 */ } else { vty_out (vty, "Nexthop: %s%s", inet_ntop (AF_INET, &p->nexthop.v4, buf1, BUFSIZ), VTY_NEWLINE); -#ifdef HAVE_IPV6 vty_out (vty, "Nexthop global: %s%s", inet_ntop (AF_INET6, &p->nexthop.v6_global, buf1, BUFSIZ), VTY_NEWLINE); @@ -8301,7 +8292,6 @@ bgp_show_peer (struct vty *vty, struct peer *p, u_char use_json, json_object *js vty_out (vty, "BGP connection: %s%s", p->shared_network ? "shared network" : "non shared network", VTY_NEWLINE); -#endif /* HAVE_IPV6 */ } } @@ -9561,7 +9551,6 @@ DEFUN (no_bgp_redistribute_ipv4, return bgp_redistribute_unset (bgp, AFI_IP, type, 0); } -#ifdef HAVE_IPV6 DEFUN (bgp_redistribute_ipv6, bgp_redistribute_ipv6_cmd, "redistribute ", @@ -9725,7 +9714,6 @@ DEFUN (no_bgp_redistribute_ipv6, return bgp_redistribute_unset (bgp, AFI_IP6, type, 0); } -#endif /* HAVE_IPV6 */ int bgp_config_write_redistribute (struct vty *vty, struct bgp *bgp, afi_t afi, @@ -10688,18 +10676,14 @@ bgp_vty_init (void) /* address-family commands. */ install_element (BGP_NODE, &address_family_ipv4_cmd); install_element (BGP_NODE, &address_family_ipv4_safi_cmd); -#ifdef HAVE_IPV6 install_element (BGP_NODE, &address_family_ipv6_cmd); install_element (BGP_NODE, &address_family_ipv6_safi_cmd); -#endif /* HAVE_IPV6 */ install_element (BGP_NODE, &address_family_vpnv4_cmd); install_element (BGP_NODE, &address_family_vpnv6_cmd); install_element (BGP_NODE, &address_family_encap_cmd); -#ifdef HAVE_IPV6 install_element (BGP_NODE, &address_family_encapv6_cmd); -#endif /* "exit-address-family" command. */ install_element (BGP_IPV4_NODE, &exit_address_family_cmd); @@ -10776,14 +10760,12 @@ bgp_vty_init (void) install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_cmd); install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_rmap_metric_cmd); install_element (BGP_IPV4_NODE, &bgp_redistribute_ipv4_ospf_metric_rmap_cmd); -#ifdef HAVE_IPV6 install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_cmd); install_element (BGP_IPV6_NODE, &no_bgp_redistribute_ipv6_cmd); install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_cmd); install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_cmd); install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_rmap_metric_cmd); install_element (BGP_IPV6_NODE, &bgp_redistribute_ipv6_metric_rmap_cmd); -#endif /* HAVE_IPV6 */ /* ttl_security commands */ install_element (BGP_NODE, &neighbor_ttl_security_cmd); diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index 3d3bd90f5b..8bc7bd3025 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -698,7 +698,6 @@ zebra_read_ipv4 (int command, struct zclient *zclient, zebra_size_t length, return 0; } -#ifdef HAVE_IPV6 /* Zebra route add and delete treatment. */ static int zebra_read_ipv6 (int command, struct zclient *zclient, zebra_size_t length, @@ -817,7 +816,6 @@ zebra_read_ipv6 (int command, struct zclient *zclient, zebra_size_t length, return 0; } -#endif /* HAVE_IPV6 */ struct interface * if_lookup_by_ipv4 (struct in_addr *addr, vrf_id_t vrf_id) @@ -870,7 +868,6 @@ if_lookup_by_ipv4_exact (struct in_addr *addr, vrf_id_t vrf_id) return NULL; } -#ifdef HAVE_IPV6 struct interface * if_lookup_by_ipv6 (struct in6_addr *addr, ifindex_t ifindex, vrf_id_t vrf_id) { @@ -979,7 +976,6 @@ if_get_ipv6_local (struct interface *ifp, struct in6_addr *addr) } return 0; } -#endif /* HAVE_IPV6 */ static int if_get_ipv4_address (struct interface *ifp, struct in_addr *addr) @@ -1022,7 +1018,6 @@ bgp_nexthop_set (union sockunion *local, union sockunion *remote, else ifp = if_lookup_by_ipv4_exact (&local->sin.sin_addr, peer->bgp->vrf_id); } -#ifdef HAVE_IPV6 if (local->sa.sa_family == AF_INET6) { if (IN6_IS_ADDR_LINKLOCAL (&local->sin6.sin6_addr)) @@ -1037,7 +1032,6 @@ bgp_nexthop_set (union sockunion *local, union sockunion *remote, local->sin6.sin6_scope_id, peer->bgp->vrf_id); } -#endif /* HAVE_IPV6 */ if (!ifp) return -1; @@ -1047,7 +1041,6 @@ bgp_nexthop_set (union sockunion *local, union sockunion *remote, /* IPv4 connection, fetch and store IPv6 local address(es) if any. */ if (local->sa.sa_family == AF_INET) { -#ifdef HAVE_IPV6 /* IPv6 nexthop*/ ret = if_get_ipv6_global (ifp, &nexthop->v6_global); @@ -1069,10 +1062,8 @@ bgp_nexthop_set (union sockunion *local, union sockunion *remote, peer->shared_network = 1; else peer->shared_network = 0; -#endif /* HAVE_IPV6 */ } -#ifdef HAVE_IPV6 /* IPv6 connection, fetch and store IPv4 local address if any. */ if (local->sa.sa_family == AF_INET6) { @@ -1135,7 +1126,6 @@ bgp_nexthop_set (union sockunion *local, union sockunion *remote, SET_IN6_LINKLOCAL_IFINDEX (nexthop->v6_local, 0); } #endif /* KAME */ -#endif /* HAVE_IPV6 */ /* If we have identified the local interface, there is no error for now. */ return 0; @@ -1390,7 +1380,6 @@ bgp_zebra_announce (struct prefix *p, struct bgp_info *info, struct bgp *bgp, zapi_ipv4_route (valid_nh_count ? ZEBRA_IPV4_ROUTE_ADD: ZEBRA_IPV4_ROUTE_DELETE, zclient, (struct prefix_ipv4 *) p, &api); } -#ifdef HAVE_IPV6 /* We have to think about a IPv6 link-local address curse. */ if (p->family == AF_INET6 || @@ -1601,7 +1590,6 @@ bgp_zebra_announce (struct prefix *p, struct bgp_info *info, struct bgp *bgp, zclient, (struct prefix_ipv6 *) p, &api); } } -#endif /* HAVE_IPV6 */ } /* Announce all routes of a table to zebra */ @@ -1700,7 +1688,6 @@ bgp_zebra_withdraw (struct prefix *p, struct bgp_info *info, safi_t safi) zapi_ipv4_route (ZEBRA_IPV4_ROUTE_DELETE, zclient, (struct prefix_ipv4 *) p, &api); } -#ifdef HAVE_IPV6 /* We have to think about a IPv6 link-local address curse. */ if (p->family == AF_INET6) { @@ -1740,8 +1727,8 @@ bgp_zebra_withdraw (struct prefix *p, struct bgp_info *info, safi_t safi) zapi_ipv6_route (ZEBRA_IPV6_ROUTE_DELETE, zclient, (struct prefix_ipv6 *) p, &api); } -#endif /* HAVE_IPV6 */ } + struct bgp_redist * bgp_redist_lookup (struct bgp *bgp, afi_t afi, u_char type, u_short instance) { diff --git a/bgpd/bgp_zebra.h b/bgpd/bgp_zebra.h index 24b4634eb6..d22a00e8fb 100644 --- a/bgpd/bgp_zebra.h +++ b/bgpd/bgp_zebra.h @@ -57,10 +57,8 @@ extern int bgp_redistribute_unreg (struct bgp *, afi_t, int, u_short); extern struct interface *if_lookup_by_ipv4 (struct in_addr *, vrf_id_t); extern struct interface *if_lookup_by_ipv4_exact (struct in_addr *, vrf_id_t); -#ifdef HAVE_IPV6 extern struct interface *if_lookup_by_ipv6 (struct in6_addr *, ifindex_t, vrf_id_t); extern struct interface *if_lookup_by_ipv6_exact (struct in6_addr *, ifindex_t, vrf_id_t); -#endif /* HAVE_IPV6 */ extern int bgp_zebra_num_connects(void); diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index 76e19ac535..9befd63703 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -405,10 +405,8 @@ struct bgp_nexthop { struct interface *ifp; struct in_addr v4; -#ifdef HAVE_IPV6 struct in6_addr v6_global; struct in6_addr v6_local; -#endif /* HAVE_IPV6 */ }; /* BGP addpath values */ diff --git a/configure.ac b/configure.ac index d883063ddb..519b1ea2e9 100755 --- a/configure.ac +++ b/configure.ac @@ -1097,9 +1097,6 @@ dnl ---------- AC_MSG_ERROR([Failed to detect IPv6 stack]) fi -dnl this is unconditial, for compatibility -AC_DEFINE(HAVE_IPV6,1,IPv6) - dnl ------------------ dnl IPv6 header checks dnl ------------------ diff --git a/isisd/isis_adjacency.c b/isisd/isis_adjacency.c index 7f8e8deccc..f550924874 100644 --- a/isisd/isis_adjacency.c +++ b/isisd/isis_adjacency.c @@ -145,10 +145,8 @@ isis_delete_adj (void *arg) list_delete (adj->area_addrs); if (adj->ipv4_addrs) list_delete (adj->ipv4_addrs); -#ifdef HAVE_IPV6 if (adj->ipv6_addrs) list_delete (adj->ipv6_addrs); -#endif XFREE (MTYPE_ISIS_ADJACENCY, adj); return; @@ -301,10 +299,8 @@ isis_adj_print (struct isis_adjacency *adj) struct isis_dynhn *dyn; struct listnode *node; struct in_addr *ipv4_addr; -#ifdef HAVE_IPV6 struct in6_addr *ipv6_addr; u_char ip6[INET6_ADDRSTRLEN]; -#endif /* HAVE_IPV6 */ if (!adj) return; @@ -323,7 +319,6 @@ isis_adj_print (struct isis_adjacency *adj) zlog_debug ("%s", inet_ntoa (*ipv4_addr)); } -#ifdef HAVE_IPV6 if (adj->ipv6_addrs && listcount (adj->ipv6_addrs) > 0) { zlog_debug ("IPv6 Address(es):"); @@ -333,7 +328,6 @@ isis_adj_print (struct isis_adjacency *adj) zlog_debug ("%s", ip6); } } -#endif /* HAVE_IPV6 */ zlog_debug ("Speaks: %s", nlpid2string (&adj->nlpids)); return; @@ -363,10 +357,8 @@ isis_adj_expire (struct thread *thread) void isis_adj_print_vty (struct isis_adjacency *adj, struct vty *vty, char detail) { -#ifdef HAVE_IPV6 struct in6_addr *ipv6_addr; u_char ip6[INET6_ADDRSTRLEN]; -#endif /* HAVE_IPV6 */ struct in_addr *ip_addr; time_t now; struct isis_dynhn *dyn; @@ -457,7 +449,6 @@ isis_adj_print_vty (struct isis_adjacency *adj, struct vty *vty, char detail) for (ALL_LIST_ELEMENTS_RO (adj->ipv4_addrs, node, ip_addr)) vty_out (vty, " %s%s", inet_ntoa (*ip_addr), VTY_NEWLINE); } -#ifdef HAVE_IPV6 if (adj->ipv6_addrs && listcount (adj->ipv6_addrs) > 0) { vty_out (vty, " IPv6 Address(es):%s", VTY_NEWLINE); @@ -467,7 +458,6 @@ isis_adj_print_vty (struct isis_adjacency *adj, struct vty *vty, char detail) vty_out (vty, " %s%s", ip6, VTY_NEWLINE); } } -#endif /* HAVE_IPV6 */ vty_out (vty, "%s", VTY_NEWLINE); } return; diff --git a/isisd/isis_adjacency.h b/isisd/isis_adjacency.h index 99d0c493ba..8539b03d6b 100644 --- a/isisd/isis_adjacency.h +++ b/isisd/isis_adjacency.h @@ -85,10 +85,8 @@ struct isis_adjacency struct nlpids nlpids; /* protocols spoken ... */ struct list *ipv4_addrs; struct in_addr router_address; -#ifdef HAVE_IPV6 struct list *ipv6_addrs; struct in6_addr router_address6; -#endif /* HAVE_IPV6 */ u_char prio[ISIS_LEVELS]; /* priorityOfNeighbour for DIS */ int circuit_t; /* from hello PDU hdr */ int level; /* level (1 or 2) */ diff --git a/isisd/isis_circuit.c b/isisd/isis_circuit.c index dfa7561484..b138b8950c 100644 --- a/isisd/isis_circuit.c +++ b/isisd/isis_circuit.c @@ -284,10 +284,8 @@ isis_circuit_del_addr (struct isis_circuit *circuit, struct prefix_ipv4 *ipv4, *ip = NULL; struct listnode *node; char buf[PREFIX2STR_BUFFER]; -#ifdef HAVE_IPV6 struct prefix_ipv6 *ipv6, *ip6 = NULL; int found = 0; -#endif /* HAVE_IPV6 */ if (connected->address->family == AF_INET) { @@ -321,7 +319,6 @@ isis_circuit_del_addr (struct isis_circuit *circuit, prefix_ipv4_free (ipv4); } -#ifdef HAVE_IPV6 if (connected->address->family == AF_INET6) { ipv6 = prefix_ipv6_new (); @@ -379,7 +376,6 @@ isis_circuit_del_addr (struct isis_circuit *circuit, prefix_ipv6_free (ipv6); } -#endif /* HAVE_IPV6 */ return; } @@ -467,10 +463,8 @@ isis_circuit_if_add (struct isis_circuit *circuit, struct interface *ifp) } circuit->ip_addrs = list_new (); -#ifdef HAVE_IPV6 circuit->ipv6_link = list_new (); circuit->ipv6_non_link = list_new (); -#endif /* HAVE_IPV6 */ for (ALL_LIST_ELEMENTS (ifp->connected, node, nnode, conn)) isis_circuit_add_addr (circuit, conn); @@ -497,7 +491,6 @@ isis_circuit_if_del (struct isis_circuit *circuit, struct interface *ifp) circuit->ip_addrs = NULL; } -#ifdef HAVE_IPV6 if (circuit->ipv6_link) { assert (listcount(circuit->ipv6_link) == 0); @@ -511,7 +504,6 @@ isis_circuit_if_del (struct isis_circuit *circuit, struct interface *ifp) list_delete (circuit->ipv6_non_link); circuit->ipv6_non_link = NULL; } -#endif /* HAVE_IPV6 */ circuit->circ_type = CIRCUIT_T_UNKNOWN; circuit->circuit_id = 0; @@ -857,13 +849,11 @@ circuit_update_nlpids (struct isis_circuit *circuit) circuit->nlpids.nlpids[0] = NLPID_IP; circuit->nlpids.count++; } -#ifdef HAVE_IPV6 if (circuit->ipv6_router) { circuit->nlpids.nlpids[circuit->nlpids.count] = NLPID_IPV6; circuit->nlpids.count++; } -#endif /* HAVE_IPV6 */ return; } @@ -1045,14 +1035,12 @@ isis_interface_config_write (struct vty *vty) vty_out (vty, " isis network point-to-point%s", VTY_NEWLINE); write++; } -#ifdef HAVE_IPV6 if (circuit->ipv6_router) { vty_out (vty, " ipv6 router isis %s%s", area->area_tag, VTY_NEWLINE); write++; } -#endif /* HAVE_IPV6 */ /* ISIS - circuit type */ if (circuit->is_type == IS_LEVEL_1) diff --git a/isisd/isis_circuit.h b/isisd/isis_circuit.h index 035e558c0a..bb0dc0f983 100644 --- a/isisd/isis_circuit.h +++ b/isisd/isis_circuit.h @@ -124,11 +124,9 @@ struct isis_circuit int ip_router; /* Route IP ? */ int is_passive; /* Is Passive ? */ struct list *ip_addrs; /* our IP addresses */ -#ifdef HAVE_IPV6 int ipv6_router; /* Route IPv6 ? */ struct list *ipv6_link; /* our link local IPv6 addresses */ struct list *ipv6_non_link; /* our non-link local IPv6 addresses */ -#endif /* HAVE_IPV6 */ u_int16_t upadjcount[2]; #define ISIS_CIRCUIT_FLAPPED_AFTER_SPF 0x01 u_char flags; diff --git a/isisd/isis_lsp.c b/isisd/isis_lsp.c index dedf2a71dd..0ece4c919a 100644 --- a/isisd/isis_lsp.c +++ b/isisd/isis_lsp.c @@ -156,9 +156,7 @@ lsp_destroy (struct isis_lsp *lsp) } isis_spf_schedule (lsp->area, lsp->level); -#ifdef HAVE_IPV6 isis_spf_schedule6 (lsp->area, lsp->level); -#endif if (lsp->pdu) stream_free (lsp->pdu); @@ -427,9 +425,7 @@ lsp_inc_seqnum (struct isis_lsp *lsp, u_int32_t seq_num) ntohs (lsp->lsp_header->pdu_len) - 12, 12); isis_spf_schedule (lsp->area, lsp->level); -#ifdef HAVE_IPV6 isis_spf_schedule6 (lsp->area, lsp->level); -#endif return; } @@ -510,10 +506,8 @@ lsp_update_data (struct isis_lsp *lsp, struct stream *stream, expected |= TLVFLAG_IPV4_ADDR; expected |= TLVFLAG_IPV4_INT_REACHABILITY; expected |= TLVFLAG_IPV4_EXT_REACHABILITY; -#ifdef HAVE_IPV6 expected |= TLVFLAG_IPV6_ADDR; expected |= TLVFLAG_IPV6_REACHABILITY; -#endif /* HAVE_IPV6 */ retval = parse_tlvs (area->area_tag, STREAM_DATA (lsp->pdu) + ISIS_FIXED_HDR_LEN + ISIS_LSP_HDR_LEN, @@ -638,9 +632,7 @@ lsp_insert (struct isis_lsp *lsp, dict_t * lspdb) if (lsp->lsp_header->seq_num != 0) { isis_spf_schedule (lsp->area, lsp->level); -#ifdef HAVE_IPV6 isis_spf_schedule6 (lsp->area, lsp->level); -#endif } } @@ -840,11 +832,9 @@ lsp_print_detail (struct isis_lsp *lsp, struct vty *vty, char dynhost) struct ipv4_reachability *ipv4_reach; struct in_addr *ipv4_addr; struct te_ipv4_reachability *te_ipv4_reach; -#ifdef HAVE_IPV6 struct ipv6_reachability *ipv6_reach; struct in6_addr in6; u_char buff[BUFSIZ]; -#endif u_char LSPid[255]; u_char hostname[255]; u_char ipv4_reach_prefix[20]; @@ -953,7 +943,6 @@ lsp_print_detail (struct isis_lsp *lsp, struct vty *vty, char dynhost) } /* IPv6 tlv */ -#ifdef HAVE_IPV6 if (lsp->tlv_data.ipv6_reachs) for (ALL_LIST_ELEMENTS_RO (lsp->tlv_data.ipv6_reachs, lnode, ipv6_reach)) { @@ -971,7 +960,6 @@ lsp_print_detail (struct isis_lsp *lsp, struct vty *vty, char dynhost) ntohl (ipv6_reach->metric), buff, ipv6_reach->prefix_len, VTY_NEWLINE); } -#endif /* TE IS neighbor tlv */ if (lsp->tlv_data.te_is_neighs) @@ -1348,10 +1336,8 @@ lsp_build (struct isis_lsp *lsp, struct isis_area *area) struct ipv4_reachability *ipreach; struct te_ipv4_reachability *te_ipreach; struct isis_adjacency *nei; -#ifdef HAVE_IPV6 struct prefix_ipv6 *ipv6, ip6prefix; struct ipv6_reachability *ip6reach; -#endif /* HAVE_IPV6 */ struct tlvs tlv_data; struct isis_lsp *lsp0 = lsp; struct in_addr *routerid; @@ -1391,11 +1377,7 @@ lsp_build (struct isis_lsp *lsp, struct isis_area *area) tlv_add_area_addrs (lsp->tlv_data.area_addrs, lsp->pdu); /* Protocols Supported */ - if (area->ip_circuits > 0 -#ifdef HAVE_IPV6 - || area->ipv6_circuits > 0 -#endif /* HAVE_IPV6 */ - ) + if (area->ip_circuits > 0 || area->ipv6_circuits > 0) { lsp->tlv_data.nlpids = XCALLOC (MTYPE_ISIS_TLV, sizeof (struct nlpids)); lsp->tlv_data.nlpids->count = 0; @@ -1405,7 +1387,6 @@ lsp_build (struct isis_lsp *lsp, struct isis_area *area) lsp->tlv_data.nlpids->count++; lsp->tlv_data.nlpids->nlpids[0] = NLPID_IP; } -#ifdef HAVE_IPV6 if (area->ipv6_circuits > 0) { lsp_debug("ISIS (%s): Found IPv6 circuit, adding IPv6 to NLPIDs", area->area_tag); @@ -1413,7 +1394,6 @@ lsp_build (struct isis_lsp *lsp, struct isis_area *area) lsp->tlv_data.nlpids->nlpids[lsp->tlv_data.nlpids->count - 1] = NLPID_IPV6; } -#endif /* HAVE_IPV6 */ tlv_add_nlpid (lsp->tlv_data.nlpids, lsp->pdu); } @@ -1560,7 +1540,6 @@ lsp_build (struct isis_lsp *lsp, struct isis_area *area) } } -#ifdef HAVE_IPV6 /* * Add IPv6 reachability of this circuit */ @@ -1598,7 +1577,6 @@ lsp_build (struct isis_lsp *lsp, struct isis_area *area) listnode_add (tlv_data.ipv6_reachs, ip6reach); } } -#endif /* HAVE_IPV6 */ switch (circuit->circ_type) { @@ -1799,7 +1777,6 @@ lsp_build (struct isis_lsp *lsp, struct isis_area *area) lsp0, area, level); } -#ifdef HAVE_IPV6 while (tlv_data.ipv6_reachs && listcount (tlv_data.ipv6_reachs)) { if (lsp->tlv_data.ipv6_reachs == NULL) @@ -1812,7 +1789,6 @@ lsp_build (struct isis_lsp *lsp, struct isis_area *area) lsp = lsp_next_frag (LSP_FRAGMENT (lsp->lsp_header->lsp_id) + 1, lsp0, area, level); } -#endif /* HAVE_IPV6 */ while (tlv_data.is_neighs && listcount (tlv_data.is_neighs)) { diff --git a/isisd/isis_pdu.c b/isisd/isis_pdu.c index 96e459a797..e111a17dee 100644 --- a/isisd/isis_pdu.c +++ b/isisd/isis_pdu.c @@ -357,7 +357,6 @@ tlvs_to_adj_ipv4_addrs (struct tlvs *tlvs, struct isis_adjacency *adj) } } -#ifdef HAVE_IPV6 static void tlvs_to_adj_ipv6_addrs (struct tlvs *tlvs, struct isis_adjacency *adj) { @@ -381,7 +380,6 @@ tlvs_to_adj_ipv6_addrs (struct tlvs *tlvs, struct isis_adjacency *adj) } } -#endif /* HAVE_IPV6 */ /* * RECEIVE SIDE @@ -527,12 +525,6 @@ process_p2p_hello (struct isis_circuit *circuit) zlog_warn ("ISIS-Adj: IPv4 addresses present but no overlap " "in P2P IIH from %s\n", circuit->interface->name); } -#ifndef HAVE_IPV6 - else /* !(found & TLVFLAG_IPV4_ADDR) */ - zlog_warn ("ISIS-Adj: no IPv4 in P2P IIH from %s " - "(this isisd has no IPv6)\n", circuit->interface->name); - -#else if (found & TLVFLAG_IPV6_ADDR) { /* TBA: check that we have a linklocal ourselves? */ @@ -553,7 +545,6 @@ process_p2p_hello (struct isis_circuit *circuit) if (!(found & (TLVFLAG_IPV4_ADDR | TLVFLAG_IPV6_ADDR))) zlog_warn ("ISIS-Adj: neither IPv4 nor IPv6 addr in P2P IIH from %s\n", circuit->interface->name); -#endif if (!v6_usable && !v4_usable) { @@ -639,10 +630,8 @@ process_p2p_hello (struct isis_circuit *circuit) set_circuitparams_rmt_ipaddr (circuit->mtc, *ip_addr); } -#ifdef HAVE_IPV6 if (found & TLVFLAG_IPV6_ADDR) tlvs_to_adj_ipv6_addrs (&tlvs, adj); -#endif /* HAVE_IPV6 */ /* lets take care of the expiry */ THREAD_TIMER_OFF (adj->t_expire); @@ -1125,12 +1114,6 @@ process_lan_hello (int level, struct isis_circuit *circuit, const u_char *ssnpa) zlog_warn ("ISIS-Adj: IPv4 addresses present but no overlap " "in LAN IIH from %s\n", circuit->interface->name); } -#ifndef HAVE_IPV6 - else /* !(found & TLVFLAG_IPV4_ADDR) */ - zlog_warn ("ISIS-Adj: no IPv4 in LAN IIH from %s " - "(this isisd has no IPv6)\n", circuit->interface->name); - -#else if (found & TLVFLAG_IPV6_ADDR) { /* TBA: check that we have a linklocal ourselves? */ @@ -1151,7 +1134,6 @@ process_lan_hello (int level, struct isis_circuit *circuit, const u_char *ssnpa) if (!(found & (TLVFLAG_IPV4_ADDR | TLVFLAG_IPV6_ADDR))) zlog_warn ("ISIS-Adj: neither IPv4 nor IPv6 addr in LAN IIH from %s\n", circuit->interface->name); -#endif if (!v6_usable && !v4_usable) { @@ -1236,10 +1218,8 @@ process_lan_hello (int level, struct isis_circuit *circuit, const u_char *ssnpa) if (found & TLVFLAG_IPV4_ADDR) tlvs_to_adj_ipv4_addrs (&tlvs, adj); -#ifdef HAVE_IPV6 if (found & TLVFLAG_IPV6_ADDR) tlvs_to_adj_ipv6_addrs (&tlvs, adj); -#endif /* HAVE_IPV6 */ adj->circuit_t = hdr.circuit_t; @@ -2357,13 +2337,11 @@ send_hello (struct isis_circuit *circuit, int level) if (tlv_add_ip_addrs (circuit->ip_addrs, circuit->snd_stream)) return ISIS_WARNING; -#ifdef HAVE_IPV6 /* IPv6 Interface Address TLV */ if (circuit->ipv6_router && circuit->ipv6_link && listcount (circuit->ipv6_link) > 0) if (tlv_add_ipv6_addrs (circuit->ipv6_link, circuit->snd_stream)) return ISIS_WARNING; -#endif /* HAVE_IPV6 */ if (circuit->pad_hellos) if (tlv_add_padding (circuit->snd_stream)) diff --git a/isisd/isis_route.c b/isisd/isis_route.c index cc3ecba0d3..b2b858feb7 100644 --- a/isisd/isis_route.c +++ b/isisd/isis_route.c @@ -128,7 +128,6 @@ nexthops_print (struct list *nhs) } #endif /* EXTREME_DEBUG */ -#ifdef HAVE_IPV6 static struct isis_nexthop6 * isis_nexthop6_new (struct in6_addr *ip6, ifindex_t ifindex) { @@ -217,7 +216,6 @@ nexthops6_print (struct list *nhs6) nexthop6_print (nh6); } #endif /* EXTREME_DEBUG */ -#endif /* HAVE_IPV6 */ static void adjinfo2nexthop (struct list *nexthops, struct isis_adjacency *adj) @@ -242,7 +240,6 @@ adjinfo2nexthop (struct list *nexthops, struct isis_adjacency *adj) } } -#ifdef HAVE_IPV6 static void adjinfo2nexthop6 (struct list *nexthops6, struct isis_adjacency *adj) { @@ -265,7 +262,6 @@ adjinfo2nexthop6 (struct list *nexthops6, struct isis_adjacency *adj) } } } -#endif /* HAVE_IPV6 */ static struct isis_route_info * isis_route_info_new (struct prefix *prefix, uint32_t cost, uint32_t depth, @@ -291,7 +287,6 @@ isis_route_info_new (struct prefix *prefix, uint32_t cost, uint32_t depth, adjinfo2nexthop (rinfo->nexthops, adj); } } -#ifdef HAVE_IPV6 if (prefix->family == AF_INET6) { rinfo->nexthops6 = list_new (); @@ -307,8 +302,6 @@ isis_route_info_new (struct prefix *prefix, uint32_t cost, uint32_t depth, } } -#endif /* HAVE_IPV6 */ - rinfo->cost = cost; rinfo->depth = depth; @@ -324,13 +317,11 @@ isis_route_info_delete (struct isis_route_info *route_info) list_delete (route_info->nexthops); } -#ifdef HAVE_IPV6 if (route_info->nexthops6) { route_info->nexthops6->del = (void (*)(void *)) isis_nexthop6_delete; list_delete (route_info->nexthops6); } -#endif /* HAVE_IPV6 */ XFREE (MTYPE_ISIS_ROUTE_INFO, route_info); } @@ -353,9 +344,7 @@ isis_route_info_same (struct isis_route_info *new, { struct listnode *node; struct isis_nexthop *nexthop; -#ifdef HAVE_IPV6 struct isis_nexthop6 *nexthop6; -#endif /* HAVE_IPV6 */ if (!CHECK_FLAG (old->flag, ISIS_ROUTE_FLAG_ZEBRA_SYNCED)) return 0; @@ -378,7 +367,6 @@ isis_route_info_same (struct isis_route_info *new, == 0) return 0; } -#ifdef HAVE_IPV6 else if (family == AF_INET6) { for (ALL_LIST_ELEMENTS_RO (new->nexthops6, node, nexthop6)) @@ -391,7 +379,6 @@ isis_route_info_same (struct isis_route_info *new, nexthop6->ifindex) == 0) return 0; } -#endif /* HAVE_IPV6 */ return 1; } @@ -414,10 +401,8 @@ isis_route_create (struct prefix *prefix, u_int32_t cost, u_int32_t depth, if (family == AF_INET) route_node = route_node_get (area->route_table[level - 1], prefix); -#ifdef HAVE_IPV6 else if (family == AF_INET6) route_node = route_node_get (area->route_table6[level - 1], prefix); -#endif /* HAVE_IPV6 */ else { isis_route_info_delete (rinfo_new); @@ -547,7 +532,6 @@ isis_route_validate_table (struct isis_area *area, struct route_table *table) drnode->info = NULL; } -#ifdef HAVE_IPV6 if (rnode->p.family == AF_INET6) { drnode = route_node_get (area->route_table6[0], &rnode->p); @@ -557,7 +541,6 @@ isis_route_validate_table (struct isis_area *area, struct route_table *table) if (drnode->info == rnode->info) drnode->info = NULL; } -#endif isis_route_delete (&rnode->p, table); } @@ -585,10 +568,8 @@ isis_route_validate_merge (struct isis_area *area, int family) if (family == AF_INET) table = area->route_table[0]; -#ifdef HAVE_IPV6 else if (family == AF_INET6) table = area->route_table6[0]; -#endif for (rnode = route_top (table); rnode; rnode = route_next (rnode)) { @@ -600,10 +581,8 @@ isis_route_validate_merge (struct isis_area *area, int family) if (family == AF_INET) table = area->route_table[1]; -#ifdef HAVE_IPV6 else if (family == AF_INET6) table = area->route_table6[1]; -#endif for (rnode = route_top (table); rnode; rnode = route_next (rnode)) { @@ -634,14 +613,12 @@ isis_route_validate (struct isis_area *area) else isis_route_validate_merge (area, AF_INET); -#ifdef HAVE_IPV6 if (area->is_type == IS_LEVEL_1) isis_route_validate_table (area, area->route_table6[0]); else if (area->is_type == IS_LEVEL_2) isis_route_validate_table (area, area->route_table6[1]); else isis_route_validate_merge (area, AF_INET6); -#endif if (!area->circuit_list) { return; diff --git a/isisd/isis_route.h b/isisd/isis_route.h index 0d2379cbe8..de23070aa8 100644 --- a/isisd/isis_route.h +++ b/isisd/isis_route.h @@ -25,7 +25,6 @@ #ifndef _ZEBRA_ISIS_ROUTE_H #define _ZEBRA_ISIS_ROUTE_H -#ifdef HAVE_IPV6 struct isis_nexthop6 { ifindex_t ifindex; @@ -33,7 +32,6 @@ struct isis_nexthop6 struct in6_addr router_address6; unsigned int lock; }; -#endif /* HAVE_IPV6 */ struct isis_nexthop { @@ -52,9 +50,7 @@ struct isis_route_info u_int32_t cost; u_int32_t depth; struct list *nexthops; -#ifdef HAVE_IPV6 struct list *nexthops6; -#endif /* HAVE_IPV6 */ }; struct isis_route_info *isis_route_create (struct prefix *prefix, diff --git a/isisd/isis_spf.c b/isisd/isis_spf.c index 041f2ed3f6..086f5b23da 100644 --- a/isisd/isis_spf.c +++ b/isisd/isis_spf.c @@ -139,14 +139,12 @@ vtype2string (enum vertextype vtype) case VTYPE_IPREACH_TE: return "IP TE"; break; -#ifdef HAVE_IPV6 case VTYPE_IP6REACH_INTERNAL: return "IP6 internal"; break; case VTYPE_IP6REACH_EXTERNAL: return "IP6 external"; break; -#endif /* HAVE_IPV6 */ default: return "UNKNOWN"; } @@ -170,10 +168,8 @@ vid2string (struct isis_vertex *vertex, char * buff, int size) case VTYPE_IPREACH_INTERNAL: case VTYPE_IPREACH_EXTERNAL: case VTYPE_IPREACH_TE: -#ifdef HAVE_IPV6 case VTYPE_IP6REACH_INTERNAL: case VTYPE_IP6REACH_EXTERNAL: -#endif /* HAVE_IPV6 */ prefix2str ((struct prefix *) &vertex->N.prefix, buff, size); break; default: @@ -205,10 +201,8 @@ isis_vertex_new (void *id, enum vertextype vtype) case VTYPE_IPREACH_INTERNAL: case VTYPE_IPREACH_EXTERNAL: case VTYPE_IPREACH_TE: -#ifdef HAVE_IPV6 case VTYPE_IP6REACH_INTERNAL: case VTYPE_IP6REACH_EXTERNAL: -#endif /* HAVE_IPV6 */ memcpy (&vertex->N.prefix, (struct prefix *) id, sizeof (struct prefix)); break; @@ -314,20 +308,16 @@ spftree_area_init (struct isis_area *area) { if (area->spftree[0] == NULL) area->spftree[0] = isis_spftree_new (area); -#ifdef HAVE_IPV6 if (area->spftree6[0] == NULL) area->spftree6[0] = isis_spftree_new (area); -#endif } if (area->is_type & IS_LEVEL_2) { if (area->spftree[1] == NULL) area->spftree[1] = isis_spftree_new (area); -#ifdef HAVE_IPV6 if (area->spftree6[1] == NULL) area->spftree6[1] = isis_spftree_new (area); -#endif } return; @@ -343,13 +333,11 @@ spftree_area_del (struct isis_area *area) isis_spftree_del (area->spftree[0]); area->spftree[0] = NULL; } -#ifdef HAVE_IPV6 if (area->spftree6[0]) { isis_spftree_del (area->spftree6[0]); area->spftree6[0] = NULL; } -#endif } if (area->is_type & IS_LEVEL_2) @@ -359,13 +347,11 @@ spftree_area_del (struct isis_area *area) isis_spftree_del (area->spftree[1]); area->spftree[1] = NULL; } -#ifdef HAVE_IPV6 if (area->spftree6[1] != NULL) { isis_spftree_del (area->spftree6[1]); area->spftree6[1] = NULL; } -#endif } return; @@ -378,20 +364,16 @@ spftree_area_adj_del (struct isis_area *area, struct isis_adjacency *adj) { if (area->spftree[0] != NULL) isis_spftree_adj_del (area->spftree[0], adj); -#ifdef HAVE_IPV6 if (area->spftree6[0] != NULL) isis_spftree_adj_del (area->spftree6[0], adj); -#endif } if (area->is_type & IS_LEVEL_2) { if (area->spftree[1] != NULL) isis_spftree_adj_del (area->spftree[1], adj); -#ifdef HAVE_IPV6 if (area->spftree6[1] != NULL) isis_spftree_adj_del (area->spftree6[1], adj); -#endif } return; @@ -475,10 +457,8 @@ isis_find_vertex (struct list *list, void *id, enum vertextype vtype) case VTYPE_IPREACH_INTERNAL: case VTYPE_IPREACH_EXTERNAL: case VTYPE_IPREACH_TE: -#ifdef HAVE_IPV6 case VTYPE_IP6REACH_INTERNAL: case VTYPE_IP6REACH_EXTERNAL: -#endif /* HAVE_IPV6 */ p1 = (struct prefix *) id; p2 = (struct prefix *) &vertex->N.id; if (p1->family == p2->family && p1->prefixlen == p2->prefixlen && @@ -718,9 +698,7 @@ isis_spf_process_lsp (struct isis_spftree *spftree, struct isis_lsp *lsp, struct te_ipv4_reachability *te_ipv4_reach; enum vertextype vtype; struct prefix prefix; -#ifdef HAVE_IPV6 struct ipv6_reachability *ip6reach; -#endif /* HAVE_IPV6 */ static const u_char null_sysid[ISIS_SYS_ID_LEN]; if (!speaks (lsp->tlv_data.nlpids, family)) @@ -820,7 +798,6 @@ lspfragloop: family, parent); } } -#ifdef HAVE_IPV6 if (family == AF_INET6 && lsp->tlv_data.ipv6_reachs) { prefix.family = AF_INET6; @@ -839,7 +816,6 @@ lspfragloop: family, parent); } } -#endif /* HAVE_IPV6 */ if (fragnode == NULL) fragnode = listhead (lsp->lspu.frags); @@ -939,9 +915,7 @@ isis_spf_preload_tent (struct isis_spftree *spftree, int level, int retval = ISIS_OK; u_char lsp_id[ISIS_SYS_ID_LEN + 2]; static u_char null_lsp_id[ISIS_SYS_ID_LEN + 2]; -#ifdef HAVE_IPV6 struct prefix_ipv6 *ipv6; -#endif /* HAVE_IPV6 */ for (ALL_LIST_ELEMENTS_RO (spftree->area->circuit_list, cnode, circuit)) { @@ -951,10 +925,8 @@ isis_spf_preload_tent (struct isis_spftree *spftree, int level, continue; if (family == AF_INET && !circuit->ip_router) continue; -#ifdef HAVE_IPV6 if (family == AF_INET6 && !circuit->ipv6_router) continue; -#endif /* HAVE_IPV6 */ /* * Add IP(v6) addresses of this circuit */ @@ -970,7 +942,6 @@ isis_spf_preload_tent (struct isis_spftree *spftree, int level, NULL, 0, family, parent); } } -#ifdef HAVE_IPV6 if (family == AF_INET6) { prefix.family = AF_INET6; @@ -983,7 +954,6 @@ isis_spf_preload_tent (struct isis_spftree *spftree, int level, &prefix, NULL, 0, family, parent); } } -#endif /* HAVE_IPV6 */ if (circuit->circ_type == CIRCUIT_T_BROADCAST) { /* @@ -1185,20 +1155,16 @@ isis_run_spf (struct isis_area *area, int level, int family, u_char *sysid) if (family == AF_INET) spftree = area->spftree[level - 1]; -#ifdef HAVE_IPV6 else if (family == AF_INET6) spftree = area->spftree6[level - 1]; -#endif assert (spftree); assert (sysid); /* Make all routes in current route table inactive. */ if (family == AF_INET) table = area->route_table[level - 1]; -#ifdef HAVE_IPV6 else if (family == AF_INET6) table = area->route_table6[level - 1]; -#endif isis_route_invalidate_table (area, table); @@ -1382,7 +1348,6 @@ isis_spf_schedule (struct isis_area *area, int level) return ISIS_OK; } -#ifdef HAVE_IPV6 static int isis_run_spf6_l1 (struct thread *thread) { @@ -1479,7 +1444,6 @@ isis_spf_schedule6 (struct isis_area *area, int level) return retval; } -#endif static void isis_print_paths (struct vty *vty, struct list *paths, u_char *root_sysid) @@ -1569,7 +1533,6 @@ DEFUN (show_isis_topology, isis_print_paths (vty, area->spftree[level]->paths, isis->sysid); vty_out (vty, "%s", VTY_NEWLINE); } -#ifdef HAVE_IPV6 if (area->ipv6_circuits > 0 && area->spftree6[level] && area->spftree6[level]->paths->count > 0) { @@ -1579,7 +1542,6 @@ DEFUN (show_isis_topology, isis_print_paths (vty, area->spftree6[level]->paths, isis->sysid); vty_out (vty, "%s", VTY_NEWLINE); } -#endif /* HAVE_IPV6 */ } vty_out (vty, "%s", VTY_NEWLINE); @@ -1615,7 +1577,6 @@ DEFUN (show_isis_topology_l1, isis_print_paths (vty, area->spftree[0]->paths, isis->sysid); vty_out (vty, "%s", VTY_NEWLINE); } -#ifdef HAVE_IPV6 if (area->ipv6_circuits > 0 && area->spftree6[0] && area->spftree6[0]->paths->count > 0) { @@ -1624,7 +1585,6 @@ DEFUN (show_isis_topology_l1, isis_print_paths (vty, area->spftree6[0]->paths, isis->sysid); vty_out (vty, "%s", VTY_NEWLINE); } -#endif /* HAVE_IPV6 */ vty_out (vty, "%s", VTY_NEWLINE); } @@ -1658,7 +1618,6 @@ DEFUN (show_isis_topology_l2, isis_print_paths (vty, area->spftree[1]->paths, isis->sysid); vty_out (vty, "%s", VTY_NEWLINE); } -#ifdef HAVE_IPV6 if (area->ipv6_circuits > 0 && area->spftree6[1] && area->spftree6[1]->paths->count > 0) { @@ -1667,7 +1626,6 @@ DEFUN (show_isis_topology_l2, isis_print_paths (vty, area->spftree6[1]->paths, isis->sysid); vty_out (vty, "%s", VTY_NEWLINE); } -#endif /* HAVE_IPV6 */ vty_out (vty, "%s", VTY_NEWLINE); } diff --git a/isisd/isis_spf.h b/isisd/isis_spf.h index aa543b705d..0e42cac81f 100644 --- a/isisd/isis_spf.h +++ b/isisd/isis_spf.h @@ -33,12 +33,9 @@ enum vertextype VTYPE_ES, VTYPE_IPREACH_INTERNAL, VTYPE_IPREACH_EXTERNAL, - VTYPE_IPREACH_TE -#ifdef HAVE_IPV6 - , + VTYPE_IPREACH_TE, VTYPE_IP6REACH_INTERNAL, VTYPE_IP6REACH_EXTERNAL -#endif /* HAVE_IPV6 */ }; /* @@ -83,7 +80,5 @@ void spftree_area_adj_del (struct isis_area *area, struct isis_adjacency *adj); int isis_spf_schedule (struct isis_area *area, int level); void isis_spf_cmds_init (void); -#ifdef HAVE_IPV6 int isis_spf_schedule6 (struct isis_area *area, int level); -#endif #endif /* _ZEBRA_ISIS_SPF_H */ diff --git a/isisd/isis_tlv.c b/isisd/isis_tlv.c index 1d29d78287..c1526af314 100644 --- a/isisd/isis_tlv.c +++ b/isisd/isis_tlv.c @@ -81,12 +81,10 @@ free_tlvs (struct tlvs *tlvs) list_delete (tlvs->ipv4_ext_reachs); if (tlvs->te_ipv4_reachs) list_delete (tlvs->te_ipv4_reachs); -#ifdef HAVE_IPV6 if (tlvs->ipv6_addrs) list_delete (tlvs->ipv6_addrs); if (tlvs->ipv6_reachs) list_delete (tlvs->ipv6_reachs); -#endif /* HAVE_IPV6 */ memset (tlvs, 0, sizeof (struct tlvs)); @@ -111,11 +109,9 @@ parse_tlvs (char *areatag, u_char * stream, int size, u_int32_t * expected, struct in_addr *ipv4_addr; struct ipv4_reachability *ipv4_reach; struct te_ipv4_reachability *te_ipv4_reach; -#ifdef HAVE_IPV6 struct in6_addr *ipv6_addr; struct ipv6_reachability *ipv6_reach; int prefix_octets; -#endif /* HAVE_IPV6 */ int value_len, retval = ISIS_OK; u_char *start = stream, *pnt = stream, *endpnt; @@ -626,7 +622,6 @@ parse_tlvs (char *areatag, u_char * stream, int size, u_int32_t * expected, pnt = endpnt; break; -#ifdef HAVE_IPV6 case IPV6_ADDR: /* +-------+-------+-------+-------+-------+-------+-------+-------+ * + IP version 6 address + 16 @@ -696,7 +691,6 @@ parse_tlvs (char *areatag, u_char * stream, int size, u_int32_t * expected, pnt = endpnt; break; -#endif /* HAVE_IPV6 */ case WAY3_HELLO: /* +---------------------------------------------------------------+ @@ -1095,7 +1089,6 @@ tlv_add_te_ipv4_reachs (struct list *te_ipv4_reachs, struct stream *stream) return add_tlv (TE_IPV4_REACHABILITY, pos - value, value, stream); } -#ifdef HAVE_IPV6 int tlv_add_ipv6_addrs (struct list *ipv6_addrs, struct stream *stream) { @@ -1152,7 +1145,6 @@ tlv_add_ipv6_reachs (struct list *ipv6_reachs, struct stream *stream) return add_tlv (IPV6_REACHABILITY, pos - value, value, stream); } -#endif /* HAVE_IPV6 */ int tlv_add_padding (struct stream *stream) diff --git a/isisd/isis_tlv.h b/isisd/isis_tlv.h index 5a39d564dc..bf2d51daa1 100644 --- a/isisd/isis_tlv.h +++ b/isisd/isis_tlv.h @@ -231,7 +231,6 @@ struct idrp_info u_char *value; }; -#ifdef HAVE_IPV6 struct ipv6_reachability { u_int32_t metric; @@ -250,7 +249,6 @@ struct ipv6_reachability #define DISTRIBUTION_EXTERNAL 0x40 #define CTRL_INFO_SUBTLVS 0x20 -#endif /* HAVE_IPV6 */ /* * Pointer to each tlv type, filled by parse_tlvs() @@ -272,10 +270,8 @@ struct tlvs struct list *ipv4_int_reachs; struct list *ipv4_ext_reachs; struct list *te_ipv4_reachs; -#ifdef HAVE_IPV6 struct list *ipv6_addrs; struct list *ipv6_reachs; -#endif struct isis_passwd auth_info; }; @@ -330,10 +326,8 @@ int tlv_add_lsp_entries (struct list *lsps, struct stream *stream); int tlv_add_ipv4_int_reachs (struct list *ipv4_reachs, struct stream *stream); int tlv_add_ipv4_ext_reachs (struct list *ipv4_reachs, struct stream *stream); int tlv_add_te_ipv4_reachs (struct list *te_ipv4_reachs, struct stream *stream); -#ifdef HAVE_IPV6 int tlv_add_ipv6_addrs (struct list *ipv6_addrs, struct stream *stream); int tlv_add_ipv6_reachs (struct list *ipv6_reachs, struct stream *stream); -#endif /* HAVE_IPV6 */ int tlv_add_padding (struct stream *stream); diff --git a/isisd/isis_zebra.c b/isisd/isis_zebra.c index 646c5fa88e..dfb9b4d7ab 100644 --- a/isisd/isis_zebra.c +++ b/isisd/isis_zebra.c @@ -187,10 +187,8 @@ isis_zebra_if_address_add (int command, struct zclient *zclient, #ifdef EXTREME_DEBUG if (p->family == AF_INET) zlog_debug ("connected IP address %s", buf); -#ifdef HAVE_IPV6 if (p->family == AF_INET6) zlog_debug ("connected IPv6 address %s", buf); -#endif /* HAVE_IPV6 */ #endif /* EXTREME_DEBUG */ if (if_is_operative (c->ifp)) isis_circuit_add_addr (circuit_scan_by_ifp (c->ifp), c); @@ -223,10 +221,8 @@ isis_zebra_if_address_del (int command, struct zclient *client, if (p->family == AF_INET) zlog_debug ("disconnected IP address %s", buf); -#ifdef HAVE_IPV6 if (p->family == AF_INET6) zlog_debug ("disconnected IPv6 address %s", buf); -#endif /* HAVE_IPV6 */ #endif /* EXTREME_DEBUG */ if (if_is_operative (ifp)) @@ -352,7 +348,6 @@ isis_zebra_route_del_ipv4 (struct prefix *prefix, return; } -#ifdef HAVE_IPV6 static void isis_zebra_route_add_ipv6 (struct prefix *prefix, struct isis_route_info *route_info) @@ -518,8 +513,6 @@ isis_zebra_route_del_ipv6 (struct prefix *prefix, XFREE (MTYPE_ISIS_TMP, ifindex_list); } -#endif /* HAVE_IPV6 */ - void isis_zebra_route_update (struct prefix *prefix, struct isis_route_info *route_info) @@ -535,19 +528,15 @@ isis_zebra_route_update (struct prefix *prefix, { if (prefix->family == AF_INET) isis_zebra_route_add_ipv4 (prefix, route_info); -#ifdef HAVE_IPV6 else if (prefix->family == AF_INET6) isis_zebra_route_add_ipv6 (prefix, route_info); -#endif /* HAVE_IPV6 */ } else { if (prefix->family == AF_INET) isis_zebra_route_del_ipv4 (prefix, route_info); -#ifdef HAVE_IPV6 else if (prefix->family == AF_INET6) isis_zebra_route_del_ipv6 (prefix, route_info); -#endif /* HAVE_IPV6 */ } return; } @@ -709,10 +698,8 @@ isis_zebra_init (struct thread_master *master) zclient->interface_link_params = isis_zebra_link_params; zclient->redistribute_route_ipv4_add = isis_zebra_read_ipv4; zclient->redistribute_route_ipv4_del = isis_zebra_read_ipv4; -#ifdef HAVE_IPV6 zclient->redistribute_route_ipv6_add = isis_zebra_read_ipv6; zclient->redistribute_route_ipv6_del = isis_zebra_read_ipv6; -#endif /* HAVE_IPV6 */ return; } diff --git a/isisd/isisd.c b/isisd/isisd.c index 1d4dab4fd3..9bef250883 100644 --- a/isisd/isisd.c +++ b/isisd/isisd.c @@ -89,9 +89,7 @@ isis_new (unsigned long process_id) isis->init_circ_list = list_new (); isis->uptime = time (NULL); isis->nexthops = list_new (); -#ifdef HAVE_IPV6 isis->nexthops6 = list_new (); -#endif /* HAVE_IPV6 */ dyn_cache_init (); /* * uncomment the next line for full debugs @@ -124,17 +122,13 @@ isis_area_create (const char *area_tag) { area->lspdb[0] = lsp_db_init (); area->route_table[0] = route_table_init (); -#ifdef HAVE_IPV6 area->route_table6[0] = route_table_init (); -#endif /* HAVE_IPV6 */ } if (area->is_type & IS_LEVEL_2) { area->lspdb[1] = lsp_db_init (); area->route_table[1] = route_table_init (); -#ifdef HAVE_IPV6 area->route_table6[1] = route_table_init (); -#endif /* HAVE_IPV6 */ } spftree_area_init (area); @@ -231,9 +225,7 @@ isis_area_destroy (struct vty *vty, const char *area_tag) for (ALL_LIST_ELEMENTS (area->circuit_list, node, nnode, circuit)) { circuit->ip_router = 0; -#ifdef HAVE_IPV6 circuit->ipv6_router = 0; -#endif isis_csm_state_change (ISIS_DISABLE, circuit, area); } list_delete (area->circuit_list); @@ -267,7 +259,6 @@ isis_area_destroy (struct vty *vty, const char *area_tag) route_table_finish (area->route_table[1]); area->route_table[1] = NULL; } -#ifdef HAVE_IPV6 if (area->route_table6[0]) { route_table_finish (area->route_table6[0]); @@ -278,7 +269,6 @@ isis_area_destroy (struct vty *vty, const char *area_tag) route_table_finish (area->route_table6[1]); area->route_table6[1] = NULL; } -#endif /* HAVE_IPV6 */ isis_redist_area_finish(area); @@ -1355,7 +1345,6 @@ DEFUN (show_isis_summary, vty_out (vty, " run count : %d%s", spftree->runcount, VTY_NEWLINE); -#ifdef HAVE_IPV6 spftree = area->spftree6[level - 1]; if (spftree->pending) vty_out (vty, " IPv6 SPF: (pending)%s", VTY_NEWLINE); @@ -1374,7 +1363,6 @@ DEFUN (show_isis_summary, vty_out (vty, " run count : %d%s", spftree->runcount, VTY_NEWLINE); -#endif } } vty_out (vty, "%s", VTY_NEWLINE); @@ -1658,25 +1646,21 @@ area_resign_level (struct isis_area *area, int level) isis_spftree_del (area->spftree[level - 1]); area->spftree[level - 1] = NULL; } -#ifdef HAVE_IPV6 if (area->spftree6[level - 1]) { isis_spftree_del (area->spftree6[level - 1]); area->spftree6[level - 1] = NULL; } -#endif if (area->route_table[level - 1]) { route_table_finish (area->route_table[level - 1]); area->route_table[level - 1] = NULL; } -#ifdef HAVE_IPV6 if (area->route_table6[level - 1]) { route_table_finish (area->route_table6[level - 1]); area->route_table6[level - 1] = NULL; } -#endif /* HAVE_IPV6 */ sched_debug("ISIS (%s): Resigned from L%d - canceling LSP regeneration timer.", area->area_tag, level); @@ -1707,10 +1691,8 @@ isis_area_is_type_set(struct isis_area *area, int is_type) area->lspdb[1] = lsp_db_init (); if (area->route_table[1] == NULL) area->route_table[1] = route_table_init (); -#ifdef HAVE_IPV6 if (area->route_table6[1] == NULL) area->route_table6[1] = route_table_init (); -#endif /* HAVE_IPV6 */ break; case IS_LEVEL_1_AND_2: @@ -1728,10 +1710,8 @@ isis_area_is_type_set(struct isis_area *area, int is_type) area->lspdb[0] = lsp_db_init (); if (area->route_table[0] == NULL) area->route_table[0] = route_table_init (); -#ifdef HAVE_IPV6 if (area->route_table6[0] == NULL) area->route_table6[0] = route_table_init (); -#endif /* HAVE_IPV6 */ break; default: diff --git a/isisd/isisd.h b/isisd/isisd.h index f7dc0efe25..efbfafc5fb 100644 --- a/isisd/isisd.h +++ b/isisd/isisd.h @@ -48,9 +48,7 @@ struct isis struct list *area_list; /* list of IS-IS areas */ struct list *init_circ_list; struct list *nexthops; /* IPv4 next hops from this IS */ -#ifdef HAVE_IPV6 struct list *nexthops6; /* IPv6 next hops from this IS */ -#endif /* HAVE_IPV6 */ u_char max_area_addrs; /* maximumAreaAdresses */ struct area_addr *man_area_addrs; /* manualAreaAddresses */ u_int32_t debugs; /* bitmap for debug */ @@ -71,10 +69,8 @@ struct isis_area dict_t *lspdb[ISIS_LEVELS]; /* link-state dbs */ struct isis_spftree *spftree[ISIS_LEVELS]; /* The v4 SPTs */ struct route_table *route_table[ISIS_LEVELS]; /* IPv4 routes */ -#ifdef HAVE_IPV6 struct isis_spftree *spftree6[ISIS_LEVELS]; /* The v6 SPTs */ struct route_table *route_table6[ISIS_LEVELS]; /* IPv6 routes */ -#endif #define DEFAULT_LSP_MTU 1497 unsigned int lsp_mtu; /* Size of LSPs to generate */ struct list *circuit_list; /* IS-IS circuits */ @@ -124,9 +120,7 @@ struct isis_area int ip_circuits; /* logging adjacency changes? */ u_char log_adj_changes; -#ifdef HAVE_IPV6 int ipv6_circuits; -#endif /* HAVE_IPV6 */ /* Counters */ u_int32_t circuit_state_changes; struct isis_redist redist_settings[REDIST_PROTOCOL_COUNT] diff --git a/lib/bfd.c b/lib/bfd.c index a498daf762..5db08fea60 100644 --- a/lib/bfd.c +++ b/lib/bfd.c @@ -179,11 +179,9 @@ bfd_peer_sendmsg (struct zclient *zclient, struct bfd_info *bfd_info, case AF_INET: stream_put_in_addr (s, (struct in_addr *)dst_ip); break; -#ifdef HAVE_IPV6 case AF_INET6: stream_put(s, dst_ip, 16); break; -#endif default: break; } @@ -207,11 +205,9 @@ bfd_peer_sendmsg (struct zclient *zclient, struct bfd_info *bfd_info, case AF_INET: stream_put_in_addr (s, (struct in_addr *) src_ip); break; - #ifdef HAVE_IPV6 case AF_INET6: stream_put(s, src_ip, 16); break; - #endif default: break; } @@ -221,13 +217,11 @@ bfd_peer_sendmsg (struct zclient *zclient, struct bfd_info *bfd_info, else { stream_putc(s, 0); -#ifdef HAVE_IPV6 if ((family == AF_INET6) && (src_ip)) { stream_putw(s, family); stream_put(s, src_ip, 16); } -#endif if (if_name) { len = strlen(if_name); diff --git a/lib/filter.c b/lib/filter.c index 072d3ddc2e..cd17a562f0 100644 --- a/lib/filter.c +++ b/lib/filter.c @@ -105,7 +105,6 @@ static struct access_master access_master_ipv4 = NULL, }; -#ifdef HAVE_IPV6 /* Static structure for IPv6 access_list's master. */ static struct access_master access_master_ipv6 = { @@ -114,17 +113,14 @@ static struct access_master access_master_ipv6 = NULL, NULL, }; -#endif /* HAVE_IPV6 */ static struct access_master * access_master_get (afi_t afi) { if (afi == AFI_IP) return &access_master_ipv4; -#ifdef HAVE_IPV6 else if (afi == AFI_IP6) return &access_master_ipv6; -#endif /* HAVE_IPV6 */ return NULL; } @@ -434,9 +430,7 @@ void access_list_add_hook (void (*func) (struct access_list *access)) { access_master_ipv4.add_hook = func; -#ifdef HAVE_IPV6 access_master_ipv6.add_hook = func; -#endif /* HAVE_IPV6 */ } /* Delete hook function. */ @@ -444,9 +438,7 @@ void access_list_delete_hook (void (*func) (struct access_list *access)) { access_master_ipv4.delete_hook = func; -#ifdef HAVE_IPV6 access_master_ipv6.delete_hook = func; -#endif /* HAVE_IPV6 */ } /* Add new filter to the end of specified access_list. */ @@ -1289,7 +1281,6 @@ filter_set_zebra (struct vty *vty, const char *name_str, const char *type_str, return CMD_WARNING; } } -#ifdef HAVE_IPV6 else if (afi == AFI_IP6) { ret = str2prefix_ipv6 (prefix_str, (struct prefix_ipv6 *) &p); @@ -1300,7 +1291,6 @@ filter_set_zebra (struct vty *vty, const char *name_str, const char *type_str, return CMD_WARNING; } } -#endif /* HAVE_IPV6 */ else return CMD_WARNING; @@ -1530,7 +1520,6 @@ DEFUN (no_access_list_remark_comment, } -#ifdef HAVE_IPV6 DEFUN (ipv6_access_list, ipv6_access_list_cmd, "ipv6 access-list WORD X:X::X:X/M", @@ -1716,8 +1705,6 @@ DEFUN (no_ipv6_access_list_remark_comment, { return no_ipv6_access_list_remark (self, vty, argc, argv); } - -#endif /* HAVE_IPV6 */ void config_write_access_zebra (struct vty *, struct filter *); void config_write_access_cisco (struct vty *, struct filter *); @@ -1855,7 +1842,6 @@ DEFUN (show_ip_access_list_name, return filter_show (vty, argv[idx_acl]->arg, AFI_IP); } -#ifdef HAVE_IPV6 DEFUN (show_ipv6_access_list, show_ipv6_access_list_cmd, "show ipv6 access-list", @@ -1877,7 +1863,6 @@ DEFUN (show_ipv6_access_list_name, int idx_word = 3; return filter_show (vty, argv[idx_word]->arg, AFI_IP6); } -#endif /* HAVE_IPV6 */ void config_write_access_cisco (struct vty *vty, struct filter *mfilter) @@ -2109,7 +2094,6 @@ access_list_init_ipv4 (void) install_element (CONFIG_NODE, &no_access_list_remark_comment_cmd); } -#ifdef HAVE_IPV6 static struct cmd_node access_ipv6_node = { ACCESS_IPV6_NODE, @@ -2172,22 +2156,17 @@ access_list_init_ipv6 (void) install_element (CONFIG_NODE, &no_ipv6_access_list_remark_cmd); install_element (CONFIG_NODE, &no_ipv6_access_list_remark_comment_cmd); } -#endif /* HAVE_IPV6 */ void access_list_init () { access_list_init_ipv4 (); -#ifdef HAVE_IPV6 access_list_init_ipv6(); -#endif /* HAVE_IPV6 */ } void access_list_reset () { access_list_reset_ipv4 (); -#ifdef HAVE_IPV6 access_list_reset_ipv6(); -#endif /* HAVE_IPV6 */ } diff --git a/lib/if.c b/lib/if.c index 0a1a8f6a26..20f792b8f8 100644 --- a/lib/if.c +++ b/lib/if.c @@ -1019,11 +1019,9 @@ connected_same_prefix (struct prefix *p1, struct prefix *p2) if (p1->family == AF_INET && IPV4_ADDR_SAME (&p1->u.prefix4, &p2->u.prefix4)) return 1; -#ifdef HAVE_IPV6 if (p1->family == AF_INET6 && IPV6_ADDR_SAME (&p1->u.prefix6, &p2->u.prefix6)) return 1; -#endif /* HAVE_IPV6 */ } return 0; } diff --git a/lib/plist.c b/lib/plist.c index 1f5e595fd8..279c85d6d6 100644 --- a/lib/plist.c +++ b/lib/plist.c @@ -103,7 +103,6 @@ static struct prefix_master prefix_master_ipv4 = PLC_MAXLEVELV4, }; -#ifdef HAVE_IPV6 /* Static structure of IPv6 prefix-list's master. */ static struct prefix_master prefix_master_ipv6 = { @@ -115,7 +114,6 @@ static struct prefix_master prefix_master_ipv6 = NULL, PLC_MAXLEVELV6, }; -#endif /* HAVE_IPV6*/ /* Static structure of BGP ORF prefix_list's master. */ static struct prefix_master prefix_master_orf_v4 = @@ -408,9 +406,7 @@ void prefix_list_add_hook (void (*func) (struct prefix_list *plist)) { prefix_master_ipv4.add_hook = func; -#ifdef HAVE_IPV6 prefix_master_ipv6.add_hook = func; -#endif /* HAVE_IPV6 */ } /* Delete hook function. */ @@ -418,9 +414,7 @@ void prefix_list_delete_hook (void (*func) (struct prefix_list *plist)) { prefix_master_ipv4.delete_hook = func; -#ifdef HAVE_IPV6 prefix_master_ipv6.delete_hook = func; -#endif /* HAVE_IPVt6 */ } /* Calculate new sequential number. */ @@ -1102,7 +1096,6 @@ vty_prefix_list_uninstall (struct vty *vty, afi_t afi, const char *name, return CMD_WARNING; } } -#ifdef HAVE_IPV6 else if (afi == AFI_IP6) { if (strncmp ("any", prefix, strlen (prefix)) == 0) @@ -1120,7 +1113,6 @@ vty_prefix_list_uninstall (struct vty *vty, afi_t afi, const char *name, return CMD_WARNING; } } -#endif /* HAVE_IPV6 */ /* Lookup prefix entry. */ pentry = prefix_list_entry_lookup(plist, &p, type, seqnum, lenum, genum); @@ -2128,7 +2120,6 @@ DEFUN (clear_ip_prefix_list_name_prefix, return vty_clear_prefix_list (vty, AFI_IP, argv[idx_word]->arg, argv[idx_ipv4_prefixlen]->arg); } -#ifdef HAVE_IPV6 DEFUN (ipv6_prefix_list, ipv6_prefix_list_cmd, "ipv6 prefix-list WORD ", @@ -2839,7 +2830,6 @@ DEFUN (clear_ipv6_prefix_list_name_prefix, int idx_ipv6_prefixlen = 4; return vty_clear_prefix_list (vty, AFI_IP6, argv[idx_word]->arg, argv[idx_ipv6_prefixlen]->arg); } -#endif /* HAVE_IPV6 */ /* Configuration write function. */ static int @@ -3214,7 +3204,6 @@ prefix_list_init_ipv4 (void) install_element (ENABLE_NODE, &clear_ip_prefix_list_name_prefix_cmd); } -#ifdef HAVE_IPV6 /* Prefix-list node. */ static struct cmd_node prefix_ipv6_node = { @@ -3279,15 +3268,12 @@ prefix_list_init_ipv6 (void) install_element (ENABLE_NODE, &clear_ipv6_prefix_list_name_cmd); install_element (ENABLE_NODE, &clear_ipv6_prefix_list_name_prefix_cmd); } -#endif /* HAVE_IPV6 */ void prefix_list_init () { prefix_list_init_ipv4 (); -#ifdef HAVE_IPV6 prefix_list_init_ipv6 (); -#endif /* HAVE_IPV6 */ } void diff --git a/lib/prefix.c b/lib/prefix.c index 84a04c5300..8289593781 100644 --- a/lib/prefix.c +++ b/lib/prefix.c @@ -207,10 +207,8 @@ afi2family (afi_t afi) { if (afi == AFI_IP) return AF_INET; -#ifdef HAVE_IPV6 else if (afi == AFI_IP6) return AF_INET6; -#endif /* HAVE_IPV6 */ else if (afi == AFI_ETHER) return AF_ETHERNET; return 0; @@ -221,10 +219,8 @@ family2afi (int family) { if (family == AF_INET) return AFI_IP; -#ifdef HAVE_IPV6 else if (family == AF_INET6) return AFI_IP6; -#endif /* HAVE_IPV6 */ else if (family == AF_ETHERNET) return AFI_ETHER; return 0; @@ -302,10 +298,8 @@ prefix_copy (struct prefix *dest, const struct prefix *src) if (src->family == AF_INET) dest->u.prefix4 = src->u.prefix4; -#ifdef HAVE_IPV6 else if (src->family == AF_INET6) dest->u.prefix6 = src->u.prefix6; -#endif /* HAVE_IPV6 */ else if (src->family == AF_UNSPEC) { dest->u.lp.id = src->u.lp.id; @@ -345,11 +339,9 @@ prefix_same (const struct prefix *p1, const struct prefix *p2) if (p1->family == AF_INET) if (IPV4_ADDR_SAME (&p1->u.prefix4.s_addr, &p2->u.prefix4.s_addr)) return 1; -#ifdef HAVE_IPV6 if (p1->family == AF_INET6 ) if (IPV6_ADDR_SAME (&p1->u.prefix6.s6_addr, &p2->u.prefix6.s6_addr)) return 1; -#endif /* HAVE_IPV6 */ if (p1->family == AF_ETHERNET) { if (!memcmp(p1->u.prefix_eth.octet, p2->u.prefix_eth.octet, ETHER_ADDR_LEN)) return 1; @@ -414,10 +406,8 @@ prefix_common_bits (const struct prefix *p1, const struct prefix *p2) if (p1->family == AF_INET) length = IPV4_MAX_BYTELEN; -#ifdef HAVE_IPV6 if (p1->family == AF_INET6) length = IPV6_MAX_BYTELEN; -#endif if (p1->family != p2->family || !length) return -1; @@ -441,10 +431,8 @@ prefix_family_str (const struct prefix *p) { if (p->family == AF_INET) return "inet"; -#ifdef HAVE_IPV6 if (p->family == AF_INET6) return "inet6"; -#endif /* HAVE_IPV6 */ if (p->family == AF_ETHERNET) return "ether"; return "unspec"; @@ -617,8 +605,6 @@ prefix_ipv4_any (const struct prefix_ipv4 *p) return (p->prefix.s_addr == 0 && p->prefixlen == 0); } -#ifdef HAVE_IPV6 - /* Allocate a new ip version 6 route */ struct prefix_ipv6 * prefix_ipv6_new (void) @@ -749,7 +735,6 @@ str2in6_addr (const char *str, struct in6_addr *addr) addr->s6_addr[i] = x & 0xff; } } -#endif /* HAVE_IPV6 */ void apply_mask (struct prefix *p) @@ -759,11 +744,9 @@ apply_mask (struct prefix *p) case AF_INET: apply_mask_ipv4 ((struct prefix_ipv4 *)p); break; -#ifdef HAVE_IPV6 case AF_INET6: apply_mask_ipv6 ((struct prefix_ipv6 *)p); break; -#endif /* HAVE_IPV6 */ default: break; } @@ -786,7 +769,6 @@ sockunion2prefix (const union sockunion *dest, p->prefixlen = ip_masklen (mask->sin.sin_addr); return (struct prefix *) p; } -#ifdef HAVE_IPV6 if (dest->sa.sa_family == AF_INET6) { struct prefix_ipv6 *p; @@ -797,7 +779,6 @@ sockunion2prefix (const union sockunion *dest, memcpy (&p->prefix, &dest->sin6.sin6_addr, sizeof (struct in6_addr)); return (struct prefix *) p; } -#endif /* HAVE_IPV6 */ return NULL; } @@ -815,7 +796,6 @@ sockunion2hostprefix (const union sockunion *su, struct prefix *prefix) p->prefixlen = IPV4_MAX_BITLEN; return (struct prefix *) p; } -#ifdef HAVE_IPV6 if (su->sa.sa_family == AF_INET6) { struct prefix_ipv6 *p; @@ -826,7 +806,6 @@ sockunion2hostprefix (const union sockunion *su, struct prefix *prefix) memcpy (&p->prefix, &su->sin6.sin6_addr, sizeof (struct in6_addr)); return (struct prefix *) p; } -#endif /* HAVE_IPV6 */ return NULL; } @@ -838,10 +817,8 @@ prefix2sockunion (const struct prefix *p, union sockunion *su) su->sa.sa_family = p->family; if (p->family == AF_INET) su->sin.sin_addr = p->u.prefix4; -#ifdef HAVE_IPV6 if (p->family == AF_INET6) memcpy (&su->sin6.sin6_addr, &p->u.prefix6, sizeof (struct in6_addr)); -#endif /* HAVE_IPV6 */ } int @@ -852,11 +829,9 @@ prefix_blen (const struct prefix *p) case AF_INET: return IPV4_MAX_BYTELEN; break; -#ifdef HAVE_IPV6 case AF_INET6: return IPV6_MAX_BYTELEN; break; -#endif /* HAVE_IPV6 */ case AF_ETHERNET: return ETHER_ADDR_LEN; } @@ -874,12 +849,10 @@ str2prefix (const char *str, struct prefix *p) if (ret) return ret; -#ifdef HAVE_IPV6 /* Next we try to convert string to struct prefix_ipv6. */ ret = str2prefix_ipv6 (str, (struct prefix_ipv6 *) p); if (ret) return ret; -#endif /* HAVE_IPV6 */ /* Next we try to convert string to struct prefix_eth. */ ret = str2prefix_eth (str, (struct prefix_eth *) p); @@ -1035,7 +1008,6 @@ netmask_str2prefix_str (const char *net_str, const char *mask_str, return 1; } -#ifdef HAVE_IPV6 /* Utility function for making IPv6 address string. */ const char * inet6_ntoa (struct in6_addr addr) @@ -1045,4 +1017,3 @@ inet6_ntoa (struct in6_addr addr) inet_ntop (AF_INET6, &addr, buf, INET6_ADDRSTRLEN); return buf; } -#endif /* HAVE_IPV6 */ diff --git a/lib/prefix.h b/lib/prefix.h index 85488ccea7..5e4b1f9c83 100644 --- a/lib/prefix.h +++ b/lib/prefix.h @@ -74,9 +74,7 @@ struct prefix { u_char prefix; struct in_addr prefix4; -#ifdef HAVE_IPV6 struct in6_addr prefix6; -#endif /* HAVE_IPV6 */ struct { struct in_addr id; @@ -97,14 +95,12 @@ struct prefix_ipv4 }; /* IPv6 prefix structure. */ -#ifdef HAVE_IPV6 struct prefix_ipv6 { u_char family; u_char prefixlen; struct in6_addr prefix __attribute__ ((aligned (8))); }; -#endif /* HAVE_IPV6 */ struct prefix_ls { @@ -271,7 +267,6 @@ extern in_addr_t ipv4_broadcast_addr (in_addr_t hostaddr, int masklen); extern int netmask_str2prefix_str (const char *, const char *, char *); -#ifdef HAVE_IPV6 extern struct prefix_ipv6 *prefix_ipv6_new (void); extern void prefix_ipv6_free (struct prefix_ipv6 *); extern int str2prefix_ipv6 (const char *, struct prefix_ipv6 *); @@ -298,8 +293,6 @@ static inline int ipv6_martian (struct in6_addr *addr) return 0; } -#endif /* HAVE_IPV6 */ - extern int all_digit (const char *); /* NOTE: This routine expects the address argument in network byte order. */ diff --git a/lib/smux.c b/lib/smux.c index bf38926376..3abfadcd28 100644 --- a/lib/smux.c +++ b/lib/smux.c @@ -154,16 +154,10 @@ static int smux_socket (void) { int ret; -#ifdef HAVE_IPV6 struct addrinfo hints, *res0, *res; int gai; -#else - struct sockaddr_in serv; - struct servent *sp; -#endif int sock = 0; -#ifdef HAVE_IPV6 memset(&hints, 0, sizeof(hints)); hints.ai_family = PF_UNSPEC; hints.ai_socktype = SOCK_STREAM; @@ -183,9 +177,7 @@ smux_socket (void) for(res=res0; res; res=res->ai_next) { if (res->ai_family != AF_INET -#ifdef HAVE_IPV6 && res->ai_family != AF_INET6 -#endif /* HAVE_IPV6 */ ) continue; @@ -206,40 +198,6 @@ smux_socket (void) freeaddrinfo(res0); if (sock < 0) zlog_warn ("Can't connect to SNMP agent with SMUX"); -#else - sock = socket (AF_INET, SOCK_STREAM, 0); - if (sock < 0) - { - zlog_warn ("Can't make socket for SNMP"); - return -1; - } - - memset (&serv, 0, sizeof (struct sockaddr_in)); - serv.sin_family = AF_INET; -#ifdef HAVE_STRUCT_SOCKADDR_IN_SIN_LEN - serv.sin_len = sizeof (struct sockaddr_in); -#endif /* HAVE_STRUCT_SOCKADDR_IN_SIN_LEN */ - - sp = getservbyname ("smux", "tcp"); - if (sp != NULL) - serv.sin_port = sp->s_port; - else - serv.sin_port = htons (SMUX_PORT_DEFAULT); - - serv.sin_addr.s_addr = htonl (INADDR_LOOPBACK); - - sockopt_reuseaddr (sock); - sockopt_reuseport (sock); - - ret = connect (sock, (struct sockaddr *) &serv, sizeof (struct sockaddr_in)); - if (ret < 0) - { - close (sock); - smux_sock = -1; - zlog_warn ("Can't connect to SNMP agent with SMUX"); - return -1; - } -#endif return sock; } diff --git a/lib/sockopt.c b/lib/sockopt.c index 461e1f7f54..2a9f907cb3 100644 --- a/lib/sockopt.c +++ b/lib/sockopt.c @@ -86,7 +86,6 @@ getsockopt_cmsg_data (struct msghdr *msgh, int level, int type) return NULL; } -#ifdef HAVE_IPV6 /* Set IPv6 packet info to the socket. */ int setsockopt_ipv6_pktinfo (int sock, int val) @@ -198,7 +197,6 @@ setsockopt_ipv6_tclass(int sock, int tclass) #endif return ret; } -#endif /* HAVE_IPV6 */ /* * Process multicast socket options for IPv4 in an OS-dependent manner. @@ -444,11 +442,9 @@ setsockopt_ifindex (int af, int sock, ifindex_t val) case AF_INET: ret = setsockopt_ipv4_ifindex (sock, val); break; -#ifdef HAVE_IPV6 case AF_INET6: ret = setsockopt_ipv6_pktinfo (sock, val); break; -#endif default: zlog_warn ("setsockopt_ifindex: unknown address family %d", af); } @@ -535,11 +531,9 @@ getsockopt_ifindex (int af, struct msghdr *msgh) case AF_INET: return (getsockopt_ipv4_ifindex (msgh)); break; -#ifdef HAVE_IPV6 case AF_INET6: return (getsockopt_ipv6_ifindex (msgh)); break; -#endif default: zlog_warn ("getsockopt_ifindex: unknown address family %d", af); return 0; @@ -646,7 +640,6 @@ sockopt_tcp_signature (int sock, union sockunion *su, const char *password) return 0; } -#ifdef HAVE_IPV6 /* If this does not work, then all users of this sockopt will need to * differentiate between IPv4 and IPv6, and keep seperate sockets for * each. @@ -663,7 +656,6 @@ sockopt_tcp_signature (int sock, union sockunion *su, const char *password) su2->sin6.sin6_addr.s6_addr32[2] = htonl(0xffff); memcpy (&su2->sin6.sin6_addr.s6_addr32[3], &su->sin.sin_addr, 4); } -#endif } memset (&md5sig, 0, sizeof (md5sig)); diff --git a/lib/sockopt.h b/lib/sockopt.h index b3ab57ab71..1b7be1e49f 100644 --- a/lib/sockopt.h +++ b/lib/sockopt.h @@ -28,7 +28,6 @@ extern void setsockopt_so_recvbuf (int sock, int size); extern void setsockopt_so_sendbuf (const int sock, int size); extern int getsockopt_so_sendbuf (const int sock); -#ifdef HAVE_IPV6 extern int setsockopt_ipv6_pktinfo (int, int); extern int setsockopt_ipv6_checksum (int, int); extern int setsockopt_ipv6_multicast_hops (int, int); @@ -36,13 +35,7 @@ extern int setsockopt_ipv6_unicast_hops (int, int); extern int setsockopt_ipv6_hoplimit (int, int); extern int setsockopt_ipv6_multicast_loop (int, int); extern int setsockopt_ipv6_tclass (int, int); -#endif /* HAVE_IPV6 */ -/* - * It is OK to reference in6_pktinfo here without a protecting #if - * because this macro will only be used #if HAVE_IPV6, and in6_pktinfo - * is not optional for HAVE_IPV6. - */ #define SOPT_SIZE_CMSG_PKTINFO_IPV6() (sizeof (struct in6_pktinfo)); /* diff --git a/lib/sockunion.c b/lib/sockunion.c index f4b6ce12cc..5b508d1bf8 100644 --- a/lib/sockunion.c +++ b/lib/sockunion.c @@ -38,11 +38,9 @@ inet_sutop (const union sockunion *su, char *str) case AF_INET: inet_ntop (AF_INET, &su->sin.sin_addr, str, INET_ADDRSTRLEN); break; -#ifdef HAVE_IPV6 case AF_INET6: inet_ntop (AF_INET6, &su->sin6.sin6_addr, str, INET6_ADDRSTRLEN); break; -#endif /* HAVE_IPV6 */ } return str; } @@ -63,7 +61,6 @@ str2sockunion (const char *str, union sockunion *su) #endif /* HAVE_STRUCT_SOCKADDR_IN_SIN_LEN */ return 0; } -#ifdef HAVE_IPV6 ret = inet_pton (AF_INET6, str, &su->sin6.sin6_addr); if (ret > 0) /* Valid IPv6 address format. */ { @@ -73,7 +70,6 @@ str2sockunion (const char *str, union sockunion *su) #endif /* SIN6_LEN */ return 0; } -#endif /* HAVE_IPV6 */ return -1; } @@ -87,10 +83,8 @@ sockunion2str (const union sockunion *su, char *buf, size_t len) return buf; case AF_INET: return inet_ntop (AF_INET, &su->sin.sin_addr, buf, len); -#ifdef HAVE_IPV6 case AF_INET6: return inet_ntop (AF_INET6, &su->sin6.sin6_addr, buf, len); -#endif /* HAVE_IPV6 */ } snprintf (buf, len, "(af %d)", sockunion_family(su)); return buf; @@ -114,7 +108,6 @@ sockunion_normalise_mapped (union sockunion *su) { struct sockaddr_in sin; -#ifdef HAVE_IPV6 if (su->sa.sa_family == AF_INET6 && IN6_IS_ADDR_V4MAPPED (&su->sin6.sin6_addr)) { @@ -124,7 +117,6 @@ sockunion_normalise_mapped (union sockunion *su) memcpy (&sin.sin_addr, ((char *)&su->sin6.sin6_addr) + 12, 4); memcpy (su, &sin, sizeof (struct sockaddr_in)); } -#endif /* HAVE_IPV6 */ } /* return sockunion structure : this function should be revised. */ @@ -190,11 +182,9 @@ sockunion_sizeof (const union sockunion *su) case AF_INET: ret = sizeof (struct sockaddr_in); break; -#ifdef HAVE_IPV6 case AF_INET6: ret = sizeof (struct sockaddr_in6); break; -#endif /* AF_INET6 */ } return ret; } @@ -218,7 +208,6 @@ sockunion_connect (int fd, const union sockunion *peersu, unsigned short port, case AF_INET: su.sin.sin_port = port; break; -#ifdef HAVE_IPV6 case AF_INET6: su.sin6.sin6_port = port; #ifdef KAME @@ -229,7 +218,6 @@ sockunion_connect (int fd, const union sockunion *peersu, unsigned short port, } #endif /* KAME */ break; -#endif /* HAVE_IPV6 */ } /* Make socket non-block. */ @@ -299,7 +287,6 @@ sockunion_bind (int sock, union sockunion *su, unsigned short port, if (su_addr == NULL) sockunion2ip (su) = htonl (INADDR_ANY); } -#ifdef HAVE_IPV6 else if (su->sa.sa_family == AF_INET6) { size = sizeof (struct sockaddr_in6); @@ -316,8 +303,6 @@ sockunion_bind (int sock, union sockunion *su, unsigned short port, #endif /* LINUX_IPV6 */ } } -#endif /* HAVE_IPV6 */ - ret = bind (sock, (struct sockaddr *)su, size); if (ret < 0) @@ -388,7 +373,6 @@ sockopt_ttl (int family, int sock, int ttl) return 0; } #endif /* IP_TTL */ -#ifdef HAVE_IPV6 if (family == AF_INET6) { ret = setsockopt (sock, IPPROTO_IPV6, IPV6_UNICAST_HOPS, @@ -401,7 +385,6 @@ sockopt_ttl (int family, int sock, int ttl) } return 0; } -#endif /* HAVE_IPV6 */ return 0; } @@ -469,7 +452,6 @@ sockopt_v6only (int family, int sock) { int ret, on = 1; -#ifdef HAVE_IPV6 #ifdef IPV6_V6ONLY if (family == AF_INET6) { @@ -484,7 +466,6 @@ sockopt_v6only (int family, int sock) return 0; } #endif /* IPV6_V6ONLY */ -#endif /* HAVE_IPV6 */ return 0; } @@ -503,7 +484,6 @@ sockunion_same (const union sockunion *su1, const union sockunion *su2) ret = memcmp (&su1->sin.sin_addr, &su2->sin.sin_addr, sizeof (struct in_addr)); break; -#ifdef HAVE_IPV6 case AF_INET6: ret = memcmp (&su1->sin6.sin6_addr, &su2->sin6.sin6_addr, sizeof (struct in6_addr)); @@ -514,7 +494,6 @@ sockunion_same (const union sockunion *su1, const union sockunion *su2) ret = (su1->sin6.sin6_scope_id == su2->sin6.sin6_scope_id) ? 0 : 1; } break; -#endif /* HAVE_IPV6 */ } if (ret == 0) return 1; @@ -529,10 +508,8 @@ sockunion_hash (const union sockunion *su) { case AF_INET: return jhash_1word(su->sin.sin_addr.s_addr, 0); -#ifdef HAVE_IPV6 case AF_INET6: return jhash2(su->sin6.sin6_addr.s6_addr32, ZEBRA_NUM_OF(su->sin6.sin6_addr.s6_addr32), 0); -#endif /* HAVE_IPV6 */ } return 0; } @@ -544,10 +521,8 @@ family2addrsize(int family) { case AF_INET: return sizeof(struct in_addr); -#ifdef HAVE_IPV6 case AF_INET6: return sizeof(struct in6_addr); -#endif /* HAVE_IPV6 */ } return 0; } @@ -565,10 +540,8 @@ sockunion_get_addr(const union sockunion *su) { case AF_INET: return (const u_char *) &su->sin.sin_addr.s_addr; -#ifdef HAVE_IPV6 case AF_INET6: return (const u_char *) &su->sin6.sin6_addr; -#endif /* HAVE_IPV6 */ } return NULL; } @@ -585,11 +558,9 @@ sockunion_set(union sockunion *su, int family, const u_char *addr, size_t bytes) case AF_INET: memcpy(&su->sin.sin_addr.s_addr, addr, bytes); break; -#ifdef HAVE_IPV6 case AF_INET6: memcpy(&su->sin6.sin6_addr, addr, bytes); break; -#endif /* HAVE_IPV6 */ } } @@ -603,9 +574,7 @@ sockunion_getsockname (int fd) { struct sockaddr sa; struct sockaddr_in sin; -#ifdef HAVE_IPV6 struct sockaddr_in6 sin6; -#endif /* HAVE_IPV6 */ char tmp_buffer[128]; } name; union sockunion *su; @@ -627,7 +596,6 @@ sockunion_getsockname (int fd) memcpy (su, &name, sizeof (struct sockaddr_in)); return su; } -#ifdef HAVE_IPV6 if (name.sa.sa_family == AF_INET6) { su = XCALLOC (MTYPE_SOCKUNION, sizeof (union sockunion)); @@ -635,7 +603,6 @@ sockunion_getsockname (int fd) sockunion_normalise_mapped (su); return su; } -#endif /* HAVE_IPV6 */ return NULL; } @@ -649,9 +616,7 @@ sockunion_getpeername (int fd) { struct sockaddr sa; struct sockaddr_in sin; -#ifdef HAVE_IPV6 struct sockaddr_in6 sin6; -#endif /* HAVE_IPV6 */ char tmp_buffer[128]; } name; union sockunion *su; @@ -672,7 +637,6 @@ sockunion_getpeername (int fd) memcpy (su, &name, sizeof (struct sockaddr_in)); return su; } -#ifdef HAVE_IPV6 if (name.sa.sa_family == AF_INET6) { su = XCALLOC (MTYPE_SOCKUNION, sizeof (union sockunion)); @@ -680,7 +644,6 @@ sockunion_getpeername (int fd) sockunion_normalise_mapped (su); return su; } -#endif /* HAVE_IPV6 */ return NULL; } @@ -696,7 +659,6 @@ sockunion_print (const union sockunion *su) case AF_INET: printf ("%s\n", inet_ntoa (su->sin.sin_addr)); break; -#ifdef HAVE_IPV6 case AF_INET6: { char buf [SU_ADDRSTRLEN]; @@ -705,7 +667,6 @@ sockunion_print (const union sockunion *su) buf, sizeof (buf))); } break; -#endif /* HAVE_IPV6 */ #ifdef AF_LINK case AF_LINK: @@ -723,7 +684,6 @@ sockunion_print (const union sockunion *su) } } -#ifdef HAVE_IPV6 static int in6addr_cmp (const struct in6_addr *addr1, const struct in6_addr *addr2) { @@ -742,7 +702,6 @@ in6addr_cmp (const struct in6_addr *addr1, const struct in6_addr *addr2) } return 0; } -#endif /* HAVE_IPV6 */ int sockunion_cmp (const union sockunion *su1, const union sockunion *su2) @@ -761,10 +720,8 @@ sockunion_cmp (const union sockunion *su1, const union sockunion *su2) else return -1; } -#ifdef HAVE_IPV6 if (su1->sa.sa_family == AF_INET6) return in6addr_cmp (&su1->sin6.sin6_addr, &su2->sin6.sin6_addr); -#endif /* HAVE_IPV6 */ return 0; } diff --git a/lib/sockunion.h b/lib/sockunion.h index 3af3d78059..bed68e1ee1 100644 --- a/lib/sockunion.h +++ b/lib/sockunion.h @@ -47,11 +47,7 @@ enum connect_result }; /* Default address family. */ -#ifdef HAVE_IPV6 #define AF_INET_UNION AF_INET6 -#else -#define AF_INET_UNION AF_INET -#endif /* Sockunion address string length. Same as INET6_ADDRSTRLEN. */ #define SU_ADDRSTRLEN 46 diff --git a/lib/table.c b/lib/table.c index 5133ef6974..7335b2a817 100644 --- a/lib/table.c +++ b/lib/table.c @@ -250,7 +250,6 @@ route_node_match_ipv4 (const struct route_table *table, return route_node_match (table, (struct prefix *) &p); } -#ifdef HAVE_IPV6 struct route_node * route_node_match_ipv6 (const struct route_table *table, const struct in6_addr *addr) @@ -264,7 +263,6 @@ route_node_match_ipv6 (const struct route_table *table, return route_node_match (table, (struct prefix *) &p); } -#endif /* HAVE_IPV6 */ /* Lookup same prefix node. Return NULL when we can't find route. */ struct route_node * diff --git a/lib/table.h b/lib/table.h index 78bf5da748..5f3eb8de37 100644 --- a/lib/table.h +++ b/lib/table.h @@ -162,10 +162,8 @@ extern struct route_node *route_node_match (const struct route_table *, const struct prefix *); extern struct route_node *route_node_match_ipv4 (const struct route_table *, const struct in_addr *); -#ifdef HAVE_IPV6 extern struct route_node *route_node_match_ipv6 (const struct route_table *, const struct in6_addr *); -#endif /* HAVE_IPV6 */ extern unsigned long route_table_count (const struct route_table *); diff --git a/lib/vty.c b/lib/vty.c index 1fe2e5d296..a0bcf130ef 100644 --- a/lib/vty.c +++ b/lib/vty.c @@ -1867,7 +1867,6 @@ vty_accept (struct thread *thread) } } -#ifdef HAVE_IPV6 /* VTY's ipv6 accesslist apply. */ if (p.family == AF_INET6 && vty_ipv6_accesslist_name) { @@ -1884,7 +1883,6 @@ vty_accept (struct thread *thread) return 0; } } -#endif /* HAVE_IPV6 */ on = 1; ret = setsockopt (vty_sock, IPPROTO_TCP, TCP_NODELAY, @@ -1901,7 +1899,6 @@ vty_accept (struct thread *thread) return 0; } -#ifdef HAVE_IPV6 static void vty_serv_sock_addrinfo (const char *hostname, unsigned short port) { @@ -1932,9 +1929,7 @@ vty_serv_sock_addrinfo (const char *hostname, unsigned short port) do { if (ainfo->ai_family != AF_INET -#ifdef HAVE_IPV6 && ainfo->ai_family != AF_INET6 -#endif /* HAVE_IPV6 */ ) continue; @@ -1967,76 +1962,6 @@ vty_serv_sock_addrinfo (const char *hostname, unsigned short port) freeaddrinfo (ainfo_save); } -#else /* HAVE_IPV6 */ - -/* Make vty server socket. */ -static void -vty_serv_sock_family (const char* addr, unsigned short port, int family) -{ - int ret; - union sockunion su; - int accept_sock; - void* naddr=NULL; - - memset (&su, 0, sizeof (union sockunion)); - su.sa.sa_family = family; - if(addr) - switch(family) - { - case AF_INET: - naddr=&su.sin.sin_addr; - break; -#ifdef HAVE_IPV6 - case AF_INET6: - naddr=&su.sin6.sin6_addr; - break; -#endif - } - - if(naddr) - switch(inet_pton(family,addr,naddr)) - { - case -1: - zlog_err("bad address %s",addr); - naddr=NULL; - break; - case 0: - zlog_err("error translating address %s: %s",addr,safe_strerror(errno)); - naddr=NULL; - } - - /* Make new socket. */ - accept_sock = sockunion_stream_socket (&su); - if (accept_sock < 0) - return; - - /* This is server, so reuse address. */ - sockopt_reuseaddr (accept_sock); - sockopt_reuseport (accept_sock); - set_cloexec (accept_sock); - - /* Bind socket to universal address and given port. */ - ret = sockunion_bind (accept_sock, &su, port, naddr); - if (ret < 0) - { - zlog_warn("can't bind socket"); - close (accept_sock); /* Avoid sd leak. */ - return; - } - - /* Listen socket under queue 3. */ - ret = listen (accept_sock, 3); - if (ret < 0) - { - zlog (NULL, LOG_WARNING, "can't listen socket"); - close (accept_sock); /* Avoid sd leak. */ - return; - } - - /* Add vty server event. */ - vty_event (VTY_SERV, accept_sock, NULL); -} -#endif /* HAVE_IPV6 */ #ifdef VTYSH /* For sockaddr_un. */ @@ -2279,14 +2204,7 @@ vty_serv_sock (const char *addr, unsigned short port, const char *path) { /* If port is set to 0, do not listen on TCP/IP at all! */ if (port) - { - -#ifdef HAVE_IPV6 - vty_serv_sock_addrinfo (addr, port); -#else /* ! HAVE_IPV6 */ - vty_serv_sock_family (addr,port, AF_INET); -#endif /* HAVE_IPV6 */ - } + vty_serv_sock_addrinfo (addr, port); #ifdef VTYSH vty_serv_un (path); @@ -2858,7 +2776,6 @@ DEFUN (no_vty_access_class, return CMD_SUCCESS; } -#ifdef HAVE_IPV6 /* Set vty access class. */ DEFUN (vty_ipv6_access_class, vty_ipv6_access_class_cmd, @@ -2902,7 +2819,6 @@ DEFUN (no_vty_ipv6_access_class, return CMD_SUCCESS; } -#endif /* HAVE_IPV6 */ /* vty login. */ DEFUN (vty_login, @@ -3184,10 +3100,8 @@ vty_init (struct thread_master *master_thread) install_element (VTY_NODE, &no_vty_access_class_cmd); install_element (VTY_NODE, &vty_login_cmd); install_element (VTY_NODE, &no_vty_login_cmd); -#ifdef HAVE_IPV6 install_element (VTY_NODE, &vty_ipv6_access_class_cmd); install_element (VTY_NODE, &no_vty_ipv6_access_class_cmd); -#endif /* HAVE_IPV6 */ } void diff --git a/lib/zclient.c b/lib/zclient.c index 440de3635f..a4c5fa4afb 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -786,7 +786,6 @@ zapi_ipv4_route (u_char cmd, struct zclient *zclient, struct prefix_ipv4 *p, return zclient_send_message(zclient); } -#ifdef HAVE_IPV6 int zapi_ipv4_route_ipv6_nexthop (u_char cmd, struct zclient *zclient, struct prefix_ipv4 *p, struct zapi_ipv6 *api) @@ -918,7 +917,6 @@ zapi_ipv6_route (u_char cmd, struct zclient *zclient, struct prefix_ipv6 *p, return zclient_send_message(zclient); } -#endif /* HAVE_IPV6 */ /* * send a ZEBRA_REDISTRIBUTE_ADD or ZEBRA_REDISTRIBUTE_DELETE diff --git a/lib/zclient.h b/lib/zclient.h index 4312cdc83c..ccb7b0509d 100644 --- a/lib/zclient.h +++ b/lib/zclient.h @@ -214,7 +214,6 @@ extern int zapi_ipv4_route (u_char, struct zclient *, struct prefix_ipv4 *, extern struct interface *zebra_interface_link_params_read (struct stream *); extern size_t zebra_interface_link_params_write (struct stream *, struct interface *); -#ifdef HAVE_IPV6 /* IPv6 prefix add and delete function prototype. */ struct zapi_ipv6 @@ -249,6 +248,5 @@ extern int zapi_ipv6_route (u_char cmd, struct zclient *zclient, struct prefix_ipv6 *p, struct zapi_ipv6 *api); extern int zapi_ipv4_route_ipv6_nexthop (u_char, struct zclient *, struct prefix_ipv4 *, struct zapi_ipv6 *); -#endif /* HAVE_IPV6 */ #endif /* _ZEBRA_ZCLIENT_H */ diff --git a/vtysh/extract.pl.in b/vtysh/extract.pl.in index 9540ffab5f..819141afe7 100755 --- a/vtysh/extract.pl.in +++ b/vtysh/extract.pl.in @@ -88,7 +88,7 @@ my $cli_stomp = 0; foreach (@ARGV) { $file = $_; - open (FH, "@CPP@ -DHAVE_CONFIG_H -DVTYSH_EXTRACT_PL -DHAVE_IPV6 -I@top_builddir@ -I@srcdir@/ -I@srcdir@/.. -I@top_srcdir@/lib -I@top_builddir@/lib -I@top_srcdir@/bgpd -I@top_srcdir@/@LIBRFP@ -I@top_srcdir@/bgpd/rfapi @CPPFLAGS@ $file |"); + open (FH, "@CPP@ -DHAVE_CONFIG_H -DVTYSH_EXTRACT_PL -I@top_builddir@ -I@srcdir@/ -I@srcdir@/.. -I@top_srcdir@/lib -I@top_builddir@/lib -I@top_srcdir@/bgpd -I@top_srcdir@/@LIBRFP@ -I@top_srcdir@/bgpd/rfapi @CPPFLAGS@ $file |"); local $/; undef $/; $line = ; close (FH); diff --git a/zebra/client_main.c b/zebra/client_main.c index 8290eafc4d..f40d995466 100644 --- a/zebra/client_main.c +++ b/zebra/client_main.c @@ -79,7 +79,6 @@ zebra_test_ipv4 (int command, int type, char *prefix, char *gateway, } } -#ifdef HAVE_IPV6 /* IPv6 route add and delete test. */ void zebra_test_v6 (int sock) @@ -95,7 +94,6 @@ zebra_test_v6 (int sock) sleep (5); /* zebra_ipv6_delete (sock, ZEBRA_ROUTE_STATIC, 0, &p, &nexthop, 1); */ } -#endif /* HAVE_IPV6 */ /* Print out usage and exit. */ void diff --git a/zebra/connected.c b/zebra/connected.c index bc54aab01c..ebd948252e 100644 --- a/zebra/connected.c +++ b/zebra/connected.c @@ -59,10 +59,8 @@ connected_withdraw (struct connected *ifc) if (ifc->address->family == AF_INET) connected_down_ipv4 (ifc->ifp, ifc); -#ifdef HAVE_IPV6 else connected_down_ipv6 (ifc->ifp, ifc); -#endif UNSET_FLAG (ifc->conf, ZEBRA_IFC_REAL); } @@ -103,10 +101,8 @@ connected_announce (struct interface *ifp, struct connected *ifc) { if (ifc->address->family == AF_INET) connected_up_ipv4 (ifp, ifc); -#ifdef HAVE_IPV6 else connected_up_ipv6 (ifp, ifc); -#endif } } diff --git a/zebra/connected.h b/zebra/connected.h index f35f47fb6a..bdcf6085e4 100644 --- a/zebra/connected.h +++ b/zebra/connected.h @@ -41,7 +41,6 @@ connected_delete_ipv4_unnumbered (struct connected *ifc); extern void connected_up_ipv4 (struct interface *, struct connected *); extern void connected_down_ipv4 (struct interface *, struct connected *); -#ifdef HAVE_IPV6 extern void connected_add_ipv6 (struct interface *ifp, int flags, struct in6_addr *address, u_char prefixlen, struct in6_addr *broad, @@ -53,8 +52,6 @@ connected_delete_ipv6 (struct interface *ifp, struct in6_addr *address, extern void connected_up_ipv6 (struct interface *, struct connected *); extern void connected_down_ipv6 (struct interface *ifp, struct connected *); -#endif /* HAVE_IPV6 */ - extern int connected_is_unnumbered (struct interface *); #endif /*_ZEBRA_CONNECTED_H */ diff --git a/zebra/if_ioctl.c b/zebra/if_ioctl.c index cc348fc237..36b0a6c795 100644 --- a/zebra/if_ioctl.c +++ b/zebra/if_ioctl.c @@ -244,7 +244,6 @@ if_getaddrs (void) connected_add_ipv4 (ifp, flags, &addr->sin_addr, prefixlen, dest_pnt, NULL); } -#ifdef HAVE_IPV6 if (ifap->ifa_addr->sa_family == AF_INET6) { struct sockaddr_in6 *addr; @@ -289,7 +288,6 @@ if_getaddrs (void) connected_add_ipv6 (ifp, flags, &addr->sin6_addr, prefixlen, dest_pnt, NULL); } -#endif /* HAVE_IPV6 */ } freeifaddrs (ifapfree); @@ -336,9 +334,9 @@ interface_list (struct zebra_ns *zns) if_getaddrs (); -#if defined(HAVE_IPV6) && defined(HAVE_PROC_NET_IF_INET6) +#if defined(HAVE_PROC_NET_IF_INET6) /* Linux provides interface's IPv6 address via /proc/net/if_inet6. */ ifaddr_proc_ipv6 (); -#endif /* HAVE_IPV6 && HAVE_PROC_NET_IF_INET6 */ +#endif /* HAVE_PROC_NET_IF_INET6 */ } diff --git a/zebra/if_ioctl_solaris.c b/zebra/if_ioctl_solaris.c index 0e727b9dc4..f27dc89007 100644 --- a/zebra/if_ioctl_solaris.c +++ b/zebra/if_ioctl_solaris.c @@ -177,12 +177,7 @@ calculate_lifc_len: /* must hold privileges to enter here */ if (lifreq->lifr_addr.ss_family == AF_INET6) { -#ifdef HAVE_IPV6 ifp->flags |= IFF_IPV6; -#else - lifreq++; - continue; -#endif /* HAVE_IPV6 */ } if_add_update (ifp); @@ -309,7 +304,6 @@ if_get_addr (struct interface *ifp, struct sockaddr *addr, const char *label) dest_pnt = (char *) &SIN (&dest)->sin_addr; } } -#ifdef HAVE_IPV6 else if (af == AF_INET6) { if (if_ioctl_ipv6 (SIOCGLIFSUBNET, (caddr_t) & lifreq) < 0) @@ -325,17 +319,14 @@ if_get_addr (struct interface *ifp, struct sockaddr *addr, const char *label) prefixlen = lifreq.lifr_addrlen; } } -#endif /* HAVE_IPV6 */ /* Set address to the interface. */ if (af == AF_INET) connected_add_ipv4 (ifp, flags, &SIN (addr)->sin_addr, prefixlen, (struct in_addr *) dest_pnt, label); -#ifdef HAVE_IPV6 else if (af == AF_INET6) connected_add_ipv6 (ifp, flags, &SIN6 (addr)->sin6_addr, prefixlen, (struct in6_addr *) dest_pnt, label); -#endif /* HAVE_IPV6 */ return 0; } @@ -367,7 +358,6 @@ interface_list (struct zebra_ns *zns) struct connected * if_lookup_linklocal (struct interface *ifp) { -#ifdef HAVE_IPV6 struct listnode *node; struct connected *ifc; @@ -380,7 +370,6 @@ if_lookup_linklocal (struct interface *ifp) (IN6_IS_ADDR_LINKLOCAL (&ifc->address->u.prefix6))) return ifc; } -#endif /* HAVE_IPV6 */ return NULL; } diff --git a/zebra/if_netlink.c b/zebra/if_netlink.c index c5fd16b9cd..678c217321 100644 --- a/zebra/if_netlink.c +++ b/zebra/if_netlink.c @@ -373,7 +373,6 @@ interface_lookup_netlink (struct zebra_ns *zns) if (ret < 0) return ret; -#ifdef HAVE_IPV6 /* Get IPv6 address of the interfaces. */ ret = netlink_request (AF_INET6, RTM_GETADDR, &zns->netlink_cmd); if (ret < 0) @@ -381,7 +380,6 @@ interface_lookup_netlink (struct zebra_ns *zns) ret = netlink_parse_info (netlink_interface_addr, &zns->netlink_cmd, zns, 0); if (ret < 0) return ret; -#endif /* HAVE_IPV6 */ return 0; } @@ -468,10 +466,7 @@ netlink_interface_addr (struct sockaddr_nl *snl, struct nlmsghdr *h, ifa = NLMSG_DATA (h); if (ifa->ifa_family != AF_INET -#ifdef HAVE_IPV6 - && ifa->ifa_family != AF_INET6 -#endif /* HAVE_IPV6 */ - ) + && ifa->ifa_family != AF_INET6) return 0; if (h->nlmsg_type != RTM_NEWADDR && h->nlmsg_type != RTM_DELADDR) @@ -571,7 +566,6 @@ netlink_interface_addr (struct sockaddr_nl *snl, struct nlmsghdr *h, (struct in_addr *) addr, ifa->ifa_prefixlen, (struct in_addr *) broad); } -#ifdef HAVE_IPV6 if (ifa->ifa_family == AF_INET6) { if (h->nlmsg_type == RTM_NEWADDR) @@ -589,7 +583,6 @@ netlink_interface_addr (struct sockaddr_nl *snl, struct nlmsghdr *h, (struct in6_addr *) addr, ifa->ifa_prefixlen, (struct in6_addr *) broad); } -#endif /* HAVE_IPV6 */ return 0; } diff --git a/zebra/interface.c b/zebra/interface.c index 4a0409702f..5a9de5b70b 100644 --- a/zebra/interface.c +++ b/zebra/interface.c @@ -439,7 +439,6 @@ if_addr_wakeup (struct interface *ifp) * from the kernel has been received. * It will also be added to the interface's subnet list then. */ } -#ifdef HAVE_IPV6 if (p->family == AF_INET6) { if (! if_is_up (ifp)) @@ -461,7 +460,6 @@ if_addr_wakeup (struct interface *ifp) /* The address will be advertised to zebra clients when the notification * from the kernel has been received. */ } -#endif /* HAVE_IPV6 */ } } } @@ -1060,10 +1058,8 @@ if_dump_vty (struct vty *vty, struct interface *ifp) vty_out (vty, " index %d metric %d mtu %d ", ifp->ifindex, ifp->metric, ifp->mtu); -#ifdef HAVE_IPV6 if (ifp->mtu6 != ifp->mtu) vty_out (vty, "mtu6 %d ", ifp->mtu6); -#endif vty_out (vty, "%s flags: %s%s", VTY_NEWLINE, if_flag_dump (ifp->flags), VTY_NEWLINE); @@ -2547,7 +2543,6 @@ DEFUN (no_ip_address_label, } #endif /* HAVE_NETLINK */ -#ifdef HAVE_IPV6 static int ipv6_address_install (struct vty *vty, struct interface *ifp, const char *addr_str, const char *peer_str, @@ -2723,7 +2718,6 @@ DEFUN (no_ipv6_address, VTY_DECLVAR_CONTEXT (interface, ifp); return ipv6_address_uninstall (vty, ifp, argv[idx_ipv6_prefixlen]->arg, NULL, NULL, 0); } -#endif /* HAVE_IPV6 */ static int link_params_config_write (struct vty *vty, struct interface *ifp) @@ -2896,10 +2890,8 @@ zebra_if_init (void) install_element (INTERFACE_NODE, &no_bandwidth_if_cmd); install_element (INTERFACE_NODE, &ip_address_cmd); install_element (INTERFACE_NODE, &no_ip_address_cmd); -#ifdef HAVE_IPV6 install_element (INTERFACE_NODE, &ipv6_address_cmd); install_element (INTERFACE_NODE, &no_ipv6_address_cmd); -#endif /* HAVE_IPV6 */ #ifdef HAVE_NETLINK install_element (INTERFACE_NODE, &ip_address_label_cmd); install_element (INTERFACE_NODE, &no_ip_address_label_cmd); diff --git a/zebra/ioctl.c b/zebra/ioctl.c index 1835fb3102..1125043310 100644 --- a/zebra/ioctl.c +++ b/zebra/ioctl.c @@ -80,7 +80,6 @@ if_ioctl (u_long request, caddr_t buffer) return 0; } -#ifdef HAVE_IPV6 static int if_ioctl_ipv6 (u_long request, caddr_t buffer) { @@ -114,7 +113,6 @@ if_ioctl_ipv6 (u_long request, caddr_t buffer) } return 0; } -#endif /* HAVE_IPV6 */ /* * get interface metric @@ -437,8 +435,6 @@ if_unset_flags (struct interface *ifp, uint64_t flags) return 0; } -#ifdef HAVE_IPV6 - #ifdef LINUX_IPV6 #ifndef _LINUX_IN6_H /* linux/include/net/ipv6.h */ @@ -594,5 +590,3 @@ if_prefix_delete_ipv6 (struct interface *ifp, struct connected *ifc) #endif /* HAVE_STRUCT_IN6_ALIASREQ */ #endif /* LINUX_IPV6 */ - -#endif /* HAVE_IPV6 */ diff --git a/zebra/ioctl.h b/zebra/ioctl.h index fee9b725c4..9e3fd5b3fb 100644 --- a/zebra/ioctl.h +++ b/zebra/ioctl.h @@ -37,10 +37,8 @@ extern int if_unset_prefix (struct interface *, struct connected *); extern void if_get_metric (struct interface *); extern void if_get_mtu (struct interface *); -#ifdef HAVE_IPV6 extern int if_prefix_add_ipv6 (struct interface *, struct connected *); extern int if_prefix_delete_ipv6 (struct interface *, struct connected *); -#endif /* HAVE_IPV6 */ #ifdef SOLARIS_IPV6 extern int if_ioctl_ipv6(u_long, caddr_t); diff --git a/zebra/ioctl_solaris.c b/zebra/ioctl_solaris.c index b5bf1ccb0a..1de583577d 100644 --- a/zebra/ioctl_solaris.c +++ b/zebra/ioctl_solaris.c @@ -85,7 +85,6 @@ if_ioctl (u_long request, caddr_t buffer) int if_ioctl_ipv6 (u_long request, caddr_t buffer) { -#ifdef HAVE_IPV6 int sock; int ret; int err; @@ -117,7 +116,6 @@ if_ioctl_ipv6 (u_long request, caddr_t buffer) errno = err; return ret; } -#endif /* HAVE_IPV6 */ return 0; } @@ -177,7 +175,6 @@ if_get_mtu (struct interface *ifp) } } -#ifdef HAVE_IPV6 if (ifp->flags & IFF_IPV6) { memset(&lifreq, 0, sizeof(lifreq)); @@ -195,7 +192,6 @@ if_get_mtu (struct interface *ifp) changed = 1; } } -#endif /* HAVE_IPV6 */ if (changed) zebra_interface_up_update(ifp); @@ -403,8 +399,6 @@ if_unset_flags (struct interface *ifp, uint64_t flags) return ret; } -#ifdef HAVE_IPV6 - /* Interface's address add/delete functions. */ int if_prefix_add_ipv6 (struct interface *ifp, struct connected *ifc) @@ -431,5 +425,3 @@ if_prefix_delete_ipv6 (struct interface *ifp, struct connected *ifc) return 0; } - -#endif /* HAVE_IPV6 */ diff --git a/zebra/ipforward.h b/zebra/ipforward.h index 8a935c139f..a75073cb36 100644 --- a/zebra/ipforward.h +++ b/zebra/ipforward.h @@ -26,10 +26,8 @@ extern int ipforward (void); extern int ipforward_on (void); extern int ipforward_off (void); -#ifdef HAVE_IPV6 extern int ipforward_ipv6 (void); extern int ipforward_ipv6_on (void); extern int ipforward_ipv6_off (void); -#endif /* HAVE_IPV6 */ #endif /* _ZEBRA_IPFORWARD_H */ diff --git a/zebra/ipforward_proc.c b/zebra/ipforward_proc.c index 2876eded37..910fd61d06 100644 --- a/zebra/ipforward_proc.c +++ b/zebra/ipforward_proc.c @@ -123,7 +123,6 @@ ipforward_off (void) return ipforward (); } -#ifdef HAVE_IPV6 char proc_ipv6_forwarding[] = "/proc/sys/net/ipv6/conf/all/forwarding"; @@ -152,7 +151,7 @@ ipforward_ipv6_on (void) FILE *fp; if ( zserv_privs.change(ZPRIVS_RAISE) ) - zlog_err ("Can't raise privileges, %s", safe_strerror (errno)); + zlog_err ("Can't raise privileges, %s", safe_strerror (errno)); fp = fopen (proc_ipv6_forwarding, "w"); @@ -172,13 +171,14 @@ ipforward_ipv6_on (void) return ipforward_ipv6 (); } + int ipforward_ipv6_off (void) { FILE *fp; if ( zserv_privs.change(ZPRIVS_RAISE) ) - zlog_err ("Can't raise privileges, %s", safe_strerror (errno)); + zlog_err ("Can't raise privileges, %s", safe_strerror (errno)); fp = fopen (proc_ipv6_forwarding, "w"); @@ -197,4 +197,3 @@ ipforward_ipv6_off (void) return ipforward_ipv6 (); } -#endif /* HAVE_IPV6 */ diff --git a/zebra/ipforward_solaris.c b/zebra/ipforward_solaris.c index 4aa1b797af..8eccfe133c 100644 --- a/zebra/ipforward_solaris.c +++ b/zebra/ipforward_solaris.c @@ -145,7 +145,6 @@ ipforward_off (void) (void) solaris_nd_set("ip_forwarding", 0); return ipforward(); } -#ifdef HAVE_IPV6 int ipforward_ipv6(void) { return solaris_nd_get("ip6_forwarding"); @@ -162,4 +161,3 @@ ipforward_ipv6_off (void) (void) solaris_nd_set("ip6_forwarding", 0); return ipforward_ipv6(); } -#endif /* HAVE_IPV6 */ diff --git a/zebra/ipforward_sysctl.c b/zebra/ipforward_sysctl.c index 57ed185785..be4c9cd99c 100644 --- a/zebra/ipforward_sysctl.c +++ b/zebra/ipforward_sysctl.c @@ -95,8 +95,6 @@ ipforward_off (void) return ipforwarding; } -#ifdef HAVE_IPV6 - /* IPv6 forwarding control MIB. */ int mib_ipv6[MIB_SIZ] = { @@ -173,4 +171,3 @@ ipforward_ipv6_off (void) zlog (NULL, LOG_ERR, "Can't lower privileges"); return ip6forwarding; } -#endif /* HAVE_IPV6 */ diff --git a/zebra/kernel_socket.c b/zebra/kernel_socket.c index bcd92e15fe..6d81c9d052 100644 --- a/zebra/kernel_socket.c +++ b/zebra/kernel_socket.c @@ -111,7 +111,7 @@ extern struct zebra_privs_t zserv_privs; */ #if defined(HAVE_STRUCT_SOCKADDR_SA_LEN) #define SAROUNDUP(X) ROUNDUP(((struct sockaddr *)(X))->sa_len) -#elif defined(HAVE_IPV6) +#else /* * One would hope all fixed-size structure definitions are aligned, * but round them up nonetheless. @@ -123,12 +123,6 @@ extern struct zebra_privs_t zserv_privs; ROUNDUP(sizeof(struct sockaddr_in6)) : \ (((struct sockaddr *)(X))->sa_family == AF_LINK ? \ ROUNDUP(sizeof(struct sockaddr_dl)) : sizeof(struct sockaddr)))) -#else /* HAVE_IPV6 */ -#define SAROUNDUP(X) \ - (((struct sockaddr *)(X))->sa_family == AF_INET ? \ - ROUNDUP(sizeof(struct sockaddr_in)):\ - (((struct sockaddr *)(X))->sa_family == AF_LINK ? \ - ROUNDUP(sizeof(struct sockaddr_dl)) : sizeof(struct sockaddr))) #endif /* HAVE_STRUCT_SOCKADDR_SA_LEN */ #endif /* !SA_SIZE */ @@ -299,10 +293,8 @@ af_check (int family) { if (family == AF_INET) return 1; -#ifdef HAVE_IPV6 if (family == AF_INET6) return 1; -#endif /* HAVE_IPV6 */ return 0; } @@ -682,9 +674,7 @@ ifam_read_mesg (struct ifa_msghdr *ifm, switch (family) { case AF_INET: -#ifdef HAVE_IPV6 case AF_INET6: -#endif { char buf[4][INET6_ADDRSTRLEN]; zlog_debug ("%s: ifindex %d, ifname %s, ifam_addrs 0x%x, " @@ -772,7 +762,6 @@ ifam_read (struct ifa_msghdr *ifam) ip_masklen (mask.sin.sin_addr), &brd.sin.sin_addr); break; -#ifdef HAVE_IPV6 case AF_INET6: /* Unset interface index from link-local address when IPv6 stack is KAME. */ @@ -792,7 +781,6 @@ ifam_read (struct ifa_msghdr *ifam) ip6_masklen (mask.sin6.sin6_addr), &brd.sin6.sin6_addr); break; -#endif /* HAVE_IPV6 */ default: /* Unsupported family silently ignore... */ break; diff --git a/zebra/redistribute.c b/zebra/redistribute.c index 9c7ef5f12c..4b2aabd186 100644 --- a/zebra/redistribute.c +++ b/zebra/redistribute.c @@ -63,14 +63,12 @@ is_default (struct prefix *p) if (p->family == AF_INET) if (p->u.prefix4.s_addr == 0 && p->prefixlen == 0) return 1; -#ifdef HAVE_IPV6 #if 0 /* IPv6 default separation is now pending until protocol daemon can handle that. */ if (p->family == AF_INET6) if (IN6_IS_ADDR_UNSPECIFIED (&p->u.prefix6) && p->prefixlen == 0) return 1; #endif /* 0 */ -#endif /* HAVE_IPV6 */ return 0; } diff --git a/zebra/rt_netlink.c b/zebra/rt_netlink.c index f168ef3957..2e7f336d20 100644 --- a/zebra/rt_netlink.c +++ b/zebra/rt_netlink.c @@ -559,7 +559,6 @@ netlink_route_read (struct zebra_ns *zns) if (ret < 0) return ret; -#ifdef HAVE_IPV6 /* Get IPv6 routing table. */ ret = netlink_request (AF_INET6, RTM_GETROUTE, &zns->netlink_cmd); if (ret < 0) @@ -567,7 +566,6 @@ netlink_route_read (struct zebra_ns *zns) ret = netlink_parse_info (netlink_routing_table, &zns->netlink_cmd, zns, 0); if (ret < 0) return ret; -#endif /* HAVE_IPV6 */ return 0; } diff --git a/zebra/rtadv.c b/zebra/rtadv.c index 6a0d01a072..12e4873adf 100644 --- a/zebra/rtadv.c +++ b/zebra/rtadv.c @@ -46,7 +46,7 @@ extern struct zebra_privs_t zserv_privs; -#if defined (HAVE_IPV6) && defined (HAVE_RTADV) +#if defined (HAVE_RTADV) #ifdef OPEN_BSD #include @@ -1728,4 +1728,4 @@ rtadv_cmd_init (void) { /* Empty.*/; } -#endif /* HAVE_RTADV && HAVE_IPV6 */ +#endif /* HAVE_RTADV */ diff --git a/zebra/zebra_fpm_netlink.c b/zebra/zebra_fpm_netlink.c index a09008b396..0d9f809328 100644 --- a/zebra/zebra_fpm_netlink.c +++ b/zebra/zebra_fpm_netlink.c @@ -54,14 +54,13 @@ addr_to_a (u_char af, void *addr) case AF_INET: return inet_ntoa (*((struct in_addr *) addr)); - -#ifdef HAVE_IPV6 + break; case AF_INET6: return inet6_ntoa (*((struct in6_addr *) addr)); -#endif - + break; default: return ""; + break; } } @@ -93,12 +92,10 @@ af_addr_size (u_char af) case AF_INET: return 4; - -#ifdef HAVE_IPV6 + break; case AF_INET6: return 16; -#endif - + break; default: assert(0); return 16; diff --git a/zebra/zebra_ptm.c b/zebra/zebra_ptm.c index c5223199a4..194833f1e9 100644 --- a/zebra/zebra_ptm.c +++ b/zebra/zebra_ptm.c @@ -714,13 +714,11 @@ zebra_ptm_bfd_dst_register (struct zserv *client, int sock, u_short length, inet_ntop(AF_INET, &dst_p.u.prefix4, buf, sizeof(buf)); ptm_lib_append_msg(ptm_hdl, out_ctxt, ZEBRA_PTM_BFD_DST_IP_FIELD, buf); } -#ifdef HAVE_IPV6 else { inet_ntop(AF_INET6, &dst_p.u.prefix6, buf, sizeof(buf)); ptm_lib_append_msg(ptm_hdl, out_ctxt, ZEBRA_PTM_BFD_DST_IP_FIELD, buf); } -#endif /* HAVE_IPV6 */ min_rx_timer = stream_getl(s); sprintf(tmp_buf, "%d", min_rx_timer); @@ -755,14 +753,12 @@ zebra_ptm_bfd_dst_register (struct zserv *client, int sock, u_short length, ptm_lib_append_msg(ptm_hdl, out_ctxt, ZEBRA_PTM_BFD_SRC_IP_FIELD, buf); } -#ifdef HAVE_IPV6 else { inet_ntop(AF_INET6, &src_p.u.prefix6, buf, sizeof(buf)); ptm_lib_append_msg(ptm_hdl, out_ctxt, ZEBRA_PTM_BFD_SRC_IP_FIELD, buf); } -#endif /* HAVE_IPV6 */ multi_hop_cnt = stream_getc(s); sprintf(tmp_buf, "%d", multi_hop_cnt); @@ -775,7 +771,6 @@ zebra_ptm_bfd_dst_register (struct zserv *client, int sock, u_short length, } else { -#ifdef HAVE_IPV6 if (dst_p.family == AF_INET6) { src_p.family = stream_getw(s); @@ -799,7 +794,6 @@ zebra_ptm_bfd_dst_register (struct zserv *client, int sock, u_short length, ZEBRA_PTM_BFD_SRC_IP_FIELD, buf); } } -#endif /* HAVE_IPV6 */ len = stream_getc(s); stream_get(if_name, s, len); if_name[len] = '\0'; @@ -875,17 +869,11 @@ zebra_ptm_bfd_dst_deregister (struct zserv *client, int sock, u_short length, stream_get(&dst_p.u.prefix, s, dst_p.prefixlen); if (dst_p.family == AF_INET) - { - inet_ntop(AF_INET, &dst_p.u.prefix4, buf, sizeof(buf)); - ptm_lib_append_msg(ptm_hdl, out_ctxt, ZEBRA_PTM_BFD_DST_IP_FIELD, buf); - } -#ifdef HAVE_IPV6 + inet_ntop(AF_INET, &dst_p.u.prefix4, buf, sizeof(buf)); else - { - inet_ntop(AF_INET6, &dst_p.u.prefix6, buf, sizeof(buf)); - ptm_lib_append_msg(ptm_hdl, out_ctxt, ZEBRA_PTM_BFD_DST_IP_FIELD, buf); - } -#endif /* HAVE_IPV6 */ + inet_ntop(AF_INET6, &dst_p.u.prefix6, buf, sizeof(buf)); + ptm_lib_append_msg(ptm_hdl, out_ctxt, ZEBRA_PTM_BFD_DST_IP_FIELD, buf); + multi_hop = stream_getc(s); if (multi_hop) @@ -908,21 +896,18 @@ zebra_ptm_bfd_dst_deregister (struct zserv *client, int sock, u_short length, ptm_lib_append_msg(ptm_hdl, out_ctxt, ZEBRA_PTM_BFD_SRC_IP_FIELD, buf); } -#ifdef HAVE_IPV6 else { inet_ntop(AF_INET6, &src_p.u.prefix6, buf, sizeof(buf)); ptm_lib_append_msg(ptm_hdl, out_ctxt, ZEBRA_PTM_BFD_SRC_IP_FIELD, buf); } -#endif /* HAVE_IPV6 */ if (zvrf_id (zvrf) != VRF_DEFAULT) ptm_lib_append_msg(ptm_hdl, out_ctxt, ZEBRA_PTM_BFD_VRF_NAME_FIELD, zvrf_name (zvrf)); } else { -#ifdef HAVE_IPV6 if (dst_p.family == AF_INET6) { src_p.family = stream_getw(s); @@ -946,7 +931,6 @@ zebra_ptm_bfd_dst_deregister (struct zserv *client, int sock, u_short length, ZEBRA_PTM_BFD_SRC_IP_FIELD, buf); } } -#endif /* HAVE_IPV6 */ len = stream_getc(s); stream_get(if_name, s, len); diff --git a/zebra/zebra_rnh.c b/zebra/zebra_rnh.c index c4c11f98d9..315d4832dd 100644 --- a/zebra/zebra_rnh.c +++ b/zebra/zebra_rnh.c @@ -900,7 +900,6 @@ send_client (struct rnh *rnh, struct zserv *client, rnh_type_t type, vrf_id_t vr stream_put_in_addr (s, &nexthop->gate.ipv4); stream_putl (s, nexthop->ifindex); break; -#ifdef HAVE_IPV6 case NEXTHOP_TYPE_IPV6: stream_put (s, &nexthop->gate.ipv6, 16); break; @@ -908,7 +907,6 @@ send_client (struct rnh *rnh, struct zserv *client, rnh_type_t type, vrf_id_t vr stream_put (s, &nexthop->gate.ipv6, 16); stream_putl (s, nexthop->ifindex); break; -#endif /* HAVE_IPV6 */ default: /* do nothing */ break; diff --git a/zebra/zebra_routemap.c b/zebra/zebra_routemap.c index c467609f0c..27bff68c75 100644 --- a/zebra/zebra_routemap.c +++ b/zebra/zebra_routemap.c @@ -1240,11 +1240,8 @@ route_set_src_compile (const char *arg) { union g_addr src, *psrc; - if ( -#ifdef HAVE_IPV6 - (inet_pton(AF_INET6, arg, &src.ipv6) == 1) || -#endif /* HAVE_IPV6 */ - (src.ipv4.s_addr && (inet_pton(AF_INET, arg, &src.ipv4) == 1))) + if (inet_pton(AF_INET6, arg, &src.ipv6) == 1 || + src.ipv4.s_addr && (inet_pton(AF_INET, arg, &src.ipv4) == 1)) { psrc = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (union g_addr)); *psrc = src; diff --git a/zebra/zserv.c b/zebra/zserv.c index b7e45d8df1..d3c204d119 100644 --- a/zebra/zserv.c +++ b/zebra/zserv.c @@ -2525,7 +2525,6 @@ DEFUN (show_ip_forwarding, return CMD_SUCCESS; } -#ifdef HAVE_IPV6 /* Only display ipv6 forwarding is enabled or not. */ DEFUN (show_ipv6_forwarding, show_ipv6_forwarding_cmd, @@ -2599,8 +2598,6 @@ DEFUN (no_ipv6_forwarding, return CMD_SUCCESS; } -#endif /* HAVE_IPV6 */ - /* IPForwarding configuration write function. */ static int config_write_forwarding (struct vty *vty) @@ -2610,10 +2607,8 @@ config_write_forwarding (struct vty *vty) if (!ipforward ()) vty_out (vty, "no ip forwarding%s", VTY_NEWLINE); -#ifdef HAVE_IPV6 if (!ipforward_ipv6 ()) vty_out (vty, "no ipv6 forwarding%s", VTY_NEWLINE); -#endif /* HAVE_IPV6 */ vty_out (vty, "!%s", VTY_NEWLINE); return 0; } @@ -2671,11 +2666,9 @@ zebra_init (void) install_element (CONFIG_NODE, &no_config_table_cmd); #endif /* HAVE_NETLINK */ -#ifdef HAVE_IPV6 install_element (VIEW_NODE, &show_ipv6_forwarding_cmd); install_element (CONFIG_NODE, &ipv6_forwarding_cmd); install_element (CONFIG_NODE, &no_ipv6_forwarding_cmd); -#endif /* HAVE_IPV6 */ /* Route-map */ zebra_route_map_init (); From 6f26de536bfca09ff7920a03f78b2315e823175c Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 13 Jan 2017 08:02:50 -0500 Subject: [PATCH 092/107] frr: Remove HAVE_LIBM from the system Signed-off-by: Donald Sharp --- configure.ac | 1 - 1 file changed, 1 deletion(-) diff --git a/configure.ac b/configure.ac index 519b1ea2e9..8050b9c832 100755 --- a/configure.ac +++ b/configure.ac @@ -779,7 +779,6 @@ AC_CHECK_HEADER([math.h], [AC_CHECK_LIB([m], [pow], [LIBM="-lm" LIBS="$LIBS $LIBM" - AC_DEFINE(HAVE_LIBM,, Have libm) AC_CHECK_FUNCS(pow,[],[LIBM=""]) ]) ]) From a6810074aa7b5cc621c8358bef99e44ee4dc3548 Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Fri, 13 Jan 2017 14:10:00 +0100 Subject: [PATCH 093/107] watchfrr: indent to Linux CodingStyle before this patch, watchfrr was using an inconsistent style that matched neither GNU nor Linux kernel nor BSD style. Reindent to Linux kernel style, which should be pretty close to pimd & ldpd. indent (2.2.11) options used: -nbad -bap -nbc -bbo -hnl -br -brs -c33 -cd33 -ncdb -ce -ci4 -cli0 -d0 -di1 -nfc1 -i8 -ip0 -l80 -lp -npcs -nprs -npsl -sai -saf -saw -ncs -nsc -sob -nfca -cp33 -ss -ts8 -il1 Signed-off-by: David Lamparter --- watchfrr/watchfrr.c | 2156 +++++++++++++++++++-------------------- watchfrr/watchfrr.h | 2 +- watchfrr/watchfrr_vty.c | 38 +- 3 files changed, 1073 insertions(+), 1123 deletions(-) diff --git a/watchfrr/watchfrr.c b/watchfrr/watchfrr.c index 903e2bbe91..122d6db6d7 100644 --- a/watchfrr/watchfrr.c +++ b/watchfrr/watchfrr.c @@ -65,149 +65,136 @@ /* Needs to be global, referenced somewhere inside libzebra. */ struct thread_master *master; -typedef enum -{ - MODE_MONITOR = 0, - MODE_GLOBAL_RESTART, - MODE_SEPARATE_RESTART, - MODE_PHASED_ZEBRA_RESTART, - MODE_PHASED_ALL_RESTART +typedef enum { + MODE_MONITOR = 0, + MODE_GLOBAL_RESTART, + MODE_SEPARATE_RESTART, + MODE_PHASED_ZEBRA_RESTART, + MODE_PHASED_ALL_RESTART } watch_mode_t; -static const char *mode_str[] = -{ - "monitor", - "global restart", - "individual daemon restart", - "phased zebra restart", - "phased global restart for any failure", +static const char *mode_str[] = { + "monitor", + "global restart", + "individual daemon restart", + "phased zebra restart", + "phased global restart for any failure", }; -typedef enum -{ - PHASE_NONE = 0, - PHASE_STOPS_PENDING, - PHASE_WAITING_DOWN, - PHASE_ZEBRA_RESTART_PENDING, - PHASE_WAITING_ZEBRA_UP +typedef enum { + PHASE_NONE = 0, + PHASE_STOPS_PENDING, + PHASE_WAITING_DOWN, + PHASE_ZEBRA_RESTART_PENDING, + PHASE_WAITING_ZEBRA_UP } restart_phase_t; -static const char *phase_str[] = -{ - "None", - "Stop jobs running", - "Waiting for other daemons to come down", - "Zebra restart job running", - "Waiting for zebra to come up", - "Start jobs running", +static const char *phase_str[] = { + "None", + "Stop jobs running", + "Waiting for other daemons to come down", + "Zebra restart job running", + "Waiting for zebra to come up", + "Start jobs running", }; #define PHASE_TIMEOUT (3*gs.restart_timeout) -struct restart_info -{ - const char *name; - const char *what; - pid_t pid; - struct timeval time; - long interval; - struct thread *t_kill; - int kills; +struct restart_info { + const char *name; + const char *what; + pid_t pid; + struct timeval time; + long interval; + struct thread *t_kill; + int kills; }; -static struct global_state -{ - watch_mode_t mode; - restart_phase_t phase; - struct thread *t_phase_hanging; - const char *vtydir; - long period; - long timeout; - long restart_timeout; - long min_restart_interval; - long max_restart_interval; - int do_ping; - struct daemon *daemons; - const char *restart_command; - const char *start_command; - const char *stop_command; - struct restart_info restart; - int unresponsive_restart; - int loglevel; - struct daemon *special; /* points to zebra when doing phased restart */ - int numdaemons; - int numpids; - int numdown; /* # of daemons that are not UP or UNRESPONSIVE */ +static struct global_state { + watch_mode_t mode; + restart_phase_t phase; + struct thread *t_phase_hanging; + const char *vtydir; + long period; + long timeout; + long restart_timeout; + long min_restart_interval; + long max_restart_interval; + int do_ping; + struct daemon *daemons; + const char *restart_command; + const char *start_command; + const char *stop_command; + struct restart_info restart; + int unresponsive_restart; + int loglevel; + struct daemon *special; /* points to zebra when doing phased restart */ + int numdaemons; + int numpids; + int numdown; /* # of daemons that are not UP or UNRESPONSIVE */ } gs = { - .mode = MODE_MONITOR, - .phase = PHASE_NONE, - .vtydir = VTYDIR, - .period = 1000*DEFAULT_PERIOD, - .timeout = DEFAULT_TIMEOUT, - .restart_timeout = DEFAULT_RESTART_TIMEOUT, - .loglevel = DEFAULT_LOGLEVEL, - .min_restart_interval = DEFAULT_MIN_RESTART, - .max_restart_interval = DEFAULT_MAX_RESTART, - .do_ping = 1, -}; +.mode = MODE_MONITOR,.phase = PHASE_NONE,.vtydir = VTYDIR,.period = + 1000 * DEFAULT_PERIOD,.timeout = + DEFAULT_TIMEOUT,.restart_timeout = + DEFAULT_RESTART_TIMEOUT,.loglevel = + DEFAULT_LOGLEVEL,.min_restart_interval = + DEFAULT_MIN_RESTART,.max_restart_interval = + DEFAULT_MAX_RESTART,.do_ping = 1,}; -typedef enum -{ - DAEMON_INIT, - DAEMON_DOWN, - DAEMON_CONNECTING, - DAEMON_UP, - DAEMON_UNRESPONSIVE +typedef enum { + DAEMON_INIT, + DAEMON_DOWN, + DAEMON_CONNECTING, + DAEMON_UP, + DAEMON_UNRESPONSIVE } daemon_state_t; #define IS_UP(DMN) \ (((DMN)->state == DAEMON_UP) || ((DMN)->state == DAEMON_UNRESPONSIVE)) -static const char *state_str[] = -{ - "Init", - "Down", - "Connecting", - "Up", - "Unresponsive", +static const char *state_str[] = { + "Init", + "Down", + "Connecting", + "Up", + "Unresponsive", }; struct daemon { - const char *name; - daemon_state_t state; - int fd; - struct timeval echo_sent; - u_int connect_tries; - struct thread *t_wakeup; - struct thread *t_read; - struct thread *t_write; - struct daemon *next; - struct restart_info restart; + const char *name; + daemon_state_t state; + int fd; + struct timeval echo_sent; + u_int connect_tries; + struct thread *t_wakeup; + struct thread *t_read; + struct thread *t_write; + struct daemon *next; + struct restart_info restart; }; -static const struct option longopts[] = -{ - { "daemon", no_argument, NULL, 'd'}, - { "statedir", required_argument, NULL, 'S'}, - { "no-echo", no_argument, NULL, 'e'}, - { "loglevel", required_argument, NULL, 'l'}, - { "interval", required_argument, NULL, 'i'}, - { "timeout", required_argument, NULL, 't'}, - { "restart-timeout", required_argument, NULL, 'T'}, - { "restart", required_argument, NULL, 'r'}, - { "start-command", required_argument, NULL, 's'}, - { "kill-command", required_argument, NULL, 'k'}, - { "restart-all", required_argument, NULL, 'R'}, - { "all-restart", no_argument, NULL, 'a'}, - { "always-all-restart", no_argument, NULL, 'A'}, - { "unresponsive-restart", no_argument, NULL, 'z'}, - { "min-restart-interval", required_argument, NULL, 'm'}, - { "max-restart-interval", required_argument, NULL, 'M'}, - { "pid-file", required_argument, NULL, 'p'}, - { "blank-string", required_argument, NULL, 'b'}, - { "help", no_argument, NULL, 'h'}, - { "version", no_argument, NULL, 'v'}, - { NULL, 0, NULL, 0 } +static const struct option longopts[] = { + {"daemon", no_argument, NULL, 'd'}, + {"statedir", required_argument, NULL, 'S'}, + {"no-echo", no_argument, NULL, 'e'}, + {"loglevel", required_argument, NULL, 'l'}, + {"interval", required_argument, NULL, 'i'}, + {"timeout", required_argument, NULL, 't'}, + {"restart-timeout", required_argument, NULL, 'T'}, + {"restart", required_argument, NULL, 'r'}, + {"start-command", required_argument, NULL, 's'}, + {"kill-command", required_argument, NULL, 'k'}, + {"restart-all", required_argument, NULL, 'R'}, + {"all-restart", no_argument, NULL, 'a'}, + {"always-all-restart", no_argument, NULL, 'A'}, + {"unresponsive-restart", no_argument, NULL, 'z'}, + {"min-restart-interval", required_argument, NULL, 'm'}, + {"max-restart-interval", required_argument, NULL, 'M'}, + {"pid-file", required_argument, NULL, 'p'}, + {"blank-string", required_argument, NULL, 'b'}, + {"help", no_argument, NULL, 'h'}, + {"version", no_argument, NULL, 'v'}, + {NULL, 0, NULL, 0} }; static int try_connect(struct daemon *dmn); @@ -215,14 +202,13 @@ static int wakeup_send_echo(struct thread *t_wakeup); static void try_restart(struct daemon *dmn); static void phase_check(void); -static int -usage(const char *progname, int status) +static int usage(const char *progname, int status) { - if (status != 0) - fprintf(stderr, "Try `%s --help' for more information.\n", progname); - else - { - printf("Usage : %s [OPTION...] ...\n\n\ + if (status != 0) + fprintf(stderr, "Try `%s --help' for more information.\n", + progname); + else { + printf("Usage : %s [OPTION...] ...\n\n\ Watchdog program to monitor status of frr daemons and try to restart\n\ them if they are down or unresponsive. It determines whether a daemon is\n\ up based on whether it can connect to the daemon's vty unix stream socket.\n\ @@ -266,12 +252,9 @@ the -m and -M options allow you to control the minimum delay between\n\ restart commands. The minimum restart delay is recalculated each time\n\ a restart is attempted: if the time since the last restart attempt exceeds\n\ twice the -M value, then the restart delay is set to the -m value.\n\ -Otherwise, the interval is doubled (but capped at the -M value).\n\n", - progname,mode_str[0],progname,mode_str[1],progname,mode_str[2], - progname,mode_str[3],progname,mode_str[4],progname,mode_str[2], - mode_str[3]); +Otherwise, the interval is doubled (but capped at the -M value).\n\n", progname, mode_str[0], progname, mode_str[1], progname, mode_str[2], progname, mode_str[3], progname, mode_str[4], progname, mode_str[2], mode_str[3]); - printf("Options:\n\ + printf("Options:\n\ -d, --daemon Run in daemon mode. In this mode, error messages are sent\n\ to syslog instead of stdout.\n\ -S, --statedir Set the vty socket directory (default is %s)\n\ @@ -329,221 +312,203 @@ Otherwise, the interval is doubled (but capped at the -M value).\n\n", it with a space. This is an ugly hack to circumvent problems\n\ passing command-line arguments with embedded spaces.\n\ -v, --version Print program version\n\ --h, --help Display this help and exit\n", - VTYDIR,DEFAULT_LOGLEVEL,LOG_EMERG,LOG_DEBUG,LOG_DEBUG, - DEFAULT_MIN_RESTART,DEFAULT_MAX_RESTART, - DEFAULT_PERIOD,DEFAULT_TIMEOUT,DEFAULT_RESTART_TIMEOUT, - DEFAULT_PIDFILE); - } +-h, --help Display this help and exit\n", VTYDIR, DEFAULT_LOGLEVEL, LOG_EMERG, LOG_DEBUG, LOG_DEBUG, DEFAULT_MIN_RESTART, DEFAULT_MAX_RESTART, DEFAULT_PERIOD, DEFAULT_TIMEOUT, DEFAULT_RESTART_TIMEOUT, DEFAULT_PIDFILE); + } - return status; + return status; } -static pid_t -run_background(char *shell_cmd) +static pid_t run_background(char *shell_cmd) { - pid_t child; + pid_t child; - switch (child = fork()) - { - case -1: - zlog_err("fork failed, cannot run command [%s]: %s", - shell_cmd,safe_strerror(errno)); - return -1; - case 0: - /* Child process. */ - /* Use separate process group so child processes can be killed easily. */ - if (setpgid(0,0) < 0) - zlog_warn("warning: setpgid(0,0) failed: %s",safe_strerror(errno)); - { - char shell[] = "sh"; - char dashc[] = "-c"; - char * const argv[4] = { shell, dashc, shell_cmd, NULL}; - execv("/bin/sh", argv); - zlog_err("execv(/bin/sh -c '%s') failed: %s", - shell_cmd,safe_strerror(errno)); - _exit(127); - } - default: - /* Parent process: we will reap the child later. */ - zlog_err("Forked background command [pid %d]: %s",(int)child,shell_cmd); - return child; - } + switch (child = fork()) { + case -1: + zlog_err("fork failed, cannot run command [%s]: %s", + shell_cmd, safe_strerror(errno)); + return -1; + case 0: + /* Child process. */ + /* Use separate process group so child processes can be killed easily. */ + if (setpgid(0, 0) < 0) + zlog_warn("warning: setpgid(0,0) failed: %s", + safe_strerror(errno)); + { + char shell[] = "sh"; + char dashc[] = "-c"; + char *const argv[4] = { shell, dashc, shell_cmd, NULL }; + execv("/bin/sh", argv); + zlog_err("execv(/bin/sh -c '%s') failed: %s", + shell_cmd, safe_strerror(errno)); + _exit(127); + } + default: + /* Parent process: we will reap the child later. */ + zlog_err("Forked background command [pid %d]: %s", (int)child, + shell_cmd); + return child; + } } -static struct timeval * -time_elapsed(struct timeval *result, const struct timeval *start_time) +static struct timeval *time_elapsed(struct timeval *result, + const struct timeval *start_time) { - gettimeofday(result,NULL); - result->tv_sec -= start_time->tv_sec; - result->tv_usec -= start_time->tv_usec; - while (result->tv_usec < 0) - { - result->tv_usec += 1000000L; - result->tv_sec--; - } - return result; + gettimeofday(result, NULL); + result->tv_sec -= start_time->tv_sec; + result->tv_usec -= start_time->tv_usec; + while (result->tv_usec < 0) { + result->tv_usec += 1000000L; + result->tv_sec--; + } + return result; } -static int -restart_kill(struct thread *t_kill) +static int restart_kill(struct thread *t_kill) { - struct restart_info *restart = THREAD_ARG(t_kill); - struct timeval delay; + struct restart_info *restart = THREAD_ARG(t_kill); + struct timeval delay; - time_elapsed(&delay,&restart->time); - zlog_warn("Warning: %s %s child process %d still running after " - "%ld seconds, sending signal %d", - restart->what,restart->name,(int)restart->pid, (long)delay.tv_sec, - (restart->kills ? SIGKILL : SIGTERM)); - kill(-restart->pid,(restart->kills ? SIGKILL : SIGTERM)); - restart->kills++; - restart->t_kill = thread_add_timer(master,restart_kill,restart, - gs.restart_timeout); - return 0; + time_elapsed(&delay, &restart->time); + zlog_warn("Warning: %s %s child process %d still running after " + "%ld seconds, sending signal %d", + restart->what, restart->name, (int)restart->pid, + (long)delay.tv_sec, (restart->kills ? SIGKILL : SIGTERM)); + kill(-restart->pid, (restart->kills ? SIGKILL : SIGTERM)); + restart->kills++; + restart->t_kill = thread_add_timer(master, restart_kill, restart, + gs.restart_timeout); + return 0; } -static struct restart_info * -find_child(pid_t child) +static struct restart_info *find_child(pid_t child) { - if (gs.mode == MODE_GLOBAL_RESTART) - { - if (gs.restart.pid == child) - return &gs.restart; - } - else - { - struct daemon *dmn; - for (dmn = gs.daemons; dmn; dmn = dmn->next) - { - if (dmn->restart.pid == child) - return &dmn->restart; - } - } - return NULL; + if (gs.mode == MODE_GLOBAL_RESTART) { + if (gs.restart.pid == child) + return &gs.restart; + } else { + struct daemon *dmn; + for (dmn = gs.daemons; dmn; dmn = dmn->next) { + if (dmn->restart.pid == child) + return &dmn->restart; + } + } + return NULL; } -static void -sigchild(void) +static void sigchild(void) { - pid_t child; - int status; - const char *name; - const char *what; - struct restart_info *restart; + pid_t child; + int status; + const char *name; + const char *what; + struct restart_info *restart; - switch (child = waitpid(-1,&status,WNOHANG)) - { - case -1: - zlog_err("waitpid failed: %s",safe_strerror(errno)); - return; - case 0: - zlog_warn("SIGCHLD received, but waitpid did not reap a child"); - return; - } + switch (child = waitpid(-1, &status, WNOHANG)) { + case -1: + zlog_err("waitpid failed: %s", safe_strerror(errno)); + return; + case 0: + zlog_warn("SIGCHLD received, but waitpid did not reap a child"); + return; + } - if (child == integrated_write_pid) - { - integrated_write_sigchld(status); - return; - } + if (child == integrated_write_pid) { + integrated_write_sigchld(status); + return; + } - if ((restart = find_child(child)) != NULL) - { - name = restart->name; - what = restart->what; - restart->pid = 0; - gs.numpids--; - thread_cancel(restart->t_kill); - restart->t_kill = NULL; - /* Update restart time to reflect the time the command completed. */ - gettimeofday(&restart->time,NULL); - } - else - { - zlog_err("waitpid returned status for an unknown child process %d", - (int)child); - name = "(unknown)"; - what = "background"; - } - if (WIFSTOPPED(status)) - zlog_warn("warning: %s %s process %d is stopped", - what,name,(int)child); - else if (WIFSIGNALED(status)) - zlog_warn("%s %s process %d terminated due to signal %d", - what,name,(int)child,WTERMSIG(status)); - else if (WIFEXITED(status)) - { - if (WEXITSTATUS(status) != 0) - zlog_warn("%s %s process %d exited with non-zero status %d", - what,name,(int)child,WEXITSTATUS(status)); - else - zlog_debug("%s %s process %d exited normally",what,name,(int)child); - } - else - zlog_err("cannot interpret %s %s process %d wait status 0x%x", - what,name,(int)child,status); - phase_check(); + if ((restart = find_child(child)) != NULL) { + name = restart->name; + what = restart->what; + restart->pid = 0; + gs.numpids--; + thread_cancel(restart->t_kill); + restart->t_kill = NULL; + /* Update restart time to reflect the time the command completed. */ + gettimeofday(&restart->time, NULL); + } else { + zlog_err + ("waitpid returned status for an unknown child process %d", + (int)child); + name = "(unknown)"; + what = "background"; + } + if (WIFSTOPPED(status)) + zlog_warn("warning: %s %s process %d is stopped", + what, name, (int)child); + else if (WIFSIGNALED(status)) + zlog_warn("%s %s process %d terminated due to signal %d", + what, name, (int)child, WTERMSIG(status)); + else if (WIFEXITED(status)) { + if (WEXITSTATUS(status) != 0) + zlog_warn + ("%s %s process %d exited with non-zero status %d", + what, name, (int)child, WEXITSTATUS(status)); + else + zlog_debug("%s %s process %d exited normally", what, + name, (int)child); + } else + zlog_err("cannot interpret %s %s process %d wait status 0x%x", + what, name, (int)child, status); + phase_check(); } static int run_job(struct restart_info *restart, const char *cmdtype, const char *command, int force, int update_interval) { - struct timeval delay; + struct timeval delay; - if (gs.loglevel > LOG_DEBUG+1) - zlog_debug("attempting to %s %s",cmdtype,restart->name); + if (gs.loglevel > LOG_DEBUG + 1) + zlog_debug("attempting to %s %s", cmdtype, restart->name); - if (restart->pid) - { - if (gs.loglevel > LOG_DEBUG+1) - zlog_debug("cannot %s %s, previous pid %d still running", - cmdtype,restart->name,(int)restart->pid); - return -1; - } + if (restart->pid) { + if (gs.loglevel > LOG_DEBUG + 1) + zlog_debug + ("cannot %s %s, previous pid %d still running", + cmdtype, restart->name, (int)restart->pid); + return -1; + } - /* Note: time_elapsed test must come before the force test, since we need - to make sure that delay is initialized for use below in updating the - restart interval. */ - if ((time_elapsed(&delay,&restart->time)->tv_sec < restart->interval) && - !force) - { - if (gs.loglevel > LOG_DEBUG+1) - zlog_debug("postponing %s %s: " - "elapsed time %ld < retry interval %ld", - cmdtype,restart->name,(long)delay.tv_sec,restart->interval); - return -1; - } + /* Note: time_elapsed test must come before the force test, since we need + to make sure that delay is initialized for use below in updating the + restart interval. */ + if ((time_elapsed(&delay, &restart->time)->tv_sec < restart->interval) + && !force) { + if (gs.loglevel > LOG_DEBUG + 1) + zlog_debug("postponing %s %s: " + "elapsed time %ld < retry interval %ld", + cmdtype, restart->name, (long)delay.tv_sec, + restart->interval); + return -1; + } - gettimeofday(&restart->time,NULL); - restart->kills = 0; - { - char cmd[strlen(command)+strlen(restart->name)+1]; - snprintf(cmd,sizeof(cmd),command,restart->name); - if ((restart->pid = run_background(cmd)) > 0) - { - restart->t_kill = thread_add_timer(master,restart_kill,restart, - gs.restart_timeout); - restart->what = cmdtype; - gs.numpids++; - } - else - restart->pid = 0; - } + gettimeofday(&restart->time, NULL); + restart->kills = 0; + { + char cmd[strlen(command) + strlen(restart->name) + 1]; + snprintf(cmd, sizeof(cmd), command, restart->name); + if ((restart->pid = run_background(cmd)) > 0) { + restart->t_kill = + thread_add_timer(master, restart_kill, restart, + gs.restart_timeout); + restart->what = cmdtype; + gs.numpids++; + } else + restart->pid = 0; + } - /* Calculate the new restart interval. */ - if (update_interval) - { - if (delay.tv_sec > 2*gs.max_restart_interval) - restart->interval = gs.min_restart_interval; - else if ((restart->interval *= 2) > gs.max_restart_interval) - restart->interval = gs.max_restart_interval; - if (gs.loglevel > LOG_DEBUG+1) - zlog_debug("restart %s interval is now %ld", - restart->name,restart->interval); - } - return restart->pid; + /* Calculate the new restart interval. */ + if (update_interval) { + if (delay.tv_sec > 2 * gs.max_restart_interval) + restart->interval = gs.min_restart_interval; + else if ((restart->interval *= 2) > gs.max_restart_interval) + restart->interval = gs.max_restart_interval; + if (gs.loglevel > LOG_DEBUG + 1) + zlog_debug("restart %s interval is now %ld", + restart->name, restart->interval); + } + return restart->pid; } #define SET_READ_HANDLER(DMN) \ @@ -551,889 +516,874 @@ run_job(struct restart_info *restart, const char *cmdtype, const char *command, #define SET_WAKEUP_DOWN(DMN) \ (DMN)->t_wakeup = thread_add_timer_msec(master,wakeup_down,(DMN), \ - FUZZY(gs.period)) + FUZZY(gs.period)) #define SET_WAKEUP_UNRESPONSIVE(DMN) \ (DMN)->t_wakeup = thread_add_timer_msec(master,wakeup_unresponsive,(DMN), \ - FUZZY(gs.period)) + FUZZY(gs.period)) #define SET_WAKEUP_ECHO(DMN) \ (DMN)->t_wakeup = thread_add_timer_msec(master,wakeup_send_echo,(DMN), \ FUZZY(gs.period)) -static int -wakeup_down(struct thread *t_wakeup) +static int wakeup_down(struct thread *t_wakeup) { - struct daemon *dmn = THREAD_ARG(t_wakeup); + struct daemon *dmn = THREAD_ARG(t_wakeup); - dmn->t_wakeup = NULL; - if (try_connect(dmn) < 0) - SET_WAKEUP_DOWN(dmn); - if ((dmn->connect_tries > 1) && (dmn->state != DAEMON_UP)) - try_restart(dmn); - return 0; + dmn->t_wakeup = NULL; + if (try_connect(dmn) < 0) + SET_WAKEUP_DOWN(dmn); + if ((dmn->connect_tries > 1) && (dmn->state != DAEMON_UP)) + try_restart(dmn); + return 0; } -static int -wakeup_init(struct thread *t_wakeup) +static int wakeup_init(struct thread *t_wakeup) { - struct daemon *dmn = THREAD_ARG(t_wakeup); + struct daemon *dmn = THREAD_ARG(t_wakeup); - dmn->t_wakeup = NULL; - if (try_connect(dmn) < 0) - { - SET_WAKEUP_DOWN(dmn); - zlog_err("%s state -> down : initial connection attempt failed", - dmn->name); - dmn->state = DAEMON_DOWN; - } - return 0; -} - -static void -daemon_down(struct daemon *dmn, const char *why) -{ - if (IS_UP(dmn) || (dmn->state == DAEMON_INIT)) - zlog_err("%s state -> down : %s",dmn->name,why); - else if (gs.loglevel > LOG_DEBUG) - zlog_debug("%s still down : %s",dmn->name,why); - if (IS_UP(dmn)) - gs.numdown++; - dmn->state = DAEMON_DOWN; - if (dmn->fd >= 0) - { - close(dmn->fd); - dmn->fd = -1; - } - THREAD_OFF(dmn->t_read); - THREAD_OFF(dmn->t_write); - THREAD_OFF(dmn->t_wakeup); - if (try_connect(dmn) < 0) - SET_WAKEUP_DOWN(dmn); - phase_check(); -} - -static int -handle_read(struct thread *t_read) -{ - struct daemon *dmn = THREAD_ARG(t_read); - static const char resp[sizeof(PING_TOKEN)+4] = PING_TOKEN "\n"; - char buf[sizeof(resp)+100]; - ssize_t rc; - struct timeval delay; - - dmn->t_read = NULL; - if ((rc = read(dmn->fd,buf,sizeof(buf))) < 0) - { - char why[100]; - - if (ERRNO_IO_RETRY(errno)) - { - /* Pretend it never happened. */ - SET_READ_HANDLER(dmn); - return 0; + dmn->t_wakeup = NULL; + if (try_connect(dmn) < 0) { + SET_WAKEUP_DOWN(dmn); + zlog_err("%s state -> down : initial connection attempt failed", + dmn->name); + dmn->state = DAEMON_DOWN; } - snprintf(why,sizeof(why),"unexpected read error: %s", - safe_strerror(errno)); - daemon_down(dmn,why); - return 0; - } - if (rc == 0) - { - daemon_down(dmn,"read returned EOF"); - return 0; - } - if (!dmn->echo_sent.tv_sec) - { - char why[sizeof(buf)+100]; - snprintf(why,sizeof(why),"unexpected read returns %d bytes: %.*s", - (int)rc,(int)rc,buf); - daemon_down(dmn,why); - return 0; - } + return 0; +} - /* We are expecting an echo response: is there any chance that the - response would not be returned entirely in the first read? That - seems inconceivable... */ - if ((rc != sizeof(resp)) || memcmp(buf,resp,sizeof(resp))) - { - char why[100+sizeof(buf)]; - snprintf(why,sizeof(why),"read returned bad echo response of %d bytes " - "(expecting %u): %.*s", - (int)rc,(u_int)sizeof(resp),(int)rc,buf); - daemon_down(dmn,why); - return 0; - } - - time_elapsed(&delay,&dmn->echo_sent); - dmn->echo_sent.tv_sec = 0; - if (dmn->state == DAEMON_UNRESPONSIVE) - { - if (delay.tv_sec < gs.timeout) - { - dmn->state = DAEMON_UP; - zlog_warn("%s state -> up : echo response received after %ld.%06ld " - "seconds", dmn->name, - (long)delay.tv_sec, (long)delay.tv_usec); +static void daemon_down(struct daemon *dmn, const char *why) +{ + if (IS_UP(dmn) || (dmn->state == DAEMON_INIT)) + zlog_err("%s state -> down : %s", dmn->name, why); + else if (gs.loglevel > LOG_DEBUG) + zlog_debug("%s still down : %s", dmn->name, why); + if (IS_UP(dmn)) + gs.numdown++; + dmn->state = DAEMON_DOWN; + if (dmn->fd >= 0) { + close(dmn->fd); + dmn->fd = -1; } - else - zlog_warn("%s: slow echo response finally received after %ld.%06ld " - "seconds", dmn->name, - (long)delay.tv_sec, (long)delay.tv_usec); - } - else if (gs.loglevel > LOG_DEBUG+1) - zlog_debug("%s: echo response received after %ld.%06ld seconds", - dmn->name, (long)delay.tv_sec, (long)delay.tv_usec); + THREAD_OFF(dmn->t_read); + THREAD_OFF(dmn->t_write); + THREAD_OFF(dmn->t_wakeup); + if (try_connect(dmn) < 0) + SET_WAKEUP_DOWN(dmn); + phase_check(); +} - SET_READ_HANDLER(dmn); - if (dmn->t_wakeup) - thread_cancel(dmn->t_wakeup); - SET_WAKEUP_ECHO(dmn); +static int handle_read(struct thread *t_read) +{ + struct daemon *dmn = THREAD_ARG(t_read); + static const char resp[sizeof(PING_TOKEN) + 4] = PING_TOKEN "\n"; + char buf[sizeof(resp) + 100]; + ssize_t rc; + struct timeval delay; - return 0; + dmn->t_read = NULL; + if ((rc = read(dmn->fd, buf, sizeof(buf))) < 0) { + char why[100]; + + if (ERRNO_IO_RETRY(errno)) { + /* Pretend it never happened. */ + SET_READ_HANDLER(dmn); + return 0; + } + snprintf(why, sizeof(why), "unexpected read error: %s", + safe_strerror(errno)); + daemon_down(dmn, why); + return 0; + } + if (rc == 0) { + daemon_down(dmn, "read returned EOF"); + return 0; + } + if (!dmn->echo_sent.tv_sec) { + char why[sizeof(buf) + 100]; + snprintf(why, sizeof(why), + "unexpected read returns %d bytes: %.*s", (int)rc, + (int)rc, buf); + daemon_down(dmn, why); + return 0; + } + + /* We are expecting an echo response: is there any chance that the + response would not be returned entirely in the first read? That + seems inconceivable... */ + if ((rc != sizeof(resp)) || memcmp(buf, resp, sizeof(resp))) { + char why[100 + sizeof(buf)]; + snprintf(why, sizeof(why), + "read returned bad echo response of %d bytes " + "(expecting %u): %.*s", (int)rc, (u_int) sizeof(resp), + (int)rc, buf); + daemon_down(dmn, why); + return 0; + } + + time_elapsed(&delay, &dmn->echo_sent); + dmn->echo_sent.tv_sec = 0; + if (dmn->state == DAEMON_UNRESPONSIVE) { + if (delay.tv_sec < gs.timeout) { + dmn->state = DAEMON_UP; + zlog_warn + ("%s state -> up : echo response received after %ld.%06ld " + "seconds", dmn->name, (long)delay.tv_sec, + (long)delay.tv_usec); + } else + zlog_warn + ("%s: slow echo response finally received after %ld.%06ld " + "seconds", dmn->name, (long)delay.tv_sec, + (long)delay.tv_usec); + } else if (gs.loglevel > LOG_DEBUG + 1) + zlog_debug("%s: echo response received after %ld.%06ld seconds", + dmn->name, (long)delay.tv_sec, (long)delay.tv_usec); + + SET_READ_HANDLER(dmn); + if (dmn->t_wakeup) + thread_cancel(dmn->t_wakeup); + SET_WAKEUP_ECHO(dmn); + + return 0; } /* * Wait till we notice that all daemons are ready before * we send we are ready to systemd */ -static void -daemon_send_ready (void) +static void daemon_send_ready(void) { - static int sent = 0; - if (!sent && gs.numdown == 0) - { + static int sent = 0; + if (!sent && gs.numdown == 0) { #if defined (HAVE_CUMULUS) - FILE *fp; + FILE *fp; - fp = fopen(DAEMON_VTY_DIR "/watchfrr.started", "w"); - fclose(fp); + fp = fopen(DAEMON_VTY_DIR "/watchfrr.started", "w"); + fclose(fp); #endif - zlog_notice ("Watchfrr: Notifying Systemd we are up and running"); - systemd_send_started(master, 0); - sent = 1; - } + zlog_notice + ("Watchfrr: Notifying Systemd we are up and running"); + systemd_send_started(master, 0); + sent = 1; + } } -static void -daemon_up(struct daemon *dmn, const char *why) +static void daemon_up(struct daemon *dmn, const char *why) { - dmn->state = DAEMON_UP; - gs.numdown--; - dmn->connect_tries = 0; - zlog_notice("%s state -> up : %s",dmn->name,why); - daemon_send_ready(); - if (gs.do_ping) - SET_WAKEUP_ECHO(dmn); - phase_check(); + dmn->state = DAEMON_UP; + gs.numdown--; + dmn->connect_tries = 0; + zlog_notice("%s state -> up : %s", dmn->name, why); + daemon_send_ready(); + if (gs.do_ping) + SET_WAKEUP_ECHO(dmn); + phase_check(); } -static int -check_connect(struct thread *t_write) +static int check_connect(struct thread *t_write) { - struct daemon *dmn = THREAD_ARG(t_write); - int sockerr; - socklen_t reslen = sizeof(sockerr); + struct daemon *dmn = THREAD_ARG(t_write); + int sockerr; + socklen_t reslen = sizeof(sockerr); - dmn->t_write = NULL; - if (getsockopt(dmn->fd,SOL_SOCKET,SO_ERROR,(char *)&sockerr,&reslen) < 0) - { - zlog_warn("%s: check_connect: getsockopt failed: %s", - dmn->name,safe_strerror(errno)); - daemon_down(dmn,"getsockopt failed checking connection success"); - return 0; - } - if ((reslen == sizeof(sockerr)) && sockerr) - { - char why[100]; - snprintf(why,sizeof(why), - "getsockopt reports that connection attempt failed: %s", - safe_strerror(sockerr)); - daemon_down(dmn,why); - return 0; - } + dmn->t_write = NULL; + if (getsockopt(dmn->fd, SOL_SOCKET, SO_ERROR, (char *)&sockerr, &reslen) + < 0) { + zlog_warn("%s: check_connect: getsockopt failed: %s", dmn->name, + safe_strerror(errno)); + daemon_down(dmn, + "getsockopt failed checking connection success"); + return 0; + } + if ((reslen == sizeof(sockerr)) && sockerr) { + char why[100]; + snprintf(why, sizeof(why), + "getsockopt reports that connection attempt failed: %s", + safe_strerror(sockerr)); + daemon_down(dmn, why); + return 0; + } - daemon_up(dmn,"delayed connect succeeded"); - return 0; + daemon_up(dmn, "delayed connect succeeded"); + return 0; } -static int -wakeup_connect_hanging(struct thread *t_wakeup) +static int wakeup_connect_hanging(struct thread *t_wakeup) { - struct daemon *dmn = THREAD_ARG(t_wakeup); - char why[100]; + struct daemon *dmn = THREAD_ARG(t_wakeup); + char why[100]; - dmn->t_wakeup = NULL; - snprintf(why,sizeof(why),"connection attempt timed out after %ld seconds", - gs.timeout); - daemon_down(dmn,why); - return 0; + dmn->t_wakeup = NULL; + snprintf(why, sizeof(why), + "connection attempt timed out after %ld seconds", gs.timeout); + daemon_down(dmn, why); + return 0; } /* Making connection to protocol daemon. */ -static int -try_connect(struct daemon *dmn) +static int try_connect(struct daemon *dmn) { - int sock; - struct sockaddr_un addr; - socklen_t len; + int sock; + struct sockaddr_un addr; + socklen_t len; - if (gs.loglevel > LOG_DEBUG+1) - zlog_debug("%s: attempting to connect",dmn->name); - dmn->connect_tries++; + if (gs.loglevel > LOG_DEBUG + 1) + zlog_debug("%s: attempting to connect", dmn->name); + dmn->connect_tries++; - memset (&addr, 0, sizeof (struct sockaddr_un)); - addr.sun_family = AF_UNIX; - snprintf(addr.sun_path, sizeof(addr.sun_path), "%s/%s.vty", - gs.vtydir,dmn->name); + memset(&addr, 0, sizeof(struct sockaddr_un)); + addr.sun_family = AF_UNIX; + snprintf(addr.sun_path, sizeof(addr.sun_path), "%s/%s.vty", + gs.vtydir, dmn->name); #ifdef HAVE_STRUCT_SOCKADDR_UN_SUN_LEN - len = addr.sun_len = SUN_LEN(&addr); + len = addr.sun_len = SUN_LEN(&addr); #else - len = sizeof (addr.sun_family) + strlen (addr.sun_path); -#endif /* HAVE_STRUCT_SOCKADDR_UN_SUN_LEN */ + len = sizeof(addr.sun_family) + strlen(addr.sun_path); +#endif /* HAVE_STRUCT_SOCKADDR_UN_SUN_LEN */ - /* Quick check to see if we might succeed before we go to the trouble - of creating a socket. */ - if (access(addr.sun_path, W_OK) < 0) - { - if (errno != ENOENT) - zlog_err("%s: access to socket %s denied: %s", - dmn->name,addr.sun_path,safe_strerror(errno)); - return -1; - } - - if ((sock = socket (AF_UNIX, SOCK_STREAM, 0)) < 0) - { - zlog_err("%s(%s): cannot make socket: %s", - __func__,addr.sun_path, safe_strerror(errno)); - return -1; - } - - if (set_nonblocking(sock) < 0 || set_cloexec(sock) < 0) - { - zlog_err("%s(%s): set_nonblocking/cloexec(%d) failed", - __func__, addr.sun_path, sock); - close(sock); - return -1; - } - - if (connect (sock, (struct sockaddr *) &addr, len) < 0) - { - if ((errno != EINPROGRESS) && (errno != EWOULDBLOCK)) - { - if (gs.loglevel > LOG_DEBUG) - zlog_debug("%s(%s): connect failed: %s", - __func__,addr.sun_path, safe_strerror(errno)); - close (sock); - return -1; + /* Quick check to see if we might succeed before we go to the trouble + of creating a socket. */ + if (access(addr.sun_path, W_OK) < 0) { + if (errno != ENOENT) + zlog_err("%s: access to socket %s denied: %s", + dmn->name, addr.sun_path, + safe_strerror(errno)); + return -1; } - if (gs.loglevel > LOG_DEBUG) - zlog_debug("%s: connection in progress",dmn->name); - dmn->state = DAEMON_CONNECTING; - dmn->fd = sock; - dmn->t_write = thread_add_write(master,check_connect,dmn,dmn->fd); - dmn->t_wakeup = thread_add_timer(master,wakeup_connect_hanging,dmn, - gs.timeout); - SET_READ_HANDLER(dmn); - return 0; - } - dmn->fd = sock; - SET_READ_HANDLER(dmn); - daemon_up(dmn,"connect succeeded"); - return 1; -} - -static int -phase_hanging(struct thread *t_hanging) -{ - gs.t_phase_hanging = NULL; - zlog_err("Phase [%s] hanging for %ld seconds, aborting phased restart", - phase_str[gs.phase],PHASE_TIMEOUT); - gs.phase = PHASE_NONE; - return 0; -} - -static void -set_phase(restart_phase_t new_phase) -{ - gs.phase = new_phase; - if (gs.t_phase_hanging) - thread_cancel(gs.t_phase_hanging); - gs.t_phase_hanging = thread_add_timer(master,phase_hanging,NULL, - PHASE_TIMEOUT); -} - -static void -phase_check(void) -{ - switch (gs.phase) - { - case PHASE_NONE: - break; - case PHASE_STOPS_PENDING: - if (gs.numpids) - break; - zlog_info("Phased restart: all routing daemon stop jobs have completed."); - set_phase(PHASE_WAITING_DOWN); - /*FALLTHRU*/ - case PHASE_WAITING_DOWN: - if (gs.numdown+IS_UP(gs.special) < gs.numdaemons) - break; - zlog_info("Phased restart: all routing daemons now down."); - run_job(&gs.special->restart,"restart",gs.restart_command,1,1); - set_phase(PHASE_ZEBRA_RESTART_PENDING); - /*FALLTHRU*/ - case PHASE_ZEBRA_RESTART_PENDING: - if (gs.special->restart.pid) - break; - zlog_info("Phased restart: %s restart job completed.",gs.special->name); - set_phase(PHASE_WAITING_ZEBRA_UP); - /*FALLTHRU*/ - case PHASE_WAITING_ZEBRA_UP: - if (!IS_UP(gs.special)) - break; - zlog_info("Phased restart: %s is now up.",gs.special->name); - { - struct daemon *dmn; - for (dmn = gs.daemons; dmn; dmn = dmn->next) - { - if (dmn != gs.special) - run_job(&dmn->restart,"start",gs.start_command,1,0); - } - } - gs.phase = PHASE_NONE; - THREAD_OFF(gs.t_phase_hanging); - zlog_notice("Phased global restart has completed."); - break; - } -} - -static void -try_restart(struct daemon *dmn) -{ - switch (gs.mode) - { - case MODE_MONITOR: - return; - case MODE_GLOBAL_RESTART: - run_job(&gs.restart,"restart",gs.restart_command,0,1); - break; - case MODE_SEPARATE_RESTART: - run_job(&dmn->restart,"restart",gs.restart_command,0,1); - break; - case MODE_PHASED_ZEBRA_RESTART: - if (dmn != gs.special) - { - if ((gs.special->state == DAEMON_UP) && (gs.phase == PHASE_NONE)) - run_job(&dmn->restart,"restart",gs.restart_command,0,1); - else - zlog_debug("%s: postponing restart attempt because master %s daemon " - "not up [%s], or phased restart in progress", - dmn->name,gs.special->name,state_str[gs.special->state]); - break; - } - /*FALLTHRU*/ - case MODE_PHASED_ALL_RESTART: - if ((gs.phase != PHASE_NONE) || gs.numpids) - { - if (gs.loglevel > LOG_DEBUG+1) - zlog_debug("postponing phased global restart: restart already in " - "progress [%s], or outstanding child processes [%d]", - phase_str[gs.phase],gs.numpids); - break; - } - /* Is it too soon for a restart? */ - { - struct timeval delay; - if (time_elapsed(&delay,&gs.special->restart.time)->tv_sec < - gs.special->restart.interval) - { - if (gs.loglevel > LOG_DEBUG+1) - zlog_debug("postponing phased global restart: " - "elapsed time %ld < retry interval %ld", - (long)delay.tv_sec,gs.special->restart.interval); - break; + if ((sock = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) { + zlog_err("%s(%s): cannot make socket: %s", + __func__, addr.sun_path, safe_strerror(errno)); + return -1; } - } - run_job(&gs.restart,"restart",gs.restart_command,0,1); - break; - default: - zlog_err("error: unknown restart mode %d",gs.mode); - break; - } + + if (set_nonblocking(sock) < 0 || set_cloexec(sock) < 0) { + zlog_err("%s(%s): set_nonblocking/cloexec(%d) failed", + __func__, addr.sun_path, sock); + close(sock); + return -1; + } + + if (connect(sock, (struct sockaddr *)&addr, len) < 0) { + if ((errno != EINPROGRESS) && (errno != EWOULDBLOCK)) { + if (gs.loglevel > LOG_DEBUG) + zlog_debug("%s(%s): connect failed: %s", + __func__, addr.sun_path, + safe_strerror(errno)); + close(sock); + return -1; + } + if (gs.loglevel > LOG_DEBUG) + zlog_debug("%s: connection in progress", dmn->name); + dmn->state = DAEMON_CONNECTING; + dmn->fd = sock; + dmn->t_write = + thread_add_write(master, check_connect, dmn, dmn->fd); + dmn->t_wakeup = + thread_add_timer(master, wakeup_connect_hanging, dmn, + gs.timeout); + SET_READ_HANDLER(dmn); + return 0; + } + + dmn->fd = sock; + SET_READ_HANDLER(dmn); + daemon_up(dmn, "connect succeeded"); + return 1; } -static int -wakeup_unresponsive(struct thread *t_wakeup) +static int phase_hanging(struct thread *t_hanging) { - struct daemon *dmn = THREAD_ARG(t_wakeup); - - dmn->t_wakeup = NULL; - if (dmn->state != DAEMON_UNRESPONSIVE) - zlog_err("%s: no longer unresponsive (now %s), " - "wakeup should have been cancelled!", - dmn->name,state_str[dmn->state]); - else - { - SET_WAKEUP_UNRESPONSIVE(dmn); - try_restart(dmn); - } - return 0; + gs.t_phase_hanging = NULL; + zlog_err("Phase [%s] hanging for %ld seconds, aborting phased restart", + phase_str[gs.phase], PHASE_TIMEOUT); + gs.phase = PHASE_NONE; + return 0; } -static int -wakeup_no_answer(struct thread *t_wakeup) +static void set_phase(restart_phase_t new_phase) { - struct daemon *dmn = THREAD_ARG(t_wakeup); - - dmn->t_wakeup = NULL; - dmn->state = DAEMON_UNRESPONSIVE; - zlog_err("%s state -> unresponsive : no response yet to ping " - "sent %ld seconds ago",dmn->name,gs.timeout); - if (gs.unresponsive_restart) - { - SET_WAKEUP_UNRESPONSIVE(dmn); - try_restart(dmn); - } - return 0; + gs.phase = new_phase; + if (gs.t_phase_hanging) + thread_cancel(gs.t_phase_hanging); + gs.t_phase_hanging = thread_add_timer(master, phase_hanging, NULL, + PHASE_TIMEOUT); } -static int -wakeup_send_echo(struct thread *t_wakeup) +static void phase_check(void) { - static const char echocmd[] = "echo " PING_TOKEN; - ssize_t rc; - struct daemon *dmn = THREAD_ARG(t_wakeup); + switch (gs.phase) { + case PHASE_NONE: + break; + case PHASE_STOPS_PENDING: + if (gs.numpids) + break; + zlog_info + ("Phased restart: all routing daemon stop jobs have completed."); + set_phase(PHASE_WAITING_DOWN); - dmn->t_wakeup = NULL; - if (((rc = write(dmn->fd,echocmd,sizeof(echocmd))) < 0) || - ((size_t)rc != sizeof(echocmd))) - { - char why[100+sizeof(echocmd)]; - snprintf(why,sizeof(why),"write '%s' returned %d instead of %u", - echocmd,(int)rc,(u_int)sizeof(echocmd)); - daemon_down(dmn,why); - } - else - { - gettimeofday(&dmn->echo_sent,NULL); - dmn->t_wakeup = thread_add_timer(master,wakeup_no_answer,dmn,gs.timeout); - } - return 0; + /*FALLTHRU*/ + case PHASE_WAITING_DOWN: + if (gs.numdown + IS_UP(gs.special) < gs.numdaemons) + break; + zlog_info("Phased restart: all routing daemons now down."); + run_job(&gs.special->restart, "restart", gs.restart_command, 1, + 1); + set_phase(PHASE_ZEBRA_RESTART_PENDING); + + /*FALLTHRU*/ + case PHASE_ZEBRA_RESTART_PENDING: + if (gs.special->restart.pid) + break; + zlog_info("Phased restart: %s restart job completed.", + gs.special->name); + set_phase(PHASE_WAITING_ZEBRA_UP); + + /*FALLTHRU*/ + case PHASE_WAITING_ZEBRA_UP: + if (!IS_UP(gs.special)) + break; + zlog_info("Phased restart: %s is now up.", gs.special->name); + { + struct daemon *dmn; + for (dmn = gs.daemons; dmn; dmn = dmn->next) { + if (dmn != gs.special) + run_job(&dmn->restart, "start", + gs.start_command, 1, 0); + } + } + gs.phase = PHASE_NONE; + THREAD_OFF(gs.t_phase_hanging); + zlog_notice("Phased global restart has completed."); + break; + } } -static void -sigint(void) +static void try_restart(struct daemon *dmn) { - zlog_notice("Terminating on signal"); - systemd_send_stopping (); - exit(0); + switch (gs.mode) { + case MODE_MONITOR: + return; + case MODE_GLOBAL_RESTART: + run_job(&gs.restart, "restart", gs.restart_command, 0, 1); + break; + case MODE_SEPARATE_RESTART: + run_job(&dmn->restart, "restart", gs.restart_command, 0, 1); + break; + case MODE_PHASED_ZEBRA_RESTART: + if (dmn != gs.special) { + if ((gs.special->state == DAEMON_UP) + && (gs.phase == PHASE_NONE)) + run_job(&dmn->restart, "restart", + gs.restart_command, 0, 1); + else + zlog_debug + ("%s: postponing restart attempt because master %s daemon " + "not up [%s], or phased restart in progress", + dmn->name, gs.special->name, + state_str[gs.special->state]); + break; + } + + /*FALLTHRU*/ + case MODE_PHASED_ALL_RESTART: + if ((gs.phase != PHASE_NONE) || gs.numpids) { + if (gs.loglevel > LOG_DEBUG + 1) + zlog_debug + ("postponing phased global restart: restart already in " + "progress [%s], or outstanding child processes [%d]", + phase_str[gs.phase], gs.numpids); + break; + } + /* Is it too soon for a restart? */ + { + struct timeval delay; + if (time_elapsed(&delay, &gs.special->restart.time)-> + tv_sec < gs.special->restart.interval) { + if (gs.loglevel > LOG_DEBUG + 1) + zlog_debug + ("postponing phased global restart: " + "elapsed time %ld < retry interval %ld", + (long)delay.tv_sec, + gs.special->restart.interval); + break; + } + } + run_job(&gs.restart, "restart", gs.restart_command, 0, 1); + break; + default: + zlog_err("error: unknown restart mode %d", gs.mode); + break; + } } -static int -valid_command(const char *cmd) +static int wakeup_unresponsive(struct thread *t_wakeup) { - char *p; + struct daemon *dmn = THREAD_ARG(t_wakeup); - return ((p = strchr(cmd,'%')) != NULL) && (*(p+1) == 's') && !strchr(p+1,'%'); + dmn->t_wakeup = NULL; + if (dmn->state != DAEMON_UNRESPONSIVE) + zlog_err("%s: no longer unresponsive (now %s), " + "wakeup should have been cancelled!", + dmn->name, state_str[dmn->state]); + else { + SET_WAKEUP_UNRESPONSIVE(dmn); + try_restart(dmn); + } + return 0; +} + +static int wakeup_no_answer(struct thread *t_wakeup) +{ + struct daemon *dmn = THREAD_ARG(t_wakeup); + + dmn->t_wakeup = NULL; + dmn->state = DAEMON_UNRESPONSIVE; + zlog_err("%s state -> unresponsive : no response yet to ping " + "sent %ld seconds ago", dmn->name, gs.timeout); + if (gs.unresponsive_restart) { + SET_WAKEUP_UNRESPONSIVE(dmn); + try_restart(dmn); + } + return 0; +} + +static int wakeup_send_echo(struct thread *t_wakeup) +{ + static const char echocmd[] = "echo " PING_TOKEN; + ssize_t rc; + struct daemon *dmn = THREAD_ARG(t_wakeup); + + dmn->t_wakeup = NULL; + if (((rc = write(dmn->fd, echocmd, sizeof(echocmd))) < 0) || + ((size_t) rc != sizeof(echocmd))) { + char why[100 + sizeof(echocmd)]; + snprintf(why, sizeof(why), + "write '%s' returned %d instead of %u", echocmd, + (int)rc, (u_int) sizeof(echocmd)); + daemon_down(dmn, why); + } else { + gettimeofday(&dmn->echo_sent, NULL); + dmn->t_wakeup = + thread_add_timer(master, wakeup_no_answer, dmn, gs.timeout); + } + return 0; +} + +static void sigint(void) +{ + zlog_notice("Terminating on signal"); + systemd_send_stopping(); + exit(0); +} + +static int valid_command(const char *cmd) +{ + char *p; + + return ((p = strchr(cmd, '%')) != NULL) && (*(p + 1) == 's') + && !strchr(p + 1, '%'); } /* This is an ugly hack to circumvent problems with passing command-line arguments that contain spaces. The fix is to use a configuration file. */ -static char * -translate_blanks(const char *cmd, const char *blankstr) +static char *translate_blanks(const char *cmd, const char *blankstr) { - char *res; - char *p; - size_t bslen = strlen(blankstr); + char *res; + char *p; + size_t bslen = strlen(blankstr); - if (!(res = strdup(cmd))) - { - perror("strdup"); - exit(1); - } - while ((p = strstr(res,blankstr)) != NULL) - { - *p = ' '; - if (bslen != 1) - memmove(p+1,p+bslen,strlen(p+bslen)+1); - } - return res; + if (!(res = strdup(cmd))) { + perror("strdup"); + exit(1); + } + while ((p = strstr(res, blankstr)) != NULL) { + *p = ' '; + if (bslen != 1) + memmove(p + 1, p + bslen, strlen(p + bslen) + 1); + } + return res; } -struct zebra_privs_t watchfrr_privs = -{ +struct zebra_privs_t watchfrr_privs = { #ifdef VTY_GROUP - .vty_group = VTY_GROUP, + .vty_group = VTY_GROUP, #endif }; -int -main(int argc, char **argv) +int main(int argc, char **argv) { - const char *progname; - int opt; - int daemon_mode = 0; - const char *pidfile = DEFAULT_PIDFILE; - const char *special = "zebra"; - const char *blankstr = NULL; - static struct quagga_signal_t my_signals[] = - { - { - .signal = SIGINT, - .handler = sigint, - }, - { - .signal = SIGTERM, - .handler = sigint, - }, - { - .signal = SIGCHLD, - .handler = sigchild, - }, - }; + const char *progname; + int opt; + int daemon_mode = 0; + const char *pidfile = DEFAULT_PIDFILE; + const char *special = "zebra"; + const char *blankstr = NULL; + static struct quagga_signal_t my_signals[] = { + { + .signal = SIGINT, + .handler = sigint, + }, + { + .signal = SIGTERM, + .handler = sigint, + }, + { + .signal = SIGCHLD, + .handler = sigchild, + }, + }; - if ((progname = strrchr (argv[0], '/')) != NULL) - progname++; - else - progname = argv[0]; - - gs.restart.name = "all"; - while ((opt = getopt_long(argc, argv, "aAb:dek:l:m:M:i:p:r:R:S:s:t:T:zvh", - longopts, 0)) != EOF) - { - switch (opt) - { - case 0: - break; - case 'a': - if ((gs.mode != MODE_MONITOR) && (gs.mode != MODE_SEPARATE_RESTART)) - { - fputs("Ambiguous operating mode selected.\n",stderr); - return usage(progname,1); - } - gs.mode = MODE_PHASED_ZEBRA_RESTART; - break; - case 'A': - if ((gs.mode != MODE_MONITOR) && (gs.mode != MODE_SEPARATE_RESTART)) - { - fputs("Ambiguous operating mode selected.\n",stderr); - return usage(progname,1); - } - gs.mode = MODE_PHASED_ALL_RESTART; - break; - case 'b': - blankstr = optarg; - break; - case 'd': - daemon_mode = 1; - break; - case 'e': - gs.do_ping = 0; - break; - case 'k': - if (!valid_command(optarg)) - { - fprintf(stderr,"Invalid kill command, must contain '%%s': %s\n", - optarg); - return usage(progname,1); - } - gs.stop_command = optarg; - break; - case 'l': - { - char garbage[3]; - if ((sscanf(optarg,"%d%1s",&gs.loglevel,garbage) != 1) || - (gs.loglevel < LOG_EMERG)) - { - fprintf(stderr,"Invalid loglevel argument: %s\n",optarg); - return usage(progname,1); - } - } - break; - case 'm': - { - char garbage[3]; - if ((sscanf(optarg,"%ld%1s", - &gs.min_restart_interval,garbage) != 1) || - (gs.min_restart_interval < 0)) - { - fprintf(stderr,"Invalid min_restart_interval argument: %s\n", - optarg); - return usage(progname,1); - } - } - break; - case 'M': - { - char garbage[3]; - if ((sscanf(optarg,"%ld%1s", - &gs.max_restart_interval,garbage) != 1) || - (gs.max_restart_interval < 0)) - { - fprintf(stderr,"Invalid max_restart_interval argument: %s\n", - optarg); - return usage(progname,1); - } - } - break; - case 'i': - { - char garbage[3]; - int period; - if ((sscanf(optarg,"%d%1s",&period,garbage) != 1) || - (gs.period < 1)) - { - fprintf(stderr,"Invalid interval argument: %s\n",optarg); - return usage(progname,1); - } - gs.period = 1000*period; - } - break; - case 'p': - pidfile = optarg; - break; - case 'r': - if ((gs.mode == MODE_GLOBAL_RESTART) || - (gs.mode == MODE_SEPARATE_RESTART)) - { - fputs("Ambiguous operating mode selected.\n",stderr); - return usage(progname,1); - } - if (!valid_command(optarg)) - { - fprintf(stderr, - "Invalid restart command, must contain '%%s': %s\n", - optarg); - return usage(progname,1); - } - gs.restart_command = optarg; - if (gs.mode == MODE_MONITOR) - gs.mode = MODE_SEPARATE_RESTART; - break; - case 'R': - if (gs.mode != MODE_MONITOR) - { - fputs("Ambiguous operating mode selected.\n",stderr); - return usage(progname,1); - } - if (strchr(optarg,'%')) - { - fprintf(stderr, - "Invalid restart-all arg, must not contain '%%s': %s\n", - optarg); - return usage(progname,1); - } - gs.restart_command = optarg; - gs.mode = MODE_GLOBAL_RESTART; - break; - case 's': - if (!valid_command(optarg)) - { - fprintf(stderr,"Invalid start command, must contain '%%s': %s\n", - optarg); - return usage(progname,1); - } - gs.start_command = optarg; - break; - case 'S': - gs.vtydir = optarg; - break; - case 't': - { - char garbage[3]; - if ((sscanf(optarg,"%ld%1s",&gs.timeout,garbage) != 1) || - (gs.timeout < 1)) - { - fprintf(stderr,"Invalid timeout argument: %s\n",optarg); - return usage(progname,1); - } - } - break; - case 'T': - { - char garbage[3]; - if ((sscanf(optarg,"%ld%1s",&gs.restart_timeout,garbage) != 1) || - (gs.restart_timeout < 1)) - { - fprintf(stderr,"Invalid restart timeout argument: %s\n",optarg); - return usage(progname,1); - } - } - break; - case 'z': - gs.unresponsive_restart = 1; - break; - case 'v': - printf ("%s version %s\n", progname, FRR_VERSION); - puts("Copyright 2004 Andrew J. Schorr"); - return 0; - case 'h': - return usage(progname,0); - default: - fputs("Invalid option.\n",stderr); - return usage(progname,1); - } - } - - if (gs.unresponsive_restart && (gs.mode == MODE_MONITOR)) - { - fputs("Option -z requires a -r or -R restart option.\n",stderr); - return usage(progname,1); - } - switch (gs.mode) - { - case MODE_MONITOR: - if (gs.restart_command || gs.start_command || gs.stop_command) - { - fprintf(stderr,"No kill/(re)start commands needed for %s mode.\n", - mode_str[gs.mode]); - return usage(progname,1); - } - break; - case MODE_GLOBAL_RESTART: - case MODE_SEPARATE_RESTART: - if (!gs.restart_command || gs.start_command || gs.stop_command) - { - fprintf(stderr,"No start/kill commands needed in [%s] mode.\n", - mode_str[gs.mode]); - return usage(progname,1); - } - break; - case MODE_PHASED_ZEBRA_RESTART: - case MODE_PHASED_ALL_RESTART: - if (!gs.restart_command || !gs.start_command || !gs.stop_command) - { - fprintf(stderr, - "Need start, kill, and restart commands in [%s] mode.\n", - mode_str[gs.mode]); - return usage(progname,1); - } - break; - } - - if (blankstr) - { - if (gs.restart_command) - gs.restart_command = translate_blanks(gs.restart_command,blankstr); - if (gs.start_command) - gs.start_command = translate_blanks(gs.start_command,blankstr); - if (gs.stop_command) - gs.stop_command = translate_blanks(gs.stop_command,blankstr); - } - - gs.restart.interval = gs.min_restart_interval; - - zprivs_init (&watchfrr_privs); - - master = thread_master_create(); - cmd_init(-1); - memory_init(); - vty_init(master); - watchfrr_vty_init(); - vty_serv_sock(NULL, 0, WATCHFRR_VTYSH_PATH); - - signal_init (master, array_size(my_signals), my_signals); - srandom(time(NULL)); - - { - int i; - struct daemon *tail = NULL; - - for (i = optind; i < argc; i++) - { - struct daemon *dmn; - - if (!(dmn = (struct daemon *)calloc(1,sizeof(*dmn)))) - { - fprintf(stderr,"calloc(1,%u) failed: %s\n", - (u_int)sizeof(*dmn), safe_strerror(errno)); - return 1; - } - dmn->name = dmn->restart.name = argv[i]; - dmn->state = DAEMON_INIT; - gs.numdaemons++; - gs.numdown++; - dmn->fd = -1; - dmn->t_wakeup = thread_add_timer_msec(master,wakeup_init,dmn, - 100+(random() % 900)); - dmn->restart.interval = gs.min_restart_interval; - if (tail) - tail->next = dmn; + if ((progname = strrchr(argv[0], '/')) != NULL) + progname++; else - gs.daemons = dmn; - tail = dmn; + progname = argv[0]; + gs.restart.name = "all"; + while ((opt = + getopt_long(argc, argv, "aAb:dek:l:m:M:i:p:r:R:S:s:t:T:zvh", + longopts, 0)) != EOF) { + switch (opt) { + case 0: + break; + case 'a': + if ((gs.mode != MODE_MONITOR) + && (gs.mode != MODE_SEPARATE_RESTART)) { + fputs("Ambiguous operating mode selected.\n", + stderr); + return usage(progname, 1); + } + gs.mode = MODE_PHASED_ZEBRA_RESTART; + break; + case 'A': + if ((gs.mode != MODE_MONITOR) + && (gs.mode != MODE_SEPARATE_RESTART)) { + fputs("Ambiguous operating mode selected.\n", + stderr); + return usage(progname, 1); + } + gs.mode = MODE_PHASED_ALL_RESTART; + break; + case 'b': + blankstr = optarg; + break; + case 'd': + daemon_mode = 1; + break; + case 'e': + gs.do_ping = 0; + break; + case 'k': + if (!valid_command(optarg)) { + fprintf(stderr, + "Invalid kill command, must contain '%%s': %s\n", + optarg); + return usage(progname, 1); + } + gs.stop_command = optarg; + break; + case 'l': + { + char garbage[3]; + if ((sscanf + (optarg, "%d%1s", &gs.loglevel, + garbage) != 1) + || (gs.loglevel < LOG_EMERG)) { + fprintf(stderr, + "Invalid loglevel argument: %s\n", + optarg); + return usage(progname, 1); + } + } + break; + case 'm': + { + char garbage[3]; + if ((sscanf(optarg, "%ld%1s", + &gs.min_restart_interval, + garbage) != 1) + || (gs.min_restart_interval < 0)) { + fprintf(stderr, + "Invalid min_restart_interval argument: %s\n", + optarg); + return usage(progname, 1); + } + } + break; + case 'M': + { + char garbage[3]; + if ((sscanf(optarg, "%ld%1s", + &gs.max_restart_interval, + garbage) != 1) + || (gs.max_restart_interval < 0)) { + fprintf(stderr, + "Invalid max_restart_interval argument: %s\n", + optarg); + return usage(progname, 1); + } + } + break; + case 'i': + { + char garbage[3]; + int period; + if ((sscanf(optarg, "%d%1s", &period, garbage) + != 1) || (gs.period < 1)) { + fprintf(stderr, + "Invalid interval argument: %s\n", + optarg); + return usage(progname, 1); + } + gs.period = 1000 * period; + } + break; + case 'p': + pidfile = optarg; + break; + case 'r': + if ((gs.mode == MODE_GLOBAL_RESTART) || + (gs.mode == MODE_SEPARATE_RESTART)) { + fputs("Ambiguous operating mode selected.\n", + stderr); + return usage(progname, 1); + } + if (!valid_command(optarg)) { + fprintf(stderr, + "Invalid restart command, must contain '%%s': %s\n", + optarg); + return usage(progname, 1); + } + gs.restart_command = optarg; + if (gs.mode == MODE_MONITOR) + gs.mode = MODE_SEPARATE_RESTART; + break; + case 'R': + if (gs.mode != MODE_MONITOR) { + fputs("Ambiguous operating mode selected.\n", + stderr); + return usage(progname, 1); + } + if (strchr(optarg, '%')) { + fprintf(stderr, + "Invalid restart-all arg, must not contain '%%s': %s\n", + optarg); + return usage(progname, 1); + } + gs.restart_command = optarg; + gs.mode = MODE_GLOBAL_RESTART; + break; + case 's': + if (!valid_command(optarg)) { + fprintf(stderr, + "Invalid start command, must contain '%%s': %s\n", + optarg); + return usage(progname, 1); + } + gs.start_command = optarg; + break; + case 'S': + gs.vtydir = optarg; + break; + case 't': + { + char garbage[3]; + if ((sscanf + (optarg, "%ld%1s", &gs.timeout, + garbage) != 1) || (gs.timeout < 1)) { + fprintf(stderr, + "Invalid timeout argument: %s\n", + optarg); + return usage(progname, 1); + } + } + break; + case 'T': + { + char garbage[3]; + if ((sscanf + (optarg, "%ld%1s", &gs.restart_timeout, + garbage) != 1) + || (gs.restart_timeout < 1)) { + fprintf(stderr, + "Invalid restart timeout argument: %s\n", + optarg); + return usage(progname, 1); + } + } + break; + case 'z': + gs.unresponsive_restart = 1; + break; + case 'v': + printf("%s version %s\n", progname, FRR_VERSION); + puts("Copyright 2004 Andrew J. Schorr"); + return 0; + case 'h': + return usage(progname, 0); + default: + fputs("Invalid option.\n", stderr); + return usage(progname, 1); + } + } + + if (gs.unresponsive_restart && (gs.mode == MODE_MONITOR)) { + fputs("Option -z requires a -r or -R restart option.\n", + stderr); + return usage(progname, 1); + } + switch (gs.mode) { + case MODE_MONITOR: + if (gs.restart_command || gs.start_command || gs.stop_command) { + fprintf(stderr, + "No kill/(re)start commands needed for %s mode.\n", + mode_str[gs.mode]); + return usage(progname, 1); + } + break; + case MODE_GLOBAL_RESTART: + case MODE_SEPARATE_RESTART: + if (!gs.restart_command || gs.start_command || gs.stop_command) { + fprintf(stderr, + "No start/kill commands needed in [%s] mode.\n", + mode_str[gs.mode]); + return usage(progname, 1); + } + break; + case MODE_PHASED_ZEBRA_RESTART: + case MODE_PHASED_ALL_RESTART: + if (!gs.restart_command || !gs.start_command + || !gs.stop_command) { + fprintf(stderr, + "Need start, kill, and restart commands in [%s] mode.\n", + mode_str[gs.mode]); + return usage(progname, 1); + } + break; + } + + if (blankstr) { + if (gs.restart_command) + gs.restart_command = + translate_blanks(gs.restart_command, blankstr); + if (gs.start_command) + gs.start_command = + translate_blanks(gs.start_command, blankstr); + if (gs.stop_command) + gs.stop_command = + translate_blanks(gs.stop_command, blankstr); + } + + gs.restart.interval = gs.min_restart_interval; + + zprivs_init(&watchfrr_privs); + + master = thread_master_create(); + cmd_init(-1); + memory_init(); + vty_init(master); + watchfrr_vty_init(); + vty_serv_sock(NULL, 0, WATCHFRR_VTYSH_PATH); + + signal_init(master, array_size(my_signals), my_signals); + srandom(time(NULL)); + + { + int i; + struct daemon *tail = NULL; + + for (i = optind; i < argc; i++) { + struct daemon *dmn; + + if (!(dmn = (struct daemon *)calloc(1, sizeof(*dmn)))) { + fprintf(stderr, "calloc(1,%u) failed: %s\n", + (u_int) sizeof(*dmn), + safe_strerror(errno)); + return 1; + } + dmn->name = dmn->restart.name = argv[i]; + dmn->state = DAEMON_INIT; + gs.numdaemons++; + gs.numdown++; + dmn->fd = -1; + dmn->t_wakeup = + thread_add_timer_msec(master, wakeup_init, dmn, + 100 + (random() % 900)); + dmn->restart.interval = gs.min_restart_interval; + if (tail) + tail->next = dmn; + else + gs.daemons = dmn; + tail = dmn; + + if (((gs.mode == MODE_PHASED_ZEBRA_RESTART) || + (gs.mode == MODE_PHASED_ALL_RESTART)) && + !strcmp(dmn->name, special)) + gs.special = dmn; + } + } + if (!gs.daemons) { + fputs("Must specify one or more daemons to monitor.\n", stderr); + return usage(progname, 1); + } if (((gs.mode == MODE_PHASED_ZEBRA_RESTART) || - (gs.mode == MODE_PHASED_ALL_RESTART)) && - !strcmp(dmn->name,special)) - gs.special = dmn; - } - } - if (!gs.daemons) - { - fputs("Must specify one or more daemons to monitor.\n",stderr); - return usage(progname,1); - } - if (((gs.mode == MODE_PHASED_ZEBRA_RESTART) || - (gs.mode == MODE_PHASED_ALL_RESTART)) && !gs.special) - { - fprintf(stderr,"In mode [%s], but cannot find master daemon %s\n", - mode_str[gs.mode],special); - return usage(progname,1); - } - - zlog_default = openzlog(progname, ZLOG_WATCHFRR, 0, - LOG_CONS|LOG_NDELAY|LOG_PID, LOG_DAEMON); - zlog_set_level(NULL, ZLOG_DEST_MONITOR, ZLOG_DISABLED); - if (daemon_mode) - { - zlog_set_level(NULL, ZLOG_DEST_SYSLOG, MIN(gs.loglevel,LOG_DEBUG)); - if (daemon (0, 0) < 0) - { - fprintf(stderr, "Watchfrr daemon failed: %s", strerror(errno)); - exit (1); + (gs.mode == MODE_PHASED_ALL_RESTART)) && !gs.special) { + fprintf(stderr, + "In mode [%s], but cannot find master daemon %s\n", + mode_str[gs.mode], special); + return usage(progname, 1); } - } - else - zlog_set_level(NULL, ZLOG_DEST_STDOUT, MIN(gs.loglevel,LOG_DEBUG)); - /* Make sure we're not already running. */ - pid_output (pidfile); + zlog_default = openzlog(progname, ZLOG_WATCHFRR, 0, + LOG_CONS | LOG_NDELAY | LOG_PID, LOG_DAEMON); + zlog_set_level(NULL, ZLOG_DEST_MONITOR, ZLOG_DISABLED); + if (daemon_mode) { + zlog_set_level(NULL, ZLOG_DEST_SYSLOG, + MIN(gs.loglevel, LOG_DEBUG)); + if (daemon(0, 0) < 0) { + fprintf(stderr, "Watchfrr daemon failed: %s", + strerror(errno)); + exit(1); + } + } else + zlog_set_level(NULL, ZLOG_DEST_STDOUT, + MIN(gs.loglevel, LOG_DEBUG)); - /* Announce which daemons are being monitored. */ - { - struct daemon *dmn; - size_t len = 0; + /* Make sure we're not already running. */ + pid_output(pidfile); - for (dmn = gs.daemons; dmn; dmn = dmn->next) - len += strlen(dmn->name)+1; - - { - char buf[len+1]; - char *p = buf; - - for (dmn = gs.daemons; dmn; dmn = dmn->next) + /* Announce which daemons are being monitored. */ { - if (p != buf) - *p++ = ' '; - strcpy(p,dmn->name); - p += strlen(p); + struct daemon *dmn; + size_t len = 0; + + for (dmn = gs.daemons; dmn; dmn = dmn->next) + len += strlen(dmn->name) + 1; + + { + char buf[len + 1]; + char *p = buf; + + for (dmn = gs.daemons; dmn; dmn = dmn->next) { + if (p != buf) + *p++ = ' '; + strcpy(p, dmn->name); + p += strlen(p); + } + zlog_notice("%s %s watching [%s], mode [%s]", + progname, FRR_VERSION, buf, + mode_str[gs.mode]); + } } - zlog_notice("%s %s watching [%s], mode [%s]", - progname, FRR_VERSION, buf, mode_str[gs.mode]); - } - } - { - struct thread thread; + { + struct thread thread; - while (thread_fetch (master, &thread)) - thread_call (&thread); - } + while (thread_fetch(master, &thread)) + thread_call(&thread); + } - systemd_send_stopping (); - /* Not reached. */ - return 0; + systemd_send_stopping(); + /* Not reached. */ + return 0; } diff --git a/watchfrr/watchfrr.h b/watchfrr/watchfrr.h index 4a479c72e6..719ad4dfd8 100644 --- a/watchfrr/watchfrr.h +++ b/watchfrr/watchfrr.h @@ -26,4 +26,4 @@ extern void watchfrr_vty_init(void); extern pid_t integrated_write_pid; extern void integrated_write_sigchld(int status); -#endif /* FRR_WATCHFRR_H */ +#endif /* FRR_WATCHFRR_H */ diff --git a/watchfrr/watchfrr_vty.c b/watchfrr/watchfrr_vty.c index 4fffb020d7..bf3e1510a7 100644 --- a/watchfrr/watchfrr_vty.c +++ b/watchfrr/watchfrr_vty.c @@ -31,18 +31,18 @@ pid_t integrated_write_pid; static int integrated_result_fd; -DEFUN (config_write_integrated, - config_write_integrated_cmd, - "write integrated", - "Write running configuration to memory, network, or terminal\n" - "Write integrated all-daemon Frr.conf file\n") +DEFUN(config_write_integrated, + config_write_integrated_cmd, + "write integrated", + "Write running configuration to memory, network, or terminal\n" + "Write integrated all-daemon Frr.conf file\n") { pid_t child; sigset_t oldmask, sigmask; if (integrated_write_pid != -1) { vty_out(vty, "%% configuration write already in progress.%s", - VTY_NEWLINE); + VTY_NEWLINE); return CMD_WARNING; } @@ -61,20 +61,20 @@ DEFUN (config_write_integrated, child = fork(); if (child == -1) { vty_out(vty, "%% configuration write fork() failed: %s.%s", - safe_strerror(errno), VTY_NEWLINE); + safe_strerror(errno), VTY_NEWLINE); sigprocmask(SIG_SETMASK, &oldmask, NULL); return CMD_WARNING; } if (child != 0) { - /* note: the VTY won't write a command return value to vtysh; the - * session temporarily enters an intentional "hang" state. This is - * to make sure latency in vtysh doing the config write (several - * seconds is not rare to see) does not interfere with watchfrr's - * supervisor job. - * - * The fd is duplicated here so we don't need to hold a vty pointer - * (which could become invalid in the meantime). - */ + /* note: the VTY won't write a command return value to vtysh; the + * session temporarily enters an intentional "hang" state. This is + * to make sure latency in vtysh doing the config write (several + * seconds is not rare to see) does not interfere with watchfrr's + * supervisor job. + * + * The fd is duplicated here so we don't need to hold a vty pointer + * (which could become invalid in the meantime). + */ integrated_write_pid = child; integrated_result_fd = dup(vty->wfd); sigprocmask(SIG_SETMASK, &oldmask, NULL); @@ -93,7 +93,7 @@ DEFUN (config_write_integrated, /* unbuffered write; we just messed with stdout... */ char msg[512]; snprintf(msg, sizeof(msg), "error executing %s: %s\n", - VTYSH_BIN_PATH, safe_strerror(errno)); + VTYSH_BIN_PATH, safe_strerror(errno)); write(1, msg, strlen(msg)); exit(1); } @@ -104,11 +104,11 @@ void integrated_write_sigchld(int status) if (WIFEXITED(status)) { zlog_info("configuration write completed with exit code %d", - WEXITSTATUS(status)); + WEXITSTATUS(status)); reply[3] = WEXITSTATUS(status); } else if (WIFSIGNALED(status)) { zlog_warn("configuration write terminated by signal %d", - WTERMSIG(status)); + WTERMSIG(status)); } else { zlog_warn("configuration write terminated"); } From c286be9683dde27557c4cb8af40a78de1869e198 Mon Sep 17 00:00:00 2001 From: Liu Xiaofeng Date: Mon, 19 Dec 2016 10:53:38 +0100 Subject: [PATCH 094/107] bgpd: add network command for vpnv6 address family Add the next commands: network X:X::X:X/M rd ASN:nn_or_IP-address:nn tag WORD [route-map WORD] no network X:X::X:X/M rd ASN:nn_or_IP-address:nn tag WORD Also, fix show running-config for vpnv6 network, as well as modiying bgp_static_set_safi, and take into account matching afi table. Signed-off-by: Liu Xiaofeng Signed-off-by: Philippe Guibert --- bgpd/bgp_mplsvpn.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++ bgpd/bgp_route.c | 23 ++++++++++++------ 2 files changed, 74 insertions(+), 7 deletions(-) diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c index 49fb3e3949..7747f15797 100644 --- a/bgpd/bgp_mplsvpn.c +++ b/bgpd/bgp_mplsvpn.c @@ -494,6 +494,59 @@ DEFUN (no_vpnv4_network, return bgp_static_unset_safi (SAFI_MPLS_VPN, vty, argv[idx_ipv4_prefixlen]->arg, argv[idx_ext_community]->arg, argv[idx_word]->arg); } +DEFUN (vpnv6_network, + vpnv6_network_cmd, + "network X:X::X:X/M rd ASN:nn_or_IP-address:nn tag WORD", + "Specify a network to announce via BGP\n" + "IPv6 prefix /, e.g., 3ffe::/16\n" + "Specify Route Distinguisher\n" + "VPN Route Distinguisher\n" + "BGP tag\n" + "tag value\n") +{ + int idx_ipv6_prefix = 1; + int idx_ext_community = 3; + int idx_word = 5; + return bgp_static_set_safi (SAFI_MPLS_VPN, vty, argv[idx_ipv6_prefix]->arg, argv[idx_ext_community]->arg, argv[idx_word]->arg, NULL); +} + +DEFUN (vpnv6_network_route_map, + vpnv6_network_route_map_cmd, + "network X:X::X:X/M rd ASN:nn_or_IP-address:nn tag WORD route-map WORD", + "Specify a network to announce via BGP\n" + "IPv6 prefix /, e.g., 3ffe::/16\n" + "Specify Route Distinguisher\n" + "VPN Route Distinguisher\n" + "BGP tag\n" + "tag value\n" + "route map\n" + "route map name\n") +{ + int idx_ipv6_prefix = 1; + int idx_ext_community = 3; + int idx_word = 5; + int idx_word_2 = 7; + return bgp_static_set_safi (SAFI_MPLS_VPN, vty, argv[idx_ipv6_prefix]->arg, argv[idx_ext_community]->arg, argv[idx_word]->arg, argv[idx_word_2]->arg); +} + +/* For testing purpose, static route of MPLS-VPN. */ +DEFUN (no_vpnv6_network, + no_vpnv6_network_cmd, + "no network X:X::X:X/M rd ASN:nn_or_IP-address:nn tag WORD", + NO_STR + "Specify a network to announce via BGP\n" + "IPv6 prefix /, e.g., 3ffe::/16\n" + "Specify Route Distinguisher\n" + "VPN Route Distinguisher\n" + "BGP tag\n" + "tag value\n") +{ + int idx_ipv6_prefix = 2; + int idx_ext_community = 4; + int idx_word = 6; + return bgp_static_unset_safi (SAFI_MPLS_VPN, vty, argv[idx_ipv6_prefix]->arg, argv[idx_ext_community]->arg, argv[idx_word]->arg); +} + static int show_adj_route_vpn (struct vty *vty, struct peer *peer, struct prefix_rd *prd, u_char use_json) { @@ -1305,6 +1358,11 @@ bgp_mplsvpn_init (void) install_element (VIEW_NODE, &show_bgp_ipv4_vpn_cmd); install_element (VIEW_NODE, &show_bgp_ipv4_vpn_rd_cmd); + + install_element (BGP_VPNV6_NODE, &vpnv6_network_cmd); + install_element (BGP_VPNV6_NODE, &vpnv6_network_route_map_cmd); + install_element (BGP_VPNV6_NODE, &no_vpnv6_network_cmd); + install_element (VIEW_NODE, &show_bgp_ipv6_vpn_cmd); install_element (VIEW_NODE, &show_bgp_ipv6_vpn_rd_cmd); install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_cmd); diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 0040c7a144..0d4b1ae3ff 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -4313,6 +4313,7 @@ bgp_static_set_safi (safi_t safi, struct vty *vty, const char *ip_str, struct bgp_table *table; struct bgp_static *bgp_static; u_char tag[3]; + afi_t afi; ret = str2prefix (ip_str, &p); if (! ret) @@ -4335,11 +4336,19 @@ bgp_static_set_safi (safi_t safi, struct vty *vty, const char *ip_str, vty_out (vty, "%% Malformed tag%s", VTY_NEWLINE); return CMD_WARNING; } - - prn = bgp_node_get (bgp->route[AFI_IP][safi], + if (p.family == AF_INET) + afi = AFI_IP; + else if (p.family == AF_INET6) + afi = AFI_IP6; + else + { + vty_out (vty, "%% Non Supported prefix%s", VTY_NEWLINE); + return CMD_WARNING; + } + prn = bgp_node_get (bgp->route[afi][safi], (struct prefix *)&prd); if (prn->info == NULL) - prn->info = bgp_table_init (AFI_IP, safi); + prn->info = bgp_table_init (afi, safi); else bgp_unlock_node (prn); table = prn->info; @@ -4372,7 +4381,7 @@ bgp_static_set_safi (safi_t safi, struct vty *vty, const char *ip_str, rn->info = bgp_static; bgp_static->valid = 1; - bgp_static_update_safi (bgp, &p, bgp_static, AFI_IP, safi); + bgp_static_update_safi (bgp, &p, bgp_static, afi, safi); } return CMD_SUCCESS; @@ -10303,7 +10312,7 @@ DEFUN (clear_ip_bgp_dampening_address_mask, /* also used for encap safi */ static int -bgp_config_write_network_vpnv4 (struct vty *vty, struct bgp *bgp, +bgp_config_write_network_vpn (struct vty *vty, struct bgp *bgp, afi_t afi, safi_t safi, int *write) { struct bgp_node *prn; @@ -10353,8 +10362,8 @@ bgp_config_write_network (struct vty *vty, struct bgp *bgp, struct bgp_aggregate *bgp_aggregate; char buf[SU_ADDRSTRLEN]; - if (afi == AFI_IP && ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP))) - return bgp_config_write_network_vpnv4 (vty, bgp, afi, safi, write); + if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP)) + return bgp_config_write_network_vpn (vty, bgp, afi, safi, write); /* Network configuration. */ for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) From af37568a48e0bd396db634a63999b9624a1b793c Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Fri, 6 Jan 2017 13:35:40 +0100 Subject: [PATCH 095/107] bgpd: fix nexthop comparison for nexthop vpnv6 attribute As nexthop attribute for vpnv6 also contains a blank RD and a blank tag, the IPv6 address length increases from 16 to 24 bytes. The same was observed for vpnv4 nexthop, but was missing for VPNv6. The same is done for martian nexthop debugging. Signed-off-by: Philippe Guibert --- bgpd/bgp_mpath.c | 2 +- bgpd/bgp_route.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/bgpd/bgp_mpath.c b/bgpd/bgp_mpath.c index c9af8419f2..dc8904ced2 100644 --- a/bgpd/bgp_mpath.c +++ b/bgpd/bgp_mpath.c @@ -113,7 +113,6 @@ bgp_info_nexthop_cmp (struct bgp_info *bi1, struct bgp_info *bi2) ae2 = bi2->attr->extra; compare = IPV4_ADDR_CMP (&bi1->attr->nexthop, &bi2->attr->nexthop); - if (!compare && ae1 && ae2) { if (ae1->mp_nexthop_len == ae2->mp_nexthop_len) @@ -127,6 +126,7 @@ bgp_info_nexthop_cmp (struct bgp_info *bi1, struct bgp_info *bi2) break; #ifdef HAVE_IPV6 case BGP_ATTR_NHLEN_IPV6_GLOBAL: + case BGP_ATTR_NHLEN_VPNV6_GLOBAL: compare = IPV6_ADDR_CMP (&ae1->mp_nexthop_global, &ae2->mp_nexthop_global); break; diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 0d4b1ae3ff..ae448d6ec5 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -2323,6 +2323,7 @@ bgp_update_martian_nexthop (struct bgp *bgp, afi_t afi, safi_t safi, struct attr #ifdef HAVE_IPV6 case BGP_ATTR_NHLEN_IPV6_GLOBAL: case BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL: + case BGP_ATTR_NHLEN_VPNV6_GLOBAL: ret = (IN6_IS_ADDR_UNSPECIFIED(&attre->mp_nexthop_global) || IN6_IS_ADDR_LOOPBACK(&attre->mp_nexthop_global) || IN6_IS_ADDR_MULTICAST(&attre->mp_nexthop_global)); From 3f22717225b6f904f860d86ccafcec02422236bd Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Sun, 8 Jan 2017 18:09:04 +0100 Subject: [PATCH 096/107] bgpd: add some show commands for vpnv6 Some show commands are added for handling vpnv6. As the commands was present for vpnv4, but not vpnv6, the handler routine for vty vpnv4 have been extended for vpnv6. Signed-off-by: Philippe Guibert --- bgpd/bgp_mplsvpn.c | 524 ++++++++++++++++++++++++--------------------- 1 file changed, 279 insertions(+), 245 deletions(-) diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c index 7747f15797..a36409c2d1 100644 --- a/bgpd/bgp_mplsvpn.c +++ b/bgpd/bgp_mplsvpn.c @@ -35,11 +35,35 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #include "bgpd/bgp_attr.h" #include "bgpd/bgp_mplsvpn.h" #include "bgpd/bgp_packet.h" +#include "bgpd/bgp_vty.h" #if ENABLE_BGP_VNC #include "bgpd/rfapi/rfapi_backend.h" #endif +#define BGP_VPNVX_HELP_STR \ + "Address Family \n" \ + "Address Family \n" + +static int +argv_find_and_parse_vpnvx(struct cmd_token **argv, int argc, int *index, afi_t *afi) +{ + int ret = 0; + if (argv_find (argv, argc, "vpnv4", index)) + { + ret = 1; + if (afi) + *afi = AFI_IP; + } + else if (argv_find (argv, argc, "vpnv6", index)) + { + ret = 1; + if (afi) + *afi = AFI_IP6; + } + return ret; +} + u_int16_t decode_rd_type (u_char *pnt) { @@ -548,7 +572,7 @@ DEFUN (no_vpnv6_network, } static int -show_adj_route_vpn (struct vty *vty, struct peer *peer, struct prefix_rd *prd, u_char use_json) +show_adj_route_vpn (struct vty *vty, struct peer *peer, struct prefix_rd *prd, u_char use_json, afi_t afi) { struct bgp *bgp; struct bgp_table *table; @@ -591,7 +615,7 @@ show_adj_route_vpn (struct vty *vty, struct peer *peer, struct prefix_rd *prd, u json_object_string_add(json_ocode, "incomplete", "?"); } - for (rn = bgp_table_top (bgp->rib[AFI_IP][SAFI_MPLS_VPN]); rn; + for (rn = bgp_table_top (bgp->rib[afi][SAFI_MPLS_VPN]); rn; rn = bgp_route_next (rn)) { if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) @@ -948,35 +972,9 @@ bgp_show_mpls_vpn (struct vty *vty, afi_t afi, struct prefix_rd *prd, return CMD_SUCCESS; } -DEFUN (show_bgp_ivp4_vpn, - show_bgp_ipv4_vpn_cmd, - "show [ip] bgp ipv4 vpn [json]", - SHOW_STR - IP_STR - BGP_STR - "Address Family\n" - "Display VPN NLRI specific information\n" - JSON_STR) -{ - return bgp_show_mpls_vpn (vty, AFI_IP, NULL, bgp_show_type_normal, NULL, 0, use_json (argc, argv)); -} - -DEFUN (show_bgp_ipv6_vpn, - show_bgp_ipv6_vpn_cmd, - "show [ip] bgp ipv6 vpn [json]", - SHOW_STR - IP_STR - BGP_STR - "Address Family\n" - "Display VPN NLRI specific information\n" - JSON_STR) -{ - return bgp_show_mpls_vpn (vty, AFI_IP6, NULL, bgp_show_type_normal, NULL, 0, use_json (argc, argv)); -} - -DEFUN (show_bgp_ipv4_vpn_rd, - show_bgp_ipv4_vpn_rd_cmd, - "show [ip] bgp ipv4 vpn rd ASN:nn_or_IP-address:nn [json]", +DEFUN (show_bgp_ip_vpn_rd, + show_bgp_ip_vpn_rd_cmd, + "show [ip] bgp "BGP_AFI_CMD_STR" vpn [rd ASN:nn_or_IP-address:nn] [json]", SHOW_STR IP_STR BGP_STR @@ -989,97 +987,103 @@ DEFUN (show_bgp_ipv4_vpn_rd, int idx_ext_community = 5; int ret; struct prefix_rd prd; + afi_t afi; + int idx = 0; - ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd); - if (! ret) + if (argv_find_and_parse_afi (argv, argc, &idx, &afi)) { - vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); - return CMD_WARNING; + if (argv[idx_ext_community]->arg) + { + ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd); + if (! ret) + { + vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); + return CMD_WARNING; + } + return bgp_show_mpls_vpn (vty, afi, &prd, bgp_show_type_normal, NULL, 0, use_json (argc, argv)); + } + else + { + return bgp_show_mpls_vpn (vty, afi, NULL, bgp_show_type_normal, NULL, 0, use_json (argc, argv)); + } } - return bgp_show_mpls_vpn (vty, AFI_IP, &prd, bgp_show_type_normal, NULL, 0, use_json (argc, argv)); + return CMD_SUCCESS; } -DEFUN (show_bgp_ipv6_vpn_rd, - show_bgp_ipv6_vpn_rd_cmd, - "show [ip] bgp ipv6 vpn rd ASN:nn_or_IP-address:nn [json]", +DEFUN (show_ip_bgp_vpn_all, + show_ip_bgp_vpn_all_cmd, + "show [ip] bgp ", SHOW_STR IP_STR BGP_STR "Address Family\n" - "Display VPN NLRI specific information\n" - "Display information for a route distinguisher\n" - "VPN Route Distinguisher\n" - JSON_STR) + BGP_VPNVX_HELP_STR) { - int idx_ext_community = 5; - int ret; - struct prefix_rd prd; + afi_t afi; + int idx = 0; - ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd); - if (!ret) - { - vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); - return CMD_WARNING; - } - - return bgp_show_mpls_vpn (vty, AFI_IP6, &prd, bgp_show_type_normal, NULL, 0, use_json (argc, argv)); + if (argv_find_and_parse_vpnvx (argv, argc, &idx, &afi)) + return bgp_show_mpls_vpn (vty, afi, NULL, bgp_show_type_normal, NULL, 0, 0); + return CMD_SUCCESS; } -DEFUN (show_ip_bgp_vpnv4_all, - show_ip_bgp_vpnv4_all_cmd, - "show [ip] bgp vpnv4 all", - SHOW_STR - IP_STR - BGP_STR - "Address Family\n" - "Display information about all VPNv4 NLRIs\n") -{ - return bgp_show_mpls_vpn (vty, AFI_IP, NULL, bgp_show_type_normal, NULL, 0, 0); -} - -DEFUN (show_ip_bgp_vpnv4_rd, - show_ip_bgp_vpnv4_rd_cmd, - "show [ip] bgp vpnv4 rd ASN:nn_or_IP-address:nn", +DEFUN (show_ip_bgp_vpn_rd, + show_ip_bgp_vpn_rd_cmd, + "show [ip] bgp rd ASN:nn_or_IP-address:nn", SHOW_STR IP_STR BGP_STR "Address Family\n" + BGP_VPNVX_HELP_STR "Display information for a route distinguisher\n" "VPN Route Distinguisher\n") { int idx_ext_community = 5; int ret; struct prefix_rd prd; + afi_t afi; + int idx = 0; - ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd); - if (! ret) + if (argv_find_and_parse_vpnvx (argv, argc, &idx, &afi)) { - vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); - return CMD_WARNING; + ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd); + if (! ret) + { + vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); + return CMD_WARNING; + } + return bgp_show_mpls_vpn (vty, afi, &prd, bgp_show_type_normal, NULL, 0, 0); } - return bgp_show_mpls_vpn (vty, AFI_IP, &prd, bgp_show_type_normal, NULL, 0, 0); -} + return CMD_SUCCESS; + } -DEFUN (show_ip_bgp_vpnv4_all_tags, - show_ip_bgp_vpnv4_all_tags_cmd, - "show [ip] bgp vpnv4 all tags", +DEFUN (show_ip_bgp_vpn_all_tags, + show_ip_bgp_vpn_all_tags_cmd, + "show [ip] bgp all tags", SHOW_STR IP_STR BGP_STR "Address Family\n" - "Display information about all VPNv4 NLRIs\n" + BGP_VPNVX_HELP_STR + "Display information about all VPNv4/VPNV6 NLRIs\n" "Display BGP tags for prefixes\n") { - return bgp_show_mpls_vpn (vty, AFI_IP, NULL, bgp_show_type_normal, NULL, 1, 0); + afi_t afi; + int idx = 0; + + if (argv_find_and_parse_vpnvx (argv, argc, &idx, &afi)) + return bgp_show_mpls_vpn (vty, afi, NULL, bgp_show_type_normal, NULL, 1, 0); + return CMD_SUCCESS; } -DEFUN (show_ip_bgp_vpnv4_rd_tags, - show_ip_bgp_vpnv4_rd_tags_cmd, - "show [ip] bgp vpnv4 rd ASN:nn_or_IP-address:nn tags", +DEFUN (show_ip_bgp_vpn_rd_tags, + show_ip_bgp_vpn_rd_tags_cmd, + "show [ip] bgp rd ASN:nn_or_IP-address:nn tags", SHOW_STR IP_STR BGP_STR "Address Family\n" + BGP_VPNVX_HELP_STR "Display information for a route distinguisher\n" "VPN Route Distinguisher\n" "Display BGP tags for prefixes\n") @@ -1087,24 +1091,31 @@ DEFUN (show_ip_bgp_vpnv4_rd_tags, int idx_ext_community = 5; int ret; struct prefix_rd prd; + afi_t afi; + int idx = 0; - ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd); - if (! ret) + if (argv_find_and_parse_vpnvx (argv, argc, &idx, &afi)) { - vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); - return CMD_WARNING; + ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd); + if (! ret) + { + vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); + return CMD_WARNING; + } + return bgp_show_mpls_vpn (vty, afi, &prd, bgp_show_type_normal, NULL, 1, 0); } - return bgp_show_mpls_vpn (vty, AFI_IP, &prd, bgp_show_type_normal, NULL, 1, 0); + return CMD_SUCCESS; } -DEFUN (show_ip_bgp_vpnv4_all_neighbor_routes, - show_ip_bgp_vpnv4_all_neighbor_routes_cmd, - "show [ip] bgp vpnv4 all neighbors A.B.C.D routes [json]", +DEFUN (show_ip_bgp_vpn_all_neighbor_routes, + show_ip_bgp_vpn_all_neighbor_routes_cmd, + "show [ip] bgp all neighbors A.B.C.D routes [json]", SHOW_STR IP_STR BGP_STR "Address Family\n" - "Display information about all VPNv4 NLRIs\n" + BGP_VPNVX_HELP_STR + "Display information about all VPNv4/VPNv6 NLRIs\n" "Detailed information on TCP and BGP neighbor connections\n" "Neighbor to display information about\n" "Display routes learned from neighbor\n" @@ -1115,49 +1126,56 @@ DEFUN (show_ip_bgp_vpnv4_all_neighbor_routes, struct peer *peer; int ret; u_char uj = use_json(argc, argv); + afi_t afi; + int idx = 0; - ret = str2sockunion (argv[idx_ipv4]->arg, &su); - if (ret < 0) + if (argv_find_and_parse_vpnvx (argv, argc, &idx, &afi)) { - if (uj) + ret = str2sockunion (argv[idx_ipv4]->arg, &su); + if (ret < 0) { - json_object *json_no = NULL; - json_no = json_object_new_object(); - json_object_string_add(json_no, "warning", "Malformed address"); - vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); - json_object_free(json_no); + if (uj) + { + json_object *json_no = NULL; + json_no = json_object_new_object(); + json_object_string_add(json_no, "warning", "Malformed address"); + vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); + json_object_free(json_no); + } + else + vty_out (vty, "Malformed address: %s%s", argv[idx_ipv4]->arg, VTY_NEWLINE); + return CMD_WARNING; } - else - vty_out (vty, "Malformed address: %s%s", argv[idx_ipv4]->arg, VTY_NEWLINE); - return CMD_WARNING; - } - peer = peer_lookup (NULL, &su); - if (! peer || ! peer->afc[AFI_IP][SAFI_MPLS_VPN]) - { - if (uj) + peer = peer_lookup (NULL, &su); + if (! peer || ! peer->afc[afi][SAFI_MPLS_VPN]) { - json_object *json_no = NULL; - json_no = json_object_new_object(); - json_object_string_add(json_no, "warning", "No such neighbor or address family"); - vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); - json_object_free(json_no); + if (uj) + { + json_object *json_no = NULL; + json_no = json_object_new_object(); + json_object_string_add(json_no, "warning", "No such neighbor or address family"); + vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); + json_object_free(json_no); + } + else + vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); + return CMD_WARNING; } - else - vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); - return CMD_WARNING; - } - return bgp_show_mpls_vpn (vty, AFI_IP, NULL, bgp_show_type_neighbor, &su, 0, uj); + return bgp_show_mpls_vpn (vty, afi, NULL, bgp_show_type_neighbor, &su, 0, uj); + } + return CMD_SUCCESS; } -DEFUN (show_ip_bgp_vpnv4_rd_neighbor_routes, - show_ip_bgp_vpnv4_rd_neighbor_routes_cmd, - "show [ip] bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors A.B.C.D routes [json]", +DEFUN (show_ip_bgp_vpn_rd_neighbor_routes, + show_ip_bgp_vpn_rd_neighbor_routes_cmd, + "show [ip] bgp rd ASN:nn_or_IP-address:nn neighbors A.B.C.D routes [json]", SHOW_STR IP_STR BGP_STR "Address Family\n" + BGP_VPNVX_HELP_STR "Display information for a route distinguisher\n" "VPN Route Distinguisher\n" "Detailed information on TCP and BGP neighbor connections\n" @@ -1172,66 +1190,73 @@ DEFUN (show_ip_bgp_vpnv4_rd_neighbor_routes, struct peer *peer; struct prefix_rd prd; u_char uj = use_json(argc, argv); + afi_t afi; + int idx = 0; - ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd); - if (! ret) + if (argv_find_and_parse_vpnvx (argv, argc, &idx, &afi)) { - if (uj) + ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd); + if (! ret) { - json_object *json_no = NULL; - json_no = json_object_new_object(); - json_object_string_add(json_no, "warning", "Malformed Route Distinguisher"); - vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); - json_object_free(json_no); + if (uj) + { + json_object *json_no = NULL; + json_no = json_object_new_object(); + json_object_string_add(json_no, "warning", "Malformed Route Distinguisher"); + vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); + json_object_free(json_no); + } + else + vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); + return CMD_WARNING; } - else - vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); - return CMD_WARNING; - } - ret = str2sockunion (argv[idx_ipv4]->arg, &su); - if (ret < 0) - { - if (uj) + ret = str2sockunion (argv[idx_ipv4]->arg, &su); + if (ret < 0) { - json_object *json_no = NULL; - json_no = json_object_new_object(); - json_object_string_add(json_no, "warning", "Malformed address"); - vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); - json_object_free(json_no); + if (uj) + { + json_object *json_no = NULL; + json_no = json_object_new_object(); + json_object_string_add(json_no, "warning", "Malformed address"); + vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); + json_object_free(json_no); + } + else + vty_out (vty, "Malformed address: %s%s", argv[idx_ext_community]->arg, VTY_NEWLINE); + return CMD_WARNING; } - else - vty_out (vty, "Malformed address: %s%s", argv[idx_ext_community]->arg, VTY_NEWLINE); - return CMD_WARNING; - } - peer = peer_lookup (NULL, &su); - if (! peer || ! peer->afc[AFI_IP][SAFI_MPLS_VPN]) - { - if (uj) + peer = peer_lookup (NULL, &su); + if (! peer || ! peer->afc[afi][SAFI_MPLS_VPN]) { - json_object *json_no = NULL; - json_no = json_object_new_object(); - json_object_string_add(json_no, "warning", "No such neighbor or address family"); - vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); - json_object_free(json_no); + if (uj) + { + json_object *json_no = NULL; + json_no = json_object_new_object(); + json_object_string_add(json_no, "warning", "No such neighbor or address family"); + vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); + json_object_free(json_no); + } + else + vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); + return CMD_WARNING; } - else - vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); - return CMD_WARNING; - } - return bgp_show_mpls_vpn (vty, AFI_IP, &prd, bgp_show_type_neighbor, &su, 0, uj); + return bgp_show_mpls_vpn (vty, afi, &prd, bgp_show_type_neighbor, &su, 0, uj); + } + return CMD_SUCCESS; } -DEFUN (show_ip_bgp_vpnv4_all_neighbor_advertised_routes, - show_ip_bgp_vpnv4_all_neighbor_advertised_routes_cmd, - "show [ip] bgp vpnv4 all neighbors A.B.C.D advertised-routes [json]", +DEFUN (show_ip_bgp_vpn_all_neighbor_advertised_routes, + show_ip_bgp_vpn_all_neighbor_advertised_routes_cmd, + "show [ip] bgp all neighbors A.B.C.D advertised-routes [json]", SHOW_STR IP_STR BGP_STR "Address Family\n" - "Display information about all VPNv4 NLRIs\n" + BGP_VPNVX_HELP_STR + "Display information about all VPNv4/VPNv6 NLRIs\n" "Detailed information on TCP and BGP neighbor connections\n" "Neighbor to display information about\n" "Display the routes advertised to a BGP neighbor\n" @@ -1242,48 +1267,55 @@ DEFUN (show_ip_bgp_vpnv4_all_neighbor_advertised_routes, struct peer *peer; union sockunion su; u_char uj = use_json(argc, argv); + afi_t afi; + int idx = 0; - ret = str2sockunion (argv[idx_ipv4]->arg, &su); - if (ret < 0) + if (argv_find_and_parse_vpnvx (argv, argc, &idx, &afi)) { - if (uj) + ret = str2sockunion (argv[idx_ipv4]->arg, &su); + if (ret < 0) { - json_object *json_no = NULL; - json_no = json_object_new_object(); - json_object_string_add(json_no, "warning", "Malformed address"); - vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); - json_object_free(json_no); + if (uj) + { + json_object *json_no = NULL; + json_no = json_object_new_object(); + json_object_string_add(json_no, "warning", "Malformed address"); + vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); + json_object_free(json_no); + } + else + vty_out (vty, "Malformed address: %s%s", argv[idx_ipv4]->arg, VTY_NEWLINE); + return CMD_WARNING; } - else - vty_out (vty, "Malformed address: %s%s", argv[idx_ipv4]->arg, VTY_NEWLINE); - return CMD_WARNING; - } - peer = peer_lookup (NULL, &su); - if (! peer || ! peer->afc[AFI_IP][SAFI_MPLS_VPN]) - { - if (uj) + peer = peer_lookup (NULL, &su); + if (! peer || ! peer->afc[afi][SAFI_MPLS_VPN]) { - json_object *json_no = NULL; - json_no = json_object_new_object(); - json_object_string_add(json_no, "warning", "No such neighbor or address family"); - vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); - json_object_free(json_no); + if (uj) + { + json_object *json_no = NULL; + json_no = json_object_new_object(); + json_object_string_add(json_no, "warning", "No such neighbor or address family"); + vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); + json_object_free(json_no); + } + else + vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); + return CMD_WARNING; } - else - vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); - return CMD_WARNING; - } - return show_adj_route_vpn (vty, peer, NULL, uj); + return show_adj_route_vpn (vty, peer, NULL, uj, afi); + } + return CMD_SUCCESS; } -DEFUN (show_ip_bgp_vpnv4_rd_neighbor_advertised_routes, - show_ip_bgp_vpnv4_rd_neighbor_advertised_routes_cmd, - "show [ip] bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors A.B.C.D advertised-routes [json]", +DEFUN (show_ip_bgp_vpn_rd_neighbor_advertised_routes, + show_ip_bgp_vpn_rd_neighbor_advertised_routes_cmd, + "show [ip] bgp rd ASN:nn_or_IP-address:nn neighbors A.B.C.D advertised-routes [json]", SHOW_STR IP_STR BGP_STR "Address Family\n" + BGP_VPNVX_HELP_STR "Display information for a route distinguisher\n" "VPN Route Distinguisher\n" "Detailed information on TCP and BGP neighbor connections\n" @@ -1298,55 +1330,61 @@ DEFUN (show_ip_bgp_vpnv4_rd_neighbor_advertised_routes, struct prefix_rd prd; union sockunion su; u_char uj = use_json(argc, argv); + afi_t afi; + int idx = 0; - ret = str2sockunion (argv[idx_ipv4]->arg, &su); - if (ret < 0) + if (argv_find_and_parse_vpnvx (argv, argc, &idx, &afi)) { - if (uj) + ret = str2sockunion (argv[idx_ipv4]->arg, &su); + if (ret < 0) { - json_object *json_no = NULL; - json_no = json_object_new_object(); - json_object_string_add(json_no, "warning", "Malformed address"); - vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); - json_object_free(json_no); + if (uj) + { + json_object *json_no = NULL; + json_no = json_object_new_object(); + json_object_string_add(json_no, "warning", "Malformed address"); + vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); + json_object_free(json_no); + } + else + vty_out (vty, "Malformed address: %s%s", argv[idx_ext_community]->arg, VTY_NEWLINE); + return CMD_WARNING; } - else - vty_out (vty, "Malformed address: %s%s", argv[idx_ext_community]->arg, VTY_NEWLINE); - return CMD_WARNING; - } - peer = peer_lookup (NULL, &su); - if (! peer || ! peer->afc[AFI_IP][SAFI_MPLS_VPN]) - { - if (uj) + peer = peer_lookup (NULL, &su); + if (! peer || ! peer->afc[afi][SAFI_MPLS_VPN]) { - json_object *json_no = NULL; - json_no = json_object_new_object(); - json_object_string_add(json_no, "warning", "No such neighbor or address family"); - vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); - json_object_free(json_no); + if (uj) + { + json_object *json_no = NULL; + json_no = json_object_new_object(); + json_object_string_add(json_no, "warning", "No such neighbor or address family"); + vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); + json_object_free(json_no); + } + else + vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); + return CMD_WARNING; } - else - vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); - return CMD_WARNING; - } - ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd); - if (! ret) - { - if (uj) + ret = str2prefix_rd (argv[idx_ext_community]->arg, &prd); + if (! ret) { - json_object *json_no = NULL; - json_no = json_object_new_object(); - json_object_string_add(json_no, "warning", "Malformed Route Distinguisher"); - vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); - json_object_free(json_no); + if (uj) + { + json_object *json_no = NULL; + json_no = json_object_new_object(); + json_object_string_add(json_no, "warning", "Malformed Route Distinguisher"); + vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); + json_object_free(json_no); + } + else + vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); + return CMD_WARNING; } - else - vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); - return CMD_WARNING; - } - return show_adj_route_vpn (vty, peer, &prd, uj); + return show_adj_route_vpn (vty, peer, &prd, uj, afi); + } + return CMD_SUCCESS; } void @@ -1356,21 +1394,17 @@ bgp_mplsvpn_init (void) install_element (BGP_VPNV4_NODE, &vpnv4_network_route_map_cmd); install_element (BGP_VPNV4_NODE, &no_vpnv4_network_cmd); - install_element (VIEW_NODE, &show_bgp_ipv4_vpn_cmd); - install_element (VIEW_NODE, &show_bgp_ipv4_vpn_rd_cmd); - install_element (BGP_VPNV6_NODE, &vpnv6_network_cmd); install_element (BGP_VPNV6_NODE, &vpnv6_network_route_map_cmd); install_element (BGP_VPNV6_NODE, &no_vpnv6_network_cmd); - install_element (VIEW_NODE, &show_bgp_ipv6_vpn_cmd); - install_element (VIEW_NODE, &show_bgp_ipv6_vpn_rd_cmd); - install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_cmd); - install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_cmd); - install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_tags_cmd); - install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_tags_cmd); - install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_neighbor_routes_cmd); - install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_neighbor_routes_cmd); - install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_neighbor_advertised_routes_cmd); - install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_neighbor_advertised_routes_cmd); + install_element (VIEW_NODE, &show_bgp_ip_vpn_rd_cmd); + install_element (VIEW_NODE, &show_ip_bgp_vpn_all_cmd); + install_element (VIEW_NODE, &show_ip_bgp_vpn_rd_cmd); + install_element (VIEW_NODE, &show_ip_bgp_vpn_all_tags_cmd); + install_element (VIEW_NODE, &show_ip_bgp_vpn_rd_tags_cmd); + install_element (VIEW_NODE, &show_ip_bgp_vpn_all_neighbor_routes_cmd); + install_element (VIEW_NODE, &show_ip_bgp_vpn_rd_neighbor_routes_cmd); + install_element (VIEW_NODE, &show_ip_bgp_vpn_all_neighbor_advertised_routes_cmd); + install_element (VIEW_NODE, &show_ip_bgp_vpn_rd_neighbor_advertised_routes_cmd); } From 52c439c1f9542a6f6b62522afaa10a62033d60cb Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Mon, 9 Jan 2017 19:29:43 +0100 Subject: [PATCH 097/107] bgpd: merge vpnvx network [route-map] command This commit merges two vty command into one single vty command Signed-off-by: Philippe Guibert --- bgpd/bgp_mplsvpn.c | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c index a36409c2d1..f6b1dc5c52 100644 --- a/bgpd/bgp_mplsvpn.c +++ b/bgpd/bgp_mplsvpn.c @@ -520,37 +520,22 @@ DEFUN (no_vpnv4_network, DEFUN (vpnv6_network, vpnv6_network_cmd, - "network X:X::X:X/M rd ASN:nn_or_IP-address:nn tag WORD", + "network X:X::X:X/M rd ASN:nn_or_IP-address:nn tag WORD [route-map WORD]", "Specify a network to announce via BGP\n" "IPv6 prefix /, e.g., 3ffe::/16\n" "Specify Route Distinguisher\n" "VPN Route Distinguisher\n" "BGP tag\n" "tag value\n") -{ - int idx_ipv6_prefix = 1; - int idx_ext_community = 3; - int idx_word = 5; - return bgp_static_set_safi (SAFI_MPLS_VPN, vty, argv[idx_ipv6_prefix]->arg, argv[idx_ext_community]->arg, argv[idx_word]->arg, NULL); -} - -DEFUN (vpnv6_network_route_map, - vpnv6_network_route_map_cmd, - "network X:X::X:X/M rd ASN:nn_or_IP-address:nn tag WORD route-map WORD", - "Specify a network to announce via BGP\n" - "IPv6 prefix /, e.g., 3ffe::/16\n" - "Specify Route Distinguisher\n" - "VPN Route Distinguisher\n" - "BGP tag\n" - "tag value\n" - "route map\n" - "route map name\n") { int idx_ipv6_prefix = 1; int idx_ext_community = 3; int idx_word = 5; int idx_word_2 = 7; - return bgp_static_set_safi (SAFI_MPLS_VPN, vty, argv[idx_ipv6_prefix]->arg, argv[idx_ext_community]->arg, argv[idx_word]->arg, argv[idx_word_2]->arg); + if (argv[idx_word_2]) + return bgp_static_set_safi (SAFI_MPLS_VPN, vty, argv[idx_ipv6_prefix]->arg, argv[idx_ext_community]->arg, argv[idx_word]->arg, argv[idx_word_2]->arg); + else + return bgp_static_set_safi (SAFI_MPLS_VPN, vty, argv[idx_ipv6_prefix]->arg, argv[idx_ext_community]->arg, argv[idx_word]->arg, NULL); } /* For testing purpose, static route of MPLS-VPN. */ @@ -1395,7 +1380,6 @@ bgp_mplsvpn_init (void) install_element (BGP_VPNV4_NODE, &no_vpnv4_network_cmd); install_element (BGP_VPNV6_NODE, &vpnv6_network_cmd); - install_element (BGP_VPNV6_NODE, &vpnv6_network_route_map_cmd); install_element (BGP_VPNV6_NODE, &no_vpnv6_network_cmd); install_element (VIEW_NODE, &show_bgp_ip_vpn_rd_cmd); From 78af6edc6cd7d17fa11d11fbb9f54efd459230e2 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Tue, 10 Jan 2017 23:33:50 +0000 Subject: [PATCH 098/107] lib: limit size of vty buffer to 4096 bytes This removes the automatic resizing of the vty input buffer and places a hard size cap of 4096 bytes. It also fixes a potentially unsafe strcpy. Signed-off-by: Quentin Young [cherry-picked from master 2af38873d89e20bd039255418366c1601aa99e64] --- lib/vty.c | 102 ++++++++++++++++++++++++++++-------------------------- lib/vty.h | 2 +- 2 files changed, 53 insertions(+), 51 deletions(-) diff --git a/lib/vty.c b/lib/vty.c index 5919e5220a..23d7153417 100644 --- a/lib/vty.c +++ b/lib/vty.c @@ -508,18 +508,6 @@ vty_write (struct vty *vty, const char *buf, size_t nbytes) buffer_put (vty->obuf, buf, nbytes); } -/* Ensure length of input buffer. Is buffer is short, double it. */ -static void -vty_ensure (struct vty *vty, int length) -{ - if (vty->max <= length) - { - vty->max *= 2; - vty->buf = XREALLOC (MTYPE_VTY, vty->buf, vty->max); - vty->error_buf = XREALLOC (MTYPE_VTY, vty->error_buf, vty->max); - } -} - /* Basic function to insert character into vty. */ static void vty_self_insert (struct vty *vty, char c) @@ -527,7 +515,9 @@ vty_self_insert (struct vty *vty, char c) int i; int length; - vty_ensure (vty, vty->length + 1); + if (vty->length + 1 > VTY_BUFSIZ) + return; + length = vty->length - vty->cp; memmove (&vty->buf[vty->cp + 1], &vty->buf[vty->cp], length); vty->buf[vty->cp] = c; @@ -544,26 +534,29 @@ vty_self_insert (struct vty *vty, char c) static void vty_self_insert_overwrite (struct vty *vty, char c) { - vty_ensure (vty, vty->length + 1); + if (vty->cp == vty->length) + { + vty_self_insert (vty, c); + return; + } + vty->buf[vty->cp++] = c; - - if (vty->cp > vty->length) - vty->length++; - - if ((vty->node == AUTH_NODE) || (vty->node == AUTH_ENABLE_NODE)) - return; - vty_write (vty, &c, 1); } -/* Insert a word into vty interface with overwrite mode. */ +/** + * Insert a string into vty->buf at the current cursor position. + * + * If the resultant string would be larger than VTY_BUFSIZ it is + * truncated to fit. + */ static void vty_insert_word_overwrite (struct vty *vty, char *str) { - int len = strlen (str); - vty_write (vty, str, len); - strcpy (&vty->buf[vty->cp], str); - vty->cp += len; + size_t nwrite = MIN ((int) strlen (str), VTY_BUFSIZ - vty->cp); + vty_write (vty, str, nwrite); + strncpy (&vty->buf[vty->cp], str, nwrite); + vty->cp += nwrite; vty->length = vty->cp; } @@ -2217,37 +2210,46 @@ vtysh_read (struct thread *thread) printf ("line: %.*s\n", nbytes, buf); #endif /* VTYSH_DEBUG */ - for (p = buf; p < buf+nbytes; p++) + if (vty->length + nbytes > VTY_BUFSIZ) { - vty_ensure(vty, vty->length+1); - vty->buf[vty->length++] = *p; - if (*p == '\0') - { - /* Pass this line to parser. */ - ret = vty_execute (vty); - /* Note that vty_execute clears the command buffer and resets - vty->length to 0. */ + /* Clear command line buffer. */ + vty->cp = vty->length = 0; + vty_clear_buf (vty); + vty_out (vty, "%% Command is too long.%s", VTY_NEWLINE); + } + else + { + for (p = buf; p < buf+nbytes; p++) + { + vty->buf[vty->length++] = *p; + if (*p == '\0') + { + /* Pass this line to parser. */ + ret = vty_execute (vty); + /* Note that vty_execute clears the command buffer and resets + vty->length to 0. */ - /* Return result. */ + /* Return result. */ #ifdef VTYSH_DEBUG - printf ("result: %d\n", ret); - printf ("vtysh node: %d\n", vty->node); + printf ("result: %d\n", ret); + printf ("vtysh node: %d\n", vty->node); #endif /* VTYSH_DEBUG */ - /* hack for asynchronous "write integrated" - * - other commands in "buf" will be ditched - * - input during pending config-write is "unsupported" */ - if (ret == CMD_SUSPEND) - break; + /* hack for asynchronous "write integrated" + * - other commands in "buf" will be ditched + * - input during pending config-write is "unsupported" */ + if (ret == CMD_SUSPEND) + break; - /* warning: watchfrr hardcodes this result write */ - header[3] = ret; - buffer_put(vty->obuf, header, 4); + /* warning: watchquagga hardcodes this result write */ + header[3] = ret; + buffer_put(vty->obuf, header, 4); - if (!vty->t_write && (vtysh_flush(vty) < 0)) - /* Try to flush results; exit if a write error occurs. */ - return 0; - } + if (!vty->t_write && (vtysh_flush(vty) < 0)) + /* Try to flush results; exit if a write error occurs. */ + return 0; + } + } } vty_event (VTYSH_READ, sock, vty); diff --git a/lib/vty.h b/lib/vty.h index 51d61b4a8c..f5c019dd61 100644 --- a/lib/vty.h +++ b/lib/vty.h @@ -26,7 +26,7 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #include "sockunion.h" #include "qobj.h" -#define VTY_BUFSIZ 512 +#define VTY_BUFSIZ 4096 #define VTY_MAXHIST 20 #if defined(VTY_DEPRECATE_INDEX) && defined(__GNUC__) && \ From 05e588f45dc2599306d8da98de1d6f53b557477a Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Fri, 13 Jan 2017 14:29:20 +0100 Subject: [PATCH 099/107] bgpd: remove one extra help handler from show bgp mpls commands This commit fixes the help display of show bgp mpls commands, since the last change introduced a problem in relation with help handlers. Signed-off-by: Philippe Guibert --- bgpd/bgp_mplsvpn.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c index f6b1dc5c52..f5ec33d0de 100644 --- a/bgpd/bgp_mplsvpn.c +++ b/bgpd/bgp_mplsvpn.c @@ -963,7 +963,7 @@ DEFUN (show_bgp_ip_vpn_rd, SHOW_STR IP_STR BGP_STR - "Address Family\n" + BGP_VPNVX_HELP_STR "Display VPN NLRI specific information\n" "Display information for a route distinguisher\n" "VPN Route Distinguisher\n" @@ -1001,7 +1001,6 @@ DEFUN (show_ip_bgp_vpn_all, SHOW_STR IP_STR BGP_STR - "Address Family\n" BGP_VPNVX_HELP_STR) { afi_t afi; @@ -1018,7 +1017,6 @@ DEFUN (show_ip_bgp_vpn_rd, SHOW_STR IP_STR BGP_STR - "Address Family\n" BGP_VPNVX_HELP_STR "Display information for a route distinguisher\n" "VPN Route Distinguisher\n") @@ -1048,7 +1046,6 @@ DEFUN (show_ip_bgp_vpn_all_tags, SHOW_STR IP_STR BGP_STR - "Address Family\n" BGP_VPNVX_HELP_STR "Display information about all VPNv4/VPNV6 NLRIs\n" "Display BGP tags for prefixes\n") @@ -1067,7 +1064,6 @@ DEFUN (show_ip_bgp_vpn_rd_tags, SHOW_STR IP_STR BGP_STR - "Address Family\n" BGP_VPNVX_HELP_STR "Display information for a route distinguisher\n" "VPN Route Distinguisher\n" @@ -1098,7 +1094,6 @@ DEFUN (show_ip_bgp_vpn_all_neighbor_routes, SHOW_STR IP_STR BGP_STR - "Address Family\n" BGP_VPNVX_HELP_STR "Display information about all VPNv4/VPNv6 NLRIs\n" "Detailed information on TCP and BGP neighbor connections\n" @@ -1159,7 +1154,6 @@ DEFUN (show_ip_bgp_vpn_rd_neighbor_routes, SHOW_STR IP_STR BGP_STR - "Address Family\n" BGP_VPNVX_HELP_STR "Display information for a route distinguisher\n" "VPN Route Distinguisher\n" @@ -1239,7 +1233,6 @@ DEFUN (show_ip_bgp_vpn_all_neighbor_advertised_routes, SHOW_STR IP_STR BGP_STR - "Address Family\n" BGP_VPNVX_HELP_STR "Display information about all VPNv4/VPNv6 NLRIs\n" "Detailed information on TCP and BGP neighbor connections\n" @@ -1299,7 +1292,6 @@ DEFUN (show_ip_bgp_vpn_rd_neighbor_advertised_routes, SHOW_STR IP_STR BGP_STR - "Address Family\n" BGP_VPNVX_HELP_STR "Display information for a route distinguisher\n" "VPN Route Distinguisher\n" From 6f3b38578810977af89bdd7903b4c5e6146f9cbe Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Fri, 13 Jan 2017 15:10:05 +0100 Subject: [PATCH 100/107] partial merge: revert "LabNConsulting/working/2.0/afi-safi-vty/c" Unfortunately, the CLI changes need to be redone on master since the CLI has massively changed there. Signed-off-by: David Lamparter --- bgpd/bgp_mplsvpn.c | 277 ++++---- bgpd/bgp_route.c | 595 ++++++++++++------ bgpd/bgp_routemap.c | 95 +++ bgpd/bgp_vty.c | 1455 ++++++++++++++++++++++++++++++------------- bgpd/bgp_vty.h | 18 +- 5 files changed, 1659 insertions(+), 781 deletions(-) diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c index b710e0b03b..d55acdd512 100644 --- a/bgpd/bgp_mplsvpn.c +++ b/bgpd/bgp_mplsvpn.c @@ -35,7 +35,6 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA #include "bgpd/bgp_attr.h" #include "bgpd/bgp_mplsvpn.h" #include "bgpd/bgp_packet.h" -#include "bgpd/bgp_vty.h" #if ENABLE_BGP_VNC #include "bgpd/rfapi/rfapi_backend.h" @@ -199,7 +198,7 @@ bgp_nlri_parse_vpn (struct peer *peer, struct attr *attr, if (prefixlen < VPN_PREFIXLEN_MIN_BYTES*8) { - zlog_err ("%s [Error] Update packet error / VPN (prefix length %d less than VPN min length)", + zlog_err ("%s [Error] Update packet error / VPNv4 (prefix length %d less than VPNv4 min length)", peer->host, prefixlen); return -1; } @@ -207,7 +206,7 @@ bgp_nlri_parse_vpn (struct peer *peer, struct attr *attr, /* sanity check against packet data */ if ((pnt + psize) > lim) { - zlog_err ("%s [Error] Update packet error / VPN (prefix length %d exceeds packet size %u)", + zlog_err ("%s [Error] Update packet error / VPNv4 (prefix length %d exceeds packet size %u)", peer->host, prefixlen, (uint)(lim-pnt)); return -1; @@ -216,7 +215,7 @@ bgp_nlri_parse_vpn (struct peer *peer, struct attr *attr, /* sanity check against storage for the IP address portion */ if ((psize - VPN_PREFIXLEN_MIN_BYTES) > (ssize_t) sizeof(p.u)) { - zlog_err ("%s [Error] Update packet error / VPN (psize %d exceeds storage size %zu)", + zlog_err ("%s [Error] Update packet error / VPNv4 (psize %d exceeds storage size %zu)", peer->host, prefixlen - VPN_PREFIXLEN_MIN_BYTES*8, sizeof(p.u)); return -1; @@ -225,7 +224,7 @@ bgp_nlri_parse_vpn (struct peer *peer, struct attr *attr, /* Sanity check against max bitlen of the address family */ if ((psize - VPN_PREFIXLEN_MIN_BYTES) > prefix_blen (&p)) { - zlog_err ("%s [Error] Update packet error / VPN (psize %d exceeds family (%u) max byte len %u)", + zlog_err ("%s [Error] Update packet error / VPNv4 (psize %d exceeds family (%u) max byte len %u)", peer->host, prefixlen - VPN_PREFIXLEN_MIN_BYTES*8, p.family, prefix_blen (&p)); @@ -296,7 +295,7 @@ bgp_nlri_parse_vpn (struct peer *peer, struct attr *attr, /* Packet length consistency check. */ if (pnt != lim) { - zlog_err ("%s [Error] Update packet error / VPN (%zu data remaining after parsing)", + zlog_err ("%s [Error] Update packet error / VPNv4 (%zu data remaining after parsing)", peer->host, lim - pnt); return -1; } @@ -486,7 +485,7 @@ DEFUN (no_vpnv4_network, } static int -show_adj_route_vpn (struct vty *vty, struct peer *peer, afi_t afi, struct prefix_rd *prd, u_char use_json) +show_adj_route_vpn (struct vty *vty, struct peer *peer, struct prefix_rd *prd, u_char use_json) { struct bgp *bgp; struct bgp_table *table; @@ -529,7 +528,7 @@ show_adj_route_vpn (struct vty *vty, struct peer *peer, afi_t afi, struct prefix json_object_string_add(json_ocode, "incomplete", "?"); } - for (rn = bgp_table_top (bgp->rib[afi][SAFI_MPLS_VPN]); rn; + for (rn = bgp_table_top (bgp->rib[AFI_IP][SAFI_MPLS_VPN]); rn; rn = bgp_route_next (rn)) { if (prd && memcmp (rn->p.u.val, prd->val, 8) != 0) @@ -955,25 +954,25 @@ DEFUN (show_bgp_ipv6_vpn_rd, return bgp_show_mpls_vpn (vty, AFI_IP6, &prd, bgp_show_type_normal, NULL, 0, use_json (argc, argv)); } -DEFUN (show_bgp_ip_vpn_all, - show_bgp_ip_vpn_all_cmd, - "show bgp "BGP_AFI_CMD_STR" vpn all", +DEFUN (show_ip_bgp_vpnv4_all, + show_ip_bgp_vpnv4_all_cmd, + "show ip bgp vpnv4 all", SHOW_STR IP_STR BGP_STR - BGP_AFI_HELP_STR - "Display information about all VPN NLRIs\n") + "Display VPNv4 NLRI specific information\n" + "Display information about all VPNv4 NLRIs\n") { - return bgp_show_mpls_vpn (vty, bgp_vty_afi_from_arg(argv[0]), NULL, bgp_show_type_normal, NULL, 0, 0); + return bgp_show_mpls_vpn (vty, AFI_IP, NULL, bgp_show_type_normal, NULL, 0, 0); } -DEFUN (show_bgp_ip_vpn_rd, - show_bgp_ip_vpn_rd_cmd, - "show bgp "BGP_AFI_CMD_STR" vpn rd ASN:nn_or_IP-address:nn", +DEFUN (show_ip_bgp_vpnv4_rd, + show_ip_bgp_vpnv4_rd_cmd, + "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn", SHOW_STR IP_STR BGP_STR - BGP_AFI_HELP_STR + "Display VPNv4 NLRI specific information\n" "Display information for a route distinguisher\n" "VPN Route Distinguisher\n") { @@ -986,29 +985,29 @@ DEFUN (show_bgp_ip_vpn_rd, vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); return CMD_WARNING; } - return bgp_show_mpls_vpn (vty, bgp_vty_afi_from_arg(argv[0]), &prd, bgp_show_type_normal, NULL, 0, 0); + return bgp_show_mpls_vpn (vty, AFI_IP, &prd, bgp_show_type_normal, NULL, 0, 0); } -DEFUN (show_bgp_ip_vpn_all_tags, - show_bgp_ip_vpn_all_tags_cmd, - "show bgp "BGP_AFI_CMD_STR" vpn all tags", +DEFUN (show_ip_bgp_vpnv4_all_tags, + show_ip_bgp_vpnv4_all_tags_cmd, + "show ip bgp vpnv4 all tags", SHOW_STR IP_STR BGP_STR - BGP_AFI_HELP_STR + "Display VPNv4 NLRI specific information\n" "Display information about all VPNv4 NLRIs\n" "Display BGP tags for prefixes\n") { - return bgp_show_mpls_vpn (vty, bgp_vty_afi_from_arg(argv[0]), NULL, bgp_show_type_normal, NULL, 1, 0); + return bgp_show_mpls_vpn (vty, AFI_IP, NULL, bgp_show_type_normal, NULL, 1, 0); } -DEFUN (show_bgp_ip_vpn_rd_tags, - show_bgp_ip_vpn_rd_tags_cmd, - "show bgp "BGP_AFI_CMD_STR" vpn rd ASN:nn_or_IP-address:nn tags", +DEFUN (show_ip_bgp_vpnv4_rd_tags, + show_ip_bgp_vpnv4_rd_tags_cmd, + "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn tags", SHOW_STR IP_STR BGP_STR - BGP_AFI_HELP_STR + "Display VPNv4 NLRI specific information\n" "Display information for a route distinguisher\n" "VPN Route Distinguisher\n" "Display BGP tags for prefixes\n") @@ -1016,26 +1015,25 @@ DEFUN (show_bgp_ip_vpn_rd_tags, int ret; struct prefix_rd prd; - ret = str2prefix_rd (argv[1], &prd); + ret = str2prefix_rd (argv[0], &prd); if (! ret) { vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); return CMD_WARNING; } - return bgp_show_mpls_vpn (vty, bgp_vty_afi_from_arg(argv[0]), &prd, bgp_show_type_normal, NULL, 1, 0); + return bgp_show_mpls_vpn (vty, AFI_IP, &prd, bgp_show_type_normal, NULL, 1, 0); } -DEFUN (show_bgp_ip_vpn_all_neighbor_routes, - show_bgp_ip_vpn_all_neighbor_routes_cmd, - "show bgp "BGP_AFI_CMD_STR" vpn all neighbors (A.B.C.D|X:X::X:X) routes {json}", +DEFUN (show_ip_bgp_vpnv4_all_neighbor_routes, + show_ip_bgp_vpnv4_all_neighbor_routes_cmd, + "show ip bgp vpnv4 all neighbors A.B.C.D routes {json}", SHOW_STR IP_STR BGP_STR - BGP_AFI_HELP_STR + "Display VPNv4 NLRI specific information\n" "Display information about all VPNv4 NLRIs\n" "Detailed information on TCP and BGP neighbor connections\n" "Neighbor to display information about\n" - "Neighbor to display information about\n" "Display routes learned from neighbor\n" "JavaScript Object Notation\n") { @@ -1043,7 +1041,77 @@ DEFUN (show_bgp_ip_vpn_all_neighbor_routes, struct peer *peer; int ret; u_char uj = use_json(argc, argv); - afi_t afi = bgp_vty_afi_from_arg(argv[0]); + + ret = str2sockunion (argv[0], &su); + if (ret < 0) + { + if (uj) + { + json_object *json_no = NULL; + json_no = json_object_new_object(); + json_object_string_add(json_no, "warning", "Malformed address"); + vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); + json_object_free(json_no); + } + else + vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE); + return CMD_WARNING; + } + + peer = peer_lookup (NULL, &su); + if (! peer || ! peer->afc[AFI_IP][SAFI_MPLS_VPN]) + { + if (uj) + { + json_object *json_no = NULL; + json_no = json_object_new_object(); + json_object_string_add(json_no, "warning", "No such neighbor or address family"); + vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); + json_object_free(json_no); + } + else + vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); + return CMD_WARNING; + } + + return bgp_show_mpls_vpn (vty, AFI_IP, NULL, bgp_show_type_neighbor, &su, 0, uj); +} + +DEFUN (show_ip_bgp_vpnv4_rd_neighbor_routes, + show_ip_bgp_vpnv4_rd_neighbor_routes_cmd, + "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors A.B.C.D routes {json}", + SHOW_STR + IP_STR + BGP_STR + "Display VPNv4 NLRI specific information\n" + "Display information for a route distinguisher\n" + "VPN Route Distinguisher\n" + "Detailed information on TCP and BGP neighbor connections\n" + "Neighbor to display information about\n" + "Display routes learned from neighbor\n" + "JavaScript Object Notation\n") +{ + int ret; + union sockunion su; + struct peer *peer; + struct prefix_rd prd; + u_char uj = use_json(argc, argv); + + ret = str2prefix_rd (argv[0], &prd); + if (! ret) + { + if (uj) + { + json_object *json_no = NULL; + json_no = json_object_new_object(); + json_object_string_add(json_no, "warning", "Malformed Route Distinguisher"); + vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); + json_object_free(json_no); + } + else + vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); + return CMD_WARNING; + } ret = str2sockunion (argv[1], &su); if (ret < 0) @@ -1062,7 +1130,7 @@ DEFUN (show_bgp_ip_vpn_all_neighbor_routes, } peer = peer_lookup (NULL, &su); - if (! peer || ! peer->afc[afi][SAFI_MPLS_VPN]) + if (! peer || ! peer->afc[AFI_IP][SAFI_MPLS_VPN]) { if (uj) { @@ -1077,48 +1145,28 @@ DEFUN (show_bgp_ip_vpn_all_neighbor_routes, return CMD_WARNING; } - return bgp_show_mpls_vpn (vty, afi, NULL, bgp_show_type_neighbor, &su, 0, uj); + return bgp_show_mpls_vpn (vty, AFI_IP, &prd, bgp_show_type_neighbor, &su, 0, uj); } -DEFUN (show_bgp_ip_vpn_rd_neighbor_routes, - show_bgp_ip_vpn_rd_neighbor_routes_cmd, - "show bgp "BGP_AFI_CMD_STR" vpn rd ASN:nn_or_IP-address:nn neighbors (A.B.C.D|X:X::X:X) routes {json}", +DEFUN (show_ip_bgp_vpnv4_all_neighbor_advertised_routes, + show_ip_bgp_vpnv4_all_neighbor_advertised_routes_cmd, + "show ip bgp vpnv4 all neighbors A.B.C.D advertised-routes {json}", SHOW_STR IP_STR BGP_STR - BGP_AFI_HELP_STR - "Display information for a route distinguisher\n" - "VPN Route Distinguisher\n" + "Display VPNv4 NLRI specific information\n" + "Display information about all VPNv4 NLRIs\n" "Detailed information on TCP and BGP neighbor connections\n" "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Display routes learned from neighbor\n" + "Display the routes advertised to a BGP neighbor\n" "JavaScript Object Notation\n") { int ret; - union sockunion su; struct peer *peer; - struct prefix_rd prd; + union sockunion su; u_char uj = use_json(argc, argv); - afi_t afi = bgp_vty_afi_from_arg(argv[0]); - ret = str2prefix_rd (argv[1], &prd); - if (! ret) - { - if (uj) - { - json_object *json_no = NULL; - json_no = json_object_new_object(); - json_object_string_add(json_no, "warning", "Malformed Route Distinguisher"); - vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); - json_object_free(json_no); - } - else - vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); - return CMD_WARNING; - } - - ret = str2sockunion (argv[2], &su); + ret = str2sockunion (argv[0], &su); if (ret < 0) { if (uj) @@ -1133,9 +1181,8 @@ DEFUN (show_bgp_ip_vpn_rd_neighbor_routes, vty_out (vty, "Malformed address: %s%s", argv[0], VTY_NEWLINE); return CMD_WARNING; } - peer = peer_lookup (NULL, &su); - if (! peer || ! peer->afc[afi][SAFI_MPLS_VPN]) + if (! peer || ! peer->afc[AFI_IP][SAFI_MPLS_VPN]) { if (uj) { @@ -1150,28 +1197,28 @@ DEFUN (show_bgp_ip_vpn_rd_neighbor_routes, return CMD_WARNING; } - return bgp_show_mpls_vpn (vty, afi, &prd, bgp_show_type_neighbor, &su, 0, uj); + return show_adj_route_vpn (vty, peer, NULL, uj); } -DEFUN (show_bgp_ip_vpn_all_neighbor_advertised_routes, - show_bgp_ip_vpn_all_neighbor_advertised_routes_cmd, - "show bgp "BGP_AFI_CMD_STR" vpn all neighbors (A.B.C.D|X:X::X:X) advertised-routes {json}", +DEFUN (show_ip_bgp_vpnv4_rd_neighbor_advertised_routes, + show_ip_bgp_vpnv4_rd_neighbor_advertised_routes_cmd, + "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors A.B.C.D advertised-routes {json}", SHOW_STR IP_STR BGP_STR - BGP_AFI_HELP_STR - "Display information about all VPN NLRIs\n" + "Display VPNv4 NLRI specific information\n" + "Display information for a route distinguisher\n" + "VPN Route Distinguisher\n" "Detailed information on TCP and BGP neighbor connections\n" "Neighbor to display information about\n" - "Neighbor to display information about\n" "Display the routes advertised to a BGP neighbor\n" "JavaScript Object Notation\n") { int ret; struct peer *peer; + struct prefix_rd prd; union sockunion su; u_char uj = use_json(argc, argv); - afi_t afi = bgp_vty_afi_from_arg(argv[0]); ret = str2sockunion (argv[1], &su); if (ret < 0) @@ -1189,7 +1236,7 @@ DEFUN (show_bgp_ip_vpn_all_neighbor_advertised_routes, return CMD_WARNING; } peer = peer_lookup (NULL, &su); - if (! peer || ! peer->afc[afi][SAFI_MPLS_VPN]) + if (! peer || ! peer->afc[AFI_IP][SAFI_MPLS_VPN]) { if (uj) { @@ -1204,63 +1251,7 @@ DEFUN (show_bgp_ip_vpn_all_neighbor_advertised_routes, return CMD_WARNING; } - return show_adj_route_vpn (vty, peer, afi, NULL, uj); -} - -DEFUN (show_bgp_ip_vpn_rd_neighbor_advertised_routes, - show_bgp_ip_vpn_rd_neighbor_advertised_routes_cmd, - "show bgp "BGP_AFI_CMD_STR" vpn rd ASN:nn_or_IP-address:nn neighbors (A.B.C.D|X:X::X:X) advertised-routes {json}", - SHOW_STR - IP_STR - BGP_STR - BGP_AFI_HELP_STR - "Display information for a route distinguisher\n" - "VPN Route Distinguisher\n" - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Neighbor to display information about\n" - "Display the routes advertised to a BGP neighbor\n" - "JavaScript Object Notation\n") -{ - int ret; - struct peer *peer; - struct prefix_rd prd; - union sockunion su; - u_char uj = use_json(argc, argv); - afi_t afi = bgp_vty_afi_from_arg(argv[0]); - - ret = str2sockunion (argv[2], &su); - if (ret < 0) - { - if (uj) - { - json_object *json_no = NULL; - json_no = json_object_new_object(); - json_object_string_add(json_no, "warning", "Malformed address"); - vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); - json_object_free(json_no); - } - else - vty_out (vty, "Malformed address: %s%s", argv[2], VTY_NEWLINE); - return CMD_WARNING; - } - peer = peer_lookup (NULL, &su); - if (! peer || ! peer->afc[afi][SAFI_MPLS_VPN]) - { - if (uj) - { - json_object *json_no = NULL; - json_no = json_object_new_object(); - json_object_string_add(json_no, "warning", "No such neighbor or address family"); - vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); - json_object_free(json_no); - } - else - vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); - return CMD_WARNING; - } - - ret = str2prefix_rd (argv[1], &prd); + ret = str2prefix_rd (argv[0], &prd); if (! ret) { if (uj) @@ -1276,7 +1267,7 @@ DEFUN (show_bgp_ip_vpn_rd_neighbor_advertised_routes, return CMD_WARNING; } - return show_adj_route_vpn (vty, peer, afi, &prd, uj); + return show_adj_route_vpn (vty, peer, &prd, uj); } void @@ -1290,12 +1281,12 @@ bgp_mplsvpn_init (void) install_element (VIEW_NODE, &show_bgp_ipv4_vpn_rd_cmd); install_element (VIEW_NODE, &show_bgp_ipv6_vpn_cmd); install_element (VIEW_NODE, &show_bgp_ipv6_vpn_rd_cmd); - install_element (VIEW_NODE, &show_bgp_ip_vpn_all_cmd); - install_element (VIEW_NODE, &show_bgp_ip_vpn_rd_cmd); - install_element (VIEW_NODE, &show_bgp_ip_vpn_all_tags_cmd); - install_element (VIEW_NODE, &show_bgp_ip_vpn_rd_tags_cmd); - install_element (VIEW_NODE, &show_bgp_ip_vpn_all_neighbor_routes_cmd); - install_element (VIEW_NODE, &show_bgp_ip_vpn_rd_neighbor_routes_cmd); - install_element (VIEW_NODE, &show_bgp_ip_vpn_all_neighbor_advertised_routes_cmd); - install_element (VIEW_NODE, &show_bgp_ip_vpn_rd_neighbor_advertised_routes_cmd); + install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_cmd); + install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_cmd); + install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_tags_cmd); + install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_tags_cmd); + install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_neighbor_routes_cmd); + install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_neighbor_routes_cmd); + install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_neighbor_advertised_routes_cmd); + install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_neighbor_advertised_routes_cmd); } diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 9e1ae854d4..c717a930b1 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -6416,8 +6416,7 @@ route_vty_out_tmp (struct vty *vty, struct prefix *p, struct attr *attr, safi_t safi == SAFI_ENCAP || !BGP_ATTR_NEXTHOP_AFI_IP6(attr))) { - if (attr->extra && - (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP)) + if (safi == SAFI_MPLS_VPN || safi == SAFI_ENCAP) vty_out (vty, "%-16s", inet_ntoa (attr->extra->mp_nexthop_global_in)); else @@ -6428,15 +6427,13 @@ route_vty_out_tmp (struct vty *vty, struct prefix *p, struct attr *attr, safi_t { int len; char buf[BUFSIZ]; - if (attr->extra) - { - len = vty_out (vty, "%s", - inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, - buf, BUFSIZ)); - len = 16 - len; - } - else - len = 0; + + assert (attr->extra); + + len = vty_out (vty, "%s", + inet_ntop (AF_INET6, &attr->extra->mp_nexthop_global, + buf, BUFSIZ)); + len = 16 - len; if (len < 1) vty_out (vty, "%s%*s", VTY_NEWLINE, 36, " "); else @@ -8160,12 +8157,13 @@ DEFUN (show_ip_bgp, DEFUN (show_ip_bgp_ipv4, show_ip_bgp_ipv4_cmd, - "show ip bgp ipv4 "BGP_SAFI_CMD_STR" {json}", + "show ip bgp ipv4 (unicast|multicast) {json}", SHOW_STR IP_STR BGP_STR "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" "JavaScript Object Notation\n") { u_char uj = use_json(argc, argv); @@ -8177,11 +8175,12 @@ DEFUN (show_ip_bgp_ipv4, ALIAS (show_ip_bgp_ipv4, show_bgp_ipv4_safi_cmd, - "show bgp ipv4 "BGP_SAFI_CMD_STR" {json}", + "show bgp ipv4 (unicast|multicast) {json}", SHOW_STR BGP_STR "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" "JavaScript Object Notation\n") DEFUN (show_ip_bgp_route, @@ -8217,10 +8216,10 @@ DEFUN (show_ip_bgp_route_pathtype, DEFUN (show_bgp_ipv4_safi_route_pathtype, show_bgp_ipv4_safi_route_pathtype_cmd, - "show bgp ipv4 "BGP_SAFI_CMD_STR" A.B.C.D (bestpath|multipath) {json}", + "show bgp ipv4 (unicast|multicast|vpn|encap) A.B.C.D (bestpath|multipath) {json}", SHOW_STR BGP_STR - BGP_AFI_SAFI_HELP_STR + AFI_SAFI_STR "IP prefix /, e.g., 35.0.0.0/8\n" "Display only the bestpath\n" "Display only multipaths\n" @@ -8276,11 +8275,11 @@ DEFUN (show_bgp_ipv6_prefix, DEFUN (show_ip_bgp_ipv4_route, show_ip_bgp_ipv4_route_cmd, - "show ip bgp ipv4 "BGP_SAFI_CMD_STR" A.B.C.D {json}", + "show ip bgp ipv4 (unicast|multicast|vpn|encap) A.B.C.D {json}", SHOW_STR IP_STR BGP_STR - BGP_AFI_SAFI_HELP_STR + AFI_SAFI_STR "Network in the BGP routing table to display\n" "JavaScript Object Notation\n") { @@ -8293,13 +8292,27 @@ DEFUN (show_ip_bgp_ipv4_route, ALIAS (show_ip_bgp_ipv4_route, show_bgp_ipv4_safi_route_cmd, - "show bgp ipv4 "BGP_SAFI_CMD_STR" A.B.C.D {json}", + "show bgp ipv4 (unicast|multicast|vpn|encap) A.B.C.D {json}", SHOW_STR BGP_STR - BGP_AFI_SAFI_HELP_STR + AFI_SAFI_STR "Network in the BGP routing table to display\n" "JavaScript Object Notation\n") +DEFUN (show_ip_bgp_vpnv4_all_route, + show_ip_bgp_vpnv4_all_route_cmd, + "show ip bgp vpnv4 all A.B.C.D {json}", + SHOW_STR + IP_STR + BGP_STR + "Display VPNv4 NLRI specific information\n" + "Display information about all VPNv4 NLRIs\n" + "Network in the BGP routing table to display\n" + "JavaScript Object Notation\n") +{ + return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 0, BGP_PATH_ALL, use_json(argc, argv)); +} + DEFUN (show_bgp_ipv4_safi_rd_route, show_bgp_ipv4_safi_rd_route_cmd, "show bgp ipv4 (encap|vpn) rd ASN:nn_or_IP-address:nn A.B.C.D {json}", @@ -8419,6 +8432,31 @@ DEFUN (show_bgp_ipv6_safi_rd_prefix, return bgp_show_route (vty, NULL, argv[2], AFI_IP6, safi, &prd, 1, BGP_PATH_ALL, use_json (argc, argv)); } +DEFUN (show_ip_bgp_vpnv4_rd_route, + show_ip_bgp_vpnv4_rd_route_cmd, + "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D {json}", + SHOW_STR + IP_STR + BGP_STR + "Display VPNv4 NLRI specific information\n" + "Display information for a route distinguisher\n" + "VPN Route Distinguisher\n" + "Network in the BGP routing table to display\n" + "JavaScript Object Notation\n") +{ + int ret; + struct prefix_rd prd; + u_char uj= use_json(argc, argv); + + ret = str2prefix_rd (argv[0], &prd); + if (! ret) + { + vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); + return CMD_WARNING; + } + return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL, uj); +} + DEFUN (show_ip_bgp_prefix, show_ip_bgp_prefix_cmd, "show ip bgp A.B.C.D/M {json}", @@ -8451,11 +8489,11 @@ DEFUN (show_ip_bgp_prefix_pathtype, DEFUN (show_ip_bgp_ipv4_prefix, show_ip_bgp_ipv4_prefix_cmd, - "show ip bgp ipv4 "BGP_SAFI_CMD_STR" A.B.C.D/M {json}", + "show ip bgp ipv4 (unicast|multicast|vpn|encap) A.B.C.D/M {json}", SHOW_STR IP_STR BGP_STR - BGP_AFI_SAFI_HELP_STR + AFI_SAFI_STR "IP prefix /, e.g., 35.0.0.0/8\n" "JavaScript Object Notation\n") { @@ -8468,20 +8506,20 @@ DEFUN (show_ip_bgp_ipv4_prefix, ALIAS (show_ip_bgp_ipv4_prefix, show_bgp_ipv4_safi_prefix_cmd, - "show bgp ipv4 "BGP_SAFI_CMD_STR" A.B.C.D/M {json}", + "show bgp ipv4 (unicast|multicast|vpn|encap) A.B.C.D/M {json}", SHOW_STR BGP_STR - BGP_AFI_SAFI_HELP_STR + AFI_SAFI_STR "IP prefix /, e.g., 35.0.0.0/8\n" "JavaScript Object Notation\n") DEFUN (show_ip_bgp_ipv4_prefix_pathtype, show_ip_bgp_ipv4_prefix_pathtype_cmd, - "show ip bgp ipv4 "BGP_SAFI_CMD_STR" A.B.C.D/M (bestpath|multipath) {json}", + "show ip bgp ipv4 (unicast|multicast|vpn|encap) A.B.C.D/M (bestpath|multipath) {json}", SHOW_STR IP_STR BGP_STR - BGP_AFI_SAFI_HELP_STR + AFI_SAFI_STR "IP prefix /, e.g., 35.0.0.0/8\n" "Display only the bestpath\n" "Display only multipaths\n" @@ -8501,15 +8539,52 @@ DEFUN (show_ip_bgp_ipv4_prefix_pathtype, ALIAS (show_ip_bgp_ipv4_prefix_pathtype, show_bgp_ipv4_safi_prefix_pathtype_cmd, - "show bgp ipv4 "BGP_SAFI_CMD_STR" A.B.C.D/M (bestpath|multipath) {json}", + "show bgp ipv4 (unicast|multicast|vpn|encap) A.B.C.D/M (bestpath|multipath) {json}", SHOW_STR BGP_STR - BGP_AFI_SAFI_HELP_STR + AFI_SAFI_STR "IP prefix /, e.g., 35.0.0.0/8\n" "Display only the bestpath\n" "Display only multipaths\n" "JavaScript Object Notation\n") +DEFUN (show_ip_bgp_vpnv4_all_prefix, + show_ip_bgp_vpnv4_all_prefix_cmd, + "show ip bgp vpnv4 all A.B.C.D/M {json}", + SHOW_STR + IP_STR + BGP_STR + "Display VPNv4 NLRI specific information\n" + "Display information about all VPNv4 NLRIs\n" + "IP prefix /, e.g., 35.0.0.0/8\n" + "JavaScript Object Notation\n") +{ + return bgp_show_route (vty, NULL, argv[0], AFI_IP, SAFI_MPLS_VPN, NULL, 1, BGP_PATH_ALL, use_json(argc, argv)); +} + +DEFUN (show_ip_bgp_vpnv4_rd_prefix, + show_ip_bgp_vpnv4_rd_prefix_cmd, + "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn A.B.C.D/M {json}", + SHOW_STR + IP_STR + BGP_STR + "Display VPNv4 NLRI specific information\n" + "Display information for a route distinguisher\n" + "VPN Route Distinguisher\n" + "IP prefix /, e.g., 35.0.0.0/8\n" + "JavaScript Object Notation\n") +{ + int ret; + struct prefix_rd prd; + + ret = str2prefix_rd (argv[0], &prd); + if (! ret) + { + vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); + return CMD_WARNING; + } + return bgp_show_route (vty, NULL, argv[1], AFI_IP, SAFI_MPLS_VPN, &prd, 0, BGP_PATH_ALL, use_json(argc, argv)); +} DEFUN (show_ip_bgp_view, show_ip_bgp_instance_cmd, @@ -8635,11 +8710,13 @@ ALIAS (show_bgp, DEFUN (show_bgp_ipv6_safi, show_bgp_ipv6_safi_cmd, - "show bgp ipv6 "BGP_SAFI_CMD_STR" {json}", + "show bgp ipv6 (unicast|multicast) {json}", SHOW_STR BGP_STR "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" + AFI_SAFI_STR "JavaScript Object Notation\n") { u_char uj = use_json(argc, argv); @@ -8684,10 +8761,10 @@ DEFUN (show_bgp_route, DEFUN (show_bgp_ipv6_safi_route, show_bgp_ipv6_safi_route_cmd, - "show bgp ipv6 "BGP_SAFI_CMD_STR" X:X::X:X {json}", + "show bgp ipv6 (unicast|multicast|vpn|encap) X:X::X:X {json}", SHOW_STR BGP_STR - BGP_AFI_SAFI_HELP_STR + AFI_SAFI_STR "Network in the BGP routing table to display\n" "JavaScript Object Notation\n") { @@ -8728,10 +8805,10 @@ ALIAS (show_bgp_route_pathtype, DEFUN (show_bgp_ipv6_safi_route_pathtype, show_bgp_ipv6_safi_route_pathtype_cmd, - "show bgp ipv6 "BGP_SAFI_CMD_STR" X:X::X:X (bestpath|multipath) {json}", + "show bgp ipv6 (unicast|multicast|vpn|encap) X:X::X:X (bestpath|multipath) {json}", SHOW_STR BGP_STR - BGP_AFI_SAFI_HELP_STR + AFI_SAFI_STR "Network in the BGP routing table to display\n" "Display only the bestpath\n" "Display only multipaths\n" @@ -8775,10 +8852,10 @@ DEFUN (show_bgp_prefix, DEFUN (show_bgp_ipv6_safi_prefix, show_bgp_ipv6_safi_prefix_cmd, - "show bgp ipv6 "BGP_SAFI_CMD_STR" X:X::X:X/M {json}", + "show bgp ipv6 (unicast|multicast|vpn|encap) X:X::X:X/M {json}", SHOW_STR BGP_STR - BGP_AFI_SAFI_HELP_STR + AFI_SAFI_STR "IPv6 prefix /, e.g., 3ffe::/16\n" "JavaScript Object Notation\n") { @@ -8819,10 +8896,10 @@ ALIAS (show_bgp_prefix_pathtype, DEFUN (show_bgp_ipv6_safi_prefix_pathtype, show_bgp_ipv6_safi_prefix_pathtype_cmd, - "show bgp ipv6 "BGP_SAFI_CMD_STR" X:X::X:X/M (bestpath|multipath) {json}", + "show bgp ipv6 (unicast|multicast|vpn|encap) X:X::X:X/M (bestpath|multipath) {json}", SHOW_STR BGP_STR - BGP_AFI_SAFI_HELP_STR + AFI_SAFI_STR "IPv6 prefix /, e.g., 3ffe::/16\n" "Display only the bestpath\n" "Display only multipaths\n" @@ -9245,19 +9322,22 @@ ALIAS (show_ip_bgp_flap_regexp, DEFUN (show_ip_bgp_ipv4_regexp, show_ip_bgp_ipv4_regexp_cmd, - "show ip bgp ipv4 "BGP_SAFI_CMD_STR" regexp .LINE", + "show ip bgp ipv4 (unicast|multicast) regexp .LINE", SHOW_STR IP_STR BGP_STR "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" "Display routes matching the AS path regular expression\n" "A regular-expression to match the BGP AS paths\n") { - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[0]); - return bgp_show_regexp (vty, argc, argv, AFI_IP, safi, - bgp_show_type_regexp); + if (strncmp (argv[0], "m", 1) == 0) + return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_MULTICAST, + bgp_show_type_regexp); + + return bgp_show_regexp (vty, argc, argv, AFI_IP, SAFI_UNICAST, + bgp_show_type_regexp); } #ifdef HAVE_IPV6 @@ -9392,19 +9472,22 @@ ALIAS (show_ip_bgp_flap_prefix_list, DEFUN (show_ip_bgp_ipv4_prefix_list, show_ip_bgp_ipv4_prefix_list_cmd, - "show ip bgp ipv4 "BGP_SAFI_CMD_STR" prefix-list WORD", + "show ip bgp ipv4 (unicast|multicast) prefix-list WORD", SHOW_STR IP_STR BGP_STR "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" "Display routes conforming to the prefix-list\n" "IP prefix-list name\n") { - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[0]); - return bgp_show_prefix_list (vty, NULL, argv[1], AFI_IP, safi, - bgp_show_type_prefix_list); + if (strncmp (argv[0], "m", 1) == 0) + return bgp_show_prefix_list (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, + bgp_show_type_prefix_list); + + return bgp_show_prefix_list (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, + bgp_show_type_prefix_list); } #ifdef HAVE_IPV6 @@ -9538,19 +9621,22 @@ ALIAS (show_ip_bgp_flap_filter_list, DEFUN (show_ip_bgp_ipv4_filter_list, show_ip_bgp_ipv4_filter_list_cmd, - "show ip bgp ipv4 "BGP_SAFI_CMD_STR" filter-list WORD", + "show ip bgp ipv4 (unicast|multicast) filter-list WORD", SHOW_STR IP_STR BGP_STR "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" "Display routes conforming to the filter-list\n" "Regular expression access list name\n") { - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[0]); - return bgp_show_filter_list (vty, NULL, argv[1], AFI_IP, safi, - bgp_show_type_filter_list); + if (strncmp (argv[0], "m", 1) == 0) + return bgp_show_filter_list (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, + bgp_show_type_filter_list); + + return bgp_show_filter_list (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, + bgp_show_type_filter_list); } #ifdef HAVE_IPV6 @@ -9621,53 +9707,61 @@ DEFUN (show_ip_bgp_dampening_info, DEFUN (show_ip_bgp_ipv4_dampening_parameters, show_ip_bgp_ipv4_dampening_parameters_cmd, - "show ip bgp ipv4 "BGP_SAFI_CMD_STR" dampening parameters", + "show ip bgp ipv4 (unicast|multicast) dampening parameters", SHOW_STR IP_STR BGP_STR "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" "Display detailed information about dampening\n" "Display detail of configured dampening parameters\n") { - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[0]); - return bgp_show_dampening_parameters (vty, AFI_IP, safi); + if (strncmp(argv[0], "m", 1) == 0) + return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_MULTICAST); + + return bgp_show_dampening_parameters (vty, AFI_IP, SAFI_UNICAST); } DEFUN (show_ip_bgp_ipv4_dampening_flap_stats, show_ip_bgp_ipv4_dampening_flap_stats_cmd, - "show ip bgp ipv4 "BGP_SAFI_CMD_STR" dampening flap-statistics", + "show ip bgp ipv4 (unicast|multicast) dampening flap-statistics", SHOW_STR IP_STR BGP_STR "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" "Display detailed information about dampening\n" "Display flap statistics of routes\n") { - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[0]); - return bgp_show (vty, NULL, AFI_IP, safi, + if (strncmp(argv[0], "m", 1) == 0) + return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_flap_statistics, NULL, 0); + + return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, + bgp_show_type_flap_statistics, NULL, 0); } DEFUN (show_ip_bgp_ipv4_dampening_dampd_paths, show_ip_bgp_ipv4_dampening_dampd_paths_cmd, - "show ip bgp ipv4 "BGP_SAFI_CMD_STR" dampening dampened-paths", + "show ip bgp ipv4 (unicast|multicast) dampening dampened-paths", SHOW_STR IP_STR BGP_STR "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" "Display detailed information about dampening\n" "Display paths suppressed due to dampening\n") { - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[0]); - return bgp_show (vty, NULL, AFI_IP, safi, + if (strncmp(argv[0], "m", 1) == 0) + return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, bgp_show_type_dampend_paths, NULL, 0); + + return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, + bgp_show_type_dampend_paths, NULL, 0); } static int @@ -9749,19 +9843,22 @@ ALIAS (show_ip_bgp_flap_route_map, DEFUN (show_ip_bgp_ipv4_route_map, show_ip_bgp_ipv4_route_map_cmd, - "show ip bgp ipv4 "BGP_SAFI_CMD_STR" route-map WORD", + "show ip bgp ipv4 (unicast|multicast) route-map WORD", SHOW_STR IP_STR BGP_STR "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" "Display routes matching the route-map\n" "A route-map to match on\n") { - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[0]); - return bgp_show_route_map (vty, NULL, argv[1], AFI_IP, safi, - bgp_show_type_route_map); + if (strncmp (argv[0], "m", 1) == 0) + return bgp_show_route_map (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, + bgp_show_type_route_map); + + return bgp_show_route_map (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, + bgp_show_type_route_map); } DEFUN (show_bgp_route_map, @@ -9822,18 +9919,21 @@ ALIAS (show_ip_bgp_flap_cidr_only, DEFUN (show_ip_bgp_ipv4_cidr_only, show_ip_bgp_ipv4_cidr_only_cmd, - "show ip bgp ipv4 "BGP_SAFI_CMD_STR" cidr-only", + "show ip bgp ipv4 (unicast|multicast) cidr-only", SHOW_STR IP_STR BGP_STR "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" "Display only routes with non-natural netmasks\n") { - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[0]); - return bgp_show (vty, NULL, AFI_IP, safi, - bgp_show_type_cidr_only, NULL, 0); + if (strncmp (argv[0], "m", 1) == 0) + return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, + bgp_show_type_cidr_only, NULL, 0); + + return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, + bgp_show_type_cidr_only, NULL, 0); } DEFUN (show_ip_bgp_community_all, @@ -9850,18 +9950,21 @@ DEFUN (show_ip_bgp_community_all, DEFUN (show_ip_bgp_ipv4_community_all, show_ip_bgp_ipv4_community_all_cmd, - "show ip bgp ipv4 "BGP_SAFI_CMD_STR" community", + "show ip bgp ipv4 (unicast|multicast) community", SHOW_STR IP_STR BGP_STR "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" "Display routes matching the communities\n") { - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[0]); - return bgp_show (vty, NULL, AFI_IP, safi, - bgp_show_type_community_all, NULL, 0); + if (strncmp (argv[0], "m", 1) == 0) + return bgp_show (vty, NULL, AFI_IP, SAFI_MULTICAST, + bgp_show_type_community_all, NULL, 0); + + return bgp_show (vty, NULL, AFI_IP, SAFI_UNICAST, + bgp_show_type_community_all, NULL, 0); } #ifdef HAVE_IPV6 @@ -10053,31 +10156,34 @@ ALIAS (show_ip_bgp_community, DEFUN (show_ip_bgp_ipv4_community, show_ip_bgp_ipv4_community_cmd, - "show ip bgp ipv4 "BGP_SAFI_CMD_STR" community (AA:NN|local-AS|no-advertise|no-export)", + "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", SHOW_STR IP_STR BGP_STR "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" "Display routes matching the communities\n" COMMUNITY_AANN_STR "Do not send outside local AS (well-known community)\n" "Do not advertise to any peer (well-known community)\n" "Do not export to next AS (well-known community)\n") { - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[0]); - return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, safi); + if (strncmp (argv[0], "m", 1) == 0) + return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_MULTICAST); + + return bgp_show_community (vty, NULL, argc, argv, 0, AFI_IP, SAFI_UNICAST); } ALIAS (show_ip_bgp_ipv4_community, show_ip_bgp_ipv4_community2_cmd, - "show ip bgp ipv4 "BGP_SAFI_CMD_STR" community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", + "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", SHOW_STR IP_STR BGP_STR "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" "Display routes matching the communities\n" COMMUNITY_AANN_STR "Do not send outside local AS (well-known community)\n" @@ -10090,12 +10196,13 @@ ALIAS (show_ip_bgp_ipv4_community, ALIAS (show_ip_bgp_ipv4_community, show_ip_bgp_ipv4_community3_cmd, - "show ip bgp ipv4 "BGP_SAFI_CMD_STR" community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", + "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", SHOW_STR IP_STR BGP_STR "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" "Display routes matching the communities\n" COMMUNITY_AANN_STR "Do not send outside local AS (well-known community)\n" @@ -10112,12 +10219,13 @@ ALIAS (show_ip_bgp_ipv4_community, ALIAS (show_ip_bgp_ipv4_community, show_ip_bgp_ipv4_community4_cmd, - "show ip bgp ipv4 "BGP_SAFI_CMD_STR" community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", + "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", SHOW_STR IP_STR BGP_STR "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" "Display routes matching the communities\n" COMMUNITY_AANN_STR "Do not send outside local AS (well-known community)\n" @@ -10138,11 +10246,14 @@ ALIAS (show_ip_bgp_ipv4_community, DEFUN (show_bgp_instance_afi_safi_community_all, show_bgp_instance_afi_safi_community_all_cmd, - "show bgp " BGP_INSTANCE_CMD " "BGP_AFI_SAFI_CMD_STR" community", + "show bgp " BGP_INSTANCE_CMD " (ipv4|ipv6) (unicast|multicast) community", SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR - BGP_AFI_SAFI_HELP_STR + "Address family\n" + "Address family\n" + "Address Family modifier\n" + "Address Family modifier\n" "Display routes matching the communities\n") { int afi; @@ -10157,14 +10268,14 @@ DEFUN (show_bgp_instance_afi_safi_community_all, return CMD_WARNING; } - afi = bgp_vty_safi_from_arg(argv[2]); - safi = bgp_vty_safi_from_arg(argv[3]); + afi = (strncmp (argv[2], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; + safi = (strncmp (argv[3], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; return bgp_show (vty, bgp, afi, safi, bgp_show_type_community_all, NULL, 0); } DEFUN (show_bgp_instance_afi_safi_community, show_bgp_instance_afi_safi_community_cmd, - "show bgp " BGP_INSTANCE_CMD " "BGP_AFI_SAFI_CMD_STR" community (AA:NN|local-AS|no-advertise|no-export)", + "show bgp " BGP_INSTANCE_CMD " (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export)", SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR @@ -10181,14 +10292,14 @@ DEFUN (show_bgp_instance_afi_safi_community, int afi; int safi; - afi = bgp_vty_safi_from_arg(argv[2]); - safi = bgp_vty_safi_from_arg(argv[3]); + afi = (strncmp (argv[2], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; + safi = (strncmp (argv[3], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; return bgp_show_community (vty, argv[1], argc-4, &argv[4], 0, afi, safi); } ALIAS (show_bgp_instance_afi_safi_community, show_bgp_instance_afi_safi_community2_cmd, - "show bgp " BGP_INSTANCE_CMD " "BGP_AFI_SAFI_CMD_STR" community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", + "show bgp " BGP_INSTANCE_CMD " (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR @@ -10208,7 +10319,7 @@ ALIAS (show_bgp_instance_afi_safi_community, ALIAS (show_bgp_instance_afi_safi_community, show_bgp_instance_afi_safi_community3_cmd, - "show bgp " BGP_INSTANCE_CMD " "BGP_AFI_SAFI_CMD_STR" community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", + "show bgp " BGP_INSTANCE_CMD " (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR @@ -10232,7 +10343,7 @@ ALIAS (show_bgp_instance_afi_safi_community, ALIAS (show_bgp_instance_afi_safi_community, show_bgp_instance_afi_safi_community4_cmd, - "show bgp " BGP_INSTANCE_CMD " "BGP_AFI_SAFI_CMD_STR" community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", + "show bgp " BGP_INSTANCE_CMD " (ipv4|ipv6) (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export)", SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR @@ -10339,12 +10450,13 @@ ALIAS (show_ip_bgp_community_exact, DEFUN (show_ip_bgp_ipv4_community_exact, show_ip_bgp_ipv4_community_exact_cmd, - "show ip bgp ipv4 "BGP_SAFI_CMD_STR" community (AA:NN|local-AS|no-advertise|no-export) exact-match", + "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) exact-match", SHOW_STR IP_STR BGP_STR "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" "Display routes matching the communities\n" COMMUNITY_AANN_STR "Do not send outside local AS (well-known community)\n" @@ -10352,19 +10464,21 @@ DEFUN (show_ip_bgp_ipv4_community_exact, "Do not export to next AS (well-known community)\n" "Exact match of the communities") { - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[0]); - return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, safi); + if (strncmp (argv[0], "m", 1) == 0) + return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_MULTICAST); + + return bgp_show_community (vty, NULL, argc, argv, 1, AFI_IP, SAFI_UNICAST); } ALIAS (show_ip_bgp_ipv4_community_exact, show_ip_bgp_ipv4_community2_exact_cmd, - "show ip bgp ipv4 "BGP_SAFI_CMD_STR" community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", + "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", SHOW_STR IP_STR BGP_STR "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" "Display routes matching the communities\n" COMMUNITY_AANN_STR "Do not send outside local AS (well-known community)\n" @@ -10378,12 +10492,13 @@ ALIAS (show_ip_bgp_ipv4_community_exact, ALIAS (show_ip_bgp_ipv4_community_exact, show_ip_bgp_ipv4_community3_exact_cmd, - "show ip bgp ipv4 "BGP_SAFI_CMD_STR" community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", + "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", SHOW_STR IP_STR BGP_STR "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" "Display routes matching the communities\n" COMMUNITY_AANN_STR "Do not send outside local AS (well-known community)\n" @@ -10401,12 +10516,13 @@ ALIAS (show_ip_bgp_ipv4_community_exact, ALIAS (show_ip_bgp_ipv4_community_exact, show_ip_bgp_ipv4_community4_exact_cmd, - "show ip bgp ipv4 "BGP_SAFI_CMD_STR" community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", + "show ip bgp ipv4 (unicast|multicast) community (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) (AA:NN|local-AS|no-advertise|no-export) exact-match", SHOW_STR IP_STR BGP_STR "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" "Display routes matching the communities\n" COMMUNITY_AANN_STR "Do not send outside local AS (well-known community)\n" @@ -11106,19 +11222,21 @@ DEFUN (show_ip_bgp_instance_community_list, DEFUN (show_ip_bgp_ipv4_community_list, show_ip_bgp_ipv4_community_list_cmd, - "show ip bgp ipv4 "BGP_SAFI_CMD_STR" community-list (<1-500>|WORD)", + "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD)", SHOW_STR IP_STR BGP_STR "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" "Display routes matching the community-list\n" "community-list number\n" "community-list name\n") { - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[0]); - return bgp_show_community_list (vty, NULL, argv[1], 0, AFI_IP, safi); + if (strncmp (argv[0], "m", 1) == 0) + return bgp_show_community_list (vty, NULL, argv[1], 0, AFI_IP, SAFI_MULTICAST); + + return bgp_show_community_list (vty, NULL, argv[1], 0, AFI_IP, SAFI_UNICAST); } DEFUN (show_ip_bgp_community_list_exact, @@ -11137,20 +11255,22 @@ DEFUN (show_ip_bgp_community_list_exact, DEFUN (show_ip_bgp_ipv4_community_list_exact, show_ip_bgp_ipv4_community_list_exact_cmd, - "show ip bgp ipv4 "BGP_SAFI_CMD_STR" community-list (<1-500>|WORD) exact-match", + "show ip bgp ipv4 (unicast|multicast) community-list (<1-500>|WORD) exact-match", SHOW_STR IP_STR BGP_STR "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" "Display routes matching the community-list\n" "community-list number\n" "community-list name\n" "Exact match of the communities\n") { - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[0]); - return bgp_show_community_list (vty, NULL, argv[1], 1, AFI_IP, safi); + if (strncmp (argv[0], "m", 1) == 0) + return bgp_show_community_list (vty, NULL, argv[1], 1, AFI_IP, SAFI_MULTICAST); + + return bgp_show_community_list (vty, NULL, argv[1], 1, AFI_IP, SAFI_UNICAST); } #ifdef HAVE_IPV6 @@ -11342,19 +11462,22 @@ ALIAS (show_ip_bgp_flap_prefix_longer, DEFUN (show_ip_bgp_ipv4_prefix_longer, show_ip_bgp_ipv4_prefix_longer_cmd, - "show ip bgp ipv4 "BGP_SAFI_CMD_STR" A.B.C.D/M longer-prefixes", + "show ip bgp ipv4 (unicast|multicast) A.B.C.D/M longer-prefixes", SHOW_STR IP_STR BGP_STR "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" "IP prefix /, e.g., 35.0.0.0/8\n" "Display route and more specific routes\n") { - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[0]); - return bgp_show_prefix_longer (vty, NULL, argv[1], AFI_IP, safi, - bgp_show_type_prefix_longer); + if (strncmp (argv[0], "m", 1) == 0) + return bgp_show_prefix_longer (vty, NULL, argv[1], AFI_IP, SAFI_MULTICAST, + bgp_show_type_prefix_longer); + + return bgp_show_prefix_longer (vty, NULL, argv[1], AFI_IP, SAFI_UNICAST, + bgp_show_type_prefix_longer); } DEFUN (show_ip_bgp_flap_address, @@ -11816,30 +11939,54 @@ bgp_table_stats_vty (struct vty *vty, const char *name, vty_out (vty, "%% No such BGP instance exists%s", VTY_NEWLINE); return CMD_WARNING; } - afi = bgp_vty_afi_from_arg(afi_str); - if (afi == AFI_MAX) + if (strncmp (afi_str, "ipv", 3) == 0) + { + if (strncmp (afi_str, "ipv4", 4) == 0) + afi = AFI_IP; + else if (strncmp (afi_str, "ipv6", 4) == 0) + afi = AFI_IP6; + else + { + vty_out (vty, "%% Invalid address family %s%s", + afi_str, VTY_NEWLINE); + return CMD_WARNING; + } + if (strncmp (safi_str, "m", 1) == 0) + safi = SAFI_MULTICAST; + else if (strncmp (safi_str, "u", 1) == 0) + safi = SAFI_UNICAST; + else if (strncmp (safi_str, "e", 1) == 0) + safi = SAFI_ENCAP; + else if (strncmp (safi_str, "vpnv4", 5) == 0 || strncmp (safi_str, "vpnv6", 5) == 0) + safi = SAFI_MPLS_VPN; + else + { + vty_out (vty, "%% Invalid subsequent address family %s%s", + safi_str, VTY_NEWLINE); + return CMD_WARNING; + } + } + else { vty_out (vty, "%% Invalid address family \"%s\"%s", afi_str, VTY_NEWLINE); return CMD_WARNING; } - safi = bgp_vty_safi_from_arg(safi_str); - if (safi == SAFI_MAX) - { - vty_out (vty, "%% Invalid subsequent address family %s%s", - safi_str, VTY_NEWLINE); - return CMD_WARNING; - } return bgp_table_stats (vty, bgp, afi, safi); } DEFUN (show_bgp_statistics, show_bgp_statistics_cmd, - "show bgp "BGP_AFI_SAFI_CMD_STR" statistics", + "show bgp (ipv4|ipv6) (encap|multicast|unicast|vpn) statistics", SHOW_STR BGP_STR - BGP_INSTANCE_HELP_STR + "Address family\n" + "Address family\n" + "Address Family modifier\n" + "Address Family modifier\n" + "Address Family modifier\n" + "Address Family modifier\n" "BGP RIB advertisement statistics\n") { return bgp_table_stats_vty (vty, NULL, argv[0], argv[1]); @@ -11847,11 +11994,16 @@ DEFUN (show_bgp_statistics, DEFUN (show_bgp_statistics_view, show_bgp_statistics_view_cmd, - "show bgp " BGP_INSTANCE_CMD " "BGP_AFI_SAFI_CMD_STR" statistics", + "show bgp " BGP_INSTANCE_CMD " (ipv4|ipv6) (unicast|multicast|vpn|encap) statistics", SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR - BGP_AFI_SAFI_HELP_STR + "Address family\n" + "Address family\n" + "Address Family modifier\n" + "Address Family modifier\n" + "Address Family modifier\n" + "Address Family modifier\n" "BGP RIB advertisement statistics\n") { return bgp_table_stats_vty (vty, NULL, argv[1], argv[2]); @@ -12144,12 +12296,13 @@ DEFUN (show_bgp_instance_ipv6_neighbor_prefix_counts, DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts, show_ip_bgp_ipv4_neighbor_prefix_counts_cmd, - "show ip bgp ipv4 "BGP_SAFI_CMD_STR" neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}", + "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}", SHOW_STR IP_STR BGP_STR "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" "Detailed information on TCP and BGP neighbor connections\n" "Neighbor to display information about\n" "Neighbor to display information about\n" @@ -12164,9 +12317,36 @@ DEFUN (show_ip_bgp_ipv4_neighbor_prefix_counts, if (! peer) return CMD_WARNING; - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[0]); - return bgp_peer_counts (vty, peer, AFI_IP, safi, uj); + if (strncmp (argv[0], "m", 1) == 0) + return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MULTICAST, uj); + + return bgp_peer_counts (vty, peer, AFI_IP, SAFI_UNICAST, uj); +} + +DEFUN (show_ip_bgp_vpnv4_neighbor_prefix_counts, + show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd, + "show ip bgp vpnv4 all neighbors (A.B.C.D|X:X::X:X|WORD) prefix-counts {json}", + SHOW_STR + IP_STR + BGP_STR + "Address family\n" + "Address Family modifier\n" + "Address Family modifier\n" + "Detailed information on TCP and BGP neighbor connections\n" + "Neighbor to display information about\n" + "Neighbor to display information about\n" + "Neighbor on bgp configured interface\n" + "Display detailed prefix count information\n" + "JavaScript Object Notation\n") +{ + struct peer *peer; + u_char uj = use_json(argc, argv); + + peer = peer_lookup_in_view (vty, NULL, argv[0], uj); + if (! peer) + return CMD_WARNING; + + return bgp_peer_counts (vty, peer, AFI_IP, SAFI_MPLS_VPN, uj); } static void @@ -12494,12 +12674,13 @@ ALIAS (show_ip_bgp_instance_neighbor_advertised_route, "JavaScript Object Notation\n") DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route, show_ip_bgp_ipv4_neighbor_advertised_route_cmd, - "show ip bgp ipv4 "BGP_SAFI_CMD_STR" neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}", + "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes {json}", SHOW_STR IP_STR BGP_STR "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" "Detailed information on TCP and BGP neighbor connections\n" "Neighbor to display information about\n" "Neighbor to display information about\n" @@ -12509,8 +12690,6 @@ DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route, { struct peer *peer; const char *rmap_name = NULL; - safi_t safi; - u_char uj = use_json(argc, argv); peer = peer_lookup_in_view (vty, NULL, argv[1], uj); @@ -12520,18 +12699,21 @@ DEFUN (show_ip_bgp_ipv4_neighbor_advertised_route, if ((argc == 4) || (argc == 3 && argv[2] && strcmp(argv[2], "json") != 0)) rmap_name = argv[2]; - safi = bgp_vty_safi_from_arg(argv[0]); - return peer_adj_routes (vty, peer, AFI_IP, safi, 0, rmap_name, uj); + if (strncmp (argv[0], "m", 1) == 0) + return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 0, rmap_name, uj); + else + return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 0, rmap_name, uj); } ALIAS (show_ip_bgp_ipv4_neighbor_advertised_route, show_ip_bgp_ipv4_neighbor_advertised_route_rmap_cmd, - "show ip bgp ipv4 "BGP_SAFI_CMD_STR" neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}", + "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) advertised-routes route-map WORD {json}", SHOW_STR IP_STR BGP_STR "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" "Detailed information on TCP and BGP neighbor connections\n" "Neighbor to display information about\n" "Neighbor to display information about\n" @@ -12783,12 +12965,13 @@ ALIAS (show_ip_bgp_instance_neighbor_received_routes, DEFUN (show_ip_bgp_ipv4_neighbor_received_routes, show_ip_bgp_ipv4_neighbor_received_routes_cmd, - "show ip bgp ipv4 "BGP_SAFI_CMD_STR" neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}", + "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) received-routes {json}", SHOW_STR IP_STR BGP_STR "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" "Detailed information on TCP and BGP neighbor connections\n" "Neighbor to display information about\n" "Neighbor to display information about\n" @@ -12798,7 +12981,6 @@ DEFUN (show_ip_bgp_ipv4_neighbor_received_routes, { struct peer *peer; const char *rmap_name = NULL; - safi_t safi; u_char uj = use_json(argc, argv); peer = peer_lookup_in_view (vty, NULL, argv[1], uj); @@ -12808,18 +12990,21 @@ DEFUN (show_ip_bgp_ipv4_neighbor_received_routes, if (argc == 4 || (argc == 3 && argv[2] && strcmp(argv[2], "json") != 0)) rmap_name = argv[2]; - safi = bgp_vty_safi_from_arg(argv[0]); - return peer_adj_routes (vty, peer, AFI_IP, safi, 1, rmap_name, uj); + if (strncmp (argv[0], "m", 1) == 0) + return peer_adj_routes (vty, peer, AFI_IP, SAFI_MULTICAST, 1, rmap_name, uj); + else + return peer_adj_routes (vty, peer, AFI_IP, SAFI_UNICAST, 1, rmap_name, uj); } ALIAS (show_ip_bgp_ipv4_neighbor_received_routes, show_ip_bgp_ipv4_neighbor_received_routes_rmap_cmd, - "show ip bgp ipv4 "BGP_SAFI_CMD_STR" neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {json}", + "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) received-routes route-map WORD {json}", SHOW_STR IP_STR BGP_STR "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" "Detailed information on TCP and BGP neighbor connections\n" "Neighbor to display information about\n" "Neighbor to display information about\n" @@ -12829,11 +13014,14 @@ ALIAS (show_ip_bgp_ipv4_neighbor_received_routes, DEFUN (show_bgp_instance_afi_safi_neighbor_adv_recd_routes, show_bgp_instance_afi_safi_neighbor_adv_recd_routes_cmd, - "show bgp " BGP_INSTANCE_CMD " "BGP_AFI_SAFI_CMD_STR" neighbors (A.B.C.D|X:X::X:X|WORD) (advertised-routes|received-routes) {json}", + "show bgp " BGP_INSTANCE_CMD " (ipv4|ipv6) (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) (advertised-routes|received-routes) {json}", SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR - BGP_AFI_SAFI_HELP_STR + "Address family\n" + "Address family\n" + "Address family modifier\n" + "Address family modifier\n" "Detailed information on TCP and BGP neighbor connections\n" "Neighbor to display information about\n" "Neighbor to display information about\n" @@ -12853,8 +13041,8 @@ DEFUN (show_bgp_instance_afi_safi_neighbor_adv_recd_routes, if (! peer) return CMD_WARNING; - afi = bgp_vty_safi_from_arg(argv[2]); - safi = bgp_vty_safi_from_arg(argv[3]); + afi = (strncmp (argv[2], "ipv6", 4) == 0) ? AFI_IP6 : AFI_IP; + safi = (strncmp (argv[3], "m", 1) == 0) ? SAFI_MULTICAST : SAFI_UNICAST; in = (strncmp (argv[5], "r", 1) == 0) ? 1 : 0; return peer_adj_routes (vty, peer, afi, safi, in, NULL, uj); @@ -12949,12 +13137,13 @@ DEFUN (show_ip_bgp_neighbor_received_prefix_filter, DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter, show_ip_bgp_ipv4_neighbor_received_prefix_filter_cmd, - "show ip bgp ipv4 "BGP_SAFI_CMD_STR" neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}", + "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) received prefix-filter {json}", SHOW_STR IP_STR BGP_STR "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" "Detailed information on TCP and BGP neighbor connections\n" "Neighbor to display information about\n" "Neighbor to display information about\n" @@ -13011,16 +13200,38 @@ DEFUN (show_ip_bgp_ipv4_neighbor_received_prefix_filter, } } + if (strncmp (argv[0], "m", 1) == 0) { - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[0]); - sprintf (name, "%s.%d.%d", peer->host, AFI_IP, safi); + sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_MULTICAST); count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name, uj); if (count) { if (!uj) - vty_out (vty, "Address family: %s%s", - afi_safi_print (AFI_IP, safi), VTY_NEWLINE); + vty_out (vty, "Address family: IPv4 Multicast%s", VTY_NEWLINE); + prefix_bgp_show_prefix_list (vty, AFI_IP, name, uj); + } + else + { + if (uj) + { + json_object *json_no = NULL; + json_no = json_object_new_object(); + json_object_boolean_true_add(json_no, "noFuntionalOutput"); + vty_out (vty, "%s%s", json_object_to_json_string(json_no), VTY_NEWLINE); + json_object_free(json_no); + } + else + vty_out (vty, "No functional output%s", VTY_NEWLINE); + } + } + else + { + sprintf (name, "%s.%d.%d", peer->host, AFI_IP, SAFI_UNICAST); + count = prefix_bgp_show_prefix_list (NULL, AFI_IP, name, uj); + if (count) + { + if (!uj) + vty_out (vty, "Address family: IPv4 Unicast%s", VTY_NEWLINE); prefix_bgp_show_prefix_list (vty, AFI_IP, name, uj); } else @@ -13449,12 +13660,13 @@ DEFUN (show_ip_bgp_neighbor_damp, DEFUN (show_ip_bgp_ipv4_neighbor_routes, show_ip_bgp_ipv4_neighbor_routes_cmd, - "show ip bgp ipv4 "BGP_SAFI_CMD_STR" neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}", + "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) routes {json}", SHOW_STR IP_STR BGP_STR "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" "Detailed information on TCP and BGP neighbor connections\n" "Neighbor to display information about\n" "Neighbor to display information about\n" @@ -13463,16 +13675,18 @@ DEFUN (show_ip_bgp_ipv4_neighbor_routes, "JavaScript Object Notation\n") { struct peer *peer; - safi_t safi; u_char uj = use_json(argc, argv); peer = peer_lookup_in_view (vty, NULL, argv[1], uj); if (! peer) return CMD_WARNING; - safi = bgp_vty_safi_from_arg(argv[0]); - return bgp_show_neighbor_route (vty, peer, AFI_IP, safi, - bgp_show_type_neighbor, uj); + if (strncmp (argv[0], "m", 1) == 0) + return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_MULTICAST, + bgp_show_type_neighbor, uj); + + return bgp_show_neighbor_route (vty, peer, AFI_IP, SAFI_UNICAST, + bgp_show_type_neighbor, uj); } #ifdef HAVE_IPV6 @@ -14678,6 +14892,8 @@ bgp_route_init (void) install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_pathtype_cmd); install_element (VIEW_NODE, &show_ip_bgp_ipv4_route_cmd); install_element (VIEW_NODE, &show_bgp_ipv4_safi_route_cmd); + install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_route_cmd); + install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_route_cmd); install_element (VIEW_NODE, &show_ip_bgp_prefix_cmd); install_element (VIEW_NODE, &show_ip_bgp_instance_prefix_cmd); install_element (VIEW_NODE, &show_ip_bgp_ipv4_prefix_cmd); @@ -14686,6 +14902,8 @@ bgp_route_init (void) install_element (VIEW_NODE, &show_bgp_ipv4_safi_prefix_cmd); install_element (VIEW_NODE, &show_ip_bgp_prefix_pathtype_cmd); install_element (VIEW_NODE, &show_ip_bgp_instance_prefix_pathtype_cmd); + install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_prefix_cmd); + install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_prefix_cmd); install_element (VIEW_NODE, &show_ip_bgp_regexp_cmd); install_element (VIEW_NODE, &show_ip_bgp_ipv4_regexp_cmd); @@ -14790,6 +15008,7 @@ bgp_route_init (void) install_element (ENABLE_NODE, &show_ip_bgp_neighbor_prefix_counts_cmd); install_element (ENABLE_NODE, &show_ip_bgp_instance_neighbor_prefix_counts_cmd); install_element (ENABLE_NODE, &show_ip_bgp_ipv4_neighbor_prefix_counts_cmd); + install_element (ENABLE_NODE, &show_ip_bgp_vpnv4_neighbor_prefix_counts_cmd); #ifdef HAVE_IPV6 install_element (ENABLE_NODE, &show_bgp_ipv6_neighbor_prefix_counts_cmd); install_element (ENABLE_NODE, &show_bgp_instance_ipv6_neighbor_prefix_counts_cmd); diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c index d0cce4a955..ea42cb57c9 100644 --- a/bgpd/bgp_routemap.c +++ b/bgpd/bgp_routemap.c @@ -2342,6 +2342,63 @@ struct route_map_rule_cmd route_set_ipv6_nexthop_peer_cmd = #endif /* HAVE_IPV6 */ +/* `set vpnv4 nexthop A.B.C.D' */ + +static route_map_result_t +route_set_vpnv4_nexthop (void *rule, struct prefix *prefix, + route_map_object_t type, void *object) +{ + struct in_addr *address; + struct bgp_info *bgp_info; + + if (type == RMAP_BGP) + { + /* Fetch routemap's rule information. */ + address = rule; + bgp_info = object; + + /* Set next hop value. */ + (bgp_attr_extra_get (bgp_info->attr))->mp_nexthop_global_in = *address; + (bgp_attr_extra_get (bgp_info->attr))->mp_nexthop_len = 4; + } + + return RMAP_OKAY; +} + +static void * +route_set_vpnv4_nexthop_compile (const char *arg) +{ + int ret; + struct in_addr *address; + + address = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (struct in_addr)); + + ret = inet_aton (arg, address); + + if (ret == 0) + { + XFREE (MTYPE_ROUTE_MAP_COMPILED, address); + return NULL; + } + + return address; +} + +static void +route_set_vpnv4_nexthop_free (void *rule) +{ + XFREE (MTYPE_ROUTE_MAP_COMPILED, rule); +} + +/* Route map commands for ip nexthop set. */ +struct route_map_rule_cmd route_set_vpnv4_nexthop_cmd = +{ + "vpnv4 next-hop", + route_set_vpnv4_nexthop, + route_set_vpnv4_nexthop_compile, + route_set_vpnv4_nexthop_free +}; + /* `set originator-id' */ /* For origin set. */ @@ -4443,6 +4500,40 @@ ALIAS (no_set_ipv6_nexthop_local, "IPv6 address of next hop\n") #endif /* HAVE_IPV6 */ +DEFUN (set_vpnv4_nexthop, + set_vpnv4_nexthop_cmd, + "set vpnv4 next-hop A.B.C.D", + SET_STR + "VPNv4 information\n" + "VPNv4 next-hop address\n" + "IP address of next hop\n") +{ + return bgp_route_set_add (vty, vty->index, "vpnv4 next-hop", argv[0]); +} + +DEFUN (no_set_vpnv4_nexthop, + no_set_vpnv4_nexthop_cmd, + "no set vpnv4 next-hop", + NO_STR + SET_STR + "VPNv4 information\n" + "VPNv4 next-hop address\n") +{ + if (argc == 0) + return bgp_route_set_delete (vty, vty->index, "vpnv4 next-hop", NULL); + + return bgp_route_set_delete (vty, vty->index, "vpnv4 next-hop", argv[0]); +} + +ALIAS (no_set_vpnv4_nexthop, + no_set_vpnv4_nexthop_val_cmd, + "no set vpnv4 next-hop A.B.C.D", + NO_STR + SET_STR + "VPNv4 information\n" + "VPNv4 next-hop address\n" + "IP address of next hop\n") + DEFUN (set_originator_id, set_originator_id_cmd, "set originator-id A.B.C.D", @@ -4513,6 +4604,7 @@ bgp_route_map_init (void) route_map_install_set (&route_set_aggregator_as_cmd); route_map_install_set (&route_set_community_cmd); route_map_install_set (&route_set_community_delete_cmd); + route_map_install_set (&route_set_vpnv4_nexthop_cmd); route_map_install_set (&route_set_originator_id_cmd); route_map_install_set (&route_set_ecommunity_rt_cmd); route_map_install_set (&route_set_ecommunity_soo_cmd); @@ -4618,6 +4710,9 @@ bgp_route_map_init (void) install_element (RMAP_NODE, &set_ecommunity_soo_cmd); install_element (RMAP_NODE, &no_set_ecommunity_soo_cmd); install_element (RMAP_NODE, &no_set_ecommunity_soo_val_cmd); + install_element (RMAP_NODE, &set_vpnv4_nexthop_cmd); + install_element (RMAP_NODE, &no_set_vpnv4_nexthop_cmd); + install_element (RMAP_NODE, &no_set_vpnv4_nexthop_val_cmd); install_element (RMAP_NODE, &set_originator_id_cmd); install_element (RMAP_NODE, &no_set_originator_id_cmd); install_element (RMAP_NODE, &no_set_originator_id_val_cmd); diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index a27a5f6b26..b435543e39 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -107,33 +107,22 @@ bgp_node_safi (struct vty *vty) return safi; } -/* supports (ipv4|ipv6) */ -afi_t -bgp_vty_afi_from_arg(const char *afi_str) -{ - afi_t afi = AFI_MAX; /* unknown */ - if (!strcmp(afi_str, "ipv4")) { - afi = AFI_IP; - } -#ifdef HAVE_IPV6 - else if (!strcmp(afi_str, "ipv6")) { - afi = AFI_IP6; - } -#endif /* HAVE_IPV6 */ - return afi; -} - int bgp_parse_afi(const char *str, afi_t *afi) { - *afi = bgp_vty_afi_from_arg(str); - if (*afi != AFI_MAX) - return 0; - else + if (!strcmp(str, "ipv4")) { + *afi = AFI_IP; + return 0; + } +#ifdef HAVE_IPV6 + if (!strcmp(str, "ipv6")) { + *afi = AFI_IP6; + return 0; + } +#endif /* HAVE_IPV6 */ return -1; } - /* supports (unicast|multicast|vpn|encap) */ safi_t bgp_vty_safi_from_arg(const char *safi_str) @@ -146,7 +135,7 @@ bgp_vty_safi_from_arg(const char *safi_str) else if (strncmp (safi_str, "e", 1) == 0) safi = SAFI_ENCAP; else if (strncmp (safi_str, "v", 1) == 0) - safi = SAFI_MPLS_VPN; + safi = SAFI_MPLS_VPN; return safi; } @@ -370,8 +359,10 @@ bgp_clear_vty_error (struct vty *vty, struct peer *peer, afi_t afi, { case BGP_ERR_AF_UNCONFIGURED: vty_out (vty, - "%%BGP: Enable %s address family for the neighbor %s%s", - afi_safi_print(afi, safi), peer->host, VTY_NEWLINE); + "%%BGP: Enable %s %s address family for the neighbor %s%s", + afi == AFI_IP6 ? "IPv6" : safi == SAFI_MPLS_VPN ? "VPNv4" : "IPv4", + safi == SAFI_MULTICAST ? "Multicast" : "Unicast", + peer->host, VTY_NEWLINE); break; case BGP_ERR_SOFT_RECONFIG_UNCONFIGURED: vty_out (vty, "%%BGP: Inbound soft reconfig for %s not possible as it%s has neither refresh capability, nor inbound soft reconfig%s", peer->host, VTY_NEWLINE, VTY_NEWLINE); @@ -6066,10 +6057,9 @@ DEFUN (address_family_ipv4, DEFUN (address_family_ipv4_safi, address_family_ipv4_safi_cmd, - "address-family ipv4 "BGP_SAFI_CMD_STR, + "address-family ipv4 (unicast|multicast)", "Enter Address Family command mode\n" - "Address Family\n" - BGP_SAFI_HELP_STR) + AFI_SAFI_STR) { switch (bgp_vty_safi_from_arg(argv[0])) { @@ -6103,28 +6093,16 @@ DEFUN (address_family_ipv6, DEFUN (address_family_ipv6_safi, address_family_ipv6_safi_cmd, - "address-family ipv6 "BGP_SAFI_CMD_STR, + "address-family ipv6 (unicast|multicast)", "Enter Address Family command mode\n" - "Address Family\n" - BGP_SAFI_HELP_STR) + "Address family\n" + "Address Family modifier\n" + "Address Family modifier\n") { - int idx_safi = 0; - switch (bgp_vty_safi_from_arg(argv[idx_safi])) - { - case SAFI_MULTICAST: - vty->node = BGP_IPV6M_NODE; - break; - case SAFI_ENCAP: - vty->node = BGP_ENCAPV6_NODE; - break; - case SAFI_MPLS_VPN: - vty->node = BGP_VPNV6_NODE; - break; - case SAFI_UNICAST: - default: - vty->node = BGP_IPV6_NODE; - break; - } + if (strncmp (argv[0], "m", 1) == 0) + vty->node = BGP_IPV6M_NODE; + else + vty->node = BGP_IPV6_NODE; return CMD_SUCCESS; } @@ -6139,6 +6117,13 @@ DEFUN (address_family_vpnv4, return CMD_SUCCESS; } +ALIAS (address_family_vpnv4, + address_family_vpnv4_unicast_cmd, + "address-family vpnv4 unicast", + "Enter Address Family command mode\n" + "Address family\n" + "Address Family Modifier\n") + DEFUN (address_family_vpnv6, address_family_vpnv6_cmd, "address-family vpnv6", @@ -6149,6 +6134,13 @@ DEFUN (address_family_vpnv6, return CMD_SUCCESS; } +ALIAS (address_family_vpnv6, + address_family_vpnv6_unicast_cmd, + "address-family vpnv6 unicast", + "Enter Address Family command mode\n" + "Address family\n" + "Address Family Modifier\n") + DEFUN (address_family_encap, address_family_encap_cmd, "address-family encap", @@ -6659,63 +6651,125 @@ ALIAS (clear_ip_bgp_all_soft_out, DEFUN (clear_ip_bgp_all_ipv4_soft_out, clear_ip_bgp_all_ipv4_soft_out_cmd, - "clear ip bgp * ipv4 "BGP_SAFI_CMD_STR" soft out", + "clear ip bgp * ipv4 (unicast|multicast) soft out", CLEAR_STR IP_STR BGP_STR "Clear all peers\n" "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" BGP_SOFT_STR BGP_SOFT_OUT_STR) { - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[0]); - return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_all, - BGP_CLEAR_SOFT_OUT, NULL); + if (strncmp (argv[0], "m", 1) == 0) + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all, + BGP_CLEAR_SOFT_OUT, NULL); + + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all, + BGP_CLEAR_SOFT_OUT, NULL); } DEFUN (clear_ip_bgp_instance_all_ipv4_soft_out, clear_ip_bgp_instance_all_ipv4_soft_out_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " * ipv4 "BGP_SAFI_CMD_STR" soft out", + "clear ip bgp " BGP_INSTANCE_CMD " * ipv4 (unicast|multicast) soft out", CLEAR_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR "Clear all peers\n" "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" BGP_SOFT_OUT_STR) { - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[2]); - return bgp_clear_vty (vty, argv[1], AFI_IP, safi, clear_all, + if (strncmp (argv[2], "m", 1) == 0) + return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_all, + BGP_CLEAR_SOFT_OUT, NULL); + + return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all, BGP_CLEAR_SOFT_OUT, NULL); } ALIAS (clear_ip_bgp_all_ipv4_soft_out, clear_ip_bgp_all_ipv4_out_cmd, - "clear ip bgp * ipv4 "BGP_SAFI_CMD_STR" out", + "clear ip bgp * ipv4 (unicast|multicast) out", CLEAR_STR IP_STR BGP_STR "Clear all peers\n" "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" BGP_SOFT_OUT_STR) ALIAS (clear_ip_bgp_instance_all_ipv4_soft_out, clear_ip_bgp_instance_all_ipv4_out_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " * ipv4 "BGP_SAFI_CMD_STR" out", + "clear ip bgp " BGP_INSTANCE_CMD " * ipv4 (unicast|multicast) out", CLEAR_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR "Clear all peers\n" "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" BGP_SOFT_OUT_STR) +DEFUN (clear_ip_bgp_all_vpnv4_soft_out, + clear_ip_bgp_all_vpnv4_soft_out_cmd, + "clear ip bgp * vpnv4 unicast soft out", + CLEAR_STR + IP_STR + BGP_STR + "Clear all peers\n" + "Address family\n" + "Address Family Modifier\n" + BGP_SOFT_STR + BGP_SOFT_OUT_STR) +{ + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all, + BGP_CLEAR_SOFT_OUT, NULL); +} + +ALIAS (clear_ip_bgp_all_vpnv4_soft_out, + clear_ip_bgp_all_vpnv4_out_cmd, + "clear ip bgp * vpnv4 unicast out", + CLEAR_STR + IP_STR + BGP_STR + "Clear all peers\n" + "Address family\n" + "Address Family Modifier\n" + BGP_SOFT_OUT_STR) + +DEFUN (clear_ip_bgp_all_encap_soft_out, + clear_ip_bgp_all_encap_soft_out_cmd, + "clear ip bgp * encap unicast soft out", + CLEAR_STR + IP_STR + BGP_STR + "Clear all peers\n" + "Address family\n" + "Address Family Modifier\n" + "Soft reconfig\n" + "Soft reconfig outbound update\n") +{ + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_all, + BGP_CLEAR_SOFT_OUT, NULL); +} + +ALIAS (clear_ip_bgp_all_encap_soft_out, + clear_ip_bgp_all_encap_out_cmd, + "clear ip bgp * encap unicast out", + CLEAR_STR + IP_STR + BGP_STR + "Clear all peers\n" + "Address family\n" + "Address Family Modifier\n" + "Soft reconfig outbound update\n") + DEFUN (clear_bgp_all_soft_out, clear_bgp_all_soft_out_cmd, "clear bgp * soft out", @@ -6802,7 +6856,7 @@ ALIAS (clear_bgp_all_soft_out, DEFUN (clear_bgp_ipv6_safi_prefix, clear_bgp_ipv6_safi_prefix_cmd, - "clear bgp ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", + "clear bgp ipv6 (unicast|multicast) prefix X:X::X:X/M", CLEAR_STR BGP_STR "Address family\n" @@ -6810,14 +6864,15 @@ DEFUN (clear_bgp_ipv6_safi_prefix, "Clear bestpath and re-advertise\n" "IPv6 prefix /, e.g., 3ffe::/16\n") { - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[0]); - return bgp_clear_prefix (vty, NULL, argv[1], AFI_IP6, safi, NULL); + if (strncmp (argv[0], "m", 1) == 0) + return bgp_clear_prefix (vty, NULL, argv[1], AFI_IP6, SAFI_MULTICAST, NULL); + else + return bgp_clear_prefix (vty, NULL, argv[1], AFI_IP6, SAFI_UNICAST, NULL); } DEFUN (clear_bgp_instance_ipv6_safi_prefix, clear_bgp_instance_ipv6_safi_prefix_cmd, - "clear bgp " BGP_INSTANCE_CMD " ipv6 "BGP_SAFI_CMD_STR" prefix X:X::X:X/M", + "clear bgp " BGP_INSTANCE_CMD " ipv6 (unicast|multicast) prefix X:X::X:X/M", CLEAR_STR BGP_STR BGP_INSTANCE_HELP_STR @@ -6826,9 +6881,10 @@ DEFUN (clear_bgp_instance_ipv6_safi_prefix, "Clear bestpath and re-advertise\n" "IPv6 prefix /, e.g., 3ffe::/16\n") { - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[2]); - return bgp_clear_prefix (vty, argv[1], argv[3], AFI_IP6, safi, NULL); + if (strncmp (argv[2], "m", 1) == 0) + return bgp_clear_prefix (vty, argv[1], argv[3], AFI_IP6, SAFI_MULTICAST, NULL); + else + return bgp_clear_prefix (vty, argv[1], argv[3], AFI_IP6, SAFI_UNICAST, NULL); } DEFUN (clear_ip_bgp_peer_soft_out, @@ -6885,26 +6941,29 @@ ALIAS (clear_ip_bgp_peer_soft_out, DEFUN (clear_ip_bgp_peer_ipv4_soft_out, clear_ip_bgp_peer_ipv4_soft_out_cmd, - "clear ip bgp (A.B.C.D|WORD) ipv4 "BGP_SAFI_CMD_STR" soft out", + "clear ip bgp (A.B.C.D|WORD) ipv4 (unicast|multicast) soft out", CLEAR_STR IP_STR BGP_STR "BGP neighbor address to clear\n" "BGP neighbor on interface to clear\n" "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" BGP_SOFT_STR BGP_SOFT_OUT_STR) { - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[1]); - return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_peer, - BGP_CLEAR_SOFT_OUT, argv[0]); + if (strncmp (argv[1], "m", 1) == 0) + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer, + BGP_CLEAR_SOFT_OUT, argv[0]); + + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer, + BGP_CLEAR_SOFT_OUT, argv[0]); } DEFUN (clear_ip_bgp_instance_peer_ipv4_soft_out, clear_ip_bgp_instance_peer_ipv4_soft_out_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) ipv4 "BGP_SAFI_CMD_STR" soft out", + "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) ipv4 (unicast|multicast) soft out", CLEAR_STR IP_STR BGP_STR @@ -6912,31 +6971,35 @@ DEFUN (clear_ip_bgp_instance_peer_ipv4_soft_out, "BGP neighbor address to clear\n" "BGP neighbor on interface to clear\n" "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" BGP_SOFT_STR BGP_SOFT_OUT_STR) { - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[3]); - return bgp_clear_vty (vty, argv[1], AFI_IP, safi, clear_peer, - BGP_CLEAR_SOFT_OUT, argv[2]); + if (strncmp (argv[3], "m", 1) == 0) + return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_peer, + BGP_CLEAR_SOFT_OUT, argv[2]); + + return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_peer, + BGP_CLEAR_SOFT_OUT, argv[2]); } ALIAS (clear_ip_bgp_peer_ipv4_soft_out, clear_ip_bgp_peer_ipv4_out_cmd, - "clear ip bgp (A.B.C.D|WORD) ipv4 "BGP_SAFI_CMD_STR" out", + "clear ip bgp (A.B.C.D|WORD) ipv4 (unicast|multicast) out", CLEAR_STR IP_STR BGP_STR "BGP neighbor address to clear\n" "BGP neighbor on interface to clear\n" "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" BGP_SOFT_OUT_STR) ALIAS (clear_ip_bgp_instance_peer_ipv4_soft_out, clear_ip_bgp_instance_peer_ipv4_out_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) ipv4 "BGP_SAFI_CMD_STR" out", + "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) ipv4 (unicast|multicast) out", CLEAR_STR IP_STR BGP_STR @@ -6944,9 +7007,67 @@ ALIAS (clear_ip_bgp_instance_peer_ipv4_soft_out, "BGP neighbor address to clear\n" "BGP neighbor on interface to clear\n" "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" BGP_SOFT_OUT_STR) +/* NOTE: WORD peers have not been tested for vpnv4 */ +DEFUN (clear_ip_bgp_peer_vpnv4_soft_out, + clear_ip_bgp_peer_vpnv4_soft_out_cmd, + "clear ip bgp (A.B.C.D|WORD) vpnv4 unicast soft out", + CLEAR_STR + IP_STR + BGP_STR + "BGP neighbor address to clear\n" + "BGP neighbor on interface to clear\n" + "Address family\n" + "Address Family Modifier\n" + BGP_SOFT_STR + BGP_SOFT_OUT_STR) +{ + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer, + BGP_CLEAR_SOFT_OUT, argv[0]); +} + +ALIAS (clear_ip_bgp_peer_vpnv4_soft_out, + clear_ip_bgp_peer_vpnv4_out_cmd, + "clear ip bgp (A.B.C.D|WORD) vpnv4 unicast out", + CLEAR_STR + IP_STR + BGP_STR + "BGP neighbor address to clear\n" + "BGP neighbor on interface to clear\n" + "Address family\n" + "Address Family Modifier\n" + BGP_SOFT_OUT_STR) + +DEFUN (clear_ip_bgp_peer_encap_soft_out, + clear_ip_bgp_peer_encap_soft_out_cmd, + "clear ip bgp A.B.C.D encap unicast soft out", + CLEAR_STR + IP_STR + BGP_STR + "BGP neighbor address to clear\n" + "Address family\n" + "Address Family Modifier\n" + "Soft reconfig\n" + "Soft reconfig outbound update\n") +{ + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_peer, + BGP_CLEAR_SOFT_OUT, argv[0]); +} + +ALIAS (clear_ip_bgp_peer_encap_soft_out, + clear_ip_bgp_peer_encap_out_cmd, + "clear ip bgp A.B.C.D encap unicast out", + CLEAR_STR + IP_STR + BGP_STR + "BGP neighbor address to clear\n" + "Address family\n" + "Address Family Modifier\n" + "Soft reconfig outbound update\n") + DEFUN (clear_bgp_peer_soft_out, clear_bgp_peer_soft_out_cmd, "clear bgp (A.B.C.D|X:X::X:X|WORD) soft out", @@ -7101,26 +7222,29 @@ ALIAS (clear_ip_bgp_peer_group_soft_out, DEFUN (clear_ip_bgp_peer_group_ipv4_soft_out, clear_ip_bgp_peer_group_ipv4_soft_out_cmd, - "clear ip bgp peer-group WORD ipv4 "BGP_SAFI_CMD_STR" soft out", + "clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft out", CLEAR_STR IP_STR BGP_STR "Clear all members of peer-group\n" "BGP peer-group name\n" "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" BGP_SOFT_STR BGP_SOFT_OUT_STR) { - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[1]); - return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_group, - BGP_CLEAR_SOFT_OUT, argv[0]); + if (strncmp (argv[1], "m", 1) == 0) + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group, + BGP_CLEAR_SOFT_OUT, argv[0]); + + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group, + BGP_CLEAR_SOFT_OUT, argv[0]); } DEFUN (clear_ip_bgp_instance_peer_group_ipv4_soft_out, clear_ip_bgp_instance_peer_group_ipv4_soft_out_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD ipv4 "BGP_SAFI_CMD_STR" soft out", + "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD ipv4 (unicast|multicast) soft out", CLEAR_STR IP_STR BGP_STR @@ -7128,31 +7252,35 @@ DEFUN (clear_ip_bgp_instance_peer_group_ipv4_soft_out, "Clear all members of peer-group\n" "BGP peer-group name\n" "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" BGP_SOFT_STR BGP_SOFT_OUT_STR) { - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[3]); - return bgp_clear_vty (vty, argv[1], AFI_IP, safi, clear_group, - BGP_CLEAR_SOFT_OUT, argv[2]); + if (strncmp (argv[3], "m", 1) == 0) + return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_group, + BGP_CLEAR_SOFT_OUT, argv[2]); + + return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_group, + BGP_CLEAR_SOFT_OUT, argv[2]); } ALIAS (clear_ip_bgp_peer_group_ipv4_soft_out, clear_ip_bgp_peer_group_ipv4_out_cmd, - "clear ip bgp peer-group WORD ipv4 "BGP_SAFI_CMD_STR" out", + "clear ip bgp peer-group WORD ipv4 (unicast|multicast) out", CLEAR_STR IP_STR BGP_STR "Clear all members of peer-group\n" "BGP peer-group name\n" "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" BGP_SOFT_OUT_STR) ALIAS (clear_ip_bgp_instance_peer_group_ipv4_soft_out, clear_ip_bgp_instance_peer_group_ipv4_out_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD ipv4 "BGP_SAFI_CMD_STR" out", + "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD ipv4 (unicast|multicast) out", CLEAR_STR IP_STR BGP_STR @@ -7160,7 +7288,8 @@ ALIAS (clear_ip_bgp_instance_peer_group_ipv4_soft_out, "Clear all members of peer-group\n" "BGP peer-group name\n" "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" BGP_SOFT_OUT_STR) DEFUN (clear_bgp_peer_group_soft_out, @@ -7305,62 +7434,70 @@ ALIAS (clear_ip_bgp_external_soft_out, DEFUN (clear_ip_bgp_external_ipv4_soft_out, clear_ip_bgp_external_ipv4_soft_out_cmd, - "clear ip bgp external ipv4 "BGP_SAFI_CMD_STR" soft out", + "clear ip bgp external ipv4 (unicast|multicast) soft out", CLEAR_STR IP_STR BGP_STR "Clear all external peers\n" "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" BGP_SOFT_STR BGP_SOFT_OUT_STR) { - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[0]); - return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_external, - BGP_CLEAR_SOFT_OUT, NULL); + if (strncmp (argv[0], "m", 1) == 0) + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external, + BGP_CLEAR_SOFT_OUT, NULL); + + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external, + BGP_CLEAR_SOFT_OUT, NULL); } DEFUN (clear_ip_bgp_instance_external_ipv4_soft_out, clear_ip_bgp_instance_external_ipv4_soft_out_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " external ipv4 "BGP_SAFI_CMD_STR" soft out", + "clear ip bgp " BGP_INSTANCE_CMD " external ipv4 (unicast|multicast) soft out", CLEAR_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR "Clear all external peers\n" "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" BGP_SOFT_STR BGP_SOFT_OUT_STR) { - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[2]); - return bgp_clear_vty (vty, argv[1], AFI_IP, safi, clear_external, - BGP_CLEAR_SOFT_OUT, NULL); + if (strncmp (argv[2], "m", 1) == 0) + return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_external, + BGP_CLEAR_SOFT_OUT, NULL); + + return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_external, + BGP_CLEAR_SOFT_OUT, NULL); } ALIAS (clear_ip_bgp_external_ipv4_soft_out, clear_ip_bgp_external_ipv4_out_cmd, - "clear ip bgp external ipv4 "BGP_SAFI_CMD_STR" out", + "clear ip bgp external ipv4 (unicast|multicast) out", CLEAR_STR IP_STR BGP_STR "Clear all external peers\n" "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" BGP_SOFT_OUT_STR) ALIAS (clear_ip_bgp_instance_external_ipv4_soft_out, clear_ip_bgp_instance_external_ipv4_out_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " external ipv4 "BGP_SAFI_CMD_STR" out", + "clear ip bgp " BGP_INSTANCE_CMD " external ipv4 (unicast|multicast) out", CLEAR_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR "Clear all external peers\n" "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" BGP_SOFT_OUT_STR) DEFUN (clear_bgp_external_soft_out, @@ -7497,64 +7634,126 @@ ALIAS (clear_ip_bgp_as_soft_out, DEFUN (clear_ip_bgp_as_ipv4_soft_out, clear_ip_bgp_as_ipv4_soft_out_cmd, - "clear ip bgp " CMD_AS_RANGE " ipv4 "BGP_SAFI_CMD_STR" soft out", + "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) soft out", CLEAR_STR IP_STR BGP_STR "Clear peers with the AS number\n" "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" BGP_SOFT_STR BGP_SOFT_OUT_STR) { - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[1]); - return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_as, - BGP_CLEAR_SOFT_OUT, argv[0]); + if (strncmp (argv[1], "m", 1) == 0) + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as, + BGP_CLEAR_SOFT_OUT, argv[0]); + + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as, + BGP_CLEAR_SOFT_OUT, argv[0]); } DEFUN (clear_ip_bgp_instance_as_ipv4_soft_out, clear_ip_bgp_instance_as_ipv4_soft_out_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " ipv4 "BGP_SAFI_CMD_STR" soft out", + "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " ipv4 (unicast|multicast) soft out", CLEAR_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR "Clear peers with the AS number\n" "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" BGP_SOFT_STR BGP_SOFT_OUT_STR) { - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[3]); - return bgp_clear_vty (vty, argv[1], AFI_IP, safi, clear_as, - BGP_CLEAR_SOFT_OUT, argv[2]); + if (strncmp (argv[3], "m", 1) == 0) + return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_as, + BGP_CLEAR_SOFT_OUT, argv[2]); + + return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_as, + BGP_CLEAR_SOFT_OUT, argv[2]); } ALIAS (clear_ip_bgp_as_ipv4_soft_out, clear_ip_bgp_as_ipv4_out_cmd, - "clear ip bgp " CMD_AS_RANGE " ipv4 "BGP_SAFI_CMD_STR" out", + "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) out", CLEAR_STR IP_STR BGP_STR "Clear peers with the AS number\n" "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" BGP_SOFT_OUT_STR) ALIAS (clear_ip_bgp_instance_as_ipv4_soft_out, clear_ip_bgp_instance_as_ipv4_out_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " ipv4 "BGP_SAFI_CMD_STR" out", + "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " ipv4 (unicast|multicast) out", CLEAR_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR "Clear peers with the AS number\n" "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" BGP_SOFT_OUT_STR) +DEFUN (clear_ip_bgp_as_vpnv4_soft_out, + clear_ip_bgp_as_vpnv4_soft_out_cmd, + "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast soft out", + CLEAR_STR + IP_STR + BGP_STR + "Clear peers with the AS number\n" + "Address family\n" + "Address Family modifier\n" + BGP_SOFT_STR + BGP_SOFT_OUT_STR) +{ + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as, + BGP_CLEAR_SOFT_OUT, argv[0]); +} + +ALIAS (clear_ip_bgp_as_vpnv4_soft_out, + clear_ip_bgp_as_vpnv4_out_cmd, + "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast out", + CLEAR_STR + IP_STR + BGP_STR + "Clear peers with the AS number\n" + "Address family\n" + "Address Family modifier\n" + BGP_SOFT_OUT_STR) + +DEFUN (clear_ip_bgp_as_encap_soft_out, + clear_ip_bgp_as_encap_soft_out_cmd, + "clear ip bgp " CMD_AS_RANGE " encap unicast soft out", + CLEAR_STR + IP_STR + BGP_STR + "Clear peers with the AS number\n" + "Address family\n" + "Address Family modifier\n" + "Soft reconfig\n" + "Soft reconfig outbound update\n") +{ + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_as, + BGP_CLEAR_SOFT_OUT, argv[0]); +} + +ALIAS (clear_ip_bgp_as_encap_soft_out, + clear_ip_bgp_as_encap_out_cmd, + "clear ip bgp " CMD_AS_RANGE " encap unicast out", + CLEAR_STR + IP_STR + BGP_STR + "Clear peers with the AS number\n" + "Address family\n" + "Address Family modifier\n" + "Soft reconfig outbound update\n") + DEFUN (clear_bgp_as_soft_out, clear_bgp_as_soft_out_cmd, "clear bgp " CMD_AS_RANGE " soft out", @@ -7708,82 +7907,147 @@ DEFUN (clear_ip_bgp_all_in_prefix_filter, DEFUN (clear_ip_bgp_all_ipv4_soft_in, clear_ip_bgp_all_ipv4_soft_in_cmd, - "clear ip bgp * ipv4 "BGP_SAFI_CMD_STR" soft in", + "clear ip bgp * ipv4 (unicast|multicast) soft in", CLEAR_STR IP_STR BGP_STR "Clear all peers\n" "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" BGP_SOFT_STR BGP_SOFT_IN_STR) { - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[0]); - return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_all, - BGP_CLEAR_SOFT_IN, NULL); + if (strncmp (argv[0], "m", 1) == 0) + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all, + BGP_CLEAR_SOFT_IN, NULL); + + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all, + BGP_CLEAR_SOFT_IN, NULL); } DEFUN (clear_ip_bgp_instance_all_ipv4_soft_in, clear_ip_bgp_instance_all_ipv4_soft_in_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " * ipv4 "BGP_SAFI_CMD_STR" soft in", + "clear ip bgp " BGP_INSTANCE_CMD " * ipv4 (unicast|multicast) soft in", CLEAR_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR "Clear all peers\n" "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" BGP_SOFT_STR BGP_SOFT_IN_STR) { - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[2]); - return bgp_clear_vty (vty, argv[1], AFI_IP, safi, clear_all, + if (strncmp (argv[2], "m", 1) == 0) + return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_all, + BGP_CLEAR_SOFT_IN, NULL); + + return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_all, BGP_CLEAR_SOFT_IN, NULL); } ALIAS (clear_ip_bgp_all_ipv4_soft_in, clear_ip_bgp_all_ipv4_in_cmd, - "clear ip bgp * ipv4 "BGP_SAFI_CMD_STR" in", + "clear ip bgp * ipv4 (unicast|multicast) in", CLEAR_STR IP_STR BGP_STR "Clear all peers\n" "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" BGP_SOFT_IN_STR) ALIAS (clear_ip_bgp_instance_all_ipv4_soft_in, clear_ip_bgp_instance_all_ipv4_in_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " * ipv4 "BGP_SAFI_CMD_STR" in", + "clear ip bgp " BGP_INSTANCE_CMD " * ipv4 (unicast|multicast) in", CLEAR_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR "Clear all peers\n" "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" BGP_SOFT_IN_STR) DEFUN (clear_ip_bgp_all_ipv4_in_prefix_filter, clear_ip_bgp_all_ipv4_in_prefix_filter_cmd, - "clear ip bgp * ipv4 "BGP_SAFI_CMD_STR" in prefix-filter", + "clear ip bgp * ipv4 (unicast|multicast) in prefix-filter", CLEAR_STR IP_STR BGP_STR "Clear all peers\n" "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" BGP_SOFT_IN_STR "Push out prefix-list ORF and do inbound soft reconfig\n") { - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[0]); - return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_all, - BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL); + if (strncmp (argv[0], "m", 1) == 0) + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all, + BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL); + + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all, + BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL); } +DEFUN (clear_ip_bgp_all_vpnv4_soft_in, + clear_ip_bgp_all_vpnv4_soft_in_cmd, + "clear ip bgp * vpnv4 unicast soft in", + CLEAR_STR + IP_STR + BGP_STR + "Clear all peers\n" + "Address family\n" + "Address Family Modifier\n" + BGP_SOFT_STR + BGP_SOFT_IN_STR) +{ + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all, + BGP_CLEAR_SOFT_IN, NULL); +} + +ALIAS (clear_ip_bgp_all_vpnv4_soft_in, + clear_ip_bgp_all_vpnv4_in_cmd, + "clear ip bgp * vpnv4 unicast in", + CLEAR_STR + IP_STR + BGP_STR + "Clear all peers\n" + "Address family\n" + "Address Family Modifier\n" + BGP_SOFT_IN_STR) + +DEFUN (clear_ip_bgp_all_encap_soft_in, + clear_ip_bgp_all_encap_soft_in_cmd, + "clear ip bgp * encap unicast soft in", + CLEAR_STR + IP_STR + BGP_STR + "Clear all peers\n" + "Address family\n" + "Address Family Modifier\n" + "Soft reconfig\n" + "Soft reconfig inbound update\n") +{ + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_all, + BGP_CLEAR_SOFT_IN, NULL); +} + +ALIAS (clear_ip_bgp_all_encap_soft_in, + clear_ip_bgp_all_encap_in_cmd, + "clear ip bgp * encap unicast in", + CLEAR_STR + IP_STR + BGP_STR + "Clear all peers\n" + "Address family\n" + "Address Family Modifier\n" + "Soft reconfig inbound update\n") + DEFUN (clear_bgp_all_soft_in, clear_bgp_all_soft_in_cmd, "clear bgp * soft in", @@ -7960,26 +8224,29 @@ DEFUN (clear_ip_bgp_peer_in_prefix_filter, DEFUN (clear_ip_bgp_peer_ipv4_soft_in, clear_ip_bgp_peer_ipv4_soft_in_cmd, - "clear ip bgp (A.B.C.D|WORD) ipv4 "BGP_SAFI_CMD_STR" soft in", + "clear ip bgp (A.B.C.D|WORD) ipv4 (unicast|multicast) soft in", CLEAR_STR IP_STR BGP_STR "BGP neighbor address to clear\n" "BGP neighbor on interface to clear\n" "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" BGP_SOFT_STR BGP_SOFT_IN_STR) { - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[1]); - return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_peer, - BGP_CLEAR_SOFT_IN, argv[0]); + if (strncmp (argv[1], "m", 1) == 0) + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer, + BGP_CLEAR_SOFT_IN, argv[0]); + + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer, + BGP_CLEAR_SOFT_IN, argv[0]); } DEFUN (clear_ip_bgp_instance_peer_ipv4_soft_in, clear_ip_bgp_instance_peer_ipv4_soft_in_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) ipv4 "BGP_SAFI_CMD_STR" soft in", + "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) ipv4 (unicast|multicast) soft in", CLEAR_STR IP_STR BGP_STR @@ -7987,31 +8254,35 @@ DEFUN (clear_ip_bgp_instance_peer_ipv4_soft_in, "BGP neighbor address to clear\n" "BGP neighbor on interface to clear\n" "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" BGP_SOFT_STR BGP_SOFT_IN_STR) { - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[3]); - return bgp_clear_vty (vty, argv[1], AFI_IP, safi, clear_peer, - BGP_CLEAR_SOFT_IN, argv[2]); + if (strncmp (argv[3], "m", 1) == 0) + return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_peer, + BGP_CLEAR_SOFT_IN, argv[2]); + + return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_peer, + BGP_CLEAR_SOFT_IN, argv[2]); } ALIAS (clear_ip_bgp_peer_ipv4_soft_in, clear_ip_bgp_peer_ipv4_in_cmd, - "clear ip bgp (A.B.C.D|WORD) ipv4 "BGP_SAFI_CMD_STR" in", + "clear ip bgp (A.B.C.D|WORD) ipv4 (unicast|multicast) in", CLEAR_STR IP_STR BGP_STR "BGP neighbor address to clear\n" "BGP neighbor on interface to clear\n" "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" BGP_SOFT_IN_STR) ALIAS (clear_ip_bgp_instance_peer_ipv4_soft_in, clear_ip_bgp_instance_peer_ipv4_in_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) ipv4 "BGP_SAFI_CMD_STR" in", + "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) ipv4 (unicast|multicast) in", CLEAR_STR IP_STR BGP_STR @@ -8019,28 +8290,88 @@ ALIAS (clear_ip_bgp_instance_peer_ipv4_soft_in, "BGP neighbor address to clear\n" "BGP neighbor on interface to clear\n" "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" BGP_SOFT_IN_STR) DEFUN (clear_ip_bgp_peer_ipv4_in_prefix_filter, clear_ip_bgp_peer_ipv4_in_prefix_filter_cmd, - "clear ip bgp (A.B.C.D|WORD) ipv4 "BGP_SAFI_CMD_STR" in prefix-filter", + "clear ip bgp (A.B.C.D|WORD) ipv4 (unicast|multicast) in prefix-filter", CLEAR_STR IP_STR BGP_STR "BGP neighbor address to clear\n" "BGP neighbor on interface to clear\n" "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" BGP_SOFT_IN_STR "Push out the existing ORF prefix-list\n") { - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[1]); - return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_peer, - BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]); + if (strncmp (argv[1], "m", 1) == 0) + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer, + BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]); + + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer, + BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]); } +DEFUN (clear_ip_bgp_peer_vpnv4_soft_in, + clear_ip_bgp_peer_vpnv4_soft_in_cmd, + "clear ip bgp (A.B.C.D|WORD) vpnv4 unicast soft in", + CLEAR_STR + IP_STR + BGP_STR + "BGP neighbor address to clear\n" + "BGP neighbor on interface to clear\n" + "Address family\n" + "Address Family Modifier\n" + BGP_SOFT_STR + BGP_SOFT_IN_STR) +{ + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer, + BGP_CLEAR_SOFT_IN, argv[0]); +} + +ALIAS (clear_ip_bgp_peer_vpnv4_soft_in, + clear_ip_bgp_peer_vpnv4_in_cmd, + "clear ip bgp (A.B.C.D|WORD) vpnv4 unicast in", + CLEAR_STR + IP_STR + BGP_STR + "BGP neighbor address to clear\n" + "BGP neighbor on interface to clear\n" + "Address family\n" + "Address Family Modifier\n" + BGP_SOFT_IN_STR) + +DEFUN (clear_ip_bgp_peer_encap_soft_in, + clear_ip_bgp_peer_encap_soft_in_cmd, + "clear ip bgp A.B.C.D encap unicast soft in", + CLEAR_STR + IP_STR + BGP_STR + "BGP neighbor address to clear\n" + "Address family\n" + "Address Family Modifier\n" + "Soft reconfig\n" + "Soft reconfig inbound update\n") +{ + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_peer, + BGP_CLEAR_SOFT_IN, argv[0]); +} + +ALIAS (clear_ip_bgp_peer_encap_soft_in, + clear_ip_bgp_peer_encap_in_cmd, + "clear ip bgp A.B.C.D encap unicast in", + CLEAR_STR + IP_STR + BGP_STR + "BGP neighbor address to clear\n" + "Address family\n" + "Address Family Modifier\n" + "Soft reconfig inbound update\n") + DEFUN (clear_bgp_peer_soft_in, clear_bgp_peer_soft_in_cmd, "clear bgp (A.B.C.D|X:X::X:X|WORD) soft in", @@ -8237,26 +8568,29 @@ DEFUN (clear_ip_bgp_peer_group_in_prefix_filter, DEFUN (clear_ip_bgp_peer_group_ipv4_soft_in, clear_ip_bgp_peer_group_ipv4_soft_in_cmd, - "clear ip bgp peer-group WORD ipv4 "BGP_SAFI_CMD_STR" soft in", + "clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft in", CLEAR_STR IP_STR BGP_STR "Clear all members of peer-group\n" "BGP peer-group name\n" "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" BGP_SOFT_STR BGP_SOFT_IN_STR) { - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[1]); - return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_group, - BGP_CLEAR_SOFT_IN, argv[0]); + if (strncmp (argv[1], "m", 1) == 0) + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group, + BGP_CLEAR_SOFT_IN, argv[0]); + + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group, + BGP_CLEAR_SOFT_IN, argv[0]); } DEFUN (clear_ip_bgp_instance_peer_group_ipv4_soft_in, clear_ip_bgp_instance_peer_group_ipv4_soft_in_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD ipv4 "BGP_SAFI_CMD_STR" soft in", + "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD ipv4 (unicast|multicast) soft in", CLEAR_STR IP_STR BGP_STR @@ -8264,31 +8598,35 @@ DEFUN (clear_ip_bgp_instance_peer_group_ipv4_soft_in, "Clear all members of peer-group\n" "BGP peer-group name\n" "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" BGP_SOFT_STR BGP_SOFT_IN_STR) { - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[3]); - return bgp_clear_vty (vty, argv[1], AFI_IP, safi, clear_group, - BGP_CLEAR_SOFT_IN, argv[2]); + if (strncmp (argv[3], "m", 1) == 0) + return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_group, + BGP_CLEAR_SOFT_IN, argv[2]); + + return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_group, + BGP_CLEAR_SOFT_IN, argv[2]); } ALIAS (clear_ip_bgp_peer_group_ipv4_soft_in, clear_ip_bgp_peer_group_ipv4_in_cmd, - "clear ip bgp peer-group WORD ipv4 "BGP_SAFI_CMD_STR" in", + "clear ip bgp peer-group WORD ipv4 (unicast|multicast) in", CLEAR_STR IP_STR BGP_STR "Clear all members of peer-group\n" "BGP peer-group name\n" "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" BGP_SOFT_IN_STR) ALIAS (clear_ip_bgp_instance_peer_group_ipv4_soft_in, clear_ip_bgp_instance_peer_group_ipv4_in_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD ipv4 "BGP_SAFI_CMD_STR" in", + "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD ipv4 (unicast|multicast) in", CLEAR_STR IP_STR BGP_STR @@ -8296,26 +8634,30 @@ ALIAS (clear_ip_bgp_instance_peer_group_ipv4_soft_in, "Clear all members of peer-group\n" "BGP peer-group name\n" "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" BGP_SOFT_IN_STR) DEFUN (clear_ip_bgp_peer_group_ipv4_in_prefix_filter, clear_ip_bgp_peer_group_ipv4_in_prefix_filter_cmd, - "clear ip bgp peer-group WORD ipv4 "BGP_SAFI_CMD_STR" in prefix-filter", + "clear ip bgp peer-group WORD ipv4 (unicast|multicast) in prefix-filter", CLEAR_STR IP_STR BGP_STR "Clear all members of peer-group\n" "BGP peer-group name\n" "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" BGP_SOFT_IN_STR "Push out prefix-list ORF and do inbound soft reconfig\n") { - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[1]); - return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_group, - BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]); + if (strncmp (argv[1], "m", 1) == 0) + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group, + BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]); + + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group, + BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]); } DEFUN (clear_bgp_peer_group_soft_in, @@ -8499,80 +8841,91 @@ DEFUN (clear_ip_bgp_external_in_prefix_filter, DEFUN (clear_ip_bgp_external_ipv4_soft_in, clear_ip_bgp_external_ipv4_soft_in_cmd, - "clear ip bgp external ipv4 "BGP_SAFI_CMD_STR" soft in", + "clear ip bgp external ipv4 (unicast|multicast) soft in", CLEAR_STR IP_STR BGP_STR "Clear all external peers\n" "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" BGP_SOFT_STR BGP_SOFT_IN_STR) { - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[0]); - return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_external, - BGP_CLEAR_SOFT_IN, NULL); + if (strncmp (argv[0], "m", 1) == 0) + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external, + BGP_CLEAR_SOFT_IN, NULL); + + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external, + BGP_CLEAR_SOFT_IN, NULL); } DEFUN (clear_ip_bgp_instance_external_ipv4_soft_in, clear_ip_bgp_instance_external_ipv4_soft_in_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " external ipv4 "BGP_SAFI_CMD_STR" soft in", + "clear ip bgp " BGP_INSTANCE_CMD " external ipv4 (unicast|multicast) soft in", CLEAR_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR "Clear all external peers\n" "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" BGP_SOFT_STR BGP_SOFT_IN_STR) { - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[2]); - return bgp_clear_vty (vty, argv[1], AFI_IP, safi, clear_external, - BGP_CLEAR_SOFT_IN, NULL); + if (strncmp (argv[2], "m", 1) == 0) + return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_external, + BGP_CLEAR_SOFT_IN, NULL); + + return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_external, + BGP_CLEAR_SOFT_IN, NULL); } ALIAS (clear_ip_bgp_external_ipv4_soft_in, clear_ip_bgp_external_ipv4_in_cmd, - "clear ip bgp external ipv4 "BGP_SAFI_CMD_STR" in", + "clear ip bgp external ipv4 (unicast|multicast) in", CLEAR_STR IP_STR BGP_STR "Clear all external peers\n" "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" BGP_SOFT_IN_STR) ALIAS (clear_ip_bgp_instance_external_ipv4_soft_in, clear_ip_bgp_instance_external_ipv4_in_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " external ipv4 "BGP_SAFI_CMD_STR" in", + "clear ip bgp " BGP_INSTANCE_CMD " external ipv4 (unicast|multicast) in", CLEAR_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR "Clear all external peers\n" "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" BGP_SOFT_IN_STR) DEFUN (clear_ip_bgp_external_ipv4_in_prefix_filter, clear_ip_bgp_external_ipv4_in_prefix_filter_cmd, - "clear ip bgp external ipv4 "BGP_SAFI_CMD_STR" in prefix-filter", + "clear ip bgp external ipv4 (unicast|multicast) in prefix-filter", CLEAR_STR IP_STR BGP_STR "Clear all external peers\n" "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" BGP_SOFT_IN_STR "Push out prefix-list ORF and do inbound soft reconfig\n") { - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[0]); - return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_external, - BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL); + if (strncmp (argv[0], "m", 1) == 0) + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external, + BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL); + + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external, + BGP_CLEAR_SOFT_IN_ORF_PREFIX, NULL); } DEFUN (clear_bgp_external_soft_in, @@ -8746,82 +9099,147 @@ DEFUN (clear_ip_bgp_as_in_prefix_filter, DEFUN (clear_ip_bgp_as_ipv4_soft_in, clear_ip_bgp_as_ipv4_soft_in_cmd, - "clear ip bgp " CMD_AS_RANGE " ipv4 "BGP_SAFI_CMD_STR" soft in", + "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) soft in", CLEAR_STR IP_STR BGP_STR "Clear peers with the AS number\n" "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" BGP_SOFT_STR BGP_SOFT_IN_STR) { - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[1]); - return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_as, - BGP_CLEAR_SOFT_IN, argv[0]); + if (strncmp (argv[1], "m", 1) == 0) + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as, + BGP_CLEAR_SOFT_IN, argv[0]); + + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as, + BGP_CLEAR_SOFT_IN, argv[0]); } DEFUN (clear_ip_bgp_instance_as_ipv4_soft_in, clear_ip_bgp_instance_as_ipv4_soft_in_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " ipv4 "BGP_SAFI_CMD_STR" soft in", + "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " ipv4 (unicast|multicast) soft in", CLEAR_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR "Clear peers with the AS number\n" "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" BGP_SOFT_STR BGP_SOFT_IN_STR) { - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[3]); - return bgp_clear_vty (vty, argv[1], AFI_IP, safi, clear_as, - BGP_CLEAR_SOFT_IN, argv[2]); + if (strncmp (argv[3], "m", 1) == 0) + return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_as, + BGP_CLEAR_SOFT_IN, argv[2]); + + return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_as, + BGP_CLEAR_SOFT_IN, argv[2]); } ALIAS (clear_ip_bgp_as_ipv4_soft_in, clear_ip_bgp_as_ipv4_in_cmd, - "clear ip bgp " CMD_AS_RANGE " ipv4 "BGP_SAFI_CMD_STR" in", + "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) in", CLEAR_STR IP_STR BGP_STR "Clear peers with the AS number\n" "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" BGP_SOFT_IN_STR) ALIAS (clear_ip_bgp_instance_as_ipv4_soft_in, clear_ip_bgp_instance_as_ipv4_in_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " ipv4 "BGP_SAFI_CMD_STR" in", + "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " ipv4 (unicast|multicast) in", CLEAR_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR "Clear peers with the AS number\n" "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" BGP_SOFT_IN_STR) DEFUN (clear_ip_bgp_as_ipv4_in_prefix_filter, clear_ip_bgp_as_ipv4_in_prefix_filter_cmd, - "clear ip bgp " CMD_AS_RANGE " ipv4 "BGP_SAFI_CMD_STR" in prefix-filter", + "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) in prefix-filter", CLEAR_STR IP_STR BGP_STR "Clear peers with the AS number\n" "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" BGP_SOFT_IN_STR "Push out prefix-list ORF and do inbound soft reconfig\n") { - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[1]); - return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_as, - BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]); + if (strncmp (argv[1], "m", 1) == 0) + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as, + BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]); + + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_as, + BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]); } +DEFUN (clear_ip_bgp_as_vpnv4_soft_in, + clear_ip_bgp_as_vpnv4_soft_in_cmd, + "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast soft in", + CLEAR_STR + IP_STR + BGP_STR + "Clear peers with the AS number\n" + "Address family\n" + "Address Family modifier\n" + BGP_SOFT_STR + BGP_SOFT_IN_STR) +{ + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as, + BGP_CLEAR_SOFT_IN, argv[0]); +} + +ALIAS (clear_ip_bgp_as_vpnv4_soft_in, + clear_ip_bgp_as_vpnv4_in_cmd, + "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast in", + CLEAR_STR + IP_STR + BGP_STR + "Clear peers with the AS number\n" + "Address family\n" + "Address Family modifier\n" + BGP_SOFT_IN_STR) + +DEFUN (clear_ip_bgp_as_encap_soft_in, + clear_ip_bgp_as_encap_soft_in_cmd, + "clear ip bgp " CMD_AS_RANGE " encap unicast soft in", + CLEAR_STR + IP_STR + BGP_STR + "Clear peers with the AS number\n" + "Address family\n" + "Address Family modifier\n" + "Soft reconfig\n" + "Soft reconfig inbound update\n") +{ + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_as, + BGP_CLEAR_SOFT_IN, argv[0]); +} + +ALIAS (clear_ip_bgp_as_encap_soft_in, + clear_ip_bgp_as_encap_in_cmd, + "clear ip bgp " CMD_AS_RANGE " encap unicast in", + CLEAR_STR + IP_STR + BGP_STR + "Clear peers with the AS number\n" + "Address family\n" + "Address Family modifier\n" + "Soft reconfig inbound update\n") + DEFUN (clear_bgp_as_soft_in, clear_bgp_as_soft_in_cmd, "clear bgp " CMD_AS_RANGE " soft in", @@ -8960,7 +9378,7 @@ ALIAS (clear_ip_bgp_all_soft, DEFUN (clear_ip_bgp_all_ipv4_soft, clear_ip_bgp_all_ipv4_soft_cmd, - "clear ip bgp * ipv4 "BGP_SAFI_CMD_STR" soft", + "clear ip bgp * ipv4 (unicast|multicast) soft", CLEAR_STR IP_STR BGP_STR @@ -8970,15 +9388,17 @@ DEFUN (clear_ip_bgp_all_ipv4_soft, "Address Family Modifier\n" BGP_SOFT_STR) { - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[0]); - return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_all, - BGP_CLEAR_SOFT_BOTH, NULL); + if (strncmp (argv[0], "m", 1) == 0) + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_all, + BGP_CLEAR_SOFT_BOTH, NULL); + + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all, + BGP_CLEAR_SOFT_BOTH, NULL); } DEFUN (clear_ip_bgp_instance_all_ipv4_soft, clear_ip_bgp_instance_all_ipv4_soft_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " * ipv4 "BGP_SAFI_CMD_STR" soft", + "clear ip bgp " BGP_INSTANCE_CMD " * ipv4 (unicast|multicast) soft", CLEAR_STR IP_STR BGP_STR @@ -8989,12 +9409,44 @@ DEFUN (clear_ip_bgp_instance_all_ipv4_soft, "Address Family Modifier\n" BGP_SOFT_STR) { - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[2]); - return bgp_clear_vty (vty, argv[1], AFI_IP, safi, clear_all, + if (strncmp (argv[2], "m", 1) == 0) + return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_all, + BGP_CLEAR_SOFT_BOTH, NULL); + + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all, BGP_CLEAR_SOFT_BOTH, NULL); } +DEFUN (clear_ip_bgp_all_vpnv4_soft, + clear_ip_bgp_all_vpnv4_soft_cmd, + "clear ip bgp * vpnv4 unicast soft", + CLEAR_STR + IP_STR + BGP_STR + "Clear all peers\n" + "Address family\n" + "Address Family Modifier\n" + BGP_SOFT_STR) +{ + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_all, + BGP_CLEAR_SOFT_BOTH, argv[0]); +} + +DEFUN (clear_ip_bgp_all_encap_soft, + clear_ip_bgp_all_encap_soft_cmd, + "clear ip bgp * encap unicast soft", + CLEAR_STR + IP_STR + BGP_STR + "Clear all peers\n" + "Address family\n" + "Address Family Modifier\n" + "Soft reconfig\n") +{ + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_all, + BGP_CLEAR_SOFT_BOTH, argv[0]); +} + DEFUN (clear_bgp_all_soft, clear_bgp_all_soft_cmd, "clear bgp * soft", @@ -9070,7 +9522,7 @@ ALIAS (clear_ip_bgp_peer_soft, DEFUN (clear_ip_bgp_peer_ipv4_soft, clear_ip_bgp_peer_ipv4_soft_cmd, - "clear ip bgp (A.B.C.D|WORD) ipv4 "BGP_SAFI_CMD_STR" soft", + "clear ip bgp (A.B.C.D|WORD) ipv4 (unicast|multicast) soft", CLEAR_STR IP_STR BGP_STR @@ -9081,15 +9533,17 @@ DEFUN (clear_ip_bgp_peer_ipv4_soft, "Address Family Modifier\n" BGP_SOFT_STR) { - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[1]); - return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_peer, - BGP_CLEAR_SOFT_BOTH, argv[0]); + if (strncmp (argv[1], "m", 1) == 0) + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_peer, + BGP_CLEAR_SOFT_BOTH, argv[0]); + + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_peer, + BGP_CLEAR_SOFT_BOTH, argv[0]); } DEFUN (clear_ip_bgp_instance_peer_ipv4_soft, clear_ip_bgp_instance_peer_ipv4_soft_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) ipv4 "BGP_SAFI_CMD_STR" soft", + "clear ip bgp " BGP_INSTANCE_CMD " (A.B.C.D|WORD) ipv4 (unicast|multicast) soft", CLEAR_STR IP_STR BGP_STR @@ -9101,10 +9555,43 @@ DEFUN (clear_ip_bgp_instance_peer_ipv4_soft, "Address Family Modifier\n" BGP_SOFT_STR) { - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[3]); - return bgp_clear_vty (vty, argv[1], AFI_IP, safi, clear_peer, - BGP_CLEAR_SOFT_BOTH, argv[2]); + if (strncmp (argv[3], "m", 1) == 0) + return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_peer, + BGP_CLEAR_SOFT_BOTH, argv[2]); + + return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_peer, + BGP_CLEAR_SOFT_BOTH, argv[2]); +} + +DEFUN (clear_ip_bgp_peer_vpnv4_soft, + clear_ip_bgp_peer_vpnv4_soft_cmd, + "clear ip bgp (A.B.C.D|WORD) vpnv4 unicast soft", + CLEAR_STR + IP_STR + BGP_STR + "BGP neighbor address to clear\n" + "BGP neighbor on interface to clear\n" + "Address family\n" + "Address Family Modifier\n" + BGP_SOFT_STR) +{ + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_peer, + BGP_CLEAR_SOFT_BOTH, argv[0]); +} + +DEFUN (clear_ip_bgp_peer_encap_soft, + clear_ip_bgp_peer_encap_soft_cmd, + "clear ip bgp A.B.C.D encap unicast soft", + CLEAR_STR + IP_STR + BGP_STR + "BGP neighbor address to clear\n" + "Address family\n" + "Address Family Modifier\n" + "Soft reconfig\n") +{ + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_peer, + BGP_CLEAR_SOFT_BOTH, argv[0]); } DEFUN (clear_bgp_peer_soft, @@ -9190,25 +9677,28 @@ ALIAS (clear_ip_bgp_peer_group_soft, DEFUN (clear_ip_bgp_peer_group_ipv4_soft, clear_ip_bgp_peer_group_ipv4_soft_cmd, - "clear ip bgp peer-group WORD ipv4 "BGP_SAFI_CMD_STR" soft", + "clear ip bgp peer-group WORD ipv4 (unicast|multicast) soft", CLEAR_STR IP_STR BGP_STR "Clear all members of peer-group\n" "BGP peer-group name\n" "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" BGP_SOFT_STR) { - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[1]); - return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_group, - BGP_CLEAR_SOFT_BOTH, argv[0]); + if (strncmp (argv[1], "m", 1) == 0) + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_group, + BGP_CLEAR_SOFT_BOTH, argv[0]); + + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group, + BGP_CLEAR_SOFT_BOTH, argv[0]); } DEFUN (clear_ip_bgp_instance_peer_group_ipv4_soft, clear_ip_bgp_instance_peer_group_ipv4_soft_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD ipv4 "BGP_SAFI_CMD_STR" soft", + "clear ip bgp " BGP_INSTANCE_CMD " peer-group WORD ipv4 (unicast|multicast) soft", CLEAR_STR IP_STR BGP_STR @@ -9216,13 +9706,16 @@ DEFUN (clear_ip_bgp_instance_peer_group_ipv4_soft, "Clear all members of peer-group\n" "BGP peer-group name\n" "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" BGP_SOFT_STR) { - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[3]); - return bgp_clear_vty (vty, argv[1], AFI_IP, safi, clear_group, - BGP_CLEAR_SOFT_BOTH, argv[2]); + if (strncmp (argv[3], "m", 1) == 0) + return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_group, + BGP_CLEAR_SOFT_BOTH, argv[2]); + + return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_group, + BGP_CLEAR_SOFT_BOTH, argv[2]); } DEFUN (clear_bgp_peer_group_soft, @@ -9302,37 +9795,43 @@ ALIAS (clear_ip_bgp_external_soft, DEFUN (clear_ip_bgp_external_ipv4_soft, clear_ip_bgp_external_ipv4_soft_cmd, - "clear ip bgp external ipv4 "BGP_SAFI_CMD_STR" soft", + "clear ip bgp external ipv4 (unicast|multicast) soft", CLEAR_STR IP_STR BGP_STR "Clear all external peers\n" "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" BGP_SOFT_STR) { - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[0]); - return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_external, - BGP_CLEAR_SOFT_BOTH, NULL); + if (strncmp (argv[0], "m", 1) == 0) + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_external, + BGP_CLEAR_SOFT_BOTH, NULL); + + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_external, + BGP_CLEAR_SOFT_BOTH, NULL); } DEFUN (clear_ip_bgp_instance_external_ipv4_soft, clear_ip_bgp_instance_external_ipv4_soft_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " external ipv4 "BGP_SAFI_CMD_STR" soft", + "clear ip bgp " BGP_INSTANCE_CMD " external ipv4 (unicast|multicast) soft", CLEAR_STR IP_STR BGP_STR BGP_INSTANCE_HELP_STR "Clear all external peers\n" "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" BGP_SOFT_STR) { - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[2]); - return bgp_clear_vty (vty, argv[1], AFI_IP, safi, clear_external, + if (strncmp (argv[2], "m", 1) == 0) + return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_external, BGP_CLEAR_SOFT_BOTH, NULL); + + return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, clear_external, + BGP_CLEAR_SOFT_BOTH, NULL); } DEFUN (clear_bgp_external_soft, @@ -9408,7 +9907,7 @@ ALIAS (clear_ip_bgp_as_soft, DEFUN (clear_ip_bgp_as_ipv4_soft, clear_ip_bgp_as_ipv4_soft_cmd, - "clear ip bgp " CMD_AS_RANGE " ipv4 "BGP_SAFI_CMD_STR" soft", + "clear ip bgp " CMD_AS_RANGE " ipv4 (unicast|multicast) soft", CLEAR_STR IP_STR BGP_STR @@ -9418,15 +9917,17 @@ DEFUN (clear_ip_bgp_as_ipv4_soft, "Address Family Modifier\n" BGP_SOFT_STR) { - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[1]); - return bgp_clear_vty (vty, NULL, AFI_IP, safi, clear_as, - BGP_CLEAR_SOFT_BOTH, argv[0]); + if (strncmp (argv[1], "m", 1) == 0) + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MULTICAST, clear_as, + BGP_CLEAR_SOFT_BOTH, argv[0]); + + return bgp_clear_vty (vty, NULL,AFI_IP, SAFI_UNICAST, clear_as, + BGP_CLEAR_SOFT_BOTH, argv[0]); } DEFUN (clear_ip_bgp_instance_as_ipv4_soft, clear_ip_bgp_instance_as_ipv4_soft_cmd, - "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " ipv4 "BGP_SAFI_CMD_STR" soft", + "clear ip bgp " BGP_INSTANCE_CMD " " CMD_AS_RANGE " ipv4 (unicast|multicast) soft", CLEAR_STR IP_STR BGP_STR @@ -9437,10 +9938,42 @@ DEFUN (clear_ip_bgp_instance_as_ipv4_soft, "Address Family Modifier\n" BGP_SOFT_STR) { - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[3]); - return bgp_clear_vty (vty, argv[1], AFI_IP, safi, clear_as, - BGP_CLEAR_SOFT_BOTH, argv[2]); + if (strncmp (argv[3], "m", 1) == 0) + return bgp_clear_vty (vty, argv[1], AFI_IP, SAFI_MULTICAST, clear_as, + BGP_CLEAR_SOFT_BOTH, argv[2]); + + return bgp_clear_vty (vty, argv[1],AFI_IP, SAFI_UNICAST, clear_as, + BGP_CLEAR_SOFT_BOTH, argv[2]); +} + +DEFUN (clear_ip_bgp_as_vpnv4_soft, + clear_ip_bgp_as_vpnv4_soft_cmd, + "clear ip bgp " CMD_AS_RANGE " vpnv4 unicast soft", + CLEAR_STR + IP_STR + BGP_STR + "Clear peers with the AS number\n" + "Address family\n" + "Address Family Modifier\n" + BGP_SOFT_STR) +{ + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, clear_as, + BGP_CLEAR_SOFT_BOTH, argv[0]); +} + +DEFUN (clear_ip_bgp_as_encap_soft, + clear_ip_bgp_as_encap_soft_cmd, + "clear ip bgp " CMD_AS_RANGE " encap unicast soft", + CLEAR_STR + IP_STR + BGP_STR + "Clear peers with the AS number\n" + "Address family\n" + "Address Family Modifier\n" + "Soft reconfig\n") +{ + return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_ENCAP, clear_as, + BGP_CLEAR_SOFT_BOTH, argv[0]); } DEFUN (clear_bgp_as_soft, @@ -10101,10 +10634,10 @@ bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi, { if (use_json) vty_out(vty, "{\"error\": {\"message\": \"No %s neighbor configured\"}}%s", - afi_safi_print(afi, safi), VTY_NEWLINE); + afi == AFI_IP ? "IPv4" : "IPv6", VTY_NEWLINE); else vty_out (vty, "No %s neighbor is configured%s", - afi_safi_print(afi, safi), VTY_NEWLINE); + afi == AFI_IP ? "IPv4" : "IPv6", VTY_NEWLINE); } if (dn_count && ! use_json) @@ -10119,62 +10652,6 @@ bgp_show_summary (struct vty *vty, struct bgp *bgp, int afi, int safi, return CMD_SUCCESS; } -static void -bgp_show_summary_afi_safi (struct vty *vty, struct bgp *bgp, int afi, int safi, - u_char use_json, json_object *json) -{ - int is_first = 1; - int afi_wildcard = (afi == AFI_MAX); - int safi_wildcard = (safi == SAFI_MAX); - int is_wildcard = (afi_wildcard || safi_wildcard); - if (use_json && is_wildcard) - vty_out (vty, "{%s", VTY_NEWLINE); - if (afi_wildcard) - afi = 1; /* AFI_IP */ - while (afi < AFI_MAX) - { - if (safi_wildcard) - safi = 1; /* SAFI_UNICAST */ - while (safi < SAFI_MAX) - { - if (is_wildcard) - { - if (use_json) - { - json = json_object_new_object(); - - if (! is_first) - vty_out (vty, ",%s", VTY_NEWLINE); - else - is_first = 0; - - vty_out(vty, "\"%s\":", afi_safi_json(afi, safi)); - } - else - { - vty_out (vty, "%s%s Summary:%s", - VTY_NEWLINE, afi_safi_print(afi, safi), VTY_NEWLINE); - } - } - bgp_show_summary (vty, bgp, afi, safi, use_json, json); - if (safi == SAFI_MPLS_VPN) /* handle special cases to match zebra.h */ - safi = SAFI_ENCAP; - else - safi++; - if (! safi_wildcard) - safi = SAFI_MAX; - } - afi++; - if (! afi_wildcard || - afi == AFI_ETHER) /* special case, not handled yet */ - afi = AFI_MAX; - } - - if (use_json && is_wildcard) - vty_out (vty, "}%s", VTY_NEWLINE); - -} - static int bgp_show_summary_vty (struct vty *vty, const char *name, afi_t afi, safi_t safi, u_char use_json) @@ -10191,14 +10668,14 @@ bgp_show_summary_vty (struct vty *vty, const char *name, return CMD_WARNING; } - bgp_show_summary_afi_safi (vty, bgp, afi, safi, use_json, NULL); + bgp_show_summary (vty, bgp, afi, safi, use_json, NULL); return CMD_SUCCESS; } bgp = bgp_get_default (); if (bgp) - bgp_show_summary_afi_safi (vty, bgp, afi, safi, use_json, NULL); + bgp_show_summary (vty, bgp, afi, safi, use_json, NULL); return CMD_SUCCESS; } @@ -10243,7 +10720,7 @@ bgp_show_all_instances_summary_vty (struct vty *vty, afi_t afi, safi_t safi, (bgp->inst_type == BGP_INSTANCE_TYPE_DEFAULT) ? "Default" : bgp->name, VTY_NEWLINE); } - bgp_show_summary_afi_safi (vty, bgp, afi, safi, use_json, json); + bgp_show_summary (vty, bgp, afi, safi, use_json, json); } if (use_json) @@ -10262,7 +10739,7 @@ DEFUN (show_ip_bgp_summary, "JavaScript Object Notation\n") { u_char uj = use_json(argc, argv); - return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MAX, uj); + return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_UNICAST, uj); } DEFUN (show_ip_bgp_instance_summary, @@ -10276,7 +10753,7 @@ DEFUN (show_ip_bgp_instance_summary, "JavaScript Object Notation\n") { u_char uj = use_json(argc, argv); - return bgp_show_summary_vty (vty, argv[1], AFI_IP, SAFI_MAX, uj); + return bgp_show_summary_vty (vty, argv[1], AFI_IP, SAFI_UNICAST, uj); } DEFUN (show_ip_bgp_instance_all_summary, @@ -10291,18 +10768,17 @@ DEFUN (show_ip_bgp_instance_all_summary, { u_char uj = use_json(argc, argv); - bgp_show_all_instances_summary_vty (vty, AFI_IP, SAFI_MAX, uj); + bgp_show_all_instances_summary_vty (vty, AFI_IP, SAFI_UNICAST, uj); return CMD_SUCCESS; } DEFUN (show_ip_bgp_ipv4_summary, show_ip_bgp_ipv4_summary_cmd, - "show ip bgp ipv4 "BGP_SAFI_CMD_STR" summary {json}", + "show ip bgp ipv4 (unicast|multicast|vpn|encap) summary {json}", SHOW_STR IP_STR BGP_STR - "Address family\n" - BGP_SAFI_HELP_STR + AFI_SAFI_STR "Summary of BGP neighbor status\n" "JavaScript Object Notation\n") { @@ -10313,42 +10789,84 @@ DEFUN (show_ip_bgp_ipv4_summary, ALIAS (show_ip_bgp_ipv4_summary, show_bgp_ipv4_safi_summary_cmd, - "show bgp ipv4 "BGP_SAFI_CMD_STR" summary {json}", + "show bgp ipv4 (unicast|multicast|vpn|encap) summary {json}", SHOW_STR BGP_STR - "Address family\n" - BGP_SAFI_HELP_STR + AFI_SAFI_STR "Summary of BGP neighbor status\n") DEFUN (show_ip_bgp_instance_ipv4_summary, show_ip_bgp_instance_ipv4_summary_cmd, - "show ip bgp view WORD ipv4 "BGP_SAFI_CMD_STR" summary {json}", + "show ip bgp view WORD ipv4 (unicast|multicast) summary {json}", SHOW_STR IP_STR BGP_STR "BGP view\n" "View name\n" "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" "Summary of BGP neighbor status\n" "JavaScript Object Notation\n") { u_char uj = use_json(argc, argv); - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[1]); - return bgp_show_summary_vty (vty, argv[0], AFI_IP, safi, uj); + if (strncmp (argv[1], "m", 1) == 0) + return bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_MULTICAST, uj); + else + return bgp_show_summary_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, uj); } ALIAS (show_ip_bgp_instance_ipv4_summary, show_bgp_instance_ipv4_safi_summary_cmd, - "show bgp view WORD ipv4 "BGP_SAFI_CMD_STR" summary {json}", + "show bgp view WORD ipv4 (unicast|multicast) summary {json}", SHOW_STR BGP_STR "BGP view\n" "View name\n" - BGP_AFI_SAFI_HELP_STR + AFI_SAFI_STR "Summary of BGP neighbor status\n") +DEFUN (show_ip_bgp_vpnv4_all_summary, + show_ip_bgp_vpnv4_all_summary_cmd, + "show ip bgp vpnv4 all summary {json}", + SHOW_STR + IP_STR + BGP_STR + "Display VPNv4 NLRI specific information\n" + "Display information about all VPNv4 NLRIs\n" + "Summary of BGP neighbor status\n" + "JavaScript Object Notation\n") +{ + u_char uj = use_json(argc, argv); + return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, uj); +} + +DEFUN (show_ip_bgp_vpnv4_rd_summary, + show_ip_bgp_vpnv4_rd_summary_cmd, + "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn summary {json}", + SHOW_STR + IP_STR + BGP_STR + "Display VPNv4 NLRI specific information\n" + "Display information for a route distinguisher\n" + "VPN Route Distinguisher\n" + "Summary of BGP neighbor status\n" + "JavaScript Object Notation\n") +{ + int ret; + struct prefix_rd prd; + u_char uj = use_json(argc, argv); + + ret = str2prefix_rd (argv[0], &prd); + if (! ret) + { + vty_out (vty, "%% Malformed Route Distinguisher%s", VTY_NEWLINE); + return CMD_WARNING; + } + + return bgp_show_summary_vty (vty, NULL, AFI_IP, SAFI_MPLS_VPN, uj); +} + #ifdef HAVE_IPV6 DEFUN (show_bgp_summary, show_bgp_summary_cmd, @@ -10358,7 +10876,7 @@ DEFUN (show_bgp_summary, "Summary of BGP neighbor status\n" "JavaScript Object Notation\n") { - return bgp_show_summary_vty (vty, NULL, AFI_MAX, SAFI_MAX, use_json(argc, argv)); + return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, use_json(argc, argv)); } DEFUN (show_bgp_instance_summary, @@ -10370,7 +10888,7 @@ DEFUN (show_bgp_instance_summary, "Summary of BGP neighbor status\n" "JavaScript Object Notation\n") { - return bgp_show_summary_vty (vty, argv[1], AFI_MAX, SAFI_MAX, use_json(argc, argv)); + return bgp_show_summary_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, use_json(argc, argv)); } DEFUN (show_bgp_instance_all_summary, @@ -10384,22 +10902,19 @@ DEFUN (show_bgp_instance_all_summary, { u_char uj = use_json(argc, argv); - bgp_show_all_instances_summary_vty (vty, AFI_MAX, SAFI_MAX, uj); + bgp_show_all_instances_summary_vty (vty, AFI_IP6, SAFI_UNICAST, uj); return CMD_SUCCESS; } -DEFUN (show_bgp_ipv6_summary, +ALIAS (show_bgp_summary, show_bgp_ipv6_summary_cmd, "show bgp ipv6 summary {json}", SHOW_STR BGP_STR "Address family\n" "Summary of BGP neighbor status\n") -{ - return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_MAX, use_json(argc, argv)); -} -DEFUN (show_bgp_instance_ipv6__summary, +ALIAS (show_bgp_instance_summary, show_bgp_instance_ipv6_summary_cmd, "show bgp " BGP_INSTANCE_CMD " ipv6 summary {json}", SHOW_STR @@ -10407,17 +10922,13 @@ DEFUN (show_bgp_instance_ipv6__summary, BGP_INSTANCE_HELP_STR "Address family\n" "Summary of BGP neighbor status\n") -{ - return bgp_show_summary_vty (vty, argv[1], AFI_IP6, SAFI_MAX, use_json(argc, argv)); -} DEFUN (show_bgp_ipv6_safi_summary, show_bgp_ipv6_safi_summary_cmd, - "show bgp ipv6 "BGP_SAFI_CMD_STR" summary {json}", + "show bgp ipv6 (unicast|multicast|vpn|encap) summary {json}", SHOW_STR BGP_STR - "Address family\n" - BGP_SAFI_HELP_STR + AFI_SAFI_STR "Summary of BGP neighbor status\n" "JavaScript Object Notation\n") { @@ -10428,18 +10939,19 @@ DEFUN (show_bgp_ipv6_safi_summary, DEFUN (show_bgp_instance_ipv6_safi_summary, show_bgp_instance_ipv6_safi_summary_cmd, - "show bgp " BGP_INSTANCE_CMD " ipv6 "BGP_SAFI_CMD_STR" summary {json}", + "show bgp " BGP_INSTANCE_CMD " ipv6 (unicast|multicast) summary {json}", SHOW_STR BGP_STR BGP_INSTANCE_HELP_STR - BGP_AFI_SAFI_HELP_STR + AFI_SAFI_STR "Summary of BGP neighbor status\n" "JavaScript Object Notation\n") { u_char uj = use_json(argc, argv); - safi_t safi; - safi = bgp_vty_safi_from_arg(argv[2]); - return bgp_show_summary_vty (vty, argv[1], AFI_IP6, safi, uj); + if (strncmp (argv[2], "m", 1) == 0) + return bgp_show_summary_vty (vty, argv[1], AFI_IP6, SAFI_MULTICAST, uj); + + return bgp_show_summary_vty (vty, argv[1], AFI_IP6, SAFI_UNICAST, uj); } /* old command */ @@ -10453,7 +10965,7 @@ DEFUN (show_ipv6_bgp_summary, "JavaScript Object Notation\n") { u_char uj = use_json(argc, argv); - return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_MAX, uj); + return bgp_show_summary_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, uj); } /* old command */ @@ -10479,40 +10991,17 @@ afi_safi_print (afi_t afi, safi_t safi) else if (afi == AFI_IP && safi == SAFI_MULTICAST) return "IPv4 Multicast"; else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) - return "IPv4 VPN"; + return "VPN-IPv4 Unicast"; else if (afi == AFI_IP && safi == SAFI_ENCAP) - return "IPv4 Encap"; + return "ENCAP-IPv4 Unicast"; else if (afi == AFI_IP6 && safi == SAFI_UNICAST) return "IPv6 Unicast"; else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) return "IPv6 Multicast"; else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) - return "IPv6 VPN"; + return "VPN-IPv6 Unicast"; else if (afi == AFI_IP6 && safi == SAFI_ENCAP) - return "IPv6 Encap"; - else - return "Unknown"; -} - -const char * -afi_safi_json (afi_t afi, safi_t safi) -{ - if (afi == AFI_IP && safi == SAFI_UNICAST) - return "IPv4Unicast"; - else if (afi == AFI_IP && safi == SAFI_MULTICAST) - return "IPv4Multicast"; - else if (afi == AFI_IP && safi == SAFI_MPLS_VPN) - return "IPv4VPN"; - else if (afi == AFI_IP && safi == SAFI_ENCAP) - return "IPv4Encap"; - else if (afi == AFI_IP6 && safi == SAFI_UNICAST) - return "IPv6Unicast"; - else if (afi == AFI_IP6 && safi == SAFI_MULTICAST) - return "IPv6Multicast"; - else if (afi == AFI_IP6 && safi == SAFI_MPLS_VPN) - return "IPv6VPN"; - else if (afi == AFI_IP6 && safi == SAFI_ENCAP) - return "IPv6Encap"; + return "ENCAP-IPv6 Unicast"; else return "Unknown"; } @@ -12337,12 +12826,36 @@ DEFUN (show_ip_bgp_neighbors, ALIAS (show_ip_bgp_neighbors, show_ip_bgp_ipv4_neighbors_cmd, - "show ip bgp ipv4 "BGP_SAFI_CMD_STR" neighbors {json}", + "show ip bgp ipv4 (unicast|multicast) neighbors {json}", SHOW_STR IP_STR BGP_STR "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" + "Detailed information on TCP and BGP neighbor connections\n" + "JavaScript Object Notation\n") + +ALIAS (show_ip_bgp_neighbors, + show_ip_bgp_vpnv4_all_neighbors_cmd, + "show ip bgp vpnv4 all neighbors {json}", + SHOW_STR + IP_STR + BGP_STR + "Display VPNv4 NLRI specific information\n" + "Display information about all VPNv4 NLRIs\n" + "Detailed information on TCP and BGP neighbor connections\n" + "JavaScript Object Notation\n") + +ALIAS (show_ip_bgp_neighbors, + show_ip_bgp_vpnv4_rd_neighbors_cmd, + "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors {json}", + SHOW_STR + IP_STR + BGP_STR + "Display VPNv4 NLRI specific information\n" + "Display information for a route distinguisher\n" + "VPN Route Distinguisher\n" "Detailed information on TCP and BGP neighbor connections\n" "JavaScript Object Notation\n") @@ -12382,18 +12895,43 @@ DEFUN (show_ip_bgp_neighbors_peer, ALIAS (show_ip_bgp_neighbors_peer, show_ip_bgp_ipv4_neighbors_peer_cmd, - "show ip bgp ipv4 "BGP_SAFI_CMD_STR" neighbors (A.B.C.D|X:X::X:X|WORD) {json}", + "show ip bgp ipv4 (unicast|multicast) neighbors (A.B.C.D|X:X::X:X|WORD) {json}", SHOW_STR IP_STR BGP_STR "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" "Detailed information on TCP and BGP neighbor connections\n" "Neighbor to display information about\n" "Neighbor to display information about\n" "Neighbor on bgp configured interface\n" "JavaScript Object Notation\n") +ALIAS (show_ip_bgp_neighbors_peer, + show_ip_bgp_vpnv4_all_neighbors_peer_cmd, + "show ip bgp vpnv4 all neighbors A.B.C.D {json}", + SHOW_STR + IP_STR + BGP_STR + "Display VPNv4 NLRI specific information\n" + "Display information about all VPNv4 NLRIs\n" + "Detailed information on TCP and BGP neighbor connections\n" + "Neighbor to display information about\n" + "JavaScript Object Notation\n") + +ALIAS (show_ip_bgp_neighbors_peer, + show_ip_bgp_vpnv4_rd_neighbors_peer_cmd, + "show ip bgp vpnv4 rd ASN:nn_or_IP-address:nn neighbors A.B.C.D {json}", + SHOW_STR + IP_STR + BGP_STR + "Display VPNv4 NLRI specific information\n" + "Display information about all VPNv4 NLRIs\n" + "Detailed information on TCP and BGP neighbor connections\n" + "Neighbor to display information about\n" + "JavaScript Object Notation\n") + ALIAS (show_ip_bgp_neighbors_peer, show_bgp_neighbors_peer_cmd, "show bgp neighbors (A.B.C.D|X:X::X:X|WORD) {json}", @@ -12528,12 +13066,13 @@ DEFUN (show_ip_bgp_paths, DEFUN (show_ip_bgp_ipv4_paths, show_ip_bgp_ipv4_paths_cmd, - "show ip bgp ipv4 "BGP_SAFI_CMD_STR" paths", + "show ip bgp ipv4 (unicast|multicast) paths", SHOW_STR IP_STR BGP_STR "Address family\n" - BGP_SAFI_HELP_STR + "Address Family modifier\n" + "Address Family modifier\n" "Path information\n") { vty_out (vty, "Address Refcnt Path\r\n"); @@ -12688,17 +13227,19 @@ DEFUN (show_bgp_instance_all_ipv6_updgrps, DEFUN (show_bgp_updgrps, show_bgp_updgrps_cmd, - "show bgp "BGP_AFI_SAFI_CMD_STR" update-groups", + "show bgp (ipv4|ipv6) (unicast|multicast|vpn|encap) update-groups", SHOW_STR BGP_STR "Address family\n" - BGP_SAFI_HELP_STR + "Address family\n" + "Address Family modifier\n" + "Address Family modifier\n" "Detailed info about dynamic update groups\n") { afi_t afi; safi_t safi; - afi = bgp_vty_safi_from_arg(argv[0]); + afi = (strcmp(argv[0], "ipv4") == 0) ? AFI_IP : AFI_IP6; safi = bgp_vty_safi_from_arg(argv[1]); return (bgp_show_update_groups(vty, NULL, afi, safi, 0)); } @@ -12764,11 +13305,11 @@ DEFUN (show_bgp_instance_ipv6_updgrps_s, DEFUN (show_bgp_updgrps_s, show_bgp_updgrps_s_cmd, - "show bgp "BGP_AFI_SAFI_CMD_STR" update-groups SUBGROUP-ID", + "show bgp (ipv4|ipv6) (unicast|multicast|vpn|encap) update-groups SUBGROUP-ID", SHOW_STR BGP_STR "Address family\n" - BGP_AFI_SAFI_HELP_STR + AFI_SAFI_STR "Detailed info about v6 dynamic update groups\n" "Specific subgroup to display detailed info for") { @@ -12776,7 +13317,7 @@ DEFUN (show_bgp_updgrps_s, safi_t safi; uint64_t subgrp_id; - afi = bgp_vty_safi_from_arg(argv[0]); + afi = (strcmp(argv[0], "ipv4") == 0) ? AFI_IP : AFI_IP6; safi = bgp_vty_safi_from_arg(argv[1]); VTY_GET_ULL("subgroup-id", subgrp_id, argv[2]); return(bgp_show_update_groups(vty, NULL, afi, safi, subgrp_id)); @@ -12875,11 +13416,11 @@ DEFUN (show_ip_bgp_instance_updgrps_adj, DEFUN (show_bgp_updgrps_afi_adj, show_bgp_updgrps_afi_adj_cmd, - "show bgp "BGP_AFI_SAFI_CMD_STR" update-groups (advertise-queue|advertised-routes|packet-queue)", + "show bgp (ipv4|ipv6) (unicast|multicast|vpn|encap) update-groups (advertise-queue|advertised-routes|packet-queue)", SHOW_STR BGP_STR "Address family\n" - BGP_SAFI_HELP_STR + AFI_SAFI_STR "BGP update groups\n" "Advertisement queue\n" "Announced routes\n" @@ -12889,7 +13430,7 @@ DEFUN (show_bgp_updgrps_afi_adj, afi_t afi; safi_t safi; - afi = bgp_vty_safi_from_arg(argv[0]); + afi = (strcmp(argv[0], "ipv4") == 0) ? AFI_IP : AFI_IP6; safi = bgp_vty_safi_from_arg(argv[1]); show_bgp_updgrps_adj_info_aux(vty, NULL, afi, safi, argv[2], 0); return CMD_SUCCESS; @@ -12969,11 +13510,11 @@ DEFUN (show_ip_bgp_instance_updgrps_adj_s, DEFUN (show_bgp_updgrps_afi_adj_s, show_bgp_updgrps_afi_adj_s_cmd, - "show bgp "BGP_AFI_SAFI_CMD_STR" update-groups SUBGROUP-ID (advertise-queue|advertised-routes|packet-queue)", + "show bgp (ipv4|ipv6) (unicast|multicast|vpn|encap) update-groups SUBGROUP-ID (advertise-queue|advertised-routes|packet-queue)", SHOW_STR BGP_STR "Address family\n" - BGP_SAFI_HELP_STR + AFI_SAFI_STR "BGP update groups\n" "Specific subgroup to display info for\n" "Advertisement queue\n" @@ -12985,7 +13526,7 @@ DEFUN (show_bgp_updgrps_afi_adj_s, safi_t safi; uint64_t subgrp_id; - afi = bgp_vty_safi_from_arg(argv[0]); + afi = (strcmp(argv[0], "ipv4") == 0) ? AFI_IP : AFI_IP6; safi = bgp_vty_safi_from_arg(argv[1]); VTY_GET_ULL("subgroup-id", subgrp_id, argv[2]); @@ -15095,7 +15636,11 @@ bgp_vty_init (void) install_element (BGP_NODE, &address_family_ipv6_safi_cmd); #endif /* HAVE_IPV6 */ install_element (BGP_NODE, &address_family_vpnv4_cmd); + install_element (BGP_NODE, &address_family_vpnv4_unicast_cmd); + install_element (BGP_NODE, &address_family_vpnv6_cmd); + install_element (BGP_NODE, &address_family_vpnv6_unicast_cmd); + install_element (BGP_NODE, &address_family_encap_cmd); install_element (BGP_NODE, &address_family_encapv4_cmd); #ifdef HAVE_IPV6 @@ -15196,6 +15741,18 @@ bgp_vty_init (void) install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_in_cmd); install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_ipv4_in_cmd); install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_in_prefix_filter_cmd); + install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_in_cmd); + install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_in_cmd); + install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_in_cmd); + install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_in_cmd); + install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_soft_in_cmd); + install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_in_cmd); + install_element (ENABLE_NODE, &clear_ip_bgp_all_encap_soft_in_cmd); + install_element (ENABLE_NODE, &clear_ip_bgp_all_encap_in_cmd); + install_element (ENABLE_NODE, &clear_ip_bgp_peer_encap_soft_in_cmd); + install_element (ENABLE_NODE, &clear_ip_bgp_peer_encap_in_cmd); + install_element (ENABLE_NODE, &clear_ip_bgp_as_encap_soft_in_cmd); + install_element (ENABLE_NODE, &clear_ip_bgp_as_encap_in_cmd); install_element (ENABLE_NODE, &clear_bgp_all_soft_in_cmd); install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_in_cmd); install_element (ENABLE_NODE, &clear_bgp_all_in_cmd); @@ -15294,6 +15851,18 @@ bgp_vty_init (void) install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_ipv4_soft_out_cmd); install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_out_cmd); install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_ipv4_out_cmd); + install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_out_cmd); + install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_out_cmd); + install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_out_cmd); + install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_out_cmd); + install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_soft_out_cmd); + install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_out_cmd); + install_element (ENABLE_NODE, &clear_ip_bgp_all_encap_soft_out_cmd); + install_element (ENABLE_NODE, &clear_ip_bgp_all_encap_out_cmd); + install_element (ENABLE_NODE, &clear_ip_bgp_peer_encap_soft_out_cmd); + install_element (ENABLE_NODE, &clear_ip_bgp_peer_encap_out_cmd); + install_element (ENABLE_NODE, &clear_ip_bgp_as_encap_soft_out_cmd); + install_element (ENABLE_NODE, &clear_ip_bgp_as_encap_out_cmd); install_element (ENABLE_NODE, &clear_bgp_all_soft_out_cmd); install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_out_cmd); install_element (ENABLE_NODE, &clear_bgp_all_out_cmd); @@ -15356,6 +15925,12 @@ bgp_vty_init (void) install_element (ENABLE_NODE, &clear_ip_bgp_instance_external_ipv4_soft_cmd); install_element (ENABLE_NODE, &clear_ip_bgp_as_ipv4_soft_cmd); install_element (ENABLE_NODE, &clear_ip_bgp_instance_as_ipv4_soft_cmd); + install_element (ENABLE_NODE, &clear_ip_bgp_all_vpnv4_soft_cmd); + install_element (ENABLE_NODE, &clear_ip_bgp_peer_vpnv4_soft_cmd); + install_element (ENABLE_NODE, &clear_ip_bgp_as_vpnv4_soft_cmd); + install_element (ENABLE_NODE, &clear_ip_bgp_all_encap_soft_cmd); + install_element (ENABLE_NODE, &clear_ip_bgp_peer_encap_soft_cmd); + install_element (ENABLE_NODE, &clear_ip_bgp_as_encap_soft_cmd); install_element (ENABLE_NODE, &clear_bgp_all_soft_cmd); install_element (ENABLE_NODE, &clear_bgp_instance_all_soft_cmd); install_element (ENABLE_NODE, &clear_bgp_peer_soft_cmd); @@ -15407,6 +15982,8 @@ bgp_vty_init (void) install_element (VIEW_NODE, &show_bgp_ipv4_safi_summary_cmd); install_element (VIEW_NODE, &show_ip_bgp_instance_ipv4_summary_cmd); install_element (VIEW_NODE, &show_bgp_instance_ipv4_safi_summary_cmd); + install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_summary_cmd); + install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_summary_cmd); #ifdef HAVE_IPV6 install_element (VIEW_NODE, &show_bgp_summary_cmd); install_element (VIEW_NODE, &show_bgp_instance_summary_cmd); @@ -15422,6 +15999,10 @@ bgp_vty_init (void) install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbors_cmd); install_element (VIEW_NODE, &show_ip_bgp_neighbors_peer_cmd); install_element (VIEW_NODE, &show_ip_bgp_ipv4_neighbors_peer_cmd); + install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_neighbors_cmd); + install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_neighbors_cmd); + install_element (VIEW_NODE, &show_ip_bgp_vpnv4_all_neighbors_peer_cmd); + install_element (VIEW_NODE, &show_ip_bgp_vpnv4_rd_neighbors_peer_cmd); install_element (VIEW_NODE, &show_ip_bgp_instance_neighbors_cmd); install_element (VIEW_NODE, &show_ip_bgp_instance_all_neighbors_cmd); install_element (VIEW_NODE, &show_ip_bgp_instance_neighbors_peer_cmd); diff --git a/bgpd/bgp_vty.h b/bgpd/bgp_vty.h index e3a51ac450..6b4e51bc50 100644 --- a/bgpd/bgp_vty.h +++ b/bgpd/bgp_vty.h @@ -30,20 +30,15 @@ struct bgp; #define BGP_INSTANCE_ALL_CMD "(view|vrf) all" #define BGP_INSTANCE_ALL_HELP_STR "BGP view\nBGP VRF\nAll Views/VRFs\n" -#define BGP_AFI_CMD_STR "(ipv4|ipv6)" -#define BGP_AFI_HELP_STR "Address Family\nAddress Family\n" -#define BGP_SAFI_CMD_STR "(unicast|multicast|vpn|encap)" -#define BGP_SAFI_HELP_STR \ - "Address Family modifier\n" \ - "Address Family modifier\n" \ - "Address Family modifier\n" \ +#define AFI_SAFI_STR \ + "Address family\n" \ + "Address Family modifier\n" \ + "Address Family modifier\n" \ + "Address Family modifier\n" \ "Address Family modifier\n" -#define BGP_AFI_SAFI_CMD_STR BGP_AFI_CMD_STR" "BGP_SAFI_CMD_STR -#define BGP_AFI_SAFI_HELP_STR BGP_AFI_HELP_STR BGP_SAFI_HELP_STR extern void bgp_vty_init (void); extern const char *afi_safi_print (afi_t, safi_t); -extern const char *afi_safi_json (afi_t, safi_t); extern int bgp_config_write_update_delay (struct vty *, struct bgp *); extern int bgp_config_write_wpkt_quanta(struct vty *vty, struct bgp *bgp); extern int bgp_config_write_listen(struct vty *vty, struct bgp *bgp); @@ -58,9 +53,6 @@ bgp_parse_afi(const char *str, afi_t *afi); extern int bgp_parse_safi(const char *str, safi_t *safi); -extern afi_t -bgp_vty_afi_from_arg(const char *afi_str); - extern safi_t bgp_vty_safi_from_arg(const char *safi_str); From 3edabb996f2b017940b28f64119da33567d4847c Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 13 Jan 2017 12:46:58 -0500 Subject: [PATCH 101/107] zebra: Fixup paranthesis mistake Signed-off-by: Donald Sharp --- zebra/zebra_routemap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zebra/zebra_routemap.c b/zebra/zebra_routemap.c index 27bff68c75..f8f3c4318d 100644 --- a/zebra/zebra_routemap.c +++ b/zebra/zebra_routemap.c @@ -1240,8 +1240,8 @@ route_set_src_compile (const char *arg) { union g_addr src, *psrc; - if (inet_pton(AF_INET6, arg, &src.ipv6) == 1 || - src.ipv4.s_addr && (inet_pton(AF_INET, arg, &src.ipv4) == 1)) + if ((inet_pton(AF_INET6, arg, &src.ipv6) == 1) || + (src.ipv4.s_addr && (inet_pton(AF_INET, arg, &src.ipv4) == 1))) { psrc = XMALLOC (MTYPE_ROUTE_MAP_COMPILED, sizeof (union g_addr)); *psrc = src; From 386ea4d526de953f3648dfa286f77e5b0a8eef12 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 13 Jan 2017 14:32:02 -0500 Subject: [PATCH 102/107] bgpd: Remove missed HAVE_IPV6 Not sure how I missed this :( Signed-off-by: Donald Sharp --- bgpd/bgp_open.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/bgpd/bgp_open.c b/bgpd/bgp_open.c index af3c0486e5..9e1b4392c9 100644 --- a/bgpd/bgp_open.c +++ b/bgpd/bgp_open.c @@ -1302,7 +1302,6 @@ bgp_open_capability (struct stream *s, struct peer *peer) stream_putc (s, 0); stream_putc (s, SAFI_ENCAP); } -#ifdef HAVE_IPV6 /* Currently supporting RFC-5549 for Link-Local peering only */ if (CHECK_FLAG (peer->flags, PEER_FLAG_CAPABILITY_ENHE) && peer->su.sa.sa_family == AF_INET6 && @@ -1371,7 +1370,6 @@ bgp_open_capability (struct stream *s, struct peer *peer) stream_putc (s, 0); stream_putc (s, SAFI_ENCAP); } -#endif /* HAVE_IPV6 */ /* Route refresh. */ SET_FLAG (peer->cap, PEER_CAP_REFRESH_ADV); From 602ba9bd8b118d3c1302e890010ca7c5d94e0ff5 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Mon, 16 Jan 2017 08:57:20 -0500 Subject: [PATCH 103/107] zebra: Some code cleanup based upon Review. Cleanup 2 spots in the code: 1) In if_netlink.c -> combine multi-line if statement into 1 line 2) In zebra_ptm.c -> only handle code that needs to be inside the if statement in the if statement. Signed-off-by: Donald Sharp --- zebra/if_netlink.c | 3 +-- zebra/zebra_ptm.c | 15 +++++---------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/zebra/if_netlink.c b/zebra/if_netlink.c index 678c217321..3665ad061d 100644 --- a/zebra/if_netlink.c +++ b/zebra/if_netlink.c @@ -465,8 +465,7 @@ netlink_interface_addr (struct sockaddr_nl *snl, struct nlmsghdr *h, zns = zebra_ns_lookup (ns_id); ifa = NLMSG_DATA (h); - if (ifa->ifa_family != AF_INET - && ifa->ifa_family != AF_INET6) + if (ifa->ifa_family != AF_INET && ifa->ifa_family != AF_INET6) return 0; if (h->nlmsg_type != RTM_NEWADDR && h->nlmsg_type != RTM_DELADDR) diff --git a/zebra/zebra_ptm.c b/zebra/zebra_ptm.c index 194833f1e9..f3f849a6f4 100644 --- a/zebra/zebra_ptm.c +++ b/zebra/zebra_ptm.c @@ -891,17 +891,12 @@ zebra_ptm_bfd_dst_deregister (struct zserv *client, int sock, u_short length, stream_get(&src_p.u.prefix, s, src_p.prefixlen); if (src_p.family == AF_INET) - { - inet_ntop(AF_INET, &src_p.u.prefix4, buf, sizeof(buf)); - ptm_lib_append_msg(ptm_hdl, out_ctxt, - ZEBRA_PTM_BFD_SRC_IP_FIELD, buf); - } + inet_ntop(AF_INET, &src_p.u.prefix4, buf, sizeof(buf)); else - { - inet_ntop(AF_INET6, &src_p.u.prefix6, buf, sizeof(buf)); - ptm_lib_append_msg(ptm_hdl, out_ctxt, - ZEBRA_PTM_BFD_SRC_IP_FIELD, buf); - } + inet_ntop(AF_INET6, &src_p.u.prefix6, buf, sizeof(buf)); + ptm_lib_append_msg(ptm_hdl, out_ctxt, + ZEBRA_PTM_BFD_SRC_IP_FIELD, buf); + if (zvrf_id (zvrf) != VRF_DEFAULT) ptm_lib_append_msg(ptm_hdl, out_ctxt, ZEBRA_PTM_BFD_VRF_NAME_FIELD, zvrf_name (zvrf)); From cc5eb677527ce107000da7de7cf69500cc64c946 Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Mon, 24 Oct 2016 15:16:36 +0200 Subject: [PATCH 104/107] bgpd: str2prefix_rd support for AS4 format This commit improves the ability for str2prefix_rd command to support AS4 format. Until now, only AS2 format and IP format was supported. Signed-off-by: Philippe Guibert --- bgpd/bgp_mplsvpn.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c index b710e0b03b..6c96dc2907 100644 --- a/bgpd/bgp_mplsvpn.c +++ b/bgpd/bgp_mplsvpn.c @@ -337,12 +337,24 @@ str2prefix_rd (const char *str, struct prefix_rd *prd) if (! p2) { + unsigned long as_val; + if (! all_digit (half)) goto out; - stream_putw (s, RD_TYPE_AS); - stream_putw (s, atoi (half)); - stream_putl (s, atol (p + 1)); + as_val = atol(half); + if (as_val > 0xffff) + { + stream_putw (s, RD_TYPE_AS4); + stream_putl (s, atol (half)); + stream_putw (s, atol (p + 1)); + } + else + { + stream_putw (s, RD_TYPE_AS); + stream_putw (s, atol (half)); + stream_putl (s, atol (p + 1)); + } } else { From cf6c0c088ecaeca16784c313234df6e11cd8584f Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Fri, 6 Jan 2017 13:35:40 +0100 Subject: [PATCH 105/107] bgpd: fix nexthop comparison for nexthop vpnv6 attribute As nexthop attribute for vpnv6 also contains a blank RD and a blank tag, the IPv6 address length increases from 16 to 24 bytes. The same was observed for vpnv4 nexthop, but was missing for VPNv6. The same is done for martian nexthop debugging. Signed-off-by: Philippe Guibert --- bgpd/bgp_mpath.c | 2 +- bgpd/bgp_route.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/bgpd/bgp_mpath.c b/bgpd/bgp_mpath.c index c9af8419f2..dc8904ced2 100644 --- a/bgpd/bgp_mpath.c +++ b/bgpd/bgp_mpath.c @@ -113,7 +113,6 @@ bgp_info_nexthop_cmp (struct bgp_info *bi1, struct bgp_info *bi2) ae2 = bi2->attr->extra; compare = IPV4_ADDR_CMP (&bi1->attr->nexthop, &bi2->attr->nexthop); - if (!compare && ae1 && ae2) { if (ae1->mp_nexthop_len == ae2->mp_nexthop_len) @@ -127,6 +126,7 @@ bgp_info_nexthop_cmp (struct bgp_info *bi1, struct bgp_info *bi2) break; #ifdef HAVE_IPV6 case BGP_ATTR_NHLEN_IPV6_GLOBAL: + case BGP_ATTR_NHLEN_VPNV6_GLOBAL: compare = IPV6_ADDR_CMP (&ae1->mp_nexthop_global, &ae2->mp_nexthop_global); break; diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 9e1ae854d4..90904e946c 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -2321,6 +2321,7 @@ bgp_update_martian_nexthop (struct bgp *bgp, afi_t afi, safi_t safi, struct attr #ifdef HAVE_IPV6 case BGP_ATTR_NHLEN_IPV6_GLOBAL: case BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL: + case BGP_ATTR_NHLEN_VPNV6_GLOBAL: ret = (IN6_IS_ADDR_UNSPECIFIED(&attre->mp_nexthop_global) || IN6_IS_ADDR_LOOPBACK(&attre->mp_nexthop_global) || IN6_IS_ADDR_MULTICAST(&attre->mp_nexthop_global)); From bac21a7c4ba2dd131e8e82a13ab57a1a295a52ef Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Tue, 17 Jan 2017 17:51:40 +0100 Subject: [PATCH 106/107] bgpd: avoid recalculating as_val value in str2prefix_rd This is an optimisation that consists in avoiding calling twice atol() function when converting an ext. community to an AS4 byte or a standard AS byte value. Signed-off-by: Philippe Guibert --- bgpd/bgp_mplsvpn.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c index 6c96dc2907..e494f8cbb7 100644 --- a/bgpd/bgp_mplsvpn.c +++ b/bgpd/bgp_mplsvpn.c @@ -346,13 +346,13 @@ str2prefix_rd (const char *str, struct prefix_rd *prd) if (as_val > 0xffff) { stream_putw (s, RD_TYPE_AS4); - stream_putl (s, atol (half)); + stream_putl (s, as_val); stream_putw (s, atol (p + 1)); } else { stream_putw (s, RD_TYPE_AS); - stream_putw (s, atol (half)); + stream_putw (s, as_val); stream_putl (s, atol (p + 1)); } } From 7758fe9f6098498afc9d25fac90dc4c9ed0ecfbc Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Fri, 13 Jan 2017 15:31:04 +0100 Subject: [PATCH 107/107] build: fix several ldpd XML-CLI build issues - the location of ldp_vty_cmds.c can be either in srcdir or builddir, depending on whether a premade file from a dist tarball is used - perl libxml support is only needed if that file is absent - the actual perl script wasn't even included in the dist tarball - the include location doesn't work when srcdir != builddir Signed-off-by: David Lamparter --- configure.ac | 10 ++++++++-- ldpd/Makefile.am | 2 ++ ldpd/ldp_vty.xml | 2 +- tools/Makefile.am | 4 +++- vtysh/Makefile.am | 25 +++++++++++++++++++------ 5 files changed, 33 insertions(+), 10 deletions(-) diff --git a/configure.ac b/configure.ac index fcc0de1b22..297e5cea55 100755 --- a/configure.ac +++ b/configure.ac @@ -292,8 +292,6 @@ if test $ac_cv_lib_json_c_json_object_get = no; then fi fi -AX_PROG_PERL_MODULES(XML::LibXML, , AC_MSG_ERROR(XML::LibXML perl module is needed to compile)) - AC_ARG_ENABLE([dev_build], AS_HELP_STRING([--enable-dev-build], [build for development])) @@ -1163,6 +1161,14 @@ AM_CONDITIONAL(OSPFD, test "x$OSPFD" = "xospfd") if test "${enable_ldpd}" = "no";then LDPD="" else + AX_PROG_PERL_MODULES(XML::LibXML, , [ + if test -f "${srcdir}/ldpd/ldp_vty_cmds.c"; then + AC_MSG_WARN([XML::LibXML perl module not found, using pregenerated ldp_vty_cmds.c]) + else + AC_MSG_ERROR([XML::LibXML perl module not found and pregenerated ldp_vty_cmds.c missing]) + fi + ]) + LDPD="ldpd" AC_DEFINE(HAVE_LDPD, 1, ldpd) fi diff --git a/ldpd/Makefile.am b/ldpd/Makefile.am index e7da216a65..6dc7c077de 100644 --- a/ldpd/Makefile.am +++ b/ldpd/Makefile.am @@ -3,6 +3,7 @@ AM_CPPFLAGS = -I.. -I$(top_srcdir) -I$(top_srcdir)/lib -I$(top_builddir)/lib DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\" INSTALL_SDATA=@INSTALL@ -m 600 +EXTRA_DIST= AM_CFLAGS = $(WERROR) @@ -10,6 +11,7 @@ noinst_LIBRARIES = libldp.a sbin_PROGRAMS = ldpd BUILT_SOURCES = ldp_vty_cmds.c +EXTRA_DIST += ldp_vty.xml libldp_a_SOURCES = \ accept.c address.c adjacency.c control.c hello.c init.c interface.c \ diff --git a/ldpd/ldp_vty.xml b/ldpd/ldp_vty.xml index ee5c6e4df2..9103dd0898 100644 --- a/ldpd/ldp_vty.xml +++ b/ldpd/ldp_vty.xml @@ -1,5 +1,5 @@ - +