diff mbox series

[net] erspan: get the proto with the md version for collect_md

Message ID e995c2a2b885e11d744e9c2743032d16e4fe9baa.1683847331.git.lucien.xin@gmail.com (mailing list archive)
State Accepted
Commit d80fc101d2eb9b3188c228d61223890aeea480a4
Delegated to: Netdev Maintainers
Headers show
Series [net] erspan: get the proto with the md version for collect_md | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 8 this patch: 8
netdev/cc_maintainers warning 1 maintainers not CCed: dsahern@kernel.org
netdev/build_clang success Errors and warnings before: 8 this patch: 8
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 8 this patch: 8
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 44 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Xin Long May 11, 2023, 11:22 p.m. UTC
In commit 20704bd1633d ("erspan: build the header with the right proto
according to erspan_ver"), it gets the proto with t->parms.erspan_ver,
but t->parms.erspan_ver is not used by collect_md branch, and instead
it should get the proto with md->version for collect_md.

Thanks to Kevin for pointing this out.

Fixes: 94d7d8f29287 ("ip6_gre: add erspan v2 support")
Reported-by: Kevin Traynor <ktraynor@redhat.com>
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
 net/ipv6/ip6_gre.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

Comments

Simon Horman May 12, 2023, 4:52 p.m. UTC | #1
On Thu, May 11, 2023 at 07:22:11PM -0400, Xin Long wrote:
> In commit 20704bd1633d ("erspan: build the header with the right proto
> according to erspan_ver"), it gets the proto with t->parms.erspan_ver,
> but t->parms.erspan_ver is not used by collect_md branch, and instead
> it should get the proto with md->version for collect_md.
> 
> Thanks to Kevin for pointing this out.
> 
> Fixes: 94d7d8f29287 ("ip6_gre: add erspan v2 support")

Hi Xin,

In a way this fixes the following commit which in turn fixes the above
commit.

Fixes: 20704bd1633d ("erspan: build the header with the right proto according to erspan_ver")

> Reported-by: Kevin Traynor <ktraynor@redhat.com>
> Signed-off-by: Xin Long <lucien.xin@gmail.com>

Reviewed-by: Simon Horman <simon.horman@corigine.com>
William Tu May 12, 2023, 6:55 p.m. UTC | #2
On Thu, May 11, 2023 at 4:22 PM Xin Long <lucien.xin@gmail.com> wrote:
>
> In commit 20704bd1633d ("erspan: build the header with the right proto
> according to erspan_ver"), it gets the proto with t->parms.erspan_ver,
> but t->parms.erspan_ver is not used by collect_md branch, and instead
> it should get the proto with md->version for collect_md.
>
> Thanks to Kevin for pointing this out.
>
> Fixes: 94d7d8f29287 ("ip6_gre: add erspan v2 support")
> Reported-by: Kevin Traynor <ktraynor@redhat.com>
> Signed-off-by: Xin Long <lucien.xin@gmail.com>
> ---

Hi Xin,
LGTM, thanks for fixing this.
Reviewed-by: William Tu <u9012063@gmail.com>
patchwork-bot+netdevbpf@kernel.org May 13, 2023, 4 p.m. UTC | #3
Hello:

This patch was applied to netdev/net.git (main)
by David S. Miller <davem@davemloft.net>:

On Thu, 11 May 2023 19:22:11 -0400 you wrote:
> In commit 20704bd1633d ("erspan: build the header with the right proto
> according to erspan_ver"), it gets the proto with t->parms.erspan_ver,
> but t->parms.erspan_ver is not used by collect_md branch, and instead
> it should get the proto with md->version for collect_md.
> 
> Thanks to Kevin for pointing this out.
> 
> [...]

Here is the summary with links:
  - [net] erspan: get the proto with the md version for collect_md
    https://git.kernel.org/netdev/net/c/d80fc101d2eb

You are awesome, thank you!
diff mbox series

Patch

diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index a4ecfc9d2593..da80974ad23a 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -1015,12 +1015,14 @@  static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
 					    ntohl(tun_id),
 					    ntohl(md->u.index), truncate,
 					    false);
+			proto = htons(ETH_P_ERSPAN);
 		} else if (md->version == 2) {
 			erspan_build_header_v2(skb,
 					       ntohl(tun_id),
 					       md->u.md2.dir,
 					       get_hwid(&md->u.md2),
 					       truncate, false);
+			proto = htons(ETH_P_ERSPAN2);
 		} else {
 			goto tx_err;
 		}
@@ -1043,24 +1045,25 @@  static netdev_tx_t ip6erspan_tunnel_xmit(struct sk_buff *skb,
 			break;
 		}
 
-		if (t->parms.erspan_ver == 1)
+		if (t->parms.erspan_ver == 1) {
 			erspan_build_header(skb, ntohl(t->parms.o_key),
 					    t->parms.index,
 					    truncate, false);
-		else if (t->parms.erspan_ver == 2)
+			proto = htons(ETH_P_ERSPAN);
+		} else if (t->parms.erspan_ver == 2) {
 			erspan_build_header_v2(skb, ntohl(t->parms.o_key),
 					       t->parms.dir,
 					       t->parms.hwid,
 					       truncate, false);
-		else
+			proto = htons(ETH_P_ERSPAN2);
+		} else {
 			goto tx_err;
+		}
 
 		fl6.daddr = t->parms.raddr;
 	}
 
 	/* Push GRE header. */
-	proto = (t->parms.erspan_ver == 1) ? htons(ETH_P_ERSPAN)
-					   : htons(ETH_P_ERSPAN2);
 	gre_build_header(skb, 8, TUNNEL_SEQ, proto, 0, htonl(atomic_fetch_inc(&t->o_seqno)));
 
 	/* TooBig packet may have updated dst->dev's mtu */