mirror of
https://github.com/FRRouting/frr.git
synced 2025-04-30 13:37:17 +02:00
Merge pull request #14885 from pguibert6WIND/misc_nhg_fixes
various nexthop group fixes
This commit is contained in:
commit
6be9452e50
|
@ -105,20 +105,6 @@ uint8_t nexthop_group_active_nexthop_num(const struct nexthop_group *nhg)
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t
|
|
||||||
nexthop_group_active_nexthop_num_no_recurse(const struct nexthop_group *nhg)
|
|
||||||
{
|
|
||||||
struct nexthop *nhop;
|
|
||||||
uint8_t num = 0;
|
|
||||||
|
|
||||||
for (nhop = nhg->nexthop; nhop; nhop = nhop->next) {
|
|
||||||
if (CHECK_FLAG(nhop->flags, NEXTHOP_FLAG_ACTIVE))
|
|
||||||
num++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return num;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool nexthop_group_has_label(const struct nexthop_group *nhg)
|
bool nexthop_group_has_label(const struct nexthop_group *nhg)
|
||||||
{
|
{
|
||||||
struct nexthop *nhop;
|
struct nexthop *nhop;
|
||||||
|
@ -1248,9 +1234,9 @@ void nexthop_group_disable_vrf(struct vrf *vrf)
|
||||||
struct nexthop_hold *nhh;
|
struct nexthop_hold *nhh;
|
||||||
|
|
||||||
RB_FOREACH (nhgc, nhgc_entry_head, &nhgc_entries) {
|
RB_FOREACH (nhgc, nhgc_entry_head, &nhgc_entries) {
|
||||||
struct listnode *node;
|
struct listnode *node, *nnode;
|
||||||
|
|
||||||
for (ALL_LIST_ELEMENTS_RO(nhgc->nhg_list, node, nhh)) {
|
for (ALL_LIST_ELEMENTS(nhgc->nhg_list, node, nnode, nhh)) {
|
||||||
struct nexthop nhop;
|
struct nexthop nhop;
|
||||||
struct nexthop *nh;
|
struct nexthop *nh;
|
||||||
|
|
||||||
|
@ -1271,6 +1257,8 @@ void nexthop_group_disable_vrf(struct vrf *vrf)
|
||||||
nhg_hooks.del_nexthop(nhgc, nh);
|
nhg_hooks.del_nexthop(nhgc, nh);
|
||||||
|
|
||||||
nexthop_free(nh);
|
nexthop_free(nh);
|
||||||
|
|
||||||
|
list_delete_node(nhgc->nhg_list, node);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,8 +154,6 @@ extern uint8_t
|
||||||
nexthop_group_nexthop_num_no_recurse(const struct nexthop_group *nhg);
|
nexthop_group_nexthop_num_no_recurse(const struct nexthop_group *nhg);
|
||||||
extern uint8_t
|
extern uint8_t
|
||||||
nexthop_group_active_nexthop_num(const struct nexthop_group *nhg);
|
nexthop_group_active_nexthop_num(const struct nexthop_group *nhg);
|
||||||
extern uint8_t
|
|
||||||
nexthop_group_active_nexthop_num_no_recurse(const struct nexthop_group *nhg);
|
|
||||||
|
|
||||||
extern bool nexthop_group_has_label(const struct nexthop_group *nhg);
|
extern bool nexthop_group_has_label(const struct nexthop_group *nhg);
|
||||||
|
|
||||||
|
|
|
@ -563,9 +563,15 @@ void nhg_add(uint32_t id, const struct nexthop_group *nhg,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (api_nhg.nexthop_num == 0) {
|
if (api_nhg.nexthop_num == 0) {
|
||||||
zlog_debug("%s: nhg %u not sent: no valid nexthops", __func__,
|
if (sharp_nhgroup_id_is_installed(id)) {
|
||||||
id);
|
zlog_debug("%s: nhg %u: no nexthops, deleting nexthop group", __func__,
|
||||||
is_valid = false;
|
id);
|
||||||
|
zclient_nhg_send(zclient, ZEBRA_NHG_DEL, &api_nhg);
|
||||||
|
} else {
|
||||||
|
zlog_debug("%s: nhg %u not sent: no valid nexthops", __func__,
|
||||||
|
id);
|
||||||
|
is_valid = false;
|
||||||
|
}
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2624,7 +2624,7 @@ static bool _netlink_nexthop_build_group(struct nlmsghdr *n, size_t req_size,
|
||||||
|
|
||||||
if (IS_ZEBRA_DEBUG_KERNEL) {
|
if (IS_ZEBRA_DEBUG_KERNEL) {
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
snprintf(buf, sizeof(buf1), "group %u",
|
snprintf(buf, sizeof(buf), "group %u",
|
||||||
grp[i].id);
|
grp[i].id);
|
||||||
else {
|
else {
|
||||||
snprintf(buf1, sizeof(buf1), "/%u",
|
snprintf(buf1, sizeof(buf1), "/%u",
|
||||||
|
|
|
@ -1973,6 +1973,8 @@ static void zread_nhg_del(ZAPI_HANDLER_ARGS)
|
||||||
zsend_nhg_notify(api_nhg.proto, client->instance,
|
zsend_nhg_notify(api_nhg.proto, client->instance,
|
||||||
client->session_id, api_nhg.id,
|
client->session_id, api_nhg.id,
|
||||||
ZAPI_NHG_REMOVE_FAIL);
|
ZAPI_NHG_REMOVE_FAIL);
|
||||||
|
/* Stats */
|
||||||
|
client->nhg_del_cnt++;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void zread_nhg_add(ZAPI_HANDLER_ARGS)
|
static void zread_nhg_add(ZAPI_HANDLER_ARGS)
|
||||||
|
@ -1981,7 +1983,7 @@ static void zread_nhg_add(ZAPI_HANDLER_ARGS)
|
||||||
struct zapi_nhg api_nhg = {};
|
struct zapi_nhg api_nhg = {};
|
||||||
struct nexthop_group *nhg = NULL;
|
struct nexthop_group *nhg = NULL;
|
||||||
struct nhg_backup_info *bnhg = NULL;
|
struct nhg_backup_info *bnhg = NULL;
|
||||||
struct nhg_hash_entry *nhe;
|
struct nhg_hash_entry *nhe, *nhe_tmp;
|
||||||
|
|
||||||
s = msg;
|
s = msg;
|
||||||
if (zapi_nhg_decode(s, hdr->command, &api_nhg) < 0) {
|
if (zapi_nhg_decode(s, hdr->command, &api_nhg) < 0) {
|
||||||
|
@ -2039,6 +2041,12 @@ static void zread_nhg_add(ZAPI_HANDLER_ARGS)
|
||||||
nexthop_group_delete(&nhg);
|
nexthop_group_delete(&nhg);
|
||||||
zebra_nhg_backup_free(&bnhg);
|
zebra_nhg_backup_free(&bnhg);
|
||||||
|
|
||||||
|
/* Stats */
|
||||||
|
nhe_tmp = zebra_nhg_lookup_id(api_nhg.id);
|
||||||
|
if (nhe_tmp)
|
||||||
|
client->nhg_upd8_cnt++;
|
||||||
|
else
|
||||||
|
client->nhg_add_cnt++;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void zread_route_add(ZAPI_HANDLER_ARGS)
|
static void zread_route_add(ZAPI_HANDLER_ARGS)
|
||||||
|
|
|
@ -1526,7 +1526,13 @@ zebra_nhg_rib_find_nhe(struct nhg_hash_entry *rt_nhe, afi_t rt_afi)
|
||||||
{
|
{
|
||||||
struct nhg_hash_entry *nhe = NULL;
|
struct nhg_hash_entry *nhe = NULL;
|
||||||
|
|
||||||
if (!(rt_nhe && rt_nhe->nhg.nexthop)) {
|
if (!rt_nhe) {
|
||||||
|
flog_err(EC_ZEBRA_TABLE_LOOKUP_FAILED,
|
||||||
|
"No nhg_hash_entry passed to %s", __func__);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!rt_nhe->nhg.nexthop) {
|
||||||
flog_err(EC_ZEBRA_TABLE_LOOKUP_FAILED,
|
flog_err(EC_ZEBRA_TABLE_LOOKUP_FAILED,
|
||||||
"No nexthop passed to %s", __func__);
|
"No nexthop passed to %s", __func__);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -1061,6 +1061,8 @@ static void zebra_show_client_detail(struct vty *vty, struct zserv *client)
|
||||||
0, client->redist_v4_del_cnt);
|
0, client->redist_v4_del_cnt);
|
||||||
vty_out(vty, "Redist:v6 %-12u%-12u%-12u\n", client->redist_v6_add_cnt,
|
vty_out(vty, "Redist:v6 %-12u%-12u%-12u\n", client->redist_v6_add_cnt,
|
||||||
0, client->redist_v6_del_cnt);
|
0, client->redist_v6_del_cnt);
|
||||||
|
vty_out(vty, "NHG %-12u%-12u%-12u\n", client->nhg_add_cnt,
|
||||||
|
client->nhg_upd8_cnt, client->nhg_del_cnt);
|
||||||
vty_out(vty, "VRF %-12u%-12u%-12u\n", client->vrfadd_cnt, 0,
|
vty_out(vty, "VRF %-12u%-12u%-12u\n", client->vrfadd_cnt, 0,
|
||||||
client->vrfdel_cnt);
|
client->vrfdel_cnt);
|
||||||
vty_out(vty, "Connected %-12u%-12u%-12u\n", client->ifadd_cnt, 0,
|
vty_out(vty, "Connected %-12u%-12u%-12u\n", client->ifadd_cnt, 0,
|
||||||
|
|
|
@ -185,6 +185,9 @@ struct zserv {
|
||||||
uint32_t local_es_evi_add_cnt;
|
uint32_t local_es_evi_add_cnt;
|
||||||
uint32_t local_es_evi_del_cnt;
|
uint32_t local_es_evi_del_cnt;
|
||||||
uint32_t error_cnt;
|
uint32_t error_cnt;
|
||||||
|
uint32_t nhg_add_cnt;
|
||||||
|
uint32_t nhg_upd8_cnt;
|
||||||
|
uint32_t nhg_del_cnt;
|
||||||
|
|
||||||
time_t nh_reg_time;
|
time_t nh_reg_time;
|
||||||
time_t nh_dereg_time;
|
time_t nh_dereg_time;
|
||||||
|
|
Loading…
Reference in a new issue