diff options
| -rw-r--r-- | bgpd/bgp_vty.c | 18 | ||||
| -rw-r--r-- | bgpd/bgp_zebra.c | 9 | ||||
| -rw-r--r-- | bgpd/bgpd.c | 6 | ||||
| -rw-r--r-- | bgpd/bgpd.h | 5 | ||||
| -rw-r--r-- | zebra/zebra_vty.c | 7 |
5 files changed, 45 insertions, 0 deletions
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 563a1faf96..955e73fcf3 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -1596,6 +1596,19 @@ DEFPY (no_bgp_norib, 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, bgp_confederation_identifier_cmd, "bgp confederation identifier (1-4294967295)", @@ -16930,6 +16943,9 @@ int bgp_config_write(struct vty *vty) if (bgp_option_check(BGP_OPT_NO_FIB)) 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. */ 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, &no_bgp_norib_cmd); + install_element(CONFIG_NODE, &no_bgp_send_extra_data_cmd); + /* "bgp confederation" commands. */ install_element(BGP_NODE, &bgp_confederation_identifier_cmd); install_element(BGP_NODE, &no_bgp_confederation_identifier_cmd); diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c index 8c85725bdc..3bd8f7a09b 100644 --- a/bgpd/bgp_zebra.c +++ b/bgpd/bgp_zebra.c @@ -41,6 +41,7 @@ #include "bgpd/bgpd.h" #include "bgpd/bgp_route.h" #include "bgpd/bgp_attr.h" +#include "bgpd/bgp_aspath.h" #include "bgpd/bgp_nexthop.h" #include "bgpd/bgp_zebra.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; + 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 * install a Null0 route in the RIB, so overwrite diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index f1454aaee8..d3db540871 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -7395,6 +7395,11 @@ char *peer_uptime(time_t uptime2, char *buf, size_t len, bool use_json, 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) { 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->terminating = false; bm->socket_buffer = buffer_size; + bm->send_extra_data_to_zebra = true; bgp_mac_init(); /* init the rd id space. diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index e867159fa6..3451a616a4 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -169,6 +169,9 @@ struct bgp_master { uint32_t flags; #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 */ 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_option_send_extra_data(bool send); + /* For benefit of rfapi */ extern struct peer *peer_new(struct bgp *bgp); diff --git a/zebra/zebra_vty.c b/zebra/zebra_vty.c index 8d71ab9429..e418df6963 100644 --- a/zebra/zebra_vty.c +++ b/zebra/zebra_vty.c @@ -434,6 +434,13 @@ static void zebra_show_ip_route_opaque(struct vty *vty, struct route_entry *re, vty_out(vty, " Opaque Data: %s", (char *)re->opaque->data); 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: break; } |
