* [PATCH net-next 00/11] Netfilter updates for net-next
@ 2022-04-11 10:27 Pablo Neira Ayuso
2022-04-11 10:27 ` [PATCH net-next 01/11] netfilter: nf_tables: replace unnecessary use of list_for_each_entry_continue() Pablo Neira Ayuso
` (10 more replies)
0 siblings, 11 replies; 20+ messages in thread
From: Pablo Neira Ayuso @ 2022-04-11 10:27 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev, kuba
Hi,
The following patchset contains Netfilter updates for net-next:
1) Replace unnecessary list_for_each_entry_continue() in nf_tables,
from Jakob Koschel.
2) Add struct nf_conntrack_net_ecache to conntrack event cache and
use it, from Florian Westphal.
3) Refactor ctnetlink_dump_list(), also from Florian.
4) Bump module reference counter on cttimeout object addition/removal,
from Florian.
5) Consolidate nf_log MAC printer, from Phil Sutter.
6) Add basic logging support for unknown ethertype, from Phil Sutter.
7) Consolidate check for sysctl nf_log_all_netns toggle, also from Phil.
8) Replace hardcode value in nft_bitwise, from Jeremy Sowden.
9) Rename BASIC-like goto tags in nft_bitwise to more meaningful names,
also from Jeremy.
10) nft_fib support for reverse path filtering with policy-based routing
on iif. Extend selftests to cover for this new usecase, from Florian.
Please, pull these changes from:
git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf-next.git
Thanks.
----------------------------------------------------------------
The following changes since commit 2975dbdc3989cd66a4cb5a7c5510de2de8ee4d14:
Merge tag 'net-5.18-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net (2022-03-31 11:23:31 -0700)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf-next.git HEAD
for you to fetch changes up to 0c7b27616fbd64b3b86c59ad5441f82a1a0c4176:
selftests: netfilter: add fib expression forward test case (2022-04-11 12:10:09 +0200)
----------------------------------------------------------------
Florian Westphal (4):
netfilter: ecache: move to separate structure
netfilter: conntrack: split inner loop of list dumping to own function
netfilter: cttimeout: inc/dec module refcount per object, not per use refcount
selftests: netfilter: add fib expression forward test case
Jakob Koschel (1):
netfilter: nf_tables: replace unnecessary use of list_for_each_entry_continue()
Jeremy Sowden (2):
netfilter: bitwise: replace hard-coded size with `sizeof` expression
netfilter: bitwise: improve error goto labels
Pablo Neira Ayuso (1):
netfilter: nft_fib: reverse path filter for policy-based routing on iif
Phil Sutter (3):
netfilter: nf_log_syslog: Merge MAC header dumpers
netfilter: nf_log_syslog: Don't ignore unknown protocols
netfilter: nf_log_syslog: Consolidate entry checks
include/net/netfilter/nf_conntrack.h | 8 +-
net/ipv4/netfilter/nft_fib_ipv4.c | 4 +
net/ipv6/netfilter/nft_fib_ipv6.c | 4 +
net/netfilter/nf_conntrack_ecache.c | 19 ++--
net/netfilter/nf_conntrack_netlink.c | 68 +++++++++-----
net/netfilter/nf_log_syslog.c | 136 +++++++++++++--------------
net/netfilter/nf_tables_api.c | 6 +-
net/netfilter/nfnetlink_cttimeout.c | 14 +--
net/netfilter/nft_bitwise.c | 13 +--
net/netfilter/nft_fib.c | 4 +
tools/testing/selftests/netfilter/nft_fib.sh | 50 ++++++++++
11 files changed, 199 insertions(+), 127 deletions(-)
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH net-next 01/11] netfilter: nf_tables: replace unnecessary use of list_for_each_entry_continue()
2022-04-11 10:27 [PATCH net-next 00/11] Netfilter updates for net-next Pablo Neira Ayuso
@ 2022-04-11 10:27 ` Pablo Neira Ayuso
2022-04-11 10:50 ` patchwork-bot+netdevbpf
2022-04-11 10:27 ` [PATCH net-next 02/11] netfilter: ecache: move to separate structure Pablo Neira Ayuso
` (9 subsequent siblings)
10 siblings, 1 reply; 20+ messages in thread
From: Pablo Neira Ayuso @ 2022-04-11 10:27 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev, kuba
From: Jakob Koschel <jakobkoschel@gmail.com>
Since there is no way for list_for_each_entry_continue() to start
interating in the middle of the list they can be replaced with a call
to list_for_each_entry().
In preparation to limit the scope of the list iterator to the list
traversal loop, the list iterator variable 'rule' should not be used
past the loop.
v1->v2:
- also replace first usage of list_for_each_entry_continue() (Florian
Westphal)
Signed-off-by: Jakob Koschel <jakobkoschel@gmail.com>
Reviewed-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nf_tables_api.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 5ddfdb2adaf1..060aa56e54d9 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -8367,10 +8367,8 @@ static int nf_tables_commit_chain_prepare(struct net *net, struct nft_chain *cha
if (chain->blob_next || !nft_is_active_next(net, chain))
return 0;
- rule = list_entry(&chain->rules, struct nft_rule, list);
-
data_size = 0;
- list_for_each_entry_continue(rule, &chain->rules, list) {
+ list_for_each_entry(rule, &chain->rules, list) {
if (nft_is_active_next(net, rule)) {
data_size += sizeof(*prule) + rule->dlen;
if (data_size > INT_MAX)
@@ -8387,7 +8385,7 @@ static int nf_tables_commit_chain_prepare(struct net *net, struct nft_chain *cha
data_boundary = data + data_size;
size = 0;
- list_for_each_entry_continue(rule, &chain->rules, list) {
+ list_for_each_entry(rule, &chain->rules, list) {
if (!nft_is_active_next(net, rule))
continue;
--
2.30.2
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH net-next 02/11] netfilter: ecache: move to separate structure
2022-04-11 10:27 [PATCH net-next 00/11] Netfilter updates for net-next Pablo Neira Ayuso
2022-04-11 10:27 ` [PATCH net-next 01/11] netfilter: nf_tables: replace unnecessary use of list_for_each_entry_continue() Pablo Neira Ayuso
@ 2022-04-11 10:27 ` Pablo Neira Ayuso
2022-04-11 10:27 ` [PATCH net-next 03/11] netfilter: conntrack: split inner loop of list dumping to own function Pablo Neira Ayuso
` (8 subsequent siblings)
10 siblings, 0 replies; 20+ messages in thread
From: Pablo Neira Ayuso @ 2022-04-11 10:27 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev, kuba
From: Florian Westphal <fw@strlen.de>
This makes it easier for a followup patch to only expose ecache
related parts of nf_conntrack_net structure.
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
include/net/netfilter/nf_conntrack.h | 8 ++++++--
net/netfilter/nf_conntrack_ecache.c | 19 ++++++++++---------
2 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/include/net/netfilter/nf_conntrack.h b/include/net/netfilter/nf_conntrack.h
index b08b70989d2c..69e6c6a218be 100644
--- a/include/net/netfilter/nf_conntrack.h
+++ b/include/net/netfilter/nf_conntrack.h
@@ -43,6 +43,11 @@ union nf_conntrack_expect_proto {
/* insert expect proto private data here */
};
+struct nf_conntrack_net_ecache {
+ struct delayed_work dwork;
+ struct netns_ct *ct_net;
+};
+
struct nf_conntrack_net {
/* only used when new connection is allocated: */
atomic_t count;
@@ -58,8 +63,7 @@ struct nf_conntrack_net {
struct ctl_table_header *sysctl_header;
#endif
#ifdef CONFIG_NF_CONNTRACK_EVENTS
- struct delayed_work ecache_dwork;
- struct netns_ct *ct_net;
+ struct nf_conntrack_net_ecache ecache;
#endif
};
diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
index 07e65b4e92f8..0cb2da0a759a 100644
--- a/net/netfilter/nf_conntrack_ecache.c
+++ b/net/netfilter/nf_conntrack_ecache.c
@@ -96,8 +96,8 @@ static enum retry_state ecache_work_evict_list(struct ct_pcpu *pcpu)
static void ecache_work(struct work_struct *work)
{
- struct nf_conntrack_net *cnet = container_of(work, struct nf_conntrack_net, ecache_dwork.work);
- struct netns_ct *ctnet = cnet->ct_net;
+ struct nf_conntrack_net *cnet = container_of(work, struct nf_conntrack_net, ecache.dwork.work);
+ struct netns_ct *ctnet = cnet->ecache.ct_net;
int cpu, delay = -1;
struct ct_pcpu *pcpu;
@@ -127,7 +127,7 @@ static void ecache_work(struct work_struct *work)
ctnet->ecache_dwork_pending = delay > 0;
if (delay >= 0)
- schedule_delayed_work(&cnet->ecache_dwork, delay);
+ schedule_delayed_work(&cnet->ecache.dwork, delay);
}
static int __nf_conntrack_eventmask_report(struct nf_conntrack_ecache *e,
@@ -293,12 +293,12 @@ void nf_conntrack_ecache_work(struct net *net, enum nf_ct_ecache_state state)
struct nf_conntrack_net *cnet = nf_ct_pernet(net);
if (state == NFCT_ECACHE_DESTROY_FAIL &&
- !delayed_work_pending(&cnet->ecache_dwork)) {
- schedule_delayed_work(&cnet->ecache_dwork, HZ);
+ !delayed_work_pending(&cnet->ecache.dwork)) {
+ schedule_delayed_work(&cnet->ecache.dwork, HZ);
net->ct.ecache_dwork_pending = true;
} else if (state == NFCT_ECACHE_DESTROY_SENT) {
net->ct.ecache_dwork_pending = false;
- mod_delayed_work(system_wq, &cnet->ecache_dwork, 0);
+ mod_delayed_work(system_wq, &cnet->ecache.dwork, 0);
}
}
@@ -310,8 +310,9 @@ void nf_conntrack_ecache_pernet_init(struct net *net)
struct nf_conntrack_net *cnet = nf_ct_pernet(net);
net->ct.sysctl_events = nf_ct_events;
- cnet->ct_net = &net->ct;
- INIT_DELAYED_WORK(&cnet->ecache_dwork, ecache_work);
+
+ cnet->ecache.ct_net = &net->ct;
+ INIT_DELAYED_WORK(&cnet->ecache.dwork, ecache_work);
BUILD_BUG_ON(__IPCT_MAX >= 16); /* e->ctmask is u16 */
}
@@ -320,5 +321,5 @@ void nf_conntrack_ecache_pernet_fini(struct net *net)
{
struct nf_conntrack_net *cnet = nf_ct_pernet(net);
- cancel_delayed_work_sync(&cnet->ecache_dwork);
+ cancel_delayed_work_sync(&cnet->ecache.dwork);
}
--
2.30.2
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH net-next 03/11] netfilter: conntrack: split inner loop of list dumping to own function
2022-04-11 10:27 [PATCH net-next 00/11] Netfilter updates for net-next Pablo Neira Ayuso
2022-04-11 10:27 ` [PATCH net-next 01/11] netfilter: nf_tables: replace unnecessary use of list_for_each_entry_continue() Pablo Neira Ayuso
2022-04-11 10:27 ` [PATCH net-next 02/11] netfilter: ecache: move to separate structure Pablo Neira Ayuso
@ 2022-04-11 10:27 ` Pablo Neira Ayuso
2022-04-11 10:27 ` [PATCH net-next 04/11] netfilter: cttimeout: inc/dec module refcount per object, not per use refcount Pablo Neira Ayuso
` (7 subsequent siblings)
10 siblings, 0 replies; 20+ messages in thread
From: Pablo Neira Ayuso @ 2022-04-11 10:27 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev, kuba
From: Florian Westphal <fw@strlen.de>
This allows code re-use in the followup patch.
No functional changes intended.
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nf_conntrack_netlink.c | 68 ++++++++++++++++++----------
1 file changed, 43 insertions(+), 25 deletions(-)
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
index 1ea2ad732d57..924d766e6c53 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -1708,6 +1708,47 @@ static int ctnetlink_done_list(struct netlink_callback *cb)
return 0;
}
+static int ctnetlink_dump_one_entry(struct sk_buff *skb,
+ struct netlink_callback *cb,
+ struct nf_conn *ct,
+ bool dying)
+{
+ struct ctnetlink_list_dump_ctx *ctx = (void *)cb->ctx;
+ struct nfgenmsg *nfmsg = nlmsg_data(cb->nlh);
+ u8 l3proto = nfmsg->nfgen_family;
+ int res;
+
+ if (l3proto && nf_ct_l3num(ct) != l3proto)
+ return 0;
+
+ if (ctx->last) {
+ if (ct != ctx->last)
+ return 0;
+
+ ctx->last = NULL;
+ }
+
+ /* We can't dump extension info for the unconfirmed
+ * list because unconfirmed conntracks can have
+ * ct->ext reallocated (and thus freed).
+ *
+ * In the dying list case ct->ext can't be free'd
+ * until after we drop pcpu->lock.
+ */
+ res = ctnetlink_fill_info(skb, NETLINK_CB(cb->skb).portid,
+ cb->nlh->nlmsg_seq,
+ NFNL_MSG_TYPE(cb->nlh->nlmsg_type),
+ ct, dying, 0);
+ if (res < 0) {
+ if (!refcount_inc_not_zero(&ct->ct_general.use))
+ return 0;
+
+ ctx->last = ct;
+ }
+
+ return res;
+}
+
static int
ctnetlink_dump_list(struct sk_buff *skb, struct netlink_callback *cb, bool dying)
{
@@ -1715,12 +1756,9 @@ ctnetlink_dump_list(struct sk_buff *skb, struct netlink_callback *cb, bool dying
struct nf_conn *ct, *last;
struct nf_conntrack_tuple_hash *h;
struct hlist_nulls_node *n;
- struct nfgenmsg *nfmsg = nlmsg_data(cb->nlh);
- u_int8_t l3proto = nfmsg->nfgen_family;
- int res;
- int cpu;
struct hlist_nulls_head *list;
struct net *net = sock_net(skb->sk);
+ int res, cpu;
if (ctx->done)
return 0;
@@ -1739,30 +1777,10 @@ ctnetlink_dump_list(struct sk_buff *skb, struct netlink_callback *cb, bool dying
restart:
hlist_nulls_for_each_entry(h, n, list, hnnode) {
ct = nf_ct_tuplehash_to_ctrack(h);
- if (l3proto && nf_ct_l3num(ct) != l3proto)
- continue;
- if (ctx->last) {
- if (ct != last)
- continue;
- ctx->last = NULL;
- }
- /* We can't dump extension info for the unconfirmed
- * list because unconfirmed conntracks can have
- * ct->ext reallocated (and thus freed).
- *
- * In the dying list case ct->ext can't be free'd
- * until after we drop pcpu->lock.
- */
- res = ctnetlink_fill_info(skb, NETLINK_CB(cb->skb).portid,
- cb->nlh->nlmsg_seq,
- NFNL_MSG_TYPE(cb->nlh->nlmsg_type),
- ct, dying, 0);
+ res = ctnetlink_dump_one_entry(skb, cb, ct, dying);
if (res < 0) {
- if (!refcount_inc_not_zero(&ct->ct_general.use))
- continue;
ctx->cpu = cpu;
- ctx->last = ct;
spin_unlock_bh(&pcpu->lock);
goto out;
}
--
2.30.2
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH net-next 04/11] netfilter: cttimeout: inc/dec module refcount per object, not per use refcount
2022-04-11 10:27 [PATCH net-next 00/11] Netfilter updates for net-next Pablo Neira Ayuso
` (2 preceding siblings ...)
2022-04-11 10:27 ` [PATCH net-next 03/11] netfilter: conntrack: split inner loop of list dumping to own function Pablo Neira Ayuso
@ 2022-04-11 10:27 ` Pablo Neira Ayuso
2022-04-11 10:27 ` [PATCH net-next 05/11] netfilter: nf_log_syslog: Merge MAC header dumpers Pablo Neira Ayuso
` (6 subsequent siblings)
10 siblings, 0 replies; 20+ messages in thread
From: Pablo Neira Ayuso @ 2022-04-11 10:27 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev, kuba
From: Florian Westphal <fw@strlen.de>
There is no need to increment the module refcount again, its enough to
obtain one reference per object, i.e. take a reference on object
creation and put it on object destruction.
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nfnetlink_cttimeout.c | 14 +++++---------
1 file changed, 5 insertions(+), 9 deletions(-)
diff --git a/net/netfilter/nfnetlink_cttimeout.c b/net/netfilter/nfnetlink_cttimeout.c
index b0d8888a539b..eea486f32971 100644
--- a/net/netfilter/nfnetlink_cttimeout.c
+++ b/net/netfilter/nfnetlink_cttimeout.c
@@ -158,6 +158,7 @@ static int cttimeout_new_timeout(struct sk_buff *skb,
timeout->timeout.l3num = l3num;
timeout->timeout.l4proto = l4proto;
refcount_set(&timeout->refcnt, 1);
+ __module_get(THIS_MODULE);
list_add_tail_rcu(&timeout->head, &pernet->nfct_timeout_list);
return 0;
@@ -506,13 +507,8 @@ static struct nf_ct_timeout *ctnl_timeout_find_get(struct net *net,
if (strncmp(timeout->name, name, CTNL_TIMEOUT_NAME_MAX) != 0)
continue;
- if (!try_module_get(THIS_MODULE))
+ if (!refcount_inc_not_zero(&timeout->refcnt))
goto err;
-
- if (!refcount_inc_not_zero(&timeout->refcnt)) {
- module_put(THIS_MODULE);
- goto err;
- }
matching = timeout;
break;
}
@@ -525,10 +521,10 @@ static void ctnl_timeout_put(struct nf_ct_timeout *t)
struct ctnl_timeout *timeout =
container_of(t, struct ctnl_timeout, timeout);
- if (refcount_dec_and_test(&timeout->refcnt))
+ if (refcount_dec_and_test(&timeout->refcnt)) {
kfree_rcu(timeout, rcu_head);
-
- module_put(THIS_MODULE);
+ module_put(THIS_MODULE);
+ }
}
static const struct nfnl_callback cttimeout_cb[IPCTNL_MSG_TIMEOUT_MAX] = {
--
2.30.2
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH net-next 05/11] netfilter: nf_log_syslog: Merge MAC header dumpers
2022-04-11 10:27 [PATCH net-next 00/11] Netfilter updates for net-next Pablo Neira Ayuso
` (3 preceding siblings ...)
2022-04-11 10:27 ` [PATCH net-next 04/11] netfilter: cttimeout: inc/dec module refcount per object, not per use refcount Pablo Neira Ayuso
@ 2022-04-11 10:27 ` Pablo Neira Ayuso
2022-04-11 10:27 ` [PATCH net-next 06/11] netfilter: nf_log_syslog: Don't ignore unknown protocols Pablo Neira Ayuso
` (5 subsequent siblings)
10 siblings, 0 replies; 20+ messages in thread
From: Pablo Neira Ayuso @ 2022-04-11 10:27 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev, kuba
From: Phil Sutter <phil@nwl.cc>
The functions for IPv4 and IPv6 were almost identical apart from extra
SIT tunnel device handling in the latter.
Signed-off-by: Phil Sutter <phil@nwl.cc>
Acked-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nf_log_syslog.c | 91 ++++++++++-------------------------
1 file changed, 25 insertions(+), 66 deletions(-)
diff --git a/net/netfilter/nf_log_syslog.c b/net/netfilter/nf_log_syslog.c
index 13234641cdb3..d1dcf36545d7 100644
--- a/net/netfilter/nf_log_syslog.c
+++ b/net/netfilter/nf_log_syslog.c
@@ -766,9 +766,9 @@ dump_ipv6_packet(struct net *net, struct nf_log_buf *m,
nf_log_buf_add(m, "MARK=0x%x ", skb->mark);
}
-static void dump_ipv4_mac_header(struct nf_log_buf *m,
- const struct nf_loginfo *info,
- const struct sk_buff *skb)
+static void dump_mac_header(struct nf_log_buf *m,
+ const struct nf_loginfo *info,
+ const struct sk_buff *skb)
{
struct net_device *dev = skb->dev;
unsigned int logflags = 0;
@@ -798,9 +798,26 @@ static void dump_ipv4_mac_header(struct nf_log_buf *m,
const unsigned char *p = skb_mac_header(skb);
unsigned int i;
- nf_log_buf_add(m, "%02x", *p++);
- for (i = 1; i < dev->hard_header_len; i++, p++)
- nf_log_buf_add(m, ":%02x", *p);
+ if (dev->type == ARPHRD_SIT) {
+ p -= ETH_HLEN;
+
+ if (p < skb->head)
+ p = NULL;
+ }
+
+ if (p) {
+ nf_log_buf_add(m, "%02x", *p++);
+ for (i = 1; i < dev->hard_header_len; i++)
+ nf_log_buf_add(m, ":%02x", *p++);
+ }
+
+ if (dev->type == ARPHRD_SIT) {
+ const struct iphdr *iph =
+ (struct iphdr *)skb_mac_header(skb);
+
+ nf_log_buf_add(m, " TUNNEL=%pI4->%pI4", &iph->saddr,
+ &iph->daddr);
+ }
}
nf_log_buf_add(m, " ");
}
@@ -827,7 +844,7 @@ static void nf_log_ip_packet(struct net *net, u_int8_t pf,
out, loginfo, prefix);
if (in)
- dump_ipv4_mac_header(m, loginfo, skb);
+ dump_mac_header(m, loginfo, skb);
dump_ipv4_packet(net, m, loginfo, skb, 0);
@@ -841,64 +858,6 @@ static struct nf_logger nf_ip_logger __read_mostly = {
.me = THIS_MODULE,
};
-static void dump_ipv6_mac_header(struct nf_log_buf *m,
- const struct nf_loginfo *info,
- const struct sk_buff *skb)
-{
- struct net_device *dev = skb->dev;
- unsigned int logflags = 0;
-
- if (info->type == NF_LOG_TYPE_LOG)
- logflags = info->u.log.logflags;
-
- if (!(logflags & NF_LOG_MACDECODE))
- goto fallback;
-
- switch (dev->type) {
- case ARPHRD_ETHER:
- nf_log_buf_add(m, "MACSRC=%pM MACDST=%pM ",
- eth_hdr(skb)->h_source, eth_hdr(skb)->h_dest);
- nf_log_dump_vlan(m, skb);
- nf_log_buf_add(m, "MACPROTO=%04x ",
- ntohs(eth_hdr(skb)->h_proto));
- return;
- default:
- break;
- }
-
-fallback:
- nf_log_buf_add(m, "MAC=");
- if (dev->hard_header_len &&
- skb->mac_header != skb->network_header) {
- const unsigned char *p = skb_mac_header(skb);
- unsigned int len = dev->hard_header_len;
- unsigned int i;
-
- if (dev->type == ARPHRD_SIT) {
- p -= ETH_HLEN;
-
- if (p < skb->head)
- p = NULL;
- }
-
- if (p) {
- nf_log_buf_add(m, "%02x", *p++);
- for (i = 1; i < len; i++)
- nf_log_buf_add(m, ":%02x", *p++);
- }
- nf_log_buf_add(m, " ");
-
- if (dev->type == ARPHRD_SIT) {
- const struct iphdr *iph =
- (struct iphdr *)skb_mac_header(skb);
- nf_log_buf_add(m, "TUNNEL=%pI4->%pI4 ", &iph->saddr,
- &iph->daddr);
- }
- } else {
- nf_log_buf_add(m, " ");
- }
-}
-
static void nf_log_ip6_packet(struct net *net, u_int8_t pf,
unsigned int hooknum, const struct sk_buff *skb,
const struct net_device *in,
@@ -921,7 +880,7 @@ static void nf_log_ip6_packet(struct net *net, u_int8_t pf,
loginfo, prefix);
if (in)
- dump_ipv6_mac_header(m, loginfo, skb);
+ dump_mac_header(m, loginfo, skb);
dump_ipv6_packet(net, m, loginfo, skb, skb_network_offset(skb), 1);
--
2.30.2
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH net-next 06/11] netfilter: nf_log_syslog: Don't ignore unknown protocols
2022-04-11 10:27 [PATCH net-next 00/11] Netfilter updates for net-next Pablo Neira Ayuso
` (4 preceding siblings ...)
2022-04-11 10:27 ` [PATCH net-next 05/11] netfilter: nf_log_syslog: Merge MAC header dumpers Pablo Neira Ayuso
@ 2022-04-11 10:27 ` Pablo Neira Ayuso
2022-04-11 10:27 ` [PATCH net-next 07/11] netfilter: nf_log_syslog: Consolidate entry checks Pablo Neira Ayuso
` (4 subsequent siblings)
10 siblings, 0 replies; 20+ messages in thread
From: Pablo Neira Ayuso @ 2022-04-11 10:27 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev, kuba
From: Phil Sutter <phil@nwl.cc>
With netdev and bridge nfprotos, loggers may see arbitrary ethernet
frames. Print at least basic info like interfaces and MAC header data.
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nf_log_syslog.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/net/netfilter/nf_log_syslog.c b/net/netfilter/nf_log_syslog.c
index d1dcf36545d7..a7ff6fdbafc9 100644
--- a/net/netfilter/nf_log_syslog.c
+++ b/net/netfilter/nf_log_syslog.c
@@ -894,6 +894,33 @@ static struct nf_logger nf_ip6_logger __read_mostly = {
.me = THIS_MODULE,
};
+static void nf_log_unknown_packet(struct net *net, u_int8_t pf,
+ unsigned int hooknum,
+ const struct sk_buff *skb,
+ const struct net_device *in,
+ const struct net_device *out,
+ const struct nf_loginfo *loginfo,
+ const char *prefix)
+{
+ struct nf_log_buf *m;
+
+ /* FIXME: Disabled from containers until syslog ns is supported */
+ if (!net_eq(net, &init_net) && !sysctl_nf_log_all_netns)
+ return;
+
+ m = nf_log_buf_open();
+
+ if (!loginfo)
+ loginfo = &default_loginfo;
+
+ nf_log_dump_packet_common(m, pf, hooknum, skb, in, out, loginfo,
+ prefix);
+
+ dump_mac_header(m, loginfo, skb);
+
+ nf_log_buf_close(m);
+}
+
static void nf_log_netdev_packet(struct net *net, u_int8_t pf,
unsigned int hooknum,
const struct sk_buff *skb,
@@ -913,6 +940,10 @@ static void nf_log_netdev_packet(struct net *net, u_int8_t pf,
case htons(ETH_P_RARP):
nf_log_arp_packet(net, pf, hooknum, skb, in, out, loginfo, prefix);
break;
+ default:
+ nf_log_unknown_packet(net, pf, hooknum, skb,
+ in, out, loginfo, prefix);
+ break;
}
}
--
2.30.2
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH net-next 07/11] netfilter: nf_log_syslog: Consolidate entry checks
2022-04-11 10:27 [PATCH net-next 00/11] Netfilter updates for net-next Pablo Neira Ayuso
` (5 preceding siblings ...)
2022-04-11 10:27 ` [PATCH net-next 06/11] netfilter: nf_log_syslog: Don't ignore unknown protocols Pablo Neira Ayuso
@ 2022-04-11 10:27 ` Pablo Neira Ayuso
2022-04-11 10:27 ` [PATCH net-next 08/11] netfilter: bitwise: replace hard-coded size with `sizeof` expression Pablo Neira Ayuso
` (3 subsequent siblings)
10 siblings, 0 replies; 20+ messages in thread
From: Pablo Neira Ayuso @ 2022-04-11 10:27 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev, kuba
From: Phil Sutter <phil@nwl.cc>
Every syslog logging callback has to perform the same check to cover for
rogue containers, introduce a helper for clarity. Drop the FIXME as
there is a viable solution since commit 2851940ffee31 ("netfilter: allow
logging from non-init namespaces").
Suggested-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nf_log_syslog.c | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/net/netfilter/nf_log_syslog.c b/net/netfilter/nf_log_syslog.c
index a7ff6fdbafc9..77bcb10fc586 100644
--- a/net/netfilter/nf_log_syslog.c
+++ b/net/netfilter/nf_log_syslog.c
@@ -40,6 +40,12 @@ struct arppayload {
unsigned char ip_dst[4];
};
+/* Guard against containers flooding syslog. */
+static bool nf_log_allowed(const struct net *net)
+{
+ return net_eq(net, &init_net) || sysctl_nf_log_all_netns;
+}
+
static void nf_log_dump_vlan(struct nf_log_buf *m, const struct sk_buff *skb)
{
u16 vid;
@@ -133,8 +139,7 @@ static void nf_log_arp_packet(struct net *net, u_int8_t pf,
{
struct nf_log_buf *m;
- /* FIXME: Disabled from containers until syslog ns is supported */
- if (!net_eq(net, &init_net) && !sysctl_nf_log_all_netns)
+ if (!nf_log_allowed(net))
return;
m = nf_log_buf_open();
@@ -831,8 +836,7 @@ static void nf_log_ip_packet(struct net *net, u_int8_t pf,
{
struct nf_log_buf *m;
- /* FIXME: Disabled from containers until syslog ns is supported */
- if (!net_eq(net, &init_net) && !sysctl_nf_log_all_netns)
+ if (!nf_log_allowed(net))
return;
m = nf_log_buf_open();
@@ -867,8 +871,7 @@ static void nf_log_ip6_packet(struct net *net, u_int8_t pf,
{
struct nf_log_buf *m;
- /* FIXME: Disabled from containers until syslog ns is supported */
- if (!net_eq(net, &init_net) && !sysctl_nf_log_all_netns)
+ if (!nf_log_allowed(net))
return;
m = nf_log_buf_open();
@@ -904,8 +907,7 @@ static void nf_log_unknown_packet(struct net *net, u_int8_t pf,
{
struct nf_log_buf *m;
- /* FIXME: Disabled from containers until syslog ns is supported */
- if (!net_eq(net, &init_net) && !sysctl_nf_log_all_netns)
+ if (!nf_log_allowed(net))
return;
m = nf_log_buf_open();
--
2.30.2
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH net-next 08/11] netfilter: bitwise: replace hard-coded size with `sizeof` expression
2022-04-11 10:27 [PATCH net-next 00/11] Netfilter updates for net-next Pablo Neira Ayuso
` (6 preceding siblings ...)
2022-04-11 10:27 ` [PATCH net-next 07/11] netfilter: nf_log_syslog: Consolidate entry checks Pablo Neira Ayuso
@ 2022-04-11 10:27 ` Pablo Neira Ayuso
2022-04-11 10:27 ` [PATCH net-next 09/11] netfilter: bitwise: improve error goto labels Pablo Neira Ayuso
` (2 subsequent siblings)
10 siblings, 0 replies; 20+ messages in thread
From: Pablo Neira Ayuso @ 2022-04-11 10:27 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev, kuba
From: Jeremy Sowden <jeremy@azazel.net>
When calculating the length of an array, use the appropriate `sizeof`
expression for its type, rather than an integer literal.
Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
Signed-off-by: Florian Westphal <fw@strlen.de>
---
net/netfilter/nft_bitwise.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/netfilter/nft_bitwise.c b/net/netfilter/nft_bitwise.c
index 38caa66632b4..dc5759fac5b6 100644
--- a/net/netfilter/nft_bitwise.c
+++ b/net/netfilter/nft_bitwise.c
@@ -30,7 +30,7 @@ static void nft_bitwise_eval_bool(u32 *dst, const u32 *src,
{
unsigned int i;
- for (i = 0; i < DIV_ROUND_UP(priv->len, 4); i++)
+ for (i = 0; i < DIV_ROUND_UP(priv->len, sizeof(u32)); i++)
dst[i] = (src[i] & priv->mask.data[i]) ^ priv->xor.data[i];
}
--
2.30.2
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH net-next 09/11] netfilter: bitwise: improve error goto labels
2022-04-11 10:27 [PATCH net-next 00/11] Netfilter updates for net-next Pablo Neira Ayuso
` (7 preceding siblings ...)
2022-04-11 10:27 ` [PATCH net-next 08/11] netfilter: bitwise: replace hard-coded size with `sizeof` expression Pablo Neira Ayuso
@ 2022-04-11 10:27 ` Pablo Neira Ayuso
2022-04-11 10:27 ` [PATCH net-next 10/11] netfilter: nft_fib: reverse path filter for policy-based routing on iif Pablo Neira Ayuso
2022-04-11 10:27 ` [PATCH net-next 11/11] selftests: netfilter: add fib expression forward test case Pablo Neira Ayuso
10 siblings, 0 replies; 20+ messages in thread
From: Pablo Neira Ayuso @ 2022-04-11 10:27 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev, kuba
From: Jeremy Sowden <jeremy@azazel.net>
Replace two labels (`err1` and `err2`) with more informative ones.
Signed-off-by: Jeremy Sowden <jeremy@azazel.net>
Signed-off-by: Florian Westphal <fw@strlen.de>
---
net/netfilter/nft_bitwise.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/net/netfilter/nft_bitwise.c b/net/netfilter/nft_bitwise.c
index dc5759fac5b6..d72143622f22 100644
--- a/net/netfilter/nft_bitwise.c
+++ b/net/netfilter/nft_bitwise.c
@@ -109,22 +109,23 @@ static int nft_bitwise_init_bool(struct nft_bitwise *priv,
return err;
if (mask.type != NFT_DATA_VALUE || mask.len != priv->len) {
err = -EINVAL;
- goto err1;
+ goto err_mask_release;
}
err = nft_data_init(NULL, &priv->xor, sizeof(priv->xor), &xor,
tb[NFTA_BITWISE_XOR]);
if (err < 0)
- goto err1;
+ goto err_mask_release;
if (xor.type != NFT_DATA_VALUE || xor.len != priv->len) {
err = -EINVAL;
- goto err2;
+ goto err_xor_release;
}
return 0;
-err2:
+
+err_xor_release:
nft_data_release(&priv->xor, xor.type);
-err1:
+err_mask_release:
nft_data_release(&priv->mask, mask.type);
return err;
}
--
2.30.2
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH net-next 10/11] netfilter: nft_fib: reverse path filter for policy-based routing on iif
2022-04-11 10:27 [PATCH net-next 00/11] Netfilter updates for net-next Pablo Neira Ayuso
` (8 preceding siblings ...)
2022-04-11 10:27 ` [PATCH net-next 09/11] netfilter: bitwise: improve error goto labels Pablo Neira Ayuso
@ 2022-04-11 10:27 ` Pablo Neira Ayuso
2022-04-11 10:27 ` [PATCH net-next 11/11] selftests: netfilter: add fib expression forward test case Pablo Neira Ayuso
10 siblings, 0 replies; 20+ messages in thread
From: Pablo Neira Ayuso @ 2022-04-11 10:27 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev, kuba
If policy-based routing using the iif selector is used, then the fib
expression fails to look up for the reverse path from the prerouting
hook because the input interface cannot be inferred. In order to support
this scenario, extend the fib expression to allow to use after the route
lookup, from the forward hook.
This patch also adds support for the input hook for usability reasons.
Since the prerouting hook cannot be used for the scenario described
above, users need two rules: one for the forward chain and another rule
for the input chain to check for the reverse path check for locally
targeted traffic.
Acked-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/ipv4/netfilter/nft_fib_ipv4.c | 4 ++++
net/ipv6/netfilter/nft_fib_ipv6.c | 4 ++++
net/netfilter/nft_fib.c | 4 ++++
3 files changed, 12 insertions(+)
diff --git a/net/ipv4/netfilter/nft_fib_ipv4.c b/net/ipv4/netfilter/nft_fib_ipv4.c
index 4151eb1262dd..b75cac69bd7e 100644
--- a/net/ipv4/netfilter/nft_fib_ipv4.c
+++ b/net/ipv4/netfilter/nft_fib_ipv4.c
@@ -112,6 +112,10 @@ void nft_fib4_eval(const struct nft_expr *expr, struct nft_regs *regs,
fl4.daddr = iph->daddr;
fl4.saddr = get_saddr(iph->saddr);
} else {
+ if (nft_hook(pkt) == NF_INET_FORWARD &&
+ priv->flags & NFTA_FIB_F_IIF)
+ fl4.flowi4_iif = nft_out(pkt)->ifindex;
+
fl4.daddr = iph->saddr;
fl4.saddr = get_saddr(iph->daddr);
}
diff --git a/net/ipv6/netfilter/nft_fib_ipv6.c b/net/ipv6/netfilter/nft_fib_ipv6.c
index b3f163b40c2b..8970d0b4faeb 100644
--- a/net/ipv6/netfilter/nft_fib_ipv6.c
+++ b/net/ipv6/netfilter/nft_fib_ipv6.c
@@ -30,6 +30,10 @@ static int nft_fib6_flowi_init(struct flowi6 *fl6, const struct nft_fib *priv,
fl6->daddr = iph->daddr;
fl6->saddr = iph->saddr;
} else {
+ if (nft_hook(pkt) == NF_INET_FORWARD &&
+ priv->flags & NFTA_FIB_F_IIF)
+ fl6->flowi6_iif = nft_out(pkt)->ifindex;
+
fl6->daddr = iph->saddr;
fl6->saddr = iph->daddr;
}
diff --git a/net/netfilter/nft_fib.c b/net/netfilter/nft_fib.c
index f198f2d9ef90..1f12d7ade606 100644
--- a/net/netfilter/nft_fib.c
+++ b/net/netfilter/nft_fib.c
@@ -35,6 +35,10 @@ int nft_fib_validate(const struct nft_ctx *ctx, const struct nft_expr *expr,
case NFT_FIB_RESULT_OIF:
case NFT_FIB_RESULT_OIFNAME:
hooks = (1 << NF_INET_PRE_ROUTING);
+ if (priv->flags & NFTA_FIB_F_IIF) {
+ hooks |= (1 << NF_INET_LOCAL_IN) |
+ (1 << NF_INET_FORWARD);
+ }
break;
case NFT_FIB_RESULT_ADDRTYPE:
if (priv->flags & NFTA_FIB_F_IIF)
--
2.30.2
^ permalink raw reply related [flat|nested] 20+ messages in thread
* [PATCH net-next 11/11] selftests: netfilter: add fib expression forward test case
2022-04-11 10:27 [PATCH net-next 00/11] Netfilter updates for net-next Pablo Neira Ayuso
` (9 preceding siblings ...)
2022-04-11 10:27 ` [PATCH net-next 10/11] netfilter: nft_fib: reverse path filter for policy-based routing on iif Pablo Neira Ayuso
@ 2022-04-11 10:27 ` Pablo Neira Ayuso
10 siblings, 0 replies; 20+ messages in thread
From: Pablo Neira Ayuso @ 2022-04-11 10:27 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev, kuba
From: Florian Westphal <fw@strlen.de>
Its now possible to use fib expression in the forward chain (where both
the input and output interfaces are known).
Add a simple test case for this.
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
tools/testing/selftests/netfilter/nft_fib.sh | 50 ++++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git a/tools/testing/selftests/netfilter/nft_fib.sh b/tools/testing/selftests/netfilter/nft_fib.sh
index 695a1958723f..fd76b69635a4 100755
--- a/tools/testing/selftests/netfilter/nft_fib.sh
+++ b/tools/testing/selftests/netfilter/nft_fib.sh
@@ -66,6 +66,20 @@ table inet filter {
EOF
}
+load_pbr_ruleset() {
+ local netns=$1
+
+ip netns exec ${netns} nft -f /dev/stdin <<EOF
+table inet filter {
+ chain forward {
+ type filter hook forward priority raw;
+ fib saddr . iif oif gt 0 accept
+ log drop
+ }
+}
+EOF
+}
+
load_ruleset_count() {
local netns=$1
@@ -219,4 +233,40 @@ sleep 2
ip netns exec ${ns1} ping -c 3 -q 1c3::c01d > /dev/null
check_fib_counter 3 ${nsrouter} 1c3::c01d || exit 1
+# delete all rules
+ip netns exec ${ns1} nft flush ruleset
+ip netns exec ${ns2} nft flush ruleset
+ip netns exec ${nsrouter} nft flush ruleset
+
+ip -net ${ns1} addr add 10.0.1.99/24 dev eth0
+ip -net ${ns1} addr add dead:1::99/64 dev eth0
+
+ip -net ${ns1} addr del 10.0.2.99/24 dev eth0
+ip -net ${ns1} addr del dead:2::99/64 dev eth0
+
+ip -net ${nsrouter} addr del dead:2::1/64 dev veth0
+
+# ... pbr ruleset for the router, check iif+oif.
+load_pbr_ruleset ${nsrouter}
+if [ $? -ne 0 ] ; then
+ echo "SKIP: Could not load fib forward ruleset"
+ exit $ksft_skip
+fi
+
+ip -net ${nsrouter} rule add from all table 128
+ip -net ${nsrouter} rule add from all iif veth0 table 129
+ip -net ${nsrouter} route add table 128 to 10.0.1.0/24 dev veth0
+ip -net ${nsrouter} route add table 129 to 10.0.2.0/24 dev veth1
+
+# drop main ipv4 table
+ip -net ${nsrouter} -4 rule delete table main
+
+test_ping 10.0.2.99 dead:2::99
+if [ $? -ne 0 ] ; then
+ ip -net ${nsrouter} nft list ruleset
+ echo "FAIL: fib mismatch in pbr setup"
+ exit 1
+fi
+
+echo "PASS: fib expression forward check with policy based routing"
exit 0
--
2.30.2
^ permalink raw reply related [flat|nested] 20+ messages in thread
* Re: [PATCH net-next 01/11] netfilter: nf_tables: replace unnecessary use of list_for_each_entry_continue()
2022-04-11 10:27 ` [PATCH net-next 01/11] netfilter: nf_tables: replace unnecessary use of list_for_each_entry_continue() Pablo Neira Ayuso
@ 2022-04-11 10:50 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 20+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-04-11 10:50 UTC (permalink / raw)
To: Pablo Neira Ayuso; +Cc: netfilter-devel, davem, netdev, kuba
Hello:
This series was applied to netdev/net-next.git (master)
by Pablo Neira Ayuso <pablo@netfilter.org>:
On Mon, 11 Apr 2022 12:27:34 +0200 you wrote:
> From: Jakob Koschel <jakobkoschel@gmail.com>
>
> Since there is no way for list_for_each_entry_continue() to start
> interating in the middle of the list they can be replaced with a call
> to list_for_each_entry().
>
> In preparation to limit the scope of the list iterator to the list
> traversal loop, the list iterator variable 'rule' should not be used
> past the loop.
>
> [...]
Here is the summary with links:
- [net-next,01/11] netfilter: nf_tables: replace unnecessary use of list_for_each_entry_continue()
https://git.kernel.org/netdev/net-next/c/10377d42281e
- [net-next,02/11] netfilter: ecache: move to separate structure
https://git.kernel.org/netdev/net-next/c/9027ce0b071a
- [net-next,03/11] netfilter: conntrack: split inner loop of list dumping to own function
https://git.kernel.org/netdev/net-next/c/49001a2e83a8
- [net-next,04/11] netfilter: cttimeout: inc/dec module refcount per object, not per use refcount
https://git.kernel.org/netdev/net-next/c/523895e5b278
- [net-next,05/11] netfilter: nf_log_syslog: Merge MAC header dumpers
https://git.kernel.org/netdev/net-next/c/39ab798fc14d
- [net-next,06/11] netfilter: nf_log_syslog: Don't ignore unknown protocols
https://git.kernel.org/netdev/net-next/c/0c8783806f63
- [net-next,07/11] netfilter: nf_log_syslog: Consolidate entry checks
https://git.kernel.org/netdev/net-next/c/c3e348666713
- [net-next,08/11] netfilter: bitwise: replace hard-coded size with `sizeof` expression
https://git.kernel.org/netdev/net-next/c/c70b921fc1e8
- [net-next,09/11] netfilter: bitwise: improve error goto labels
https://git.kernel.org/netdev/net-next/c/00bd435208e5
- [net-next,10/11] netfilter: nft_fib: reverse path filter for policy-based routing on iif
https://git.kernel.org/netdev/net-next/c/be8be04e5ddb
- [net-next,11/11] selftests: netfilter: add fib expression forward test case
https://git.kernel.org/netdev/net-next/c/0c7b27616fbd
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH net-next 00/11] Netfilter updates for net-next
@ 2022-05-19 22:01 Pablo Neira Ayuso
0 siblings, 0 replies; 20+ messages in thread
From: Pablo Neira Ayuso @ 2022-05-19 22:01 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev, kuba, pabeni
Hi,
The following patchset contains Netfilter updates for net-next, misc
updates and fallout fixes from recent Florian's code rewritting (from
last pull request):
1) Use new flowi4_l3mdev field in ip_route_me_harder(), from Martin Willi.
2) Avoid unnecessary GC with a timestamp in conncount, from William Tu
and Yifeng Sun.
3) Remove TCP conntrack debugging, from Florian Westphal.
4) Fix compilation warning in ctnetlink, from Florian.
5) Add flowtable entry count and limit hw entries toggles, from
Vlad Buslov and Oz Shlomo.
6) Add flowtable in-flight workqueue objects count, also from Vlad and Oz.
7) syzbot warning in nfnetlink bind, from Florian.
8) Refetch conntrack after __nf_conntrack_confirm(), from Florian Westphal.
9) Move struct nf_ct_timeout back at the bottom of the ctnl_time, to
where it before recent update, also from Florian.
10) A few NL_SET_BAD_ATTR() for nf_tables netlink set element commands.
Please, pull these changes from:
git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf-next.git
Thanks.
----------------------------------------------------------------
The following changes since commit 5cf15ce3c8f1ef431dc9fa845c6d1674f630ecd1:
Merge branch 'Renesas-RSZ-V2M-support' (2022-05-16 10:14:27 +0100)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf-next.git HEAD
for you to fetch changes up to eb6fb4d6ecbcfd69dfc36fbedbafc9860aeef1e4:
netfilter: nf_tables: set element extended ACK reporting support (2022-05-19 22:39:50 +0200)
----------------------------------------------------------------
Florian Westphal (4):
netfilter: conntrack: remove pr_debug callsites from tcp tracker
netfilter: nfnetlink: fix warn in nfnetlink_unbind
netfilter: conntrack: re-fetch conntrack after insertion
netfilter: cttimeout: fix slab-out-of-bounds read in cttimeout_net_exit
Martin Willi (1):
netfilter: Use l3mdev flow key when re-routing mangled packets
Pablo Neira Ayuso (1):
netfilter: nf_tables: set element extended ACK reporting support
Stephen Rothwell (1):
netfilter: ctnetlink: fix up for "netfilter: conntrack: remove unconfirmed list"
Vlad Buslov (3):
net/sched: act_ct: set 'net' pointer when creating new nf_flow_table
netfilter: nf_flow_table: count and limit hw offloaded entries
netfilter: nf_flow_table: count pending offload workqueue tasks
William Tu (1):
netfilter: nf_conncount: reduce unnecessary GC
Documentation/networking/nf_conntrack-sysctl.rst | 9 ++
include/net/net_namespace.h | 6 +
include/net/netfilter/nf_conntrack_core.h | 7 +-
include/net/netfilter/nf_conntrack_count.h | 1 +
include/net/netfilter/nf_flow_table.h | 57 +++++++++
include/net/netns/flow_table.h | 14 +++
net/ipv4/netfilter.c | 3 +-
net/ipv6/netfilter.c | 3 +-
net/netfilter/Kconfig | 9 ++
net/netfilter/Makefile | 1 +
net/netfilter/nf_conncount.c | 11 ++
net/netfilter/nf_conntrack_netlink.c | 2 +
net/netfilter/nf_conntrack_proto_tcp.c | 52 +-------
net/netfilter/nf_flow_table_core.c | 89 +++++++++++++-
net/netfilter/nf_flow_table_offload.c | 55 +++++++--
net/netfilter/nf_flow_table_sysctl.c | 148 +++++++++++++++++++++++
net/netfilter/nf_tables_api.c | 12 +-
net/netfilter/nfnetlink.c | 24 +---
net/netfilter/nfnetlink_cttimeout.c | 5 +-
net/sched/act_ct.c | 5 +-
20 files changed, 423 insertions(+), 90 deletions(-)
create mode 100644 include/net/netns/flow_table.h
create mode 100644 net/netfilter/nf_flow_table_sysctl.c
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH net-next 00/11] Netfilter updates for net-next
@ 2024-11-06 23:46 Pablo Neira Ayuso
2024-11-07 0:19 ` Jakub Kicinski
0 siblings, 1 reply; 20+ messages in thread
From: Pablo Neira Ayuso @ 2024-11-06 23:46 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev, kuba, pabeni, edumazet, fw
Hi,
The following series contains Netfilter updates for net-next:
1) Make legacy xtables configs user selectable, from Breno Leitao.
2) Fix a few sparse warnings related to percpu, from Uros Bizjak.
3) Use strscpy_pad, from Justin Stitt.
4) Use nft_trans_elem_alloc() in catchall flush, from Florian Westphal.
5) A series of 7 patches to fix false positive with CONFIG_RCU_LIST=y.
Florian also sees possible issue with 10 while module load/removal
when requesting an expression that is available via module. As for
patch 11, object is being updated so reference on the module already
exists so I don't see any real issue.
Florian says:
"Unfortunately there are many more errors, and not all are false positives.
First patches pass lockdep_commit_lock_is_held() to the rcu list traversal
macro so that those splats are avoided.
The last two patches are real code change as opposed to
'pass the transaction mutex to relax rcu check':
Those two lists are not protected by transaction mutex so could be altered
in parallel.
This targets nf-next because these are long-standing issues."
Please, pull these changes from:
git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf-next.git nf-next-24-11-07
Thanks.
----------------------------------------------------------------
The following changes since commit f66ebf37d69cc700ca884c6a18c2258caf8b151b:
Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net (2024-10-03 10:05:55 -0700)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf-next.git nf-next-24-11-07
for you to fetch changes up to cddc04275f95ca3b18da5c0fb111705ac173af89:
netfilter: nf_tables: must hold rcu read lock while iterating object type list (2024-11-05 22:07:12 +0100)
----------------------------------------------------------------
netfilter pull request 24-11-07
----------------------------------------------------------------
Breno Leitao (1):
netfilter: Make legacy configs user selectable
Florian Westphal (8):
netfilter: nf_tables: prefer nft_trans_elem_alloc helper
netfilter: nf_tables: avoid false-positive lockdep splat on rule deletion
netfilter: nf_tables: avoid false-positive lockdep splats with sets
netfilter: nf_tables: avoid false-positive lockdep splats with flowtables
netfilter: nf_tables: avoid false-positive lockdep splats in set walker
netfilter: nf_tables: avoid false-positive lockdep splats with basechain hook
netfilter: nf_tables: must hold rcu read lock while iterating expression type list
netfilter: nf_tables: must hold rcu read lock while iterating object type list
Justin Stitt (1):
netfilter: nf_tables: replace deprecated strncpy with strscpy_pad
Uros Bizjak (1):
netfilter: nf_tables: Fix percpu address space issues in nf_tables_api.c
include/net/netfilter/nf_tables.h | 3 +-
net/bridge/netfilter/Kconfig | 8 +-
net/bridge/netfilter/nft_meta_bridge.c | 2 +-
net/ipv4/netfilter/Kconfig | 16 +++-
net/ipv6/netfilter/Kconfig | 9 ++-
net/netfilter/nf_tables_api.c | 132 +++++++++++++++++++--------------
net/netfilter/nft_flow_offload.c | 4 +-
net/netfilter/nft_set_bitmap.c | 10 ++-
net/netfilter/nft_set_hash.c | 3 +-
9 files changed, 119 insertions(+), 68 deletions(-)
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH net-next 00/11] Netfilter updates for net-next
2024-11-06 23:46 Pablo Neira Ayuso
@ 2024-11-07 0:19 ` Jakub Kicinski
2024-11-07 7:08 ` Florian Westphal
0 siblings, 1 reply; 20+ messages in thread
From: Jakub Kicinski @ 2024-11-07 0:19 UTC (permalink / raw)
To: Pablo Neira Ayuso, fw; +Cc: netfilter-devel, davem, netdev, pabeni, edumazet
On Thu, 7 Nov 2024 00:46:14 +0100 Pablo Neira Ayuso wrote:
> "Unfortunately there are many more errors, and not all are false positives.
Thanks a lot for jumping on fixing the CONFIG_RCU_LIST=y splats!
To clarify should the selftests be splat-free now or there is more
work required to get there?
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH net-next 00/11] Netfilter updates for net-next
2024-11-07 0:19 ` Jakub Kicinski
@ 2024-11-07 7:08 ` Florian Westphal
2024-11-07 20:48 ` Jakub Kicinski
0 siblings, 1 reply; 20+ messages in thread
From: Florian Westphal @ 2024-11-07 7:08 UTC (permalink / raw)
To: Jakub Kicinski
Cc: Pablo Neira Ayuso, fw, netfilter-devel, davem, netdev, pabeni,
edumazet
Jakub Kicinski <kuba@kernel.org> wrote:
> On Thu, 7 Nov 2024 00:46:14 +0100 Pablo Neira Ayuso wrote:
> > "Unfortunately there are many more errors, and not all are false positives.
>
> Thanks a lot for jumping on fixing the CONFIG_RCU_LIST=y splats!
> To clarify should the selftests be splat-free now or there is more
> work required to get there?
I tried to repro last week on net-next (not nf-next!) + v2 of these patches
and I did not see splats, but I'll re-run everything later today to make
sure they've been fixed up.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH net-next 00/11] Netfilter updates for net-next
2024-11-07 7:08 ` Florian Westphal
@ 2024-11-07 20:48 ` Jakub Kicinski
2024-11-07 21:07 ` Florian Westphal
2024-11-07 21:09 ` Eric Dumazet
0 siblings, 2 replies; 20+ messages in thread
From: Jakub Kicinski @ 2024-11-07 20:48 UTC (permalink / raw)
To: Florian Westphal
Cc: Pablo Neira Ayuso, netfilter-devel, davem, netdev, pabeni,
edumazet
On Thu, 7 Nov 2024 08:08:34 +0100 Florian Westphal wrote:
> Jakub Kicinski <kuba@kernel.org> wrote:
> > On Thu, 7 Nov 2024 00:46:14 +0100 Pablo Neira Ayuso wrote:
> > > "Unfortunately there are many more errors, and not all are false positives.
> >
> > Thanks a lot for jumping on fixing the CONFIG_RCU_LIST=y splats!
> > To clarify should the selftests be splat-free now or there is more
> > work required to get there?
>
> I tried to repro last week on net-next (not nf-next!) + v2 of these patches
> and I did not see splats, but I'll re-run everything later today to make
> sure they've been fixed up.
Great! I was double checking if you know of any selftest-triggered
problems before I re-enable that config in our CI.
I flipped it back on few hours ago and looks like it's only hitting
mcast routing and sctp bugs we already know about, so all good :)
Thanks again!
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH net-next 00/11] Netfilter updates for net-next
2024-11-07 20:48 ` Jakub Kicinski
@ 2024-11-07 21:07 ` Florian Westphal
2024-11-07 21:09 ` Eric Dumazet
1 sibling, 0 replies; 20+ messages in thread
From: Florian Westphal @ 2024-11-07 21:07 UTC (permalink / raw)
To: Jakub Kicinski
Cc: Florian Westphal, Pablo Neira Ayuso, netfilter-devel, davem,
netdev, pabeni, edumazet
Jakub Kicinski <kuba@kernel.org> wrote:
> > I tried to repro last week on net-next (not nf-next!) + v2 of these patches
> > and I did not see splats, but I'll re-run everything later today to make
> > sure they've been fixed up.
>
> Great! I was double checking if you know of any selftest-triggered
> problems before I re-enable that config in our CI.
The only splat I saw today on re-run is in kernel/events/core.c, but
Matthieu Baerts tells me there is a fix pending for it.
> I flipped it back on few hours ago and looks like it's only hitting
> mcast routing and sctp bugs we already know about, so all good :)
Great. It finds real bugs so its good that it can be turned on again
to catch future issues.
^ permalink raw reply [flat|nested] 20+ messages in thread
* Re: [PATCH net-next 00/11] Netfilter updates for net-next
2024-11-07 20:48 ` Jakub Kicinski
2024-11-07 21:07 ` Florian Westphal
@ 2024-11-07 21:09 ` Eric Dumazet
1 sibling, 0 replies; 20+ messages in thread
From: Eric Dumazet @ 2024-11-07 21:09 UTC (permalink / raw)
To: Jakub Kicinski
Cc: Florian Westphal, Pablo Neira Ayuso, netfilter-devel, davem,
netdev, pabeni
On Thu, Nov 7, 2024 at 9:48 PM Jakub Kicinski <kuba@kernel.org> wrote:
>
> On Thu, 7 Nov 2024 08:08:34 +0100 Florian Westphal wrote:
> > Jakub Kicinski <kuba@kernel.org> wrote:
> > > On Thu, 7 Nov 2024 00:46:14 +0100 Pablo Neira Ayuso wrote:
> > > > "Unfortunately there are many more errors, and not all are false positives.
> > >
> > > Thanks a lot for jumping on fixing the CONFIG_RCU_LIST=y splats!
> > > To clarify should the selftests be splat-free now or there is more
> > > work required to get there?
> >
> > I tried to repro last week on net-next (not nf-next!) + v2 of these patches
> > and I did not see splats, but I'll re-run everything later today to make
> > sure they've been fixed up.
>
> Great! I was double checking if you know of any selftest-triggered
> problems before I re-enable that config in our CI.
>
> I flipped it back on few hours ago and looks like it's only hitting
> mcast routing and sctp bugs we already know about, so all good :)
>
sctp fix :
https://patchwork.kernel.org/project/netdevbpf/patch/20241107192021.2579789-1-edumazet@google.com/
^ permalink raw reply [flat|nested] 20+ messages in thread
end of thread, other threads:[~2024-11-07 21:09 UTC | newest]
Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-04-11 10:27 [PATCH net-next 00/11] Netfilter updates for net-next Pablo Neira Ayuso
2022-04-11 10:27 ` [PATCH net-next 01/11] netfilter: nf_tables: replace unnecessary use of list_for_each_entry_continue() Pablo Neira Ayuso
2022-04-11 10:50 ` patchwork-bot+netdevbpf
2022-04-11 10:27 ` [PATCH net-next 02/11] netfilter: ecache: move to separate structure Pablo Neira Ayuso
2022-04-11 10:27 ` [PATCH net-next 03/11] netfilter: conntrack: split inner loop of list dumping to own function Pablo Neira Ayuso
2022-04-11 10:27 ` [PATCH net-next 04/11] netfilter: cttimeout: inc/dec module refcount per object, not per use refcount Pablo Neira Ayuso
2022-04-11 10:27 ` [PATCH net-next 05/11] netfilter: nf_log_syslog: Merge MAC header dumpers Pablo Neira Ayuso
2022-04-11 10:27 ` [PATCH net-next 06/11] netfilter: nf_log_syslog: Don't ignore unknown protocols Pablo Neira Ayuso
2022-04-11 10:27 ` [PATCH net-next 07/11] netfilter: nf_log_syslog: Consolidate entry checks Pablo Neira Ayuso
2022-04-11 10:27 ` [PATCH net-next 08/11] netfilter: bitwise: replace hard-coded size with `sizeof` expression Pablo Neira Ayuso
2022-04-11 10:27 ` [PATCH net-next 09/11] netfilter: bitwise: improve error goto labels Pablo Neira Ayuso
2022-04-11 10:27 ` [PATCH net-next 10/11] netfilter: nft_fib: reverse path filter for policy-based routing on iif Pablo Neira Ayuso
2022-04-11 10:27 ` [PATCH net-next 11/11] selftests: netfilter: add fib expression forward test case Pablo Neira Ayuso
-- strict thread matches above, loose matches on Subject: below --
2022-05-19 22:01 [PATCH net-next 00/11] Netfilter updates for net-next Pablo Neira Ayuso
2024-11-06 23:46 Pablo Neira Ayuso
2024-11-07 0:19 ` Jakub Kicinski
2024-11-07 7:08 ` Florian Westphal
2024-11-07 20:48 ` Jakub Kicinski
2024-11-07 21:07 ` Florian Westphal
2024-11-07 21:09 ` Eric Dumazet
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).