]> git.proxmox.com Git - mirror_frr.git/commitdiff
bgpd: Fix crash when rd has no data
authorDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 6 Jun 2019 00:59:02 +0000 (20:59 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Tue, 18 Jun 2019 13:11:15 +0000 (09:11 -0400)
There exists a state where we may have a rd node but no individual
evpn prefix nodes in the two level table:

(gdb) bt
    at bgpd/bgp_evpn_vty.c:1190
    filter=FILTER_RELAXED) at lib/command.c:1060
    at lib/command.c:1119
    vtysh=vtysh@entry=0) at lib/command.c:1273
(gdb) f 5
    at bgpd/bgp_evpn_vty.c:1190
1190    bgpd/bgp_evpn_vty.c: No such file or directory.
(gdb) p buf
$1 = "[2]:[0]:[48]:[00:00:00:00:00:00]", '\000' <repeats 240 times>...
(gdb) p json_nroute
$2 = (json_object *) 0x0
(gdb) p rd_header
$3 = 1
(gdb) p buf
$4 = "[2]:[0]:[48]:[00:00:00:00:00:00]", '\000' <repeats 240 times>...
(gdb)

I'm not entirely sure that this is not a `different` problem in that the
rd node should have been removed.  But I think preventing the crash
in a show command is probably the right thing to do here.

Fixes: #4501
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
bgpd/bgp_evpn_vty.c

index 67b0079c37bf4a03d6dfcdf3363e0a7c66f0b981..ca6edffab088c6f6956655fdbfc0ba51bc7d9a8d 100644 (file)
@@ -1060,6 +1060,9 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd,
 
                                json_object_int_add(json_prefix_info,
                                        "prefixLen", rm->p.prefixlen);
+
+                               if (rd_header)
+                                       json_nroute = json_object_new_object();
                        }
 
                        for (pi = bgp_node_get_bgp_path_info(rm); pi;
@@ -1132,8 +1135,6 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd,
                                        else if (type == RD_TYPE_IP)
                                                decode_rd_ip(pnt + 2, &rd_ip);
                                        if (use_json) {
-                                               json_nroute =
-                                                     json_object_new_object();
                                                if (type == RD_TYPE_AS
                                                    || type == RD_TYPE_AS4)
                                                        sprintf(rd_str, "%u:%d",
@@ -1184,6 +1185,7 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd,
                                                      SAFI_EVPN, json_array);
                                output_count++;
                        }
+                       rd_header = 0;
                        if (use_json) {
                                json_object_object_add(json_prefix_info,
                                        "paths", json_array);