From d9000c1e28d79189ae69374e3a904725c48aca36 Mon Sep 17 00:00:00 2001 From: Divakar D Date: Thu, 16 Nov 2017 12:19:07 +0530 Subject: [PATCH] Calculate Ecmp component NH for non-IP packets 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 --- dp-core/vr_nexthop.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/dp-core/vr_nexthop.c b/dp-core/vr_nexthop.c index 7c93e1df6..478701c8e 100644 --- a/dp-core/vr_nexthop.c +++ b/dp-core/vr_nexthop.c @@ -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; @@ -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) {