geneve: show remote address and checksum info even after link down
Subsystems (2)
PATCH 1/1 geneve: show remote address and checksum info even after link down
geneve->sock4/6 were added with geneve_open and released with geneve_stop. So when geneve link down, we will not able to show remote address and checksum info after commit 11387fe4a98 ("geneve: fix fill_info when using collect_metadata").
Fix this by reset back to the previous behavior: only show the corresponding remote address and always show checksum info.
--- drivers/net/geneve.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-)
drivers/net/geneve.c +11 -17
@@ -1511,32 +1511,18 @@ static int geneve_fill_info(struct sk_buff *skb, const struct net_device *dev)if (nla_put_u32 (skb,IFLA_GENEVE_ID , vni)) goto nla_put_failure; -if (rtnl_dereference (geneve->sock4)) { +if (ip_tunnel_info_af (info) ==AF_INET ) {if (nla_put_in_addr (skb,IFLA_GENEVE_REMOTE , info->key.u.ipv4.dst)) goto nla_put_failure; -if (nla_put_u8 (skb,IFLA_GENEVE_UDP_CSUM , - !!(info->key.tun_flags &TUNNEL_CSUM ))) - goto nla_put_failure; - - } -#if IS_ENABLED (CONFIG_IPV6 ) -if (rtnl_dereference (geneve->sock6)) { + } else {if (nla_put_in6_addr (skb,IFLA_GENEVE_REMOTE6 , &info->key.u.ipv6.dst)) goto nla_put_failure; - -if (nla_put_u8 (skb,IFLA_GENEVE_UDP_ZERO_CSUM6_TX , - !(info->key.tun_flags &TUNNEL_CSUM ))) - goto nla_put_failure; - -if (nla_put_u8 (skb,IFLA_GENEVE_UDP_ZERO_CSUM6_RX , - !geneve->use_udp6_rx_checksums)) - goto nla_put_failure; - }#endif + } if (nla_put_u8(skb, IFLA_GENEVE_TTL, info->key.ttl) || nla_put_u8(skb, IFLA_GENEVE_TOS, info->key.tos) ||
@@ -1550,6 +1536,14 @@ static int geneve_fill_info(struct sk_buff *skb, const struct net_device *dev)if (nla_put_flag (skb,IFLA_GENEVE_COLLECT_METADATA )) goto nla_put_failure; } + +if (nla_put_u8 (skb,IFLA_GENEVE_UDP_CSUM , + !!(info->key.tun_flags &TUNNEL_CSUM )) || +nla_put_u8 (skb,IFLA_GENEVE_UDP_ZERO_CSUM6_TX , + !(info->key.tun_flags &TUNNEL_CSUM )) || +nla_put_u8 (skb,IFLA_GENEVE_UDP_ZERO_CSUM6_RX , + !geneve->use_udp6_rx_checksums)) + goto nla_put_failure;return 0 ; nla_put_failure:
Signature · 1 line
2.5.5
Quoted 7 lines · Hangbin Liu
geneve->sock4/6 were added with
geneve_openand released withgeneve_stop. So when geneve link down, we will not able to show remote address and checksum info after commit11387fe4a98("geneve: fixfill_infowhen usingcollect_metadata").Fix this by reset back to the previous behavior: only show the corresponding remote address and always show checksum info.
Thanks Hangbin,
I think we can do better though and maybe avoid another round of this churn.
Quoted 12 lines
Fixes 11387fe4a98 ("geneve: fix fill_info when using collect_metadata")Signed-off-by Hangbin Liu <[email protected]>--- drivers/net/geneve.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-)drivers/net/geneve.c +0
-0
drivers/net/geneve.c static int geneve_fill_info(struct sk_buff *skb, const struct net_device *dev) · line 1518
Quoted 9 lines
drivers/net/geneve.c +1
-1@@ -1511,32 +1511,18 @@ static int geneve_fill_info(struct sk_buff *skb, const struct net_device *dev)if (nla_put_u32 (skb,IFLA_GENEVE_ID , vni)) goto nla_put_failure; -if (rtnl_dereference (geneve->sock4)) { +if (ip_tunnel_info_af (info) ==AF_INET ) {if (nla_put_in_addr (skb,IFLA_GENEVE_REMOTE , info->key.u.ipv4.dst)) goto nla_put_failure;
We can avoid passing up *_REMOTE{,6} for COLLECT_METADATA. They're mutually exclusive.
Quoted 27 lines
drivers/net/geneve.c +2
-16-if (nla_put_u8 (skb,IFLA_GENEVE_UDP_CSUM , - !!(info->key.tun_flags &TUNNEL_CSUM ))) - goto nla_put_failure; - - } -#if IS_ENABLED (CONFIG_IPV6 ) -if (rtnl_dereference (geneve->sock6)) { + } else {if (nla_put_in6_addr (skb,IFLA_GENEVE_REMOTE6 , &info->key.u.ipv6.dst)) goto nla_put_failure; - -if (nla_put_u8 (skb,IFLA_GENEVE_UDP_ZERO_CSUM6_TX , - !(info->key.tun_flags &TUNNEL_CSUM ))) - goto nla_put_failure; - -if (nla_put_u8 (skb,IFLA_GENEVE_UDP_ZERO_CSUM6_RX , - !geneve->use_udp6_rx_checksums)) - goto nla_put_failure; - }#endif + } if (nla_put_u8(skb, IFLA_GENEVE_TTL, info->key.ttl) || nla_put_u8(skb, IFLA_GENEVE_TOS, info->key.tos) ||
drivers/net/geneve.c static int geneve_fill_info(struct sk_buff *skb, const struct net_device *dev) · line 1543
Quoted 8 lines
drivers/net/geneve.c +5
-0@@ -1550,6 +1536,14 @@ static int geneve_fill_info(struct sk_buff *skb, const struct net_device *dev)if (nla_put_flag (skb,IFLA_GENEVE_COLLECT_METADATA )) goto nla_put_failure; } + + if (nla_put_u8(skb, IFLA_GENEVE_UDP_CSUM, + !!(info->key.tun_flags & TUNNEL_CSUM)) || + nla_put_u8(skb, IFLA_GENEVE_UDP_ZERO_CSUM6_TX, + !(info->key.tun_flags & TUNNEL_CSUM)) ||
These two are nonsensical for COLLECT_METADATA as they come from the skb tun_info. They can be moved to inside the ipv4/ipv6 checks. For non-metadata, it doesn't make sense to pass them both as the tunnel is either ipv4 or ipv6, but not both.
Quoted 6 lines
drivers/net/geneve.c +3
-0+ nla_put_u8(skb, IFLA_GENEVE_UDP_ZERO_CSUM6_RX, + !geneve->use_udp6_rx_checksums)) + goto nla_put_failure;return 0 ; nla_put_failure:
Hi Eric,
Thanks for the comments.
Quoted 14 lines · Eric Garver
Quoted 14 lines
Fixes 11387fe4a98 ("geneve: fix fill_info when using collect_metadata")Signed-off-by Hangbin Liu <[email protected]>--- drivers/net/geneve.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-)drivers/net/geneve.c +0
-0@@ -1511,32 +1511,18 @@ static int geneve_fill_info(struct sk_buff *skb, const struct net_device *dev)if (nla_put_u32 (skb,IFLA_GENEVE_ID , vni)) goto nla_put_failure;
Quoted 9 lines
drivers/net/geneve.c static int geneve_fill_info(struct sk_buff *skb, const struct net_device *dev) · line 1518
Quoted 6 lines
drivers/net/geneve.c +1
-1-if (rtnl_dereference (geneve->sock4)) { +if (ip_tunnel_info_af (info) ==AF_INET ) {if (nla_put_in_addr (skb,IFLA_GENEVE_REMOTE , info->key.u.ipv4.dst)) goto nla_put_failure;We can avoid passing up *_REMOTE{,6} for
COLLECT_METADATA. They're mutually exclusive.
Do you mean something like
+ bool metadata = geneve->collect_md;
- if (rtnl_dereference(geneve->sock4)) {
+ if (!metadata && ip_tunnel_info_af(info) == AF_INET) {Quoted 10 lines
drivers/net/geneve.c static int geneve_fill_info(struct sk_buff *skb, const struct net_device *dev) · line 1520
Quoted 10 lines
drivers/net/geneve.c +1
-7-if (nla_put_u8 (skb,IFLA_GENEVE_UDP_CSUM , - !!(info->key.tun_flags &TUNNEL_CSUM ))) - goto nla_put_failure; - - } -#if IS_ENABLED (CONFIG_IPV6 ) -if (rtnl_dereference (geneve->sock6)) { + } else {
and
- if (rtnl_dereference(geneve->sock6)) {
+ } else if (!metadata) {
?
Quoted 10 lines
drivers/net/geneve.c static int geneve_fill_info(struct sk_buff *skb, const struct net_device *dev) · line 1543
Quoted 5 lines
drivers/net/geneve.c +5
-0+ + if (nla_put_u8(skb, IFLA_GENEVE_UDP_CSUM, + !!(info->key.tun_flags & TUNNEL_CSUM)) || + nla_put_u8(skb, IFLA_GENEVE_UDP_ZERO_CSUM6_TX, + !(info->key.tun_flags & TUNNEL_CSUM)) ||These two are nonsensical for
COLLECT_METADATAas they come from the skbtun_info. They can be moved to inside the ipv4/ipv6 checks. For non-metadata, it doesn't make sense to pass them both as the tunnel is either ipv4 or ipv6, but not both.
OK, I will put them back to the ipv4/6 chunks.
Thanks
Hangbin
Quoted 31 lines · Hangbin Liu
Hi Eric,
Thanks for the comments.
Quoted 14 lines · Eric Garver
Quoted 14 lines
Fixes 11387fe4a98 ("geneve: fix fill_info when using collect_metadata")Signed-off-by Hangbin Liu <[email protected]>--- drivers/net/geneve.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-)drivers/net/geneve.c +0
-0@@ -1511,32 +1511,18 @@ static int geneve_fill_info(struct sk_buff *skb, const struct net_device *dev)if (nla_put_u32 (skb,IFLA_GENEVE_ID , vni)) goto nla_put_failure;Quoted 9 lines
drivers/net/geneve.c static int geneve_fill_info(struct sk_buff *skb, const struct net_device *dev) · line 1518
Quoted 6 lines
drivers/net/geneve.c +1
-1-if (rtnl_dereference (geneve->sock4)) { +if (ip_tunnel_info_af (info) ==AF_INET ) {if (nla_put_in_addr (skb,IFLA_GENEVE_REMOTE , info->key.u.ipv4.dst)) goto nla_put_failure;We can avoid passing up *_REMOTE{,6} for
COLLECT_METADATA. They're mutually exclusive.Do you mean something like
Review
Quoted 3 lines
(quoted diff) +2
-1+ bool metadata = geneve->collect_md; - if (rtnl_dereference(geneve->sock4)) { + if (!metadata && ip_tunnel_info_af(info) == AF_INET) {
Yes.
Quoted 16 lines
Quoted 10 lines
drivers/net/geneve.c static int geneve_fill_info(struct sk_buff *skb, const struct net_device *dev) · line 1520
Quoted 10 lines
drivers/net/geneve.c +1
-7-if (nla_put_u8 (skb,IFLA_GENEVE_UDP_CSUM , - !!(info->key.tun_flags &TUNNEL_CSUM ))) - goto nla_put_failure; - - } -#if IS_ENABLED (CONFIG_IPV6 ) -if (rtnl_dereference (geneve->sock6)) { + } else {and
(quoted diff) +1
-1- if (rtnl_dereference(geneve->sock6)) { + } else if (!metadata) {
Quoted 1 line
?
Yes.
PATCH v2 1/1 geneve: fix fill_info when link down
In reply to Hangbin Liugeneve->sock4/6 were added with geneve_open and released with geneve_stop. So when geneve link down, we will not able to show remote address and checksum info after commit 11387fe4a98 ("geneve: fix fill_info when using collect_metadata").
Fix this by avoid passing *_REMOTE{,6} for COLLECT_METADATA since they are mutually exclusive, and always show UDP_ZERO_CSUM6_RX info.
--- drivers/net/geneve.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-)
drivers/net/geneve.c +10 -14
@@ -1503,6 +1503,7 @@ static int geneve_fill_info(struct sk_buff *skb, const struct net_device *dev) {struct geneve_dev *geneve =netdev_priv (dev);struct ip_tunnel_info *info = &geneve->info; +bool metadata = geneve->collect_md;__u8 tmp_vni[3 ];__u32 vni;
@@ -1511,32 +1512,24 @@ static int geneve_fill_info(struct sk_buff *skb, const struct net_device *dev)if (nla_put_u32 (skb,IFLA_GENEVE_ID , vni)) goto nla_put_failure; -if (rtnl_dereference (geneve->sock4)) { +if (!metadata &&ip_tunnel_info_af (info) ==AF_INET ) {if (nla_put_in_addr (skb,IFLA_GENEVE_REMOTE , info->key.u.ipv4.dst)) goto nla_put_failure; -if (nla_put_u8 (skb,IFLA_GENEVE_UDP_CSUM , !!(info->key.tun_flags &TUNNEL_CSUM ))) goto nla_put_failure; - } -#if IS_ENABLED (CONFIG_IPV6 ) -if (rtnl_dereference (geneve->sock6)) { + } else if (!metadata) {if (nla_put_in6_addr (skb,IFLA_GENEVE_REMOTE6 , &info->key.u.ipv6.dst)) goto nla_put_failure; -if (nla_put_u8 (skb,IFLA_GENEVE_UDP_ZERO_CSUM6_TX , !(info->key.tun_flags &TUNNEL_CSUM ))) goto nla_put_failure; - -if (nla_put_u8 (skb,IFLA_GENEVE_UDP_ZERO_CSUM6_RX , - !geneve->use_udp6_rx_checksums)) - goto nla_put_failure; - }#endif + } if (nla_put_u8(skb, IFLA_GENEVE_TTL, info->key.ttl) || nla_put_u8(skb, IFLA_GENEVE_TOS, info->key.tos) ||
@@ -1546,10 +1539,13 @@ static int geneve_fill_info(struct sk_buff *skb, const struct net_device *dev)if (nla_put_be16 (skb,IFLA_GENEVE_PORT , info->key.tp_dst)) goto nla_put_failure; -if (geneve->collect_md) { -if (nla_put_flag (skb,IFLA_GENEVE_COLLECT_METADATA )) +if (metadata &&nla_put_flag (skb,IFLA_GENEVE_COLLECT_METADATA )) goto nla_put_failure; - } + +if (nla_put_u8 (skb,IFLA_GENEVE_UDP_ZERO_CSUM6_RX , + !geneve->use_udp6_rx_checksums)) + goto nla_put_failure; +return 0 ; nla_put_failure:
Signature · 1 line
2.5.5
Re: [PATCHv2 net] geneve: fix fill_info when link down
From: Hangbin Liu <[email protected]>
Date: Wed, 15 Nov 2017 09:43:09 +0800
Quoted 10 lines
geneve->sock4/6 were added with
geneve_openand released withgeneve_stop. So when geneve link down, we will not able to show remote address and checksum info after commit11387fe4a98("geneve: fixfill_infowhen usingcollect_metadata").Fix this by avoid passing *_REMOTE{,6} for
COLLECT_METADATAsince they are mutually exclusive, and always showUDP_ZERO_CSUM6_RXinfo.Fixes 11387fe4a98 ("geneve: fix fill_info when using collect_metadata")Signed-off-by Hangbin Liu <[email protected]>
Applied.