Skip to content

Commit 5e5d8b9

Browse files
committed
Merge tag 'nf-23-10-25' of git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf
Pablo Neira Ayuso says: ==================== Netfilter fixes for net This patch contains two late Netfilter's flowtable fixes for net: 1) Flowtable GC pushes back packets to classic path in every GC run, ie. every second. This is because NF_FLOW_HW_ESTABLISHED is only used by sched/act_ct (never set) and IPS_SEEN_REPLY might be unset by the time the flow is offloaded (this status bit is only reliable in the sched/act_ct datapath). 2) sched/act_ct logic to push back packets to classic path to reevaluate if UDP flow is unidirectional only applies if IPS_HW_OFFLOAD_BIT is set on and no hardware offload request is pending to be handled. From Vlad Buslov. These two patches fixes two problems that were introduced in the previous 6.5 development cycle. * tag 'nf-23-10-25' of git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf: net/sched: act_ct: additional checks for outdated flows netfilter: flowtable: GC pushes back packets to classic path ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 53b08c4 + a63b662 commit 5e5d8b9

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

include/net/netfilter/nf_flow_table.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ struct nf_flowtable_type {
5353
struct list_head list;
5454
int family;
5555
int (*init)(struct nf_flowtable *ft);
56+
bool (*gc)(const struct flow_offload *flow);
5657
int (*setup)(struct nf_flowtable *ft,
5758
struct net_device *dev,
5859
enum flow_block_command cmd);

net/netfilter/nf_flow_table_core.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -316,12 +316,6 @@ void flow_offload_refresh(struct nf_flowtable *flow_table,
316316
}
317317
EXPORT_SYMBOL_GPL(flow_offload_refresh);
318318

319-
static bool nf_flow_is_outdated(const struct flow_offload *flow)
320-
{
321-
return test_bit(IPS_SEEN_REPLY_BIT, &flow->ct->status) &&
322-
!test_bit(NF_FLOW_HW_ESTABLISHED, &flow->flags);
323-
}
324-
325319
static inline bool nf_flow_has_expired(const struct flow_offload *flow)
326320
{
327321
return nf_flow_timeout_delta(flow->timeout) <= 0;
@@ -407,12 +401,18 @@ nf_flow_table_iterate(struct nf_flowtable *flow_table,
407401
return err;
408402
}
409403

404+
static bool nf_flow_custom_gc(struct nf_flowtable *flow_table,
405+
const struct flow_offload *flow)
406+
{
407+
return flow_table->type->gc && flow_table->type->gc(flow);
408+
}
409+
410410
static void nf_flow_offload_gc_step(struct nf_flowtable *flow_table,
411411
struct flow_offload *flow, void *data)
412412
{
413413
if (nf_flow_has_expired(flow) ||
414414
nf_ct_is_dying(flow->ct) ||
415-
nf_flow_is_outdated(flow))
415+
nf_flow_custom_gc(flow_table, flow))
416416
flow_offload_teardown(flow);
417417

418418
if (test_bit(NF_FLOW_TEARDOWN, &flow->flags)) {

net/sched/act_ct.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,16 @@ static int tcf_ct_flow_table_fill_actions(struct net *net,
278278
return err;
279279
}
280280

281+
static bool tcf_ct_flow_is_outdated(const struct flow_offload *flow)
282+
{
283+
return test_bit(IPS_SEEN_REPLY_BIT, &flow->ct->status) &&
284+
test_bit(IPS_HW_OFFLOAD_BIT, &flow->ct->status) &&
285+
!test_bit(NF_FLOW_HW_PENDING, &flow->flags) &&
286+
!test_bit(NF_FLOW_HW_ESTABLISHED, &flow->flags);
287+
}
288+
281289
static struct nf_flowtable_type flowtable_ct = {
290+
.gc = tcf_ct_flow_is_outdated,
282291
.action = tcf_ct_flow_table_fill_actions,
283292
.owner = THIS_MODULE,
284293
};

0 commit comments

Comments
 (0)