diff mbox series

[API-NEXT,v3,10/11] linux-gen: ipsec: support inbound TFC dummy packets

Message ID 1519761609-20848-11-git-send-email-odpbot@yandex.ru
State Superseded
Headers show
Series [API-NEXT,v3,1/11] linux-gen: packet: add odp_packet_l2_type() implementation | expand

Commit Message

Github ODP bot Feb. 27, 2018, 8 p.m. UTC
From: Dmitry Eremin-Solenikov <dmitry.ereminsolenikov@linaro.org>


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

---
/** Email created from pull request 502 (lumag:ipsec-imp-upd)
 ** https://github.com/Linaro/odp/pull/502
 ** Patch: https://github.com/Linaro/odp/pull/502.patch
 ** Base sha: ce5c4f9e7ce9fe504451c29429b9ae9fb68083ae
 ** Merge commit sha: fcd6960c97fe9a0a399be4f3418ba3dd83134544
 **/
 platform/linux-generic/odp_ipsec.c | 32 ++++++++++++++++++++++----------
 1 file changed, 22 insertions(+), 10 deletions(-)
diff mbox series

Patch

diff --git a/platform/linux-generic/odp_ipsec.c b/platform/linux-generic/odp_ipsec.c
index 9d13e60ca..fb852e70e 100644
--- a/platform/linux-generic/odp_ipsec.c
+++ b/platform/linux-generic/odp_ipsec.c
@@ -651,7 +651,6 @@  static ipsec_sa_t *ipsec_in_single(odp_packet_t pkt,
 	odp_crypto_packet_op_param_t param;
 	int rc;
 	odp_crypto_packet_result_t crypto; /**< Crypto operation result */
-	odp_packet_parse_param_t parse_param;
 	odp_packet_hdr_t *pkt_hdr;
 
 	state.ip_offset = odp_packet_l3_offset(pkt);
@@ -784,6 +783,9 @@  static ipsec_sa_t *ipsec_in_single(odp_packet_t pkt,
 		} else if (_ODP_IPPROTO_IPV6 == state.ip_next_hdr) {
 			state.is_ipv4 = 0;
 			state.is_ipv6 = 1;
+		} else if (_ODP_IPPROTO_NO_NEXT == state.ip_next_hdr) {
+			state.is_ipv4 = 0;
+			state.is_ipv6 = 0;
 		} else {
 			status->error.proto = 1;
 			goto err;
@@ -817,20 +819,30 @@  static ipsec_sa_t *ipsec_in_single(odp_packet_t pkt,
 						  _ODP_IPV6HDR_LEN);
 		else
 			ipv6hdr->hop_limit -= ipsec_sa->dec_ttl;
-	} else {
+	} else if (state.ip_next_hdr != _ODP_IPPROTO_NO_NEXT) {
 		status->error.proto = 1;
 		goto err;
 	}
 
-	parse_param.proto = state.is_ipv4 ? ODP_PROTO_IPV4 :
-			    state.is_ipv6 ? ODP_PROTO_IPV6 :
-					    ODP_PROTO_NONE;
-	parse_param.last_layer = ipsec_config.inbound.parse_level;
-	parse_param.chksums = ipsec_config.inbound.chksums;
+	if (_ODP_IPPROTO_NO_NEXT == state.ip_next_hdr &&
+	    ODP_IPSEC_MODE_TUNNEL == ipsec_sa->mode) {
+		odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt);
 
-	/* We do not care about return code here.
-	 * Parsing error should not result in IPsec error. */
-	odp_packet_parse(pkt, state.ip_offset, &parse_param);
+		packet_parse_reset(pkt_hdr);
+		pkt_hdr->p.l3_offset = state.ip_offset;
+	} else {
+		odp_packet_parse_param_t parse_param;
+
+		parse_param.proto = state.is_ipv4 ? ODP_PROTO_IPV4 :
+			state.is_ipv6 ? ODP_PROTO_IPV6 :
+			ODP_PROTO_NONE;
+		parse_param.last_layer = ipsec_config.inbound.parse_level;
+		parse_param.chksums = ipsec_config.inbound.chksums;
+
+		/* We do not care about return code here.
+		 * Parsing error should not result in IPsec error. */
+		odp_packet_parse(pkt, state.ip_offset, &parse_param);
+	}
 
 	*pkt_out = pkt;