diff options
| author | Donald Sharp <sharpd@cumulusnetworks.com> | 2018-08-23 16:05:02 -0400 |
|---|---|---|
| committer | Donald Sharp <sharpd@cumulusnetworks.com> | 2018-08-25 08:11:01 -0400 |
| commit | 1d30d1f4a8241ca45df4eb70181211f5af0ff487 (patch) | |
| tree | a3891c6bd1bc53c1d0d21e3f9d9620322638eb72 /zebra/zapi_msg.c | |
| parent | 9b8c3903bdf0f681df17a532286bc717e1f607ad (diff) | |
zebra: When registering a nexthop, we do not always need to re-eval
The code prior to this change, was allowing clients to register
for nexthop tracking. Then zebra would look up the rnh and
send to that particular client any known data. Additionally
zebra was blindly re-evaluating the rnh for every registration.
This leads to interesting behavior in that all people registered
for that nexthop will get callbacks even if nothing changes.
Modify the code to know if we have evaluated the rnh or not
and if so limit the re-evaluation to when absolutely necessary
This is of particular importance to do because of nht callbacks
for protocols cause those protocols to do not insignificant
work and as more protocols are registering for nht callbacks
we will cause more work than is necessary.
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'zebra/zapi_msg.c')
| -rw-r--r-- | zebra/zapi_msg.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c index 6990fd95f5..d95f78109c 100644 --- a/zebra/zapi_msg.c +++ b/zebra/zapi_msg.c @@ -1022,6 +1022,7 @@ static void zread_rnh_register(ZAPI_HANDLER_ARGS) unsigned short l = 0; uint8_t flags = 0; uint16_t type = cmd2type[hdr->command]; + bool exist; if (IS_ZEBRA_DEBUG_NHT) zlog_debug( @@ -1064,7 +1065,10 @@ static void zread_rnh_register(ZAPI_HANDLER_ARGS) p.family); return; } - rnh = zebra_add_rnh(&p, zvrf_id(zvrf), type); + rnh = zebra_add_rnh(&p, zvrf_id(zvrf), type, &exist); + if (!rnh) + return; + if (type == RNH_NEXTHOP_TYPE) { if (flags && !CHECK_FLAG(rnh->flags, ZEBRA_NHT_CONNECTED)) @@ -1084,7 +1088,9 @@ static void zread_rnh_register(ZAPI_HANDLER_ARGS) zebra_add_rnh_client(rnh, client, type, zvrf_id(zvrf)); /* Anything not AF_INET/INET6 has been filtered out above */ - zebra_evaluate_rnh(zvrf_id(zvrf), p.family, 1, type, &p); + if (!exist) + zebra_evaluate_rnh(zvrf_id(zvrf), p.family, 1, type, + &p); } stream_failure: |
