Skip to content

Commit

Permalink
[NETLINK]: Use nlmsg_trim() where appropriate
Browse files Browse the repository at this point in the history
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
acmel authored and David S. Miller committed Apr 26, 2007
1 parent a36ca73 commit dc5fc57
Show file tree
Hide file tree
Showing 34 changed files with 93 additions and 62 deletions.
2 changes: 1 addition & 1 deletion include/net/netlink.h
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
*
* Trims the message to the provided mark. Returns -1.
*/
static inline int nlmsg_trim(struct sk_buff *skb, void *mark)
static inline int nlmsg_trim(struct sk_buff *skb, const void *mark)
{
if (mark)
skb_trim(skb, (unsigned char *) mark - skb->data);
Expand Down
2 changes: 1 addition & 1 deletion net/core/wireless.c
Original file line number Diff line number Diff line change
Expand Up @@ -1957,7 +1957,7 @@ static inline int rtnetlink_fill_iwinfo(struct sk_buff * skb,

nlmsg_failure:
rtattr_failure:
skb_trim(skb, b - skb->data);
nlmsg_trim(skb, b);
return -1;
}

Expand Down
3 changes: 2 additions & 1 deletion net/decnet/dn_route.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
#include <linux/rcupdate.h>
#include <linux/times.h>
#include <asm/errno.h>
#include <net/netlink.h>
#include <net/neighbour.h>
#include <net/dst.h>
#include <net/flow.h>
Expand Down Expand Up @@ -1514,7 +1515,7 @@ static int dn_rt_fill_info(struct sk_buff *skb, u32 pid, u32 seq,

nlmsg_failure:
rtattr_failure:
skb_trim(skb, b - skb->data);
nlmsg_trim(skb, b);
return -1;
}

Expand Down
3 changes: 2 additions & 1 deletion net/decnet/dn_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <asm/uaccess.h>
#include <linux/route.h> /* RTF_xxx */
#include <net/neighbour.h>
#include <net/netlink.h>
#include <net/dst.h>
#include <net/flow.h>
#include <net/fib_rules.h>
Expand Down Expand Up @@ -349,7 +350,7 @@ static int dn_fib_dump_info(struct sk_buff *skb, u32 pid, u32 seq, int event,

nlmsg_failure:
rtattr_failure:
skb_trim(skb, b - skb->data);
nlmsg_trim(skb, b);
return -EMSGSIZE;
}

Expand Down
7 changes: 4 additions & 3 deletions net/ipv4/inet_diag.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <net/inet_hashtables.h>
#include <net/inet_timewait_sock.h>
#include <net/inet6_hashtables.h>
#include <net/netlink.h>

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

rtattr_failure:
nlmsg_failure:
skb_trim(skb, b - skb->data);
nlmsg_trim(skb, b);
return -EMSGSIZE;
}

Expand Down Expand Up @@ -208,7 +209,7 @@ static int inet_twsk_diag_fill(struct inet_timewait_sock *tw,
nlh->nlmsg_len = skb_tail_pointer(skb) - previous_tail;
return skb->len;
nlmsg_failure:
skb_trim(skb, previous_tail - skb->data);
nlmsg_trim(skb, previous_tail);
return -EMSGSIZE;
}

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

nlmsg_failure:
skb_trim(skb, b - skb->data);
nlmsg_trim(skb, b);
return -1;
}

Expand Down
3 changes: 2 additions & 1 deletion net/ipv4/ipmr.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
#include <linux/netfilter_ipv4.h>
#include <net/ipip.h>
#include <net/checksum.h>
#include <net/netlink.h>

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

rtattr_failure:
skb_trim(skb, b - skb->data);
nlmsg_trim(skb, b);
return -EMSGSIZE;
}

Expand Down
5 changes: 3 additions & 2 deletions net/netfilter/nf_conntrack_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <linux/notifier.h>

#include <linux/netfilter.h>
#include <net/netlink.h>
#include <net/netfilter/nf_conntrack.h>
#include <net/netfilter/nf_conntrack_core.h>
#include <net/netfilter/nf_conntrack_expect.h>
Expand Down Expand Up @@ -306,7 +307,7 @@ ctnetlink_fill_info(struct sk_buff *skb, u32 pid, u32 seq,

nlmsg_failure:
nfattr_failure:
skb_trim(skb, b - skb->data);
nlmsg_trim(skb, b);
return -1;
}

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

nlmsg_failure:
nfattr_failure:
skb_trim(skb, b - skb->data);
nlmsg_trim(skb, b);
return -1;
}

