From patchwork Mon Jun 18 14:04:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 930879 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming-netdev@ozlabs.org Delivered-To: patchwork-incoming-netdev@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="eR7232yE"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 418Xss3YdJz9s2t for ; Tue, 19 Jun 2018 00:05:05 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933445AbeFROE7 (ORCPT ); Mon, 18 Jun 2018 10:04:59 -0400 Received: from mail-pf0-f193.google.com ([209.85.192.193]:38711 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754321AbeFROE6 (ORCPT ); Mon, 18 Jun 2018 10:04:58 -0400 Received: by mail-pf0-f193.google.com with SMTP id b74-v6so8230119pfl.5 for ; Mon, 18 Jun 2018 07:04:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=JWCbi06sf60TL2yy/+5qoJ8qI3pSQkghrANtQWPumcw=; b=eR7232yEw3oVszUKghVjyMpd4wlbYYswcZjzbRFTuvRnjaY/0LKmFWtkR56J9CtEbG 5IajPP8SJQW/X/vgLrX6/Bx/ZjJh94/8QDoHnKty3p/mTaxPtP6z05UtR3tgn0KoAviB OdQisy1kxM95NXYTc0L7zcBBHOo8742GSXHoAOM9UW/A9+gIgNpcv/h35UEIujU6veO+ Qjw0AHDF9HQpePa2tsf/wXZDP7cER9BkfnagH5vquXL4iuP1FyR2o1Tprz1fvVbX+47Y a56rFe/6s3VIAVLicm4JBE0ny7E7AhHE3qkkwb1gTvxvhtzvin3n8TiD22+gAQ58PWd/ ryGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=JWCbi06sf60TL2yy/+5qoJ8qI3pSQkghrANtQWPumcw=; b=s1poPCwvVbWcsFruf9QZhqiwe0dikykA0nC2zO5aIzMBpxOl0n8bAHZ7q0E+ebypBT 6oWAqftA67TUrjZFy40KTxGzlGceQmzcMCJ2/NrYRN9fdqLA4MhqPmgvLZ8HGb9bVWmg XgWJkMa9UefLC6QWTyJYdJLk2r5Vjktl3MxxN6+F9W6VJWUwnEUJJVowRQDTMHNJDTVH HvfM8vjhQ7safn0rr2BWcz+nwM+zZhmVdkjRXKID10Zoab4UNfyBfhlTgjXaV65BNoTi OtuLrm1di0SXht+FbgUEwwUM/e1dLeqmyY2xAQsX5RHN1cxqTk077cLLwQKmLxZiRJSs j7+w== X-Gm-Message-State: APt69E2uj0/YsTCl/u0P+0dIP0MrjuR3jtxgu8rZcq+/4z/AYAWz+veZ fXoSjobSf0JNYJVsYYsfIjKzU/J0 X-Google-Smtp-Source: ADUXVKIQ4nvDzPVBHs9g+teZamzrQTC54HI7VPV5g8Dnrl+w339ThN8bO+ZdM1VpMeA1HRUn02/HCQ== X-Received: by 2002:a62:e903:: with SMTP id j3-v6mr13803296pfh.228.1529330697312; Mon, 18 Jun 2018 07:04:57 -0700 (PDT) Received: from leo.usersys.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id y10-v6sm21374682pgr.44.2018.06.18.07.04.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Jun 2018 07:04:56 -0700 (PDT) From: Hangbin Liu To: netdev@vger.kernel.org Cc: Stefano Brivio , Paolo Abeni , David Miller , Mahesh Bandewar , Hangbin Liu Subject: [PATCH net] ipvlan: call dev_change_flags when reset ipvlan mode Date: Mon, 18 Jun 2018 22:04:37 +0800 Message-Id: <1529330677-15328-1-git-send-email-liuhangbin@gmail.com> X-Mailer: git-send-email 2.5.5 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 Reviewed-by: Stefano Brivio Fixes: 2ad7bf3638411 ("ipvlan: Initial check-in of the IPVLAN driver.") Signed-off-by: Hangbin Liu --- 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; }