From afec8642ca1a3204e219e5c4bb64ed8cc6112104 Mon Sep 17 00:00:00 2001 From: "Anand H. Krishnan" Date: Mon, 14 Mar 2016 12:24:49 +0530 Subject: [PATCH] Do not swap ports for an ICMP packet inside an ICMP error For an ICMP packet, the port numbers remain the same in either direction i.e.: source port remains the same for both foward and the reverse flows as does the destination port. Hence, we should not be swapping ports in calculating the flow key while trying to tag an ICMP error packet to a flow set up for the original stream. Change-Id: Ic5df8aec5f1009441aefd3d177568d55f3cb0d2c Closes-BUG: #1554236 --- dp-core/vr_proto_ip.c | 8 +++++--- dp-core/vr_proto_ip6.c | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/dp-core/vr_proto_ip.c b/dp-core/vr_proto_ip.c index 4f83e78ef..fbcf6a9d0 100644 --- a/dp-core/vr_proto_ip.c +++ b/dp-core/vr_proto_ip.c @@ -723,9 +723,11 @@ vr_inet_flow_swap(struct vr_flow *key_p) unsigned short port; unsigned int ipaddr; - port = key_p->flow4_sport; - key_p->flow4_sport = key_p->flow4_dport; - key_p->flow4_dport = port; + if (key_p->flow4_proto != VR_IP_PROTO_ICMP) { + port = key_p->flow4_sport; + key_p->flow4_sport = key_p->flow4_dport; + key_p->flow4_dport = port; + } ipaddr = key_p->flow4_sip; key_p->flow4_sip = key_p->flow4_dip; diff --git a/dp-core/vr_proto_ip6.c b/dp-core/vr_proto_ip6.c index d99341b74..47a8d872f 100644 --- a/dp-core/vr_proto_ip6.c +++ b/dp-core/vr_proto_ip6.c @@ -140,9 +140,11 @@ vr_inet6_flow_swap(struct vr_flow *key_p) unsigned short port; uint8_t ip6_addr[VR_IP6_ADDRESS_LEN]; - port = key_p->flow6_sport; - key_p->flow6_sport = key_p->flow6_dport; - key_p->flow6_dport = port; + if (key_p->flow6_proto != VR_IP_PROTO_ICMP6) { + port = key_p->flow6_sport; + key_p->flow6_sport = key_p->flow6_dport; + key_p->flow6_dport = port; + } memcpy(ip6_addr, key_p->flow6_sip, VR_IP6_ADDRESS_LEN); memcpy(key_p->flow6_sip, key_p->flow6_dip, VR_IP6_ADDRESS_LEN);