* [PATCH nf-next 0/6] Netfilter updates for net-next
@ 2022-03-15 9:15 Pablo Neira Ayuso
2022-03-15 9:15 ` [PATCH nf-next 1/6] Revert "netfilter: conntrack: mark UDP zero checksum as CHECKSUM_UNNECESSARY" Pablo Neira Ayuso
` (5 more replies)
0 siblings, 6 replies; 14+ messages in thread
From: Pablo Neira Ayuso @ 2022-03-15 9:15 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev, kuba
Hi,
The following patchset contains Netfilter updates for net-next:
1) Revert CHECKSUM_UNNECESSARY for UDP packet from conntrack.
2) Reject unsupported families when creating tables, from Phil Sutter.
3) GRE support for the flowtable, from Toshiaki Makita.
4) Add GRE offload support for act_ct, also from Toshiaki.
5) Update mlx5 driver to support for GRE flowtable offload,
from Toshiaki Makita.
6) Oneliner to clean up incorrect indentation in nf_conntrack_bridge,
from Jiapeng Chong.
Please, pull these changes from:
git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf-next.git
Special request of mine: Would it be possible to merge net into net-next?
Many thanks
----------------------------------------------------------------
The following changes since commit ef132dc40a28e07ba10b707b505781ffca46b97f:
Merge branch 'nfc-llcp-cleanups' (2022-03-03 10:43:37 +0000)
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 334ff12284fc56bdc5af6d310c6381d96906f5a0:
netfilter: bridge: clean up some inconsistent indenting (2022-03-07 12:42:37 +0100)
----------------------------------------------------------------
Florian Westphal (1):
Revert "netfilter: conntrack: mark UDP zero checksum as CHECKSUM_UNNECESSARY"
Jiapeng Chong (1):
netfilter: bridge: clean up some inconsistent indenting
Phil Sutter (1):
netfilter: nf_tables: Reject tables of unsupported family
Toshiaki Makita (3):
netfilter: flowtable: Support GRE
act_ct: Support GRE offload
net/mlx5: Support GRE conntrack offload
drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c | 21 ++--
net/bridge/netfilter/nf_conntrack_bridge.c | 2 +-
net/netfilter/nf_conntrack_proto_udp.c | 4 +-
net/netfilter/nf_flow_table_core.c | 10 +-
net/netfilter/nf_flow_table_ip.c | 62 +++++++++--
net/netfilter/nf_flow_table_offload.c | 22 ++--
net/netfilter/nf_tables_api.c | 27 +++++
net/netfilter/nft_flow_offload.c | 13 +++
net/sched/act_ct.c | 115 ++++++++++++++++-----
9 files changed, 223 insertions(+), 53 deletions(-)
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH nf-next 1/6] Revert "netfilter: conntrack: mark UDP zero checksum as CHECKSUM_UNNECESSARY"
2022-03-15 9:15 [PATCH nf-next 0/6] Netfilter updates for net-next Pablo Neira Ayuso
@ 2022-03-15 9:15 ` Pablo Neira Ayuso
2022-03-15 19:00 ` patchwork-bot+netdevbpf
2022-03-15 9:15 ` [PATCH nf-next 2/6] netfilter: nf_tables: Reject tables of unsupported family Pablo Neira Ayuso
` (4 subsequent siblings)
5 siblings, 1 reply; 14+ messages in thread
From: Pablo Neira Ayuso @ 2022-03-15 9:15 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev, kuba
From: Florian Westphal <fw@strlen.de>
This reverts commit 5bed9f3f63f8f9d2b1758c24640cbf77b5377511.
Gal Presman says:
this patch broke geneve tunnels, or possibly all udp tunnels?
A simple test that creates two geneve tunnels and runs tcp iperf fails
and results in checksum errors (TcpInCsumErrors).
Original commit wanted to fix nf_reject with zero checksum,
so it appears better to change nf reject infra instead.
Fixes: 5bed9f3f63f8f ("netfilter: conntrack: mark UDP zero checksum as CHECKSUM_UNNECESSARY")
Reported-by: Gal Pressman <gal@nvidia.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nf_conntrack_proto_udp.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/net/netfilter/nf_conntrack_proto_udp.c b/net/netfilter/nf_conntrack_proto_udp.c
index 12f793d8fe0c..3b516cffc779 100644
--- a/net/netfilter/nf_conntrack_proto_udp.c
+++ b/net/netfilter/nf_conntrack_proto_udp.c
@@ -63,10 +63,8 @@ static bool udp_error(struct sk_buff *skb,
}
/* Packet with no checksum */
- if (!hdr->check) {
- skb->ip_summed = CHECKSUM_UNNECESSARY;
+ if (!hdr->check)
return false;
- }
/* Checksum invalid? Ignore.
* We skip checking packets on the outgoing path
--
2.30.2
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH nf-next 2/6] netfilter: nf_tables: Reject tables of unsupported family
2022-03-15 9:15 [PATCH nf-next 0/6] Netfilter updates for net-next Pablo Neira Ayuso
2022-03-15 9:15 ` [PATCH nf-next 1/6] Revert "netfilter: conntrack: mark UDP zero checksum as CHECKSUM_UNNECESSARY" Pablo Neira Ayuso
@ 2022-03-15 9:15 ` Pablo Neira Ayuso
2022-03-15 18:56 ` Jakub Kicinski
2022-03-15 9:15 ` [PATCH nf-next 3/6] netfilter: flowtable: Support GRE Pablo Neira Ayuso
` (3 subsequent siblings)
5 siblings, 1 reply; 14+ messages in thread
From: Pablo Neira Ayuso @ 2022-03-15 9:15 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev, kuba
From: Phil Sutter <phil@nwl.cc>
An nftables family is merely a hollow container, its family just a
number and such not reliant on compile-time options other than nftables
support itself. Add an artificial check so attempts at using a family
the kernel can't support fail as early as possible. This helps user
space detect kernels which lack e.g. NFPROTO_INET.
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nf_tables_api.c | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 9cd1d7a62804..3168ad8cffd1 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -1072,6 +1072,30 @@ static int nft_objname_hash_cmp(struct rhashtable_compare_arg *arg,
return strcmp(obj->key.name, k->name);
}
+static bool nft_supported_family(u8 family)
+{
+ return false
+#ifdef CONFIG_NF_TABLES_INET
+ || family == NFPROTO_INET
+#endif
+#ifdef CONFIG_NF_TABLES_IPV4
+ || family == NFPROTO_IPV4
+#endif
+#ifdef CONFIG_NF_TABLES_ARP
+ || family == NFPROTO_ARP
+#endif
+#ifdef CONFIG_NF_TABLES_NETDEV
+ || family == NFPROTO_NETDEV
+#endif
+#if IS_ENABLED(CONFIG_NF_TABLES_BRIDGE)
+ || family == NFPROTO_BRIDGE
+#endif
+#ifdef CONFIG_NF_TABLES_IPV6
+ || family == NFPROTO_IPV6
+#endif
+ ;
+}
+
static int nf_tables_newtable(struct sk_buff *skb, const struct nfnl_info *info,
const struct nlattr * const nla[])
{
@@ -1086,6 +1110,9 @@ static int nf_tables_newtable(struct sk_buff *skb, const struct nfnl_info *info,
u32 flags = 0;
int err;
+ if (!nft_supported_family(family))
+ return -EOPNOTSUPP;
+
lockdep_assert_held(&nft_net->commit_mutex);
attr = nla[NFTA_TABLE_NAME];
table = nft_table_lookup(net, attr, family, genmask,
--
2.30.2
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH nf-next 3/6] netfilter: flowtable: Support GRE
2022-03-15 9:15 [PATCH nf-next 0/6] Netfilter updates for net-next Pablo Neira Ayuso
2022-03-15 9:15 ` [PATCH nf-next 1/6] Revert "netfilter: conntrack: mark UDP zero checksum as CHECKSUM_UNNECESSARY" Pablo Neira Ayuso
2022-03-15 9:15 ` [PATCH nf-next 2/6] netfilter: nf_tables: Reject tables of unsupported family Pablo Neira Ayuso
@ 2022-03-15 9:15 ` Pablo Neira Ayuso
2022-03-15 9:15 ` [PATCH nf-next 4/6] act_ct: Support GRE offload Pablo Neira Ayuso
` (2 subsequent siblings)
5 siblings, 0 replies; 14+ messages in thread
From: Pablo Neira Ayuso @ 2022-03-15 9:15 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev, kuba
From: Toshiaki Makita <toshiaki.makita1@gmail.com>
Support GREv0 without NAT.
Signed-off-by: Toshiaki Makita <toshiaki.makita1@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/nf_flow_table_core.c | 10 ++++-
net/netfilter/nf_flow_table_ip.c | 62 ++++++++++++++++++++++-----
net/netfilter/nf_flow_table_offload.c | 22 +++++++---
net/netfilter/nft_flow_offload.c | 13 ++++++
4 files changed, 88 insertions(+), 19 deletions(-)
diff --git a/net/netfilter/nf_flow_table_core.c b/net/netfilter/nf_flow_table_core.c
index b90eca7a2f22..e66a375075c9 100644
--- a/net/netfilter/nf_flow_table_core.c
+++ b/net/netfilter/nf_flow_table_core.c
@@ -39,8 +39,14 @@ flow_offload_fill_dir(struct flow_offload *flow,
ft->l3proto = ctt->src.l3num;
ft->l4proto = ctt->dst.protonum;
- ft->src_port = ctt->src.u.tcp.port;
- ft->dst_port = ctt->dst.u.tcp.port;
+
+ switch (ctt->dst.protonum) {
+ case IPPROTO_TCP:
+ case IPPROTO_UDP:
+ ft->src_port = ctt->src.u.tcp.port;
+ ft->dst_port = ctt->dst.u.tcp.port;
+ break;
+ }
}
struct flow_offload *flow_offload_alloc(struct nf_conn *ct)
diff --git a/net/netfilter/nf_flow_table_ip.c b/net/netfilter/nf_flow_table_ip.c
index 889cf88d3dba..6e9cacf694de 100644
--- a/net/netfilter/nf_flow_table_ip.c
+++ b/net/netfilter/nf_flow_table_ip.c
@@ -172,6 +172,7 @@ static int nf_flow_tuple_ip(struct sk_buff *skb, const struct net_device *dev,
struct flow_ports *ports;
unsigned int thoff;
struct iphdr *iph;
+ u8 ipproto;
if (!pskb_may_pull(skb, sizeof(*iph) + offset))
return -1;
@@ -185,13 +186,19 @@ static int nf_flow_tuple_ip(struct sk_buff *skb, const struct net_device *dev,
thoff += offset;
- switch (iph->protocol) {
+ ipproto = iph->protocol;
+ switch (ipproto) {
case IPPROTO_TCP:
*hdrsize = sizeof(struct tcphdr);
break;
case IPPROTO_UDP:
*hdrsize = sizeof(struct udphdr);
break;
+#ifdef CONFIG_NF_CT_PROTO_GRE
+ case IPPROTO_GRE:
+ *hdrsize = sizeof(struct gre_base_hdr);
+ break;
+#endif
default:
return -1;
}
@@ -202,15 +209,29 @@ static int nf_flow_tuple_ip(struct sk_buff *skb, const struct net_device *dev,
if (!pskb_may_pull(skb, thoff + *hdrsize))
return -1;
+ switch (ipproto) {
+ case IPPROTO_TCP:
+ case IPPROTO_UDP:
+ ports = (struct flow_ports *)(skb_network_header(skb) + thoff);
+ tuple->src_port = ports->source;
+ tuple->dst_port = ports->dest;
+ break;
+ case IPPROTO_GRE: {
+ struct gre_base_hdr *greh;
+
+ greh = (struct gre_base_hdr *)(skb_network_header(skb) + thoff);
+ if ((greh->flags & GRE_VERSION) != GRE_VERSION_0)
+ return -1;
+ break;
+ }
+ }
+
iph = (struct iphdr *)(skb_network_header(skb) + offset);
- ports = (struct flow_ports *)(skb_network_header(skb) + thoff);
tuple->src_v4.s_addr = iph->saddr;
tuple->dst_v4.s_addr = iph->daddr;
- tuple->src_port = ports->source;
- tuple->dst_port = ports->dest;
tuple->l3proto = AF_INET;
- tuple->l4proto = iph->protocol;
+ tuple->l4proto = ipproto;
tuple->iifidx = dev->ifindex;
nf_flow_tuple_encap(skb, tuple);
@@ -521,6 +542,7 @@ static int nf_flow_tuple_ipv6(struct sk_buff *skb, const struct net_device *dev,
struct flow_ports *ports;
struct ipv6hdr *ip6h;
unsigned int thoff;
+ u8 nexthdr;
thoff = sizeof(*ip6h) + offset;
if (!pskb_may_pull(skb, thoff))
@@ -528,13 +550,19 @@ static int nf_flow_tuple_ipv6(struct sk_buff *skb, const struct net_device *dev,
ip6h = (struct ipv6hdr *)(skb_network_header(skb) + offset);
- switch (ip6h->nexthdr) {
+ nexthdr = ip6h->nexthdr;
+ switch (nexthdr) {
case IPPROTO_TCP:
*hdrsize = sizeof(struct tcphdr);
break;
case IPPROTO_UDP:
*hdrsize = sizeof(struct udphdr);
break;
+#ifdef CONFIG_NF_CT_PROTO_GRE
+ case IPPROTO_GRE:
+ *hdrsize = sizeof(struct gre_base_hdr);
+ break;
+#endif
default:
return -1;
}
@@ -545,15 +573,29 @@ static int nf_flow_tuple_ipv6(struct sk_buff *skb, const struct net_device *dev,
if (!pskb_may_pull(skb, thoff + *hdrsize))
return -1;
+ switch (nexthdr) {
+ case IPPROTO_TCP:
+ case IPPROTO_UDP:
+ ports = (struct flow_ports *)(skb_network_header(skb) + thoff);
+ tuple->src_port = ports->source;
+ tuple->dst_port = ports->dest;
+ break;
+ case IPPROTO_GRE: {
+ struct gre_base_hdr *greh;
+
+ greh = (struct gre_base_hdr *)(skb_network_header(skb) + thoff);
+ if ((greh->flags & GRE_VERSION) != GRE_VERSION_0)
+ return -1;
+ break;
+ }
+ }
+
ip6h = (struct ipv6hdr *)(skb_network_header(skb) + offset);
- ports = (struct flow_ports *)(skb_network_header(skb) + thoff);
tuple->src_v6 = ip6h->saddr;
tuple->dst_v6 = ip6h->daddr;
- tuple->src_port = ports->source;
- tuple->dst_port = ports->dest;
tuple->l3proto = AF_INET6;
- tuple->l4proto = ip6h->nexthdr;
+ tuple->l4proto = nexthdr;
tuple->iifidx = dev->ifindex;
nf_flow_tuple_encap(skb, tuple);
diff --git a/net/netfilter/nf_flow_table_offload.c b/net/netfilter/nf_flow_table_offload.c
index b561e0a44a45..99f6db3757ad 100644
--- a/net/netfilter/nf_flow_table_offload.c
+++ b/net/netfilter/nf_flow_table_offload.c
@@ -170,6 +170,7 @@ static int nf_flow_rule_match(struct nf_flow_match *match,
match->dissector.used_keys |= BIT(FLOW_DISSECTOR_KEY_TCP);
break;
case IPPROTO_UDP:
+ case IPPROTO_GRE:
break;
default:
return -EOPNOTSUPP;
@@ -178,15 +179,22 @@ static int nf_flow_rule_match(struct nf_flow_match *match,
key->basic.ip_proto = tuple->l4proto;
mask->basic.ip_proto = 0xff;
- key->tp.src = tuple->src_port;
- mask->tp.src = 0xffff;
- key->tp.dst = tuple->dst_port;
- mask->tp.dst = 0xffff;
-
match->dissector.used_keys |= BIT(FLOW_DISSECTOR_KEY_META) |
BIT(FLOW_DISSECTOR_KEY_CONTROL) |
- BIT(FLOW_DISSECTOR_KEY_BASIC) |
- BIT(FLOW_DISSECTOR_KEY_PORTS);
+ BIT(FLOW_DISSECTOR_KEY_BASIC);
+
+ switch (tuple->l4proto) {
+ case IPPROTO_TCP:
+ case IPPROTO_UDP:
+ key->tp.src = tuple->src_port;
+ mask->tp.src = 0xffff;
+ key->tp.dst = tuple->dst_port;
+ mask->tp.dst = 0xffff;
+
+ match->dissector.used_keys |= BIT(FLOW_DISSECTOR_KEY_PORTS);
+ break;
+ }
+
return 0;
}
diff --git a/net/netfilter/nft_flow_offload.c b/net/netfilter/nft_flow_offload.c
index 0af34ad41479..731b5d87ef45 100644
--- a/net/netfilter/nft_flow_offload.c
+++ b/net/netfilter/nft_flow_offload.c
@@ -298,6 +298,19 @@ static void nft_flow_offload_eval(const struct nft_expr *expr,
break;
case IPPROTO_UDP:
break;
+#ifdef CONFIG_NF_CT_PROTO_GRE
+ case IPPROTO_GRE: {
+ struct nf_conntrack_tuple *tuple;
+
+ if (ct->status & IPS_NAT_MASK)
+ goto out;
+ tuple = &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple;
+ /* No support for GRE v1 */
+ if (tuple->src.u.gre.key || tuple->dst.u.gre.key)
+ goto out;
+ break;
+ }
+#endif
default:
goto out;
}
--
2.30.2
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH nf-next 4/6] act_ct: Support GRE offload
2022-03-15 9:15 [PATCH nf-next 0/6] Netfilter updates for net-next Pablo Neira Ayuso
` (2 preceding siblings ...)
2022-03-15 9:15 ` [PATCH nf-next 3/6] netfilter: flowtable: Support GRE Pablo Neira Ayuso
@ 2022-03-15 9:15 ` Pablo Neira Ayuso
2022-03-15 9:15 ` [PATCH nf-next 5/6] net/mlx5: Support GRE conntrack offload Pablo Neira Ayuso
2022-03-15 9:15 ` [PATCH nf-next 6/6] netfilter: bridge: clean up some inconsistent indenting Pablo Neira Ayuso
5 siblings, 0 replies; 14+ messages in thread
From: Pablo Neira Ayuso @ 2022-03-15 9:15 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev, kuba
From: Toshiaki Makita <toshiaki.makita1@gmail.com>
Support GREv0 without NAT.
Signed-off-by: Toshiaki Makita <toshiaki.makita1@gmail.com>
Acked-by: Paul Blakey <paulb@nvidia.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/sched/act_ct.c | 115 +++++++++++++++++++++++++++++++++++----------
1 file changed, 91 insertions(+), 24 deletions(-)
diff --git a/net/sched/act_ct.c b/net/sched/act_ct.c
index 5234e8bcc764..bed0b100dd0c 100644
--- a/net/sched/act_ct.c
+++ b/net/sched/act_ct.c
@@ -415,6 +415,19 @@ static void tcf_ct_flow_table_process_conn(struct tcf_ct_flow_table *ct_ft,
break;
case IPPROTO_UDP:
break;
+#ifdef CONFIG_NF_CT_PROTO_GRE
+ case IPPROTO_GRE: {
+ struct nf_conntrack_tuple *tuple;
+
+ if (ct->status & IPS_NAT_MASK)
+ return;
+ tuple = &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple;
+ /* No support for GRE v1 */
+ if (tuple->src.u.gre.key || tuple->dst.u.gre.key)
+ return;
+ break;
+ }
+#endif
default:
return;
}
@@ -434,6 +447,8 @@ tcf_ct_flow_table_fill_tuple_ipv4(struct sk_buff *skb,
struct flow_ports *ports;
unsigned int thoff;
struct iphdr *iph;
+ size_t hdrsize;
+ u8 ipproto;
if (!pskb_network_may_pull(skb, sizeof(*iph)))
return false;
@@ -445,29 +460,54 @@ tcf_ct_flow_table_fill_tuple_ipv4(struct sk_buff *skb,
unlikely(thoff != sizeof(struct iphdr)))
return false;
- if (iph->protocol != IPPROTO_TCP &&
- iph->protocol != IPPROTO_UDP)
+ ipproto = iph->protocol;
+ switch (ipproto) {
+ case IPPROTO_TCP:
+ hdrsize = sizeof(struct tcphdr);
+ break;
+ case IPPROTO_UDP:
+ hdrsize = sizeof(*ports);
+ break;
+#ifdef CONFIG_NF_CT_PROTO_GRE
+ case IPPROTO_GRE:
+ hdrsize = sizeof(struct gre_base_hdr);
+ break;
+#endif
+ default:
return false;
+ }
if (iph->ttl <= 1)
return false;
- if (!pskb_network_may_pull(skb, iph->protocol == IPPROTO_TCP ?
- thoff + sizeof(struct tcphdr) :
- thoff + sizeof(*ports)))
+ if (!pskb_network_may_pull(skb, thoff + hdrsize))
return false;
- iph = ip_hdr(skb);
- if (iph->protocol == IPPROTO_TCP)
+ switch (ipproto) {
+ case IPPROTO_TCP:
*tcph = (void *)(skb_network_header(skb) + thoff);
+ fallthrough;
+ case IPPROTO_UDP:
+ ports = (struct flow_ports *)(skb_network_header(skb) + thoff);
+ tuple->src_port = ports->source;
+ tuple->dst_port = ports->dest;
+ break;
+ case IPPROTO_GRE: {
+ struct gre_base_hdr *greh;
+
+ greh = (struct gre_base_hdr *)(skb_network_header(skb) + thoff);
+ if ((greh->flags & GRE_VERSION) != GRE_VERSION_0)
+ return false;
+ break;
+ }
+ }
+
+ iph = ip_hdr(skb);
- ports = (struct flow_ports *)(skb_network_header(skb) + thoff);
tuple->src_v4.s_addr = iph->saddr;
tuple->dst_v4.s_addr = iph->daddr;
- tuple->src_port = ports->source;
- tuple->dst_port = ports->dest;
tuple->l3proto = AF_INET;
- tuple->l4proto = iph->protocol;
+ tuple->l4proto = ipproto;
return true;
}
@@ -480,36 +520,63 @@ tcf_ct_flow_table_fill_tuple_ipv6(struct sk_buff *skb,
struct flow_ports *ports;
struct ipv6hdr *ip6h;
unsigned int thoff;
+ size_t hdrsize;
+ u8 nexthdr;
if (!pskb_network_may_pull(skb, sizeof(*ip6h)))
return false;
ip6h = ipv6_hdr(skb);
+ thoff = sizeof(*ip6h);
- if (ip6h->nexthdr != IPPROTO_TCP &&
- ip6h->nexthdr != IPPROTO_UDP)
- return false;
+ nexthdr = ip6h->nexthdr;
+ switch (nexthdr) {
+ case IPPROTO_TCP:
+ hdrsize = sizeof(struct tcphdr);
+ break;
+ case IPPROTO_UDP:
+ hdrsize = sizeof(*ports);
+ break;
+#ifdef CONFIG_NF_CT_PROTO_GRE
+ case IPPROTO_GRE:
+ hdrsize = sizeof(struct gre_base_hdr);
+ break;
+#endif
+ default:
+ return -1;
+ }
if (ip6h->hop_limit <= 1)
return false;
- thoff = sizeof(*ip6h);
- if (!pskb_network_may_pull(skb, ip6h->nexthdr == IPPROTO_TCP ?
- thoff + sizeof(struct tcphdr) :
- thoff + sizeof(*ports)))
+ if (!pskb_network_may_pull(skb, thoff + hdrsize))
return false;
- ip6h = ipv6_hdr(skb);
- if (ip6h->nexthdr == IPPROTO_TCP)
+ switch (nexthdr) {
+ case IPPROTO_TCP:
*tcph = (void *)(skb_network_header(skb) + thoff);
+ fallthrough;
+ case IPPROTO_UDP:
+ ports = (struct flow_ports *)(skb_network_header(skb) + thoff);
+ tuple->src_port = ports->source;
+ tuple->dst_port = ports->dest;
+ break;
+ case IPPROTO_GRE: {
+ struct gre_base_hdr *greh;
+
+ greh = (struct gre_base_hdr *)(skb_network_header(skb) + thoff);
+ if ((greh->flags & GRE_VERSION) != GRE_VERSION_0)
+ return false;
+ break;
+ }
+ }
+
+ ip6h = ipv6_hdr(skb);
- ports = (struct flow_ports *)(skb_network_header(skb) + thoff);
tuple->src_v6 = ip6h->saddr;
tuple->dst_v6 = ip6h->daddr;
- tuple->src_port = ports->source;
- tuple->dst_port = ports->dest;
tuple->l3proto = AF_INET6;
- tuple->l4proto = ip6h->nexthdr;
+ tuple->l4proto = nexthdr;
return true;
}
--
2.30.2
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH nf-next 5/6] net/mlx5: Support GRE conntrack offload
2022-03-15 9:15 [PATCH nf-next 0/6] Netfilter updates for net-next Pablo Neira Ayuso
` (3 preceding siblings ...)
2022-03-15 9:15 ` [PATCH nf-next 4/6] act_ct: Support GRE offload Pablo Neira Ayuso
@ 2022-03-15 9:15 ` Pablo Neira Ayuso
2022-03-15 9:15 ` [PATCH nf-next 6/6] netfilter: bridge: clean up some inconsistent indenting Pablo Neira Ayuso
5 siblings, 0 replies; 14+ messages in thread
From: Pablo Neira Ayuso @ 2022-03-15 9:15 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev, kuba
From: Toshiaki Makita <toshiaki.makita1@gmail.com>
Support GREv0 without NAT.
Signed-off-by: Toshiaki Makita <toshiaki.makita1@gmail.com>
Acked-by: Paul Blakey <paulb@nvidia.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
.../ethernet/mellanox/mlx5/core/en/tc_ct.c | 21 +++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c
index 875e77af0ae6..675bd6ede845 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c
@@ -258,7 +258,8 @@ mlx5_tc_ct_rule_to_tuple(struct mlx5_ct_tuple *tuple, struct flow_rule *rule)
return -EOPNOTSUPP;
}
} else {
- return -EOPNOTSUPP;
+ if (tuple->ip_proto != IPPROTO_GRE)
+ return -EOPNOTSUPP;
}
return 0;
@@ -807,7 +808,11 @@ mlx5_tc_ct_entry_add_rule(struct mlx5_tc_ct_priv *ct_priv,
attr->dest_chain = 0;
attr->dest_ft = mlx5e_tc_post_act_get_ft(ct_priv->post_act);
attr->ft = nat ? ct_priv->ct_nat : ct_priv->ct;
- attr->outer_match_level = MLX5_MATCH_L4;
+ if (entry->tuple.ip_proto == IPPROTO_TCP ||
+ entry->tuple.ip_proto == IPPROTO_UDP)
+ attr->outer_match_level = MLX5_MATCH_L4;
+ else
+ attr->outer_match_level = MLX5_MATCH_L3;
attr->counter = entry->counter->counter;
attr->flags |= MLX5_ATTR_FLAG_NO_IN_PORT;
if (ct_priv->ns_type == MLX5_FLOW_NAMESPACE_FDB)
@@ -1224,16 +1229,20 @@ mlx5_tc_ct_skb_to_tuple(struct sk_buff *skb, struct mlx5_ct_tuple *tuple,
struct flow_keys flow_keys;
skb_reset_network_header(skb);
- skb_flow_dissect_flow_keys(skb, &flow_keys, 0);
+ skb_flow_dissect_flow_keys(skb, &flow_keys, FLOW_DISSECTOR_F_STOP_BEFORE_ENCAP);
tuple->zone = zone;
if (flow_keys.basic.ip_proto != IPPROTO_TCP &&
- flow_keys.basic.ip_proto != IPPROTO_UDP)
+ flow_keys.basic.ip_proto != IPPROTO_UDP &&
+ flow_keys.basic.ip_proto != IPPROTO_GRE)
return false;
- tuple->port.src = flow_keys.ports.src;
- tuple->port.dst = flow_keys.ports.dst;
+ if (flow_keys.basic.ip_proto == IPPROTO_TCP ||
+ flow_keys.basic.ip_proto == IPPROTO_UDP) {
+ tuple->port.src = flow_keys.ports.src;
+ tuple->port.dst = flow_keys.ports.dst;
+ }
tuple->n_proto = flow_keys.basic.n_proto;
tuple->ip_proto = flow_keys.basic.ip_proto;
--
2.30.2
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH nf-next 6/6] netfilter: bridge: clean up some inconsistent indenting
2022-03-15 9:15 [PATCH nf-next 0/6] Netfilter updates for net-next Pablo Neira Ayuso
` (4 preceding siblings ...)
2022-03-15 9:15 ` [PATCH nf-next 5/6] net/mlx5: Support GRE conntrack offload Pablo Neira Ayuso
@ 2022-03-15 9:15 ` Pablo Neira Ayuso
5 siblings, 0 replies; 14+ messages in thread
From: Pablo Neira Ayuso @ 2022-03-15 9:15 UTC (permalink / raw)
To: netfilter-devel; +Cc: davem, netdev, kuba
From: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
Eliminate the follow smatch warning:
net/bridge/netfilter/nf_conntrack_bridge.c:385 nf_ct_bridge_confirm()
warn: inconsistent indenting.
Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Jiapeng Chong <jiapeng.chong@linux.alibaba.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
---
net/bridge/netfilter/nf_conntrack_bridge.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/bridge/netfilter/nf_conntrack_bridge.c b/net/bridge/netfilter/nf_conntrack_bridge.c
index fdbed3158555..4a79d25c6391 100644
--- a/net/bridge/netfilter/nf_conntrack_bridge.c
+++ b/net/bridge/netfilter/nf_conntrack_bridge.c
@@ -380,7 +380,7 @@ static unsigned int nf_ct_bridge_confirm(struct sk_buff *skb)
protoff = skb_network_offset(skb) + ip_hdrlen(skb);
break;
case htons(ETH_P_IPV6): {
- unsigned char pnum = ipv6_hdr(skb)->nexthdr;
+ unsigned char pnum = ipv6_hdr(skb)->nexthdr;
__be16 frag_off;
protoff = ipv6_skip_exthdr(skb, sizeof(struct ipv6hdr), &pnum,
--
2.30.2
^ permalink raw reply related [flat|nested] 14+ messages in thread
* Re: [PATCH nf-next 2/6] netfilter: nf_tables: Reject tables of unsupported family
2022-03-15 9:15 ` [PATCH nf-next 2/6] netfilter: nf_tables: Reject tables of unsupported family Pablo Neira Ayuso
@ 2022-03-15 18:56 ` Jakub Kicinski
2022-03-15 20:05 ` Phil Sutter
2022-03-15 20:27 ` Pablo Neira Ayuso
0 siblings, 2 replies; 14+ messages in thread
From: Jakub Kicinski @ 2022-03-15 18:56 UTC (permalink / raw)
To: Pablo Neira Ayuso, Phil Sutter; +Cc: netfilter-devel, davem, netdev
On Tue, 15 Mar 2022 10:15:09 +0100 Pablo Neira Ayuso wrote:
> + return false
> +#ifdef CONFIG_NF_TABLES_INET
> + || family == NFPROTO_INET
> +#endif
> +#ifdef CONFIG_NF_TABLES_IPV4
> + || family == NFPROTO_IPV4
> +#endif
> +#ifdef CONFIG_NF_TABLES_ARP
> + || family == NFPROTO_ARP
> +#endif
> +#ifdef CONFIG_NF_TABLES_NETDEV
> + || family == NFPROTO_NETDEV
> +#endif
> +#if IS_ENABLED(CONFIG_NF_TABLES_BRIDGE)
is there a reason this one is IS_ENABLED() and everything else is ifdef?
> + || family == NFPROTO_BRIDGE
> +#endif
> +#ifdef CONFIG_NF_TABLES_IPV6
> + || family == NFPROTO_IPV6
> +#endif
> + ;
return (IS_ENABLED(CONFIG_NF_TABLES_INET) && family == NFPROTO_INET)) ||
(IS_ENABLED(CONFIG_NF_TABLES_IPV4) && family == NFPROTO_IPV4)) ||
...
would have also been an option, for future reference.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH nf-next 1/6] Revert "netfilter: conntrack: mark UDP zero checksum as CHECKSUM_UNNECESSARY"
2022-03-15 9:15 ` [PATCH nf-next 1/6] Revert "netfilter: conntrack: mark UDP zero checksum as CHECKSUM_UNNECESSARY" Pablo Neira Ayuso
@ 2022-03-15 19:00 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 14+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-03-15 19:00 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 Florian Westphal <fw@strlen.de>:
On Tue, 15 Mar 2022 10:15:08 +0100 you wrote:
> From: Florian Westphal <fw@strlen.de>
>
> This reverts commit 5bed9f3f63f8f9d2b1758c24640cbf77b5377511.
>
> Gal Presman says:
> this patch broke geneve tunnels, or possibly all udp tunnels?
> A simple test that creates two geneve tunnels and runs tcp iperf fails
> and results in checksum errors (TcpInCsumErrors).
>
> [...]
Here is the summary with links:
- [nf-next,1/6] Revert "netfilter: conntrack: mark UDP zero checksum as CHECKSUM_UNNECESSARY"
https://git.kernel.org/netdev/net-next/c/bbfbf7a5e77e
- [nf-next,2/6] netfilter: nf_tables: Reject tables of unsupported family
https://git.kernel.org/netdev/net-next/c/f1082dd31fe4
- [nf-next,3/6] netfilter: flowtable: Support GRE
https://git.kernel.org/netdev/net-next/c/4e8d9584d154
- [nf-next,4/6] act_ct: Support GRE offload
https://git.kernel.org/netdev/net-next/c/fcb6aa86532c
- [nf-next,5/6] net/mlx5: Support GRE conntrack offload
https://git.kernel.org/netdev/net-next/c/1918ace1382d
- [nf-next,6/6] netfilter: bridge: clean up some inconsistent indenting
https://git.kernel.org/netdev/net-next/c/334ff12284fc
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] 14+ messages in thread
* Re: [PATCH nf-next 2/6] netfilter: nf_tables: Reject tables of unsupported family
2022-03-15 18:56 ` Jakub Kicinski
@ 2022-03-15 20:05 ` Phil Sutter
2022-03-15 20:10 ` Pablo Neira Ayuso
2022-03-15 20:27 ` Pablo Neira Ayuso
1 sibling, 1 reply; 14+ messages in thread
From: Phil Sutter @ 2022-03-15 20:05 UTC (permalink / raw)
To: Jakub Kicinski; +Cc: Pablo Neira Ayuso, netfilter-devel, davem, netdev
Hi Jakub,
On Tue, Mar 15, 2022 at 11:56:44AM -0700, Jakub Kicinski wrote:
> On Tue, 15 Mar 2022 10:15:09 +0100 Pablo Neira Ayuso wrote:
> > + return false
> > +#ifdef CONFIG_NF_TABLES_INET
> > + || family == NFPROTO_INET
> > +#endif
> > +#ifdef CONFIG_NF_TABLES_IPV4
> > + || family == NFPROTO_IPV4
> > +#endif
> > +#ifdef CONFIG_NF_TABLES_ARP
> > + || family == NFPROTO_ARP
> > +#endif
> > +#ifdef CONFIG_NF_TABLES_NETDEV
> > + || family == NFPROTO_NETDEV
> > +#endif
> > +#if IS_ENABLED(CONFIG_NF_TABLES_BRIDGE)
>
> is there a reason this one is IS_ENABLED() and everything else is ifdef?
I based my patch on the existing ifdefs in nft_chain_filter.c where
these config symbols are checked exactly like above. Looking at git
history, the check was changed from a simple ifdef in commit
dfee0e99bcff7 ("netfilter: bridge: make NF_TABLES_BRIDGE tristate").
> > + || family == NFPROTO_BRIDGE
> > +#endif
> > +#ifdef CONFIG_NF_TABLES_IPV6
> > + || family == NFPROTO_IPV6
> > +#endif
> > + ;
>
> return (IS_ENABLED(CONFIG_NF_TABLES_INET) && family == NFPROTO_INET)) ||
> (IS_ENABLED(CONFIG_NF_TABLES_IPV4) && family == NFPROTO_IPV4)) ||
> ...
>
> would have also been an option, for future reference.
Yes, that is indeed much cleaner. I wasn't aware of this possibility
using IS_ENABLED. What do you think, worth a follow-up?
Thanks, Phil
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH nf-next 2/6] netfilter: nf_tables: Reject tables of unsupported family
2022-03-15 20:05 ` Phil Sutter
@ 2022-03-15 20:10 ` Pablo Neira Ayuso
2022-03-15 21:25 ` Jakub Kicinski
0 siblings, 1 reply; 14+ messages in thread
From: Pablo Neira Ayuso @ 2022-03-15 20:10 UTC (permalink / raw)
To: Phil Sutter, Jakub Kicinski, netfilter-devel, davem, netdev
On Tue, Mar 15, 2022 at 09:05:53PM +0100, Phil Sutter wrote:
> Hi Jakub,
>
> On Tue, Mar 15, 2022 at 11:56:44AM -0700, Jakub Kicinski wrote:
> > On Tue, 15 Mar 2022 10:15:09 +0100 Pablo Neira Ayuso wrote:
> > > + return false
> > > +#ifdef CONFIG_NF_TABLES_INET
> > > + || family == NFPROTO_INET
> > > +#endif
> > > +#ifdef CONFIG_NF_TABLES_IPV4
> > > + || family == NFPROTO_IPV4
> > > +#endif
> > > +#ifdef CONFIG_NF_TABLES_ARP
> > > + || family == NFPROTO_ARP
> > > +#endif
> > > +#ifdef CONFIG_NF_TABLES_NETDEV
> > > + || family == NFPROTO_NETDEV
> > > +#endif
> > > +#if IS_ENABLED(CONFIG_NF_TABLES_BRIDGE)
> >
> > is there a reason this one is IS_ENABLED() and everything else is ifdef?
>
> I based my patch on the existing ifdefs in nft_chain_filter.c where
> these config symbols are checked exactly like above. Looking at git
> history, the check was changed from a simple ifdef in commit
> dfee0e99bcff7 ("netfilter: bridge: make NF_TABLES_BRIDGE tristate").
>
> > > + || family == NFPROTO_BRIDGE
> > > +#endif
> > > +#ifdef CONFIG_NF_TABLES_IPV6
> > > + || family == NFPROTO_IPV6
> > > +#endif
> > > + ;
> >
> > return (IS_ENABLED(CONFIG_NF_TABLES_INET) && family == NFPROTO_INET)) ||
> > (IS_ENABLED(CONFIG_NF_TABLES_IPV4) && family == NFPROTO_IPV4)) ||
> > ...
> >
> > would have also been an option, for future reference.
>
> Yes, that is indeed much cleaner. I wasn't aware of this possibility
> using IS_ENABLED. What do you think, worth a follow-up?
CONFIG_NF_TABLES_INET and CONFIG_NF_TABLES_IPV4 are never modules, I
think IS_ENABLED is misleading there to the reader.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH nf-next 2/6] netfilter: nf_tables: Reject tables of unsupported family
2022-03-15 18:56 ` Jakub Kicinski
2022-03-15 20:05 ` Phil Sutter
@ 2022-03-15 20:27 ` Pablo Neira Ayuso
2022-03-15 21:27 ` Jakub Kicinski
1 sibling, 1 reply; 14+ messages in thread
From: Pablo Neira Ayuso @ 2022-03-15 20:27 UTC (permalink / raw)
To: Jakub Kicinski; +Cc: Phil Sutter, netfilter-devel, davem, netdev
On Tue, Mar 15, 2022 at 11:56:44AM -0700, Jakub Kicinski wrote:
> On Tue, 15 Mar 2022 10:15:09 +0100 Pablo Neira Ayuso wrote:
> > + return false
> > +#ifdef CONFIG_NF_TABLES_INET
> > + || family == NFPROTO_INET
> > +#endif
> > +#ifdef CONFIG_NF_TABLES_IPV4
> > + || family == NFPROTO_IPV4
> > +#endif
> > +#ifdef CONFIG_NF_TABLES_ARP
> > + || family == NFPROTO_ARP
> > +#endif
> > +#ifdef CONFIG_NF_TABLES_NETDEV
> > + || family == NFPROTO_NETDEV
> > +#endif
> > +#if IS_ENABLED(CONFIG_NF_TABLES_BRIDGE)
>
> is there a reason this one is IS_ENABLED() and everything else is ifdef?
bridge might be compiled as a module, if the bridge infrastructure
also comes a module as well.
Anything else is either built-in or off.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH nf-next 2/6] netfilter: nf_tables: Reject tables of unsupported family
2022-03-15 20:10 ` Pablo Neira Ayuso
@ 2022-03-15 21:25 ` Jakub Kicinski
0 siblings, 0 replies; 14+ messages in thread
From: Jakub Kicinski @ 2022-03-15 21:25 UTC (permalink / raw)
To: Pablo Neira Ayuso; +Cc: Phil Sutter, netfilter-devel, davem, netdev
On Tue, 15 Mar 2022 21:10:33 +0100 Pablo Neira Ayuso wrote:
> > > return (IS_ENABLED(CONFIG_NF_TABLES_INET) && family == NFPROTO_INET)) ||
> > > (IS_ENABLED(CONFIG_NF_TABLES_IPV4) && family == NFPROTO_IPV4)) ||
> > > ...
> > >
> > > would have also been an option, for future reference.
> >
> > Yes, that is indeed much cleaner. I wasn't aware of this possibility
> > using IS_ENABLED. What do you think, worth a follow-up?
>
> CONFIG_NF_TABLES_INET and CONFIG_NF_TABLES_IPV4 are never modules, I
> think IS_ENABLED is misleading there to the reader.
It's not about being a module, IS_ENABLED() is usable in C code,
no need to use the pre-processor. But your call, obviously.
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH nf-next 2/6] netfilter: nf_tables: Reject tables of unsupported family
2022-03-15 20:27 ` Pablo Neira Ayuso
@ 2022-03-15 21:27 ` Jakub Kicinski
0 siblings, 0 replies; 14+ messages in thread
From: Jakub Kicinski @ 2022-03-15 21:27 UTC (permalink / raw)
To: Pablo Neira Ayuso; +Cc: Phil Sutter, netfilter-devel, davem, netdev
On Tue, 15 Mar 2022 21:27:45 +0100 Pablo Neira Ayuso wrote:
> > is there a reason this one is IS_ENABLED() and everything else is ifdef?
>
> bridge might be compiled as a module, if the bridge infrastructure
> also comes a module as well.
>
> Anything else is either built-in or off.
:o I thought ifdef works for modules, after checking the code
it makes sense, thanks!
^ permalink raw reply [flat|nested] 14+ messages in thread
end of thread, other threads:[~2022-03-15 21:28 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-15 9:15 [PATCH nf-next 0/6] Netfilter updates for net-next Pablo Neira Ayuso
2022-03-15 9:15 ` [PATCH nf-next 1/6] Revert "netfilter: conntrack: mark UDP zero checksum as CHECKSUM_UNNECESSARY" Pablo Neira Ayuso
2022-03-15 19:00 ` patchwork-bot+netdevbpf
2022-03-15 9:15 ` [PATCH nf-next 2/6] netfilter: nf_tables: Reject tables of unsupported family Pablo Neira Ayuso
2022-03-15 18:56 ` Jakub Kicinski
2022-03-15 20:05 ` Phil Sutter
2022-03-15 20:10 ` Pablo Neira Ayuso
2022-03-15 21:25 ` Jakub Kicinski
2022-03-15 20:27 ` Pablo Neira Ayuso
2022-03-15 21:27 ` Jakub Kicinski
2022-03-15 9:15 ` [PATCH nf-next 3/6] netfilter: flowtable: Support GRE Pablo Neira Ayuso
2022-03-15 9:15 ` [PATCH nf-next 4/6] act_ct: Support GRE offload Pablo Neira Ayuso
2022-03-15 9:15 ` [PATCH nf-next 5/6] net/mlx5: Support GRE conntrack offload Pablo Neira Ayuso
2022-03-15 9:15 ` [PATCH nf-next 6/6] netfilter: bridge: clean up some inconsistent indenting Pablo Neira Ayuso
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).