macauley_cheng | 4bb7ffc | 2015-10-26 15:30:26 +0800 | [diff] [blame^] | 1 | import logging
|
| 2 | import oftest.base_tests as base_tests
|
| 3 | from oftest import config
|
| 4 | from oftest.testutils import *
|
| 5 | from util import *
|
| 6 | from accton_util import convertIP4toStr as toIpV4Str
|
| 7 | from accton_util import convertMACtoStr as toMacStr
|
| 8 |
|
| 9 |
|
| 10 | class single_tag_to_double_tag(base_tests.SimpleDataPlane):
|
| 11 | """
|
| 12 | [Single tag to double tag]
|
| 13 | Add a specified outer tag to incoming tagged packet
|
| 14 |
|
| 15 | Inject eth 1/3 Tag 3, SA000000112233, DA000000113355, V4
|
| 16 | Output eth 1/1 Outter Tag 5, inner Tag 3, others not change
|
| 17 |
|
| 18 | dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=3,vlan_vid=0x1003/0x1fff apply:push_vlan=0x8100,set_field=vlan_vid=5 goto:20
|
| 19 | dpctl tcp:192.168.1.1:6633 flow-mod table=20,cmd=add,prio=201 in_port=3,vlan_vid=3/0xfff,eth_dst=00:00:00:11:33:55,eth_type=0x0800 goto:30
|
| 20 | dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x50001 group=any,port=any,weight=0 output=1
|
| 21 | dpctl tcp:192.168.1.1:6633 flow-mod table=60,cmd=add,prio=601 eth_type=0x0800,in_port=3 write:group=0x50001
|
| 22 | dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x30003 group=any,port=any,weight=0 pop_vlan,output=3
|
| 23 | dpctl tcp:192.168.1.1:6633 flow-mod table=50,cmd=add,prio=501 vlan_vid=3,eth_dst=00:00:00:11:22:33 write:group=0x30003 goto:60
|
| 24 | """
|
| 25 | def runTest(self):
|
| 26 | delete_all_flows(self.controller)
|
| 27 | delete_all_groups(self.controller)
|
| 28 |
|
| 29 | test_ports = sorted(config["port_map"].keys())
|
| 30 | input_port = test_ports[0]
|
| 31 | output_port = test_ports[1]
|
| 32 |
|
| 33 | apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1003/0x1fff apply:push_vlan=0x8100,set_field=vlan_vid=5 goto:20")
|
| 34 | apply_dpctl_mod(self, config, "flow-mod table=20,cmd=add,prio=201 in_port="+str(input_port)+",vlan_vid=3/0xfff,eth_dst=00:00:00:11:33:55,eth_type=0x0800 goto:30")
|
| 35 | apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x50001 group=any,port=any,weight=0 output=1"+str(output_port))
|
| 36 | apply_dpctl_mod(self, config, "flow-mod table=60,cmd=add,prio=601 eth_type=0x0800,in_port="+str(input_port)+" write:group=0x50001")
|
| 37 | apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x30003 group=any,port=any,weight=0 pop_vlan,output="+str(input_port))
|
| 38 | apply_dpctl_mod(self, config, " flow-mod table=50,cmd=add,prio=501 vlan_vid=3,eth_dst=00:00:00:11:22:33 write:group=0x30003 goto:60")
|
| 39 |
|
| 40 | input_pkt = simple_tcp_packet(eth_dst="00:00:00:11:33:55",
|
| 41 | eth_src="00:00:00:11:22:33",
|
| 42 | dl_vlan_enable=True,
|
| 43 | vlan_vid=3)
|
| 44 |
|
| 45 | output_pkt = simple_tcp_packet_two_vlan(eth_dst="00:00:00:11:33:55",
|
| 46 | eth_src="00:00:00:11:22:33",
|
| 47 | out_dl_vlan_enable=True,
|
| 48 | in_dl_vlan_enable=True,
|
| 49 | out_vlan_vid=5,
|
| 50 | in_vlan_vid=3)
|
| 51 |
|
| 52 | self.dataplane.send(input_port, str(input_pkt))
|
| 53 | verify_packet(self, str(output_pkt), output_port)
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 | class double_tag_to_single_tag(base_tests.SimpleDataPlane):
|
| 59 | """
|
| 60 | [Double tag to single tag]
|
| 61 | Pop outter tag of incoming double tagged packet
|
| 62 |
|
| 63 | Inject eth 1/3 Outer 0x8100 + 6, Inner 0x8100 +3, SA000000112233, DA000000113355, V4
|
| 64 | Output eth 1/1 Tag 3, others not change
|
| 65 |
|
| 66 | dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=3,vlan_vid=0x1006/0x1fff apply:pop_vlan,set_field=ofdpa_ovid:6 goto:11
|
| 67 | dpctl tcp:192.168.1.1:6633 flow-mod table=11,cmd=add,prio=101 in_port=3,vlan_vid=0x1003/0x1fff,ofdpa_ovid=0x1006 goto:20
|
| 68 | dpctl tcp:192.168.1.1:6633 flow-mod table=20,cmd=add,prio=201 in_port=3,vlan_vid=6/0xfff,eth_dst=00:00:00:11:33:55,eth_type=0x0800 goto:30
|
| 69 | dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x30001 group=any,port=any,weight=0 output=1
|
| 70 | dpctl tcp:192.168.1.1:6633 flow-mod table=60,cmd=add,prio=601 eth_type=0x0800,in_port=3 write:group=0x30001
|
| 71 | dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x60003 group=any,port=any,weight=0 output=3
|
| 72 | dpctl tcp:192.168.1.1:6633 flow-mod table=50,cmd=add,prio=501 vlan_vid=6,eth_dst=00:00:00:11:22:33 write:group=0x60003 goto:60
|
| 73 |
|
| 74 | """
|
| 75 | def runTest(self):
|
| 76 | delete_all_flows(self.controller)
|
| 77 | delete_all_groups(self.controller)
|
| 78 |
|
| 79 | test_ports = sorted(config["port_map"].keys())
|
| 80 | input_port = test_ports[0]
|
| 81 | output_port = test_ports[1]
|
| 82 |
|
| 83 | apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1006/0x1fff apply:pop_vlan,set_field=ofdpa_ovid:6 goto:11")
|
| 84 | apply_dpctl_mod(self, config, "flow-mod table=20,cmd=add,prio=201 in_port="+str(input_port)+",vlan_vid=0x1003/0x1fff,ofdpa_ovid=0x1006 goto:20")
|
| 85 | apply_dpctl_mod(self, config, "flow-mod table=20,cmd=add,prio=201 in_port="+str(input_port)+",vlan_vid=6/0xfff,eth_dst=00:00:00:11:33:55,eth_type=0x0800 goto:30")
|
| 86 | apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x30001 group=any,port=any,weight=0 output="+str(output_port))
|
| 87 | apply_dpctl_mod(self, config, "flow-mod table=60,cmd=add,prio=601 eth_type=0x0800,in_port="+str(input_port)+" write:group=0x30001")
|
| 88 | apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x60003 group=any,port=any,weight=0 output="+str(input_port))
|
| 89 | apply_dpctl_mod(self, config, "flow-mod table=50,cmd=add,prio=501 vlan_vid=6,eth_dst=00:00:00:11:22:33 write:group=0x60003 goto:60")
|
| 90 |
|
| 91 | input_pkt = simple_tcp_packet_two_vlan(eth_dst="00:00:00:11:33:55",
|
| 92 | eth_src="00:00:00:11:22:33",
|
| 93 | out_dl_vlan_enable=True,
|
| 94 | in_dl_vlan_enable=True,
|
| 95 | out_vlan_vid=6,
|
| 96 | in_vlan_vid=3)
|
| 97 |
|
| 98 | output_pkt = simple_tcp_packet(eth_dst="00:00:04:22:44:66",
|
| 99 | eth_src="00:00:04:22:33:55",
|
| 100 | dl_vlan_enable=True,
|
| 101 | vlan_vid=5)
|
| 102 |
|
| 103 | self.dataplane.send(input_port, str(input_pkt))
|
| 104 | verify_packet(self, str(output_pkt), output_port)
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 | class vlan_translate(base_tests.SimpleDataPlane):
|
| 110 | """
|
| 111 | [Double tag to single tag and modify inner tag]
|
| 112 | Pop outter tag of incoming double tagged packet and modify inner tag
|
| 113 |
|
| 114 | Inject eth 1/3 Outer 0x8100 + 6, Inner 0x8100 +3, SA000000112233, DA000000113355, V4
|
| 115 | Output eth 1/1 Tag 4, others not change
|
| 116 |
|
| 117 | dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=3,vlan_vid=0x1006/0x1fff apply:pop_vlan,set_field=ofdpa_ovid:6 goto:11
|
| 118 | dpctl tcp:192.168.1.1:6633 flow-mod table=11,cmd=add,prio=101 in_port=3,vlan_vid=0x1003/0x1fff,ofdpa_ovid=0x1006 apply:set_field=vlan_vid=4 goto:20
|
| 119 | dpctl tcp:192.168.1.1:6633 flow-mod table=20,cmd=add,prio=201 in_port=3,vlan_vid=6/0xfff,eth_dst=00:00:00:11:33:55,eth_type=0x0800 goto:30
|
| 120 | dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x40001 group=any,port=any,weight=0 output=1
|
| 121 | dpctl tcp:192.168.1.1:6633 flow-mod table=60,cmd=add,prio=601 eth_type=0x0800,in_port=3 write:group=0x40001
|
| 122 | dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x60003 group=any,port=any,weight=0 output=3
|
| 123 | dpctl tcp:192.168.1.1:6633 flow-mod table=50,cmd=add,prio=501 vlan_vid=6,eth_dst=00:00:00:11:22:33 write:group=0x60003 goto:60
|
| 124 |
|
| 125 | """
|
| 126 | def runTest(self):
|
| 127 | delete_all_flows(self.controller)
|
| 128 | delete_all_groups(self.controller)
|
| 129 |
|
| 130 | test_ports = sorted(config["port_map"].keys())
|
| 131 | input_port = test_ports[0]
|
| 132 | output_port = test_ports[1]
|
| 133 |
|
| 134 | apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1006/0x1fff apply:pop_vlan,set_field=ofdpa_ovid:6 goto:11")
|
| 135 | apply_dpctl_mod(self, config, "flow-mod table=11,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1003/0x1fff,ofdpa_ovid=0x1006 apply:set_field=vlan_vid=4 goto:20")
|
| 136 | apply_dpctl_mod(self, config, "flow-mod table=20,cmd=add,prio=201 in_port="+str(input_port)+",vlan_vid=6/0xfff,eth_dst=00:00:00:11:33:55,eth_type=0x0800 goto:30")
|
| 137 | apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x40001 group=any,port=any,weight=0 output="+str(output_port))
|
| 138 | apply_dpctl_mod(self, config, "flow-mod table=60,cmd=add,prio=601 eth_type=0x0800,in_port="+str(input_port)+" write:group=0x40001")
|
| 139 | apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x60003 group=any,port=any,weight=0 output="+str(input_port))
|
| 140 | apply_dpctl_mod(self, config, "flow-mod table=50,cmd=add,prio=501 vlan_vid=6,eth_dst=00:00:00:11:22:33 write:group=0x60003 goto:60")
|
| 141 |
|
| 142 | input_pkt = simple_tcp_packet_two_vlan(eth_dst="00:00:00:11:33:55",
|
| 143 | eth_src="00:00:00:11:22:33",
|
| 144 | out_dl_vlan_enable=True,
|
| 145 | in_dl_vlan_enable=True,
|
| 146 | out_vlan_vid=6,
|
| 147 | in_vlan_vid=3)
|
| 148 |
|
| 149 | output_pkt = simple_tcp_packet_two_vlan(eth_dst="00:00:00:11:33:55",
|
| 150 | eth_src="00:00:00:11:22:33",
|
| 151 | out_dl_vlan_enable=True,
|
| 152 | in_dl_vlan_enable=True,
|
| 153 | out_vlan_vid=6,
|
| 154 | in_vlan_vid=4)
|
| 155 |
|
| 156 | self.dataplane.send(input_port, str(input_pkt))
|
| 157 | verify_packet(self, str(output_pkt), output_port)
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 | class vlan_translate(base_tests.SimpleDataPlane):
|
| 162 | """
|
| 163 | [VLAN tanslate]
|
| 164 | Swap incoming tagged packet to a specified VLAN tag
|
| 165 |
|
| 166 | Inject eth 1/3 Tag 3, SA000000112233, DA000000113355, V4
|
| 167 | Output eth 1/1 Tag 5, others not change
|
| 168 |
|
| 169 | dpctl tcp:192.168.1.1:6633 flow-mod table=10,cmd=add,prio=101 in_port=3,vlan_vid=0x1003/0x1fff apply:set_field=vlan_vid=5 goto:20
|
| 170 | dpctl tcp:192.168.1.1:6633 flow-mod table=20,cmd=add,prio=201 in_port=3,vlan_vid=3/0xfff,eth_dst=00:00:00:11:33:55,eth_type=0x0800 goto:30
|
| 171 | dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x50001 group=any,port=any,weight=0 output=1
|
| 172 | dpctl tcp:192.168.1.1:6633 flow-mod table=60,cmd=add,prio=601 eth_type=0x0800,in_port=3 write:group=0x50001
|
| 173 | dpctl tcp:192.168.1.1:6633 group-mod cmd=add,type=ind,group=0x30003 group=any,port=any,weight=0 pop_vlan,output=3
|
| 174 | dpctl tcp:192.168.1.1:6633 flow-mod table=50,cmd=add,prio=501 vlan_vid=3,eth_dst=00:00:00:11:22:33 write:group=0x30003 goto:60
|
| 175 |
|
| 176 | """
|
| 177 | def runTest(self):
|
| 178 | delete_all_flows(self.controller)
|
| 179 | delete_all_groups(self.controller)
|
| 180 |
|
| 181 | test_ports = sorted(config["port_map"].keys())
|
| 182 | input_port = test_ports[0]
|
| 183 | output_port = test_ports[1]
|
| 184 |
|
| 185 | apply_dpctl_mod(self, config, "flow-mod table=10,cmd=add,prio=101 in_port="+str(input_port)+",vlan_vid=0x1003/0x1fff apply:set_field=vlan_vid=5 goto:20")
|
| 186 | apply_dpctl_mod(self, config, "flow-mod table=20,cmd=add,prio=201 in_port="+str(input_port)+",vlan_vid=3/0xfff,eth_dst=00:00:00:11:33:55,eth_type=0x0800 goto:30")
|
| 187 | apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x50001 group=any,port=any,weight=0 output="+str(output_port))
|
| 188 | apply_dpctl_mod(self, config, "flow-mod table=60,cmd=add,prio=601 eth_type=0x0800,in_port="+str(input_port)+" write:group=0x50001")
|
| 189 | apply_dpctl_mod(self, config, "group-mod cmd=add,type=ind,group=0x30003 group=any,port=any,weight=0 pop_vlan,output="+str(input_port))
|
| 190 | apply_dpctl_mod(self, config, "flow-mod table=50,cmd=add,prio=501 vlan_vid=3,eth_dst=00:00:00:11:22:33 write:group=0x30003 goto:60")
|
| 191 |
|
| 192 | input_pkt = simple_tcp_packet(eth_dst="00:00:00:11:33:55",
|
| 193 | eth_src="00:00:00:11:22:33",
|
| 194 | dl_vlan_enable=True,
|
| 195 | vlan_vid=3)
|
| 196 |
|
| 197 | output_pkt = simple_tcp_packet(eth_dst="00:00:00:11:33:55",
|
| 198 | eth_src="00:00:00:11:22:33",
|
| 199 | dl_vlan_enable=True,
|
| 200 | vlan_vid=5)
|
| 201 |
|
| 202 | self.dataplane.send(input_port, str(input_pkt))
|
| 203 | verify_packet(self, str(output_pkt), output_port) |