aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/netlink.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/net/netlink.h')
-rw-r--r--include/net/netlink.h31
1 files changed, 15 insertions, 16 deletions
diff --git a/include/net/netlink.h b/include/net/netlink.h
index a5506c42f03c..dfc3701dfcc3 100644
--- a/include/net/netlink.h
+++ b/include/net/netlink.h
@@ -556,14 +556,12 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
556 * @skb: socket buffer the message is stored in 556 * @skb: socket buffer the message is stored in
557 * @mark: mark to trim to 557 * @mark: mark to trim to
558 * 558 *
559 * Trims the message to the provided mark. Returns -1. 559 * Trims the message to the provided mark.
560 */ 560 */
561static inline int nlmsg_trim(struct sk_buff *skb, const void *mark) 561static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
562{ 562{
563 if (mark) 563 if (mark)
564 skb_trim(skb, (unsigned char *) mark - skb->data); 564 skb_trim(skb, (unsigned char *) mark - skb->data);
565
566 return -1;
567} 565}
568 566
569/** 567/**
@@ -572,11 +570,11 @@ static inline int nlmsg_trim(struct sk_buff *skb, const void *mark)
572 * @nlh: netlink message header 570 * @nlh: netlink message header
573 * 571 *
574 * Removes the complete netlink message including all 572 * Removes the complete netlink message including all
575 * attributes from the socket buffer again. Returns -1. 573 * attributes from the socket buffer again.
576 */ 574 */
577static inline int nlmsg_cancel(struct sk_buff *skb, struct nlmsghdr *nlh) 575static inline void nlmsg_cancel(struct sk_buff *skb, struct nlmsghdr *nlh)
578{ 576{
579 return nlmsg_trim(skb, nlh); 577 nlmsg_trim(skb, nlh);
580} 578}
581 579
582/** 580/**
@@ -772,12 +770,13 @@ static inline int __nla_parse_nested_compat(struct nlattr *tb[], int maxtype,
772 const struct nla_policy *policy, 770 const struct nla_policy *policy,
773 int len) 771 int len)
774{ 772{
775 if (nla_len(nla) < len) 773 int nested_len = nla_len(nla) - NLA_ALIGN(len);
776 return -1; 774
777 if (nla_len(nla) >= NLA_ALIGN(len) + sizeof(struct nlattr)) 775 if (nested_len < 0)
778 return nla_parse_nested(tb, maxtype, 776 return -EINVAL;
779 nla_data(nla) + NLA_ALIGN(len), 777 if (nested_len >= nla_attr_size(0))
780 policy); 778 return nla_parse(tb, maxtype, nla_data(nla) + NLA_ALIGN(len),
779 nested_len, policy);
781 memset(tb, 0, sizeof(struct nlattr *) * (maxtype + 1)); 780 memset(tb, 0, sizeof(struct nlattr *) * (maxtype + 1));
782 return 0; 781 return 0;
783} 782}
@@ -1079,11 +1078,11 @@ static inline int nla_nest_compat_end(struct sk_buff *skb, struct nlattr *start)
1079 * @start: container attribute 1078 * @start: container attribute
1080 * 1079 *
1081 * Removes the container attribute and including all nested 1080 * Removes the container attribute and including all nested
1082 * attributes. Returns -1. 1081 * attributes. Returns -EMSGSIZE
1083 */ 1082 */
1084static inline int nla_nest_cancel(struct sk_buff *skb, struct nlattr *start) 1083static inline void nla_nest_cancel(struct sk_buff *skb, struct nlattr *start)
1085{ 1084{
1086 return nlmsg_trim(skb, start); 1085 nlmsg_trim(skb, start);
1087} 1086}
1088 1087
1089/** 1088/**