Skip to content

Commit

Permalink
bgpd: use zclient->nexthop_update
Browse files Browse the repository at this point in the history
Same as before.

Signed-off-by: David Lamparter <[email protected]>
  • Loading branch information
eqvinox committed Nov 20, 2023
1 parent f115dc5 commit 409a693
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 38 deletions.
48 changes: 20 additions & 28 deletions bgpd/bgp_nht.c
Original file line number Diff line number Diff line change
Expand Up @@ -897,52 +897,44 @@ void bgp_nht_interface_events(struct peer *peer)
bnc->ifindex_ipv6_ll, NULL);
}

void bgp_parse_nexthop_update(int command, vrf_id_t vrf_id)
void bgp_nexthop_update(struct vrf *vrf, struct prefix *match,
struct zapi_route *nhr)
{
struct bgp_nexthop_cache_head *tree = NULL;
struct bgp_nexthop_cache *bnc_nhc, *bnc_import;
struct bgp *bgp;
struct prefix match;
struct zapi_route nhr;
afi_t afi;

bgp = bgp_lookup_by_vrf_id(vrf_id);
if (!bgp) {
flog_err(
EC_BGP_NH_UPD,
"parse nexthop update: instance not found for vrf_id %u",
vrf_id);
if (!vrf->info) {
flog_err(EC_BGP_NH_UPD,
"parse nexthop update: instance not found for vrf_id %u",
vrf->vrf_id);
return;
}

if (!zapi_nexthop_update_decode(zclient->ibuf, &match, &nhr)) {
zlog_err("%s[%s]: Failure to decode nexthop update", __func__,
bgp->name_pretty);
return;
}

afi = family2afi(match.family);
bgp = (struct bgp *)vrf->info;
afi = family2afi(match->family);
tree = &bgp->nexthop_cache_table[afi];

bnc_nhc = bnc_find(tree, &match, nhr.srte_color, 0);
bnc_nhc = bnc_find(tree, match, nhr->srte_color, 0);
if (!bnc_nhc) {
if (BGP_DEBUG(nht, NHT))
zlog_debug(
"parse nexthop update %pFX(%u)(%s): bnc info not found for nexthop cache",
&nhr.prefix, nhr.srte_color, bgp->name_pretty);
zlog_debug("parse nexthop update %pFX(%u)(%s): bnc info not found for nexthop cache",
&nhr->prefix, nhr->srte_color,
bgp->name_pretty);
} else
bgp_process_nexthop_update(bnc_nhc, &nhr, false);
bgp_process_nexthop_update(bnc_nhc, nhr, false);

tree = &bgp->import_check_table[afi];

bnc_import = bnc_find(tree, &match, nhr.srte_color, 0);
bnc_import = bnc_find(tree, match, nhr->srte_color, 0);
if (!bnc_import) {
if (BGP_DEBUG(nht, NHT))
zlog_debug(
"parse nexthop update %pFX(%u)(%s): bnc info not found for import check",
&nhr.prefix, nhr.srte_color, bgp->name_pretty);
zlog_debug("parse nexthop update %pFX(%u)(%s): bnc info not found for import check",
&nhr->prefix, nhr->srte_color,
bgp->name_pretty);
} else
bgp_process_nexthop_update(bnc_import, &nhr, true);
bgp_process_nexthop_update(bnc_import, nhr, true);

/*
* HACK: if any BGP route is dependant on an SR-policy that doesn't
Expand All @@ -955,7 +947,7 @@ void bgp_parse_nexthop_update(int command, vrf_id_t vrf_id)
* which should provide a better infrastructure to solve this issue in
* a more efficient and elegant way.
*/
if (nhr.srte_color == 0 && bnc_nhc) {
if (nhr->srte_color == 0 && bnc_nhc) {
struct bgp_nexthop_cache *bnc_iter;

frr_each (bgp_nexthop_cache, &bgp->nexthop_cache_table[afi],
Expand All @@ -965,7 +957,7 @@ void bgp_parse_nexthop_update(int command, vrf_id_t vrf_id)
CHECK_FLAG(bnc_iter->flags, BGP_NEXTHOP_VALID))
continue;

bgp_process_nexthop_update(bnc_iter, &nhr, false);
bgp_process_nexthop_update(bnc_iter, nhr, false);
}
}
}
Expand Down
5 changes: 3 additions & 2 deletions bgpd/bgp_nht.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
#define _BGP_NHT_H

/**
* bgp_parse_nexthop_update() - parse a nexthop update message from Zebra.
* bgp_nexthop_update() - process a nexthop update message from Zebra.
*/
extern void bgp_parse_nexthop_update(int command, vrf_id_t vrf_id);
extern void bgp_nexthop_update(struct vrf *vrf, struct prefix *match,
struct zapi_route *nhr);

/**
* bgp_find_or_add_nexthop() - lookup the nexthop cache table for the bnc
Expand Down
9 changes: 1 addition & 8 deletions bgpd/bgp_zebra.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,6 @@ static int bgp_router_id_update(ZAPI_CALLBACK_ARGS)
return 0;
}

/* Nexthop update message from zebra. */
static int bgp_read_nexthop_update(ZAPI_CALLBACK_ARGS)
{
bgp_parse_nexthop_update(cmd, vrf_id);
return 0;
}

/* Set or clear interface on which unnumbered neighbor is configured. This
* would in turn cause BGP to initiate or turn off IPv6 RAs on this
* interface.
Expand Down Expand Up @@ -3332,7 +3325,6 @@ static zclient_handler *const bgp_handlers[] = {
[ZEBRA_INTERFACE_NBR_ADDRESS_DELETE] = bgp_interface_nbr_address_delete,
[ZEBRA_REDISTRIBUTE_ROUTE_ADD] = zebra_read_route,
[ZEBRA_REDISTRIBUTE_ROUTE_DEL] = zebra_read_route,
[ZEBRA_NEXTHOP_UPDATE] = bgp_read_nexthop_update,
[ZEBRA_FEC_UPDATE] = bgp_read_fec_update,
[ZEBRA_LOCAL_ES_ADD] = bgp_zebra_process_local_es_add,
[ZEBRA_LOCAL_ES_DEL] = bgp_zebra_process_local_es_del,
Expand Down Expand Up @@ -3454,6 +3446,7 @@ void bgp_zebra_init(struct event_loop *master, unsigned short instance)
zclient_init(zclient, ZEBRA_ROUTE_BGP, 0, &bgpd_privs);
zclient->zebra_connected = bgp_zebra_connected;
zclient->zebra_capabilities = bgp_zebra_capabilities;
zclient->nexthop_update = bgp_nexthop_update;
zclient->instance = instance;

/* Initialize special zclient for synchronous message exchanges. */
Expand Down

0 comments on commit 409a693

Please sign in to comment.