backports: fix the extack backport
authorJohannes Berg <johannes.berg@intel.com>
Tue, 24 Oct 2017 14:08:48 +0000 (16:08 +0200)
committerJohannes Berg <johannes.berg@intel.com>
Tue, 24 Oct 2017 14:08:48 +0000 (16:08 +0200)
I neglected to take into account that the spatch will also
be applied to the backport-4.12.c file itself, fix that.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
backport/backport-include/linux/netlink.h
backport/backport-include/net/genetlink.h
backport/compat/backport-4.12.c

index 44359918792040962c64bbfd47560a5089449aa1..7da31aad43d6a1c201067b62911c0f997c32f0f6 100644 (file)
@@ -13,7 +13,7 @@ struct netlink_ext_ack {
        u8 cookie_len;
 
        /* backport only field */
-       const void *__bp_genl_real_ops;
+       void *__bp_genl_real_ops;
 };
 
 #define NL_SET_ERR_MSG(extack, msg) do {       \
index 65a4a4b275489549eb3e47e7f1866877a14e3df8..f620b99da2805543dce3ce5ead3a2b56bb7d2ee4 100644 (file)
@@ -3,6 +3,17 @@
 #include_next <net/genetlink.h>
 #include <linux/version.h>
 
+static inline void __bp_genl_info_userhdr_set(struct genl_info *info,
+                                             void *userhdr)
+{
+       info->userhdr = userhdr;
+}
+
+static inline void *__bp_genl_info_userhdr(struct genl_info *info)
+{
+       return info->userhdr;
+}
+
 #if LINUX_VERSION_IS_LESS(4,12,0)
 #define GENL_SET_ERR_MSG(info, msg) do { } while (0)
 
index 73973bca949eb4570226155961a0529810b1e766..382a3af444bcdf5f2634d1eb1554686694fe14ba 100644 (file)
@@ -25,7 +25,7 @@ struct bp_extack_genl_family {
 
 static const struct nla_policy extack_dummy_policy[1] = {};
 
-static struct bp_extack_genl_family *get_copy(const struct genl_ops *op)
+static struct bp_extack_genl_family *get_copy(__genl_const struct genl_ops *op)
 {
        do {
                op--;
@@ -34,23 +34,23 @@ static struct bp_extack_genl_family *get_copy(const struct genl_ops *op)
        return container_of(op, struct bp_extack_genl_family, ops[0]);
 }
 
-static int extack_pre_doit(const struct genl_ops *ops,
+static int extack_pre_doit(__genl_const struct genl_ops *ops,
                           struct sk_buff *skb,
                           struct genl_info *info)
 {
        struct netlink_ext_ack *extack = kzalloc(sizeof(*extack), GFP_KERNEL);
        struct bp_extack_genl_family *copy = get_copy(ops);
-       const struct genl_ops *real_ops;
+       struct genl_ops *real_ops;
        int err;
 
-       info->userhdr = extack;
+       __bp_genl_info_userhdr_set(info, extack);
 
        if (!extack) {
-               info->userhdr = ERR_PTR(-ENOMEM);
+               __bp_genl_info_userhdr_set(info, ERR_PTR(-ENOMEM));
                return -ENOMEM;
        }
 
-       real_ops = &copy->real_family->ops[ops - &copy->ops[1]];
+       real_ops = (void *)&copy->real_family->ops[ops - &copy->ops[1]];
        extack->__bp_genl_real_ops = real_ops;
 
        if (copy->real_family->pre_doit)
@@ -59,7 +59,7 @@ static int extack_pre_doit(const struct genl_ops *ops,
                err = 0;
 
        if (err) {
-               info->userhdr = ERR_PTR(err);
+               __bp_genl_info_userhdr_set(info, ERR_PTR(err));
                kfree(extack);
        }
 
@@ -144,13 +144,13 @@ static void extack_netlink_ack(struct sk_buff *in_skb, struct nlmsghdr *nlh,
 
 static int extack_doit(struct sk_buff *skb, struct genl_info *info)
 {
-       const struct genl_ops *real_ops;
+       struct genl_ops *real_ops;
        int err;
 
        /* older kernels have a bug here */
-       if (IS_ERR(info->userhdr)) {
+       if (IS_ERR(__bp_genl_info_userhdr(info))) {
                extack_netlink_ack(skb, info->nlhdr,
-                                  PTR_ERR(info->userhdr),
+                                  PTR_ERR(__bp_genl_info_userhdr(info)),
                                   genl_info_extack(info));
                goto out;
        }
@@ -171,11 +171,11 @@ out:
        return 0;
 }
 
-static void extack_post_doit(const struct genl_ops *ops,
+static void extack_post_doit(__genl_const struct genl_ops *ops,
                             struct sk_buff *skb,
                             struct genl_info *info)
 {
-       void (*post_doit)(const struct genl_ops *ops,
+       void (*post_doit)(__genl_const struct genl_ops *ops,
                          struct sk_buff *skb,
                          struct genl_info *info);
 
@@ -183,7 +183,7 @@ static void extack_post_doit(const struct genl_ops *ops,
 
        if (post_doit)
                post_doit(ops, skb, info);
-       kfree(info->userhdr);
+       kfree(__bp_genl_info_userhdr(info));
 }
 
 int bp_extack_genl_register_family(struct genl_family *family)