From nobody Tue Apr 7 10:52:40 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 87F47C6FA8B for ; Sat, 17 Sep 2022 20:18:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229628AbiIQUSV (ORCPT ); Sat, 17 Sep 2022 16:18:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37916 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229608AbiIQUSM (ORCPT ); Sat, 17 Sep 2022 16:18:12 -0400 Received: from mail-qk1-x72f.google.com (mail-qk1-x72f.google.com [IPv6:2607:f8b0:4864:20::72f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9575F2E9F0; Sat, 17 Sep 2022 13:18:11 -0700 (PDT) Received: by mail-qk1-x72f.google.com with SMTP id o7so14439671qkj.10; Sat, 17 Sep 2022 13:18:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=rA1J3wNnURwjVaQRzDPJJFo52izXeQrMGO3evzyuiQ0=; b=KxoD7xykKYyawuxkaTKHAsD+UHEKwbfX7XWCNBZe6i7Mgrw0YCsTjl+qKqObCTg6p0 Act4uRMpeCSYfygeT7s2GPeEMjBiZx2NKzesoXaO38hnh+dFLYZeuerbOgD0h7aQpNpA BE4nMBe9E5K6ppuDhZupAYJkurPuEAOIjfUZ3+DIvrYkNz1HBb92lc8uK22slSLy1SkN K4enAfXoM/6wWBxcp/GQlLS2x0PwMU9qyFLWxt9HMB5rFG9TCu0npvbhSMJ6bSsDJQbL VAFQv4WIJnvs+PQX1jJ0r3ctc7FpQRnlvPxkuOLp2BkxE+s7ZRcARsOyU0XsW5DugsVW drZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=rA1J3wNnURwjVaQRzDPJJFo52izXeQrMGO3evzyuiQ0=; b=IOX6Ow5BxJNwiZTEDdZqbXKg/svCFq68o6I+YwOj8qU2ibpH3GTRXgcrV2Gv05XYXv mrC959nLvp4fbekBXZGOCAd0HianQtglbEJH2wmH7lkOjaLl8/NS16tgMluyTzu997aw r0i4rx/p9HRLDX/F9qULiNgrhKmSRgKVei7UH0HJW0ZZZrzVKUqNJsBAZDGEJCmfAH2t dSVF0aM5ZX5oUFeNg9q/d0TYtdCo+uZpdimtbJ3GSpjdMvNsmJUFbKYGdN8/T9+g/Zbp OgXfsC15PpI3QmQUNWeMTOCF2L5CBay0TxzuQNkXSLMMZ0+NQnNoyaZMuKfq3oM/jbf5 6SzA== X-Gm-Message-State: ACrzQf2kTILqB/88KuEPmxPgzolfSkyqcdWm2uFm8x8x8YiUpCPRapog qUEUPX7OstR9Kv+rbnFKPAI= X-Google-Smtp-Source: AMsMyM5ob17a28YWQup5oSo+fcrgZBzZZvGQMtPbfQahiNyXRukM2fBEkogohQnFZJLUANcC9Ea8Nw== X-Received: by 2002:a05:620a:1aa4:b0:6ce:6105:dc3f with SMTP id bl36-20020a05620a1aa400b006ce6105dc3fmr8340523qkb.632.1663445890697; Sat, 17 Sep 2022 13:18:10 -0700 (PDT) Received: from euclid ([71.58.109.160]) by smtp.gmail.com with ESMTPSA id y30-20020a37f61e000000b006a6ebde4799sm8579191qkj.90.2022.09.17.13.18.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Sep 2022 13:18:10 -0700 (PDT) From: Sevinj Aghayeva To: netdev@vger.kernel.org Cc: "David S. Miller" , aroulin@nvidia.com, sbrivio@redhat.com, roopa@nvidia.com, Eric Dumazet , Jakub Kicinski , Paolo Abeni , Nikolay Aleksandrov , linux-kernel@vger.kernel.org, bridge@lists.linux-foundation.org, Sevinj Aghayeva Subject: [PATCH RFC net-next 1/5] net: core: export call_netdevice_notifiers_info Date: Sat, 17 Sep 2022 16:17:57 -0400 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" The function call_netdevice_notifiers_info will be used by the vlan module for sending link-type-specific information to other modules. Signed-off-by: Sevinj Aghayeva --- include/linux/netdevice.h | 2 ++ net/core/dev.c | 5 ++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index f0068c1ff1df..56b96b1e4c4c 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -2906,6 +2906,8 @@ netdev_notifier_info_to_extack(const struct netdev_no= tifier_info *info) } =20 int call_netdevice_notifiers(unsigned long val, struct net_device *dev); +int call_netdevice_notifiers_info(unsigned long val, + struct netdev_notifier_info *info); =20 =20 extern rwlock_t dev_base_lock; /* Device list lock */ diff --git a/net/core/dev.c b/net/core/dev.c index d66c73c1c734..e233145d1452 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -160,8 +160,6 @@ struct list_head ptype_base[PTYPE_HASH_SIZE] __read_mos= tly; struct list_head ptype_all __read_mostly; /* Taps */ =20 static int netif_rx_internal(struct sk_buff *skb); -static int call_netdevice_notifiers_info(unsigned long val, - struct netdev_notifier_info *info); static int call_netdevice_notifiers_extack(unsigned long val, struct net_device *dev, struct netlink_ext_ack *extack); @@ -1927,7 +1925,7 @@ static void move_netdevice_notifiers_dev_net(struct n= et_device *dev, * are as for raw_notifier_call_chain(). */ =20 -static int call_netdevice_notifiers_info(unsigned long val, +int call_netdevice_notifiers_info(unsigned long val, struct netdev_notifier_info *info) { struct net *net =3D dev_net(info->dev); @@ -1944,6 +1942,7 @@ static int call_netdevice_notifiers_info(unsigned lon= g val, return ret; return raw_notifier_call_chain(&netdev_chain, val, info); } +EXPORT_SYMBOL_GPL(call_netdevice_notifiers_info); =20 /** * call_netdevice_notifiers_info_robust - call per-netns notifier blocks --=20 2.34.1 From nobody Tue Apr 7 10:52:40 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 26FF7C6FA82 for ; Sat, 17 Sep 2022 20:18:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229683AbiIQUS0 (ORCPT ); Sat, 17 Sep 2022 16:18:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229586AbiIQUSP (ORCPT ); Sat, 17 Sep 2022 16:18:15 -0400 Received: from mail-qv1-xf34.google.com (mail-qv1-xf34.google.com [IPv6:2607:f8b0:4864:20::f34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BB1B2ED44; Sat, 17 Sep 2022 13:18:14 -0700 (PDT) Received: by mail-qv1-xf34.google.com with SMTP id l14so10735221qvq.8; Sat, 17 Sep 2022 13:18:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=XwRURR16o8IU6+jA9ItEJoRw2ePOvsnk2WOjALj1ZLc=; b=DR6GSoqK3SF1nT3MGrQtB/w9LqHLwFXcSX8bTXMJdecy6L4PTdYMHDmY60jhjLZjgR obsBHNDbljWwVIZ3qfIZ5cQtuLxZGJNXHdL+27mtzzC0UYujs4U2ZU+GAr1RXbfd+A1m 1K/Byn2FoZ+PdItsh+lgCLBB0UlUAgj6vVnxXaWUysi6ZzofsFtL0/iCZhFHgrU5miWU NkMoIEHbrcOXCM4f16+mhM0MyszJl4Db/ywTI4U3msepTQwWoo+obpNDdaIgEKZbdg0/ wRbSgOp8mpS7ZlqHgsTc40AqiiIGYYPP7WqQQrE3/sGDCxFn2g10x/tCYlSvb//kKk/1 oD8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=XwRURR16o8IU6+jA9ItEJoRw2ePOvsnk2WOjALj1ZLc=; b=YdvkOWOkphNtFa7QxY9kytc334Jy930D6FTsYyxdgt9GTurkP0K9f9L2nnNEXSNPDe JKYZEwy8OJXTqsfcDpYz0OPMgWyF7NJzRE+hyGSuoOyZMjGnY4tWp2a+iPOhccCP2J5Y Q3GjyGyOzgQDhbsGnOkz+nX1IyE8h7dCe7my51rwwzzd3kUVN+SUqpyuBVQq2fgQoWz1 vOw/BhGdT7iTMW3uu8LbBfGp+M0z9IZvfZRhhEUn5qC8r6hcAbqF11GqfzSy61sCPW6f tvAUAegPy2dVVeTeB9w+szno4424mjp0S75ng0xiaFcT88H5f3WpIij4g2B2U6QyB/TQ xP2Q== X-Gm-Message-State: ACrzQf3K3jvQzQv2zLmRQNv0xbEEpGzUluC2p1kjYxaJhK8rZutUq1tr yg0ETkQFEhALItyojkmLmqI= X-Google-Smtp-Source: AMsMyM6kpA6kK7/4ITcDIIujrBRqXvPKin1oTiH6aVt/sl5nnK6zp0+UCBzwn+I5hDvMyShWhUWifg== X-Received: by 2002:a05:6214:21ee:b0:4ac:7107:4c23 with SMTP id p14-20020a05621421ee00b004ac71074c23mr8950360qvj.86.1663445893566; Sat, 17 Sep 2022 13:18:13 -0700 (PDT) Received: from euclid ([71.58.109.160]) by smtp.gmail.com with ESMTPSA id do53-20020a05620a2b3500b006cea2984c9bsm6791961qkb.100.2022.09.17.13.18.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Sep 2022 13:18:13 -0700 (PDT) From: Sevinj Aghayeva To: netdev@vger.kernel.org Cc: "David S. Miller" , aroulin@nvidia.com, sbrivio@redhat.com, roopa@nvidia.com, Eric Dumazet , Jakub Kicinski , Paolo Abeni , Nikolay Aleksandrov , linux-kernel@vger.kernel.org, bridge@lists.linux-foundation.org, Sevinj Aghayeva Subject: [PATCH RFC net-next 2/5] net: core: introduce a new notifier for link-type-specific changes Date: Sat, 17 Sep 2022 16:17:58 -0400 Message-Id: <31aa2b6c1eb53812abeaf75f8c01017713eb3cbf.1663445339.git.sevinj.aghayeva@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The netdev notification subsystem is lacking a generic notifier than can pass link-type-specific information alongside the device. For example, the VLAN subsystem needs to notify the bridge of a change in the VLAN bridge brinding flag. This flag change might result in the bridge setting VLAN devices UP or DOWN depending on the state of the bridge ports. Instead of introducing one new NETDEV_* notification just for this specific use-case, introduce a generic notifier which can pass link-type specific information. The notification=E2=80=99s target can decode the union type by checking the type of the target device. That way, other link types will be able to reuse this notification type to notify with their own specific link specific struct. As this notification is only for internal use, there=E2=80=99s no need to export it= to userspace. Other NETDEV_* notifiers have also been looked at to see if it is possible to consolidate: * NETDEV_CHANGEINFODATA: this notification needs to be sent to userspace; keep it separate from NETDEV_CHANGE_DETAILS. * NETDEV_CHANGE: this is to notify net_device->flags change; it is not link-type specific. Signed-off-by: Sevinj Aghayeva --- include/linux/if_vlan.h | 4 ++++ include/linux/netdevice.h | 1 + include/linux/notifier_info.h | 21 +++++++++++++++++++++ net/core/dev.c | 2 +- 4 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 include/linux/notifier_info.h diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h index e00c4ee81ff7..38ffd2ee5112 100644 --- a/include/linux/if_vlan.h +++ b/include/linux/if_vlan.h @@ -37,6 +37,10 @@ struct vlan_hdr { __be16 h_vlan_encapsulated_proto; }; =20 +struct vlan_change_details { + bool bridge_binding; +}; + /** * struct vlan_ethhdr - vlan ethernet header (ethhdr + vlan_hdr) * @h_dest: destination ethernet address diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 56b96b1e4c4c..912c04b09ebb 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -2770,6 +2770,7 @@ enum netdev_cmd { NETDEV_UNREGISTER, NETDEV_CHANGEMTU, /* notify after mtu change happened */ NETDEV_CHANGEADDR, /* notify after the address change */ + NETDEV_CHANGE_DETAILS, NETDEV_PRE_CHANGEADDR, /* notify before the address change */ NETDEV_GOING_DOWN, NETDEV_CHANGENAME, diff --git a/include/linux/notifier_info.h b/include/linux/notifier_info.h new file mode 100644 index 000000000000..3e53f18c6da1 --- /dev/null +++ b/include/linux/notifier_info.h @@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef _LINUX_NOTIFIER_INFO_H_ +#define _LINUX_NOTIFIER_INFO_H_ + +#include +#include + +/* + * This struct is used for passing link-type-specific information to + * the device. + */ + +struct netdev_notifier_change_details_info { + struct netdev_notifier_info info; /* must be first */ + union { + struct vlan_change_details vlan; + }; +}; + +#endif /* !(_LINUX_NOTIFIER_INFO_H_) */ diff --git a/net/core/dev.c b/net/core/dev.c index e233145d1452..b50470378994 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -1622,7 +1622,7 @@ const char *netdev_cmd_to_name(enum netdev_cmd cmd) N(POST_INIT) N(RELEASE) N(NOTIFY_PEERS) N(JOIN) N(CHANGEUPPER) N(RESEND_IGMP) N(PRECHANGEMTU) N(CHANGEINFODATA) N(BONDING_INFO) N(PRECHANGEUPPER) N(CHANGELOWERSTATE) N(UDP_TUNNEL_PUSH_INFO) - N(UDP_TUNNEL_DROP_INFO) N(CHANGE_TX_QUEUE_LEN) + N(UDP_TUNNEL_DROP_INFO) N(CHANGE_TX_QUEUE_LEN) N(CHANGE_DETAILS) N(CVLAN_FILTER_PUSH_INFO) N(CVLAN_FILTER_DROP_INFO) N(SVLAN_FILTER_PUSH_INFO) N(SVLAN_FILTER_DROP_INFO) N(PRE_CHANGEADDR) N(OFFLOAD_XSTATS_ENABLE) N(OFFLOAD_XSTATS_DISABLE) --=20 2.34.1 From nobody Tue Apr 7 10:52:40 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B9D45C6FA82 for ; Sat, 17 Sep 2022 20:18:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229719AbiIQUSd (ORCPT ); Sat, 17 Sep 2022 16:18:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229618AbiIQUSR (ORCPT ); Sat, 17 Sep 2022 16:18:17 -0400 Received: from mail-qk1-x72f.google.com (mail-qk1-x72f.google.com [IPv6:2607:f8b0:4864:20::72f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85C542ED4C; Sat, 17 Sep 2022 13:18:16 -0700 (PDT) Received: by mail-qk1-x72f.google.com with SMTP id g2so15288286qkk.1; Sat, 17 Sep 2022 13:18:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=KD38OQmgSaziFwz483qpbZ1Z/wABtZJQ/6K4DXA6e78=; b=gs9ODi1SU9Kl9RMZdfPPVTL92g9U582A3QyiLLRHk0DP7aMRekW1vpxaCY0DuFyIy4 Gmc4JC2MEREo4YrkmPICVj1cRladnhz9FRB9fiEK9D3+BIlyLccZYLnCIxuHqHwdrsGD dW8uzY5Nr3tOyjePNVIUQBANY0ZAZjFX1So6C4mK1nQlfAAJBFmtz6jCoNsXy7zttZND jKfX1evavoNcmyB5HmuMkKAb5ycpNjp8o+OKvklksejBqwuCTi0YqGk2/+C1AXLVvmLd o8ma7WJJpQUuFiae7662YPBheSg92Qu7bruwrCCM5boqvzkYdsq1aBWq0QBXeiPfQ6Js 14Xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=KD38OQmgSaziFwz483qpbZ1Z/wABtZJQ/6K4DXA6e78=; b=d296d2ejuUjMHgNskUsDjSaet5STLOVCEJhdn1+6UYCng6RB7IRHBpg7DWhSul6Utr LkJrdZYXUB8qtv+2iENLpAkVYC/3k0shl1qgHxrzKVf9DgHYCRX1+No+qKcYldR5NeBG bDwC++VBP3x0M4oHOshbne9lflIt2sstLpYT6x4RIgtRjg6zzSSrfiZwzv/22jwv0lzX a9KpUAAzoj3tJi3cq7TqvWV2xe5KlV9oKiBcrel+TdlSvUunP60TC+KhdVQNq4ZfAPwL d4abinUpPWb4C77ZygqoR7kl2kj9H8cnWVoRfGW3SFtNECk7EQ+29T94RXJBb7z3+pEy qAiw== X-Gm-Message-State: ACrzQf01lk10JtAbIV7dcUX+hRo7OvTFUw9PvspJBZwSAAMVszUDydnB jELo/Kvf/8WnOwchgoK1fAm9X/FaDUEHTyxF X-Google-Smtp-Source: AMsMyM6Ok6WmHv6IRGK6yGFxMFRo9CdplvCq2/ELeU5O7Zh8aUDcrdFmWFDh2DR4PhIfiFuVbfsnHg== X-Received: by 2002:a05:620a:254f:b0:6bc:5763:de4b with SMTP id s15-20020a05620a254f00b006bc5763de4bmr8083968qko.207.1663445895626; Sat, 17 Sep 2022 13:18:15 -0700 (PDT) Received: from euclid ([71.58.109.160]) by smtp.gmail.com with ESMTPSA id q13-20020a37f70d000000b006b8e63dfffbsm8769539qkj.58.2022.09.17.13.18.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Sep 2022 13:18:15 -0700 (PDT) From: Sevinj Aghayeva To: netdev@vger.kernel.org Cc: "David S. Miller" , aroulin@nvidia.com, sbrivio@redhat.com, roopa@nvidia.com, Eric Dumazet , Jakub Kicinski , Paolo Abeni , Nikolay Aleksandrov , linux-kernel@vger.kernel.org, bridge@lists.linux-foundation.org, Sevinj Aghayeva Subject: [PATCH RFC net-next 3/5] net: 8021q: notify bridge module of bridge-binding flag change Date: Sat, 17 Sep 2022 16:17:59 -0400 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Notify the bridge module when a user changes the bridge-binding flag of a VLAN interface using "ip link set ... vlan bridge_binding on" command, so that the bridge module can take the appropriate action for this change. Signed-off-by: Sevinj Aghayeva --- net/8021q/vlan.h | 2 +- net/8021q/vlan_dev.c | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/net/8021q/vlan.h b/net/8021q/vlan.h index 5eaf38875554..71947cdcfaaa 100644 --- a/net/8021q/vlan.h +++ b/net/8021q/vlan.h @@ -130,7 +130,7 @@ void vlan_dev_set_ingress_priority(const struct net_dev= ice *dev, int vlan_dev_set_egress_priority(const struct net_device *dev, u32 skb_prio, u16 vlan_prio); void vlan_dev_free_egress_priority(const struct net_device *dev); -int vlan_dev_change_flags(const struct net_device *dev, u32 flag, u32 mask= ); +int vlan_dev_change_flags(struct net_device *dev, u32 flag, u32 mask); void vlan_dev_get_realdev_name(const struct net_device *dev, char *result, size_t size); =20 diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c index e1bb41a443c4..7c61b813e654 100644 --- a/net/8021q/vlan_dev.c +++ b/net/8021q/vlan_dev.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -211,8 +212,9 @@ int vlan_dev_set_egress_priority(const struct net_devic= e *dev, /* Flags are defined in the vlan_flags enum in * include/uapi/linux/if_vlan.h file. */ -int vlan_dev_change_flags(const struct net_device *dev, u32 flags, u32 mas= k) +int vlan_dev_change_flags(struct net_device *dev, u32 flags, u32 mask) { + struct netdev_notifier_change_details_info details; struct vlan_dev_priv *vlan =3D vlan_dev_priv(dev); u32 old_flags =3D vlan->flags; =20 @@ -223,19 +225,31 @@ int vlan_dev_change_flags(const struct net_device *de= v, u32 flags, u32 mask) =20 vlan->flags =3D (old_flags & ~mask) | (flags & mask); =20 - if (netif_running(dev) && (vlan->flags ^ old_flags) & VLAN_FLAG_GVRP) { + if (!netif_running(dev)) + return 0; + + if ((vlan->flags ^ old_flags) & VLAN_FLAG_GVRP) { if (vlan->flags & VLAN_FLAG_GVRP) vlan_gvrp_request_join(dev); else vlan_gvrp_request_leave(dev); } =20 - if (netif_running(dev) && (vlan->flags ^ old_flags) & VLAN_FLAG_MVRP) { + if ((vlan->flags ^ old_flags) & VLAN_FLAG_MVRP) { if (vlan->flags & VLAN_FLAG_MVRP) vlan_mvrp_request_join(dev); else vlan_mvrp_request_leave(dev); } + + if ((vlan->flags ^ old_flags) & VLAN_FLAG_BRIDGE_BINDING && + netif_is_bridge_master(vlan->real_dev)) { + details.info.dev =3D dev; + details.vlan.bridge_binding =3D + !!(vlan->flags & VLAN_FLAG_BRIDGE_BINDING); + call_netdevice_notifiers_info(NETDEV_CHANGE_DETAILS, &details.info); + } + return 0; } =20 --=20 2.34.1 From nobody Tue Apr 7 10:52:40 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 493D8C6FA82 for ; Sat, 17 Sep 2022 20:18:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229733AbiIQUSi (ORCPT ); Sat, 17 Sep 2022 16:18:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229635AbiIQUST (ORCPT ); Sat, 17 Sep 2022 16:18:19 -0400 Received: from mail-qk1-x729.google.com (mail-qk1-x729.google.com [IPv6:2607:f8b0:4864:20::729]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67D1A2ED44; Sat, 17 Sep 2022 13:18:18 -0700 (PDT) Received: by mail-qk1-x729.google.com with SMTP id h28so18150612qka.0; Sat, 17 Sep 2022 13:18:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=W7xcUTJ+Xi3/2c+HEMlnIJrwY7Px5v+GX+wSId5EDcY=; b=MWAjhl+xoCtoaOvlX5qq05l39uxVSoxvIlUaU55ko4WaCeYDNkn0oncD0EiX46yoQt ccbjdN3leY+2tL2T1iPG0AqZri5cOUHdEloinZbEdwtjquCkGvhnn6olCwK9n6KsuZc9 PfzXa7Z7yvrCO3hT97TvsXKKFkl9MwxaWwpfFP3ODGWKl7nlHsnh2OpBrCQw7O6inAho 8Bl/kbDWxvu9mez4VtcPkke48/0Chbnh/gzTRZtox9jwpEeuNfWbOc7DWXTxRSsLtBVz hgpo8sQOTKAOI+JTFU9jiRXpul6ILHO7TxsHOtmbdgSRAf0vEleLgFrP1p2S301/TlZV QoPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=W7xcUTJ+Xi3/2c+HEMlnIJrwY7Px5v+GX+wSId5EDcY=; b=wat/1XZnmMB8jB0nzHLFiRgl24KkLCia6XqtMsXCHxyRfJmhIFAbPRHr06bxp6sA+m QNsS1Fn6GLCt44e9LnTzKqgWEpkikKFZlEtJsbTKrgnb4KTYX2Zi08x3FcWP4Euu/Evw 4/CqLXxJodszqN7OqjEZdfgie7CC4ypayDi65plCTTXwg05VRw065sYF/SxtzPF9G1+L lus+7aybSdjsiLpILtrjyxhDbqKnCFG/TOKtOepeMGfY7tm4/a5zLgpqMH2kKfdvwQ5L A+ePE9PyNbLQtqWF4tI7NzvW/gPzjJuZZOgi0zT3uY7BI0oYjLMUo2YmJf5asKwqc08M U1yQ== X-Gm-Message-State: ACrzQf3dsQh/oGFDT8s1iWUXeD4AecKax4XXJ0VmV5nDmdMmRBe3WATb qZtm+vGmApyG/r1j/eEnCLo= X-Google-Smtp-Source: AMsMyM6iUxZzKpNhK/xvKNJBH21tgFbn0d8acYZSQ3UJuauQl/86HAVdFvqViqcHMOKe4c6+4ROcrA== X-Received: by 2002:a05:620a:2681:b0:6b5:b60c:1e66 with SMTP id c1-20020a05620a268100b006b5b60c1e66mr8303008qkp.99.1663445897521; Sat, 17 Sep 2022 13:18:17 -0700 (PDT) Received: from euclid ([71.58.109.160]) by smtp.gmail.com with ESMTPSA id s21-20020a05620a0bd500b006bb7ccf6855sm10374577qki.76.2022.09.17.13.18.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Sep 2022 13:18:17 -0700 (PDT) From: Sevinj Aghayeva To: netdev@vger.kernel.org Cc: "David S. Miller" , aroulin@nvidia.com, sbrivio@redhat.com, roopa@nvidia.com, Eric Dumazet , Jakub Kicinski , Paolo Abeni , Nikolay Aleksandrov , linux-kernel@vger.kernel.org, bridge@lists.linux-foundation.org, Sevinj Aghayeva Subject: [PATCH RFC net-next 4/5] net: bridge: handle link-type-specific changes in the bridge module Date: Sat, 17 Sep 2022 16:18:00 -0400 Message-Id: <8ef43d44ebdebe90783325cb68edb70a7c80c038.1663445339.git.sevinj.aghayeva@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Introduce a handler to bridge module for handling vlan-specific events. Signed-off-by: Sevinj Aghayeva --- net/bridge/br.c | 5 +++++ net/bridge/br_private.h | 7 +++++++ net/bridge/br_vlan.c | 18 ++++++++++++++++++ 3 files changed, 30 insertions(+) diff --git a/net/bridge/br.c b/net/bridge/br.c index 96e91d69a9a8..62e939c6a3f0 100644 --- a/net/bridge/br.c +++ b/net/bridge/br.c @@ -51,6 +51,11 @@ static int br_device_event(struct notifier_block *unused= , unsigned long event, v } } =20 + if (is_vlan_dev(dev)) { + br_vlan_device_event(dev, event, ptr); + return NOTIFY_DONE; + } + /* not a port of a bridge */ p =3D br_port_get_rtnl(dev); if (!p) diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h index 06e5f6faa431..a9a08e49c76c 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h @@ -1470,6 +1470,8 @@ void br_vlan_get_stats(const struct net_bridge_vlan *= v, void br_vlan_port_event(struct net_bridge_port *p, unsigned long event); int br_vlan_bridge_event(struct net_device *dev, unsigned long event, void *ptr); +void br_vlan_device_event(struct net_device *dev, unsigned long event, + void *ptr); void br_vlan_rtnl_init(void); void br_vlan_rtnl_uninit(void); void br_vlan_notify(const struct net_bridge *br, @@ -1701,6 +1703,11 @@ static inline int br_vlan_bridge_event(struct net_de= vice *dev, return 0; } =20 +static void br_vlan_device_event(struct net_device *dev, + unsigned long event, void *ptr) +{ +} + static inline void br_vlan_rtnl_init(void) { } diff --git a/net/bridge/br_vlan.c b/net/bridge/br_vlan.c index 6e53dc991409..ba4e3c7a5f03 100644 --- a/net/bridge/br_vlan.c +++ b/net/bridge/br_vlan.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only #include #include +#include #include #include #include @@ -1768,6 +1769,23 @@ void br_vlan_port_event(struct net_bridge_port *p, u= nsigned long event) } } =20 +void br_vlan_device_event(struct net_device *dev, + unsigned long event, void *ptr) +{ + struct netdev_notifier_change_details_info *details; + struct net_device *br_dev; + + switch (event) { + case NETDEV_CHANGE_DETAILS: + details =3D ptr; + if (!netif_is_bridge_master(vlan_dev_priv(dev)->real_dev)) + break; + br_dev =3D vlan_dev_priv(dev)->real_dev; + br_vlan_upper_change(br_dev, dev, details->vlan.bridge_binding); + break; + } +} + static bool br_vlan_stats_fill(struct sk_buff *skb, const struct net_bridge_vlan *v) { --=20 2.34.1 From nobody Tue Apr 7 10:52:40 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2FEF7ECAAA1 for ; Sat, 17 Sep 2022 20:18:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229743AbiIQUSn (ORCPT ); Sat, 17 Sep 2022 16:18:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38096 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229676AbiIQUSW (ORCPT ); Sat, 17 Sep 2022 16:18:22 -0400 Received: from mail-qv1-xf2d.google.com (mail-qv1-xf2d.google.com [IPv6:2607:f8b0:4864:20::f2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 782302ED51; Sat, 17 Sep 2022 13:18:20 -0700 (PDT) Received: by mail-qv1-xf2d.google.com with SMTP id z9so7710876qvn.9; Sat, 17 Sep 2022 13:18:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=00Tw4Iguiga6FIJOQTAU2+b9Codsgvfv3AG/3wKNVqM=; b=FZ7G+W/tFDZsg5m8et+ZfWZX+4PjaCgi1eksG5u4CCRchWpmUEt0I9eG42xBA6HxzT QrStOK1km8P3bBa6dBMtGK8g5roVU03R/aPWl2v+GNYPN+NQAXum8o6fWr6UGnN4DEKS 4pUa6MJqvPGMaE95CrmUwMhtL9PlDy6kvS+rWlujoGhNcCMe/rfMjIwSYeTQ8/SvcOud gGCSxfMpapJPzvRqtt+CXvjcoc5ftKp/egs1LDyErvMbwJs9/yyUVmyDqyU0d6To4HQy JudEstUVnQdsOG3q55dmFOlfRmqZa6iEMFQ9CiVeeil4neoDiRXj1IlqAi4mxb1KAJCl TxnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=00Tw4Iguiga6FIJOQTAU2+b9Codsgvfv3AG/3wKNVqM=; b=4dMWhpYphs84DQ+D6Hd91Zf5W1fazsw+gVJsRz1YTiTc82SVWYYtDnP9OcEOPEHKUQ yqpObK9vxOyuDsAKUL5LH0Yn/aLsLo4fVP43+ZH/263Yoqs/+V9S7RSMILeqqMiXOrLm ORPyeuxFUxuvcW6H1Os9opzC4DdHjxXjffECe398Ki9cqXA4y9EFWevODtmoFkEs7ph6 Y8PjyPJrtyaYrGF67OpDiq8jVls1tWpG48g0m294LzoNRaYMl0rZXRbhUROQ0nvHIrhO 79z0GJrzRizJV+VJe58cV81AFNTzSk9UjC3iCOiRNj4/Iy0ahcFNoehzc6uteM4ovK8G GIrA== X-Gm-Message-State: ACrzQf1stkA4kDJhNCblbLeBXcv6+xPwUpaCt+FeEPZ16/3JaeObtpBp IwJ113C/NYbTxG6kt4cTkT8= X-Google-Smtp-Source: AMsMyM6idTlZ53YB1hY5TEa6/BimH2eRTDY7cE0gD3aQdMJGBGm3G32SrIhP0qOGJiE3SkIvTMSUtA== X-Received: by 2002:a05:6214:4006:b0:48d:3f52:52e7 with SMTP id kd6-20020a056214400600b0048d3f5252e7mr9262865qvb.113.1663445899504; Sat, 17 Sep 2022 13:18:19 -0700 (PDT) Received: from euclid ([71.58.109.160]) by smtp.gmail.com with ESMTPSA id x8-20020ac85388000000b0035bafecff78sm7280790qtp.74.2022.09.17.13.18.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Sep 2022 13:18:19 -0700 (PDT) From: Sevinj Aghayeva To: netdev@vger.kernel.org Cc: "David S. Miller" , aroulin@nvidia.com, sbrivio@redhat.com, roopa@nvidia.com, Eric Dumazet , Jakub Kicinski , Paolo Abeni , Nikolay Aleksandrov , linux-kernel@vger.kernel.org, bridge@lists.linux-foundation.org, Sevinj Aghayeva Subject: [PATCH RFC net-next 5/5] selftests: net: tests for bridge binding behavior Date: Sat, 17 Sep 2022 16:18:01 -0400 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This patch adds two tests in a single file. The first of these is in function run_test_late_bridge_binding_set, which tests that when a vlan interface is created with bridge binding turned off, and later bridge binding is turned on (using ip link set... command), the vlan interface behaves accordingly, that is, it tracks the status of the ports in its vlan. The second test, which is in function run_test_multiple_vlan, tests that when there are two vlan interfaces with bridge binding turned on, turning off the bridge binding in one of the vlan interfaces does not affect the bridge binding on the other interface. Signed-off-by: Sevinj Aghayeva --- tools/testing/selftests/net/Makefile | 1 + .../selftests/net/bridge_vlan_binding_test.sh | 143 ++++++++++++++++++ 2 files changed, 144 insertions(+) create mode 100755 tools/testing/selftests/net/bridge_vlan_binding_test.sh diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests= /net/Makefile index f5ac1433c301..48443928c3dd 100644 --- a/tools/testing/selftests/net/Makefile +++ b/tools/testing/selftests/net/Makefile @@ -44,6 +44,7 @@ TEST_PROGS +=3D arp_ndisc_untracked_subnets.sh TEST_PROGS +=3D stress_reuseport_listen.sh TEST_PROGS +=3D l2_tos_ttl_inherit.sh TEST_PROGS +=3D bind_bhash.sh +TEST_PROGS +=3D bridge_vlan_binding_test.sh TEST_PROGS_EXTENDED :=3D in_netns.sh setup_loopback.sh setup_veth.sh TEST_PROGS_EXTENDED +=3D toeplitz_client.sh toeplitz.sh TEST_GEN_FILES =3D socket nettest diff --git a/tools/testing/selftests/net/bridge_vlan_binding_test.sh b/tool= s/testing/selftests/net/bridge_vlan_binding_test.sh new file mode 100755 index 000000000000..d094d847800c --- /dev/null +++ b/tools/testing/selftests/net/bridge_vlan_binding_test.sh @@ -0,0 +1,143 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0-or-later + +cleanup() { + # Remove interfaces created by the previous run + ip link delete veth10 2>/dev/null + ip link delete veth20 2>/dev/null + ip link delete veth30 2>/dev/null + ip link delete br_default 2>/dev/null +} + +trap cleanup EXIT + +setup() { + cleanup + + # Create a bridge and add three ports to it. + ip link add dev br_default type bridge + ip link add dev veth10 type veth peer name veth11 + ip link add dev veth20 type veth peer name veth21 + ip link add dev veth30 type veth peer name veth31 + ip link set dev veth10 master br_default + ip link set dev veth20 master br_default + ip link set dev veth30 master br_default + + # Create VLAN 10 and VLAN 20. + bridge vlan add vid 10 dev br_default self + bridge vlan add vid 20 dev br_default self + + # Add veth10 to VLAN 10 and veth20 to VLAN 20. + bridge vlan add vid 10 dev veth10 + bridge vlan add vid 20 dev veth20 + + # Bring up the ports and the bridge. + ip link set veth10 up + ip link set veth11 up + ip link set veth20 up + ip link set veth21 up + ip link set veth30 up + ip link set veth31 up + ip link set br_default up +} + +# This test checks that when a vlan interface is created with bridge +# binding off, and then bridge binding turned on using "ip link set" +# command, bridge binding is actually turned on -- this hasn't been +# the case in the past. +run_test_late_bridge_binding_set() { + setup + + # Add VLAN interface vlan10 to VLAN 10 with bridge binding off. + ip link add link br_default name vlan10 type vlan id 10 protocol \ + 802.1q bridge_binding off + + # Bring up VLAN interface. + ip link set vlan10 up + + # Turn bridge binding on for vlan10. + ip link set vlan10 type vlan bridge_binding on + + # Bring down the port in vlan 10. + ip link set veth10 down + + # Since bridge binding is turned on for vlan10 interface, it + # should be tracking only the port, veth10 in its vlan. Since + # veth10 is down, vlan10 should be down as well. + if ! ip link show vlan10 | grep -q 'state LOWERLAYERDOWN'; then + echo "FAIL - vlan10 should be LOWERLAYERDOWN but it is not" + exit 1 + fi + + # Bringe the port back up. + ip link set veth10 up + + # The vlan 10 interface should be up now. + if ! ip link show vlan10 | grep -q 'state UP'; then + echo "FAIL - vlan10 should be UP but it is not" + exit 1 + fi + + echo "OK" +} + +# This test checks that when there are multiple vlan interfaces with +# bridge binding on, turning off bride binding in one of the vlan +# interfaces does not affect the bridge binding of the other +# interface. +run_test_multiple_vlan() { + setup + + # Add VLAN interface vlan10 to VLAN 10 with bridge binding on. + ip link add link br_default name vlan10 type vlan id 10 protocol \ + 802.1q bridge_binding on + # Add VLAN interface vlan20 to VLAN 20 with bridge binding on. + ip link add link br_default name vlan20 type vlan id 20 protocol \ + 802.1q bridge_binding on + + # Bring up VLAN interfaces. + ip link set vlan10 up + ip link set vlan20 up + + # Turn bridge binding off for vlan10. + ip link set vlan10 type vlan bridge_binding off + + # Bring down the ports in vlans 10 and 20. + ip link set veth10 down + ip link set veth20 down + + # Since bridge binding is off for vlan10 interface, it should + # be tracking all of the ports in the bridge; since veth30 is + # still up, vlan10 should also be up. + if ! ip link show vlan10 | grep -q 'state UP'; then + echo "FAIL - vlan10 should be UP but it is not" + exit 1 + fi + + # Since bridge binding is on for vlan20 interface, it should + # be tracking only the ports in its vlan. This port is veth20, + # and it is down; therefore, vlan20 should be down as well. + if ! ip link show vlan20 | grep -q 'state LOWERLAYERDOWN'; then + echo "FAIL - vlan20 should be LOWERLAYERDOWN but it is not" + exit 1 + fi + + # Bring the ports back up. + ip link set veth10 up + ip link set veth20 up + + # Both vlan interfaces should be up now. + if ! ip link show vlan10 | grep -q 'state UP'; then + echo "FAIL - vlan10 should be UP but it is not" + exit 1 + fi + if ! ip link show vlan20 | grep -q 'state UP' ; then + echo "FAIL - vlan20 should be UP but it is not" + exit 1 + fi + + echo "OK" +} + +run_test_late_bridge_binding_set +run_test_multiple_vlan --=20 2.34.1