Skip to content

Commit 840a647

Browse files
committed
Merge tag 'nf-next-25-11-28' of git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf-next
Pablo Neira Ayuso says: ==================== Netfilter updates for net-next The following batch contains Netfilter updates for net-next: 0) Add sanity check for maximum encapsulations in bridge vlan, reported by the new AI robot. 1) Move the flowtable path discovery code to its own file, the nft_flow_offload.c mixes the nf_tables evaluation with the path discovery logic, just split this in two for clarity. 2) Consolidate flowtable xmit path by using dev_queue_xmit() and the real device behind the layer 2 vlan/pppoe device. This allows to inline encapsulation. After this update, hw_ifidx can be removed since both ifidx and hw_ifidx now point to the same device. 3) Support for IPIP encapsulation in the flowtable, extend selftest to cover for this new layer 3 offload, from Lorenzo Bianconi. 4) Push down the skb into the conncount API to fix duplicates in the conncount list for packets with non-confirmed conntrack entries, this is due to an optimization introduced in d265929 ("netfilter: nf_conncount: reduce unnecessary GC"). From Fernando Fernandez Mancera. 5) In conncount, disable BH when performing garbage collection to consolidate existing behaviour in the conncount API, also from Fernando. 6) A matching packet with a confirmed conntrack invokes GC if conncount reaches the limit in an attempt to release slots. This allows the existing extensions to be used for real conntrack counting, not just limiting new connections, from Fernando. 7) Support for updating ct count objects in nf_tables, from Fernando. 8) Extend nft_flowtables.sh selftest to send IPv6 TCP traffic, from Lorenzo Bianconi. 9) Fixes for UAPI kernel-doc documentation, from Randy Dunlap. * tag 'nf-next-25-11-28' of git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf-next: netfilter: nf_tables: improve UAPI kernel-doc comments netfilter: ip6t_srh: fix UAPI kernel-doc comments format selftests: netfilter: nft_flowtable.sh: Add the capability to send IPv6 TCP traffic netfilter: nft_connlimit: add support to object update operation netfilter: nft_connlimit: update the count if add was skipped netfilter: nf_conncount: make nf_conncount_gc_list() to disable BH netfilter: nf_conncount: rework API to use sk_buff directly selftests: netfilter: nft_flowtable.sh: Add IPIP flowtable selftest netfilter: flowtable: Add IPIP tx sw acceleration netfilter: flowtable: Add IPIP rx sw acceleration netfilter: flowtable: use tuple address to calculate next hop netfilter: flowtable: remove hw_ifidx netfilter: flowtable: inline pppoe encapsulation in xmit path netfilter: flowtable: inline vlan encapsulation in xmit path netfilter: flowtable: consolidate xmit path netfilter: flowtable: move path discovery infrastructure to its own file netfilter: flowtable: check for maximum number of encapsulations in bridge vlan ==================== Link: https://patch.msgid.link/20251128002345.29378-1-pablo@netfilter.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2 parents 8aa1053 + d3a439e commit 840a647

17 files changed

Lines changed: 980 additions & 459 deletions

File tree

include/linux/netdevice.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -877,6 +877,7 @@ enum net_device_path_type {
877877
DEV_PATH_PPPOE,
878878
DEV_PATH_DSA,
879879
DEV_PATH_MTK_WDMA,
880+
DEV_PATH_TUN,
880881
};
881882

