Skip to content

Commit dc5fc57

Browse files
acmelDavid S. Miller
authored andcommitted
[NETLINK]: Use nlmsg_trim() where appropriate
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent a36ca73 commit dc5fc57

34 files changed

Lines changed: 93 additions & 62 deletions

‎include/net/netlink.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
548548
*
549549
* Trims the message to the provided mark. Returns -1.
550550
*/
551-
static inline int nlmsg_trim(struct sk_buff *skb, void *mark)
551+
static inline int nlmsg_trim(struct sk_buff *skb, const void *mark)
552552
{
553553
if (mark)
554554
skb_trim(skb, (unsigned char *) mark - skb->data);

‎net/core/wireless.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1957,7 +1957,7 @@ static inline int rtnetlink_fill_iwinfo(struct sk_buff * skb,
19571957

19581958
nlmsg_failure:
19591959
rtattr_failure:
1960-
skb_trim(skb, b - skb->data);
1960+
nlmsg_trim(skb, b);
19611961
return -1;
19621962
}
19631963

‎net/decnet/dn_route.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
#include <linux/rcupdate.h>
7878
#include <linux/times.h>
7979
#include <asm/errno.h>
80+
#include <net/netlink.h>
8081
#include <net/neighbour.h>
8182
#include <net/dst.h>
8283
#include <net/flow.h>
@@ -1514,7 +1515,7 @@ static int dn_rt_fill_info(struct sk_buff *skb, u32 pid, u32 seq,
15141515

15151516
nlmsg_failure:
15161517
rtattr_failure:
1517-
skb_trim(skb, b - skb->data);
1518+
nlmsg_trim(skb, b);
15181519
return -1;
15191520
}
15201521

‎net/decnet/dn_table.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <asm/uaccess.h>
2929
#include <linux/route.h> /* RTF_xxx */
3030
#include <net/neighbour.h>
31+
#include <net/netlink.h>
3132
#include <net/dst.h>
3233
#include <net/flow.h>
3334
#include <net/fib_rules.h>
@@ -349,7 +350,7 @@ static int dn_fib_dump_info(struct sk_buff *skb, u32 pid, u32 seq, int event,
349350

350351
nlmsg_failure:
351352
rtattr_failure:
352-
skb_trim(skb, b - skb->data);
353+
nlmsg_trim(skb, b);
353354
return -EMSGSIZE;
354355
}
355356

‎net/ipv4/inet_diag.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <net/inet_hashtables.h>
2828
#include <net/inet_timewait_sock.h>
2929
#include <net/inet6_hashtables.h>
30+
#include <net/netlink.h>
3031

3132
#include <linux/inet.h>
3233
#include <linux/stddef.h>
@@ -152,7 +153,7 @@ static int inet_csk_diag_fill(struct sock *sk,
152153

153154
rtattr_failure:
154155
nlmsg_failure:
155-
skb_trim(skb, b - skb->data);
156+
nlmsg_trim(skb, b);
156157
return -EMSGSIZE;
157158
}
158159

@@ -208,7 +209,7 @@ static int inet_twsk_diag_fill(struct inet_timewait_sock *tw,
208209
nlh->nlmsg_len = skb_tail_pointer(skb) - previous_tail;
209210
return skb->len;
210211
nlmsg_failure:
211-
skb_trim(skb, previous_tail - skb->data);
212+
nlmsg_trim(skb, previous_tail);
212213
return -EMSGSIZE;
213214
}
214215

@@ -579,7 +580,7 @@ static int inet_diag_fill_req(struct sk_buff *skb, struct sock *sk,
579580
return skb->len;
580581

581582
nlmsg_failure:
582-
skb_trim(skb, b - skb->data);
583+
nlmsg_trim(skb, b);
583584
return -1;
584585
}
585586

‎net/ipv4/ipmr.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
#include <linux/netfilter_ipv4.h>
6363
#include <net/ipip.h>
6464
#include <net/checksum.h>
65+
#include <net/netlink.h>
6566

6667
#if defined(CONFIG_IP_PIMSM_V1) || defined(CONFIG_IP_PIMSM_V2)
6768
#define CONFIG_IP_PIMSM 1
@@ -1570,7 +1571,7 @@ ipmr_fill_mroute(struct sk_buff *skb, struct mfc_cache *c, struct rtmsg *rtm)
15701571
return 1;
15711572

15721573
rtattr_failure:
1573-
skb_trim(skb, b - skb->data);
1574+
nlmsg_trim(skb, b);
15741575
return -EMSGSIZE;
15751576
}
15761577

‎net/netfilter/nf_conntrack_netlink.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#include <linux/notifier.h>
3434

3535
#include <linux/netfilter.h>
36+
#include <net/netlink.h>
3637
#include <net/netfilter/nf_conntrack.h>
3738
#include <net/netfilter/nf_conntrack_core.h>
3839
#include <net/netfilter/nf_conntrack_expect.h>
@@ -306,7 +307,7 @@ ctnetlink_fill_info(struct sk_buff *skb, u32 pid, u32 seq,
306307

307308
nlmsg_failure:
308309
nfattr_failure:
309-
skb_trim(skb, b - skb->data);
310+
nlmsg_trim(skb, b);
310311
return -1;
311312
}
312313

