Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2024546ybl; Thu, 29 Aug 2019 02:26:53 -0700 (PDT) X-Google-Smtp-Source: APXvYqwqwaEcGsB4YYBJ/oM3Cpn9oXI38lqT8C2lHw3/9F5XuQFVib4p0gnzzno6ywHta1u4M0g1 X-Received: by 2002:a17:902:4401:: with SMTP id k1mr8844804pld.193.1567070813228; Thu, 29 Aug 2019 02:26:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567070813; cv=none; d=google.com; s=arc-20160816; b=KqO2HwXA/ImgLazqj1jZtZdc3HSHVEmiGXwLStUQjisC/KEdcQJO6OtNjI9sYC0TD4 X4vX6ODZgFfyOGABfHC3ai+EXPTxKPe1cr8GcEblQsp59ABPtdJMLJ60IZgAMhk4J9Xp 5TfVUmxLCMcPvcZe6yo5Ac3d7QTwSRdNdPrWHbPwza7Sg91pl7kmIV+8gqX73P0oUYu8 i4oWsvM7UIDjrt6FlMoW8qLG/IF8xjsR1XbGX5rkexURvVbZax4M1vRSLcWBD49Hdqs5 9wHLT4j2BkP1qLfPTb6PgPmxe/gFyHwROJ98Oqa30idzZmjOaK5biDQnLfB4SnQisHXc Sr7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:ironport-sdr; bh=68QJuIhlAECDLL1RyHPWUz9VECKPjOyHMB68Rgd1VxQ=; b=vbDk2GWiuxQETH648Eh012iHEYWekVul3UToHA4Asu7xYX53GIP7owHjD5DibIJ/rH rOc0X3TU45XEmrnDikoYiUV3XZTxNoOEVd+zegKw2RbIjyqG7TLkwY63VTiqa1ghH5gj MDj8b2y72Askg5gf39W9eAxNbs/v5b6gTvC3fp+giClXXXYEUpKqGWfDP34YPlAedkFD 5rzidn1+IssGE/mNSsxdztDdx9I9J/5TwHnMTf/G3bixFtjdBMi1xP5rCtFBFJ4qGYFB bU++6zgttGtoAZkcEift2YwC2nfe4BaTXfbGKNp/pwJa3FoyIQJMARbMAWQzVwdG0zvv EINA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=microchip.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y63si1515257pgd.403.2019.08.29.02.26.38; Thu, 29 Aug 2019 02:26:53 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727930AbfH2JYU (ORCPT + 99 others); Thu, 29 Aug 2019 05:24:20 -0400 Received: from esa4.microchip.iphmx.com ([68.232.154.123]:57642 "EHLO esa4.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726009AbfH2JYT (ORCPT ); Thu, 29 Aug 2019 05:24:19 -0400 Received-SPF: Pass (esa4.microchip.iphmx.com: domain of Horatiu.Vultur@microchip.com designates 198.175.253.82 as permitted sender) identity=mailfrom; client-ip=198.175.253.82; receiver=esa4.microchip.iphmx.com; envelope-from="Horatiu.Vultur@microchip.com"; x-sender="Horatiu.Vultur@microchip.com"; x-conformance=spf_only; x-record-type="v=spf1"; x-record-text="v=spf1 mx a:ushub1.microchip.com a:smtpout.microchip.com a:mx1.microchip.iphmx.com a:mx2.microchip.iphmx.com include:servers.mcsv.net include:mktomail.com include:spf.protection.outlook.com ~all" Received-SPF: None (esa4.microchip.iphmx.com: no sender authenticity information available from domain of postmaster@email.microchip.com) identity=helo; client-ip=198.175.253.82; receiver=esa4.microchip.iphmx.com; envelope-from="Horatiu.Vultur@microchip.com"; x-sender="postmaster@email.microchip.com"; x-conformance=spf_only Authentication-Results: esa4.microchip.iphmx.com; dkim=none (message not signed) header.i=none; spf=Pass smtp.mailfrom=Horatiu.Vultur@microchip.com; spf=None smtp.helo=postmaster@email.microchip.com; dmarc=pass (p=none dis=none) d=microchip.com IronPort-SDR: K9qjtGmCkJXBZS9NtJNMUdFoe0jVZbYtANKuCmWcNL+LbstwSn9gMVdmw8mhY90L5hmvky6dkC srJgJAytZf/v+TdHfCL1faz9HTq9co5ufWD1gHxEyrsz3pTiRDf3NgmOciNK6+3g3qAb+mzW5l jRXsoUMCQjFAUVeFBynQjcep5sWVa+IaH0AHwTM6zlpCl/gaL5Z3iqv3BxJ8wPEdM3Hsf6vZtR vIsjIDHX2sgtV8jD9ItnyDuzfl/9vOv9PNQr+ZWGl6Ro8ag7oiHFHBauLqes2A9OSYhmH3fhxE OYM= X-IronPort-AV: E=Sophos;i="5.64,442,1559545200"; d="scan'208";a="46054437" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 29 Aug 2019 02:24:17 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Thu, 29 Aug 2019 02:24:14 -0700 Received: from soft-dev3.microsemi.net (10.10.85.251) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.1713.5 via Frontend Transport; Thu, 29 Aug 2019 02:24:14 -0700 From: Horatiu Vultur To: , , , , , , , , , CC: Horatiu Vultur Subject: [PATCH v3 1/2] net: core: Notify on changes to dev->promiscuity. Date: Thu, 29 Aug 2019 11:22:28 +0200 Message-ID: <1567070549-29255-2-git-send-email-horatiu.vultur@microchip.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1567070549-29255-1-git-send-email-horatiu.vultur@microchip.com> References: <1567070549-29255-1-git-send-email-horatiu.vultur@microchip.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add the SWITCHDEV_ATTR_ID_PORT_PROMISCUITY switchdev notification type, used to indicate whenever the dev promiscuity counter is changed. The notification doesn't use any switchdev_attr attribute because in the notifier callbacks is it possible to get the dev and read directly the promiscuity value. Signed-off-by: Horatiu Vultur --- include/net/switchdev.h | 1 + net/core/dev.c | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/include/net/switchdev.h b/include/net/switchdev.h index aee86a1..14b1617 100644 --- a/include/net/switchdev.h +++ b/include/net/switchdev.h @@ -40,6 +40,7 @@ enum switchdev_attr_id { SWITCHDEV_ATTR_ID_BRIDGE_VLAN_FILTERING, SWITCHDEV_ATTR_ID_BRIDGE_MC_DISABLED, SWITCHDEV_ATTR_ID_BRIDGE_MROUTER, + SWITCHDEV_ATTR_ID_PORT_PROMISCUITY, }; struct switchdev_attr { diff --git a/net/core/dev.c b/net/core/dev.c index 49589ed..40c74f2 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -142,6 +142,7 @@ #include #include #include +#include #include "net-sysfs.h" @@ -7377,6 +7378,11 @@ static void dev_change_rx_flags(struct net_device *dev, int flags) static int __dev_set_promiscuity(struct net_device *dev, int inc, bool notify) { unsigned int old_flags = dev->flags; + struct switchdev_attr attr = { + .orig_dev = dev, + .id = SWITCHDEV_ATTR_ID_PORT_PROMISCUITY, + .flags = SWITCHDEV_F_DEFER, + }; kuid_t uid; kgid_t gid; @@ -7419,6 +7425,9 @@ static int __dev_set_promiscuity(struct net_device *dev, int inc, bool notify) } if (notify) __dev_notify_flags(dev, old_flags, IFF_PROMISC); + + switchdev_port_attr_set(dev, &attr); + return 0; } -- 2.7.4