All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Gal Pressman <gal@nvidia.com>
Cc: <netdev@vger.kernel.org>, "David S. Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@google.com>,
	Paolo Abeni <pabeni@redhat.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	Tariq Toukan <tariqt@nvidia.com>,
	Louis Peens <louis.peens@corigine.com>,
	Simon Horman <horms@kernel.org>, David Ahern <dsahern@kernel.org>,
	"Pravin B Shelar" <pshelar@ovn.org>,
	Yotam Gigi <yotam.gi@gmail.com>,
	Jamal Hadi Salim <jhs@mojatatu.com>,
	Cong Wang <xiyou.wangcong@gmail.com>,
	Jiri Pirko <jiri@resnulli.us>, Kees Cook <kees@kernel.org>,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>,
	<dev@openvswitch.org>, <linux-hardening@vger.kernel.org>,
	Ilya Maximets <i.maximets@ovn.org>,
	Alexander Lobakin <aleksander.lobakin@intel.com>
Subject: Re: [PATCH net-next v3 1/2] ip_tunnel: Use ip_tunnel_info() helper instead of 'info + 1'
Date: Tue, 18 Feb 2025 18:45:13 -0800	[thread overview]
Message-ID: <20250218184513.05ac19d0@kernel.org> (raw)
In-Reply-To: <20250217202503.265318-2-gal@nvidia.com>

On Mon, 17 Feb 2025 22:25:02 +0200 Gal Pressman wrote:
> diff --git a/net/sched/act_tunnel_key.c b/net/sched/act_tunnel_key.c
> index af7c99845948..6d97be6bc7fa 100644
> --- a/net/sched/act_tunnel_key.c
> +++ b/net/sched/act_tunnel_key.c
> @@ -572,7 +572,7 @@ static int tunnel_key_geneve_opts_dump(struct sk_buff *skb,
>  				       const struct ip_tunnel_info *info)
>  {
>  	int len = info->options_len;
> -	u8 *src = (u8 *)(info + 1);
> +	u8 *src = (u8 *)ip_tunnel_info_opts(info);
>  	struct nlattr *start;
>  
>  	start = nla_nest_start_noflag(skb, TCA_TUNNEL_KEY_ENC_OPTS_GENEVE);
> @@ -603,7 +603,8 @@ static int tunnel_key_geneve_opts_dump(struct sk_buff *skb,
>  static int tunnel_key_vxlan_opts_dump(struct sk_buff *skb,
>  				      const struct ip_tunnel_info *info)
>  {
> -	struct vxlan_metadata *md = (struct vxlan_metadata *)(info + 1);
> +	struct vxlan_metadata *md =
> +		(struct vxlan_metadata *)ip_tunnel_info_opts(info);
>  	struct nlattr *start;
>  
>  	start = nla_nest_start_noflag(skb, TCA_TUNNEL_KEY_ENC_OPTS_VXLAN);
> @@ -622,7 +623,8 @@ static int tunnel_key_vxlan_opts_dump(struct sk_buff *skb,
>  static int tunnel_key_erspan_opts_dump(struct sk_buff *skb,
>  				       const struct ip_tunnel_info *info)
>  {
> -	struct erspan_metadata *md = (struct erspan_metadata *)(info + 1);
> +	struct erspan_metadata *md =
> +		(struct erspan_metadata *)ip_tunnel_info_opts(info);
>  	struct nlattr *start;

We shouldn't cast the const away any more. 
Squash this in, please:

diff --git a/net/sched/act_tunnel_key.c b/net/sched/act_tunnel_key.c
index 6d97be6bc7fa..ae5dea7c48a8 100644
--- a/net/sched/act_tunnel_key.c
+++ b/net/sched/act_tunnel_key.c
@@ -569,20 +569,20 @@ static void tunnel_key_release(struct tc_action *a)
 }
 
 static int tunnel_key_geneve_opts_dump(struct sk_buff *skb,
                                       const struct ip_tunnel_info *info)
 {
+       const u8 *src = ip_tunnel_info_opts(info);
        int len = info->options_len;
-       u8 *src = (u8 *)ip_tunnel_info_opts(info);
        struct nlattr *start;
 
        start = nla_nest_start_noflag(skb, TCA_TUNNEL_KEY_ENC_OPTS_GENEVE);
        if (!start)
                return -EMSGSIZE;
 
        while (len > 0) {
-               struct geneve_opt *opt = (struct geneve_opt *)src;
+               const struct geneve_opt *opt = (const struct geneve_opt *)src;
 
                if (nla_put_be16(skb, TCA_TUNNEL_KEY_ENC_OPT_GENEVE_CLASS,
                                 opt->opt_class) ||
                    nla_put_u8(skb, TCA_TUNNEL_KEY_ENC_OPT_GENEVE_TYPE,
                               opt->type) ||
@@ -601,12 +601,11 @@ static int tunnel_key_geneve_opts_dump(struct sk_buff *skb,
 }
 
 static int tunnel_key_vxlan_opts_dump(struct sk_buff *skb,
                                      const struct ip_tunnel_info *info)
 {
-       struct vxlan_metadata *md =
-               (struct vxlan_metadata *)ip_tunnel_info_opts(info);
+       const struct vxlan_metadata *md = ip_tunnel_info_opts(info);
        struct nlattr *start;
 
        start = nla_nest_start_noflag(skb, TCA_TUNNEL_KEY_ENC_OPTS_VXLAN);
        if (!start)
                return -EMSGSIZE;
@@ -621,12 +620,11 @@ static int tunnel_key_vxlan_opts_dump(struct sk_buff *skb,
 }
 
 static int tunnel_key_erspan_opts_dump(struct sk_buff *skb,
                                       const struct ip_tunnel_info *info)
 {
-       struct erspan_metadata *md =
-               (struct erspan_metadata *)ip_tunnel_info_opts(info);
+       const struct erspan_metadata *md = ip_tunnel_info_opts(info);
        struct nlattr *start;
 
        start = nla_nest_start_noflag(skb, TCA_TUNNEL_KEY_ENC_OPTS_ERSPAN);
        if (!start)
                return -EMSGSIZE;

-- 
pw-bot: cr

  reply	other threads:[~2025-02-19  2:45 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-17 20:25 [PATCH net-next v3 0/2] Flexible array for ip tunnel options Gal Pressman
2025-02-17 20:25 ` [PATCH net-next v3 1/2] ip_tunnel: Use ip_tunnel_info() helper instead of 'info + 1' Gal Pressman
2025-02-19  2:45   ` Jakub Kicinski [this message]
2025-02-17 20:25 ` [PATCH net-next v3 2/2] net: Add options as a flexible array to struct ip_tunnel_info Gal Pressman

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=20250218184513.05ac19d0@kernel.org \
    --to=kuba@kernel.org \
    --cc=aleksander.lobakin@intel.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=dev@openvswitch.org \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=gal@nvidia.com \
    --cc=gustavoars@kernel.org \
    --cc=horms@kernel.org \
    --cc=i.maximets@ovn.org \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=kees@kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=louis.peens@corigine.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pshelar@ovn.org \
    --cc=tariqt@nvidia.com \
    --cc=xiyou.wangcong@gmail.com \
    --cc=yotam.gi@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.