From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Miller Subject: Re: [PATCHv2 net] ipvlan: call dev_change_flags when ipvlan mode is reset Date: Mon, 02 Jul 2018 20:38:44 +0900 (KST) Message-ID: <20180702.203844.186407000526604117.davem@davemloft.net> References: <1529330677-15328-1-git-send-email-liuhangbin@gmail.com> <1530433281-22743-1-git-send-email-liuhangbin@gmail.com> Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit Cc: netdev@vger.kernel.org, sbrivio@redhat.com, pabeni@redhat.com, maheshb@google.com, xiyou.wangcong@gmail.com, sd@queasysnail.net To: liuhangbin@gmail.com Return-path: Received: from shards.monkeyblade.net ([23.128.96.9]:48602 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933345AbeGBLiw (ORCPT ); Mon, 2 Jul 2018 07:38:52 -0400 In-Reply-To: <1530433281-22743-1-git-send-email-liuhangbin@gmail.com> Sender: netdev-owner@vger.kernel.org List-ID: From: Hangbin Liu Date: Sun, 1 Jul 2018 16:21:21 +0800 > 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. > > v2: > a) As pointed out by Wang Cong, check return value for dev_change_flags() when > change dev flags. > b) As suggested by Stefano and Sabrina, move flags setting before l3mdev_ops. > So we don't need to redo ipvlan_{, un}register_nf_hook() again in err path. > > Reported-by: Jianlin Shi > Reviewed-by: Stefano Brivio > Reviewed-by: Sabrina Dubroca > Fixes: 2ad7bf3638411 ("ipvlan: Initial check-in of the IPVLAN driver.") > Signed-off-by: Hangbin Liu Applied, thank you.