[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZioHJtWPNbb3bcqT@shredder>
Date: Thu, 25 Apr 2024 10:32:54 +0300
From: Ido Schimmel <idosch@...sch.org>
To: Adrian Moreno <amorenoz@...hat.com>
Cc: netdev@...r.kernel.org, aconole@...hat.com, echaudro@...hat.com,
horms@...nel.org, i.maximets@....org,
Yotam Gigi <yotam.gi@...il.com>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH net-next 3/8] net: psample: add user cookie
On Wed, Apr 24, 2024 at 03:50:50PM +0200, Adrian Moreno wrote:
> @@ -579,6 +580,15 @@ void psample_sample_packet(struct psample_group *group, struct sk_buff *skb,
> goto error;
> }
> #endif
> + if (md->user_cookie && md->user_cookie_len) {
> + int nla_len = nla_total_size(md->user_cookie_len);
> + struct nlattr *nla;
> +
> + nla = skb_put(nl_skb, nla_len);
> + nla->nla_type = PSAMPLE_ATTR_USER_COOKIE;
> + nla->nla_len = nla_attr_size(md->user_cookie_len);
> + memcpy(nla_data(nla), md->user_cookie, md->user_cookie_len);
> + }
Did you consider using nla_put() instead?
diff --git a/net/psample/psample.c b/net/psample/psample.c
index 92db8ffa2ba2..ea59ca46b119 100644
--- a/net/psample/psample.c
+++ b/net/psample/psample.c
@@ -589,15 +589,10 @@ void psample_sample_packet(struct psample_group *group, struct sk_buff *skb,
goto error;
}
#endif
- if (md->user_cookie && md->user_cookie_len) {
- int nla_len = nla_total_size(md->user_cookie_len);
- struct nlattr *nla;
-
- nla = skb_put(nl_skb, nla_len);
- nla->nla_type = PSAMPLE_ATTR_USER_COOKIE;
- nla->nla_len = nla_attr_size(md->user_cookie_len);
- memcpy(nla_data(nla), md->user_cookie, md->user_cookie_len);
- }
+ if (md->user_cookie && md->user_cookie_len &&
+ nla_put(nl_skb, PSAMPLE_ATTR_USER_COOKIE, md->user_cookie_len,
+ md->user_cookie))
+ goto error;
genlmsg_end(nl_skb, data);
psample_nl_obj_desc_init(&desc, group->group_num);
Powered by blists - more mailing lists