From patchwork Fri Sep 4 09:15:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Henrik Bjoernlund X-Patchwork-Id: 261528 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AFA94C43461 for ; Fri, 4 Sep 2020 09:19:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6FCF120748 for ; Fri, 4 Sep 2020 09:19:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b="hJt8cp/k" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730095AbgIDJTK (ORCPT ); Fri, 4 Sep 2020 05:19:10 -0400 Received: from esa5.microchip.iphmx.com ([216.71.150.166]:43022 "EHLO esa5.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729986AbgIDJTH (ORCPT ); Fri, 4 Sep 2020 05:19:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1599211147; x=1630747147; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=TlHaHc/zEULpiySGcyA3zFXAZbTghhNCxWyQSG0iZwY=; b=hJt8cp/kIE55f7/p0i+RO4rgd0JOFGUrqHOX18rGUotAk56ZnYRyVPls l7W9jqdwn8lVvNnJJB0/SMyBg6TEi/oTxxVGeEuOqT3eGoTz2SIXWdxDc lkaXVoqU0qVHL/wpv5EGbQTMx/uP9TGUv9VammK8aPXiaKTP7YpXn/qZg Y782sFzyKI+denAr87kaA2Y6Dz7MTPAVkk3MCgz25SRM7FkjnzsaU0ijZ YRyiBEfUNEpEbQXC3wuzlywNuAJvSVpCxwy8TOXfJfLh2WUNnrDwusM0L ltRBIQ9E2jC8DxwCF8i+OhJJ4Xp1wU2C3i30VckxvgRvyahm/c+709i47 w==; IronPort-SDR: 94rIDS2CUDAJWr3KkBCBE06lhEScvdgnVg9znPlWS3ttzJxiX70iHluy2089E7Ep9L8BqDgwqe jzHWJcTAfJ/24G9g19HMJeZNEaWjl0Sfa5drFFAGQjM9VJC+oEWujiI51iDAfzvKyQAn6Lqabf A0ULrrHuucW8QwcS8QiaaNAWreM19nptjJdI+B7ESuEzRq3V7uRVvCUWB63kLN0gzAl3BedsWl OjzKUAD9N/neUb5DFzn8phCRjG10CqC3NLAO0AteI0oAVB9CGiQ3267EQGHOYevzBHT91Jb4V3 kpM= X-IronPort-AV: E=Sophos;i="5.76,389,1592895600"; d="scan'208";a="89829014" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 04 Sep 2020 02:19:06 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 4 Sep 2020 02:19:02 -0700 Received: from soft-test08.microsemi.net (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.1979.3 via Frontend Transport; Fri, 4 Sep 2020 02:18:59 -0700 From: Henrik Bjoernlund To: , , , , , , , , , CC: Henrik Bjoernlund , Horatiu Vultur Subject: [PATCH RFC 2/7] bridge: cfm: Add BRIDGE_CFM to Kconfig. Date: Fri, 4 Sep 2020 09:15:22 +0000 Message-ID: <20200904091527.669109-3-henrik.bjoernlund@microchip.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200904091527.669109-1-henrik.bjoernlund@microchip.com> References: <20200904091527.669109-1-henrik.bjoernlund@microchip.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This makes it possible to include or exclude the CFM protocol according to 802.1Q section 12.14. Signed-off-by: Henrik Bjoernlund --- net/bridge/Kconfig | 11 +++++++++++ net/bridge/br_device.c | 3 +++ net/bridge/br_private.h | 3 +++ 3 files changed, 17 insertions(+) diff --git a/net/bridge/Kconfig b/net/bridge/Kconfig index 80879196560c..3c8ded7d3e84 100644 --- a/net/bridge/Kconfig +++ b/net/bridge/Kconfig @@ -73,3 +73,14 @@ config BRIDGE_MRP Say N to exclude this support and reduce the binary size. If unsure, say N. + +config BRIDGE_CFM + bool "CFM protocol" + depends on BRIDGE + help + If you say Y here, then the Ethernet bridge will be able to run CFM + protocol according to 802.1Q section 12.14 + + Say N to exclude this support and reduce the binary size. + + If unsure, say N. diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c index a9232db03108..d12f5626a4b1 100644 --- a/net/bridge/br_device.c +++ b/net/bridge/br_device.c @@ -476,6 +476,9 @@ void br_dev_setup(struct net_device *dev) INIT_LIST_HEAD(&br->ftype_list); #if IS_ENABLED(CONFIG_BRIDGE_MRP) INIT_LIST_HEAD(&br->mrp_list); +#endif +#if IS_ENABLED(CONFIG_BRIDGE_CFM) + INIT_LIST_HEAD(&br->mep_list); #endif spin_lock_init(&br->hash_lock); diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h index e67c6d9e8bea..6294a3e51a33 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h @@ -445,6 +445,9 @@ struct net_bridge { #if IS_ENABLED(CONFIG_BRIDGE_MRP) struct list_head mrp_list; #endif +#if IS_ENABLED(CONFIG_BRIDGE_CFM) + struct list_head mep_list; +#endif }; struct br_input_skb_cb { From patchwork Fri Sep 4 09:15:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Henrik Bjoernlund X-Patchwork-Id: 261527 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AD5F2C43461 for ; Fri, 4 Sep 2020 09:19:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7F42920748 for ; Fri, 4 Sep 2020 09:19:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b="MEBpGx/3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730108AbgIDJTR (ORCPT ); Fri, 4 Sep 2020 05:19:17 -0400 Received: from esa5.microchip.iphmx.com ([216.71.150.166]:43022 "EHLO esa5.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729986AbgIDJTO (ORCPT ); Fri, 4 Sep 2020 05:19:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1599211154; x=1630747154; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=XG2WKbLHFnej+8AJLKZjXJ9YI92uDGizpyWGrWmiWBY=; b=MEBpGx/3Od6rqW5dsIT1ni76eHXw/EqlxBLY9Jfcu8hWDBu8pwrvxkiw wM9lLEkyCrS/q25gnrZVH6mQ06Sbo3cQ1TKPaqqDJ/VN93Pko8HH876xW mehND6qgstmnnvxOzI0YOwmGwwfvx4ZqQWPTyfyjogebH52QOPyQ5DvHU uji9wSYaJsZYQR2dChN7xPRY0VPbtx3FKLMArccC3smbbbHnykL9qC+1g dGJP6hC4mYFT7Q5Uac9nUDItHC2DC2M2VSsHyt/gYR7ox8wJ7Ag+gdB4P sCR+V3WbGNs8CaKote9VTcDSei9KziFrAdsi+5ck0u3UoL2j458j/Lzz1 w==; IronPort-SDR: g9tBrI7zoSO9FTiJE5lOuYWOYgLL3cW4NGfJ4Bvu3e/xWCUXvb4sOYbiGl8ZK1dV2C6EUnZgTc 4oT9r+zUf+Opu35Sp/AIGyiHCVlHwBl3u1Txp+dFZ3JNzgVg3wrBtx45WIgQ3Av7FAz6IcrgXE ohzgMTaBSxqr41FIgZs7woqFl43do1rS7v0FkAXJBODTOHQ5xZ9rj5QMU5OfpfHZI7Zlj8swgi W6XuxoK4aCDjeJXQaZc50v/fig7HWXuOR+ZqVXHNoiTbsDJurZUyTE+CezUeJhw1fwLCsYxgcP 1pg= X-IronPort-AV: E=Sophos;i="5.76,389,1592895600"; d="scan'208";a="89829025" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 04 Sep 2020 02:19:13 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 4 Sep 2020 02:19:06 -0700 Received: from soft-test08.microsemi.net (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.1979.3 via Frontend Transport; Fri, 4 Sep 2020 02:19:04 -0700 From: Henrik Bjoernlund To: , , , , , , , , , CC: Henrik Bjoernlund , Horatiu Vultur Subject: [PATCH RFC 3/7] bridge: uapi: cfm: Added EtherType used by the CFM protocol. Date: Fri, 4 Sep 2020 09:15:23 +0000 Message-ID: <20200904091527.669109-4-henrik.bjoernlund@microchip.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200904091527.669109-1-henrik.bjoernlund@microchip.com> References: <20200904091527.669109-1-henrik.bjoernlund@microchip.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This EtherType is used by all CFM protocal frames transmitted according to 802.1Q section 12.14. Signed-off-by: Henrik Bjoernlund --- include/uapi/linux/if_ether.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/uapi/linux/if_ether.h b/include/uapi/linux/if_ether.h index d6de2b167448..a0b637911d3c 100644 --- a/include/uapi/linux/if_ether.h +++ b/include/uapi/linux/if_ether.h @@ -99,6 +99,7 @@ #define ETH_P_1588 0x88F7 /* IEEE 1588 Timesync */ #define ETH_P_NCSI 0x88F8 /* NCSI protocol */ #define ETH_P_PRP 0x88FB /* IEC 62439-3 PRP/HSRv0 */ +#define ETH_P_CFM 0x8902 /* Connectivity Fault Management */ #define ETH_P_FCOE 0x8906 /* Fibre Channel over Ethernet */ #define ETH_P_IBOE 0x8915 /* Infiniband over Ethernet */ #define ETH_P_TDLS 0x890D /* TDLS */ From patchwork Fri Sep 4 09:15:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Henrik Bjoernlund X-Patchwork-Id: 261526 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1D3D0C433E2 for ; Fri, 4 Sep 2020 09:19:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BA6B620748 for ; Fri, 4 Sep 2020 09:19:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=microchip.com header.i=@microchip.com header.b="NJJrJqDh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730138AbgIDJTr (ORCPT ); Fri, 4 Sep 2020 05:19:47 -0400 Received: from esa6.microchip.iphmx.com ([216.71.154.253]:8292 "EHLO esa6.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730025AbgIDJTc (ORCPT ); Fri, 4 Sep 2020 05:19:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1599211170; x=1630747170; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=BkqX6+/LQSrJs+XTxc1DCNz7FululLE0m1ftR3LVtO0=; b=NJJrJqDhWg64mfTJPyuLQ4+ZppUDPpzvh9uutQrBkfN+oWHY8fHu5/J7 2RHpLKMFezQ6tHIs9wghVMwF43LgpCStJm3T8DJzXEuyNqsPD/qkFF1Vs ihtRbRYdukCUHS9Fm26ovO5x4xvO26zE88EzXIFVyd6iBh0YrFa6U/njT JWodYg8JT9moPnOIVj8WYZPYSWNyelmHF9pRLkeqafhFfhztTiebM8rnQ ENAYaw5CFmqvX1oWjZeasH9rNr1OKFxAj3TaeoTw4dEc7lsSlTMHVaVCq i+oSBRKLeX9tBRNq9twSkFXTSlMftmZIYNMO//UiUX/PlqwEBcUowCLRf g==; IronPort-SDR: BifmdAFiO0rERubWulRut3gUMrOq1b5jCtdsFbzZwexmWXSQFyNmGB+ze3vejL9rQYuxz3zRKS uwfcgienaodV0zqAbYWoCGqfhp1FA0E9XIzoCTiFbjm3n75v77gjOtgQNwfgRDdx0/2tMoP0L6 9jA/YQhZR+c+V1GQ/in6m5z4gOjNKPwd9Rnw+3Im8owgGksTV0wFOZ2uSw2NBG2uPPWsU/CODT p1g6VMZFDk4RENIvx6fkz0jBtHSpN2QUII3rG1xLcj2p4SZZMDUmhS0WNUj5P3HsC5BGCon/7U Q94= X-IronPort-AV: E=Sophos;i="5.76,389,1592895600"; d="scan'208";a="25340155" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 04 Sep 2020 02:19:24 -0700 Received: from chn-vm-ex03.mchp-main.com (10.10.85.151) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1979.3; Fri, 4 Sep 2020 02:19:21 -0700 Received: from soft-test08.microsemi.net (10.10.115.15) by chn-vm-ex03.mchp-main.com (10.10.85.151) with Microsoft SMTP Server id 15.1.1979.3 via Frontend Transport; Fri, 4 Sep 2020 02:19:19 -0700 From: Henrik Bjoernlund To: , , , , , , , , , CC: Henrik Bjoernlund , Horatiu Vultur Subject: [PATCH RFC 6/7] bridge: cfm: Netlink Notifications. Date: Fri, 4 Sep 2020 09:15:26 +0000 Message-ID: <20200904091527.669109-7-henrik.bjoernlund@microchip.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200904091527.669109-1-henrik.bjoernlund@microchip.com> References: <20200904091527.669109-1-henrik.bjoernlund@microchip.com> MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This is the implementation of Netlink notifications out of CFM. Notifications are initiated whenever a state change happens in CFM. IFLA_BRIDGE_CFM: Points to the CFM information. IFLA_BRIDGE_CFM_MEP_STATUS_INFO: This indicate that the MEP instance status are following. IFLA_BRIDGE_CFM_CC_PEER_STATUS_INFO: This indicate that the peer MEP status are following. CFM nested attribute has the following attributes in next level. IFLA_BRIDGE_CFM_MEP_STATUS_INSTANCE: The MEP instance number of the delivered status. The type is NLA_U32. IFLA_BRIDGE_CFM_MEP_STATUS_OPCODE_UNEXP_SEEN: The MEP instance received CFM PDU with unexpected Opcode. The type is NLA_U32 (bool). IFLA_BRIDGE_CFM_MEP_STATUS_VERSION_UNEXP_SEEN: The MEP instance received CFM PDU with unexpected version. The type is NLA_U32 (bool). IFLA_BRIDGE_CFM_MEP_STATUS_RX_LEVEL_LOW_SEEN: The MEP instance received CCM PDU with MD level lower than configured level. This frame is discarded. The type is NLA_U32 (bool). IFLA_BRIDGE_CFM_CC_PEER_STATUS_INSTANCE: The MEP instance number of the delivered status. The type is NLA_U32. IFLA_BRIDGE_CFM_CC_PEER_STATUS_PEER_MEPID: The added Peer MEP ID of the delivered status. The type is NLA_U32. IFLA_BRIDGE_CFM_CC_PEER_STATUS_CCM_DEFECT: The CCM defect status. The type is NLA_U32 (bool). True means no CCM frame is received for 3.25 intervals. IFLA_BRIDGE_CFM_CC_CONFIG_EXP_INTERVAL. IFLA_BRIDGE_CFM_CC_PEER_STATUS_RDI: The last received CCM PDU RDI. The type is NLA_U32 (bool). IFLA_BRIDGE_CFM_CC_PEER_STATUS_PORT_TLV_VALUE: The last received CCM PDU Port Status TLV value field. The type is NLA_U8. IFLA_BRIDGE_CFM_CC_PEER_STATUS_IF_TLV_VALUE: The last received CCM PDU Interface Status TLV value field. The type is NLA_U8. IFLA_BRIDGE_CFM_CC_PEER_STATUS_SEEN: A CCM frame has been received from Peer MEP. The type is NLA_U32 (bool). This is cleared after GETLINK IFLA_BRIDGE_CFM_CC_PEER_STATUS_INFO. IFLA_BRIDGE_CFM_CC_PEER_STATUS_TLV_SEEN: A CCM frame with TLV has been received from Peer MEP. The type is NLA_U32 (bool). This is cleared after GETLINK IFLA_BRIDGE_CFM_CC_PEER_STATUS_INFO. IFLA_BRIDGE_CFM_CC_PEER_STATUS_SEQ_UNEXP_SEEN: A CCM frame with unexpected sequence number has been received from Peer MEP. The type is NLA_U32 (bool). When a sequence number is not one higher than previously received then it is unexpected. This is cleared after GETLINK IFLA_BRIDGE_CFM_CC_PEER_STATUS_INFO. Signed-off-by: Henrik Bjoernlund --- net/bridge/br_cfm.c | 43 +++++++++++++++++++++ net/bridge/br_cfm_netlink.c | 24 +++++++----- net/bridge/br_netlink.c | 76 ++++++++++++++++++++++++++++++++----- net/bridge/br_private.h | 22 ++++++++++- 4 files changed, 144 insertions(+), 21 deletions(-) diff --git a/net/bridge/br_cfm.c b/net/bridge/br_cfm.c index e38cc3e8f262..b7fed2c1d8ec 100644 --- a/net/bridge/br_cfm.c +++ b/net/bridge/br_cfm.c @@ -155,6 +155,13 @@ static void ccm_rx_timer_start(struct br_cfm_peer_mep *peer_mep) usecs_to_jiffies(interval_us / 4)); } +static void br_cfm_notify(int event, const struct net_bridge_port *port) +{ + u32 filter = RTEXT_FILTER_CFM_STATUS; + + return br_info_notify(event, port->br, NULL, filter); +} + static void cc_peer_enable(struct br_cfm_peer_mep *peer_mep) { memset(&peer_mep->cc_status, 0, sizeof(peer_mep->cc_status)); @@ -299,6 +306,7 @@ static void ccm_tx_work_expired(struct work_struct *work) static void ccm_rx_work_expired(struct work_struct *work) { struct br_cfm_peer_mep *peer_mep; + struct net_bridge_port *b_port; struct delayed_work *del_work; del_work = to_delayed_work(work); @@ -318,6 +326,11 @@ static void ccm_rx_work_expired(struct work_struct *work) peer_mep->cc_status.ccm_defect = true; /* Change in CCM defect status - notify */ + rcu_read_lock(); + b_port = rcu_dereference(peer_mep->mep->b_port); + if (b_port) + br_cfm_notify(RTM_NEWLINK, b_port); + rcu_read_unlock(); } } @@ -445,6 +458,7 @@ static int br_cfm_frame_rx(struct net_bridge_port *port, struct sk_buff *skb) peer_mep->cc_status.ccm_defect = false; /* Change in CCM defect status - notify */ + br_cfm_notify(RTM_NEWLINK, port); /* Start CCM RX timer */ ccm_rx_timer_start(peer_mep); @@ -874,6 +888,35 @@ int br_cfm_cc_counters_clear(struct net_bridge *br, const u32 instance, return 0; } +int br_cfm_mep_count(struct net_bridge *br, u32 *count) +{ + struct br_cfm_mep *mep; + *count = 0; + + rcu_read_lock(); + list_for_each_entry_rcu(mep, &br->mep_list, head) + * count += 1; + rcu_read_unlock(); + + return 0; +} + +int br_cfm_peer_mep_count(struct net_bridge *br, u32 *count) +{ + struct br_cfm_peer_mep *peer_mep; + struct br_cfm_mep *mep; + *count = 0; + + rcu_read_lock(); + list_for_each_entry_rcu(mep, &br->mep_list, head) { + list_for_each_entry_rcu(peer_mep, &mep->peer_mep_list, head) + * count += 1; + } + rcu_read_unlock(); + + return 0; +} + bool br_cfm_created(struct net_bridge *br) { return !list_empty(&br->mep_list); diff --git a/net/bridge/br_cfm_netlink.c b/net/bridge/br_cfm_netlink.c index 4e39aab1cd0b..13664ac8608a 100644 --- a/net/bridge/br_cfm_netlink.c +++ b/net/bridge/br_cfm_netlink.c @@ -582,7 +582,9 @@ int br_cfm_config_fill_info(struct sk_buff *skb, struct net_bridge *br) return -EMSGSIZE; } -int br_cfm_status_fill_info(struct sk_buff *skb, struct net_bridge *br) +int br_cfm_status_fill_info(struct sk_buff *skb, + struct net_bridge *br, + bool getlink) { struct nlattr *tb, *cfm_tb; struct br_cfm_mep *mep; @@ -613,10 +615,12 @@ int br_cfm_status_fill_info(struct sk_buff *skb, struct net_bridge *br) mep->status.rx_level_low_seen)) goto nla_put_failure; - /* Clear all 'seen' indications */ - mep->status.opcode_unexp_seen = false; - mep->status.version_unexp_seen = false; - mep->status.rx_level_low_seen = false; + if (getlink) { /* Only clear if this is a GETLINK */ + /* Clear all 'seen' indications */ + mep->status.opcode_unexp_seen = false; + mep->status.version_unexp_seen = false; + mep->status.rx_level_low_seen = false; + } nla_nest_end(skb, tb); @@ -662,10 +666,12 @@ int br_cfm_status_fill_info(struct sk_buff *skb, struct net_bridge *br) peer_mep->cc_status.seq_unexp_seen)) goto nla_put_failure; - /* Clear all 'seen' indications */ - peer_mep->cc_status.seen = false; - peer_mep->cc_status.tlv_seen = false; - peer_mep->cc_status.seq_unexp_seen = false; + if (getlink) { /* Only clear if this is a GETLINK */ + /* Clear all 'seen' indications */ + peer_mep->cc_status.seen = false; + peer_mep->cc_status.tlv_seen = false; + peer_mep->cc_status.seq_unexp_seen = false; + } nla_nest_end(skb, tb); } diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c index 6de5cb1295f6..f2e885521f4f 100644 --- a/net/bridge/br_netlink.c +++ b/net/bridge/br_netlink.c @@ -94,9 +94,11 @@ static size_t br_get_link_af_size_filtered(const struct net_device *dev, { struct net_bridge_vlan_group *vg = NULL; struct net_bridge_port *p = NULL; - struct net_bridge *br; - int num_vlan_infos; + struct net_bridge *br = NULL; + u32 num_cfm_peer_mep_infos; + u32 num_cfm_mep_infos; size_t vinfo_sz = 0; + int num_vlan_infos; rcu_read_lock(); if (netif_is_bridge_port(dev)) { @@ -115,6 +117,52 @@ static size_t br_get_link_af_size_filtered(const struct net_device *dev, /* Each VLAN is returned in bridge_vlan_info along with flags */ vinfo_sz += num_vlan_infos * nla_total_size(sizeof(struct bridge_vlan_info)); + if (!(filter_mask & RTEXT_FILTER_CFM_STATUS)) + return vinfo_sz; + + if (!br) + return vinfo_sz; + + /* CFM status info must be added */ + if (br_cfm_mep_count(br, &num_cfm_mep_infos)) + return vinfo_sz; + + if (br_cfm_peer_mep_count(br, &num_cfm_peer_mep_infos)) + return vinfo_sz; + + vinfo_sz += nla_total_size(0); /* IFLA_BRIDGE_CFM */ + /* For each status struct the MEP instance (u32) is added */ + /* MEP instance (u32) + br_cfm_mep_status */ + vinfo_sz += num_cfm_mep_infos * + /*IFLA_BRIDGE_CFM_MEP_STATUS_INSTANCE */ + (nla_total_size(sizeof(u32)) + /* IFLA_BRIDGE_CFM_MEP_STATUS_OPCODE_UNEXP_SEEN */ + + nla_total_size(sizeof(u32)) + /* IFLA_BRIDGE_CFM_MEP_STATUS_VERSION_UNEXP_SEEN */ + + nla_total_size(sizeof(u32)) + /* IFLA_BRIDGE_CFM_MEP_STATUS_RX_LEVEL_LOW_SEEN */ + + nla_total_size(sizeof(u32))); + /* MEP instance (u32) + br_cfm_cc_peer_status */ + vinfo_sz += num_cfm_peer_mep_infos * + /* IFLA_BRIDGE_CFM_CC_PEER_STATUS_INSTANCE */ + (nla_total_size(sizeof(u32)) + /* IFLA_BRIDGE_CFM_CC_PEER_STATUS_PEER_MEPID */ + + nla_total_size(sizeof(u32)) + /* IFLA_BRIDGE_CFM_CC_PEER_STATUS_CCM_DEFECT */ + + nla_total_size(sizeof(u32)) + /* IFLA_BRIDGE_CFM_CC_PEER_STATUS_RDI */ + + nla_total_size(sizeof(u32)) + /* IFLA_BRIDGE_CFM_CC_PEER_STATUS_PORT_TLV_VALUE */ + + nla_total_size(sizeof(u8)) + /* IFLA_BRIDGE_CFM_CC_PEER_STATUS_IF_TLV_VALUE */ + + nla_total_size(sizeof(u8)) + /* IFLA_BRIDGE_CFM_CC_PEER_STATUS_SEEN */ + + nla_total_size(sizeof(u32)) + /* IFLA_BRIDGE_CFM_CC_PEER_STATUS_TLV_SEEN */ + + nla_total_size(sizeof(u32)) + /* IFLA_BRIDGE_CFM_CC_PEER_STATUS_SEQ_UNEXP_SEEN */ + + nla_total_size(sizeof(u32))); + return vinfo_sz; } @@ -378,7 +426,8 @@ static int br_fill_ifvlaninfo(struct sk_buff *skb, static int br_fill_ifinfo(struct sk_buff *skb, const struct net_bridge_port *port, u32 pid, u32 seq, int event, unsigned int flags, - u32 filter_mask, const struct net_device *dev) + u32 filter_mask, const struct net_device *dev, + bool getlink) { u8 operstate = netif_running(dev) ? dev->operstate : IF_OPER_DOWN; struct net_bridge *br; @@ -515,7 +564,7 @@ static int br_fill_ifinfo(struct sk_buff *skb, goto nla_put_failure; rcu_read_lock(); - err = br_cfm_status_fill_info(skb, br); + err = br_cfm_status_fill_info(skb, br, getlink); rcu_read_unlock(); if (err) @@ -533,11 +582,9 @@ static int br_fill_ifinfo(struct sk_buff *skb, return -EMSGSIZE; } -/* Notify listeners of a change in bridge or port information */ -void br_ifinfo_notify(int event, const struct net_bridge *br, - const struct net_bridge_port *port) +void br_info_notify(int event, const struct net_bridge *br, + const struct net_bridge_port *port, u32 filter) { - u32 filter = RTEXT_FILTER_BRVLAN_COMPRESSED; struct net_device *dev; struct sk_buff *skb; int err = -ENOBUFS; @@ -562,7 +609,7 @@ void br_ifinfo_notify(int event, const struct net_bridge *br, if (skb == NULL) goto errout; - err = br_fill_ifinfo(skb, port, 0, 0, event, 0, filter, dev); + err = br_fill_ifinfo(skb, port, 0, 0, event, 0, filter, dev, false); if (err < 0) { /* -EMSGSIZE implies BUG in br_nlmsg_size() */ WARN_ON(err == -EMSGSIZE); @@ -575,6 +622,15 @@ void br_ifinfo_notify(int event, const struct net_bridge *br, rtnl_set_sk_err(net, RTNLGRP_LINK, err); } +/* Notify listeners of a change in bridge or port information */ +void br_ifinfo_notify(int event, const struct net_bridge *br, + const struct net_bridge_port *port) +{ + u32 filter = RTEXT_FILTER_BRVLAN_COMPRESSED; + + return br_info_notify(event, br, port, filter); +} + /* * Dump information about all ports, in response to GETLINK */ @@ -591,7 +647,7 @@ int br_getlink(struct sk_buff *skb, u32 pid, u32 seq, return 0; return br_fill_ifinfo(skb, port, pid, seq, RTM_NEWLINK, nlflags, - filter_mask, dev); + filter_mask, dev, true); } static int br_vlan_info(struct net_bridge *br, struct net_bridge_port *p, diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h index fe36592f7525..53bcbdd21f34 100644 --- a/net/bridge/br_private.h +++ b/net/bridge/br_private.h @@ -1370,7 +1370,11 @@ int br_cfm_parse(struct net_bridge *br, struct net_bridge_port *p, int br_cfm_rx_frame_process(struct net_bridge_port *p, struct sk_buff *skb); bool br_cfm_created(struct net_bridge *br); int br_cfm_config_fill_info(struct sk_buff *skb, struct net_bridge *br); -int br_cfm_status_fill_info(struct sk_buff *skb, struct net_bridge *br); +int br_cfm_status_fill_info(struct sk_buff *skb, + struct net_bridge *br, + bool getlink); +int br_cfm_mep_count(struct net_bridge *br, u32 *count); +int br_cfm_peer_mep_count(struct net_bridge *br, u32 *count); #else static inline int br_cfm_parse(struct net_bridge *br, struct net_bridge_port *p, struct nlattr *attr, int cmd, @@ -1394,7 +1398,19 @@ static inline int br_cfm_config_fill_info(struct sk_buff *skb, struct net_bridge return -EOPNOTSUPP; } -static inline int br_cfm_status_fill_info(struct sk_buff *skb, struct net_bridge *br) +static inline int br_cfm_status_fill_info(struct sk_buff *skb, + struct net_bridge *br, + bool getlink) +{ + return -EOPNOTSUPP; +} + +static inline int br_cfm_mep_count(struct net_bridge *br, u32 *count) +{ + return -EOPNOTSUPP; +} + +static inline int br_cfm_peer_mep_count(struct net_bridge *br, u32 *count) { return -EOPNOTSUPP; } @@ -1406,6 +1422,8 @@ int br_netlink_init(void); void br_netlink_fini(void); void br_ifinfo_notify(int event, const struct net_bridge *br, const struct net_bridge_port *port); +void br_info_notify(int event, const struct net_bridge *br, + const struct net_bridge_port *port, u32 filter); int br_setlink(struct net_device *dev, struct nlmsghdr *nlmsg, u16 flags, struct netlink_ext_ack *extack); int br_dellink(struct net_device *dev, struct nlmsghdr *nlmsg, u16 flags);