From mboxrd@z Thu Jan 1 00:00:00 1970 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=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,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 B6B2CC432C0 for ; Wed, 27 Nov 2019 21:03:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8B4442086A for ; Wed, 27 Nov 2019 21:03:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574888594; bh=xy9fV6VRf6ZTjqVGfwmNG4IyHl8ycEZP8gaaGlsnQeU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=SFIAVn6b3eCY2oJ6QMr+iR69UeyVwNEeHNU589aT8+efbU4uIH9CYHvJ/uT70gIbu sYJ+4T7y4aru7l2zym8QL/7FtNrR9kVsv/sNPpujA2sc7+l9XLSX9HLrHunSqhg4G4 xqIh0YxLxGq/9s75eNzsrmIRXPXS1i644VJQ8tN4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732013AbfK0VDM (ORCPT ); Wed, 27 Nov 2019 16:03:12 -0500 Received: from mail.kernel.org ([198.145.29.99]:56262 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732006AbfK0VDK (ORCPT ); Wed, 27 Nov 2019 16:03:10 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 34E5421569; Wed, 27 Nov 2019 21:03:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574888589; bh=xy9fV6VRf6ZTjqVGfwmNG4IyHl8ycEZP8gaaGlsnQeU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Og3m16eVWE7dRvg7JHDCJdu5FhhqlabChg6XPep8wQQyhVjii7t8Sl/lGUKToI/Su mLVIVu2zV2XQr/JpX8Q1hWgLApCqOnw8aKVz6MqeTSP2jJrYm2Z4S7sStfr1a40VT0 KF+SPoSoWtRgAk+afqCk0Pghg47Dq9kiuyQGodHk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Radu Rendec , Patrick Talbert , Sabrina Dubroca , "David S. Miller" , Sasha Levin Subject: [PATCH 4.19 151/306] macsec: update operstate when lower device changes Date: Wed, 27 Nov 2019 21:30:01 +0100 Message-Id: <20191127203126.714967921@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127203114.766709977@linuxfoundation.org> References: <20191127203114.766709977@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sabrina Dubroca [ Upstream commit e6ac075882b2afcdf2d5ab328ce4ab42a1eb9593 ] Like all other virtual devices (macvlan, vlan), the operstate of a macsec device should match the state of its lower device. This is done by calling netif_stacked_transfer_operstate from its netdevice notifier. We also need to call netif_stacked_transfer_operstate when a new macsec device is created, so that its operstate is set properly. This is only relevant when we try to bring the device up directly when we create it. Radu Rendec proposed a similar patch, inspired from the 802.1q driver, that included changing the administrative state of the macsec device, instead of just the operstate. This version is similar to what the macvlan driver does, and updates only the operstate. Fixes: c09440f7dcb3 ("macsec: introduce IEEE 802.1AE driver") Reported-by: Radu Rendec Reported-by: Patrick Talbert Signed-off-by: Sabrina Dubroca Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/macsec.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c index 05115fb0c97a9..50acd8c9d7f53 100644 --- a/drivers/net/macsec.c +++ b/drivers/net/macsec.c @@ -3305,6 +3305,9 @@ static int macsec_newlink(struct net *net, struct net_device *dev, if (err < 0) goto del_dev; + netif_stacked_transfer_operstate(real_dev, dev); + linkwatch_fire_event(dev); + macsec_generation++; return 0; @@ -3489,6 +3492,20 @@ static int macsec_notify(struct notifier_block *this, unsigned long event, return NOTIFY_DONE; switch (event) { + case NETDEV_DOWN: + case NETDEV_UP: + case NETDEV_CHANGE: { + struct macsec_dev *m, *n; + struct macsec_rxh_data *rxd; + + rxd = macsec_data_rtnl(real_dev); + list_for_each_entry_safe(m, n, &rxd->secys, secys) { + struct net_device *dev = m->secy.netdev; + + netif_stacked_transfer_operstate(real_dev, dev); + } + break; + } case NETDEV_UNREGISTER: { struct macsec_dev *m, *n; struct macsec_rxh_data *rxd; -- 2.20.1