Skip to contentSkip to conversation

netfilter: nft_flow_offload: clear tcp MAXACK flag before moving to slowpath

PATCH Superseded Pablo Neira Ayuso 2 participants 7 messages Jan 7, 2025 – Jan 9, 2025

Subsystems (2)
lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH v2 1/6 netfilter: nft_flow_offload: clear tcp MAXACK flag before moving to slowpath

From: Florian Westphal <[email protected]>

This state reset is racy, no locks are held here.

Since commit
8437a6209f76 ("netfilter: nft_flow_offload: set liberal tracking mode for tcp"), the window checks are disabled for normal data packets, but MAXACK flag is checked when validating TCP resets.

Clear the flag so tcp reset validation checks are ignored.

---
v2: no changes, rebase on top of nf-next.

 net/netfilter/nf_flow_table_core.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
net/netfilter/nf_flow_table_core.c +12 -2
index df72b0376970..bdde469bbbd1 100644
@@ -161,10 +161,20 @@ void flow_offload_route_init(struct flow_offload *flow,
 }
 EXPORT_SYMBOL_GPL(flow_offload_route_init);
 
-static void flow_offload_fixup_tcp(struct ip_ct_tcp *tcp)
+static void flow_offload_fixup_tcp(struct nf_conn *ct)
 {
+	struct ip_ct_tcp *tcp = &ct->proto.tcp;
+
+	spin_lock_bh(&ct->lock);
+	/* Conntrack state is outdated due to offload bypass.
+	 * Clear IP_CT_TCP_FLAG_MAXACK_SET, otherwise conntracks
+	 * TCP reset validation will fail.
+	 */
 	tcp->seen[0].td_maxwin = 0;
+	tcp->seen[0].flags &= ~IP_CT_TCP_FLAG_MAXACK_SET;
 	tcp->seen[1].td_maxwin = 0;
+	tcp->seen[1].flags &= ~IP_CT_TCP_FLAG_MAXACK_SET;
+	spin_unlock_bh(&ct->lock);
 }
 
 static void flow_offload_fixup_ct(struct nf_conn *ct)
@@ -176,7 +186,7 @@ static void flow_offload_fixup_ct(struct nf_conn *ct)
 	if (l4num == IPPROTO_TCP) {
 		struct nf_tcp_net *tn = nf_tcp_pernet(net);
 
-		flow_offload_fixup_tcp(&ct->proto.tcp);
+		flow_offload_fixup_tcp(ct);
 
 		timeout = tn->timeouts[ct->proto.tcp.state];
 		timeout -= tn->offload_timeout;
Signature · 1 line
2.30.2
author maintainer
#1 lore raw

PATCH v2 2/6 netfilter: nft_flow_offload: update tcp state flags under lock

From: Florian Westphal <[email protected]>

The conntrack entry is already public, there is a small chance that another CPU is handling a packet in reply direction and racing with the tcp state update.

Move this under ct spinlock.

This is done once, when ct is about to be offloaded, so this should not result in a noticeable performance hit.

Fixes 8437a6209f76 ("netfilter: nft_flow_offload: set liberal tracking mode for tcp")

---
v2: no changes, rebase on top of nf-next.

 net/netfilter/nft_flow_offload.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
net/netfilter/nft_flow_offload.c +11 -5
index 3b474d235663..221d50223018 100644
@@ -289,6 +289,15 @@ static bool nft_flow_offload_skip(struct sk_buff *skb, int family)
 	return false;
 }
 
+static void flow_offload_ct_tcp(struct nf_conn *ct)
+{
+	/* conntrack will not see all packets, disable tcp window validation. */
+	spin_lock_bh(&ct->lock);
+	ct->proto.tcp.seen[0].flags |= IP_CT_TCP_FLAG_BE_LIBERAL;
+	ct->proto.tcp.seen[1].flags |= IP_CT_TCP_FLAG_BE_LIBERAL;
+	spin_unlock_bh(&ct->lock);
+}
+
 static void nft_flow_offload_eval(const struct nft_expr *expr,
 				  struct nft_regs *regs,
 				  const struct nft_pktinfo *pkt)
