summaryrefslogtreecommitdiff
path: root/ipacm/src/IPACM_ConntrackListener.cpp
diff options
context:
space:
mode:
authorSkylar Chang <chiaweic@codeaurora.org>2014-02-24 23:16:33 -0800
committerSkylar Chang <chiaweic@codeaurora.org>2014-02-25 10:32:27 -0800
commitc0089bcb817911f610f475b19f9441f505c24198 (patch)
tree9f8c19c9d6cfdaa9ad98536329a01cdf52be942a /ipacm/src/IPACM_ConntrackListener.cpp
parent945e148b270ca90e48a8a1fe717f0a4bb8ab741b (diff)
downloadipacfg-mgr-c0089bcb817911f610f475b19f9441f505c24198.tar.gz
IPANAT: fix nat entry is not clean when usb-client unplug
when IPANAT received del_neighbor event, it should clean the NAT entry in IPA-hw related to that ip-address. Current IPANAT is failed to clean NAT entry in IPA-HW. Change-Id: If02dfc23cbf241c902eeda99fd7ffd64bbc7c060 Signed-off-by: Skylar Chang <chiaweic@codeaurora.org>
Diffstat (limited to 'ipacm/src/IPACM_ConntrackListener.cpp')
-rw-r--r--ipacm/src/IPACM_ConntrackListener.cpp47
1 files changed, 30 insertions, 17 deletions
diff --git a/ipacm/src/IPACM_ConntrackListener.cpp b/ipacm/src/IPACM_ConntrackListener.cpp
index 3b62bd4..f5ba1dd 100644
--- a/ipacm/src/IPACM_ConntrackListener.cpp
+++ b/ipacm/src/IPACM_ConntrackListener.cpp
@@ -128,6 +128,29 @@ void IPACM_ConntrackListener::HandleNeighIpAddrEvt(void *in_param, bool del)
int fd = 0, len = 0, cnt, i, j;
struct ifreq ifr;
+ /* existing nat-entry needs to be clean */
+ if(del == true)
+ {
+ if(data->ipv4_addr == 0 || data->iptype != IPA_IP_v4)
+ {
+ IPACMDBG("Ignoring IPA_NEIGH_CLIENT_IP_ADDR_DEL_EVENT EVENT\n");
+ return;
+ }
+ IPACMDBG("Received interface index %d with ip type:%d", data->if_index, data->iptype);
+ IPACMDBG("Entering NAT entry deletion checking\n");
+ for(j = 0; j < MAX_NAT_IFACES; j++)
+ {
+ if(nat_iface_ipv4_addr[j] == data->ipv4_addr)
+ {
+ /* Reset */
+ IPACMDBG("Reseting ct filters of Interface (%d), entry (%d)\n", data->if_index, j);
+ IPACM_ConntrackClient::iptodot("with ipv4 address", nat_iface_ipv4_addr[j]);
+ nat_iface_ipv4_addr[j] = 0;
+ }
+ }
+ return;
+ }
+
if(del == false)
{
if(data->ipv4_addr == 0 || data->iptype != IPA_IP_v4)
@@ -210,30 +233,19 @@ void IPACM_ConntrackListener::HandleNeighIpAddrEvt(void *in_param, bool del)
{
for(j = 0; j < MAX_NAT_IFACES; j++)
{
- if(nat_iface_ipv4_addr[j] == 0)
+ /* check if duplicate NAT ip */
+ if(nat_iface_ipv4_addr[j] == data->ipv4_addr)
{
- nat_iface_ipv4_addr[j] = data->ipv4_addr;
break;
}
- }
- IPACMDBG("Nating connections of Interface (%s)\n", pNatIfaces[i].iface_name);
- IPACM_ConntrackClient::iptodot("with ipv4 address", nat_iface_ipv4_addr[j]);
- }
- else
- {
- for(j = 0; j < MAX_NAT_IFACES; j++)
- {
- if(nat_iface_ipv4_addr[j] == data->ipv4_addr)
+ if(nat_iface_ipv4_addr[j] == 0)
{
- /* Reset */
- IPACMDBG("Reseting ct filters of Interface (%s)\n", pNatIfaces[i].iface_name);
- IPACM_ConntrackClient::iptodot("with ipv4 address", nat_iface_ipv4_addr[j]);
-
- nat_iface_ipv4_addr[j] = 0;
+ nat_iface_ipv4_addr[j] = data->ipv4_addr;
break;
}
}
-
+ IPACMDBG("Nating connections of Interface (%s), entry (%d)\n", pNatIfaces[i].iface_name, j);
+ IPACM_ConntrackClient::iptodot("with ipv4 address", nat_iface_ipv4_addr[j]);
}
break;
}
@@ -626,6 +638,7 @@ void IPACM_ConntrackListener::ProcessTCPorUDPMsg(
if(rule.private_ip == nat_iface_ipv4_addr[cnt] ||
rule.target_ip == nat_iface_ipv4_addr[cnt])
{
+ IPACMDBG("matched nat_iface_ipv4_addr entry(%d)\n", cnt);
IPACM_ConntrackClient::iptodot("ProcessTCPorUDPMsg(): Nat entry match with ip addr",
nat_iface_ipv4_addr[cnt]);
break;