diff options
66 files changed, 671 insertions, 733 deletions
diff --git a/babeld/kernel.c b/babeld/kernel.c index 3941db8d5f..5aa01ceb44 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 5b1437ef3e..f39bc35bdb 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 cfbb29df1c..f62a54b03c 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 bc6d4e144e..34d4be8c93 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 9acbaf7733..664619078a 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 720925b20f..9f64341640 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 0642c966eb..ce05005eab 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 3f801f7ea0..95a0c31b55 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 6ba516c39c..4277162339 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 b570c84d8b..7b96555913 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 aba28fa504..7af1fae280 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 8772afd736..fa1dcf33e0 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 7b8f0df2e2..e99c2ba661 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 e1fcc743ec..971b1817c8 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 9d653ef4dc..efad906d0a 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 344608fda1..61f1b295ca 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 fe1887565e..7daac44946 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 04f955f97a..989b361597 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 e25d8d90db..6bc313464a 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 f1173941a0..3a974910fa 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 ab3a24770f..c56edac7f2 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -9591,10 +9591,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)) { @@ -12741,7 +12739,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; @@ -12769,7 +12767,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); @@ -12777,7 +12775,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); @@ -12785,7 +12783,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); @@ -14057,7 +14055,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 c17bd76ad7..036bbbd6b6 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 8348b37b8e..dc7ad32a50 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 2437bd8cfe..831f92996a 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 382886e0bd..a34c10d842 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 1d42702769..6fb509fd9c 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 bc0e192ae2..8c76e1dd0b 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 9d61ada7db..9e13c48134 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 c8fdadcac9..a8ab618417 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 e31bfe7bfa..e6c4076300 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/doc/user/pimv6.rst b/doc/user/pimv6.rst index 851e58b814..843734e217 100644 --- a/doc/user/pimv6.rst +++ b/doc/user/pimv6.rst @@ -195,7 +195,7 @@ is in a vrf, enter the interface command with the vrf keyword at the end. Set the MLD last member query count. The default value is 2. 'no' form of this command is used to configure back to the default value. -.. clicmd:: ipv6 MLD last-member-query-interval (1-65535) +.. clicmd:: ipv6 mld last-member-query-interval (1-65535) Set the MLD last member query interval in deciseconds. The default value is 10 deciseconds. 'no' form of this command is used to to configure back to the @@ -325,6 +325,9 @@ MLD state a MLDv2 querier. MLDv1 joins are recorded as "untracked" and shown in the ``NonTrkSeen`` output column. +.. clicmd:: show ipv6 mld [vrf NAME] groups [json] + + Display MLD group information. General multicast routing state ------------------------------- diff --git a/gdb/lib.txt b/gdb/lib.txt index 913b455ed1..b44c237985 100644 --- a/gdb/lib.txt +++ b/gdb/lib.txt @@ -293,3 +293,25 @@ Arguments: 1st: A (struct route_node *) to the top of the route table. 2nd: The (struct route_node *) to walk up from end + +define mq_walk + set $mg = (struct memgroup *)$arg0 + + while ($mg) + printf "showing active allocations in memory group %s\n", $mg->name + set $mt = (struct memtype *)$mg->types + while ($mt) + printf "memstats: %s:%zu\n", $mt->name, $mt->n_alloc + set $mt = $mt->next + end + set $mg = $mg->next + end + +document mg_walk +Walk the memory data structures to show what is holding memory. + +Arguments: +1st: A (struct memgroup *) where to start the walk. If you are not + sure where to start pass it mg_first, which is a global DS for + all memory allocated in FRR +end diff --git a/isisd/isis_adjacency.c b/isisd/isis_adjacency.c index 86cf10ae17..00763135e6 100644 --- a/isisd/isis_adjacency.c +++ b/isisd/isis_adjacency.c @@ -860,13 +860,13 @@ void isis_adj_build_neigh_list(struct list *adjdb, struct list *list) struct listnode *node; if (!list) { - zlog_warn("isis_adj_build_neigh_list(): NULL list"); + zlog_warn("%s: NULL list", __func__); return; } for (ALL_LIST_ELEMENTS_RO(adjdb, node, adj)) { if (!adj) { - zlog_warn("isis_adj_build_neigh_list(): NULL adj"); + zlog_warn("%s: NULL adj", __func__); return; } @@ -883,18 +883,18 @@ void isis_adj_build_up_list(struct list *adjdb, struct list *list) struct listnode *node; if (adjdb == NULL) { - zlog_warn("isis_adj_build_up_list(): adjacency DB is empty"); + zlog_warn("%s: adjacency DB is empty", __func__); return; } if (!list) { - zlog_warn("isis_adj_build_up_list(): NULL list"); + zlog_warn("%s: NULL list", __func__); return; } for (ALL_LIST_ELEMENTS_RO(adjdb, node, adj)) { if (!adj) { - zlog_warn("isis_adj_build_up_list(): NULL adj"); + zlog_warn("%s: NULL adj", __func__); return; } diff --git a/isisd/isis_bpf.c b/isisd/isis_bpf.c index 5f3d70ed3a..11f43279ec 100644 --- a/isisd/isis_bpf.c +++ b/isisd/isis_bpf.c @@ -165,7 +165,7 @@ static int open_bpf_dev(struct isis_circuit *circuit) bpf_prog.bf_len = 8; bpf_prog.bf_insns = &(llcfilter[0]); if (ioctl(fd, BIOCSETF, (caddr_t)&bpf_prog) < 0) { - zlog_warn("open_bpf_dev(): failed to install filter: %s", + zlog_warn("%s: failed to install filter: %s", __func__, safe_strerror(errno)); return ISIS_WARNING; } @@ -198,7 +198,7 @@ int isis_sock_init(struct isis_circuit *circuit) circuit->tx = isis_send_pdu_bcast; circuit->rx = isis_recv_pdu_bcast; } else { - zlog_warn("isis_sock_init(): unknown circuit type"); + zlog_warn("%s: unknown circuit type", __func__); retval = ISIS_WARNING; break; } @@ -223,8 +223,8 @@ int isis_recv_pdu_bcast(struct isis_circuit *circuit, uint8_t *ssnpa) bytesread = read(circuit->fd, readbuff, readblen); } if (bytesread < 0) { - zlog_warn("isis_recv_pdu_bcast(): read() failed: %s", - safe_strerror(errno)); + zlog_warn("%s: read() failed: %s", __func__, + safe_strerror(errno)); return ISIS_WARNING; } @@ -267,8 +267,9 @@ int isis_send_pdu_bcast(struct isis_circuit *circuit, int level) buflen = stream_get_endp(circuit->snd_stream) + LLC_LEN + ETHER_HDR_LEN; if (buflen > sizeof(sock_buff)) { zlog_warn( - "isis_send_pdu_bcast: sock_buff size %zu is less than output pdu size %zu on circuit %s", - sizeof(sock_buff), buflen, circuit->interface->name); + "%s: sock_buff size %zu is less than output pdu size %zu on circuit %s", + __func__, sizeof(sock_buff), buflen, + circuit->interface->name); return ISIS_WARNING; } diff --git a/isisd/isis_circuit.c b/isisd/isis_circuit.c index 9e97e48937..178fbe7903 100644 --- a/isisd/isis_circuit.c +++ b/isisd/isis_circuit.c @@ -513,7 +513,7 @@ void isis_circuit_if_add(struct isis_circuit *circuit, struct interface *ifp) } else { /* It's normal in case of loopback etc. */ if (IS_DEBUG_EVENTS) - zlog_debug("isis_circuit_if_add: unsupported media"); + zlog_debug("%s: unsupported media", __func__); circuit->circ_type = CIRCUIT_T_UNKNOWN; } @@ -678,10 +678,10 @@ int isis_circuit_up(struct isis_circuit *circuit) } #ifdef EXTREME_DEGUG if (IS_DEBUG_EVENTS) - zlog_debug( - "isis_circuit_if_add: if_id %d, isomtu %d snpa %s", - circuit->interface->ifindex, ISO_MTU(circuit), - snpa_print(circuit->u.bc.snpa)); + zlog_debug("%s: if_id %d, isomtu %d snpa %s", __func__, + circuit->interface->ifindex, + ISO_MTU(circuit), + snpa_print(circuit->u.bc.snpa)); #endif /* EXTREME_DEBUG */ circuit->u.bc.adjdb[0] = list_new(); diff --git a/isisd/isis_dlpi.c b/isisd/isis_dlpi.c index bb8c542597..f6ea0aea60 100644 --- a/isisd/isis_dlpi.c +++ b/isisd/isis_dlpi.c @@ -336,9 +336,8 @@ static int open_dlpi_dev(struct isis_circuit *circuit) /* Double check the DLPI style */ if (dia->dl_provider_style != DL_STYLE2) { - zlog_warn( - "open_dlpi_dev(): interface %s: %s is not style 2", - circuit->interface->name, devpath); + zlog_warn("%s: interface %s: %s is not style 2", + __func__, circuit->interface->name, devpath); close(fd); return ISIS_WARNING; } @@ -355,9 +354,8 @@ static int open_dlpi_dev(struct isis_circuit *circuit) } else { /* Double check the DLPI style */ if (dia->dl_provider_style != DL_STYLE1) { - zlog_warn( - "open_dlpi_dev(): interface %s: %s is not style 1", - circuit->interface->name, devpath); + zlog_warn("%s: interface %s: %s is not style 1", + __func__, circuit->interface->name, devpath); close(fd); return ISIS_WARNING; } @@ -404,9 +402,8 @@ static int open_dlpi_dev(struct isis_circuit *circuit) * so we need to be careful and use DL_PHYS_ADDR_REQ instead. */ if (dlpiaddr(fd, circuit->u.bc.snpa) == -1) { - zlog_warn( - "open_dlpi_dev(): interface %s: unable to get MAC address", - circuit->interface->name); + zlog_warn("%s: interface %s: unable to get MAC address", + __func__, circuit->interface->name); close(fd); return ISIS_WARNING; } @@ -479,7 +476,7 @@ int isis_sock_init(struct isis_circuit *circuit) circuit->tx = isis_send_pdu_bcast; circuit->rx = isis_recv_pdu_bcast; } else { - zlog_warn("isis_sock_init(): unknown circuit type"); + zlog_warn("%s: unknown circuit type", __func__); retval = ISIS_WARNING; break; } @@ -511,7 +508,7 @@ int isis_recv_pdu_bcast(struct isis_circuit *circuit, uint8_t *ssnpa) retv = getmsg(circuit->fd, &ctlbuf, &databuf, &flags); if (retv < 0) { - zlog_warn("isis_recv_pdu_bcast: getmsg failed: %s", + zlog_warn("%s: getmsg failed: %s", __func__, safe_strerror(errno)); return ISIS_WARNING; } @@ -561,8 +558,9 @@ int isis_send_pdu_bcast(struct isis_circuit *circuit, int level) buflen = stream_get_endp(circuit->snd_stream) + LLC_LEN; if ((size_t)buflen > sizeof(sock_buff)) { zlog_warn( - "isis_send_pdu_bcast: sock_buff size %zu is less than output pdu size %d on circuit %s", - sizeof(sock_buff), buflen, circuit->interface->name); + "%s: sock_buff size %zu is less than output pdu size %d on circuit %s", + __func__, sizeof(sock_buff), buflen, + circuit->interface->name); return ISIS_WARNING; } diff --git a/isisd/isis_dr.c b/isisd/isis_dr.c index b9bf49867d..400982f2fc 100644 --- a/isisd/isis_dr.c +++ b/isisd/isis_dr.c @@ -80,7 +80,8 @@ void isis_run_dr(struct thread *thread) } if (circuit->u.bc.run_dr_elect[level - 1]) - zlog_warn("isis_run_dr(): run_dr_elect already set for l%d", level); + zlog_warn("%s: run_dr_elect already set for l%d", __func__, + level); circuit->u.bc.t_run_dr[level - 1] = NULL; circuit->u.bc.run_dr_elect[level - 1] = 1; @@ -126,7 +127,7 @@ int isis_dr_elect(struct isis_circuit *circuit, int level) adjdb = circuit->u.bc.adjdb[level - 1]; if (!adjdb) { - zlog_warn("isis_dr_elect() adjdb == NULL"); + zlog_warn("%s adjdb == NULL", __func__); list_delete(&list); return ISIS_WARNING; } @@ -155,7 +156,8 @@ int isis_dr_elect(struct isis_circuit *circuit, int level) } if (cmp_res == 0) zlog_warn( - "isis_dr_elect(): multiple adjacencies with same SNPA"); + "%s: multiple adjacencies with same SNPA", + __func__); } else { adj_dr = adj; } @@ -218,7 +220,7 @@ int isis_dr_resign(struct isis_circuit *circuit, int level) uint8_t id[ISIS_SYS_ID_LEN + 2]; if (IS_DEBUG_EVENTS) - zlog_debug("isis_dr_resign l%d", level); + zlog_debug("%s l%d", __func__, level); circuit->u.bc.is_dr[level - 1] = 0; circuit->u.bc.run_dr_elect[level - 1] = 0; @@ -266,7 +268,7 @@ int isis_dr_commence(struct isis_circuit *circuit, int level) uint8_t old_dr[ISIS_SYS_ID_LEN + 2]; if (IS_DEBUG_EVENTS) - zlog_debug("isis_dr_commence l%d", level); + zlog_debug("%s l%d", __func__, level); /* Lets keep a pause in DR election */ circuit->u.bc.run_dr_elect[level - 1] = 0; diff --git a/lib/sigevent.c b/lib/sigevent.c index 0f20bc0270..985bedeb92 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_ase.c b/ospfd/ospf_ase.c index 23c7a1e706..706a22e9bf 100644 --- a/ospfd/ospf_ase.c +++ b/ospfd/ospf_ase.c @@ -212,12 +212,12 @@ int ospf_ase_calculate_route(struct ospf *ospf, struct ospf_lsa *lsa) if (lsa->data->type == OSPF_AS_NSSA_LSA) if (IS_DEBUG_OSPF_NSSA) - zlog_debug("ospf_ase_calc(): Processing Type-7"); + zlog_debug("%s: Processing Type-7", __func__); /* Stay away from any Local Translated Type-7 LSAs */ if (CHECK_FLAG(lsa->flags, OSPF_LSA_LOCAL_XLT)) { if (IS_DEBUG_OSPF_NSSA) - zlog_debug("ospf_ase_calc(): Rejecting Local Xlt'd"); + zlog_debug("%s: Rejecting Local Xlt'd", __func__); return 0; } @@ -589,9 +589,8 @@ static void ospf_ase_calculate_timer(struct thread *t) if (ospf->anyNSSA) for (ALL_LIST_ELEMENTS_RO(ospf->areas, node, area)) { if (IS_DEBUG_OSPF_NSSA) - zlog_debug( - "ospf_ase_calculate_timer(): looking at area %pI4", - &area->area_id); + zlog_debug("%s: looking at area %pI4", + __func__, &area->area_id); if (area->external_routing == OSPF_AREA_NSSA) LSDB_LOOP (NSSA_LSDB(area), rn, lsa) diff --git a/ospfd/ospf_flood.c b/ospfd/ospf_flood.c index fb3fb21e08..e686a93ba9 100644 --- a/ospfd/ospf_flood.c +++ b/ospfd/ospf_flood.c @@ -804,8 +804,7 @@ int ospf_flood_through(struct ospf *ospf, struct ospf_neighbor *inbr, /* Any P-bit was installed with the Type-7. */ if (IS_DEBUG_OSPF_NSSA) - zlog_debug( - "ospf_flood_through: LOCAL NSSA FLOOD of Type-7."); + zlog_debug("%s: LOCAL NSSA FLOOD of Type-7.", __func__); /* Fallthrough */ default: lsa_ack_flag = ospf_flood_through_area(lsa->area, inbr, lsa); diff --git a/ospfd/ospf_lsa.c b/ospfd/ospf_lsa.c index af05f5b59e..278f263da3 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_opaque.c b/ospfd/ospf_opaque.c index c7ac81d961..261d69df33 100644 --- a/ospfd/ospf_opaque.c +++ b/ospfd/ospf_opaque.c @@ -358,9 +358,8 @@ static struct list *ospf_get_opaque_funclist(uint8_t lsa_type) funclist = ospf_opaque_type11_funclist; break; default: - flog_warn(EC_OSPF_LSA_UNEXPECTED, - "ospf_get_opaque_funclist: Unexpected LSA-type(%u)", - lsa_type); + flog_warn(EC_OSPF_LSA_UNEXPECTED, "%s: Unexpected LSA-type(%u)", + __func__, lsa_type); break; } return funclist; @@ -396,8 +395,8 @@ int ospf_register_opaque_functab( if (functab->opaque_type == opaque_type) { flog_warn( EC_OSPF_LSA, - "ospf_register_opaque_functab: Duplicated entry?: lsa_type(%u), opaque_type(%u)", - lsa_type, opaque_type); + "%s: Duplicated entry?: lsa_type(%u), opaque_type(%u)", + __func__, lsa_type, opaque_type); return -1; } @@ -565,10 +564,8 @@ register_opaque_info_per_type(struct ospf_opaque_functab *functab, listnode_add(top->opaque_lsa_self, oipt); break; default: - flog_warn( - EC_OSPF_LSA_UNEXPECTED, - "register_opaque_info_per_type: Unexpected LSA-type(%u)", - new->data->type); + flog_warn(EC_OSPF_LSA_UNEXPECTED, "%s: Unexpected LSA-type(%u)", + __func__, new->data->type); free_opaque_info_per_type(oipt, true); oipt = NULL; goto out; /* This case may not exist. */ @@ -675,9 +672,8 @@ lookup_opaque_info_by_type(struct ospf_lsa *lsa) listtop = top->opaque_lsa_self; break; default: - flog_warn(EC_OSPF_LSA_UNEXPECTED, - "lookup_opaque_info_by_type: Unexpected LSA-type(%u)", - lsa->data->type); + flog_warn(EC_OSPF_LSA_UNEXPECTED, "%s: Unexpected LSA-type(%u)", + __func__, lsa->data->type); break; } @@ -1303,16 +1299,14 @@ void ospf_opaque_lsa_originate_schedule(struct ospf_interface *oi, int *delay0) if ((top = oi_to_top(oi)) == NULL || (area = oi->area) == NULL) { if (IS_DEBUG_OSPF_EVENT) - zlog_debug( - "ospf_opaque_lsa_originate_schedule: Invalid argument?"); + zlog_debug("%s: Invalid argument?", __func__); return; } /* It may not a right time to schedule origination now. */ if (!CHECK_FLAG(top->opaque, OPAQUE_OPERATION_READY_BIT)) { if (IS_DEBUG_OSPF_EVENT) - zlog_debug( - "ospf_opaque_lsa_originate_schedule: Not operational."); + zlog_debug("%s: Not operational.", __func__); return; /* This is not an error. */ } @@ -1529,10 +1523,8 @@ static void ospf_opaque_lsa_reoriginate_resume(struct list *listtop, void *arg) continue; if ((*functab->lsa_originator)(arg) != 0) { - flog_warn( - EC_OSPF_LSA, - "ospf_opaque_lsa_reoriginate_resume: Failed (opaque-type=%u)", - oipt->opaque_type); + flog_warn(EC_OSPF_LSA, "%s: Failed (opaque-type=%u)", + __func__, oipt->opaque_type); continue; } } @@ -1570,8 +1562,7 @@ struct ospf_lsa *ospf_opaque_lsa_install(struct ospf_lsa *lsa, int rt_recalc) } /* Register the new lsa entry */ else if (register_opaque_lsa(lsa) == NULL) { - flog_warn(EC_OSPF_LSA, - "ospf_opaque_lsa_install: register_opaque_lsa() ?"); + flog_warn(EC_OSPF_LSA, "%s: register_opaque_lsa() ?", __func__); goto out; } @@ -1583,16 +1574,16 @@ struct ospf_lsa *ospf_opaque_lsa_install(struct ospf_lsa *lsa, int rt_recalc) case OSPF_OPAQUE_LINK_LSA: if ((top = oi_to_top(lsa->oi)) == NULL) { /* Above conditions must have passed. */ - flog_warn(EC_OSPF_LSA, - "ospf_opaque_lsa_install: Something wrong?"); + flog_warn(EC_OSPF_LSA, "%s: Something wrong?", + __func__); goto out; } break; case OSPF_OPAQUE_AREA_LSA: if (lsa->area == NULL || (top = lsa->area->ospf) == NULL) { /* Above conditions must have passed. */ - flog_warn(EC_OSPF_LSA, - "ospf_opaque_lsa_install: Something wrong?"); + flog_warn(EC_OSPF_LSA, "%s: Something wrong?", + __func__); goto out; } break; @@ -1600,15 +1591,14 @@ struct ospf_lsa *ospf_opaque_lsa_install(struct ospf_lsa *lsa, int rt_recalc) top = ospf_lookup_by_vrf_id(lsa->vrf_id); if (lsa->area != NULL && (top = lsa->area->ospf) == NULL) { /* Above conditions must have passed. */ - flog_warn(EC_OSPF_LSA, - "ospf_opaque_lsa_install: Something wrong?"); + flog_warn(EC_OSPF_LSA, "%s: Something wrong?", + __func__); goto out; } break; default: - flog_warn(EC_OSPF_LSA_UNEXPECTED, - "ospf_opaque_lsa_install: Unexpected LSA-type(%u)", - lsa->data->type); + flog_warn(EC_OSPF_LSA_UNEXPECTED, "%s: Unexpected LSA-type(%u)", + __func__, lsa->data->type); goto out; } @@ -1679,16 +1669,14 @@ void ospf_opaque_lsa_reoriginate_schedule(void *lsa_type_dependent, case OSPF_OPAQUE_LINK_LSA: if ((oi = (struct ospf_interface *)lsa_type_dependent) == NULL) { - flog_warn( - EC_OSPF_LSA, - "ospf_opaque_lsa_reoriginate_schedule: Type-9 Opaque-LSA: Invalid parameter?"); + flog_warn(EC_OSPF_LSA, + "%s: Type-9 Opaque-LSA: Invalid parameter?", + __func__); goto out; } if ((top = oi_to_top(oi)) == NULL) { - flog_warn( - EC_OSPF_LSA, - "ospf_opaque_lsa_reoriginate_schedule: OI(%s) -> TOP?", - IF_NAME(oi)); + flog_warn(EC_OSPF_LSA, "%s: OI(%s) -> TOP?", __func__, + IF_NAME(oi)); goto out; } if (!list_isempty(ospf_opaque_type9_funclist) @@ -1704,16 +1692,14 @@ void ospf_opaque_lsa_reoriginate_schedule(void *lsa_type_dependent, break; case OSPF_OPAQUE_AREA_LSA: if ((area = (struct ospf_area *)lsa_type_dependent) == NULL) { - flog_warn( - EC_OSPF_LSA, - "ospf_opaque_lsa_reoriginate_schedule: Type-10 Opaque-LSA: Invalid parameter?"); + flog_warn(EC_OSPF_LSA, + "%s: Type-10 Opaque-LSA: Invalid parameter?", + __func__); goto out; } if ((top = area->ospf) == NULL) { - flog_warn( - EC_OSPF_LSA, - "ospf_opaque_lsa_reoriginate_schedule: AREA(%pI4) -> TOP?", - &area->area_id); + flog_warn(EC_OSPF_LSA, "%s: AREA(%pI4) -> TOP?", + __func__, &area->area_id); goto out; } if (!list_isempty(ospf_opaque_type10_funclist) @@ -1729,9 +1715,9 @@ void ospf_opaque_lsa_reoriginate_schedule(void *lsa_type_dependent, break; case OSPF_OPAQUE_AS_LSA: if ((top = (struct ospf *)lsa_type_dependent) == NULL) { - flog_warn( - EC_OSPF_LSA, - "ospf_opaque_lsa_reoriginate_schedule: Type-11 Opaque-LSA: Invalid parameter?"); + flog_warn(EC_OSPF_LSA, + "%s: Type-11 Opaque-LSA: Invalid parameter?", + __func__); goto out; } if (!list_isempty(ospf_opaque_type11_funclist) @@ -1751,18 +1737,15 @@ void ospf_opaque_lsa_reoriginate_schedule(void *lsa_type_dependent, func = ospf_opaque_type11_lsa_reoriginate_timer; break; default: - flog_warn( - EC_OSPF_LSA_UNEXPECTED, - "ospf_opaque_lsa_reoriginate_schedule: Unexpected LSA-type(%u)", - lsa_type); + flog_warn(EC_OSPF_LSA_UNEXPECTED, "%s: Unexpected LSA-type(%u)", + __func__, lsa_type); goto out; } /* It may not a right time to schedule reorigination now. */ if (!CHECK_FLAG(top->opaque, OPAQUE_OPERATION_READY_BIT)) { if (IS_DEBUG_OSPF_EVENT) - zlog_debug( - "ospf_opaque_lsa_reoriginate_schedule: Not operational."); + zlog_debug("%s: Not operational.", __func__); goto out; /* This is not an error. */ } @@ -1775,16 +1758,16 @@ void ospf_opaque_lsa_reoriginate_schedule(void *lsa_type_dependent, if ((functab = ospf_opaque_functab_lookup(lsa)) == NULL) { flog_warn( EC_OSPF_LSA, - "ospf_opaque_lsa_reoriginate_schedule: No associated function?: lsa_type(%u), opaque_type(%u)", - lsa_type, opaque_type); + "%s: No associated function?: lsa_type(%u), opaque_type(%u)", + __func__, lsa_type, opaque_type); goto out; } if ((oipt = register_opaque_info_per_type(functab, lsa)) == NULL) { flog_warn( EC_OSPF_LSA, - "ospf_opaque_lsa_reoriginate_schedule: Cannot get a control info?: lsa_type(%u), opaque_type(%u)", - lsa_type, opaque_type); + "%s: Cannot get a control info?: lsa_type(%u), opaque_type(%u)", + __func__, lsa_type, opaque_type); goto out; } } @@ -1850,17 +1833,13 @@ static void ospf_opaque_type9_lsa_reoriginate_timer(struct thread *t) if ((functab = oipt->functab) == NULL || functab->lsa_originator == NULL) { - flog_warn( - EC_OSPF_LSA, - "ospf_opaque_type9_lsa_reoriginate_timer: No associated function?"); + flog_warn(EC_OSPF_LSA, "%s: No associated function?", __func__); return; } oi = (struct ospf_interface *)oipt->owner; if ((top = oi_to_top(oi)) == NULL) { - flog_warn( - EC_OSPF_LSA, - "ospf_opaque_type9_lsa_reoriginate_timer: Something wrong?"); + flog_warn(EC_OSPF_LSA, "%s: Something wrong?", __func__); return; } @@ -1898,17 +1877,13 @@ static void ospf_opaque_type10_lsa_reoriginate_timer(struct thread *t) if ((functab = oipt->functab) == NULL || functab->lsa_originator == NULL) { - flog_warn( - EC_OSPF_LSA, - "ospf_opaque_type10_lsa_reoriginate_timer: No associated function?"); + flog_warn(EC_OSPF_LSA, "%s: No associated function?", __func__); return; } area = (struct ospf_area *)oipt->owner; if (area == NULL || (top = area->ospf) == NULL) { - flog_warn( - EC_OSPF_LSA, - "ospf_opaque_type10_lsa_reoriginate_timer: Something wrong?"); + flog_warn(EC_OSPF_LSA, "%s: Something wrong?", __func__); return; } @@ -1947,16 +1922,12 @@ static void ospf_opaque_type11_lsa_reoriginate_timer(struct thread *t) if ((functab = oipt->functab) == NULL || functab->lsa_originator == NULL) { - flog_warn( - EC_OSPF_LSA, - "ospf_opaque_type11_lsa_reoriginate_timer: No associated function?"); + flog_warn(EC_OSPF_LSA, "%s: No associated function?", __func__); return; } if ((top = (struct ospf *)oipt->owner) == NULL) { - flog_warn( - EC_OSPF_LSA, - "ospf_opaque_type11_lsa_reoriginate_timer: Something wrong?"); + flog_warn(EC_OSPF_LSA, "%s: Something wrong?", __func__); return; } @@ -1988,16 +1959,13 @@ void ospf_opaque_lsa_refresh_schedule(struct ospf_lsa *lsa0) if ((oipt = lookup_opaque_info_by_type(lsa0)) == NULL || (oipi = lookup_opaque_info_by_id(oipt, lsa0)) == NULL) { - flog_warn( - EC_OSPF_LSA, - "ospf_opaque_lsa_refresh_schedule: Invalid parameter?"); + flog_warn(EC_OSPF_LSA, "%s: Invalid parameter?", __func__); goto out; } /* Given "lsa0" and current "oipi->lsa" may different, but harmless. */ if ((lsa = oipi->lsa) == NULL) { - flog_warn(EC_OSPF_LSA, - "ospf_opaque_lsa_refresh_schedule: Something wrong?"); + flog_warn(EC_OSPF_LSA, "%s: Something wrong?", __func__); goto out; } @@ -2024,10 +1992,8 @@ void ospf_opaque_lsa_refresh_schedule(struct ospf_lsa *lsa0) ospf_ls_retransmit_delete_nbr_as(top, lsa); break; default: - flog_warn( - EC_OSPF_LSA_UNEXPECTED, - "ospf_opaque_lsa_refresh_schedule: Unexpected LSA-type(%u)", - lsa->data->type); + flog_warn(EC_OSPF_LSA_UNEXPECTED, "%s: Unexpected LSA-type(%u)", + __func__, lsa->data->type); goto out; } @@ -2074,15 +2040,13 @@ void ospf_opaque_lsa_flush_schedule(struct ospf_lsa *lsa0) if ((oipt = lookup_opaque_info_by_type(lsa0)) == NULL || (oipi = lookup_opaque_info_by_id(oipt, lsa0)) == NULL) { - flog_warn(EC_OSPF_LSA, - "ospf_opaque_lsa_flush_schedule: Invalid parameter?"); + flog_warn(EC_OSPF_LSA, "%s: Invalid parameter?", __func__); goto out; } /* Given "lsa0" and current "oipi->lsa" may different, but harmless. */ if ((lsa = oipi->lsa) == NULL) { - flog_warn(EC_OSPF_LSA, - "ospf_opaque_lsa_flush_schedule: Something wrong?"); + flog_warn(EC_OSPF_LSA, "%s: Something wrong?", __func__); goto out; } @@ -2098,10 +2062,8 @@ void ospf_opaque_lsa_flush_schedule(struct ospf_lsa *lsa0) ospf_ls_retransmit_delete_nbr_as(top, lsa); break; default: - flog_warn( - EC_OSPF_LSA_UNEXPECTED, - "ospf_opaque_lsa_flush_schedule: Unexpected LSA-type(%u)", - lsa->data->type); + flog_warn(EC_OSPF_LSA_UNEXPECTED, "%s: Unexpected LSA-type(%u)", + __func__, lsa->data->type); goto out; } @@ -2154,10 +2116,8 @@ void ospf_opaque_self_originated_lsa_received(struct ospf_neighbor *nbr, ospf_flood_through_as(top, NULL /*inbr*/, lsa); break; default: - flog_warn( - EC_OSPF_LSA_UNEXPECTED, - "ospf_opaque_self_originated_lsa_received: Unexpected LSA-type(%u)", - lsa->data->type); + flog_warn(EC_OSPF_LSA_UNEXPECTED, "%s: Unexpected LSA-type(%u)", + __func__, lsa->data->type); return; } ospf_lsa_discard(lsa); /* List "lsas" will be deleted by caller. */ diff --git a/ospfd/ospf_packet.c b/ospfd/ospf_packet.c index c5e26fa371..57643f637e 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/ospfd/ospf_route.c b/ospfd/ospf_route.c index c5b26bbd76..6360d8ec60 100644 --- a/ospfd/ospf_route.c +++ b/ospfd/ospf_route.c @@ -371,13 +371,12 @@ void ospf_intra_add_router(struct route_table *rt, struct vertex *v, struct router_lsa *lsa; if (IS_DEBUG_OSPF_EVENT) - zlog_debug("ospf_intra_add_router: Start"); + zlog_debug("%s: Start", __func__); lsa = (struct router_lsa *)v->lsa; if (IS_DEBUG_OSPF_EVENT) - zlog_debug("ospf_intra_add_router: LS ID: %pI4", - &lsa->header.id); + zlog_debug("%s: LS ID: %pI4", __func__, &lsa->header.id); if (!OSPF_IS_AREA_BACKBONE(area)) ospf_vl_up_check(area, lsa->header.id, v); @@ -392,7 +391,8 @@ void ospf_intra_add_router(struct route_table *rt, struct vertex *v, !IS_ROUTER_LSA_EXTERNAL(lsa)) { if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_intra_add_router: this router is neither ASBR nor ABR, skipping it"); + "%s: this router is neither ASBR nor ABR, skipping it", + __func__); return; } @@ -434,7 +434,7 @@ void ospf_intra_add_router(struct route_table *rt, struct vertex *v, apply_mask_ipv4(&p); if (IS_DEBUG_OSPF_EVENT) - zlog_debug("ospf_intra_add_router: talking about %pFX", &p); + zlog_debug("%s: talking about %pFX", __func__, &p); rn = route_node_get(rt, (struct prefix *)&p); @@ -449,7 +449,7 @@ void ospf_intra_add_router(struct route_table *rt, struct vertex *v, listnode_add(rn->info, or); if (IS_DEBUG_OSPF_EVENT) - zlog_debug("ospf_intra_add_router: Stop"); + zlog_debug("%s: Stop", __func__); } /* RFC2328 16.1. (4). For transit network. */ @@ -526,7 +526,7 @@ void ospf_intra_add_stub(struct route_table *rt, struct router_lsa_link *link, struct ospf_path *path; if (IS_DEBUG_OSPF_EVENT) - zlog_debug("ospf_intra_add_stub(): Start"); + zlog_debug("%s: Start", __func__); lsa = (struct router_lsa *)v->lsa; @@ -536,8 +536,7 @@ void ospf_intra_add_stub(struct route_table *rt, struct router_lsa_link *link, apply_mask_ipv4(&p); if (IS_DEBUG_OSPF_EVENT) - zlog_debug("ospf_intra_add_stub(): processing route to %pFX", - &p); + zlog_debug("%s: processing route to %pFX", __func__, &p); /* (1) Calculate the distance D of stub network from the root. D is equal to the distance from the root to the router vertex @@ -546,9 +545,8 @@ void ospf_intra_add_stub(struct route_table *rt, struct router_lsa_link *link, cost = v->distance + ntohs(link->m[0].metric); if (IS_DEBUG_OSPF_EVENT) - zlog_debug( - "ospf_intra_add_stub(): calculated cost is %d + %d = %d", - v->distance, ntohs(link->m[0].metric), cost); + zlog_debug("%s: calculated cost is %d + %d = %d", __func__, + v->distance, ntohs(link->m[0].metric), cost); /* PtP links with /32 masks adds host routes to remote, directly * connected hosts, see RFC 2328, 12.4.1.1, Option 1. @@ -574,8 +572,8 @@ void ospf_intra_add_stub(struct route_table *rt, struct router_lsa_link *link, if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_intra_add_stub(): another route to the same prefix found with cost %u", - cur_or->cost); + "%s: another route to the same prefix found with cost %u", + __func__, cur_or->cost); /* Compare this distance to the current best cost to the stub network. This is done by looking up the stub network's @@ -584,8 +582,8 @@ void ospf_intra_add_stub(struct route_table *rt, struct router_lsa_link *link, LSA. */ if (cost > cur_or->cost) { if (IS_DEBUG_OSPF_EVENT) - zlog_debug( - "ospf_intra_add_stub(): old route is better, exit"); + zlog_debug("%s: old route is better, exit", + __func__); return; } @@ -604,8 +602,8 @@ void ospf_intra_add_stub(struct route_table *rt, struct router_lsa_link *link, if (cost == cur_or->cost) { if (IS_DEBUG_OSPF_EVENT) - zlog_debug( - "ospf_intra_add_stub(): routes are equal, merge"); + zlog_debug("%s: routes are equal, merge", + __func__); ospf_route_copy_nexthops_from_vertex(area, cur_or, v); @@ -625,8 +623,8 @@ void ospf_intra_add_stub(struct route_table *rt, struct router_lsa_link *link, if (cost < cur_or->cost) { if (IS_DEBUG_OSPF_EVENT) - zlog_debug( - "ospf_intra_add_stub(): new route is better, set it"); + zlog_debug("%s: new route is better, set it", + __func__); cur_or->cost = cost; @@ -640,7 +638,7 @@ void ospf_intra_add_stub(struct route_table *rt, struct router_lsa_link *link, } if (IS_DEBUG_OSPF_EVENT) - zlog_debug("ospf_intra_add_stub(): installing new route"); + zlog_debug("%s: installing new route", __func__); or = ospf_route_new(); @@ -655,13 +653,13 @@ void ospf_intra_add_stub(struct route_table *rt, struct router_lsa_link *link, /* Nexthop is depend on connection type. */ if (v != area->spf) { if (IS_DEBUG_OSPF_EVENT) - zlog_debug( - "ospf_intra_add_stub(): this network is on remote router"); + zlog_debug("%s: this network is on remote router", + __func__); ospf_route_copy_nexthops_from_vertex(area, or, v); } else { if (IS_DEBUG_OSPF_EVENT) - zlog_debug( - "ospf_intra_add_stub(): this network is on this router"); + zlog_debug("%s: this network is on this router", + __func__); /* * Only deal with interface data when we @@ -672,9 +670,8 @@ void ospf_intra_add_stub(struct route_table *rt, struct router_lsa_link *link, if (oi || area->spf_dry_run) { if (IS_DEBUG_OSPF_EVENT) - zlog_debug( - "ospf_intra_add_stub(): the lsa pos is %d", - lsa_pos); + zlog_debug("%s: the lsa pos is %d", __func__, + lsa_pos); path = ospf_path_new(); path->nexthop.s_addr = INADDR_ANY; @@ -689,15 +686,15 @@ void ospf_intra_add_stub(struct route_table *rt, struct router_lsa_link *link, listnode_add(or->paths, path); } else { if (IS_DEBUG_OSPF_EVENT) - zlog_debug( - "ospf_intra_add_stub(): where's the interface ?"); + zlog_debug("%s: where's the interface ?", + __func__); } } rn->info = or ; if (IS_DEBUG_OSPF_EVENT) - zlog_debug("ospf_intra_add_stub(): Stop"); + zlog_debug("%s: Stop", __func__); } static const char *const ospf_path_type_str[] = { @@ -931,7 +928,7 @@ void ospf_route_add(struct route_table *rt, struct prefix_ipv4 *p, if (rn->info) { if (IS_DEBUG_OSPF_EVENT) - zlog_debug("ospf_route_add(): something's wrong !"); + zlog_debug("%s: something's wrong !", __func__); route_unlock_node(rn); return; } @@ -1016,8 +1013,7 @@ int ospf_add_discard_route(struct ospf *ospf, struct route_table *rt, if (rn == NULL) { if (IS_DEBUG_OSPF_EVENT) - zlog_debug( - "ospf_add_discard_route(): router installation error"); + zlog_debug("%s: router installation error", __func__); return 0; } @@ -1029,15 +1025,16 @@ int ospf_add_discard_route(struct ospf *ospf, struct route_table *rt, if (or->path_type == OSPF_PATH_INTRA_AREA) { if (IS_DEBUG_OSPF_EVENT) - zlog_debug( - "ospf_add_discard_route(): an intra-area route exists"); + zlog_debug("%s: an intra-area route exists", + __func__); return 0; } if (or->type == OSPF_DESTINATION_DISCARD) { if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_add_discard_route(): discard entry already installed"); + "%s: discard entry already installed", + __func__); return 0; } @@ -1045,7 +1042,7 @@ int ospf_add_discard_route(struct ospf *ospf, struct route_table *rt, } if (IS_DEBUG_OSPF_EVENT) - zlog_debug("ospf_add_discard_route(): adding %pFX", p); + zlog_debug("%s: adding %pFX", __func__, p); new_or = ospf_route_new(); new_or->type = OSPF_DESTINATION_DISCARD; @@ -1068,14 +1065,13 @@ void ospf_delete_discard_route(struct ospf *ospf, struct route_table *rt, struct ospf_route * or ; if (IS_DEBUG_OSPF_EVENT) - zlog_debug("ospf_delete_discard_route(): deleting %pFX", p); + zlog_debug("%s: deleting %pFX", __func__, p); rn = route_node_lookup(rt, (struct prefix *)p); if (rn == NULL) { if (IS_DEBUG_OSPF_EVENT) - zlog_debug( - "ospf_delete_discard_route(): no route found"); + zlog_debug("%s: no route found", __func__); return; } @@ -1083,15 +1079,13 @@ void ospf_delete_discard_route(struct ospf *ospf, struct route_table *rt, if (or->path_type == OSPF_PATH_INTRA_AREA) { if (IS_DEBUG_OSPF_EVENT) - zlog_debug( - "ospf_delete_discard_route(): an intra-area route exists"); + zlog_debug("%s: an intra-area route exists", __func__); return; } if (or->type != OSPF_DESTINATION_DISCARD) { if (IS_DEBUG_OSPF_EVENT) - zlog_debug( - "ospf_delete_discard_route(): not a discard entry"); + zlog_debug("%s: not a discard entry", __func__); return; } diff --git a/ospfd/ospf_spf.c b/ospfd/ospf_spf.c index 74a5674273..46492ff6b0 100644 --- a/ospfd/ospf_spf.c +++ b/ospfd/ospf_spf.c @@ -799,7 +799,7 @@ static unsigned int ospf_nexthop_calculation(struct ospf_area *area, unsigned int added = 0; if (IS_DEBUG_OSPF_EVENT) { - zlog_debug("ospf_nexthop_calculation(): Start"); + zlog_debug("%s: Start", __func__); ospf_vertex_dump("V (parent):", v, 1, 1); ospf_vertex_dump("W (dest) :", w, 1, 1); zlog_debug("V->W distance: %d", distance); @@ -1021,7 +1021,8 @@ static unsigned int ospf_nexthop_calculation(struct ospf_area *area, return 1; } else zlog_info( - "ospf_nexthop_calculation(): vl_data for VL link not found"); + "%s: vl_data for VL link not found", + __func__); } /* end virtual-link from V to W */ return 0; } /* end W is a Router vertex */ @@ -1569,7 +1570,7 @@ static void ospf_spf_process_stubs(struct ospf_area *area, struct vertex *v, struct vertex *child; if (IS_DEBUG_OSPF_EVENT) - zlog_debug("ospf_process_stub():processing stubs for area %pI4", + zlog_debug("%s: processing stubs for area %pI4", __func__, &area->area_id); if (v->type == OSPF_VERTEX_ROUTER) { @@ -1580,16 +1581,14 @@ static void ospf_spf_process_stubs(struct ospf_area *area, struct vertex *v, int lsa_pos = 0; if (IS_DEBUG_OSPF_EVENT) - zlog_debug( - "ospf_process_stubs():processing router LSA, id: %pI4", - &v->lsa->id); + zlog_debug("%s: processing router LSA, id: %pI4", + __func__, &v->lsa->id); router_lsa = (struct router_lsa *)v->lsa; if (IS_DEBUG_OSPF_EVENT) - zlog_debug( - "ospf_process_stubs(): we have %d links to process", - ntohs(router_lsa->links)); + zlog_debug("%s: we have %d links to process", __func__, + ntohs(router_lsa->links)); p = ((uint8_t *)v->lsa) + OSPF_LSA_HEADER_SIZE + 4; lim = ((uint8_t *)v->lsa) + ntohs(v->lsa->length); @@ -1683,9 +1682,8 @@ void ospf_spf_calculate(struct ospf_area *area, struct ospf_lsa *root_lsa, struct vertex *v; if (IS_DEBUG_OSPF_EVENT) { - zlog_debug("ospf_spf_calculate: Start"); - zlog_debug("ospf_spf_calculate: running Dijkstra for area %pI4", - &area->area_id); + zlog_debug("%s: Start: running Dijkstra for area %pI4", + __func__, &area->area_id); } /* @@ -1696,8 +1694,8 @@ void ospf_spf_calculate(struct ospf_area *area, struct ospf_lsa *root_lsa, if (!root_lsa) { if (IS_DEBUG_OSPF_EVENT) zlog_debug( - "ospf_spf_calculate: Skip area %pI4's calculation due to empty root LSA", - &area->area_id); + "%s: Skip area %pI4's calculation due to empty root LSA", + __func__, &area->area_id); return; } @@ -1777,7 +1775,7 @@ void ospf_spf_calculate(struct ospf_area *area, struct ospf_lsa *root_lsa, area->ts_spf = area->ospf->ts_spf; if (IS_DEBUG_OSPF_EVENT) - zlog_debug("ospf_spf_calculate: Stop. %zd vertices", + zlog_debug("%s: Stop. %zd vertices", __func__, mtype_stats_alloc(MTYPE_OSPF_VERTEX)); } diff --git a/ospfd/ospf_vty.c b/ospfd/ospf_vty.c index a6572794aa..7d72487686 100644 --- a/ospfd/ospf_vty.c +++ b/ospfd/ospf_vty.c @@ -10118,6 +10118,21 @@ static int ospf_print_vty_helper_dis_rtr_walkcb(struct hash_bucket *bucket, return HASHWALK_CONTINUE; } +static int ospf_print_json_helper_enabled_rtr_walkcb(struct hash_bucket *bucket, + void *arg) +{ + struct advRtr *rtr = bucket->data; + struct json_object *json_rid_array = arg; + struct json_object *json_rid; + + json_rid = json_object_new_object(); + + json_object_string_addf(json_rid, "routerId", "%pI4", &rtr->advRtrAddr); + json_object_array_add(json_rid_array, json_rid); + + return HASHWALK_CONTINUE; +} + static int ospf_show_gr_helper_details(struct vty *vty, struct ospf *ospf, uint8_t use_vrf, json_object *json, bool uj, bool detail) @@ -10237,6 +10252,18 @@ CPP_NOTICE("Remove JSON object commands with keys starting with capital") if (ospf->active_restarter_cnt) json_object_int_add(json_vrf, "activeRestarterCnt", ospf->active_restarter_cnt); + + if (OSPF_HELPER_ENABLE_RTR_COUNT(ospf)) { + struct json_object *json_rid_array = + json_object_new_array(); + + json_object_object_add(json_vrf, "enabledRouterIds", + json_rid_array); + + hash_walk(ospf->enable_rtr_list, + ospf_print_json_helper_enabled_rtr_walkcb, + json_rid_array); + } } diff --git a/pimd/mtracebis_netlink.c b/pimd/mtracebis_netlink.c index fe2cb56a26..81e28f2407 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/pimd/pim6_mld.c b/pimd/pim6_mld.c index 60602ee04a..4b10c4c9c1 100644 --- a/pimd/pim6_mld.c +++ b/pimd/pim6_mld.c @@ -33,12 +33,15 @@ #include "lib/prefix.h" #include "lib/checksum.h" #include "lib/thread.h" +#include "termtable.h" #include "pimd/pim6_mld.h" #include "pimd/pim6_mld_protocol.h" #include "pimd/pim_memory.h" #include "pimd/pim_instance.h" #include "pimd/pim_iface.h" +#include "pimd/pim6_cmd.h" +#include "pimd/pim_cmd_common.h" #include "pimd/pim_util.h" #include "pimd/pim_tib.h" #include "pimd/pimd.h" @@ -415,7 +418,7 @@ static void gm_sg_update(struct gm_sg *sg, bool has_expired) gm_sg_timer_start(gm_ifp, sg, timers.expire_wait); THREAD_OFF(sg->t_sg_query); - sg->n_query = gm_ifp->cur_qrv; + sg->n_query = gm_ifp->cur_lmqc; sg->query_sbit = false; gm_trigger_specific(sg); } @@ -2088,11 +2091,12 @@ static void gm_start(struct interface *ifp) else gm_ifp->cur_version = GM_MLDV2; - /* hardcoded for dev without CLI */ - gm_ifp->cur_qrv = 2; + gm_ifp->cur_qrv = pim_ifp->gm_default_robustness_variable; gm_ifp->cur_query_intv = pim_ifp->gm_default_query_interval * 1000; - gm_ifp->cur_query_intv_trig = gm_ifp->cur_query_intv; - gm_ifp->cur_max_resp = 250; + gm_ifp->cur_query_intv_trig = + pim_ifp->gm_specific_query_max_response_time_dsec * 100; + gm_ifp->cur_max_resp = pim_ifp->gm_query_max_response_time_dsec * 100; + gm_ifp->cur_lmqc = pim_ifp->gm_last_member_query_count; gm_ifp->cfg_timing_fuzz.tv_sec = 0; gm_ifp->cfg_timing_fuzz.tv_usec = 10 * 1000; @@ -2265,10 +2269,26 @@ void gm_ifp_update(struct interface *ifp) if (gm_ifp->cur_query_intv != cfg_query_intv) { gm_ifp->cur_query_intv = cfg_query_intv; - gm_ifp->cur_query_intv_trig = cfg_query_intv; changed = true; } + unsigned int cfg_query_intv_trig = + pim_ifp->gm_specific_query_max_response_time_dsec * 100; + + if (gm_ifp->cur_query_intv_trig != cfg_query_intv_trig) { + gm_ifp->cur_query_intv_trig = cfg_query_intv_trig; + changed = true; + } + + unsigned int cfg_max_response = + pim_ifp->gm_query_max_response_time_dsec * 100; + + if (gm_ifp->cur_max_resp != cfg_max_response) + gm_ifp->cur_max_resp = cfg_max_response; + + if (gm_ifp->cur_lmqc != pim_ifp->gm_last_member_query_count) + gm_ifp->cur_lmqc = pim_ifp->gm_last_member_query_count; + enum gm_version cfg_version; if (pim_ifp->mld_version == 1) @@ -2314,8 +2334,6 @@ void gm_group_delete(struct gm_if *gm_ifp) #include "pimd/pim6_mld_clippy.c" #endif -#define MLD_STR "Multicast Listener Discovery\n" - static struct vrf *gm_cmd_vrf_lookup(struct vty *vty, const char *vrf_str, int *err) { @@ -2855,6 +2873,125 @@ DEFPY(gm_show_interface_joins, return vty_json(vty, js); } +static void gm_show_groups(struct vty *vty, struct vrf *vrf, bool uj) +{ + struct interface *ifp; + struct ttable *tt = NULL; + char *table; + json_object *json = NULL; + json_object *json_iface = NULL; + json_object *json_group = NULL; + json_object *json_groups = NULL; + struct pim_instance *pim = vrf->info; + + if (uj) { + json = json_object_new_object(); + json_object_int_add(json, "totalGroups", pim->gm_group_count); + json_object_int_add(json, "watermarkLimit", + pim->gm_watermark_limit); + } else { + /* Prepare table. */ + tt = ttable_new(&ttable_styles[TTSTYLE_BLANK]); + ttable_add_row(tt, "Interface|Group|Version|Uptime"); + tt->style.cell.rpad = 2; + tt->style.corner = '+'; + ttable_restyle(tt); + + vty_out(vty, "Total MLD groups: %u\n", pim->gm_group_count); + vty_out(vty, "Watermark warn limit(%s): %u\n", + pim->gm_watermark_limit ? "Set" : "Not Set", + pim->gm_watermark_limit); + } + + /* scan interfaces */ + FOR_ALL_INTERFACES (vrf, ifp) { + + struct pim_interface *pim_ifp = ifp->info; + struct gm_if *gm_ifp; + struct gm_sg *sg; + + if (!pim_ifp) + continue; + + gm_ifp = pim_ifp->mld; + if (!gm_ifp) + continue; + + /* scan mld groups */ + frr_each (gm_sgs, gm_ifp->sgs, sg) { + + if (uj) { + json_object_object_get_ex(json, ifp->name, + &json_iface); + + if (!json_iface) { + json_iface = json_object_new_object(); + json_object_pim_ifp_add(json_iface, + ifp); + json_object_object_add(json, ifp->name, + json_iface); + json_groups = json_object_new_array(); + json_object_object_add(json_iface, + "groups", + json_groups); + } + + json_group = json_object_new_object(); + json_object_string_addf(json_group, "group", + "%pPAs", + &sg->sgaddr.grp); + + json_object_int_add(json_group, "version", + pim_ifp->mld_version); + json_object_string_addf(json_group, "uptime", + "%pTVMs", &sg->created); + json_object_array_add(json_groups, json_group); + } else { + ttable_add_row(tt, "%s|%pPAs|%d|%pTVMs", + ifp->name, &sg->sgaddr.grp, + pim_ifp->mld_version, + &sg->created); + } + } /* scan gm groups */ + } /* scan interfaces */ + + if (uj) + vty_json(vty, json); + else { + /* Dump the generated table. */ + table = ttable_dump(tt, "\n"); + vty_out(vty, "%s\n", table); + XFREE(MTYPE_TMP, table); + ttable_del(tt); + } +} + +DEFPY(gm_show_mld_groups, + gm_show_mld_groups_cmd, + "show ipv6 mld [vrf <VRF|all>$vrf_str] groups [json$json]", + SHOW_STR + IPV6_STR + MLD_STR + VRF_FULL_CMD_HELP_STR + MLD_GROUP_STR + JSON_STR) +{ + int ret = CMD_SUCCESS; + struct vrf *vrf; + + vrf = gm_cmd_vrf_lookup(vty, vrf_str, &ret); + if (ret != CMD_SUCCESS) + return ret; + + if (vrf) + gm_show_groups(vty, vrf, !!json); + else + RB_FOREACH (vrf, vrf_name_head, &vrfs_by_name) + gm_show_groups(vty, vrf, !!json); + + return CMD_SUCCESS; +} + DEFPY(gm_debug_show, gm_debug_show_cmd, "debug show mld interface IFNAME", @@ -3029,6 +3166,7 @@ void gm_cli_init(void) install_element(VIEW_NODE, &gm_show_interface_cmd); install_element(VIEW_NODE, &gm_show_interface_stats_cmd); install_element(VIEW_NODE, &gm_show_interface_joins_cmd); + install_element(VIEW_NODE, &gm_show_mld_groups_cmd); install_element(VIEW_NODE, &gm_debug_show_cmd); install_element(INTERFACE_NODE, &gm_debug_iface_cfg_cmd); diff --git a/pimd/pim6_mld.h b/pimd/pim6_mld.h index 95523c2922..540d2e1899 100644 --- a/pimd/pim6_mld.h +++ b/pimd/pim6_mld.h @@ -324,6 +324,7 @@ struct gm_if { unsigned int cur_query_intv_trig; /* ms */ unsigned int cur_max_resp; /* ms */ enum gm_version cur_version; + int cur_lmqc; /* last member query count in ds */ /* this value (positive, default 10ms) defines our "timing tolerance": * - added to deadlines for expiring joins diff --git a/pimd/pim_addr.h b/pimd/pim_addr.h index defe4070cf..7852d1788a 100644 --- a/pimd/pim_addr.h +++ b/pimd/pim_addr.h @@ -31,6 +31,7 @@ typedef struct in_addr pim_addr; #define PIM_ADDRSTRLEN INET_ADDRSTRLEN #define PIM_AF AF_INET #define PIM_AFI AFI_IP +#define PIM_PROTO_REG IPPROTO_RAW #define PIM_IPADDR IPADDR_V4 #define ipaddr_pim ipaddr_v4 #define PIM_MAX_BITLEN IPV4_MAX_BITLEN @@ -58,6 +59,7 @@ typedef struct in6_addr pim_addr; #define PIM_ADDRSTRLEN INET6_ADDRSTRLEN #define PIM_AF AF_INET6 #define PIM_AFI AFI_IP6 +#define PIM_PROTO_REG IPPROTO_PIM #define PIM_IPADDR IPADDR_V6 #define ipaddr_pim ipaddr_v6 #define PIM_MAX_BITLEN IPV6_MAX_BITLEN diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index c2453efa06..f0b6037db9 100644 --- a/pimd/pim_cmd.c +++ b/pimd/pim_cmd.c @@ -1129,11 +1129,11 @@ static void igmp_show_groups(struct pim_instance *pim, struct vty *vty, bool uj) if (uj) { json = json_object_new_object(); - json_object_int_add(json, "totalGroups", pim->igmp_group_count); + json_object_int_add(json, "totalGroups", pim->gm_group_count); json_object_int_add(json, "watermarkLimit", pim->gm_watermark_limit); } else { - vty_out(vty, "Total IGMP groups: %u\n", pim->igmp_group_count); + vty_out(vty, "Total IGMP groups: %u\n", pim->gm_group_count); vty_out(vty, "Watermark warn limit(%s): %u\n", pim->gm_watermark_limit ? "Set" : "Not Set", pim->gm_watermark_limit); diff --git a/pimd/pim_cmd_common.c b/pimd/pim_cmd_common.c index 3092d1d3f5..ff77b856fb 100644 --- a/pimd/pim_cmd_common.c +++ b/pimd/pim_cmd_common.c @@ -1827,13 +1827,14 @@ void pim_show_join(struct pim_instance *pim, struct vty *vty, pim_sgaddr *sg, } } -static void pim_show_jp_agg_helper(struct vty *vty, struct interface *ifp, +static void pim_show_jp_agg_helper(struct interface *ifp, struct pim_neighbor *neigh, - struct pim_upstream *up, int is_join) + struct pim_upstream *up, int is_join, + struct ttable *tt) { - vty_out(vty, "%-16s %-15pPAs %-15pPAs %-15pPAs %5s\n", ifp->name, - &neigh->source_addr, &up->sg.src, &up->sg.grp, - is_join ? "J" : "P"); + ttable_add_row(tt, "%s|%pPAs|%pPAs|%pPAs|%s", ifp->name, + &neigh->source_addr, &up->sg.src, &up->sg.grp, + is_join ? "J" : "P"); } int pim_show_jp_agg_list_cmd_helper(const char *vrf, struct vty *vty) @@ -1869,9 +1870,15 @@ void pim_show_jp_agg_list(struct pim_instance *pim, struct vty *vty) struct pim_jp_agg_group *jag; struct listnode *js_node; struct pim_jp_sources *js; + struct ttable *tt; + char *table; - vty_out(vty, - "Interface RPF Nbr Source Group State\n"); + /* Prepare table. */ + tt = ttable_new(&ttable_styles[TTSTYLE_BLANK]); + ttable_add_row(tt, "Interface|RPF Nbr|Source|Group|State"); + tt->style.cell.rpad = 2; + tt->style.corner = '+'; + ttable_restyle(tt); FOR_ALL_INTERFACES (pim->vrf, ifp) { pim_ifp = ifp->info; @@ -1884,13 +1891,19 @@ void pim_show_jp_agg_list(struct pim_instance *pim, struct vty *vty) jag_node, jag)) { for (ALL_LIST_ELEMENTS_RO(jag->sources, js_node, js)) { - pim_show_jp_agg_helper(vty, ifp, neigh, + pim_show_jp_agg_helper(ifp, neigh, js->up, - js->is_join); + js->is_join, tt); } } } } + + /* Dump the generated table. */ + table = ttable_dump(tt, "\n"); + vty_out(vty, "%s\n", table); + XFREE(MTYPE_TMP, table); + ttable_del(tt); } int pim_show_membership_cmd_helper(const char *vrf, struct vty *vty, bool uj) @@ -2025,10 +2038,10 @@ void pim_show_membership(struct pim_instance *pim, struct vty *vty, bool uj) } } -static void pim_show_channel_helper(struct pim_instance *pim, struct vty *vty, +static void pim_show_channel_helper(struct pim_instance *pim, struct pim_interface *pim_ifp, struct pim_ifchannel *ch, json_object *json, - bool uj) + bool uj, struct ttable *tt) { struct pim_upstream *up = ch->upstream; json_object *json_group = NULL; @@ -2071,17 +2084,17 @@ static void pim_show_channel_helper(struct pim_instance *pim, struct vty *vty, &up->sg.src); } else { - vty_out(vty, - "%-16s %-15pPAs %-15pPAs %-10s %-5s %-10s %-11s %-6s\n", - ch->interface->name, &up->sg.src, &up->sg.grp, - pim_macro_ch_lost_assert(ch) ? "yes" : "no", - pim_macro_chisin_joins(ch) ? "yes" : "no", - pim_macro_chisin_pim_include(ch) ? "yes" : "no", - PIM_UPSTREAM_FLAG_TEST_DR_JOIN_DESIRED(up->flags) - ? "yes" - : "no", - pim_upstream_evaluate_join_desired(pim, up) ? "yes" - : "no"); + ttable_add_row(tt, "%s|%pPAs|%pPAs|%s|%s|%s|%s|%s", + ch->interface->name, &up->sg.src, &up->sg.grp, + pim_macro_ch_lost_assert(ch) ? "yes" : "no", + pim_macro_chisin_joins(ch) ? "yes" : "no", + pim_macro_chisin_pim_include(ch) ? "yes" : "no", + PIM_UPSTREAM_FLAG_TEST_DR_JOIN_DESIRED(up->flags) + ? "yes" + : "no", + pim_upstream_evaluate_join_desired(pim, up) + ? "yes" + : "no"); } } @@ -2090,14 +2103,22 @@ void pim_show_channel(struct pim_instance *pim, struct vty *vty, bool uj) struct pim_interface *pim_ifp; struct pim_ifchannel *ch; struct interface *ifp; - + struct ttable *tt = NULL; json_object *json = NULL; + char *table = NULL; if (uj) json = json_object_new_object(); - else - vty_out(vty, - "Interface Source Group LostAssert Joins PimInclude JoinDesired EvalJD\n"); + else { + /* Prepare table. */ + tt = ttable_new(&ttable_styles[TTSTYLE_BLANK]); + ttable_add_row( + tt, + "Interface|Source|Group|LostAssert|Joins|PimInclude|JoinDesired|EvalJD"); + tt->style.cell.rpad = 2; + tt->style.corner = '+'; + ttable_restyle(tt); + } /* scan per-interface (S,G) state */ FOR_ALL_INTERFACES (pim->vrf, ifp) { @@ -2105,16 +2126,21 @@ void pim_show_channel(struct pim_instance *pim, struct vty *vty, bool uj) if (!pim_ifp) continue; - RB_FOREACH (ch, pim_ifchannel_rb, &pim_ifp->ifchannel_rb) { /* scan all interfaces */ - pim_show_channel_helper(pim, vty, pim_ifp, ch, json, - uj); + pim_show_channel_helper(pim, pim_ifp, ch, json, uj, tt); } } if (uj) vty_json(vty, json); + else { + /* Dump the generated table. */ + table = ttable_dump(tt, "\n"); + vty_out(vty, "%s\n", table); + XFREE(MTYPE_TMP, table); + ttable_del(tt); + } } int pim_show_channel_cmd_helper(const char *vrf, struct vty *vty, bool uj) diff --git a/pimd/pim_igmp.c b/pimd/pim_igmp.c index 6ffeeb9657..fdc56fd3f3 100644 --- a/pimd/pim_igmp.c +++ b/pimd/pim_igmp.c @@ -1008,12 +1008,11 @@ static void igmp_group_count_incr(struct pim_interface *pim_ifp) { uint32_t group_count = listcount(pim_ifp->gm_group_list); - ++pim_ifp->pim->igmp_group_count; - if (pim_ifp->pim->igmp_group_count == - pim_ifp->pim->gm_watermark_limit) { + ++pim_ifp->pim->gm_group_count; + if (pim_ifp->pim->gm_group_count == pim_ifp->pim->gm_watermark_limit) { zlog_warn( "IGMP group count reached watermark limit: %u(vrf: %s)", - pim_ifp->pim->igmp_group_count, + pim_ifp->pim->gm_group_count, VRF_LOGNAME(pim_ifp->pim->vrf)); } @@ -1023,13 +1022,13 @@ static void igmp_group_count_incr(struct pim_interface *pim_ifp) static void igmp_group_count_decr(struct pim_interface *pim_ifp) { - if (pim_ifp->pim->igmp_group_count == 0) { + if (pim_ifp->pim->gm_group_count == 0) { zlog_warn("Cannot decrement igmp group count below 0(vrf: %s)", VRF_LOGNAME(pim_ifp->pim->vrf)); return; } - --pim_ifp->pim->igmp_group_count; + --pim_ifp->pim->gm_group_count; } void igmp_group_delete(struct gm_group *group) diff --git a/pimd/pim_instance.h b/pimd/pim_instance.h index 0da881557c..57bc74efb4 100644 --- a/pimd/pim_instance.h +++ b/pimd/pim_instance.h @@ -173,7 +173,7 @@ struct pim_instance { int gm_socket; struct thread *t_gm_recv; - unsigned int igmp_group_count; + unsigned int gm_group_count; unsigned int gm_watermark_limit; unsigned int keep_alive_time; unsigned int rp_keep_alive_time; diff --git a/pimd/pim_nb_config.c b/pimd/pim_nb_config.c index 72b16a5f49..aaad56e543 100644 --- a/pimd/pim_nb_config.c +++ b/pimd/pim_nb_config.c @@ -454,14 +454,17 @@ static void change_query_interval(struct pim_interface *pim_ifp, } #endif -#if PIM_IPV == 4 -static void change_query_max_response_time(struct pim_interface *pim_ifp, - int query_max_response_time_dsec) +static void change_query_max_response_time(struct interface *ifp, + int query_max_response_time_dsec) { +#if PIM_IPV == 4 struct listnode *sock_node; struct gm_sock *igmp; struct listnode *grp_node; struct gm_group *grp; +#endif + + struct pim_interface *pim_ifp = ifp->info; if (pim_ifp->gm_query_max_response_time_dsec == query_max_response_time_dsec) @@ -469,6 +472,9 @@ static void change_query_max_response_time(struct pim_interface *pim_ifp, pim_ifp->gm_query_max_response_time_dsec = query_max_response_time_dsec; +#if PIM_IPV == 6 + gm_ifp_update(ifp); +#else /* * Below we modify socket/group/source timers in order to quickly * reflect the change. Otherwise, those timers would args->eventually @@ -501,8 +507,8 @@ static void change_query_max_response_time(struct pim_interface *pim_ifp, igmp_source_reset_gmi(grp, src); } } +#endif /* PIM_IPV == 4 */ } -#endif int routing_control_plane_protocols_name_validate( struct nb_cb_create_args *args) @@ -2797,7 +2803,6 @@ int lib_interface_gmp_address_family_query_interval_modify( int lib_interface_gmp_address_family_query_max_response_time_modify( struct nb_cb_modify_args *args) { -#if PIM_IPV == 4 struct interface *ifp; int query_max_response_time_dsec; @@ -2810,13 +2815,9 @@ int lib_interface_gmp_address_family_query_max_response_time_modify( ifp = nb_running_get_entry(args->dnode, NULL, true); query_max_response_time_dsec = yang_dnode_get_uint16(args->dnode, NULL); - change_query_max_response_time(ifp->info, - query_max_response_time_dsec); + change_query_max_response_time(ifp, + query_max_response_time_dsec); } -#else - /* TBD Depends on MLD data structure changes */ -#endif - return NB_OK; } @@ -2827,7 +2828,6 @@ int lib_interface_gmp_address_family_query_max_response_time_modify( int lib_interface_gmp_address_family_last_member_query_interval_modify( struct nb_cb_modify_args *args) { -#if PIM_IPV == 4 struct interface *ifp; struct pim_interface *pim_ifp; int last_member_query_interval; @@ -2847,9 +2847,6 @@ int lib_interface_gmp_address_family_last_member_query_interval_modify( break; } -#else - /* TBD Depends on MLD data structure changes */ -#endif return NB_OK; } @@ -2860,7 +2857,6 @@ int lib_interface_gmp_address_family_last_member_query_interval_modify( int lib_interface_gmp_address_family_robustness_variable_modify( struct nb_cb_modify_args *args) { -#if PIM_IPV == 4 struct interface *ifp; struct pim_interface *pim_ifp; int last_member_query_count; @@ -2879,9 +2875,6 @@ int lib_interface_gmp_address_family_robustness_variable_modify( break; } -#else - /* TBD Depends on MLD data structure changes */ -#endif return NB_OK; } diff --git a/pimd/pim_sock.c b/pimd/pim_sock.c index b5a055c6aa..4b91bf07d9 100644 --- a/pimd/pim_sock.c +++ b/pimd/pim_sock.c @@ -185,7 +185,7 @@ int pim_reg_sock(void) long flags; frr_with_privs (&pimd_privs) { - fd = socket(PIM_AF, SOCK_RAW, IPPROTO_RAW); + fd = socket(PIM_AF, SOCK_RAW, PIM_PROTO_REG); } if (fd < 0) { diff --git a/pimd/pim_vty.c b/pimd/pim_vty.c index cfbd436981..c18652f72e 100644 --- a/pimd/pim_vty.c +++ b/pimd/pim_vty.c @@ -378,9 +378,29 @@ static int gm_config_write(struct vty *vty, int writes, if (pim_ifp->mld_version != MLD_DEFAULT_VERSION) vty_out(vty, " ipv6 mld version %d\n", pim_ifp->mld_version); + + /* IF ipv6 mld query-max-response-time */ + if (pim_ifp->gm_query_max_response_time_dsec != + IGMP_QUERY_MAX_RESPONSE_TIME_DSEC) + vty_out(vty, " ipv6 mld query-max-response-time %d\n", + pim_ifp->gm_query_max_response_time_dsec); + if (pim_ifp->gm_default_query_interval != IGMP_GENERAL_QUERY_INTERVAL) vty_out(vty, " ipv6 mld query-interval %d\n", pim_ifp->gm_default_query_interval); + + /* IF ipv6 mld last-member_query-count */ + if (pim_ifp->gm_last_member_query_count != + IGMP_DEFAULT_ROBUSTNESS_VARIABLE) + vty_out(vty, " ipv6 mld last-member-query-count %d\n", + pim_ifp->gm_last_member_query_count); + + /* IF ipv6 mld last-member_query-interval */ + if (pim_ifp->gm_specific_query_max_response_time_dsec != + IGMP_SPECIFIC_QUERY_MAX_RESPONSE_TIME_DSEC) + vty_out(vty, " ipv6 mld last-member-query-interval %d\n", + pim_ifp->gm_specific_query_max_response_time_dsec); + return 0; } #endif diff --git a/ripd/ripd.c b/ripd/ripd.c index 9798186036..c3a9369a06 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 e69de29bb2..0000000000 --- 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 68c5222e92..0000000000 --- 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 ae668d79ed..0000000000 --- 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 cdc0d217be..0000000000 --- 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 606c17bec9..0000000000 --- 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 93825f441b..0000000000 --- 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 f76b29deff..ebe246ffbc 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 9986cc9f7e..db7b70d7c4 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 |