Expand Down
17 changes: 9 additions & 8 deletions net/sched/act_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <net/sock.h>
#include <net/sch_generic.h>
#include <net/act_api.h>
#include <net/netlink.h>

void tcf_hash_destroy(struct tcf_common *p, struct tcf_hashinfo *hinfo)
{
Expand Down Expand Up @@ -98,7 +99,7 @@ static int tcf_dump_walker(struct sk_buff *skb, struct netlink_callback *cb,
err = tcf_action_dump_1(skb, a, 0, 0);
if (err < 0) {
index--;
skb_trim(skb, (u8*)r - skb->data);
nlmsg_trim(skb, r);
goto done;
}
r->rta_len = skb_tail_pointer(skb) - (u8 *)r;
Expand All @@ -114,7 +115,7 @@ static int tcf_dump_walker(struct sk_buff *skb, struct netlink_callback *cb,
return n_i;

rtattr_failure:
skb_trim(skb, (u8*)r - skb->data);
nlmsg_trim(skb, r);
goto done;
}

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

return n_i;
rtattr_failure:
skb_trim(skb, (u8*)r - skb->data);
nlmsg_trim(skb, r);
return -EINVAL;
}

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

rtattr_failure:
skb_trim(skb, b - skb->data);
nlmsg_trim(skb, b);
return -1;
}

Expand All @@ -467,7 +468,7 @@ tcf_action_dump(struct sk_buff *skb, struct tc_action *act, int bind, int ref)
rtattr_failure:
err = -EINVAL;
errout:
skb_trim(skb, b - skb->data);
nlmsg_trim(skb, b);
return err;
}

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

rtattr_failure:
nlmsg_failure:
skb_trim(skb, b - skb->data);
nlmsg_trim(skb, b);
return -1;
}

Expand Down Expand Up @@ -1059,7 +1060,7 @@ tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb)
x->rta_len = skb_tail_pointer(skb) - (u8 *)x;
ret = skb->len;
} else
skb_trim(skb, (u8*)x - skb->data);
nlmsg_trim(skb, x);

nlh->nlmsg_len = skb_tail_pointer(skb) - b;
if (NETLINK_CB(cb->skb).pid && ret)
Expand All @@ -1070,7 +1071,7 @@ tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb)
rtattr_failure:
nlmsg_failure:
module_put(a_o->owner);
skb_trim(skb, b - skb->data);
nlmsg_trim(skb, b);
return skb->len;
}

Expand Down
3 changes: 2 additions & 1 deletion net/sched/act_gact.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <linux/module.h>
#include <linux/init.h>
#include <linux/proc_fs.h>
#include <net/netlink.h>
#include <net/sock.h>
#include <net/pkt_sched.h>
#include <linux/tc_act/tc_gact.h>
Expand Down Expand Up @@ -181,7 +182,7 @@ static int tcf_gact_dump(struct sk_buff *skb, struct tc_action *a, int bind, int
return skb->len;

rtattr_failure:
skb_trim(skb, b - skb->data);
nlmsg_trim(skb, b);
return -1;
}

Expand Down
3 changes: 2 additions & 1 deletion net/sched/act_ipt.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <linux/init.h>
#include <linux/proc_fs.h>
#include <linux/kmod.h>
#include <net/netlink.h>
#include <net/sock.h>
#include <net/pkt_sched.h>
#include <linux/tc_act/tc_ipt.h>
Expand Down Expand Up @@ -277,7 +278,7 @@ static int tcf_ipt_dump(struct sk_buff *skb, struct tc_action *a, int bind, int
return skb->len;

rtattr_failure:
skb_trim(skb, b - skb->data);
nlmsg_trim(skb, b);
kfree(t);
return -1;
}
Expand Down
3 changes: 2 additions & 1 deletion net/sched/act_mirred.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <linux/module.h>
#include <linux/init.h>
#include <linux/proc_fs.h>
#include <net/netlink.h>
#include <net/sock.h>
#include <net/pkt_sched.h>
#include <linux/tc_act/tc_mirred.h>
Expand Down Expand Up @@ -225,7 +226,7 @@ static int tcf_mirred_dump(struct sk_buff *skb, struct tc_action *a, int bind, i
return skb->len;

rtattr_failure:
skb_trim(skb, b - skb->data);
nlmsg_trim(skb, b);
return -1;
}

