From 2e0b44cc7059f9a90e131ef26b6b3c52fc6f686f Mon Sep 17 00:00:00 2001 From: Mohammed Javid Date: Mon, 22 Jan 2018 12:11:41 +0530 Subject: ipacm: Fix KW issue Fix KW issue and remove conditional check which is always true. Change-Id: I902b56c3eab262798813e3c9c6d920665e5ecb99 --- ipacm/src/IPACM_CmdQueue.cpp | 13 +++++-- ipacm/src/IPACM_ConntrackClient.cpp | 6 +-- ipacm/src/IPACM_ConntrackListener.cpp | 73 ++++++++++++++++------------------- ipacm/src/IPACM_Conntrack_NATApp.cpp | 23 +++++++---- ipacm/src/IPACM_EvtDispatcher.cpp | 6 +-- ipacm/src/IPACM_Filtering.cpp | 24 ++++++------ 6 files changed, 75 insertions(+), 70 deletions(-) diff --git a/ipacm/src/IPACM_CmdQueue.cpp b/ipacm/src/IPACM_CmdQueue.cpp index c612b7f..3a2d470 100644 --- a/ipacm/src/IPACM_CmdQueue.cpp +++ b/ipacm/src/IPACM_CmdQueue.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2013-2016, The Linux Foundation. All rights reserved. +Copyright (c) 2013-2018, The Linux Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -123,6 +123,7 @@ void* MessageQueue::Process(void *param) MessageQueue *MsgQueueExternal = NULL; Message *item = NULL; param = NULL; + const char *eventName = NULL; IPACMDBG("MessageQueue::Process()\n"); @@ -160,8 +161,12 @@ void* MessageQueue::Process(void *param) } else { - IPACMDBG("Get event %s from internal queue.\n", - IPACM_Iface::ipacmcfg->getEventName(item->evt.data.event)); + eventName = IPACM_Iface::ipacmcfg->getEventName(item->evt.data.event); + if (eventName != NULL) + { + IPACMDBG("Get event %s from internal queue.\n", + eventName); + } } if(item == NULL) @@ -196,7 +201,7 @@ void* MessageQueue::Process(void *param) return NULL; } - IPACMDBG("Processing item %p event ID: %d\n",item,item->evt.data.event); + IPACMDBG("Processing item %pK event ID: %d\n",item,item->evt.data.event); item->evt.callback_ptr(&item->evt.data); delete item; item = NULL; diff --git a/ipacm/src/IPACM_ConntrackClient.cpp b/ipacm/src/IPACM_ConntrackClient.cpp index 3eab6fa..8a2499c 100644 --- a/ipacm/src/IPACM_ConntrackClient.cpp +++ b/ipacm/src/IPACM_ConntrackClient.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2013-2016, The Linux Foundation. All rights reserved. +Copyright (c) 2013-2018, The Linux Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -177,8 +177,6 @@ int IPACM_ConntrackClient::IPA_Conntrack_Filters_Ignore_Bridge_Addrs /* retrieve bridge interface ipv4 address */ memset(&ifr, 0, sizeof(struct ifreq)); ifr.ifr_addr.sa_family = AF_INET; - (void)strlcpy(ifr.ifr_name, IPACM_Iface::ipacmcfg->ipa_virtual_iface_name, sizeof(ifr.ifr_name)); - IPACMDBG("bridge interface name (%s)\n", ifr.ifr_name); if(strlen(IPACM_Iface::ipacmcfg->ipa_virtual_iface_name) >= sizeof(ifr.ifr_name)) { @@ -187,6 +185,8 @@ int IPACM_ConntrackClient::IPA_Conntrack_Filters_Ignore_Bridge_Addrs close(fd); return -1; } + (void)strlcpy(ifr.ifr_name, IPACM_Iface::ipacmcfg->ipa_virtual_iface_name, sizeof(ifr.ifr_name)); + IPACMDBG("bridge interface name (%s)\n", ifr.ifr_name); ret = ioctl(fd, SIOCGIFADDR, &ifr); if (ret < 0) diff --git a/ipacm/src/IPACM_ConntrackListener.cpp b/ipacm/src/IPACM_ConntrackListener.cpp index 4a0c1c1..29a70b9 100644 --- a/ipacm/src/IPACM_ConntrackListener.cpp +++ b/ipacm/src/IPACM_ConntrackListener.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2013-2017, The Linux Foundation. All rights reserved. +Copyright (c) 2013-2018, The Linux Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -1037,9 +1037,9 @@ void IPACM_ConntrackListener::ProcessTCPorUDPMsg( nat_entry.ct = ct; nat_entry.type = type; - memset(&rule, 0, sizeof(rule)); - IPACMDBG("Received type:%d with proto:%d\n", type, l4proto); - status = nfct_get_attr_u32(ct, ATTR_STATUS); + memset(&rule, 0, sizeof(rule)); + IPACMDBG("Received type:%d with proto:%d\n", type, l4proto); + status = nfct_get_attr_u32(ct, ATTR_STATUS); /* Retrieve Protocol */ rule.protocol = nfct_get_attr_u8(ct, ATTR_REPL_L4PROTO); @@ -1089,47 +1089,40 @@ void IPACM_ConntrackListener::ProcessTCPorUDPMsg( #ifdef CT_OPT HandleLan2Lan(ct, type, &rule); #endif - return; + IPACMDBG("Neither source Nor destination nat\n"); + goto IGNORE; } - } + } - if(IPS_DST_NAT == status || IPS_SRC_NAT == status) - { - PopulateTCPorUDPEntry(ct, status, &rule); - rule.public_ip = wan_ipaddr; - } - else - { - IPACMDBG("Neither source Nor destination nat\n"); - goto IGNORE; - } + PopulateTCPorUDPEntry(ct, status, &rule); + rule.public_ip = wan_ipaddr; - if (rule.private_ip != wan_ipaddr) - { - isAdd = AddIface(&rule, &nat_entry.isTempEntry); - if (!isAdd) - { - goto IGNORE; - } - } - else - { - if (isStaMode) - { - IPACMDBG("In STA mode, ignore connections destinated to STA interface\n"); - goto IGNORE; - } + if (rule.private_ip != wan_ipaddr) + { + isAdd = AddIface(&rule, &nat_entry.isTempEntry); + if (!isAdd) + { + goto IGNORE; + } + } + else + { + if (isStaMode) + { + IPACMDBG("In STA mode, ignore connections destinated to STA interface\n"); + goto IGNORE; + } - IPACMDBG("For embedded connections add dummy nat rule\n"); - IPACMDBG("Change private port %d to %d\n", - rule.private_port, rule.public_port); - rule.private_port = rule.public_port; - } + IPACMDBG("For embedded connections add dummy nat rule\n"); + IPACMDBG("Change private port %d to %d\n", + rule.private_port, rule.public_port); + rule.private_port = rule.public_port; + } - CheckSTAClient(&rule, &nat_entry.isTempEntry); - nat_entry.rule = &rule; - AddORDeleteNatEntry(&nat_entry); - return; + CheckSTAClient(&rule, &nat_entry.isTempEntry); + nat_entry.rule = &rule; + AddORDeleteNatEntry(&nat_entry); + return; IGNORE: IPACMDBG_H("ignoring below Nat Entry\n"); diff --git a/ipacm/src/IPACM_Conntrack_NATApp.cpp b/ipacm/src/IPACM_Conntrack_NATApp.cpp index 27bf95a..4004597 100644 --- a/ipacm/src/IPACM_Conntrack_NATApp.cpp +++ b/ipacm/src/IPACM_Conntrack_NATApp.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2013-2017, The Linux Foundation. All rights reserved. +Copyright (c) 2013-2018, The Linux Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -94,11 +94,7 @@ int NatApp::Init(void) } memset(pALGPorts, 0, sizeof(ipacm_alg) * nALGPort); - if(pConfig->GetAlgPorts(nALGPort, pALGPorts) != 0) - { - IPACMERR("Unable to retrieve ALG prots\n"); - goto fail; - } + pConfig->GetAlgPorts(nALGPort, pALGPorts); IPACMDBG("Printing %d alg ports information\n", nALGPort); for(int cnt=0; cntenqueue(item); - IPACMDBG("Enqueued item %p\n", item); + IPACMDBG("Enqueued item %pK\n", item); if(pthread_cond_signal(&cond_var) != 0) { @@ -141,7 +141,7 @@ void IPACM_EvtDispatcher::ProcessEvt(ipacm_cmd_q_data *data) if(data->evt_data != NULL) { - IPACMDBG("free the event:%d data: %p\n", data->event, data->evt_data); + IPACMDBG("free the event:%d data: %pK\n", data->event, data->evt_data); free(data->evt_data); } return; diff --git a/ipacm/src/IPACM_Filtering.cpp b/ipacm/src/IPACM_Filtering.cpp index 411fe90..3545d81 100644 --- a/ipacm/src/IPACM_Filtering.cpp +++ b/ipacm/src/IPACM_Filtering.cpp @@ -1,5 +1,5 @@ /* -Copyright (c) 2013-2016, The Linux Foundation. All rights reserved. +Copyright (c) 2013-2018, The Linux Foundation. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are @@ -87,7 +87,7 @@ bool IPACM_Filtering::AddFilteringRule(struct ipa_ioc_add_flt_rule const *ruleTa retval = ioctl(fd, IPA_IOC_ADD_FLT_RULE, ruleTable); if (retval != 0) { - IPACMERR("Failed adding Filtering rule %p\n", ruleTable); + IPACMERR("Failed adding Filtering rule %pK\n", ruleTable); PERROR("unable to add filter rule:"); for (int cnt = 0; cnt < ruleTable->num_rules; cnt++) @@ -110,7 +110,7 @@ bool IPACM_Filtering::AddFilteringRule(struct ipa_ioc_add_flt_rule const *ruleTa } } - IPACMDBG("Added Filtering rule %p\n", ruleTable); + IPACMDBG("Added Filtering rule %pK\n", ruleTable); return true; } @@ -138,13 +138,13 @@ bool IPACM_Filtering::AddFilteringRuleAfter(struct ipa_ioc_add_flt_rule_after co if (retval != 0) { - IPACMERR("Failed adding Filtering rule %p\n", ruleTable); + IPACMERR("Failed adding Filtering rule %pK\n", ruleTable); return false; } - IPACMDBG("Added Filtering rule %p\n", ruleTable); + IPACMDBG("Added Filtering rule %pK\n", ruleTable); #else if (ruleTable) - IPACMERR("Not support adding Filtering rule %p\n", ruleTable); + IPACMERR("Not support adding Filtering rule %pK\n", ruleTable); #endif return true; } @@ -156,11 +156,11 @@ bool IPACM_Filtering::DeleteFilteringRule(struct ipa_ioc_del_flt_rule *ruleTable retval = ioctl(fd, IPA_IOC_DEL_FLT_RULE, ruleTable); if (retval != 0) { - IPACMERR("Failed deleting Filtering rule %p\n", ruleTable); + IPACMERR("Failed deleting Filtering rule %pK\n", ruleTable); return false; } - IPACMDBG("Deleted Filtering rule %p\n", ruleTable); + IPACMDBG("Deleted Filtering rule %pK\n", ruleTable); return true; } @@ -450,7 +450,7 @@ bool IPACM_Filtering::AddWanDLFilteringRule(struct ipa_ioc_add_flt_rule const *r ret = ioctl(fd_wwan_ioctl, WAN_IOC_ADD_FLT_RULE_EX, &qmi_rule_ex_msg); if (ret != 0) { - IPACMERR("Failed adding Filtering rule %p with ret %d\n ", &qmi_rule_ex_msg, ret); + IPACMERR("Failed adding Filtering rule %pK with ret %d\n ", &qmi_rule_ex_msg, ret); close(fd_wwan_ioctl); return false; } @@ -474,12 +474,12 @@ bool IPACM_Filtering::SendFilteringRuleIndex(struct ipa_fltr_installed_notif_req ret = ioctl(fd_wwan_ioctl, WAN_IOC_ADD_FLT_RULE_INDEX, table); if (ret != 0) { - IPACMERR("Failed adding filtering rule index %p with ret %d\n", table, ret); + IPACMERR("Failed adding filtering rule index %pK with ret %d\n", table, ret); close(fd_wwan_ioctl); return false; } - IPACMDBG("Added Filtering rule index %p\n", table); + IPACMDBG("Added Filtering rule index %pK\n", table); close(fd_wwan_ioctl); return true; } @@ -520,7 +520,7 @@ bool IPACM_Filtering::ModifyFilteringRule(struct ipa_ioc_mdfy_flt_rule* ruleTabl ret = ioctl(fd, IPA_IOC_MDFY_FLT_RULE, ruleTable); if (ret != 0) { - IPACMERR("Failed modifying filtering rule %p\n", ruleTable); + IPACMERR("Failed modifying filtering rule %pK\n", ruleTable); for (i = 0; i < ruleTable->num_rules; i++) { -- cgit v1.2.3