@@ -1169,7 +1170,7 @@ ctnetlink_exp_fill_info(struct sk_buff *skb, u32 pid, u32 seq,
11691170

11701171
nlmsg_failure:
11711172
nfattr_failure:
1172-
skb_trim(skb, b - skb->data);
1173+
nlmsg_trim(skb, b);
11731174
return -1;
11741175
}
11751176

‎net/sched/act_api.c‎

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include <net/sock.h>
3232
#include <net/sch_generic.h>
3333
#include <net/act_api.h>
34+
#include <net/netlink.h>
3435

3536
void tcf_hash_destroy(struct tcf_common *p, struct tcf_hashinfo *hinfo)
3637
{
@@ -98,7 +99,7 @@ static int tcf_dump_walker(struct sk_buff *skb, struct netlink_callback *cb,
9899
err = tcf_action_dump_1(skb, a, 0, 0);
99100
if (err < 0) {
100101
index--;
101-
skb_trim(skb, (u8*)r - skb->data);
102+
nlmsg_trim(skb, r);
102103
goto done;
103104
}
104105
r->rta_len = skb_tail_pointer(skb) - (u8 *)r;
@@ -114,7 +115,7 @@ static int tcf_dump_walker(struct sk_buff *skb, struct netlink_callback *cb,
114115
return n_i;
115116

116117
rtattr_failure:
117-
skb_trim(skb, (u8*)r - skb->data);
118+
nlmsg_trim(skb, r);
118119
goto done;
119120
}
120121

@@ -144,7 +145,7 @@ static int tcf_del_walker(struct sk_buff *skb, struct tc_action *a,
144145

145146
return n_i;
146147
rtattr_failure:
147-
skb_trim(skb, (u8*)r - skb->data);
148+
nlmsg_trim(skb, r);
148149
return -EINVAL;
149150
}
150151

@@ -440,7 +441,7 @@ tcf_action_dump_1(struct sk_buff *skb, struct tc_action *a, int bind, int ref)
440441
}
441442

442443
rtattr_failure:
443-
skb_trim(skb, b - skb->data);
444+
nlmsg_trim(skb, b);
444445
return -1;
445446
}
446447

@@ -467,7 +468,7 @@ tcf_action_dump(struct sk_buff *skb, struct tc_action *act, int bind, int ref)
467468
rtattr_failure:
468469
err = -EINVAL;
469470
errout:
470-
skb_trim(skb, b - skb->data);
471+
nlmsg_trim(skb, b);
471472
return err;
472473
}
473474

@@ -658,7 +659,7 @@ tca_get_fill(struct sk_buff *skb, struct tc_action *a, u32 pid, u32 seq,
658659

659660
rtattr_failure:
660661
nlmsg_failure:
661-
skb_trim(skb, b - skb->data);
662+
nlmsg_trim(skb, b);
662663
return -1;
663664
}
664665

@@ -1059,7 +1060,7 @@ tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb)
10591060
x->rta_len = skb_tail_pointer(skb) - (u8 *)x;
10601061
ret = skb->len;
10611062
} else
1062-
skb_trim(skb, (u8*)x - skb->data);
1063+
nlmsg_trim(skb, x);
10631064

10641065
nlh->nlmsg_len = skb_tail_pointer(skb) - b;
10651066
if (NETLINK_CB(cb->skb).pid && ret)
@@ -1070,7 +1071,7 @@ tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb)
10701071
rtattr_failure:
10711072
nlmsg_failure:
10721073
module_put(a_o->owner);
1073-
skb_trim(skb, b - skb->data);
1074+
nlmsg_trim(skb, b);
10741075
return skb->len;
10751076
}
10761077

‎net/sched/act_gact.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <linux/module.h>
2929
#include <linux/init.h>
3030
#include <linux/proc_fs.h>
31+
#include <net/netlink.h>
3132
#include <net/sock.h>
3233
#include <net/pkt_sched.h>
3334
#include <linux/tc_act/tc_gact.h>
@@ -181,7 +182,7 @@ static int tcf_gact_dump(struct sk_buff *skb, struct tc_action *a, int bind, int
181182
return skb->len;
182183

183184
rtattr_failure:
184-
skb_trim(skb, b - skb->data);
185+
nlmsg_trim(skb, b);
185186
return -1;
186187
}
187188

‎net/sched/act_ipt.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <linux/init.h>
3131
#include <linux/proc_fs.h>
3232
#include <linux/kmod.h>
33+
#include <net/netlink.h>
3334
#include <net/sock.h>
3435
#include <net/pkt_sched.h>
3536
#include <linux/tc_act/tc_ipt.h>
@@ -277,7 +278,7 @@ static int tcf_ipt_dump(struct sk_buff *skb, struct tc_action *a, int bind, int
277278
return skb->len;
278279

279280
rtattr_failure:
280-
skb_trim(skb, b - skb->data);
281+
nlmsg_trim(skb, b);
281282
kfree(t);
282283
return -1;
283284
}

0 commit comments

Comments
 (0)