* [PATCH net-next] net/sched: act_api: Remove unnecessary nlmsg_trim()
@ 2025-08-13 12:59 Yue Haibing
2025-08-14 0:34 ` Jakub Kicinski
0 siblings, 1 reply; 2+ messages in thread
From: Yue Haibing @ 2025-08-13 12:59 UTC (permalink / raw)
To: jhs, xiyou.wangcong, jiri, davem, edumazet, kuba, pabeni, horms,
vladimir.oltean
Cc: netdev, linux-kernel
If tca_get_fill() fails, all callers free the skb immediately, no need to
trim it back to the previous size.
Signed-off-by: Yue Haibing <yuehaibing@huawei.com>
---
net/sched/act_api.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/net/sched/act_api.c b/net/sched/act_api.c
index 9e468e463467..54c92d0755c9 100644
--- a/net/sched/act_api.c
+++ b/net/sched/act_api.c
@@ -1649,7 +1649,7 @@ static int tca_get_fill(struct sk_buff *skb, struct tc_action *actions[],
nlh = nlmsg_put(skb, portid, seq, event, sizeof(*t), flags);
if (!nlh)
- goto out_nlmsg_trim;
+ goto out;
t = nlmsg_data(nlh);
t->tca_family = AF_UNSPEC;
t->tca__pad1 = 0;
@@ -1657,14 +1657,14 @@ static int tca_get_fill(struct sk_buff *skb, struct tc_action *actions[],
if (extack && extack->_msg &&
nla_put_string(skb, TCA_ROOT_EXT_WARN_MSG, extack->_msg))
- goto out_nlmsg_trim;
+ goto out;
nest = nla_nest_start_noflag(skb, TCA_ACT_TAB);
if (!nest)
- goto out_nlmsg_trim;
+ goto out;
if (tcf_action_dump(skb, actions, bind, ref, false) < 0)
- goto out_nlmsg_trim;
+ goto out;
nla_nest_end(skb, nest);
@@ -1672,8 +1672,7 @@ static int tca_get_fill(struct sk_buff *skb, struct tc_action *actions[],
return skb->len;
-out_nlmsg_trim:
- nlmsg_trim(skb, b);
+out:
return -1;
}
--
2.33.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net-next] net/sched: act_api: Remove unnecessary nlmsg_trim()
2025-08-13 12:59 [PATCH net-next] net/sched: act_api: Remove unnecessary nlmsg_trim() Yue Haibing
@ 2025-08-14 0:34 ` Jakub Kicinski
0 siblings, 0 replies; 2+ messages in thread
From: Jakub Kicinski @ 2025-08-14 0:34 UTC (permalink / raw)
To: Yue Haibing
Cc: jhs, xiyou.wangcong, jiri, davem, edumazet, pabeni, horms,
vladimir.oltean, netdev, linux-kernel
On Wed, 13 Aug 2025 20:59:15 +0800 Yue Haibing wrote:
> If tca_get_fill() fails, all callers free the skb immediately, no need to
> trim it back to the previous size.
Okay, but why do we care enough to change it?
This is a fairly common pattern in netlink message formatting.
--
pw-bot: cr
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-08-14 0:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-13 12:59 [PATCH net-next] net/sched: act_api: Remove unnecessary nlmsg_trim() Yue Haibing
2025-08-14 0:34 ` Jakub Kicinski
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).