Merge pull request #7472 from opensourcerouting/fpm-fixes

fpm: frr-reload, IPv6 and an improvement
This commit is contained in:
Mark Stapp 2020-12-22 11:37:58 -05:00 committed by GitHub
commit 700ff41ed3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 27 deletions

View File

@ -550,6 +550,7 @@ end
"dump ", "dump ",
"enable ", "enable ",
"frr ", "frr ",
"fpm ",
"hostname ", "hostname ",
"ip ", "ip ",
"ipv6 ", "ipv6 ",

View File

@ -75,9 +75,6 @@ struct fpm_nl_ctx {
int socket; int socket;
bool disabled; bool disabled;
bool connecting; bool connecting;
bool nhg_complete;
bool rib_complete;
bool rmac_complete;
bool use_nhg; bool use_nhg;
struct sockaddr_storage addr; struct sockaddr_storage addr;
@ -377,7 +374,6 @@ static int fpm_write_config(struct vty *vty)
struct sockaddr_in *sin; struct sockaddr_in *sin;
struct sockaddr_in6 *sin6; struct sockaddr_in6 *sin6;
int written = 0; int written = 0;
char addrstr[INET6_ADDRSTRLEN];
if (gfnc->disabled) if (gfnc->disabled)
return written; return written;
@ -386,8 +382,7 @@ static int fpm_write_config(struct vty *vty)
case AF_INET: case AF_INET:
written = 1; written = 1;
sin = (struct sockaddr_in *)&gfnc->addr; sin = (struct sockaddr_in *)&gfnc->addr;
inet_ntop(AF_INET, &sin->sin_addr, addrstr, sizeof(addrstr)); vty_out(vty, "fpm address %pI4", &sin->sin_addr);
vty_out(vty, "fpm address %s", addrstr);
if (sin->sin_port != htons(SOUTHBOUND_DEFAULT_PORT)) if (sin->sin_port != htons(SOUTHBOUND_DEFAULT_PORT))
vty_out(vty, " port %d", ntohs(sin->sin_port)); vty_out(vty, " port %d", ntohs(sin->sin_port));
@ -396,8 +391,7 @@ static int fpm_write_config(struct vty *vty)
case AF_INET6: case AF_INET6:
written = 1; written = 1;
sin6 = (struct sockaddr_in6 *)&gfnc->addr; sin6 = (struct sockaddr_in6 *)&gfnc->addr;
inet_ntop(AF_INET, &sin6->sin6_addr, addrstr, sizeof(addrstr)); vty_out(vty, "fpm address %pI6", &sin6->sin6_addr);
vty_out(vty, "fpm address %s", addrstr);
if (sin6->sin6_port != htons(SOUTHBOUND_DEFAULT_PORT)) if (sin6->sin6_port != htons(SOUTHBOUND_DEFAULT_PORT))
vty_out(vty, " port %d", ntohs(sin6->sin6_port)); vty_out(vty, " port %d", ntohs(sin6->sin6_port));
@ -542,6 +536,13 @@ static int fpm_write(struct thread *t)
fnc->connecting = false; fnc->connecting = false;
/*
* Starting with LSPs walk all FPM objects, marking them
* as unsent and then replaying them.
*/
thread_add_timer(zrouter.master, fpm_lsp_reset, fnc, 0,
&fnc->t_lspreset);
/* Permit receiving messages now. */ /* Permit receiving messages now. */
thread_add_read(fnc->fthread->master, fpm_read, fnc, thread_add_read(fnc->fthread->master, fpm_read, fnc,
fnc->socket, &fnc->t_read); fnc->socket, &fnc->t_read);
@ -664,9 +665,12 @@ static int fpm_connect(struct thread *t)
/* /*
* Starting with LSPs walk all FPM objects, marking them * Starting with LSPs walk all FPM objects, marking them
* as unsent and then replaying them. * as unsent and then replaying them.
*
* If we are not connected, then delay the objects reset/send.
*/ */
thread_add_timer(zrouter.master, fpm_lsp_reset, fnc, 0, if (!fnc->connecting)
&fnc->t_lspreset); thread_add_timer(zrouter.master, fpm_lsp_reset, fnc, 0,
&fnc->t_lspreset);
return 0; return 0;
} }
@ -908,12 +912,8 @@ static int fpm_lsp_send(struct thread *t)
WALK_FINISH(fnc, FNE_LSP_FINISHED); WALK_FINISH(fnc, FNE_LSP_FINISHED);
/* Now move onto routes */ /* Now move onto routes */
if (fnc->use_nhg) thread_add_timer(zrouter.master, fpm_nhg_reset, fnc, 0,
thread_add_timer(zrouter.master, fpm_nhg_reset, fnc, 0, &fnc->t_nhgreset);
&fnc->t_nhgreset);
else
thread_add_timer(zrouter.master, fpm_rib_reset, fnc, 0,
&fnc->t_ribreset);
} else { } else {
/* Didn't finish - reschedule LSP walk */ /* Didn't finish - reschedule LSP walk */
thread_add_timer(zrouter.master, fpm_lsp_send, fnc, 0, thread_add_timer(zrouter.master, fpm_lsp_send, fnc, 0,
@ -966,7 +966,8 @@ static int fpm_nhg_send(struct thread *t)
fna.complete = true; fna.complete = true;
/* Send next hops. */ /* Send next hops. */
hash_walk(zrouter.nhgs_id, fpm_nhg_send_cb, &fna); if (fnc->use_nhg)
hash_walk(zrouter.nhgs_id, fpm_nhg_send_cb, &fna);
/* `free()` allocated memory. */ /* `free()` allocated memory. */
dplane_ctx_fini(&fna.ctx); dplane_ctx_fini(&fna.ctx);
@ -1124,7 +1125,6 @@ static int fpm_nhg_reset(struct thread *t)
{ {
struct fpm_nl_ctx *fnc = THREAD_ARG(t); struct fpm_nl_ctx *fnc = THREAD_ARG(t);
fnc->nhg_complete = false;
hash_iterate(zrouter.nhgs_id, fpm_nhg_reset_cb, NULL); hash_iterate(zrouter.nhgs_id, fpm_nhg_reset_cb, NULL);
/* Schedule next step: send next hop groups. */ /* Schedule next step: send next hop groups. */
@ -1167,8 +1167,6 @@ static int fpm_rib_reset(struct thread *t)
struct route_table *rt; struct route_table *rt;
rib_tables_iter_t rt_iter; rib_tables_iter_t rt_iter;
fnc->rib_complete = false;
rt_iter.state = RIB_TABLES_ITER_S_INIT; rt_iter.state = RIB_TABLES_ITER_S_INIT;
while ((rt = rib_tables_iter_next(&rt_iter))) { while ((rt = rib_tables_iter_next(&rt_iter))) {
for (rn = route_top(rt); rn; rn = srcdest_route_next(rn)) { for (rn = route_top(rt); rn; rn = srcdest_route_next(rn)) {
@ -1208,7 +1206,6 @@ static int fpm_rmac_reset(struct thread *t)
{ {
struct fpm_nl_ctx *fnc = THREAD_ARG(t); struct fpm_nl_ctx *fnc = THREAD_ARG(t);
fnc->rmac_complete = false;
hash_iterate(zrouter.l3vni_table, fpm_unset_l3vni_table, NULL); hash_iterate(zrouter.l3vni_table, fpm_unset_l3vni_table, NULL);
/* Schedule next event: send RMAC entries. */ /* Schedule next event: send RMAC entries. */
@ -1317,20 +1314,14 @@ static int fpm_process_event(struct thread *t)
if (IS_ZEBRA_DEBUG_FPM) if (IS_ZEBRA_DEBUG_FPM)
zlog_debug("%s: next hop groups walk finished", zlog_debug("%s: next hop groups walk finished",
__func__); __func__);
fnc->nhg_complete = true;
break; break;
case FNE_RIB_FINISHED: case FNE_RIB_FINISHED:
if (IS_ZEBRA_DEBUG_FPM) if (IS_ZEBRA_DEBUG_FPM)
zlog_debug("%s: RIB walk finished", __func__); zlog_debug("%s: RIB walk finished", __func__);
fnc->rib_complete = true;
break; break;
case FNE_RMAC_FINISHED: case FNE_RMAC_FINISHED:
if (IS_ZEBRA_DEBUG_FPM) if (IS_ZEBRA_DEBUG_FPM)
zlog_debug("%s: RMAC walk finished", __func__); zlog_debug("%s: RMAC walk finished", __func__);
fnc->rmac_complete = true;
break; break;
case FNE_LSP_FINISHED: case FNE_LSP_FINISHED:
if (IS_ZEBRA_DEBUG_FPM) if (IS_ZEBRA_DEBUG_FPM)