forked from Mirror/frr
bgpd, zebra: Add ability for bgp to send AS-Path information to zebra
Add a bit of code to allow bgp to send the AS-Path associated with the route being installed to zebra so it can be displayed and used as part of the `show ip route A` command in zebra. eva# show ip route 20.0.0.0/11 Routing entry for 20.0.0.0/11 Known via "bgp", distance 20, metric 0, best Last update 00:00:00 ago * 192.168.161.1, via enp39s0, weight 1 AS-Path: 60000 64539 15096 6939 8075 Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
parent
cfa2a35d8d
commit
e46723a50e
|
@ -1596,6 +1596,19 @@ DEFPY (no_bgp_norib,
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DEFPY (no_bgp_send_extra_data,
|
||||||
|
no_bgp_send_extra_data_cmd,
|
||||||
|
"[no] bgp send-extra-data zebra",
|
||||||
|
NO_STR
|
||||||
|
BGP_STR
|
||||||
|
"Extra data to Zebra for display/use\n"
|
||||||
|
"To zebra\n")
|
||||||
|
{
|
||||||
|
bgp_option_send_extra_data(!!no);
|
||||||
|
|
||||||
|
return CMD_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
DEFUN_YANG(bgp_confederation_identifier,
|
DEFUN_YANG(bgp_confederation_identifier,
|
||||||
bgp_confederation_identifier_cmd,
|
bgp_confederation_identifier_cmd,
|
||||||
"bgp confederation identifier (1-4294967295)",
|
"bgp confederation identifier (1-4294967295)",
|
||||||
|
@ -16930,6 +16943,9 @@ int bgp_config_write(struct vty *vty)
|
||||||
if (bgp_option_check(BGP_OPT_NO_FIB))
|
if (bgp_option_check(BGP_OPT_NO_FIB))
|
||||||
vty_out(vty, "bgp no-rib\n");
|
vty_out(vty, "bgp no-rib\n");
|
||||||
|
|
||||||
|
if (bm->send_extra_data_to_zebra)
|
||||||
|
vty_out(vty, "no bgp send-extra-data zebra\n");
|
||||||
|
|
||||||
/* BGP configuration. */
|
/* BGP configuration. */
|
||||||
for (ALL_LIST_ELEMENTS(bm->bgp, mnode, mnnode, bgp)) {
|
for (ALL_LIST_ELEMENTS(bm->bgp, mnode, mnnode, bgp)) {
|
||||||
|
|
||||||
|
@ -17485,6 +17501,8 @@ void bgp_vty_init(void)
|
||||||
install_element(CONFIG_NODE, &bgp_norib_cmd);
|
install_element(CONFIG_NODE, &bgp_norib_cmd);
|
||||||
install_element(CONFIG_NODE, &no_bgp_norib_cmd);
|
install_element(CONFIG_NODE, &no_bgp_norib_cmd);
|
||||||
|
|
||||||
|
install_element(CONFIG_NODE, &no_bgp_send_extra_data_cmd);
|
||||||
|
|
||||||
/* "bgp confederation" commands. */
|
/* "bgp confederation" commands. */
|
||||||
install_element(BGP_NODE, &bgp_confederation_identifier_cmd);
|
install_element(BGP_NODE, &bgp_confederation_identifier_cmd);
|
||||||
install_element(BGP_NODE, &no_bgp_confederation_identifier_cmd);
|
install_element(BGP_NODE, &no_bgp_confederation_identifier_cmd);
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
#include "bgpd/bgpd.h"
|
#include "bgpd/bgpd.h"
|
||||||
#include "bgpd/bgp_route.h"
|
#include "bgpd/bgp_route.h"
|
||||||
#include "bgpd/bgp_attr.h"
|
#include "bgpd/bgp_attr.h"
|
||||||
|
#include "bgpd/bgp_aspath.h"
|
||||||
#include "bgpd/bgp_nexthop.h"
|
#include "bgpd/bgp_nexthop.h"
|
||||||
#include "bgpd/bgp_zebra.h"
|
#include "bgpd/bgp_zebra.h"
|
||||||
#include "bgpd/bgp_fsm.h"
|
#include "bgpd/bgp_fsm.h"
|
||||||
|
@ -1409,6 +1410,14 @@ void bgp_zebra_announce(struct bgp_dest *dest, const struct prefix *p,
|
||||||
|
|
||||||
is_add = (valid_nh_count || nhg_id) ? true : false;
|
is_add = (valid_nh_count || nhg_id) ? true : false;
|
||||||
|
|
||||||
|
if (is_add && bm->send_extra_data_to_zebra) {
|
||||||
|
struct aspath *aspath = info->attr->aspath;
|
||||||
|
|
||||||
|
SET_FLAG(api.message, ZAPI_MESSAGE_OPAQUE);
|
||||||
|
api.opaque.length = strlen(aspath->str) + 1;
|
||||||
|
memcpy(api.opaque.data, aspath->str, api.opaque.length);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* When we create an aggregate route we must also
|
* When we create an aggregate route we must also
|
||||||
* install a Null0 route in the RIB, so overwrite
|
* install a Null0 route in the RIB, so overwrite
|
||||||
|
|
|
@ -7395,6 +7395,11 @@ char *peer_uptime(time_t uptime2, char *buf, size_t len, bool use_json,
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void bgp_option_send_extra_data(bool send)
|
||||||
|
{
|
||||||
|
bm->send_extra_data_to_zebra = send;
|
||||||
|
}
|
||||||
|
|
||||||
void bgp_master_init(struct thread_master *master, const int buffer_size)
|
void bgp_master_init(struct thread_master *master, const int buffer_size)
|
||||||
{
|
{
|
||||||
qobj_init();
|
qobj_init();
|
||||||
|
@ -7413,6 +7418,7 @@ void bgp_master_init(struct thread_master *master, const int buffer_size)
|
||||||
bm->v_establish_wait = BGP_UPDATE_DELAY_DEF;
|
bm->v_establish_wait = BGP_UPDATE_DELAY_DEF;
|
||||||
bm->terminating = false;
|
bm->terminating = false;
|
||||||
bm->socket_buffer = buffer_size;
|
bm->socket_buffer = buffer_size;
|
||||||
|
bm->send_extra_data_to_zebra = true;
|
||||||
|
|
||||||
bgp_mac_init();
|
bgp_mac_init();
|
||||||
/* init the rd id space.
|
/* init the rd id space.
|
||||||
|
|
|
@ -169,6 +169,9 @@ struct bgp_master {
|
||||||
uint32_t flags;
|
uint32_t flags;
|
||||||
#define BM_FLAG_GRACEFUL_SHUTDOWN (1 << 0)
|
#define BM_FLAG_GRACEFUL_SHUTDOWN (1 << 0)
|
||||||
|
|
||||||
|
/* Send extra data to zebra like aspath */
|
||||||
|
bool send_extra_data_to_zebra;
|
||||||
|
|
||||||
bool terminating; /* global flag that sigint terminate seen */
|
bool terminating; /* global flag that sigint terminate seen */
|
||||||
QOBJ_FIELDS
|
QOBJ_FIELDS
|
||||||
};
|
};
|
||||||
|
@ -2246,6 +2249,8 @@ static inline bool bgp_in_graceful_shutdown(struct bgp *bgp)
|
||||||
|
|
||||||
extern void bgp_unset_redist_vrf_bitmaps(struct bgp *, vrf_id_t);
|
extern void bgp_unset_redist_vrf_bitmaps(struct bgp *, vrf_id_t);
|
||||||
|
|
||||||
|
extern void bgp_option_send_extra_data(bool send);
|
||||||
|
|
||||||
/* For benefit of rfapi */
|
/* For benefit of rfapi */
|
||||||
extern struct peer *peer_new(struct bgp *bgp);
|
extern struct peer *peer_new(struct bgp *bgp);
|
||||||
|
|
||||||
|
|
|
@ -434,6 +434,13 @@ static void zebra_show_ip_route_opaque(struct vty *vty, struct route_entry *re,
|
||||||
vty_out(vty, " Opaque Data: %s",
|
vty_out(vty, " Opaque Data: %s",
|
||||||
(char *)re->opaque->data);
|
(char *)re->opaque->data);
|
||||||
break;
|
break;
|
||||||
|
case ZEBRA_ROUTE_BGP:
|
||||||
|
if (json)
|
||||||
|
json_object_string_add(json, "asPath",
|
||||||
|
(char *)re->opaque->data);
|
||||||
|
else
|
||||||
|
vty_out(vty, " AS-Path: %s",
|
||||||
|
(char *)re->opaque->data);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue