aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/nat
diff options
context:
space:
mode:
authorFilip Varga <fivarga@cisco.com>2021-09-17 14:11:59 +0200
committerOle Tr�an <otroan@employees.org>2021-10-20 10:46:13 +0000
commit27775f0b903f4ea088514153e27354d5094cbf0c (patch)
treef755a427ef21875dfddeffbde58616747de6e3c9 /src/plugins/nat
parent4c3c60daf7bccffc0f1fe59d8d09557bc62d00b0 (diff)
nat: NAT44-ED api fix and improvement
This patch fixes issue with NAT_API_IS_TWICE_NAT and NAT_API_IS_ADDR_ONLY flags. Because of control plane code change - move from boolean parameters to flags in https://gerrit.fd.io/r/c/vpp/+/32796 patch these api flags weren't correctly set. Type: fix Change-Id: Ieec5fe6bdcca314da027f2d23e3a24f174391a6f Signed-off-by: Filip Varga <fivarga@cisco.com>
Diffstat (limited to 'src/plugins/nat')
-rw-r--r--src/plugins/nat/nat44-ed/nat44_ed.c8
-rw-r--r--src/plugins/nat/nat44-ed/nat44_ed.h5
-rw-r--r--src/plugins/nat/nat44-ed/nat44_ed_api.c15
-rw-r--r--src/plugins/nat/nat44-ed/nat44_ed_format.c2
4 files changed, 14 insertions, 16 deletions
diff --git a/src/plugins/nat/nat44-ed/nat44_ed.c b/src/plugins/nat/nat44-ed/nat44_ed.c
index b1917f3b36c..f58002c156d 100644
--- a/src/plugins/nat/nat44-ed/nat44_ed.c
+++ b/src/plugins/nat/nat44-ed/nat44_ed.c
@@ -3068,7 +3068,7 @@ nat44_ed_add_del_static_mapping_addr_only_cb (
for (i = 0; i < vec_len (sm->to_resolve); i++)
{
rp = sm->to_resolve + i;
- if (rp->addr_only && rp->sw_if_index == sw_if_index)
+ if (is_sm_addr_only (rp->flags) && rp->sw_if_index == sw_if_index)
{
match = 1;
break;
@@ -3079,8 +3079,8 @@ nat44_ed_add_del_static_mapping_addr_only_cb (
return;
}
- m = nat44_ed_sm_o2i_lookup (sm, *address, rp->addr_only ? 0 : rp->e_port, 0,
- rp->proto);
+ m = nat44_ed_sm_o2i_lookup (
+ sm, *address, is_sm_addr_only (rp->flags) ? 0 : rp->e_port, 0, rp->proto);
if (is_delete)
{
@@ -3171,7 +3171,7 @@ nat44_ed_add_del_interface_address_cb (ip4_main_t *im, uword opaque,
for (i = 0; i < vec_len (sm->to_resolve); i++)
{
rp = sm->to_resolve + i;
- if (rp->addr_only)
+ if (is_sm_addr_only (rp->flags))
{
continue;
}
diff --git a/src/plugins/nat/nat44-ed/nat44_ed.h b/src/plugins/nat/nat44-ed/nat44_ed.h
index 4665f7c0966..9fb34aa45f1 100644
--- a/src/plugins/nat/nat44-ed/nat44_ed.h
+++ b/src/plugins/nat/nat44-ed/nat44_ed.h
@@ -455,11 +455,6 @@ typedef struct
u32 vrf_id;
ip_protocol_t proto;
u32 flags;
- int addr_only;
- int twice_nat;
- int out2in_only;
- int identity_nat;
- int exact;
u8 *tag;
} snat_static_map_resolve_t;
diff --git a/src/plugins/nat/nat44-ed/nat44_ed_api.c b/src/plugins/nat/nat44-ed/nat44_ed_api.c
index 759cfd37e26..15059752ee7 100644
--- a/src/plugins/nat/nat44-ed/nat44_ed_api.c
+++ b/src/plugins/nat/nat44-ed/nat44_ed_api.c
@@ -840,10 +840,12 @@ send_nat44_static_map_resolve_details (snat_static_map_resolve_t * m,
rmp->vrf_id = htonl (m->vrf_id);
rmp->context = context;
- if (m->twice_nat)
- rmp->flags |= NAT_API_IS_TWICE_NAT;
+ if (is_sm_twice_nat (m->flags))
+ {
+ rmp->flags |= NAT_API_IS_TWICE_NAT;
+ }
- if (m->addr_only)
+ if (is_sm_addr_only (m->flags))
{
rmp->flags |= NAT_API_IS_ADDR_ONLY;
}
@@ -853,6 +855,7 @@ send_nat44_static_map_resolve_details (snat_static_map_resolve_t * m,
rmp->external_port = m->e_port;
rmp->local_port = m->l_port;
}
+
if (m->tag)
strncpy ((char *) rmp->tag, (char *) m->tag, vec_len (m->tag));
@@ -882,7 +885,7 @@ vl_api_nat44_static_mapping_dump_t_handler (vl_api_nat44_static_mapping_dump_t
for (j = 0; j < vec_len (sm->to_resolve); j++)
{
rp = sm->to_resolve + j;
- if (!rp->identity_nat)
+ if (!is_sm_identity_nat (rp->flags))
send_nat44_static_map_resolve_details (rp, reg, mp->context);
}
}
@@ -985,7 +988,7 @@ send_nat44_identity_map_resolve_details (snat_static_map_resolve_t * m,
rmp->_vl_msg_id =
ntohs (VL_API_NAT44_IDENTITY_MAPPING_DETAILS + sm->msg_id_base);
- if (m->addr_only)
+ if (is_sm_addr_only (m->flags))
rmp->flags = (vl_api_nat_config_flags_t) NAT_API_IS_ADDR_ONLY;
rmp->port = m->l_port;
@@ -1027,7 +1030,7 @@ static void
for (j = 0; j < vec_len (sm->to_resolve); j++)
{
rp = sm->to_resolve + j;
- if (rp->identity_nat)
+ if (is_sm_identity_nat (rp->flags))
send_nat44_identity_map_resolve_details (rp, reg, mp->context);
}
}
diff --git a/src/plugins/nat/nat44-ed/nat44_ed_format.c b/src/plugins/nat/nat44-ed/nat44_ed_format.c
index 5eb683d888e..81e743fd276 100644
--- a/src/plugins/nat/nat44-ed/nat44_ed_format.c
+++ b/src/plugins/nat/nat44-ed/nat44_ed_format.c
@@ -191,7 +191,7 @@ format_snat_static_map_to_resolve (u8 * s, va_list * args)
snat_static_map_resolve_t *m = va_arg (*args, snat_static_map_resolve_t *);
vnet_main_t *vnm = vnet_get_main ();
- if (m->addr_only)
+ if (is_sm_addr_only (m->flags))
s = format (s, "local %U external %U vrf %d",
format_ip4_address, &m->l_addr,
format_vnet_sw_if_index_name, vnm, m->sw_if_index, m->vrf_id);
#n213'>213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326
# Copyright (c) 2022 Cisco and/or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Keywords used in suite setups."""

*** Settings ***
| Library | resources.libraries.python.DPDK.DPDKTools
| Library | resources.libraries.python.InterfaceUtil
| Library | resources.libraries.python.NGINX.NGINXTools
| Library | resources.tools.ab.ABTools
| Library | resources.libraries.python.Iperf3
| Library | resources.libraries.python.NodePath
| Library | resources.libraries.python.topology.Topology
| Library | resources.libraries.python.TrafficGenerator
| Variables | resources/libraries/python/Constants.py
|
| Documentation | Suite setup keywords.

*** Keywords ***
| Create suite topology variables
| | [Documentation]
| | ... | Create suite topology variables
| |
| | ... | _NOTE:_ This KW sets various suite variables based on filtered
| | ... | topology. All variables are set with also backward compatibility
| | ... | format dut{m}_if{n} (where the value type is string).
| | ... | List type allows to access physical interfaces in same way as
| | ... | virtual interface (e.g. SRIOV). This keeps abstracted compatibility
| | ... | between existing L1 and L2 KWs library and underlaying physical
| | ... | topology.
| |
| | ... | - duts - List of DUT nodes (name as seen in topology file).
| | ... | - duts_count - Number of DUT nodes.
| | ... | - int - Interfacy type (layer).
| | ... | Type: string
| | ... | - dut{n} - DUTx node.
| | ... | Type: dictionary
| | ... | - dut{m}_pf{n} - Nth interface of Mth DUT.
| | ... | Type: list
| | ... | - dut{m}_pf{n}_mac - Nth interface of Mth DUT - MAC address.
| | ... | Type: list
| | ... | - dut{m}_pf{n}_vlan - Nth interface of Mth DUT - VLAN id.
| | ... | Type: list
| | ... | - dut{m}_pf{n}_pci - Nth interface of Mth DUT - PCI address.
| | ... | Type: list
| | ... | - dut{m}_pf{n}_ip4_addr - Nth interface of Mth DUT - IPv4 address.
| | ... | Type: list
| | ... | - dut{m}_pf{n}_ip4_prefix - Nth interface of Mth DUT - IPv4 prefix.
| | ... | Type: list
| |
| | ... | *Arguments:*
| | ... | - @{actions} - Additional setup action. Type: list
| |
| | [Arguments] | @{actions}
| |
| | ${variables}= | Get Dictionary Keys | ${topology_info}
| | FOR | ${variable} | IN | @{variables}
| | | ${value}= | Get From Dictionary | ${topology_info} | ${variable}
| | | Set Suite Variable | ${${variable}} | ${value}
| | END
| | FOR | ${action} | IN | @{actions}
| | | Run Keyword | Additional Suite setup Action For ${action}
| | END

| Setup suite topology interfaces
| | [Documentation]
| | ... | Common suite setup for one to multiple link tests.
| | ... |
| | ... | Compute path for testing on given topology nodes in circular topology
| | ... | based on interface model provided as an argument and set
| | ... | corresponding suite variables.
| |
| | ... | *Arguments:*
| | ... | - ${actions} - Additional setup action. Type: list
| |
| | [Arguments] | @{actions}
| |
| | Start Suite Setup Export
| | ${nic_model_list}= | Create list | ${nic_name}
| | &{info}= | Compute Circular Topology
| | ... | ${nodes} | filter_list=${nic_model_list} | nic_pfs=${nic_pfs}
| | ... | always_same_link=${False} | topo_has_tg=${True}
| | Set suite variable | &{topology_info} | &{info}
| | Create suite topology variables | @{actions}
| | Finalize Suite Setup Export

| Setup suite topology interfaces with no TG
| | [Documentation]
| | ... | Common suite setup for single link tests with no traffic generator
| | ... | node.
| | ... |
| | ... | Compute path for testing on given topology nodes in circular topology
| | ... | based on interface model provided as an argument and set
| | ... | corresponding suite variables.
| |
| | ... | *Arguments:*
| | ... | - ${actions} - Additional setup action. Type: list
| |
| | [Arguments] | @{actions}
| |
| | Start Suite Setup Export
| | ${nic_model_list}= | Create list | ${nic_name}
| | &{info}= | Compute Circular Topology
| | ... | ${nodes} | filter_list=${nic_model_list} | nic_pfs=${nic_pfs}
| | ... | always_same_link=${True} | topo_has_tg=${False}
| | Set suite variable | &{topology_info} | &{info}
| | Create suite topology variables | @{actions}
| | Finalize Suite Setup Export

| Setup suite topology interfaces with no DUT
| | [Documentation]
| | ... | Common suite setup for single link tests with no device under test
| | ... | node.
| | ... |
| | ... | Compute path for testing on given topology nodes in circular topology
| | ... | based on interface model provided as an argument and set
| | ... | corresponding suite variables.
| |
| | ... | *Arguments:*
| | ... | - ${actions} - Additional setup action. Type: list
| |
| | [Arguments] | @{actions}
| |
| | Start Suite Setup Export
| | ${nic_model_list}= | Create list | ${nic_name}
| | &{info}= | Compute Circular Topology
| | ... | ${nodes} | filter_list=${nic_model_list} | nic_pfs=${nic_pfs}
| | ... | always_same_link=${True} | topo_has_tg=${True} | topo_has_dut=${False}
| | Set suite variable | &{topology_info} | &{info}
| | Create suite topology variables | @{actions}
| | Finalize Suite Setup Export

| Additional Suite Setup Action For scapy
| | [Documentation]
| | ... | Additional Setup for suites which uses scapy as Traffic generator.
| |
| | Export TG Type And Version | scapy | 2.4.3
| | FOR | ${dut} | IN | @{duts}
| | | Set Suite Variable | ${${dut}_vf1} | ${${dut}_${int}1}
| | | Set Suite Variable | ${${dut}_vf2} | ${${dut}_${int}2}
| | END
| | Set Interface State | ${tg} | ${TG_pf1}[0] | up
| | Set Interface State | ${tg} | ${TG_pf2}[0] | up

| Additional Suite Setup Action For dpdk
| | [Documentation]
| | ... | Additional Setup for suites which uses dpdk.
| |
| | ${version} = | Get Dpdk Version | ${nodes}[DUT1]
| | Export Dut Type And Version | dpdk | ${version}
| | FOR | ${dut} | IN | @{duts}
| | | Initialize DPDK Framework | ${nodes['${dut}']}
| | | ... | ${${dut}_${int}1}[0] | ${${dut}_${int}2}[0] | ${nic_driver}
| | END

| Additional Suite Setup Action For performance vf
| | [Documentation]
| | ... | Additional Setup for suites which uses performance measurement for
| | ... | single DUT (inner loop).
| |
| | ... | *Arguments:*
| | ... | - dut - DUT node. Type: string
| |
| | ... | *Example:*
| |
| | ... | \| Additional Suite Setup Action For performance vf \| DUT1 \|
| |
| | [Arguments] | ${dut}
| |
| | FOR | ${pf} | IN RANGE | 1 | ${nic_pfs} + 1
| | | ${_vf}=
| | | ... | Run Keyword | Init interface
| | | ... | ${nodes['${dut}']} | ${${dut}_pf${pf}}[0] | driver=${nic_driver}
| | | ... | numvfs=${nic_vfs} | osi_layer=${osi_layer}
| | | ${_mac}=
| | | ... | Create List | ${EMPTY}
| | | ${_ip4_addr}=
| | | ... | Create List | ${EMPTY}
| | | ${_ip4_prefix}=
| | | ... | Create List | ${EMPTY}
| | | ${_pci}=
| | | ... | Create List | ${EMPTY}
| | | ${_vlan}=
| | | ... | Create List | ${EMPTY}
| | | Set Suite Variable
| | | ... | ${${dut}_prevf${pf}} | ${_vf}
| | | Set Suite Variable
| | | ... | ${${dut}_prevf${pf}_ip4_addr} | ${_ip4_addr}
| | | Set Suite Variable
| | | ... | ${${dut}_prevf${pf}_ip4_prefix} | ${_ip4_prefix}
| | | Set Suite Variable
| | | ... | ${${dut}_prevf${pf}_mac} | ${_mac}
| | | Set Suite Variable
| | | ... | ${${dut}_prevf${pf}_pci} | ${_pci}
| | | Set Suite Variable
| | | ... | ${${dut}_prevf${pf}_vlan} | ${_vlan}
| | END
| | Set Suite Variable
| | ... | ${int} | prevf

| Additional Suite Setup Action For performance pf
| | [Documentation]
| | ... | Additional Setup for suites which uses performance measurement for
| | ... | single DUT (inner loop).
| |
| | ... | *Arguments:*
| | ... | - dut - DUT node. Type: string
| |
| | ... | *Example:*
| |
| | ... | \| Additional Suite Setup Action For performance pf \| DUT1 \|
| |
| | [Arguments] | ${dut}
| |
| | FOR | ${pf} | IN RANGE | 1 | ${nic_pfs} + 1
| | | Run Keyword | Init interface
| | | ... | ${nodes['${dut}']} | ${${dut}_pf${pf}}[0] | driver=${nic_driver}
| | | ... | numvfs=${0} | osi_layer=${osi_layer}
| | END

| Additional Suite Setup Action For performance
| | [Documentation]
| | ... | Additional Setup for suites which uses performance measurement.
| |
| | FOR | ${dut} | IN | @{duts}
| | | Run Keyword If | ${nic_vfs} > 0
| | | ... | Additional Suite Setup Action For performance vf | ${dut}
| | | ... | ELSE
| | | ... | Additional Suite Setup Action For performance pf | ${dut}
| | END
| | ${type} = | Get TG Type | ${nodes}[TG]
| | ${version} = | Get TG Version | ${nodes}[TG]
| | Export TG Type And Version | ${type} | ${version}
| | Initialize traffic generator
| | ... | ${tg} | ${TG_pf1}[0] | ${TG_pf2}[0]
| | ... | ${dut1} | ${DUT1_${int}1}[0]
| | ... | ${dut${duts_count}} | ${DUT${duts_count}_${int}2}[0]
| | ... | ${osi_layer}

| Additional Suite Setup Action For performance_tg_nic
| | [Documentation]
| | ... | Additional Setup for suites which uses performance measurement
| | ... | for L1 cross connect tests
| |
| | ${type} = | Get TG Type | ${nodes}[TG]
| | ${version} = | Get TG Version | ${nodes}[TG]
| | Export Dut Type And Version | ${type} | ${version}
| | Export TG Type And Version | ${type} | ${version}
| | Initialize traffic generator
| | ... | ${tg} | ${TG_pf1}[0] | ${TG_pf2}[0]
| | ... | ${tg} | ${TG_pf2}[0]
| | ... | ${tg} | ${TG_pf1}[0]
| | ... | ${osi_layer}

| Additional Suite Setup Action For iPerf3
| | [Documentation]
| | ... | Additional Setup for suites which uses performance measurement over
| | ... | iPerf3.
| |
| | ${type} = | Get iPerf Type | ${nodes}[TG]
| | ${version} = | Get iPerf Version | ${nodes}[TG]
| | Export DUT Type And Version | ${type} | ${version}

| Additional Suite Setup Action For ipsechw
| | [Documentation]
| | ... | Additional Setup for suites which uses QAT HW.
| |
| | ${numvfs}= | Set Variable If
| | ... | '${crypto_type}' == 'HW_DH895xcc' | ${32}
| | ... | '${crypto_type}' == 'HW_C3xxx' | ${16}
| | Configure crypto device on all DUTs | ${crypto_type} | numvfs=${numvfs}
| | ... | force_init=${True}
| | Configure kernel module on all DUTs | vfio_pci | force_load=${True}

| Additional Suite Setup Action For nginx
| | [Documentation]
| | ... | Additional Setup for suites which uses Nginx.
| |
| | Install NGINX framework on all DUTs | ${nodes} | ${packages_dir}
| | ... |  ${nginx_version}

| Additional Suite Setup Action For vppecho
| | [Documentation]
| | ... | Additional Setup for suites which uses performance measurement over
| | ... | VPP Echo.
| |
| | Export DUT Type And Version | ${DUT_TYPE} | ${DUT_VERSION}

| Additional Suite Setup Action For ab
| | [Documentation]
| | ... | Additional Setup for suites which uses ab TG.
| |
| | Iface update numa node | ${tg}
| | ${running}= | Is TRex running | ${tg}
| | Run keyword if | ${running}==${True} | Teardown traffic generator | ${tg}
| | ${curr_driver}= | Get PCI dev driver | ${tg}
| | ... | ${tg['interfaces']['${tg_if1}']['pci_address']}
| | Run keyword if | '${curr_driver}'!='${None}'
| | ... | PCI Driver Unbind | ${tg} |
| | ... | ${tg['interfaces']['${tg_if1}']['pci_address']}
| | ${driver}= | Get Variable Value | ${tg['interfaces']['${tg_if1}']['driver']}
| | PCI Driver Bind | ${tg}
| | ... | ${tg['interfaces']['${tg_if1}']['pci_address']} | ${driver}
| | ${intf_name}= | Get Linux interface name | ${tg}
| | ... | ${tg['interfaces']['${tg_if1}']['pci_address']}
| | FOR | ${ip_addr} | IN | @{ab_ip_addrs}
| | | ${ip_addr_on_intf}= | Linux interface has IP | ${tg} | ${intf_name}
| | | ... | ${ip_addr} | ${ab_ip_prefix}
| | | Run Keyword If | ${ip_addr_on_intf}==${False} | Set Linux interface IP
| | | ... | ${tg} | ${intf_name} | ${ip_addr} | ${ab_ip_prefix}
| | END
| | Set Linux interface up | ${nodes}[TG] | ${intf_name}
| | Check AB | ${tg}
| | ${type} = | Get AB Type | ${nodes}[TG]
| | ${version} = | Get AB Version | ${nodes}[TG]
| | Export TG Type And Version | ${type} | ${version}