mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-14 20:13:53 +00:00
pimd: use zclient->nexthop_update
Same as before, use shared nexthop decode function. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
This commit is contained in:
parent
20007eb773
commit
ac18d56a0b
@ -723,7 +723,8 @@ static int pim_ecmp_nexthop_search(struct pim_instance *pim,
|
|||||||
|
|
||||||
/* This API is used to parse Registered address nexthop update coming from Zebra
|
/* This API is used to parse Registered address nexthop update coming from Zebra
|
||||||
*/
|
*/
|
||||||
int pim_parse_nexthop_update(ZAPI_CALLBACK_ARGS)
|
void pim_nexthop_update(struct vrf *vrf, struct prefix *match,
|
||||||
|
struct zapi_route *nhr)
|
||||||
{
|
{
|
||||||
struct nexthop *nexthop;
|
struct nexthop *nexthop;
|
||||||
struct nexthop *nhlist_head = NULL;
|
struct nexthop *nhlist_head = NULL;
|
||||||
@ -732,38 +733,27 @@ int pim_parse_nexthop_update(ZAPI_CALLBACK_ARGS)
|
|||||||
struct pim_rpf rpf;
|
struct pim_rpf rpf;
|
||||||
struct pim_nexthop_cache *pnc = NULL;
|
struct pim_nexthop_cache *pnc = NULL;
|
||||||
struct interface *ifp = NULL;
|
struct interface *ifp = NULL;
|
||||||
struct vrf *vrf = vrf_lookup_by_id(vrf_id);
|
|
||||||
struct pim_instance *pim;
|
struct pim_instance *pim;
|
||||||
struct zapi_route nhr;
|
|
||||||
struct prefix match;
|
|
||||||
|
|
||||||
if (!vrf)
|
|
||||||
return 0;
|
|
||||||
pim = vrf->info;
|
pim = vrf->info;
|
||||||
|
|
||||||
if (!zapi_nexthop_update_decode(zclient->ibuf, &match, &nhr)) {
|
rpf.rpf_addr = pim_addr_from_prefix(match);
|
||||||
zlog_err("%s: Decode of nexthop update from zebra failed",
|
|
||||||
__func__);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
rpf.rpf_addr = pim_addr_from_prefix(&match);
|
|
||||||
pnc = pim_nexthop_cache_find(pim, &rpf);
|
pnc = pim_nexthop_cache_find(pim, &rpf);
|
||||||
if (!pnc) {
|
if (!pnc) {
|
||||||
if (PIM_DEBUG_PIM_NHT)
|
if (PIM_DEBUG_PIM_NHT)
|
||||||
zlog_debug(
|
zlog_debug(
|
||||||
"%s: Skipping NHT update, addr %pPA is not in local cached DB.",
|
"%s: Skipping NHT update, addr %pPA is not in local cached DB.",
|
||||||
__func__, &rpf.rpf_addr);
|
__func__, &rpf.rpf_addr);
|
||||||
return 0;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
pnc->last_update = pim_time_monotonic_usec();
|
pnc->last_update = pim_time_monotonic_usec();
|
||||||
|
|
||||||
if (nhr.nexthop_num) {
|
if (nhr->nexthop_num) {
|
||||||
pnc->nexthop_num = 0;
|
pnc->nexthop_num = 0;
|
||||||
|
|
||||||
for (i = 0; i < nhr.nexthop_num; i++) {
|
for (i = 0; i < nhr->nexthop_num; i++) {
|
||||||
nexthop = nexthop_from_zapi_nexthop(&nhr.nexthops[i]);
|
nexthop = nexthop_from_zapi_nexthop(&nhr->nexthops[i]);
|
||||||
switch (nexthop->type) {
|
switch (nexthop->type) {
|
||||||
case NEXTHOP_TYPE_IFINDEX:
|
case NEXTHOP_TYPE_IFINDEX:
|
||||||
/*
|
/*
|
||||||
@ -842,11 +832,11 @@ int pim_parse_nexthop_update(ZAPI_CALLBACK_ARGS)
|
|||||||
#else
|
#else
|
||||||
pim_addr nhaddr = nexthop->gate.ipv6;
|
pim_addr nhaddr = nexthop->gate.ipv6;
|
||||||
#endif
|
#endif
|
||||||
zlog_debug(
|
zlog_debug("%s: NHT addr %pFX(%s) %d-nhop via %pPA(%s) type %d distance:%u metric:%u ",
|
||||||
"%s: NHT addr %pFX(%s) %d-nhop via %pPA(%s) type %d distance:%u metric:%u ",
|
__func__, match, pim->vrf->name,
|
||||||
__func__, &match, pim->vrf->name, i + 1,
|
i + 1, &nhaddr, ifp->name,
|
||||||
&nhaddr, ifp->name, nexthop->type,
|
nexthop->type, nhr->distance,
|
||||||
nhr.distance, nhr.metric);
|
nhr->metric);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ifp->info) {
|
if (!ifp->info) {
|
||||||
@ -887,23 +877,22 @@ int pim_parse_nexthop_update(ZAPI_CALLBACK_ARGS)
|
|||||||
pnc->nexthop = nhlist_head;
|
pnc->nexthop = nhlist_head;
|
||||||
if (pnc->nexthop_num) {
|
if (pnc->nexthop_num) {
|
||||||
pnc->flags |= PIM_NEXTHOP_VALID;
|
pnc->flags |= PIM_NEXTHOP_VALID;
|
||||||
pnc->distance = nhr.distance;
|
pnc->distance = nhr->distance;
|
||||||
pnc->metric = nhr.metric;
|
pnc->metric = nhr->metric;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
pnc->flags &= ~PIM_NEXTHOP_VALID;
|
pnc->flags &= ~PIM_NEXTHOP_VALID;
|
||||||
pnc->nexthop_num = nhr.nexthop_num;
|
pnc->nexthop_num = nhr->nexthop_num;
|
||||||
nexthops_free(pnc->nexthop);
|
nexthops_free(pnc->nexthop);
|
||||||
pnc->nexthop = NULL;
|
pnc->nexthop = NULL;
|
||||||
}
|
}
|
||||||
SET_FLAG(pnc->flags, PIM_NEXTHOP_ANSWER_RECEIVED);
|
SET_FLAG(pnc->flags, PIM_NEXTHOP_ANSWER_RECEIVED);
|
||||||
|
|
||||||
if (PIM_DEBUG_PIM_NHT)
|
if (PIM_DEBUG_PIM_NHT)
|
||||||
zlog_debug(
|
zlog_debug("%s: NHT Update for %pFX(%s) num_nh %d num_pim_nh %d vrf:%u up %ld rp %d",
|
||||||
"%s: NHT Update for %pFX(%s) num_nh %d num_pim_nh %d vrf:%u up %ld rp %d",
|
__func__, match, pim->vrf->name, nhr->nexthop_num,
|
||||||
__func__, &match, pim->vrf->name, nhr.nexthop_num,
|
pnc->nexthop_num, vrf->vrf_id,
|
||||||
pnc->nexthop_num, vrf_id, pnc->upstream_hash->count,
|
pnc->upstream_hash->count, listcount(pnc->rp_list));
|
||||||
listcount(pnc->rp_list));
|
|
||||||
|
|
||||||
pim_rpf_set_refresh_time(pim);
|
pim_rpf_set_refresh_time(pim);
|
||||||
|
|
||||||
@ -911,8 +900,6 @@ int pim_parse_nexthop_update(ZAPI_CALLBACK_ARGS)
|
|||||||
pim_update_rp_nh(pim, pnc);
|
pim_update_rp_nh(pim, pnc);
|
||||||
if (pnc->upstream_hash->count)
|
if (pnc->upstream_hash->count)
|
||||||
pim_update_upstream_nh(pim, pnc);
|
pim_update_upstream_nh(pim, pnc);
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int pim_ecmp_nexthop_lookup(struct pim_instance *pim,
|
int pim_ecmp_nexthop_lookup(struct pim_instance *pim,
|
||||||
|
@ -45,7 +45,8 @@ struct pnc_hash_walk_data {
|
|||||||
struct interface *ifp;
|
struct interface *ifp;
|
||||||
};
|
};
|
||||||
|
|
||||||
int pim_parse_nexthop_update(ZAPI_CALLBACK_ARGS);
|
void pim_nexthop_update(struct vrf *vrf, struct prefix *match,
|
||||||
|
struct zapi_route *nhr);
|
||||||
int pim_find_or_track_nexthop(struct pim_instance *pim, pim_addr addr,
|
int pim_find_or_track_nexthop(struct pim_instance *pim, pim_addr addr,
|
||||||
struct pim_upstream *up, struct rp_info *rp,
|
struct pim_upstream *up, struct rp_info *rp,
|
||||||
struct pim_nexthop_cache *out_pnc);
|
struct pim_nexthop_cache *out_pnc);
|
||||||
|
@ -428,7 +428,6 @@ static zclient_handler *const pim_handlers[] = {
|
|||||||
[ZEBRA_INTERFACE_ADDRESS_ADD] = pim_zebra_if_address_add,
|
[ZEBRA_INTERFACE_ADDRESS_ADD] = pim_zebra_if_address_add,
|
||||||
[ZEBRA_INTERFACE_ADDRESS_DELETE] = pim_zebra_if_address_del,
|
[ZEBRA_INTERFACE_ADDRESS_DELETE] = pim_zebra_if_address_del,
|
||||||
|
|
||||||
[ZEBRA_NEXTHOP_UPDATE] = pim_parse_nexthop_update,
|
|
||||||
[ZEBRA_ROUTER_ID_UPDATE] = pim_router_id_update_zebra,
|
[ZEBRA_ROUTER_ID_UPDATE] = pim_router_id_update_zebra,
|
||||||
|
|
||||||
#if PIM_IPV == 4
|
#if PIM_IPV == 4
|
||||||
@ -449,6 +448,7 @@ void pim_zebra_init(void)
|
|||||||
|
|
||||||
zclient->zebra_capabilities = pim_zebra_capabilities;
|
zclient->zebra_capabilities = pim_zebra_capabilities;
|
||||||
zclient->zebra_connected = pim_zebra_connected;
|
zclient->zebra_connected = pim_zebra_connected;
|
||||||
|
zclient->nexthop_update = pim_nexthop_update;
|
||||||
|
|
||||||
zclient_init(zclient, ZEBRA_ROUTE_PIM, 0, &pimd_privs);
|
zclient_init(zclient, ZEBRA_ROUTE_PIM, 0, &pimd_privs);
|
||||||
if (PIM_DEBUG_PIM_TRACE) {
|
if (PIM_DEBUG_PIM_TRACE) {
|
||||||
|
Loading…
Reference in New Issue
Block a user