From 0114135890141e50c25d66d24e803ad4e23fc465 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 3 Sep 2021 09:40:26 -0400 Subject: [PATCH] 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 --- zebra/zapi_msg.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c index 6666b3525e..72c7071502 100644 --- a/zebra/zapi_msg.c +++ b/zebra/zapi_msg.c @@ -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: -- 2.39.5