Merge tag 'landlock_v34' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris...
[linux-2.6-microblaze.git] / net / netfilter / nft_log.c
index a06a46b..54f6c20 100644 (file)
@@ -128,6 +128,20 @@ static const struct nla_policy nft_log_policy[NFTA_LOG_MAX + 1] = {
        [NFTA_LOG_FLAGS]        = { .type = NLA_U32 },
 };
 
+static int nft_log_modprobe(struct net *net, enum nf_log_type t)
+{
+       switch (t) {
+       case NF_LOG_TYPE_LOG:
+               return nft_request_module(net, "%s", "nf_log_syslog");
+       case NF_LOG_TYPE_ULOG:
+               return nft_request_module(net, "%s", "nfnetlink_log");
+       case NF_LOG_TYPE_MAX:
+               break;
+       }
+
+       return -ENOENT;
+}
+
 static int nft_log_init(const struct nft_ctx *ctx,
                        const struct nft_expr *expr,
                        const struct nlattr * const tb[])
@@ -197,8 +211,12 @@ static int nft_log_init(const struct nft_ctx *ctx,
                return 0;
 
        err = nf_logger_find_get(ctx->family, li->type);
-       if (err < 0)
+       if (err < 0) {
+               if (nft_log_modprobe(ctx->net, li->type) == -EAGAIN)
+                       err = -EAGAIN;
+
                goto err1;
+       }
 
        return 0;