All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHv2 net] ip_gre: do not report erspan version on GRE interface
@ 2022-12-03  3:28 Hangbin Liu
  2022-12-03 15:25 ` William Tu
  2022-12-06 10:50 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Hangbin Liu @ 2022-12-03  3:28 UTC (permalink / raw)
  To: netdev
  Cc: David S . Miller, David Ahern, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, William Tu, Hangbin Liu, Jianlin Shi

Although the type I ERSPAN is based on the barebones IP + GRE
encapsulation and no extra ERSPAN header. Report erspan version on GRE
interface looks unreasonable. Fix this by separating the erspan and gre
fill info.

IPv6 GRE does not have this info as IPv6 only supports erspan version
1 and 2.

Reported-by: Jianlin Shi <jishi@redhat.com>
Fixes: f989d546a2d5 ("erspan: Add type I version 0 support.")
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
v2: fix o_flags not passed to gre fill info, reported by kernel test robot
---
 net/ipv4/ip_gre.c | 48 ++++++++++++++++++++++++++++-------------------
 1 file changed, 29 insertions(+), 19 deletions(-)

diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index f866d6282b2b..cae9f1a4e059 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -1492,24 +1492,6 @@ static int ipgre_fill_info(struct sk_buff *skb, const struct net_device *dev)
 	struct ip_tunnel_parm *p = &t->parms;
 	__be16 o_flags = p->o_flags;
 
-	if (t->erspan_ver <= 2) {
-		if (t->erspan_ver != 0 && !t->collect_md)
-			o_flags |= TUNNEL_KEY;
-
-		if (nla_put_u8(skb, IFLA_GRE_ERSPAN_VER, t->erspan_ver))
-			goto nla_put_failure;
-
-		if (t->erspan_ver == 1) {
-			if (nla_put_u32(skb, IFLA_GRE_ERSPAN_INDEX, t->index))
-				goto nla_put_failure;
-		} else if (t->erspan_ver == 2) {
-			if (nla_put_u8(skb, IFLA_GRE_ERSPAN_DIR, t->dir))
-				goto nla_put_failure;
-			if (nla_put_u16(skb, IFLA_GRE_ERSPAN_HWID, t->hwid))
-				goto nla_put_failure;
-		}
-	}
-
 	if (nla_put_u32(skb, IFLA_GRE_LINK, p->link) ||
 	    nla_put_be16(skb, IFLA_GRE_IFLAGS,
 			 gre_tnl_flags_to_gre_flags(p->i_flags)) ||
@@ -1550,6 +1532,34 @@ static int ipgre_fill_info(struct sk_buff *skb, const struct net_device *dev)
 	return -EMSGSIZE;
 }
 
+static int erspan_fill_info(struct sk_buff *skb, const struct net_device *dev)
+{
+	struct ip_tunnel *t = netdev_priv(dev);
+
+	if (t->erspan_ver <= 2) {
+		if (t->erspan_ver != 0 && !t->collect_md)
+			t->parms.o_flags |= TUNNEL_KEY;
+
+		if (nla_put_u8(skb, IFLA_GRE_ERSPAN_VER, t->erspan_ver))
+			goto nla_put_failure;
+
+		if (t->erspan_ver == 1) {
+			if (nla_put_u32(skb, IFLA_GRE_ERSPAN_INDEX, t->index))
+				goto nla_put_failure;
+		} else if (t->erspan_ver == 2) {
+			if (nla_put_u8(skb, IFLA_GRE_ERSPAN_DIR, t->dir))
+				goto nla_put_failure;
+			if (nla_put_u16(skb, IFLA_GRE_ERSPAN_HWID, t->hwid))
+				goto nla_put_failure;
+		}
+	}
+
+	return ipgre_fill_info(skb, dev);
+
+nla_put_failure:
+	return -EMSGSIZE;
+}
+
 static void erspan_setup(struct net_device *dev)
 {
 	struct ip_tunnel *t = netdev_priv(dev);
@@ -1628,7 +1638,7 @@ static struct rtnl_link_ops erspan_link_ops __read_mostly = {
 	.changelink	= erspan_changelink,
 	.dellink	= ip_tunnel_dellink,
 	.get_size	= ipgre_get_size,
-	.fill_info	= ipgre_fill_info,
+	.fill_info	= erspan_fill_info,
 	.get_link_net	= ip_tunnel_get_link_net,
 };
 
-- 
2.38.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCHv2 net] ip_gre: do not report erspan version on GRE interface
  2022-12-03  3:28 [PATCHv2 net] ip_gre: do not report erspan version on GRE interface Hangbin Liu
@ 2022-12-03 15:25 ` William Tu
  2022-12-06 10:50 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: William Tu @ 2022-12-03 15:25 UTC (permalink / raw)
  To: Hangbin Liu
  Cc: netdev, David S . Miller, David Ahern, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Jianlin Shi

On Fri, Dec 2, 2022 at 7:29 PM Hangbin Liu <liuhangbin@gmail.com> wrote:
>
> Although the type I ERSPAN is based on the barebones IP + GRE
> encapsulation and no extra ERSPAN header. Report erspan version on GRE
> interface looks unreasonable. Fix this by separating the erspan and gre
> fill info.

Thanks, it's true that current code when using GRE, we will report ERSPAN type,
which is not necessary.

>
> IPv6 GRE does not have this info as IPv6 only supports erspan version
> 1 and 2.

I checked the ipv6 GRE, and it doesn't report because we're checking
in ip6gre_fill_info
        if (p->erspan_ver == 1 || p->erspan_ver == 2) {
So it's indeed ok for IPv6 GRE.

>
> Reported-by: Jianlin Shi <jishi@redhat.com>
> Fixes: f989d546a2d5 ("erspan: Add type I version 0 support.")
> Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>

Acked-by: William Tu <u9012063@gmail.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCHv2 net] ip_gre: do not report erspan version on GRE interface
  2022-12-03  3:28 [PATCHv2 net] ip_gre: do not report erspan version on GRE interface Hangbin Liu
  2022-12-03 15:25 ` William Tu
@ 2022-12-06 10:50 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-12-06 10:50 UTC (permalink / raw)
  To: Hangbin Liu
  Cc: netdev, davem, dsahern, edumazet, kuba, pabeni, u9012063, jishi

Hello:

This patch was applied to netdev/net.git (master)
by Paolo Abeni <pabeni@redhat.com>:

On Sat,  3 Dec 2022 11:28:58 +0800 you wrote:
> Although the type I ERSPAN is based on the barebones IP + GRE
> encapsulation and no extra ERSPAN header. Report erspan version on GRE
> interface looks unreasonable. Fix this by separating the erspan and gre
> fill info.
> 
> IPv6 GRE does not have this info as IPv6 only supports erspan version
> 1 and 2.
> 
> [...]

Here is the summary with links:
  - [PATCHv2,net] ip_gre: do not report erspan version on GRE interface
    https://git.kernel.org/netdev/net/c/ee496694b9ee

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-12-06 10:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-03  3:28 [PATCHv2 net] ip_gre: do not report erspan version on GRE interface Hangbin Liu
2022-12-03 15:25 ` William Tu
2022-12-06 10:50 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.