* [PATCH 20.11] app/testpmd: fix encap/decap size calculation
@ 2023-03-29 7:36 Michael Baum
0 siblings, 0 replies; only message in thread
From: Michael Baum @ 2023-03-29 7:36 UTC (permalink / raw)
To: stable; +Cc: Aman Singh, Yuying Zhang, Luca Boccassi, Ori Kam, Ferruh Yigit
[ upstream commit 7bdf7a13ae34dd9c5d8a6aeef7019003dade6f83 ]
Testpmd app has some functions to create either encap or decap buffer
for some special cases:
- "l2_encap" and "l2_decap"
- "mplsogre_encap" and "mplsogre_decap"
- "mplsoudp_encap" and "mplsoudp_decap"
The functions use both "rte_flow_item_eth" and "rte_flow_item_vlan"
structures to represent the headers and copy them into "raw_encap"
action. The size of either "raw_encap" or "raw_decap" is calculated as
sum of headers size.
However, the both "rte_flow_item_eth" and "rte_flow_item_vlan" contain
more fields than original headers, so using them cause bad size
calculation.
This patch uses "rte_ether_hdr" and "rte_vlan_hdr" structures for header
size calculation.
Fixes: 3e77031be855 ("app/testpmd: add MPLSoGRE encapsulation")
Fixes: a1191d39cb57 ("app/testpmd: add MPLSoUDP encapsulation")
Signed-off-by: Michael Baum <michaelba@nvidia.com>
Acked-by: Ori Kam <orika@nvidia.com>
Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>
---
app/test-pmd/cmdline_flow.c | 48 ++++++++++++++++++-------------------
1 file changed, 24 insertions(+), 24 deletions(-)
diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c
index de0db3994b..a56a760748 100644
--- a/app/test-pmd/cmdline_flow.c
+++ b/app/test-pmd/cmdline_flow.c
@@ -5281,15 +5281,15 @@ parse_vc_action_l2_encap(struct context *ctx, const struct token *token,
l2_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
memcpy(eth.src.addr_bytes,
l2_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
- memcpy(header, ð, sizeof(eth));
- header += sizeof(eth);
+ memcpy(header, ð, sizeof(struct rte_ether_hdr));
+ header += sizeof(struct rte_ether_hdr);
if (l2_encap_conf.select_vlan) {
if (l2_encap_conf.select_ipv4)
vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
else
vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
- memcpy(header, &vlan, sizeof(vlan));
- header += sizeof(vlan);
+ memcpy(header, &vlan, sizeof(struct rte_vlan_hdr));
+ header += sizeof(struct rte_vlan_hdr);
}
action_encap_data->conf.size = header -
action_encap_data->data;
@@ -5337,11 +5337,11 @@ parse_vc_action_l2_decap(struct context *ctx, const struct token *token,
header = action_decap_data->data;
if (l2_decap_conf.select_vlan)
eth.type = rte_cpu_to_be_16(RTE_ETHER_TYPE_VLAN);
- memcpy(header, ð, sizeof(eth));
- header += sizeof(eth);
+ memcpy(header, ð, sizeof(struct rte_ether_hdr));
+ header += sizeof(struct rte_ether_hdr);
if (l2_decap_conf.select_vlan) {
- memcpy(header, &vlan, sizeof(vlan));
- header += sizeof(vlan);
+ memcpy(header, &vlan, sizeof(struct rte_vlan_hdr));
+ header += sizeof(struct rte_vlan_hdr);
}
action_decap_data->conf.size = header -
action_decap_data->data;
@@ -5421,15 +5421,15 @@ parse_vc_action_mplsogre_encap(struct context *ctx, const struct token *token,
mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
memcpy(eth.src.addr_bytes,
mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
- memcpy(header, ð, sizeof(eth));
- header += sizeof(eth);
+ memcpy(header, ð, sizeof(struct rte_ether_hdr));
+ header += sizeof(struct rte_ether_hdr);
if (mplsogre_encap_conf.select_vlan) {
if (mplsogre_encap_conf.select_ipv4)
vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
else
vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
- memcpy(header, &vlan, sizeof(vlan));
- header += sizeof(vlan);
+ memcpy(header, &vlan, sizeof(struct rte_vlan_hdr));
+ header += sizeof(struct rte_vlan_hdr);
}
if (mplsogre_encap_conf.select_ipv4) {
memcpy(header, &ipv4, sizeof(ipv4));
@@ -5516,15 +5516,15 @@ parse_vc_action_mplsogre_decap(struct context *ctx, const struct token *token,
mplsogre_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
memcpy(eth.src.addr_bytes,
mplsogre_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
- memcpy(header, ð, sizeof(eth));
- header += sizeof(eth);
+ memcpy(header, ð, sizeof(struct rte_ether_hdr));
+ header += sizeof(struct rte_ether_hdr);
if (mplsogre_encap_conf.select_vlan) {
if (mplsogre_encap_conf.select_ipv4)
vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
else
vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
- memcpy(header, &vlan, sizeof(vlan));
- header += sizeof(vlan);
+ memcpy(header, &vlan, sizeof(struct rte_vlan_hdr));
+ header += sizeof(struct rte_vlan_hdr);
}
if (mplsogre_encap_conf.select_ipv4) {
memcpy(header, &ipv4, sizeof(ipv4));
@@ -5615,15 +5615,15 @@ parse_vc_action_mplsoudp_encap(struct context *ctx, const struct token *token,
mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
memcpy(eth.src.addr_bytes,
mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
- memcpy(header, ð, sizeof(eth));
- header += sizeof(eth);
+ memcpy(header, ð, sizeof(struct rte_ether_hdr));
+ header += sizeof(struct rte_ether_hdr);
if (mplsoudp_encap_conf.select_vlan) {
if (mplsoudp_encap_conf.select_ipv4)
vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
else
vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
- memcpy(header, &vlan, sizeof(vlan));
- header += sizeof(vlan);
+ memcpy(header, &vlan, sizeof(struct rte_vlan_hdr));
+ header += sizeof(struct rte_vlan_hdr);
}
if (mplsoudp_encap_conf.select_ipv4) {
memcpy(header, &ipv4, sizeof(ipv4));
@@ -5712,15 +5712,15 @@ parse_vc_action_mplsoudp_decap(struct context *ctx, const struct token *token,
mplsoudp_encap_conf.eth_dst, RTE_ETHER_ADDR_LEN);
memcpy(eth.src.addr_bytes,
mplsoudp_encap_conf.eth_src, RTE_ETHER_ADDR_LEN);
- memcpy(header, ð, sizeof(eth));
- header += sizeof(eth);
+ memcpy(header, ð, sizeof(struct rte_ether_hdr));
+ header += sizeof(struct rte_ether_hdr);
if (mplsoudp_encap_conf.select_vlan) {
if (mplsoudp_encap_conf.select_ipv4)
vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV4);
else
vlan.inner_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_IPV6);
- memcpy(header, &vlan, sizeof(vlan));
- header += sizeof(vlan);
+ memcpy(header, &vlan, sizeof(struct rte_vlan_hdr));
+ header += sizeof(struct rte_vlan_hdr);
}
if (mplsoudp_encap_conf.select_ipv4) {
memcpy(header, &ipv4, sizeof(ipv4));
--
2.25.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-03-29 7:36 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-29 7:36 [PATCH 20.11] app/testpmd: fix encap/decap size calculation Michael Baum
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).