Subject: Re: [PATCH] net/sched: sch_cake: fix NAT destination port not being updated in cake_update_flowkeys

From: Toke Høiland-Jørgensen <[email-masked]>
Date: Mon, 13 Apr 2026 11:41:37 +0200

Dudu Lu <[email-masked]> writes:

> cake_update_flowkeys() is supposed to update the flow dissector keys
> with the NAT-translated addresses and ports from conntrack, so that
> CAKE's per-flow fairness correctly identifies post-NAT flows as
> belonging to the same connection.
>
> For the source port, this works correctly:
>     keys->ports.src = port;  /* writes conntrack port into keys */
>
> But for the destination port, the assignment is reversed:
>     port = keys->ports.dst;  /* reads FROM keys into local var — no-op */

Huh, what a silly mistake - nice find!

> This means the NAT destination port is never updated in the flow keys.
> As a result, when multiple connections are NATed to the same destination
> (same IP + same port), CAKE treats them as separate flows because the
> original (pre-NAT) destination ports differ. This completely defeats
> CAKE's NAT-aware flow isolation when using the "nat" mode.
>
> The vulnerability was introduced in commit b0c19ed6088a ("sch_cake: Take advantage
> of skb->hash where appropriate")

Calling it a "vulnerability" seems perhaps a tad hyperbolic. Care to
elaborate on what you mean here?

-Toke