diff mbox series

[net] ip_gre: clear feature flags when incompatible o_flags are set

Message ID a989fb36846d45587455e648ed4e8ff8707bcee2.1523357388.git.sd@queasysnail.net
State Accepted, archived
Delegated to: David Miller
Headers show
Series [net] ip_gre: clear feature flags when incompatible o_flags are set | expand

Commit Message

Sabrina Dubroca April 10, 2018, 10:57 a.m. UTC
Commit dd9d598c6657 ("ip_gre: add the support for i/o_flags update via
netlink") added the ability to change o_flags, but missed that the
GSO/LLTX features are disabled by default, and only enabled some gre
features are unused. Thus we also need to disable the GSO/LLTX features
on the device when the TUNNEL_SEQ or TUNNEL_CSUM flags are set.

These two examples should result in the same features being set:

    ip link add gre_none type gre local 192.168.0.10 remote 192.168.0.20 ttl 255 key 0

    ip link set gre_none type gre seq
    ip link add gre_seq type gre local 192.168.0.10 remote 192.168.0.20 ttl 255 key 1 seq

Fixes: dd9d598c6657 ("ip_gre: add the support for i/o_flags update via netlink")
Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
---
 net/ipv4/ip_gre.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Xin Long April 10, 2018, 1:10 p.m. UTC | #1
On Tue, Apr 10, 2018 at 6:57 PM, Sabrina Dubroca <sd@queasysnail.net> wrote:
> Commit dd9d598c6657 ("ip_gre: add the support for i/o_flags update via
> netlink") added the ability to change o_flags, but missed that the
> GSO/LLTX features are disabled by default, and only enabled some gre
> features are unused. Thus we also need to disable the GSO/LLTX features
> on the device when the TUNNEL_SEQ or TUNNEL_CSUM flags are set.
>
> These two examples should result in the same features being set:
>
>     ip link add gre_none type gre local 192.168.0.10 remote 192.168.0.20 ttl 255 key 0
>
>     ip link set gre_none type gre seq
>     ip link add gre_seq type gre local 192.168.0.10 remote 192.168.0.20 ttl 255 key 1 seq
>
> Fixes: dd9d598c6657 ("ip_gre: add the support for i/o_flags update via netlink")
> Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
> ---
>  net/ipv4/ip_gre.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
> index a8772a978224..9c169bb2444d 100644
> --- a/net/ipv4/ip_gre.c
> +++ b/net/ipv4/ip_gre.c
> @@ -781,8 +781,14 @@ static void ipgre_link_update(struct net_device *dev, bool set_mtu)
>                     tunnel->encap.type == TUNNEL_ENCAP_NONE) {
>                         dev->features |= NETIF_F_GSO_SOFTWARE;
>                         dev->hw_features |= NETIF_F_GSO_SOFTWARE;
> +               } else {
> +                       dev->features &= ~NETIF_F_GSO_SOFTWARE;
> +                       dev->hw_features &= ~NETIF_F_GSO_SOFTWARE;
>                 }
>                 dev->features |= NETIF_F_LLTX;
> +       } else {
> +               dev->hw_features &= ~NETIF_F_GSO_SOFTWARE;
> +               dev->features &= ~(NETIF_F_LLTX | NETIF_F_GSO_SOFTWARE);
>         }
>  }
>
> --
> 2.16.2
>
Reviewed-by: Xin Long <lucien.xin@gmail.com>
William Tu April 10, 2018, 1:36 p.m. UTC | #2
On Tue, Apr 10, 2018 at 6:10 AM, Xin Long <lucien.xin@gmail.com> wrote:
> On Tue, Apr 10, 2018 at 6:57 PM, Sabrina Dubroca <sd@queasysnail.net> wrote:
>> Commit dd9d598c6657 ("ip_gre: add the support for i/o_flags update via
>> netlink") added the ability to change o_flags, but missed that the
>> GSO/LLTX features are disabled by default, and only enabled some gre
>> features are unused. Thus we also need to disable the GSO/LLTX features
>> on the device when the TUNNEL_SEQ or TUNNEL_CSUM flags are set.
>>
>> These two examples should result in the same features being set:
>>
>>     ip link add gre_none type gre local 192.168.0.10 remote 192.168.0.20 ttl 255 key 0
>>
>>     ip link set gre_none type gre seq
>>     ip link add gre_seq type gre local 192.168.0.10 remote 192.168.0.20 ttl 255 key 1 seq
>>
>> Fixes: dd9d598c6657 ("ip_gre: add the support for i/o_flags update via netlink")
>> Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>
>> ---

Looks good to me.
Acked-by: William Tu <u9012063@gmail.com>


>>  net/ipv4/ip_gre.c | 6 ++++++
>>  1 file changed, 6 insertions(+)
>>
>> diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
>> index a8772a978224..9c169bb2444d 100644
>> --- a/net/ipv4/ip_gre.c
>> +++ b/net/ipv4/ip_gre.c
>> @@ -781,8 +781,14 @@ static void ipgre_link_update(struct net_device *dev, bool set_mtu)
>>                     tunnel->encap.type == TUNNEL_ENCAP_NONE) {
>>                         dev->features |= NETIF_F_GSO_SOFTWARE;
>>                         dev->hw_features |= NETIF_F_GSO_SOFTWARE;
>> +               } else {
>> +                       dev->features &= ~NETIF_F_GSO_SOFTWARE;
>> +                       dev->hw_features &= ~NETIF_F_GSO_SOFTWARE;
>>                 }
>>                 dev->features |= NETIF_F_LLTX;
>> +       } else {
>> +               dev->hw_features &= ~NETIF_F_GSO_SOFTWARE;
>> +               dev->features &= ~(NETIF_F_LLTX | NETIF_F_GSO_SOFTWARE);
>>         }
>>  }
>>
>> --
>> 2.16.2
>>
> Reviewed-by: Xin Long <lucien.xin@gmail.com>
David Miller April 10, 2018, 3:04 p.m. UTC | #3
From: Sabrina Dubroca <sd@queasysnail.net>
Date: Tue, 10 Apr 2018 12:57:18 +0200

