diff mbox series

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

Message ID 1519232408-28445-11-git-send-email-odpbot@yandex.ru
State Superseded
Headers show
Series [API-NEXT,v1,1/15] api: don't create special case for the tunnel-dummy packets | expand

Commit Message

Github ODP bot Feb. 21, 2018, 5 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 494 (lumag:ipsec-tfc-imp)
 ** https://github.com/Linaro/odp/pull/494
 ** Patch: https://github.com/Linaro/odp/pull/494.patch
 ** Base sha: ea2afab619ae74108a03798bc358fdfcd29fdd88
 ** Merge commit sha: 7bc900650676584bfb99c8a92c3d8812b458f172
 **/
 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 55beb382e..855b504e5 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;