All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net 0/2] erspan: always reports output key to userspace
@ 2019-01-28 21:23 Lorenzo Bianconi
  2019-01-28 21:23 ` [PATCH net 1/2] net: ip_gre: always reports o_key " Lorenzo Bianconi
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Lorenzo Bianconi @ 2019-01-28 21:23 UTC (permalink / raw)
  To: davem; +Cc: netdev, u9012063

Erspan protocol relies on output key to set session id header field.
However TUNNEL_KEY bit is cleared in order to not add key field to
the external GRE header and so the configured o_key is not reported
to userspace.
Fix the issue adding TUNNEL_KEY bit to the o_flags parameter dumping
device info

Lorenzo Bianconi (2):
  net: ip_gre: always reports o_key to userspace
  net: ip6_gre: always reports o_key to userspace

 net/ipv4/ip_gre.c  | 7 ++++++-
 net/ipv6/ip6_gre.c | 7 ++++++-
 2 files changed, 12 insertions(+), 2 deletions(-)

-- 
2.20.1


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

* [PATCH net 1/2] net: ip_gre: always reports o_key to userspace
  2019-01-28 21:23 [PATCH net 0/2] erspan: always reports output key to userspace Lorenzo Bianconi
@ 2019-01-28 21:23 ` Lorenzo Bianconi
  2019-01-28 21:23 ` [PATCH net 2/2] net: ip6_gre: " Lorenzo Bianconi
  2019-01-30 22:00 ` [PATCH net 0/2] erspan: always reports output key " David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Lorenzo Bianconi @ 2019-01-28 21:23 UTC (permalink / raw)
  To: davem; +Cc: netdev, u9012063

Erspan protocol (version 1 and 2) relies on o_key to configure
session id header field. However TUNNEL_KEY bit is cleared in
erspan_xmit since ERSPAN protocol does not set the key field
of the external GRE header and so the configured o_key is not reported
to userspace. The issue can be triggered with the following reproducer:

$ip link add erspan1 type erspan local 192.168.0.1 remote 192.168.0.2 \
    key 1 seq erspan_ver 1
$ip link set erspan1 up
$ip -d link sh erspan1

erspan1@NONE: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1450 qdisc pfifo_fast state UNKNOWN mode DEFAULT
  link/ether 52:aa:99:95:9a:b5 brd ff:ff:ff:ff:ff:ff promiscuity 0 minmtu 68 maxmtu 1500
  erspan remote 192.168.0.2 local 192.168.0.1 ttl inherit ikey 0.0.0.1 iseq oseq erspan_index 0

Fix the issue adding TUNNEL_KEY bit to the o_flags parameter in
ipgre_fill_info

Fixes: 84e54fe0a5ea ("gre: introduce native tunnel support for ERSPAN")
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
---
 net/ipv4/ip_gre.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index 20a64fe6254b..3978f807fa8b 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -1455,12 +1455,17 @@ static int ipgre_fill_info(struct sk_buff *skb, const struct net_device *dev)
 {
 	struct ip_tunnel *t = netdev_priv(dev);
 	struct ip_tunnel_parm *p = &t->parms;
+	__be16 o_flags = p->o_flags;
+
+	if ((t->erspan_ver == 1 || t->erspan_ver == 2) &&
+	    !t->collect_md)
+		o_flags |= TUNNEL_KEY;
 
 	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)) ||
 	    nla_put_be16(skb, IFLA_GRE_OFLAGS,
-			 gre_tnl_flags_to_gre_flags(p->o_flags)) ||
+			 gre_tnl_flags_to_gre_flags(o_flags)) ||
 	    nla_put_be32(skb, IFLA_GRE_IKEY, p->i_key) ||
 	    nla_put_be32(skb, IFLA_GRE_OKEY, p->o_key) ||
 	    nla_put_in_addr(skb, IFLA_GRE_LOCAL, p->iph.saddr) ||
-- 
2.20.1


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

