netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] ipvlan: call dev_change_flags when reset ipvlan mode
@ 2018-06-18 14:04 Hangbin Liu
  2018-06-19 21:10 ` Cong Wang
  2018-07-01  8:21 ` [PATCHv2 net] ipvlan: call dev_change_flags when ipvlan mode is reset Hangbin Liu
  0 siblings, 2 replies; 8+ messages in thread
From: Hangbin Liu @ 2018-06-18 14:04 UTC (permalink / raw)
  To: netdev
  Cc: Stefano Brivio, Paolo Abeni, David Miller, Mahesh Bandewar,
	Hangbin Liu

After we change the ipvlan mode from l3 to l2, or vice versa. We only
reset IFF_NOARP flag, but don't flush the ARP table cache, which will
cause eth->h_dest to be equal to eth->h_source in ipvlan_xmit_mode_l2().
Then the message will not come out of host.

Here is the reproducer on local host:

ip link set eth1 up
ip addr add 192.168.1.1/24 dev eth1
ip link add link eth1 ipvlan1 type ipvlan mode l3

ip netns add net1
ip link set ipvlan1 netns net1
ip netns exec net1 ip link set ipvlan1 up
ip netns exec net1 ip addr add 192.168.2.1/24 dev ipvlan1

ip route add 192.168.2.0/24 via 192.168.1.2
ping 192.168.2.2 -c 2

ip netns exec net1 ip link set ipvlan1 type ipvlan mode l2
ping 192.168.2.2 -c 2

Add the same configuration on remote host. After we set the mode to l2,
we could find that the src/dst MAC addresses are the same on eth1:

21:26:06.648565 00:b7:13:ad:d3:05 > 00:b7:13:ad:d3:05, ethertype IPv4 (0x0800), length 98: (tos 0x0, ttl 64, id 58356, offset 0, flags [DF], proto ICMP (1), length 84)
    192.168.2.1 > 192.168.2.2: ICMP echo request, id 22686, seq 1, length 64

Fix this by calling dev_change_flags(), which will call netdevice notifier
with flag change info.

Reported-by: Jianlin Shi <jishi@redhat.com>
Reviewed-by: Stefano Brivio <sbrivio@redhat.com>
Fixes: 2ad7bf3638411 ("ipvlan: Initial check-in of the IPVLAN driver.")
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
 drivers/net/ipvlan/ipvlan_main.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ipvlan/ipvlan_main.c b/drivers/net/ipvlan/ipvlan_main.c
index 4377c26..368712b 100644
--- a/drivers/net/ipvlan/ipvlan_main.c
+++ b/drivers/net/ipvlan/ipvlan_main.c
@@ -75,6 +75,7 @@ static int ipvlan_set_port_mode(struct ipvl_port *port, u16 nval)
 {
 	struct ipvl_dev *ipvlan;
 	struct net_device *mdev = port->dev;
+	unsigned int flags;
 	int err = 0;
 
 	ASSERT_RTNL();
@@ -94,10 +95,13 @@ static int ipvlan_set_port_mode(struct ipvl_port *port, u16 nval)
 			mdev->l3mdev_ops = NULL;
 		}
 		list_for_each_entry(ipvlan, &port->ipvlans, pnode) {
+			flags = ipvlan->dev->flags;
 			if (nval == IPVLAN_MODE_L3 || nval == IPVLAN_MODE_L3S)
-				ipvlan->dev->flags |= IFF_NOARP;
+				dev_change_flags(ipvlan->dev,
+						 flags | IFF_NOARP);
 			else
-				ipvlan->dev->flags &= ~IFF_NOARP;
+				dev_change_flags(ipvlan->dev,
+						 flags & ~IFF_NOARP);
 		}
 		port->mode = nval;
 	}
-- 
2.5.5

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

end of thread, other threads:[~2018-07-02 11:38 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-06-18 14:04 [PATCH net] ipvlan: call dev_change_flags when reset ipvlan mode Hangbin Liu
2018-06-19 21:10 ` Cong Wang
2018-06-20  3:22   ` Hangbin Liu
2018-06-20  5:31     ` David Miller
2018-06-20 17:45       ` Cong Wang
2018-06-21  1:18         ` Hangbin Liu
2018-07-01  8:21 ` [PATCHv2 net] ipvlan: call dev_change_flags when ipvlan mode is reset Hangbin Liu
2018-07-02 11:38   ` 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).