summaryrefslogtreecommitdiff
path: root/pimd/pim_nht.c
diff options
context:
space:
mode:
Diffstat (limited to 'pimd/pim_nht.c')
-rw-r--r--pimd/pim_nht.c70
1 files changed, 19 insertions, 51 deletions
diff --git a/pimd/pim_nht.c b/pimd/pim_nht.c
index ccef796724..7b35ca0209 100644
--- a/pimd/pim_nht.c
+++ b/pimd/pim_nht.c
@@ -608,13 +608,9 @@ int pim_ecmp_nexthop_search(struct pim_instance *pim,
int pim_parse_nexthop_update(int command, struct zclient *zclient,
zebra_size_t length, vrf_id_t vrf_id)
{
- struct stream *s;
- struct prefix p;
struct nexthop *nexthop;
struct nexthop *nhlist_head = NULL;
struct nexthop *nhlist_tail = NULL;
- uint32_t metric, distance;
- u_char nexthop_num = 0;
int i;
struct pim_rpf rpf;
struct pim_nexthop_cache *pnc = NULL;
@@ -623,30 +619,16 @@ int pim_parse_nexthop_update(int command, struct zclient *zclient,
struct interface *ifp1 = NULL;
struct vrf *vrf = vrf_lookup_by_id(vrf_id);
struct pim_instance *pim;
+ struct zapi_route nhr;
if (!vrf)
return 0;
pim = vrf->info;
- s = zclient->ibuf;
- memset(&p, 0, sizeof(struct prefix));
- p.family = stream_getw(s);
- p.prefixlen = stream_getc(s);
- switch (p.family) {
- case AF_INET:
- p.u.prefix4.s_addr = stream_get_ipv4(s);
- break;
- case AF_INET6:
- stream_get(&p.u.prefix6, s, 16);
- break;
- default:
- break;
- }
+ zapi_nexthop_update_decode(zclient->ibuf, &nhr);
if (command == ZEBRA_NEXTHOP_UPDATE) {
- rpf.rpf_addr.family = p.family;
- rpf.rpf_addr.prefixlen = p.prefixlen;
- rpf.rpf_addr.u.prefix4.s_addr = p.u.prefix4.s_addr;
+ prefix_copy(&rpf.rpf_addr, &nhr.prefix);
pnc = pim_nexthop_cache_find(pim, &rpf);
if (!pnc) {
if (PIM_DEBUG_PIM_NHT) {
@@ -666,34 +648,20 @@ int pim_parse_nexthop_update(int command, struct zclient *zclient,
}
pnc->last_update = pim_time_monotonic_usec();
- distance = stream_getc(s);
- metric = stream_getl(s);
- nexthop_num = stream_getc(s);
- if (nexthop_num) {
+ if (nhr.nexthop_num) {
pnc->nexthop_num = 0; // Only increment for pim enabled rpf.
- for (i = 0; i < nexthop_num; i++) {
- nexthop = nexthop_new();
- nexthop->type = stream_getc(s);
+ for (i = 0; i < nhr.nexthop_num; i++) {
+ nexthop = nexthop_from_zapi_nexthop(&nhr.nexthops[i]);
switch (nexthop->type) {
case NEXTHOP_TYPE_IPV4:
- nexthop->gate.ipv4.s_addr = stream_get_ipv4(s);
- nexthop->ifindex = stream_getl(s);
- break;
case NEXTHOP_TYPE_IFINDEX:
- nexthop->ifindex = stream_getl(s);
- break;
case NEXTHOP_TYPE_IPV4_IFINDEX:
- nexthop->gate.ipv4.s_addr = stream_get_ipv4(s);
- nexthop->ifindex = stream_getl(s);
- break;
case NEXTHOP_TYPE_IPV6:
- stream_get(&nexthop->gate.ipv6, s, 16);
+ case NEXTHOP_TYPE_BLACKHOLE:
break;
case NEXTHOP_TYPE_IPV6_IFINDEX:
- stream_get(&nexthop->gate.ipv6, s, 16);
- nexthop->ifindex = stream_getl(s);
ifp1 = if_lookup_by_index(nexthop->ifindex,
pim->vrf_id);
nbr = pim_neighbor_find_if(ifp1);
@@ -708,9 +676,6 @@ int pim_parse_nexthop_update(int command, struct zclient *zclient,
}
break;
- default:
- /* do nothing */
- break;
}
ifp = if_lookup_by_index(nexthop->ifindex, pim->vrf_id);
@@ -731,19 +696,21 @@ int pim_parse_nexthop_update(int command, struct zclient *zclient,
if (PIM_DEBUG_PIM_NHT) {
char p_str[PREFIX2STR_BUFFER];
- prefix2str(&p, p_str, sizeof(p_str));
+
+ prefix2str(&nhr.prefix, p_str, sizeof(p_str));
zlog_debug(
"%s: NHT addr %s(%s) %d-nhop via %s(%s) type %d distance:%u metric:%u ",
__PRETTY_FUNCTION__, p_str,
pim->vrf->name, i + 1,
inet_ntoa(nexthop->gate.ipv4),
- ifp->name, nexthop->type, distance,
- metric);
+ ifp->name, nexthop->type, nhr.distance,
+ nhr.metric);
}
if (!ifp->info) {
if (PIM_DEBUG_PIM_NHT) {
char buf[NEXTHOP_STRLEN];
+
zlog_debug(
"%s: multicast not enabled on input interface %s(%s) (ifindex=%d, addr %s)",
__PRETTY_FUNCTION__, ifp->name,
@@ -771,23 +738,24 @@ int pim_parse_nexthop_update(int command, struct zclient *zclient,
pnc->nexthop = nhlist_head;
if (pnc->nexthop_num) {
pnc->flags |= PIM_NEXTHOP_VALID;
- pnc->distance = distance;
- pnc->metric = metric;
+ pnc->distance = nhr.distance;
+ pnc->metric = nhr.metric;
}
} else {
pnc->flags &= ~PIM_NEXTHOP_VALID;
- pnc->nexthop_num = nexthop_num;
+ pnc->nexthop_num = nhr.nexthop_num;
nexthops_free(pnc->nexthop);
pnc->nexthop = NULL;
}
if (PIM_DEBUG_PIM_NHT) {
char buf[PREFIX2STR_BUFFER];
- prefix2str(&p, buf, sizeof(buf));
+ prefix2str(&nhr.prefix, buf, sizeof(buf));
zlog_debug(
"%s: NHT Update for %s(%s) num_nh %d num_pim_nh %d vrf:%u up %ld rp %d",
- __PRETTY_FUNCTION__, buf, pim->vrf->name, nexthop_num,
- pnc->nexthop_num, vrf_id, pnc->upstream_hash->count,
+ __PRETTY_FUNCTION__, buf, pim->vrf->name,
+ nhr.nexthop_num, pnc->nexthop_num, vrf_id,
+ pnc->upstream_hash->count,
listcount(pnc->rp_list));
}