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 | |
| 1105 | |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1106 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1107 | class _MplsFwd( base_tests.SimpleDataPlane ): |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 1108 | """ |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1109 | Insert MPLS packet |
Flavio Castro | 5494794 | 2016-02-03 16:05:20 -0500 | [diff] [blame] | 1110 | Receive MPLS packet |
castroflavio | 30c6cc5 | 2016-01-07 15:19:42 -0800 | [diff] [blame] | 1111 | """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1112 | |
| 1113 | def runTest( self ): |
| 1114 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1115 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1116 | if len( config[ "port_map" ] ) < 2: |
| 1117 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1118 | return |
| 1119 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1120 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1121 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1122 | # 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^] | 1123 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1124 | for port in ports: |
| 1125 | # add l2 interface group |
| 1126 | id = port |
| 1127 | vlan_id = id |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1128 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False ) |
| 1129 | dst_mac[ 5 ] = vlan_id |
| 1130 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| 1131 | vlan_id, id ) |
| 1132 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| 1133 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_SWAP_LABEL, index=id, ref_gid=mpls_gid, |
| 1134 | push_mpls_header=False, set_mpls_label=port, set_bos=1 ) |
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 ) |
| 1139 | add_mpls_flow( self.controller, mpls_label_gid, port, goto_table=29 ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1140 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1141 | Groups._put( l2_gid ) |
| 1142 | Groups._put( mpls_gid ) |
| 1143 | Groups._put( mpls_label_gid ) |
| 1144 | do_barrier( self.controller ) |
castroflavio | 30c6cc5 | 2016-01-07 15:19:42 -0800 | [diff] [blame] | 1145 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1146 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1147 | for in_port in ports: |
| 1148 | ip_src = '192.168.%02d.1' % (in_port) |
| 1149 | for out_port in ports: |
| 1150 | if in_port == out_port: |
| 1151 | continue |
| 1152 | ip_dst = '192.168.%02d.1' % (out_port) |
Flavio Castro | 5494794 | 2016-02-03 16:05:20 -0500 | [diff] [blame] | 1153 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1154 | label = (out_port, 0, 1, 32) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1155 | parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(in_port), |
| 1156 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] ) |
| 1157 | pkt = str( parsed_pkt ) |
| 1158 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 5494794 | 2016-02-03 16:05:20 -0500 | [diff] [blame] | 1159 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1160 | # build expect packet |
| 1161 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
| 1162 | label = (out_port, 0, 1, 31) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1163 | exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), |
| 1164 | ip_src=ip_src, ip_dst=ip_dst, eth_src=switch_mac, eth_dst=mac_dst, |
| 1165 | label=[ label ] ) |
| 1166 | pkt = str( exp_pkt ) |
| 1167 | verify_packet( self, pkt, out_port ) |
| 1168 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1169 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1170 | delete_all_flows( self.controller ) |
| 1171 | delete_groups( self.controller, Groups ) |
| 1172 | delete_all_groups( self.controller ) |
Flavio Castro | b702a2f | 2016-04-10 22:01:48 -0400 | [diff] [blame] | 1173 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1174 | |
| 1175 | class _MplsTermination( base_tests.SimpleDataPlane ): |
Flavio Castro | b702a2f | 2016-04-10 22:01:48 -0400 | [diff] [blame] | 1176 | """ |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1177 | Insert MPLS packet |
| 1178 | Receive IP packet |
Flavio Castro | b702a2f | 2016-04-10 22:01:48 -0400 | [diff] [blame] | 1179 | """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1180 | |
| 1181 | def runTest( self ): |
| 1182 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1183 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1184 | if len( config[ "port_map" ] ) < 2: |
| 1185 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1186 | return |
| 1187 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1188 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1189 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1190 | # 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^] | 1191 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1192 | for port in ports: |
| 1193 | # add l2 interface group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1194 | vlan_id, id, dst_mac[ 5 ] = port, port, port |
| 1195 | 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] | 1196 | # add L3 Unicast group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1197 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id, |
| 1198 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1199 | # add L3 ecmp group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1200 | 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] | 1201 | # add vlan flow table |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1202 | 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] | 1203 | # add termination flow |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1204 | add_termination_flow( self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24 ) |
| 1205 | # add_mpls_flow(self.controller, ecmp_msg.group_id, port) |
| 1206 | add_mpls_flow( self.controller, label=port ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1207 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1208 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id, 1 ) |
| 1209 | Groups._put( l2_gid ) |
| 1210 | Groups._put( l3_msg.group_id ) |
| 1211 | Groups._put( ecmp_msg.group_id ) |
| 1212 | do_barrier( self.controller ) |
Flavio Castro | b702a2f | 2016-04-10 22:01:48 -0400 | [diff] [blame] | 1213 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1214 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1215 | for in_port in ports: |
| 1216 | ip_src = '192.168.%02d.1' % (in_port) |
| 1217 | for out_port in ports: |
| 1218 | if in_port == out_port: |
| 1219 | continue |
| 1220 | ip_dst = '192.168.%02d.1' % (out_port) |
| 1221 | label = (out_port, 0, 1, 32) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1222 | parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(in_port), |
| 1223 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] ) |
| 1224 | pkt = str( parsed_pkt ) |
| 1225 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1226 | # build expect packet |
| 1227 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1228 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(out_port), |
| 1229 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst ) |
| 1230 | pkt = str( exp_pkt ) |
| 1231 | verify_packet( self, pkt, out_port ) |
| 1232 | verify_no_other_packets( self ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1233 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1234 | delete_all_flows( self.controller ) |
| 1235 | delete_groups( self.controller, Groups ) |
| 1236 | delete_all_groups( self.controller ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1237 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1238 | |
| 1239 | class _MplsVpnFwd( base_tests.SimpleDataPlane ): |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1240 | """ |
| 1241 | Insert MPLS packet |
| 1242 | Receive IP packet |
| 1243 | """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1244 | |
| 1245 | def runTest( self ): |
| 1246 | Groups = Queue.LifoQueue( ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1247 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1248 | if len( config[ "port_map" ] ) < 2: |
| 1249 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1250 | return |
| 1251 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1252 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1253 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1254 | # 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^] | 1255 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1256 | for port in ports: |
| 1257 | # add l2 interface group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1258 | vlan_id, id, dst_mac[ 5 ] = port, port, port |
| 1259 | 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] | 1260 | # add L3 Unicast group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1261 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id, |
| 1262 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1263 | # add L3 ecmp group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1264 | 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] | 1265 | # add vlan flow table |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1266 | 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] | 1267 | # add termination flow |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1268 | add_termination_flow( self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24 ) |
| 1269 | add_mpls_flow( self.controller, ecmp_msg.group_id, port ) |
| 1270 | # add_mpls_flow(self.controller, label=port) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1271 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1272 | # add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffff00, |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1273 | # ecmp_msg.group_id, 1) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1274 | Groups._put( l2_gid ) |
| 1275 | Groups._put( l3_msg.group_id ) |
| 1276 | Groups._put( ecmp_msg.group_id ) |
| 1277 | do_barrier( self.controller ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1278 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1279 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1280 | for in_port in ports: |
| 1281 | ip_src = '192.168.%02d.1' % (in_port) |
| 1282 | for out_port in ports: |
| 1283 | if in_port == out_port: |
| 1284 | continue |
| 1285 | ip_dst = '192.168.%02d.1' % (out_port) |
| 1286 | label = (out_port, 0, 1, 32) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1287 | parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(in_port), |
| 1288 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] ) |
| 1289 | pkt = str( parsed_pkt ) |
| 1290 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1291 | # build expect packet |
| 1292 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1293 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(out_port), |
| 1294 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst ) |
| 1295 | pkt = str( exp_pkt ) |
| 1296 | verify_packet( self, pkt, out_port ) |
| 1297 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1298 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1299 | delete_all_flows( self.controller ) |
| 1300 | delete_groups( self.controller, Groups ) |
| 1301 | delete_all_groups( self.controller ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1302 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1303 | |
| 1304 | class _24UcastTagged( base_tests.SimpleDataPlane ): |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1305 | """ |
| 1306 | Verify a IP forwarding works for a /32 rule to L3 Unicast Interface |
| 1307 | """ |
| 1308 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1309 | def runTest( self ): |
| 1310 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1311 | try: |
| 1312 | test_id = 26 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1313 | if len( config[ "port_map" ] ) < 2: |
| 1314 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1315 | return |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1316 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1317 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1318 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1319 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1320 | for port in ports: |
| 1321 | # add l2 interface group |
| 1322 | vlan_id = port + test_id |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1323 | l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, |
| 1324 | is_tagged=True, send_barrier=False ) |
| 1325 | dst_mac[ 5 ] = vlan_id |
| 1326 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id, |
| 1327 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1328 | # add vlan flow table |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1329 | 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] | 1330 | # add termination flow |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1331 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1332 | # add unicast routing flow |
| 1333 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1334 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, l3_msg.group_id ) |
| 1335 | Groups.put( l2gid ) |
| 1336 | Groups.put( l3_msg.group_id ) |
| 1337 | do_barrier( self.controller ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1338 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1339 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1340 | for in_port in ports: |
| 1341 | mac_src = '00:00:00:22:22:%02X' % (test_id + in_port) |
| 1342 | ip_src = '192.168.%02d.1' % (test_id + in_port) |
| 1343 | for out_port in ports: |
| 1344 | if in_port == out_port: |
| 1345 | continue |
| 1346 | ip_dst = '192.168.%02d.1' % (test_id + out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1347 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, |
| 1348 | vlan_vid=(test_id + in_port), eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, |
| 1349 | ip_src=ip_src, ip_dst=ip_dst ) |
| 1350 | pkt = str( parsed_pkt ) |
| 1351 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1352 | # build expected packet |
| 1353 | mac_dst = '00:00:00:22:22:%02X' % (test_id + out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1354 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, |
| 1355 | vlan_vid=(test_id + out_port), eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, |
| 1356 | ip_src=ip_src, ip_dst=ip_dst ) |
| 1357 | pkt = str( exp_pkt ) |
| 1358 | verify_packet( self, pkt, out_port ) |
| 1359 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1360 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1361 | delete_all_flows( self.controller ) |
| 1362 | delete_groups( self.controller, Groups ) |
| 1363 | delete_all_groups( self.controller ) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 1364 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1365 | |
| 1366 | class _0Ucast( base_tests.SimpleDataPlane ): |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 1367 | """ |
| 1368 | Verify a IP forwarding works for a /0 rule to L3 Unicast Interface |
| 1369 | """ |
| 1370 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1371 | def runTest( self ): |
| 1372 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1373 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1374 | if len( config[ "port_map" ] ) < 2: |
| 1375 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1376 | return |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 1377 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1378 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1379 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1380 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1381 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1382 | for port in ports: |
| 1383 | # add l2 interface group |
| 1384 | vlan_id = port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1385 | l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id + 1, |
| 1386 | is_tagged=True, send_barrier=False ) |
| 1387 | dst_mac[ 5 ] = vlan_id |
| 1388 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id + 1, id=vlan_id, |
| 1389 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1390 | # add vlan flow table |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1391 | 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] | 1392 | # add termination flow |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1393 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1394 | # add unicast routing flow |
| 1395 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1396 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id ) |
| 1397 | Groups.put( l2gid ) |
| 1398 | Groups.put( l3_msg.group_id ) |
| 1399 | l3_gid = encode_l3_unicast_group_id( ports[ 0 ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1400 | dst_ip = 0x0 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1401 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0x0, l3_gid ) |
| 1402 | do_barrier( self.controller ) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 1403 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1404 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1405 | for in_port in ports: |
| 1406 | mac_src = '00:00:00:22:22:%02X' % (in_port) |
| 1407 | ip_src = '192.168.%02d.1' % (in_port) |
| 1408 | for out_port in ports: |
| 1409 | if in_port == out_port: |
| 1410 | continue |
| 1411 | ip_dst = '192.168.%02d.1' % (out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1412 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port), |
| 1413 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 1414 | pkt = str( parsed_pkt ) |
| 1415 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1416 | # build expected packet |
| 1417 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1418 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(out_port + 1), |
| 1419 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst ) |
| 1420 | pkt = str( exp_pkt ) |
| 1421 | verify_packet( self, pkt, out_port ) |
| 1422 | verify_no_other_packets( self ) |
| 1423 | ip_dst = '1.168.%02d.1' % ports[ 0 ] |
| 1424 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| 1425 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 1426 | pkt = str( parsed_pkt ) |
| 1427 | self.dataplane.send( in_port, pkt ) |
| 1428 | # build expect packet |
| 1429 | mac_dst = '00:00:00:22:22:%02X' % ports[ 0 ] |
| 1430 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ] + 1, |
| 1431 | ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac ) |
| 1432 | pkt = str( exp_pkt ) |
| 1433 | verify_packet( self, pkt, ports[ 0 ] ) |
| 1434 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1435 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1436 | delete_all_flows( self.controller ) |
| 1437 | delete_groups( self.controller, Groups ) |
| 1438 | delete_all_groups( self.controller ) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 1439 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1440 | |
| 1441 | class Unfiltered( base_tests.SimpleDataPlane ): |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1442 | """ |
| 1443 | Testing addition of unfiltered groups |
| 1444 | """ |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 1445 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1446 | def runTest( self ): |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1447 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1448 | ports = sorted( config[ "port_map" ].keys( ) ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1449 | vlan_id = 1; |
| 1450 | for port in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1451 | add_l2_unfiltered_group( self.controller, [ port ], False ) |
| 1452 | do_barrier( self.controller ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1453 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1454 | delete_all_flows( self.controller ) |
| 1455 | delete_all_groups( self.controller ) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 1456 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1457 | |
| 1458 | class L3McastToVPN( base_tests.SimpleDataPlane ): |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1459 | """ |
| 1460 | Mcast routing |
| 1461 | """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1462 | |
| 1463 | def runTest( self ): |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1464 | """ |
| 1465 | port1 (vlan 1)-> port 2 (vlan 2) |
| 1466 | """ |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1467 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1468 | delete_all_flows( self.controller ) |
| 1469 | delete_all_groups( self.controller ) |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1470 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1471 | if len( config[ "port_map" ] ) < 3: |
| 1472 | logging.info( "Port count less than 3, can't run this case" ) |
| 1473 | assert (False) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1474 | return |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1475 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1476 | vlan_id = 1 |
| 1477 | port2_out_vlan = 2 |
| 1478 | port3_out_vlan = 3 |
| 1479 | in_vlan = 1 # macast group vid shall use input vlan diffe from l3 interface use output vlan |
| 1480 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1481 | intf_src_mac_str = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| 1482 | dst_mac = [ 0x01, 0x00, 0x5e, 0x01, 0x01, 0x01 ] |
| 1483 | dst_mac_str = ':'.join( [ '%02X' % x for x in dst_mac ] ) |
| 1484 | port1_mac = [ 0x00, 0x11, 0x11, 0x11, 0x11, 0x11 ] |
| 1485 | port1_mac_str = ':'.join( [ '%02X' % x for x in port1_mac ] ) |
| 1486 | src_ip = 0xc0a80101 |
| 1487 | src_ip_str = "192.168.1.1" |
| 1488 | dst_ip = 0xe0010101 |
| 1489 | dst_ip_str = "224.1.1.1" |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1490 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1491 | port1 = config[ "port_map" ].keys( )[ 0 ] |
| 1492 | port2 = config[ "port_map" ].keys( )[ 1 ] |
| 1493 | # port3=config["port_map"].keys()[2] |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1494 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1495 | # add l2 interface group |
| 1496 | for port in config[ "port_map" ].keys( ): |
| 1497 | add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, is_tagged=False, |
| 1498 | send_barrier=False ) |
| 1499 | # add vlan flow table |
| 1500 | add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 1501 | vlan_id += 1 |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1502 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1503 | # add termination flow |
| 1504 | add_termination_flow( self.controller, port1, 0x0800, [ 0x01, 0x00, 0x5e, 0x00, 0x00, 0x00 ], |
| 1505 | vlan_id ) |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1506 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1507 | # add MPLS interface group |
| 1508 | l2_gid = encode_l2_interface_group_id( port2_out_vlan, port2 ) |
| 1509 | mpls_gid2, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| 1510 | port2_out_vlan, port2 ) |
| 1511 | # l2_gid3 = encode_l2_interface_group_id(port3_out_vlan, port3) |
| 1512 | # mpls_gid3, mpls_msg = add_mpls_intf_group(self.controller, l2_gid3, dst_mac, intf_src_mac, port3_out_vlan, port3) |
| 1513 | # add L3VPN groups |
| 1514 | mpls_label_gid2, mpls_label_msg = add_mpls_label_group( self.controller, |
| 1515 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=(0x20000 + port2), ref_gid=mpls_gid2, |
| 1516 | push_mpls_header=True, set_mpls_label=port2, set_bos=1, cpy_ttl_outward=True ) |
| 1517 | # 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] | 1518 | # 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] | 1519 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1520 | mcat_group_msg = add_l3_mcast_group( self.controller, in_vlan, 2, [ mpls_label_gid2 ] ) |
| 1521 | 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] | 1522 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1523 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=1, eth_dst=dst_mac_str, |
| 1524 | eth_src=port1_mac_str, ip_ttl=64, ip_src=src_ip_str, ip_dst=dst_ip_str ) |
| 1525 | pkt = str( parsed_pkt ) |
| 1526 | self.dataplane.send( port1, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1527 | label = (12, 0, 1, 63) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1528 | exp_pkt = mpls_packet( pktlen=100, eth_dst=dst_mac_str, eth_src=intf_src_mac_str, ip_ttl=64, |
| 1529 | ip_src=src_ip_str, label=[ label ], ip_dst=dst_ip_str ) |
| 1530 | pkt = str( exp_pkt ) |
| 1531 | verify_packet( self, pkt, port2 ) |
| 1532 | # verify_packet(self, pkt, port3) |
| 1533 | verify_no_other_packets( self ) |
| 1534 | delete_all_groups( self.controller ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1535 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1536 | delete_all_flows( self.controller ) |
| 1537 | delete_all_groups( self.controller ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1538 | |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1539 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1540 | class PacketInSrcMacMiss( base_tests.SimpleDataPlane ): |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1541 | """ |
| 1542 | Test packet in function on a src-mac miss |
| 1543 | Send a packet to each dataplane port and verify that a packet |
| 1544 | in message is received from the controller for each |
| 1545 | #todo verify you stop receiving after adding rule |
| 1546 | """ |
| 1547 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1548 | def runTest( self ): |
| 1549 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1550 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1551 | ports = sorted( config[ "port_map" ].keys( ) ) |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1552 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1553 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1554 | for port in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1555 | L2gid, l2msg = add_one_l2_interface_group( self.controller, port, 1, True, False ) |
| 1556 | add_one_vlan_table_flow( self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 1557 | Groups.put( L2gid ) |
| 1558 | parsed_vlan_pkt = simple_tcp_packet( pktlen=104, vlan_vid=0x1001, dl_vlan_enable=True ) |
| 1559 | vlan_pkt = str( parsed_vlan_pkt ) |
| 1560 | for of_port in config[ "port_map" ].keys( ): |
| 1561 | logging.info( "PacketInMiss test, port %d", of_port ) |
| 1562 | self.dataplane.send( of_port, vlan_pkt ) |
| 1563 | verify_packet_in( self, vlan_pkt, of_port, ofp.OFPR_NO_MATCH ) |
| 1564 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1565 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame^] | 1566 | delete_all_flows( self.controller ) |
| 1567 | delete_all_groups( self.controller ) |
| 1568 | |
| 1569 | |
| 1570 | class EcmpGroupMod( base_tests.SimpleDataPlane ): |
| 1571 | """ |
| 1572 | Insert IP packet |
| 1573 | Receive IP packet |
| 1574 | """ |
| 1575 | |
| 1576 | def runTest( self ): |
| 1577 | Groups = Queue.LifoQueue( ) |
| 1578 | try: |
| 1579 | if len( config[ "port_map" ] ) < 2: |
| 1580 | logging.info( "Port count less than 2, can't run this case" ) |
| 1581 | return |
| 1582 | |
| 1583 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1584 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 1585 | dip = 0xc0a80001 |
| 1586 | # Hashes Test Name and uses it as id for installing unique groups |
| 1587 | ports = config[ "port_map" ].keys( ) |
| 1588 | ecmp=[] |
| 1589 | for port in ports: |
| 1590 | vlan_id = port |
| 1591 | id = port |
| 1592 | # add l2 interface group |
| 1593 | l2_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, |
| 1594 | is_tagged=True, send_barrier=False ) |
| 1595 | dst_mac[ 5 ] = vlan_id |
| 1596 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id, |
| 1597 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
| 1598 | ecmp +=[l3_msg.group_id] |
| 1599 | Groups._put( l2_gid ) |
| 1600 | Groups._put( l3_msg.group_id ) |
| 1601 | ecmp_msg = add_l3_ecmp_group( self.controller, ports[0], [l3_msg.group_id]) |
| 1602 | #ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] ) |
| 1603 | # add vlan flow table |
| 1604 | add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 1605 | # add termination flow |
| 1606 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
| 1607 | # add unicast routing flow |
| 1608 | dst_ip = dip + (vlan_id << 8) |
| 1609 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id ) |
| 1610 | Groups._put( ecmp_msg.group_id ) |
| 1611 | mod_l3_ecmp_group( self.controller, ports[0], ecmp) |
| 1612 | |
| 1613 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| 1614 | parsed_pkt=exp_pkt=0 |
| 1615 | for out_port in ports: |
| 1616 | mac_src = '00:00:00:22:22:%02X' % ports[0] |
| 1617 | ip_src = '192.168.%02d.%02d' % (ports[0], 1) |
| 1618 | ip_dst = '192.168.%02d.%02d' % ( ports[1], 1) |
| 1619 | tcp= out_port if out_port==24 else 25 |
| 1620 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[0], |
| 1621 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst, |
| 1622 | tcp_dport=tcp) |
| 1623 | pkt = str( parsed_pkt ) |
| 1624 | self.dataplane.send( ports[0], pkt ) |
| 1625 | # build expected packet |
| 1626 | mac_dst = '00:00:00:22:22:%02X' % out_port |
| 1627 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| 1628 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst, tcp_dport=tcp ) |
| 1629 | pkt = str( exp_pkt ) |
| 1630 | verify_packet( self, pkt, out_port ) |
| 1631 | verify_no_other_packets( self ) |
| 1632 | l3_gid = encode_l3_unicast_group_id(ports[0]) |
| 1633 | mod_l3_ecmp_group( self.controller, ports[0], [l3_gid]) |
| 1634 | for port in ports: |
| 1635 | mac_src = '00:00:00:22:22:%02X' % ports[0] |
| 1636 | ip_src = '192.168.%02d.%02d' % ( ports[0], 1 ) |
| 1637 | ip_dst = '192.168.%02d.%02d' % ( ports[1], 1 ) |
| 1638 | tcp= port if port==24 else 25 |
| 1639 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[0], |
| 1640 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst, |
| 1641 | tcp_dport=tcp) |
| 1642 | pkt = str( parsed_pkt ) |
| 1643 | self.dataplane.send( ports[0], pkt ) |
| 1644 | # build expected packet |
| 1645 | mac_dst = '00:00:00:22:22:%02X' % ports[0] |
| 1646 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[0], |
| 1647 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst, tcp_dport=tcp ) |
| 1648 | pkt = str( exp_pkt ) |
| 1649 | verify_packet( self, pkt, ports[0] ) |
| 1650 | verify_no_other_packets( self ) |
| 1651 | mod_l3_ecmp_group( self.controller, ports[0], [] ) |
| 1652 | for port in ports: |
| 1653 | mac_src = '00:00:00:22:22:%02X' % ports[0] |
| 1654 | ip_src = '192.168.%02d.%02d' % ( ports[0], 1 ) |
| 1655 | ip_dst = '192.168.%02d.%02d' % ( ports[1], 1 ) |
| 1656 | tcp= port if port==24 else 25 |
| 1657 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[0], |
| 1658 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst, |
| 1659 | tcp_dport=tcp) |
| 1660 | pkt = str( parsed_pkt ) |
| 1661 | self.dataplane.send( ports[0], pkt ) |
| 1662 | verify_no_other_packets( self ) |
| 1663 | finally: |
| 1664 | delete_all_flows( self.controller ) |
| 1665 | delete_groups( self.controller, Groups ) |
| 1666 | delete_all_groups( self.controller ) |
| 1667 | |