summaryrefslogtreecommitdiff
path: root/bgpd
diff options
context:
space:
mode:
Diffstat (limited to 'bgpd')
-rw-r--r--bgpd/bgp_bfd.c19
-rw-r--r--bgpd/bgp_damp.c6
-rw-r--r--bgpd/bgp_debug.c42
-rw-r--r--bgpd/bgp_dump.c7
-rw-r--r--bgpd/bgp_evpn.c121
-rw-r--r--bgpd/bgp_evpn_mh.c38
-rw-r--r--bgpd/bgp_flowspec_util.c11
-rw-r--r--bgpd/bgp_fsm.c23
-rw-r--r--bgpd/bgp_fsm.h2
-rw-r--r--bgpd/bgp_io.c2
-rw-r--r--bgpd/bgp_label.c11
-rw-r--r--bgpd/bgp_main.c3
-rw-r--r--bgpd/bgp_mplsvpn.c10
-rw-r--r--bgpd/bgp_nb_config.c2
-rw-r--r--bgpd/bgp_nht.c19
-rw-r--r--bgpd/bgp_pbr.c19
-rw-r--r--bgpd/bgp_route.c352
-rw-r--r--bgpd/bgp_route.h15
-rw-r--r--bgpd/bgp_routemap.c34
-rw-r--r--bgpd/bgp_rpki.c19
-rw-r--r--bgpd/bgp_updgrp.c6
-rw-r--r--bgpd/bgp_updgrp_packet.c16
-rw-r--r--bgpd/bgp_vty.c22
-rw-r--r--bgpd/bgp_zebra.c88
-rw-r--r--bgpd/bgpd.c24
-rw-r--r--bgpd/bgpd.h6
-rw-r--r--bgpd/rfapi/bgp_rfapi_cfg.c32
-rw-r--r--bgpd/rfapi/rfapi.c46
-rw-r--r--bgpd/rfapi/rfapi_import.c79
-rw-r--r--bgpd/rfapi/rfapi_monitor.c54
-rw-r--r--bgpd/rfapi/rfapi_rib.c73
-rw-r--r--bgpd/rfapi/rfapi_vty.c19
-rw-r--r--bgpd/rfapi/vnc_export_bgp.c31
-rw-r--r--bgpd/rfapi/vnc_import_bgp.c152
-rw-r--r--bgpd/rfapi/vnc_zebra.c20
35 files changed, 646 insertions, 777 deletions
diff --git a/bgpd/bgp_bfd.c b/bgpd/bgp_bfd.c
index 1e1c97c2d9..7e1d64056d 100644
--- a/bgpd/bgp_bfd.c
+++ b/bgpd/bgp_bfd.c
@@ -385,24 +385,21 @@ static int bgp_bfd_dest_update(ZAPI_CALLBACK_ARGS)
if (BGP_DEBUG(zebra, ZEBRA)) {
struct vrf *vrf;
- char buf[2][PREFIX2STR_BUFFER];
vrf = vrf_lookup_by_id(vrf_id);
- prefix2str(&dp, buf[0], sizeof(buf[0]));
- if (ifp) {
+
+ if (ifp)
zlog_debug(
- "Zebra: vrf %s(%u) interface %s bfd destination %s %s %s",
- VRF_LOGNAME(vrf), vrf_id, ifp->name,
- buf[0], bfd_get_status_str(status),
+ "Zebra: vrf %s(%u) interface %s bfd destination %pFX %s %s",
+ VRF_LOGNAME(vrf), vrf_id, ifp->name, &dp,
+ bfd_get_status_str(status),
remote_cbit ? "(cbit on)" : "");
- } else {
- prefix2str(&sp, buf[1], sizeof(buf[1]));
+ else
zlog_debug(
- "Zebra: vrf %s(%u) source %s bfd destination %s %s %s",
- VRF_LOGNAME(vrf), vrf_id, buf[1], buf[0],
+ "Zebra: vrf %s(%u) source %pFX bfd destination %pFX %s %s",
+ VRF_LOGNAME(vrf), vrf_id, &sp, &dp,
bfd_get_status_str(status),
remote_cbit ? "(cbit on)" : "");
- }
}
/* Bring the peer down if BFD is enabled in BGP */
diff --git a/bgpd/bgp_damp.c b/bgpd/bgp_damp.c
index 9992168182..94a27ead0e 100644
--- a/bgpd/bgp_damp.c
+++ b/bgpd/bgp_damp.c
@@ -467,10 +467,8 @@ int bgp_damp_disable(struct bgp *bgp, afi_t afi, safi_t safi)
if (!CHECK_FLAG(bgp->af_flags[afi][safi], BGP_CONFIG_DAMPENING))
return 0;
- /* Cancel reuse thread. */
- if (bdc->t_reuse)
- thread_cancel(bdc->t_reuse);
- bdc->t_reuse = NULL;
+ /* Cancel reuse event. */
+ thread_cancel(&(bdc->t_reuse));
/* Clean BGP dampening information. */
bgp_damp_info_clean(afi, safi);
diff --git a/bgpd/bgp_debug.c b/bgpd/bgp_debug.c
index e7e349daa1..a513bc493d 100644
--- a/bgpd/bgp_debug.c
+++ b/bgpd/bgp_debug.c
@@ -237,7 +237,6 @@ static void bgp_debug_list_print(struct vty *vty, const char *desc,
{
struct bgp_debug_filter *filter;
struct listnode *node, *nnode;
- char buf[PREFIX2STR_BUFFER];
vty_out(vty, "%s", desc);
@@ -249,10 +248,8 @@ static void bgp_debug_list_print(struct vty *vty, const char *desc,
if (filter->p && filter->p->family == AF_EVPN)
bgp_debug_print_evpn_prefix(vty, "", filter->p);
- else if (filter->p) {
- prefix2str(filter->p, buf, sizeof(buf));
- vty_out(vty, " %s", buf);
- }
+ else if (filter->p)
+ vty_out(vty, " %pFX", filter->p);
}
}
@@ -268,7 +265,6 @@ static int bgp_debug_list_conf_print(struct vty *vty, const char *desc,
{
struct bgp_debug_filter *filter;
struct listnode *node, *nnode;
- char buf[PREFIX2STR_BUFFER];
int write = 0;
if (list && !list_isempty(list)) {
@@ -283,8 +279,7 @@ static int bgp_debug_list_conf_print(struct vty *vty, const char *desc,
filter->p);
write++;
} else if (filter->p) {
- prefix2str(filter->p, buf, sizeof(buf));
- vty_out(vty, "%s %s\n", desc, buf);
+ vty_out(vty, "%s %pFX\n", desc, filter->p);
write++;
}
}
@@ -1416,7 +1411,6 @@ DEFPY (debug_bgp_update_prefix_afi_safi,
{
struct prefix *argv_p;
int ret = CMD_SUCCESS;
- char buf[PREFIX2STR_BUFFER];
argv_p = prefix_new();
@@ -1429,12 +1423,10 @@ DEFPY (debug_bgp_update_prefix_afi_safi,
if (!bgp_debug_update_prefixes)
bgp_debug_update_prefixes = list_new();
- prefix2str(argv_p, buf, sizeof(buf));
-
if (bgp_debug_list_has_entry(bgp_debug_update_prefixes, NULL, argv_p)) {
vty_out(vty,
- "BGP updates debugging is already enabled for %s\n",
- buf);
+ "BGP updates debugging is already enabled for %pFX\n",
+ argv_p);
prefix_free(&argv_p);
return CMD_SUCCESS;
}
@@ -1445,7 +1437,7 @@ DEFPY (debug_bgp_update_prefix_afi_safi,
DEBUG_ON(update, UPDATE_PREFIX);
} else {
TERM_DEBUG_ON(update, UPDATE_PREFIX);
- vty_out(vty, "BGP updates debugging is on for %s\n", buf);
+ vty_out(vty, "BGP updates debugging is on for %pFX\n", argv_p);
}
prefix_free(&argv_p);
@@ -1484,7 +1476,6 @@ DEFPY (no_debug_bgp_update_prefix_afi_safi,
struct prefix *argv_p;
bool found_prefix = false;
int ret = CMD_SUCCESS;
- char buf[PREFIX2STR_BUFFER];
argv_p = prefix_new();
@@ -1510,13 +1501,11 @@ DEFPY (no_debug_bgp_update_prefix_afi_safi,
}
}
- prefix2str(argv_p, buf, sizeof(buf));
-
if (found_prefix)
- vty_out(vty, "BGP updates debugging is off for %s\n", buf);
+ vty_out(vty, "BGP updates debugging is off for %pFX\n", argv_p);
else
- vty_out(vty, "BGP updates debugging was not enabled for %s\n",
- buf);
+ vty_out(vty, "BGP updates debugging was not enabled for %pFX\n",
+ argv_p);
prefix_free(&argv_p);
@@ -2643,7 +2632,6 @@ const char *bgp_debug_rdpfxpath2str(afi_t afi, safi_t safi,
char *str, int size)
{
char rd_buf[RD_ADDRSTRLEN];
- char pfx_buf[PREFIX_STRLEN];
char tag_buf[30];
/* ' with addpath ID ' 17
* max strlen of uint32 + 10
@@ -2681,10 +2669,9 @@ const char *bgp_debug_rdpfxpath2str(afi_t afi, safi_t safi,
}
if (prd)
- snprintf(str, size, "RD %s %s%s%s %s %s",
- prefix_rd2str(prd, rd_buf, sizeof(rd_buf)),
- prefix2str(pu, pfx_buf, sizeof(pfx_buf)), tag_buf,
- pathid_buf, afi2str(afi), safi2str(safi));
+ snprintfrr(str, size, "RD %s %pFX%s%s %s %s",
+ prefix_rd2str(prd, rd_buf, sizeof(rd_buf)), pu.p,
+ tag_buf, pathid_buf, afi2str(afi), safi2str(safi));
else if (safi == SAFI_FLOWSPEC) {
char return_string[BGP_FLOWSPEC_NLRI_STRING_MAX];
const struct prefix_fs *fs = pu.fs;
@@ -2697,9 +2684,8 @@ const char *bgp_debug_rdpfxpath2str(afi_t afi, safi_t safi,
snprintf(str, size, "FS %s Match{%s}", afi2str(afi),
return_string);
} else
- snprintf(str, size, "%s%s%s %s %s",
- prefix2str(pu, pfx_buf, sizeof(pfx_buf)), tag_buf,
- pathid_buf, afi2str(afi), safi2str(safi));
+ snprintfrr(str, size, "%pFX%s%s %s %s", pu.p, tag_buf,
+ pathid_buf, afi2str(afi), safi2str(safi));
return str;
}
diff --git a/bgpd/bgp_dump.c b/bgpd/bgp_dump.c
index abd349a188..975bba9314 100644
--- a/bgpd/bgp_dump.c
+++ b/bgpd/bgp_dump.c
@@ -677,11 +677,8 @@ static int bgp_dump_unset(struct bgp_dump *bgp_dump)
bgp_dump->fp = NULL;
}
- /* Removing interval thread. */
- if (bgp_dump->t_interval) {
- thread_cancel(bgp_dump->t_interval);
- bgp_dump->t_interval = NULL;
- }
+ /* Removing interval event. */
+ thread_cancel(&bgp_dump->t_interval);
bgp_dump->interval = 0;
diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c
index e58bb7c671..67d0a95cb6 100644
--- a/bgpd/bgp_evpn.c
+++ b/bgpd/bgp_evpn.c
@@ -1034,19 +1034,17 @@ static void evpn_delete_old_local_route(struct bgp *bgp, struct bgpevpn *vpn,
safi_t safi = SAFI_EVPN;
if (BGP_DEBUG(evpn_mh, EVPN_MH_RT)) {
- char prefix_buf[PREFIX_STRLEN];
char esi_buf[ESI_STR_LEN];
char esi_buf2[ESI_STR_LEN];
struct prefix_evpn *evp =
(struct prefix_evpn *)bgp_dest_get_prefix(dest);
- zlog_debug("local path deleted %s es %s; new-path-es %s",
- prefix2str(evp,
- prefix_buf, sizeof(prefix_buf)),
- esi_to_str(&old_local->attr->esi,
- esi_buf, sizeof(esi_buf)),
- new_select ? esi_to_str(&new_select->attr->esi,
- esi_buf2, sizeof(esi_buf2)) : "");
+ zlog_debug("local path deleted %pFX es %s; new-path-es %s", evp,
+ esi_to_str(&old_local->attr->esi, esi_buf,
+ sizeof(esi_buf)),
+ new_select ? esi_to_str(&new_select->attr->esi,
+ esi_buf2, sizeof(esi_buf2))
+ : "");
}
/* Locate route node in the global EVPN routing table. Note that
@@ -1313,23 +1311,18 @@ static int update_evpn_type5_route(struct bgp *bgp_vrf, struct prefix_evpn *evp,
attr.nexthop = bgp_vrf->evpn_info->pip_ip;
attr.mp_nexthop_global_in = bgp_vrf->evpn_info->pip_ip;
} else if (bgp_vrf->evpn_info->pip_ip.s_addr == INADDR_ANY)
- if (bgp_debug_zebra(NULL)) {
- char buf1[PREFIX_STRLEN];
-
- zlog_debug("VRF %s evp %s advertise-pip primary ip is not configured",
- vrf_id_to_name(bgp_vrf->vrf_id),
- prefix2str(evp, buf1, sizeof(buf1)));
- }
+ if (bgp_debug_zebra(NULL))
+ zlog_debug(
+ "VRF %s evp %pFX advertise-pip primary ip is not configured",
+ vrf_id_to_name(bgp_vrf->vrf_id), evp);
}
if (bgp_debug_zebra(NULL)) {
char buf[ETHER_ADDR_STRLEN];
- char buf1[PREFIX_STRLEN];
char buf2[INET6_ADDRSTRLEN];
- zlog_debug("VRF %s type-5 route evp %s RMAC %s nexthop %s",
- vrf_id_to_name(bgp_vrf->vrf_id),
- prefix2str(evp, buf1, sizeof(buf1)),
+ zlog_debug("VRF %s type-5 route evp %pFX RMAC %s nexthop %s",
+ vrf_id_to_name(bgp_vrf->vrf_id), evp,
prefix_mac2str(&attr.rmac, buf, sizeof(buf)),
inet_ntop(AF_INET, &attr.nexthop, buf2,
INET_ADDRSTRLEN));
@@ -1461,21 +1454,23 @@ static void update_evpn_route_entry_sync_info(struct bgp *bgp,
attr->es_flags &= ~ATTR_ES_PEER_ROUTER;
if (BGP_DEBUG(evpn_mh, EVPN_MH_RT)) {
- char prefix_buf[PREFIX_STRLEN];
char esi_buf[ESI_STR_LEN];
- zlog_debug("setup sync info for %s es %s max_seq %d %s%s%s",
- prefix2str(evp, prefix_buf,
- sizeof(prefix_buf)),
+ zlog_debug(
+ "setup sync info for %pFX es %s max_seq %d %s%s%s",
+ evp,
esi_to_str(esi, esi_buf,
- sizeof(esi_buf)),
+ sizeof(esi_buf)),
max_sync_seq,
- (attr->es_flags & ATTR_ES_PEER_ACTIVE) ?
- "peer-active " : "",
- (attr->es_flags & ATTR_ES_PEER_PROXY) ?
- "peer-proxy " : "",
- (attr->es_flags & ATTR_ES_PEER_ROUTER) ?
- "peer-router " : "");
+ (attr->es_flags & ATTR_ES_PEER_ACTIVE)
+ ? "peer-active "
+ : "",
+ (attr->es_flags & ATTR_ES_PEER_PROXY)
+ ? "peer-proxy "
+ : "",
+ (attr->es_flags & ATTR_ES_PEER_ROUTER)
+ ? "peer-router "
+ : "");
}
}
} else {
@@ -1721,14 +1716,13 @@ static int update_evpn_route(struct bgp *bgp, struct bgpevpn *vpn,
if (bgp_debug_zebra(NULL)) {
char buf[ETHER_ADDR_STRLEN];
- char buf1[PREFIX_STRLEN];
char buf3[ESI_STR_LEN];
zlog_debug(
- "VRF %s vni %u type-2 route evp %s RMAC %s nexthop %pI4 esi %s",
+ "VRF %s vni %u type-2 route evp %pFX RMAC %s nexthop %pI4 esi %s",
vpn->bgp_vrf ? vrf_id_to_name(vpn->bgp_vrf->vrf_id)
: " ",
- vpn->vni, prefix2str(p, buf1, sizeof(buf1)),
+ vpn->vni, p,
prefix_mac2str(&attr.rmac, buf, sizeof(buf)),
&attr.mp_nexthop_global_in,
esi_to_str(esi, buf3, sizeof(buf3)));
@@ -2001,14 +1995,13 @@ static void bgp_evpn_update_type2_route_entry(struct bgp *bgp,
if (bgp_debug_zebra(NULL)) {
char buf[ETHER_ADDR_STRLEN];
- char buf1[PREFIX_STRLEN];
char buf3[ESI_STR_LEN];
zlog_debug(
- "VRF %s vni %u evp %s RMAC %s nexthop %pI4 esi %s esf 0x%x from %s",
+ "VRF %s vni %u evp %pFX RMAC %s nexthop %pI4 esi %s esf 0x%x from %s",
vpn->bgp_vrf ? vrf_id_to_name(vpn->bgp_vrf->vrf_id)
: " ",
- vpn->vni, prefix2str(evp, buf1, sizeof(buf1)),
+ vpn->vni, evp,
prefix_mac2str(&attr.rmac, buf, sizeof(buf)),
&attr.mp_nexthop_global_in,
esi_to_str(&attr.esi, buf3, sizeof(buf3)),
@@ -2391,19 +2384,16 @@ static int install_evpn_route_entry_in_vrf(struct bgp *bgp_vrf,
struct prefix *pp = &p;
afi_t afi = 0;
safi_t safi = 0;
- char buf[PREFIX_STRLEN];
bool new_pi = false;
memset(pp, 0, sizeof(struct prefix));
ip_prefix_from_evpn_prefix(evp, pp);
- if (bgp_debug_zebra(NULL)) {
+ if (bgp_debug_zebra(NULL))
zlog_debug(
- "vrf %s: import evpn prefix %s parent %p flags 0x%x",
- vrf_id_to_name(bgp_vrf->vrf_id),
- prefix2str(evp, buf, sizeof(buf)),
- parent_pi, parent_pi->flags);
- }
+ "vrf %s: import evpn prefix %pFX parent %p flags 0x%x",
+ vrf_id_to_name(bgp_vrf->vrf_id), evp, parent_pi,
+ parent_pi->flags);
/* Create (or fetch) route within the VRF. */
/* NOTE: There is no RD here. */
@@ -2582,18 +2572,15 @@ static int uninstall_evpn_route_entry_in_vrf(struct bgp *bgp_vrf,
struct prefix *pp = &p;
afi_t afi = 0;
safi_t safi = 0;
- char buf[PREFIX_STRLEN];
memset(pp, 0, sizeof(struct prefix));
ip_prefix_from_evpn_prefix(evp, pp);
- if (bgp_debug_zebra(NULL)) {
+ if (bgp_debug_zebra(NULL))
zlog_debug(
- "vrf %s: unimport evpn prefix %s parent %p flags 0x%x",
- vrf_id_to_name(bgp_vrf->vrf_id),
- prefix2str(evp, buf, sizeof(buf)),
- parent_pi, parent_pi->flags);
- }
+ "vrf %s: unimport evpn prefix %pFX parent %p flags 0x%x",
+ vrf_id_to_name(bgp_vrf->vrf_id), evp, parent_pi,
+ parent_pi->flags);
/* Locate route within the VRF. */
/* NOTE: There is no RD here. */
@@ -2850,15 +2837,13 @@ static int bgp_evpn_route_rmac_self_check(struct bgp *bgp_vrf,
*/
if (memcmp(&bgp_vrf->rmac, &pi->attr->rmac, ETH_ALEN) == 0) {
if (bgp_debug_update(pi->peer, NULL, NULL, 1)) {
- char buf1[PREFIX_STRLEN];
char attr_str[BUFSIZ] = {0};
bgp_dump_attr(pi->attr, attr_str, sizeof(attr_str));
- zlog_debug("%s: bgp %u prefix %s with attr %s - DENIED due to self mac",
- __func__, bgp_vrf->vrf_id,
- prefix2str(evp, buf1, sizeof(buf1)),
- attr_str);
+ zlog_debug(
+ "%s: bgp %u prefix %pFX with attr %s - DENIED due to self mac",
+ __func__, bgp_vrf->vrf_id, evp, attr_str);
}
return 1;
@@ -2879,7 +2864,6 @@ static int install_uninstall_routes_for_vrf(struct bgp *bgp_vrf, int install)
struct bgp_table *table;
struct bgp_path_info *pi;
int ret;
- char buf[PREFIX_STRLEN];
struct bgp *bgp_evpn = NULL;
afi = AFI_L2VPN;
@@ -2940,11 +2924,10 @@ static int install_uninstall_routes_for_vrf(struct bgp *bgp_vrf, int install)
if (ret) {
flog_err(
EC_BGP_EVPN_FAIL,
- "Failed to %s EVPN %s route in VRF %s",
+ "Failed to %s EVPN %pFX route in VRF %s",
install ? "install"
: "uninstall",
- prefix2str(evp, buf,
- sizeof(buf)),
+ evp,
vrf_id_to_name(
bgp_vrf->vrf_id));
return ret;
@@ -3113,7 +3096,6 @@ static int install_uninstall_route_in_vrfs(struct bgp *bgp_def, afi_t afi,
struct bgp_path_info *pi,
struct list *vrfs, int install)
{
- char buf[PREFIX2STR_BUFFER];
struct bgp *bgp_vrf;
struct listnode *node, *nnode;
@@ -3139,10 +3121,9 @@ static int install_uninstall_route_in_vrfs(struct bgp *bgp_def, afi_t afi,
if (ret) {
flog_err(EC_BGP_EVPN_FAIL,
- "%u: Failed to %s prefix %s in VRF %s",
+ "%u: Failed to %s prefix %pFX in VRF %s",
bgp_def->vrf_id,
- install ? "install" : "uninstall",
- prefix2str(evp, buf, sizeof(buf)),
+ install ? "install" : "uninstall", evp,
vrf_id_to_name(bgp_vrf->vrf_id));
return ret;
}
@@ -4100,17 +4081,14 @@ void bgp_evpn_withdraw_type5_route(struct bgp *bgp_vrf, const struct prefix *p,
{
int ret = 0;
struct prefix_evpn evp;
- char buf[PREFIX_STRLEN];
build_type5_prefix_from_ip_prefix(&evp, p);
ret = delete_evpn_type5_route(bgp_vrf, &evp);
- if (ret) {
+ if (ret)
flog_err(
EC_BGP_EVPN_ROUTE_DELETE,
- "%u failed to delete type-5 route for prefix %s in vrf %s",
- bgp_vrf->vrf_id, prefix2str(p, buf, sizeof(buf)),
- vrf_id_to_name(bgp_vrf->vrf_id));
- }
+ "%u failed to delete type-5 route for prefix %pFX in vrf %s",
+ bgp_vrf->vrf_id, p, vrf_id_to_name(bgp_vrf->vrf_id));
}
/* withdraw all type-5 routes for an address family */
@@ -4172,14 +4150,13 @@ void bgp_evpn_advertise_type5_route(struct bgp *bgp_vrf, const struct prefix *p,
{
int ret = 0;
struct prefix_evpn evp;
- char buf[PREFIX_STRLEN];
build_type5_prefix_from_ip_prefix(&evp, p);
ret = update_evpn_type5_route(bgp_vrf, &evp, src_attr);
if (ret)
flog_err(EC_BGP_EVPN_ROUTE_CREATE,
- "%u: Failed to create type-5 route for prefix %s",
- bgp_vrf->vrf_id, prefix2str(p, buf, sizeof(buf)));
+ "%u: Failed to create type-5 route for prefix %pFX",
+ bgp_vrf->vrf_id, p);
}
/* Inject all prefixes of a particular address-family (currently, IPv4 or
diff --git a/bgpd/bgp_evpn_mh.c b/bgpd/bgp_evpn_mh.c
index f064f87830..8f81278dee 100644
--- a/bgpd/bgp_evpn_mh.c
+++ b/bgpd/bgp_evpn_mh.c
@@ -699,7 +699,6 @@ static int bgp_evpn_type4_remote_routes_import(struct bgp *bgp,
int ret;
afi_t afi;
safi_t safi;
- char buf[PREFIX_STRLEN];
struct bgp_dest *rd_dest, *dest;
struct bgp_table *table;
struct bgp_path_info *pi;
@@ -744,13 +743,11 @@ static int bgp_evpn_type4_remote_routes_import(struct bgp *bgp,
if (ret) {
flog_err(
- EC_BGP_EVPN_FAIL,
- "Failed to %s EVPN %s route in ESI %s",
- install ? "install"
+ EC_BGP_EVPN_FAIL,
+ "Failed to %s EVPN %pFX route in ESI %s",
+ install ? "install"
: "uninstall",
- prefix2str(evp, buf,
- sizeof(buf)),
- es->esi_str);
+ evp, es->esi_str);
return ret;
}
}
@@ -1316,11 +1313,14 @@ static struct bgp_evpn_es *bgp_evpn_es_new(struct bgp *bgp, const esi_t *esi)
* This just frees appropriate memory, caller should have taken other
* needed actions.
*/
-static void bgp_evpn_es_free(struct bgp_evpn_es *es)
+static void bgp_evpn_es_free(struct bgp_evpn_es *es, const char *caller)
{
if (es->flags & (BGP_EVPNES_LOCAL | BGP_EVPNES_REMOTE))
return;
+ if (BGP_DEBUG(evpn_mh, EVPN_MH_ES))
+ zlog_debug("%s: es %s free", caller, es->esi_str);
+
/* cleanup resources maintained against the ES */
list_delete(&es->es_evi_list);
list_delete(&es->es_vtep_list);
@@ -1367,7 +1367,7 @@ static void bgp_evpn_es_local_info_clear(struct bgp_evpn_es *es)
bf_release_index(bm->rd_idspace, es->rd_id);
- bgp_evpn_es_free(es);
+ bgp_evpn_es_free(es, __func__);
}
/* eval remote info associated with the ES */
@@ -1378,7 +1378,7 @@ static void bgp_evpn_es_remote_info_re_eval(struct bgp_evpn_es *es)
} else {
if (CHECK_FLAG(es->flags, BGP_EVPNES_REMOTE)) {
UNSET_FLAG(es->flags, BGP_EVPNES_REMOTE);
- bgp_evpn_es_free(es);
+ bgp_evpn_es_free(es, __func__);
}
}
}
@@ -2320,7 +2320,7 @@ int bgp_evpn_remote_es_evi_add(struct bgp *bgp, struct bgpevpn *vpn,
if (!es_evi) {
es_evi = bgp_evpn_es_evi_new(es, vpn);
if (!es_evi) {
- bgp_evpn_es_free(es);
+ bgp_evpn_es_free(es, __func__);
return -1;
}
}
@@ -2903,17 +2903,15 @@ void bgp_evpn_mh_finish(void)
{
struct bgp_evpn_es *es;
struct bgp_evpn_es *es_next;
- struct bgp *bgp;
- bgp = bgp_get_evpn();
- if (bgp) {
- RB_FOREACH_SAFE(es, bgp_es_rb_head,
- &bgp_mh_info->es_rb_tree, es_next) {
- /* XXX - need to force free remote ESs here */
- bgp_evpn_local_es_do_del(bgp, es);
- }
+ if (BGP_DEBUG(evpn_mh, EVPN_MH_RT))
+ zlog_debug("evpn mh finish");
+
+ RB_FOREACH_SAFE (es, bgp_es_rb_head, &bgp_mh_info->es_rb_tree,
+ es_next) {
+ bgp_evpn_es_local_info_clear(es);
}
- thread_cancel(bgp_mh_info->t_cons_check);
+ thread_cancel(&bgp_mh_info->t_cons_check);
list_delete(&bgp_mh_info->local_es_list);
list_delete(&bgp_mh_info->pend_es_list);
diff --git a/bgpd/bgp_flowspec_util.c b/bgpd/bgp_flowspec_util.c
index 90e9236385..55e7973f81 100644
--- a/bgpd/bgp_flowspec_util.c
+++ b/bgpd/bgp_flowspec_util.c
@@ -20,6 +20,8 @@
#include "zebra.h"
+#include "lib/printfrr.h"
+
#include "prefix.h"
#include "lib_errors.h"
@@ -211,14 +213,11 @@ int bgp_flowspec_ip_address(enum bgp_flowspec_util_nlri_t type,
switch (type) {
case BGP_FLOWSPEC_RETURN_STRING:
if (prefix_local.family == AF_INET6) {
- char str[BGP_FLOWSPEC_STRING_DISPLAY_MAX];
int ret;
- prefix2str(&prefix_local, str,
- BGP_FLOWSPEC_STRING_DISPLAY_MAX);
- ret = snprintf(display, BGP_FLOWSPEC_STRING_DISPLAY_MAX,
- "%s/off %u",
- str, prefix_offset);
+ ret = snprintfrr(
+ display, BGP_FLOWSPEC_STRING_DISPLAY_MAX,
+ "%pFX/off %u", &prefix_local, prefix_offset);
if (ret < 0) {
*error = -1;
break;
diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c
index d7df707a36..4468408415 100644
--- a/bgpd/bgp_fsm.c
+++ b/bgpd/bgp_fsm.c
@@ -704,8 +704,8 @@ bool bgp_update_delay_configured(struct bgp *bgp)
on ending the update delay. */
void bgp_update_delay_end(struct bgp *bgp)
{
- THREAD_TIMER_OFF(bgp->t_update_delay);
- THREAD_TIMER_OFF(bgp->t_establish_wait);
+ THREAD_OFF(bgp->t_update_delay);
+ THREAD_OFF(bgp->t_establish_wait);
/* Reset update-delay related state */
bgp->update_delay_over = 1;
@@ -740,11 +740,12 @@ void bgp_update_delay_end(struct bgp *bgp)
bgp->main_zebra_update_hold = 1;
bgp->main_peers_update_hold = 1;
- /* Resume the queue processing. This should trigger the event that would
- take
- care of processing any work that was queued during the read-only
- mode. */
- work_queue_unplug(bm->process_main_queue);
+ /*
+ * Resume the queue processing. This should trigger the event that would
+ * take care of processing any work that was queued during the read-only
+ * mode.
+ */
+ work_queue_unplug(bgp->process_queue);
}
/**
@@ -923,7 +924,7 @@ static int bgp_maxmed_onstartup_timer(struct thread *thread)
zlog_info("Max med on startup ended - timer expired.");
bgp = THREAD_ARG(thread);
- THREAD_TIMER_OFF(bgp->t_maxmed_onstartup);
+ THREAD_OFF(bgp->t_maxmed_onstartup);
bgp->maxmed_onstartup_over = 1;
bgp_maxmed_update(bgp);
@@ -967,7 +968,7 @@ static int bgp_update_delay_timer(struct thread *thread)
zlog_info("Update delay ended - timer expired.");
bgp = THREAD_ARG(thread);
- THREAD_TIMER_OFF(bgp->t_update_delay);
+ THREAD_OFF(bgp->t_update_delay);
bgp_update_delay_end(bgp);
return 0;
@@ -981,7 +982,7 @@ static int bgp_establish_wait_timer(struct thread *thread)
zlog_info("Establish wait - timer expired.");
bgp = THREAD_ARG(thread);
- THREAD_TIMER_OFF(bgp->t_establish_wait);
+ THREAD_OFF(bgp->t_establish_wait);
bgp_check_update_delay(bgp);
return 0;
@@ -997,7 +998,7 @@ static void bgp_update_delay_begin(struct bgp *bgp)
struct peer *peer;
/* Stop the processing of queued work. Enqueue shall continue */
- work_queue_plug(bm->process_main_queue);
+ work_queue_plug(bgp->process_queue);
for (ALL_LIST_ELEMENTS(bgp->peer, node, nnode, peer))
peer->update_delay_over = 0;
diff --git a/bgpd/bgp_fsm.h b/bgpd/bgp_fsm.h
index aa98515c3f..b9156df617 100644
--- a/bgpd/bgp_fsm.h
+++ b/bgpd/bgp_fsm.h
@@ -31,7 +31,7 @@
#define BGP_TIMER_OFF(T) \
do { \
- THREAD_TIMER_OFF(T); \
+ THREAD_OFF(T); \
} while (0)
#define BGP_EVENT_ADD(P, E) \
diff --git a/bgpd/bgp_io.c b/bgpd/bgp_io.c
index 8f898c3121..38455b5e02 100644
--- a/bgpd/bgp_io.c
+++ b/bgpd/bgp_io.c
@@ -31,7 +31,7 @@
#include "network.h" // for ERRNO_IO_RETRY
#include "stream.h" // for stream_get_endp, stream_getw_from, str...
#include "ringbuf.h" // for ringbuf_remain, ringbuf_peek, ringbuf_...
-#include "thread.h" // for THREAD_OFF, THREAD_ARG, thread, thread...
+#include "thread.h" // for THREAD_OFF, THREAD_ARG, thread...
#include "zassert.h" // for assert
#include "bgpd/bgp_io.h"
diff --git a/bgpd/bgp_label.c b/bgpd/bgp_label.c
index 075dbe1cca..4f440cd1f8 100644
--- a/bgpd/bgp_label.c
+++ b/bgpd/bgp_label.c
@@ -215,7 +215,6 @@ void bgp_reg_dereg_for_label(struct bgp_dest *dest, struct bgp_path_info *pi,
int command;
uint16_t flags = 0;
size_t flags_pos = 0;
- char addr[PREFIX_STRLEN];
p = bgp_dest_get_prefix(dest);
local_label = &(dest->local_label);
@@ -242,11 +241,11 @@ void bgp_reg_dereg_for_label(struct bgp_dest *dest, struct bgp_path_info *pi,
* always takes precedence over auto-assigned labels.
*/
if (!have_label_to_reg) {
- if (BGP_DEBUG(labelpool, LABELPOOL)) {
- prefix2str(p, addr, PREFIX_STRLEN);
- zlog_debug("%s: Requesting label from LP for %s",
- __func__, addr);
- }
+ if (BGP_DEBUG(labelpool, LABELPOOL))
+ zlog_debug(
+ "%s: Requesting label from LP for %pFX",
+ __func__, p);
+
/* bgp_reg_for_label_callback() will call back
* __func__ when it gets a label from the pool.
* This means we'll never register FECs without
diff --git a/bgpd/bgp_main.c b/bgpd/bgp_main.c
index d0a32ee408..21c880e95b 100644
--- a/bgpd/bgp_main.c
+++ b/bgpd/bgp_main.c
@@ -62,6 +62,7 @@
#include "bgpd/bgp_errors.h"
#include "lib/routing_nb.h"
#include "bgpd/bgp_nb.h"
+#include "bgpd/bgp_evpn_mh.h"
#ifdef ENABLE_BGP_VNC
#include "bgpd/rfapi/rfapi_backend.h"
@@ -207,6 +208,8 @@ static __attribute__((__noreturn__)) void bgp_exit(int status)
if (bgp_default)
bgp_delete(bgp_default);
+ bgp_evpn_mh_finish();
+
/* reverse bgp_dump_init */
bgp_dump_finish();
diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c
index 67885cbf7e..f1aeafced7 100644
--- a/bgpd/bgp_mplsvpn.c
+++ b/bgpd/bgp_mplsvpn.c
@@ -1106,13 +1106,9 @@ vpn_leak_to_vrf_update_onevrf(struct bgp *bgp_vrf, /* to */
return;
}
- if (debug) {
- char buf_prefix[PREFIX_STRLEN];
-
- prefix2str(p, buf_prefix, sizeof(buf_prefix));
- zlog_debug("%s: updating %s to vrf %s", __func__,
- buf_prefix, bgp_vrf->name_pretty);
- }
+ if (debug)
+ zlog_debug("%s: updating %pFX to vrf %s", __func__, p,
+ bgp_vrf->name_pretty);
/* shallow copy */
static_attr = *path_vpn->attr;
diff --git a/bgpd/bgp_nb_config.c b/bgpd/bgp_nb_config.c
index f01325577c..3f0325eac6 100644
--- a/bgpd/bgp_nb_config.c
+++ b/bgpd/bgp_nb_config.c
@@ -509,7 +509,7 @@ int bgp_global_med_config_max_med_onstart_up_time_destroy(
/* Cancel max-med onstartup if its on */
if (bgp->t_maxmed_onstartup) {
- THREAD_TIMER_OFF(bgp->t_maxmed_onstartup);
+ THREAD_OFF(bgp->t_maxmed_onstartup);
bgp->maxmed_onstartup_over = 1;
}
diff --git a/bgpd/bgp_nht.c b/bgpd/bgp_nht.c
index 6cd38ec78f..64b10c0252 100644
--- a/bgpd/bgp_nht.c
+++ b/bgpd/bgp_nht.c
@@ -315,15 +315,12 @@ static void bgp_process_nexthop_update(struct bgp_nexthop_cache *bnc,
bnc->change_flags = 0;
/* debug print the input */
- if (BGP_DEBUG(nht, NHT)) {
- char buf[PREFIX2STR_BUFFER];
- prefix2str(&nhr->prefix, buf, sizeof(buf));
+ if (BGP_DEBUG(nht, NHT))
zlog_debug(
- "%s(%u): Rcvd NH update %s(%u) - metric %d/%d #nhops %d/%d flags 0x%x",
- bnc->bgp->name_pretty, bnc->bgp->vrf_id, buf,
+ "%s(%u): Rcvd NH update %pFX(%u) - metric %d/%d #nhops %d/%d flags 0x%x",
+ bnc->bgp->name_pretty, bnc->bgp->vrf_id, &nhr->prefix,
bnc->srte_color, nhr->metric, bnc->metric,
nhr->nexthop_num, bnc->nexthop_num, bnc->flags);
- }
if (nhr->metric != bnc->metric)
bnc->change_flags |= BGP_NEXTHOP_METRIC_CHANGED;
@@ -454,14 +451,10 @@ void bgp_parse_nexthop_update(int command, vrf_id_t vrf_id)
bnc = bnc_find(tree, &nhr.prefix, nhr.srte_color);
if (!bnc) {
- if (BGP_DEBUG(nht, NHT)) {
- char buf[PREFIX2STR_BUFFER];
-
- prefix2str(&nhr.prefix, buf, sizeof(buf));
+ if (BGP_DEBUG(nht, NHT))
zlog_debug(
- "parse nexthop update(%s(%u)(%s)): bnc info not found",
- buf, nhr.srte_color, bgp->name_pretty);
- }
+ "parse nexthop update(%pFX(%u)(%s)): bnc info not found",
+ &nhr.prefix, nhr.srte_color, bgp->name_pretty);
return;
}
diff --git a/bgpd/bgp_pbr.c b/bgpd/bgp_pbr.c
index f6e5c196ca..f7dd08443f 100644
--- a/bgpd/bgp_pbr.c
+++ b/bgpd/bgp_pbr.c
@@ -23,6 +23,8 @@
#include "jhash.h"
#include "pbr.h"
+#include "lib/printfrr.h"
+
#include "bgpd/bgpd.h"
#include "bgpd/bgp_pbr.h"
#include "bgpd/bgp_debug.h"
@@ -1438,7 +1440,6 @@ void bgp_pbr_print_policy_route(struct bgp_pbr_entry_main *api)
int i = 0;
char return_string[512];
char *ptr = return_string;
- char buff[64];
int nb_items = 0;
int delta, len = sizeof(return_string);
@@ -1449,12 +1450,10 @@ void bgp_pbr_print_policy_route(struct bgp_pbr_entry_main *api)
struct prefix *p = &(api->src_prefix);
if (api->src_prefix_offset)
- delta = snprintf(ptr, len, "@src %s/off%u",
- prefix2str(p, buff, 64),
- api->src_prefix_offset);
+ delta = snprintfrr(ptr, len, "@src %pFX/off%u", p,
+ api->src_prefix_offset);
else
- delta = snprintf(ptr, len, "@src %s",
- prefix2str(p, buff, 64));
+ delta = snprintfrr(ptr, len, "@src %pFX", p);
len -= delta;
ptr += delta;
INCREMENT_DISPLAY(ptr, nb_items, len);
@@ -1464,12 +1463,10 @@ void bgp_pbr_print_policy_route(struct bgp_pbr_entry_main *api)
INCREMENT_DISPLAY(ptr, nb_items, len);
if (api->dst_prefix_offset)
- delta = snprintf(ptr, len, "@dst %s/off%u",
- prefix2str(p, buff, 64),
- api->dst_prefix_offset);
+ delta = snprintfrr(ptr, len, "@dst %pFX/off%u", p,
+ api->dst_prefix_offset);
else
- delta = snprintf(ptr, len, "@dst %s",
- prefix2str(p, buff, 64));
+ delta = snprintfrr(ptr, len, "@dst %pFX", p);
len -= delta;
ptr += delta;
}
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index 4713452d5e..b637191d10 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -116,6 +116,14 @@ DEFINE_HOOK(bgp_process,
struct peer *peer, bool withdraw),
(bgp, afi, safi, bn, peer, withdraw))
+/** Test if path is suppressed. */
+static bool bgp_path_suppressed(struct bgp_path_info *pi)
+{
+ if (pi->extra == NULL || pi->extra->aggr_suppressors == NULL)
+ return false;
+
+ return listcount(pi->extra->aggr_suppressors) > 0;
+}
struct bgp_dest *bgp_afi_node_get(struct bgp_table *table, afi_t afi,
safi_t safi, const struct prefix *p,
@@ -1740,10 +1748,8 @@ bool subgroup_announce_check(struct bgp_dest *dest, struct bgp_path_info *pi,
}
/* Aggregate-address suppress check. */
- if (pi->extra && pi->extra->suppress)
- if (!UNSUPPRESS_MAP_NAME(filter)) {
- return false;
- }
+ if (bgp_path_suppressed(pi) && !UNSUPPRESS_MAP_NAME(filter))
+ return false;
/*
* If we are doing VRF 2 VRF leaking via the import
@@ -1980,7 +1986,7 @@ bool subgroup_announce_check(struct bgp_dest *dest, struct bgp_path_info *pi,
bgp_peer_as_override(bgp, afi, safi, peer, attr);
/* Route map & unsuppress-map apply. */
- if (ROUTE_MAP_OUT_NAME(filter) || (pi->extra && pi->extra->suppress)) {
+ if (ROUTE_MAP_OUT_NAME(filter) || bgp_path_suppressed(pi)) {
struct bgp_path_info rmap_path = {0};
struct bgp_path_info_extra dummy_rmap_path_extra = {0};
struct attr dummy_attr = {0};
@@ -2005,7 +2011,7 @@ bool subgroup_announce_check(struct bgp_dest *dest, struct bgp_path_info *pi,
SET_FLAG(peer->rmap_type, PEER_RMAP_TYPE_OUT);
- if (pi->extra && pi->extra->suppress)
+ if (bgp_path_suppressed(pi))
ret = route_map_apply(UNSUPPRESS_MAP(filter), p,
RMAP_BGP, &rmap_path);
else
@@ -2464,12 +2470,8 @@ void subgroup_process_announce_selected(struct update_subgroup *subgrp,
onlypeer = ((SUBGRP_PCOUNT(subgrp) == 1) ? (SUBGRP_PFIRST(subgrp))->peer
: NULL);
- if (BGP_DEBUG(update, UPDATE_OUT)) {
- char buf_prefix[PREFIX_STRLEN];
- prefix2str(p, buf_prefix, sizeof(buf_prefix));
- zlog_debug("%s: p=%s, selected=%p", __func__, buf_prefix,
- selected);
- }
+ if (BGP_DEBUG(update, UPDATE_OUT))
+ zlog_debug("%s: p=%pFX, selected=%p", __func__, p, selected);
/* First update is deferred until ORF or ROUTE-REFRESH is received */
if (onlypeer && CHECK_FLAG(onlypeer->af_sflags[afi][safi],
@@ -2973,18 +2975,21 @@ static void bgp_processq_del(struct work_queue *wq, void *data)
XFREE(MTYPE_BGP_PROCESS_QUEUE, pqnode);
}
-void bgp_process_queue_init(void)
+void bgp_process_queue_init(struct bgp *bgp)
{
- if (!bm->process_main_queue)
- bm->process_main_queue =
- work_queue_new(bm->master, "process_main_queue");
+ if (!bgp->process_queue) {
+ char name[BUFSIZ];
+
+ snprintf(name, BUFSIZ, "process_queue %s", bgp->name_pretty);
+ bgp->process_queue = work_queue_new(bm->master, name);
+ }
- bm->process_main_queue->spec.workfunc = &bgp_process_wq;
- bm->process_main_queue->spec.del_item_data = &bgp_processq_del;
- bm->process_main_queue->spec.max_retries = 0;
- bm->process_main_queue->spec.hold = 50;
+ bgp->process_queue->spec.workfunc = &bgp_process_wq;
+ bgp->process_queue->spec.del_item_data = &bgp_processq_del;
+ bgp->process_queue->spec.max_retries = 0;
+ bgp->process_queue->spec.hold = 50;
/* Use a higher yield value of 50ms for main queue processing */
- bm->process_main_queue->spec.yield = 50 * 1000L;
+ bgp->process_queue->spec.yield = 50 * 1000L;
}
static struct bgp_process_queue *bgp_processq_alloc(struct bgp *bgp)
@@ -3004,7 +3009,7 @@ static struct bgp_process_queue *bgp_processq_alloc(struct bgp *bgp)
void bgp_process(struct bgp *bgp, struct bgp_dest *dest, afi_t afi, safi_t safi)
{
#define ARBITRARY_PROCESS_QLEN 10000
- struct work_queue *wq = bm->process_main_queue;
+ struct work_queue *wq = bgp->process_queue;
struct bgp_process_queue *pqnode;
int pqnode_reuse = 0;
@@ -3061,13 +3066,13 @@ void bgp_add_eoiu_mark(struct bgp *bgp)
{
struct bgp_process_queue *pqnode;
- if (bm->process_main_queue == NULL)
+ if (bgp->process_queue == NULL)
return;
pqnode = bgp_processq_alloc(bgp);
SET_FLAG(pqnode->flags, BGP_PROCESS_QUEUE_EOIU_MARKER);
- work_queue_add(bm->process_main_queue, pqnode);
+ work_queue_add(bgp->process_queue, pqnode);
}
static int bgp_maximum_prefix_restart_timer(struct thread *thread)
@@ -4328,7 +4333,7 @@ void bgp_stop_announce_route_timer(struct peer_af *paf)
if (!paf->t_announce_route)
return;
- THREAD_TIMER_OFF(paf->t_announce_route);
+ thread_cancel(&paf->t_announce_route);
}
/*
@@ -4587,7 +4592,7 @@ static void bgp_clear_route_table(struct peer *peer, afi_t afi, safi_t safi,
struct bgp_table *table)
{
struct bgp_dest *dest;
- int force = bm->process_main_queue ? 0 : 1;
+ int force = peer->bgp->process_queue ? 0 : 1;
if (!table)
table = peer->bgp->rib[afi][safi];
@@ -5786,9 +5791,9 @@ void bgp_static_delete(struct bgp *bgp)
bgp_dest_get_prefix(
dest));
bgp_static_free(bgp_static);
- bgp_dest_set_bgp_static_info(dest,
+ bgp_dest_set_bgp_static_info(rm,
NULL);
- bgp_dest_unlock_node(dest);
+ bgp_dest_unlock_node(rm);
}
} else {
bgp_static = bgp_dest_get_bgp_static_info(dest);
@@ -6221,11 +6226,119 @@ static struct bgp_aggregate *bgp_aggregate_new(void)
static void bgp_aggregate_free(struct bgp_aggregate *aggregate)
{
+ XFREE(MTYPE_ROUTE_MAP_NAME, aggregate->suppress_map_name);
+ route_map_counter_decrement(aggregate->suppress_map);
XFREE(MTYPE_ROUTE_MAP_NAME, aggregate->rmap.name);
route_map_counter_decrement(aggregate->rmap.map);
XFREE(MTYPE_BGP_AGGREGATE, aggregate);
}
+/**
+ * Helper function to avoid repeated code: prepare variables for a
+ * `route_map_apply` call.
+ *
+ * \returns `true` on route map match, otherwise `false`.
+ */
+static bool aggr_suppress_map_test(struct bgp *bgp,
+ struct bgp_aggregate *aggregate,
+ struct bgp_path_info *pi)
+{
+ const struct prefix *p = bgp_dest_get_prefix(pi->net);
+ route_map_result_t rmr = RMAP_DENYMATCH;
+ struct bgp_path_info rmap_path = {};
+ struct attr attr = {};
+
+ /* No route map entries created, just don't match. */
+ if (aggregate->suppress_map == NULL)
+ return false;
+
+ /* Call route map matching and return result. */
+ attr.aspath = aspath_empty();
+ rmap_path.peer = bgp->peer_self;
+ rmap_path.attr = &attr;
+
+ SET_FLAG(bgp->peer_self->rmap_type, PEER_RMAP_TYPE_AGGREGATE);
+ rmr = route_map_apply(aggregate->suppress_map, p, RMAP_BGP, &rmap_path);
+ bgp->peer_self->rmap_type = 0;
+
+ bgp_attr_flush(&attr);
+
+ return rmr == RMAP_PERMITMATCH;
+}
+
+/** Test whether the aggregation has suppressed this path or not. */
+static bool aggr_suppress_exists(struct bgp_aggregate *aggregate,
+ struct bgp_path_info *pi)
+{
+ if (pi->extra == NULL || pi->extra->aggr_suppressors == NULL)
+ return false;
+
+ return listnode_lookup(pi->extra->aggr_suppressors, aggregate) != NULL;
+}
+
+/**
+ * Suppress this path and keep the reference.
+ *
+ * \returns `true` if needs processing otherwise `false`.
+ */
+static bool aggr_suppress_path(struct bgp_aggregate *aggregate,
+ struct bgp_path_info *pi)
+{
+ struct bgp_path_info_extra *pie;
+
+ /* Path is already suppressed by this aggregation. */
+ if (aggr_suppress_exists(aggregate, pi))
+ return false;
+
+ pie = bgp_path_info_extra_get(pi);
+
+ /* This is the first suppression, allocate memory and list it. */
+ if (pie->aggr_suppressors == NULL)
+ pie->aggr_suppressors = list_new();
+
+ listnode_add(pie->aggr_suppressors, aggregate);
+
+ /* Only mark for processing if suppressed. */
+ if (listcount(pie->aggr_suppressors) == 1) {
+ if (BGP_DEBUG(update, UPDATE_OUT))
+ zlog_debug("aggregate-address suppressing: %pFX",
+ bgp_dest_get_prefix(pi->net));
+
+ bgp_path_info_set_flag(pi->net, pi, BGP_PATH_ATTR_CHANGED);
+ return true;
+ }
+
+ return false;
+}
+
+/**
+ * Unsuppress this path and remove the reference.
+ *
+ * \returns `true` if needs processing otherwise `false`.
+ */
+static bool aggr_unsuppress_path(struct bgp_aggregate *aggregate,
+ struct bgp_path_info *pi)
+{
+ /* Path wasn't suppressed. */
+ if (!aggr_suppress_exists(aggregate, pi))
+ return false;
+
+ listnode_delete(pi->extra->aggr_suppressors, aggregate);
+
+ /* Unsuppress and free extra memory if last item. */
+ if (listcount(pi->extra->aggr_suppressors) == 0) {
+ if (BGP_DEBUG(update, UPDATE_OUT))
+ zlog_debug("aggregate-address unsuppressing: %pFX",
+ bgp_dest_get_prefix(pi->net));
+
+ list_delete(&pi->extra->aggr_suppressors);
+ bgp_path_info_set_flag(pi->net, pi, BGP_PATH_ATTR_CHANGED);
+ return true;
+ }
+
+ return false;
+}
+
static bool bgp_aggregate_info_same(struct bgp_path_info *pi, uint8_t origin,
struct aspath *aspath,
struct community *comm,
@@ -6420,13 +6533,11 @@ static bool bgp_aggregate_test_all_med(struct bgp_aggregate *aggregate,
* Toggles the route suppression status for this aggregate address
* configuration.
*/
-static void bgp_aggregate_toggle_suppressed(struct bgp_aggregate *aggregate,
- struct bgp *bgp,
- const struct prefix *p, afi_t afi,
- safi_t safi, bool suppress)
+void bgp_aggregate_toggle_suppressed(struct bgp_aggregate *aggregate,
+ struct bgp *bgp, const struct prefix *p,
+ afi_t afi, safi_t safi, bool suppress)
{
struct bgp_table *table = bgp->rib[afi][safi];
- struct bgp_path_info_extra *pie;
const struct prefix *dest_p;
struct bgp_dest *dest, *top;
struct bgp_path_info *pi;
@@ -6447,32 +6558,17 @@ static void bgp_aggregate_toggle_suppressed(struct bgp_aggregate *aggregate,
if (pi->sub_type == BGP_ROUTE_AGGREGATE)
continue;
- /*
- * On installation it is possible that pi->extra is
- * set to NULL, otherwise it must exists.
- */
- assert(!suppress && pi->extra != NULL);
-
/* We are toggling suppression back. */
if (suppress) {
- pie = bgp_path_info_extra_get(pi);
/* Suppress route if not suppressed already. */
- pie->suppress++;
- bgp_path_info_set_flag(dest, pi,
- BGP_PATH_ATTR_CHANGED);
- toggle_suppression = true;
+ if (aggr_suppress_path(aggregate, pi))
+ toggle_suppression = true;
continue;
}
- pie = pi->extra;
- assert(pie->suppress > 0);
- pie->suppress--;
/* Install route if there is no more suppression. */
- if (pie->suppress == 0) {
- bgp_path_info_set_flag(dest, pi,
- BGP_PATH_ATTR_CHANGED);
+ if (aggr_unsuppress_path(aggregate, pi))
toggle_suppression = true;
- }
}
if (toggle_suppression)
@@ -6559,6 +6655,17 @@ void bgp_aggregate_route(struct bgp *bgp, const struct prefix *p, afi_t afi,
if (aggregate->match_med)
bgp_aggregate_test_all_med(aggregate, bgp, p, afi, safi);
+ /*
+ * Reset aggregate count: we might've been called from route map
+ * update so in that case we must retest all more specific routes.
+ *
+ * \see `bgp_route_map_process_update`.
+ */
+ aggregate->count = 0;
+ aggregate->incomplete_origin_count = 0;
+ aggregate->incomplete_origin_count = 0;
+ aggregate->egp_origin_count = 0;
+
/* ORIGIN attribute: If at least one route among routes that are
aggregated has ORIGIN with the value INCOMPLETE, then the
aggregated route must have the ORIGIN attribute with the value
@@ -6603,10 +6710,24 @@ void bgp_aggregate_route(struct bgp *bgp, const struct prefix *p, afi_t afi,
*/
if (aggregate->summary_only
&& AGGREGATE_MED_VALID(aggregate)) {
- (bgp_path_info_extra_get(pi))->suppress++;
- bgp_path_info_set_flag(dest, pi,
- BGP_PATH_ATTR_CHANGED);
- match++;
+ if (aggr_suppress_path(aggregate, pi))
+ match++;
+ }
+
+ /*
+ * Suppress more specific routes that match the route
+ * map results.
+ *
+ * MED matching:
+ * Don't suppress routes if MED matching is enabled and
+ * it mismatched otherwise we might end up with no
+ * routes for this path.
+ */
+ if (aggregate->suppress_map_name
+ && AGGREGATE_MED_VALID(aggregate)
+ && aggr_suppress_map_test(bgp, aggregate, pi)) {
+ if (aggr_suppress_path(aggregate, pi))
+ match++;
}
aggregate->count++;
@@ -6746,15 +6867,17 @@ void bgp_aggregate_delete(struct bgp *bgp, const struct prefix *p, afi_t afi,
if (aggregate->summary_only && pi->extra
&& AGGREGATE_MED_VALID(aggregate)) {
- pi->extra->suppress--;
+ if (aggr_unsuppress_path(aggregate, pi))
+ match++;
+ }
- if (pi->extra->suppress == 0) {
- bgp_path_info_set_flag(
- dest, pi,
- BGP_PATH_ATTR_CHANGED);
+ if (aggregate->suppress_map_name
+ && AGGREGATE_MED_VALID(aggregate)
+ && aggr_suppress_map_test(bgp, aggregate, pi)) {
+ if (aggr_unsuppress_path(aggregate, pi))
match++;
- }
}
+
aggregate->count--;
if (pi->attr->origin == BGP_ORIGIN_INCOMPLETE)
@@ -6845,7 +6968,11 @@ static void bgp_add_route_to_aggregate(struct bgp *bgp,
pinew, true);
if (aggregate->summary_only && AGGREGATE_MED_VALID(aggregate))
- (bgp_path_info_extra_get(pinew))->suppress++;
+ aggr_suppress_path(aggregate, pinew);
+
+ if (aggregate->suppress_map_name && AGGREGATE_MED_VALID(aggregate)
+ && aggr_suppress_map_test(bgp, aggregate, pinew))
+ aggr_suppress_path(aggregate, pinew);
switch (pinew->attr->origin) {
case BGP_ORIGIN_INCOMPLETE:
@@ -6941,19 +7068,17 @@ static void bgp_remove_route_from_aggregate(struct bgp *bgp, afi_t afi,
if (pi->sub_type == BGP_ROUTE_AGGREGATE)
return;
- if (aggregate->summary_only && pi->extra && pi->extra->suppress > 0
- && AGGREGATE_MED_VALID(aggregate)) {
- pi->extra->suppress--;
+ if (aggregate->summary_only && AGGREGATE_MED_VALID(aggregate))
+ if (aggr_unsuppress_path(aggregate, pi))
+ match++;
- if (pi->extra->suppress == 0) {
- bgp_path_info_set_flag(pi->net, pi,
- BGP_PATH_ATTR_CHANGED);
+ if (aggregate->suppress_map_name && AGGREGATE_MED_VALID(aggregate)
+ && aggr_suppress_map_test(bgp, aggregate, pi))
+ if (aggr_unsuppress_path(aggregate, pi))
match++;
- }
- }
/*
- * This must be called after `summary` check to avoid
+ * This must be called after `summary`, `suppress-map` check to avoid
* "unsuppressing" twice.
*/
if (aggregate->match_med)
@@ -7216,7 +7341,8 @@ static int bgp_aggregate_unset(struct vty *vty, const char *prefix_str,
static int bgp_aggregate_set(struct vty *vty, const char *prefix_str, afi_t afi,
safi_t safi, const char *rmap,
uint8_t summary_only, uint8_t as_set,
- uint8_t origin, bool match_med)
+ uint8_t origin, bool match_med,
+ const char *suppress_map)
{
VTY_DECLVAR_CONTEXT(bgp, bgp);
int ret;
@@ -7225,6 +7351,12 @@ static int bgp_aggregate_set(struct vty *vty, const char *prefix_str, afi_t afi,
struct bgp_aggregate *aggregate;
uint8_t as_set_new = as_set;
+ if (suppress_map && summary_only) {
+ vty_out(vty,
+ "'summary-only' and 'suppress-map' can't be used at the same time\n");
+ return CMD_WARNING_CONFIG_FAILED;
+ }
+
/* Convert string to prefix structure. */
ret = str2prefix(prefix_str, &p);
if (!ret) {
@@ -7296,6 +7428,18 @@ static int bgp_aggregate_set(struct vty *vty, const char *prefix_str, afi_t afi,
aggregate->rmap.map = route_map_lookup_by_name(rmap);
route_map_counter_increment(aggregate->rmap.map);
}
+
+ if (suppress_map) {
+ XFREE(MTYPE_ROUTE_MAP_NAME, aggregate->suppress_map_name);
+ route_map_counter_decrement(aggregate->suppress_map);
+
+ aggregate->suppress_map_name =
+ XSTRDUP(MTYPE_ROUTE_MAP_NAME, suppress_map);
+ aggregate->suppress_map =
+ route_map_lookup_by_name(aggregate->suppress_map_name);
+ route_map_counter_increment(aggregate->suppress_map);
+ }
+
bgp_dest_set_bgp_aggregate_info(dest, aggregate);
/* Aggregate address insert into BGP routing table. */
@@ -7311,6 +7455,7 @@ DEFPY(aggregate_addressv4, aggregate_addressv4_cmd,
"|route-map WORD$rmap_name"
"|origin <egp|igp|incomplete>$origin_s"
"|matching-MED-only$match_med"
+ "|suppress-map WORD$suppress_map"
"}",
NO_STR
"Configure BGP aggregate entries\n"
@@ -7323,7 +7468,9 @@ DEFPY(aggregate_addressv4, aggregate_addressv4_cmd,
"Remote EGP\n"
"Local IGP\n"
"Unknown heritage\n"
- "Only aggregate routes with matching MED\n")
+ "Only aggregate routes with matching MED\n"
+ "Suppress the selected more specific routes\n"
+ "Route map with the route selectors\n")
{
const char *prefix_s = NULL;
safi_t safi = bgp_node_safi(vty);
@@ -7359,7 +7506,7 @@ DEFPY(aggregate_addressv4, aggregate_addressv4_cmd,
return bgp_aggregate_set(vty, prefix_s, AFI_IP, safi, rmap_name,
summary_only != NULL, as_set, origin,
- match_med != NULL);
+ match_med != NULL, suppress_map);
}
DEFPY(aggregate_addressv6, aggregate_addressv6_cmd,
@@ -7369,6 +7516,7 @@ DEFPY(aggregate_addressv6, aggregate_addressv6_cmd,
"|route-map WORD$rmap_name"
"|origin <egp|igp|incomplete>$origin_s"
"|matching-MED-only$match_med"
+ "|suppress-map WORD$suppress_map"
"}",
NO_STR
"Configure BGP aggregate entries\n"
@@ -7381,7 +7529,9 @@ DEFPY(aggregate_addressv6, aggregate_addressv6_cmd,
"Remote EGP\n"
"Local IGP\n"
"Unknown heritage\n"
- "Only aggregate routes with matching MED\n")
+ "Only aggregate routes with matching MED\n"
+ "Suppress the selected more specific routes\n"
+ "Route map with the route selectors\n")
{
uint8_t origin = BGP_ORIGIN_UNSPECIFIED;
int as_set = AGGREGATE_AS_UNSET;
@@ -7405,7 +7555,7 @@ DEFPY(aggregate_addressv6, aggregate_addressv6_cmd,
return bgp_aggregate_set(vty, prefix_str, AFI_IP6, SAFI_UNICAST,
rmap_name, summary_only != NULL, as_set,
- origin, match_med != NULL);
+ origin, match_med != NULL, suppress_map);
}
/* Redistribute route treatment. */
@@ -7661,13 +7811,10 @@ static void route_vty_out_route(const struct prefix *p, struct vty *vty,
json_object_string_add(json, "network", buf2);
}
} else if (p->family == AF_ETHERNET) {
- prefix2str(p, buf, PREFIX_STRLEN);
len = vty_out(vty, "%pFX", p);
} else if (p->family == AF_EVPN) {
if (!json)
- len = vty_out(vty, "%s",
- prefix2str((struct prefix_evpn *)p, buf,
- BUFSIZ));
+ len = vty_out(vty, "%pFX", (struct prefix_evpn *)p);
else
bgp_evpn_route2json((struct prefix_evpn *)p, json);
} else if (p->family == AF_FLOWSPEC) {
@@ -7716,7 +7863,7 @@ static void route_vty_short_status_out(struct vty *vty,
if (CHECK_FLAG(path->flags, BGP_PATH_STALE))
json_object_boolean_true_add(json_path, "stale");
- if (path->extra && path->extra->suppress)
+ if (path->extra && bgp_path_suppressed(path))
json_object_boolean_true_add(json_path, "suppressed");
if (CHECK_FLAG(path->flags, BGP_PATH_VALID)
@@ -7753,7 +7900,7 @@ static void route_vty_short_status_out(struct vty *vty,
vty_out(vty, "R");
else if (CHECK_FLAG(path->flags, BGP_PATH_STALE))
vty_out(vty, "S");
- else if (path->extra && path->extra->suppress)
+ else if (bgp_path_suppressed(path))
vty_out(vty, "s");
else if (CHECK_FLAG(path->flags, BGP_PATH_VALID)
&& !CHECK_FLAG(path->flags, BGP_PATH_HISTORY))
@@ -8995,7 +9142,6 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp,
{
char buf[INET6_ADDRSTRLEN];
char buf1[BUFSIZ];
- char buf2[EVPN_ROUTE_STRLEN];
struct attr *attr = path->attr;
int sockunion_vty_out(struct vty *, union sockunion *);
time_t tbuf;
@@ -9033,7 +9179,6 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp,
if (path->extra) {
char tag_buf[30];
- buf2[0] = '\0';
tag_buf[0] = '\0';
if (path->extra && path->extra->num_labels) {
bgp_evpn_label2str(path->extra->label,
@@ -9042,10 +9187,9 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp,
}
if (safi == SAFI_EVPN) {
if (!json_paths) {
- prefix2str((struct prefix_evpn *)
- bgp_dest_get_prefix(bn),
- buf2, sizeof(buf2));
- vty_out(vty, " Route %s", buf2);
+ vty_out(vty, " Route %pFX",
+ (struct prefix_evpn *)
+ bgp_dest_get_prefix(bn));
if (tag_buf[0] != '\0')
vty_out(vty, " VNI %s", tag_buf);
vty_out(vty, "\n");
@@ -9069,13 +9213,20 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp,
pdest),
buf1, sizeof(buf1));
if (is_pi_family_evpn(parent_ri)) {
- prefix2str((struct prefix_evpn *)
- bgp_dest_get_prefix(
- dest),
- buf2, sizeof(buf2));
- vty_out(vty, " Imported from %s:%s, VNI %s\n", buf1, buf2, tag_buf);
+ vty_out(vty,
+ " Imported from %s:%pFX, VNI %s\n",
+ buf1,
+ (struct prefix_evpn *)
+ bgp_dest_get_prefix(
+ dest),
+ tag_buf);
} else
- vty_out(vty, " Imported from %s:%s\n", buf1, buf2);
+ vty_out(vty,
+ " Imported from %s:%pFX\n",
+ buf1,
+ (struct prefix_evpn *)
+ bgp_dest_get_prefix(
+ dest));
}
}
}
@@ -10407,7 +10558,6 @@ void route_vty_out_detail_header(struct vty *vty, struct bgp *bgp,
struct peer *peer;
struct listnode *node, *nnode;
char buf1[RD_ADDRSTRLEN];
- char buf3[EVPN_ROUTE_STRLEN];
char prefix_str[BUFSIZ];
int count = 0;
int best = 0;
@@ -10439,12 +10589,10 @@ void route_vty_out_detail_header(struct vty *vty, struct bgp *bgp,
if (safi == SAFI_EVPN) {
if (!json) {
- vty_out(vty, "BGP routing table entry for %s%s%s\n",
+ vty_out(vty, "BGP routing table entry for %s%s%pFX\n",
prd ? prefix_rd2str(prd, buf1, sizeof(buf1))
: "",
- prd ? ":" : "",
- prefix2str((struct prefix_evpn *)p, buf3,
- sizeof(buf3)));
+ prd ? ":" : "", (struct prefix_evpn *)p);
} else {
json_object_string_add(json, "rd",
prd ? prefix_rd2str(prd, buf1, sizeof(buf1)) :
@@ -10480,7 +10628,7 @@ void route_vty_out_detail_header(struct vty *vty, struct bgp *bgp,
count++;
if (CHECK_FLAG(pi->flags, BGP_PATH_SELECTED)) {
best = count;
- if (pi->extra && pi->extra->suppress)
+ if (bgp_path_suppressed(pi))
suppress = 1;
if (pi->attr->community == NULL)
@@ -14045,6 +14193,10 @@ void bgp_config_write_network(struct vty *vty, struct bgp *bgp, afi_t afi,
if (bgp_aggregate->match_med)
vty_out(vty, " matching-MED-only");
+ if (bgp_aggregate->suppress_map_name)
+ vty_out(vty, " suppress-map %s",
+ bgp_aggregate->suppress_map_name);
+
vty_out(vty, "\n");
}
}
diff --git a/bgpd/bgp_route.h b/bgpd/bgp_route.h
index 962a086081..4a4959298a 100644
--- a/bgpd/bgp_route.h
+++ b/bgpd/bgp_route.h
@@ -110,8 +110,8 @@ struct bgp_path_info_extra {
/* Pointer to dampening structure. */
struct bgp_damp_info *damp_info;
- /* This route is suppressed with aggregation. */
- int suppress;
+ /** List of aggregations that suppress this path. */
+ struct list *aggr_suppressors;
/* Nexthop reachability check. */
uint32_t igpmetric;
@@ -398,6 +398,11 @@ struct bgp_aggregate {
#define AGGREGATE_MED_VALID(aggregate) \
(((aggregate)->match_med && !(aggregate)->med_mismatched) \
|| !(aggregate)->match_med)
+
+ /** Suppress map route map name (`NULL` when disabled). */
+ char *suppress_map_name;
+ /** Suppress map route map pointer. */
+ struct route_map *suppress_map;
};
#define BGP_NEXTHOP_AFI_FROM_NHLEN(nhlen) \
@@ -527,7 +532,7 @@ DECLARE_HOOK(bgp_process,
/* Prototypes. */
extern void bgp_rib_remove(struct bgp_dest *dest, struct bgp_path_info *pi,
struct peer *peer, afi_t afi, safi_t safi);
-extern void bgp_process_queue_init(void);
+extern void bgp_process_queue_init(struct bgp *bgp);
extern void bgp_route_init(void);
extern void bgp_route_finish(void);
extern void bgp_cleanup_routes(struct bgp *);
@@ -710,4 +715,8 @@ extern bool bgp_update_martian_nexthop(struct bgp *bgp, afi_t afi, safi_t safi,
struct attr *attr, struct bgp_dest *dest);
extern int bgp_evpn_path_info_cmp(struct bgp *bgp, struct bgp_path_info *new,
struct bgp_path_info *exist, int *paths_eq);
+extern void bgp_aggregate_toggle_suppressed(struct bgp_aggregate *aggregate,
+ struct bgp *bgp,
+ const struct prefix *p, afi_t afi,
+ safi_t safi, bool suppress);
#endif /* _QUAGGA_BGP_ROUTE_H */
diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c
index 0e26576c1b..c655743936 100644
--- a/bgpd/bgp_routemap.c
+++ b/bgpd/bgp_routemap.c
@@ -3746,6 +3746,7 @@ static void bgp_route_map_process_update(struct bgp *bgp, const char *rmap_name,
int route_update)
{
int i;
+ bool matched;
afi_t afi;
safi_t safi;
struct peer *peer;
@@ -3845,16 +3846,35 @@ static void bgp_route_map_process_update(struct bgp *bgp, const char *rmap_name,
if (!aggregate)
continue;
- if (!aggregate->rmap.name
- || (strcmp(rmap_name, aggregate->rmap.name) != 0))
- continue;
+ matched = false;
- if (!aggregate->rmap.map)
- route_map_counter_increment(map);
+ /* Update suppress map pointer. */
+ if (aggregate->suppress_map_name
+ && strmatch(aggregate->suppress_map_name,
+ rmap_name)) {
+ if (aggregate->rmap.map == NULL)
+ route_map_counter_increment(map);
- aggregate->rmap.map = map;
+ aggregate->suppress_map = map;
+
+ bgp_aggregate_toggle_suppressed(
+ aggregate, bgp, bgp_dest_get_prefix(bn),
+ afi, safi, false);
+
+ matched = true;
+ }
+
+ if (aggregate->rmap.name
+ && strmatch(rmap_name, aggregate->rmap.name)) {
+ if (aggregate->rmap.map == NULL)
+ route_map_counter_increment(map);
+
+ aggregate->rmap.map = map;
+
+ matched = true;
+ }
- if (route_update) {
+ if (matched && route_update) {
const struct prefix *bn_p =
bgp_dest_get_prefix(bn);
diff --git a/bgpd/bgp_rpki.c b/bgpd/bgp_rpki.c
index ca47fb316a..0f0aff7eaa 100644
--- a/bgpd/bgp_rpki.c
+++ b/bgpd/bgp_rpki.c
@@ -702,8 +702,6 @@ static int rpki_validate_prefix(struct peer *peer, struct attr *attr,
as_t as_number = 0;
struct lrtr_ip_addr ip_addr_prefix;
enum pfxv_state result;
- char buf[BUFSIZ];
- const char *prefix_string;
if (!is_synchronized())
return 0;
@@ -754,27 +752,26 @@ static int rpki_validate_prefix(struct peer *peer, struct attr *attr,
prefix->prefixlen, &result);
// Print Debug output
- prefix_string = prefix2str(prefix, buf, sizeof(buf));
switch (result) {
case BGP_PFXV_STATE_VALID:
RPKI_DEBUG(
- "Validating Prefix %s from asn %u Result: VALID",
- prefix_string, as_number);
+ "Validating Prefix %pFX from asn %u Result: VALID",
+ prefix, as_number);
return RPKI_VALID;
case BGP_PFXV_STATE_NOT_FOUND:
RPKI_DEBUG(
- "Validating Prefix %s from asn %u Result: NOT FOUND",
- prefix_string, as_number);
+ "Validating Prefix %pFX from asn %u Result: NOT FOUND",
+ prefix, as_number);
return RPKI_NOTFOUND;
case BGP_PFXV_STATE_INVALID:
RPKI_DEBUG(
- "Validating Prefix %s from asn %u Result: INVALID",
- prefix_string, as_number);
+ "Validating Prefix %pFX from asn %u Result: INVALID",
+ prefix, as_number);
return RPKI_INVALID;
default:
RPKI_DEBUG(
- "Validating Prefix %s from asn %u Result: CANNOT VALIDATE",
- prefix_string, as_number);
+ "Validating Prefix %pFX from asn %u Result: CANNOT VALIDATE",
+ prefix, as_number);
break;
}
return 0;
diff --git a/bgpd/bgp_updgrp.c b/bgpd/bgp_updgrp.c
index 1685f98181..21eca78abc 100644
--- a/bgpd/bgp_updgrp.c
+++ b/bgpd/bgp_updgrp.c
@@ -796,13 +796,11 @@ static void update_subgroup_delete(struct update_subgroup *subgrp)
UPDGRP_INCR_STAT(subgrp->update_group, subgrps_deleted);
THREAD_OFF(subgrp->t_merge_check);
-
- THREAD_TIMER_OFF(subgrp->t_coalesce);
+ THREAD_OFF(subgrp->t_coalesce);
bpacket_queue_cleanup(SUBGRP_PKTQ(subgrp));
subgroup_clear_table(subgrp);
- THREAD_TIMER_OFF(subgrp->t_coalesce);
sync_delete(subgrp);
if (BGP_DEBUG(update_groups, UPDATE_GROUPS) && subgrp->update_group)
@@ -1768,7 +1766,7 @@ int update_group_refresh_default_originate_route_map(struct thread *thread)
bgp = THREAD_ARG(thread);
update_group_walk(bgp, update_group_default_originate_route_map_walkcb,
reason);
- THREAD_TIMER_OFF(bgp->t_rmap_def_originate_eval);
+ thread_cancel(&bgp->t_rmap_def_originate_eval);
bgp_unlock(bgp);
return 0;
diff --git a/bgpd/bgp_updgrp_packet.c b/bgpd/bgp_updgrp_packet.c
index d1ddfd7a75..c3edb9e9a4 100644
--- a/bgpd/bgp_updgrp_packet.c
+++ b/bgpd/bgp_updgrp_packet.c
@@ -1137,7 +1137,6 @@ void subgroup_default_update_packet(struct update_subgroup *subgrp,
/* Logging the attribute. */
if (bgp_debug_update(NULL, &p, subgrp->update_group, 0)) {
char attrstr[BUFSIZ];
- char buf[PREFIX_STRLEN];
/* ' with addpath ID ' 17
* max strlen of uint32 + 10
* +/- (just in case) + 1
@@ -1156,10 +1155,9 @@ void subgroup_default_update_packet(struct update_subgroup *subgrp,
else
tx_id_buf[0] = '\0';
- zlog_debug("u%" PRIu64 ":s%" PRIu64 " send UPDATE %s%s %s",
- (SUBGRP_UPDGRP(subgrp))->id, subgrp->id,
- prefix2str(&p, buf, sizeof(buf)), tx_id_buf,
- attrstr);
+ zlog_debug("u%" PRIu64 ":s%" PRIu64 " send UPDATE %pFX%s %s",
+ (SUBGRP_UPDGRP(subgrp))->id, subgrp->id, &p,
+ tx_id_buf, attrstr);
}
s = stream_new(BGP_MAX_PACKET_SIZE);
@@ -1222,7 +1220,6 @@ void subgroup_default_withdraw_packet(struct update_subgroup *subgrp)
p.prefixlen = 0;
if (bgp_debug_update(NULL, &p, subgrp->update_group, 0)) {
- char buf[PREFIX_STRLEN];
/* ' with addpath ID ' 17
* max strlen of uint32 + 10
* +/- (just in case) + 1
@@ -1235,9 +1232,10 @@ void subgroup_default_withdraw_packet(struct update_subgroup *subgrp)
" with addpath ID %u",
BGP_ADDPATH_TX_ID_FOR_DEFAULT_ORIGINATE);
- zlog_debug("u%" PRIu64 ":s%" PRIu64" send UPDATE %s%s -- unreachable",
- (SUBGRP_UPDGRP(subgrp))->id, subgrp->id,
- prefix2str(&p, buf, sizeof(buf)), tx_id_buf);
+ zlog_debug("u%" PRIu64 ":s%" PRIu64
+ " send UPDATE %pFX%s -- unreachable",
+ (SUBGRP_UPDGRP(subgrp))->id, subgrp->id, &p,
+ tx_id_buf);
}
s = stream_new(BGP_MAX_PACKET_SIZE);
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index 13dd50aa88..087836425b 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -3883,7 +3883,6 @@ void bgp_config_write_listen(struct vty *vty, struct bgp *bgp)
struct listnode *node, *nnode, *rnode, *nrnode;
struct prefix *range;
afi_t afi;
- char buf[PREFIX2STR_BUFFER];
if (bgp->dynamic_neighbors_limit != BGP_DYNAMIC_NEIGHBORS_LIMIT_DEFAULT)
vty_out(vty, " bgp listen limit %d\n",
@@ -3893,10 +3892,9 @@ void bgp_config_write_listen(struct vty *vty, struct bgp *bgp)
for (afi = AFI_IP; afi < AFI_MAX; afi++) {
for (ALL_LIST_ELEMENTS(group->listen_range[afi], rnode,
nrnode, range)) {
- prefix2str(range, buf, sizeof(buf));
vty_out(vty,
- " bgp listen range %s peer-group %s\n",
- buf, group->name);
+ " bgp listen range %pFX peer-group %s\n",
+ range, group->name);
}
}
}
@@ -14112,7 +14110,6 @@ static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group)
struct prefix *range;
struct peer *conf;
struct peer *peer;
- char buf[PREFIX2STR_BUFFER];
afi_t afi;
safi_t safi;
const char *peer_status;
@@ -14166,10 +14163,8 @@ static int bgp_show_one_peer_group(struct vty *vty, struct peer_group *group)
for (ALL_LIST_ELEMENTS(group->listen_range[afi], node,
- nnode, range)) {
- prefix2str(range, buf, sizeof(buf));
- vty_out(vty, " %s\n", buf);
- }
+ nnode, range))
+ vty_out(vty, " %pFX\n", range);
}
}
@@ -17937,9 +17932,10 @@ DEFUN (no_community_list_expanded_all,
return CMD_SUCCESS;
}
-ALIAS(no_community_list_expanded_all, no_bgp_community_list_expanded_all_list_cmd,
+ALIAS(no_community_list_expanded_all,
+ no_bgp_community_list_expanded_all_list_cmd,
"no bgp community-list <(100-500)|expanded WORD>",
- NO_STR IP_STR COMMUNITY_LIST_STR
+ NO_STR BGP_STR COMMUNITY_LIST_STR
"Community list number (expanded)\n"
"Add an expanded community-list entry\n"
"Community list name\n")
@@ -18558,7 +18554,7 @@ DEFUN (no_extcommunity_list_standard_all,
ALIAS(no_extcommunity_list_standard_all,
no_bgp_extcommunity_list_standard_all_list_cmd,
"no bgp extcommunity-list <(1-99)|standard WORD>",
- NO_STR IP_STR EXTCOMMUNITY_LIST_STR
+ NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
"Extended Community list number (standard)\n"
"Specify standard extcommunity-list\n"
"Community list name\n")
@@ -18623,7 +18619,7 @@ DEFUN (no_extcommunity_list_expanded_all,
ALIAS(no_extcommunity_list_expanded_all,
no_bgp_extcommunity_list_expanded_all_list_cmd,
"no bgp extcommunity-list <(100-500)|expanded WORD>",
- NO_STR IP_STR EXTCOMMUNITY_LIST_STR
+ NO_STR BGP_STR EXTCOMMUNITY_LIST_STR
"Extended Community list number (expanded)\n"
"Specify expanded extcommunity-list\n"
"Extended Community list name\n")
diff --git a/bgpd/bgp_zebra.c b/bgpd/bgp_zebra.c
index efc1672189..d4a69af4f7 100644
--- a/bgpd/bgp_zebra.c
+++ b/bgpd/bgp_zebra.c
@@ -91,11 +91,9 @@ static int bgp_router_id_update(ZAPI_CALLBACK_ARGS)
zebra_router_id_update_read(zclient->ibuf, &router_id);
- if (BGP_DEBUG(zebra, ZEBRA)) {
- char buf[PREFIX2STR_BUFFER];
- prefix2str(&router_id, buf, sizeof(buf));
- zlog_debug("Rx Router Id update VRF %u Id %s", vrf_id, buf);
- }
+ if (BGP_DEBUG(zebra, ZEBRA))
+ zlog_debug("Rx Router Id update VRF %u Id %pFX", vrf_id,
+ &router_id);
bgp_router_id_zebra_bump(vrf_id, &router_id);
return 0;
@@ -313,12 +311,9 @@ static int bgp_interface_address_add(ZAPI_CALLBACK_ARGS)
if (ifc == NULL)
return 0;
- if (bgp_debug_zebra(ifc->address)) {
- char buf[PREFIX2STR_BUFFER];
- prefix2str(ifc->address, buf, sizeof(buf));
- zlog_debug("Rx Intf address add VRF %u IF %s addr %s", vrf_id,
- ifc->ifp->name, buf);
- }
+ if (bgp_debug_zebra(ifc->address))
+ zlog_debug("Rx Intf address add VRF %u IF %s addr %pFX", vrf_id,
+ ifc->ifp->name, ifc->address);
if (!bgp)
return 0;
@@ -350,12 +345,9 @@ static int bgp_interface_address_delete(ZAPI_CALLBACK_ARGS)
if (ifc == NULL)
return 0;
- if (bgp_debug_zebra(ifc->address)) {
- char buf[PREFIX2STR_BUFFER];
- prefix2str(ifc->address, buf, sizeof(buf));
- zlog_debug("Rx Intf address del VRF %u IF %s addr %s", vrf_id,
- ifc->ifp->name, buf);
- }
+ if (bgp_debug_zebra(ifc->address))
+ zlog_debug("Rx Intf address del VRF %u IF %s addr %pFX", vrf_id,
+ ifc->ifp->name, ifc->address);
if (bgp && if_is_operative(ifc->ifp)) {
bgp_connected_delete(bgp, ifc);
@@ -376,12 +368,9 @@ static int bgp_interface_nbr_address_add(ZAPI_CALLBACK_ARGS)
if (ifc == NULL)
return 0;
- if (bgp_debug_zebra(ifc->address)) {
- char buf[PREFIX2STR_BUFFER];
- prefix2str(ifc->address, buf, sizeof(buf));
- zlog_debug("Rx Intf neighbor add VRF %u IF %s addr %s", vrf_id,
- ifc->ifp->name, buf);
- }
+ if (bgp_debug_zebra(ifc->address))
+ zlog_debug("Rx Intf neighbor add VRF %u IF %s addr %pFX",
+ vrf_id, ifc->ifp->name, ifc->address);
if (if_is_operative(ifc->ifp)) {
bgp = bgp_lookup_by_vrf_id(vrf_id);
@@ -402,12 +391,9 @@ static int bgp_interface_nbr_address_delete(ZAPI_CALLBACK_ARGS)
if (ifc == NULL)
return 0;
- if (bgp_debug_zebra(ifc->address)) {
- char buf[PREFIX2STR_BUFFER];
- prefix2str(ifc->address, buf, sizeof(buf));
- zlog_debug("Rx Intf neighbor del VRF %u IF %s addr %s", vrf_id,
- ifc->ifp->name, buf);
- }
+ if (bgp_debug_zebra(ifc->address))
+ zlog_debug("Rx Intf neighbor del VRF %u IF %s addr %pFX",
+ vrf_id, ifc->ifp->name, ifc->address);
if (if_is_operative(ifc->ifp)) {
bgp = bgp_lookup_by_vrf_id(vrf_id);
@@ -534,22 +520,20 @@ static int zebra_read_route(ZAPI_CALLBACK_ARGS)
}
if (bgp_debug_zebra(&api.prefix)) {
- char buf[2][PREFIX_STRLEN];
+ char buf[PREFIX_STRLEN];
- prefix2str(&api.prefix, buf[0], sizeof(buf[0]));
if (add) {
- inet_ntop(api.prefix.family, &nexthop, buf[1],
- sizeof(buf[1]));
+ inet_ntop(api.prefix.family, &nexthop, buf,
+ sizeof(buf));
zlog_debug(
- "Rx route ADD VRF %u %s[%d] %s nexthop %s (type %d if %u) metric %u tag %" ROUTE_TAG_PRI,
+ "Rx route ADD VRF %u %s[%d] %pFX nexthop %s (type %d if %u) metric %u tag %" ROUTE_TAG_PRI,
vrf_id, zebra_route_string(api.type),
- api.instance, buf[0], buf[1], nhtype,
- ifindex, api.metric, api.tag);
+ api.instance, &api.prefix, buf, nhtype, ifindex,
+ api.metric, api.tag);
} else {
- zlog_debug(
- "Rx route DEL VRF %u %s[%d] %s",
- vrf_id, zebra_route_string(api.type),
- api.instance, buf[0]);
+ zlog_debug("Rx route DEL VRF %u %s[%d] %s", vrf_id,
+ zebra_route_string(api.type), api.instance,
+ buf);
}
}
@@ -1436,18 +1420,17 @@ void bgp_zebra_announce(struct bgp_dest *dest, const struct prefix *p,
}
if (bgp_debug_zebra(p)) {
- char prefix_buf[PREFIX_STRLEN];
char nh_buf[INET6_ADDRSTRLEN];
char eth_buf[ETHER_ADDR_STRLEN + 7] = {'\0'};
char buf1[ETHER_ADDR_STRLEN];
char label_buf[20];
int i;
- prefix2str(&api.prefix, prefix_buf, sizeof(prefix_buf));
- zlog_debug("Tx route %s VRF %u %s metric %u tag %" ROUTE_TAG_PRI
- " count %d",
- valid_nh_count ? "add" : "delete", bgp->vrf_id,
- prefix_buf, api.metric, api.tag, api.nexthop_num);
+ zlog_debug(
+ "Tx route %s VRF %u %pFX metric %u tag %" ROUTE_TAG_PRI
+ " count %d",
+ valid_nh_count ? "add" : "delete", bgp->vrf_id,
+ &api.prefix, api.metric, api.tag, api.nexthop_num);
for (i = 0; i < api.nexthop_num; i++) {
api_nh = &api.nexthops[i];
@@ -1596,12 +1579,9 @@ void bgp_zebra_withdraw(const struct prefix *p, struct bgp_path_info *info,
if (is_route_parent_evpn(info))
SET_FLAG(api.flags, ZEBRA_FLAG_EVPN_ROUTE);
- if (bgp_debug_zebra(p)) {
- char buf[PREFIX_STRLEN];
-
- prefix2str(&api.prefix, buf, sizeof(buf));
- zlog_debug("Tx route delete VRF %u %s", bgp->vrf_id, buf);
- }
+ if (bgp_debug_zebra(p))
+ zlog_debug("Tx route delete VRF %u %pFX", bgp->vrf_id,
+ &api.prefix);
zclient_route_send(ZEBRA_ROUTE_DELETE, zclient, &api);
}
@@ -2787,7 +2767,6 @@ static void bgp_zebra_process_local_ip_prefix(ZAPI_CALLBACK_ARGS)
struct stream *s = NULL;
struct bgp *bgp_vrf = NULL;
struct prefix p;
- char buf[PREFIX_STRLEN];
memset(&p, 0, sizeof(struct prefix));
s = zclient->ibuf;
@@ -2798,8 +2777,7 @@ static void bgp_zebra_process_local_ip_prefix(ZAPI_CALLBACK_ARGS)
return;
if (BGP_DEBUG(zebra, ZEBRA))
- zlog_debug("Recv prefix %s %s on vrf %s",
- prefix2str(&p, buf, sizeof(buf)),
+ zlog_debug("Recv prefix %pFX %s on vrf %s", &p,
(cmd == ZEBRA_IP_PREFIX_ROUTE_ADD) ? "ADD" : "DEL",
vrf_id_to_name(vrf_id));
diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c
index 959f9e51c6..be3322e468 100644
--- a/bgpd/bgpd.c
+++ b/bgpd/bgpd.c
@@ -2738,7 +2738,6 @@ int peer_group_listen_range_del(struct peer_group *group, struct prefix *range)
struct listnode *node, *nnode;
struct peer *peer;
afi_t afi;
- char buf[PREFIX2STR_BUFFER];
afi = family2afi(range->family);
@@ -2751,8 +2750,6 @@ int peer_group_listen_range_del(struct peer_group *group, struct prefix *range)
if (!prefix)
return BGP_ERR_DYNAMIC_NEIGHBORS_RANGE_NOT_FOUND;
- prefix2str(prefix, buf, sizeof(buf));
-
/* Dispose off any dynamic neighbors that exist due to this listen range
*/
for (ALL_LIST_ELEMENTS(group->peer, node, nnode, peer)) {
@@ -2763,8 +2760,8 @@ int peer_group_listen_range_del(struct peer_group *group, struct prefix *range)
if (prefix_match(prefix, &prefix2)) {
if (bgp_debug_neighbor_events(peer))
zlog_debug(
- "Deleting dynamic neighbor %s group %s upon delete of listen range %s",
- peer->host, group->name, buf);
+ "Deleting dynamic neighbor %s group %s upon delete of listen range %pFX",
+ peer->host, group->name, prefix);
peer_delete(peer);
}
}
@@ -2981,6 +2978,8 @@ static struct bgp *bgp_create(as_t *as, const char *name,
}
bgp_lock(bgp);
+
+ bgp_process_queue_init(bgp);
bgp->heuristic_coalesce = true;
bgp->inst_type = inst_type;
bgp->vrf_id = (inst_type == BGP_INSTANCE_TYPE_DEFAULT) ? VRF_DEFAULT
@@ -3505,6 +3504,9 @@ int bgp_delete(struct bgp *bgp)
bgp_set_evpn(bgp_get_default());
}
+ if (bgp->process_queue)
+ work_queue_free_and_null(&bgp->process_queue);
+
thread_master_free_unused(bm->master);
bgp_unlock(bgp); /* initial reference */
@@ -3770,7 +3772,6 @@ struct peer *peer_lookup_dynamic_neighbor(struct bgp *bgp, union sockunion *su)
struct prefix *listen_range;
int dncount;
char buf[PREFIX2STR_BUFFER];
- char buf1[PREFIX2STR_BUFFER];
sockunion2hostprefix(su, &prefix);
@@ -3787,12 +3788,11 @@ struct peer *peer_lookup_dynamic_neighbor(struct bgp *bgp, union sockunion *su)
return NULL;
prefix2str(&prefix, buf, sizeof(buf));
- prefix2str(listen_range, buf1, sizeof(buf1));
if (bgp_debug_neighbor_events(NULL))
zlog_debug(
- "Dynamic Neighbor %s matches group %s listen range %s",
- buf, group->name, buf1);
+ "Dynamic Neighbor %s matches group %s listen range %pFX",
+ buf, group->name, listen_range);
/* Are we within the listen limit? */
dncount = gbgp->dynamic_neighbors_count;
@@ -7085,8 +7085,6 @@ void bgp_master_init(struct thread_master *master, const int buffer_size)
bm->terminating = false;
bm->socket_buffer = buffer_size;
- bgp_process_queue_init();
-
bgp_mac_init();
/* init the rd id space.
assign 0th index in the bitfield,
@@ -7291,14 +7289,10 @@ void bgp_terminate(void)
bgp_notify_send(peer, BGP_NOTIFY_CEASE,
BGP_NOTIFY_CEASE_PEER_UNCONFIG);
- if (bm->process_main_queue)
- work_queue_free_and_null(&bm->process_main_queue);
-
if (bm->t_rmap_update)
BGP_TIMER_OFF(bm->t_rmap_update);
bgp_mac_finish();
- bgp_evpn_mh_finish();
}
struct peer *peer_lookup_in_view(struct vty *vty, struct bgp *bgp,
diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h
index 00f1d5acc9..eae3d97730 100644
--- a/bgpd/bgpd.h
+++ b/bgpd/bgpd.h
@@ -122,9 +122,6 @@ struct bgp_master {
/* BGP thread master. */
struct thread_master *master;
- /* work queues */
- struct work_queue *process_main_queue;
-
/* Listening sockets */
struct list *listen_sockets;
@@ -682,6 +679,9 @@ struct bgp {
/* Weighted ECMP related config. */
enum bgp_link_bw_handling lb_handling;
+ /* Process Queue for handling routes */
+ struct work_queue *process_queue;
+
QOBJ_FIELDS
};
DECLARE_QOBJ_TYPE(bgp)
diff --git a/bgpd/rfapi/bgp_rfapi_cfg.c b/bgpd/rfapi/bgp_rfapi_cfg.c
index 2bcef97fc3..88c92f7954 100644
--- a/bgpd/rfapi/bgp_rfapi_cfg.c
+++ b/bgpd/rfapi/bgp_rfapi_cfg.c
@@ -170,14 +170,8 @@ struct rfapi_nve_group_cfg *bgp_rfapi_cfg_match_group(struct rfapi_cfg *hc,
#ifdef BGP_VNC_DEBUG_MATCH_GROUP
{
- char buf[PREFIX_STRLEN];
-
- prefix2str(vn, buf, sizeof(buf));
- vnc_zlog_debug_verbose("%s: vn prefix: %s", __func__, buf);
-
- prefix2str(un, buf, sizeof(buf));
- vnc_zlog_debug_verbose("%s: un prefix: %s", __func__, buf);
-
+ vnc_zlog_debug_verbose("%s: vn prefix: %pFX", __func__, vn);
+ vnc_zlog_debug_verbose("%s: un prefix: %pFX", __func__, un);
vnc_zlog_debug_verbose(
"%s: rn_vn=%p, rn_un=%p, rfg_vn=%p, rfg_un=%p",
__func__, rn_vn, rn_un, rfg_vn, rfg_un);
@@ -4215,23 +4209,13 @@ int bgp_rfapi_cfg_write(struct vty *vty, struct bgp *bgp)
++write;
vty_out(vty, " vnc nve-group %s\n", rfg->name);
- if (rfg->vn_prefix.family && rfg->vn_node) {
- char buf[PREFIX_STRLEN];
+ if (rfg->vn_prefix.family && rfg->vn_node)
+ vty_out(vty, " prefix %s %pFX\n", "vn",
+ &rfg->vn_prefix);
- prefix2str(&rfg->vn_prefix, buf,
- sizeof(buf));
- vty_out(vty, " prefix %s %s\n", "vn",
- buf);
- }
-
- if (rfg->un_prefix.family && rfg->un_node) {
- char buf[PREFIX_STRLEN];
-
- prefix2str(&rfg->un_prefix, buf,
- sizeof(buf));
- vty_out(vty, " prefix %s %s\n", "un",
- buf);
- }
+ if (rfg->un_prefix.family && rfg->un_node)
+ vty_out(vty, " prefix %s %pFX\n", "un",
+ &rfg->un_prefix);
if (rfg->rd.prefixlen) {
diff --git a/bgpd/rfapi/rfapi.c b/bgpd/rfapi/rfapi.c
index 0ff4b2c825..2d81a6ce65 100644
--- a/bgpd/rfapi/rfapi.c
+++ b/bgpd/rfapi/rfapi.c
@@ -362,12 +362,9 @@ void del_vnc_route(struct rfapi_descriptor *rfd,
afi_t afi; /* of the VN address */
struct bgp_dest *bn;
struct bgp_path_info *bpi;
- char buf[PREFIX_STRLEN];
char buf2[RD_ADDRSTRLEN];
struct prefix_rd prd0;
- prefix2str(p, buf, sizeof(buf));
-
afi = family2afi(p->family);
assert(afi == AFI_IP || afi == AFI_IP6);
@@ -380,9 +377,9 @@ void del_vnc_route(struct rfapi_descriptor *rfd,
bn = bgp_afi_node_get(bgp->rib[afi][safi], afi, safi, p, prd);
vnc_zlog_debug_verbose(
- "%s: peer=%p, prefix=%s, prd=%s afi=%d, safi=%d bn=%p, bn->info=%p",
- __func__, peer, buf, prefix_rd2str(prd, buf2, sizeof(buf2)),
- afi, safi, bn, (bn ? bgp_dest_get_bgp_path_info(bn) : NULL));
+ "%s: peer=%p, prefix=%pFX, prd=%s afi=%d, safi=%d bn=%p, bn->info=%p",
+ __func__, peer, p, prefix_rd2str(prd, buf2, sizeof(buf2)), afi,
+ safi, bn, (bn ? bgp_dest_get_bgp_path_info(bn) : NULL));
for (bpi = (bn ? bgp_dest_get_bgp_path_info(bn) : NULL); bpi;
bpi = bpi->next) {
@@ -418,8 +415,8 @@ void del_vnc_route(struct rfapi_descriptor *rfd,
* no local nexthops
*/
vnc_zlog_debug_verbose(
- "%s: lnh list already empty at prefix %s",
- __func__, buf);
+ "%s: lnh list already empty at prefix %pFX",
+ __func__, p);
goto done;
}
@@ -445,8 +442,8 @@ void del_vnc_route(struct rfapi_descriptor *rfd,
* list->del on data */
rfapi_nexthop_free(pLnh);
} else {
- vnc_zlog_debug_verbose("%s: desired lnh not found %s",
- __func__, buf);
+ vnc_zlog_debug_verbose("%s: desired lnh not found %pFX",
+ __func__, p);
}
goto done;
}
@@ -459,10 +456,9 @@ void del_vnc_route(struct rfapi_descriptor *rfd,
rfapiProcessWithdraw(peer, rfd, p, prd, NULL, afi, safi, type, kill);
if (bpi) {
- prefix2str(p, buf, sizeof(buf));
vnc_zlog_debug_verbose(
- "%s: Found route (safi=%d) to delete at prefix %s",
- __func__, safi, buf);
+ "%s: Found route (safi=%d) to delete at prefix %pFX",
+ __func__, safi, p);
if (safi == SAFI_MPLS_VPN) {
struct bgp_dest *pdest = NULL;
@@ -488,8 +484,8 @@ void del_vnc_route(struct rfapi_descriptor *rfd,
bgp_process(bgp, bn, afi, safi);
} else {
vnc_zlog_debug_verbose(
- "%s: Couldn't find route (safi=%d) at prefix %s",
- __func__, safi, buf);
+ "%s: Couldn't find route (safi=%d) at prefix %pFX",
+ __func__, safi, p);
}
done:
bgp_dest_unlock_node(bn);
@@ -1577,12 +1573,10 @@ rfapi_query_inner(void *handle, struct rfapi_ip_addr *target,
}
{
- char buf[PREFIX_STRLEN];
char *s;
- prefix2str(&p, buf, sizeof(buf));
- vnc_zlog_debug_verbose("%s(rfd=%p, target=%s, ppNextHop=%p)",
- __func__, rfd, buf, ppNextHopEntry);
+ vnc_zlog_debug_verbose("%s(rfd=%p, target=%pFX, ppNextHop=%p)",
+ __func__, rfd, &p, ppNextHopEntry);
s = ecommunity_ecom2str(rfd->import_table->rt_import_list,
ECOMMUNITY_FORMAT_ROUTE_MAP, 0);
@@ -2397,16 +2391,10 @@ int rfapi_register(void *handle, struct rfapi_ip_prefix *prefix,
afi = family2afi(prefix->prefix.addr_family);
assert(afi);
-
- {
- char buf[PREFIX_STRLEN];
-
- prefix2str(&p, buf, sizeof(buf));
- vnc_zlog_debug_verbose(
- "%s(rfd=%p, pfx=%s, lifetime=%d, opts_un=%p, opts_vn=%p, action=%s)",
- __func__, rfd, buf, lifetime, options_un, options_vn,
- action_str);
- }
+ vnc_zlog_debug_verbose(
+ "%s(rfd=%p, pfx=%pFX, lifetime=%d, opts_un=%p, opts_vn=%p, action=%s)",
+ __func__, rfd, &p, lifetime, options_un, options_vn,
+ action_str);
/*
* These tests come after the prefix conversion so that we can
diff --git a/bgpd/rfapi/rfapi_import.c b/bgpd/rfapi/rfapi_import.c
index 1e8a381e2d..e3581addee 100644
--- a/bgpd/rfapi/rfapi_import.c
+++ b/bgpd/rfapi/rfapi_import.c
@@ -612,11 +612,8 @@ rfapiMonitorMoveShorter(struct agg_node *original_vpn_node, int lockoffset)
#ifdef DEBUG_MONITOR_MOVE_SHORTER
{
- char buf[PREFIX_STRLEN];
-
- prefix2str(&original_vpn_node->p, buf, sizeof(buf));
- vnc_zlog_debug_verbose("%s: called with node pfx=%s", __func__,
- buf);
+ vnc_zlog_debug_verbose("%s: called with node pfx=%pFX",
+ __func__, &original_vpn_node->p);
}
#endif
@@ -751,11 +748,8 @@ rfapiMonitorMoveShorter(struct agg_node *original_vpn_node, int lockoffset)
#ifdef DEBUG_MONITOR_MOVE_SHORTER
{
- char buf[PREFIX_STRLEN];
-
- prefix2str(&par->p, buf, sizeof(buf));
- vnc_zlog_debug_verbose("%s: moved to node pfx=%s", __func__,
- buf);
+ vnc_zlog_debug_verbose("%s: moved to node pfx=%pFX", __func__,
+ &par->p);
}
#endif
@@ -864,9 +858,9 @@ static void rfapiBgpInfoChainFree(struct bgp_path_info *bpi)
if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)
&& bpi->extra->vnc.import.timer) {
- struct thread *t =
- (struct thread *)bpi->extra->vnc.import.timer;
- struct rfapi_withdraw *wcb = t->arg;
+ struct thread **t =
+ &(bpi->extra->vnc.import.timer);
+ struct rfapi_withdraw *wcb = (*t)->arg;
XFREE(MTYPE_RFAPI_WITHDRAW, wcb);
thread_cancel(t);
@@ -1556,12 +1550,9 @@ static int rfapiNhlAddNodeRoutes(
}
if (!skiplist_search(seen_nexthops, &pfx_vn, NULL)) {
#ifdef DEBUG_RETURNED_NHL
- char buf[PREFIX_STRLEN];
-
- prefix2str(&pfx_vn, buf, sizeof(buf));
vnc_zlog_debug_verbose(
- "%s: already put VN/nexthop %s, skip", __func__,
- buf);
+ "%s: already put VN/nexthop %pFX, skip",
+ __func__, &pfx_vn);
#endif
continue;
}
@@ -3102,10 +3093,9 @@ static void rfapiBgpInfoFilteredImportEncap(
if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)
&& bpi->extra->vnc.import.timer) {
- struct thread *t =
- (struct thread *)bpi->extra->vnc
- .import.timer;
- struct rfapi_withdraw *wcb = t->arg;
+ struct thread **t =
+ &(bpi->extra->vnc.import.timer);
+ struct rfapi_withdraw *wcb = (*t)->arg;
XFREE(MTYPE_RFAPI_WITHDRAW, wcb);
thread_cancel(t);
@@ -3195,9 +3185,9 @@ static void rfapiBgpInfoFilteredImportEncap(
"%s: removing holddown bpi matching NVE of new route",
__func__);
if (bpi->extra->vnc.import.timer) {
- struct thread *t =
- (struct thread *)bpi->extra->vnc.import.timer;
- struct rfapi_withdraw *wcb = t->arg;
+ struct thread **t =
+ &(bpi->extra->vnc.import.timer);
+ struct rfapi_withdraw *wcb = (*t)->arg;
XFREE(MTYPE_RFAPI_WITHDRAW, wcb);
thread_cancel(t);
@@ -3558,10 +3548,9 @@ void rfapiBgpInfoFilteredImportVPN(
if (CHECK_FLAG(bpi->flags, BGP_PATH_REMOVED)
&& bpi->extra->vnc.import.timer) {
- struct thread *t =
- (struct thread *)bpi->extra->vnc
- .import.timer;
- struct rfapi_withdraw *wcb = t->arg;
+ struct thread **t =
+ &(bpi->extra->vnc.import.timer);
+ struct rfapi_withdraw *wcb = (*t)->arg;
XFREE(MTYPE_RFAPI_WITHDRAW, wcb);
thread_cancel(t);
@@ -3634,12 +3623,9 @@ void rfapiBgpInfoFilteredImportVPN(
rfapiCopyUnEncap2VPN(ern->info, info_new);
agg_unlock_node(ern); /* undo lock in route_note_match */
} else {
- char bpf[PREFIX_STRLEN];
-
- prefix2str(&vn_prefix, bpf, sizeof(bpf));
/* Not a big deal, just means VPN route got here first */
- vnc_zlog_debug_verbose("%s: no encap route for vn addr %s",
- __func__, bpf);
+ vnc_zlog_debug_verbose("%s: no encap route for vn addr %pFX",
+ __func__, &vn_prefix);
info_new->extra->vnc.import.un_family = 0;
}
@@ -3780,9 +3766,9 @@ void rfapiBgpInfoFilteredImportVPN(
"%s: removing holddown bpi matching NVE of new route",
__func__);
if (bpi->extra->vnc.import.timer) {
- struct thread *t =
- (struct thread *)bpi->extra->vnc.import.timer;
- struct rfapi_withdraw *wcb = t->arg;
+ struct thread **t =
+ &(bpi->extra->vnc.import.timer);
+ struct rfapi_withdraw *wcb = (*t)->arg;
XFREE(MTYPE_RFAPI_WITHDRAW, wcb);
thread_cancel(t);
@@ -4441,13 +4427,9 @@ static void rfapiDeleteRemotePrefixesIt(
struct bgp_path_info *next;
const struct prefix *rn_p = agg_node_get_prefix(rn);
- if (p && VNC_DEBUG(IMPORT_DEL_REMOTE)) {
- char p1line[PREFIX_STRLEN];
-
- prefix2str(p, p1line, sizeof(p1line));
- vnc_zlog_debug_any("%s: want %s, have %pRN",
- __func__, p1line, rn);
- }
+ if (p && VNC_DEBUG(IMPORT_DEL_REMOTE))
+ vnc_zlog_debug_any("%s: want %pFX, have %pRN",
+ __func__, p, rn);
if (p && prefix_cmp(p, rn_p))
continue;
@@ -4514,12 +4496,11 @@ static void rfapiDeleteRemotePrefixesIt(
continue;
if (bpi->extra->vnc.import.timer) {
- struct thread *t =
- (struct thread *)bpi
- ->extra->vnc
- .import.timer;
+ struct thread **t =
+ &(bpi->extra->vnc
+ .import.timer);
struct rfapi_withdraw *wcb =
- t->arg;
+ (*t)->arg;
wcb->import_table
->holddown_count[afi] -=
diff --git a/bgpd/rfapi/rfapi_monitor.c b/bgpd/rfapi/rfapi_monitor.c
index cd26892b84..ce916c104b 100644
--- a/bgpd/rfapi/rfapi_monitor.c
+++ b/bgpd/rfapi/rfapi_monitor.c
@@ -620,10 +620,7 @@ void rfapiMonitorDel(struct bgp *bgp, struct rfapi_descriptor *rfd,
rfapiMonitorDetachImport(m);
}
- if (m->timer) {
- thread_cancel(m->timer);
- m->timer = NULL;
- }
+ thread_cancel(&m->timer);
/*
* remove from rfd list
@@ -660,10 +657,7 @@ int rfapiMonitorDelHd(struct rfapi_descriptor *rfd)
rfapiMonitorDetachImport(m);
}
- if (m->timer) {
- thread_cancel(m->timer);
- m->timer = NULL;
- }
+ thread_cancel(&m->timer);
XFREE(MTYPE_RFAPI_MONITOR, m);
rn->info = NULL;
@@ -697,10 +691,7 @@ int rfapiMonitorDelHd(struct rfapi_descriptor *rfd)
#endif
}
- if (mon_eth->timer) {
- thread_cancel(mon_eth->timer);
- mon_eth->timer = NULL;
- }
+ thread_cancel(&mon_eth->timer);
/*
* remove from rfd list
@@ -766,8 +757,7 @@ static void rfapiMonitorTimerRestart(struct rfapi_monitor_vpn *m)
if (m->rfd->response_lifetime - remain < 2)
return;
- thread_cancel(m->timer);
- m->timer = NULL;
+ thread_cancel(&m->timer);
}
{
@@ -846,9 +836,6 @@ void rfapiMonitorItNodeChanged(
struct bgp *bgp = bgp_get_default();
const struct prefix *p = agg_node_get_prefix(rn);
afi_t afi = family2afi(p->family);
-#if DEBUG_L2_EXTRA
- char buf_prefix[PREFIX_STRLEN];
-#endif
assert(bgp);
assert(import_table);
@@ -856,9 +843,8 @@ void rfapiMonitorItNodeChanged(
nves_seen = skiplist_new(0, NULL, NULL);
#if DEBUG_L2_EXTRA
- prefix2str(&it_node->p, buf_prefix, sizeof(buf_prefix));
- vnc_zlog_debug_verbose("%s: it=%p, it_node=%p, it_node->prefix=%s",
- __func__, import_table, it_node, buf_prefix);
+ vnc_zlog_debug_verbose("%s: it=%p, it_node=%p, it_node->prefix=%pFX",
+ __func__, import_table, it_node, &it_node->p);
#endif
if (AFI_L2VPN == afi) {
@@ -934,14 +920,10 @@ void rfapiMonitorItNodeChanged(
assert(!skiplist_insert(nves_seen,
m->rfd, NULL));
- char buf_target_pfx[PREFIX_STRLEN];
-
- prefix2str(&m->p, buf_target_pfx,
- sizeof(buf_target_pfx));
vnc_zlog_debug_verbose(
- "%s: update rfd %p attached to pfx %pRN (targ=%s)",
+ "%s: update rfd %p attached to pfx %pRN (targ=%pFX)",
__func__, m->rfd, m->node,
- buf_target_pfx);
+ &m->p);
/*
* update its RIB
@@ -1086,8 +1068,7 @@ static void rfapiMonitorEthTimerRestart(struct rfapi_monitor_eth *m)
if (m->rfd->response_lifetime - remain < 2)
return;
- thread_cancel(m->timer);
- m->timer = NULL;
+ thread_cancel(&m->timer);
}
{
@@ -1269,21 +1250,15 @@ static void rfapiMonitorEthDetachImport(
rn = agg_node_get(it->imported_vpn[AFI_L2VPN], &pfx_mac_buf);
assert(rn);
-#if DEBUG_L2_EXTRA
- char buf_prefix[PREFIX_STRLEN];
-
- prefix2str(agg_node_get_prefix(rn), buf_prefix, sizeof(buf_prefix));
-#endif
-
/*
* Get sl to detach from
*/
sl = RFAPI_MONITOR_ETH(rn);
#if DEBUG_L2_EXTRA
vnc_zlog_debug_verbose(
- "%s: it=%p, rn=%p, rn->lock=%d, sl=%p, pfx=%s, LNI=%d, detaching eth mon %p",
- __func__, it, rn, rn->lock, sl, buf_prefix, mon->logical_net_id,
- mon);
+ "%s: it=%p, rn=%p, rn->lock=%d, sl=%p, pfx=%pFX, LNI=%d, detaching eth mon %p",
+ __func__, it, rn, rn->lock, sl, agg_node_get_prefix(rn),
+ mon->logical_net_id, mon);
#endif
assert(sl);
@@ -1432,10 +1407,7 @@ void rfapiMonitorEthDel(struct bgp *bgp, struct rfapi_descriptor *rfd,
rfapiMonitorEthDetachImport(bgp, val);
}
- if (val->timer) {
- thread_cancel(val->timer);
- val->timer = NULL;
- }
+ thread_cancel(&val->timer);
/*
* remove from rfd list
diff --git a/bgpd/rfapi/rfapi_rib.c b/bgpd/rfapi/rfapi_rib.c
index 8109e7e3d7..630a379ec2 100644
--- a/bgpd/rfapi/rfapi_rib.c
+++ b/bgpd/rfapi/rfapi_rib.c
@@ -269,9 +269,8 @@ static void rfapi_info_free(struct rfapi_info *goner)
struct rfapi_rib_tcb *tcb;
tcb = goner->timer->arg;
- thread_cancel(goner->timer);
+ thread_cancel(&goner->timer);
XFREE(MTYPE_RFAPI_RECENT_DELETE, tcb);
- goner->timer = NULL;
}
XFREE(MTYPE_RFAPI_INFO, goner);
}
@@ -338,13 +337,11 @@ static void rfapiRibStartTimer(struct rfapi_descriptor *rfd,
struct agg_node *rn, /* route node attached to */
int deleted)
{
- struct thread *t = ri->timer;
struct rfapi_rib_tcb *tcb = NULL;
- if (t) {
- tcb = t->arg;
- thread_cancel(t);
- ri->timer = NULL;
+ if (ri->timer) {
+ tcb = ri->timer->arg;
+ thread_cancel(&ri->timer);
} else {
tcb = XCALLOC(MTYPE_RFAPI_RECENT_DELETE,
sizeof(struct rfapi_rib_tcb));
@@ -907,10 +904,6 @@ static void process_pending_node(struct bgp *bgp, struct rfapi_descriptor *rfd,
delete_list = list_new();
while (0
== skiplist_first(slRibPt, NULL, (void **)&ri)) {
-
- char buf[PREFIX_STRLEN];
- char buf2[PREFIX_STRLEN];
-
listnode_add(delete_list, ri);
vnc_zlog_debug_verbose(
"%s: after listnode_add, delete_list->count=%d",
@@ -921,18 +914,15 @@ static void process_pending_node(struct bgp *bgp, struct rfapi_descriptor *rfd,
if (ri->timer) {
struct rfapi_rib_tcb *tcb;
- tcb = ((struct thread *)ri->timer)->arg;
- thread_cancel(ri->timer);
+ tcb = ri->timer->arg;
+ thread_cancel(&ri->timer);
XFREE(MTYPE_RFAPI_RECENT_DELETE, tcb);
- ri->timer = NULL;
}
- prefix2str(&ri->rk.vn, buf, sizeof(buf));
- prefix2str(&ri->un, buf2, sizeof(buf2));
vnc_zlog_debug_verbose(
- "%s: put dl pfx=%pRN vn=%s un=%s cost=%d life=%d vn_options=%p",
- __func__, pn, buf, buf2, ri->cost,
- ri->lifetime, ri->vn_options);
+ "%s: put dl pfx=%pRN vn=%pFX un=%pFX cost=%d life=%d vn_options=%p",
+ __func__, pn, &ri->rk.vn, &ri->un,
+ ri->cost, ri->lifetime, ri->vn_options);
skiplist_delete_first(slRibPt);
}
@@ -1009,11 +999,9 @@ static void process_pending_node(struct bgp *bgp, struct rfapi_descriptor *rfd,
if (ori->timer) {
struct rfapi_rib_tcb *tcb;
- tcb = ((struct thread *)ori->timer)
- ->arg;
- thread_cancel(ori->timer);
+ tcb = ori->timer->arg;
+ thread_cancel(&ori->timer);
XFREE(MTYPE_RFAPI_RECENT_DELETE, tcb);
- ori->timer = NULL;
}
#if DEBUG_PROCESS_PENDING_NODE
@@ -1357,11 +1345,9 @@ callback:
if (ri->timer) {
struct rfapi_rib_tcb *tcb;
- tcb = ((struct thread *)ri->timer)->arg;
- thread_cancel(
- (struct thread *)ri->timer);
+ tcb = ri->timer->arg;
+ thread_cancel(&ri->timer);
XFREE(MTYPE_RFAPI_RECENT_DELETE, tcb);
- ri->timer = NULL;
}
RFAPI_RIB_CHECK_COUNTS(0, delete_list->count);
@@ -1589,7 +1575,6 @@ void rfapiRibUpdatePendingNode(
afi_t afi;
uint32_t queued_flag;
int count = 0;
- char buf[PREFIX_STRLEN];
vnc_zlog_debug_verbose("%s: entry", __func__);
@@ -1602,8 +1587,7 @@ void rfapiRibUpdatePendingNode(
prefix = agg_node_get_prefix(it_node);
afi = family2afi(prefix->family);
- prefix2str(prefix, buf, sizeof(buf));
- vnc_zlog_debug_verbose("%s: prefix=%s", __func__, buf);
+ vnc_zlog_debug_verbose("%s: prefix=%pFX", __func__, prefix);
pn = agg_node_get(rfd->rib_pending[afi], prefix);
assert(pn);
@@ -1809,11 +1793,8 @@ int rfapiRibFTDFilterRecentPrefix(
#ifdef DEBUG_FTD_FILTER_RECENT
{
- char buf_pfx[PREFIX_STRLEN];
-
- prefix2str(agg_node_get_prefix(it_rn), buf_pfx,
- sizeof(buf_pfx));
- vnc_zlog_debug_verbose("%s: prefix %s", __func__, buf_pfx);
+ vnc_zlog_debug_verbose("%s: prefix %pFX", __func__,
+ agg_node_get_prefix(it_rn));
}
#endif
@@ -1974,21 +1955,18 @@ rfapiRibPreload(struct bgp *bgp, struct rfapi_descriptor *rfd,
#if DEBUG_NHL
{
- char str_vn[PREFIX_STRLEN];
char str_aux_prefix[PREFIX_STRLEN];
- str_vn[0] = 0;
str_aux_prefix[0] = 0;
- prefix2str(&rk.vn, str_vn, sizeof(str_vn));
prefix2str(&rk.aux_prefix, str_aux_prefix,
sizeof(str_aux_prefix));
if (!rk.aux_prefix.family) {
}
vnc_zlog_debug_verbose(
- "%s: rk.vn=%s rk.aux_prefix=%s", __func__,
- str_vn,
+ "%s: rk.vn=%pFX rk.aux_prefix=%s", __func__,
+ &rk.vn,
(rk.aux_prefix.family ? str_aux_prefix : "-"));
}
vnc_zlog_debug_verbose(
@@ -2072,17 +2050,10 @@ rfapiRibPreload(struct bgp *bgp, struct rfapi_descriptor *rfd,
if (agg_node_get_lock_count(trn) > 1)
agg_unlock_node(trn);
- {
- char str_pfx[PREFIX_STRLEN];
- char str_pfx_vn[PREFIX_STRLEN];
-
- prefix2str(&pfx, str_pfx, sizeof(str_pfx));
- prefix2str(&rk.vn, str_pfx_vn, sizeof(str_pfx_vn));
- vnc_zlog_debug_verbose(
- "%s: added pfx=%s nh[vn]=%s, cost=%u, lifetime=%u, allowed=%d",
- __func__, str_pfx, str_pfx_vn, nhp->prefix.cost,
- nhp->lifetime, allowed);
- }
+ vnc_zlog_debug_verbose(
+ "%s: added pfx=%pFX nh[vn]=%pFX, cost=%u, lifetime=%u, allowed=%d",
+ __func__, &pfx, &rk.vn, nhp->prefix.cost, nhp->lifetime,
+ allowed);
if (allowed) {
if (tail)
diff --git a/bgpd/rfapi/rfapi_vty.c b/bgpd/rfapi/rfapi_vty.c
index 850e8325c9..b9a6c4ddc4 100644
--- a/bgpd/rfapi/rfapi_vty.c
+++ b/bgpd/rfapi/rfapi_vty.c
@@ -1596,7 +1596,6 @@ void rfapiPrintDescriptor(struct vty *vty, struct rfapi_descriptor *rfd)
int rc;
afi_t afi;
struct rfapi_adb *adb;
- char buf[PREFIX_STRLEN];
vty_out(vty, "%-10p ", rfd);
rfapiPrintRfapiIpAddr(vty, &rfd->un_addr);
@@ -1648,9 +1647,8 @@ void rfapiPrintDescriptor(struct vty *vty, struct rfapi_descriptor *rfd)
if (family != adb->u.s.prefix_ip.family)
continue;
- prefix2str(&adb->u.s.prefix_ip, buf, sizeof(buf));
-
- vty_out(vty, " Adv Pfx: %s%s", buf, HVTYNL);
+ vty_out(vty, " Adv Pfx: %pFX%s", &adb->u.s.prefix_ip,
+ HVTYNL);
rfapiPrintAdvertisedInfo(vty, rfd, SAFI_MPLS_VPN,
&adb->u.s.prefix_ip);
}
@@ -1659,10 +1657,7 @@ void rfapiPrintDescriptor(struct vty *vty, struct rfapi_descriptor *rfd)
(void **)&adb, &cursor);
rc == 0; rc = skiplist_next(rfd->advertised.ip0_by_ether, NULL,
(void **)&adb, &cursor)) {
-
- prefix2str(&adb->u.s.prefix_eth, buf, sizeof(buf));
-
- vty_out(vty, " Adv Pfx: %s%s", buf, HVTYNL);
+ vty_out(vty, " Adv Pfx: %pFX%s", &adb->u.s.prefix_eth, HVTYNL);
/* TBD update the following function to print ethernet info */
/* Also need to pass/use rd */
@@ -1863,11 +1858,9 @@ void rfapiPrintNhl(void *stream, struct rfapi_next_hop_entry *next_hops)
break;
case RFAPI_VN_OPTION_TYPE_LOCAL_NEXTHOP:
- prefix2str(&vo->v.local_nexthop.addr,
- pbuf, sizeof(pbuf));
- fp(out, "%sLNH %s cost=%d%s", offset,
- pbuf, vo->v.local_nexthop.cost,
- HVTYNL);
+ fp(out, "%sLNH %pFX cost=%d%s", offset,
+ &vo->v.local_nexthop.addr,
+ vo->v.local_nexthop.cost, HVTYNL);
break;
default:
diff --git a/bgpd/rfapi/vnc_export_bgp.c b/bgpd/rfapi/vnc_export_bgp.c
index b56261669c..11f39b2b82 100644
--- a/bgpd/rfapi/vnc_export_bgp.c
+++ b/bgpd/rfapi/vnc_export_bgp.c
@@ -1711,14 +1711,11 @@ void vnc_direct_bgp_rh_add_route(struct bgp *bgp, afi_t afi,
rfapiGetVncLifetime(attr, &eti->lifetime);
eti->lifetime = rfapiGetHolddownFromLifetime(eti->lifetime);
- if (eti->timer) {
- /*
- * export expiration timer is already running on
- * this route: cancel it
- */
- thread_cancel(eti->timer);
- eti->timer = NULL;
- }
+ /*
+ * export expiration timer is already running on
+ * this route: cancel it
+ */
+ thread_cancel(&eti->timer);
bgp_update(peer, prefix, /* prefix */
0, /* addpath_id */
@@ -1947,15 +1944,12 @@ void vnc_direct_bgp_rh_vpn_enable(struct bgp *bgp, afi_t afi)
rfapiGetVncLifetime(ri->attr,
&eti->lifetime);
- if (eti->timer) {
- /*
- * export expiration timer is
- * already running on
- * this route: cancel it
- */
- thread_cancel(eti->timer);
- eti->timer = NULL;
- }
+ /*
+ * export expiration timer is
+ * already running on
+ * this route: cancel it
+ */
+ thread_cancel(&eti->timer);
vnc_zlog_debug_verbose(
"%s: calling bgp_update",
@@ -2024,8 +2018,7 @@ void vnc_direct_bgp_rh_vpn_disable(struct bgp *bgp, afi_t afi)
ZEBRA_ROUTE_VNC_DIRECT_RH,
BGP_ROUTE_REDISTRIBUTE);
if (eti) {
- if (eti->timer)
- thread_cancel(eti->timer);
+ thread_cancel(&eti->timer);
vnc_eti_delete(eti);
}
diff --git a/bgpd/rfapi/vnc_import_bgp.c b/bgpd/rfapi/vnc_import_bgp.c
index 85d64b5a72..0b6b39b966 100644
--- a/bgpd/rfapi/vnc_import_bgp.c
+++ b/bgpd/rfapi/vnc_import_bgp.c
@@ -206,19 +206,11 @@ static void print_rhn_list(const char *tag1, const char *tag2)
/* XXX uses secret knowledge of skiplist structure */
for (p = sl->header->forward[0]; p; p = p->forward[0]) {
- char kbuf[PREFIX_STRLEN];
- char hbuf[PREFIX_STRLEN];
- char ubuf[PREFIX_STRLEN];
-
pb = p->value;
- prefix2str(p->key, kbuf, sizeof(kbuf));
- prefix2str(&pb->hpfx, hbuf, sizeof(hbuf));
- prefix2str(&pb->upfx, ubuf, sizeof(ubuf));
-
vnc_zlog_debug_verbose(
- "RHN Entry %d (q=%p): kpfx=%s, upfx=%s, hpfx=%s, ubpi=%p",
- ++count, p, kbuf, ubuf, hbuf, pb->ubpi);
+ "RHN Entry %d (q=%p): kpfx=%pFX, upfx=%pFX, hpfx=%pFX, ubpi=%p",
+ ++count, p, p->key, &pb->upfx, &pb->hpfx, pb->ubpi);
}
}
#endif
@@ -260,15 +252,9 @@ static void vnc_rhnck(char *tag)
* pfx */
assert(!vnc_prefix_cmp(&pb->hpfx, pkey));
if (vnc_prefix_cmp(&pb->hpfx, &pfx_orig_nexthop)) {
- char str_onh[PREFIX_STRLEN];
- char str_nve_pfx[PREFIX_STRLEN];
-
- prefix2str(&pfx_orig_nexthop, str_onh, sizeof(str_onh));
- prefix2str(&pb->hpfx, str_nve_pfx, sizeof(str_nve_pfx));
-
vnc_zlog_debug_verbose(
- "%s: %s: FATAL: resolve_nve_nexthop list item bpi nexthop %s != nve pfx %s",
- __func__, tag, str_onh, str_nve_pfx);
+ "%s: %s: FATAL: resolve_nve_nexthop list item bpi nexthop %pFX != nve pfx %pFX",
+ __func__, tag, &pfx_orig_nexthop, &pb->hpfx);
assert(0);
}
}
@@ -529,13 +515,7 @@ static void vnc_import_bgp_add_route_mode_resolve_nve_one_rd(
if (!table_rd)
return;
- {
- char str_nh[PREFIX_STRLEN];
-
- prefix2str(ubpi_nexthop, str_nh, sizeof(str_nh));
-
- vnc_zlog_debug_verbose("%s: ubpi_nexthop=%s", __func__, str_nh);
- }
+ vnc_zlog_debug_verbose("%s: ubpi_nexthop=%pFX", __func__, ubpi_nexthop);
/* exact match */
bd = bgp_node_lookup(table_rd, ubpi_nexthop);
@@ -574,12 +554,9 @@ static void vnc_import_bgp_add_route_mode_resolve_nve(
/*debugging */
if (VNC_DEBUG(VERBOSE)) {
- char str_pfx[PREFIX_STRLEN];
char str_nh[PREFIX_STRLEN];
struct prefix nh;
- prefix2str(prefix, str_pfx, sizeof(str_pfx));
-
nh.prefixlen = 0;
rfapiUnicastNexthop2Prefix(afi, info->attr, &nh);
if (nh.prefixlen) {
@@ -590,8 +567,8 @@ static void vnc_import_bgp_add_route_mode_resolve_nve(
}
vnc_zlog_debug_verbose(
- "%s(bgp=%p, unicast prefix=%s, unicast nh=%s)",
- __func__, bgp, str_pfx, str_nh);
+ "%s(bgp=%p, unicast prefix=%pFX, unicast nh=%s)",
+ __func__, bgp, prefix, str_nh);
}
if (info->type != ZEBRA_ROUTE_BGP) {
@@ -713,12 +690,7 @@ static void vnc_import_bgp_add_route_mode_plain(struct bgp *bgp,
uint32_t local_pref;
uint32_t *med = NULL;
- {
- char buf[PREFIX_STRLEN];
-
- prefix2str(prefix, buf, sizeof(buf));
- vnc_zlog_debug_verbose("%s(prefix=%s) entry", __func__, buf);
- }
+ vnc_zlog_debug_verbose("%s(prefix=%pFX) entry", __func__, prefix);
if (!afi) {
flog_err(EC_LIB_DEVELOPMENT, "%s: can't get afi of prefix",
@@ -783,12 +755,8 @@ static void vnc_import_bgp_add_route_mode_plain(struct bgp *bgp,
ahr_flags |= RFAPI_AHR_NO_TUNNEL_SUBTLV;
}
- if (VNC_DEBUG(IMPORT_BGP_ADD_ROUTE)) {
- char buf[PREFIX_STRLEN];
-
- prefix2str(vn_pfx, buf, sizeof(buf));
- vnc_zlog_debug_any("%s vn_pfx=%s", __func__, buf);
- }
+ if (VNC_DEBUG(IMPORT_BGP_ADD_ROUTE))
+ vnc_zlog_debug_any("%s vn_pfx=%pFX", __func__, vn_pfx);
/*
* Compute VN address
@@ -899,12 +867,7 @@ static void vnc_import_bgp_add_route_mode_nvegroup(
struct route_map *rmap = NULL;
uint32_t local_pref;
- {
- char buf[PREFIX_STRLEN];
-
- prefix2str(prefix, buf, sizeof(buf));
- vnc_zlog_debug_verbose("%s(prefix=%s) entry", __func__, buf);
- }
+ vnc_zlog_debug_verbose("%s(prefix=%pFX) entry", __func__, prefix);
assert(rfg);
@@ -985,12 +948,8 @@ static void vnc_import_bgp_add_route_mode_nvegroup(
vncHDBgpDirect.un_addr = pfx_un.prefix;
}
- if (VNC_DEBUG(IMPORT_BGP_ADD_ROUTE)) {
- char buf[PREFIX_STRLEN];
-
- prefix2str(vn_pfx, buf, sizeof(buf));
- vnc_zlog_debug_any("%s vn_pfx=%s", __func__, buf);
- }
+ if (VNC_DEBUG(IMPORT_BGP_ADD_ROUTE))
+ vnc_zlog_debug_any("%s vn_pfx=%pFX", __func__, vn_pfx);
/*
* Compute VN address
@@ -1288,12 +1247,7 @@ static void vnc_import_bgp_del_route_mode_resolve_nve_one_rd(
if (!table_rd)
return;
- {
- char str_nh[PREFIX_STRLEN];
-
- prefix2str(ubpi_nexthop, str_nh, sizeof(str_nh));
- vnc_zlog_debug_verbose("%s: ubpi_nexthop=%s", __func__, str_nh);
- }
+ vnc_zlog_debug_verbose("%s: ubpi_nexthop=%pFX", __func__, ubpi_nexthop);
/* exact match */
@@ -1467,17 +1421,11 @@ void vnc_import_bgp_add_vnc_host_route_mode_resolve_nve(
memset(&pfx_unicast_nexthop, 0,
sizeof(struct prefix)); /* keep valgrind happy */
- if (VNC_DEBUG(IMPORT_BGP_ADD_ROUTE)) {
- char hbuf[PREFIX_STRLEN];
- char ubuf[PREFIX_STRLEN];
-
- prefix2str(&pb->hpfx, hbuf, sizeof(hbuf));
- prefix2str(&pb->upfx, ubuf, sizeof(ubuf));
-
+ if (VNC_DEBUG(IMPORT_BGP_ADD_ROUTE))
vnc_zlog_debug_any(
- "%s: examining RHN Entry (q=%p): upfx=%s, hpfx=%s, ubpi=%p",
- __func__, cursor, ubuf, hbuf, pb->ubpi);
- }
+ "%s: examining RHN Entry (q=%p): upfx=%pFX, hpfx=%pFX, ubpi=%p",
+ __func__, cursor, &pb->upfx, &pb->hpfx,
+ pb->ubpi);
if (process_unicast_route(bgp, afi, &pb->upfx, pb->ubpi, &ecom,
&pfx_unicast_nexthop)) {
@@ -1497,16 +1445,9 @@ void vnc_import_bgp_add_vnc_host_route_mode_resolve_nve(
* Sanity check
*/
if (vnc_prefix_cmp(&pfx_unicast_nexthop, prefix)) {
- char str_unh[PREFIX_STRLEN];
- char str_nve_pfx[PREFIX_STRLEN];
-
- prefix2str(&pfx_unicast_nexthop, str_unh,
- sizeof(str_unh));
- prefix2str(prefix, str_nve_pfx, sizeof(str_nve_pfx));
-
vnc_zlog_debug_verbose(
- "%s: FATAL: resolve_nve_nexthop list item bpi nexthop %s != nve pfx %s",
- __func__, str_unh, str_nve_pfx);
+ "%s: FATAL: resolve_nve_nexthop list item bpi nexthop %pFX != nve pfx %pFX",
+ __func__, &pfx_unicast_nexthop, prefix);
assert(0);
}
@@ -1521,13 +1462,9 @@ void vnc_import_bgp_add_vnc_host_route_mode_resolve_nve(
#if DEBUG_RHN_LIST
/* debug */
{
- char pbuf[PREFIX_STRLEN];
-
- prefix2str(prefix, pbuf, sizeof(pbuf));
-
vnc_zlog_debug_verbose(
- "%s: advancing past RHN Entry (q=%p): with prefix %s",
- __func__, cursor, pbuf);
+ "%s: advancing past RHN Entry (q=%p): with prefix %pFX",
+ __func__, cursor, prefix);
print_rhn_list(__func__, NULL); /* debug */
}
#endif
@@ -1550,14 +1487,8 @@ void vnc_import_bgp_del_vnc_host_route_mode_resolve_nve(
struct rfapi_cfg *hc = NULL;
int rc;
- {
- char str_pfx[PREFIX_STRLEN];
-
- prefix2str(prefix, str_pfx, sizeof(str_pfx));
-
- vnc_zlog_debug_verbose("%s(bgp=%p, nve prefix=%s)", __func__,
- bgp, str_pfx);
- }
+ vnc_zlog_debug_verbose("%s(bgp=%p, nve prefix=%pFX)", __func__, bgp,
+ prefix);
if (afi != AFI_IP && afi != AFI_IP6)
return;
@@ -1621,16 +1552,9 @@ void vnc_import_bgp_del_vnc_host_route_mode_resolve_nve(
* Sanity check
*/
if (vnc_prefix_cmp(&pfx_unicast_nexthop, prefix)) {
- char str_unh[PREFIX_STRLEN];
- char str_nve_pfx[PREFIX_STRLEN];
-
- prefix2str(&pfx_unicast_nexthop, str_unh,
- sizeof(str_unh));
- prefix2str(prefix, str_nve_pfx, sizeof(str_nve_pfx));
-
vnc_zlog_debug_verbose(
- "%s: FATAL: resolve_nve_nexthop list item bpi nexthop %s != nve pfx %s",
- __func__, str_unh, str_nve_pfx);
+ "%s: FATAL: resolve_nve_nexthop list item bpi nexthop %pFX != nve pfx %pFX",
+ __func__, &pfx_unicast_nexthop, prefix);
assert(0);
}
@@ -2305,13 +2229,11 @@ void vnc_import_bgp_exterior_add_route_interior(
(void **)&pfx_exterior, &cursor)) {
struct prefix pfx_nexthop;
- char buf[PREFIX_STRLEN];
afi_t afi_exterior = family2afi(pfx_exterior->family);
- prefix2str(pfx_exterior, buf, sizeof(buf));
vnc_zlog_debug_verbose(
- "%s: checking exterior orphan at prefix %s", __func__,
- buf);
+ "%s: checking exterior orphan at prefix %pFX", __func__,
+ pfx_exterior);
if (afi_exterior != afi) {
vnc_zlog_debug_verbose(
@@ -2602,15 +2524,10 @@ void vnc_import_bgp_add_route(struct bgp *bgp, const struct prefix *prefix,
if (VNC_DEBUG(VERBOSE)) {
struct prefix pfx_nexthop;
- char buf[PREFIX_STRLEN];
- char buf_nh[PREFIX_STRLEN];
- prefix2str(prefix, buf, sizeof(buf));
rfapiUnicastNexthop2Prefix(afi, info->attr, &pfx_nexthop);
- prefix2str(&pfx_nexthop, buf_nh, sizeof(buf_nh));
-
- vnc_zlog_debug_verbose("%s: pfx %s, nh %s", __func__, buf,
- buf_nh);
+ vnc_zlog_debug_verbose("%s: pfx %pFX, nh %pFX", __func__,
+ prefix, &pfx_nexthop);
}
#if DEBUG_RHN_LIST
print_rhn_list(__func__, "ENTER ");
@@ -2673,15 +2590,10 @@ void vnc_import_bgp_del_route(struct bgp *bgp, const struct prefix *prefix,
{
struct prefix pfx_nexthop;
- char buf[PREFIX_STRLEN];
- char buf_nh[PREFIX_STRLEN];
- prefix2str(prefix, buf, sizeof(buf));
rfapiUnicastNexthop2Prefix(afi, info->attr, &pfx_nexthop);
- prefix2str(&pfx_nexthop, buf_nh, sizeof(buf_nh));
-
- vnc_zlog_debug_verbose("%s: pfx %s, nh %s", __func__, buf,
- buf_nh);
+ vnc_zlog_debug_verbose("%s: pfx %pFX, nh %pFX", __func__,
+ prefix, &pfx_nexthop);
}
#if DEBUG_RHN_LIST
print_rhn_list(__func__, "ENTER ");
diff --git a/bgpd/rfapi/vnc_zebra.c b/bgpd/rfapi/vnc_zebra.c
index 008c7b28b7..b254f11ce7 100644
--- a/bgpd/rfapi/vnc_zebra.c
+++ b/bgpd/rfapi/vnc_zebra.c
@@ -363,15 +363,11 @@ static int vnc_zebra_read_route(ZAPI_CALLBACK_ARGS)
else
vnc_redistribute_delete(&api.prefix, api.type);
- if (BGP_DEBUG(zebra, ZEBRA)) {
- char buf[PREFIX_STRLEN];
-
- prefix2str(&api.prefix, buf, sizeof(buf));
+ if (BGP_DEBUG(zebra, ZEBRA))
vnc_zlog_debug_verbose(
- "%s: Zebra rcvd: route delete %s %s metric %u",
- __func__, zebra_route_string(api.type), buf,
+ "%s: Zebra rcvd: route delete %s %pFX metric %u",
+ __func__, zebra_route_string(api.type), &api.prefix,
api.metric);
- }
return 0;
}
@@ -425,14 +421,10 @@ static void vnc_zebra_route_msg(const struct prefix *p, unsigned int nhp_count,
}
}
- if (BGP_DEBUG(zebra, ZEBRA)) {
- char buf[PREFIX_STRLEN];
-
- prefix2str(&api.prefix, buf, sizeof(buf));
+ if (BGP_DEBUG(zebra, ZEBRA))
vnc_zlog_debug_verbose(
- "%s: Zebra send: route %s %s, nhp_count=%d", __func__,
- (add ? "add" : "del"), buf, nhp_count);
- }
+ "%s: Zebra send: route %s %pFX, nhp_count=%d", __func__,
+ (add ? "add" : "del"), &api.prefix, nhp_count);
zclient_route_send((add ? ZEBRA_ROUTE_ADD : ZEBRA_ROUTE_DELETE),
zclient_vnc, &api);