diff mbox series

[API-NEXT,v5,10/11] linux-gen: packet: add flag for UDP-encapsulated IPsec packets

Message ID 1511870411-24507-11-git-send-email-odpbot@yandex.ru
State Superseded
Headers show
Series [API-NEXT,v5,1/11] validation: ipsec: add ipv4 name parts | expand

Commit Message

Github ODP bot Nov. 28, 2017, noon UTC
From: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>


Signed-off-by: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>

---
/** Email created from pull request 304 (lumag:ipsec-ipv6-2)
 ** https://github.com/Linaro/odp/pull/304
 ** Patch: https://github.com/Linaro/odp/pull/304.patch
 ** Base sha: 4cb02e1caccb9179575e95448fd46979e17d0905
 ** Merge commit sha: 38498451ec522810c4433d56c78af6c4be05a7c7
 **/
 platform/linux-generic/include/odp/api/plat/packet_types.h |  1 +
 platform/linux-generic/odp_ipsec.c                         |  2 +-
 platform/linux-generic/odp_packet.c                        | 11 +++++++++++
 3 files changed, 13 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/platform/linux-generic/include/odp/api/plat/packet_types.h b/platform/linux-generic/include/odp/api/plat/packet_types.h
index 82fc66e53..128e83148 100644
--- a/platform/linux-generic/include/odp/api/plat/packet_types.h
+++ b/platform/linux-generic/include/odp/api/plat/packet_types.h
@@ -151,6 +151,7 @@  typedef union {
 
 		uint64_t l3_chksum_done:1; /**< L3 checksum validation done */
 		uint64_t l4_chksum_done:1; /**< L4 checksum validation done */
+		uint64_t ipsec_udp:1; /**< UDP-encapsulated IPsec packet */
 	};
 
 } _odp_packet_input_flags_t;
diff --git a/platform/linux-generic/odp_ipsec.c b/platform/linux-generic/odp_ipsec.c
index 0dffd98cf..31b5e687e 100644
--- a/platform/linux-generic/odp_ipsec.c
+++ b/platform/linux-generic/odp_ipsec.c
@@ -472,7 +472,7 @@  static int ipsec_in_esp_post(odp_packet_t pkt,
 				 ipsec_padding, esptrl.pad_len) != 0)
 		return -1;
 
-	if (udp_encap) {
+	if (_ODP_IPPROTO_UDP == state->ip_next_hdr) {
 		state->ip_hdr_len -= _ODP_UDPHDR_LEN;
 		state->in.hdr_len += _ODP_UDPHDR_LEN;
 	}
diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c
index bdcb482fa..167f8cbc6 100644
--- a/platform/linux-generic/odp_packet.c
+++ b/platform/linux-generic/odp_packet.c
@@ -2141,6 +2141,17 @@  static inline void parse_udp(packet_parser_t *prs,
 	if (odp_unlikely(udplen < sizeof(_odp_udphdr_t)))
 		prs->error_flags.udp_err = 1;
 
+	if (odp_cpu_to_be_16(_ODP_UDP_IPSEC_PORT) == udp->dst_port &&
+	    udplen > 4) {
+		uint32_t val;
+
+		memcpy(&val, udp + 1, 4);
+		if (val != 0) {
+			prs->input_flags.ipsec = 1;
+			prs->input_flags.ipsec_udp = 1;
+		}
+	}
+
 	if (offset)
 		*offset   += sizeof(_odp_udphdr_t);
 	*parseptr += sizeof(_odp_udphdr_t);