Skip to content

Commit

Permalink
Calculate Ecmp component NH for non-IP packets
Browse files Browse the repository at this point in the history
Currently the Ecmp component NH is calculated for IP/IP6 packets only as
Ecmp has been supported for only for L3 packets. With the support of L2 Ecmp, the
component NH needs to be chosen even for L2 packets. As there is no Flow
available for L2 packets, the hash is calculated on Ether dst, src and
VRF

Change-Id: I61085c729da9633630088604c1a6b8db5897bba8
closes-bug: #1732285
  • Loading branch information
divakardhar committed Nov 16, 2017
1 parent 4e96a15 commit d9000c1
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions dp-core/vr_nexthop.c
Expand Up @@ -810,6 +810,7 @@ static int
nh_composite_ecmp_select_nh(struct vr_packet *pkt, struct vr_nexthop *nh,
struct vr_forwarding_md *fmd)
{
bool hash_computed = false;
int ret = -1, ecmp_index = -1;
unsigned int hash, hash_ecmp, count, rflow_src_info;

Expand Down Expand Up @@ -861,14 +862,21 @@ nh_composite_ecmp_select_nh(struct vr_packet *pkt, struct vr_nexthop *nh,
if (ret < 0)
return ret;
} else {
return ret;
/*
* packet can be hashed on ethernet header and VRF to identify
* the component
*/
hash_ecmp = vr_hash(pkt_data(pkt), VR_ETHER_HLEN, 0);
hash_ecmp = vr_hash_2words(hash_ecmp, fmd->fmd_dvrf, 0);
hash_computed = true;
}
}


if (ecmp_index == -1) {
hash = hash_ecmp = vr_hash(flowp, flowp->flow_key_len, 0);
hash %= count;
if (!hash_computed)
hash_ecmp = vr_hash(flowp, flowp->flow_key_len, 0);
hash = hash_ecmp % count;
ecmp_index = cnhp[hash].cnh_ecmp_index;
cnh = cnhp[hash].cnh;
if (!cnh) {
Expand Down

0 comments on commit d9000c1

Please sign in to comment.