diff options
43 files changed, 224 insertions, 468 deletions
diff --git a/babeld/kernel.c b/babeld/kernel.c index 3941db8d5..5aa01ceb4 100644 --- a/babeld/kernel.c +++ b/babeld/kernel.c @@ -227,10 +227,10 @@ if_eui64(int ifindex, unsigned char *eui) /* Like gettimeofday, but returns monotonic time. If POSIX clocks are not available, falls back to gettimeofday but enforces monotonicity. */ -int +void gettime(struct timeval *tv) { - return monotime(tv); + monotime(tv); } /* If /dev/urandom doesn't exist, this will fail with ENOENT, which the diff --git a/babeld/kernel.h b/babeld/kernel.h index 5b1437ef3..f39bc35bd 100644 --- a/babeld/kernel.h +++ b/babeld/kernel.h @@ -43,7 +43,7 @@ int kernel_route(enum babel_kernel_routes operation, const unsigned char *dest, unsigned int metric, const unsigned char *newgate, int newifindex, unsigned int newmetric); int if_eui64(int ifindex, unsigned char *eui); -int gettime(struct timeval *tv); +void gettime(struct timeval *tv); int read_random_bytes(void *buf, size_t len); #endif /* BABEL_KERNEL_H */ diff --git a/bgpd/bgp_advertise.c b/bgpd/bgp_advertise.c index cfbb29df1..f62a54b03 100644 --- a/bgpd/bgp_advertise.c +++ b/bgpd/bgp_advertise.c @@ -197,7 +197,7 @@ void bgp_adj_in_set(struct bgp_dest *dest, struct peer *peer, struct attr *attr, adj = XCALLOC(MTYPE_BGP_ADJ_IN, sizeof(struct bgp_adj_in)); adj->peer = peer_lock(peer); /* adj_in peer reference */ adj->attr = bgp_attr_intern(attr); - adj->uptime = bgp_clock(); + adj->uptime = monotime(NULL); adj->addpath_rx_id = addpath_id; BGP_ADJ_IN_ADD(dest, adj); bgp_dest_lock_node(dest); diff --git a/bgpd/bgp_clist.c b/bgpd/bgp_clist.c index bc6d4e144..34d4be8c9 100644 --- a/bgpd/bgp_clist.c +++ b/bgpd/bgp_clist.c @@ -674,6 +674,9 @@ bool community_list_match(struct community *com, struct community_list *list) return entry->direct == COMMUNITY_PERMIT; if (entry->style == COMMUNITY_LIST_STANDARD) { + if (community_include(entry->u.com, COMMUNITY_INTERNET)) + return entry->direct == COMMUNITY_PERMIT; + if (community_match(com, entry->u.com)) return entry->direct == COMMUNITY_PERMIT; } else if (entry->style == COMMUNITY_LIST_EXPANDED) { diff --git a/bgpd/bgp_damp.c b/bgpd/bgp_damp.c index 9acbaf773..664619078 100644 --- a/bgpd/bgp_damp.c +++ b/bgpd/bgp_damp.c @@ -125,7 +125,7 @@ static void bgp_reuse_timer(struct thread *t) thread_add_timer(bm->master, bgp_reuse_timer, bdc, DELTA_REUSE, &bdc->t_reuse); - t_now = bgp_clock(); + t_now = monotime(NULL); /* 1. save a pointer to the current zeroth queue head and zero the list head entry. */ @@ -189,7 +189,7 @@ int bgp_damp_withdraw(struct bgp_path_info *path, struct bgp_dest *dest, unsigned int last_penalty = 0; struct bgp_damp_config *bdc = &damp[afi][safi]; - t_now = bgp_clock(); + t_now = monotime(NULL); /* Processing Unreachable Messages. */ if (path->extra) @@ -273,7 +273,7 @@ int bgp_damp_update(struct bgp_path_info *path, struct bgp_dest *dest, if (!path->extra || !((bdi = path->extra->damp_info))) return BGP_DAMP_USED; - t_now = bgp_clock(); + t_now = monotime(NULL); bgp_path_info_unset_flag(dest, path, BGP_PATH_HISTORY); bdi->lastrecord = BGP_RECORD_UPDATE; @@ -588,7 +588,7 @@ void bgp_damp_info_vty(struct vty *vty, struct bgp_path_info *path, afi_t afi, return; /* Calculate new penalty. */ - t_now = bgp_clock(); + t_now = monotime(NULL); t_diff = t_now - bdi->t_updated; penalty = bgp_damp_decay(t_diff, bdi->penalty, bdc); @@ -642,7 +642,7 @@ const char *bgp_damp_reuse_time_vty(struct vty *vty, struct bgp_path_info *path, return NULL; /* Calculate new penalty. */ - t_now = bgp_clock(); + t_now = monotime(NULL); t_diff = t_now - bdi->t_updated; penalty = bgp_damp_decay(t_diff, bdi->penalty, bdc); diff --git a/bgpd/bgp_dump.c b/bgpd/bgp_dump.c index 720925b20..9f6434164 100644 --- a/bgpd/bgp_dump.c +++ b/bgpd/bgp_dump.c @@ -367,7 +367,7 @@ bgp_dump_route_node_record(int afi, struct bgp_dest *dest, stream_putw(obuf, path->peer->table_dump_index); /* Originated */ - stream_putl(obuf, time(NULL) - (bgp_clock() - path->uptime)); + stream_putl(obuf, time(NULL) - (monotime(NULL) - path->uptime)); /*Path Identifier*/ if (addpath_capable) { diff --git a/bgpd/bgp_evpn.c b/bgpd/bgp_evpn.c index 0642c966e..ce05005ea 100644 --- a/bgpd/bgp_evpn.c +++ b/bgpd/bgp_evpn.c @@ -1263,7 +1263,7 @@ static int update_evpn_type5_route_entry(struct bgp *bgp_evpn, /* Unintern existing, set to new. */ bgp_attr_unintern(&tmp_pi->attr); tmp_pi->attr = attr_new; - tmp_pi->uptime = bgp_clock(); + tmp_pi->uptime = monotime(NULL); } } return 0; @@ -1626,7 +1626,7 @@ static int update_evpn_route_entry(struct bgp *bgp, struct bgpevpn *vpn, /* Unintern existing, set to new. */ bgp_attr_unintern(&tmp_pi->attr); tmp_pi->attr = attr_new; - tmp_pi->uptime = bgp_clock(); + tmp_pi->uptime = monotime(NULL); } } @@ -2520,7 +2520,7 @@ static int install_evpn_route_entry_in_vrf(struct bgp *bgp_vrf, /* Unintern existing, set to new. */ bgp_attr_unintern(&pi->attr); pi->attr = attr_new; - pi->uptime = bgp_clock(); + pi->uptime = monotime(NULL); } /* Gateway IP nexthop should be resolved */ @@ -2643,7 +2643,7 @@ static int install_evpn_route_entry(struct bgp *bgp, struct bgpevpn *vpn, /* Unintern existing, set to new. */ bgp_attr_unintern(&pi->attr); pi->attr = attr_new; - pi->uptime = bgp_clock(); + pi->uptime = monotime(NULL); } /* Add this route to remote IP hashtable */ @@ -6239,9 +6239,6 @@ static void bgp_evpn_remote_ip_hash_iterate(struct bgpevpn *vpn, static void show_remote_ip_entry(struct hash_bucket *bucket, void *args) { char buf[INET6_ADDRSTRLEN]; - char buf2[EVPN_ROUTE_STRLEN]; - struct prefix_evpn *evp; - struct listnode *node = NULL; struct bgp_path_info *pi = NULL; struct vty *vty = (struct vty *)args; @@ -6250,11 +6247,8 @@ static void show_remote_ip_entry(struct hash_bucket *bucket, void *args) vty_out(vty, " Remote IP: %s\n", ipaddr2str(&ip->addr, buf, sizeof(buf))); vty_out(vty, " Linked MAC/IP routes:\n"); - for (ALL_LIST_ELEMENTS_RO(ip->macip_path_list, node, pi)) { - evp = (struct prefix_evpn *)&pi->net->p; - prefix2str(evp, buf2, sizeof(buf2)); - vty_out(vty, " %s\n", buf2); - } + for (ALL_LIST_ELEMENTS_RO(ip->macip_path_list, node, pi)) + vty_out(vty, " %pFX\n", &pi->net->p); } void bgp_evpn_show_remote_ip_hash(struct hash_bucket *bucket, void *args) @@ -6438,14 +6432,11 @@ static void bgp_evpn_remote_ip_process_nexthops(struct bgpevpn *vpn, if (!bnc->nexthop || bnc->nexthop->ifindex != vpn->svi_ifindex) return; - if (BGP_DEBUG(nht, NHT)) { - char buf[PREFIX2STR_BUFFER]; - - prefix2str(&bnc->prefix, buf, sizeof(buf)); - zlog_debug("%s(%u): vni %u mac/ip %s for NH %s", + if (BGP_DEBUG(nht, NHT)) + zlog_debug("%s(%u): vni %u mac/ip %s for NH %pFX", vpn->bgp_vrf->name_pretty, vpn->tenant_vrf_id, - vpn->vni, (resolve ? "add" : "delete"), buf); - } + vpn->vni, (resolve ? "add" : "delete"), + &bnc->prefix); /* * MAC/IP route or SVI or tenant vrf being added to EVI. diff --git a/bgpd/bgp_evpn_mh.c b/bgpd/bgp_evpn_mh.c index 3f801f7ea..95a0c31b5 100644 --- a/bgpd/bgp_evpn_mh.c +++ b/bgpd/bgp_evpn_mh.c @@ -233,7 +233,7 @@ static int bgp_evpn_es_route_install(struct bgp *bgp, /* Unintern existing, set to new. */ bgp_attr_unintern(&pi->attr); pi->attr = attr_new; - pi->uptime = bgp_clock(); + pi->uptime = monotime(NULL); } /* Perform route selection and update zebra, if required. */ @@ -432,7 +432,7 @@ int bgp_evpn_mh_route_update(struct bgp *bgp, struct bgp_evpn_es *es, /* Unintern existing, set to new. */ bgp_attr_unintern(&tmp_pi->attr); tmp_pi->attr = attr_new; - tmp_pi->uptime = bgp_clock(); + tmp_pi->uptime = monotime(NULL); } } diff --git a/bgpd/bgp_evpn_vty.c b/bgpd/bgp_evpn_vty.c index 6ba516c39..427716233 100644 --- a/bgpd/bgp_evpn_vty.c +++ b/bgpd/bgp_evpn_vty.c @@ -614,14 +614,10 @@ static void show_esi_routes(struct bgp *bgp, for (dest = bgp_table_top(es->route_table); dest; dest = bgp_route_next(dest)) { int add_prefix_to_json = 0; - char prefix_str[BUFSIZ]; json_object *json_paths = NULL; json_object *json_prefix = NULL; const struct prefix *p = bgp_dest_get_prefix(dest); - prefix2str((struct prefix_evpn *)p, prefix_str, - sizeof(prefix_str)); - if (json) json_prefix = json_object_new_object(); @@ -661,14 +657,14 @@ static void show_esi_routes(struct bgp *bgp, if (json) { if (add_prefix_to_json) { - json_object_string_add(json_prefix, "prefix", - prefix_str); + json_object_string_addf(json_prefix, "prefix", + "%pFX", p); json_object_int_add(json_prefix, "prefixLen", p->prefixlen); json_object_object_add(json_prefix, "paths", json_paths); - json_object_object_add(json, prefix_str, - json_prefix); + json_object_object_addf(json, json_prefix, + "%pFX", p); } else { json_object_free(json_paths); json_object_free(json_prefix); @@ -800,14 +796,10 @@ static void show_vni_routes(struct bgp *bgp, struct bgpevpn *vpn, int type, const struct prefix_evpn *evp = (const struct prefix_evpn *)bgp_dest_get_prefix(dest); int add_prefix_to_json = 0; - char prefix_str[BUFSIZ]; json_object *json_paths = NULL; json_object *json_prefix = NULL; const struct prefix *p = bgp_dest_get_prefix(dest); - prefix2str((struct prefix_evpn *)bgp_dest_get_prefix(dest), - prefix_str, sizeof(prefix_str)); - if (type && evp->prefix.route_type != type) continue; @@ -861,14 +853,14 @@ static void show_vni_routes(struct bgp *bgp, struct bgpevpn *vpn, int type, if (json) { if (add_prefix_to_json) { - json_object_string_add(json_prefix, "prefix", - prefix_str); + json_object_string_addf(json_prefix, "prefix", + "%pFX", p); json_object_int_add(json_prefix, "prefixLen", p->prefixlen); json_object_object_add(json_prefix, "paths", json_paths); - json_object_object_add(json, prefix_str, - json_prefix); + json_object_object_addf(json, json_prefix, + "%pFX", p); } else { json_object_free(json_paths); json_object_free(json_prefix); @@ -1190,7 +1182,6 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd, int rd_header; int header = 1; char rd_str[RD_ADDRSTRLEN]; - char buf[BUFSIZ]; int no_display; unsigned long output_count = 0; @@ -1353,20 +1344,17 @@ static int bgp_show_ethernet_vpn(struct vty *vty, struct prefix_rd *prd, json_prefix_info = json_object_new_object(); - prefix2str((struct prefix_evpn *)p, buf, - BUFSIZ); - - json_object_string_addf( - json_prefix_info, "prefix", "%pFX", - (struct prefix_evpn *)p); + json_object_string_addf(json_prefix_info, + "prefix", "%pFX", p); json_object_int_add(json_prefix_info, "prefixLen", p->prefixlen); json_object_object_add(json_prefix_info, "paths", json_array); - json_object_object_add(json_nroute, buf, - json_prefix_info); + json_object_object_addf(json_nroute, + json_prefix_info, + "%pFX", p); json_array = NULL; } } @@ -2574,7 +2562,6 @@ static void evpn_show_route_rd_macip(struct vty *vty, struct bgp *bgp, safi_t safi; uint32_t path_cnt = 0; json_object *json_paths = NULL; - char prefix_str[BUFSIZ]; afi = AFI_L2VPN; safi = SAFI_EVPN; @@ -2593,8 +2580,6 @@ static void evpn_show_route_rd_macip(struct vty *vty, struct bgp *bgp, return; } - prefix2str(&p, prefix_str, sizeof(prefix_str)); - /* Prefix and num paths displayed once per prefix. */ route_vty_out_detail_header(vty, bgp, dest, prd, afi, safi, json); @@ -2619,7 +2604,7 @@ static void evpn_show_route_rd_macip(struct vty *vty, struct bgp *bgp, if (json && path_cnt) { if (path_cnt) - json_object_object_add(json, prefix_str, json_paths); + json_object_object_addf(json, json_paths, "%pFX", &p); json_object_int_add(json, "numPaths", path_cnt); } else { vty_out(vty, "\nDisplayed %u paths for requested prefix\n", @@ -2678,12 +2663,8 @@ static void evpn_show_route_rd(struct vty *vty, struct bgp *bgp, (const struct prefix_evpn *)bgp_dest_get_prefix(dest); json_object *json_prefix = NULL; json_object *json_paths = NULL; - char prefix_str[BUFSIZ]; int add_prefix_to_json = 0; - prefix2str((struct prefix_evpn *)evp, prefix_str, - sizeof(prefix_str)); - if (type && evp->prefix.route_type != type) continue; @@ -2739,8 +2720,8 @@ static void evpn_show_route_rd(struct vty *vty, struct bgp *bgp, if (add_prefix_to_json) { json_object_object_add(json_prefix, "paths", json_paths); - json_object_object_add(json_rd, prefix_str, - json_prefix); + json_object_object_addf(json_rd, json_prefix, + "%pFX", evp); } else { json_object_free(json_paths); json_object_free(json_prefix); @@ -2798,7 +2779,6 @@ static void evpn_show_route_rd_all_macip(struct vty *vty, struct bgp *bgp, json_object *json_prefix = NULL; /* prefix within an RD */ json_object *json_rd = NULL; /* holds all prefixes for RD */ char rd_str[RD_ADDRSTRLEN]; - char prefix_str[BUFSIZ]; int add_rd_to_json = 0; struct prefix_evpn ep; const struct prefix *rd_destp = bgp_dest_get_prefix(rd_dest); @@ -2825,8 +2805,6 @@ static void evpn_show_route_rd_all_macip(struct vty *vty, struct bgp *bgp, const struct prefix *p = bgp_dest_get_prefix(dest); - prefix2str(p, prefix_str, sizeof(prefix_str)); - pi = bgp_dest_get_bgp_path_info(dest); if (pi) { /* RD header - per RD. */ @@ -2838,8 +2816,8 @@ static void evpn_show_route_rd_all_macip(struct vty *vty, struct bgp *bgp, if (json) { json_prefix = json_object_new_object(); json_paths = json_object_new_array(); - json_object_string_add(json_prefix, "prefix", - prefix_str); + json_object_string_addf(json_prefix, "prefix", "%pFX", + p); json_object_int_add(json_prefix, "prefixLen", p->prefixlen); } else @@ -2873,8 +2851,8 @@ static void evpn_show_route_rd_all_macip(struct vty *vty, struct bgp *bgp, if (json) { json_object_object_add(json_prefix, "paths", json_paths); - json_object_object_add(json_rd, prefix_str, - json_prefix); + json_object_object_addf(json_rd, json_prefix, "%pFX", + p); if (add_rd_to_json) json_object_object_add(json, rd_str, json_rd); else { @@ -2954,13 +2932,9 @@ static void evpn_show_all_routes(struct vty *vty, struct bgp *bgp, int type, const struct prefix_evpn *evp = (const struct prefix_evpn *)bgp_dest_get_prefix( dest); - char prefix_str[BUFSIZ]; int add_prefix_to_json = 0; const struct prefix *p = bgp_dest_get_prefix(dest); - prefix2str((struct prefix_evpn *)p, prefix_str, - sizeof(prefix_str)); - if (type && evp->prefix.route_type != type) continue; @@ -2992,8 +2966,8 @@ static void evpn_show_all_routes(struct vty *vty, struct bgp *bgp, int type, if (json) { json_prefix = json_object_new_object(); json_paths = json_object_new_array(); - json_object_string_add(json_prefix, "prefix", - prefix_str); + json_object_string_addf(json_prefix, "prefix", + "%pFX", p); json_object_int_add(json_prefix, "prefixLen", p->prefixlen); } @@ -3038,9 +3012,9 @@ static void evpn_show_all_routes(struct vty *vty, struct bgp *bgp, int type, json_object_object_add(json_prefix, "paths", json_paths); - json_object_object_add(json_rd, - prefix_str, - json_prefix); + json_object_object_addf(json_rd, + json_prefix, + "%pFX", p); } else { json_object_free(json_prefix); json_object_free(json_paths); diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c index b570c84d8..7b9655591 100644 --- a/bgpd/bgp_fsm.c +++ b/bgpd/bgp_fsm.c @@ -574,7 +574,7 @@ void bgp_routeadv_timer(struct thread *thread) zlog_debug("%s [FSM] Timer (routeadv timer expire)", peer->host); - peer->synctime = bgp_clock(); + peer->synctime = monotime(NULL); thread_add_timer_msec(bm->master, bgp_generate_updgrp_packets, peer, 0, &peer->t_generate_updgrp_packets); @@ -975,7 +975,7 @@ void bgp_start_routeadv(struct bgp *bgp) */ void bgp_adjust_routeadv(struct peer *peer) { - time_t nowtime = bgp_clock(); + time_t nowtime = monotime(NULL); double diff; unsigned long remain; @@ -987,7 +987,7 @@ void bgp_adjust_routeadv(struct peer *peer) */ THREAD_OFF(peer->t_routeadv); - peer->synctime = bgp_clock(); + peer->synctime = monotime(NULL); /* If suppress fib pending is enabled, route is advertised to * peers when the status is received from the FIB. The delay * is added to update group packet generate which will allow @@ -1471,7 +1471,7 @@ int bgp_stop(struct peer *peer) } /* set last reset time */ - peer->resettime = peer->uptime = bgp_clock(); + peer->resettime = peer->uptime = monotime(NULL); if (BGP_DEBUG(update_groups, UPDATE_GROUPS)) zlog_debug("%s remove from all update group", @@ -2220,7 +2220,7 @@ static int bgp_establish(struct peer *peer) if (!peer->v_holdtime) bgp_keepalives_on(peer); - peer->uptime = bgp_clock(); + peer->uptime = monotime(NULL); /* Send route-refresh when ORF is enabled. * Stop Long-lived Graceful Restart timers. diff --git a/bgpd/bgp_io.c b/bgpd/bgp_io.c index aba28fa50..7af1fae28 100644 --- a/bgpd/bgp_io.c +++ b/bgpd/bgp_io.c @@ -431,7 +431,7 @@ static uint16_t bgp_write(struct peer *peer) } done : { - now = bgp_clock(); + now = monotime(NULL); /* * Update last_update if UPDATEs were written. * Note: that these are only updated at end, diff --git a/bgpd/bgp_labelpool.c b/bgpd/bgp_labelpool.c index 8772afd73..fa1dcf33e 100644 --- a/bgpd/bgp_labelpool.c +++ b/bgpd/bgp_labelpool.c @@ -719,16 +719,14 @@ DEFUN(show_bgp_labelpool_ledger, show_bgp_labelpool_ledger_cmd, vty_out(vty, "%-18s %u\n", "INVALID", lcb->label); else { - char buf[PREFIX2STR_BUFFER]; p = bgp_dest_get_prefix(dest); - prefix2str(p, buf, sizeof(buf)); if (uj) { - json_object_string_add(json_elem, - "prefix", buf); + json_object_string_addf( + json_elem, "prefix", "%pFX", p); json_object_int_add(json_elem, "label", lcb->label); } else - vty_out(vty, "%-18s %u\n", buf, + vty_out(vty, "%-18pFX %u\n", p, lcb->label); } break; @@ -812,16 +810,14 @@ DEFUN(show_bgp_labelpool_inuse, show_bgp_labelpool_inuse_cmd, vty_out(vty, "INVALID %u\n", label); else { - char buf[PREFIX2STR_BUFFER]; p = bgp_dest_get_prefix(dest); - prefix2str(p, buf, sizeof(buf)); if (uj) { - json_object_string_add(json_elem, - "prefix", buf); + json_object_string_addf( + json_elem, "prefix", "%pFX", p); json_object_int_add(json_elem, "label", label); } else - vty_out(vty, "%-18s %u\n", buf, + vty_out(vty, "%-18pFX %u\n", p, label); } break; @@ -851,7 +847,6 @@ DEFUN(show_bgp_labelpool_requests, show_bgp_labelpool_requests_cmd, json_object *json = NULL, *json_elem = NULL; struct bgp_dest *dest; const struct prefix *p; - char buf[PREFIX2STR_BUFFER]; struct lp_fifo *item, *next; int count; @@ -893,12 +888,11 @@ DEFUN(show_bgp_labelpool_requests, show_bgp_labelpool_requests_cmd, vty_out(vty, "INVALID\n"); } else { p = bgp_dest_get_prefix(dest); - prefix2str(p, buf, sizeof(buf)); if (uj) - json_object_string_add(json_elem, - "prefix", buf); + json_object_string_addf( + json_elem, "prefix", "%pFX", p); else - vty_out(vty, "%-18s\n", buf); + vty_out(vty, "%-18pFX\n", p); } break; case LP_TYPE_VRF: diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c index 7b8f0df2e..e99c2ba66 100644 --- a/bgpd/bgp_mplsvpn.c +++ b/bgpd/bgp_mplsvpn.c @@ -925,7 +925,7 @@ leak_update(struct bgp *to_bgp, struct bgp_dest *bn, bgp_aggregate_decrement(to_bgp, p, bpi, afi, safi); bgp_attr_unintern(&bpi->attr); bpi->attr = new_attr; - bpi->uptime = bgp_clock(); + bpi->uptime = monotime(NULL); /* * rewrite labels diff --git a/bgpd/bgp_nexthop.c b/bgpd/bgp_nexthop.c index e1fcc743e..971b1817c 100644 --- a/bgpd/bgp_nexthop.c +++ b/bgpd/bgp_nexthop.c @@ -64,11 +64,6 @@ int bgp_nexthop_cache_compare(const struct bgp_nexthop_cache *a, return prefix_cmp(&a->prefix, &b->prefix); } -const char *bnc_str(struct bgp_nexthop_cache *bnc, char *buf, int size) -{ - return prefix2str(&bnc->prefix, buf, size); -} - void bnc_nexthop_free(struct bgp_nexthop_cache *bnc) { nexthops_free(bnc->nexthop); @@ -868,7 +863,7 @@ static void bgp_show_nexthop(struct vty *vty, struct bgp *bgp, if (!CHECK_FLAG(bnc->flags, BGP_NEXTHOP_REGISTERED)) vty_out(vty, " Is not Registered\n"); } - tbuf = time(NULL) - (bgp_clock() - bnc->last_update); + tbuf = time(NULL) - (monotime(NULL) - bnc->last_update); vty_out(vty, " Last update: %s", ctime(&tbuf)); vty_out(vty, "\n"); diff --git a/bgpd/bgp_nexthop.h b/bgpd/bgp_nexthop.h index 9d653ef4d..efad906d0 100644 --- a/bgpd/bgp_nexthop.h +++ b/bgpd/bgp_nexthop.h @@ -161,7 +161,6 @@ extern struct bgp_nexthop_cache *bnc_find(struct bgp_nexthop_cache_head *tree, uint32_t srte_color, ifindex_t ifindex); extern void bnc_nexthop_free(struct bgp_nexthop_cache *bnc); -extern const char *bnc_str(struct bgp_nexthop_cache *bnc, char *buf, int size); extern void bgp_scan_init(struct bgp *bgp); extern void bgp_scan_finish(struct bgp *bgp); extern void bgp_scan_vty_init(void); diff --git a/bgpd/bgp_nht.c b/bgpd/bgp_nht.c index 344608fda..61f1b295c 100644 --- a/bgpd/bgp_nht.c +++ b/bgpd/bgp_nht.c @@ -82,13 +82,10 @@ static int bgp_isvalid_labeled_nexthop(struct bgp_nexthop_cache *bnc) static void bgp_unlink_nexthop_check(struct bgp_nexthop_cache *bnc) { if (LIST_EMPTY(&(bnc->paths)) && !bnc->nht_info) { - if (BGP_DEBUG(nht, NHT)) { - char buf[PREFIX2STR_BUFFER]; - zlog_debug("%s: freeing bnc %s(%d)(%u)(%s)", __func__, - bnc_str(bnc, buf, PREFIX2STR_BUFFER), - bnc->ifindex, bnc->srte_color, + if (BGP_DEBUG(nht, NHT)) + zlog_debug("%s: freeing bnc %pFX(%d)(%u)(%s)", __func__, + &bnc->prefix, bnc->ifindex, bnc->srte_color, bnc->bgp->name_pretty); - } /* only unregister if this is the last nh for this prefix*/ if (!bnc_existing_for_prefix(bnc)) unregister_zebra_rnh(bnc); @@ -261,24 +258,17 @@ int bgp_find_or_add_nexthop(struct bgp *bgp_route, struct bgp *bgp_nexthop, if (!bnc) { bnc = bnc_new(tree, &p, srte_color, ifindex); bnc->bgp = bgp_nexthop; - if (BGP_DEBUG(nht, NHT)) { - char buf[PREFIX2STR_BUFFER]; - - zlog_debug("Allocated bnc %s(%d)(%u)(%s) peer %p", - bnc_str(bnc, buf, PREFIX2STR_BUFFER), - bnc->ifindex, bnc->srte_color, + if (BGP_DEBUG(nht, NHT)) + zlog_debug("Allocated bnc %pFX(%d)(%u)(%s) peer %p", + &bnc->prefix, bnc->ifindex, bnc->srte_color, bnc->bgp->name_pretty, peer); - } } else { - if (BGP_DEBUG(nht, NHT)) { - char buf[PREFIX2STR_BUFFER]; - + if (BGP_DEBUG(nht, NHT)) zlog_debug( - "Found existing bnc %s(%d)(%s) flags 0x%x ifindex %d #paths %d peer %p", - bnc_str(bnc, buf, PREFIX2STR_BUFFER), - bnc->ifindex, bnc->bgp->name_pretty, bnc->flags, - bnc->ifindex, bnc->path_count, bnc->nht_info); - } + "Found existing bnc %pFX(%d)(%s) flags 0x%x ifindex %d #paths %d peer %p", + &bnc->prefix, bnc->ifindex, + bnc->bgp->name_pretty, bnc->flags, bnc->ifindex, + bnc->path_count, bnc->nht_info); } if (pi && is_route_parent_evpn(pi)) @@ -436,7 +426,7 @@ static void bgp_process_nexthop_update(struct bgp_nexthop_cache *bnc, int i; bool evpn_resolved = false; - bnc->last_update = bgp_clock(); + bnc->last_update = monotime(NULL); bnc->change_flags = 0; /* debug print the input */ @@ -563,16 +553,12 @@ static void bgp_process_nexthop_update(struct bgp_nexthop_cache *bnc, if (bnc->is_evpn_gwip_nexthop) { evpn_resolved = bgp_evpn_is_gateway_ip_resolved(bnc); - if (BGP_DEBUG(nht, NHT)) { - char buf2[PREFIX2STR_BUFFER]; - - prefix2str(&bnc->prefix, buf2, sizeof(buf2)); + if (BGP_DEBUG(nht, NHT)) zlog_debug( - "EVPN gateway IP %s recursive MAC/IP lookup %s", - buf2, + "EVPN gateway IP %pFX recursive MAC/IP lookup %s", + &bnc->prefix, (evpn_resolved ? "successful" : "failed")); - } if (evpn_resolved) { bnc->flags |= BGP_NEXTHOP_VALID; @@ -609,7 +595,7 @@ static void bgp_nht_ifp_table_handle(struct bgp *bgp, if (bnc->ifindex != ifp->ifindex) continue; - bnc->last_update = bgp_clock(); + bnc->last_update = monotime(NULL); bnc->change_flags = 0; /* @@ -1023,14 +1009,12 @@ void evaluate_paths(struct bgp_nexthop_cache *bnc) const struct prefix *p; if (BGP_DEBUG(nht, NHT)) { - char buf[PREFIX2STR_BUFFER]; char bnc_buf[BNC_FLAG_DUMP_SIZE]; char chg_buf[BNC_FLAG_DUMP_SIZE]; - bnc_str(bnc, buf, PREFIX2STR_BUFFER); zlog_debug( - "NH update for %s(%d)(%u)(%s) - flags %s chgflags %s- evaluate paths", - buf, bnc->ifindex, bnc->srte_color, + "NH update for %pFX(%d)(%u)(%s) - flags %s chgflags %s- evaluate paths", + &bnc->prefix, bnc->ifindex, bnc->srte_color, bnc->bgp->name_pretty, bgp_nexthop_dump_bnc_flags(bnc, bnc_buf, sizeof(bnc_buf)), diff --git a/bgpd/bgp_packet.c b/bgpd/bgp_packet.c index fe1887565..7daac4494 100644 --- a/bgpd/bgp_packet.c +++ b/bgpd/bgp_packet.c @@ -131,11 +131,11 @@ static void bgp_packet_add(struct peer *peer, struct stream *s) * after it'll get confused */ if (!stream_fifo_count_safe(peer->obuf)) - peer->last_sendq_ok = bgp_clock(); + peer->last_sendq_ok = monotime(NULL); stream_fifo_push(peer->obuf, s); - delta = bgp_clock() - peer->last_sendq_ok; + delta = monotime(NULL) - peer->last_sendq_ok; holdtime = atomic_load_explicit(&peer->holdtime, memory_order_relaxed); @@ -156,12 +156,12 @@ static void bgp_packet_add(struct peer *peer, struct stream *s) peer->host); BGP_EVENT_ADD(peer, TCP_fatal_error); } else if (delta > (intmax_t)holdtime && - bgp_clock() - peer->last_sendq_warn > 5) { + monotime(NULL) - peer->last_sendq_warn > 5) { flog_warn( EC_BGP_SENDQ_STUCK_WARN, "%s has not made any SendQ progress for 1 holdtime, peer overloaded?", peer->host); - peer->last_sendq_warn = bgp_clock(); + peer->last_sendq_warn = monotime(NULL); } } } @@ -2026,7 +2026,7 @@ static int bgp_update_receive(struct peer *peer, bgp_size_t size) interned in bgp_attr_parse(). */ bgp_attr_unintern_sub(&attr); - peer->update_time = bgp_clock(); + peer->update_time = monotime(NULL); /* Notify BGP Conditional advertisement scanner process */ peer->advmap_table_change = true; diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 04f955f97..989b36159 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -3672,7 +3672,7 @@ struct bgp_path_info *info_make(int type, int sub_type, unsigned short instance, new->sub_type = sub_type; new->peer = peer; new->attr = attr; - new->uptime = bgp_clock(); + new->uptime = monotime(NULL); new->net = dest; return new; } @@ -4062,7 +4062,7 @@ int bgp_update(struct peer *peer, const struct prefix *p, uint32_t addpath_id, /* If the update is implicit withdraw. */ if (pi) { - pi->uptime = bgp_clock(); + pi->uptime = monotime(NULL); same_attr = attrhash_cmp(pi->attr, attr_new); hook_call(bgp_process, bgp, afi, safi, dest, peer, true); @@ -5995,7 +5995,7 @@ void bgp_static_update(struct bgp *bgp, const struct prefix *p, #endif bgp_attr_unintern(&pi->attr); pi->attr = attr_new; - pi->uptime = bgp_clock(); + pi->uptime = monotime(NULL); #ifdef ENABLE_BGP_VNC if ((afi == AFI_IP || afi == AFI_IP6) && (safi == SAFI_UNICAST)) { @@ -6297,7 +6297,7 @@ static void bgp_static_update_safi(struct bgp *bgp, const struct prefix *p, bgp_aggregate_decrement(bgp, p, pi, afi, safi); bgp_attr_unintern(&pi->attr); pi->attr = attr_new; - pi->uptime = bgp_clock(); + pi->uptime = monotime(NULL); #ifdef ENABLE_BGP_VNC if (pi->extra) label = decode_label(&pi->extra->label[0]); @@ -8521,7 +8521,7 @@ void bgp_redistribute_add(struct bgp *bgp, struct prefix *p, bgp, p, bpi, afi, SAFI_UNICAST); bgp_attr_unintern(&bpi->attr); bpi->attr = new_attr; - bpi->uptime = bgp_clock(); + bpi->uptime = monotime(NULL); /* Process change. */ bgp_aggregate_increment(bgp, p, bpi, afi, @@ -9456,9 +9456,7 @@ void route_vty_out_tmp(struct vty *vty, struct bgp_dest *dest, json_object_boolean_true_add(json_status, ">"); json_object_object_add(json_net, "appliedStatusSymbols", json_status); - - prefix2str(p, buff, PREFIX_STRLEN); - json_object_object_add(json_ar, buff, json_net); + json_object_object_addf(json_ar, json_net, "%pFX", p); } else vty_out(vty, "\n"); } @@ -10052,7 +10050,7 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn, vty_out(vty, " Gateway IP %s", gwip_buf); } - if (safi == SAFI_EVPN) + if (safi == SAFI_EVPN && !json_path) vty_out(vty, "\n"); /* Line1 display AS-path, Aggregator */ @@ -10808,7 +10806,7 @@ void route_vty_out_detail(struct vty *vty, struct bgp *bgp, struct bgp_dest *bn, } /* Line 9 display Uptime */ - tbuf = time(NULL) - (bgp_clock() - path->uptime); + tbuf = time(NULL) - (monotime(NULL) - path->uptime); if (json_paths) { json_last_update = json_object_new_object(); json_object_int_add(json_last_update, "epoch", tbuf); @@ -11545,7 +11543,6 @@ void route_vty_out_detail_header(struct vty *vty, struct bgp *bgp, has_valid_label = bgp_is_valid_label(&label); if (safi == SAFI_EVPN) { - if (!json) { vty_out(vty, "BGP routing table entry for %s%s%pFX\n", prd ? prefix_rd2str(prd, buf1, sizeof(buf1)) diff --git a/bgpd/bgp_snmp.c b/bgpd/bgp_snmp.c index e25d8d90d..6bc313464 100644 --- a/bgpd/bgp_snmp.c +++ b/bgpd/bgp_snmp.c @@ -588,7 +588,7 @@ static uint8_t *bgpPeerTable(struct variable *v, oid name[], size_t *length, if (peer->uptime == 0) return SNMP_INTEGER(0); else - return SNMP_INTEGER(bgp_clock() - peer->uptime); + return SNMP_INTEGER(monotime(NULL) - peer->uptime); case BGPPEERCONNECTRETRYINTERVAL: *write_method = write_bgpPeerTable; return SNMP_INTEGER(peer->v_connect); @@ -615,7 +615,7 @@ static uint8_t *bgpPeerTable(struct variable *v, oid name[], size_t *length, if (peer->update_time == 0) return SNMP_INTEGER(0); else - return SNMP_INTEGER(bgp_clock() - peer->update_time); + return SNMP_INTEGER(monotime(NULL) - peer->update_time); default: return NULL; } diff --git a/bgpd/bgp_updgrp.c b/bgpd/bgp_updgrp.c index f1173941a..3a974910f 100644 --- a/bgpd/bgp_updgrp.c +++ b/bgpd/bgp_updgrp.c @@ -70,14 +70,14 @@ static void update_group_checkin(struct update_group *updgrp) { updgrp->id = ++bm->updgrp_idspace; - updgrp->uptime = bgp_clock(); + updgrp->uptime = monotime(NULL); } static void update_subgroup_checkin(struct update_subgroup *subgrp, struct update_group *updgrp) { subgrp->id = ++bm->subgrp_idspace; - subgrp->uptime = bgp_clock(); + subgrp->uptime = monotime(NULL); } static void sync_init(struct update_subgroup *subgrp, diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index 0eba5ea44..cfa661456 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -9573,10 +9573,8 @@ DEFPY (show_bgp_srv6, vty_out(vty, "locator_name: %s\n", bgp->srv6_locator_name); vty_out(vty, "locator_chunks:\n"); - for (ALL_LIST_ELEMENTS_RO(bgp->srv6_locator_chunks, node, chunk)) { - prefix2str(&chunk->prefix, buf, sizeof(buf)); - vty_out(vty, "- %s\n", buf); - } + for (ALL_LIST_ELEMENTS_RO(bgp->srv6_locator_chunks, node, chunk)) + vty_out(vty, "- %pFX\n", &chunk->prefix); vty_out(vty, "functions:\n"); for (ALL_LIST_ELEMENTS_RO(bgp->srv6_functions, node, func)) { @@ -12723,7 +12721,7 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json, if (peer_established(p)) { time_t uptime; - uptime = bgp_clock(); + uptime = monotime(NULL); uptime -= p->uptime; epoch_tbuf = time(NULL) - uptime; @@ -12751,7 +12749,7 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json, time_t uptime; struct tm tm; - uptime = bgp_clock(); + uptime = monotime(NULL); uptime -= p->readtime; gmtime_r(&uptime, &tm); @@ -12759,7 +12757,7 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json, (tm.tm_sec * 1000) + (tm.tm_min * 60000) + (tm.tm_hour * 3600000)); - uptime = bgp_clock(); + uptime = monotime(NULL); uptime -= p->last_write; gmtime_r(&uptime, &tm); @@ -12767,7 +12765,7 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json, (tm.tm_sec * 1000) + (tm.tm_min * 60000) + (tm.tm_hour * 3600000)); - uptime = bgp_clock(); + uptime = monotime(NULL); uptime -= p->update_time; gmtime_r(&uptime, &tm); @@ -14039,7 +14037,7 @@ static void bgp_show_peer(struct vty *vty, struct peer *p, bool use_json, time_t uptime; struct tm tm; - uptime = bgp_clock(); + uptime = monotime(NULL); uptime -= p->resettime; gmtime_r(&uptime, &tm); diff --git a/bgpd/bgpd.c b/bgpd/bgpd.c index c17bd76ad..036bbbd6b 100644 --- a/bgpd/bgpd.c +++ b/bgpd/bgpd.c @@ -531,17 +531,6 @@ void bgp_cluster_id_unset(struct bgp *bgp) } } -/* time_t value that is monotonicly increasing - * and uneffected by adjustments to system clock - */ -time_t bgp_clock(void) -{ - struct timeval tv; - - monotime(&tv); - return tv.tv_sec; -} - /* BGP timer configuration. */ void bgp_timers_set(struct bgp *bgp, uint32_t keepalive, uint32_t holdtime, uint32_t connect_retry, uint32_t delayopen) @@ -1760,7 +1749,7 @@ struct peer *peer_create(union sockunion *su, const char *conf_if, } /* Last read and reset time set */ - peer->readtime = peer->resettime = bgp_clock(); + peer->readtime = peer->resettime = monotime(NULL); /* Default TTL set. */ peer->ttl = (peer->sort == BGP_PEER_IBGP) ? MAXTTL : BGP_DEFAULT_TTL; @@ -4017,7 +4006,6 @@ struct peer *peer_lookup_dynamic_neighbor(struct bgp *bgp, union sockunion *su) struct prefix prefix; struct prefix *listen_range; int dncount; - char buf[PREFIX2STR_BUFFER]; if (!sockunion2hostprefix(su, &prefix)) return NULL; @@ -4034,21 +4022,19 @@ struct peer *peer_lookup_dynamic_neighbor(struct bgp *bgp, union sockunion *su) if (!gbgp) return NULL; - prefix2str(&prefix, buf, sizeof(buf)); - if (bgp_debug_neighbor_events(NULL)) zlog_debug( - "Dynamic Neighbor %s matches group %s listen range %pFX", - buf, group->name, listen_range); + "Dynamic Neighbor %pFX matches group %s listen range %pFX", + &prefix, group->name, listen_range); /* Are we within the listen limit? */ dncount = gbgp->dynamic_neighbors_count; if (dncount >= gbgp->dynamic_neighbors_limit) { if (bgp_debug_neighbor_events(NULL)) - zlog_debug("Dynamic Neighbor %s rejected - at limit %d", - inet_sutop(su, buf), - gbgp->dynamic_neighbors_limit); + zlog_debug( + "Dynamic Neighbor %pFX rejected - at limit %d", + &prefix, gbgp->dynamic_neighbors_limit); return NULL; } @@ -4056,8 +4042,8 @@ struct peer *peer_lookup_dynamic_neighbor(struct bgp *bgp, union sockunion *su) if (CHECK_FLAG(group->conf->flags, PEER_FLAG_SHUTDOWN)) { if (bgp_debug_neighbor_events(NULL)) zlog_debug( - "Dynamic Neighbor %s rejected - group %s disabled", - buf, group->name); + "Dynamic Neighbor %pFX rejected - group %s disabled", + &prefix, group->name); return NULL; } @@ -4065,8 +4051,8 @@ struct peer *peer_lookup_dynamic_neighbor(struct bgp *bgp, union sockunion *su) if (!peer_group_af_configured(group)) { if (bgp_debug_neighbor_events(NULL)) zlog_debug( - "Dynamic Neighbor %s rejected - no AF activated for group %s", - buf, group->name); + "Dynamic Neighbor %pFX rejected - no AF activated for group %s", + &prefix, group->name); return NULL; } @@ -7960,7 +7946,7 @@ char *peer_uptime(time_t uptime2, char *buf, size_t len, bool use_json, } /* Get current time. */ - uptime1 = bgp_clock(); + uptime1 = monotime(NULL); uptime1 -= uptime2; gmtime_r(&uptime1, &tm); @@ -8002,7 +7988,7 @@ void bgp_master_init(struct thread_master *master, const int buffer_size, bm->port = BGP_PORT_DEFAULT; bm->addresses = addresses; bm->master = master; - bm->start_time = bgp_clock(); + bm->start_time = monotime(NULL); bm->t_rmap_update = NULL; bm->rmap_update_timer = RMAP_DEFAULT_UPDATE_TIMER; bm->v_update_delay = BGP_UPDATE_DELAY_DEF; diff --git a/bgpd/bgpd.h b/bgpd/bgpd.h index 8348b37b8..dc7ad32a5 100644 --- a/bgpd/bgpd.h +++ b/bgpd/bgpd.h @@ -2043,7 +2043,6 @@ extern unsigned int multipath_num; /* Prototypes. */ extern void bgp_terminate(void); extern void bgp_reset(void); -extern time_t bgp_clock(void); extern void bgp_zclient_reset(void); extern struct bgp *bgp_get_default(void); extern struct bgp *bgp_lookup(as_t, const char *); @@ -2449,7 +2448,7 @@ static inline int peer_group_af_configured(struct peer_group *group) static inline char *timestamp_string(time_t ts) { time_t tbuf; - tbuf = time(NULL) - (bgp_clock() - ts); + tbuf = time(NULL) - (monotime(NULL) - ts); return ctime(&tbuf); } diff --git a/bgpd/rfapi/bgp_rfapi_cfg.c b/bgpd/rfapi/bgp_rfapi_cfg.c index 2437bd8cf..831f92996 100644 --- a/bgpd/rfapi/bgp_rfapi_cfg.c +++ b/bgpd/rfapi/bgp_rfapi_cfg.c @@ -94,7 +94,7 @@ DEFINE_QOBJ_TYPE(rfapi_l2_group_cfg); */ time_t rfapi_time(time_t *t) { - time_t clock = bgp_clock(); + time_t clock = monotime(NULL); if (t) *t = clock; return clock; diff --git a/bgpd/rfapi/rfapi.c b/bgpd/rfapi/rfapi.c index 382886e0b..a34c10d84 100644 --- a/bgpd/rfapi/rfapi.c +++ b/bgpd/rfapi/rfapi.c @@ -1006,7 +1006,7 @@ void add_vnc_route(struct rfapi_descriptor *rfd, /* cookie, VPN UN addr, peer */ bgp_aggregate_decrement(bgp, p, bpi, afi, safi); bgp_attr_unintern(&bpi->attr); bpi->attr = new_attr; - bpi->uptime = bgp_clock(); + bpi->uptime = monotime(NULL); if (safi == SAFI_MPLS_VPN) { @@ -1351,8 +1351,7 @@ int rfapi_init_and_open(struct bgp *bgp, struct rfapi_descriptor *rfd, struct prefix pfx_un; struct agg_node *rn; - - rfapi_time(&rfd->open_time); + rfd->open_time = monotime(NULL); if (rfg->type == RFAPI_GROUP_CFG_VRF) SET_FLAG(rfd->flags, RFAPI_HD_FLAG_IS_VRF); @@ -1521,10 +1520,10 @@ rfapi_query_inner(void *handle, struct rfapi_ip_addr *target, } rfd->rsp_counter++; /* dedup: identify this generation */ - rfd->rsp_time = rfapi_time(NULL); /* response content dedup */ + rfd->rsp_time = monotime(NULL); /* response content dedup */ rfd->ftd_last_allowed_time = - bgp_clock() - - bgp->rfapi_cfg->rfp_cfg.ftd_advertisement_interval; + monotime(NULL) - + bgp->rfapi_cfg->rfp_cfg.ftd_advertisement_interval; if (l2o) { if (!memcmp(l2o->macaddr.octet, rfapi_ethaddr0.octet, diff --git a/bgpd/rfapi/rfapi_import.c b/bgpd/rfapi/rfapi_import.c index 1d4270276..6fb509fd9 100644 --- a/bgpd/rfapi/rfapi_import.c +++ b/bgpd/rfapi/rfapi_import.c @@ -489,7 +489,7 @@ static struct bgp_path_info *rfapiBgpInfoCreate(struct attr *attr, bgp_path_info_extra_get(new); if (prd) { new->extra->vnc.import.rd = *prd; - rfapi_time(&new->extra->vnc.import.create_time); + new->extra->vnc.import.create_time = monotime(NULL); } if (label) encode_label(*label, &new->extra->label[0]); diff --git a/bgpd/rfapi/rfapi_private.h b/bgpd/rfapi/rfapi_private.h index bc0e192ae..8c76e1dd0 100644 --- a/bgpd/rfapi/rfapi_private.h +++ b/bgpd/rfapi/rfapi_private.h @@ -364,6 +364,11 @@ extern int rfapi_extract_l2o( * compaitibility to old quagga_time call * time_t value in terms of stabilised absolute time. * replacement for POSIX time() + * + * Please do not use this. This is kept only for + * Lou's CI in that that CI compiles against some + * private bgp code and it will just fail to compile + * without this. Use monotime() */ extern time_t rfapi_time(time_t *t); diff --git a/bgpd/rfapi/rfapi_rib.c b/bgpd/rfapi/rfapi_rib.c index 9d61ada7d..9e13c4813 100644 --- a/bgpd/rfapi/rfapi_rib.c +++ b/bgpd/rfapi/rfapi_rib.c @@ -784,7 +784,7 @@ int rfapiRibPreloadBi( skiplist_insert(slRibPt, &ori->rk, ori); } - ori->last_sent_time = rfapi_time(NULL); + ori->last_sent_time = monotime(NULL); /* * poke timer @@ -797,7 +797,7 @@ int rfapiRibPreloadBi( * Update last sent time for prefix */ trn = agg_node_get(rfd->rsp_times[afi], p); /* locks trn */ - trn->info = (void *)(uintptr_t)bgp_clock(); + trn->info = (void *)(uintptr_t)monotime(NULL); if (agg_node_get_lock_count(trn) > 1) agg_unlock_node(trn); @@ -1089,7 +1089,7 @@ static void process_pending_node(struct bgp *bgp, struct rfapi_descriptor *rfd, rfapiFreeBgpTeaOptionChain(ori->tea_options); ori->tea_options = rfapiOptionsDup(ri->tea_options); - ori->last_sent_time = rfapi_time(NULL); + ori->last_sent_time = monotime(NULL); rfapiFreeRfapiVnOptionChain(ori->vn_options); ori->vn_options = @@ -1115,7 +1115,7 @@ static void process_pending_node(struct bgp *bgp, struct rfapi_descriptor *rfd, ori->lifetime = ri->lifetime; ori->tea_options = rfapiOptionsDup(ri->tea_options); - ori->last_sent_time = rfapi_time(NULL); + ori->last_sent_time = monotime(NULL); ori->vn_options = rfapiVnOptionsDup(ri->vn_options); ori->un_options = @@ -1227,7 +1227,7 @@ callback: */ trn = agg_node_get(rfd->rsp_times[afi], p); /* locks trn */ - trn->info = (void *)(uintptr_t)bgp_clock(); + trn->info = (void *)(uintptr_t)monotime(NULL); if (agg_node_get_lock_count(trn) > 1) agg_unlock_node(trn); @@ -1376,7 +1376,7 @@ callback: rfapiRibStartTimer(rfd, ri, rn, 1); RFAPI_RIB_CHECK_COUNTS( 0, delete_list->count); - ri->last_sent_time = rfapi_time(NULL); + ri->last_sent_time = monotime(NULL); #if DEBUG_RIB_SL_RD { char buf_rd[RD_ADDRSTRLEN]; @@ -1400,7 +1400,7 @@ callback: rfapiRibStartTimer(rfd, ri_del, rn, 1); RFAPI_RIB_CHECK_COUNTS( 0, delete_list->count); - ri->last_sent_time = rfapi_time(NULL); + ri->last_sent_time = monotime(NULL); } } } else { @@ -1849,7 +1849,7 @@ rfapiRibPreload(struct bgp *bgp, struct rfapi_descriptor *rfd, vnc_zlog_debug_verbose("%s: loading response=%p, use_eth_resolution=%d", __func__, response, use_eth_resolution); - new_last_sent_time = rfapi_time(NULL); + new_last_sent_time = monotime(NULL); for (nhp = response; nhp; nhp = nhp_next) { @@ -2019,7 +2019,7 @@ rfapiRibPreload(struct bgp *bgp, struct rfapi_descriptor *rfd, ri->lifetime = nhp->lifetime; ri->vn_options = rfapiVnOptionsDup(nhp->vn_options); ri->rsp_counter = rfd->rsp_counter; - ri->last_sent_time = rfapi_time(NULL); + ri->last_sent_time = monotime(NULL); if (need_insert) { int rc; @@ -2042,7 +2042,7 @@ rfapiRibPreload(struct bgp *bgp, struct rfapi_descriptor *rfd, * update this NVE's timestamp for this prefix */ trn = agg_node_get(rfd->rsp_times[afi], &pfx); /* locks trn */ - trn->info = (void *)(uintptr_t)bgp_clock(); + trn->info = (void *)(uintptr_t)monotime(NULL); if (agg_node_get_lock_count(trn) > 1) agg_unlock_node(trn); @@ -2275,7 +2275,7 @@ static int print_rib_sl(int (*fp)(void *, const char *, ...), struct vty *vty, rfapiFormatAge(ri->last_sent_time, str_age, BUFSIZ); #else { - time_t now = rfapi_time(NULL); + time_t now = monotime(NULL); time_t expire = ri->last_sent_time + (time_t)ri->lifetime; /* allow for delayed/async removal */ diff --git a/bgpd/rfapi/rfapi_vty.c b/bgpd/rfapi/rfapi_vty.c index c8fdadcac..a8ab61841 100644 --- a/bgpd/rfapi/rfapi_vty.c +++ b/bgpd/rfapi/rfapi_vty.c @@ -109,7 +109,7 @@ char *rfapiFormatAge(time_t age, char *buf, size_t len) { time_t now, age_adjusted; - now = rfapi_time(NULL); + now = monotime(NULL); age_adjusted = now - age; return rfapiFormatSeconds(age_adjusted, buf, len); diff --git a/doc/user/bgp.rst b/doc/user/bgp.rst index e31bfe7bf..e6c407630 100644 --- a/doc/user/bgp.rst +++ b/doc/user/bgp.rst @@ -2490,6 +2490,9 @@ Extended Community Lists there is no matched entry, deny will be returned. When `extcommunity` is empty it matches to any routes. + A special handling for ``internet`` community is applied. It matches + any community. + .. clicmd:: bgp extcommunity-list expanded NAME permit|deny LINE This command defines a new expanded extcommunity-list. `line` is a string diff --git a/lib/sigevent.c b/lib/sigevent.c index 0f20bc027..985bedeb9 100644 --- a/lib/sigevent.c +++ b/lib/sigevent.c @@ -134,8 +134,7 @@ int frr_sigevent_process(void) #ifdef SIGEVENT_BLOCK_SIGNALS if (sigprocmask(SIG_UNBLOCK, &oldmask, NULL) < 0) - ; - return -1; + return -1; #endif /* SIGEVENT_BLOCK_SIGNALS */ return 0; diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c index af05f5b59..278f263da 100644 --- a/ospfd/ospf_lsa.c +++ b/ospfd/ospf_lsa.c @@ -1978,9 +1978,8 @@ static struct ospf_lsa *ospf_lsa_translated_nssa_new(struct ospf *ospf, if (type7->area->suppress_fa) { extnew->e[0].fwd_addr.s_addr = 0; if (IS_DEBUG_OSPF_NSSA) - zlog_debug( - "ospf_lsa_translated_nssa_new(): Suppress forwarding address for %pI4", - &ei.p.prefix); + zlog_debug("%s: Suppress forwarding address for %pI4", + __func__, &ei.p.prefix); } else extnew->e[0].fwd_addr.s_addr = ext->e[0].fwd_addr.s_addr; new->data->ls_seqnum = type7->data->ls_seqnum; @@ -2103,9 +2102,8 @@ struct ospf_lsa *ospf_translated_nssa_refresh(struct ospf *ospf, /* do we have type7? */ if (!type7) { if (IS_DEBUG_OSPF_NSSA) - zlog_debug( - "ospf_translated_nssa_refresh(): no Type-7 found for Type-5 LSA Id %pI4", - &type5->data->id); + zlog_debug("%s: no Type-7 found for Type-5 LSA Id %pI4", + __func__, &type5->data->id); return NULL; } @@ -2113,8 +2111,8 @@ struct ospf_lsa *ospf_translated_nssa_refresh(struct ospf *ospf, if (type5 == NULL || !CHECK_FLAG(type5->flags, OSPF_LSA_LOCAL_XLT)) { if (IS_DEBUG_OSPF_NSSA) zlog_debug( - "ospf_translated_nssa_refresh(): No translated Type-5 found for Type-7 with Id %pI4", - &type7->data->id); + "%s: No translated Type-5 found for Type-7 with Id %pI4", + __func__, &type7->data->id); return NULL; } @@ -2131,8 +2129,8 @@ struct ospf_lsa *ospf_translated_nssa_refresh(struct ospf *ospf, if ((new = ospf_lsa_translated_nssa_new(ospf, type7)) == NULL) { if (IS_DEBUG_OSPF_NSSA) zlog_debug( - "ospf_translated_nssa_refresh(): Could not translate Type-7 for %pI4 to Type-5", - &type7->data->id); + "%s: Could not translate Type-7 for %pI4 to Type-5", + __func__, &type7->data->id); return NULL; } @@ -2142,10 +2140,9 @@ struct ospf_lsa *ospf_translated_nssa_refresh(struct ospf *ospf, } if (!(new = ospf_lsa_install(ospf, NULL, new))) { - flog_warn( - EC_OSPF_LSA_INSTALL_FAILURE, - "ospf_translated_nssa_refresh(): Could not install translated LSA, Id %pI4", - &type7->data->id); + flog_warn(EC_OSPF_LSA_INSTALL_FAILURE, + "%s: Could not install translated LSA, Id %pI4", + __func__, &type7->data->id); return NULL; } @@ -2434,7 +2431,7 @@ void ospf_external_lsa_flush(struct ospf *ospf, uint8_t type, } if (IS_DEBUG_OSPF(lsa, LSA_FLOODING)) - zlog_debug("ospf_external_lsa_flush(): stop"); + zlog_debug("%s: stop", __func__); } void ospf_external_lsa_refresh_default(struct ospf *ospf) @@ -3935,9 +3932,9 @@ void ospf_refresher_register_lsa(struct ospf *ospf, struct ospf_lsa *lsa) if (IS_DEBUG_OSPF(lsa, LSA_REFRESH)) zlog_debug( - "LSA[Refresh:Type%d:%pI4]: ospf_refresher_register_lsa(): setting refresh_list on lsa %p (slot %d)", - lsa->data->type, &lsa->data->id, (void *)lsa, - index); + "LSA[Refresh:Type%d:%pI4]: %s: setting refresh_list on lsa %p (slot %d)", + lsa->data->type, &lsa->data->id, __func__, + (void *)lsa, index); } } @@ -3968,7 +3965,7 @@ void ospf_lsa_refresh_walker(struct thread *t) struct list *lsa_to_refresh = list_new(); if (IS_DEBUG_OSPF(lsa, LSA_REFRESH)) - zlog_debug("LSA[Refresh]: ospf_lsa_refresh_walker(): start"); + zlog_debug("LSA[Refresh]: %s: start", __func__); i = ospf->lsa_refresh_queue.index; @@ -3985,16 +3982,14 @@ void ospf_lsa_refresh_walker(struct thread *t) % OSPF_LSA_REFRESHER_SLOTS; if (IS_DEBUG_OSPF(lsa, LSA_REFRESH)) - zlog_debug( - "LSA[Refresh]: ospf_lsa_refresh_walker(): next index %d", - ospf->lsa_refresh_queue.index); + zlog_debug("LSA[Refresh]: %s: next index %d", __func__, + ospf->lsa_refresh_queue.index); for (; i != ospf->lsa_refresh_queue.index; i = (i + 1) % OSPF_LSA_REFRESHER_SLOTS) { if (IS_DEBUG_OSPF(lsa, LSA_REFRESH)) - zlog_debug( - "LSA[Refresh]: ospf_lsa_refresh_walker(): refresh index %d", - i); + zlog_debug("LSA[Refresh]: %s: refresh index %d", + __func__, i); refresh_list = ospf->lsa_refresh_queue.qs[i]; @@ -4007,10 +4002,9 @@ void ospf_lsa_refresh_walker(struct thread *t) lsa)) { if (IS_DEBUG_OSPF(lsa, LSA_REFRESH)) zlog_debug( - "LSA[Refresh:Type%d:%pI4]: ospf_lsa_refresh_walker(): refresh lsa %p (slot %d)", - lsa->data->type, - &lsa->data->id, - (void *)lsa, i); + "LSA[Refresh:Type%d:%pI4]: %s: refresh lsa %p (slot %d)", + lsa->data->type, &lsa->data->id, + __func__, (void *)lsa, i); assert(lsa->lock > 0); list_delete_node(refresh_list, node); @@ -4036,7 +4030,7 @@ void ospf_lsa_refresh_walker(struct thread *t) list_delete(&lsa_to_refresh); if (IS_DEBUG_OSPF(lsa, LSA_REFRESH)) - zlog_debug("LSA[Refresh]: ospf_lsa_refresh_walker(): end"); + zlog_debug("LSA[Refresh]: %s: end", __func__); } /* Flush the LSAs for the specific area */ diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c index c5e26fa37..57643f637 100644 --- a/ospfd/ospf_packet.c +++ b/ospfd/ospf_packet.c @@ -440,10 +440,10 @@ static int ospf_make_md5_digest(struct ospf_interface *oi, if (stream_get_endp(op->s) != op->length) /* XXX size_t */ - flog_warn( - EC_OSPF_MD5, - "ospf_make_md5_digest: length mismatch stream %lu ospf_packet %u", - (unsigned long)stream_get_endp(op->s), op->length); + flog_warn(EC_OSPF_MD5, + "%s: length mismatch stream %lu ospf_packet %u", + __func__, (unsigned long)stream_get_endp(op->s), + op->length); return OSPF_AUTH_MD5_SIZE; } @@ -596,15 +596,14 @@ static void ospf_write_frags(int fd, struct ospf_packet *op, struct ip *iph, if (ret < 0) flog_err( EC_LIB_SOCKET, - "*** ospf_write_frags: sendmsg failed to %pI4, id %d, off %d, len %d, mtu %u failed with %s", - &iph->ip_dst, iph->ip_id, iph->ip_off, + "*** %s: sendmsg failed to %pI4, id %d, off %d, len %d, mtu %u failed with %s", + __func__, &iph->ip_dst, iph->ip_id, iph->ip_off, iph->ip_len, mtu, safe_strerror(errno)); if (IS_DEBUG_OSPF_PACKET(type - 1, SEND)) { - zlog_debug( - "ospf_write_frags: sent id %d, off %d, len %d to %pI4", - iph->ip_id, iph->ip_off, iph->ip_len, - &iph->ip_dst); + zlog_debug("%s: sent id %d, off %d, len %d to %pI4", + __func__, iph->ip_id, iph->ip_off, + iph->ip_len, &iph->ip_dst); } iph->ip_off += offset; @@ -647,9 +646,8 @@ static void ospf_write(struct thread *thread) if (ospf->fd < 0 || ospf->oi_running == 0) { if (IS_DEBUG_OSPF_EVENT) - zlog_debug( - "ospf_write failed to send, fd %d, instance %u", - ospf->fd, ospf->oi_running); + zlog_debug("%s failed to send, fd %d, instance %u", + __func__, ospf->fd, ospf->oi_running); return; } @@ -782,8 +780,8 @@ static void ospf_write(struct thread *thread) sockopt_iphdrincl_swab_systoh(&iph); if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_write to %pI4, id %d, off %d, len %d, interface %s, mtu %u:", - &iph.ip_dst, iph.ip_id, iph.ip_off, + "%s to %pI4, id %d, off %d, len %d, interface %s, mtu %u:", + __func__, &iph.ip_dst, iph.ip_id, iph.ip_off, iph.ip_len, oi->ifp->name, oi->ifp->mtu); /* sendmsg will return EPERM if firewall is blocking sending. @@ -795,8 +793,8 @@ static void ospf_write(struct thread *thread) if (ret < 0 && errno != EPERM) flog_err( EC_LIB_SOCKET, - "*** sendmsg in ospf_write failed to %pI4, id %d, off %d, len %d, interface %s, mtu %u: %s", - &iph.ip_dst, iph.ip_id, iph.ip_off, + "*** sendmsg in %s failed to %pI4, id %d, off %d, len %d, interface %s, mtu %u: %s", + __func__, &iph.ip_dst, iph.ip_id, iph.ip_off, iph.ip_len, oi->ifp->name, oi->ifp->mtu, safe_strerror(errno)); @@ -2318,8 +2316,8 @@ static struct stream *ospf_recv_packet(struct ospf *ospf, int fd, if ((unsigned int)ret < sizeof(struct ip)) { flog_warn( EC_OSPF_PACKET, - "ospf_recv_packet: discarding runt packet of length %d (ip header size is %u)", - ret, (unsigned int)sizeof(iph)); + "%s: discarding runt packet of length %d (ip header size is %u)", + __func__, ret, (unsigned int)sizeof(iph)); return NULL; } @@ -2364,8 +2362,8 @@ static struct stream *ospf_recv_packet(struct ospf *ospf, int fd, if (ret != ip_len) { flog_warn( EC_OSPF_PACKET, - "ospf_recv_packet read length mismatch: ip_len is %d, but recvmsg returned %d", - ip_len, ret); + "%s read length mismatch: ip_len is %d, but recvmsg returned %d", + __func__, ip_len, ret); return NULL; } @@ -2587,8 +2585,8 @@ static int ospf_check_sum(struct ospf_header *ospfh) ret = in_cksum(ospfh, ntohs(ospfh->length)); if (ret != sum) { - zlog_info("ospf_check_sum(): checksum mismatch, my %X, his %X", - ret, sum); + zlog_info("%s: checksum mismatch, my %X, his %X", __func__, ret, + sum); return 0; } @@ -3328,7 +3326,7 @@ static int ospf_make_hello(struct ospf_interface *oi, struct stream *s) stream_putw(s, 0); /* hello-interval of 0 for fast-hellos */ if (IS_DEBUG_OSPF_EVENT) - zlog_debug("make_hello: options: %x, int: %s", OPTIONS(oi), + zlog_debug("%s: options: %x, int: %s", __func__, OPTIONS(oi), IF_NAME(oi)); /* Set Options. */ @@ -3567,7 +3565,7 @@ static int ospf_make_ls_upd(struct ospf_interface *oi, struct list *update, int count = 0; if (IS_DEBUG_OSPF_EVENT) - zlog_debug("ospf_make_ls_upd: Start"); + zlog_debug("%s: Start", __func__); pp = stream_get_endp(s); stream_forward_endp(s, OSPF_LS_UPD_MIN_SIZE); @@ -3617,7 +3615,7 @@ static int ospf_make_ls_upd(struct ospf_interface *oi, struct list *update, stream_putl_at(s, pp, count); if (IS_DEBUG_OSPF_EVENT) - zlog_debug("ospf_make_ls_upd: Stop"); + zlog_debug("%s: Stop", __func__); return length; } @@ -3965,14 +3963,15 @@ static struct ospf_packet *ospf_ls_upd_packet_new(struct list *update, if (!warned) { flog_warn( EC_OSPF_LARGE_LSA, - "ospf_ls_upd_packet_new: oversized LSA encountered!will need to fragment. Not optimal. Try divide up your network with areas. Use 'debug ospf packet send' to see details, or look at 'show ip ospf database ..'"); + "%s: oversized LSA encountered!will need to fragment. Not optimal. Try divide up your network with areas. Use 'debug ospf packet send' to see details, or look at 'show ip ospf database ..'", + __func__); warned = 1; } if (IS_DEBUG_OSPF_PACKET(0, SEND)) zlog_debug( - "ospf_ls_upd_packet_new: oversized LSA id:%pI4, %d bytes originated by %pI4, will be fragmented!", - &lsa->data->id, + "%s: oversized LSA id:%pI4, %d bytes originated by %pI4, will be fragmented!", + __func__, &lsa->data->id, ntohs(lsa->data->length), &lsa->data->adv_router); @@ -3988,10 +3987,11 @@ static struct ospf_packet *ospf_ls_upd_packet_new(struct list *update, size = oi->ifp->mtu; if (size > OSPF_MAX_PACKET_SIZE) { - flog_warn(EC_OSPF_LARGE_LSA, - "ospf_ls_upd_packet_new: oversized LSA id:%pI4 too big, %d bytes, packet size %ld, dropping it completely. OSPF routing is broken!", - &lsa->data->id, ntohs(lsa->data->length), - (long int)size); + flog_warn( + EC_OSPF_LARGE_LSA, + "%s: oversized LSA id:%pI4 too big, %d bytes, packet size %ld, dropping it completely. OSPF routing is broken!", + __func__, &lsa->data->id, ntohs(lsa->data->length), + (long int)size); list_delete_node(update, ln); return NULL; } @@ -4097,7 +4097,7 @@ static void ospf_ls_upd_send_queue_event(struct thread *thread) oi->t_ls_upd_event = NULL; if (IS_DEBUG_OSPF_EVENT) - zlog_debug("ospf_ls_upd_send_queue start"); + zlog_debug("%s start", __func__); for (rn = route_top(oi->ls_upd_queue); rn; rn = rnext) { rnext = route_next(rn); @@ -4120,15 +4120,15 @@ static void ospf_ls_upd_send_queue_event(struct thread *thread) if (again != 0) { if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_ls_upd_send_queue: update lists not cleared, %d nodes to try again, raising new event", - again); + "%s: update lists not cleared, %d nodes to try again, raising new event", + __func__, again); oi->t_ls_upd_event = NULL; thread_add_event(master, ospf_ls_upd_send_queue_event, oi, 0, &oi->t_ls_upd_event); } if (IS_DEBUG_OSPF_EVENT) - zlog_debug("ospf_ls_upd_send_queue stop"); + zlog_debug("%s stop", __func__); } void ospf_ls_upd_send(struct ospf_neighbor *nbr, struct list *update, int flag, diff --git a/pimd/mtracebis_netlink.c b/pimd/mtracebis_netlink.c index fe2cb56a2..81e28f240 100644 --- a/pimd/mtracebis_netlink.c +++ b/pimd/mtracebis_netlink.c @@ -92,7 +92,7 @@ int rtnl_open_byproto(struct rtnl_handle *rth, unsigned subscriptions, rth->local.nl_family); return -1; } - rth->seq = time(NULL); + rth->seq = (uint32_t)time(NULL); return 0; } diff --git a/ripd/ripd.c b/ripd/ripd.c index 979818603..c3a9369a0 100644 --- a/ripd/ripd.c +++ b/ripd/ripd.c @@ -996,6 +996,7 @@ static size_t rip_auth_md5_ah_write(struct stream *s, struct rip_interface *ri, struct key *key) { size_t doff = 0; + static uint32_t seq = 0; assert(s && ri && ri->auth_type == RIP_AUTH_MD5); @@ -1028,7 +1029,7 @@ static size_t rip_auth_md5_ah_write(struct stream *s, struct rip_interface *ri, /* RFC2080: The value used in the sequence number is arbitrary, but two suggestions are the time of the message's creation or a simple message counter. */ - stream_putl(s, time(NULL)); + stream_putl(s, ++seq); /* Reserved field must be zero. */ stream_putl(s, 0); diff --git a/tests/topotests/bgp_clist/__init__.py b/tests/topotests/bgp_clist/__init__.py deleted file mode 100644 index e69de29bb..000000000 --- a/tests/topotests/bgp_clist/__init__.py +++ /dev/null diff --git a/tests/topotests/bgp_clist/r1/bgpd.conf b/tests/topotests/bgp_clist/r1/bgpd.conf deleted file mode 100644 index 68c5222e9..000000000 --- a/tests/topotests/bgp_clist/r1/bgpd.conf +++ /dev/null @@ -1,28 +0,0 @@ -router bgp 65001 - no bgp ebgp-requires-policy - neighbor 192.168.255.2 remote-as 65002 - neighbor 192.168.255.2 timers 3 10 - address-family ipv4 - redistribute connected route-map connected - neighbor 192.168.255.2 route-map r2 out - exit-address-family -! -ip prefix-list p1 seq 5 permit 172.16.255.253/32 -ip prefix-list p2 seq 5 permit 172.16.255.254/32 -! -bgp community-list standard OUT_AS_PERMIT seq 5 permit internet -bgp community-list standard OUT_AS_PERMIT seq 10 deny 4:1 -bgp community-list standard OUT_AS_PERMIT seq 20 permit 3:1 -! -route-map r2 permit 10 - match community OUT_AS_PERMIT - set community 123:123 additive -exit -! -route-map connected permit 10 - match ip address prefix-list p1 - set community 3:1 -route-map connected permit 20 - match ip address prefix-list p2 - set community 4:1 -exit diff --git a/tests/topotests/bgp_clist/r1/zebra.conf b/tests/topotests/bgp_clist/r1/zebra.conf deleted file mode 100644 index ae668d79e..000000000 --- a/tests/topotests/bgp_clist/r1/zebra.conf +++ /dev/null @@ -1,10 +0,0 @@ -! -interface lo - ip address 172.16.255.253/32 - ip address 172.16.255.254/32 -! -interface r1-eth0 - ip address 192.168.255.1/24 -! -ip forwarding -! diff --git a/tests/topotests/bgp_clist/r2/bgpd.conf b/tests/topotests/bgp_clist/r2/bgpd.conf deleted file mode 100644 index cdc0d217b..000000000 --- a/tests/topotests/bgp_clist/r2/bgpd.conf +++ /dev/null @@ -1,5 +0,0 @@ -router bgp 65002 - no bgp ebgp-requires-policy - neighbor 192.168.255.1 remote-as 65001 - neighbor 192.168.255.1 timers 3 10 -! diff --git a/tests/topotests/bgp_clist/r2/zebra.conf b/tests/topotests/bgp_clist/r2/zebra.conf deleted file mode 100644 index 606c17bec..000000000 --- a/tests/topotests/bgp_clist/r2/zebra.conf +++ /dev/null @@ -1,6 +0,0 @@ -! -interface r2-eth0 - ip address 192.168.255.2/24 -! -ip forwarding -! diff --git a/tests/topotests/bgp_clist/test_bgp_clist.py b/tests/topotests/bgp_clist/test_bgp_clist.py deleted file mode 100644 index 93825f441..000000000 --- a/tests/topotests/bgp_clist/test_bgp_clist.py +++ /dev/null @@ -1,114 +0,0 @@ -#!/usr/bin/env python - -# -# Copyright (c) 2022 by -# Donatas Abraitis <donatas@opensourcerouting.org> -# -# Permission to use, copy, modify, and/or distribute this software -# for any purpose with or without fee is hereby granted, provided -# that the above copyright notice and this permission notice appear -# in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND NETDEF DISCLAIMS ALL WARRANTIES -# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL NETDEF BE LIABLE FOR -# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY -# DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS -# ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE -# OF THIS SOFTWARE. -# - -""" -Test if basic BGP community-list filtering works correctly. -""" - -import os -import sys -import json -import pytest -import pytest -import functools - -CWD = os.path.dirname(os.path.realpath(__file__)) -sys.path.append(os.path.join(CWD, "../")) - -# pylint: disable=C0413 -from lib import topotest -from lib.topogen import Topogen, TopoRouter, get_topogen - -pytestmark = [pytest.mark.bgpd] - - -def build_topo(tgen): - for routern in range(1, 3): - tgen.add_router("r{}".format(routern)) - - switch = tgen.add_switch("s1") - switch.add_link(tgen.gears["r1"]) - switch.add_link(tgen.gears["r2"]) - - -def setup_module(mod): - tgen = Topogen(build_topo, mod.__name__) - tgen.start_topology() - - router_list = tgen.routers() - - for i, (rname, router) in enumerate(router_list.items(), 1): - router.load_config( - TopoRouter.RD_ZEBRA, os.path.join(CWD, "{}/zebra.conf".format(rname)) - ) - router.load_config( - TopoRouter.RD_BGP, os.path.join(CWD, "{}/bgpd.conf".format(rname)) - ) - - tgen.start_router() - - -def teardown_module(mod): - tgen = get_topogen() - tgen.stop_topology() - - -def test_bgp_clist(): - tgen = get_topogen() - - router = tgen.gears["r2"] - - if tgen.routers_have_failure(): - pytest.skip(tgen.errors) - - def _bgp_converge(): - output = json.loads(router.vtysh_cmd("show bgp summary json")) - expected = { - "ipv4Unicast": { - "peers": {"192.168.255.1": {"state": "Established", "pfxRcd": 1}} - } - } - return topotest.json_cmp(output, expected) - - test_func = functools.partial(_bgp_converge) - _, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5) - assert result is None, "BGP can't converge" - - def _bgp_clist_match(): - output = json.loads(router.vtysh_cmd("show bgp ipv4 unicast json detail")) - expected = { - "routes": { - "172.16.255.253/32": [ - {"valid": True, "community": {"string": "3:1 123:123"}} - ], - "172.16.255.254/32": None, - } - } - return topotest.json_cmp(output, expected) - - test_func = functools.partial(_bgp_clist_match) - _, result = topotest.run_and_expect(test_func, None, count=60, wait=0.5) - assert result is None, "BGP community-list filtering doesn't work" - - -if __name__ == "__main__": - args = ["-s"] + sys.argv[1:] - sys.exit(pytest.main(args)) diff --git a/zebra/zserv.c b/zebra/zserv.c index f76b29def..ebe246ffb 100644 --- a/zebra/zserv.c +++ b/zebra/zserv.c @@ -228,8 +228,7 @@ static void zserv_write(struct thread *thread) case BUFFER_ERROR: goto zwrite_fail; case BUFFER_PENDING: - atomic_store_explicit(&client->last_write_time, - (uint32_t)monotime(NULL), + atomic_store_explicit(&client->last_write_time, monotime(NULL), memory_order_relaxed); zserv_client_event(client, ZSERV_CLIENT_WRITE); return; @@ -264,8 +263,7 @@ static void zserv_write(struct thread *thread) case BUFFER_ERROR: goto zwrite_fail; case BUFFER_PENDING: - atomic_store_explicit(&client->last_write_time, - (uint32_t)monotime(NULL), + atomic_store_explicit(&client->last_write_time, monotime(NULL), memory_order_relaxed); zserv_client_event(client, ZSERV_CLIENT_WRITE); return; @@ -276,8 +274,8 @@ static void zserv_write(struct thread *thread) atomic_store_explicit(&client->last_write_cmd, wcmd, memory_order_relaxed); - atomic_store_explicit(&client->last_write_time, - (uint32_t)monotime(NULL), memory_order_relaxed); + atomic_store_explicit(&client->last_write_time, monotime(NULL), + memory_order_relaxed); return; @@ -748,7 +746,7 @@ static struct zserv *zserv_client_create(int sock) client->wb = buffer_new(0); TAILQ_INIT(&(client->gr_info_queue)); - atomic_store_explicit(&client->connect_time, (uint32_t) monotime(NULL), + atomic_store_explicit(&client->connect_time, monotime(NULL), memory_order_relaxed); /* Initialize flags */ diff --git a/zebra/zserv.h b/zebra/zserv.h index 9986cc9f7..db7b70d7c 100644 --- a/zebra/zserv.h +++ b/zebra/zserv.h @@ -216,15 +216,15 @@ struct zserv { */ /* monotime of client creation */ - _Atomic uint32_t connect_time; + _Atomic uint64_t connect_time; /* monotime of last message received */ - _Atomic uint32_t last_read_time; + _Atomic uint64_t last_read_time; /* monotime of last message sent */ - _Atomic uint32_t last_write_time; + _Atomic uint64_t last_write_time; /* command code of last message read */ - _Atomic uint32_t last_read_cmd; + _Atomic uint64_t last_read_cmd; /* command code of last message written */ - _Atomic uint32_t last_write_cmd; + _Atomic uint64_t last_write_cmd; /* * Number of instances configured with |