Merge 5e1e9facafb22446aa8c5c78e9c1bd3a76ab748d on remote branch
Change-Id: Ie9a9c4c9860f4a0c0b7131364df285b598d22ea7
diff --git a/ipacm/inc/IPACM_Filtering.h b/ipacm/inc/IPACM_Filtering.h
index 6667235..9393342 100644
--- a/ipacm/inc/IPACM_Filtering.h
+++ b/ipacm/inc/IPACM_Filtering.h
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2013-2019, The Linux Foundation. All rights reserved.
+Copyright (c) 2013-2019,2021, 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
@@ -56,6 +56,7 @@
IPACM_Filtering();
~IPACM_Filtering();
bool AddFilteringRule(struct ipa_ioc_add_flt_rule const *ruleTable);
+ bool AddFilteringRule_v2(struct ipa_ioc_add_flt_rule_v2 const *ruleTable);
bool AddFilteringRuleAfter(struct ipa_ioc_add_flt_rule_after const *ruleTable);
#ifdef IPA_IOCTL_SET_FNR_COUNTER_INFO
bool AddFilteringRule_hw_index(struct ipa_ioc_add_flt_rule *ruleTable, int hw_counter_index);
diff --git a/ipacm/src/IPACM_Filtering.cpp b/ipacm/src/IPACM_Filtering.cpp
index 875a794..e559cdf 100644
--- a/ipacm/src/IPACM_Filtering.cpp
+++ b/ipacm/src/IPACM_Filtering.cpp
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2013-2019, The Linux Foundation. All rights reserved.
+Copyright (c) 2013-2019,2021, 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
@@ -118,6 +118,50 @@
return true;
}
+bool IPACM_Filtering::AddFilteringRule_v2(struct ipa_ioc_add_flt_rule_v2 const *ruleTable)
+{
+ int retval = 0;
+ int i;
+ int num_rules = ruleTable->num_rules;
+ int cnt;
+
+ IPACMDBG_H("Printing filter add attributes\n");
+ IPACMDBG_H("ip type: %d\n", ruleTable->ip);
+ IPACMDBG_H("Number of rules: %d\n", ruleTable->num_rules);
+ IPACMDBG_H("End point: %d and global value: %d\n", ruleTable->ep, ruleTable->global);
+ IPACMDBG_H("commit value: %d\n", ruleTable->commit);
+ for (int cnt=0; cnt<ruleTable->num_rules; cnt++)
+ {
+ IPACMDBG("Filter rule:%d attrib mask: 0x%x\n", cnt,
+ ((struct ipa_flt_rule_add_v2 *)&ruleTable->rules)[cnt].rule.attrib.attrib_mask);
+ }
+
+ retval = ioctl(fd, IPA_IOC_ADD_FLT_RULE_V2, ruleTable);
+ if (retval != 0)
+ {
+ for (cnt = 0; cnt < ruleTable->num_rules; cnt++)
+ {
+ if (((struct ipa_flt_rule_add_v2 *)&ruleTable->rules)[cnt].status != 0)
+ {
+ IPACMDBG_H("Adding Filter rule:%d failed with status:%d\n",
+ cnt, ((struct ipa_flt_rule_add_v2 *)ruleTable->rules)[cnt].status);
+ }
+ }
+ return false;
+ }
+
+ for (cnt = 0; cnt<ruleTable->num_rules; cnt++)
+ {
+ if (((struct ipa_flt_rule_add_v2 *)&ruleTable->rules)[cnt].status != 0)
+ {
+ IPACMERR("Adding Filter rule:%d failed with status:%d\n",
+ cnt, ((struct ipa_flt_rule_add_v2 *)ruleTable->rules)[cnt].status);
+ }
+ }
+ IPACMDBG("Added Filtering rule %p\n", ruleTable);
+ return true;
+}
+
#ifdef IPA_IOCTL_SET_FNR_COUNTER_INFO
bool IPACM_Filtering::AddFilteringRule_hw_index(struct ipa_ioc_add_flt_rule *ruleTable, int hw_counter_index)
{
diff --git a/ipacm/src/IPACM_Lan.cpp b/ipacm/src/IPACM_Lan.cpp
index c97168d..bffcd8e 100644
--- a/ipacm/src/IPACM_Lan.cpp
+++ b/ipacm/src/IPACM_Lan.cpp
@@ -1,5 +1,5 @@
/*
-Copyright (c) 2013-2020, The Linux Foundation. All rights reserved.
+Copyright (c) 2013-2021, 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
@@ -3960,144 +3960,154 @@
int IPACM_Lan::install_ipv4_icmp_flt_rule()
{
- int len;
- struct ipa_ioc_add_flt_rule* flt_rule;
- struct ipa_flt_rule_add flt_rule_entry;
- bool result;
+ int ret = IPACM_SUCCESS;
+ struct ipa_ioc_add_flt_rule_v2 *flt_rule;
+ struct ipa_flt_rule_add_v2 *flt_rule_entry;
if(rx_prop != NULL)
{
- len = sizeof(struct ipa_ioc_add_flt_rule) + sizeof(struct ipa_flt_rule_add);
-
- flt_rule = (struct ipa_ioc_add_flt_rule *)calloc(1, len);
+ flt_rule = (struct ipa_ioc_add_flt_rule_v2 *)calloc(1,
+ sizeof(struct ipa_ioc_add_flt_rule_v2));
if (!flt_rule)
{
- IPACMERR("Error Locate ipa_flt_rule_add memory...\n");
+ IPACMERR("Error Locate ipa_ioc_add_flt_rule_v2 memory...\n");
return IPACM_FAILURE;
}
+ flt_rule_entry = (struct ipa_flt_rule_add_v2 *)calloc(1, sizeof(struct ipa_flt_rule_add_v2));
+ if (!flt_rule_entry)
+ {
+ IPACMERR("Failed to allocate ipa_flt_rule_add_v2 memory...\n");
+ free(flt_rule);
+ return IPACM_FAILURE;
+ }
+ flt_rule->rules = (uint64_t)flt_rule_entry;
flt_rule->commit = 1;
flt_rule->ep = rx_prop->rx[0].src_pipe;
flt_rule->global = false;
flt_rule->ip = IPA_IP_v4;
flt_rule->num_rules = 1;
+ flt_rule->flt_rule_size = sizeof(struct ipa_flt_rule_add_v2);
- memset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add));
-
- flt_rule_entry.rule.retain_hdr = 1;
- flt_rule_entry.rule.to_uc = 0;
- flt_rule_entry.rule.eq_attrib_type = 0;
- flt_rule_entry.at_rear = true;
- flt_rule_entry.flt_rule_hdl = -1;
- flt_rule_entry.status = -1;
- flt_rule_entry.rule.action = IPA_PASS_TO_EXCEPTION;
+ flt_rule_entry->rule.retain_hdr = 1;
+ flt_rule_entry->rule.to_uc = 0;
+ flt_rule_entry->rule.eq_attrib_type = 0;
+ flt_rule_entry->at_rear = true;
+ flt_rule_entry->flt_rule_hdl = -1;
+ flt_rule_entry->status = -1;
+ flt_rule_entry->rule.action = IPA_PASS_TO_EXCEPTION;
if (IPACM_Iface::ipacmcfg->isIPAv3Supported())
- flt_rule_entry.rule.hashable = true;
- memcpy(&flt_rule_entry.rule.attrib, &rx_prop->rx[0].attrib, sizeof(flt_rule_entry.rule.attrib));
+ flt_rule_entry->rule.hashable = true;
+ flt_rule_entry->rule.close_aggr_irq_mod = true;
+ memcpy(&flt_rule_entry->rule.attrib,
+ &rx_prop->rx[0].attrib,
+ sizeof(flt_rule_entry->rule.attrib));
- flt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_PROTOCOL;
- flt_rule_entry.rule.attrib.u.v4.protocol = (uint8_t)IPACM_FIREWALL_IPPROTO_ICMP;
- memcpy(&(flt_rule->rules[0]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));
+ flt_rule_entry->rule.attrib.attrib_mask |= IPA_FLT_PROTOCOL;
+ flt_rule_entry->rule.attrib.u.v4.protocol = (uint8_t)IPACM_FIREWALL_IPPROTO_ICMP;
#ifdef IPA_IOCTL_SET_FNR_COUNTER_INFO
/* use index hw-counter */
if(ipa_if_cate == WLAN_IF && IPACM_Iface::ipacmcfg->hw_fnr_stats_support)
{
- IPACMDBG_H("hw-index-enable %d, counter %d\n", IPACM_Iface::ipacmcfg->hw_fnr_stats_support, IPACM_Iface::ipacmcfg->hw_counter_offset + UL_ALL);
- result = m_filtering.AddFilteringRule_hw_index(flt_rule, IPACM_Iface::ipacmcfg->hw_counter_offset + UL_ALL);
- } else {
- result = m_filtering.AddFilteringRule(flt_rule);
+ IPACMDBG_H("hw-index-enable %d, counter %d\n",
+ IPACM_Iface::ipacmcfg->hw_fnr_stats_support,
+ IPACM_Iface::ipacmcfg->hw_counter_offset + UL_ALL);
+ flt_rule_entry->rule.enable_stats = 1;
+ flt_rule_entry->rule.cnt_idx = IPACM_Iface::ipacmcfg->hw_counter_offset + UL_ALL;
}
-#else
- result = m_filtering.AddFilteringRule(flt_rule);
#endif
- if (result == false)
+ if (m_filtering.AddFilteringRule_v2(flt_rule) == false)
{
IPACMERR("Error Adding Filtering rule, aborting...\n");
- free(flt_rule);
- return IPACM_FAILURE;
+ ret = IPACM_FAILURE;
}
else
{
IPACM_Iface::ipacmcfg->increaseFltRuleCount(rx_prop->rx[0].src_pipe, IPA_IP_v4, 1);
- ipv4_icmp_flt_rule_hdl[0] = flt_rule->rules[0].flt_rule_hdl;
+ ipv4_icmp_flt_rule_hdl[0] = flt_rule_entry->flt_rule_hdl;
IPACMDBG_H("IPv4 icmp filter rule HDL:0x%x\n", ipv4_icmp_flt_rule_hdl[0]);
- free(flt_rule);
}
+ free(flt_rule_entry);
+ free(flt_rule);
}
- return IPACM_SUCCESS;
+
+ return ret;
}
int IPACM_Lan::install_ipv6_icmp_flt_rule()
{
-
- int len;
- struct ipa_ioc_add_flt_rule* flt_rule;
- struct ipa_flt_rule_add flt_rule_entry;
- bool result;
+ int ret = IPACM_SUCCESS;
+ struct ipa_ioc_add_flt_rule_v2 *flt_rule;
+ struct ipa_flt_rule_add_v2 *flt_rule_entry;
if(rx_prop != NULL)
{
- len = sizeof(struct ipa_ioc_add_flt_rule) + sizeof(struct ipa_flt_rule_add);
-
- flt_rule = (struct ipa_ioc_add_flt_rule *)calloc(1, len);
+ flt_rule = (struct ipa_ioc_add_flt_rule_v2 *)calloc(1, sizeof(struct ipa_ioc_add_flt_rule_v2));
if (!flt_rule)
{
- IPACMERR("Error Locate ipa_flt_rule_add memory...\n");
+ IPACMERR("Error Locate ipa_ioc_add_flt_rule_v2 memory...\n");
return IPACM_FAILURE;
}
+ flt_rule_entry = (struct ipa_flt_rule_add_v2 *)calloc(1, sizeof(struct ipa_flt_rule_add_v2));
+ if (!flt_rule_entry)
+ {
+ IPACMERR("Failed to allocate ipa_flt_rule_add_v2 memory...\n");
+ free(flt_rule);
+ return IPACM_FAILURE;
+ }
+ flt_rule->rules = (uint64_t)flt_rule_entry;
flt_rule->commit = 1;
flt_rule->ep = rx_prop->rx[0].src_pipe;
flt_rule->global = false;
flt_rule->ip = IPA_IP_v6;
flt_rule->num_rules = 1;
+ flt_rule->flt_rule_size = sizeof(struct ipa_flt_rule_add_v2);
- memset(&flt_rule_entry, 0, sizeof(struct ipa_flt_rule_add));
-
- flt_rule_entry.rule.retain_hdr = 1;
- flt_rule_entry.rule.to_uc = 0;
- flt_rule_entry.rule.eq_attrib_type = 0;
- flt_rule_entry.at_rear = true;
- flt_rule_entry.flt_rule_hdl = -1;
- flt_rule_entry.status = -1;
- flt_rule_entry.rule.action = IPA_PASS_TO_EXCEPTION;
+ flt_rule_entry->rule.retain_hdr = 1;
+ flt_rule_entry->rule.to_uc = 0;
+ flt_rule_entry->rule.eq_attrib_type = 0;
+ flt_rule_entry->at_rear = true;
+ flt_rule_entry->flt_rule_hdl = -1;
+ flt_rule_entry->status = -1;
+ flt_rule_entry->rule.action = IPA_PASS_TO_EXCEPTION;
if (IPACM_Iface::ipacmcfg->isIPAv3Supported())
- flt_rule_entry.rule.hashable = false;
- memcpy(&flt_rule_entry.rule.attrib, &rx_prop->rx[0].attrib, sizeof(flt_rule_entry.rule.attrib));
- flt_rule_entry.rule.attrib.attrib_mask |= IPA_FLT_NEXT_HDR;
- flt_rule_entry.rule.attrib.u.v6.next_hdr = (uint8_t)IPACM_FIREWALL_IPPROTO_ICMP6;
- memcpy(&(flt_rule->rules[0]), &flt_rule_entry, sizeof(struct ipa_flt_rule_add));
+ flt_rule_entry->rule.hashable = false;
+ flt_rule_entry->rule.close_aggr_irq_mod = true;
+ memcpy(&flt_rule_entry->rule.attrib, &rx_prop->rx[0].attrib, sizeof(flt_rule_entry->rule.attrib));
+
+ flt_rule_entry->rule.attrib.attrib_mask |= IPA_FLT_NEXT_HDR;
+ flt_rule_entry->rule.attrib.u.v6.next_hdr = (uint8_t)IPACM_FIREWALL_IPPROTO_ICMP6;
#ifdef IPA_IOCTL_SET_FNR_COUNTER_INFO
/* use index hw-counter */
if(ipa_if_cate == WLAN_IF && IPACM_Iface::ipacmcfg->hw_fnr_stats_support)
{
- IPACMDBG_H("hw-index-enable %d, counter %d\n", IPACM_Iface::ipacmcfg->hw_fnr_stats_support, IPACM_Iface::ipacmcfg->hw_counter_offset + UL_ALL);
- result = m_filtering.AddFilteringRule_hw_index(flt_rule, IPACM_Iface::ipacmcfg->hw_counter_offset + UL_ALL);
- } else {
- result = m_filtering.AddFilteringRule(flt_rule);
+ IPACMDBG_H("hw-index-enable %d, counter %d\n",
+ IPACM_Iface::ipacmcfg->hw_fnr_stats_support,
+ IPACM_Iface::ipacmcfg->hw_counter_offset + UL_ALL);
+ flt_rule_entry->rule.enable_stats = 1;
+ flt_rule_entry->rule.cnt_idx = IPACM_Iface::ipacmcfg->hw_counter_offset + UL_ALL;
}
-#else
- result = m_filtering.AddFilteringRule(flt_rule);
#endif
- if (result == false)
+ if (m_filtering.AddFilteringRule_v2(flt_rule) == false)
{
IPACMERR("Error Adding Filtering rule, aborting...\n");
- free(flt_rule);
- return IPACM_FAILURE;
+ ret = IPACM_FAILURE;
}
else
{
IPACM_Iface::ipacmcfg->increaseFltRuleCount(rx_prop->rx[0].src_pipe, IPA_IP_v6, 1);
- ipv6_icmp_flt_rule_hdl[0] = flt_rule->rules[0].flt_rule_hdl;
+ ipv6_icmp_flt_rule_hdl[0] = flt_rule_entry->flt_rule_hdl;
IPACMDBG_H("IPv6 icmp filter rule HDL:0x%x\n", ipv6_icmp_flt_rule_hdl[0]);
- free(flt_rule);
}
+ free(flt_rule_entry);
+ free(flt_rule);
}
- return IPACM_SUCCESS;
+ return ret;
}
int IPACM_Lan::add_dummy_private_subnet_flt_rule(ipa_ip_type iptype)