From 77f5ad25b00174539a5d1b020300dce150f468de Mon Sep 17 00:00:00 2001 From: Paras Singh Jain Date: Wed, 2 Sep 2020 18:49:36 +0530 Subject: [PATCH] msm: netfilter: changes to handle contact address modification in SIP ALG SIP ALG mangles contact address only when both address and port are mentioned. Some clients send only address information in which case the contact address does not get mangled an hence SIP call does not get established. Change-Id: Ie760f6fcc6dd8e269b057488414b23beff4e8fc3 Signed-off-by: Paras Singh Jain --- net/netfilter/nf_nat_sip.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/net/netfilter/nf_nat_sip.c b/net/netfilter/nf_nat_sip.c index f0a735e86851..8274b85aa298 100644 --- a/net/netfilter/nf_nat_sip.c +++ b/net/netfilter/nf_nat_sip.c @@ -113,13 +113,26 @@ static int map_addr(struct sk_buff *skb, unsigned int protoff, newaddr = ct->tuplehash[!dir].tuple.src.u3; newport = ct_sip_info->forced_dport ? : ct->tuplehash[!dir].tuple.src.u.udp.port; + } else if (nf_inet_addr_cmp(&ct->tuplehash[dir].tuple.src.u3, addr) && + ct->tuplehash[dir].tuple.src.u.udp.port != port) { + newaddr = ct->tuplehash[!dir].tuple.dst.u3; + newport = 0; + } else if (nf_inet_addr_cmp(&ct->tuplehash[dir].tuple.dst.u3, addr) && + ct->tuplehash[dir].tuple.dst.u.udp.port != port) { + newaddr = ct->tuplehash[!dir].tuple.src.u3; + newport = 0; } else return 1; if (nf_inet_addr_cmp(&newaddr, addr) && newport == port) return 1; - buflen = sip_sprintf_addr_port(ct, buffer, &newaddr, ntohs(newport)); + if (newport == 0) + buflen = sip_sprintf_addr(ct, buffer, &newaddr, false); + else + buflen = sip_sprintf_addr_port(ct, buffer, &newaddr, + ntohs(newport)); + return mangle_packet(skb, protoff, dataoff, dptr, datalen, matchoff, matchlen, buffer, buflen); }