Skip to content

Commit 6c7a147

Browse files
ummakynesgregkh
authored andcommitted
netfilter: conntrack: set on IPS_ASSURED if flows enters internal stream state
[ Upstream commit b7b1d02 ] The internal stream state sets the timeout to 120 seconds 2 seconds after the creation of the flow, attach this internal stream state to the IPS_ASSURED flag for consistent event reporting. Before this patch: [NEW] udp 17 30 src=10.246.11.13 dst=216.239.35.0 sport=37282 dport=123 [UNREPLIED] src=216.239.35.0 dst=10.246.11.13 sport=123 dport=37282 [UPDATE] udp 17 30 src=10.246.11.13 dst=216.239.35.0 sport=37282 dport=123 src=216.239.35.0 dst=10.246.11.13 sport=123 dport=37282 [UPDATE] udp 17 30 src=10.246.11.13 dst=216.239.35.0 sport=37282 dport=123 src=216.239.35.0 dst=10.246.11.13 sport=123 dport=37282 [ASSURED] [DESTROY] udp 17 src=10.246.11.13 dst=216.239.35.0 sport=37282 dport=123 src=216.239.35.0 dst=10.246.11.13 sport=123 dport=37282 [ASSURED] Note IPS_ASSURED for the flow not yet in the internal stream state. after this update: [NEW] udp 17 30 src=10.246.11.13 dst=216.239.35.0 sport=37282 dport=123 [UNREPLIED] src=216.239.35.0 dst=10.246.11.13 sport=123 dport=37282 [UPDATE] udp 17 30 src=10.246.11.13 dst=216.239.35.0 sport=37282 dport=123 src=216.239.35.0 dst=10.246.11.13 sport=123 dport=37282 [UPDATE] udp 17 120 src=10.246.11.13 dst=216.239.35.0 sport=37282 dport=123 src=216.239.35.0 dst=10.246.11.13 sport=123 dport=37282 [ASSURED] [DESTROY] udp 17 src=10.246.11.13 dst=216.239.35.0 sport=37282 dport=123 src=216.239.35.0 dst=10.246.11.13 sport=123 dport=37282 [ASSURED] Before this patch, short-lived UDP flows never entered IPS_ASSURED, so they were already candidate flow to be deleted by early_drop under stress. Before this patch, IPS_ASSURED is set on regardless the internal stream state, attach this internal stream state to IPS_ASSURED. packet #1 (original direction) enters NEW state packet #2 (reply direction) enters ESTABLISHED state, sets on IPS_SEEN_REPLY paclet #3 (any direction) sets on IPS_ASSURED (if 2 seconds since the creation has passed by). Reported-by: Maciej Żenczykowski <zenczykowski@gmail.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent ad04ebb commit 6c7a147

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

net/netfilter/nf_conntrack_proto_udp.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,13 @@ int nf_conntrack_udp_packet(struct nf_conn *ct,
104104
*/
105105
if (test_bit(IPS_SEEN_REPLY_BIT, &ct->status)) {
106106
unsigned long extra = timeouts[UDP_CT_UNREPLIED];
107+
bool stream = false;
107108

108109
/* Still active after two seconds? Extend timeout. */
109-
if (time_after(jiffies, ct->proto.udp.stream_ts))
110+
if (time_after(jiffies, ct->proto.udp.stream_ts)) {
110111
extra = timeouts[UDP_CT_REPLIED];
112+
stream = true;
113+
}
111114

112115
nf_ct_refresh_acct(ct, ctinfo, skb, extra);
113116

@@ -116,7 +119,7 @@ int nf_conntrack_udp_packet(struct nf_conn *ct,
116119
return NF_ACCEPT;
117120

118121
/* Also, more likely to be important, and not a probe */
119-
if (!test_and_set_bit(IPS_ASSURED_BIT, &ct->status))
122+
if (stream && !test_and_set_bit(IPS_ASSURED_BIT, &ct->status))
120123
nf_conntrack_event_cache(IPCT_ASSURED, ct);
121124
} else {
122125
nf_ct_refresh_acct(ct, ctinfo, skb, timeouts[UDP_CT_UNREPLIED]);

0 commit comments

Comments
 (0)