zebra: Do not send a router-id of 0.0.0.0 when we don't know it yet

At startup there exists a time frame where we might not know
a particular vrf's router id.  When zebra gets a request for
it let's not just blindly send whatever we have.  Let's be
a bit smart and only respond with one if we have one.
The upper level protocol can wait for it to have one.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
Donald Sharp 2021-09-03 09:40:26 -04:00
parent 2ca7780ab5
commit 0114135890

View File

@ -2221,8 +2221,8 @@ stream_failure:
static void zread_router_id_add(ZAPI_HANDLER_ARGS)
{
afi_t afi;
struct prefix p;
struct prefix zero;
STREAM_GETW(msg, afi);
@ -2238,6 +2238,18 @@ static void zread_router_id_add(ZAPI_HANDLER_ARGS)
router_id_get(afi, &p, zvrf);
/*
* If we have not officially setup a router-id let's not
* tell the upper level protocol about it yet.
*/
memset(&zero, 0, sizeof(zero));
if ((p.family == AF_INET && p.u.prefix4.s_addr == INADDR_ANY)
|| (p.family == AF_INET6
&& memcmp(&p.u.prefix6, &zero.u.prefix6,
sizeof(struct in6_addr))
== 0))
return;
zsend_router_id_update(client, afi, &p, zvrf_id(zvrf));
stream_failure: