netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: "Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: Simon Horman <horms@kernel.org>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Paolo Abeni <pabeni@redhat.com>,
	oss-drivers@corigine.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: Re: [PATCH][next] nfp: tls: Avoid -Wflex-array-member-not-at-end warnings
Date: Mon, 24 Nov 2025 18:39:49 -0800	[thread overview]
Message-ID: <20251124183949.62d61b24@kernel.org> (raw)
In-Reply-To: <aR5_a1tD9KKp363I@kspp>

On Thu, 20 Nov 2025 11:39:39 +0900 Gustavo A. R. Silva wrote:
>  struct nfp_crypto_req_add_front {
> -	struct nfp_ccm_hdr hdr;
> -	__be32 ep_id;
> -	u8 resv[3];
> -	u8 opcode;
> -	u8 key_len;
> -	__be16 ipver_vlan __packed;
> -	u8 l4_proto;
> +	/* New members MUST be added within the struct_group() macro below. */
> +	struct_group_tagged(nfp_crypto_req_add_front_hdr, __hdr,
> +		struct nfp_ccm_hdr hdr;
> +		__be32 ep_id;
> +		u8 resv[3];
> +		u8 opcode;
> +		u8 key_len;
> +		__be16 ipver_vlan __packed;
> +		u8 l4_proto;
> +	);
>  #define NFP_NET_TLS_NON_ADDR_KEY_LEN	8
>  	u8 l3_addrs[];
>  };
> +static_assert(offsetof(struct nfp_crypto_req_add_front, l3_addrs) ==
> +	      sizeof(struct nfp_crypto_req_add_front_hdr),
> +	      "struct member likely outside of struct_group_tagged()");
>  
>  struct nfp_crypto_req_add_back {
>  	__be16 src_port;
> @@ -55,14 +61,14 @@ struct nfp_crypto_req_add_back {
>  };
>  
>  struct nfp_crypto_req_add_v4 {
> -	struct nfp_crypto_req_add_front front;
> +	struct nfp_crypto_req_add_front_hdr front;
>  	__be32 src_ip;
>  	__be32 dst_ip;
>  	struct nfp_crypto_req_add_back back;
>  };
>  
>  struct nfp_crypto_req_add_v6 {
> -	struct nfp_crypto_req_add_front front;
> +	struct nfp_crypto_req_add_front_hdr front;
>  	__be32 src_ip[4];
>  	__be32 dst_ip[4];
>  	struct nfp_crypto_req_add_back back;
> diff --git a/drivers/net/ethernet/netronome/nfp/crypto/tls.c b/drivers/net/ethernet/netronome/nfp/crypto/tls.c
> index f252ecdcd2cd..a6d6a334c84b 100644
> --- a/drivers/net/ethernet/netronome/nfp/crypto/tls.c
> +++ b/drivers/net/ethernet/netronome/nfp/crypto/tls.c
> @@ -180,7 +180,8 @@ nfp_net_tls_set_ipv4(struct nfp_net *nn, struct nfp_crypto_req_add_v4 *req,
>  	req->front.key_len += sizeof(__be32) * 2;
>  
>  	if (direction == TLS_OFFLOAD_CTX_DIR_TX) {
> -		nfp_net_tls_assign_conn_id(nn, &req->front);
> +		nfp_net_tls_assign_conn_id(nn,
> +			container_of(&req->front, struct nfp_crypto_req_add_front, __hdr));

Once again you're making the code unacceptably ugly.
-- 
pw-bot: cr

      parent reply	other threads:[~2025-11-25  2:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-20  2:39 [PATCH][next] nfp: tls: Avoid -Wflex-array-member-not-at-end warnings Gustavo A. R. Silva
2025-11-24 14:13 ` Simon Horman
2025-11-25  2:39 ` Jakub Kicinski [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251124183949.62d61b24@kernel.org \
    --to=kuba@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=gustavoars@kernel.org \
    --cc=horms@kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=oss-drivers@corigine.com \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).