From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <dev-bounces@dpdk.org>
Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124])
	by inbox.dpdk.org (Postfix) with ESMTP id 8ABF945A97;
	Thu,  3 Oct 2024 20:46:28 +0200 (CEST)
Received: from mails.dpdk.org (localhost [127.0.0.1])
	by mails.dpdk.org (Postfix) with ESMTP id 26CBD402B3;
	Thu,  3 Oct 2024 20:46:28 +0200 (CEST)
Received: from mail-pj1-f49.google.com (mail-pj1-f49.google.com
 [209.85.216.49]) by mails.dpdk.org (Postfix) with ESMTP id 673CC402B1
 for <dev@dpdk.org>; Thu,  3 Oct 2024 20:46:26 +0200 (CEST)
Received: by mail-pj1-f49.google.com with SMTP id
 98e67ed59e1d1-2e07d85e956so1129421a91.3
 for <dev@dpdk.org>; Thu, 03 Oct 2024 11:46:26 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=networkplumber-org.20230601.gappssmtp.com; s=20230601; t=1727981185;
 x=1728585985; darn=dpdk.org; 
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:subject:cc:to:from:date:from:to:cc:subject:date
 :message-id:reply-to;
 bh=7rbO7DNQWGi35oAccfzz5tzzwx43Jo6DXb6IJ+S7aLc=;
 b=o+P2Cf69c4pm/dqGaeo+42NyoNGi4xxIGgyj6XnPWgD0HGN125pRTTakT7nyzpmY4I
 FtT8htSNu1CiugRYvYHGnZQqoxBcMQ67GVCRFtkf2b13GNbgY2g1sa2hm7YO+iQebQTM
 c7jNPb8mM4VMpJG5ltSMFC4SFeDx6ZdDjSp7Tu87XhNk01bxOjDf0QfuZT/vG8zSWQ14
 3lC9l7nv35zcnz+ShGl5CSVnqTQqyE2+nUhmFByWivGd/LAuFTIzqs3dPbu7S/NznZpC
 YvfwJkZ9k14/grGdrLfUokhe6IsaZ6E6vSCWHrF4uFmDmA3x1iECtuvwu41uMDZ7nDpQ
 jn2w==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20230601; t=1727981185; x=1728585985;
 h=content-transfer-encoding:mime-version:references:in-reply-to
 :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=7rbO7DNQWGi35oAccfzz5tzzwx43Jo6DXb6IJ+S7aLc=;
 b=CyUSx3c+mlTDwtitUGos2ux7mz6IONdcnOYKaTJhIF0XNH7zl/6MnGOv1TF50nQk4/
 62AzrPSAsZ/G+MNEFn3yU7JHoU+8PncqKxRRaCWfW0nf1TPFX4CSwz7yHpsSLXjn9iuy
 2xfTFhJ4uYXoMV6BBZctPz7uHbtKqppm3Sn198B3MCHU26gtP0k5dLIGaoUqvj/5IZ4R
 QV/UkNR9ZmaX0M68EQTn7c7de2p9XrKCMApB8+GBEnyKjOcxJNcTtGlCOy3bH674OJPT
 sAyaI3QZ8+clfLGz+djCYkDXt68UBlCgkQ0CPpp3jQu6wT+VaSFbp0qKuG7MrolwUKb2
 OCJw==
X-Forwarded-Encrypted: i=1;
 AJvYcCUpqVx0mwSXkhFDDcQicSM69FS/RhrN/5Gf4KBp1LivwovGLbOs59SIWYoE8wQlAhBc0C4=@dpdk.org
X-Gm-Message-State: AOJu0Ywk66inACvdWeLauOf6hcRZh4uj4f8oiyLn27zczz1hFJqgomVa
 s6y/P1MnkeWtN1DvmtuXvAp8kzcCEenouUrybARyKNM/umBvvHvyHgaDkzkXTVs=
X-Google-Smtp-Source: AGHT+IF25Yac09kBp3VKzNhR3FxDuPPRVerV4IWCedF+mW6thd6OUkb5qX2cGMaIrtLZ0Bes/CygHA==
X-Received: by 2002:a17:90a:7c45:b0:2e0:855a:ab31 with SMTP id
 98e67ed59e1d1-2e1e621e540mr75476a91.12.1727981185459; 
 Thu, 03 Oct 2024 11:46:25 -0700 (PDT)
Received: from hermes.local (204-195-96-226.wavecable.com. [204.195.96.226])
 by smtp.gmail.com with ESMTPSA id
 98e67ed59e1d1-2e1bfd2a06asm2015423a91.40.2024.10.03.11.46.25
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Thu, 03 Oct 2024 11:46:25 -0700 (PDT)
Date: Thu, 3 Oct 2024 11:46:23 -0700
From: Stephen Hemminger <stephen@networkplumber.org>
To: Tanzeel-inline <tanxeel1.ahmed@gmail.com>
Cc: olivier.matz@6wind.com, thomas@monjalon.net, tanzeelahmed713@gmail.com,
 dev@dpdk.org
Subject: Re: [PATCH v3] lib/net: add MPLS insert and strip functionality
Message-ID: <20241003114623.74d9526a@hermes.local>
In-Reply-To: <20230224110619.665-1-tanxeel1.ahmed@gmail.com>
References: <20230224110619.665-1-tanxeel1.ahmed@gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <https://mails.dpdk.org/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://mails.dpdk.org/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <https://mails.dpdk.org/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
Errors-To: dev-bounces@dpdk.org

On Fri, 24 Feb 2023 16:06:19 +0500
Tanzeel-inline <tanxeel1.ahmed@gmail.com> wrote:

> +static inline int
> +rte_mpls_strip_over_l2(struct rte_mbuf *m)
> +{
> +	struct rte_ether_hdr *eh = rte_pktmbuf_mtod(m, struct rte_ether_hdr *);
> +	struct rte_mpls_hdr *mph;
> +	bool mpls_exist = true;
> +
> +	if (eh->ether_type != rte_cpu_to_be_16(RTE_ETHER_TYPE_MPLS))
> +		return -1;
> +
> +	/* Stripping all MPLS header */
> +	while (mpls_exist) {
> +		mph = rte_pktmbuf_mtod_offset(m, struct rte_mpls_hdr*,
space required (i.e "struct rte_mpls_hdr *")
> +		sizeof(struct rte_ether_hdr));
> +		if (mph->bs & 1)
> +			mpls_exist = false;
> +		memmove(rte_pktmbuf_adj(m, sizeof(struct rte_mpls_hdr)),
> +		eh, sizeof(struct rte_ether_hdr));
> +		eh = rte_pktmbuf_mtod(m, struct rte_ether_hdr *);
> +	}
> +
> +	return 0;
> +}

This function will fail for the case of segmented mbuf.
Also need to handle case where mbuf is corrupted and just has stack of mpls
tags and the last one is incomplete.