* [PATCH net 2/2] net: ip6_gre: always reports o_key to userspace
  2019-01-28 21:23 [PATCH net 0/2] erspan: always reports output key to userspace Lorenzo Bianconi
  2019-01-28 21:23 ` [PATCH net 1/2] net: ip_gre: always reports o_key " Lorenzo Bianconi
@ 2019-01-28 21:23 ` Lorenzo Bianconi
  2019-01-30 22:00 ` [PATCH net 0/2] erspan: always reports output key " David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: Lorenzo Bianconi @ 2019-01-28 21:23 UTC (permalink / raw)
  To: davem; +Cc: netdev, u9012063

As Erspan_v4, Erspan_v6 protocol relies on o_key to configure
session id header field. However TUNNEL_KEY bit is cleared in
ip6erspan_tunnel_xmit since ERSPAN protocol does not set the key field
of the external GRE header and so the configured o_key is not reported
to userspace. The issue can be triggered with the following reproducer:

$ip link add ip6erspan1 type ip6erspan local 2000::1 remote 2000::2 \
    key 1 seq erspan_ver 1
$ip link set ip6erspan1 up
ip -d link sh ip6erspan1

ip6erspan1@NONE: <BROADCAST,MULTICAST> mtu 1422 qdisc noop state DOWN mode DEFAULT
    link/ether ba:ff:09:24:c3:0e brd ff:ff:ff:ff:ff:ff promiscuity 0 minmtu 68 maxmtu 1500
    ip6erspan remote 2000::2 local 2000::1 encaplimit 4 flowlabel 0x00000 ikey 0.0.0.1 iseq oseq

Fix the issue adding TUNNEL_KEY bit to the o_flags parameter in
ip6gre_fill_info

Fixes: 5a963eb61b7c ("ip6_gre: Add ERSPAN native tunnel support")
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
---
 net/ipv6/ip6_gre.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index 4416368dbd49..801a9a0c217e 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -2098,12 +2098,17 @@ static int ip6gre_fill_info(struct sk_buff *skb, const struct net_device *dev)
 {
 	struct ip6_tnl *t = netdev_priv(dev);
 	struct __ip6_tnl_parm *p = &t->parms;
+	__be16 o_flags = p->o_flags;
+
+	if ((p->erspan_ver == 1 || p->erspan_ver == 2) &&
+	    !p->collect_md)
+		o_flags |= TUNNEL_KEY;
 
 	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)) ||
 	    nla_put_be16(skb, IFLA_GRE_OFLAGS,
-			 gre_tnl_flags_to_gre_flags(p->o_flags)) ||
+			 gre_tnl_flags_to_gre_flags(o_flags)) ||
 	    nla_put_be32(skb, IFLA_GRE_IKEY, p->i_key) ||
 	    nla_put_be32(skb, IFLA_GRE_OKEY, p->o_key) ||
 	    nla_put_in6_addr(skb, IFLA_GRE_LOCAL, &p->laddr) ||
-- 
2.20.1


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

* Re: [PATCH net 0/2] erspan: always reports output key to userspace
  2019-01-28 21:23 [PATCH net 0/2] erspan: always reports output key to userspace Lorenzo Bianconi
  2019-01-28 21:23 ` [PATCH net 1/2] net: ip_gre: always reports o_key " Lorenzo Bianconi
  2019-01-28 21:23 ` [PATCH net 2/2] net: ip6_gre: " Lorenzo Bianconi
@ 2019-01-30 22:00 ` David Miller
  2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2019-01-30 22:00 UTC (permalink / raw)
  To: lorenzo.bianconi; +Cc: netdev, u9012063

From: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
Date: Mon, 28 Jan 2019 22:23:47 +0100

> Erspan protocol relies on output key to set session id header field.
> However TUNNEL_KEY bit is cleared in order to not add key field to
> the external GRE header and so the configured o_key is not reported
> to userspace.
> Fix the issue adding TUNNEL_KEY bit to the o_flags parameter dumping
> device info

Series applied, thanks!

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

end of thread, other threads:[~2019-01-30 23:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-28 21:23 [PATCH net 0/2] erspan: always reports output key to userspace Lorenzo Bianconi
2019-01-28 21:23 ` [PATCH net 1/2] net: ip_gre: always reports o_key " Lorenzo Bianconi
2019-01-28 21:23 ` [PATCH net 2/2] net: ip6_gre: " Lorenzo Bianconi
2019-01-30 22:00 ` [PATCH net 0/2] erspan: always reports output key " David Miller

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.