From patchwork Wed Aug 9 15:39:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Sitnicki X-Patchwork-Id: 799841 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@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=) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3xSFnG3PSWz9s65 for ; Thu, 10 Aug 2017 01:39:30 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753461AbdHIPjQ (ORCPT ); Wed, 9 Aug 2017 11:39:16 -0400 Received: from mail-wr0-f171.google.com ([209.85.128.171]:34268 "EHLO mail-wr0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752467AbdHIPjP (ORCPT ); Wed, 9 Aug 2017 11:39:15 -0400 Received: by mail-wr0-f171.google.com with SMTP id c24so19818552wra.1 for ; Wed, 09 Aug 2017 08:39:15 -0700 (PDT) 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=hN3mctjArznaRAum4X49Krx74jYYETwa2EfAJKpnlN4=; b=KZCwgEaeaIbXB4lqLMUHB3+CNpv0VKCkFtdeJ6HY3SgQZJnuDCRuutCQMGdCriIG1N XucopqHIBM8BUNpvfpn3awvA3KBQ/hH5kNsfdxAQl02wgP6p3sOC8gANURDjreNz7+px viAm6d2KWIdQzmhmmVxf5vwgflq/887TTcpRAXcQfV1/TDdUU41enZR6GiEg663/biNn iHGIiDXS54c9Szdse+YhGYLE+qaJNlAdUVNEmfGcyDxsn8nXGTv8Lr1GQiefJ7zDrB/l EzfoBc3qM1c0SHKzWLU2aP3Yc1GMZUWT5DVkYglX5YAIcr5xw9WtK8LJngxtkQ06f+IF ckJA== X-Gm-Message-State: AHYfb5iF0r4Z+O8lwjr3kbIh2lYU7BYRx4vbXNre8FO1ktOtB6Tx64Kz xMzhEJVpXHA1vtIQj6SyZQ== X-Received: by 10.223.157.4 with SMTP id k4mr7099909wre.270.1502293154206; Wed, 09 Aug 2017 08:39:14 -0700 (PDT) Received: from redhat.com (red-hat-inc.vlan404.asr1.mad1.gblx.net. [64.215.113.190]) by smtp.gmail.com with ESMTPSA id p133sm2987685wme.0.2017.08.09.08.39.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 09 Aug 2017 08:39:13 -0700 (PDT) From: Jakub Sitnicki To: netdev@vger.kernel.org Cc: "David S. Miller" Subject: [PATCH net-next] rtnelink: Move link dump consistency check out of the loop Date: Wed, 9 Aug 2017 17:39:12 +0200 Message-Id: <20170809153912.19733-1-jkbs@redhat.com> X-Mailer: git-send-email 2.9.4 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Calls to rtnl_dump_ifinfo() are protected by RTNL lock. So are the {list,unlist}_netdevice() calls where we bump the net->dev_base_seq number. For this reason net->dev_base_seq can't change under out feet while we're looping over links in rtnl_dump_ifinfo(). So move the check for net->dev_base_seq change (since the last time we were called) out of the loop. This way we avoid giving a wrong impression that there are concurrent updates to the link list going on while we're iterating over them. Signed-off-by: Jakub Sitnicki --- net/core/rtnetlink.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 9201e36..6b7888e 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -1644,8 +1644,6 @@ static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb) s_h = cb->args[0]; s_idx = cb->args[1]; - cb->seq = net->dev_base_seq; - /* A hack to preserve kernel<->userspace interface. * The correct header is ifinfomsg. It is consistent with rtnl_getlink. * However, before Linux v3.9 the code here assumed rtgenmsg and that's @@ -1691,8 +1689,6 @@ static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb) goto out_err; } - - nl_dump_check_consistent(cb, nlmsg_hdr(skb)); cont: idx++; } @@ -1702,6 +1698,8 @@ static int rtnl_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb) out_err: cb->args[1] = idx; cb->args[0] = h; + cb->seq = net->dev_base_seq; + nl_dump_check_consistent(cb, nlmsg_hdr(skb)); return err; }