struct nhrc *nhrc;
new = XCALLOC(MTYPE_PBR_NHG, sizeof(*new));
- nhrc = hash_get(pbr_nhrc_hash, pnhc->nexthop, pbr_nhrc_hash_alloc);
- new->nexthop = &nhrc->nexthop;
+ nhrc = hash_get(pbr_nhrc_hash, &pnhc->nexthop, pbr_nhrc_hash_alloc);
+ new->nexthop = nhrc->nexthop;
/* Decremented again in pbr_nh_delete */
++nhrc->refcount;
DEBUGD(&pbr_dbg_nht, "%s: Sending nexthop to Zebra", __func__);
- pbr_send_rnh(new->nexthop, true);
+ pbr_send_rnh(&new->nexthop, true);
new->valid = false;
return new;
{
struct nhrc *nhrc;
- nhrc = hash_lookup(pbr_nhrc_hash, (*pnhc)->nexthop);
+ nhrc = hash_lookup(pbr_nhrc_hash, &((*pnhc)->nexthop));
if (nhrc)
--nhrc->refcount;
if (!nhrc || nhrc->refcount == 0) {
DEBUGD(&pbr_dbg_nht, "%s: Removing nexthop from Zebra",
__func__);
- pbr_send_rnh((*pnhc)->nexthop, false);
+ pbr_send_rnh(&((*pnhc)->nexthop), false);
}
if (nhrc && nhrc->refcount == 0) {
hash_release(pbr_nhrc_hash, nhrc);
uint32_t key;
const struct pbr_nexthop_cache *pbrnc = arg;
- key = nexthop_hash(pbrnc->nexthop);
+ key = nexthop_hash(&pbrnc->nexthop);
return key;
}
const struct pbr_nexthop_cache *pbrnc2 =
(const struct pbr_nexthop_cache *)arg2;
- if (pbrnc1->nexthop->vrf_id != pbrnc2->nexthop->vrf_id)
+ if (pbrnc1->nexthop.vrf_id != pbrnc2->nexthop.vrf_id)
return false;
- if (pbrnc1->nexthop->ifindex != pbrnc2->nexthop->ifindex)
+ if (pbrnc1->nexthop.ifindex != pbrnc2->nexthop.ifindex)
return false;
- if (pbrnc1->nexthop->type != pbrnc2->nexthop->type)
+ if (pbrnc1->nexthop.type != pbrnc2->nexthop.type)
return false;
- switch (pbrnc1->nexthop->type) {
+ switch (pbrnc1->nexthop.type) {
case NEXTHOP_TYPE_IFINDEX:
- return pbrnc1->nexthop->ifindex == pbrnc2->nexthop->ifindex;
+ return pbrnc1->nexthop.ifindex == pbrnc2->nexthop.ifindex;
case NEXTHOP_TYPE_IPV4_IFINDEX:
case NEXTHOP_TYPE_IPV4:
- return pbrnc1->nexthop->gate.ipv4.s_addr
- == pbrnc2->nexthop->gate.ipv4.s_addr;
+ return pbrnc1->nexthop.gate.ipv4.s_addr
+ == pbrnc2->nexthop.gate.ipv4.s_addr;
case NEXTHOP_TYPE_IPV6_IFINDEX:
case NEXTHOP_TYPE_IPV6:
- return !memcmp(&pbrnc1->nexthop->gate.ipv6,
- &pbrnc2->nexthop->gate.ipv6, 16);
+ return !memcmp(&pbrnc1->nexthop.gate.ipv6,
+ &pbrnc2->nexthop.gate.ipv6, 16);
case NEXTHOP_TYPE_BLACKHOLE:
- return pbrnc1->nexthop->bh_type == pbrnc2->nexthop->bh_type;
+ return pbrnc1->nexthop.bh_type == pbrnc2->nexthop.bh_type;
}
/*
pnhgc = hash_get(pbr_nhg_hash, &pnhgc_find, pbr_nhgc_alloc);
/* create & insert new pnhc into pnhgc->nhh */
- pnhc_find.nexthop = (struct nexthop *)nhop;
+ pnhc_find.nexthop = *nhop;
pnhc = hash_get(pnhgc->nhh, &pnhc_find, pbr_nh_alloc);
- pnhc_find.nexthop = NULL;
/* set parent pnhgc */
pnhc->parent = pnhgc;
pnhgc = hash_lookup(pbr_nhg_hash, &pnhgc_find);
/* delete pnhc from pnhgc->nhh */
- pnhc_find.nexthop = (struct nexthop *)nhop;
+ pnhc_find.nexthop = *nhop;
pnhc = hash_release(pnhgc->nhh, &pnhc_find);
/* delete pnhc */
struct pbr_nexthop_cache lookup;
struct pbr_nexthop_cache *pnhc;
- lookup.nexthop = nhop;
+ lookup.nexthop = *nhop;
pnhc = hash_lookup(pnhgc->nhh, &lookup);
if (!pnhc) {
pnhc = hash_get(pnhgc->nhh, &lookup, pbr_nh_alloc);
pnhgc = hash_get(pbr_nhg_hash, &find, pbr_nhgc_alloc);
- lookup.nexthop = pbrms->nhg->nexthop;
+ lookup.nexthop = *pbrms->nhg->nexthop;
pnhc = hash_get(pnhgc->nhh, &lookup, pbr_nh_alloc);
pnhc->parent = pnhgc;
if (nhop->vrf_id != VRF_DEFAULT) {
nh = pbrms->nhg->nexthop;
nh_type = nh->type;
- lup.nexthop = nh;
+ lup.nexthop = *nh;
pnhc = hash_lookup(pnhgc->nhh, &lup);
pnhc->parent = NULL;
hash_release(pnhgc->nhh, pnhc);
struct pbr_nexthop_cache lookupc;
struct pbr_nexthop_cache *pnhc;
- lookupc.nexthop = nhop;
+ lookupc.nexthop = *nhop;
pnhc = hash_lookup(pnhgc->nhh, &lookupc);
if (!pnhc) {
pnhc = hash_get(pnhgc->nhh, &lookupc, pbr_nh_alloc);
switch (pnhi->nhr->prefix.family) {
case AF_INET:
- if (pnhc->nexthop->gate.ipv4.s_addr
+ if (pnhc->nexthop.gate.ipv4.s_addr
!= pnhi->nhr->prefix.u.prefix4.s_addr)
goto done; /* Unrelated change */
break;
case AF_INET6:
- if (memcmp(&pnhc->nexthop->gate.ipv6,
+ if (memcmp(&pnhc->nexthop.gate.ipv6,
&pnhi->nhr->prefix.u.prefix6, 16)
!= 0)
goto done; /* Unrelated change */
goto done;
}
- if (pnhc->nexthop->type == NEXTHOP_TYPE_IPV4_IFINDEX
- || pnhc->nexthop->type == NEXTHOP_TYPE_IPV6_IFINDEX) {
+ if (pnhc->nexthop.type == NEXTHOP_TYPE_IPV4_IFINDEX
+ || pnhc->nexthop.type == NEXTHOP_TYPE_IPV6_IFINDEX) {
/* GATEWAY_IFINDEX type shouldn't resolve to group */
if (pnhi->nhr->nexthop_num > 1) {
/* If whatever we resolved to wasn't on the interface we
* specified. (i.e. not a connected route), its invalid.
*/
- if (pnhi->nhr->nexthops[0].ifindex != pnhc->nexthop->ifindex) {
+ if (pnhi->nhr->nexthops[0].ifindex != pnhc->nexthop.ifindex) {
is_valid = false;
goto done;
}
if (!pnhi->ifp) /* It doesn't care about non-interface updates */
goto done;
- if (pnhc->nexthop->ifindex
+ if (pnhc->nexthop.ifindex
!= pnhi->ifp->ifindex) /* Un-related interface */
goto done;
{
assert(pnhi->nhr || pnhi->ifp); /* Either nexthop or interface update */
- switch (pnhc->nexthop->type) {
+ switch (pnhc->nexthop.type) {
case NEXTHOP_TYPE_IFINDEX:
pbr_nht_individual_nexthop_interface_update(pnhc, pnhi);
break;
case NEXTHOP_TYPE_IPV6_IFINDEX:
- if (IN6_IS_ADDR_LINKLOCAL(&pnhc->nexthop->gate.ipv6)) {
+ if (IN6_IS_ADDR_LINKLOCAL(&pnhc->nexthop.gate.ipv6)) {
pbr_nht_individual_nexthop_interface_update(pnhc, pnhi);
break;
}
struct nexthop_group *nhg = data;
struct nexthop *nh = NULL;
- copy_nexthops(&nh, pnhc->nexthop, NULL);
+ copy_nexthops(&nh, &pnhc->nexthop, NULL);
_nexthop_add(&nhg->nexthop, nh);
}
if (pnhc->looked_at == true)
return HASHWALK_CONTINUE;
- if (pnhc->nexthop->vrf_id == VRF_DEFAULT)
+ if (pnhc->nexthop.vrf_id == VRF_DEFAULT)
return HASHWALK_CONTINUE;
if (strncmp(pnhc->vrf_name, pbr_vrf_name(pnhi->pbr_vrf),
== 0) {
pnhi->pnhc = pnhc;
- if (pnhc->nexthop->vrf_id != pbr_vrf_id(pnhi->pbr_vrf)) {
+ if (pnhc->nexthop.vrf_id != pbr_vrf_id(pnhi->pbr_vrf)) {
struct nhrc_vrf_info nhrcvi;
memset(&nhrcvi, 0, sizeof(nhrcvi));
nhrcvi.pbr_vrf = pnhi->pbr_vrf;
- nhrcvi.old_vrf_id = pnhc->nexthop->vrf_id;
+ nhrcvi.old_vrf_id = pnhc->nexthop.vrf_id;
pnhi->nhr_matched = true;
- pnhi->old_vrf_id = pnhc->nexthop->vrf_id;
+ pnhi->old_vrf_id = pnhc->nexthop.vrf_id;
do {
nhrcvi.nhrc = NULL;
continue;
pnhc = pnhi.pnhc;
- pnhc->nexthop->vrf_id = pnhi.old_vrf_id;
+ pnhc->nexthop.vrf_id = pnhi.old_vrf_id;
pnhi.pnhc = hash_release(pnhgc->nhh, pnhi.pnhc);
if (pnhi.pnhc) {
- pnhi.pnhc->nexthop->vrf_id = pbr_vrf_id(pbr_vrf);
+ pnhi.pnhc->nexthop.vrf_id = pbr_vrf_id(pbr_vrf);
hash_get(pnhgc->nhh, pnhi.pnhc, hash_alloc_intern);
} else
- pnhc->nexthop->vrf_id = pbr_vrf_id(pbr_vrf);
+ pnhc->nexthop.vrf_id = pbr_vrf_id(pbr_vrf);
pbr_map_check_vrf_nh_group_change(pnhgc->name, pbr_vrf,
pnhi.old_vrf_id);
struct pbr_nexthop_cache *pnhc = b->data;
struct pbr_nht_individual *pnhi = data;
- if (pnhc->nexthop->ifindex == 0)
+ if (pnhc->nexthop.ifindex == 0)
return;
if ((strncmp(pnhc->intf_name, pnhi->ifp->name, sizeof(pnhc->intf_name))
== 0)
- && pnhc->nexthop->ifindex != pnhi->ifp->ifindex)
+ && pnhc->nexthop.ifindex != pnhi->ifp->ifindex)
pnhi->pnhc = pnhc;
}
continue;
pnhi.pnhc = hash_release(pnhgc->nhh, pnhi.pnhc);
- old_ifindex = pnhi.pnhc->nexthop->ifindex;
+ old_ifindex = pnhi.pnhc->nexthop.ifindex;
- nhrc = hash_lookup(pbr_nhrc_hash, pnhi.pnhc->nexthop);
+ nhrc = hash_lookup(pbr_nhrc_hash, &pnhi.pnhc->nexthop);
if (nhrc) {
hash_release(pbr_nhrc_hash, nhrc);
nhrc->nexthop.ifindex = ifp->ifindex;
hash_get(pbr_nhrc_hash, nhrc, hash_alloc_intern);
}
- pnhi.pnhc->nexthop->ifindex = ifp->ifindex;
+ pnhi.pnhc->nexthop.ifindex = ifp->ifindex;
hash_get(pnhgc->nhh, pnhi.pnhc, hash_alloc_intern);
struct vty *vty = data;
vty_out(vty, "\tValid: %d ", pnhc->valid);
- nexthop_group_write_nexthop(vty, pnhc->nexthop);
+ nexthop_group_write_nexthop(vty, &pnhc->nexthop);
}
static void pbr_nht_json_nhg_nexthops(struct hash_bucket *b, void *data)
json_object *this_hop;
this_hop = json_object_new_object();
- nexthop_group_json_nexthop(this_hop, pnhc->nexthop);
+ nexthop_group_json_nexthop(this_hop, &pnhc->nexthop);
json_object_boolean_add(this_hop, "valid", pnhc->valid);
json_object_array_add(all_hops, this_hop);