Merge branch 'wimax-2.6.35.y' of git://git.kernel.org/pub/scm/linux/kernel/git/inaky...
[firefly-linux-kernel-4.4.55.git] / net / netfilter / xt_SECMARK.c
index 4855fd9d7c6f787390a1f195b7b8daa0b6b7a22a..23b2d6c486b573927dcefd00b575546b35376bfa 100644 (file)
@@ -30,7 +30,7 @@ MODULE_ALIAS("ip6t_SECMARK");
 static u8 mode;
 
 static unsigned int
-secmark_tg(struct sk_buff *skb, const struct xt_target_param *par)
+secmark_tg(struct sk_buff *skb, const struct xt_action_param *par)
 {
        u32 secmark = 0;
        const struct xt_secmark_target_info *info = par->targinfo;
@@ -50,7 +50,7 @@ secmark_tg(struct sk_buff *skb, const struct xt_target_param *par)
        return XT_CONTINUE;
 }
 
-static bool checkentry_selinux(struct xt_secmark_target_info *info)
+static int checkentry_selinux(struct xt_secmark_target_info *info)
 {
        int err;
        struct xt_secmark_target_selinux_info *sel = &info->u.sel;
@@ -62,55 +62,57 @@ static bool checkentry_selinux(struct xt_secmark_target_info *info)
                if (err == -EINVAL)
                        pr_info("invalid SELinux context \'%s\'\n",
                                sel->selctx);
-               return false;
+               return err;
        }
 
        if (!sel->selsid) {
                pr_info("unable to map SELinux context \'%s\'\n", sel->selctx);
-               return false;
+               return -ENOENT;
        }
 
        err = selinux_secmark_relabel_packet_permission(sel->selsid);
        if (err) {
                pr_info("unable to obtain relabeling permission\n");
-               return false;
+               return err;
        }
 
        selinux_secmark_refcount_inc();
-       return true;
+       return 0;
 }
 
-static bool secmark_tg_check(const struct xt_tgchk_param *par)
+static int secmark_tg_check(const struct xt_tgchk_param *par)
 {
        struct xt_secmark_target_info *info = par->targinfo;
+       int err;
 
        if (strcmp(par->table, "mangle") != 0 &&
            strcmp(par->table, "security") != 0) {
                pr_info("target only valid in the \'mangle\' "
                        "or \'security\' tables, not \'%s\'.\n", par->table);
-               return false;
+               return -EINVAL;
        }
 
        if (mode && mode != info->mode) {
                pr_info("mode already set to %hu cannot mix with "
                        "rules for mode %hu\n", mode, info->mode);
-               return false;
+               return -EINVAL;
        }
 
        switch (info->mode) {
        case SECMARK_MODE_SEL:
-               if (!checkentry_selinux(info))
-                       return false;
+               err = checkentry_selinux(info);
+               if (err <= 0)
+                       return err;
                break;
 
        default:
                pr_info("invalid mode: %hu\n", info->mode);
-               return false;
+               return -EINVAL;
        }
 
        if (!mode)
                mode = info->mode;
-       return true;
+       return 0;
 }
 
 static void secmark_tg_destroy(const struct xt_tgdtor_param *par)