Flavio Castro | 05d20bc | 2015-11-16 15:06:14 -0500 | [diff] [blame] | 1 | """ |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 2 | Check README file |
Flavio Castro | 05d20bc | 2015-11-16 15:06:14 -0500 | [diff] [blame] | 3 | """ |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 4 | import Queue |
Flavio Castro | 05d20bc | 2015-11-16 15:06:14 -0500 | [diff] [blame] | 5 | |
Flavio Castro | 05d20bc | 2015-11-16 15:06:14 -0500 | [diff] [blame] | 6 | from oftest import config |
Flavio Castro | 67d8bd5 | 2016-02-03 14:22:14 -0500 | [diff] [blame] | 7 | import inspect |
Flavio Castro | 167f5bd | 2015-12-02 19:33:53 -0500 | [diff] [blame] | 8 | import logging |
| 9 | import oftest.base_tests as base_tests |
Flavio Castro | 05d20bc | 2015-11-16 15:06:14 -0500 | [diff] [blame] | 10 | import ofp |
| 11 | from oftest.testutils import * |
| 12 | from accton_util import * |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 13 | |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 14 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 15 | class PacketInUDP( base_tests.SimpleDataPlane ): |
Flavio Castro | 6d49852 | 2015-12-15 14:05:04 -0500 | [diff] [blame] | 16 | """ |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 17 | Verify a ACL rule that matches on IP_PROTO 2 will not match a UDP packet. |
| 18 | Next it verify a rule that matches on IP_PROTO 17 WILL match a UDP packet. |
Flavio Castro | 6d49852 | 2015-12-15 14:05:04 -0500 | [diff] [blame] | 19 | """ |
| 20 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 21 | def runTest( self ): |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 22 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 23 | parsed_vlan_pkt = simple_udp_packet( pktlen=104, vlan_vid=0x1001, dl_vlan_enable=True ) |
| 24 | vlan_pkt = str( parsed_vlan_pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 25 | # create match |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 26 | match = ofp.match( ) |
| 27 | match.oxm_list.append( ofp.oxm.eth_type( 0x0800 ) ) |
| 28 | match.oxm_list.append( ofp.oxm.ip_proto( 2 ) ) |
| 29 | request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[ |
| 30 | ofp.instruction.apply_actions( actions=[ |
| 31 | ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ), ], |
| 32 | buffer_id=ofp.OFP_NO_BUFFER, priority=1 ) |
| 33 | logging.info( "Inserting packet in flow to controller" ) |
| 34 | self.controller.message_send( request ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 35 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 36 | for of_port in config[ "port_map" ].keys( ): |
| 37 | logging.info( "PacketInMiss test, port %d", of_port ) |
| 38 | self.dataplane.send( of_port, vlan_pkt ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 39 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 40 | verify_no_packet_in( self, vlan_pkt, of_port ) |
| 41 | delete_all_flows( self.controller ) |
| 42 | do_barrier( self.controller ) |
Flavio Castro | 6d49852 | 2015-12-15 14:05:04 -0500 | [diff] [blame] | 43 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 44 | match = ofp.match( ) |
| 45 | match.oxm_list.append( ofp.oxm.eth_type( 0x0800 ) ) |
| 46 | match.oxm_list.append( ofp.oxm.ip_proto( 17 ) ) |
| 47 | request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[ |
| 48 | ofp.instruction.apply_actions( actions=[ |
| 49 | ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ), ], |
| 50 | buffer_id=ofp.OFP_NO_BUFFER, priority=1 ) |
| 51 | logging.info( "Inserting packet in flow to controller" ) |
| 52 | self.controller.message_send( request ) |
| 53 | do_barrier( self.controller ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 54 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 55 | for of_port in config[ "port_map" ].keys( ): |
| 56 | logging.info( "PacketInMiss test, port %d", of_port ) |
| 57 | self.dataplane.send( of_port, vlan_pkt ) |
Flavio Castro | 6d49852 | 2015-12-15 14:05:04 -0500 | [diff] [blame] | 58 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 59 | verify_packet_in( self, vlan_pkt, of_port, ofp.OFPR_ACTION ) |
Flavio Castro | 6d49852 | 2015-12-15 14:05:04 -0500 | [diff] [blame] | 60 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 61 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 62 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 63 | delete_all_flows( self.controller ) |
| 64 | delete_all_groups( self.controller ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 65 | |
Flavio Castro | af2b450 | 2016-02-02 17:41:32 -0500 | [diff] [blame] | 66 | |
Flavio Castro | 67d8bd5 | 2016-02-03 14:22:14 -0500 | [diff] [blame] | 67 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 68 | class ArpNL2( base_tests.SimpleDataPlane ): |
| 69 | def runTest( self ): |
| 70 | delete_all_flows( self.controller ) |
| 71 | delete_all_groups( self.controller ) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 72 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 73 | ports = sorted( config[ "port_map" ].keys( ) ) |
| 74 | match = ofp.match( ) |
| 75 | match.oxm_list.append( ofp.oxm.eth_type( 0x0806 ) ) |
| 76 | request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[ |
| 77 | ofp.instruction.apply_actions( actions=[ |
| 78 | ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ), ], |
| 79 | buffer_id=ofp.OFP_NO_BUFFER, priority=40000 ) |
| 80 | self.controller.message_send( request ) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 81 | for port in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 82 | add_one_l2_interface_group( self.controller, port, 1, False, False ) |
| 83 | add_one_vlan_table_flow( self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_BOTH ) |
| 84 | group_id = encode_l2_interface_group_id( 1, port ) |
| 85 | add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, port ], 1, group_id, True ) |
| 86 | do_barrier( self.controller ) |
| 87 | parsed_arp_pkt = simple_arp_packet( ) |
| 88 | arp_pkt = str( parsed_arp_pkt ) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 89 | |
| 90 | for out_port in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 91 | self.dataplane.send( out_port, arp_pkt ) |
| 92 | verify_packet_in( self, arp_pkt, out_port, ofp.OFPR_ACTION ) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 93 | # change dest based on port number |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 94 | mac_dst = '00:12:34:56:78:%02X' % out_port |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 95 | for in_port in ports: |
| 96 | if in_port == out_port: |
| 97 | continue |
| 98 | # change source based on port number to avoid packet-ins from learning |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 99 | mac_src = '00:12:34:56:78:%02X' % in_port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 100 | parsed_pkt = simple_tcp_packet( eth_dst=mac_dst, eth_src=mac_src ) |
| 101 | pkt = str( parsed_pkt ) |
| 102 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 103 | |
| 104 | for ofport in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 105 | if ofport in [ out_port ]: |
| 106 | verify_packet( self, pkt, ofport ) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 107 | else: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 108 | verify_no_packet( self, pkt, ofport ) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 109 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 110 | verify_no_other_packets( self ) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 111 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 112 | class PacketInArp( base_tests.SimpleDataPlane ): |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 113 | """ |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 114 | Verify an ACL rule matching on ethertyper 0x806 will result in a packet-in |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 115 | """ |
| 116 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 117 | def runTest( self ): |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 118 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 119 | parsed_arp_pkt = simple_arp_packet( ) |
| 120 | arp_pkt = str( parsed_arp_pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 121 | # create match |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 122 | match = ofp.match( ) |
| 123 | match.oxm_list.append( ofp.oxm.eth_type( 0x0806 ) ) |
| 124 | request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[ |
| 125 | ofp.instruction.apply_actions( actions=[ |
| 126 | ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ), ], |
| 127 | buffer_id=ofp.OFP_NO_BUFFER, priority=1 ) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 128 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 129 | logging.info( "Inserting packet in flow to controller" ) |
| 130 | self.controller.message_send( request ) |
| 131 | do_barrier( self.controller ) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 132 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 133 | for of_port in config[ "port_map" ].keys( ): |
| 134 | logging.info( "PacketInMiss test, port %d", of_port ) |
| 135 | self.dataplane.send( of_port, arp_pkt ) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 136 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 137 | verify_packet_in( self, arp_pkt, of_port, ofp.OFPR_ACTION ) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 138 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 139 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 140 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 141 | delete_all_flows( self.controller ) |
| 142 | delete_all_groups( self.controller ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 143 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 144 | |
| 145 | class PacketInIPTable( base_tests.SimpleDataPlane ): |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 146 | """ |
| 147 | Test packet in function on IPTABLE |
| 148 | Send a packet to each dataplane port and verify that a packet |
| 149 | in message is received from the controller for each |
| 150 | #todo verify you stop receiving after adding rule |
| 151 | """ |
| 152 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 153 | def runTest( self ): |
| 154 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 155 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 156 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 157 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 158 | dip = 0xc0a80001 |
| 159 | ports = sorted( config[ "port_map" ].keys( ) ) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 160 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 161 | for port in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 162 | # add l2 interface group |
| 163 | vlan_id = port |
| 164 | add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, is_tagged=True, |
| 165 | send_barrier=False ) |
| 166 | dst_mac[ 5 ] = vlan_id |
| 167 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id, |
| 168 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
| 169 | # add vlan flow table |
| 170 | add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 171 | # add termination flow |
| 172 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
| 173 | # add unicast routing flow |
| 174 | dst_ip = dip + (vlan_id << 8) |
| 175 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, l3_msg.group_id, |
| 176 | send_ctrl=True ) |
| 177 | Groups.put( l3_msg.group_id ) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 178 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 179 | do_barrier( self.controller ) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 180 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 181 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 182 | for in_port in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 183 | mac_src = '00:00:00:22:22:%02X' % in_port |
| 184 | ip_src = '192.168.%02d.1' % in_port |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 185 | for out_port in ports: |
| 186 | if in_port == out_port: |
| 187 | continue |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 188 | ip_dst = '192.168.%02d.1' % out_port |
| 189 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| 190 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 191 | pkt = str( parsed_pkt ) |
| 192 | self.dataplane.send( in_port, pkt ) |
| 193 | verify_packet_in( self, pkt, in_port, ofp.OFPR_ACTION ) |
| 194 | # verify_no_other_packets(self) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 195 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 196 | delete_all_flows( self.controller ) |
| 197 | delete_groups( self.controller, Groups ) |
| 198 | delete_all_groups( self.controller ) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 199 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 200 | |
| 201 | class L2FloodQinQ( base_tests.SimpleDataPlane ): |
Flavio Castro | 1b5c21d | 2015-12-08 12:41:56 -0500 | [diff] [blame] | 202 | """ |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 203 | Verify a tagged frame can be flooded based on its outer vlan |
Flavio Castro | 1b5c21d | 2015-12-08 12:41:56 -0500 | [diff] [blame] | 204 | """ |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 205 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 206 | def runTest( self ): |
| 207 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 208 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 209 | ports = sorted( config[ "port_map" ].keys( ) ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 210 | vlan_id = 1 |
Flavio Castro | 1b5c21d | 2015-12-08 12:41:56 -0500 | [diff] [blame] | 211 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 212 | for port in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 213 | L2gid, l2msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False ) |
| 214 | add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 215 | Groups.put( L2gid ) |
Flavio Castro | 1b5c21d | 2015-12-08 12:41:56 -0500 | [diff] [blame] | 216 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 217 | msg = add_l2_flood_group( self.controller, ports, vlan_id, vlan_id ) |
| 218 | Groups.put( msg.group_id ) |
| 219 | add_bridge_flow( self.controller, None, vlan_id, msg.group_id, True ) |
| 220 | do_barrier( self.controller ) |
Flavio Castro | 1b5c21d | 2015-12-08 12:41:56 -0500 | [diff] [blame] | 221 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 222 | # verify flood |
| 223 | for ofport in ports: |
| 224 | # change dest based on port number |
| 225 | mac_src = '00:12:34:56:78:%02X' % ofport |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 226 | parsed_pkt = simple_tcp_packet_two_vlan( pktlen=108, out_dl_vlan_enable=True, |
| 227 | out_vlan_vid=vlan_id, in_dl_vlan_enable=True, in_vlan_vid=10, |
| 228 | eth_dst='00:12:34:56:78:9a', eth_src=mac_src ) |
| 229 | pkt = str( parsed_pkt ) |
| 230 | self.dataplane.send( ofport, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 231 | # self won't rx packet |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 232 | verify_no_packet( self, pkt, ofport ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 233 | # others will rx packet |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 234 | tmp_ports = list( ports ) |
| 235 | tmp_ports.remove( ofport ) |
| 236 | verify_packets( self, pkt, tmp_ports ) |
Flavio Castro | 1b5c21d | 2015-12-08 12:41:56 -0500 | [diff] [blame] | 237 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 238 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 239 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 240 | delete_all_flows( self.controller ) |
| 241 | delete_groups( self.controller, Groups ) |
| 242 | delete_all_groups( self.controller ) |
| 243 | |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 244 | |
Flavio Castro | ce3bfeb | 2016-02-04 14:06:55 -0500 | [diff] [blame] | 245 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 246 | class L2FloodTagged( base_tests.SimpleDataPlane ): |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 247 | """ |
| 248 | Test L2 flood to a vlan |
| 249 | Send a packet with unknown dst_mac and check if the packet is flooded to all ports except inport |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 250 | """ |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 251 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 252 | def runTest( self ): |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 253 | # Hashes Test Name and uses it as id for installing unique groups |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 254 | vlan_id = abs( hash( inspect.stack( )[ 0 ][ 3 ] ) ) % (256) |
Flavio Castro | ce3bfeb | 2016-02-04 14:06:55 -0500 | [diff] [blame] | 255 | print vlan_id |
Flavio Castro | aba28ff | 2016-02-03 16:47:48 -0500 | [diff] [blame] | 256 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 257 | ports = sorted( config[ "port_map" ].keys( ) ) |
Flavio Castro | 34352e7 | 2015-12-07 20:01:51 -0500 | [diff] [blame] | 258 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 259 | delete_all_flows( self.controller ) |
| 260 | delete_all_groups( self.controller ) |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 261 | |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 262 | # Installing flows to avoid packet-in |
| 263 | for port in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 264 | add_one_l2_interface_group( self.controller, port, vlan_id, True, False ) |
| 265 | add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 266 | msg = add_l2_flood_group( self.controller, ports, vlan_id, vlan_id ) |
| 267 | add_bridge_flow( self.controller, None, vlan_id, msg.group_id, True ) |
| 268 | do_barrier( self.controller ) |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 269 | |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 270 | # verify flood |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 271 | for ofport in ports: |
| 272 | # change dest based on port number |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 273 | pkt = str( |
| 274 | simple_tcp_packet( dl_vlan_enable=True, vlan_vid=vlan_id, eth_dst='00:12:34:56:78:9a' ) ) |
| 275 | self.dataplane.send( ofport, pkt ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 276 | # self won't rx packet |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 277 | verify_no_packet( self, pkt, ofport ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 278 | # others will rx packet |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 279 | tmp_ports = list( ports ) |
| 280 | tmp_ports.remove( ofport ) |
| 281 | verify_packets( self, pkt, tmp_ports ) |
| 282 | verify_no_other_packets( self ) |
Flavio Castro | aabb579 | 2015-11-18 19:03:50 -0500 | [diff] [blame] | 283 | |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 284 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 285 | class L2UnicastTagged( base_tests.SimpleDataPlane ): |
Flavio Castro | aabb579 | 2015-11-18 19:03:50 -0500 | [diff] [blame] | 286 | """ |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 287 | Verify L2 forwarding works |
Flavio Castro | aabb579 | 2015-11-18 19:03:50 -0500 | [diff] [blame] | 288 | """ |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 289 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 290 | def runTest( self ): |
Flavio Castro | b01d0aa | 2016-07-20 16:14:48 -0700 | [diff] [blame] | 291 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 292 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 293 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 294 | ports = sorted( config[ "port_map" ].keys( ) ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 295 | vlan_id = 1; |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 296 | for port in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 297 | L2gid, l2msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False ) |
| 298 | add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 299 | Groups.put( L2gid ) |
| 300 | add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, port ], vlan_id, L2gid, |
| 301 | True ) |
| 302 | do_barrier( self.controller ) |
Flavio Castro | 6efe186 | 2015-11-18 16:28:06 -0500 | [diff] [blame] | 303 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 304 | for out_port in ports: |
| 305 | # change dest based on port number |
| 306 | mac_dst = '00:12:34:56:78:%02X' % out_port |
| 307 | for in_port in ports: |
| 308 | if in_port == out_port: |
| 309 | continue |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 310 | pkt = str( simple_tcp_packet( dl_vlan_enable=True, vlan_vid=vlan_id, eth_dst=mac_dst ) ) |
| 311 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 312 | for ofport in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 313 | if ofport in [ out_port ]: |
| 314 | verify_packet( self, pkt, ofport ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 315 | else: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 316 | verify_no_packet( self, pkt, ofport ) |
| 317 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 318 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 319 | delete_all_flows( self.controller ) |
| 320 | delete_groups( self.controller, Groups ) |
| 321 | delete_all_groups( self.controller ) |
Flavio Castro | 6efe186 | 2015-11-18 16:28:06 -0500 | [diff] [blame] | 322 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 323 | |
| 324 | class Mtu1500( base_tests.SimpleDataPlane ): |
| 325 | def runTest( self ): |
| 326 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 327 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 328 | ports = sorted( config[ "port_map" ].keys( ) ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 329 | vlan_id = 18 |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 330 | for port in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 331 | L2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False ) |
| 332 | add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 333 | Groups.put( L2gid ) |
| 334 | add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, port ], vlan_id, L2gid, |
| 335 | True ) |
| 336 | do_barrier( self.controller ) |
Flavio Castro | b677303 | 2015-11-19 22:49:24 -0500 | [diff] [blame] | 337 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 338 | for out_port in ports: |
| 339 | # change dest based on port number |
| 340 | mac_dst = '00:12:34:56:78:%02X' % out_port |
| 341 | for in_port in ports: |
| 342 | if in_port == out_port: |
| 343 | continue |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 344 | pkt = str( simple_tcp_packet( pktlen=1500, dl_vlan_enable=True, vlan_vid=vlan_id, |
| 345 | eth_dst=mac_dst ) ) |
| 346 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 347 | for ofport in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 348 | if ofport in [ out_port ]: |
| 349 | verify_packet( self, pkt, ofport ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 350 | else: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 351 | verify_no_packet( self, pkt, ofport ) |
| 352 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 353 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 354 | delete_all_flows( self.controller ) |
| 355 | delete_groups( self.controller, Groups ) |
| 356 | delete_all_groups( self.controller ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 357 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 358 | |
| 359 | class _32UcastTagged( base_tests.SimpleDataPlane ): |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 360 | """ |
| 361 | Verify a IP forwarding works for a /32 rule to L3 Unicast Interface |
| 362 | """ |
| 363 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 364 | def runTest( self ): |
| 365 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 366 | try: |
| 367 | test_id = 26 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 368 | if len( config[ "port_map" ] ) < 2: |
| 369 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 370 | return |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 371 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 372 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 373 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 374 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 375 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 376 | for port in ports: |
| 377 | # add l2 interface group |
| 378 | vlan_id = port + test_id |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 379 | l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, |
| 380 | is_tagged=True, send_barrier=False ) |
| 381 | dst_mac[ 5 ] = vlan_id |
| 382 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id, |
| 383 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 384 | # add vlan flow table |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 385 | add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 386 | # add termination flow |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 387 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 388 | # add unicast routing flow |
| 389 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 390 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id ) |
| 391 | Groups.put( l2gid ) |
| 392 | Groups.put( l3_msg.group_id ) |
| 393 | do_barrier( self.controller ) |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 394 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 395 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 396 | for in_port in ports: |
| 397 | mac_src = '00:00:00:22:32:%02X' % (test_id + in_port) |
| 398 | ip_src = '192.168.%02d.1' % (test_id + in_port) |
| 399 | for out_port in ports: |
| 400 | if in_port == out_port: |
| 401 | continue |
| 402 | ip_dst = '192.168.%02d.1' % (test_id + out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 403 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, |
| 404 | vlan_vid=(test_id + in_port), eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, |
| 405 | ip_src=ip_src, ip_dst=ip_dst ) |
| 406 | pkt = str( parsed_pkt ) |
| 407 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 408 | # build expected packet |
| 409 | mac_dst = '00:00:00:22:22:%02X' % (test_id + out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 410 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, |
| 411 | vlan_vid=(test_id + out_port), eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, |
| 412 | ip_src=ip_src, ip_dst=ip_dst ) |
| 413 | pkt = str( exp_pkt ) |
| 414 | verify_packet( self, pkt, out_port ) |
| 415 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 416 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 417 | delete_all_flows( self.controller ) |
| 418 | delete_groups( self.controller, Groups ) |
| 419 | delete_all_groups( self.controller ) |
Flavio Castro | 05d20bc | 2015-11-16 15:06:14 -0500 | [diff] [blame] | 420 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 421 | |
| 422 | class _32VPN( base_tests.SimpleDataPlane ): |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 423 | """ |
| 424 | Insert IP packet |
| 425 | Receive MPLS packet |
| 426 | """ |
| 427 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 428 | def runTest( self ): |
| 429 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 430 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 431 | if len( config[ "port_map" ] ) < 2: |
| 432 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 433 | return |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 434 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 435 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 436 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 437 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 438 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 439 | for port in ports: |
| 440 | # add l2 interface group |
| 441 | id = port |
| 442 | vlan_id = port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 443 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True ) |
| 444 | dst_mac[ 5 ] = vlan_id |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 445 | # add MPLS interface group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 446 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| 447 | vlan_id, id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 448 | # add MPLS L3 VPN group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 449 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| 450 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid, |
| 451 | push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 452 | # ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [mpls_label_gid]) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 453 | do_barrier( self.controller ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 454 | # add vlan flow table |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 455 | add_one_vlan_table_flow( self.controller, port, vlan_id, vrf=2, |
| 456 | flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 457 | # add termination flow |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 458 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 459 | # add routing flow |
| 460 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 461 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, mpls_label_gid, vrf=2 ) |
| 462 | Groups._put( l2_gid ) |
| 463 | Groups._put( mpls_gid ) |
| 464 | Groups._put( mpls_label_gid ) |
| 465 | do_barrier( self.controller ) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 466 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 467 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 468 | for in_port in ports: |
| 469 | ip_src = '192.168.%02d.1' % (in_port) |
| 470 | for out_port in ports: |
| 471 | if in_port == out_port: |
| 472 | continue |
| 473 | ip_dst = '192.168.%02d.1' % (out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 474 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port), |
| 475 | eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 476 | pkt = str( parsed_pkt ) |
| 477 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 478 | # build expect packet |
| 479 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
| 480 | label = (out_port, 0, 1, 32) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 481 | exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63, |
| 482 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, |
| 483 | label=[ label ] ) |
| 484 | pkt = str( exp_pkt ) |
| 485 | verify_packet( self, pkt, out_port ) |
| 486 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 487 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 488 | delete_all_flows( self.controller ) |
| 489 | delete_groups( self.controller, Groups ) |
| 490 | delete_all_groups( self.controller ) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 491 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 492 | |
| 493 | class _32EcmpVpn( base_tests.SimpleDataPlane ): |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 494 | """ |
| 495 | Insert IP packet |
| 496 | Receive MPLS packet |
| 497 | """ |
| 498 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 499 | def runTest( self ): |
| 500 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 501 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 502 | if len( config[ "port_map" ] ) < 2: |
| 503 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 504 | return |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 505 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 506 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 507 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 508 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 509 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 510 | for port in ports: |
| 511 | # add l2 interface group |
| 512 | id = port |
| 513 | vlan_id = port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 514 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True ) |
| 515 | dst_mac[ 5 ] = vlan_id |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 516 | # add MPLS interface group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 517 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| 518 | vlan_id, id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 519 | # add MPLS L3 VPN group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 520 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| 521 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid, |
| 522 | push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 ) |
| 523 | ecmp_msg = add_l3_ecmp_group( self.controller, vlan_id, [ mpls_label_gid ] ) |
| 524 | do_barrier( self.controller ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 525 | # add vlan flow table |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 526 | add_one_vlan_table_flow( self.controller, port, vlan_id, vrf=0, |
| 527 | flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 528 | # add termination flow |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 529 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 530 | # add routing flow |
| 531 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 532 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id ) |
| 533 | Groups._put( l2_gid ) |
| 534 | Groups._put( mpls_gid ) |
| 535 | Groups._put( mpls_label_gid ) |
| 536 | Groups._put( ecmp_msg.group_id ) |
| 537 | do_barrier( self.controller ) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 538 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 539 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 540 | for in_port in ports: |
| 541 | ip_src = '192.168.%02d.1' % (in_port) |
| 542 | for out_port in ports: |
| 543 | if in_port == out_port: |
| 544 | continue |
| 545 | ip_dst = '192.168.%02d.1' % (out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 546 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port), |
| 547 | eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 548 | pkt = str( parsed_pkt ) |
| 549 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 550 | # build expect packet |
| 551 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
| 552 | label = (out_port, 0, 1, 32) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 553 | exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63, |
| 554 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, |
| 555 | label=[ label ] ) |
| 556 | pkt = str( exp_pkt ) |
| 557 | verify_packet( self, pkt, out_port ) |
| 558 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 559 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 560 | delete_all_flows( self.controller ) |
| 561 | delete_groups( self.controller, Groups ) |
| 562 | delete_all_groups( self.controller ) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 563 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 564 | |
| 565 | class _32ECMPL3( base_tests.SimpleDataPlane ): |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 566 | """ |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 567 | Insert IP packet |
| 568 | Receive IP packet |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 569 | """ |
| 570 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 571 | def runTest( self ): |
| 572 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 573 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 574 | if len( config[ "port_map" ] ) < 2: |
| 575 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 576 | return |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 577 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 578 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 579 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 580 | dip = 0xc0a80001 |
| 581 | # Hashes Test Name and uses it as id for installing unique groups |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 582 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 583 | for port in ports: |
| 584 | vlan_id = port |
| 585 | id = port |
| 586 | # add l2 interface group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 587 | l2_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, |
| 588 | is_tagged=True, send_barrier=False ) |
| 589 | dst_mac[ 5 ] = vlan_id |
| 590 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id, |
| 591 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
| 592 | ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 593 | # add vlan flow table |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 594 | add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 595 | # add termination flow |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 596 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 597 | # add unicast routing flow |
| 598 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 599 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id ) |
| 600 | Groups._put( l2_gid ) |
| 601 | Groups._put( l3_msg.group_id ) |
| 602 | Groups._put( ecmp_msg.group_id ) |
| 603 | do_barrier( self.controller ) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 604 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 605 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 606 | for in_port in ports: |
| 607 | mac_src = '00:00:00:22:22:%02X' % in_port |
| 608 | ip_src = '192.168.%02d.1' % in_port |
| 609 | for out_port in ports: |
| 610 | if in_port == out_port: |
| 611 | continue |
| 612 | ip_dst = '192.168.%02d.1' % out_port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 613 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| 614 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 615 | pkt = str( parsed_pkt ) |
| 616 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 617 | # build expected packet |
| 618 | mac_dst = '00:00:00:22:22:%02X' % out_port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 619 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| 620 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst ) |
| 621 | pkt = str( exp_pkt ) |
| 622 | verify_packet( self, pkt, out_port ) |
| 623 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 624 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 625 | delete_all_flows( self.controller ) |
| 626 | delete_groups( self.controller, Groups ) |
| 627 | delete_all_groups( self.controller ) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 628 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 629 | |
| 630 | class _24VPN( base_tests.SimpleDataPlane ): |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 631 | """ |
| 632 | Insert IP packet |
| 633 | Receive MPLS packet |
| 634 | """ |
| 635 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 636 | def runTest( self ): |
| 637 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 638 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 639 | if len( config[ "port_map" ] ) < 2: |
| 640 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 641 | return |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 642 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 643 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 644 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 645 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 646 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 647 | for port in ports: |
| 648 | # add l2 interface group |
| 649 | id = port |
| 650 | vlan_id = port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 651 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True ) |
| 652 | dst_mac[ 5 ] = vlan_id |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 653 | # add MPLS interface group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 654 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| 655 | vlan_id, id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 656 | # add MPLS L3 VPN group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 657 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| 658 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid, |
| 659 | push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 660 | # ecmp_msg=add_l3_ecmp_group(self.controller, vlan_id, [mpls_label_gid]) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 661 | do_barrier( self.controller ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 662 | # add vlan flow table |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 663 | add_one_vlan_table_flow( self.controller, port, vlan_id, vrf=0, |
| 664 | flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 665 | # add termination flow |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 666 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 667 | # add routing flow |
| 668 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 669 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, mpls_label_gid ) |
| 670 | Groups._put( l2_gid ) |
| 671 | Groups._put( mpls_gid ) |
| 672 | Groups._put( mpls_label_gid ) |
| 673 | do_barrier( self.controller ) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 674 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 675 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 676 | for in_port in ports: |
| 677 | ip_src = '192.168.%02d.1' % (in_port) |
| 678 | for out_port in ports: |
| 679 | if in_port == out_port: |
| 680 | continue |
| 681 | ip_dst = '192.168.%02d.1' % (out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 682 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port), |
| 683 | eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 684 | pkt = str( parsed_pkt ) |
| 685 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 686 | # build expect packet |
| 687 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
| 688 | label = (out_port, 0, 1, 32) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 689 | exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63, |
| 690 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, |
| 691 | label=[ label ] ) |
| 692 | pkt = str( exp_pkt ) |
| 693 | verify_packet( self, pkt, out_port ) |
| 694 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 695 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 696 | delete_all_flows( self.controller ) |
| 697 | delete_groups( self.controller, Groups ) |
| 698 | delete_all_groups( self.controller ) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 699 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 700 | |
| 701 | class _24EcmpVpn( base_tests.SimpleDataPlane ): |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 702 | """ |
| 703 | Insert IP packet |
| 704 | Receive MPLS packet |
| 705 | """ |
Flavio Castro | 72a45d5 | 2015-12-02 16:37:05 -0500 | [diff] [blame] | 706 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 707 | def runTest( self ): |
| 708 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 709 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 710 | if len( config[ "port_map" ] ) < 2: |
| 711 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 712 | return |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 713 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 714 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 715 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 716 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 717 | for port in ports: |
| 718 | # add l2 interface group |
| 719 | id = port |
| 720 | vlan_id = id |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 721 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True ) |
| 722 | dst_mac[ 5 ] = vlan_id |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 723 | # add MPLS interface group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 724 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| 725 | vlan_id, id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 726 | # add MPLS L3 VPN group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 727 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| 728 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid, |
| 729 | push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 ) |
| 730 | ecmp_msg = add_l3_ecmp_group( self.controller, id, [ mpls_label_gid ] ) |
| 731 | do_barrier( self.controller ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 732 | # add vlan flow table |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 733 | add_one_vlan_table_flow( self.controller, port, vlan_id, vrf=0, |
| 734 | flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 735 | # add termination flow |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 736 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 737 | # add routing flow |
| 738 | dst_ip = dip + (vlan_id << 8) |
| 739 | # add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0, mpls_label_gid, vrf=2) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 740 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id, |
| 741 | vrf=0 ) |
| 742 | Groups._put( l2_gid ) |
| 743 | Groups._put( mpls_gid ) |
| 744 | Groups._put( mpls_label_gid ) |
| 745 | Groups._put( ecmp_msg.group_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 746 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 747 | do_barrier( self.controller ) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 748 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 749 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 750 | for in_port in ports: |
| 751 | mac_src = '00:00:00:22:22:%02X' % (in_port) |
| 752 | ip_src = '192.168.%02d.1' % (in_port) |
| 753 | for out_port in ports: |
| 754 | if in_port == out_port: |
| 755 | continue |
| 756 | ip_dst = '192.168.%02d.1' % (out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 757 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port), |
| 758 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 759 | pkt = str( parsed_pkt ) |
| 760 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 761 | # build expect packet |
| 762 | mac_dst = '00:00:00:22:22:%02X' % out_port |
| 763 | label = (out_port, 0, 1, 32) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 764 | exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63, |
| 765 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, |
| 766 | label=[ label ] ) |
| 767 | pkt = str( exp_pkt ) |
| 768 | verify_packet( self, pkt, out_port ) |
| 769 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 770 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 771 | delete_all_flows( self.controller ) |
| 772 | delete_groups( self.controller, Groups ) |
| 773 | delete_all_groups( self.controller ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 774 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 775 | |
| 776 | class FloodGroupMod( base_tests.SimpleDataPlane ): |
| 777 | """ |
| 778 | Modify referenced group test |
| 779 | """ |
| 780 | |
| 781 | def runTest( self ): |
| 782 | Groups = Queue.LifoQueue( ) |
| 783 | try: |
| 784 | ports = sorted( config[ "port_map" ].keys( ) ) |
| 785 | vlan_id = 1 |
| 786 | |
| 787 | for port in ports: |
| 788 | L2gid, l2msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False ) |
| 789 | add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 790 | Groups.put( L2gid ) |
| 791 | |
| 792 | msg = add_l2_flood_group( self.controller, ports, vlan_id, vlan_id ) |
| 793 | Groups.put( msg.group_id ) |
| 794 | add_bridge_flow( self.controller, None, vlan_id, msg.group_id, True ) |
| 795 | do_barrier( self.controller ) |
| 796 | # verify flood |
| 797 | for ofport in ports: |
| 798 | # change dest based on port number |
| 799 | mac_src = '00:12:34:56:78:%02X' % ofport |
| 800 | parsed_pkt = simple_tcp_packet_two_vlan( pktlen=108, out_dl_vlan_enable=True, |
| 801 | out_vlan_vid=vlan_id, in_dl_vlan_enable=True, in_vlan_vid=10, |
| 802 | eth_dst='00:12:34:56:78:9a', eth_src=mac_src ) |
| 803 | pkt = str( parsed_pkt ) |
| 804 | self.dataplane.send( ofport, pkt ) |
| 805 | # self won't rx packet |
| 806 | verify_no_packet( self, pkt, ofport ) |
| 807 | # others will rx packet |
| 808 | tmp_ports = list( ports ) |
| 809 | tmp_ports.remove( ofport ) |
| 810 | verify_packets( self, pkt, tmp_ports ) |
| 811 | verify_no_other_packets( self ) |
| 812 | msg = mod_l2_flood_group( self.controller, [ ports[ 0 ] ], vlan_id, vlan_id ) |
| 813 | mac_src = '00:12:34:56:78:%02X' % ports[ 1 ] |
| 814 | parsed_pkt = simple_tcp_packet_two_vlan( pktlen=108, out_dl_vlan_enable=True, |
| 815 | out_vlan_vid=vlan_id, in_dl_vlan_enable=True, in_vlan_vid=10, eth_dst='00:12:34:56:78:9a', |
| 816 | eth_src=mac_src ) |
| 817 | pkt = str( parsed_pkt ) |
| 818 | self.dataplane.send( ports[ 1 ], pkt ) |
| 819 | verify_packets( self, pkt, [ ports[ 0 ] ] ) |
| 820 | finally: |
| 821 | delete_all_flows( self.controller ) |
| 822 | delete_groups( self.controller, Groups ) |
| 823 | delete_all_groups( self.controller ) |
| 824 | |
| 825 | |
| 826 | class _24ECMPL3( base_tests.SimpleDataPlane ): |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 827 | """ |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 828 | Insert IP packet |
| 829 | Receive IP packet |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 830 | """ |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 831 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 832 | def runTest( self ): |
| 833 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 834 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 835 | if len( config[ "port_map" ] ) < 2: |
| 836 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 837 | return |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 838 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 839 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 840 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 841 | dip = 0xc0a80001 |
| 842 | # Hashes Test Name and uses it as id for installing unique groups |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 843 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 844 | for port in ports: |
| 845 | vlan_id = port |
| 846 | id = port |
| 847 | # add l2 interface group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 848 | l2_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, |
| 849 | is_tagged=True, send_barrier=False ) |
| 850 | dst_mac[ 5 ] = vlan_id |
| 851 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id, |
| 852 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
| 853 | ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 854 | # add vlan flow table |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 855 | add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 856 | # add termination flow |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 857 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 858 | # add unicast routing flow |
| 859 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 860 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id ) |
| 861 | Groups._put( l2_gid ) |
| 862 | Groups._put( l3_msg.group_id ) |
| 863 | Groups._put( ecmp_msg.group_id ) |
| 864 | do_barrier( self.controller ) |
Flavio Castro | 72a45d5 | 2015-12-02 16:37:05 -0500 | [diff] [blame] | 865 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 866 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 867 | for in_port in ports: |
| 868 | mac_src = '00:00:00:22:22:%02X' % in_port |
| 869 | ip_src = '192.168.%02d.1' % in_port |
| 870 | for out_port in ports: |
| 871 | if in_port == out_port: |
| 872 | continue |
| 873 | ip_dst = '192.168.%02d.1' % out_port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 874 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| 875 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 876 | pkt = str( parsed_pkt ) |
| 877 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 878 | # build expected packet |
| 879 | mac_dst = '00:00:00:22:22:%02X' % out_port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 880 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| 881 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst ) |
| 882 | pkt = str( exp_pkt ) |
| 883 | verify_packet( self, pkt, out_port ) |
| 884 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 885 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 886 | delete_all_flows( self.controller ) |
| 887 | delete_groups( self.controller, Groups ) |
| 888 | delete_all_groups( self.controller ) |
| 889 | |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 890 | |
Flavio Castro | aba28ff | 2016-02-03 16:47:48 -0500 | [diff] [blame] | 891 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 892 | class MPLSBUG( base_tests.SimpleDataPlane ): |
| 893 | def runTest( self ): |
| 894 | if len( config[ "port_map" ] ) < 2: |
| 895 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 896 | return |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 897 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 898 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 899 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 900 | Groups = Queue.LifoQueue( ) |
| 901 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 902 | for port in ports: |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 903 | # add l2 interface group |
| 904 | vlan_id = port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 905 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False ) |
| 906 | dst_mac[ 5 ] = vlan_id |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 907 | # add L3 Unicast group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 908 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id, |
| 909 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 910 | # add vlan flow table |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 911 | add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_BOTH ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 912 | # add termination flow |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 913 | add_termination_flow( self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24 ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 914 | # add mpls flow |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 915 | add_mpls_flow( self.controller, l3_msg.group_id, port ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 916 | # add termination flow |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 917 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 918 | # add unicast routing flow |
| 919 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 920 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id ) |
| 921 | Groups._put( l2_gid ) |
| 922 | Groups._put( l3_msg.group_id ) |
| 923 | do_barrier( self.controller ) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 924 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 925 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 926 | for in_port in ports: |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 927 | mac_src = '00:00:00:22:22:%02X' % in_port |
| 928 | ip_src = '192.168.%02d.1' % in_port |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 929 | for out_port in ports: |
| 930 | if in_port == out_port: |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 931 | continue |
| 932 | ip_dst = '192.168.%02d.1' % out_port |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 933 | switch_mac = "00:00:00:cc:cc:cc" |
| 934 | label = (out_port, 0, 1, 32) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 935 | parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=in_port, ip_src=ip_src, |
| 936 | ip_dst=ip_dst, eth_dst=switch_mac, eth_src=mac_src, label=[ label ] ) |
| 937 | pkt = str( parsed_pkt ) |
| 938 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 939 | |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 940 | # build expect packet |
| 941 | mac_dst = '00:00:00:22:22:%02X' % out_port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 942 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| 943 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst ) |
| 944 | pkt = str( exp_pkt ) |
| 945 | verify_packet( self, pkt, out_port ) |
| 946 | verify_no_other_packets( self ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 947 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 948 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| 949 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 950 | pkt = str( parsed_pkt ) |
| 951 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 952 | # build expected packet |
| 953 | mac_dst = '00:00:00:22:22:%02X' % out_port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 954 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| 955 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst ) |
| 956 | pkt = str( exp_pkt ) |
| 957 | verify_packet( self, pkt, out_port ) |
| 958 | verify_no_other_packets( self ) |
| 959 | delete_all_flows( self.controller ) |
| 960 | delete_groups( self.controller, Groups ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 961 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 962 | |
| 963 | class L3McastToL2( base_tests.SimpleDataPlane ): |
castroflavio | cc403a9 | 2015-12-15 14:04:19 -0500 | [diff] [blame] | 964 | """ |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 965 | Mcast routing to L2 |
castroflavio | cc403a9 | 2015-12-15 14:04:19 -0500 | [diff] [blame] | 966 | """ |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 967 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 968 | def runTest( self ): |
castroflavio | cc403a9 | 2015-12-15 14:04:19 -0500 | [diff] [blame] | 969 | """ |
| 970 | port1 (vlan 300)-> All Ports (vlan 300) |
| 971 | """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 972 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 973 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 974 | if len( config[ "port_map" ] ) < 3: |
| 975 | logging.info( "Port count less than 3, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 976 | assert (False) |
| 977 | return |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 978 | vlan_id = 300 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 979 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 980 | intf_src_mac_str = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| 981 | dst_mac = [ 0x01, 0x00, 0x5e, 0x01, 0x01, 0x01 ] |
| 982 | dst_mac_str = ':'.join( [ '%02X' % x for x in dst_mac ] ) |
| 983 | port1_mac = [ 0x00, 0x11, 0x11, 0x11, 0x11, 0x11 ] |
| 984 | port1_mac_str = ':'.join( [ '%02X' % x for x in port1_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 985 | src_ip = 0xc0a80101 |
| 986 | src_ip_str = "192.168.1.1" |
| 987 | dst_ip = 0xe0010101 |
| 988 | dst_ip_str = "224.1.1.1" |
castroflavio | cc403a9 | 2015-12-15 14:04:19 -0500 | [diff] [blame] | 989 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 990 | port1 = config[ "port_map" ].keys( )[ 0 ] |
| 991 | port2 = config[ "port_map" ].keys( )[ 1 ] |
castroflavio | cc403a9 | 2015-12-15 14:04:19 -0500 | [diff] [blame] | 992 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 993 | switch_mac = [ 0x01, 0x00, 0x5e, 0x00, 0x00, 0x00 ] |
castroflavio | cc403a9 | 2015-12-15 14:04:19 -0500 | [diff] [blame] | 994 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 995 | # add l2 interface group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 996 | l2_intf_group_list = [ ] |
| 997 | for port in config[ "port_map" ].keys( ): |
| 998 | add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 999 | if port == port2: |
| 1000 | continue |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1001 | l2_intf_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, |
| 1002 | is_tagged=True, send_barrier=False ) |
| 1003 | l2_intf_group_list.append( l2_intf_gid ) |
| 1004 | Groups.put( l2_intf_gid ) |
castroflavio | cc403a9 | 2015-12-15 14:04:19 -0500 | [diff] [blame] | 1005 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1006 | # add termination flow |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1007 | add_termination_flow( self.controller, port1, 0x0800, switch_mac, vlan_id ) |
castroflavio | cc403a9 | 2015-12-15 14:04:19 -0500 | [diff] [blame] | 1008 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1009 | # add l3 interface group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1010 | mcat_group_msg = add_l3_mcast_group( self.controller, vlan_id, 2, l2_intf_group_list ) |
| 1011 | add_mcast4_routing_flow( self.controller, vlan_id, src_ip, 0, dst_ip, mcat_group_msg.group_id ) |
| 1012 | Groups._put( mcat_group_msg.group_id ) |
castroflavio | cc403a9 | 2015-12-15 14:04:19 -0500 | [diff] [blame] | 1013 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1014 | parsed_pkt = simple_udp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=vlan_id, |
| 1015 | eth_dst=dst_mac_str, eth_src=port1_mac_str, ip_ttl=64, ip_src=src_ip_str, |
| 1016 | ip_dst=dst_ip_str ) |
| 1017 | pkt = str( parsed_pkt ) |
| 1018 | self.dataplane.send( port1, pkt ) |
| 1019 | for port in config[ "port_map" ].keys( ): |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1020 | if port == port2 or port == port1: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1021 | verify_no_packet( self, pkt, port ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1022 | continue |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1023 | verify_packet( self, pkt, port ) |
| 1024 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1025 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1026 | delete_all_flows( self.controller ) |
| 1027 | delete_groups( self.controller, Groups ) |
| 1028 | delete_all_groups( self.controller ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1029 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1030 | |
| 1031 | class L3McastToL3( base_tests.SimpleDataPlane ): |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 1032 | """ |
| 1033 | Mcast routing |
| 1034 | """ |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1035 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1036 | def runTest( self ): |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 1037 | """ |
| 1038 | port1 (vlan 1)-> port 2 (vlan 2) |
| 1039 | """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1040 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1041 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1042 | if len( config[ "port_map" ] ) < 3: |
| 1043 | logging.info( "Port count less than 3, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1044 | assert (False) |
| 1045 | return |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 1046 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1047 | vlan_id = 1 |
| 1048 | port2_out_vlan = 2 |
| 1049 | port3_out_vlan = 3 |
| 1050 | in_vlan = 1 # macast group vid shall use input vlan diffe from l3 interface use output vlan |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1051 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1052 | intf_src_mac_str = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| 1053 | dst_mac = [ 0x01, 0x00, 0x5e, 0x01, 0x01, 0x01 ] |
| 1054 | dst_mac_str = ':'.join( [ '%02X' % x for x in dst_mac ] ) |
| 1055 | port1_mac = [ 0x00, 0x11, 0x11, 0x11, 0x11, 0x11 ] |
| 1056 | port1_mac_str = ':'.join( [ '%02X' % x for x in port1_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1057 | src_ip = 0xc0a80101 |
| 1058 | src_ip_str = "192.168.1.1" |
| 1059 | dst_ip = 0xe0010101 |
| 1060 | dst_ip_str = "224.1.1.1" |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 1061 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1062 | port1 = config[ "port_map" ].keys( )[ 0 ] |
| 1063 | port2 = config[ "port_map" ].keys( )[ 1 ] |
| 1064 | port3 = config[ "port_map" ].keys( )[ 2 ] |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 1065 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1066 | # add l2 interface group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1067 | for port in config[ "port_map" ].keys( ): |
| 1068 | l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, |
| 1069 | is_tagged=False, send_barrier=False ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1070 | # add vlan flow table |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1071 | add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1072 | vlan_id += 1 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1073 | Groups._put( l2gid ) |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 1074 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1075 | # add termination flow |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1076 | add_termination_flow( self.controller, port1, 0x0800, [ 0x01, 0x00, 0x5e, 0x00, 0x00, 0x00 ], |
| 1077 | vlan_id ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1078 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1079 | # add l3 interface group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1080 | port2_ucast_msg = add_l3_interface_group( self.controller, port2, port2_out_vlan, 2, |
| 1081 | intf_src_mac ) |
| 1082 | port3_ucast_msg = add_l3_interface_group( self.controller, port3, port3_out_vlan, 3, |
| 1083 | intf_src_mac ) |
| 1084 | mcat_group_msg = add_l3_mcast_group( self.controller, in_vlan, 2, |
| 1085 | [ port2_ucast_msg.group_id, port3_ucast_msg.group_id ] ) |
| 1086 | add_mcast4_routing_flow( self.controller, in_vlan, src_ip, 0, dst_ip, mcat_group_msg.group_id ) |
| 1087 | Groups._put( port2_ucast_msg.group_id ) |
| 1088 | Groups._put( port3_ucast_msg.group_id ) |
| 1089 | Groups._put( mcat_group_msg.group_id ) |
| 1090 | parsed_pkt = simple_udp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=1, eth_dst=dst_mac_str, |
| 1091 | eth_src=port1_mac_str, ip_ttl=64, ip_src=src_ip_str, ip_dst=dst_ip_str ) |
| 1092 | pkt = str( parsed_pkt ) |
| 1093 | self.dataplane.send( port1, pkt ) |
| 1094 | parsed_pkt = simple_udp_packet( pktlen=96, eth_dst=dst_mac_str, eth_src=intf_src_mac_str, |
| 1095 | ip_ttl=63, ip_src=src_ip_str, ip_dst=dst_ip_str ) |
| 1096 | pkt = str( parsed_pkt ) |
| 1097 | verify_packet( self, pkt, port2 ) |
| 1098 | verify_packet( self, pkt, port3 ) |
| 1099 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1100 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1101 | delete_all_flows( self.controller ) |
| 1102 | delete_groups( self.controller, Groups ) |
| 1103 | delete_all_groups( self.controller ) |
| 1104 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1105 | class _MplsFwd( base_tests.SimpleDataPlane ): |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 1106 | """ |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1107 | Insert MPLS packet |
Flavio Castro | 5494794 | 2016-02-03 16:05:20 -0500 | [diff] [blame] | 1108 | Receive MPLS packet |
castroflavio | 30c6cc5 | 2016-01-07 15:19:42 -0800 | [diff] [blame] | 1109 | """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1110 | |
| 1111 | def runTest( self ): |
| 1112 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1113 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1114 | if len( config[ "port_map" ] ) < 2: |
| 1115 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1116 | return |
| 1117 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1118 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1119 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1120 | # Assigns unique hardcoded test_id to make sure tests don't overlap when writing rules |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1121 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1122 | for port in ports: |
| 1123 | # add l2 interface group |
| 1124 | id = port |
| 1125 | vlan_id = id |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1126 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False ) |
| 1127 | dst_mac[ 5 ] = vlan_id |
| 1128 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| 1129 | vlan_id, id ) |
| 1130 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| 1131 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_SWAP_LABEL, index=id, ref_gid=mpls_gid, |
| 1132 | push_mpls_header=False, set_mpls_label=port, set_bos=1 ) |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 1133 | #ecmp_gid, ecmp_msg = add_mpls_forwarding_group( self.controller, |
| 1134 | # subtype=OFDPA_MPLS_GROUP_SUBTYPE_ECMP, index=id, ref_gids=[mpls_label_gid] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1135 | # add vlan flow table |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1136 | add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1137 | # add termination flow |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1138 | add_termination_flow( self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24 ) |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 1139 | #add_mpls_flow( self.controller, ecmp_gid, port, goto_table=29 ) |
| 1140 | add_mpls_flow( self.controller, mpls_label_gid, port, goto_table=29 ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1141 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1142 | Groups._put( l2_gid ) |
| 1143 | Groups._put( mpls_gid ) |
| 1144 | Groups._put( mpls_label_gid ) |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 1145 | Groups._put( ecmp_gid ) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1146 | do_barrier( self.controller ) |
castroflavio | 30c6cc5 | 2016-01-07 15:19:42 -0800 | [diff] [blame] | 1147 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1148 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1149 | for in_port in ports: |
| 1150 | ip_src = '192.168.%02d.1' % (in_port) |
| 1151 | for out_port in ports: |
| 1152 | if in_port == out_port: |
| 1153 | continue |
| 1154 | ip_dst = '192.168.%02d.1' % (out_port) |
Flavio Castro | 5494794 | 2016-02-03 16:05:20 -0500 | [diff] [blame] | 1155 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1156 | label = (out_port, 0, 1, 32) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1157 | parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(in_port), |
| 1158 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] ) |
| 1159 | pkt = str( parsed_pkt ) |
| 1160 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 5494794 | 2016-02-03 16:05:20 -0500 | [diff] [blame] | 1161 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1162 | # build expect packet |
| 1163 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
| 1164 | label = (out_port, 0, 1, 31) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1165 | exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), |
| 1166 | ip_src=ip_src, ip_dst=ip_dst, eth_src=switch_mac, eth_dst=mac_dst, |
| 1167 | label=[ label ] ) |
| 1168 | pkt = str( exp_pkt ) |
| 1169 | verify_packet( self, pkt, out_port ) |
| 1170 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1171 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1172 | delete_all_flows( self.controller ) |
| 1173 | delete_groups( self.controller, Groups ) |
| 1174 | delete_all_groups( self.controller ) |
Flavio Castro | b702a2f | 2016-04-10 22:01:48 -0400 | [diff] [blame] | 1175 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1176 | |
| 1177 | class _MplsTermination( base_tests.SimpleDataPlane ): |
Flavio Castro | b702a2f | 2016-04-10 22:01:48 -0400 | [diff] [blame] | 1178 | """ |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1179 | Insert MPLS packet |
| 1180 | Receive IP packet |
Flavio Castro | b702a2f | 2016-04-10 22:01:48 -0400 | [diff] [blame] | 1181 | """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1182 | |
| 1183 | def runTest( self ): |
| 1184 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1185 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1186 | if len( config[ "port_map" ] ) < 2: |
| 1187 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1188 | return |
| 1189 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1190 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1191 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1192 | # Assigns unique hardcoded test_id to make sure tests don't overlap when writing rules |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1193 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1194 | for port in ports: |
| 1195 | # add l2 interface group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1196 | vlan_id, id, dst_mac[ 5 ] = port, port, port |
| 1197 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1198 | # add L3 Unicast group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1199 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id, |
| 1200 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1201 | # add L3 ecmp group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1202 | ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1203 | # add vlan flow table |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1204 | add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1205 | # add termination flow |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1206 | add_termination_flow( self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24 ) |
| 1207 | # add_mpls_flow(self.controller, ecmp_msg.group_id, port) |
| 1208 | add_mpls_flow( self.controller, label=port ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1209 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1210 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id, 1 ) |
| 1211 | Groups._put( l2_gid ) |
| 1212 | Groups._put( l3_msg.group_id ) |
| 1213 | Groups._put( ecmp_msg.group_id ) |
| 1214 | do_barrier( self.controller ) |
Flavio Castro | b702a2f | 2016-04-10 22:01:48 -0400 | [diff] [blame] | 1215 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1216 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1217 | for in_port in ports: |
| 1218 | ip_src = '192.168.%02d.1' % (in_port) |
| 1219 | for out_port in ports: |
| 1220 | if in_port == out_port: |
| 1221 | continue |
| 1222 | ip_dst = '192.168.%02d.1' % (out_port) |
| 1223 | label = (out_port, 0, 1, 32) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1224 | parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(in_port), |
| 1225 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] ) |
| 1226 | pkt = str( parsed_pkt ) |
| 1227 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1228 | # build expect packet |
| 1229 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1230 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(out_port), |
| 1231 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst ) |
| 1232 | pkt = str( exp_pkt ) |
| 1233 | verify_packet( self, pkt, out_port ) |
| 1234 | verify_no_other_packets( self ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1235 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1236 | delete_all_flows( self.controller ) |
| 1237 | delete_groups( self.controller, Groups ) |
| 1238 | delete_all_groups( self.controller ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1239 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1240 | |
| 1241 | class _MplsVpnFwd( base_tests.SimpleDataPlane ): |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1242 | """ |
| 1243 | Insert MPLS packet |
| 1244 | Receive IP packet |
| 1245 | """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1246 | |
| 1247 | def runTest( self ): |
| 1248 | Groups = Queue.LifoQueue( ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1249 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1250 | if len( config[ "port_map" ] ) < 2: |
| 1251 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1252 | return |
| 1253 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1254 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1255 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1256 | # Assigns unique hardcoded test_id to make sure tests don't overlap when writing rules |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1257 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1258 | for port in ports: |
| 1259 | # add l2 interface group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1260 | vlan_id, id, dst_mac[ 5 ] = port, port, port |
| 1261 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1262 | # add L3 Unicast group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1263 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id, |
| 1264 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1265 | # add L3 ecmp group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1266 | ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1267 | # add vlan flow table |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1268 | add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1269 | # add termination flow |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1270 | add_termination_flow( self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24 ) |
| 1271 | add_mpls_flow( self.controller, ecmp_msg.group_id, port ) |
| 1272 | # add_mpls_flow(self.controller, label=port) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1273 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1274 | # add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffff00, |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1275 | # ecmp_msg.group_id, 1) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1276 | Groups._put( l2_gid ) |
| 1277 | Groups._put( l3_msg.group_id ) |
| 1278 | Groups._put( ecmp_msg.group_id ) |
| 1279 | do_barrier( self.controller ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1280 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1281 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1282 | for in_port in ports: |
| 1283 | ip_src = '192.168.%02d.1' % (in_port) |
| 1284 | for out_port in ports: |
| 1285 | if in_port == out_port: |
| 1286 | continue |
| 1287 | ip_dst = '192.168.%02d.1' % (out_port) |
| 1288 | label = (out_port, 0, 1, 32) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1289 | parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(in_port), |
| 1290 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] ) |
| 1291 | pkt = str( parsed_pkt ) |
| 1292 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1293 | # build expect packet |
| 1294 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1295 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(out_port), |
| 1296 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst ) |
| 1297 | pkt = str( exp_pkt ) |
| 1298 | verify_packet( self, pkt, out_port ) |
| 1299 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1300 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1301 | delete_all_flows( self.controller ) |
| 1302 | delete_groups( self.controller, Groups ) |
| 1303 | delete_all_groups( self.controller ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1304 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1305 | |
| 1306 | class _24UcastTagged( base_tests.SimpleDataPlane ): |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1307 | """ |
| 1308 | Verify a IP forwarding works for a /32 rule to L3 Unicast Interface |
| 1309 | """ |
| 1310 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1311 | def runTest( self ): |
| 1312 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1313 | try: |
| 1314 | test_id = 26 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1315 | if len( config[ "port_map" ] ) < 2: |
| 1316 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1317 | return |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1318 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1319 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1320 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1321 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1322 | for port in ports: |
| 1323 | # add l2 interface group |
| 1324 | vlan_id = port + test_id |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1325 | l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, |
| 1326 | is_tagged=True, send_barrier=False ) |
| 1327 | dst_mac[ 5 ] = vlan_id |
| 1328 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id, |
| 1329 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1330 | # add vlan flow table |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1331 | add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1332 | # add termination flow |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1333 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1334 | # add unicast routing flow |
| 1335 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1336 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, l3_msg.group_id ) |
| 1337 | Groups.put( l2gid ) |
| 1338 | Groups.put( l3_msg.group_id ) |
| 1339 | do_barrier( self.controller ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1340 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1341 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1342 | for in_port in ports: |
| 1343 | mac_src = '00:00:00:22:22:%02X' % (test_id + in_port) |
| 1344 | ip_src = '192.168.%02d.1' % (test_id + in_port) |
| 1345 | for out_port in ports: |
| 1346 | if in_port == out_port: |
| 1347 | continue |
| 1348 | ip_dst = '192.168.%02d.1' % (test_id + out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1349 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, |
| 1350 | vlan_vid=(test_id + in_port), eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, |
| 1351 | ip_src=ip_src, ip_dst=ip_dst ) |
| 1352 | pkt = str( parsed_pkt ) |
| 1353 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1354 | # build expected packet |
| 1355 | mac_dst = '00:00:00:22:22:%02X' % (test_id + out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1356 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, |
| 1357 | vlan_vid=(test_id + out_port), eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, |
| 1358 | ip_src=ip_src, ip_dst=ip_dst ) |
| 1359 | pkt = str( exp_pkt ) |
| 1360 | verify_packet( self, pkt, out_port ) |
| 1361 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1362 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1363 | delete_all_flows( self.controller ) |
| 1364 | delete_groups( self.controller, Groups ) |
| 1365 | delete_all_groups( self.controller ) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 1366 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1367 | |
| 1368 | class _0Ucast( base_tests.SimpleDataPlane ): |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 1369 | """ |
| 1370 | Verify a IP forwarding works for a /0 rule to L3 Unicast Interface |
| 1371 | """ |
| 1372 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1373 | def runTest( self ): |
| 1374 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1375 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1376 | if len( config[ "port_map" ] ) < 2: |
| 1377 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1378 | return |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 1379 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1380 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1381 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1382 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1383 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1384 | for port in ports: |
| 1385 | # add l2 interface group |
| 1386 | vlan_id = port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1387 | l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id + 1, |
| 1388 | is_tagged=True, send_barrier=False ) |
| 1389 | dst_mac[ 5 ] = vlan_id |
| 1390 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id + 1, id=vlan_id, |
| 1391 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1392 | # add vlan flow table |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1393 | add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1394 | # add termination flow |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1395 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1396 | # add unicast routing flow |
| 1397 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1398 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id ) |
| 1399 | Groups.put( l2gid ) |
| 1400 | Groups.put( l3_msg.group_id ) |
| 1401 | l3_gid = encode_l3_unicast_group_id( ports[ 0 ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1402 | dst_ip = 0x0 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1403 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0x0, l3_gid ) |
| 1404 | do_barrier( self.controller ) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 1405 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1406 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1407 | for in_port in ports: |
| 1408 | mac_src = '00:00:00:22:22:%02X' % (in_port) |
| 1409 | ip_src = '192.168.%02d.1' % (in_port) |
| 1410 | for out_port in ports: |
| 1411 | if in_port == out_port: |
| 1412 | continue |
| 1413 | ip_dst = '192.168.%02d.1' % (out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1414 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port), |
| 1415 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 1416 | pkt = str( parsed_pkt ) |
| 1417 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1418 | # build expected packet |
| 1419 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1420 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(out_port + 1), |
| 1421 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst ) |
| 1422 | pkt = str( exp_pkt ) |
| 1423 | verify_packet( self, pkt, out_port ) |
| 1424 | verify_no_other_packets( self ) |
| 1425 | ip_dst = '1.168.%02d.1' % ports[ 0 ] |
| 1426 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| 1427 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 1428 | pkt = str( parsed_pkt ) |
| 1429 | self.dataplane.send( in_port, pkt ) |
| 1430 | # build expect packet |
| 1431 | mac_dst = '00:00:00:22:22:%02X' % ports[ 0 ] |
| 1432 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ] + 1, |
| 1433 | ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac ) |
| 1434 | pkt = str( exp_pkt ) |
| 1435 | verify_packet( self, pkt, ports[ 0 ] ) |
| 1436 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1437 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1438 | delete_all_flows( self.controller ) |
| 1439 | delete_groups( self.controller, Groups ) |
| 1440 | delete_all_groups( self.controller ) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 1441 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1442 | |
| 1443 | class Unfiltered( base_tests.SimpleDataPlane ): |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1444 | """ |
| 1445 | Testing addition of unfiltered groups |
| 1446 | """ |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 1447 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1448 | def runTest( self ): |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1449 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1450 | ports = sorted( config[ "port_map" ].keys( ) ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1451 | vlan_id = 1; |
| 1452 | for port in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1453 | add_l2_unfiltered_group( self.controller, [ port ], False ) |
| 1454 | do_barrier( self.controller ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1455 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1456 | delete_all_flows( self.controller ) |
| 1457 | delete_all_groups( self.controller ) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 1458 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1459 | |
| 1460 | class L3McastToVPN( base_tests.SimpleDataPlane ): |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1461 | """ |
| 1462 | Mcast routing |
| 1463 | """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1464 | |
| 1465 | def runTest( self ): |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1466 | """ |
| 1467 | port1 (vlan 1)-> port 2 (vlan 2) |
| 1468 | """ |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1469 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1470 | delete_all_flows( self.controller ) |
| 1471 | delete_all_groups( self.controller ) |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1472 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1473 | if len( config[ "port_map" ] ) < 3: |
| 1474 | logging.info( "Port count less than 3, can't run this case" ) |
| 1475 | assert (False) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1476 | return |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1477 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1478 | vlan_id = 1 |
| 1479 | port2_out_vlan = 2 |
| 1480 | port3_out_vlan = 3 |
| 1481 | in_vlan = 1 # macast group vid shall use input vlan diffe from l3 interface use output vlan |
| 1482 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1483 | intf_src_mac_str = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| 1484 | dst_mac = [ 0x01, 0x00, 0x5e, 0x01, 0x01, 0x01 ] |
| 1485 | dst_mac_str = ':'.join( [ '%02X' % x for x in dst_mac ] ) |
| 1486 | port1_mac = [ 0x00, 0x11, 0x11, 0x11, 0x11, 0x11 ] |
| 1487 | port1_mac_str = ':'.join( [ '%02X' % x for x in port1_mac ] ) |
| 1488 | src_ip = 0xc0a80101 |
| 1489 | src_ip_str = "192.168.1.1" |
| 1490 | dst_ip = 0xe0010101 |
| 1491 | dst_ip_str = "224.1.1.1" |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1492 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1493 | port1 = config[ "port_map" ].keys( )[ 0 ] |
| 1494 | port2 = config[ "port_map" ].keys( )[ 1 ] |
| 1495 | # port3=config["port_map"].keys()[2] |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1496 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1497 | # add l2 interface group |
| 1498 | for port in config[ "port_map" ].keys( ): |
| 1499 | add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, is_tagged=False, |
| 1500 | send_barrier=False ) |
| 1501 | # add vlan flow table |
| 1502 | add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 1503 | vlan_id += 1 |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1504 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1505 | # add termination flow |
| 1506 | add_termination_flow( self.controller, port1, 0x0800, [ 0x01, 0x00, 0x5e, 0x00, 0x00, 0x00 ], |
| 1507 | vlan_id ) |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1508 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1509 | # add MPLS interface group |
| 1510 | l2_gid = encode_l2_interface_group_id( port2_out_vlan, port2 ) |
| 1511 | mpls_gid2, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| 1512 | port2_out_vlan, port2 ) |
| 1513 | # l2_gid3 = encode_l2_interface_group_id(port3_out_vlan, port3) |
| 1514 | # mpls_gid3, mpls_msg = add_mpls_intf_group(self.controller, l2_gid3, dst_mac, intf_src_mac, port3_out_vlan, port3) |
| 1515 | # add L3VPN groups |
| 1516 | mpls_label_gid2, mpls_label_msg = add_mpls_label_group( self.controller, |
| 1517 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=(0x20000 + port2), ref_gid=mpls_gid2, |
| 1518 | push_mpls_header=True, set_mpls_label=port2, set_bos=1, cpy_ttl_outward=True ) |
| 1519 | # mpls_label_gid3, mpls_label_msg = add_mpls_label_group(self.controller, subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1520 | # index=(0x10000+port3), ref_gid= mpls_gid3, push_mpls_header=True, set_mpls_label=port3, set_bos=1, cpy_ttl_outward=True) |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1521 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1522 | mcat_group_msg = add_l3_mcast_group( self.controller, in_vlan, 2, [ mpls_label_gid2 ] ) |
| 1523 | add_mcast4_routing_flow( self.controller, in_vlan, src_ip, 0, dst_ip, mcat_group_msg.group_id ) |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1524 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1525 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=1, eth_dst=dst_mac_str, |
| 1526 | eth_src=port1_mac_str, ip_ttl=64, ip_src=src_ip_str, ip_dst=dst_ip_str ) |
| 1527 | pkt = str( parsed_pkt ) |
| 1528 | self.dataplane.send( port1, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1529 | label = (12, 0, 1, 63) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1530 | exp_pkt = mpls_packet( pktlen=100, eth_dst=dst_mac_str, eth_src=intf_src_mac_str, ip_ttl=64, |
| 1531 | ip_src=src_ip_str, label=[ label ], ip_dst=dst_ip_str ) |
| 1532 | pkt = str( exp_pkt ) |
| 1533 | verify_packet( self, pkt, port2 ) |
| 1534 | # verify_packet(self, pkt, port3) |
| 1535 | verify_no_other_packets( self ) |
| 1536 | delete_all_groups( self.controller ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1537 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1538 | delete_all_flows( self.controller ) |
| 1539 | delete_all_groups( self.controller ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1540 | |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1541 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1542 | class PacketInSrcMacMiss( base_tests.SimpleDataPlane ): |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1543 | """ |
| 1544 | Test packet in function on a src-mac miss |
| 1545 | Send a packet to each dataplane port and verify that a packet |
| 1546 | in message is received from the controller for each |
| 1547 | #todo verify you stop receiving after adding rule |
| 1548 | """ |
| 1549 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1550 | def runTest( self ): |
| 1551 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1552 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1553 | ports = sorted( config[ "port_map" ].keys( ) ) |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1554 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1555 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1556 | for port in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1557 | L2gid, l2msg = add_one_l2_interface_group( self.controller, port, 1, True, False ) |
| 1558 | add_one_vlan_table_flow( self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 1559 | Groups.put( L2gid ) |
| 1560 | parsed_vlan_pkt = simple_tcp_packet( pktlen=104, vlan_vid=0x1001, dl_vlan_enable=True ) |
| 1561 | vlan_pkt = str( parsed_vlan_pkt ) |
| 1562 | for of_port in config[ "port_map" ].keys( ): |
| 1563 | logging.info( "PacketInMiss test, port %d", of_port ) |
| 1564 | self.dataplane.send( of_port, vlan_pkt ) |
| 1565 | verify_packet_in( self, vlan_pkt, of_port, ofp.OFPR_NO_MATCH ) |
| 1566 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1567 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1568 | delete_all_flows( self.controller ) |
| 1569 | delete_all_groups( self.controller ) |
| 1570 | |
| 1571 | |
| 1572 | class EcmpGroupMod( base_tests.SimpleDataPlane ): |
| 1573 | """ |
| 1574 | Insert IP packet |
| 1575 | Receive IP packet |
| 1576 | """ |
| 1577 | |
| 1578 | def runTest( self ): |
| 1579 | Groups = Queue.LifoQueue( ) |
| 1580 | try: |
| 1581 | if len( config[ "port_map" ] ) < 2: |
| 1582 | logging.info( "Port count less than 2, can't run this case" ) |
| 1583 | return |
| 1584 | |
| 1585 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1586 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 1587 | dip = 0xc0a80001 |
| 1588 | # Hashes Test Name and uses it as id for installing unique groups |
| 1589 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 1590 | ecmp = [ ] |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1591 | for port in ports: |
| 1592 | vlan_id = port |
| 1593 | id = port |
| 1594 | # add l2 interface group |
| 1595 | l2_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, |
| 1596 | is_tagged=True, send_barrier=False ) |
| 1597 | dst_mac[ 5 ] = vlan_id |
| 1598 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id, |
| 1599 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 1600 | ecmp += [ l3_msg.group_id ] |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1601 | Groups._put( l2_gid ) |
| 1602 | Groups._put( l3_msg.group_id ) |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 1603 | ecmp_msg = add_l3_ecmp_group( self.controller, ports[ 0 ], [ l3_msg.group_id ] ) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1604 | # add vlan flow table |
| 1605 | add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 1606 | # add termination flow |
| 1607 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
| 1608 | # add unicast routing flow |
| 1609 | dst_ip = dip + (vlan_id << 8) |
| 1610 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id ) |
| 1611 | Groups._put( ecmp_msg.group_id ) |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 1612 | mod_l3_ecmp_group( self.controller, ports[ 0 ], ecmp ) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1613 | |
| 1614 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 1615 | parsed_pkt = exp_pkt = 0 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1616 | for out_port in ports: |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 1617 | mac_src = '00:00:00:22:22:%02X' % ports[ 0 ] |
| 1618 | ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1) |
| 1619 | ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1) |
| 1620 | tcp = out_port if out_port == 24 else 25 |
| 1621 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ], |
| 1622 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst, |
| 1623 | tcp_dport=tcp ) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1624 | pkt = str( parsed_pkt ) |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 1625 | self.dataplane.send( ports[ 0 ], pkt ) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1626 | # build expected packet |
| 1627 | mac_dst = '00:00:00:22:22:%02X' % out_port |
| 1628 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 1629 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst, |
| 1630 | tcp_dport=tcp ) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1631 | pkt = str( exp_pkt ) |
| 1632 | verify_packet( self, pkt, out_port ) |
| 1633 | verify_no_other_packets( self ) |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 1634 | l3_gid = encode_l3_unicast_group_id( ports[ 0 ] ) |
| 1635 | mod_l3_ecmp_group( self.controller, ports[ 0 ], [ l3_gid ] ) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1636 | for port in ports: |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 1637 | mac_src = '00:00:00:22:22:%02X' % ports[ 0 ] |
| 1638 | ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1) |
| 1639 | ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1) |
| 1640 | tcp = port if port == 24 else 25 |
| 1641 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ], |
| 1642 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst, |
| 1643 | tcp_dport=tcp ) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1644 | pkt = str( parsed_pkt ) |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 1645 | self.dataplane.send( ports[ 0 ], pkt ) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1646 | # build expected packet |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 1647 | mac_dst = '00:00:00:22:22:%02X' % ports[ 0 ] |
| 1648 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ], |
| 1649 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst, |
| 1650 | tcp_dport=tcp ) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1651 | pkt = str( exp_pkt ) |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 1652 | verify_packet( self, pkt, ports[ 0 ] ) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1653 | verify_no_other_packets( self ) |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 1654 | mod_l3_ecmp_group( self.controller, ports[ 0 ], [ ] ) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1655 | for port in ports: |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 1656 | mac_src = '00:00:00:22:22:%02X' % ports[ 0 ] |
| 1657 | ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1) |
| 1658 | ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1) |
| 1659 | tcp = port if port == 24 else 25 |
| 1660 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ], |
| 1661 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst, |
| 1662 | tcp_dport=tcp ) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1663 | pkt = str( parsed_pkt ) |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 1664 | self.dataplane.send( ports[ 0 ], pkt ) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1665 | verify_no_other_packets( self ) |
| 1666 | finally: |
| 1667 | delete_all_flows( self.controller ) |
| 1668 | delete_groups( self.controller, Groups ) |
| 1669 | delete_all_groups( self.controller ) |