* [PATCH net] vxlan: fix unexpected failure of vxlan_changelink()
@ 2019-10-30 8:15 Taehee Yoo
2019-10-30 18:55 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Taehee Yoo @ 2019-10-30 8:15 UTC (permalink / raw)
To: davem, roopa, netdev; +Cc: ap420073
After commit 0ce1822c2a08 ("vxlan: add adjacent link to limit depth
level"), vxlan_changelink() could fail because of
netdev_adjacent_change_prepare().
netdev_adjacent_change_prepare() returns -EEXIST when old lower device
and new lower device are same.
(old lower device is "dst->remote_dev" and new lower device is "lowerdev")
So, before calling it, lowerdev should be NULL if these devices are same.
Test command1:
ip link add dummy0 type dummy
ip link add vxlan0 type vxlan dev dummy0 dstport 4789 vni 1
ip link set vxlan0 type vxlan ttl 5
RTNETLINK answers: File exists
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Fixes: 0ce1822c2a08 ("vxlan: add adjacent link to limit depth level")
Signed-off-by: Taehee Yoo <ap420073@gmail.com>
---
drivers/net/vxlan.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index fcf028220bca..a01b8ddaa44a 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -3965,6 +3965,9 @@ static int vxlan_changelink(struct net_device *dev, struct nlattr *tb[],
if (err)
return err;
+ if (dst->remote_dev == lowerdev)
+ lowerdev = NULL;
+
err = netdev_adjacent_change_prepare(dst->remote_dev, lowerdev, dev,
extack);
if (err)
@@ -4006,10 +4009,10 @@ static int vxlan_changelink(struct net_device *dev, struct nlattr *tb[],
mod_timer(&vxlan->age_timer, jiffies);
netdev_adjacent_change_commit(dst->remote_dev, lowerdev, dev);
- if (lowerdev && lowerdev != dst->remote_dev)
+ if (lowerdev && lowerdev != dst->remote_dev) {
dst->remote_dev = lowerdev;
-
- netdev_update_lockdep_key(lowerdev);
+ netdev_update_lockdep_key(lowerdev);
+ }
vxlan_config_apply(dev, &conf, lowerdev, vxlan->net, true);
return 0;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net] vxlan: fix unexpected failure of vxlan_changelink()
2019-10-30 8:15 [PATCH net] vxlan: fix unexpected failure of vxlan_changelink() Taehee Yoo
@ 2019-10-30 18:55 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2019-10-30 18:55 UTC (permalink / raw)
To: ap420073; +Cc: roopa, netdev
From: Taehee Yoo <ap420073@gmail.com>
Date: Wed, 30 Oct 2019 08:15:12 +0000
> After commit 0ce1822c2a08 ("vxlan: add adjacent link to limit depth
> level"), vxlan_changelink() could fail because of
> netdev_adjacent_change_prepare().
> netdev_adjacent_change_prepare() returns -EEXIST when old lower device
> and new lower device are same.
> (old lower device is "dst->remote_dev" and new lower device is "lowerdev")
> So, before calling it, lowerdev should be NULL if these devices are same.
>
> Test command1:
> ip link add dummy0 type dummy
> ip link add vxlan0 type vxlan dev dummy0 dstport 4789 vni 1
> ip link set vxlan0 type vxlan ttl 5
> RTNETLINK answers: File exists
>
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Fixes: 0ce1822c2a08 ("vxlan: add adjacent link to limit depth level")
> Signed-off-by: Taehee Yoo <ap420073@gmail.com>
Applied, thank you.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-10-30 18:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-30 8:15 [PATCH net] vxlan: fix unexpected failure of vxlan_changelink() Taehee Yoo
2019-10-30 18:55 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).