diff options
-rw-r--r-- | include/net/genetlink.h | 10 | ||||
-rw-r--r-- | net/netlink/genetlink.c | 36 | ||||
-rw-r--r-- | net/wireless/nl80211.c | 8 |
3 files changed, 30 insertions, 24 deletions
diff --git a/include/net/genetlink.h b/include/net/genetlink.h index d4802af1a8b3..d87486aa0611 100644 --- a/include/net/genetlink.h +++ b/include/net/genetlink.h | |||
@@ -52,14 +52,14 @@ struct genl_family { | |||
52 | unsigned int maxattr; | 52 | unsigned int maxattr; |
53 | bool netnsok; | 53 | bool netnsok; |
54 | bool parallel_ops; | 54 | bool parallel_ops; |
55 | int (*pre_doit)(struct genl_ops *ops, | 55 | int (*pre_doit)(const struct genl_ops *ops, |
56 | struct sk_buff *skb, | 56 | struct sk_buff *skb, |
57 | struct genl_info *info); | 57 | struct genl_info *info); |
58 | void (*post_doit)(struct genl_ops *ops, | 58 | void (*post_doit)(const struct genl_ops *ops, |
59 | struct sk_buff *skb, | 59 | struct sk_buff *skb, |
60 | struct genl_info *info); | 60 | struct genl_info *info); |
61 | struct nlattr ** attrbuf; /* private */ | 61 | struct nlattr ** attrbuf; /* private */ |
62 | struct genl_ops * ops; /* private */ | 62 | const struct genl_ops * ops; /* private */ |
63 | unsigned int n_ops; /* private */ | 63 | unsigned int n_ops; /* private */ |
64 | struct list_head family_list; /* private */ | 64 | struct list_head family_list; /* private */ |
65 | struct list_head mcast_groups; /* private */ | 65 | struct list_head mcast_groups; /* private */ |
@@ -132,10 +132,10 @@ static inline int genl_register_family(struct genl_family *family) | |||
132 | } | 132 | } |
133 | 133 | ||
134 | int __genl_register_family_with_ops(struct genl_family *family, | 134 | int __genl_register_family_with_ops(struct genl_family *family, |
135 | struct genl_ops *ops, size_t n_ops); | 135 | const struct genl_ops *ops, size_t n_ops); |
136 | 136 | ||
137 | static inline int genl_register_family_with_ops(struct genl_family *family, | 137 | static inline int genl_register_family_with_ops(struct genl_family *family, |
138 | struct genl_ops *ops, size_t n_ops) | 138 | const struct genl_ops *ops, size_t n_ops) |
139 | { | 139 | { |
140 | family->module = THIS_MODULE; | 140 | family->module = THIS_MODULE; |
141 | return __genl_register_family_with_ops(family, ops, n_ops); | 141 | return __genl_register_family_with_ops(family, ops, n_ops); |
diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c index d8273b057763..a7c62d3d05a1 100644 --- a/net/netlink/genetlink.c +++ b/net/netlink/genetlink.c | |||
@@ -106,7 +106,7 @@ static struct genl_family *genl_family_find_byname(char *name) | |||
106 | return NULL; | 106 | return NULL; |
107 | } | 107 | } |
108 | 108 | ||
109 | static struct genl_ops *genl_get_cmd(u8 cmd, struct genl_family *family) | 109 | static const struct genl_ops *genl_get_cmd(u8 cmd, struct genl_family *family) |
110 | { | 110 | { |
111 | int i; | 111 | int i; |
112 | 112 | ||
@@ -283,7 +283,8 @@ static void genl_unregister_mc_groups(struct genl_family *family) | |||
283 | __genl_unregister_mc_group(family, grp); | 283 | __genl_unregister_mc_group(family, grp); |
284 | } | 284 | } |
285 | 285 | ||
286 | static int genl_validate_add_ops(struct genl_family *family, struct genl_ops *ops, | 286 | static int genl_validate_add_ops(struct genl_family *family, |
287 | const struct genl_ops *ops, | ||
287 | unsigned int n_ops) | 288 | unsigned int n_ops) |
288 | { | 289 | { |
289 | int i, j; | 290 | int i, j; |
@@ -294,12 +295,6 @@ static int genl_validate_add_ops(struct genl_family *family, struct genl_ops *op | |||
294 | for (j = i + 1; j < n_ops; j++) | 295 | for (j = i + 1; j < n_ops; j++) |
295 | if (ops[i].cmd == ops[j].cmd) | 296 | if (ops[i].cmd == ops[j].cmd) |
296 | return -EINVAL; | 297 | return -EINVAL; |
297 | if (ops[i].dumpit) | ||
298 | ops[i].flags |= GENL_CMD_CAP_DUMP; | ||
299 | if (ops[i].doit) | ||
300 | ops[i].flags |= GENL_CMD_CAP_DO; | ||
301 | if (ops[i].policy) | ||
302 | ops[i].flags |= GENL_CMD_CAP_HASPOL; | ||
303 | } | 298 | } |
304 | 299 | ||
305 | /* family is not registered yet, so no locking needed */ | 300 | /* family is not registered yet, so no locking needed */ |
@@ -399,7 +394,7 @@ EXPORT_SYMBOL(__genl_register_family); | |||
399 | * Return 0 on success or a negative error code. | 394 | * Return 0 on success or a negative error code. |
400 | */ | 395 | */ |
401 | int __genl_register_family_with_ops(struct genl_family *family, | 396 | int __genl_register_family_with_ops(struct genl_family *family, |
402 | struct genl_ops *ops, size_t n_ops) | 397 | const struct genl_ops *ops, size_t n_ops) |
403 | { | 398 | { |
404 | int err; | 399 | int err; |
405 | 400 | ||
@@ -479,7 +474,8 @@ EXPORT_SYMBOL(genlmsg_put); | |||
479 | 474 | ||
480 | static int genl_lock_dumpit(struct sk_buff *skb, struct netlink_callback *cb) | 475 | static int genl_lock_dumpit(struct sk_buff *skb, struct netlink_callback *cb) |
481 | { | 476 | { |
482 | struct genl_ops *ops = cb->data; | 477 | /* our ops are always const - netlink API doesn't propagate that */ |
478 | const struct genl_ops *ops = cb->data; | ||
483 | int rc; | 479 | int rc; |
484 | 480 | ||
485 | genl_lock(); | 481 | genl_lock(); |
@@ -490,7 +486,8 @@ static int genl_lock_dumpit(struct sk_buff *skb, struct netlink_callback *cb) | |||
490 | 486 | ||
491 | static int genl_lock_done(struct netlink_callback *cb) | 487 | static int genl_lock_done(struct netlink_callback *cb) |
492 | { | 488 | { |
493 | struct genl_ops *ops = cb->data; | 489 | /* our ops are always const - netlink API doesn't propagate that */ |
490 | const struct genl_ops *ops = cb->data; | ||
494 | int rc = 0; | 491 | int rc = 0; |
495 | 492 | ||
496 | if (ops->done) { | 493 | if (ops->done) { |
@@ -505,7 +502,7 @@ static int genl_family_rcv_msg(struct genl_family *family, | |||
505 | struct sk_buff *skb, | 502 | struct sk_buff *skb, |
506 | struct nlmsghdr *nlh) | 503 | struct nlmsghdr *nlh) |
507 | { | 504 | { |
508 | struct genl_ops *ops; | 505 | const struct genl_ops *ops; |
509 | struct net *net = sock_net(skb->sk); | 506 | struct net *net = sock_net(skb->sk); |
510 | struct genl_info info; | 507 | struct genl_info info; |
511 | struct genlmsghdr *hdr = nlmsg_data(nlh); | 508 | struct genlmsghdr *hdr = nlmsg_data(nlh); |
@@ -537,7 +534,8 @@ static int genl_family_rcv_msg(struct genl_family *family, | |||
537 | if (!family->parallel_ops) { | 534 | if (!family->parallel_ops) { |
538 | struct netlink_dump_control c = { | 535 | struct netlink_dump_control c = { |
539 | .module = family->module, | 536 | .module = family->module, |
540 | .data = ops, | 537 | /* we have const, but the netlink API doesn't */ |
538 | .data = (void *)ops, | ||
541 | .dump = genl_lock_dumpit, | 539 | .dump = genl_lock_dumpit, |
542 | .done = genl_lock_done, | 540 | .done = genl_lock_done, |
543 | }; | 541 | }; |
@@ -669,14 +667,22 @@ static int ctrl_fill_info(struct genl_family *family, u32 portid, u32 seq, | |||
669 | 667 | ||
670 | for (i = 0; i < family->n_ops; i++) { | 668 | for (i = 0; i < family->n_ops; i++) { |
671 | struct nlattr *nest; | 669 | struct nlattr *nest; |
672 | struct genl_ops *ops = &family->ops[i]; | 670 | const struct genl_ops *ops = &family->ops[i]; |
671 | u32 flags = ops->flags; | ||
672 | |||
673 | if (ops->dumpit) | ||
674 | flags |= GENL_CMD_CAP_DUMP; | ||
675 | if (ops->doit) | ||
676 | flags |= GENL_CMD_CAP_DO; | ||
677 | if (ops->policy) | ||
678 | flags |= GENL_CMD_CAP_HASPOL; | ||
673 | 679 | ||
674 | nest = nla_nest_start(skb, i + 1); | 680 | nest = nla_nest_start(skb, i + 1); |
675 | if (nest == NULL) | 681 | if (nest == NULL) |
676 | goto nla_put_failure; | 682 | goto nla_put_failure; |
677 | 683 | ||
678 | if (nla_put_u32(skb, CTRL_ATTR_OP_ID, ops->cmd) || | 684 | if (nla_put_u32(skb, CTRL_ATTR_OP_ID, ops->cmd) || |
679 | nla_put_u32(skb, CTRL_ATTR_OP_FLAGS, ops->flags)) | 685 | nla_put_u32(skb, CTRL_ATTR_OP_FLAGS, flags)) |
680 | goto nla_put_failure; | 686 | goto nla_put_failure; |
681 | 687 | ||
682 | nla_nest_end(skb, nest); | 688 | nla_nest_end(skb, nest); |
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index a7f4e7902104..3fef55958e98 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c | |||
@@ -30,9 +30,9 @@ static int nl80211_crypto_settings(struct cfg80211_registered_device *rdev, | |||
30 | struct cfg80211_crypto_settings *settings, | 30 | struct cfg80211_crypto_settings *settings, |
31 | int cipher_limit); | 31 | int cipher_limit); |
32 | 32 | ||
33 | static int nl80211_pre_doit(struct genl_ops *ops, struct sk_buff *skb, | 33 | static int nl80211_pre_doit(const struct genl_ops *ops, struct sk_buff *skb, |
34 | struct genl_info *info); | 34 | struct genl_info *info); |
35 | static void nl80211_post_doit(struct genl_ops *ops, struct sk_buff *skb, | 35 | static void nl80211_post_doit(const struct genl_ops *ops, struct sk_buff *skb, |
36 | struct genl_info *info); | 36 | struct genl_info *info); |
37 | 37 | ||
38 | /* the netlink family */ | 38 | /* the netlink family */ |
@@ -8851,7 +8851,7 @@ static int nl80211_crit_protocol_stop(struct sk_buff *skb, | |||
8851 | #define NL80211_FLAG_NEED_WDEV_UP (NL80211_FLAG_NEED_WDEV |\ | 8851 | #define NL80211_FLAG_NEED_WDEV_UP (NL80211_FLAG_NEED_WDEV |\ |
8852 | NL80211_FLAG_CHECK_NETDEV_UP) | 8852 | NL80211_FLAG_CHECK_NETDEV_UP) |
8853 | 8853 | ||
8854 | static int nl80211_pre_doit(struct genl_ops *ops, struct sk_buff *skb, | 8854 | static int nl80211_pre_doit(const struct genl_ops *ops, struct sk_buff *skb, |
8855 | struct genl_info *info) | 8855 | struct genl_info *info) |
8856 | { | 8856 | { |
8857 | struct cfg80211_registered_device *rdev; | 8857 | struct cfg80211_registered_device *rdev; |
@@ -8920,7 +8920,7 @@ static int nl80211_pre_doit(struct genl_ops *ops, struct sk_buff *skb, | |||
8920 | return 0; | 8920 | return 0; |
8921 | } | 8921 | } |
8922 | 8922 | ||
8923 | static void nl80211_post_doit(struct genl_ops *ops, struct sk_buff *skb, | 8923 | static void nl80211_post_doit(const struct genl_ops *ops, struct sk_buff *skb, |
8924 | struct genl_info *info) | 8924 | struct genl_info *info) |
8925 | { | 8925 | { |
8926 | if (info->user_ptr[1]) { | 8926 | if (info->user_ptr[1]) { |