Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp10166668rwd; Wed, 21 Jun 2023 17:51:29 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7PtO2MHczBt3BwRCryjDCwZ6d6V2jdkA8Ztmakxo89iacpyXojnUgA2reVOm8aAecGosSi X-Received: by 2002:a05:6870:50e4:b0:1aa:2446:d34c with SMTP id s36-20020a05687050e400b001aa2446d34cmr7427864oaf.9.1687395089428; Wed, 21 Jun 2023 17:51:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687395089; cv=none; d=google.com; s=arc-20160816; b=ALKhBbg0WpAd/KksjIUPt3VWt4o0sexLWGw6DcvQ8YNcYkNsESmP19veX3xLtoyOMm RWLEI0WkAJqcm+RDfQIoQN5uEQLZReqNanRMnEWsmFh3BRBl2j+wG1nKdnt5i+fbQcHI jqmWAnxUC3mIqpMBMHBOs3akAhLvNYVZ0Spn5LYTggyav1Fu0G8mZApb+FbHiUlATpPd kN/gygziqLl9J6bgMMg+FWKWG34YEgDPkBizkF2Oj8cFhHR7/swDO3t9S79PLOIn9kHX ZU4yDxHD+HfG2i0K/Xi5hr8bYkk36WP2fQqmTdjsvz6SZns72SmsoIUogZTGWcW4XUez /6DA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=E/XEsYe+VdTXt3BB4hwTf3rOOO4PmJ8XJjo+Ne8UZc0=; b=DeiiluQVMzMmtY2z/v3Ldd4zyFNcbn7SpF0zZ/5GdAF2NuI/qzpXhJGjiYsIaTelr1 c3tiik8mVxdAtI7TckBTcjwa6ba7fwJvNQ7rY3aW+gzHtMqi+gED6oNkuVW+Uf8Tf+eE +jgl7NkraEJJuiQL/kPvB+1p1t5dIct/hkBfS6cqxa02sOlwgD5djnZtxJZWOZcdAc5i 88Ih9gJT7ANqwJWH2jwd8U5QBXHdSYwTPcPtMjazldWp35ysT9dALLxdgL/0SH0qh0Q3 tHU05HhGbVa/sKWWEOl61UD3e2M4+LsL5B9+0StC0mfa7M3R6C6dpcus3ur91V/tQtat SOXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=vAorBcPF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u5-20020a637905000000b0054ff8291783si609286pgc.424.2023.06.21.17.51.16; Wed, 21 Jun 2023 17:51:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=vAorBcPF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229590AbjFVAed (ORCPT + 99 others); Wed, 21 Jun 2023 20:34:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229472AbjFVAec (ORCPT ); Wed, 21 Jun 2023 20:34:32 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F0B71710 for ; Wed, 21 Jun 2023 17:34:31 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 209B261702 for ; Thu, 22 Jun 2023 00:34:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2DF99C433C8; Thu, 22 Jun 2023 00:34:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1687394070; bh=AiZo/yWVr6AaszhH++L2NsU42IKDuEpbVQ7bGj7ECf4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=vAorBcPFmLvJTgk2RkidGZUjcsqiRPLMtFSoPBlyahiZDWeOO6gojp2QwLG8RMcW1 fSdHDXu+oCcr3PMFKXtBDl2gDTDJVZXjJeKxUEqYuXipK1Pc7xlEXWyX5B3OOKSljV t2iZEiz1qV0qI8FWEeIFvnC6GJpHu4jeqa44M7URp72oXtP92tP3x1K1XU2vERtEpb INrVQx7HTI7Kme9INelS5Bvbb79anLy3CoZUNiqhBIOMbLzH4FBUTPw3dxHZbSfTnl J6aC7wab7Z3jhSUBFGG6FtyEntEX+kBgn/eYcHHYUmd6IZZ6vCje5bheOVJOFZtoyM yb9Td4DcPhCtQ== Date: Wed, 21 Jun 2023 17:34:29 -0700 From: Jakub Kicinski To: carlos.fernandez@technica-engineering.de Cc: davem@davemloft.net, edumazet@google.com, pabeni@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Sabrina Dubroca Subject: Re: [PATCH v3] net: macsec SCI assignment for ES = 0 Message-ID: <20230621173429.18348fc8@kernel.org> In-Reply-To: <20230620091301.21981-1-carlos.fernandez@technica-engineering.de> References: <20230620091301.21981-1-carlos.fernandez@technica-engineering.de> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org A few nit picks and questions, when you repost please make sure to CC Sabrina Dubroca On Tue, 20 Jun 2023 11:13:01 +0200 carlos.fernandez@technica-engineering.de wrote: > -static sci_t macsec_frame_sci(struct macsec_eth_header *hdr, bool sci_present) > +static sci_t macsec_frame_sci(struct macsec_eth_header *hdr, bool sci_present, > + struct macsec_rxh_data *rxd) > { > + struct macsec_dev *macsec_device; > sci_t sci; > > - if (sci_present) > + if (sci_present) { > memcpy(&sci, hdr->secure_channel_id, > - sizeof(hdr->secure_channel_id)); > - else > + sizeof(hdr->secure_channel_id)); the alignment of sizeof() was correct, don't change it > + } else if (0 == (hdr->tci_an & (MACSEC_TCI_ES | MACSEC_TCI_SC))) { Just } else if (hdr->tci_an & (MACSEC_TCI_ES | MACSEC_TCI_SC)) { > + list_for_each_entry_rcu(macsec_device, &rxd->secys, secys) { > + struct macsec_rx_sc *rx_sc; > + struct macsec_secy *secy = &macsec_device->secy; You should reorder these two declaration, networking likes local variable declaration lines longest to shortest. > + for_each_rxsc(secy, rx_sc) { > + rx_sc = rx_sc ? macsec_rxsc_get(rx_sc) : NULL; > + if (rx_sc && rx_sc->active) > + return rx_sc->sci; > + } I haven't looked in detail but are you possibly returning rx_sc->sci here just to ... > + } > + /* If not found, use MAC in hdr as default*/ > sci = make_sci(hdr->eth.h_source, MACSEC_PORT_ES); > - > + } else { > + sci = make_sci(hdr->eth.h_source, MACSEC_PORT_ES); > + } > return sci; > } > > @@ -1150,11 +1165,12 @@ static rx_handler_result_t macsec_handle_frame(struct sk_buff **pskb) > > macsec_skb_cb(skb)->has_sci = !!(hdr->tci_an & MACSEC_TCI_SC); > macsec_skb_cb(skb)->assoc_num = hdr->tci_an & MACSEC_AN_MASK; > - sci = macsec_frame_sci(hdr, macsec_skb_cb(skb)->has_sci); > > rcu_read_lock(); > rxd = macsec_data_rcu(skb->dev); > > + sci = macsec_frame_sci(hdr, macsec_skb_cb(skb)->has_sci, rxd); > + > list_for_each_entry_rcu(macsec, &rxd->secys, secys) { > struct macsec_rx_sc *sc = find_rx_sc(&macsec->secy, sci); ... look up the rx_sc based on the sci? -- pw-bot: cr