diff options
Diffstat (limited to 'include/net/netlink.h')
-rw-r--r-- | include/net/netlink.h | 124 |
1 files changed, 111 insertions, 13 deletions
diff --git a/include/net/netlink.h b/include/net/netlink.h index 785f37a3b44e..9690b0f6698a 100644 --- a/include/net/netlink.h +++ b/include/net/netlink.h | |||
@@ -98,6 +98,10 @@ | |||
98 | * nla_put_u16(skb, type, value) add u16 attribute to skb | 98 | * nla_put_u16(skb, type, value) add u16 attribute to skb |
99 | * nla_put_u32(skb, type, value) add u32 attribute to skb | 99 | * nla_put_u32(skb, type, value) add u32 attribute to skb |
100 | * nla_put_u64(skb, type, value) add u64 attribute to skb | 100 | * nla_put_u64(skb, type, value) add u64 attribute to skb |
101 | * nla_put_s8(skb, type, value) add s8 attribute to skb | ||
102 | * nla_put_s16(skb, type, value) add s16 attribute to skb | ||
103 | * nla_put_s32(skb, type, value) add s32 attribute to skb | ||
104 | * nla_put_s64(skb, type, value) add s64 attribute to skb | ||
101 | * nla_put_string(skb, type, str) add string attribute to skb | 105 | * nla_put_string(skb, type, str) add string attribute to skb |
102 | * nla_put_flag(skb, type) add flag attribute to skb | 106 | * nla_put_flag(skb, type) add flag attribute to skb |
103 | * nla_put_msecs(skb, type, jiffies) add msecs attribute to skb | 107 | * nla_put_msecs(skb, type, jiffies) add msecs attribute to skb |
@@ -121,6 +125,10 @@ | |||
121 | * nla_get_u16(nla) get payload for a u16 attribute | 125 | * nla_get_u16(nla) get payload for a u16 attribute |
122 | * nla_get_u32(nla) get payload for a u32 attribute | 126 | * nla_get_u32(nla) get payload for a u32 attribute |
123 | * nla_get_u64(nla) get payload for a u64 attribute | 127 | * nla_get_u64(nla) get payload for a u64 attribute |
128 | * nla_get_s8(nla) get payload for a s8 attribute | ||
129 | * nla_get_s16(nla) get payload for a s16 attribute | ||
130 | * nla_get_s32(nla) get payload for a s32 attribute | ||
131 | * nla_get_s64(nla) get payload for a s64 attribute | ||
124 | * nla_get_flag(nla) return 1 if flag is true | 132 | * nla_get_flag(nla) return 1 if flag is true |
125 | * nla_get_msecs(nla) get payload for a msecs attribute | 133 | * nla_get_msecs(nla) get payload for a msecs attribute |
126 | * | 134 | * |
@@ -160,6 +168,10 @@ enum { | |||
160 | NLA_NESTED_COMPAT, | 168 | NLA_NESTED_COMPAT, |
161 | NLA_NUL_STRING, | 169 | NLA_NUL_STRING, |
162 | NLA_BINARY, | 170 | NLA_BINARY, |
171 | NLA_S8, | ||
172 | NLA_S16, | ||
173 | NLA_S32, | ||
174 | NLA_S64, | ||
163 | __NLA_TYPE_MAX, | 175 | __NLA_TYPE_MAX, |
164 | }; | 176 | }; |
165 | 177 | ||
@@ -183,6 +195,8 @@ enum { | |||
183 | * NLA_NESTED_COMPAT Minimum length of structure payload | 195 | * NLA_NESTED_COMPAT Minimum length of structure payload |
184 | * NLA_U8, NLA_U16, | 196 | * NLA_U8, NLA_U16, |
185 | * NLA_U32, NLA_U64, | 197 | * NLA_U32, NLA_U64, |
198 | * NLA_S8, NLA_S16, | ||
199 | * NLA_S32, NLA_S64, | ||
186 | * NLA_MSECS Leaving the length field zero will verify the | 200 | * NLA_MSECS Leaving the length field zero will verify the |
187 | * given type fits, using it verifies minimum length | 201 | * given type fits, using it verifies minimum length |
188 | * just like "All other" | 202 | * just like "All other" |
@@ -203,19 +217,19 @@ struct nla_policy { | |||
203 | /** | 217 | /** |
204 | * struct nl_info - netlink source information | 218 | * struct nl_info - netlink source information |
205 | * @nlh: Netlink message header of original request | 219 | * @nlh: Netlink message header of original request |
206 | * @pid: Netlink PID of requesting application | 220 | * @portid: Netlink PORTID of requesting application |
207 | */ | 221 | */ |
208 | struct nl_info { | 222 | struct nl_info { |
209 | struct nlmsghdr *nlh; | 223 | struct nlmsghdr *nlh; |
210 | struct net *nl_net; | 224 | struct net *nl_net; |
211 | u32 pid; | 225 | u32 portid; |
212 | }; | 226 | }; |
213 | 227 | ||
214 | extern int netlink_rcv_skb(struct sk_buff *skb, | 228 | extern int netlink_rcv_skb(struct sk_buff *skb, |
215 | int (*cb)(struct sk_buff *, | 229 | int (*cb)(struct sk_buff *, |
216 | struct nlmsghdr *)); | 230 | struct nlmsghdr *)); |
217 | extern int nlmsg_notify(struct sock *sk, struct sk_buff *skb, | 231 | extern int nlmsg_notify(struct sock *sk, struct sk_buff *skb, |
218 | u32 pid, unsigned int group, int report, | 232 | u32 portid, unsigned int group, int report, |
219 | gfp_t flags); | 233 | gfp_t flags); |
220 | 234 | ||
221 | extern int nla_validate(const struct nlattr *head, | 235 | extern int nla_validate(const struct nlattr *head, |
@@ -430,7 +444,7 @@ static inline int nlmsg_report(const struct nlmsghdr *nlh) | |||
430 | /** | 444 | /** |
431 | * nlmsg_put - Add a new netlink message to an skb | 445 | * nlmsg_put - Add a new netlink message to an skb |
432 | * @skb: socket buffer to store message in | 446 | * @skb: socket buffer to store message in |
433 | * @pid: netlink process id | 447 | * @portid: netlink process id |
434 | * @seq: sequence number of message | 448 | * @seq: sequence number of message |
435 | * @type: message type | 449 | * @type: message type |
436 | * @payload: length of message payload | 450 | * @payload: length of message payload |
@@ -439,13 +453,13 @@ static inline int nlmsg_report(const struct nlmsghdr *nlh) | |||
439 | * Returns NULL if the tailroom of the skb is insufficient to store | 453 | * Returns NULL if the tailroom of the skb is insufficient to store |
440 | * the message header and payload. | 454 | * the message header and payload. |
441 | */ | 455 | */ |
442 | static inline struct nlmsghdr *nlmsg_put(struct sk_buff *skb, u32 pid, u32 seq, | 456 | static inline struct nlmsghdr *nlmsg_put(struct sk_buff *skb, u32 portid, u32 seq, |
443 | int type, int payload, int flags) | 457 | int type, int payload, int flags) |
444 | { | 458 | { |
445 | if (unlikely(skb_tailroom(skb) < nlmsg_total_size(payload))) | 459 | if (unlikely(skb_tailroom(skb) < nlmsg_total_size(payload))) |
446 | return NULL; | 460 | return NULL; |
447 | 461 | ||
448 | return __nlmsg_put(skb, pid, seq, type, payload, flags); | 462 | return __nlmsg_put(skb, portid, seq, type, payload, flags); |
449 | } | 463 | } |
450 | 464 | ||
451 | /** | 465 | /** |
@@ -464,7 +478,7 @@ static inline struct nlmsghdr *nlmsg_put_answer(struct sk_buff *skb, | |||
464 | int type, int payload, | 478 | int type, int payload, |
465 | int flags) | 479 | int flags) |
466 | { | 480 | { |
467 | return nlmsg_put(skb, NETLINK_CB(cb->skb).pid, cb->nlh->nlmsg_seq, | 481 | return nlmsg_put(skb, NETLINK_CB(cb->skb).portid, cb->nlh->nlmsg_seq, |
468 | type, payload, flags); | 482 | type, payload, flags); |
469 | } | 483 | } |
470 | 484 | ||
@@ -549,18 +563,18 @@ static inline void nlmsg_free(struct sk_buff *skb) | |||
549 | * nlmsg_multicast - multicast a netlink message | 563 | * nlmsg_multicast - multicast a netlink message |
550 | * @sk: netlink socket to spread messages to | 564 | * @sk: netlink socket to spread messages to |
551 | * @skb: netlink message as socket buffer | 565 | * @skb: netlink message as socket buffer |
552 | * @pid: own netlink pid to avoid sending to yourself | 566 | * @portid: own netlink portid to avoid sending to yourself |
553 | * @group: multicast group id | 567 | * @group: multicast group id |
554 | * @flags: allocation flags | 568 | * @flags: allocation flags |
555 | */ | 569 | */ |
556 | static inline int nlmsg_multicast(struct sock *sk, struct sk_buff *skb, | 570 | static inline int nlmsg_multicast(struct sock *sk, struct sk_buff *skb, |
557 | u32 pid, unsigned int group, gfp_t flags) | 571 | u32 portid, unsigned int group, gfp_t flags) |
558 | { | 572 | { |
559 | int err; | 573 | int err; |
560 | 574 | ||
561 | NETLINK_CB(skb).dst_group = group; | 575 | NETLINK_CB(skb).dst_group = group; |
562 | 576 | ||
563 | err = netlink_broadcast(sk, skb, pid, group, flags); | 577 | err = netlink_broadcast(sk, skb, portid, group, flags); |
564 | if (err > 0) | 578 | if (err > 0) |
565 | err = 0; | 579 | err = 0; |
566 | 580 | ||
@@ -571,13 +585,13 @@ static inline int nlmsg_multicast(struct sock *sk, struct sk_buff *skb, | |||
571 | * nlmsg_unicast - unicast a netlink message | 585 | * nlmsg_unicast - unicast a netlink message |
572 | * @sk: netlink socket to spread message to | 586 | * @sk: netlink socket to spread message to |
573 | * @skb: netlink message as socket buffer | 587 | * @skb: netlink message as socket buffer |
574 | * @pid: netlink pid of the destination socket | 588 | * @portid: netlink portid of the destination socket |
575 | */ | 589 | */ |
576 | static inline int nlmsg_unicast(struct sock *sk, struct sk_buff *skb, u32 pid) | 590 | static inline int nlmsg_unicast(struct sock *sk, struct sk_buff *skb, u32 portid) |
577 | { | 591 | { |
578 | int err; | 592 | int err; |
579 | 593 | ||
580 | err = netlink_unicast(sk, skb, pid, MSG_DONTWAIT); | 594 | err = netlink_unicast(sk, skb, portid, MSG_DONTWAIT); |
581 | if (err > 0) | 595 | if (err > 0) |
582 | err = 0; | 596 | err = 0; |
583 | 597 | ||
@@ -879,6 +893,50 @@ static inline int nla_put_le64(struct sk_buff *skb, int attrtype, __le64 value) | |||
879 | } | 893 | } |
880 | 894 | ||
881 | /** | 895 | /** |
896 | * nla_put_s8 - Add a s8 netlink attribute to a socket buffer | ||
897 | * @skb: socket buffer to add attribute to | ||
898 | * @attrtype: attribute type | ||
899 | * @value: numeric value | ||
900 | */ | ||
901 | static inline int nla_put_s8(struct sk_buff *skb, int attrtype, s8 value) | ||
902 | { | ||
903 | return nla_put(skb, attrtype, sizeof(s8), &value); | ||
904 | } | ||
905 | |||
906 | /** | ||
907 | * nla_put_s16 - Add a s16 netlink attribute to a socket buffer | ||
908 | * @skb: socket buffer to add attribute to | ||
909 | * @attrtype: attribute type | ||
910 | * @value: numeric value | ||
911 | */ | ||
912 | static inline int nla_put_s16(struct sk_buff *skb, int attrtype, s16 value) | ||
913 | { | ||
914 | return nla_put(skb, attrtype, sizeof(s16), &value); | ||
915 | } | ||
916 | |||
917 | /** | ||
918 | * nla_put_s32 - Add a s32 netlink attribute to a socket buffer | ||
919 | * @skb: socket buffer to add attribute to | ||
920 | * @attrtype: attribute type | ||
921 | * @value: numeric value | ||
922 | */ | ||
923 | static inline int nla_put_s32(struct sk_buff *skb, int attrtype, s32 value) | ||
924 | { | ||
925 | return nla_put(skb, attrtype, sizeof(s32), &value); | ||
926 | } | ||
927 | |||
928 | /** | ||
929 | * nla_put_s64 - Add a s64 netlink attribute to a socket buffer | ||
930 | * @skb: socket buffer to add attribute to | ||
931 | * @attrtype: attribute type | ||
932 | * @value: numeric value | ||
933 | */ | ||
934 | static inline int nla_put_s64(struct sk_buff *skb, int attrtype, s64 value) | ||
935 | { | ||
936 | return nla_put(skb, attrtype, sizeof(s64), &value); | ||
937 | } | ||
938 | |||
939 | /** | ||
882 | * nla_put_string - Add a string netlink attribute to a socket buffer | 940 | * nla_put_string - Add a string netlink attribute to a socket buffer |
883 | * @skb: socket buffer to add attribute to | 941 | * @skb: socket buffer to add attribute to |
884 | * @attrtype: attribute type | 942 | * @attrtype: attribute type |
@@ -994,6 +1052,46 @@ static inline __be64 nla_get_be64(const struct nlattr *nla) | |||
994 | } | 1052 | } |
995 | 1053 | ||
996 | /** | 1054 | /** |
1055 | * nla_get_s32 - return payload of s32 attribute | ||
1056 | * @nla: s32 netlink attribute | ||
1057 | */ | ||
1058 | static inline s32 nla_get_s32(const struct nlattr *nla) | ||
1059 | { | ||
1060 | return *(s32 *) nla_data(nla); | ||
1061 | } | ||
1062 | |||
1063 | /** | ||
1064 | * nla_get_s16 - return payload of s16 attribute | ||
1065 | * @nla: s16 netlink attribute | ||
1066 | */ | ||
1067 | static inline s16 nla_get_s16(const struct nlattr *nla) | ||
1068 | { | ||
1069 | return *(s16 *) nla_data(nla); | ||
1070 | } | ||
1071 | |||
1072 | /** | ||
1073 | * nla_get_s8 - return payload of s8 attribute | ||
1074 | * @nla: s8 netlink attribute | ||
1075 | */ | ||
1076 | static inline s8 nla_get_s8(const struct nlattr *nla) | ||
1077 | { | ||
1078 | return *(s8 *) nla_data(nla); | ||
1079 | } | ||
1080 | |||
1081 | /** | ||
1082 | * nla_get_s64 - return payload of s64 attribute | ||
1083 | * @nla: s64 netlink attribute | ||
1084 | */ | ||
1085 | static inline s64 nla_get_s64(const struct nlattr *nla) | ||
1086 | { | ||
1087 | s64 tmp; | ||
1088 | |||
1089 | nla_memcpy(&tmp, nla, sizeof(tmp)); | ||
1090 | |||
1091 | return tmp; | ||
1092 | } | ||
1093 | |||
1094 | /** | ||
997 | * nla_get_flag - return payload of flag attribute | 1095 | * nla_get_flag - return payload of flag attribute |
998 | * @nla: flag netlink attribute | 1096 | * @nla: flag netlink attribute |
999 | */ | 1097 | */ |