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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BD71CC6FA83 for ; Tue, 6 Sep 2022 05:21:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232658AbiIFFVt (ORCPT ); Tue, 6 Sep 2022 01:21:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232628AbiIFFVp (ORCPT ); Tue, 6 Sep 2022 01:21:45 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 382356CF64 for ; Mon, 5 Sep 2022 22:21:44 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 4B45AB81624 for ; Tue, 6 Sep 2022 05:21:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4B89C433B5; Tue, 6 Sep 2022 05:21:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1662441700; bh=ofrt/h68tYS/wlb2IuElG7h7AQ5WuQ+f9NdBkh1YL7E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LxYoZxakuoaUpLBkhUcnmCeXnALLsADXAV3M+eR54VxIURv3/4sJLpYEqW/pK5Qb5 YGlRa36b66IvNl6Q5NxSIFr1d1l3HmwoNUdL4oCbBnonHofcMm1OZ554IHm+vgZNNK Hfc5n3kd47DYl8hVmAl0QqT4/7O37fDutwV8KEHtj39+EYo7rrTJWOXhG2D6eCVzSK mAEAjnOl03nq+POcX1KUsSWaR9JdMPPA2orGpsuyGZdIBPXzY8i1uJ6yzMGwwNRpbp XKCZTzxCx8DHuGkFybS02+ctjnd7TFY2Sb+LPDwcfN0w1tbRhWHE0Dartr8/UQ0QSI m8h0DLKOwS1fg== From: Saeed Mahameed To: "David S. Miller" , Jakub Kicinski , Paolo Abeni , Eric Dumazet Cc: Saeed Mahameed , netdev@vger.kernel.org, Tariq Toukan , Lior Nahmanson , Raed Salem Subject: [PATCH net-next V2 02/17] net/macsec: Add MACsec skb_metadata_dst Rx Data path support Date: Mon, 5 Sep 2022 22:21:14 -0700 Message-Id: <20220906052129.104507-3-saeed@kernel.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220906052129.104507-1-saeed@kernel.org> References: <20220906052129.104507-1-saeed@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Lior Nahmanson Like in the Tx changes, if there are more than one MACsec device with the same MAC address as in the packet's destination MAC, the packet will be forward only to this device and not neccessarly to the desired one. Offloading device drivers will mark offloaded MACsec SKBs with the corresponding SCI in the skb_metadata_dst so the macsec rx handler will know to which port to divert those skbs, instead of wrongly solely relaying on dst MAC address comparison. Signed-off-by: Lior Nahmanson Reviewed-by: Raed Salem Signed-off-by: Saeed Mahameed --- drivers/net/macsec.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c index c190dc019717..e781b3e22aac 100644 --- a/drivers/net/macsec.c +++ b/drivers/net/macsec.c @@ -1025,11 +1025,13 @@ static enum rx_handler_result handle_not_macsec(struct sk_buff *skb) /* Deliver to the uncontrolled port by default */ enum rx_handler_result ret = RX_HANDLER_PASS; struct ethhdr *hdr = eth_hdr(skb); + struct metadata_dst *md_dst; struct macsec_rxh_data *rxd; struct macsec_dev *macsec; rcu_read_lock(); rxd = macsec_data_rcu(skb->dev); + md_dst = skb_metadata_dst(skb); list_for_each_entry_rcu(macsec, &rxd->secys, secys) { struct sk_buff *nskb; @@ -1040,6 +1042,10 @@ static enum rx_handler_result handle_not_macsec(struct sk_buff *skb) * the SecTAG, so we have to deduce which port to deliver to. */ if (macsec_is_offloaded(macsec) && netif_running(ndev)) { + if (md_dst && md_dst->type == METADATA_MACSEC && + (!find_rx_sc(&macsec->secy, md_dst->u.macsec_info.sci))) + continue; + if (ether_addr_equal_64bits(hdr->h_dest, ndev->dev_addr)) { /* exact match, divert skb to this port */ -- 2.37.2