From bb1e60c3a17d7a6168f450d909cf51918e85f7ee Mon Sep 17 00:00:00 2001 From: Hung-Weic Chiu Date: Wed, 10 May 2017 01:57:11 +0000 Subject: [PATCH 01/10] - Solve the Coverity Scan PW.ASSIGN_WHERE_COMPARE_MEANT - Minor refactoring Signed-off-by: Hung-Weic Chiu --- lib/command.c | 5 ++++- tools/permutations.c | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/command.c b/lib/command.c index 43b2c478a0..ff921ff402 100644 --- a/lib/command.c +++ b/lib/command.c @@ -1615,8 +1615,11 @@ permute (struct graph_node *start, struct vty *vty) bool skip = false; if (stok->type == FORK_TKN && tok->type != FORK_TKN) for (ALL_LIST_ELEMENTS_RO (position, ln, gnn)) - if (gnn == gn && (skip = true)) + if (gnn == gn) + { + skip = true; break; + } if (!skip) permute (gn, vty); } diff --git a/tools/permutations.c b/tools/permutations.c index 6e1a37981a..88d1464697 100644 --- a/tools/permutations.c +++ b/tools/permutations.c @@ -87,8 +87,11 @@ permute (struct graph_node *start) bool skip = false; if (stok->type == FORK_TKN && tok->type != FORK_TKN) for (ALL_LIST_ELEMENTS_RO (position, ln, gnn)) - if (gnn == gn && (skip = true)) + if (gnn == gn) + { + skip = true; break; + } if (!skip) permute (gn); } From 4afc1b4d4b88484379a78d794e9eee7374cb8b08 Mon Sep 17 00:00:00 2001 From: Hung-Weic Chiu Date: Wed, 10 May 2017 02:51:28 +0000 Subject: [PATCH 02/10] Address the error "Dead assignment" of static analysif - Refer to https://ci1.netdef.org/browse/FRR-FRR4-44/artifact/shared/static_analysis/index.html - Remove unused variable Signed-off-by: Hung-Weic Chiu --- bgpd/bgp_btoa.c | 2 +- bgpd/bgpd.c | 2 +- bgpd/rfapi/rfapi_rib.c | 1 - isisd/isis_pdu.c | 1 - ospfd/ospf_flood.c | 1 - ospfd/ospf_te.c | 4 ++-- ripd/ripd.c | 1 - ripngd/ripngd.c | 12 ++++++------ zebra/label_manager.c | 1 - 9 files changed, 10 insertions(+), 15 deletions(-) diff --git a/bgpd/bgp_btoa.c b/bgpd/bgp_btoa.c index 37bef9b85d..d3162a4ea5 100644 --- a/bgpd/bgp_btoa.c +++ b/bgpd/bgp_btoa.c @@ -238,7 +238,7 @@ main (int argc, char **argv) printf ("len: %zd\n", len); - ret = fread (s->data + 12, len, 1, fp); + fread (s->data + 12, len, 1, fp); if (feof (fp)) { printf ("ENDOF FILE 2\n"); diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index 9af26f5510..24ef4465fe 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -6116,7 +6116,7 @@ peer_ttl_security_hops_set (struct peer *peer, int gtsm_hops) * min & max ttls on the socket. The return value is * irrelevant. */ - ret = peer_ebgp_multihop_set (peer, MAXTTL); + peer_ebgp_multihop_set (peer, MAXTTL); } } } diff --git a/bgpd/rfapi/rfapi_rib.c b/bgpd/rfapi/rfapi_rib.c index d633023dcf..8fb2fe44ed 100644 --- a/bgpd/rfapi/rfapi_rib.c +++ b/bgpd/rfapi/rfapi_rib.c @@ -1306,7 +1306,6 @@ callback: if (!printedprefix) { vnc_zlog_debug_verbose ("%s: For prefix %s (d)", __func__, buf_prefix); - printedprefix = 1; } vnc_zlog_debug_verbose ("%s: delete_list has %d elements", __func__, delete_list->count); diff --git a/isisd/isis_pdu.c b/isisd/isis_pdu.c index 5fbf6c194e..a41581ff02 100644 --- a/isisd/isis_pdu.c +++ b/isisd/isis_pdu.c @@ -1458,7 +1458,6 @@ process_lsp (int level, struct isis_circuit *circuit, const u_char *ssnpa) ((level == IS_LEVEL_2) && (circuit->u.p2p.neighbor->adj_usage == ISIS_ADJ_LEVEL1))) return ISIS_WARNING; /* Silently discard */ - adj = circuit->u.p2p.neighbor; } } diff --git a/ospfd/ospf_flood.c b/ospfd/ospf_flood.c index 417a7aa8d2..4cc28f7486 100644 --- a/ospfd/ospf_flood.c +++ b/ospfd/ospf_flood.c @@ -260,7 +260,6 @@ ospf_flood (struct ospf *ospf, struct ospf_neighbor *nbr, (void *)current, dump_lsa_key (new)); - lsa_ack_flag = 0; oi = nbr->oi; /* If there is already a database copy, and if the diff --git a/ospfd/ospf_te.c b/ospfd/ospf_te.c index 449f9e7b97..a89d67c6bb 100644 --- a/ospfd/ospf_te.c +++ b/ospfd/ospf_te.c @@ -1480,12 +1480,12 @@ ospf_mpls_te_lsa_originate_as (void *arg) if (IS_FLOOD_AS (lp->type)) { top = (struct ospf *) arg; - rc = ospf_mpls_te_lsa_originate2 (top, lp); + ospf_mpls_te_lsa_originate2 (top, lp); } else { area = (struct ospf_area *) arg; - rc = ospf_mpls_te_lsa_originate1 (area, lp); + ospf_mpls_te_lsa_originate1 (area, lp); } } diff --git a/ripd/ripd.c b/ripd/ripd.c index b668b0a0b4..9e8c21da31 100644 --- a/ripd/ripd.c +++ b/ripd/ripd.c @@ -2398,7 +2398,6 @@ rip_output_process (struct connected *ifc, struct sockaddr_in *to, if (ret >= 0 && IS_RIP_DEBUG_SEND) rip_packet_dump ((struct rip_packet *)STREAM_DATA (s), stream_get_endp (s), "SEND"); - num = 0; stream_reset (s); } diff --git a/ripngd/ripngd.c b/ripngd/ripngd.c index a883bec3c4..8ea66517c3 100644 --- a/ripngd/ripngd.c +++ b/ripngd/ripngd.c @@ -970,11 +970,11 @@ ripng_redistribute_add (int type, int sub_type, struct prefix_ipv6 *p, } } - rinfo = ripng_ecmp_replace (&newinfo); + ripng_ecmp_replace (&newinfo); route_unlock_node (rp); } else - rinfo = ripng_ecmp_add (&newinfo); + ripng_ecmp_add (&newinfo); if (IS_RIPNG_DEBUG_EVENT) { if (!nexthop) @@ -2021,11 +2021,11 @@ DEFUN (show_ipv6_ripng, p = (struct prefix_ipv6 *) &rp->p; #ifdef DEBUG - len = vty_out (vty, "R(a) %d/%d %s/%d ", + vty_out (vty, "R(a) %d/%d %s/%d ", aggregate->count, aggregate->suppress, inet6_ntoa (p->prefix), p->prefixlen); #else - len = vty_out (vty, "R(a) %s/%d ", + vty_out (vty, "R(a) %s/%d ", inet6_ntoa (p->prefix), p->prefixlen); #endif /* DEBUG */ vty_out (vty, "%s", VTY_NEWLINE); @@ -2043,13 +2043,13 @@ DEFUN (show_ipv6_ripng, p = (struct prefix_ipv6 *) &rp->p; #ifdef DEBUG - len = vty_out (vty, "%c(%s) 0/%d %s/%d ", + vty_out (vty, "%c(%s) 0/%d %s/%d ", zebra_route_char(rinfo->type), ripng_route_subtype_print(rinfo), rinfo->suppress, inet6_ntoa (p->prefix), p->prefixlen); #else - len = vty_out (vty, "%c(%s) %s/%d ", + vty_out (vty, "%c(%s) %s/%d ", zebra_route_char(rinfo->type), ripng_route_subtype_print(rinfo), inet6_ntoa (p->prefix), p->prefixlen); diff --git a/zebra/label_manager.c b/zebra/label_manager.c index bf67141cd4..7dbb36edb8 100644 --- a/zebra/label_manager.c +++ b/zebra/label_manager.c @@ -205,7 +205,6 @@ struct label_manager_chunk *assign_label_chunk(u_char proto, u_short instance, struct label_manager_chunk *lmc; struct listnode *node; - node = lbl_mgr.lc_list->head; /* first check if there's one available */ for (ALL_LIST_ELEMENTS_RO(lbl_mgr.lc_list, node, lmc)) { if (lmc->proto == NO_PROTO && lmc->end - lmc->start + 1 == size) { From 6500e013dbc2acd10d619f899c9a0f93b008d5fa Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Tue, 9 May 2017 21:04:00 +0000 Subject: [PATCH 03/10] vtysh: add \n to 'router rip[ng]' docstrings Signed-off-by: Quentin Young --- vtysh/vtysh.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c index 682cd99c23..5bb969bef7 100644 --- a/vtysh/vtysh.c +++ b/vtysh/vtysh.c @@ -1315,22 +1315,22 @@ DEFUNSH (VTYSH_RIPD, } DEFUNSH (VTYSH_RIPD, - router_rip, - router_rip_cmd, - "router rip", - ROUTER_STR - "RIP") + router_rip, + router_rip_cmd, + "router rip", + ROUTER_STR + "RIP\n") { vty->node = RIP_NODE; return CMD_SUCCESS; } DEFUNSH (VTYSH_RIPNGD, - router_ripng, - router_ripng_cmd, - "router ripng", - ROUTER_STR - "RIPng") + router_ripng, + router_ripng_cmd, + "router ripng", + ROUTER_STR + "RIPng\n") { vty->node = RIPNG_NODE; return CMD_SUCCESS; From 86fb2ae8414acafe417dc8a45e080b9cdb9e377e Mon Sep 17 00:00:00 2001 From: Adam Fitzgerald Date: Thu, 11 May 2017 21:03:23 +1000 Subject: [PATCH 04/10] added troubleshooting section to debian 8 build doc --- doc/Building_FRR_on_Debian8.md | 39 ++++++++++++++++++++++++++++++---- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/doc/Building_FRR_on_Debian8.md b/doc/Building_FRR_on_Debian8.md index a42ca6d781..1a961f752a 100644 --- a/doc/Building_FRR_on_Debian8.md +++ b/doc/Building_FRR_on_Debian8.md @@ -4,8 +4,8 @@ Building FRR on Debian 8 from Git Source Debian 8 restrictions: ---------------------- -- MPLS is not supported on `Debian 8` with default kernel. MPLS requires - Linux Kernel 4.5 or higher (LDP can be built, but may have limited use +- MPLS is not supported on `Debian 8` with default kernel. MPLS requires + Linux Kernel 4.5 or higher (LDP can be built, but may have limited use without MPLS) Install required packages @@ -24,7 +24,7 @@ Install newer pytest (>3.0) from pip Get FRR, compile it and install it (from Git) --------------------------------------------- -**This assumes you want to build and install FRR from source and not using +**This assumes you want to build and install FRR from source and not using any packages** ### Add frr groups and user @@ -87,7 +87,7 @@ an example.) ### Enable IP & IPv6 forwarding -Edit `/etc/sysctl.conf` and uncomment the following values (ignore the +Edit `/etc/sysctl.conf` and uncomment the following values (ignore the other settings) # Uncomment the next line to enable packet forwarding for IPv4 @@ -99,3 +99,34 @@ other settings) net.ipv6.conf.all.forwarding=1 **Reboot** or use `sysctl -p` to apply the same config to the running system + +### Troubleshooting + +**Local state directory** + +The local state directory must exist and have the correct permissions applied +for the frrouting daemons to start. In the above ./configure example the +local state directory is set to /var/run/frr (--localstatedir=/var/run/frr) +Debian considers /var/run/frr to be temporary and this is removed after a +reboot. + +When using a different local state directory you need to create the new +directory and change the ownership to the frr user, for example: + + mkdir /var/opt/frr + chown frr /var/opt/frr + +**Shared library error** + +If you try and start any of the frrouting daemons you may see the below error +due to the frrouting shared library directory not being found: + + ./zebra: error while loading shared libraries: libfrr.so.0: cannot open shared object file: No such file or directory + +The fix is to add the following line to /etc/ld.so.conf which will continue to +reference the library directory after the system reboots. To load the library +directory path immediately run the ldconfig command after adding the line to +the file eg: + + echo include /usr/local/lib >> /etc/ld.so.conf + ldconfig From 42025b43f265c042116d9432cf4d34aeb79152f6 Mon Sep 17 00:00:00 2001 From: Philippe Guibert Date: Wed, 10 May 2017 19:27:33 +0200 Subject: [PATCH 05/10] bgpd: fixup bgpd: allow VPN next hop to be different AFI than NLRI next hop for EVPN In the case of EVPN, add the nexthop attribute. Signed-off-by: Philippe Guibert --- bgpd/bgp_attr.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c index 1fccd25c8a..61dcbd1b29 100644 --- a/bgpd/bgp_attr.c +++ b/bgpd/bgp_attr.c @@ -2737,8 +2737,9 @@ bgp_packet_mpattr_start (struct stream *s, afi_t afi, safi_t safi, afi_t nh_afi, stream_putw (s, pkt_afi); /* AFI */ stream_putc (s, pkt_safi); /* SAFI */ - - if (nh_afi == AFI_MAX) + if (afi == AFI_L2VPN) + nh_afi = AFI_L2VPN; + else if (nh_afi == AFI_MAX) nh_afi = BGP_NEXTHOP_AFI_FROM_NHLEN(attr->extra->mp_nexthop_len); /* Nexthop */ switch (nh_afi) From cefd435b19fda334c102ab020254658bee72ccec Mon Sep 17 00:00:00 2001 From: Lou Berger Date: Thu, 11 May 2017 08:46:48 -0400 Subject: [PATCH 06/10] bgpd: Issue #198 - clean up duplicate command resulting from CLI refactoring Signed-off-by: Lou Berger --- bgpd/bgp_encap.c | 137 ----------------------------------------------- 1 file changed, 137 deletions(-) diff --git a/bgpd/bgp_encap.c b/bgpd/bgp_encap.c index 603979942d..23be34c63b 100644 --- a/bgpd/bgp_encap.c +++ b/bgpd/bgp_encap.c @@ -577,73 +577,6 @@ DEFUN (show_bgp_ipv6_encap_rd_tags, return bgp_show_encap (vty, AFI_IP6, &prd, bgp_show_type_normal, NULL, 1); } -DEFUN (show_bgp_ipv4_encap_neighbor_routes, - show_bgp_ipv4_encap_neighbor_routes_cmd, - "show [ip] bgp ipv4 encap neighbors A.B.C.D routes", - SHOW_STR - IP_STR - BGP_STR - "Address Family\n" - "Display ENCAP NLRI specific information\n" - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Display routes learned from neighbor\n") -{ - int idx_peer = 0; - union sockunion *su; - struct peer *peer; - - argv_find(argv, argc, "A.B.C.D", &idx_peer); - su = sockunion_str2su (argv[idx_peer]->arg); - - if (!su) - { - vty_out (vty, "Malformed address: %s%s", argv[idx_peer]->arg, VTY_NEWLINE); - return CMD_WARNING; - } - - peer = peer_lookup (NULL, su); - if (! peer || ! peer->afc[AFI_IP][SAFI_ENCAP]) - { - vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); - return CMD_WARNING; - } - - return bgp_show_encap (vty, AFI_IP, NULL, bgp_show_type_neighbor, su, 0); -} - -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", - SHOW_STR - IP_STR - BGP_STR - "Address Family\n" - "Display ENCAP NLRI specific information\n" - "Detailed information on TCP and BGP neighbor connections\n" - "Neighbor to display information about\n" - "Display routes learned from neighbor\n") -{ - int idx_peer = 5; - union sockunion su; - struct peer *peer; - - if (str2sockunion(argv[idx_peer]->arg, &su)) - { - vty_out (vty, "Malformed address: %s%s", argv[idx_peer]->arg, VTY_NEWLINE); - return CMD_WARNING; - } - - peer = peer_lookup (NULL, &su); - if (! peer || ! peer->afc[AFI_IP6][SAFI_ENCAP]) - { - vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); - return CMD_WARNING; - } - - return bgp_show_encap (vty, AFI_IP6, NULL, bgp_show_type_neighbor, &su, 0); -} - DEFUN (show_bgp_ipv4_encap_rd_neighbor_routes, show_bgp_ipv4_encap_rd_neighbor_routes_cmd, "show [ip] bgp ipv4 encap rd ASN:nn_or_IP-address:nn neighbors routes", @@ -734,72 +667,6 @@ DEFUN (show_bgp_ipv6_encap_rd_neighbor_routes, return bgp_show_encap (vty, AFI_IP6, &prd, bgp_show_type_neighbor, &su, 0); } -DEFUN (show_bgp_ipv4_encap_neighbor_advertised_routes, - show_bgp_ipv4_encap_neighbor_advertised_routes_cmd, - "show [ip] bgp ipv4 encap neighbors A.B.C.D advertised-routes", - SHOW_STR - IP_STR - BGP_STR - "Address Family\n" - "Display ENCAP NLRI specific information\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") -{ - int idx_peer = 5; - int ret; - struct peer *peer; - union sockunion su; - - ret = str2sockunion (argv[idx_peer]->arg, &su); - if (ret < 0) - { - vty_out (vty, "%% Malformed address: %s%s", argv[idx_peer]->arg, VTY_NEWLINE); - return CMD_WARNING; - } - peer = peer_lookup (NULL, &su); - if (! peer || ! peer->afc[AFI_IP][SAFI_ENCAP]) - { - vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); - return CMD_WARNING; - } - - return show_adj_route_encap (vty, peer, NULL); -} - -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", - SHOW_STR - IP_STR - BGP_STR - "Address Family\n" - "Display ENCAP NLRI specific information\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") -{ - int idx_peer = 5; - int ret; - struct peer *peer; - union sockunion su; - - ret = str2sockunion (argv[idx_peer]->arg, &su); - if (ret < 0) - { - vty_out (vty, "%% Malformed address: %s%s", argv[idx_peer]->arg, VTY_NEWLINE); - return CMD_WARNING; - } - peer = peer_lookup (NULL, &su); - if (! peer || ! peer->afc[AFI_IP6][SAFI_ENCAP]) - { - vty_out (vty, "%% No such neighbor or address family%s", VTY_NEWLINE); - return CMD_WARNING; - } - - return show_adj_route_encap (vty, peer, NULL); -} - DEFUN (show_bgp_ipv4_encap_rd_neighbor_advertised_routes, show_bgp_ipv4_encap_rd_neighbor_advertised_routes_cmd, "show [ip] bgp ipv4 encap rd ASN:nn_or_IP-address:nn neighbors advertised-routes", @@ -899,16 +766,12 @@ bgp_encap_init (void) install_element (VIEW_NODE, &show_bgp_ipv4_encap_rd_cmd); install_element (VIEW_NODE, &show_bgp_ipv4_encap_tags_cmd); install_element (VIEW_NODE, &show_bgp_ipv4_encap_rd_tags_cmd); - install_element (VIEW_NODE, &show_bgp_ipv4_encap_neighbor_routes_cmd); install_element (VIEW_NODE, &show_bgp_ipv4_encap_rd_neighbor_routes_cmd); - 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); install_element (VIEW_NODE, &show_bgp_ipv6_encap_rd_cmd); install_element (VIEW_NODE, &show_bgp_ipv6_encap_tags_cmd); install_element (VIEW_NODE, &show_bgp_ipv6_encap_rd_tags_cmd); - install_element (VIEW_NODE, &show_bgp_ipv6_encap_neighbor_routes_cmd); 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); } From ff595214665edcf0564c7f08693e1eacb03f39c4 Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Fri, 12 May 2017 09:19:42 -0300 Subject: [PATCH 07/10] bgpd: fix 'show bgp [...] longer-prefixes' Signed-off-by: Renato Westphal --- bgpd/bgp_route.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index d3a6e7e906..195e3811d4 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -8421,7 +8421,7 @@ DEFUN (show_ip_bgp, } /* prefix-longer */ if (argv_find(argv, argc, "A.B.C.D/M", &idx) || argv_find(argv, argc, "X:X::X:X/M", &idx)) - return bgp_show_prefix_longer (vty, bgp, argv[idx + 1]->arg, afi, safi, bgp_show_type_prefix_longer); + return bgp_show_prefix_longer (vty, bgp, argv[idx]->arg, afi, safi, bgp_show_type_prefix_longer); if (safi == SAFI_MPLS_VPN) return bgp_show_mpls_vpn (vty, afi, NULL, bgp_show_type_normal, NULL, 0, uj); From 92a8bd6e7a9b24a350e45c1a3db939b0f591fa0a Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Fri, 12 May 2017 09:40:21 -0300 Subject: [PATCH 08/10] bgpd: fix duplicate install of command Only happens when FRR is configured with --enable-oldvpn-commands. Signed-off-by: Renato Westphal --- bgpd/bgp_mplsvpn.c | 1 - 1 file changed, 1 deletion(-) diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c index 421b62fba0..97b40df28a 100644 --- a/bgpd/bgp_mplsvpn.c +++ b/bgpd/bgp_mplsvpn.c @@ -1196,7 +1196,6 @@ bgp_mplsvpn_init (void) install_element (VIEW_NODE, &show_ip_bgp_vpn_rd_cmd); #ifdef KEEP_OLD_VPN_COMMANDS 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); From 7c7f4284cf79cf973f9d50b2a40889e09e328d72 Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Fri, 12 May 2017 11:01:02 -0300 Subject: [PATCH 09/10] bgpd: fix segfault with '[no] bgp network import-check' These commands were causing bgpd to crash if a static VPN route was configured. While here, fix a bug in bgp_static_add() and bgp_static_delete(). Signed-off-by: Renato Westphal --- bgpd/bgp_route.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 195e3811d4..de51de7a66 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -4314,7 +4314,7 @@ bgp_static_add (struct bgp *bgp) for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm)) { - bgp_static = rn->info; + bgp_static = rm->info; bgp_static_update_safi (bgp, &rm->p, bgp_static, afi, safi); } } @@ -4348,7 +4348,7 @@ bgp_static_delete (struct bgp *bgp) for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm)) { - bgp_static = rn->info; + bgp_static = rm->info; bgp_static_withdraw_safi (bgp, &rm->p, AFI_IP, safi, (struct prefix_rd *)&rn->p, @@ -4375,6 +4375,8 @@ bgp_static_redo_import_check (struct bgp *bgp) afi_t afi; safi_t safi; struct bgp_node *rn; + struct bgp_node *rm; + struct bgp_table *table; struct bgp_static *bgp_static; /* Use this flag to force reprocessing of the route */ @@ -4384,8 +4386,21 @@ bgp_static_redo_import_check (struct bgp *bgp) for (rn = bgp_table_top (bgp->route[afi][safi]); rn; rn = bgp_route_next (rn)) if (rn->info != NULL) { - bgp_static = rn->info; - bgp_static_update (bgp, &rn->p, bgp_static, afi, safi); + if ((safi == SAFI_MPLS_VPN) || (safi == SAFI_ENCAP) || (safi == SAFI_EVPN)) + { + table = rn->info; + + for (rm = bgp_table_top (table); rm; rm = bgp_route_next (rm)) + { + bgp_static = rm->info; + bgp_static_update_safi (bgp, &rm->p, bgp_static, afi, safi); + } + } + else + { + bgp_static = rn->info; + bgp_static_update (bgp, &rn->p, bgp_static, afi, safi); + } } bgp_flag_unset(bgp, BGP_FLAG_FORCE_STATIC_PROCESS); } From ab87c0f350f8c844f31f9420d2be579482eb8250 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Fri, 12 May 2017 21:37:36 +0000 Subject: [PATCH 10/10] lib: use %p specifier for pointers Fixes builds on ARM Signed-off-by: Quentin Young --- lib/grammar_sandbox.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/lib/grammar_sandbox.c b/lib/grammar_sandbox.c index 97de943216..0da7981fc1 100644 --- a/lib/grammar_sandbox.c +++ b/lib/grammar_sandbox.c @@ -588,7 +588,7 @@ pretty_print_dot (FILE *ofd, unsigned opts, struct graph_node *start, return; snprintf(tokennum, sizeof(tokennum), "%d?", tok->type); - fprintf(ofd, " n%016llx [ shape=box, label=<", (unsigned long long)start); + fprintf(ofd, " n%p [ shape=box, label=<", start); fprintf(ofd, "%s", LOOKUP_DEF(tokennames, tok->type, tokennum)); if (tok->attr == CMD_ATTR_DEPRECATED) @@ -621,20 +621,13 @@ pretty_print_dot (FILE *ofd, unsigned opts, struct graph_node *start, struct graph_node *adj = vector_slot (start->to, i); // if this node is a vararg, just print * if (adj == start) { - fprintf(ofd, " n%016llx -> n%016llx;\n", - (unsigned long long)start, - (unsigned long long)start); + fprintf(ofd, " n%p -> n%p;\n", start, start); } else if (((struct cmd_token *)adj->data)->type == END_TKN) { //struct cmd_token *et = adj->data; - fprintf(ofd, " n%016llx -> end%016llx;\n", - (unsigned long long)start, - (unsigned long long)adj); - fprintf(ofd, " end%016llx [ shape=box, label=, style = filled, fillcolor = \"#ffddaa\" ];\n", - (unsigned long long)adj); + fprintf(ofd, " n%p -> end%p;\n", start, adj); + fprintf(ofd, " end%p [ shape=box, label=, style = filled, fillcolor = \"#ffddaa\" ];\n", adj); } else { - fprintf(ofd, " n%016llx -> n%016llx;\n", - (unsigned long long)start, - (unsigned long long)adj); + fprintf(ofd, " n%p -> n%p;\n", start, adj); size_t k; for (k = 0; k < stackpos; k++) if (stack[k] == adj)