From patchwork Tue May 21 10:23:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Timo Teras X-Patchwork-Id: 245256 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 6C44B2C00AB for ; Tue, 21 May 2013 20:23:01 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753409Ab3EUKWz (ORCPT ); Tue, 21 May 2013 06:22:55 -0400 Received: from mail-ee0-f48.google.com ([74.125.83.48]:38218 "EHLO mail-ee0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752655Ab3EUKWy (ORCPT ); Tue, 21 May 2013 06:22:54 -0400 Received: by mail-ee0-f48.google.com with SMTP id b47so274890eek.7 for ; Tue, 21 May 2013 03:22:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:mime-version:content-type:content-transfer-encoding; bh=0fbIp5EAynJ6F3HYwjpi/CPihrRJZ3T+T7yg1ZQUJgc=; b=kpJfKWS+lq6i513XU0bguLeKoUcvXvSeBpR6AVRTOHbHFWCGTB2k18JJdu++lIdrEu 9uv3f+MEcst16Rmqu7vZhRp02zxFENAU0g+kusf6+wdsMrUdlGirnzQLBxSZjKVjlLFs NRG1cM0Y5ws3J1PMn+eRvy9t9R1Y5iOigAEZXPGhGJYYbVJmvgaJhkfVbNflSn40qKhL Vl5+fEsls8h7U52e9x8NfFuJ4Jx3bHL7sQNC6B3QgYOsQWAjlPWChDq4lQL80DSIssr0 nj4HFc5cjCfMrURCB61vSc3ZTsJDONvVvZY5BUIhroXlI4COyc2eUZrU5eVeFxHyHJtC rD4Q== X-Received: by 10.14.206.136 with SMTP id l8mr4906372eeo.26.1369131771866; Tue, 21 May 2013 03:22:51 -0700 (PDT) Received: from vostro.util.wtbts.net ([83.145.235.199]) by mx.google.com with ESMTPSA id s43sm2364074eem.13.2013.05.21.03.22.50 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 21 May 2013 03:22:50 -0700 (PDT) From: =?UTF-8?q?Timo=20Ter=C3=A4s?= To: David Miller , netdev@vger.kernel.org, kaber@trash.net Cc: =?UTF-8?q?Timo=20Ter=C3=A4s?= Subject: [PATCH v2 net-next] arp: flush arp cache on IFF_NOARP change Date: Tue, 21 May 2013 13:23:44 +0300 Message-Id: <1369131824-6318-1-git-send-email-timo.teras@iki.fi> X-Mailer: git-send-email 1.8.2.3 In-Reply-To: <20130520.134633.448574202175922639.davem@davemloft.net> References: <20130520.134633.448574202175922639.davem@davemloft.net> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org IFF_NOARP affects what kind of neighbor entries are created (nud NOARP or nud INCOMPLETE). If the flag changes, flush the arp cache to refresh all entries. Signed-off-by: Timo Teräs --- > This patch makes no sense at all. > > The state bit in ->priv_flags is a boolean stating whether the > notified should do something or not. > > But you're setting it to match what IFF_NOARP is. > > You should set it any time IFF_NOARP _changes_, and then clear > the bit when the notifier clears the neighbour entries. IFF_NOARP_CHANGED is set according to "changes = dev->flags ^ old_flags;" which reflect the change. But I agree that the clearing out bit was misplaced. This is especially true as it seems NETDEV_CHANGE can be notified from another place too. I've updated the if.h comment to state that the bit is valid only during NETDEV_CHANGE notifier. And __dev_notify_flags is updated to always clear the bit after notifiers are done. include/uapi/linux/if.h | 2 ++ net/core/dev.c | 6 +++++- net/ipv4/arp.c | 4 ++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/uapi/linux/if.h b/include/uapi/linux/if.h index 1ec407b..1be8b35 100644 --- a/include/uapi/linux/if.h +++ b/include/uapi/linux/if.h @@ -83,6 +83,8 @@ #define IFF_SUPP_NOFCS 0x80000 /* device supports sending custom FCS */ #define IFF_LIVE_ADDR_CHANGE 0x100000 /* device supports hardware address * change when it's running */ +#define IFF_NOARP_CHANGED 0x200000 /* Set during NETDEV_CHANGE notifier + * if IFF_NOARP has changed */ #define IF_GET_IFACE 0x0001 /* for querying only */ diff --git a/net/core/dev.c b/net/core/dev.c index 18e9730..ce30761 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -4699,8 +4699,12 @@ void __dev_notify_flags(struct net_device *dev, unsigned int old_flags) } if (dev->flags & IFF_UP && - (changes & ~(IFF_UP | IFF_PROMISC | IFF_ALLMULTI | IFF_VOLATILE))) + (changes & ~(IFF_UP | IFF_PROMISC | IFF_ALLMULTI | IFF_VOLATILE))) { + if (changes & IFF_NOARP) + dev->priv_flags |= IFF_NOARP_CHANGED; call_netdevice_notifiers(NETDEV_CHANGE, dev); + dev->priv_flags &= ~IFF_NOARP_CHANGED; + } } /** diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c index 247ec19..375b2f2 100644 --- a/net/ipv4/arp.c +++ b/net/ipv4/arp.c @@ -1241,6 +1241,10 @@ static int arp_netdev_event(struct notifier_block *this, unsigned long event, neigh_changeaddr(&arp_tbl, dev); rt_cache_flush(dev_net(dev)); break; + case NETDEV_CHANGE: + if (dev->priv_flags & IFF_NOARP_CHANGED) + neigh_changeaddr(&arp_tbl, dev); + break; default: break; }