882883
struct net_device_path {
@@ -888,6 +889,18 @@ struct net_device_path {
888889
__be16 proto;
889890
u8 h_dest[ETH_ALEN];
890891
} encap;
892+
struct {
893+
union {
894+
struct in_addr src_v4;
895+
struct in6_addr src_v6;
896+
};
897+
union {
898+
struct in_addr dst_v4;
899+
struct in6_addr dst_v6;
900+
};
901+
902+
u8 l3_proto;
903+
} tun;
891904
struct {
892905
enum {
893906
DEV_PATH_BR_VLAN_KEEP,

include/net/netfilter/nf_conntrack_count.h

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,14 @@ struct nf_conncount_list {
1818
struct nf_conncount_data *nf_conncount_init(struct net *net, unsigned int keylen);
1919
void nf_conncount_destroy(struct net *net, struct nf_conncount_data *data);
2020

21-
unsigned int nf_conncount_count(struct net *net,
22-
struct nf_conncount_data *data,
23-
const u32 *key,
24-
const struct nf_conntrack_tuple *tuple,
25-
const struct nf_conntrack_zone *zone);
26-
27-
int nf_conncount_add(struct net *net, struct nf_conncount_list *list,
28-
const struct nf_conntrack_tuple *tuple,
29-
const struct nf_conntrack_zone *zone);
21+
unsigned int nf_conncount_count_skb(struct net *net,
22+
const struct sk_buff *skb,
23+
u16 l3num,
24+
struct nf_conncount_data *data,
25+
const u32 *key);
26+
27+
int nf_conncount_add_skb(struct net *net, const struct sk_buff *skb,
28+
u16 l3num, struct nf_conncount_list *list);
3029

3130
void nf_conncount_list_init(struct nf_conncount_list *list);
3231

include/net/netfilter/nf_flow_table.h

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,19 @@ enum flow_offload_xmit_type {
107107

108108
#define NF_FLOW_TABLE_ENCAP_MAX 2
109109

110+
struct flow_offload_tunnel {
111+
union {
112+
struct in_addr src_v4;
113+
struct in6_addr src_v6;
114+
};
115+
union {
116+
struct in_addr dst_v4;
117+
struct in6_addr dst_v6;
118+
};
119+
120+
u8 l3_proto;
121+
};
122+
110123
struct flow_offload_tuple {
111124
union {
112125
struct in_addr src_v4;
@@ -130,22 +143,25 @@ struct flow_offload_tuple {
130143
__be16 proto;
131144
} encap[NF_FLOW_TABLE_ENCAP_MAX];
132145

146+
struct flow_offload_tunnel tun;
147+
133148
/* All members above are keys for lookups, see flow_offload_hash(). */
134149
struct { } __hash;
135150

136151
u8 dir:2,
137152
xmit_type:3,
138153
encap_num:2,
154+
tun_num:2,
139155
in_vlan_ingress:2;
140156
u16 mtu;
141157
union {
142158
struct {
143159
struct dst_entry *dst_cache;
160+
u32 ifidx;
144161
u32 dst_cookie;
145162
};
146163
struct {
147164
u32 ifidx;
148-
u32 hw_ifidx;
149165
u8 h_source[ETH_ALEN];
150166
u8 h_dest[ETH_ALEN];
151167
} out;
@@ -206,7 +222,9 @@ struct nf_flow_route {
206222
u16 id;
207223
__be16 proto;
208224
} encap[NF_FLOW_TABLE_ENCAP_MAX];
225+
struct flow_offload_tunnel tun;
209226
u8 num_encaps:2,
227+
num_tuns:2,
210228
ingress_vlans:2;
211229
} in;
212230
struct {
@@ -222,6 +240,12 @@ struct nf_flow_route {
222240
struct flow_offload *flow_offload_alloc(struct nf_conn *ct);
223241
void flow_offload_free(struct flow_offload *flow);
224242

243+
struct nft_flowtable;
244+
struct nft_pktinfo;
245+
int nft_flow_route(const struct nft_pktinfo *pkt, const struct nf_conn *ct,
246+
struct nf_flow_route *route, enum ip_conntrack_dir dir,
247+
struct nft_flowtable *ft);
248+
225249
static inline int
226250
nf_flow_table_offload_add_cb(struct nf_flowtable *flow_table,
227251
flow_setup_cb_t *cb, void *cb_priv)

include/uapi/linux/netfilter/nf_tables.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ enum nft_exthdr_flags {
881881
* enum nft_exthdr_op - nf_tables match options
882882
*
883883
* @NFT_EXTHDR_OP_IPV6: match against ipv6 extension headers
884-
* @NFT_EXTHDR_OP_TCP: match against tcp options
884+
* @NFT_EXTHDR_OP_TCPOPT: match against tcp options
885885
* @NFT_EXTHDR_OP_IPV4: match against ipv4 options
886886
* @NFT_EXTHDR_OP_SCTP: match against sctp chunks
887887
* @NFT_EXTHDR_OP_DCCP: match against dccp otions
@@ -1200,7 +1200,7 @@ enum nft_ct_attributes {
12001200
#define NFTA_CT_MAX (__NFTA_CT_MAX - 1)
12011201

12021202
/**
1203-
* enum nft_flow_attributes - ct offload expression attributes
1203+
* enum nft_offload_attributes - ct offload expression attributes
12041204
* @NFTA_FLOW_TABLE_NAME: flow table name (NLA_STRING)
12051205
*/
12061206
enum nft_offload_attributes {
@@ -1410,7 +1410,7 @@ enum nft_reject_types {
14101410
};
14111411

14121412
/**
1413-
* enum nft_reject_code - Generic reject codes for IPv4/IPv6
1413+
* enum nft_reject_inet_code - Generic reject codes for IPv4/IPv6
14141414
*
14151415
* @NFT_REJECT_ICMPX_NO_ROUTE: no route to host / network unreachable
14161416
* @NFT_REJECT_ICMPX_PORT_UNREACH: port unreachable
@@ -1480,9 +1480,9 @@ enum nft_nat_attributes {
14801480
/**
14811481
* enum nft_tproxy_attributes - nf_tables tproxy expression netlink attributes
14821482
*
1483-
* NFTA_TPROXY_FAMILY: Target address family (NLA_U32: nft_registers)
1484-
* NFTA_TPROXY_REG_ADDR: Target address register (NLA_U32: nft_registers)
1485-
* NFTA_TPROXY_REG_PORT: Target port register (NLA_U32: nft_registers)
1483+
* @NFTA_TPROXY_FAMILY: Target address family (NLA_U32: nft_registers)
1484+
* @NFTA_TPROXY_REG_ADDR: Target address register (NLA_U32: nft_registers)
1485+
* @NFTA_TPROXY_REG_PORT: Target port register (NLA_U32: nft_registers)
14861486
*/
14871487
enum nft_tproxy_attributes {
14881488
NFTA_TPROXY_UNSPEC,
@@ -1783,7 +1783,7 @@ enum nft_synproxy_attributes {
17831783
#define NFTA_SYNPROXY_MAX (__NFTA_SYNPROXY_MAX - 1)
17841784

17851785
/**
1786-
* enum nft_device_attributes - nf_tables device netlink attributes
1786+
* enum nft_devices_attributes - nf_tables device netlink attributes
17871787
*
17881788
* @NFTA_DEVICE_NAME: name of this device (NLA_STRING)
17891789
* @NFTA_DEVICE_PREFIX: device name prefix, a simple wildcard (NLA_STRING)

include/uapi/linux/netfilter_ipv6/ip6t_srh.h

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,13 @@
4141

4242
/**
4343
* struct ip6t_srh - SRH match options
44-
* @ next_hdr: Next header field of SRH
45-
* @ hdr_len: Extension header length field of SRH
46-
* @ segs_left: Segments left field of SRH
47-
* @ last_entry: Last entry field of SRH
48-
* @ tag: Tag field of SRH
49-
* @ mt_flags: match options
50-
* @ mt_invflags: Invert the sense of match options
44+
* @next_hdr: Next header field of SRH
45+
* @hdr_len: Extension header length field of SRH
46+
* @segs_left: Segments left field of SRH
47+
* @last_entry: Last entry field of SRH
48+
* @tag: Tag field of SRH
49+
* @mt_flags: match options
50+
* @mt_invflags: Invert the sense of match options
5151
*/
5252

5353
struct ip6t_srh {
@@ -62,19 +62,19 @@ struct ip6t_srh {
6262

6363
/**
6464
* struct ip6t_srh1 - SRH match options (revision 1)
65-
* @ next_hdr: Next header field of SRH
66-
* @ hdr_len: Extension header length field of SRH
67-
* @ segs_left: Segments left field of SRH
68-
* @ last_entry: Last entry field of SRH
69-
* @ tag: Tag field of SRH
70-
* @ psid_addr: Address of previous SID in SRH SID list
71-
* @ nsid_addr: Address of NEXT SID in SRH SID list
72-
* @ lsid_addr: Address of LAST SID in SRH SID list
73-
* @ psid_msk: Mask of previous SID in SRH SID list
74-
* @ nsid_msk: Mask of next SID in SRH SID list
75-
* @ lsid_msk: MAsk of last SID in SRH SID list
76-
* @ mt_flags: match options
77-
* @ mt_invflags: Invert the sense of match options
65+
* @next_hdr: Next header field of SRH
66+
* @hdr_len: Extension header length field of SRH
67+
* @segs_left: Segments left field of SRH
68+
* @last_entry: Last entry field of SRH
69+
* @tag: Tag field of SRH
70+
* @psid_addr: Address of previous SID in SRH SID list
71+
* @nsid_addr: Address of NEXT SID in SRH SID list
72+
* @lsid_addr: Address of LAST SID in SRH SID list
73+
* @psid_msk: Mask of previous SID in SRH SID list
74+
* @nsid_msk: Mask of next SID in SRH SID list
75+
* @lsid_msk: MAsk of last SID in SRH SID list
76+
* @mt_flags: match options
77+
* @mt_invflags: Invert the sense of match options
7878
*/
7979

8080
struct ip6t_srh1 {

net/ipv4/ipip.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,30 @@ ipip_tunnel_ctl(struct net_device *dev, struct ip_tunnel_parm_kern *p, int cmd)
353353
return ip_tunnel_ctl(dev, p, cmd);
354354
}
355355

356+
static int ipip_fill_forward_path(struct net_device_path_ctx *ctx,
357+
struct net_device_path *path)
358+
{
359+
struct ip_tunnel *tunnel = netdev_priv(ctx->dev);
360+
const struct iphdr *tiph = &tunnel->parms.iph;
361+
struct rtable *rt;
362+
363+
rt = ip_route_output(dev_net(ctx->dev), tiph->daddr, 0, 0, 0,
364+
RT_SCOPE_UNIVERSE);
365+
if (IS_ERR(rt))
366+
return PTR_ERR(rt);
367+
368+
path->type = DEV_PATH_TUN;
369+
path->tun.src_v4.s_addr = tiph->saddr;
370+
path->tun.dst_v4.s_addr = tiph->daddr;
371+
path->tun.l3_proto = IPPROTO_IPIP;
372+
path->dev = ctx->dev;
373+
374+
ctx->dev = rt->dst.dev;
375+
ip_rt_put(rt);
376+
377+
return 0;
378+
}
379+
356380
static const struct net_device_ops ipip_netdev_ops = {
357381
.ndo_init = ipip_tunnel_init,
358382
.ndo_uninit = ip_tunnel_uninit,
@@ -362,6 +386,7 @@ static const struct net_device_ops ipip_netdev_ops = {
362386
.ndo_get_stats64 = dev_get_tstats64,
363387
.ndo_get_iflink = ip_tunnel_get_iflink,
364388
.ndo_tunnel_ctl = ipip_tunnel_ctl,
389+
.ndo_fill_forward_path = ipip_fill_forward_path,
365390
};
366391

367392
#define IPIP_FEATURES (NETIF_F_SG | \

net/netfilter/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ obj-$(CONFIG_NFT_FWD_NETDEV) += nft_fwd_netdev.o
141141
# flow table infrastructure
142142
obj-$(CONFIG_NF_FLOW_TABLE) += nf_flow_table.o
143143
nf_flow_table-objs := nf_flow_table_core.o nf_flow_table_ip.o \
144+
nf_flow_table_path.o \
144145
nf_flow_table_offload.o nf_flow_table_xdp.o
145146
nf_flow_table-$(CONFIG_NF_FLOW_TABLE_PROCFS) += nf_flow_table_procfs.o
146147
ifeq ($(CONFIG_NF_FLOW_TABLE),m)

0 commit comments

Comments
 (0)