Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nhrp maintain used state #14739

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion nhrpd/netlink_arp.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,9 @@ int nhrp_neighbor_operation(ZAPI_CALLBACK_ARGS)
} else {
state = (cmd == ZEBRA_NEIGH_ADDED) ? ndm_state
: ZEBRA_NEIGH_STATE_FAILED;
nhrp_cache_set_used(c, state == ZEBRA_NEIGH_STATE_REACHABLE);
if (ndm_state != ZEBRA_NEIGH_STATE_STALE)
nhrp_cache_set_used(c,
state == ZEBRA_NEIGH_STATE_REACHABLE);
}
return 0;
}
53 changes: 38 additions & 15 deletions nhrpd/nhrp_vty.c
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,8 @@ static void show_ip_nhrp_cache(struct nhrp_cache *c, void *pctx)
struct vty *vty = ctx->vty;
char buf[3][SU_ADDRSTRLEN];
struct json_object *json = NULL;
struct timeval *t;
struct timeval now;

if (ctx->afi != family2afi(sockunion_family(&c->remote_addr)))
return;
Expand Down Expand Up @@ -802,23 +804,32 @@ static void show_ip_nhrp_cache(struct nhrp_cache *c, void *pctx)
nhrp_cache_type_str[c->cur.type]);
json_object_string_add(json, "protocol", buf[0]);
json_object_string_add(json, "nbma", buf[1]);
#if CONFDATE > 20250115
CPP_NOTICE("remove claimed_nbma key")
#endif
json_object_string_add(json, "claimed_nbma", buf[2]);
json_object_string_add(json, "claimedNbma", buf[2]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please go through an appropriate deprecation cycle with this change. Even if it is wrong

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I proposed to keep the old value.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, we should mark this as a deprecation anyway (claimed_nbma) because it's not compliant with our JSON requirements for the key names.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pguibert6WIND can you add deprecation for claimed_nbma? (CONFDATE)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


json_object_boolean_add(json, "used", !!c->used);
json_object_boolean_add(json, "routeInstalled",
!!c->route_installed);
json_object_boolean_add(json, "nhrpRouteInstalled",
!!c->nhrp_route_installed);

json_object_boolean_add(json, "timeout", !!c->t_timeout);
monotime(&now);
if (c->t_timeout) {
t = &c->t_timeout->u.sands;
json_object_int_add(json, "timeoutRemainingTimeSecs",
t->tv_sec - now.tv_sec);
}

if (c->used)
json_object_boolean_true_add(json, "used");
else
json_object_boolean_false_add(json, "used");

if (c->t_timeout)
json_object_boolean_true_add(json, "timeout");
else
json_object_boolean_false_add(json, "timeout");

if (c->t_auth)
json_object_boolean_true_add(json, "auth");
else
json_object_boolean_false_add(json, "auth");

json_object_boolean_add(json, "auth", !!c->t_auth);
if (c->t_auth) {
t = &c->t_auth->u.sands;
json_object_int_add(json, "authRemainingTimeSecs",
t->tv_sec - now.tv_sec);
}
if (c->cur.peer)
json_object_string_add(json, "identity",
c->cur.peer->vc->remote.id);
Expand Down Expand Up @@ -881,6 +892,8 @@ static void show_ip_nhrp_shortcut(struct nhrp_shortcut *s, void *pctx)
struct vty *vty = ctx->vty;
char buf1[PREFIX_STRLEN], buf2[SU_ADDRSTRLEN];
struct json_object *json = NULL;
struct timeval *t;
struct timeval now;

if (!ctx->count && !ctx->json) {
vty_out(vty, "%-8s %-24s %-24s %s\n", "Type", "Prefix", "Via",
Expand Down Expand Up @@ -909,6 +922,16 @@ static void show_ip_nhrp_shortcut(struct nhrp_shortcut *s, void *pctx)
else
json_object_string_add(json, "identity", "");

json_object_int_add(json, "holdingTimeSecs", s->holding_time);
json_object_boolean_add(json, "routeInstalled",
!!s->route_installed);
json_object_boolean_add(json, "expiring", !!s->expiring);
if (s->t_timer) {
monotime(&now);
t = &s->t_timer->u.sands;
json_object_int_add(json, "remainingTimeSecs",
t->tv_sec - now.tv_sec);
}
json_object_array_add(ctx->json, json);
return;
}
Expand Down
14 changes: 7 additions & 7 deletions tests/topotests/nhrp_redundancy/nhc1/nhrp_cache.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"type": "nhs",
"protocol": "172.16.1.2",
"nbma": "192.168.1.2",
"claimed_nbma": "192.168.1.2",
"used": false,
"claimedNbma": "192.168.1.2",
"used": true,
"timeout": true,
"auth": false,
"identity": ""
Expand All @@ -19,7 +19,7 @@
"type": "local",
"protocol": "172.16.1.4",
"nbma": "192.168.2.4",
"claimed_nbma": "192.168.2.4",
"claimedNbma": "192.168.2.4",
"used": false,
"timeout": false,
"auth": false,
Expand All @@ -30,8 +30,8 @@
"type": "nhs",
"protocol": "172.16.1.3",
"nbma": "192.168.1.3",
"claimed_nbma": "192.168.1.3",
"used": false,
"claimedNbma": "192.168.1.3",
"used": true,
"timeout": true,
"auth": false,
"identity": ""
Expand All @@ -41,8 +41,8 @@
"type": "nhs",
"protocol": "172.16.1.1",
"nbma": "192.168.1.1",
"claimed_nbma": "192.168.1.1",
"used": false,
"claimedNbma": "192.168.1.1",
"used": true,
"timeout": true,
"auth": false,
"identity": ""
Expand Down
10 changes: 5 additions & 5 deletions tests/topotests/nhrp_redundancy/nhc1/nhrp_cache_nhs1_down.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"type": "nhs",
"protocol": "172.16.1.2",
"nbma": "192.168.1.2",
"claimed_nbma": "192.168.1.2",
"used": false,
"claimedNbma": "192.168.1.2",
"used": true,
"timeout": true,
"auth": false,
"identity": ""
Expand All @@ -19,7 +19,7 @@
"type": "local",
"protocol": "172.16.1.4",
"nbma": "192.168.2.4",
"claimed_nbma": "192.168.2.4",
"claimedNbma": "192.168.2.4",
"used": false,
"timeout": false,
"auth": false,
Expand All @@ -30,8 +30,8 @@
"type": "nhs",
"protocol": "172.16.1.3",
"nbma": "192.168.1.3",
"claimed_nbma": "192.168.1.3",
"used": false,
"claimedNbma": "192.168.1.3",
"used": true,
"timeout": true,
"auth": false,
"identity": ""
Expand Down
14 changes: 7 additions & 7 deletions tests/topotests/nhrp_redundancy/nhc2/nhrp_cache.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"type": "nhs",
"protocol": "172.16.1.2",
"nbma": "192.168.1.2",
"claimed_nbma": "192.168.1.2",
"used": false,
"claimedNbma": "192.168.1.2",
"used": true,
"timeout": true,
"auth": false,
"identity": ""
Expand All @@ -19,8 +19,8 @@
"type": "nhs",
"protocol": "172.16.1.3",
"nbma": "192.168.1.3",
"claimed_nbma": "192.168.1.3",
"used": false,
"claimedNbma": "192.168.1.3",
"used": true,
"timeout": true,
"auth": false,
"identity": ""
Expand All @@ -30,8 +30,8 @@
"type": "nhs",
"protocol": "172.16.1.1",
"nbma": "192.168.1.1",
"claimed_nbma": "192.168.1.1",
"used": false,
"claimedNbma": "192.168.1.1",
"used": true,
"timeout": true,
"auth": false,
"identity": ""
Expand All @@ -41,7 +41,7 @@
"type": "local",
"protocol": "172.16.1.5",
"nbma": "192.168.2.5",
"claimed_nbma": "192.168.2.5",
"claimedNbma": "192.168.2.5",
"used": false,
"timeout": false,
"auth": false,
Expand Down
10 changes: 5 additions & 5 deletions tests/topotests/nhrp_redundancy/nhc2/nhrp_cache_nhs1_down.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"type": "nhs",
"protocol": "172.16.1.2",
"nbma": "192.168.1.2",
"claimed_nbma": "192.168.1.2",
"used": false,
"claimedNbma": "192.168.1.2",
"used": true,
"timeout": true,
"auth": false,
"identity": ""
Expand All @@ -19,8 +19,8 @@
"type": "nhs",
"protocol": "172.16.1.3",
"nbma": "192.168.1.3",
"claimed_nbma": "192.168.1.3",
"used": false,
"claimedNbma": "192.168.1.3",
"used": true,
"timeout": true,
"auth": false,
"identity": ""
Expand All @@ -30,7 +30,7 @@
"type": "local",
"protocol": "172.16.1.5",
"nbma": "192.168.2.5",
"claimed_nbma": "192.168.2.5",
"claimedNbma": "192.168.2.5",
"used": false,
"timeout": false,
"auth": false,
Expand Down
10 changes: 5 additions & 5 deletions tests/topotests/nhrp_redundancy/nhs1/nhrp_cache.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"type": "dynamic",
"protocol": "172.16.1.4",
"nbma": "192.168.2.4",
"claimed_nbma": "192.168.2.4",
"used": false,
"claimedNbma": "192.168.2.4",
"used": true,
"timeout": true,
"auth": false,
"identity": ""
Expand All @@ -19,7 +19,7 @@
"type": "local",
"protocol": "172.16.1.1",
"nbma": "192.168.1.1",
"claimed_nbma": "192.168.1.1",
"claimedNbma": "192.168.1.1",
"used": false,
"timeout": false,
"auth": false,
Expand All @@ -30,8 +30,8 @@
"type": "dynamic",
"protocol": "172.16.1.5",
"nbma": "192.168.2.5",
"claimed_nbma": "192.168.2.5",
"used": false,
"claimedNbma": "192.168.2.5",
"used": true,
"timeout": true,
"auth": false,
"identity": ""
Expand Down
10 changes: 5 additions & 5 deletions tests/topotests/nhrp_redundancy/nhs2/nhrp_cache.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"type": "local",
"protocol": "172.16.1.2",
"nbma": "192.168.1.2",
"claimed_nbma": "192.168.1.2",
"claimedNbma": "192.168.1.2",
"used": false,
"timeout": false,
"auth": false,
Expand All @@ -19,8 +19,8 @@
"type": "dynamic",
"protocol": "172.16.1.4",
"nbma": "192.168.2.4",
"claimed_nbma": "192.168.2.4",
"used": false,
"claimedNbma": "192.168.2.4",
"used": true,
"timeout": true,
"auth": false,
"identity": ""
Expand All @@ -30,8 +30,8 @@
"type": "dynamic",
"protocol": "172.16.1.5",
"nbma": "192.168.2.5",
"claimed_nbma": "192.168.2.5",
"used": false,
"claimedNbma": "192.168.2.5",
"used": true,
"timeout": true,
"auth": false,
"identity": ""
Expand Down
10 changes: 5 additions & 5 deletions tests/topotests/nhrp_redundancy/nhs2/nhrp_cache_nhs1_down.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"type": "local",
"protocol": "172.16.1.2",
"nbma": "192.168.1.2",
"claimed_nbma": "192.168.1.2",
"claimedNbma": "192.168.1.2",
"used": false,
"timeout": false,
"auth": false,
Expand All @@ -19,8 +19,8 @@
"type": "dynamic",
"protocol": "172.16.1.4",
"nbma": "192.168.2.4",
"claimed_nbma": "192.168.2.4",
"used": false,
"claimedNbma": "192.168.2.4",
"used": true,
"timeout": true,
"auth": false,
"identity": ""
Expand All @@ -30,8 +30,8 @@
"type": "dynamic",
"protocol": "172.16.1.5",
"nbma": "192.168.2.5",
"claimed_nbma": "192.168.2.5",
"used": false,
"claimedNbma": "192.168.2.5",
"used": true,
"timeout": true,
"auth": false,
"identity": ""
Expand Down
10 changes: 5 additions & 5 deletions tests/topotests/nhrp_redundancy/nhs3/nhrp_cache.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"type": "dynamic",
"protocol": "172.16.1.4",
"nbma": "192.168.2.4",
"claimed_nbma": "192.168.2.4",
"used": false,
"claimedNbma": "192.168.2.4",
"used": true,
"timeout": true,
"auth": false,
"identity": ""
Expand All @@ -19,7 +19,7 @@
"type": "local",
"protocol": "172.16.1.3",
"nbma": "192.168.1.3",
"claimed_nbma": "192.168.1.3",
"claimedNbma": "192.168.1.3",
"used": false,
"timeout": false,
"auth": false,
Expand All @@ -30,8 +30,8 @@
"type": "dynamic",
"protocol": "172.16.1.5",
"nbma": "192.168.2.5",
"claimed_nbma": "192.168.2.5",
"used": false,
"claimedNbma": "192.168.2.5",
"used": true,
"timeout": true,
"auth": false,
"identity": ""
Expand Down
10 changes: 5 additions & 5 deletions tests/topotests/nhrp_redundancy/nhs3/nhrp_cache_nhs1_down.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"type": "dynamic",
"protocol": "172.16.1.4",
"nbma": "192.168.2.4",
"claimed_nbma": "192.168.2.4",
"used": false,
"claimedNbma": "192.168.2.4",
"used": true,
"timeout": true,
"auth": false,
"identity": ""
Expand All @@ -19,7 +19,7 @@
"type": "local",
"protocol": "172.16.1.3",
"nbma": "192.168.1.3",
"claimed_nbma": "192.168.1.3",
"claimedNbma": "192.168.1.3",
"used": false,
"timeout": false,
"auth": false,
Expand All @@ -30,8 +30,8 @@
"type": "dynamic",
"protocol": "172.16.1.5",
"nbma": "192.168.2.5",
"claimed_nbma": "192.168.2.5",
"used": false,
"claimedNbma": "192.168.2.5",
"used": true,
"timeout": true,
"auth": false,
"identity": ""
Expand Down
Loading
Loading