FAILED: patch "[PATCH] netfilter: nf_tables: autoload modules from the abort path" failed to apply to 4.19-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 4.19-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From eb014de4fd418de1a277913cba244e47274fe392 Mon Sep 17 00:00:00 2001
From: Pablo Neira Ayuso <[email protected]>
Date: Tue, 21 Jan 2020 16:48:03 +0100
Subject: [PATCH] netfilter: nf_tables: autoload modules from the abort path
This patch introduces a list of pending module requests. This new module list is composed of nft_module_request objects that contain the module name and one status field that tells if the module has been already loaded (the 'done' field).
In the first pass, from the preparation phase, the netlink command finds that a module is missing on this list. Then, a module request is allocated and added to this list and nft_request_module() returns -EAGAIN. This triggers the abort path with the autoload parameter set on from nfnetlink, request_module() is called and the module request enters the 'done' state. Since the mutex is released when loading modules from the abort phase, the module list is zapped so this is iteration occurs over a local list. Therefore, the request_module() calls happen when object lists are in consistent state (after fulling aborting the transaction) and the commit list is empty.
On the second pass, the netlink command will find that it already tried to load the module, so it does not request it again and nft_request_module() returns 0. Then, there is a look up to find the object that the command was missing. If the module was successfully loaded, the command proceeds normally since it finds the missing object in place, otherwise -ENOENT is reported to userspace.
This patch also updates nfnetlink to include the reason to enter the abort phase, which is required for this new autoload module rationale.
include/linux/netfilter/nfnetlink.h +1 -1
@@ -31,7 +31,7 @@ struct nfnetlink_subsystem {const struct nfnl_callback *cb;/* callback for individual types */ struct module *owner;int (*commit)(struct net *net,struct sk_buff *skb); -int (*abort)(struct net *net,struct sk_buff *skb); +int (*abort)(struct net *net,struct sk_buff *skb,bool autoload);void (*cleanup)(struct net *net);bool (*valid_genid)(struct net *net,u32 genid); };
include/net/netns/nftables.h +1 -0
@@ -7,6 +7,7 @@struct netns_nftables {struct list_head tables;struct list_head commit_list; +struct list_head module_list;struct mutex commit_mutex;unsigned int base_seq;u8 gencursor;
net/netfilter/nf_tables_api.c +86 -40
241 lines not on this page · raw message
net/netfilter/nfnetlink.c +3 -3
@@ -476,7 +476,7 @@ static void nfnetlink_rcv_batch(struct sk_buff *skb, struct nlmsghdr *nlh, } done:if (status &NFNL_BATCH_REPLAY ) { - ss->abort (net, oskb); + ss->abort (net, oskb, true);nfnl_err_reset (&err_list);kfree_skb (skb);module_put (ss->owner);
@@ -487,11 +487,11 @@ static void nfnetlink_rcv_batch(struct sk_buff *skb, struct nlmsghdr *nlh, status |=NFNL_BATCH_REPLAY ; goto done; }else if (err) { - ss->abort (net, oskb); + ss->abort (net, oskb, false);netlink_ack (oskb,nlmsg_hdr (oskb), err,NULL ); } }else { - ss->abort (net, oskb); + ss->abort (net, oskb, false); }if (ss->cleanup) ss->cleanup (net);