* [PATCH netfilter-next] netfilter: nf_conntrack_sip: tear down expectations on CANCEL
@ 2026-12-01 20:57 Florian Fainelli
2026-12-05 21:11 ` netdev-bot+sashiko
0 siblings, 1 reply; 2+ messages in thread
From: Florian Fainelli @ 2026-12-01 20:57 UTC (permalink / raw)
To: netdev
Cc: bcm-kernel-feedback-list, Anand Gore, Florian Fainelli,
Pablo Neira Ayuso, Jozsef Kadlecsik, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman,
open list:NETFILTER, open list:NETFILTER, open list
From: Anand Gore <anand.gore@broadcom.com>
RFC 3261 requires a CANCEL request to terminate the pending INVITE
transaction it targets the same way a BYE would for an established
dialog, including releasing any RTP/RTCP expectations created for it.
Route CANCEL through process_bye_request(), which already does this
for BYE.
Signed-off-by: Anand Gore <anand.gore@broadcom.com>
[florian: commit message, forward ported]
Signed-off-by: Florian Fainelli <florian.fainelli@broadcom.com>
---
net/netfilter/nf_conntrack_sip.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/net/netfilter/nf_conntrack_sip.c b/net/netfilter/nf_conntrack_sip.c
index b05dc8858d09..1e649bd2c0d8 100644
--- a/net/netfilter/nf_conntrack_sip.c
+++ b/net/netfilter/nf_conntrack_sip.c
@@ -1516,6 +1516,7 @@ static const struct sip_handler sip_handlers[] = {
SIP_HANDLER("ACK", process_sdp, NULL),
SIP_HANDLER("PRACK", process_sdp, process_prack_response),
SIP_HANDLER("BYE", process_bye_request, NULL),
+ SIP_HANDLER("CANCEL", process_bye_request, NULL),
SIP_HANDLER("REGISTER", process_register_request, process_register_response),
};
--
2.34.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH netfilter-next] netfilter: nf_conntrack_sip: tear down expectations on CANCEL
2026-12-01 20:57 [PATCH netfilter-next] netfilter: nf_conntrack_sip: tear down expectations on CANCEL Florian Fainelli
@ 2026-12-05 21:11 ` netdev-bot+sashiko
0 siblings, 0 replies; 2+ messages in thread
From: netdev-bot+sashiko @ 2026-12-05 21:11 UTC (permalink / raw)
To: florian.fainelli
Cc: netdev, bcm-kernel-feedback-list, anand.gore, pablo, kadlec,
davem, edumazet, kuba, pabeni, horms, netfilter-devel, coreteam,
linux-kernel
Thank you for your contribution! Sashiko AI review found 3 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 2 · Low: 1
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] The new CANCEL entry in sip_handlers[]
(net/netfilter/nf_conntrack_sip.c:1519) routes every CANCEL request to…
- [Medium] The commit message misstates RFC 3261 and suggests a bug the
code does not have.
- [Low] Before the patch, no sip_handlers[] entry matched a "CANCEL "
request line, so process_sip_request() left the loop and returned…
--
netfilter: nf_conntrack_sip: tear down expectations on CANCEL
This patch adds a CANCEL entry to sip_handlers[] that sends CANCEL
requests to process_bye_request(). The goal is to release the RTP/RTCP
expectations created for an INVITE transaction that is being cancelled.
> RFC 3261 requires a CANCEL request to terminate the pending INVITE
> transaction it targets the same way a BYE would for an established
> dialog, including releasing any RTP/RTCP expectations created for it.
[Severity: Medium]
Is this description of RFC 3261 accurate?
Under section 9.2, a CANCEL only asks the UAS to stop a request that is
still pending. It has no effect once a final response has been sent. When
it does take effect, the UAS answers the INVITE with 487 Request
Terminated.
That 487 (CSeq N INVITE) already goes through
process_sip_response()->process_invite_response():
net/netfilter/nf_conntrack_sip.c:process_invite_response() {
...
if ((code >= 100 && code <= 199) ||
(code >= 200 && code <= 299))
return process_sdp(skb, protoff, dataoff, dptr, datalen, cseq);
else if (ct_sip_info->invite_cseq == cseq)
flush_expectations(ct, true);
...
}
So the expectations for a cancelled INVITE already seem to be released
without this patch.
The message also says the expectations "created for it" are released.
However, flush_expectations() removes every media expectation on the
master conntrack.
Is there a concrete case that the 487 path misses? Without one, and
without a Fixes: tag, it is hard to tell what bug is being fixed.
The message also leaves out the one behaviour change: expectations are now
flushed when the CANCEL arrives, even if the CANCEL ends up having no
effect.
> diff --git a/net/netfilter/nf_conntrack_sip.c b/net/netfilter/nf_conntrack_sip.c
> index b05dc8858d094..1e649bd2c0d8f 100644
> --- a/net/netfilter/nf_conntrack_sip.c
> +++ b/net/netfilter/nf_conntrack_sip.c
> @@ -1516,6 +1516,7 @@ static const struct sip_handler sip_handlers[] = {
> SIP_HANDLER("ACK", process_sdp, NULL),
> SIP_HANDLER("PRACK", process_sdp, process_prack_response),
> SIP_HANDLER("BYE", process_bye_request, NULL),
> + SIP_HANDLER("CANCEL", process_bye_request, NULL),
[Severity: Medium]
Can this remove the media expectations of a call that is established or
about to be? process_bye_request() ignores its cseq argument and always
flushes:
net/netfilter/nf_conntrack_sip.c:process_bye_request() {
...
flush_expectations(ct, true);
return NF_ACCEPT;
}
flush_expectations() then unlinks every non-signalling expectation on the
master conntrack. That includes RTP/RTCP/T.38 expectations that nf_nat_sip
set up for SDP it rewrote.
Nothing checks that the CANCEL targets the INVITE this conntrack is
tracking. RFC 3261 section 9.1 says the CANCEL's CSeq number equals the
cancelled request's. process_invite_request() stores that number in
ct_sip_info->invite_cseq.
Nothing checks that the INVITE is still pending, either.
The response paths are process_invite_response(),
process_update_response() and process_prack_response(). Each of them
flushes only when ct_sip_info->invite_cseq == cseq. The 487 sent after a
successful CANCEL already passes that check.
So the new flush only changes behaviour when the CANCEL should have no
effect:
- A CANCEL that crosses a 200 OK. The 200 OK's SDP has already created
the answer expectations through
process_invite_response()->process_sdp(), and the CANCEL then removes
them.
- A conntrack that carries several dialogs, such as a 5060<->5060
proxy/PBX trunk. A CANCEL for one transaction, for example the losing
branch of a forked INVITE, removes expectations that another dialog's
2xx SDP answer created afterwards.
- A stale or retransmitted CANCEL, or one whose CSeq does not match
invite_cseq.
In those cases, RTP/RTCP that hasn't started yet is no longer RELATED or
DNAT-translated to the ports in the SDP. The result is one-way audio or
no audio.
Would comparing cseq against ct_sip_info->invite_cseq, as the response
paths do, match the stated intent? Or could this rely on the existing 487
path instead?
[Severity: Low]
Before this patch, no sip_handlers[] entry matched a "CANCEL " request
line, so process_sip_request() returned NF_ACCEPT without parsing CSeq.
With this entry, CANCEL now goes through the CSeq checks:
net/netfilter/nf_conntrack_sip.c:process_sip_request() {
...
if (ct_sip_get_header(ct, *dptr, 0, *datalen, SIP_HDR_CSEQ,
&matchoff, &matchlen) <= 0) {
nf_ct_helper_log(skb, ct, "cannot parse cseq");
return NF_DROP;
}
cseq = sip_strtouint(*dptr + matchoff, *datalen - matchoff, (char **)&end);
if (*dptr + matchoff == end) {
nf_ct_helper_log(skb, ct, "cannot get cseq");
return NF_DROP;
}
...
}
A CANCEL with a missing or non-numeric CSeq is now dropped instead of
passed through.
Only CANCELs that break RFC 3261 are affected, and other handled methods
already get the same drop policy. Should the commit message mention this
change?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261201205747.478614-1-florian.fainelli%40broadcom.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-12-05 21:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01 20:57 [PATCH netfilter-next] netfilter: nf_conntrack_sip: tear down expectations on CANCEL Florian Fainelli
2026-12-05 21:11 ` netdev-bot+sashiko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox