diff options
Diffstat (limited to 'include/net/netlink.h')
-rw-r--r-- | include/net/netlink.h | 84 |
1 files changed, 1 insertions, 83 deletions
diff --git a/include/net/netlink.h b/include/net/netlink.h index 18024b8cecb8..3643bbb8e585 100644 --- a/include/net/netlink.h +++ b/include/net/netlink.h | |||
@@ -119,9 +119,6 @@ | |||
119 | * Nested Attributes Construction: | 119 | * Nested Attributes Construction: |
120 | * nla_nest_start(skb, type) start a nested attribute | 120 | * nla_nest_start(skb, type) start a nested attribute |
121 | * nla_nest_end(skb, nla) finalize a nested attribute | 121 | * nla_nest_end(skb, nla) finalize a nested attribute |
122 | * nla_nest_compat_start(skb, type, start a nested compat attribute | ||
123 | * len, data) | ||
124 | * nla_nest_compat_end(skb, type) finalize a nested compat attribute | ||
125 | * nla_nest_cancel(skb, nla) cancel nested attribute construction | 122 | * nla_nest_cancel(skb, nla) cancel nested attribute construction |
126 | * | 123 | * |
127 | * Attribute Length Calculations: | 124 | * Attribute Length Calculations: |
@@ -156,7 +153,6 @@ | |||
156 | * nla_find_nested() find attribute in nested attributes | 153 | * nla_find_nested() find attribute in nested attributes |
157 | * nla_parse() parse and validate stream of attrs | 154 | * nla_parse() parse and validate stream of attrs |
158 | * nla_parse_nested() parse nested attribuets | 155 | * nla_parse_nested() parse nested attribuets |
159 | * nla_parse_nested_compat() parse nested compat attributes | ||
160 | * nla_for_each_attr() loop over all attributes | 156 | * nla_for_each_attr() loop over all attributes |
161 | * nla_for_each_nested() loop over the nested attributes | 157 | * nla_for_each_nested() loop over the nested attributes |
162 | *========================================================================= | 158 | *========================================================================= |
@@ -702,7 +698,7 @@ static inline int nla_len(const struct nlattr *nla) | |||
702 | */ | 698 | */ |
703 | static inline int nla_ok(const struct nlattr *nla, int remaining) | 699 | static inline int nla_ok(const struct nlattr *nla, int remaining) |
704 | { | 700 | { |
705 | return remaining >= sizeof(*nla) && | 701 | return remaining >= (int) sizeof(*nla) && |
706 | nla->nla_len >= sizeof(*nla) && | 702 | nla->nla_len >= sizeof(*nla) && |
707 | nla->nla_len <= remaining; | 703 | nla->nla_len <= remaining; |
708 | } | 704 | } |
@@ -752,39 +748,6 @@ static inline int nla_parse_nested(struct nlattr *tb[], int maxtype, | |||
752 | } | 748 | } |
753 | 749 | ||
754 | /** | 750 | /** |
755 | * nla_parse_nested_compat - parse nested compat attributes | ||
756 | * @tb: destination array with maxtype+1 elements | ||
757 | * @maxtype: maximum attribute type to be expected | ||
758 | * @nla: attribute containing the nested attributes | ||
759 | * @data: pointer to point to contained structure | ||
760 | * @len: length of contained structure | ||
761 | * @policy: validation policy | ||
762 | * | ||
763 | * Parse a nested compat attribute. The compat attribute contains a structure | ||
764 | * and optionally a set of nested attributes. On success the data pointer | ||
765 | * points to the nested data and tb contains the parsed attributes | ||
766 | * (see nla_parse). | ||
767 | */ | ||
768 | static inline int __nla_parse_nested_compat(struct nlattr *tb[], int maxtype, | ||
769 | struct nlattr *nla, | ||
770 | const struct nla_policy *policy, | ||
771 | int len) | ||
772 | { | ||
773 | int nested_len = nla_len(nla) - NLA_ALIGN(len); | ||
774 | |||
775 | if (nested_len < 0) | ||
776 | return -EINVAL; | ||
777 | if (nested_len >= nla_attr_size(0)) | ||
778 | return nla_parse(tb, maxtype, nla_data(nla) + NLA_ALIGN(len), | ||
779 | nested_len, policy); | ||
780 | memset(tb, 0, sizeof(struct nlattr *) * (maxtype + 1)); | ||
781 | return 0; | ||
782 | } | ||
783 | |||
784 | #define nla_parse_nested_compat(tb, maxtype, nla, policy, data, len) \ | ||
785 | ({ data = nla_len(nla) >= len ? nla_data(nla) : NULL; \ | ||
786 | __nla_parse_nested_compat(tb, maxtype, nla, policy, len); }) | ||
787 | /** | ||
788 | * nla_put_u8 - Add a u8 netlink attribute to a socket buffer | 751 | * nla_put_u8 - Add a u8 netlink attribute to a socket buffer |
789 | * @skb: socket buffer to add attribute to | 752 | * @skb: socket buffer to add attribute to |
790 | * @attrtype: attribute type | 753 | * @attrtype: attribute type |
@@ -1031,51 +994,6 @@ static inline int nla_nest_end(struct sk_buff *skb, struct nlattr *start) | |||
1031 | } | 994 | } |
1032 | 995 | ||
1033 | /** | 996 | /** |
1034 | * nla_nest_compat_start - Start a new level of nested compat attributes | ||
1035 | * @skb: socket buffer to add attributes to | ||
1036 | * @attrtype: attribute type of container | ||
1037 | * @attrlen: length of structure | ||
1038 | * @data: pointer to structure | ||
1039 | * | ||
1040 | * Start a nested compat attribute that contains both a structure and | ||
1041 | * a set of nested attributes. | ||
1042 | * | ||
1043 | * Returns the container attribute | ||
1044 | */ | ||
1045 | static inline struct nlattr *nla_nest_compat_start(struct sk_buff *skb, | ||
1046 | int attrtype, int attrlen, | ||
1047 | const void *data) | ||
1048 | { | ||
1049 | struct nlattr *start = (struct nlattr *)skb_tail_pointer(skb); | ||
1050 | |||
1051 | if (nla_put(skb, attrtype, attrlen, data) < 0) | ||
1052 | return NULL; | ||
1053 | if (nla_nest_start(skb, attrtype) == NULL) { | ||
1054 | nlmsg_trim(skb, start); | ||
1055 | return NULL; | ||
1056 | } | ||
1057 | return start; | ||
1058 | } | ||
1059 | |||
1060 | /** | ||
1061 | * nla_nest_compat_end - Finalize nesting of compat attributes | ||
1062 | * @skb: socket buffer the attributes are stored in | ||
1063 | * @start: container attribute | ||
1064 | * | ||
1065 | * Corrects the container attribute header to include the all | ||
1066 | * appeneded attributes. | ||
1067 | * | ||
1068 | * Returns the total data length of the skb. | ||
1069 | */ | ||
1070 | static inline int nla_nest_compat_end(struct sk_buff *skb, struct nlattr *start) | ||
1071 | { | ||
1072 | struct nlattr *nest = (void *)start + NLMSG_ALIGN(start->nla_len); | ||
1073 | |||
1074 | start->nla_len = skb_tail_pointer(skb) - (unsigned char *)start; | ||
1075 | return nla_nest_end(skb, nest); | ||
1076 | } | ||
1077 | |||
1078 | /** | ||
1079 | * nla_nest_cancel - Cancel nesting of attributes | 997 | * nla_nest_cancel - Cancel nesting of attributes |
1080 | * @skb: socket buffer the message is stored in | 998 | * @skb: socket buffer the message is stored in |
1081 | * @start: container attribute | 999 | * @start: container attribute |