Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp185363iob; Mon, 2 May 2022 16:35:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwPw3jBUG7uNj0zLJOnDgTrus/yNmZyyVKhB7FIyYFrSeJhAoag4BVjpRm0JWccNTg930t X-Received: by 2002:a17:90b:3507:b0:1dc:68e2:10bc with SMTP id ls7-20020a17090b350700b001dc68e210bcmr1744910pjb.30.1651534506466; Mon, 02 May 2022 16:35:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651534506; cv=none; d=google.com; s=arc-20160816; b=c/JfwFiglv8gAYM51cxMj6sP7hXCejKvHAlWy18PUeBwVMRTOjDA3WP1PYrtXbDJSs hsHYKK4lrCbfmFszlmgIfJ7BSnbxoJt4eKkjGqlBfVWegLUm70Z8nG+6NCnWuzoRvdrG 2NjoX+B3d0d/1/W4pa0JMYIRMEwUpqIxY6aRr2OFXG4oSB7VMr2H5ktkLwTPWxuarGqK +lfw7FRBT1b004ve+caD35TIprKuiRV1hAzWyJ0tUTJB/mbkhpGlW3ZWjBrkiGUbkDGZ PgU6277kgrZhVZzMaYXNted09MKa/1B7rjCuKBC7ycZiBSat5e2ZXhdc7jfZHxOHZ8pN 15Kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from :dkim-signature; bh=WIpumGU76fy6Q2rBLSbndwpcAjiNC5TWyx8e5ZMdPnE=; b=D+ttm1NYrSCF3Shi159rAg7bCm/26DhRvHGhTcaxjPzP6+lGsQXtZGlF0bjjvSrHHj DbT8Bu/a+SiwTO7CVpErly/2phz0vrbFhDsdSkAPeMPwW/mdzvP9c2rgL3uqRoNH27T5 /x5/euT9i5mhIJt2DfQNB4f7mMfWuwxVGoxGPSMItjmnpK9jbUGQplZ6Ksnj1+JtSrGI xMukGLgbx67QWj0D9qI524RA+0BUKH6Mev83fCnqeSiWd5alEfPDxZZEYRPTKarP0uq0 SWF1SFJhKG6/qt+vGPc1VTXACN1eaaLmZkcqwX9p7srCBd5XZyf2j6E8hMt2sgpWgyo9 ITNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20210112 header.b=evPU9kZc; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id gw19-20020a17090b0a5300b001cb278ad6cesi606714pjb.138.2022.05.02.16.35.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 May 2022 16:35:06 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20210112 header.b=evPU9kZc; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 29A4D31DF6; Mon, 2 May 2022 16:35:01 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1384998AbiEBMWW (ORCPT + 99 others); Mon, 2 May 2022 08:22:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1377770AbiEBMWN (ORCPT ); Mon, 2 May 2022 08:22:13 -0400 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30007167C2; Mon, 2 May 2022 05:18:44 -0700 (PDT) Received: by mail-wr1-x42b.google.com with SMTP id b19so19317746wrh.11; Mon, 02 May 2022 05:18:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WIpumGU76fy6Q2rBLSbndwpcAjiNC5TWyx8e5ZMdPnE=; b=evPU9kZc+kl8DmkB++3DrVzHNnWpvCcv3xgSFZWN4TAaca9s5v8yeHA7QUGkY+82KP Or6M7B5IRhMSU0U0PueN5isbBtKW/nMDBprsiZBsCBFPgWSpuPq45LeAD6CLPjHdxzQF grtOHgKV37WkwbImfp39ckNy+kiaBcLOiatwWeV15RmsXOPOJlEWjh+C+CRi/95hFy+D C1kPObEArsGGJUUCPMrEorCt4fx+JVSJwm1/OnLfCYjOMhi65yBt8JNBH25akETAfdvQ 1/nSr58mVhSwF43QgdnuFFBkTgbdFkmlCu8WtQKLO4mNdoHFUHFGPPvQ0BfMPGrZz2WN 6Y8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WIpumGU76fy6Q2rBLSbndwpcAjiNC5TWyx8e5ZMdPnE=; b=X/7qrnRW5U6gf7UA+Lr6KP1zWHpFGc9puf1nSO4JzEnHVo+PXAwcHdopwXnvubLobJ L9tA0kwJ1lSdCATNAuC6R+eexcUXN0XHB/YExYWwzYeuvfanAo5Y3YeSaD0asCNLm73U ymuE4cM1x7ZRNDIcp3a9mZoVIzNuVZsl5hskCWvQsLQ9XopD4e9Y94Hg8SfWr5woEZuz WTOo9eYiuniantIcSP+FfHoYvrILpJX3qEeKy8yWocTmfkxisysQ+/yEfwBP5Dv8iLVA Yr/BFidNtD/NuN1LGVBUpHyXwxL9J6qhzTrCtUiHi7Xfv6low/CE8mxceKiCxuNcp4SP 2DPA== X-Gm-Message-State: AOAM533ISRkvrxCJjUSnU5RBlm6ylLrJz1IjVGkZNdETDCHjklNBzjZQ vtKKp7M9Y5b991114rW5//s= X-Received: by 2002:a05:6000:2a3:b0:20a:ef18:a09a with SMTP id l3-20020a05600002a300b0020aef18a09amr8991747wry.588.1651493922691; Mon, 02 May 2022 05:18:42 -0700 (PDT) Received: from localhost.localdomain (52.pool85-60-27.dynamic.orange.es. [85.60.27.52]) by smtp.gmail.com with ESMTPSA id l7-20020adfa387000000b0020c5253d8fbsm6930335wrb.71.2022.05.02.05.18.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 May 2022 05:18:42 -0700 (PDT) From: Carlos Fernansez Cc: carlos.fernandez@technica-enineering.de, Carlos Fernandez , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] net/macsec copy salt to MACSec ctx for XPN Date: Mon, 2 May 2022 14:18:37 +0200 Message-Id: <20220502121837.22794-1-carlos.escuin@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,SPOOFED_FREEMAIL_NO_RDNS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Carlos Fernandez Salt and KeyId copied to offloading context. If not, offloaded phys cannot work with XPN Signed-off-by: Carlos Fernandez --- drivers/net/macsec.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c index 832f09ac075e..4f2bd3d722c3 100644 --- a/drivers/net/macsec.c +++ b/drivers/net/macsec.c @@ -1804,6 +1804,14 @@ static int macsec_add_rxsa(struct sk_buff *skb, struct genl_info *info) rx_sa->sc = rx_sc; + if (secy->xpn) { + rx_sa->ssci = nla_get_ssci(tb_sa[MACSEC_SA_ATTR_SSCI]); + nla_memcpy(rx_sa->key.salt.bytes, tb_sa[MACSEC_SA_ATTR_SALT], + MACSEC_SALT_LEN); + } + + nla_memcpy(rx_sa->key.id, tb_sa[MACSEC_SA_ATTR_KEYID], MACSEC_KEYID_LEN); + /* If h/w offloading is available, propagate to the device */ if (macsec_is_offloaded(netdev_priv(dev))) { const struct macsec_ops *ops; @@ -1826,13 +1834,6 @@ static int macsec_add_rxsa(struct sk_buff *skb, struct genl_info *info) goto cleanup; } - if (secy->xpn) { - rx_sa->ssci = nla_get_ssci(tb_sa[MACSEC_SA_ATTR_SSCI]); - nla_memcpy(rx_sa->key.salt.bytes, tb_sa[MACSEC_SA_ATTR_SALT], - MACSEC_SALT_LEN); - } - - nla_memcpy(rx_sa->key.id, tb_sa[MACSEC_SA_ATTR_KEYID], MACSEC_KEYID_LEN); rcu_assign_pointer(rx_sc->sa[assoc_num], rx_sa); rtnl_unlock(); @@ -2046,6 +2047,14 @@ static int macsec_add_txsa(struct sk_buff *skb, struct genl_info *info) if (assoc_num == tx_sc->encoding_sa && tx_sa->active) secy->operational = true; + if (secy->xpn) { + tx_sa->ssci = nla_get_ssci(tb_sa[MACSEC_SA_ATTR_SSCI]); + nla_memcpy(tx_sa->key.salt.bytes, tb_sa[MACSEC_SA_ATTR_SALT], + MACSEC_SALT_LEN); + } + + nla_memcpy(tx_sa->key.id, tb_sa[MACSEC_SA_ATTR_KEYID], MACSEC_KEYID_LEN); + /* If h/w offloading is available, propagate to the device */ if (macsec_is_offloaded(netdev_priv(dev))) { const struct macsec_ops *ops; @@ -2068,13 +2077,6 @@ static int macsec_add_txsa(struct sk_buff *skb, struct genl_info *info) goto cleanup; } - if (secy->xpn) { - tx_sa->ssci = nla_get_ssci(tb_sa[MACSEC_SA_ATTR_SSCI]); - nla_memcpy(tx_sa->key.salt.bytes, tb_sa[MACSEC_SA_ATTR_SALT], - MACSEC_SALT_LEN); - } - - nla_memcpy(tx_sa->key.id, tb_sa[MACSEC_SA_ATTR_KEYID], MACSEC_KEYID_LEN); rcu_assign_pointer(tx_sc->sa[assoc_num], tx_sa); rtnl_unlock(); -- 2.25.1