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 |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame^] | 11 | import time |
Flavio Castro | 05d20bc | 2015-11-16 15:06:14 -0500 | [diff] [blame] | 12 | from oftest.testutils import * |
| 13 | from accton_util import * |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 14 | from utils import * |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 15 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 16 | class PacketInUDP( base_tests.SimpleDataPlane ): |
Flavio Castro | 6d49852 | 2015-12-15 14:05:04 -0500 | [diff] [blame] | 17 | """ |
Flavio Castro | 76c5b26 | 2016-07-27 19:53:00 -0700 | [diff] [blame] | 18 | Verify ACL rule for IP_PROTO=2 wont match a UDP packet and a rule for 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 ): |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame^] | 69 | """ |
| 70 | Needs a description, disabled for now. Also needs try/finally |
| 71 | """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 72 | def runTest( self ): |
| 73 | delete_all_flows( self.controller ) |
| 74 | delete_all_groups( self.controller ) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 75 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 76 | ports = sorted( config[ "port_map" ].keys( ) ) |
| 77 | match = ofp.match( ) |
| 78 | match.oxm_list.append( ofp.oxm.eth_type( 0x0806 ) ) |
| 79 | request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[ |
| 80 | ofp.instruction.apply_actions( actions=[ |
| 81 | ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ), ], |
| 82 | buffer_id=ofp.OFP_NO_BUFFER, priority=40000 ) |
| 83 | self.controller.message_send( request ) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 84 | for port in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 85 | add_one_l2_interface_group( self.controller, port, 1, False, False ) |
| 86 | add_one_vlan_table_flow( self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_BOTH ) |
| 87 | group_id = encode_l2_interface_group_id( 1, port ) |
| 88 | add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, port ], 1, group_id, True ) |
| 89 | do_barrier( self.controller ) |
| 90 | parsed_arp_pkt = simple_arp_packet( ) |
| 91 | arp_pkt = str( parsed_arp_pkt ) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 92 | |
| 93 | for out_port in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 94 | self.dataplane.send( out_port, arp_pkt ) |
| 95 | verify_packet_in( self, arp_pkt, out_port, ofp.OFPR_ACTION ) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 96 | # change dest based on port number |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 97 | mac_dst = '00:12:34:56:78:%02X' % out_port |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 98 | for in_port in ports: |
| 99 | if in_port == out_port: |
| 100 | continue |
| 101 | # change source based on port number to avoid packet-ins from learning |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 102 | mac_src = '00:12:34:56:78:%02X' % in_port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 103 | parsed_pkt = simple_tcp_packet( eth_dst=mac_dst, eth_src=mac_src ) |
| 104 | pkt = str( parsed_pkt ) |
| 105 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 106 | |
| 107 | for ofport in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 108 | if ofport in [ out_port ]: |
| 109 | verify_packet( self, pkt, ofport ) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 110 | else: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 111 | verify_no_packet( self, pkt, ofport ) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 112 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 113 | verify_no_other_packets( self ) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 114 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 115 | class PacketInArp( base_tests.SimpleDataPlane ): |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 116 | """ |
Flavio Castro | 76c5b26 | 2016-07-27 19:53:00 -0700 | [diff] [blame] | 117 | Verify Packet-in message from eth_type 0x806 on ACL table |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 118 | """ |
| 119 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 120 | def runTest( self ): |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 121 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 122 | parsed_arp_pkt = simple_arp_packet( ) |
| 123 | arp_pkt = str( parsed_arp_pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 124 | # create match |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 125 | match = ofp.match( ) |
| 126 | match.oxm_list.append( ofp.oxm.eth_type( 0x0806 ) ) |
| 127 | request = ofp.message.flow_add( table_id=60, cookie=42, match=match, instructions=[ |
| 128 | ofp.instruction.apply_actions( actions=[ |
| 129 | ofp.action.output( port=ofp.OFPP_CONTROLLER, max_len=ofp.OFPCML_NO_BUFFER ) ] ), ], |
| 130 | buffer_id=ofp.OFP_NO_BUFFER, priority=1 ) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 131 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame^] | 132 | logging.info( "Inserting arp flow " ) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 133 | self.controller.message_send( request ) |
| 134 | do_barrier( self.controller ) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 135 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 136 | for of_port in config[ "port_map" ].keys( ): |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame^] | 137 | logging.info( "PacketInArp test, sending arp packet to port %d", of_port ) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 138 | self.dataplane.send( of_port, arp_pkt ) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 139 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 140 | verify_packet_in( self, arp_pkt, of_port, ofp.OFPR_ACTION ) |
Flavio Castro | 7fb6ca9 | 2015-12-16 15:50:14 -0500 | [diff] [blame] | 141 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 142 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 143 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 144 | delete_all_flows( self.controller ) |
| 145 | delete_all_groups( self.controller ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 146 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame^] | 147 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 148 | class PacketInIPTable( base_tests.SimpleDataPlane ): |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 149 | """ |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 150 | Verify Packet-in message from IP table when controller action is used |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 151 | Send a packet to each dataplane port and verify that a packet |
| 152 | in message is received from the controller for each |
| 153 | #todo verify you stop receiving after adding rule |
| 154 | """ |
| 155 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 156 | def runTest( self ): |
| 157 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 158 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 159 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 160 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 161 | dip = 0xc0a80001 |
| 162 | ports = sorted( config[ "port_map" ].keys( ) ) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 163 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 164 | for port in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 165 | # add l2 interface group |
| 166 | vlan_id = port |
| 167 | add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, is_tagged=True, |
| 168 | send_barrier=False ) |
| 169 | dst_mac[ 5 ] = vlan_id |
| 170 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id, |
| 171 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
| 172 | # add vlan flow table |
| 173 | add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 174 | # add termination flow |
| 175 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
| 176 | # add unicast routing flow |
| 177 | dst_ip = dip + (vlan_id << 8) |
| 178 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, l3_msg.group_id, |
| 179 | send_ctrl=True ) |
| 180 | Groups.put( l3_msg.group_id ) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 181 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 182 | do_barrier( self.controller ) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 183 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 184 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 185 | for in_port in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 186 | mac_src = '00:00:00:22:22:%02X' % in_port |
| 187 | ip_src = '192.168.%02d.1' % in_port |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 188 | for out_port in ports: |
| 189 | if in_port == out_port: |
| 190 | continue |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 191 | ip_dst = '192.168.%02d.1' % out_port |
| 192 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| 193 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 194 | pkt = str( parsed_pkt ) |
| 195 | self.dataplane.send( in_port, pkt ) |
| 196 | verify_packet_in( self, pkt, in_port, ofp.OFPR_ACTION ) |
| 197 | # verify_no_other_packets(self) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 198 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 199 | delete_all_flows( self.controller ) |
| 200 | delete_groups( self.controller, Groups ) |
| 201 | delete_all_groups( self.controller ) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 202 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 203 | |
| 204 | class L2FloodQinQ( base_tests.SimpleDataPlane ): |
Flavio Castro | 1b5c21d | 2015-12-08 12:41:56 -0500 | [diff] [blame] | 205 | """ |
Flavio Castro | 76c5b26 | 2016-07-27 19:53:00 -0700 | [diff] [blame] | 206 | Verify Vlan based flooding of QinQ based on its outer vlan |
Flavio Castro | 1b5c21d | 2015-12-08 12:41:56 -0500 | [diff] [blame] | 207 | """ |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 208 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 209 | def runTest( self ): |
| 210 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 211 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 212 | ports = sorted( config[ "port_map" ].keys( ) ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 213 | vlan_id = 1 |
Flavio Castro | 1b5c21d | 2015-12-08 12:41:56 -0500 | [diff] [blame] | 214 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 215 | for port in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 216 | L2gid, l2msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False ) |
| 217 | add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 218 | Groups.put( L2gid ) |
Flavio Castro | 1b5c21d | 2015-12-08 12:41:56 -0500 | [diff] [blame] | 219 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 220 | msg = add_l2_flood_group( self.controller, ports, vlan_id, vlan_id ) |
| 221 | Groups.put( msg.group_id ) |
| 222 | add_bridge_flow( self.controller, None, vlan_id, msg.group_id, True ) |
| 223 | do_barrier( self.controller ) |
Flavio Castro | 1b5c21d | 2015-12-08 12:41:56 -0500 | [diff] [blame] | 224 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 225 | # verify flood |
| 226 | for ofport in ports: |
| 227 | # change dest based on port number |
| 228 | mac_src = '00:12:34:56:78:%02X' % ofport |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 229 | parsed_pkt = simple_tcp_packet_two_vlan( pktlen=108, out_dl_vlan_enable=True, |
| 230 | out_vlan_vid=vlan_id, in_dl_vlan_enable=True, in_vlan_vid=10, |
| 231 | eth_dst='00:12:34:56:78:9a', eth_src=mac_src ) |
| 232 | pkt = str( parsed_pkt ) |
| 233 | self.dataplane.send( ofport, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 234 | # self won't rx packet |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 235 | verify_no_packet( self, pkt, ofport ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 236 | # others will rx packet |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 237 | tmp_ports = list( ports ) |
| 238 | tmp_ports.remove( ofport ) |
| 239 | verify_packets( self, pkt, tmp_ports ) |
Flavio Castro | 1b5c21d | 2015-12-08 12:41:56 -0500 | [diff] [blame] | 240 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 241 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 242 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 243 | delete_all_flows( self.controller ) |
| 244 | delete_groups( self.controller, Groups ) |
| 245 | delete_all_groups( self.controller ) |
| 246 | |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 247 | |
Flavio Castro | ce3bfeb | 2016-02-04 14:06:55 -0500 | [diff] [blame] | 248 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 249 | class L2FloodTagged( base_tests.SimpleDataPlane ): |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 250 | """ |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame^] | 251 | currently disabled; fix with try/finally |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 252 | Test L2 flood to a vlan |
| 253 | 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] | 254 | """ |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 255 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 256 | def runTest( self ): |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 257 | # Hashes Test Name and uses it as id for installing unique groups |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 258 | vlan_id = abs( hash( inspect.stack( )[ 0 ][ 3 ] ) ) % (256) |
Flavio Castro | ce3bfeb | 2016-02-04 14:06:55 -0500 | [diff] [blame] | 259 | print vlan_id |
Flavio Castro | aba28ff | 2016-02-03 16:47:48 -0500 | [diff] [blame] | 260 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 261 | ports = sorted( config[ "port_map" ].keys( ) ) |
Flavio Castro | 34352e7 | 2015-12-07 20:01:51 -0500 | [diff] [blame] | 262 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 263 | delete_all_flows( self.controller ) |
| 264 | delete_all_groups( self.controller ) |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 265 | |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 266 | # Installing flows to avoid packet-in |
| 267 | for port in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 268 | add_one_l2_interface_group( self.controller, port, vlan_id, True, False ) |
| 269 | add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 270 | msg = add_l2_flood_group( self.controller, ports, vlan_id, vlan_id ) |
| 271 | add_bridge_flow( self.controller, None, vlan_id, msg.group_id, True ) |
| 272 | do_barrier( self.controller ) |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 273 | |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 274 | # verify flood |
Flavio Castro | 184cefe | 2015-11-19 20:52:49 -0500 | [diff] [blame] | 275 | for ofport in ports: |
| 276 | # change dest based on port number |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 277 | pkt = str( |
| 278 | simple_tcp_packet( dl_vlan_enable=True, vlan_vid=vlan_id, eth_dst='00:12:34:56:78:9a' ) ) |
| 279 | self.dataplane.send( ofport, pkt ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 280 | # self won't rx packet |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 281 | verify_no_packet( self, pkt, ofport ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 282 | # others will rx packet |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 283 | tmp_ports = list( ports ) |
| 284 | tmp_ports.remove( ofport ) |
| 285 | verify_packets( self, pkt, tmp_ports ) |
| 286 | verify_no_other_packets( self ) |
Flavio Castro | aabb579 | 2015-11-18 19:03:50 -0500 | [diff] [blame] | 287 | |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 288 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 289 | class L2UnicastTagged( base_tests.SimpleDataPlane ): |
Flavio Castro | 76c5b26 | 2016-07-27 19:53:00 -0700 | [diff] [blame] | 290 | """ Verify Bridging works: match(VID, DST_MAC)> fwd(port) """ |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 291 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 292 | def runTest( self ): |
Flavio Castro | b01d0aa | 2016-07-20 16:14:48 -0700 | [diff] [blame] | 293 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 294 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 295 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 296 | ports = sorted( config[ "port_map" ].keys( ) ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 297 | vlan_id = 1; |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 298 | for port in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 299 | L2gid, l2msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False ) |
| 300 | add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 301 | Groups.put( L2gid ) |
| 302 | add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, port ], vlan_id, L2gid, |
| 303 | True ) |
| 304 | do_barrier( self.controller ) |
Flavio Castro | 6efe186 | 2015-11-18 16:28:06 -0500 | [diff] [blame] | 305 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 306 | for out_port in ports: |
| 307 | # change dest based on port number |
| 308 | mac_dst = '00:12:34:56:78:%02X' % out_port |
| 309 | for in_port in ports: |
| 310 | if in_port == out_port: |
| 311 | continue |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 312 | pkt = str( simple_tcp_packet( dl_vlan_enable=True, vlan_vid=vlan_id, eth_dst=mac_dst ) ) |
| 313 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 314 | for ofport in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 315 | if ofport in [ out_port ]: |
| 316 | verify_packet( self, pkt, ofport ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 317 | else: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 318 | verify_no_packet( self, pkt, ofport ) |
| 319 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 320 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 321 | delete_all_flows( self.controller ) |
| 322 | delete_groups( self.controller, Groups ) |
| 323 | delete_all_groups( self.controller ) |
Flavio Castro | 6efe186 | 2015-11-18 16:28:06 -0500 | [diff] [blame] | 324 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 325 | |
| 326 | class Mtu1500( base_tests.SimpleDataPlane ): |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame^] | 327 | """ |
| 328 | Verifies basic mtu limits |
| 329 | """ |
| 330 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 331 | def runTest( self ): |
| 332 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 333 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 334 | ports = sorted( config[ "port_map" ].keys( ) ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 335 | vlan_id = 18 |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 336 | for port in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 337 | L2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False ) |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 338 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 339 | Groups.put( L2gid ) |
| 340 | add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, port ], vlan_id, L2gid, |
| 341 | True ) |
| 342 | do_barrier( self.controller ) |
Flavio Castro | b677303 | 2015-11-19 22:49:24 -0500 | [diff] [blame] | 343 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 344 | for out_port in ports: |
| 345 | # change dest based on port number |
| 346 | mac_dst = '00:12:34:56:78:%02X' % out_port |
| 347 | for in_port in ports: |
| 348 | if in_port == out_port: |
| 349 | continue |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 350 | pkt = str( simple_tcp_packet( pktlen=1500, dl_vlan_enable=True, vlan_vid=vlan_id, |
| 351 | eth_dst=mac_dst ) ) |
| 352 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 353 | for ofport in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 354 | if ofport in [ out_port ]: |
| 355 | verify_packet( self, pkt, ofport ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 356 | else: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 357 | verify_no_packet( self, pkt, ofport ) |
| 358 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 359 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 360 | delete_all_flows( self.controller ) |
| 361 | delete_groups( self.controller, Groups ) |
| 362 | delete_all_groups( self.controller ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 363 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 364 | |
| 365 | class _32UcastTagged( base_tests.SimpleDataPlane ): |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame^] | 366 | """ Verify /32 IP forwarding to L3 Unicast-> L2Interface""" |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 367 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 368 | def runTest( self ): |
| 369 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 370 | try: |
| 371 | test_id = 26 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 372 | if len( config[ "port_map" ] ) < 2: |
| 373 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 374 | return |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 375 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 376 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 377 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 378 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 379 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 380 | for port in ports: |
| 381 | # add l2 interface group |
| 382 | vlan_id = port + test_id |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 383 | l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, |
| 384 | is_tagged=True, send_barrier=False ) |
| 385 | dst_mac[ 5 ] = vlan_id |
| 386 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id, |
| 387 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 388 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 389 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 390 | # add termination flow |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 391 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 392 | # add unicast routing flow |
| 393 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 394 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id ) |
| 395 | Groups.put( l2gid ) |
| 396 | Groups.put( l3_msg.group_id ) |
| 397 | do_barrier( self.controller ) |
Flavio Castro | d8f8af2 | 2015-12-02 18:19:26 -0500 | [diff] [blame] | 398 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 399 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 400 | for in_port in ports: |
| 401 | mac_src = '00:00:00:22:32:%02X' % (test_id + in_port) |
| 402 | ip_src = '192.168.%02d.1' % (test_id + in_port) |
| 403 | for out_port in ports: |
| 404 | if in_port == out_port: |
| 405 | continue |
| 406 | ip_dst = '192.168.%02d.1' % (test_id + out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 407 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, |
| 408 | vlan_vid=(test_id + in_port), eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, |
| 409 | ip_src=ip_src, ip_dst=ip_dst ) |
| 410 | pkt = str( parsed_pkt ) |
| 411 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 412 | # build expected packet |
| 413 | mac_dst = '00:00:00:22:22:%02X' % (test_id + out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 414 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, |
| 415 | vlan_vid=(test_id + out_port), eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, |
| 416 | ip_src=ip_src, ip_dst=ip_dst ) |
| 417 | pkt = str( exp_pkt ) |
| 418 | verify_packet( self, pkt, out_port ) |
| 419 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 420 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 421 | delete_all_flows( self.controller ) |
| 422 | delete_groups( self.controller, Groups ) |
| 423 | delete_all_groups( self.controller ) |
Flavio Castro | 05d20bc | 2015-11-16 15:06:14 -0500 | [diff] [blame] | 424 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame^] | 425 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 426 | class _32VPN( base_tests.SimpleDataPlane ): |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame^] | 427 | """ |
| 428 | Verify /32 routing rule -> MPLS_VPN_Label -> MPLSInterface -> L2Interface |
| 429 | No ECMP group used |
| 430 | """ |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 431 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 432 | def runTest( self ): |
| 433 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 434 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 435 | if len( config[ "port_map" ] ) < 2: |
| 436 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 437 | return |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 438 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 439 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 440 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 441 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 442 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 443 | for port in ports: |
| 444 | # add l2 interface group |
| 445 | id = port |
| 446 | vlan_id = port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 447 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True ) |
| 448 | dst_mac[ 5 ] = vlan_id |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 449 | # add MPLS interface group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 450 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| 451 | vlan_id, id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 452 | # add MPLS L3 VPN group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 453 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| 454 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid, |
| 455 | push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 ) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 456 | do_barrier( self.controller ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 457 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 458 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, vrf=2, |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 459 | flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 460 | # add termination flow |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 461 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 462 | # add routing flow |
| 463 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 464 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, mpls_label_gid, vrf=2 ) |
| 465 | Groups._put( l2_gid ) |
| 466 | Groups._put( mpls_gid ) |
| 467 | Groups._put( mpls_label_gid ) |
| 468 | do_barrier( self.controller ) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 469 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 470 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 471 | for in_port in ports: |
| 472 | ip_src = '192.168.%02d.1' % (in_port) |
| 473 | for out_port in ports: |
| 474 | if in_port == out_port: |
| 475 | continue |
| 476 | ip_dst = '192.168.%02d.1' % (out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 477 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port), |
| 478 | eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 479 | pkt = str( parsed_pkt ) |
| 480 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 481 | # build expect packet |
| 482 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
| 483 | label = (out_port, 0, 1, 32) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 484 | exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63, |
| 485 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, |
| 486 | label=[ label ] ) |
| 487 | pkt = str( exp_pkt ) |
| 488 | verify_packet( self, pkt, out_port ) |
| 489 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 490 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 491 | delete_all_flows( self.controller ) |
| 492 | delete_groups( self.controller, Groups ) |
| 493 | delete_all_groups( self.controller ) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 494 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame^] | 495 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 496 | class _32EcmpVpn( base_tests.SimpleDataPlane ): |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame^] | 497 | """ |
| 498 | Verify /32 routing rule -> L3 ECMP -> MPLS_VPN_Label -> MPLSInterface -> L2Interface |
| 499 | """ |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 500 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 501 | def runTest( self ): |
| 502 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 503 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 504 | if len( config[ "port_map" ] ) < 2: |
| 505 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 506 | return |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 507 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 508 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 509 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 510 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 511 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 512 | for port in ports: |
| 513 | # add l2 interface group |
| 514 | id = port |
| 515 | vlan_id = port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 516 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True ) |
| 517 | dst_mac[ 5 ] = vlan_id |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 518 | # add MPLS interface group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 519 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| 520 | vlan_id, id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 521 | # add MPLS L3 VPN group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 522 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| 523 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid, |
| 524 | push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 ) |
| 525 | ecmp_msg = add_l3_ecmp_group( self.controller, vlan_id, [ mpls_label_gid ] ) |
| 526 | do_barrier( self.controller ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 527 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 528 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, vrf=0, |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 529 | flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 530 | # add termination flow |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 531 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 532 | # add routing flow |
| 533 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 534 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id ) |
| 535 | Groups._put( l2_gid ) |
| 536 | Groups._put( mpls_gid ) |
| 537 | Groups._put( mpls_label_gid ) |
| 538 | Groups._put( ecmp_msg.group_id ) |
| 539 | do_barrier( self.controller ) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 540 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 541 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 542 | for in_port in ports: |
| 543 | ip_src = '192.168.%02d.1' % (in_port) |
| 544 | for out_port in ports: |
| 545 | if in_port == out_port: |
| 546 | continue |
| 547 | ip_dst = '192.168.%02d.1' % (out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 548 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port), |
| 549 | eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 550 | pkt = str( parsed_pkt ) |
| 551 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 552 | # build expect packet |
| 553 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
| 554 | label = (out_port, 0, 1, 32) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 555 | exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63, |
| 556 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, |
| 557 | label=[ label ] ) |
| 558 | pkt = str( exp_pkt ) |
| 559 | verify_packet( self, pkt, out_port ) |
| 560 | verify_no_other_packets( self ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame^] | 561 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 562 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 563 | delete_all_flows( self.controller ) |
| 564 | delete_groups( self.controller, Groups ) |
| 565 | delete_all_groups( self.controller ) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 566 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 567 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame^] | 568 | @disabled |
| 569 | class One_32EcmpVpn( base_tests.SimpleDataPlane ): |
| 570 | """ |
| 571 | Verify /32 routing rule -> L3 ECMP -> MPLS_VPN_Label -> MPLSInterface -> L2Interface |
| 572 | in only one direction |
| 573 | """ |
| 574 | |
| 575 | def runTest( self ): |
| 576 | Groups = Queue.LifoQueue( ) |
| 577 | try: |
| 578 | if len( config[ "port_map" ] ) < 2: |
| 579 | logging.info( "Port count less than 2, can't run this case" ) |
| 580 | return |
| 581 | |
| 582 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 583 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 584 | dip = 0xc0a80001 |
| 585 | ports = config[ "port_map" ].keys( ) |
| 586 | # add l2 interface group |
| 587 | id = ports[1] |
| 588 | vlan_id = ports[1] + 20 |
| 589 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, ports[1], vlan_id, True, True ) |
| 590 | dst_mac[ 5 ] = vlan_id |
| 591 | # add MPLS interface group |
| 592 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| 593 | vlan_id, id ) |
| 594 | # add MPLS L3 VPN group |
| 595 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| 596 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid, |
| 597 | push_mpls_header=True, set_mpls_label=ports[1] + 20, set_bos=1, set_ttl=32 ) |
| 598 | # add ECMP group |
| 599 | ecmp_msg = add_l3_ecmp_group( self.controller, vlan_id, [ mpls_label_gid ] ) |
| 600 | do_barrier( self.controller ) |
| 601 | # add vlan flow table |
| 602 | add_one_vlan_table_flow( self.controller, ports[0], 1, vlan_id=ports[0] + 10, vrf=0, |
| 603 | flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 604 | # add termination flow |
| 605 | add_termination_flow( self.controller, ports[0], 0x0800, intf_src_mac, vlanid=ports[0] + 10 ) |
| 606 | # add routing flow |
| 607 | dst_ip = dip + (vlan_id << 8) |
| 608 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id, send_barrier=True ) |
| 609 | Groups._put( l2_gid ) |
| 610 | Groups._put( mpls_gid ) |
| 611 | Groups._put( mpls_label_gid ) |
| 612 | Groups._put( ecmp_msg.group_id ) |
| 613 | |
| 614 | |
| 615 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| 616 | in_port = ports[0] |
| 617 | out_port = ports[1] |
| 618 | ip_src = '192.168.%02d.1' % (in_port) |
| 619 | ip_dst = '192.168.%02d.1' % (out_port) |
| 620 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port + 20), |
| 621 | eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 622 | pkt = str( parsed_pkt ) |
| 623 | self.dataplane.send( in_port, pkt ) |
| 624 | # build expect packet |
| 625 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
| 626 | label = (out_port, 0, 1, 32) |
| 627 | exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port + 20), ip_ttl=63, |
| 628 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, |
| 629 | label=[ label+20 ] ) |
| 630 | pkt = str( exp_pkt ) |
| 631 | verify_packet( self, pkt, out_port ) |
| 632 | #verify_no_other_packets( self ) |
| 633 | |
| 634 | finally: |
| 635 | delete_all_flows( self.controller ) |
| 636 | delete_group(self.controller, ecmp_msg.group_id) |
| 637 | delete_group(self.controller, mpls_label_gid) |
| 638 | delete_group(self.controller, mpls_gid) |
| 639 | delete_group(self.controller, l2_gid) |
| 640 | |
| 641 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 642 | class _32ECMPL3( base_tests.SimpleDataPlane ): |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame^] | 643 | """ |
| 644 | Verifies /32 IP routing and ECMP with no label push |
| 645 | IP -> L3ECMP -> L3Unicast -> L2Interface |
| 646 | """ |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 647 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 648 | def runTest( self ): |
| 649 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 650 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 651 | if len( config[ "port_map" ] ) < 2: |
| 652 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 653 | return |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 654 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 655 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 656 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 657 | dip = 0xc0a80001 |
| 658 | # Hashes Test Name and uses it as id for installing unique groups |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 659 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 660 | for port in ports: |
| 661 | vlan_id = port |
| 662 | id = port |
| 663 | # add l2 interface group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 664 | l2_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, |
| 665 | is_tagged=True, send_barrier=False ) |
| 666 | dst_mac[ 5 ] = vlan_id |
| 667 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id, |
| 668 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
| 669 | 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] | 670 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 671 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 672 | # add termination flow |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 673 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 674 | # add unicast routing flow |
| 675 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 676 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id ) |
| 677 | Groups._put( l2_gid ) |
| 678 | Groups._put( l3_msg.group_id ) |
| 679 | Groups._put( ecmp_msg.group_id ) |
| 680 | do_barrier( self.controller ) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 681 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 682 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 683 | for in_port in ports: |
| 684 | mac_src = '00:00:00:22:22:%02X' % in_port |
| 685 | ip_src = '192.168.%02d.1' % in_port |
| 686 | for out_port in ports: |
| 687 | if in_port == out_port: |
| 688 | continue |
| 689 | ip_dst = '192.168.%02d.1' % out_port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 690 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| 691 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 692 | pkt = str( parsed_pkt ) |
| 693 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 694 | # build expected packet |
| 695 | mac_dst = '00:00:00:22:22:%02X' % out_port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 696 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| 697 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst ) |
| 698 | pkt = str( exp_pkt ) |
| 699 | verify_packet( self, pkt, out_port ) |
| 700 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 701 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 702 | delete_all_flows( self.controller ) |
| 703 | delete_groups( self.controller, Groups ) |
| 704 | delete_all_groups( self.controller ) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 705 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame^] | 706 | @disabled |
| 707 | class One_32ECMPL3( base_tests.SimpleDataPlane ): |
| 708 | """ |
| 709 | Verifies /32 IP routing and ECMP with no label push |
| 710 | IP -> L3ECMP -> L3Unicast -> L2Interface |
| 711 | in only one direction |
| 712 | """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 713 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame^] | 714 | def runTest( self ): |
| 715 | Groups = Queue.LifoQueue( ) |
| 716 | try: |
| 717 | if len( config[ "port_map" ] ) < 2: |
| 718 | logging.info( "Port count less than 2, can't run this case" ) |
| 719 | return |
| 720 | |
| 721 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 722 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 723 | dip = 0xc0a80001 |
| 724 | # Hashes Test Name and uses it as id for installing unique groups |
| 725 | ports = config[ "port_map" ].keys( ) |
| 726 | inport = ports[0] |
| 727 | outport = ports[1] |
| 728 | |
| 729 | vlan_id = outport + 20 |
| 730 | id = outport |
| 731 | # add l2 interface group, l3 unicast and ecmp group for outport |
| 732 | l2_gid, msg = add_one_l2_interface_group( self.controller, outport, vlan_id=vlan_id, |
| 733 | is_tagged=True, send_barrier=False ) |
| 734 | dst_mac[ 5 ] = vlan_id |
| 735 | l3_msg = add_l3_unicast_group( self.controller, outport, vlanid=vlan_id, id=id, |
| 736 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
| 737 | ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] ) |
| 738 | # add vlan flow table |
| 739 | add_one_vlan_table_flow( self.controller, of_port=inport, vlan_id=inport+20, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 740 | # add termination flow |
| 741 | add_termination_flow( self.controller, in_port=inport, eth_type=0x0800, dst_mac=intf_src_mac, vlanid=inport+20 ) |
| 742 | # add unicast routing flow |
| 743 | dst_ip = dip + (vlan_id << 8) |
| 744 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id, send_barrier=True ) |
| 745 | Groups._put( l2_gid ) |
| 746 | Groups._put( l3_msg.group_id ) |
| 747 | Groups._put( ecmp_msg.group_id ) |
| 748 | |
| 749 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| 750 | mac_src = '00:00:00:22:22:%02X' % inport |
| 751 | ip_src = '192.168.%02d.1' % inport |
| 752 | ip_dst = '192.168.%02d.1' % outport |
| 753 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=inport+20, |
| 754 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 755 | pkt = str( parsed_pkt ) |
| 756 | self.dataplane.send( inport, pkt ) |
| 757 | # build expected packet |
| 758 | mac_dst = '00:00:00:22:22:%02X' % outport |
| 759 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=outport+20, |
| 760 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst ) |
| 761 | pkt = str( exp_pkt ) |
| 762 | verify_packet( self, pkt, outport ) |
| 763 | verify_no_other_packets( self ) |
| 764 | finally: |
| 765 | delete_all_flows( self.controller ) |
| 766 | delete_groups( self.controller, Groups ) |
| 767 | delete_all_groups( self.controller ) |
| 768 | |
| 769 | |
| 770 | |
| 771 | |
| 772 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 773 | class _24VPN( base_tests.SimpleDataPlane ): |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame^] | 774 | """ Verify MPLS IP VPN Initiation from /32 rule without using ECMP """ |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 775 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 776 | def runTest( self ): |
| 777 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 778 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 779 | if len( config[ "port_map" ] ) < 2: |
| 780 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 781 | return |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 782 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 783 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 784 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 785 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 786 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 787 | for port in ports: |
| 788 | # add l2 interface group |
| 789 | id = port |
| 790 | vlan_id = port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 791 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True ) |
| 792 | dst_mac[ 5 ] = vlan_id |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 793 | # add MPLS interface group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 794 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| 795 | vlan_id, id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 796 | # add MPLS L3 VPN group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 797 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| 798 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid, |
| 799 | 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] | 800 | # 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] | 801 | do_barrier( self.controller ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 802 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 803 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, vrf=0, |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 804 | flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 805 | # add termination flow |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 806 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 807 | # add routing flow |
| 808 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 809 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, mpls_label_gid ) |
| 810 | Groups._put( l2_gid ) |
| 811 | Groups._put( mpls_gid ) |
| 812 | Groups._put( mpls_label_gid ) |
| 813 | do_barrier( self.controller ) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 814 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 815 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 816 | for in_port in ports: |
| 817 | ip_src = '192.168.%02d.1' % (in_port) |
| 818 | for out_port in ports: |
| 819 | if in_port == out_port: |
| 820 | continue |
| 821 | ip_dst = '192.168.%02d.1' % (out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 822 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port), |
| 823 | eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 824 | pkt = str( parsed_pkt ) |
| 825 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 826 | # build expect packet |
| 827 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
| 828 | label = (out_port, 0, 1, 32) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 829 | exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63, |
| 830 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, |
| 831 | label=[ label ] ) |
| 832 | pkt = str( exp_pkt ) |
| 833 | verify_packet( self, pkt, out_port ) |
| 834 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 835 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 836 | delete_all_flows( self.controller ) |
| 837 | delete_groups( self.controller, Groups ) |
| 838 | delete_all_groups( self.controller ) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 839 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame^] | 840 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 841 | class _24EcmpVpn( base_tests.SimpleDataPlane ): |
Flavio Castro | 76c5b26 | 2016-07-27 19:53:00 -0700 | [diff] [blame] | 842 | """ Verify MPLS IP VPN Initiation from /24 rule using ECMP """ |
Flavio Castro | 72a45d5 | 2015-12-02 16:37:05 -0500 | [diff] [blame] | 843 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 844 | def runTest( self ): |
| 845 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 846 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 847 | if len( config[ "port_map" ] ) < 2: |
| 848 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 849 | return |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 850 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 851 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 852 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 853 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 854 | for port in ports: |
| 855 | # add l2 interface group |
| 856 | id = port |
| 857 | vlan_id = id |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 858 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True ) |
| 859 | dst_mac[ 5 ] = vlan_id |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 860 | # add MPLS interface group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 861 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| 862 | vlan_id, id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 863 | # add MPLS L3 VPN group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 864 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| 865 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid, |
| 866 | push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 ) |
| 867 | ecmp_msg = add_l3_ecmp_group( self.controller, id, [ mpls_label_gid ] ) |
| 868 | do_barrier( self.controller ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 869 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 870 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, vrf=0, |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 871 | flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 872 | # add termination flow |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 873 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 874 | # add routing flow |
| 875 | dst_ip = dip + (vlan_id << 8) |
| 876 | # 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] | 877 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id, |
| 878 | vrf=0 ) |
| 879 | Groups._put( l2_gid ) |
| 880 | Groups._put( mpls_gid ) |
| 881 | Groups._put( mpls_label_gid ) |
| 882 | Groups._put( ecmp_msg.group_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 883 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 884 | do_barrier( self.controller ) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 885 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 886 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 887 | for in_port in ports: |
| 888 | mac_src = '00:00:00:22:22:%02X' % (in_port) |
| 889 | ip_src = '192.168.%02d.1' % (in_port) |
| 890 | for out_port in ports: |
| 891 | if in_port == out_port: |
| 892 | continue |
| 893 | ip_dst = '192.168.%02d.1' % (out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 894 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port), |
| 895 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 896 | pkt = str( parsed_pkt ) |
| 897 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 898 | # build expect packet |
| 899 | mac_dst = '00:00:00:22:22:%02X' % out_port |
| 900 | label = (out_port, 0, 1, 32) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 901 | exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63, |
| 902 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, |
| 903 | label=[ label ] ) |
| 904 | pkt = str( exp_pkt ) |
| 905 | verify_packet( self, pkt, out_port ) |
| 906 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 907 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 908 | delete_all_flows( self.controller ) |
| 909 | delete_groups( self.controller, Groups ) |
| 910 | delete_all_groups( self.controller ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 911 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 912 | |
| 913 | class FloodGroupMod( base_tests.SimpleDataPlane ): |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame^] | 914 | """ Modify a referenced flood group """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 915 | |
| 916 | def runTest( self ): |
| 917 | Groups = Queue.LifoQueue( ) |
| 918 | try: |
| 919 | ports = sorted( config[ "port_map" ].keys( ) ) |
| 920 | vlan_id = 1 |
| 921 | |
| 922 | for port in ports: |
| 923 | L2gid, l2msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False ) |
| 924 | add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 925 | Groups.put( L2gid ) |
| 926 | |
| 927 | msg = add_l2_flood_group( self.controller, ports, vlan_id, vlan_id ) |
| 928 | Groups.put( msg.group_id ) |
| 929 | add_bridge_flow( self.controller, None, vlan_id, msg.group_id, True ) |
| 930 | do_barrier( self.controller ) |
| 931 | # verify flood |
| 932 | for ofport in ports: |
| 933 | # change dest based on port number |
| 934 | mac_src = '00:12:34:56:78:%02X' % ofport |
| 935 | parsed_pkt = simple_tcp_packet_two_vlan( pktlen=108, out_dl_vlan_enable=True, |
| 936 | out_vlan_vid=vlan_id, in_dl_vlan_enable=True, in_vlan_vid=10, |
| 937 | eth_dst='00:12:34:56:78:9a', eth_src=mac_src ) |
| 938 | pkt = str( parsed_pkt ) |
| 939 | self.dataplane.send( ofport, pkt ) |
| 940 | # self won't rx packet |
| 941 | verify_no_packet( self, pkt, ofport ) |
| 942 | # others will rx packet |
| 943 | tmp_ports = list( ports ) |
| 944 | tmp_ports.remove( ofport ) |
| 945 | verify_packets( self, pkt, tmp_ports ) |
| 946 | verify_no_other_packets( self ) |
| 947 | msg = mod_l2_flood_group( self.controller, [ ports[ 0 ] ], vlan_id, vlan_id ) |
| 948 | mac_src = '00:12:34:56:78:%02X' % ports[ 1 ] |
| 949 | parsed_pkt = simple_tcp_packet_two_vlan( pktlen=108, out_dl_vlan_enable=True, |
| 950 | out_vlan_vid=vlan_id, in_dl_vlan_enable=True, in_vlan_vid=10, eth_dst='00:12:34:56:78:9a', |
| 951 | eth_src=mac_src ) |
| 952 | pkt = str( parsed_pkt ) |
| 953 | self.dataplane.send( ports[ 1 ], pkt ) |
| 954 | verify_packets( self, pkt, [ ports[ 0 ] ] ) |
| 955 | finally: |
| 956 | delete_all_flows( self.controller ) |
| 957 | delete_groups( self.controller, Groups ) |
| 958 | delete_all_groups( self.controller ) |
| 959 | |
| 960 | |
| 961 | class _24ECMPL3( base_tests.SimpleDataPlane ): |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame^] | 962 | """ Verifies /24 IP routing using ECMP -> L3U -> L2I """ |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 963 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 964 | def runTest( self ): |
| 965 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 966 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 967 | if len( config[ "port_map" ] ) < 2: |
| 968 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 969 | return |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 970 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 971 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 972 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 973 | dip = 0xc0a80001 |
| 974 | # Hashes Test Name and uses it as id for installing unique groups |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 975 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 976 | for port in ports: |
| 977 | vlan_id = port |
| 978 | id = port |
| 979 | # add l2 interface group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 980 | l2_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, |
| 981 | is_tagged=True, send_barrier=False ) |
| 982 | dst_mac[ 5 ] = vlan_id |
| 983 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id, |
| 984 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
| 985 | 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] | 986 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 987 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 988 | # add termination flow |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 989 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 990 | # add unicast routing flow |
| 991 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 992 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id ) |
| 993 | Groups._put( l2_gid ) |
| 994 | Groups._put( l3_msg.group_id ) |
| 995 | Groups._put( ecmp_msg.group_id ) |
| 996 | do_barrier( self.controller ) |
Flavio Castro | 72a45d5 | 2015-12-02 16:37:05 -0500 | [diff] [blame] | 997 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 998 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 999 | for in_port in ports: |
| 1000 | mac_src = '00:00:00:22:22:%02X' % in_port |
| 1001 | ip_src = '192.168.%02d.1' % in_port |
| 1002 | for out_port in ports: |
| 1003 | if in_port == out_port: |
| 1004 | continue |
| 1005 | ip_dst = '192.168.%02d.1' % out_port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1006 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| 1007 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 1008 | pkt = str( parsed_pkt ) |
| 1009 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1010 | # build expected packet |
| 1011 | mac_dst = '00:00:00:22:22:%02X' % out_port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1012 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| 1013 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst ) |
| 1014 | pkt = str( exp_pkt ) |
| 1015 | verify_packet( self, pkt, out_port ) |
| 1016 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1017 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1018 | delete_all_flows( self.controller ) |
| 1019 | delete_groups( self.controller, Groups ) |
| 1020 | delete_all_groups( self.controller ) |
| 1021 | |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1022 | |
Flavio Castro | aba28ff | 2016-02-03 16:47:48 -0500 | [diff] [blame] | 1023 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1024 | class MPLSBUG( base_tests.SimpleDataPlane ): |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame^] | 1025 | """ |
| 1026 | Needs a description or needs to be removed |
| 1027 | """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1028 | def runTest( self ): |
| 1029 | if len( config[ "port_map" ] ) < 2: |
| 1030 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 1031 | return |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1032 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1033 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1034 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1035 | Groups = Queue.LifoQueue( ) |
| 1036 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 1037 | for port in ports: |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1038 | # add l2 interface group |
| 1039 | vlan_id = port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1040 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False ) |
| 1041 | dst_mac[ 5 ] = vlan_id |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1042 | # add L3 Unicast group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1043 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id, |
| 1044 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1045 | # add vlan flow table |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1046 | 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] | 1047 | # add termination flow |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1048 | 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] | 1049 | # add mpls flow |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1050 | add_mpls_flow( self.controller, l3_msg.group_id, port ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1051 | # add termination flow |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1052 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1053 | # add unicast routing flow |
| 1054 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1055 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id ) |
| 1056 | Groups._put( l2_gid ) |
| 1057 | Groups._put( l3_msg.group_id ) |
| 1058 | do_barrier( self.controller ) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 1059 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1060 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 1061 | for in_port in ports: |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1062 | mac_src = '00:00:00:22:22:%02X' % in_port |
| 1063 | ip_src = '192.168.%02d.1' % in_port |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 1064 | for out_port in ports: |
| 1065 | if in_port == out_port: |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1066 | continue |
| 1067 | ip_dst = '192.168.%02d.1' % out_port |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 1068 | switch_mac = "00:00:00:cc:cc:cc" |
| 1069 | label = (out_port, 0, 1, 32) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1070 | parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=in_port, ip_src=ip_src, |
| 1071 | ip_dst=ip_dst, eth_dst=switch_mac, eth_src=mac_src, label=[ label ] ) |
| 1072 | pkt = str( parsed_pkt ) |
| 1073 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 1074 | |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1075 | # build expect packet |
| 1076 | mac_dst = '00:00:00:22:22:%02X' % out_port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1077 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| 1078 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst ) |
| 1079 | pkt = str( exp_pkt ) |
| 1080 | verify_packet( self, pkt, out_port ) |
| 1081 | verify_no_other_packets( self ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1082 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1083 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| 1084 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 1085 | pkt = str( parsed_pkt ) |
| 1086 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1087 | # build expected packet |
| 1088 | mac_dst = '00:00:00:22:22:%02X' % out_port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1089 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| 1090 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst ) |
| 1091 | pkt = str( exp_pkt ) |
| 1092 | verify_packet( self, pkt, out_port ) |
| 1093 | verify_no_other_packets( self ) |
| 1094 | delete_all_flows( self.controller ) |
| 1095 | delete_groups( self.controller, Groups ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1096 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1097 | class L3McastToL3( base_tests.SimpleDataPlane ): |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1098 | """ |
| 1099 | Mcast routing, in this test case the traffic comes in tagged. |
| 1100 | port+1 is used as ingress vlan_id. The packet goes out tagged on |
| 1101 | different ports. 4094-port is used as egress vlan_id. |
| 1102 | """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1103 | def runTest( self ): |
Pier | 7b031af | 2016-08-25 15:00:22 -0700 | [diff] [blame] | 1104 | """ |
| 1105 | port1 (vlan 300)-> All Ports (vlan 300) |
| 1106 | """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1107 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1108 | try: |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1109 | # We can forward on the in_port but egress_vlan has to be different from ingress_vlan |
| 1110 | if len( config[ "port_map" ] ) < 1: |
| 1111 | logging.info( "Port count less than 1, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1112 | assert (False) |
| 1113 | return |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1114 | ports = config[ "port_map" ].keys( ) |
| 1115 | dst_ip_str = "224.0.0.1" |
| 1116 | ( |
| 1117 | port_to_in_vlan, |
| 1118 | port_to_out_vlan, |
| 1119 | port_to_src_mac_str, |
| 1120 | port_to_dst_mac_str, |
| 1121 | port_to_src_ip_str, |
| 1122 | port_to_intf_src_mac_str, |
| 1123 | Groups) = fill_mcast_pipeline_L3toL3( |
| 1124 | self.controller, |
| 1125 | logging, |
| 1126 | ports, |
| 1127 | is_ingress_tagged = True, |
| 1128 | is_egress_tagged = True, |
| 1129 | is_vlan_translated = True, |
| 1130 | is_max_vlan = False |
| 1131 | ) |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 1132 | |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1133 | for in_port in ports: |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 1134 | |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1135 | parsed_pkt = simple_udp_packet( |
| 1136 | pktlen = 100, |
| 1137 | dl_vlan_enable = True, |
| 1138 | vlan_vid = port_to_in_vlan[in_port], |
| 1139 | eth_dst = port_to_dst_mac_str[in_port], |
| 1140 | eth_src = port_to_src_mac_str[in_port], |
| 1141 | ip_ttl = 64, |
| 1142 | ip_src = port_to_src_ip_str[in_port], |
| 1143 | ip_dst = dst_ip_str |
| 1144 | ) |
| 1145 | pkt = str( parsed_pkt ) |
| 1146 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 1147 | |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1148 | for out_port in ports: |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 1149 | |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1150 | parsed_pkt = simple_udp_packet( |
| 1151 | pktlen = 100, |
| 1152 | dl_vlan_enable = True, |
| 1153 | vlan_vid = port_to_out_vlan[out_port], |
| 1154 | eth_dst = port_to_dst_mac_str[in_port], |
| 1155 | eth_src = port_to_intf_src_mac_str[out_port], |
| 1156 | ip_ttl = 63, |
| 1157 | ip_src = port_to_src_ip_str[in_port], |
| 1158 | ip_dst = dst_ip_str |
| 1159 | ) |
| 1160 | pkt = str( parsed_pkt ) |
| 1161 | verify_packet( self, pkt, out_port ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1162 | |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1163 | verify_no_other_packets( self ) |
| 1164 | |
Pier | 7b031af | 2016-08-25 15:00:22 -0700 | [diff] [blame] | 1165 | finally: |
| 1166 | delete_all_flows( self.controller ) |
| 1167 | delete_groups( self.controller, Groups ) |
| 1168 | delete_all_groups( self.controller ) |
| 1169 | |
| 1170 | class L3McastToL2UntagToUntag( base_tests.SimpleDataPlane ): |
| 1171 | """ |
| 1172 | Mcast routing, in this test case the traffic is untagged. |
| 1173 | 4094 is used as internal vlan_id. The packet goes out |
| 1174 | untagged. |
| 1175 | """ |
| 1176 | def runTest( self ): |
| 1177 | Groups = Queue.LifoQueue( ) |
| 1178 | try: |
| 1179 | if len( config[ "port_map" ] ) < 2: |
| 1180 | logging.info( "Port count less than 2, can't run this case" ) |
| 1181 | assert (False) |
| 1182 | return |
| 1183 | ports = config[ "port_map" ].keys( ) |
| 1184 | dst_ip_str = "224.0.0.1" |
| 1185 | ( |
| 1186 | port_to_in_vlan, |
| 1187 | port_to_out_vlan, |
| 1188 | port_to_src_mac_str, |
| 1189 | port_to_dst_mac_str, |
| 1190 | port_to_src_ip_str, |
| 1191 | Groups) = fill_mcast_pipeline_L3toL2( |
| 1192 | self.controller, |
| 1193 | logging, |
| 1194 | ports, |
| 1195 | is_ingress_tagged = False, |
| 1196 | is_egress_tagged = False, |
| 1197 | is_vlan_translated = False, |
| 1198 | is_max_vlan = True |
| 1199 | ) |
| 1200 | |
| 1201 | for in_port in ports: |
| 1202 | |
| 1203 | parsed_pkt = simple_udp_packet( |
| 1204 | pktlen = 96, |
| 1205 | eth_dst = port_to_dst_mac_str[in_port], |
| 1206 | eth_src = port_to_src_mac_str[in_port], |
| 1207 | ip_ttl = 64, |
| 1208 | ip_src = port_to_src_ip_str[in_port], |
| 1209 | ip_dst = dst_ip_str |
| 1210 | ) |
| 1211 | pkt = str( parsed_pkt ) |
| 1212 | self.dataplane.send( in_port, pkt ) |
| 1213 | |
| 1214 | for out_port in ports: |
| 1215 | |
| 1216 | parsed_pkt = simple_udp_packet( |
| 1217 | pktlen = 96, |
| 1218 | eth_dst = port_to_dst_mac_str[in_port], |
| 1219 | eth_src = port_to_src_mac_str[in_port], |
| 1220 | ip_ttl = 64, |
| 1221 | ip_src = port_to_src_ip_str[in_port], |
| 1222 | ip_dst = dst_ip_str |
| 1223 | ) |
| 1224 | pkt = str( parsed_pkt ) |
| 1225 | if out_port == in_port: |
| 1226 | verify_no_packet( self, pkt, in_port ) |
| 1227 | continue |
| 1228 | verify_packet( self, pkt, out_port ) |
| 1229 | verify_no_other_packets( self ) |
| 1230 | finally: |
| 1231 | delete_all_flows( self.controller ) |
| 1232 | delete_groups( self.controller, Groups ) |
| 1233 | delete_all_groups( self.controller ) |
| 1234 | |
| 1235 | class L3McastToL2UntagToTag( base_tests.SimpleDataPlane ): |
| 1236 | """ |
| 1237 | Mcast routing, in this test case the traffic is untagged. |
| 1238 | 300 is used as vlan_id. The packet goes out |
| 1239 | tagged. |
| 1240 | """ |
| 1241 | def runTest( self ): |
| 1242 | Groups = Queue.LifoQueue( ) |
| 1243 | try: |
| 1244 | if len( config[ "port_map" ] ) < 2: |
| 1245 | logging.info( "Port count less than 2, can't run this case" ) |
| 1246 | assert (False) |
| 1247 | return |
| 1248 | ports = config[ "port_map" ].keys( ) |
| 1249 | dst_ip_str = "224.0.0.1" |
| 1250 | ( |
| 1251 | port_to_in_vlan, |
| 1252 | port_to_out_vlan, |
| 1253 | port_to_src_mac_str, |
| 1254 | port_to_dst_mac_str, |
| 1255 | port_to_src_ip_str, |
| 1256 | Groups) = fill_mcast_pipeline_L3toL2( |
| 1257 | self.controller, |
| 1258 | logging, |
| 1259 | ports, |
| 1260 | is_ingress_tagged = False, |
| 1261 | is_egress_tagged = True, |
| 1262 | is_vlan_translated = False, |
| 1263 | is_max_vlan = False |
| 1264 | ) |
| 1265 | |
| 1266 | for in_port in ports: |
| 1267 | |
| 1268 | parsed_pkt = simple_udp_packet( |
| 1269 | pktlen = 96, |
| 1270 | eth_dst = port_to_dst_mac_str[in_port], |
| 1271 | eth_src = port_to_src_mac_str[in_port], |
| 1272 | ip_ttl = 64, |
| 1273 | ip_src = port_to_src_ip_str[in_port], |
| 1274 | ip_dst = dst_ip_str |
| 1275 | ) |
| 1276 | pkt = str( parsed_pkt ) |
| 1277 | self.dataplane.send( in_port, pkt ) |
| 1278 | |
| 1279 | for out_port in ports: |
| 1280 | |
| 1281 | parsed_pkt = simple_udp_packet( |
| 1282 | pktlen = 100, |
| 1283 | dl_vlan_enable = True, |
| 1284 | vlan_vid = port_to_out_vlan[in_port], |
| 1285 | eth_dst = port_to_dst_mac_str[in_port], |
| 1286 | eth_src = port_to_src_mac_str[in_port], |
| 1287 | ip_ttl = 64, |
| 1288 | ip_src = port_to_src_ip_str[in_port], |
| 1289 | ip_dst = dst_ip_str |
| 1290 | ) |
| 1291 | pkt = str( parsed_pkt ) |
| 1292 | if out_port == in_port: |
| 1293 | verify_no_packet( self, pkt, in_port ) |
| 1294 | continue |
| 1295 | verify_packet( self, pkt, out_port ) |
| 1296 | verify_no_other_packets( self ) |
| 1297 | finally: |
| 1298 | delete_all_flows( self.controller ) |
| 1299 | delete_groups( self.controller, Groups ) |
| 1300 | delete_all_groups( self.controller ) |
| 1301 | |
| 1302 | |
| 1303 | class L3McastToL2TagToUntag( base_tests.SimpleDataPlane ): |
| 1304 | """ |
| 1305 | Mcast routing, in this test case the traffic is tagged. |
| 1306 | 300 is used as vlan_id. The packet goes out |
| 1307 | untagged. |
| 1308 | """ |
| 1309 | def runTest( self ): |
| 1310 | Groups = Queue.LifoQueue( ) |
| 1311 | try: |
| 1312 | if len( config[ "port_map" ] ) < 2: |
| 1313 | logging.info( "Port count less than 2, can't run this case" ) |
| 1314 | assert (False) |
| 1315 | return |
| 1316 | ports = config[ "port_map" ].keys( ) |
| 1317 | dst_ip_str = "224.0.0.1" |
| 1318 | ( |
| 1319 | port_to_in_vlan, |
| 1320 | port_to_out_vlan, |
| 1321 | port_to_src_mac_str, |
| 1322 | port_to_dst_mac_str, |
| 1323 | port_to_src_ip_str, |
| 1324 | Groups) = fill_mcast_pipeline_L3toL2( |
| 1325 | self.controller, |
| 1326 | logging, |
| 1327 | ports, |
| 1328 | is_ingress_tagged = True, |
| 1329 | is_egress_tagged = False, |
| 1330 | is_vlan_translated = False, |
| 1331 | is_max_vlan = False |
| 1332 | ) |
| 1333 | |
| 1334 | for in_port in ports: |
| 1335 | |
| 1336 | parsed_pkt = simple_udp_packet( |
| 1337 | pktlen = 100, |
| 1338 | dl_vlan_enable = True, |
| 1339 | vlan_vid = port_to_in_vlan[in_port], |
| 1340 | eth_dst = port_to_dst_mac_str[in_port], |
| 1341 | eth_src = port_to_src_mac_str[in_port], |
| 1342 | ip_ttl = 64, |
| 1343 | ip_src = port_to_src_ip_str[in_port], |
| 1344 | ip_dst = dst_ip_str |
| 1345 | ) |
| 1346 | pkt = str( parsed_pkt ) |
| 1347 | self.dataplane.send( in_port, pkt ) |
| 1348 | |
| 1349 | for out_port in ports: |
| 1350 | |
| 1351 | parsed_pkt = simple_udp_packet( |
| 1352 | pktlen = 96, |
| 1353 | eth_dst = port_to_dst_mac_str[in_port], |
| 1354 | eth_src = port_to_src_mac_str[in_port], |
| 1355 | ip_ttl = 64, |
| 1356 | ip_src = port_to_src_ip_str[in_port], |
| 1357 | ip_dst = dst_ip_str |
| 1358 | ) |
| 1359 | pkt = str( parsed_pkt ) |
| 1360 | if out_port == in_port: |
| 1361 | verify_no_packet( self, pkt, in_port ) |
| 1362 | continue |
| 1363 | verify_packet( self, pkt, out_port ) |
| 1364 | verify_no_other_packets( self ) |
| 1365 | finally: |
| 1366 | delete_all_flows( self.controller ) |
| 1367 | delete_groups( self.controller, Groups ) |
| 1368 | delete_all_groups( self.controller ) |
| 1369 | |
| 1370 | class L3McastToL2TagToTag( base_tests.SimpleDataPlane ): |
| 1371 | """ |
| 1372 | Mcast routing, in this test case the traffic is tagged. |
| 1373 | 300 is used as vlan_id. The packet goes out tagged. |
| 1374 | """ |
| 1375 | def runTest( self ): |
| 1376 | Groups = Queue.LifoQueue( ) |
| 1377 | try: |
| 1378 | if len( config[ "port_map" ] ) < 2: |
| 1379 | logging.info( "Port count less than 2, can't run this case" ) |
| 1380 | assert (False) |
| 1381 | return |
| 1382 | ports = config[ "port_map" ].keys( ) |
| 1383 | dst_ip_str = "224.0.0.1" |
| 1384 | ( |
| 1385 | port_to_in_vlan, |
| 1386 | port_to_out_vlan, |
| 1387 | port_to_src_mac_str, |
| 1388 | port_to_dst_mac_str, |
| 1389 | port_to_src_ip_str, |
| 1390 | Groups) = fill_mcast_pipeline_L3toL2( |
| 1391 | self.controller, |
| 1392 | logging, |
| 1393 | ports, |
| 1394 | is_ingress_tagged = True, |
| 1395 | is_egress_tagged = True, |
| 1396 | is_vlan_translated = False, |
| 1397 | is_max_vlan = False |
| 1398 | ) |
| 1399 | |
| 1400 | for in_port in ports: |
| 1401 | |
| 1402 | parsed_pkt = simple_udp_packet( |
| 1403 | pktlen = 100, |
| 1404 | dl_vlan_enable = True, |
| 1405 | vlan_vid = port_to_in_vlan[in_port], |
| 1406 | eth_dst = port_to_dst_mac_str[in_port], |
| 1407 | eth_src = port_to_src_mac_str[in_port], |
| 1408 | ip_ttl = 64, |
| 1409 | ip_src = port_to_src_ip_str[in_port], |
| 1410 | ip_dst = dst_ip_str |
| 1411 | ) |
| 1412 | pkt = str( parsed_pkt ) |
| 1413 | self.dataplane.send( in_port, pkt ) |
| 1414 | |
| 1415 | for out_port in ports: |
| 1416 | |
| 1417 | parsed_pkt = simple_udp_packet( |
| 1418 | pktlen = 100, |
| 1419 | dl_vlan_enable = True, |
| 1420 | vlan_vid = port_to_in_vlan[in_port], |
| 1421 | eth_dst = port_to_dst_mac_str[in_port], |
| 1422 | eth_src = port_to_src_mac_str[in_port], |
| 1423 | ip_ttl = 64, |
| 1424 | ip_src = port_to_src_ip_str[in_port], |
| 1425 | ip_dst = dst_ip_str |
| 1426 | ) |
| 1427 | pkt = str( parsed_pkt ) |
| 1428 | if out_port == in_port: |
| 1429 | verify_no_packet( self, pkt, in_port ) |
| 1430 | continue |
| 1431 | verify_packet( self, pkt, out_port ) |
| 1432 | verify_no_other_packets( self ) |
| 1433 | finally: |
| 1434 | delete_all_flows( self.controller ) |
| 1435 | delete_groups( self.controller, Groups ) |
| 1436 | delete_all_groups( self.controller ) |
| 1437 | |
| 1438 | class L3McastToL2TagToTagTranslated( base_tests.SimpleDataPlane ): |
| 1439 | """ |
| 1440 | Mcast routing, in this test case the traffic is tagged. |
| 1441 | port+1 is used as ingress vlan_id. The packet goes out |
| 1442 | tagged. 4094-port is used as egress vlan_id |
| 1443 | """ |
| 1444 | def runTest( self ): |
| 1445 | Groups = Queue.LifoQueue( ) |
| 1446 | try: |
| 1447 | if len( config[ "port_map" ] ) < 2: |
| 1448 | logging.info( "Port count less than 2, can't run this case" ) |
| 1449 | assert (False) |
| 1450 | return |
| 1451 | ports = config[ "port_map" ].keys( ) |
| 1452 | dst_ip_str = "224.0.0.1" |
| 1453 | ( |
| 1454 | port_to_in_vlan, |
| 1455 | port_to_out_vlan, |
| 1456 | port_to_src_mac_str, |
| 1457 | port_to_dst_mac_str, |
| 1458 | port_to_src_ip_str, |
| 1459 | Groups) = fill_mcast_pipeline_L3toL2( |
| 1460 | self.controller, |
| 1461 | logging, |
| 1462 | ports, |
| 1463 | is_ingress_tagged = True, |
| 1464 | is_egress_tagged = True, |
| 1465 | is_vlan_translated = True, |
| 1466 | is_max_vlan = False |
| 1467 | ) |
| 1468 | |
| 1469 | for in_port in ports: |
| 1470 | |
| 1471 | parsed_pkt = simple_udp_packet( |
| 1472 | pktlen = 100, |
| 1473 | dl_vlan_enable = True, |
| 1474 | vlan_vid = port_to_in_vlan[in_port], |
| 1475 | eth_dst = port_to_dst_mac_str[in_port], |
| 1476 | eth_src = port_to_src_mac_str[in_port], |
| 1477 | ip_ttl = 64, |
| 1478 | ip_src = port_to_src_ip_str[in_port], |
| 1479 | ip_dst = dst_ip_str |
| 1480 | ) |
| 1481 | pkt = str( parsed_pkt ) |
| 1482 | self.dataplane.send( in_port, pkt ) |
| 1483 | |
| 1484 | for out_port in ports: |
| 1485 | |
| 1486 | parsed_pkt = simple_udp_packet( |
| 1487 | pktlen = 100, |
| 1488 | dl_vlan_enable = True, |
| 1489 | vlan_vid = port_to_out_vlan[in_port], |
| 1490 | eth_dst = port_to_dst_mac_str[in_port], |
| 1491 | eth_src = port_to_src_mac_str[in_port], |
| 1492 | ip_ttl = 64, |
| 1493 | ip_src = port_to_src_ip_str[in_port], |
| 1494 | ip_dst = dst_ip_str |
| 1495 | ) |
| 1496 | pkt = str( parsed_pkt ) |
| 1497 | if out_port == in_port: |
| 1498 | verify_no_packet( self, pkt, in_port ) |
| 1499 | continue |
| 1500 | verify_packet( self, pkt, out_port ) |
| 1501 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1502 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1503 | delete_all_flows( self.controller ) |
| 1504 | delete_groups( self.controller, Groups ) |
| 1505 | delete_all_groups( self.controller ) |
| 1506 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame^] | 1507 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1508 | class _MplsFwd( base_tests.SimpleDataPlane ): |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame^] | 1509 | """ Verify basic MPLS forwarding: Label switch router """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1510 | |
| 1511 | def runTest( self ): |
| 1512 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1513 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1514 | if len( config[ "port_map" ] ) < 2: |
| 1515 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1516 | return |
| 1517 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1518 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1519 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1520 | # 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] | 1521 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1522 | for port in ports: |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1523 | # Shift MPLS label and VLAN ID by 16 to avoid reserved values |
| 1524 | vlan_id = port + 16 |
| 1525 | mpls_label = port + 16 |
| 1526 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1527 | # add l2 interface group |
| 1528 | id = port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1529 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False ) |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1530 | dst_mac[ 5 ] = port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1531 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| 1532 | vlan_id, id ) |
| 1533 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| 1534 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_SWAP_LABEL, index=id, ref_gid=mpls_gid, |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1535 | push_mpls_header=False, set_mpls_label=mpls_label, set_bos=1 ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame^] | 1536 | #ecmp_gid, ecmp_msg = add_mpls_forwarding_group( self.controller, |
| 1537 | # subtype=OFDPA_MPLS_GROUP_SUBTYPE_ECMP, index=id, ref_gids=[mpls_label_gid] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1538 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 1539 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1540 | # add termination flow |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1541 | add_termination_flow( self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24 ) |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 1542 | #add_mpls_flow( self.controller, ecmp_gid, port, goto_table=29 ) |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1543 | add_mpls_flow( self.controller, mpls_label_gid, mpls_label, goto_table=29 ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1544 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1545 | Groups._put( l2_gid ) |
| 1546 | Groups._put( mpls_gid ) |
| 1547 | Groups._put( mpls_label_gid ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame^] | 1548 | #Groups._put( ecmp_gid ) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1549 | do_barrier( self.controller ) |
castroflavio | 30c6cc5 | 2016-01-07 15:19:42 -0800 | [diff] [blame] | 1550 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1551 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1552 | for in_port in ports: |
| 1553 | ip_src = '192.168.%02d.1' % (in_port) |
| 1554 | for out_port in ports: |
| 1555 | if in_port == out_port: |
| 1556 | continue |
Flavio Castro | 5494794 | 2016-02-03 16:05:20 -0500 | [diff] [blame] | 1557 | |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1558 | # Shift MPLS label and VLAN ID by 16 to avoid reserved values |
| 1559 | out_mpls_label = out_port + 16 |
| 1560 | in_vlan_vid = in_port + 16 |
| 1561 | out_vlan_vid = out_port + 16 |
| 1562 | |
| 1563 | ip_dst = '192.168.%02d.1' % (out_port) |
| 1564 | label = (out_mpls_label, 0, 1, 32) |
| 1565 | parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(in_vlan_vid), |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1566 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] ) |
| 1567 | pkt = str( parsed_pkt ) |
| 1568 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 5494794 | 2016-02-03 16:05:20 -0500 | [diff] [blame] | 1569 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1570 | # build expect packet |
| 1571 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1572 | label = (out_mpls_label, 0, 1, 31) |
| 1573 | exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_vlan_vid), |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1574 | ip_src=ip_src, ip_dst=ip_dst, eth_src=switch_mac, eth_dst=mac_dst, |
| 1575 | label=[ label ] ) |
| 1576 | pkt = str( exp_pkt ) |
| 1577 | verify_packet( self, pkt, out_port ) |
| 1578 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1579 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1580 | delete_all_flows( self.controller ) |
| 1581 | delete_groups( self.controller, Groups ) |
| 1582 | delete_all_groups( self.controller ) |
Flavio Castro | b702a2f | 2016-04-10 22:01:48 -0400 | [diff] [blame] | 1583 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame^] | 1584 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1585 | class _MplsTermination( base_tests.SimpleDataPlane ): |
Flavio Castro | 76c5b26 | 2016-07-27 19:53:00 -0700 | [diff] [blame] | 1586 | """ Verify MPLS VPN Termination at penultimate hop """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1587 | |
| 1588 | def runTest( self ): |
| 1589 | Groups = Queue.LifoQueue( ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1590 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1591 | if len( config[ "port_map" ] ) < 2: |
| 1592 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1593 | return |
| 1594 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1595 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1596 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1597 | # 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] | 1598 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1599 | for port in ports: |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1600 | # Shift MPLS label and VLAN ID by 16 to avoid reserved values |
| 1601 | vlan_id = port + 16 |
| 1602 | mpls_label = port + 16 |
| 1603 | |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1604 | # add l2 interface group |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1605 | id, dst_mac[ 5 ] = port, port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1606 | 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] | 1607 | # add L3 Unicast group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1608 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id, |
| 1609 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1610 | # add L3 ecmp group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1611 | 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] | 1612 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 1613 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1614 | # add termination flow |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1615 | add_termination_flow( self.controller, port, 0x8847, intf_src_mac, vlan_id, goto_table=24 ) |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1616 | add_mpls_flow( self.controller, ecmp_msg.group_id, mpls_label ) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1617 | # add_mpls_flow(self.controller, label=port) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1618 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1619 | # add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffff00, |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1620 | # ecmp_msg.group_id, 1) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1621 | Groups._put( l2_gid ) |
| 1622 | Groups._put( l3_msg.group_id ) |
| 1623 | Groups._put( ecmp_msg.group_id ) |
| 1624 | do_barrier( self.controller ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1625 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1626 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1627 | for in_port in ports: |
| 1628 | ip_src = '192.168.%02d.1' % (in_port) |
| 1629 | for out_port in ports: |
| 1630 | if in_port == out_port: |
| 1631 | continue |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1632 | |
| 1633 | # Shift MPLS label and VLAN ID by 16 to avoid reserved values |
| 1634 | out_mpls_label = out_port + 16 |
| 1635 | in_vlan_vid = in_port + 16 |
| 1636 | out_vlan_vid = out_port + 16 |
| 1637 | |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1638 | ip_dst = '192.168.%02d.1' % (out_port) |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1639 | label = (out_mpls_label, 0, 1, 32) |
| 1640 | parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(in_vlan_vid), |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1641 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] ) |
| 1642 | pkt = str( parsed_pkt ) |
| 1643 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1644 | # build expect packet |
| 1645 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1646 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(out_vlan_vid), |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1647 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst ) |
| 1648 | pkt = str( exp_pkt ) |
| 1649 | verify_packet( self, pkt, out_port ) |
| 1650 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1651 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1652 | delete_all_flows( self.controller ) |
| 1653 | delete_groups( self.controller, Groups ) |
| 1654 | delete_all_groups( self.controller ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame^] | 1655 | print("Done") |
| 1656 | |
| 1657 | @disabled |
| 1658 | class One_MplsTermination( base_tests.SimpleDataPlane ): |
| 1659 | """ |
| 1660 | Verify MPLS VPN Termination at penultimate hop in only one direction |
| 1661 | """ |
| 1662 | |
| 1663 | def runTest( self ): |
| 1664 | Groups = Queue.LifoQueue( ) |
| 1665 | try: |
| 1666 | if len( config[ "port_map" ] ) < 2: |
| 1667 | logging.info( "Port count less than 2, can't run this case" ) |
| 1668 | return |
| 1669 | dip = 0xc0a80001 |
| 1670 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1671 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 1672 | # Assigns unique hardcoded test_id to make sure tests don't overlap when writing rules |
| 1673 | ports = config[ "port_map" ].keys( ) |
| 1674 | inport = ports[0] |
| 1675 | outport = ports[1] |
| 1676 | |
| 1677 | # Shift MPLS label and VLAN ID by 16 to avoid reserved values |
| 1678 | invlan_id = inport + 16 |
| 1679 | outvlan_id = outport + 16 |
| 1680 | mpls_label = outport + 16 |
| 1681 | |
| 1682 | # add l2 interface group |
| 1683 | id, dst_mac[ 5 ] = inport, outport |
| 1684 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, outport, outvlan_id, True, False ) |
| 1685 | # add L3 Unicast group |
| 1686 | l3_msg = add_l3_unicast_group( self.controller, outport, vlanid=outvlan_id, id=id, |
| 1687 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
| 1688 | # add L3 ecmp group |
| 1689 | ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] ) |
| 1690 | # add vlan flow table |
| 1691 | add_one_vlan_table_flow( self.controller, inport, 1, invlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 1692 | # add tmac flow |
| 1693 | add_termination_flow( self.controller, inport, 0x8847, intf_src_mac, invlan_id, goto_table=24 ) |
| 1694 | # add mpls termination flow |
| 1695 | add_mpls_flow( self.controller, ecmp_msg.group_id, mpls_label, send_barrier=True ) |
| 1696 | Groups._put( l2_gid ) |
| 1697 | Groups._put( l3_msg.group_id ) |
| 1698 | Groups._put( ecmp_msg.group_id ) |
| 1699 | |
| 1700 | time.sleep(0.1) |
| 1701 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| 1702 | ip_src = '192.168.%02d.1' % (inport) |
| 1703 | # Shift MPLS label and VLAN ID by 16 to avoid reserved values |
| 1704 | out_mpls_label = outport + 16 |
| 1705 | in_vlan_vid = inport + 16 |
| 1706 | out_vlan_vid = outport + 16 |
| 1707 | |
| 1708 | ip_dst = '192.168.%02d.1' % (outport) |
| 1709 | label = (out_mpls_label, 0, 1, 32) |
| 1710 | parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(in_vlan_vid), |
| 1711 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] ) |
| 1712 | pkt = str( parsed_pkt ) |
| 1713 | self.dataplane.send( inport, pkt ) |
| 1714 | # build expect packet |
| 1715 | mac_dst = '00:00:00:22:22:%02X' % (outport) |
| 1716 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(out_vlan_vid), |
| 1717 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst ) |
| 1718 | pkt = str( exp_pkt ) |
| 1719 | verify_packet( self, pkt, outport ) |
| 1720 | verify_no_other_packets( self ) |
| 1721 | finally: |
| 1722 | delete_all_flows( self.controller ) |
| 1723 | delete_groups( self.controller, Groups ) |
| 1724 | delete_all_groups( self.controller ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1725 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1726 | |
| 1727 | class _24UcastTagged( base_tests.SimpleDataPlane ): |
Flavio Castro | 76c5b26 | 2016-07-27 19:53:00 -0700 | [diff] [blame] | 1728 | """ Verify /24 IP forwarding to L3 Interface """ |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1729 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1730 | def runTest( self ): |
| 1731 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1732 | try: |
| 1733 | test_id = 26 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1734 | if len( config[ "port_map" ] ) < 2: |
| 1735 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1736 | return |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1737 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1738 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1739 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1740 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1741 | for port in ports: |
| 1742 | # add l2 interface group |
| 1743 | vlan_id = port + test_id |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1744 | l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, |
| 1745 | is_tagged=True, send_barrier=False ) |
| 1746 | dst_mac[ 5 ] = vlan_id |
| 1747 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id, |
| 1748 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1749 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 1750 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1751 | # add termination flow |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1752 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1753 | # add unicast routing flow |
| 1754 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1755 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, l3_msg.group_id ) |
| 1756 | Groups.put( l2gid ) |
| 1757 | Groups.put( l3_msg.group_id ) |
| 1758 | do_barrier( self.controller ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1759 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1760 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1761 | for in_port in ports: |
| 1762 | mac_src = '00:00:00:22:22:%02X' % (test_id + in_port) |
| 1763 | ip_src = '192.168.%02d.1' % (test_id + in_port) |
| 1764 | for out_port in ports: |
| 1765 | if in_port == out_port: |
| 1766 | continue |
| 1767 | ip_dst = '192.168.%02d.1' % (test_id + out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1768 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, |
| 1769 | vlan_vid=(test_id + in_port), eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, |
| 1770 | ip_src=ip_src, ip_dst=ip_dst ) |
| 1771 | pkt = str( parsed_pkt ) |
| 1772 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1773 | # build expected packet |
| 1774 | mac_dst = '00:00:00:22:22:%02X' % (test_id + out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1775 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, |
| 1776 | vlan_vid=(test_id + out_port), eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, |
| 1777 | ip_src=ip_src, ip_dst=ip_dst ) |
| 1778 | pkt = str( exp_pkt ) |
| 1779 | verify_packet( self, pkt, out_port ) |
| 1780 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1781 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1782 | delete_all_flows( self.controller ) |
| 1783 | delete_groups( self.controller, Groups ) |
| 1784 | delete_all_groups( self.controller ) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 1785 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1786 | |
| 1787 | class _0Ucast( base_tests.SimpleDataPlane ): |
Flavio Castro | 76c5b26 | 2016-07-27 19:53:00 -0700 | [diff] [blame] | 1788 | """ Verify default gateway IP forwarding to L3 Interface ( /0 rule ) """ |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 1789 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1790 | def runTest( self ): |
| 1791 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1792 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1793 | if len( config[ "port_map" ] ) < 2: |
| 1794 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1795 | return |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 1796 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1797 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1798 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1799 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1800 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1801 | for port in ports: |
| 1802 | # add l2 interface group |
| 1803 | vlan_id = port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1804 | l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id + 1, |
| 1805 | is_tagged=True, send_barrier=False ) |
| 1806 | dst_mac[ 5 ] = vlan_id |
| 1807 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id + 1, id=vlan_id, |
| 1808 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1809 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 1810 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1811 | # add termination flow |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1812 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1813 | # add unicast routing flow |
| 1814 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1815 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id ) |
| 1816 | Groups.put( l2gid ) |
| 1817 | Groups.put( l3_msg.group_id ) |
| 1818 | l3_gid = encode_l3_unicast_group_id( ports[ 0 ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1819 | dst_ip = 0x0 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1820 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0x0, l3_gid ) |
| 1821 | do_barrier( self.controller ) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 1822 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1823 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1824 | for in_port in ports: |
| 1825 | mac_src = '00:00:00:22:22:%02X' % (in_port) |
| 1826 | ip_src = '192.168.%02d.1' % (in_port) |
| 1827 | for out_port in ports: |
| 1828 | if in_port == out_port: |
| 1829 | continue |
| 1830 | ip_dst = '192.168.%02d.1' % (out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1831 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port), |
| 1832 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 1833 | pkt = str( parsed_pkt ) |
| 1834 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1835 | # build expected packet |
| 1836 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1837 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(out_port + 1), |
| 1838 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst ) |
| 1839 | pkt = str( exp_pkt ) |
| 1840 | verify_packet( self, pkt, out_port ) |
| 1841 | verify_no_other_packets( self ) |
| 1842 | ip_dst = '1.168.%02d.1' % ports[ 0 ] |
| 1843 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| 1844 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 1845 | pkt = str( parsed_pkt ) |
| 1846 | self.dataplane.send( in_port, pkt ) |
| 1847 | # build expect packet |
| 1848 | mac_dst = '00:00:00:22:22:%02X' % ports[ 0 ] |
| 1849 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ] + 1, |
| 1850 | ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac ) |
| 1851 | pkt = str( exp_pkt ) |
| 1852 | verify_packet( self, pkt, ports[ 0 ] ) |
| 1853 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1854 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1855 | delete_all_flows( self.controller ) |
| 1856 | delete_groups( self.controller, Groups ) |
| 1857 | delete_all_groups( self.controller ) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 1858 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1859 | |
| 1860 | class Unfiltered( base_tests.SimpleDataPlane ): |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1861 | """ |
Flavio Castro | 76c5b26 | 2016-07-27 19:53:00 -0700 | [diff] [blame] | 1862 | Attempt to add an unfiltered group: [ATTENTION] this doesn't verify addition |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1863 | """ |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 1864 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1865 | def runTest( self ): |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1866 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1867 | ports = sorted( config[ "port_map" ].keys( ) ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1868 | vlan_id = 1; |
| 1869 | for port in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1870 | add_l2_unfiltered_group( self.controller, [ port ], False ) |
| 1871 | do_barrier( self.controller ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1872 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1873 | delete_all_flows( self.controller ) |
| 1874 | delete_all_groups( self.controller ) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 1875 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame^] | 1876 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1877 | class L3McastToVPN( base_tests.SimpleDataPlane ): |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1878 | """ |
Flavio Castro | 76c5b26 | 2016-07-27 19:53:00 -0700 | [diff] [blame] | 1879 | Mcast routing and VPN initiation |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1880 | """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1881 | |
| 1882 | def runTest( self ): |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1883 | """ |
| 1884 | port1 (vlan 1)-> port 2 (vlan 2) |
| 1885 | """ |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1886 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1887 | delete_all_flows( self.controller ) |
| 1888 | delete_all_groups( self.controller ) |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1889 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1890 | if len( config[ "port_map" ] ) < 3: |
| 1891 | logging.info( "Port count less than 3, can't run this case" ) |
| 1892 | assert (False) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1893 | return |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1894 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1895 | vlan_id = 1 |
| 1896 | port2_out_vlan = 2 |
| 1897 | port3_out_vlan = 3 |
| 1898 | in_vlan = 1 # macast group vid shall use input vlan diffe from l3 interface use output vlan |
| 1899 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1900 | intf_src_mac_str = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| 1901 | dst_mac = [ 0x01, 0x00, 0x5e, 0x01, 0x01, 0x01 ] |
| 1902 | dst_mac_str = ':'.join( [ '%02X' % x for x in dst_mac ] ) |
| 1903 | port1_mac = [ 0x00, 0x11, 0x11, 0x11, 0x11, 0x11 ] |
| 1904 | port1_mac_str = ':'.join( [ '%02X' % x for x in port1_mac ] ) |
| 1905 | src_ip = 0xc0a80101 |
| 1906 | src_ip_str = "192.168.1.1" |
| 1907 | dst_ip = 0xe0010101 |
| 1908 | dst_ip_str = "224.1.1.1" |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1909 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1910 | port1 = config[ "port_map" ].keys( )[ 0 ] |
| 1911 | port2 = config[ "port_map" ].keys( )[ 1 ] |
| 1912 | # port3=config["port_map"].keys()[2] |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1913 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1914 | # add l2 interface group |
| 1915 | for port in config[ "port_map" ].keys( ): |
| 1916 | add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, is_tagged=False, |
| 1917 | send_barrier=False ) |
| 1918 | # add vlan flow table |
| 1919 | add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 1920 | vlan_id += 1 |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1921 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1922 | # add termination flow |
| 1923 | add_termination_flow( self.controller, port1, 0x0800, [ 0x01, 0x00, 0x5e, 0x00, 0x00, 0x00 ], |
| 1924 | vlan_id ) |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1925 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1926 | # add MPLS interface group |
| 1927 | l2_gid = encode_l2_interface_group_id( port2_out_vlan, port2 ) |
| 1928 | mpls_gid2, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| 1929 | port2_out_vlan, port2 ) |
| 1930 | # l2_gid3 = encode_l2_interface_group_id(port3_out_vlan, port3) |
| 1931 | # mpls_gid3, mpls_msg = add_mpls_intf_group(self.controller, l2_gid3, dst_mac, intf_src_mac, port3_out_vlan, port3) |
| 1932 | # add L3VPN groups |
| 1933 | mpls_label_gid2, mpls_label_msg = add_mpls_label_group( self.controller, |
| 1934 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=(0x20000 + port2), ref_gid=mpls_gid2, |
| 1935 | push_mpls_header=True, set_mpls_label=port2, set_bos=1, cpy_ttl_outward=True ) |
| 1936 | # 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] | 1937 | # 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] | 1938 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1939 | mcat_group_msg = add_l3_mcast_group( self.controller, in_vlan, 2, [ mpls_label_gid2 ] ) |
| 1940 | 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] | 1941 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1942 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=1, eth_dst=dst_mac_str, |
| 1943 | eth_src=port1_mac_str, ip_ttl=64, ip_src=src_ip_str, ip_dst=dst_ip_str ) |
| 1944 | pkt = str( parsed_pkt ) |
| 1945 | self.dataplane.send( port1, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1946 | label = (12, 0, 1, 63) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1947 | exp_pkt = mpls_packet( pktlen=100, eth_dst=dst_mac_str, eth_src=intf_src_mac_str, ip_ttl=64, |
| 1948 | ip_src=src_ip_str, label=[ label ], ip_dst=dst_ip_str ) |
| 1949 | pkt = str( exp_pkt ) |
| 1950 | verify_packet( self, pkt, port2 ) |
| 1951 | # verify_packet(self, pkt, port3) |
| 1952 | verify_no_other_packets( self ) |
| 1953 | delete_all_groups( self.controller ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1954 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1955 | delete_all_flows( self.controller ) |
| 1956 | delete_all_groups( self.controller ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1957 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame^] | 1958 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1959 | class PacketInSrcMacMiss( base_tests.SimpleDataPlane ): |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1960 | """ |
| 1961 | Test packet in function on a src-mac miss |
| 1962 | Send a packet to each dataplane port and verify that a packet |
| 1963 | in message is received from the controller for each |
| 1964 | #todo verify you stop receiving after adding rule |
| 1965 | """ |
| 1966 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1967 | def runTest( self ): |
| 1968 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1969 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1970 | ports = sorted( config[ "port_map" ].keys( ) ) |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1971 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1972 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1973 | for port in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1974 | L2gid, l2msg = add_one_l2_interface_group( self.controller, port, 1, True, False ) |
| 1975 | add_one_vlan_table_flow( self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 1976 | Groups.put( L2gid ) |
| 1977 | parsed_vlan_pkt = simple_tcp_packet( pktlen=104, vlan_vid=0x1001, dl_vlan_enable=True ) |
| 1978 | vlan_pkt = str( parsed_vlan_pkt ) |
| 1979 | for of_port in config[ "port_map" ].keys( ): |
| 1980 | logging.info( "PacketInMiss test, port %d", of_port ) |
| 1981 | self.dataplane.send( of_port, vlan_pkt ) |
| 1982 | verify_packet_in( self, vlan_pkt, of_port, ofp.OFPR_NO_MATCH ) |
| 1983 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1984 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1985 | delete_all_flows( self.controller ) |
| 1986 | delete_all_groups( self.controller ) |
| 1987 | |
| 1988 | |
| 1989 | class EcmpGroupMod( base_tests.SimpleDataPlane ): |
| 1990 | """ |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame^] | 1991 | Verify referenced group can be modified by adding or removing buckets |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1992 | """ |
| 1993 | |
| 1994 | def runTest( self ): |
| 1995 | Groups = Queue.LifoQueue( ) |
| 1996 | try: |
| 1997 | if len( config[ "port_map" ] ) < 2: |
| 1998 | logging.info( "Port count less than 2, can't run this case" ) |
| 1999 | return |
| 2000 | |
| 2001 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 2002 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 2003 | dip = 0xc0a80001 |
| 2004 | # Hashes Test Name and uses it as id for installing unique groups |
| 2005 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 2006 | ecmp = [ ] |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame^] | 2007 | dst_ips = [] |
| 2008 | # add flows for all ports but include only the egress switchport (connected to ports[1]) |
| 2009 | # in the ecmp group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2010 | for port in ports: |
| 2011 | vlan_id = port |
| 2012 | id = port |
| 2013 | # add l2 interface group |
| 2014 | l2_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, |
| 2015 | is_tagged=True, send_barrier=False ) |
| 2016 | dst_mac[ 5 ] = vlan_id |
| 2017 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id, |
| 2018 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame^] | 2019 | if port == ports[1]: |
| 2020 | ecmp += [ l3_msg.group_id ] |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2021 | Groups._put( l2_gid ) |
| 2022 | Groups._put( l3_msg.group_id ) |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 2023 | ecmp_msg = add_l3_ecmp_group( self.controller, ports[ 0 ], [ l3_msg.group_id ] ) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2024 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 2025 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2026 | # add termination flow |
| 2027 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
| 2028 | # add unicast routing flow |
| 2029 | dst_ip = dip + (vlan_id << 8) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame^] | 2030 | dst_ips += [dst_ip] |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2031 | Groups._put( ecmp_msg.group_id ) |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 2032 | mod_l3_ecmp_group( self.controller, ports[ 0 ], ecmp ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame^] | 2033 | for dst_ip in dst_ips: |
| 2034 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id ) |
| 2035 | time.sleep(0.1) |
| 2036 | # first part of the test: send packet from ingress switchport and expect it at egress switchport |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2037 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 2038 | parsed_pkt = exp_pkt = 0 |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame^] | 2039 | in_port = ports[0] |
| 2040 | out_port = ports[1] |
| 2041 | logging.info("\nSending packet to port: " + str(in_port) + ", expected egress on port: " + str(out_port)) |
| 2042 | mac_src = '00:00:00:22:22:%02X' % ports[ 0 ] |
| 2043 | ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1) |
| 2044 | ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1) |
| 2045 | tcp = out_port if out_port == 24 else 25 |
| 2046 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ], |
| 2047 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, |
| 2048 | ip_dst=ip_dst, tcp_dport=tcp ) |
| 2049 | pkt = str( parsed_pkt ) |
| 2050 | self.dataplane.send( ports[ 0 ], pkt ) |
| 2051 | # build expected packet at egress switchport |
| 2052 | mac_dst = '00:00:00:22:22:%02X' % out_port |
| 2053 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| 2054 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, |
| 2055 | ip_dst=ip_dst, tcp_dport=tcp ) |
| 2056 | pkt = str( exp_pkt ) |
| 2057 | verify_packet( self, pkt, out_port ) |
| 2058 | verify_no_other_packets( self ) |
| 2059 | |
| 2060 | # second part of the test - edit the ecmp group to remove the orginal egress switchport |
| 2061 | # and instead add the ingress switchport. Send packet from ingress switchport, and expect |
| 2062 | # it back on the ingress switchport |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 2063 | l3_gid = encode_l3_unicast_group_id( ports[ 0 ] ) |
| 2064 | mod_l3_ecmp_group( self.controller, ports[ 0 ], [ l3_gid ] ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame^] | 2065 | time.sleep(0.1) |
| 2066 | logging.info("Sending packet to port: " + str(ports[0]) + ", expected egress on port: " + str(ports[0])) |
| 2067 | mac_src = '00:00:00:22:22:%02X' % ports[ 0 ] |
| 2068 | ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1) |
| 2069 | ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1) |
| 2070 | tcp = port if port == 24 else 25 |
| 2071 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ], |
| 2072 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, |
| 2073 | ip_dst=ip_dst,tcp_dport=tcp ) |
| 2074 | pkt = str( parsed_pkt ) |
| 2075 | self.dataplane.send( ports[ 0 ], pkt ) |
| 2076 | # build expected packet |
| 2077 | mac_dst = '00:00:00:22:22:%02X' % ports[ 0 ] |
| 2078 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ], |
| 2079 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, |
| 2080 | ip_dst=ip_dst,tcp_dport=tcp ) |
| 2081 | pkt = str( exp_pkt ) |
| 2082 | verify_packet( self, pkt, ports[ 0 ] ) |
| 2083 | verify_no_other_packets( self ) |
| 2084 | |
| 2085 | # third part of the test - edit the group to completely remove bucket. Packet sent |
| 2086 | # should be dropped by the switch |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 2087 | mod_l3_ecmp_group( self.controller, ports[ 0 ], [ ] ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame^] | 2088 | time.sleep(0.1) |
| 2089 | logging.info("Sending packet to port: " + str(ports[0]) + ", expected drop") |
| 2090 | mac_src = '00:00:00:22:22:%02X' % ports[ 0 ] |
| 2091 | ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1) |
| 2092 | ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1) |
| 2093 | tcp = port if port == 24 else 25 |
| 2094 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ], |
| 2095 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, |
| 2096 | ip_dst=ip_dst,tcp_dport=tcp ) |
| 2097 | pkt = str( parsed_pkt ) |
| 2098 | self.dataplane.send( ports[ 0 ], pkt ) |
| 2099 | verify_no_other_packets( self ) |
| 2100 | |
| 2101 | # final part of the test - edit the empty group to add back the bucket for the |
| 2102 | # original egress port, and verify packet is received on egress switch port |
| 2103 | l3_gid = encode_l3_unicast_group_id( ports[ 1 ] ) |
| 2104 | mod_l3_ecmp_group( self.controller, ports[ 0 ], [ l3_gid ] ) |
| 2105 | time.sleep(0.1) |
| 2106 | in_port = ports[0] |
| 2107 | out_port = ports[1] |
| 2108 | logging.info("Sending packet to port: " + str(in_port) + ", expected egress on port: " + str(out_port)) |
| 2109 | mac_src = '00:00:00:22:22:%02X' % ports[ 0 ] |
| 2110 | ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1) |
| 2111 | ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1) |
| 2112 | tcp = out_port if out_port == 24 else 25 |
| 2113 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ], |
| 2114 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, |
| 2115 | ip_dst=ip_dst, tcp_dport=tcp ) |
| 2116 | pkt = str( parsed_pkt ) |
| 2117 | self.dataplane.send( ports[ 0 ], pkt ) |
| 2118 | # build expected packet at egress switchport |
| 2119 | mac_dst = '00:00:00:22:22:%02X' % out_port |
| 2120 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| 2121 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, |
| 2122 | ip_dst=ip_dst, tcp_dport=tcp ) |
| 2123 | pkt = str( exp_pkt ) |
| 2124 | verify_packet( self, pkt, out_port ) |
| 2125 | verify_no_other_packets( self ) |
| 2126 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2127 | finally: |
| 2128 | delete_all_flows( self.controller ) |
| 2129 | delete_groups( self.controller, Groups ) |
| 2130 | delete_all_groups( self.controller ) |
Pier | 8b22302 | 2016-08-19 22:47:49 -0700 | [diff] [blame] | 2131 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame^] | 2132 | |
Pier | 8b22302 | 2016-08-19 22:47:49 -0700 | [diff] [blame] | 2133 | class Untagged( base_tests.SimpleDataPlane ): |
| 2134 | """ |
| 2135 | Verify VLAN filtering table does not require OFPVID_PRESENT bit to be 0. |
| 2136 | This should be fixed in OFDPA 2.0 GA and above, the test fails with |
| 2137 | previous versions of the OFDPA. |
| 2138 | |
| 2139 | Two rules are necessary in VLAN table (10): |
| 2140 | 1) Assignment: match 0x0000/(no mask), set_vlan_vid 0x100A, goto 20 |
| 2141 | 2) Filtering: match 0x100A/0x1FFF, goto 20 |
| 2142 | |
| 2143 | In this test case vlan_id = (MAX_INTERNAL_VLAN - port_no). |
| 2144 | The remaining part of the test is based on the use of the bridging table |
| 2145 | """ |
| 2146 | |
| 2147 | MAX_INTERNAL_VLAN = 4094 |
| 2148 | |
| 2149 | def runTest( self ): |
| 2150 | groups = Queue.LifoQueue( ) |
| 2151 | try: |
| 2152 | if len( config[ "port_map" ] ) < 2: |
| 2153 | logging.info( "Port count less than 2, can't run this case" ) |
| 2154 | return |
| 2155 | |
| 2156 | ports = sorted( config[ "port_map" ].keys( ) ) |
| 2157 | for port in ports: |
| 2158 | vlan_id = Untagged.MAX_INTERNAL_VLAN - port |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 2159 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 2160 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_UNTAG ) |
Pier | 8b22302 | 2016-08-19 22:47:49 -0700 | [diff] [blame] | 2161 | for other_port in ports: |
| 2162 | if other_port == port: |
| 2163 | continue |
| 2164 | L2gid, l2msg = add_one_l2_interface_group( self.controller, other_port, vlan_id, False, False ) |
| 2165 | groups.put( L2gid ) |
| 2166 | add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, other_port ], vlan_id, L2gid, True ) |
| 2167 | |
| 2168 | do_barrier( self.controller ) |
| 2169 | |
| 2170 | for out_port in ports: |
| 2171 | # change dest based on port number |
| 2172 | mac_dst = '00:12:34:56:78:%02X' % out_port |
| 2173 | for in_port in ports: |
| 2174 | if in_port == out_port: |
| 2175 | continue |
| 2176 | pkt = str( simple_tcp_packet( eth_dst=mac_dst ) ) |
| 2177 | self.dataplane.send( in_port, pkt ) |
| 2178 | for ofport in ports: |
| 2179 | if ofport in [ out_port ]: |
| 2180 | verify_packet( self, pkt, ofport ) |
| 2181 | else: |
| 2182 | verify_no_packet( self, pkt, ofport ) |
| 2183 | verify_no_other_packets( self ) |
| 2184 | finally: |
| 2185 | delete_all_flows( self.controller ) |
Pier | f49f79b | 2016-08-25 15:12:04 -0700 | [diff] [blame] | 2186 | delete_groups( self.controller, groups ) |
Pier | 8b22302 | 2016-08-19 22:47:49 -0700 | [diff] [blame] | 2187 | delete_all_groups( self.controller ) |