blob: 342b4586b28b2ea7a899d96bf2f6f381b2d06e6a [file] [log] [blame]
Flavio Castro34352e72015-12-07 20:01:51 -05001
2from oftest import config
3import logging
4import oftest.base_tests as base_tests
5import ofp
6from oftest.testutils import *
7from accton_util import *
8
9class Leaf1(base_tests.SimpleDataPlane):
10
11 def runTest(self):
12 #Add flows correspondent to Leaf1
13 switch_mac=[0x00, 0x00, 0x00, 0x01, 0xea, 0xf1]
14 dst_mac= [0x00, 0x00, 0x00, 0x12, 0x34, 0x01]
Flavio Castro7fb6ca92015-12-16 15:50:14 -050015 id=0x1eaf
Flavio Castro34352e72015-12-07 20:01:51 -050016 #Add L3Unicast to Host
Flavio Castro7fb6ca92015-12-16 15:50:14 -050017 port, vlan_id = 33, 4093
Flavio Castro34352e72015-12-07 20:01:51 -050018 ##add L2 Interface Group
Flavio Castro7fb6ca92015-12-16 15:50:14 -050019 add_one_l2_interface_group(self.controller, port, vlan_id=vlan_id, is_tagged=False, send_barrier=False)
Flavio Castro34352e72015-12-07 20:01:51 -050020 ##add L3 Unicast Group
Flavio Castro7fb6ca92015-12-16 15:50:14 -050021 l3_msg=add_l3_unicast_group(self.controller, port, vlanid=vlan_id, id=id, src_mac=switch_mac,
Flavio Castro34352e72015-12-07 20:01:51 -050022 dst_mac=dst_mac)
Flavio Castro7fb6ca92015-12-16 15:50:14 -050023 add_one_vlan_table_flow(self.controller, of_port=port, vlan_id=vlan_id, flag=VLAN_TABLE_FLAG_ONLY_BOTH)
Flavio Castro34352e72015-12-07 20:01:51 -050024 ##add Termination Flow
25 add_termination_flow(self.controller, port, 0x0800, switch_mac, vlan_id)
26 ##add unicast routing flow
27 dst_ip=0x0a000001
28 mask=0xffffff00
Flavio Castro7fb6ca92015-12-16 15:50:14 -050029 add_unicast_routing_flow(self.controller, 0x0800, dst_ip, mask, l3_msg.group_id)
Flavio Castro34352e72015-12-07 20:01:51 -050030
31 port = 32
Flavio Castro7fb6ca92015-12-16 15:50:14 -050032 l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port, vlan_id=vlan_id, is_tagged=False, send_barrier=False)
33 add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_BOTH)
Flavio Castro34352e72015-12-07 20:01:51 -050034 add_termination_flow(self.controller, port, 0x0800, switch_mac, vlan_id)
Flavio Castro34352e72015-12-07 20:01:51 -050035
36 #Add L3VPN initiation
37 dst_mac = [0x00, 0x00, 0x00, 0x55, 0x55, 0x55]
Flavio Castro34352e72015-12-07 20:01:51 -050038 #add MPLS interface group
39 mpls_gid, mpls_msg = add_mpls_intf_group(self.controller, l2_gid, dst_mac, switch_mac, vlan_id, port)
40 ##add L3VPN interface
41 mpls_label_gid, mpls_label_msg = add_mpls_label_group(self.controller, subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL,
Flavio Castro7fb6ca92015-12-16 15:50:14 -050042 index=id, ref_gid= mpls_gid, push_mpls_header=True, set_mpls_label=20, set_bos=1, cpy_ttl_outward=True)
43 ecmp_msg=add_l3_ecmp_group(self.controller, port, [mpls_label_gid])
Flavio Castro34352e72015-12-07 20:01:51 -050044 ##add unicast routing flow
45 dst_ip=0x14000001
Flavio Castro7fb6ca92015-12-16 15:50:14 -050046 add_unicast_routing_flow(self.controller, 0x0800, dst_ip, mask, ecmp_msg.group_id)
Flavio Castro34352e72015-12-07 20:01:51 -050047
Flavio Castro34352e72015-12-07 20:01:51 -050048 do_barrier(self.controller)
49
50class Leaf2(base_tests.SimpleDataPlane):
51
Flavio Castro7fb6ca92015-12-16 15:50:14 -050052 def runTest(self):
53 #Add flows correspondent to Leaf1
Flavio Castro34352e72015-12-07 20:01:51 -050054 switch_mac=[0x00, 0x00, 0x00, 0x01, 0xea, 0xf2]
55 dst_mac= [0x00, 0x00, 0x00, 0x12, 0x34, 0x02]
Flavio Castro7fb6ca92015-12-16 15:50:14 -050056 id=0x2eaf
Flavio Castro34352e72015-12-07 20:01:51 -050057 #Add L3Unicast to Host
Flavio Castro7fb6ca92015-12-16 15:50:14 -050058 port, vlan_id = 33, 4093
Flavio Castro34352e72015-12-07 20:01:51 -050059 ##add L2 Interface Group
Flavio Castro7fb6ca92015-12-16 15:50:14 -050060 add_one_l2_interface_group(self.controller, port, vlan_id=vlan_id, is_tagged=False, send_barrier=False)
Flavio Castro34352e72015-12-07 20:01:51 -050061 ##add L3 Unicast Group
Flavio Castro7fb6ca92015-12-16 15:50:14 -050062 l3_msg=add_l3_unicast_group(self.controller, port, vlanid=vlan_id, id=id, src_mac=switch_mac,
Flavio Castro34352e72015-12-07 20:01:51 -050063 dst_mac=dst_mac)
Flavio Castro7fb6ca92015-12-16 15:50:14 -050064 add_one_vlan_table_flow(self.controller, of_port=port, vlan_id=vlan_id, flag=VLAN_TABLE_FLAG_ONLY_BOTH)
Flavio Castro34352e72015-12-07 20:01:51 -050065 ##add Termination Flow
66 add_termination_flow(self.controller, port, 0x0800, switch_mac, vlan_id)
67 ##add unicast routing flow
68 dst_ip=0x14000001
69 mask=0xffffff00
Flavio Castro7fb6ca92015-12-16 15:50:14 -050070 add_unicast_routing_flow(self.controller, 0x0800, dst_ip, mask, l3_msg.group_id)
Flavio Castro34352e72015-12-07 20:01:51 -050071
72 port = 32
Flavio Castro7fb6ca92015-12-16 15:50:14 -050073 l2_gid, l2_msg = add_one_l2_interface_group(self.controller, port, vlan_id=vlan_id, is_tagged=False, send_barrier=False)
74 add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_BOTH)
Flavio Castro34352e72015-12-07 20:01:51 -050075 add_termination_flow(self.controller, port, 0x0800, switch_mac, vlan_id)
Flavio Castro34352e72015-12-07 20:01:51 -050076
77 #Add L3VPN initiation
Flavio Castro7fb6ca92015-12-16 15:50:14 -050078 dst_mac = [0x00, 0x00, 0x00, 0x55, 0x55, 0x55]
Flavio Castro34352e72015-12-07 20:01:51 -050079 #add MPLS interface group
80 mpls_gid, mpls_msg = add_mpls_intf_group(self.controller, l2_gid, dst_mac, switch_mac, vlan_id, port)
81 ##add L3VPN interface
Flavio Castro7fb6ca92015-12-16 15:50:14 -050082 mpls_label_gid, mpls_label_msg = add_mpls_label_group(self.controller, subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL,
83 index=id, ref_gid= mpls_gid, push_mpls_header=True, set_mpls_label=20, set_bos=1, cpy_ttl_outward=True)
84 ecmp_msg=add_l3_ecmp_group(self.controller, id, [mpls_label_gid])
Flavio Castro34352e72015-12-07 20:01:51 -050085 ##add unicast routing flow
86 dst_ip=0x0a000001
Flavio Castro7fb6ca92015-12-16 15:50:14 -050087 add_unicast_routing_flow(self.controller, 0x0800, dst_ip, mask, ecmp_msg.group_id)
88
89 do_barrier(self.controller)
Flavio Castro34352e72015-12-07 20:01:51 -050090
91class Spine(base_tests.SimpleDataPlane):
92
93 def runTest(self):
94 #add Spine Flows
95 switch_mac = [0x00, 0x00, 0x00, 0x55, 0x55, 0x55]
96 dst_mac = [0x00, 0x00, 0x00, 0x01, 0xea, 0xf1]
Flavio Castro7fb6ca92015-12-16 15:50:14 -050097 id = 0x55
Flavio Castro34352e72015-12-07 20:01:51 -050098 #Add MPLS termination
Flavio Castro7fb6ca92015-12-16 15:50:14 -050099 port, vlan_id=31, 4093
Flavio Castro34352e72015-12-07 20:01:51 -0500100 ##add L2 Interface Group
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500101 add_one_l2_interface_group(self.controller, port, vlan_id=vlan_id, is_tagged=False, send_barrier=False)
Flavio Castro34352e72015-12-07 20:01:51 -0500102 ##add L3 Unicast Group
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500103 l3_msg=add_l3_unicast_group(self.controller, port, vlanid=vlan_id, id=id, src_mac=switch_mac,
Flavio Castro34352e72015-12-07 20:01:51 -0500104 dst_mac=dst_mac)
105 ecmp_msg = add_l3_ecmp_group(self.controller, port, [l3_msg.group_id])
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500106 add_one_vlan_table_flow(self.controller, of_port=port, vlan_id=vlan_id, flag=VLAN_TABLE_FLAG_ONLY_BOTH)
Flavio Castro34352e72015-12-07 20:01:51 -0500107 add_termination_flow(self.controller, port, 0x8847, switch_mac, vlan_id, goto_table=24)
108 add_mpls_flow(self.controller, ecmp_msg.group_id, 10)
Flavio Castro34352e72015-12-07 20:01:51 -0500109
110 dst_mac = [0x00, 0x00, 0x00, 0x01, 0xea, 0xf2]
111 #Add MPLS termination
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500112 port=32
Flavio Castro34352e72015-12-07 20:01:51 -0500113 ##add L2 Interface Group
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500114 add_one_l2_interface_group(self.controller, port, vlan_id=vlan_id, is_tagged=False, send_barrier=False)
Flavio Castro34352e72015-12-07 20:01:51 -0500115 ##add L3 Unicast Group
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500116 id=id+1
117 l3_msg=add_l3_unicast_group(self.controller, port, vlanid=vlan_id, id=id, src_mac=switch_mac,
Flavio Castro34352e72015-12-07 20:01:51 -0500118 dst_mac=dst_mac)
119 ecmp_msg = add_l3_ecmp_group(self.controller, port, [l3_msg.group_id])
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500120 add_one_vlan_table_flow(self.controller, of_port=port, vlan_id=vlan_id, flag=VLAN_TABLE_FLAG_ONLY_BOTH)
Flavio Castro34352e72015-12-07 20:01:51 -0500121 add_termination_flow(self.controller, port, 0x8847, switch_mac, vlan_id, goto_table=24)
122 add_mpls_flow(self.controller, ecmp_msg.group_id, 20)
Flavio Castro34352e72015-12-07 20:01:51 -0500123
124class TestLeaf1(base_tests.SimpleDataPlane):
125
126 def runTest(self):
127 host_mac='00:00:00:12:34:01'
128 ip_src='10.0.0.1'
129 ip_dst='20.0.0.2'
130 switch_mac='00:00:00:01:ea:f1'
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500131 parsed_pkt = simple_tcp_packet(pktlen=100, ip_src=ip_src,
Flavio Castro34352e72015-12-07 20:01:51 -0500132 ip_dst=ip_dst, eth_dst=switch_mac, eth_src=host_mac, ip_ttl=33)
133 pkt=str(parsed_pkt)
134 self.dataplane.send(33, pkt)
135
136 #build expect packet
137 next_hop_mac='00:00:00:55:55:55'
138 switch_mac='00:00:00:01:ea:f1'
139 label = (20, 0, 1, 32)
140 exp_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True, vlan_vid=100, label=[label],
141 eth_dst=next_hop_mac, eth_src=switch_mac, ip_ttl=32, ip_src=ip_src, ip_dst=ip_dst)
142 pkt=str(exp_pkt)
143 verify_packet(self, pkt, 37)
144
145class TestSpine(base_tests.SimpleDataPlane):
146
147 def runTest(self):
148 ip_src='10.0.0.1'
149 ip_dst='20.0.0.2'
150
151 #build outgoing packet
152 spine_mac='00:00:00:55:55:55'
153 switch_mac='00:00:00:01:ea:f2'
154 leaf1= '00:00:00:01:ea:f1'
155 label = (20, 0, 1, 32)
156 parsed_pkt = mpls_packet(pktlen=104, dl_vlan_enable=True, vlan_vid=100, label=[label],
157 eth_dst=spine_mac, eth_src=leaf1, ip_ttl=32, ip_src=ip_src, ip_dst=ip_dst)
158 pkt=str(parsed_pkt)
159 self.dataplane.send(33, pkt)
160
161 exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=20, ip_src=ip_src,
162 ip_dst=ip_dst, eth_dst=switch_mac, eth_src=spine_mac, ip_ttl=31)
163 pkt=str(exp_pkt)
164 verify_packet(self, pkt, 37)
165
166class TestLeaf2(base_tests.SimpleDataPlane):
167
168 def runTest(self):
169 host_mac='00:00:00:55:55:55'
170 ip_src='10.0.0.1'
171 ip_dst='20.0.0.3'
172 switch_mac='00:00:00:01:ea:f1'
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500173 parsed_pkt = simple_tcp_packet(pktlen=100, ip_src=ip_src,
Flavio Castro34352e72015-12-07 20:01:51 -0500174 ip_dst=ip_dst, eth_dst=switch_mac, eth_src=host_mac, ip_ttl=33)
175 pkt=str(parsed_pkt)
176 self.dataplane.send(33, pkt)
177 switch_mac='00:00:00:01:ea:f2'
178 host_mac='00:00:00:12:34:02'
Flavio Castro7fb6ca92015-12-16 15:50:14 -0500179 exp_pkt = simple_tcp_packet(pktlen=100, ip_src=ip_src,
Flavio Castro34352e72015-12-07 20:01:51 -0500180 ip_dst=ip_dst, eth_dst=host_mac, eth_src=switch_mac, ip_ttl=30)
181 pkt=str(exp_pkt)
182 verify_packet(self, pkt, 37)
183
184
185