diff mbox series

[API-NEXT,v2,5/5] linux-gen: packet: set next layer offsets allways

Message ID 1512993608-19038-6-git-send-email-odpbot@yandex.ru
State New
Headers show
Series [API-NEXT,v2,1/5] api: packet: refine layer offset specification | expand

Commit Message

Github ODP bot Dec. 11, 2017, noon UTC
From: Petri Savolainen <petri.savolainen@linaro.org>


Update implementation to follow API change of layer offsets.
Set L3 offset always after successful L2 parse. Set L4 offset
always after successful L3 parse.

Signed-off-by: Petri Savolainen <petri.savolainen@linaro.org>

---
/** Email created from pull request 332 (psavol:next-l4-offset)
 ** https://github.com/Linaro/odp/pull/332
 ** Patch: https://github.com/Linaro/odp/pull/332.patch
 ** Base sha: 0980001e33b4190133d478a0aa2e718fd1e3c164
 ** Merge commit sha: 821e53e2ab0847f73ddb171a65e3e4fc5d28e64f
 **/
 platform/linux-generic/odp_packet.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c
index 55f59178b..14d0ab63e 100644
--- a/platform/linux-generic/odp_packet.c
+++ b/platform/linux-generic/odp_packet.c
@@ -2154,11 +2154,12 @@  int packet_parse_common_l3_l4(packet_parser_t *prs, const uint8_t *parseptr,
 {
 	uint8_t  ip_proto;
 
+	prs->l3_offset = offset;
+
 	if (layer <= ODP_PKTIO_PARSER_LAYER_L2)
 		return prs->error_flags.all != 0;
 
-	/* Set l3_offset+flag only for known ethtypes */
-	prs->l3_offset = offset;
+	/* Set l3 flag only for known ethtypes */
 	prs->input_flags.l3 = 1;
 
 	/* Parse Layer 3 headers */
@@ -2166,12 +2167,14 @@  int packet_parse_common_l3_l4(packet_parser_t *prs, const uint8_t *parseptr,
 	case _ODP_ETHTYPE_IPV4:
 		prs->input_flags.ipv4 = 1;
 		ip_proto = parse_ipv4(prs, &parseptr, &offset, frame_len);
+		prs->l4_offset = offset;
 		break;
 
 	case _ODP_ETHTYPE_IPV6:
 		prs->input_flags.ipv6 = 1;
 		ip_proto = parse_ipv6(prs, &parseptr, &offset, frame_len,
 				      seg_len);
+		prs->l4_offset = offset;
 		break;
 
 	case _ODP_ETHTYPE_ARP:
@@ -2181,15 +2184,13 @@  int packet_parse_common_l3_l4(packet_parser_t *prs, const uint8_t *parseptr,
 
 	default:
 		prs->input_flags.l3 = 0;
-		prs->l3_offset = ODP_PACKET_OFFSET_INVALID;
 		ip_proto = 255;  /* Reserved invalid by IANA */
 	}
 
 	if (layer == ODP_PKTIO_PARSER_LAYER_L3)
 		return prs->error_flags.all != 0;
 
-	/* Set l4_offset+flag only for known ip_proto */
-	prs->l4_offset = offset;
+	/* Set l4 flag only for known ip_proto */
 	prs->input_flags.l4 = 1;
 
 	/* Parse Layer 4 headers */
@@ -2235,7 +2236,6 @@  int packet_parse_common_l3_l4(packet_parser_t *prs, const uint8_t *parseptr,
 
 	default:
 		prs->input_flags.l4 = 0;
-		prs->l4_offset = ODP_PACKET_OFFSET_INVALID;
 		break;
 	}