> Commit dd9d598c6657 ("ip_gre: add the support for i/o_flags update via
> netlink") added the ability to change o_flags, but missed that the
> GSO/LLTX features are disabled by default, and only enabled some gre
> features are unused. Thus we also need to disable the GSO/LLTX features
> on the device when the TUNNEL_SEQ or TUNNEL_CSUM flags are set.
> 
> These two examples should result in the same features being set:
> 
>     ip link add gre_none type gre local 192.168.0.10 remote 192.168.0.20 ttl 255 key 0
> 
>     ip link set gre_none type gre seq
>     ip link add gre_seq type gre local 192.168.0.10 remote 192.168.0.20 ttl 255 key 1 seq
> 
> Fixes: dd9d598c6657 ("ip_gre: add the support for i/o_flags update via netlink")
> Signed-off-by: Sabrina Dubroca <sd@queasysnail.net>

Applied and queued up for -stable, thank you.
diff mbox series

Patch

diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index a8772a978224..9c169bb2444d 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -781,8 +781,14 @@  static void ipgre_link_update(struct net_device *dev, bool set_mtu)
 		    tunnel->encap.type == TUNNEL_ENCAP_NONE) {
 			dev->features |= NETIF_F_GSO_SOFTWARE;
 			dev->hw_features |= NETIF_F_GSO_SOFTWARE;
+		} else {
+			dev->features &= ~NETIF_F_GSO_SOFTWARE;
+			dev->hw_features &= ~NETIF_F_GSO_SOFTWARE;
 		}
 		dev->features |= NETIF_F_LLTX;
+	} else {
+		dev->hw_features &= ~NETIF_F_GSO_SOFTWARE;
+		dev->features &= ~(NETIF_F_LLTX | NETIF_F_GSO_SOFTWARE);
 	}
 }