summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bgpd/bgp_route.c3
-rw-r--r--bgpd/bgp_route.h5
-rw-r--r--bgpd/bgp_zebra.c5
-rw-r--r--bgpd/bgpd.c10
-rw-r--r--lib/route_opaque.h6
-rw-r--r--tests/topotests/bfd_isis_topo1/test_bfd_isis_topo1.py2
-rw-r--r--zebra/zebra_vty.c5
7 files changed, 31 insertions, 5 deletions
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index 2a84f548f8..b9a46a2afe 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -8433,8 +8433,7 @@ enum bgp_display_type {
normal_list,
};
-static const char *
-bgp_path_selection_reason2str(enum bgp_path_selection_reason reason)
+const char *bgp_path_selection_reason2str(enum bgp_path_selection_reason reason)
{
switch (reason) {
case bgp_path_selection_none:
diff --git a/bgpd/bgp_route.h b/bgpd/bgp_route.h
index 37bf675b67..46802d0d14 100644
--- a/bgpd/bgp_route.h
+++ b/bgpd/bgp_route.h
@@ -90,6 +90,9 @@ enum bgp_show_adj_route_type {
/* Maximum number of sids we can process or send with a prefix. */
#define BGP_MAX_SIDS 6
+/* Maximum buffer length for storing BGP best path selection reason */
+#define BGP_MAX_SELECTION_REASON_STR_BUF 32
+
/* Error codes for handling NLRI */
#define BGP_NLRI_PARSE_OK 0
#define BGP_NLRI_PARSE_ERROR_PREFIX_OVERFLOW -1
@@ -803,4 +806,6 @@ extern void bgp_aggregate_toggle_suppressed(struct bgp_aggregate *aggregate,
const struct prefix *p, afi_t afi,
safi_t safi, bool suppress);
extern void subgroup_announce_reset_nhop(uint8_t family, struct attr *attr);
+const char *
+bgp_path_selection_reason2str(enum bgp_path_selection_reason reason);
#endif /* _QUAGGA_BGP_ROUTE_H */
diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c
index 6161f56fe6..5fc6bb2a1a 100644
--- a/bgpd/bgp_zebra.c
+++ b/bgpd/bgp_zebra.c
@@ -1490,6 +1490,8 @@ void bgp_zebra_announce(struct bgp_dest *dest, const struct prefix *p,
if (is_add && CHECK_FLAG(bm->flags, BM_FLAG_SEND_EXTRA_DATA_TO_ZEBRA)) {
struct bgp_zebra_opaque bzo = {};
+ const char *reason =
+ bgp_path_selection_reason2str(dest->reason);
strlcpy(bzo.aspath, info->attr->aspath->str,
sizeof(bzo.aspath));
@@ -1503,6 +1505,9 @@ void bgp_zebra_announce(struct bgp_dest *dest, const struct prefix *p,
strlcpy(bzo.lcommunity, info->attr->lcommunity->str,
sizeof(bzo.lcommunity));
+ strlcpy(bzo.selection_reason, reason,
+ sizeof(bzo.selection_reason));
+
SET_FLAG(api.message, ZAPI_MESSAGE_OPAQUE);
api.opaque.length = MIN(sizeof(struct bgp_zebra_opaque),
ZAPI_MESSAGE_OPAQUE_LENGTH);
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index b191029d2f..c5a5e49a48 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -4775,6 +4775,7 @@ int peer_ebgp_multihop_unset(struct peer *peer)
{
struct peer_group *group;
struct listnode *node, *nnode;
+ int ttl;
if (peer->sort == BGP_PEER_IBGP)
return 0;
@@ -4783,9 +4784,14 @@ int peer_ebgp_multihop_unset(struct peer *peer)
return BGP_ERR_NO_EBGP_MULTIHOP_WITH_TTLHACK;
if (peer_group_active(peer))
- peer->ttl = peer->group->conf->ttl;
+ ttl = peer->group->conf->ttl;
else
- peer->ttl = BGP_DEFAULT_TTL;
+ ttl = BGP_DEFAULT_TTL;
+
+ if (ttl == peer->ttl)
+ return 0;
+
+ peer->ttl = ttl;
if (!CHECK_FLAG(peer->sflags, PEER_STATUS_GROUP)) {
if (BGP_IS_VALID_STATE_FOR_NOTIF(peer->status))
diff --git a/lib/route_opaque.h b/lib/route_opaque.h
index 7c4e9a16e1..c5e7d6a327 100644
--- a/lib/route_opaque.h
+++ b/lib/route_opaque.h
@@ -36,6 +36,12 @@ struct bgp_zebra_opaque {
/* Show at least 10 large-communities AA:BB:CC */
char lcommunity[LCOMMUNITY_SIZE * 30];
+
+ /* 32 bytes seems enough because of
+ * bgp_path_selection_confed_as_path which is
+ * `Confederation based AS Path`.
+ */
+ char selection_reason[BGP_MAX_SELECTION_REASON_STR_BUF];
};
static_assert(sizeof(struct bgp_zebra_opaque) <= ZAPI_MESSAGE_OPAQUE_LENGTH,
diff --git a/tests/topotests/bfd_isis_topo1/test_bfd_isis_topo1.py b/tests/topotests/bfd_isis_topo1/test_bfd_isis_topo1.py
index 863c296927..27a4419329 100644
--- a/tests/topotests/bfd_isis_topo1/test_bfd_isis_topo1.py
+++ b/tests/topotests/bfd_isis_topo1/test_bfd_isis_topo1.py
@@ -193,7 +193,7 @@ def test_bfd_isis_interface_failure_rt2_step3():
# initial 2 seconds to let the CI not suffer.
# TODO: add check for array size
router_compare_json_output(
- "rt1", "show ip route isis json", "step3/show_ip_route_rt2_down.ref", 20, 10
+ "rt1", "show ip route isis json", "step3/show_ip_route_rt2_down.ref", 20, 1
)
router_compare_json_output(
"rt1", "show ipv6 route isis json", "step3/show_ipv6_route_rt2_down.ref", 20, 1
diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c
index 5b79de9697..2cb2b5118b 100644
--- a/zebra/zebra_vty.c
+++ b/zebra/zebra_vty.c
@@ -449,6 +449,8 @@ static void zebra_show_ip_route_opaque(struct vty *vty, struct route_entry *re,
bzo.community);
json_object_string_add(json, "largeCommunities",
bzo.lcommunity);
+ json_object_string_add(json, "selectionReason",
+ bzo.selection_reason);
} else {
vty_out(vty, " AS-Path : %s\n", bzo.aspath);
@@ -459,6 +461,9 @@ static void zebra_show_ip_route_opaque(struct vty *vty, struct route_entry *re,
if (bzo.lcommunity[0] != '\0')
vty_out(vty, " Large-Communities: %s\n",
bzo.lcommunity);
+
+ vty_out(vty, " Selection reason : %s\n",
+ bzo.selection_reason);
}
}
default: