Perf: NAT44 endpoint-dependent mode - udp, part I
[csit.git] / resources / libraries / robot / ip / nat.robot
1 # Copyright (c) 2020 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
5 #
6 #     http://www.apache.org/licenses/LICENSE-2.0
7 #
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
13
14 *** Settings ***
15 | Library | resources.libraries.python.NATUtil
16 |
17 | Documentation | Keywords for NAT feature in VPP.
18
19 *** Keywords ***
20 | Configure inside and outside interfaces
21 | | [Documentation] | Configure inside and outside interfaces for NAT44.
22 | |
23 | | ... | *Arguments:*
24 | | ... | - node - DUT node to set NAT44 interfaces on. Type: dictionary
25 | | ... | - int_in - Inside interface. Type: string
26 | | ... | - int_out - Outside interface. Type: string
27 | |
28 | | ... | *Example:*
29 | |
30 | | ... | \| Configure inside and outside interfaces \| ${nodes['DUT1']} \
31 | | ... | \| FortyGigabitEtherneta/0/0 \| FortyGigabitEtherneta/0/1 \|
32 | |
33 | | [Arguments] | ${node} | ${int_in} | ${int_out}
34 | |
35 | | ${int_in_name}= | Set variable | ${node['interfaces']['${int_in}']['name']}
36 | | ${int_out_name}= | Set variable
37 | | ... | ${node['interfaces']['${int_out}']['name']}
38 | | Set NAT44 Interfaces | ${node} | ${int_in_name} | ${int_out_name}
39
40 | Configure deterministic mode for NAT44
41 | | [Documentation] | Set deterministic behaviour of NAT44.
42 | |
43 | | ... | *Arguments:*
44 | | ... | - node - DUT node to set deterministic mode for NAT44 on.
45 | | ... | Type: dictionary
46 | | ... | - ip_in - Inside IP. Type: string
47 | | ... | - subnet_in - Inside IP subnet. Type: string
48 | | ... | - ip_out - Outside IP. Type: string
49 | | ... | - subnet_out - Outside IP subnet. Type: string
50 | |
51 | | ... | *Example:*
52 | |
53 | | ... | \| Configure deterministic mode for NAT44 \| ${nodes['DUT1']} \
54 | | ... | \| 100.0.0.0 \| 12 \| 12.1.1.0 \| 24 \|
55 | |
56 | | [Arguments] | ${node} | ${ip_in} | ${subnet_in} | ${ip_out} | ${subnet_out}
57 | |
58 | | Set NAT44 deterministic | ${node} | ${ip_in} | ${subnet_in} | ${ip_out}
59 | | ... | ${subnet_out}
60
61 | Show NAT verbose
62 | | [Documentation] | Get the NAT settings on the node.
63 | |
64 | | ... | *Arguments:*
65 | | ... | - node - DUT node to show NAT. Type: dictionary
66 | |
67 | | ... | *Example:*
68 | |
69 | | ... | \| Show NAT verbose \| ${nodes['DUT1']} \|
70 | |
71 | | [Arguments] | ${node}
72 | |
73 | | Show NAT | ${node}
74
75 | Initialize NAT44 deterministic mode in circular topology
76 | | [Documentation] | Initialization of NAT44 deterministic mode on DUT1
77 | |
78 | | Configure inside and outside interfaces
79 | | ... | ${dut1} | ${DUT1_${int}1}[0] | ${DUT1_${int}2}[0]
80 | | Configure deterministic mode for NAT44
81 | | ... | ${dut1} | ${in_net} | ${in_mask} | ${out_net} | ${out_mask}
82
83 | Initialize NAT44 endpoint-dependent mode in circular topology
84 | | [Documentation] | Initialization of NAT44 endpoint-dependent mode on DUT1
85 | |
86 | | Configure inside and outside interfaces
87 | | ... | ${dut1} | ${DUT1_${int}1}[0] | ${DUT1_${int}2}[0]
88 | | Set NAT44 Address Range
89 | | ... | ${dut1} | ${out_net} | ${out_net_end}
90
91 # TODO: Remove when 'ip4.Initialize IPv4 forwarding in circular topology' KW
92 # adapted to use IP values from variables
93 | Initialize IPv4 forwarding for NAT44 in circular topology
94 | | [Documentation]
95 | | ... | Set IPv4 forwarding for NAT44:
96 | | ... | - set interfaces up
97 | | ... | - set IP addresses
98 | | ... | - set ARP
99 | | ... | - create routes
100 | |
101 | | ${status} | ${value}= | Run Keyword And Ignore Error
102 | | ... | Variable Should Exist | ${dut2}
103 | | ${dut2_status}= | Set Variable If | '${status}' == 'PASS' | ${True}
104 | | ... | ${False}
105 | |
106 | | Set interfaces in path up
107 | |
108 | | VPP Interface Set IP Address
109 | | ... | ${dut1} | ${DUT1_${int}1}[0] | ${dut1_if1_ip4} | ${dut1_if1_mask}
110 | | VPP Interface Set IP Address
111 | | ... | ${dut1} | ${DUT1_${int}2}[0] | ${dut1_if2_ip4} | ${dut1_if2_mask}
112 | | Run Keyword If | ${dut2_status}
113 | | ... | VPP Interface Set IP Address
114 | | ... | ${dut2} | ${DUT2_${int}1}[0] | ${dut2_if1_ip4} | ${dut2_if1_mask}
115 | | Run Keyword If | ${dut2_status}
116 | | ... | VPP Interface Set IP Address
117 | | ... | ${dut2} | ${DUT2_${int}2}[0] | ${dut2_if2_ip4} | ${dut2_if2_mask}
118 | |
119 | | VPP Add IP Neighbor
120 | | ... | ${dut1} | ${DUT1_${int}1}[0] | ${tg_if1_ip4} | ${TG_pf1_mac}[0]
121 | | Run Keyword If |  ${dut2_status}
122 | | ... | VPP Add IP Neighbor
123 | | ... | ${dut1} | ${DUT1_${int}2}[0] | ${dut2_if1_ip4}
124 | | ... | ${DUT2_${int}1_mac}[0]
125 | | ... | ELSE | VPP Add IP Neighbor
126 | | ... | ${dut1} | ${DUT1_${int}2}[0] | ${tg_if2_ip4} | ${TG_pf2_mac}[0]
127 | | Run Keyword If |  ${dut2_status}
128 | | ... | VPP Add IP Neighbor
129 | | ... | ${dut2} | ${DUT2_${int}1}[0] | ${dut1_if1_ip4}
130 | | ... | ${DUT1_${int}2_mac}[0]
131 | | Run Keyword If |  ${dut2_status}
132 | | ... | VPP Add IP Neighbor
133 | | ... | ${dut2} | ${DUT2_${int}2}[0] | ${tg_if2_ip4}| ${TG_pf2_mac}[0]
134 | |
135 | | Vpp Route Add
136 | | ... | ${dut1} | ${in_net} | ${in_mask} | gateway=${tg_if1_ip4}
137 | | ... | interface=${DUT1_${int}1}[0]
138 | | Run Keyword If | ${dut2_status}
139 | | ... | Vpp Route Add
140 | | ... | ${dut1} | ${dest_net} | ${dest_mask} | gateway=${dut2_if1_ip4}
141 | | ... | interface=${DUT1_${int}2}[0]
142 | | ... | ELSE | Vpp Route Add
143 | | ... | ${dut1} | ${dest_net} | ${dest_mask} | gateway=${tg_if2_ip4}
144 | | ... | interface=${DUT1_${int}2}[0]
145 | | Run Keyword If | ${dut2_status}
146 | | ... | Vpp Route Add
147 | | ... | ${dut2} | ${dest_net} | ${dest_mask} | gateway=${tg_if2_ip4}
148 | | ... | interface=${DUT2_${int}2}[0]
149 | | Run Keyword If | ${dut2_status}
150 | | ... | Vpp Route Add
151 | | ... | ${dut2} | ${out_net} | ${out_mask} | gateway=${dut1_if2_ip4}
152 | | ... | interface=${DUT2_${int}1}[0]