@@ -356,11 +365,8 @@ static void nft_flow_offload_eval(const struct nft_expr *expr,
 		goto err_flow_alloc;
 
 	flow_offload_route_init(flow, &route);
-
-	if (tcph) {
-		ct->proto.tcp.seen[0].flags |= IP_CT_TCP_FLAG_BE_LIBERAL;
-		ct->proto.tcp.seen[1].flags |= IP_CT_TCP_FLAG_BE_LIBERAL;
-	}
+	if (tcph)
+		flow_offload_ct_tcp(ct);
 
 	__set_bit(NF_FLOW_HW_BIDIRECTIONAL, &flow->flags);
 	ret = flow_offload_add(flowtable, flow);
Signature · 1 line
2.30.2
author maintainer
#2 lore raw

PATCH v2 3/6 netfilter: conntrack: remove skb argument from nf_ct_refresh

In reply to Pablo Neira Ayuso

From: Florian Westphal <[email protected]>

Its not used (and could be NULL), so remove it.
This allows to use nf_ct_refresh in places where we don't have an skb without having to double-check that skb == NULL would be safe.

---
v2: no changes, rebase on top of nf-next.

 include/net/netfilter/nf_conntrack.h   | 8 +++-----
 net/netfilter/nf_conntrack_amanda.c    | 2 +-
 net/netfilter/nf_conntrack_broadcast.c | 2 +-
 net/netfilter/nf_conntrack_core.c      | 7 +++----
 net/netfilter/nf_conntrack_h323_main.c | 4 ++--
 net/netfilter/nf_conntrack_sip.c       | 4 ++--
 net/netfilter/nft_ct.c                 | 2 +-
 7 files changed, 13 insertions(+), 16 deletions(-)
include/net/netfilter/nf_conntrack.h +3 -5
index cba3ccf03fcc..3cbf29dd0b71 100644
@@ -204,8 +204,7 @@ bool nf_ct_get_tuplepr(const struct sk_buff *skb, unsigned int nhoff,
 		       struct nf_conntrack_tuple *tuple);
 
 void __nf_ct_refresh_acct(struct nf_conn *ct, enum ip_conntrack_info ctinfo,
-			  const struct sk_buff *skb,
-			  u32 extra_jiffies, bool do_acct);
+			  u32 extra_jiffies, unsigned int bytes);
 
 /* Refresh conntrack for this many jiffies and do accounting */
 static inline void nf_ct_refresh_acct(struct nf_conn *ct,
@@ -213,15 +212,14 @@ static inline void nf_ct_refresh_acct(struct nf_conn *ct,
 				      const struct sk_buff *skb,
 				      u32 extra_jiffies)
 {
-	__nf_ct_refresh_acct(ct, ctinfo, skb, extra_jiffies, true);
+	__nf_ct_refresh_acct(ct, ctinfo, extra_jiffies, skb->len);
 }
 
 /* Refresh conntrack for this many jiffies */
 static inline void nf_ct_refresh(struct nf_conn *ct,
-				 const struct sk_buff *skb,
 				 u32 extra_jiffies)
 {
-	__nf_ct_refresh_acct(ct, 0, skb, extra_jiffies, false);
+	__nf_ct_refresh_acct(ct, 0, extra_jiffies, 0);
 }
 
 /* kill conntrack and do accounting */
net/netfilter/nf_conntrack_amanda.c +1 -1
index d011d2eb0848..7be4c35e4795 100644
@@ -106,7 +106,7 @@ static int amanda_help(struct sk_buff *skb,
 
 	/* increase the UDP timeout of the master connection as replies from
 	 * Amanda clients to the server can be quite delayed */
-	nf_ct_refresh(ct, skb, master_timeout * HZ);
+	nf_ct_refresh(ct, master_timeout * HZ);
 
 	/* No data? */
 	dataoff = protoff + sizeof(struct udphdr);
net/netfilter/nf_conntrack_broadcast.c +1 -1
index cfa0fe0356de..a7552a46d6ac 100644
@@ -75,7 +75,7 @@ int nf_conntrack_broadcast_help(struct sk_buff *skb,
 	nf_ct_expect_related(exp, 0);
 	nf_ct_expect_put(exp);
 
-	nf_ct_refresh(ct, skb, timeout * HZ);
+	nf_ct_refresh(ct, timeout * HZ);
 out:
 	return NF_ACCEPT;
 }
net/netfilter/nf_conntrack_core.c +3 -4
index 9db3e2b0b1c3..687fa99bfb5a 100644
@@ -2089,9 +2089,8 @@ EXPORT_SYMBOL_GPL(nf_conntrack_in);
 /* Refresh conntrack for this many jiffies and do accounting if do_acct is 1 */
 void __nf_ct_refresh_acct(struct nf_conn *ct,
 			  enum ip_conntrack_info ctinfo,
-			  const struct sk_buff *skb,
 			  u32 extra_jiffies,
-			  bool do_acct)
+			  unsigned int bytes)
 {
 	/* Only update if this is not a fixed timeout */
 	if (test_bit(IPS_FIXED_TIMEOUT_BIT, &ct->status))
@@ -2104,8 +2103,8 @@ void __nf_ct_refresh_acct(struct nf_conn *ct,
 	if (READ_ONCE(ct->timeout) != extra_jiffies)
 		WRITE_ONCE(ct->timeout, extra_jiffies);
 acct:
-	if (do_acct)
-		nf_ct_acct_update(ct, CTINFO2DIR(ctinfo), skb->len);
+	if (bytes)
+		nf_ct_acct_update(ct, CTINFO2DIR(ctinfo), bytes);
 }
 EXPORT_SYMBOL_GPL(__nf_ct_refresh_acct);
 
net/netfilter/nf_conntrack_h323_main.c +2 -2
index 5a9bce24f3c3..14f73872f647 100644
@@ -1385,7 +1385,7 @@ static int process_rcf(struct sk_buff *skb, struct nf_conn *ct,
 	if (info->timeout > 0) {
 		pr_debug("nf_ct_ras: set RAS connection timeout to "
 			 "%u seconds\n", info->timeout);
-		nf_ct_refresh(ct, skb, info->timeout * HZ);
+		nf_ct_refresh(ct, info->timeout * HZ);
 
 		/* Set expect timeout */
 		spin_lock_bh(&nf_conntrack_expect_lock);
@@ -1433,7 +1433,7 @@ static int process_urq(struct sk_buff *skb, struct nf_conn *ct,
 	info->sig_port[!dir] = 0;
 
 	/* Give it 30 seconds for UCF or URJ */
-	nf_ct_refresh(ct, skb, 30 * HZ);
+	nf_ct_refresh(ct, 30 * HZ);
 
 	return 0;
 }
net/netfilter/nf_conntrack_sip.c +2 -2
index d0eac27f6ba0..ca748f8dbff1 100644
@@ -1553,7 +1553,7 @@ static int sip_help_tcp(struct sk_buff *skb, unsigned int protoff,
 	if (dataoff >= skb->len)
 		return NF_ACCEPT;
 
-	nf_ct_refresh(ct, skb, sip_timeout * HZ);
+	nf_ct_refresh(ct, sip_timeout * HZ);
 
 	if (unlikely(skb_linearize(skb)))
 		return NF_DROP;
@@ -1624,7 +1624,7 @@ static int sip_help_udp(struct sk_buff *skb, unsigned int protoff,
 	if (dataoff >= skb->len)
 		return NF_ACCEPT;
 
-	nf_ct_refresh(ct, skb, sip_timeout * HZ);
+	nf_ct_refresh(ct, sip_timeout * HZ);
 
 	if (unlikely(skb_linearize(skb)))
 		return NF_DROP;
net/netfilter/nft_ct.c +1 -1
index 67a41cd2baaf..2e59aba681a1 100644
@@ -929,7 +929,7 @@ static void nft_ct_timeout_obj_eval(struct nft_object *obj,
 	 */
 	values = nf_ct_timeout_data(timeout);
 	if (values)
-		nf_ct_refresh(ct, pkt->skb, values[0]);
+		nf_ct_refresh(ct, values[0]);
 }
 
 static int nft_ct_timeout_obj_init(const struct nft_ctx *ctx,
Signature · 1 line
2.30.2
author maintainer
#3 lore raw

PATCH v2 4/6 netfilter: conntrack: rework offload nf_conn timeout extension logic

In reply to Pablo Neira Ayuso

From: Florian Westphal <[email protected]>

Offload nf_conn entries may not see traffic for a very long time.

To prevent incorrect 'ct is stale' checks during nf_conntrack table lookup, the gc worker extends the timeout nf_conn entries marked for offload to a large value.

The existing logic suffers from a few problems.

Garbage collection runs without locks, its unlikely but possible that @ct is removed right after the 'offload' bit test.

In that case, the timeout of a new/reallocated nf_conn entry will be increased.

Prevent this by obtaining a reference count on the ct object and re-check of the confirmed and offload bits.

If those are not set, the ct is being removed, skip the timeout extension in this case.

Parallel teardown is also problematic:
cpu1 cpu2
gc_worker
calls flow_offload_teardown()
tests OFFLOAD bit, set
clear OFFLOAD bit
ct->timeout is repaired (e.g. set to timeout[UDP_CT_REPLIED])
nf_ct_offload_timeout() called
expire value is fetched
<INTERRUPT>
-> NF_CT_DAY timeout for flow that isn't offloaded
(and might not see any further packets).

Use cmpxchg: if ct->timeout was repaired after the 2nd 'offload bit' test passed, then ct->timeout will only be updated of ct->timeout was not altered in between.

As we already have a gc worker for flowtable entries, ct->timeout repair can be handled from the flowtable gc worker.

This avoids having flowtable specific logic in the conntrack core and avoids checking entries that were never offloaded.

This allows to remove the nf_ct_offload_timeout helper. Its safe to use in the add case, but not on teardown.

---
v2: I collapsed a small patch to:

- nf_ct_offload_timeout(flow->ct);
+ nf_ct_refresh(flow->ct, NF_CT_DAY);

and I added a check not to extend timeout in nf_flow_offload_gc_step() when flow is already in teardown state, otherwise previous timeout fixup gets an override.

 include/net/netfilter/nf_conntrack.h |  10 ---
 net/netfilter/nf_conntrack_core.c    |   6 --
 net/netfilter/nf_flow_table_core.c   | 105 ++++++++++++++++++++++++++-
 3 files changed, 103 insertions(+), 18 deletions(-)
include/net/netfilter/nf_conntrack.h +0 -10
index 3cbf29dd0b71..3f02a45773e8 100644
@@ -312,16 +312,6 @@ static inline bool nf_ct_should_gc(const struct nf_conn *ct)
 
 #define	NF_CT_DAY	(86400 * HZ)
 
-/* Set an arbitrary timeout large enough not to ever expire, this save
- * us a check for the IPS_OFFLOAD_BIT from the packet path via
- * nf_ct_is_expired().
- */
-static inline void nf_ct_offload_timeout(struct nf_conn *ct)
-{
-	if (nf_ct_expires(ct) < NF_CT_DAY / 2)
-		WRITE_ONCE(ct->timeout, nfct_time_stamp + NF_CT_DAY);
-}
-
 struct kernel_param;
 
 int nf_conntrack_set_hashsize(const char *val, const struct kernel_param *kp);
net/netfilter/nf_conntrack_core.c +0 -6
index 687fa99bfb5a..8666d733b984 100644
@@ -1544,12 +1544,6 @@ static void gc_worker(struct work_struct *work)
 
 			tmp = nf_ct_tuplehash_to_ctrack(h);
 
-			if (test_bit(IPS_OFFLOAD_BIT, &tmp->status)) {
-				nf_ct_offload_timeout(tmp);
-				if (!nf_conntrack_max95)
-					continue;
-			}
-
 			if (expired_count > GC_SCAN_EXPIRED_MAX) {
 				rcu_read_unlock();
 
net/netfilter/nf_flow_table_core.c +103 -2

125 lines not on this page · raw message

Signature · 1 line
2.30.2
author maintainer
#4 lore raw

PATCH v2 5/6 netfilter: flowtable: teardown flow if cached mtu is stale

In reply to Pablo Neira Ayuso

Tear down the flow entry in the unlikely case that the interface mtu changes, this gives the flow a chance to refresh the cached mtu, otherwise such refresh does not occur until flow entry expires.

---
v2: new in this series.

 net/netfilter/nf_flow_table_ip.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
net/netfilter/nf_flow_table_ip.c +6 -2
index 98edcaa37b38..a22856106383 100644
@@ -377,8 +377,10 @@ static int nf_flow_offload_forward(struct nf_flowtable_ctx *ctx,
 	flow = container_of(tuplehash, struct flow_offload, tuplehash[dir]);
 
 	mtu = flow->tuplehash[dir].tuple.mtu + ctx->offset;
-	if (unlikely(nf_flow_exceeds_mtu(skb, mtu)))
+	if (unlikely(nf_flow_exceeds_mtu(skb, mtu))) {
+		flow_offload_teardown(flow);
 		return 0;
+	}
 
 	iph = (struct iphdr *)(skb_network_header(skb) + ctx->offset);
 	thoff = (iph->ihl * 4) + ctx->offset;
@@ -656,8 +658,10 @@ static int nf_flow_offload_ipv6_forward(struct nf_flowtable_ctx *ctx,
 	flow = container_of(tuplehash, struct flow_offload, tuplehash[dir]);
 
 	mtu = flow->tuplehash[dir].tuple.mtu + ctx->offset;
-	if (unlikely(nf_flow_exceeds_mtu(skb, mtu)))
+	if (unlikely(nf_flow_exceeds_mtu(skb, mtu))) {
+		flow_offload_teardown(flow);
 		return 0;
+	}
 
 	ip6h = (struct ipv6hdr *)(skb_network_header(skb) + ctx->offset);
 	thoff = sizeof(*ip6h) + ctx->offset;
Signature · 1 line
2.30.2
author maintainer
#5 lore raw

PATCH v2 6/6 netfilter: flowtable: add CLOSING state

In reply to Pablo Neira Ayuso

tcp rst/fin packet triggers an immediate teardown of the flow which results in sending flows back to the classic forwarding path.

This behaviour was introduced by:

da5984e51063 ("netfilter: nf_flow_table: add support for sending flows back to the slow path") b6f27d322a0a ("netfilter: nf_flow_table: tear down TCP flows if RST or FIN was seen")

whose goal is to expedite removal of flow entries from the hardware table. Before these patches flow was only releases after the flow timeout.

However, this approach leads to packet races when restoring the conntrack state as well as late flow re-offload situations.

This patch adds a new CLOSING state that is is entered when tcp rst/fin packet is seen. This allows for an early removal of the flow entry from the hardware table. The flow entry still remains in software, so tcp packets to shut down the flow are not sent back to slow path.

If syn packet is seen from this new CLOSING state, then this flow enters teardown state, ct state is set to TCP_CONNTRACK_CLOSE state and packet is sent to slow path, so this TCP reopen scenario can be handled by conntrack. TCP_CONNTRACK_CLOSE provides a small timeout that aims at quickly releasing this stale entry from the conntrack table.

Skip hardware re-offload from flowtable software packet if the flow is in CLOSING state.

---
v6: new in this series.

- nf_flow_has_expired() is just moved to avoid a forward declaration, because flow_offload_fixup_ct() uses it.

- TCP_CONNTRACK_ESTABLISHED is still used when flow entry expires, _UNACK is fine for the unlikely conntrack pickup from the middle case, but probably too short for this purpose. In the flowtable scenario, sending a flow back to slow path could happen more frequently, user still has a chance to tune _ESTABLISHED to something more reasonable such as default TCP keepalive.

 include/net/netfilter/nf_flow_table.h |  1 +
 net/netfilter/nf_flow_table_core.c    | 62 +++++++++++++++++++--------
 net/netfilter/nf_flow_table_ip.c      |  7 ++-
 3 files changed, 51 insertions(+), 19 deletions(-)
include/net/netfilter/nf_flow_table.h +1 -0
index b63d53bb9dd6..d711642e78b5 100644
@@ -163,6 +163,7 @@ struct flow_offload_tuple_rhash {
 enum nf_flow_flags {
 	NF_FLOW_SNAT,
 	NF_FLOW_DNAT,
+	NF_FLOW_CLOSING,
 	NF_FLOW_TEARDOWN,
 	NF_FLOW_HW,
 	NF_FLOW_HW_DYING,
net/netfilter/nf_flow_table_core.c +44 -18

122 lines not on this page · raw message

net/netfilter/nf_flow_table_ip.c +6 -1
index a22856106383..8aea61f2f9d2 100644
@@ -28,11 +28,16 @@ static int nf_flow_state_check(struct flow_offload *flow, int proto,
 		return 0;
 
 	tcph = (void *)(skb_network_header(skb) + thoff);
-	if (unlikely(tcph->fin || tcph->rst)) {
+	if (tcph->syn && test_bit(NF_FLOW_CLOSING, &flow->flags)) {
 		flow_offload_teardown(flow);
 		return -1;
 	}
 
+	if (tcph->fin || tcph->rst) {
+		set_bit(NF_FLOW_CLOSING, &flow->flags);
+		return -1;
+	}
+
 	return 0;
 }
 
Signature · 1 line
2.30.2
#6 lore raw

Re: [PATCH nf-next,v2 6/6] netfilter: flowtable: add CLOSING state

kernel test robot noticed the following build warnings:

Hi Pablo,

kernel test robot noticed the following build warnings:

[auto build test WARNING on netfilter-nf/main]
[also build test WARNING on linus/master v6.13-rc6 next-20250108] [cannot apply to nf-next/master]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Pablo-Neira-Ayuso/netfilter-nft_flow_offload-update-tcp-state-flags-under-lock/20250108-075203
base:   https://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf.git main
patch link:    https://lore.kernel.org/r/20250107235038.115651-6-pablo%40netfilter.org
patch subject: [PATCH nf-next,v2 6/6] netfilter: flowtable: add CLOSING state
config: hexagon-allyesconfig (https://download.01.org/0day-ci/archive/20250109/[email protected]/config)
compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250109/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

>> net/netfilter/nf_flow_table_core.c:217:13: warning: variable 'expired' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
     217 |         } else if (l4num == IPPROTO_UDP) {
         |                    ^~~~~~~~~~~~~~~~~~~~
   net/netfilter/nf_flow_table_core.c:229:6: note: uninitialized use occurs here
     229 |         if (expired)
         |             ^~~~~~~
   net/netfilter/nf_flow_table_core.c:217:9: note: remove the 'if' if its condition is always false
     217 |         } else if (l4num == IPPROTO_UDP) {
         |                ^~~~~~~~~~~~~~~~~~~~~~~~~~~
     218 |                 const struct nf_udp_net *tn = nf_udp_pernet(net);
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     219 |                 enum udp_conntrack state =
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~
     220 |                         test_bit(IPS_SEEN_REPLY_BIT, &ct->status) ?
         |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     221 |                         UDP_CT_REPLIED : UDP_CT_UNREPLIED;
         |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     222 | 
     223 |                 timeout = READ_ONCE(tn->timeouts[state]);
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     224 |                 offload_timeout = READ_ONCE(tn->offload_timeout);
         |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     225 |         } else {
         |         ~~~~~~
   net/netfilter/nf_flow_table_core.c:194:14: note: initialize the variable 'expired' to silence this warning
     194 |         bool expired;
         |                     ^
         |                      = 0

1 warning generated.

vim +217 net/netfilter/nf_flow_table_core.c

da5984e51063a2 Felix Fietkau     2018-02-26  187  
e622d94ec73f66 Pablo Neira Ayuso 2025-01-08  188  static void flow_offload_fixup_ct(struct flow_offload *flow)
da5984e51063a2 Felix Fietkau     2018-02-26  189  {
e622d94ec73f66 Pablo Neira Ayuso 2025-01-08  190  	struct nf_conn *ct = flow->ct;
1d91d2e1a7f767 Oz Shlomo         2021-06-03  191  	struct net *net = nf_ct_net(ct);
1e5b2471bcc483 Pablo Neira Ayuso 2019-08-09  192  	int l4num = nf_ct_protonum(ct);
e622d94ec73f66 Pablo Neira Ayuso 2025-01-08  193  	u32 offload_timeout = 0;
e622d94ec73f66 Pablo Neira Ayuso 2025-01-08  194  	bool expired;
4592ee7f525c46 Florian Westphal  2021-08-04  195  	s32 timeout;
da5984e51063a2 Felix Fietkau     2018-02-26  196  
1d91d2e1a7f767 Oz Shlomo         2021-06-03  197  	if (l4num == IPPROTO_TCP) {
e622d94ec73f66 Pablo Neira Ayuso 2025-01-08  198  		const struct nf_tcp_net *tn = nf_tcp_pernet(net);
e622d94ec73f66 Pablo Neira Ayuso 2025-01-08  199  		u8 tcp_state;
1d91d2e1a7f767 Oz Shlomo         2021-06-03  200  
e622d94ec73f66 Pablo Neira Ayuso 2025-01-08  201  		/* Enter CLOSE state if fin/rst packet has been seen, this
e622d94ec73f66 Pablo Neira Ayuso 2025-01-08  202  		 * allows TCP reopen from conntrack. Otherwise, pick up from
e622d94ec73f66 Pablo Neira Ayuso 2025-01-08  203  		 * the last seen TCP state.
e622d94ec73f66 Pablo Neira Ayuso 2025-01-08  204  		 */
e622d94ec73f66 Pablo Neira Ayuso 2025-01-08  205  		if (test_bit(NF_FLOW_CLOSING, &flow->flags)) {
e622d94ec73f66 Pablo Neira Ayuso 2025-01-08  206  			flow_offload_fixup_tcp(ct, TCP_CONNTRACK_CLOSE);
e622d94ec73f66 Pablo Neira Ayuso 2025-01-08  207  			timeout = READ_ONCE(tn->timeouts[TCP_CONNTRACK_CLOSE]);
e622d94ec73f66 Pablo Neira Ayuso 2025-01-08  208  			expired = false;
e622d94ec73f66 Pablo Neira Ayuso 2025-01-08  209  		} else {
e622d94ec73f66 Pablo Neira Ayuso 2025-01-08  210  			tcp_state = READ_ONCE(ct->proto.tcp.state);
e622d94ec73f66 Pablo Neira Ayuso 2025-01-08  211  			flow_offload_fixup_tcp(ct, tcp_state);
e622d94ec73f66 Pablo Neira Ayuso 2025-01-08  212  			timeout = READ_ONCE(tn->timeouts[tcp_state]);
e622d94ec73f66 Pablo Neira Ayuso 2025-01-08  213  			expired = nf_flow_has_expired(flow);
e622d94ec73f66 Pablo Neira Ayuso 2025-01-08  214  		}
e622d94ec73f66 Pablo Neira Ayuso 2025-01-08  215  		offload_timeout = READ_ONCE(tn->offload_timeout);
e5eaac2beb54f0 Pablo Neira Ayuso 2022-05-17  216  
1d91d2e1a7f767 Oz Shlomo         2021-06-03 @217  	} else if (l4num == IPPROTO_UDP) {
e622d94ec73f66 Pablo Neira Ayuso 2025-01-08  218  		const struct nf_udp_net *tn = nf_udp_pernet(net);
0eb5acb1641889 Vlad Buslov       2023-02-01  219  		enum udp_conntrack state =
0eb5acb1641889 Vlad Buslov       2023-02-01  220  			test_bit(IPS_SEEN_REPLY_BIT, &ct->status) ?
0eb5acb1641889 Vlad Buslov       2023-02-01  221  			UDP_CT_REPLIED : UDP_CT_UNREPLIED;
1d91d2e1a7f767 Oz Shlomo         2021-06-03  222  
e622d94ec73f66 Pablo Neira Ayuso 2025-01-08  223  		timeout = READ_ONCE(tn->timeouts[state]);
e622d94ec73f66 Pablo Neira Ayuso 2025-01-08  224  		offload_timeout = READ_ONCE(tn->offload_timeout);
1d91d2e1a7f767 Oz Shlomo         2021-06-03  225  	} else {
da5984e51063a2 Felix Fietkau     2018-02-26  226  		return;
1d91d2e1a7f767 Oz Shlomo         2021-06-03  227  	}
da5984e51063a2 Felix Fietkau     2018-02-26  228  
e622d94ec73f66 Pablo Neira Ayuso 2025-01-08  229  	if (expired)
e622d94ec73f66 Pablo Neira Ayuso 2025-01-08  230  		timeout -= offload_timeout;
e622d94ec73f66 Pablo Neira Ayuso 2025-01-08  231  
4592ee7f525c46 Florian Westphal  2021-08-04  232  	if (timeout < 0)
4592ee7f525c46 Florian Westphal  2021-08-04  233  		timeout = 0;
4592ee7f525c46 Florian Westphal  2021-08-04  234  
e622d94ec73f66 Pablo Neira Ayuso 2025-01-08  235  	nf_ct_refresh(ct, timeout);
da5984e51063a2 Felix Fietkau     2018-02-26  236  }
da5984e51063a2 Felix Fietkau     2018-02-26  237  
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki