OSDN Git Service

netfilter: nf_nat_sip: fix RTP/RTCP source port translations
authorAlin Nastac <alin.nastac@gmail.com>
Thu, 13 Dec 2018 10:10:37 +0000 (11:10 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Mon, 17 Dec 2018 22:43:58 +0000 (23:43 +0100)
commit8294059931448aa1ca112615bdffa3eab552c382
treeaa59a692a324f98ae8e159200962ee586c735324
parent5cbabeec1eb758233b35683123de446a57852932
netfilter: nf_nat_sip: fix RTP/RTCP source port translations

Each media stream negotiation between 2 SIP peers will trigger creation
of 4 different expectations (2 RTP and 2 RTCP):
 - INVITE will create expectations for the media packets sent by the
   called peer
 - reply to the INVITE will create expectations for media packets sent
   by the caller

The dport used by these expectations usually match the ones selected
by the SIP peers, but they might get translated due to conflicts with
another expectation. When such event occur, it is important to do
this translation in both directions, dport translation on the receiving
path and sport translation on the sending path.

This commit fixes the sport translation when the peer requiring it is
also the one that starts the media stream. In this scenario, first media
stream packet is forwarded from LAN to WAN and will rely on
nf_nat_sip_expected() to do the necessary sport translation. However, the
expectation matched by this packet does not contain the necessary information
for doing SNAT, this data being stored in the paired expectation created by
the sender's SIP message (INVITE or reply to it).

Signed-off-by: Alin Nastac <alin.nastac@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nf_nat_sip.c