Skip to content

Commit

Permalink
Merge "In case of ECMP calculation, update the ECMP index in the forw…
Browse files Browse the repository at this point in the history
…aring metadata" into R3.1
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Jul 21, 2016
2 parents 0ecb87c + efcb945 commit 55193c5
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
26 changes: 21 additions & 5 deletions dp-core/vr_nexthop.c
Expand Up @@ -612,14 +612,13 @@ static struct vr_nexthop *
nh_composite_ecmp_select_nh(struct vr_packet *pkt, struct vr_nexthop *nh,
struct vr_forwarding_md *fmd)
{
int ret;
int ret, ecmp_index;
unsigned int hash, hash_ecmp, count;

struct vr_flow flow;
struct vr_ip6 *ip6;
struct vr_nexthop *cnh = NULL;
struct vr_component_nh *cnhp = nh->nh_component_nh;
struct vr_component_nh *cnhp_ecmp = nh->nh_component_ecmp;

if (!(count = nh->nh_component_cnt))
return NULL;
Expand All @@ -640,12 +639,20 @@ nh_composite_ecmp_select_nh(struct vr_packet *pkt, struct vr_nexthop *nh,

hash = hash_ecmp = vr_hash(&flow, flow.flow_key_len, 0);
hash %= count;
ecmp_index = cnhp[hash].cnh_ecmp_index;
cnh = cnhp[hash].cnh;
if (!cnh && nh->nh_component_ecmp_cnt) {
hash_ecmp %= nh->nh_component_ecmp_cnt;
cnh = cnhp_ecmp[hash_ecmp].cnh;
if (!cnh) {
if (nh->nh_component_ecmp_cnt) {
cnhp = nh->nh_component_ecmp;
hash_ecmp %= nh->nh_component_ecmp_cnt;
ecmp_index = cnhp[hash_ecmp].cnh_ecmp_index;
cnh = cnhp[hash_ecmp].cnh;
}
}

if (cnh)
fmd->fmd_ecmp_nh_index = ecmp_index;

return cnh;
}

Expand Down Expand Up @@ -2300,7 +2307,14 @@ nh_composite_add(struct vr_nexthop *nh, vr_nexthop_req *req)
nh->nh_component_nh[i].cnh_label = req->nhr_label_list[i];
if (nh->nh_component_nh[i].cnh)
active++;

if (req->nhr_flags & NH_FLAG_COMPOSITE_ECMP) {
nh->nh_component_nh[i].cnh_ecmp_index = i;
} else {
nh->nh_component_nh[i].cnh_ecmp_index = -1;
}
}

nh->nh_component_cnt = req->nhr_nh_list_size;

if (nh_composite_mcast_validate(nh, req))
Expand All @@ -2324,6 +2338,8 @@ nh_composite_add(struct vr_nexthop *nh, vr_nexthop_req *req)
if (nh->nh_component_nh[i].cnh) {
memcpy(&nh->nh_component_ecmp[j++], &nh->nh_component_nh[i],
sizeof(struct vr_component_nh));
/* this happens implicitly */
/* nh->nh_component_ecmp[j++].cnh_ecmp_index = i */
}
}
nh->nh_component_ecmp_cnt = j;
Expand Down
1 change: 1 addition & 0 deletions include/vr_nexthop.h
Expand Up @@ -70,6 +70,7 @@ struct vr_forwarding_md;

struct vr_component_nh {
int cnh_label;
int cnh_ecmp_index;
struct vr_nexthop *cnh;
};

Expand Down

0 comments on commit 55193c5

Please sign in to comment.