Commit 840a6471 authored by Jakub Kicinski's avatar Jakub Kicinski
Browse files
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 d2659299
   ("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: default avatarJakub Kicinski <kuba@kernel.org>
parents 8aa1053f d3a439e5
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -877,6 +877,7 @@ enum net_device_path_type {
	DEV_PATH_PPPOE,
	DEV_PATH_DSA,
	DEV_PATH_MTK_WDMA,
	DEV_PATH_TUN,
};

struct net_device_path {
@@ -888,6 +889,18 @@ struct net_device_path {
			__be16		proto;
			u8		h_dest[ETH_ALEN];
		} encap;
		struct {
			union {
				struct in_addr	src_v4;
				struct in6_addr	src_v6;
			};
			union {
				struct in_addr	dst_v4;
				struct in6_addr	dst_v6;
			};

			u8	l3_proto;
		} tun;
		struct {
			enum {
				DEV_PATH_BR_VLAN_KEEP,
+8 −9
Original line number Diff line number Diff line
@@ -18,15 +18,14 @@ struct nf_conncount_list {
struct nf_conncount_data *nf_conncount_init(struct net *net, unsigned int keylen);
void nf_conncount_destroy(struct net *net, struct nf_conncount_data *data);

unsigned int nf_conncount_count(struct net *net,
unsigned int nf_conncount_count_skb(struct net *net,
				    const struct sk_buff *skb,
				    u16 l3num,
				    struct nf_conncount_data *data,
				const u32 *key,
				const struct nf_conntrack_tuple *tuple,
				const struct nf_conntrack_zone *zone);
				    const u32 *key);

int nf_conncount_add(struct net *net, struct nf_conncount_list *list,
		     const struct nf_conntrack_tuple *tuple,
		     const struct nf_conntrack_zone *zone);
int nf_conncount_add_skb(struct net *net, const struct sk_buff *skb,
			 u16 l3num, struct nf_conncount_list *list);

void nf_conncount_list_init(struct nf_conncount_list *list);

+25 −1
Original line number Diff line number Diff line
@@ -107,6 +107,19 @@ enum flow_offload_xmit_type {

#define NF_FLOW_TABLE_ENCAP_MAX		2

struct flow_offload_tunnel {
	union {
		struct in_addr	src_v4;
		struct in6_addr	src_v6;
	};
	union {
		struct in_addr	dst_v4;
		struct in6_addr	dst_v6;
	};

	u8	l3_proto;
};

struct flow_offload_tuple {
	union {
		struct in_addr		src_v4;
@@ -130,22 +143,25 @@ struct flow_offload_tuple {
		__be16			proto;
	} encap[NF_FLOW_TABLE_ENCAP_MAX];

	struct flow_offload_tunnel	tun;

	/* All members above are keys for lookups, see flow_offload_hash(). */
	struct { }			__hash;

	u8				dir:2,
					xmit_type:3,
					encap_num:2,
					tun_num:2,
					in_vlan_ingress:2;
	u16				mtu;
	union {
		struct {
			struct dst_entry *dst_cache;
			u32		ifidx;
			u32		dst_cookie;
		};
		struct {
			u32		ifidx;
			u32		hw_ifidx;
			u8		h_source[ETH_ALEN];
			u8		h_dest[ETH_ALEN];
		} out;
@@ -206,7 +222,9 @@ struct nf_flow_route {
				u16		id;
				__be16		proto;
			} encap[NF_FLOW_TABLE_ENCAP_MAX];
			struct flow_offload_tunnel tun;
			u8			num_encaps:2,
						num_tuns:2,
						ingress_vlans:2;
		} in;
		struct {
@@ -222,6 +240,12 @@ struct nf_flow_route {
struct flow_offload *flow_offload_alloc(struct nf_conn *ct);
void flow_offload_free(struct flow_offload *flow);

struct nft_flowtable;
struct nft_pktinfo;
int nft_flow_route(const struct nft_pktinfo *pkt, const struct nf_conn *ct,
		   struct nf_flow_route *route, enum ip_conntrack_dir dir,
		   struct nft_flowtable *ft);

static inline int
nf_flow_table_offload_add_cb(struct nf_flowtable *flow_table,
			     flow_setup_cb_t *cb, void *cb_priv)
+7 −7
Original line number Diff line number Diff line
@@ -881,7 +881,7 @@ enum nft_exthdr_flags {
 * enum nft_exthdr_op - nf_tables match options
 *
 * @NFT_EXTHDR_OP_IPV6: match against ipv6 extension headers
 * @NFT_EXTHDR_OP_TCP: match against tcp options
 * @NFT_EXTHDR_OP_TCPOPT: match against tcp options
 * @NFT_EXTHDR_OP_IPV4: match against ipv4 options
 * @NFT_EXTHDR_OP_SCTP: match against sctp chunks
 * @NFT_EXTHDR_OP_DCCP: match against dccp otions
@@ -1200,7 +1200,7 @@ enum nft_ct_attributes {
#define NFTA_CT_MAX		(__NFTA_CT_MAX - 1)

/**
 * enum nft_flow_attributes - ct offload expression attributes
 * enum nft_offload_attributes - ct offload expression attributes
 * @NFTA_FLOW_TABLE_NAME: flow table name (NLA_STRING)
 */
enum nft_offload_attributes {
@@ -1410,7 +1410,7 @@ enum nft_reject_types {
};

/**
 * enum nft_reject_code - Generic reject codes for IPv4/IPv6
 * enum nft_reject_inet_code - Generic reject codes for IPv4/IPv6
 *
 * @NFT_REJECT_ICMPX_NO_ROUTE: no route to host / network unreachable
 * @NFT_REJECT_ICMPX_PORT_UNREACH: port unreachable
@@ -1480,9 +1480,9 @@ enum nft_nat_attributes {
/**
 * enum nft_tproxy_attributes - nf_tables tproxy expression netlink attributes
 *
 * NFTA_TPROXY_FAMILY: Target address family (NLA_U32: nft_registers)
 * NFTA_TPROXY_REG_ADDR: Target address register (NLA_U32: nft_registers)
 * NFTA_TPROXY_REG_PORT: Target port register (NLA_U32: nft_registers)
 * @NFTA_TPROXY_FAMILY: Target address family (NLA_U32: nft_registers)
 * @NFTA_TPROXY_REG_ADDR: Target address register (NLA_U32: nft_registers)
 * @NFTA_TPROXY_REG_PORT: Target port register (NLA_U32: nft_registers)
 */
enum nft_tproxy_attributes {
	NFTA_TPROXY_UNSPEC,
@@ -1783,7 +1783,7 @@ enum nft_synproxy_attributes {
#define NFTA_SYNPROXY_MAX (__NFTA_SYNPROXY_MAX - 1)

/**
 * enum nft_device_attributes - nf_tables device netlink attributes
 * enum nft_devices_attributes - nf_tables device netlink attributes
 *
 * @NFTA_DEVICE_NAME: name of this device (NLA_STRING)
 * @NFTA_DEVICE_PREFIX: device name prefix, a simple wildcard (NLA_STRING)
+25 −0
Original line number Diff line number Diff line
@@ -353,6 +353,30 @@ ipip_tunnel_ctl(struct net_device *dev, struct ip_tunnel_parm_kern *p, int cmd)
	return ip_tunnel_ctl(dev, p, cmd);
}

static int ipip_fill_forward_path(struct net_device_path_ctx *ctx,
				  struct net_device_path *path)
{
	struct ip_tunnel *tunnel = netdev_priv(ctx->dev);
	const struct iphdr *tiph = &tunnel->parms.iph;
	struct rtable *rt;

	rt = ip_route_output(dev_net(ctx->dev), tiph->daddr, 0, 0, 0,
			     RT_SCOPE_UNIVERSE);
	if (IS_ERR(rt))
		return PTR_ERR(rt);

	path->type = DEV_PATH_TUN;
	path->tun.src_v4.s_addr = tiph->saddr;
	path->tun.dst_v4.s_addr = tiph->daddr;
	path->tun.l3_proto = IPPROTO_IPIP;
	path->dev = ctx->dev;

	ctx->dev = rt->dst.dev;
	ip_rt_put(rt);

	return 0;
}

static const struct net_device_ops ipip_netdev_ops = {
	.ndo_init       = ipip_tunnel_init,
	.ndo_uninit     = ip_tunnel_uninit,
@@ -362,6 +386,7 @@ static const struct net_device_ops ipip_netdev_ops = {
	.ndo_get_stats64 = dev_get_tstats64,
	.ndo_get_iflink = ip_tunnel_get_iflink,
	.ndo_tunnel_ctl	= ipip_tunnel_ctl,
	.ndo_fill_forward_path = ipip_fill_forward_path,
};

#define IPIP_FEATURES (NETIF_F_SG |		\
Loading