Expand Down
3 changes: 2 additions & 1 deletion net/sched/act_pedit.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <linux/module.h>
#include <linux/init.h>
#include <linux/proc_fs.h>
#include <net/netlink.h>
#include <net/sock.h>
#include <net/pkt_sched.h>
#include <linux/tc_act/tc_pedit.h>
Expand Down Expand Up @@ -226,7 +227,7 @@ static int tcf_pedit_dump(struct sk_buff *skb, struct tc_action *a,
return skb->len;

rtattr_failure:
skb_trim(skb, b - skb->data);
nlmsg_trim(skb, b);
kfree(opt);
return -1;
}
Expand Down
9 changes: 5 additions & 4 deletions net/sched/act_police.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <linux/init.h>
#include <net/sock.h>
#include <net/act_api.h>
#include <net/netlink.h>

#define L2T(p,L) ((p)->tcfp_R_tab->data[(L)>>(p)->tcfp_R_tab->rate.cell_log])
#define L2T_P(p,L) ((p)->tcfp_P_tab->data[(L)>>(p)->tcfp_P_tab->rate.cell_log])
Expand Down Expand Up @@ -88,7 +89,7 @@ static int tcf_act_police_walker(struct sk_buff *skb, struct netlink_callback *c
err = tcf_action_dump_1(skb, a, 0, 0);
if (err < 0) {
index--;
skb_trim(skb, (u8*)r - skb->data);
nlmsg_trim(skb, r);
goto done;
}
r->rta_len = skb_tail_pointer(skb) - (u8 *)r;
Expand All @@ -102,7 +103,7 @@ static int tcf_act_police_walker(struct sk_buff *skb, struct netlink_callback *c
return n_i;

rtattr_failure:
skb_trim(skb, (u8*)r - skb->data);
nlmsg_trim(skb, r);
goto done;
}
#endif
Expand Down Expand Up @@ -355,7 +356,7 @@ tcf_act_police_dump(struct sk_buff *skb, struct tc_action *a, int bind, int ref)
return skb->len;

rtattr_failure:
skb_trim(skb, b - skb->data);
nlmsg_trim(skb, b);
return -1;
}

Expand Down Expand Up @@ -598,7 +599,7 @@ int tcf_police_dump(struct sk_buff *skb, struct tcf_police *police)
return skb->len;

rtattr_failure:
skb_trim(skb, b - skb->data);
nlmsg_trim(skb, b);
return -1;
}

Expand Down
3 changes: 2 additions & 1 deletion net/sched/act_simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <linux/netdevice.h>
#include <linux/skbuff.h>
#include <linux/rtnetlink.h>
#include <net/netlink.h>
#include <net/pkt_sched.h>

#define TCA_ACT_SIMP 22
Expand Down Expand Up @@ -173,7 +174,7 @@ static inline int tcf_simp_dump(struct sk_buff *skb, struct tc_action *a,
return skb->len;

rtattr_failure:
skb_trim(skb, b - skb->data);
nlmsg_trim(skb, b);
return -1;
}

Expand Down
4 changes: 3 additions & 1 deletion net/sched/cls_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
#include <linux/rtnetlink.h>
#include <linux/init.h>
#include <linux/kmod.h>
#include <linux/netlink.h>
#include <net/netlink.h>
#include <net/sock.h>
#include <net/pkt_sched.h>
#include <net/pkt_cls.h>
Expand Down Expand Up @@ -345,7 +347,7 @@ tcf_fill_node(struct sk_buff *skb, struct tcf_proto *tp, unsigned long fh,

nlmsg_failure:
rtattr_failure:
skb_trim(skb, b - skb->data);
nlmsg_trim(skb, b);
return -1;
}

Expand Down
3 changes: 2 additions & 1 deletion net/sched/cls_basic.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <linux/errno.h>
#include <linux/rtnetlink.h>
#include <linux/skbuff.h>
#include <net/netlink.h>
#include <net/act_api.h>
#include <net/pkt_cls.h>

Expand Down Expand Up @@ -267,7 +268,7 @@ static int basic_dump(struct tcf_proto *tp, unsigned long fh,
return skb->len;

rtattr_failure:
skb_trim(skb, b - skb->data);
nlmsg_trim(skb, b);
return -1;
}

Expand Down
3 changes: 2 additions & 1 deletion net/sched/cls_fw.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include <linux/notifier.h>
#include <linux/netfilter.h>
#include <net/ip.h>
#include <net/netlink.h>
#include <net/route.h>
#include <linux/skbuff.h>
#include <net/sock.h>
Expand Down Expand Up @@ -382,7 +383,7 @@ static int fw_dump(struct tcf_proto *tp, unsigned long fh,
return skb->len;

rtattr_failure:
skb_trim(skb, b - skb->data);
nlmsg_trim(skb, b);
return -1;
}

Expand Down
Loading

0 comments on commit dc5fc57

Please sign in to comment.