Message ID | ZeIhOT44ON5rjPiP@neat |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-88932-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:fa17:b0:10a:f01:a869 with SMTP id ju23csp84875dyc; Fri, 1 Mar 2024 10:52:32 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU6Sn7uACrsLM+DIqQCnvja+/EhN9ZgFt4SGkEgr8IweXrYzSamSHu6Z+pIZhVffXggOvu9bxqI62SVS6gYXhbcFdDrEg== X-Google-Smtp-Source: AGHT+IFKEbNo0AKUZsH5qjfuMTofUOQGViaXge2yLPsuttSo4N6XIAJZMGQcya1Ne/YSnjzhu+TG X-Received: by 2002:a05:6e02:1c0a:b0:365:1dbb:a30a with SMTP id l10-20020a056e021c0a00b003651dbba30amr2818032ilh.3.1709319152718; Fri, 01 Mar 2024 10:52:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709319152; cv=pass; d=google.com; s=arc-20160816; b=kTuX1fujEIiaksRjQNhJbC28gvhqUWuADDERmldo46QNVyrhpuqIdPE0tScTvBMEKO P/SAU5wb/Rl2pKtu+DrLsOAgTNRWKFoBGY6K9tjK7q/AKrHV4t8xuFf9TGOR8abPhDMU CyfltQvE5uGAy1QXCK771jLZUYhOWa2uMcjdoNuCVtcQmSSi9d8IoM7H9M5fc0ewdbgT UIgJWt5KFpjVmtije0pkyw6eJTtBh2doz5MynRUjBqgklDeUtAhArKkYN7CbJ3hVEahw CKBjkLwqnPLDIEOeFVmlJWcj6r0DUeNpmTVoRwr39aJMr7JVvUXQN7h6AVmUznAwEpQp phNg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-disposition:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:message-id:subject:cc:to:from:date :dkim-signature; bh=SkR7uJqze2ZYGAah3tkGw2OKoXnbtH0B4LHwRQUDyY0=; fh=lqYwNRvEnMW5fl5jnjq5HYUeHhJejQHy3opkgy/7QE8=; b=ZuWuMe539W/oOafKJnzjEebDKXsL657wOGs5nKWdN/kBcKu2XRtUXGVocBEAbFYR+k cA7GmiPdxwbRcJs+0ZM4nsTiukm0maHqRJDWaL0k29qJsycA0hdJ2XAvw/VLAVc4vx0G 9q5pwOADsQqe03h20k38cpLD4aV2cdOpI/FP7RLg9yRqi2GWei1eGVcuFbfBwvpSO0za VVjnpCNjdB65J5pOKdPANUv/gsja0El241rvEDXqj+dOg9drDcJGWA6X7AjvJ6DHHoW8 CwQZ9vFYofxJDcRBr/359zgfL06shEJKnQt+8ZHmivQAmhIcx7V6ah2nNO/1EEb2PZXD bKqQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=r2Q7QuqW; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-88932-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88932-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id e7-20020a635447000000b005cdf992367dsi4089142pgm.730.2024.03.01.10.52.32 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Mar 2024 10:52:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-88932-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=r2Q7QuqW; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-88932-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-88932-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id A167F28E3D7 for <ouuuleilei@gmail.com>; Fri, 1 Mar 2024 18:41:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2C9E43A8ED; Fri, 1 Mar 2024 18:41:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="r2Q7QuqW" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 472013A1B8; Fri, 1 Mar 2024 18:41:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709318461; cv=none; b=K8mz0Oi3O1J86hdtT0evJ6kq8Yda+UMJkAs/ZUg4jrnnjk2hqc1e0RX6RkQCHElLCNuy2rzAT7h/ydz0/ZzNBkSlsnNR4mqmcSNmoSLaEjwyoDfQIv+uEd0w3hlk3D25EZ+Yr8Uq+512w0kLB7Mxv6T7a2gkBLgwiHSUXA/Pqps= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709318461; c=relaxed/simple; bh=Ikr2dasxWHE+lNItweXLpqVfoJa5a0SH5QW2mOtObok=; h=Date:From:To:Cc:Subject:Message-ID:MIME-Version:Content-Type: Content-Disposition; b=jh9XS/DYOMrEhFsbR5flfTktrim36iJJbDuQDrn7K1WlFJ7lzf5xjVt/YbNufEf1nATc4RBMlMXBMl+RmMVm1hy/NQoMpoopriqG8tyNW3LxjaxgrqzRX6Or7YQdPe7yfJzgEi30HXvX7Yz9TPJD47+4X26EqFELaF7/k956WKo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=r2Q7QuqW; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A4AF6C433C7; Fri, 1 Mar 2024 18:40:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709318460; bh=Ikr2dasxWHE+lNItweXLpqVfoJa5a0SH5QW2mOtObok=; h=Date:From:To:Cc:Subject:From; b=r2Q7QuqWR02YX4BwJB96aQVS8C1pgLZiSKZF52iPU96KkxawAS/eKf60dMe8iqlpp lP9HwlYIXAV7fWehnNcLTi9cfxjGuCNxXRtBQg7Sj00O74QryCsKDTyo3Cemna8cn8 7VDDvZuAV5pSUH7h3AUAW9UwrxnwS5uQ98PScqKFmqDUddsW6c4BE77RE1a01qlUO9 dh801ZgPnZFzcZqmn+GTGogZvPty6zapDZ2h9FtkLPKyWreeZBVdiN73HQSxxEwprO nUz6817YY4RHzPLDdoDn5JLxVzOp7JePcQ/c95z1MhJrmpY5/2s8YclcCD4iPJ3kTu HTHaFQbnIGYhA== Date: Fri, 1 Mar 2024 12:40:57 -0600 From: "Gustavo A. R. Silva" <gustavoars@kernel.org> To: Wenjia Zhang <wenjia@linux.ibm.com>, Jan Karcher <jaka@linux.ibm.com>, "D. Wythe" <alibuda@linux.alibaba.com>, Tony Lu <tonylu@linux.alibaba.com>, Wen Gu <guwen@linux.alibaba.com>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com> Cc: linux-s390@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" <gustavoars@kernel.org>, linux-hardening@vger.kernel.org, Kees Cook <keescook@chromium.org> Subject: [PATCH][next] net/smc: Avoid -Wflex-array-member-not-at-end warnings Message-ID: <ZeIhOT44ON5rjPiP@neat> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792351040199907572 X-GMAIL-MSGID: 1792351040199907572 |
Series |
[next] net/smc: Avoid -Wflex-array-member-not-at-end warnings
|
|
Commit Message
Gustavo A. R. Silva
March 1, 2024, 6:40 p.m. UTC
-Wflex-array-member-not-at-end is coming in GCC-14, and we are getting
ready to enable it globally.
There are currently a couple of objects in `struct smc_clc_msg_proposal_area`
that contain a couple of flexible structures:
struct smc_clc_msg_proposal_area {
...
struct smc_clc_v2_extension pclc_v2_ext;
...
struct smc_clc_smcd_v2_extension pclc_smcd_v2_ext;
...
};
So, in order to avoid ending up with a couple of flexible-array members
in the middle of a struct, we use the `struct_group_tagged()` helper to
separate the flexible array from the rest of the members in the flexible
structure:
struct smc_clc_smcd_v2_extension {
struct_group_tagged(smc_clc_smcd_v2_extension_hdr, hdr,
u8 system_eid[SMC_MAX_EID_LEN];
u8 reserved[16];
);
struct smc_clc_smcd_gid_chid gidchid[];
};
With the change described above, we now declare objects of the type of
the tagged struct without embedding flexible arrays in the middle of
another struct:
struct smc_clc_msg_proposal_area {
...
struct smc_clc_v2_extension_hdr pclc_v2_ext;
...
struct smc_clc_smcd_v2_extension_hdr pclc_smcd_v2_ext;
...
};
We also use `container_of()` when we need to retrieve a pointer to the
flexible structures.
So, with these changes, fix the following warnings:
In file included from net/smc/af_smc.c:42:
net/smc/smc_clc.h:186:49: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
186 | struct smc_clc_v2_extension pclc_v2_ext;
| ^~~~~~~~~~~
net/smc/smc_clc.h:188:49: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
188 | struct smc_clc_smcd_v2_extension pclc_smcd_v2_ext;
| ^~~~~~~~~~~~~~~~
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
net/smc/smc_clc.c | 5 +++--
net/smc/smc_clc.h | 24 ++++++++++++++----------
2 files changed, 17 insertions(+), 12 deletions(-)
Comments
On Fri, Mar 01, 2024 at 12:40:57PM -0600, Gustavo A. R. Silva wrote: > -Wflex-array-member-not-at-end is coming in GCC-14, and we are getting > ready to enable it globally. > > There are currently a couple of objects in `struct smc_clc_msg_proposal_area` > that contain a couple of flexible structures: > > struct smc_clc_msg_proposal_area { > ... > struct smc_clc_v2_extension pclc_v2_ext; > ... > struct smc_clc_smcd_v2_extension pclc_smcd_v2_ext; > ... > }; > > So, in order to avoid ending up with a couple of flexible-array members > in the middle of a struct, we use the `struct_group_tagged()` helper to > separate the flexible array from the rest of the members in the flexible > structure: > > struct smc_clc_smcd_v2_extension { > struct_group_tagged(smc_clc_smcd_v2_extension_hdr, hdr, > u8 system_eid[SMC_MAX_EID_LEN]; > u8 reserved[16]; > ); > struct smc_clc_smcd_gid_chid gidchid[]; > }; > > With the change described above, we now declare objects of the type of > the tagged struct without embedding flexible arrays in the middle of > another struct: > > struct smc_clc_msg_proposal_area { > ... > struct smc_clc_v2_extension_hdr pclc_v2_ext; > ... > struct smc_clc_smcd_v2_extension_hdr pclc_smcd_v2_ext; > ... > }; > > We also use `container_of()` when we need to retrieve a pointer to the > flexible structures. > > So, with these changes, fix the following warnings: > > In file included from net/smc/af_smc.c:42: > net/smc/smc_clc.h:186:49: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end] > 186 | struct smc_clc_v2_extension pclc_v2_ext; > | ^~~~~~~~~~~ > net/smc/smc_clc.h:188:49: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end] > 188 | struct smc_clc_smcd_v2_extension pclc_smcd_v2_ext; > | ^~~~~~~~~~~~~~~~ > > Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> I think this is a nice way to deal with these flex-array cases. Using the struct_group() and container_of() means there is very little collateral impact. Since this is isolated to a single file, I wonder if it's easy to check that there are no binary differences too? I wouldn't expect any -- container_of() is all constant expressions, so the assignment offsets should all be the same, etc. Reviewed-by: Kees Cook <keescook@chromium.org> -Kees
On 2024/3/2 02:40, Gustavo A. R. Silva wrote: > -Wflex-array-member-not-at-end is coming in GCC-14, and we are getting > ready to enable it globally. > > There are currently a couple of objects in `struct smc_clc_msg_proposal_area` > that contain a couple of flexible structures: > > struct smc_clc_msg_proposal_area { > ... > struct smc_clc_v2_extension pclc_v2_ext; > ... > struct smc_clc_smcd_v2_extension pclc_smcd_v2_ext; > ... > }; > > So, in order to avoid ending up with a couple of flexible-array members > in the middle of a struct, we use the `struct_group_tagged()` helper to > separate the flexible array from the rest of the members in the flexible > structure: > > struct smc_clc_smcd_v2_extension { > struct_group_tagged(smc_clc_smcd_v2_extension_hdr, hdr, > u8 system_eid[SMC_MAX_EID_LEN]; > u8 reserved[16]; > ); > struct smc_clc_smcd_gid_chid gidchid[]; > }; > > With the change described above, we now declare objects of the type of > the tagged struct without embedding flexible arrays in the middle of > another struct: > > struct smc_clc_msg_proposal_area { > ... > struct smc_clc_v2_extension_hdr pclc_v2_ext; > ... > struct smc_clc_smcd_v2_extension_hdr pclc_smcd_v2_ext; > ... > }; > > We also use `container_of()` when we need to retrieve a pointer to the > flexible structures. > > So, with these changes, fix the following warnings: > > In file included from net/smc/af_smc.c:42: > net/smc/smc_clc.h:186:49: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end] > 186 | struct smc_clc_v2_extension pclc_v2_ext; > | ^~~~~~~~~~~ > net/smc/smc_clc.h:188:49: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end] > 188 | struct smc_clc_smcd_v2_extension pclc_smcd_v2_ext; > | ^~~~~~~~~~~~~~~~ > > Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> > --- > net/smc/smc_clc.c | 5 +++-- > net/smc/smc_clc.h | 24 ++++++++++++++---------- > 2 files changed, 17 insertions(+), 12 deletions(-) > > diff --git a/net/smc/smc_clc.c b/net/smc/smc_clc.c > index e55026c7529c..3094cfa1c458 100644 > --- a/net/smc/smc_clc.c > +++ b/net/smc/smc_clc.c > @@ -853,8 +853,9 @@ int smc_clc_send_proposal(struct smc_sock *smc, struct smc_init_info *ini) > pclc_smcd = &pclc->pclc_smcd; > pclc_prfx = &pclc->pclc_prfx; > ipv6_prfx = pclc->pclc_prfx_ipv6; > - v2_ext = &pclc->pclc_v2_ext; > - smcd_v2_ext = &pclc->pclc_smcd_v2_ext; > + v2_ext = container_of(&pclc->pclc_v2_ext, struct smc_clc_v2_extension, _hdr); > + smcd_v2_ext = container_of(&pclc->pclc_smcd_v2_ext, > + struct smc_clc_smcd_v2_extension, hdr); > gidchids = pclc->pclc_gidchids; > trl = &pclc->pclc_trl; > > diff --git a/net/smc/smc_clc.h b/net/smc/smc_clc.h > index 7cc7070b9772..5b91a1947078 100644 > --- a/net/smc/smc_clc.h > +++ b/net/smc/smc_clc.h > @@ -134,12 +134,14 @@ struct smc_clc_smcd_gid_chid { > */ > > struct smc_clc_v2_extension { > - struct smc_clnt_opts_area_hdr hdr; > - u8 roce[16]; /* RoCEv2 GID */ > - u8 max_conns; > - u8 max_links; > - __be16 feature_mask; > - u8 reserved[12]; > + struct_group_tagged(smc_clc_v2_extension_hdr, _hdr, > + struct smc_clnt_opts_area_hdr hdr; > + u8 roce[16]; /* RoCEv2 GID */ > + u8 max_conns; > + u8 max_links; > + __be16 feature_mask; > + u8 reserved[12]; > + ); > u8 user_eids[][SMC_MAX_EID_LEN]; > }; > > @@ -159,8 +161,10 @@ struct smc_clc_msg_smcd { /* SMC-D GID information */ > }; > > struct smc_clc_smcd_v2_extension { > - u8 system_eid[SMC_MAX_EID_LEN]; > - u8 reserved[16]; > + struct_group_tagged(smc_clc_smcd_v2_extension_hdr, hdr, > + u8 system_eid[SMC_MAX_EID_LEN]; > + u8 reserved[16]; > + ); > struct smc_clc_smcd_gid_chid gidchid[]; > }; > > @@ -183,9 +187,9 @@ struct smc_clc_msg_proposal_area { > struct smc_clc_msg_smcd pclc_smcd; > struct smc_clc_msg_proposal_prefix pclc_prfx; > struct smc_clc_ipv6_prefix pclc_prfx_ipv6[SMC_CLC_MAX_V6_PREFIX]; > - struct smc_clc_v2_extension pclc_v2_ext; > + struct smc_clc_v2_extension_hdr pclc_v2_ext; > u8 user_eids[SMC_CLC_MAX_UEID][SMC_MAX_EID_LEN]; > - struct smc_clc_smcd_v2_extension pclc_smcd_v2_ext; > + struct smc_clc_smcd_v2_extension_hdr pclc_smcd_v2_ext; > struct smc_clc_smcd_gid_chid > pclc_gidchids[SMCD_CLC_MAX_V2_GID_ENTRIES]; > struct smc_clc_msg_trail pclc_trl; Thank you! Gustavo. This patch can fix this warning well, just the name '*_hdr' might not be very accurate, but I don't have a good idea ATM. Besides, I am wondering if this can be fixed by moving user_eids of smc_clc_msg_proposal_area into smc_clc_v2_extension, and pclc_gidchids of smc_clc_msg_proposal_area into smc_clc_smcd_v2_extension. so that we can avoid to use the flexible-array in smc_clc_v2_extension and smc_clc_smcd_v2_extension. diff --git a/net/smc/smc_clc.c b/net/smc/smc_clc.c index e55026c7529c..971b4677b84d 100644 --- a/net/smc/smc_clc.c +++ b/net/smc/smc_clc.c @@ -855,7 +855,7 @@ int smc_clc_send_proposal(struct smc_sock *smc, struct smc_init_info *ini) ipv6_prfx = pclc->pclc_prfx_ipv6; v2_ext = &pclc->pclc_v2_ext; smcd_v2_ext = &pclc->pclc_smcd_v2_ext; - gidchids = pclc->pclc_gidchids; + gidchids = pclc->pclc_smcd_v2_ext.gidchid; trl = &pclc->pclc_trl; pclc_base->hdr.version = SMC_V2; diff --git a/net/smc/smc_clc.h b/net/smc/smc_clc.h index 7cc7070b9772..36c8432af73e 100644 --- a/net/smc/smc_clc.h +++ b/net/smc/smc_clc.h @@ -133,6 +133,14 @@ struct smc_clc_smcd_gid_chid { * (https://www.ibm.com/support/pages/node/6326337) */ +#define SMC_CLC_MAX_V6_PREFIX 8 +#define SMC_CLC_MAX_UEID 8 +#define SMCD_CLC_MAX_V2_GID_ENTRIES 8 /* max # of CHID-GID entries in CLC + * proposal SMC-Dv2 extension. + * each ISM device takes one entry and + * each Emulated-ISM takes two entries + */ + struct smc_clc_v2_extension { struct smc_clnt_opts_area_hdr hdr; u8 roce[16]; /* RoCEv2 GID */ @@ -140,7 +148,7 @@ struct smc_clc_v2_extension { u8 max_links; __be16 feature_mask; u8 reserved[12]; - u8 user_eids[][SMC_MAX_EID_LEN]; + u8 user_eids[SMC_CLC_MAX_UEID][SMC_MAX_EID_LEN]; }; struct smc_clc_msg_proposal_prefix { /* prefix part of clc proposal message*/ @@ -161,7 +169,7 @@ struct smc_clc_msg_smcd { /* SMC-D GID information */ struct smc_clc_smcd_v2_extension { u8 system_eid[SMC_MAX_EID_LEN]; u8 reserved[16]; - struct smc_clc_smcd_gid_chid gidchid[]; + struct smc_clc_smcd_gid_chid gidchid[SMCD_CLC_MAX_V2_GID_ENTRIES]; }; struct smc_clc_msg_proposal { /* clc proposal message sent by Linux */ @@ -170,24 +178,13 @@ struct smc_clc_msg_proposal { /* clc proposal message sent by Linux */ __be16 iparea_offset; /* offset to IP address information area */ } __aligned(4); -#define SMC_CLC_MAX_V6_PREFIX 8 -#define SMC_CLC_MAX_UEID 8 -#define SMCD_CLC_MAX_V2_GID_ENTRIES 8 /* max # of CHID-GID entries in CLC - * proposal SMC-Dv2 extension. - * each ISM device takes one entry and - * each Emulated-ISM takes two entries - */ - struct smc_clc_msg_proposal_area { struct smc_clc_msg_proposal pclc_base; struct smc_clc_msg_smcd pclc_smcd; struct smc_clc_msg_proposal_prefix pclc_prfx; struct smc_clc_ipv6_prefix pclc_prfx_ipv6[SMC_CLC_MAX_V6_PREFIX]; struct smc_clc_v2_extension pclc_v2_ext; - u8 user_eids[SMC_CLC_MAX_UEID][SMC_MAX_EID_LEN]; struct smc_clc_smcd_v2_extension pclc_smcd_v2_ext; - struct smc_clc_smcd_gid_chid - pclc_gidchids[SMCD_CLC_MAX_V2_GID_ENTRIES]; struct smc_clc_msg_trail pclc_trl; }; Thanks! Wen Gu
diff --git a/net/smc/smc_clc.c b/net/smc/smc_clc.c index e55026c7529c..3094cfa1c458 100644 --- a/net/smc/smc_clc.c +++ b/net/smc/smc_clc.c @@ -853,8 +853,9 @@ int smc_clc_send_proposal(struct smc_sock *smc, struct smc_init_info *ini) pclc_smcd = &pclc->pclc_smcd; pclc_prfx = &pclc->pclc_prfx; ipv6_prfx = pclc->pclc_prfx_ipv6; - v2_ext = &pclc->pclc_v2_ext; - smcd_v2_ext = &pclc->pclc_smcd_v2_ext; + v2_ext = container_of(&pclc->pclc_v2_ext, struct smc_clc_v2_extension, _hdr); + smcd_v2_ext = container_of(&pclc->pclc_smcd_v2_ext, + struct smc_clc_smcd_v2_extension, hdr); gidchids = pclc->pclc_gidchids; trl = &pclc->pclc_trl; diff --git a/net/smc/smc_clc.h b/net/smc/smc_clc.h index 7cc7070b9772..5b91a1947078 100644 --- a/net/smc/smc_clc.h +++ b/net/smc/smc_clc.h @@ -134,12 +134,14 @@ struct smc_clc_smcd_gid_chid { */ struct smc_clc_v2_extension { - struct smc_clnt_opts_area_hdr hdr; - u8 roce[16]; /* RoCEv2 GID */ - u8 max_conns; - u8 max_links; - __be16 feature_mask; - u8 reserved[12]; + struct_group_tagged(smc_clc_v2_extension_hdr, _hdr, + struct smc_clnt_opts_area_hdr hdr; + u8 roce[16]; /* RoCEv2 GID */ + u8 max_conns; + u8 max_links; + __be16 feature_mask; + u8 reserved[12]; + ); u8 user_eids[][SMC_MAX_EID_LEN]; }; @@ -159,8 +161,10 @@ struct smc_clc_msg_smcd { /* SMC-D GID information */ }; struct smc_clc_smcd_v2_extension { - u8 system_eid[SMC_MAX_EID_LEN]; - u8 reserved[16]; + struct_group_tagged(smc_clc_smcd_v2_extension_hdr, hdr, + u8 system_eid[SMC_MAX_EID_LEN]; + u8 reserved[16]; + ); struct smc_clc_smcd_gid_chid gidchid[]; }; @@ -183,9 +187,9 @@ struct smc_clc_msg_proposal_area { struct smc_clc_msg_smcd pclc_smcd; struct smc_clc_msg_proposal_prefix pclc_prfx; struct smc_clc_ipv6_prefix pclc_prfx_ipv6[SMC_CLC_MAX_V6_PREFIX]; - struct smc_clc_v2_extension pclc_v2_ext; + struct smc_clc_v2_extension_hdr pclc_v2_ext; u8 user_eids[SMC_CLC_MAX_UEID][SMC_MAX_EID_LEN]; - struct smc_clc_smcd_v2_extension pclc_smcd_v2_ext; + struct smc_clc_smcd_v2_extension_hdr pclc_smcd_v2_ext; struct smc_clc_smcd_gid_chid pclc_gidchids[SMCD_CLC_MAX_V2_GID_ENTRIES]; struct smc_clc_msg_trail pclc_trl;