]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: Show hostname in `show [ip] bgp ...` only if nexthop is connected
authorDonatas Abraitis <donatas.abraitis@gmail.com>
Thu, 16 Apr 2020 07:36:59 +0000 (10:36 +0300)
committerDonatas Abraitis <donatas.abraitis@gmail.com>
Thu, 16 Apr 2020 07:36:59 +0000 (10:36 +0300)
The problem is when using kinda such topologies:
(192.168.1.1/32) r1 <-- eBGP --> r2 <-- iBGP --> r3

Looking at r3's nexthop for 192.168.1.1/32 we have it as r2, but really
it MUST be r1.

Checking if the nexthop is connected solves the problem even for cases
when route-reflectors are used.

Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
bgpd/bgp_route.c

index d5f903f6e22571174948071c9cce098d8c75da43..fc6b4ce7f954c09b6c3a6c7906b0fe8da0d45241 100644 (file)
@@ -7540,11 +7540,12 @@ static void route_vty_short_status_out(struct vty *vty,
                vty_out(vty, " ");
 }
 
-static char *bgp_nexthop_hostname(struct peer *peer, struct attr *attr)
+static char *bgp_nexthop_hostname(struct peer *peer,
+                                 struct bgp_nexthop_cache *bnc)
 {
        if (peer->hostname
            && CHECK_FLAG(peer->bgp->flags, BGP_FLAG_SHOW_HOSTNAME)
-           && !(attr->flag & ATTR_FLAG_BIT(BGP_ATTR_ORIGINATOR_ID)))
+           && CHECK_FLAG(bnc->flags, BGP_NEXTHOP_CONNECTED))
                return peer->hostname;
        return NULL;
 }
@@ -7566,7 +7567,8 @@ void route_vty_out(struct vty *vty, const struct prefix *p,
        bool nexthop_othervrf = false;
        vrf_id_t nexthop_vrfid = VRF_DEFAULT;
        const char *nexthop_vrfname = VRF_DEFAULT_NAME;
-       char *nexthop_hostname = bgp_nexthop_hostname(path->peer, attr);
+       char *nexthop_hostname =
+               bgp_nexthop_hostname(path->peer, path->nexthop);
 
        if (json_paths)
                json_path = json_object_new_object();
@@ -8637,7 +8639,8 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp,
        bool nexthop_self =
                CHECK_FLAG(path->flags, BGP_PATH_ANNC_NH_SELF) ? true : false;
        int i;
-       char *nexthop_hostname = bgp_nexthop_hostname(path->peer, attr);
+       char *nexthop_hostname =
+               bgp_nexthop_hostname(path->peer, path->nexthop);
 
        if (json_paths) {
                json_path = json_object_new_object();