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] |
Saurav Das | 1ab6a14 | 2017-04-25 14:42:25 -0700 | [diff] [blame^] | 588 | in_offset = 19 |
| 589 | out_offset = 20 |
| 590 | vlan_id = ports[1] + out_offset |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 591 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, ports[1], vlan_id, True, True ) |
Saurav Das | 1ab6a14 | 2017-04-25 14:42:25 -0700 | [diff] [blame^] | 592 | dst_mac[ 5 ] = ports[1] |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 593 | # add MPLS interface group |
| 594 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| 595 | vlan_id, id ) |
| 596 | # add MPLS L3 VPN group |
| 597 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| 598 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid, |
Saurav Das | 1ab6a14 | 2017-04-25 14:42:25 -0700 | [diff] [blame^] | 599 | push_mpls_header=True, set_mpls_label=ports[1] + out_offset, set_bos=1, set_ttl=32 ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 600 | # add ECMP group |
| 601 | ecmp_msg = add_l3_ecmp_group( self.controller, vlan_id, [ mpls_label_gid ] ) |
| 602 | do_barrier( self.controller ) |
| 603 | # add vlan flow table |
Saurav Das | 1ab6a14 | 2017-04-25 14:42:25 -0700 | [diff] [blame^] | 604 | add_one_vlan_table_flow( self.controller, ports[0], 1, vlan_id=ports[0] + in_offset, vrf=0, |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 605 | flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 606 | # add termination flow |
Saurav Das | 1ab6a14 | 2017-04-25 14:42:25 -0700 | [diff] [blame^] | 607 | add_termination_flow( self.controller, ports[0], 0x0800, intf_src_mac, vlanid=ports[0] + in_offset ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 608 | # add routing flow |
| 609 | dst_ip = dip + (vlan_id << 8) |
| 610 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id, send_barrier=True ) |
| 611 | Groups._put( l2_gid ) |
| 612 | Groups._put( mpls_gid ) |
| 613 | Groups._put( mpls_label_gid ) |
| 614 | Groups._put( ecmp_msg.group_id ) |
| 615 | |
| 616 | |
| 617 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| 618 | in_port = ports[0] |
| 619 | out_port = ports[1] |
| 620 | ip_src = '192.168.%02d.1' % (in_port) |
Saurav Das | 1ab6a14 | 2017-04-25 14:42:25 -0700 | [diff] [blame^] | 621 | ip_dst = '192.168.%02d.1' % (out_port+out_offset) |
| 622 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port + in_offset), |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 623 | eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 624 | pkt = str( parsed_pkt ) |
| 625 | self.dataplane.send( in_port, pkt ) |
| 626 | # build expect packet |
| 627 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
Saurav Das | 1ab6a14 | 2017-04-25 14:42:25 -0700 | [diff] [blame^] | 628 | label = (out_port+out_offset, 0, 1, 32) |
| 629 | exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port + out_offset), ip_ttl=63, |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 630 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, |
Saurav Das | 1ab6a14 | 2017-04-25 14:42:25 -0700 | [diff] [blame^] | 631 | label=[ label ] ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 632 | pkt = str( exp_pkt ) |
| 633 | verify_packet( self, pkt, out_port ) |
| 634 | #verify_no_other_packets( self ) |
| 635 | |
| 636 | finally: |
| 637 | delete_all_flows( self.controller ) |
| 638 | delete_group(self.controller, ecmp_msg.group_id) |
| 639 | delete_group(self.controller, mpls_label_gid) |
| 640 | delete_group(self.controller, mpls_gid) |
| 641 | delete_group(self.controller, l2_gid) |
| 642 | |
| 643 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 644 | class _32ECMPL3( base_tests.SimpleDataPlane ): |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 645 | """ |
| 646 | Verifies /32 IP routing and ECMP with no label push |
| 647 | IP -> L3ECMP -> L3Unicast -> L2Interface |
| 648 | """ |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 649 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 650 | def runTest( self ): |
| 651 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 652 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 653 | if len( config[ "port_map" ] ) < 2: |
| 654 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 655 | return |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 656 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 657 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 658 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 659 | dip = 0xc0a80001 |
| 660 | # Hashes Test Name and uses it as id for installing unique groups |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 661 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 662 | for port in ports: |
| 663 | vlan_id = port |
| 664 | id = port |
| 665 | # add l2 interface group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 666 | l2_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, |
| 667 | is_tagged=True, send_barrier=False ) |
| 668 | dst_mac[ 5 ] = vlan_id |
| 669 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id, |
| 670 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
| 671 | 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] | 672 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 673 | 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] | 674 | # add termination flow |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 675 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 676 | # add unicast routing flow |
| 677 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 678 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id ) |
| 679 | Groups._put( l2_gid ) |
| 680 | Groups._put( l3_msg.group_id ) |
| 681 | Groups._put( ecmp_msg.group_id ) |
| 682 | do_barrier( self.controller ) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 683 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 684 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 685 | for in_port in ports: |
| 686 | mac_src = '00:00:00:22:22:%02X' % in_port |
| 687 | ip_src = '192.168.%02d.1' % in_port |
| 688 | for out_port in ports: |
| 689 | if in_port == out_port: |
| 690 | continue |
| 691 | ip_dst = '192.168.%02d.1' % out_port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 692 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| 693 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 694 | pkt = str( parsed_pkt ) |
| 695 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 696 | # build expected packet |
| 697 | mac_dst = '00:00:00:22:22:%02X' % out_port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 698 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| 699 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst ) |
| 700 | pkt = str( exp_pkt ) |
| 701 | verify_packet( self, pkt, out_port ) |
| 702 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 703 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 704 | delete_all_flows( self.controller ) |
| 705 | delete_groups( self.controller, Groups ) |
| 706 | delete_all_groups( self.controller ) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 707 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 708 | @disabled |
| 709 | class One_32ECMPL3( base_tests.SimpleDataPlane ): |
| 710 | """ |
| 711 | Verifies /32 IP routing and ECMP with no label push |
| 712 | IP -> L3ECMP -> L3Unicast -> L2Interface |
| 713 | in only one direction |
| 714 | """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 715 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 716 | def runTest( self ): |
| 717 | Groups = Queue.LifoQueue( ) |
| 718 | try: |
| 719 | if len( config[ "port_map" ] ) < 2: |
| 720 | logging.info( "Port count less than 2, can't run this case" ) |
| 721 | return |
| 722 | |
| 723 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 724 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 725 | dip = 0xc0a80001 |
| 726 | # Hashes Test Name and uses it as id for installing unique groups |
| 727 | ports = config[ "port_map" ].keys( ) |
| 728 | inport = ports[0] |
| 729 | outport = ports[1] |
Saurav Das | 1ab6a14 | 2017-04-25 14:42:25 -0700 | [diff] [blame^] | 730 | in_offset = 19 |
| 731 | out_offset = 20 |
| 732 | vlan_id = outport + out_offset |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 733 | id = outport |
| 734 | # add l2 interface group, l3 unicast and ecmp group for outport |
| 735 | l2_gid, msg = add_one_l2_interface_group( self.controller, outport, vlan_id=vlan_id, |
| 736 | is_tagged=True, send_barrier=False ) |
Saurav Das | 1ab6a14 | 2017-04-25 14:42:25 -0700 | [diff] [blame^] | 737 | dst_mac[ 5 ] = outport |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 738 | l3_msg = add_l3_unicast_group( self.controller, outport, vlanid=vlan_id, id=id, |
| 739 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
| 740 | ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] ) |
| 741 | # add vlan flow table |
Saurav Das | 1ab6a14 | 2017-04-25 14:42:25 -0700 | [diff] [blame^] | 742 | add_one_vlan_table_flow( self.controller, of_port=inport, vlan_id=inport+in_offset, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 743 | # add termination flow |
Saurav Das | 1ab6a14 | 2017-04-25 14:42:25 -0700 | [diff] [blame^] | 744 | add_termination_flow( self.controller, in_port=inport, eth_type=0x0800, dst_mac=intf_src_mac, vlanid=inport+in_offset ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 745 | # add unicast routing flow |
| 746 | dst_ip = dip + (vlan_id << 8) |
| 747 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, ecmp_msg.group_id, send_barrier=True ) |
| 748 | Groups._put( l2_gid ) |
| 749 | Groups._put( l3_msg.group_id ) |
| 750 | Groups._put( ecmp_msg.group_id ) |
| 751 | |
| 752 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| 753 | mac_src = '00:00:00:22:22:%02X' % inport |
| 754 | ip_src = '192.168.%02d.1' % inport |
Saurav Das | 1ab6a14 | 2017-04-25 14:42:25 -0700 | [diff] [blame^] | 755 | ip_dst = '192.168.%02d.1' % (outport+out_offset) |
| 756 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=inport+in_offset, |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 757 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 758 | pkt = str( parsed_pkt ) |
| 759 | self.dataplane.send( inport, pkt ) |
| 760 | # build expected packet |
| 761 | mac_dst = '00:00:00:22:22:%02X' % outport |
Saurav Das | 1ab6a14 | 2017-04-25 14:42:25 -0700 | [diff] [blame^] | 762 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=outport+out_offset, |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 763 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst ) |
| 764 | pkt = str( exp_pkt ) |
| 765 | verify_packet( self, pkt, outport ) |
| 766 | verify_no_other_packets( self ) |
| 767 | finally: |
| 768 | delete_all_flows( self.controller ) |
| 769 | delete_groups( self.controller, Groups ) |
| 770 | delete_all_groups( self.controller ) |
| 771 | |
| 772 | |
| 773 | |
| 774 | |
| 775 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 776 | class _24VPN( base_tests.SimpleDataPlane ): |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 777 | """ Verify MPLS IP VPN Initiation from /32 rule without using ECMP """ |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 778 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 779 | def runTest( self ): |
| 780 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 781 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 782 | if len( config[ "port_map" ] ) < 2: |
| 783 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 784 | return |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 785 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 786 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 787 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 788 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 789 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 790 | for port in ports: |
| 791 | # add l2 interface group |
| 792 | id = port |
| 793 | vlan_id = port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 794 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True ) |
| 795 | dst_mac[ 5 ] = vlan_id |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 796 | # add MPLS interface group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 797 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| 798 | vlan_id, id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 799 | # add MPLS L3 VPN group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 800 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| 801 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid, |
| 802 | 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] | 803 | # 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] | 804 | do_barrier( self.controller ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 805 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 806 | 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] | 807 | flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 808 | # add termination flow |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 809 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 810 | # add routing flow |
| 811 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 812 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, mpls_label_gid ) |
| 813 | Groups._put( l2_gid ) |
| 814 | Groups._put( mpls_gid ) |
| 815 | Groups._put( mpls_label_gid ) |
| 816 | do_barrier( self.controller ) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 817 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 818 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 819 | for in_port in ports: |
| 820 | ip_src = '192.168.%02d.1' % (in_port) |
| 821 | for out_port in ports: |
| 822 | if in_port == out_port: |
| 823 | continue |
| 824 | ip_dst = '192.168.%02d.1' % (out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 825 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port), |
| 826 | eth_dst=switch_mac, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 827 | pkt = str( parsed_pkt ) |
| 828 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 829 | # build expect packet |
| 830 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
| 831 | label = (out_port, 0, 1, 32) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 832 | exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63, |
| 833 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, |
| 834 | label=[ label ] ) |
| 835 | pkt = str( exp_pkt ) |
| 836 | verify_packet( self, pkt, out_port ) |
| 837 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 838 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 839 | delete_all_flows( self.controller ) |
| 840 | delete_groups( self.controller, Groups ) |
| 841 | delete_all_groups( self.controller ) |
Flavio Castro | 2262fd4 | 2016-02-04 19:03:36 -0500 | [diff] [blame] | 842 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 843 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 844 | class _24EcmpVpn( base_tests.SimpleDataPlane ): |
Flavio Castro | 76c5b26 | 2016-07-27 19:53:00 -0700 | [diff] [blame] | 845 | """ Verify MPLS IP VPN Initiation from /24 rule using ECMP """ |
Flavio Castro | 72a45d5 | 2015-12-02 16:37:05 -0500 | [diff] [blame] | 846 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 847 | def runTest( self ): |
| 848 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 849 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 850 | if len( config[ "port_map" ] ) < 2: |
| 851 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 852 | return |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 853 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 854 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 855 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 856 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 857 | for port in ports: |
| 858 | # add l2 interface group |
| 859 | id = port |
| 860 | vlan_id = id |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 861 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, True ) |
| 862 | dst_mac[ 5 ] = vlan_id |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 863 | # add MPLS interface group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 864 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| 865 | vlan_id, id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 866 | # add MPLS L3 VPN group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 867 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| 868 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=id, ref_gid=mpls_gid, |
| 869 | push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32 ) |
| 870 | ecmp_msg = add_l3_ecmp_group( self.controller, id, [ mpls_label_gid ] ) |
| 871 | do_barrier( self.controller ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 872 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 873 | 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] | 874 | flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 875 | # add termination flow |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 876 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 877 | # add routing flow |
| 878 | dst_ip = dip + (vlan_id << 8) |
| 879 | # 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] | 880 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id, |
| 881 | vrf=0 ) |
| 882 | Groups._put( l2_gid ) |
| 883 | Groups._put( mpls_gid ) |
| 884 | Groups._put( mpls_label_gid ) |
| 885 | Groups._put( ecmp_msg.group_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 886 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 887 | do_barrier( self.controller ) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 888 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 889 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 890 | for in_port in ports: |
| 891 | mac_src = '00:00:00:22:22:%02X' % (in_port) |
| 892 | ip_src = '192.168.%02d.1' % (in_port) |
| 893 | for out_port in ports: |
| 894 | if in_port == out_port: |
| 895 | continue |
| 896 | ip_dst = '192.168.%02d.1' % (out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 897 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port), |
| 898 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 899 | pkt = str( parsed_pkt ) |
| 900 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 901 | # build expect packet |
| 902 | mac_dst = '00:00:00:22:22:%02X' % out_port |
| 903 | label = (out_port, 0, 1, 32) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 904 | exp_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(out_port), ip_ttl=63, |
| 905 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, |
| 906 | label=[ label ] ) |
| 907 | pkt = str( exp_pkt ) |
| 908 | verify_packet( self, pkt, out_port ) |
| 909 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 910 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 911 | delete_all_flows( self.controller ) |
| 912 | delete_groups( self.controller, Groups ) |
| 913 | delete_all_groups( self.controller ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 914 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 915 | |
| 916 | class FloodGroupMod( base_tests.SimpleDataPlane ): |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 917 | """ Modify a referenced flood group """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 918 | |
| 919 | def runTest( self ): |
| 920 | Groups = Queue.LifoQueue( ) |
| 921 | try: |
| 922 | ports = sorted( config[ "port_map" ].keys( ) ) |
| 923 | vlan_id = 1 |
| 924 | |
| 925 | for port in ports: |
| 926 | L2gid, l2msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False ) |
| 927 | add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 928 | Groups.put( L2gid ) |
| 929 | |
| 930 | msg = add_l2_flood_group( self.controller, ports, vlan_id, vlan_id ) |
| 931 | Groups.put( msg.group_id ) |
| 932 | add_bridge_flow( self.controller, None, vlan_id, msg.group_id, True ) |
| 933 | do_barrier( self.controller ) |
| 934 | # verify flood |
| 935 | for ofport in ports: |
| 936 | # change dest based on port number |
| 937 | mac_src = '00:12:34:56:78:%02X' % ofport |
| 938 | parsed_pkt = simple_tcp_packet_two_vlan( pktlen=108, out_dl_vlan_enable=True, |
| 939 | out_vlan_vid=vlan_id, in_dl_vlan_enable=True, in_vlan_vid=10, |
| 940 | eth_dst='00:12:34:56:78:9a', eth_src=mac_src ) |
| 941 | pkt = str( parsed_pkt ) |
| 942 | self.dataplane.send( ofport, pkt ) |
| 943 | # self won't rx packet |
| 944 | verify_no_packet( self, pkt, ofport ) |
| 945 | # others will rx packet |
| 946 | tmp_ports = list( ports ) |
| 947 | tmp_ports.remove( ofport ) |
| 948 | verify_packets( self, pkt, tmp_ports ) |
| 949 | verify_no_other_packets( self ) |
| 950 | msg = mod_l2_flood_group( self.controller, [ ports[ 0 ] ], vlan_id, vlan_id ) |
| 951 | mac_src = '00:12:34:56:78:%02X' % ports[ 1 ] |
| 952 | parsed_pkt = simple_tcp_packet_two_vlan( pktlen=108, out_dl_vlan_enable=True, |
| 953 | out_vlan_vid=vlan_id, in_dl_vlan_enable=True, in_vlan_vid=10, eth_dst='00:12:34:56:78:9a', |
| 954 | eth_src=mac_src ) |
| 955 | pkt = str( parsed_pkt ) |
| 956 | self.dataplane.send( ports[ 1 ], pkt ) |
| 957 | verify_packets( self, pkt, [ ports[ 0 ] ] ) |
| 958 | finally: |
| 959 | delete_all_flows( self.controller ) |
| 960 | delete_groups( self.controller, Groups ) |
| 961 | delete_all_groups( self.controller ) |
| 962 | |
| 963 | |
| 964 | class _24ECMPL3( base_tests.SimpleDataPlane ): |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 965 | """ Verifies /24 IP routing using ECMP -> L3U -> L2I """ |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 966 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 967 | def runTest( self ): |
| 968 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 969 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 970 | if len( config[ "port_map" ] ) < 2: |
| 971 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 972 | return |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 973 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 974 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 975 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 976 | dip = 0xc0a80001 |
| 977 | # Hashes Test Name and uses it as id for installing unique groups |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 978 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 979 | for port in ports: |
| 980 | vlan_id = port |
| 981 | id = port |
| 982 | # add l2 interface group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 983 | l2_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, |
| 984 | is_tagged=True, send_barrier=False ) |
| 985 | dst_mac[ 5 ] = vlan_id |
| 986 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id, |
| 987 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
| 988 | 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] | 989 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 990 | 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] | 991 | # add termination flow |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 992 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 993 | # add unicast routing flow |
| 994 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 995 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id ) |
| 996 | Groups._put( l2_gid ) |
| 997 | Groups._put( l3_msg.group_id ) |
| 998 | Groups._put( ecmp_msg.group_id ) |
| 999 | do_barrier( self.controller ) |
Flavio Castro | 72a45d5 | 2015-12-02 16:37:05 -0500 | [diff] [blame] | 1000 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1001 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1002 | for in_port in ports: |
| 1003 | mac_src = '00:00:00:22:22:%02X' % in_port |
| 1004 | ip_src = '192.168.%02d.1' % in_port |
| 1005 | for out_port in ports: |
| 1006 | if in_port == out_port: |
| 1007 | continue |
| 1008 | ip_dst = '192.168.%02d.1' % out_port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1009 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| 1010 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 1011 | pkt = str( parsed_pkt ) |
| 1012 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1013 | # build expected packet |
| 1014 | mac_dst = '00:00:00:22:22:%02X' % out_port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1015 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| 1016 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst ) |
| 1017 | pkt = str( exp_pkt ) |
| 1018 | verify_packet( self, pkt, out_port ) |
| 1019 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1020 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1021 | delete_all_flows( self.controller ) |
| 1022 | delete_groups( self.controller, Groups ) |
| 1023 | delete_all_groups( self.controller ) |
| 1024 | |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1025 | |
Flavio Castro | aba28ff | 2016-02-03 16:47:48 -0500 | [diff] [blame] | 1026 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1027 | class MPLSBUG( base_tests.SimpleDataPlane ): |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 1028 | """ |
| 1029 | Needs a description or needs to be removed |
| 1030 | """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1031 | def runTest( self ): |
| 1032 | if len( config[ "port_map" ] ) < 2: |
| 1033 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 1034 | return |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1035 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1036 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1037 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1038 | Groups = Queue.LifoQueue( ) |
| 1039 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 1040 | for port in ports: |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1041 | # add l2 interface group |
| 1042 | vlan_id = port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1043 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, port, vlan_id, True, False ) |
| 1044 | dst_mac[ 5 ] = vlan_id |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1045 | # add L3 Unicast group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1046 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id, |
| 1047 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1048 | # add vlan flow table |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1049 | 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] | 1050 | # add termination flow |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1051 | 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] | 1052 | # add mpls flow |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1053 | add_mpls_flow( self.controller, l3_msg.group_id, port ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1054 | # add termination flow |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1055 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1056 | # add unicast routing flow |
| 1057 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1058 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id ) |
| 1059 | Groups._put( l2_gid ) |
| 1060 | Groups._put( l3_msg.group_id ) |
| 1061 | do_barrier( self.controller ) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 1062 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1063 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 1064 | for in_port in ports: |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1065 | mac_src = '00:00:00:22:22:%02X' % in_port |
| 1066 | ip_src = '192.168.%02d.1' % in_port |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 1067 | for out_port in ports: |
| 1068 | if in_port == out_port: |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1069 | continue |
| 1070 | ip_dst = '192.168.%02d.1' % out_port |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 1071 | switch_mac = "00:00:00:cc:cc:cc" |
| 1072 | label = (out_port, 0, 1, 32) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1073 | parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=in_port, ip_src=ip_src, |
| 1074 | ip_dst=ip_dst, eth_dst=switch_mac, eth_src=mac_src, label=[ label ] ) |
| 1075 | pkt = str( parsed_pkt ) |
| 1076 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8073082 | 2015-12-11 15:38:47 -0500 | [diff] [blame] | 1077 | |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1078 | # build expect packet |
| 1079 | mac_dst = '00:00:00:22:22:%02X' % out_port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1080 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| 1081 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst ) |
| 1082 | pkt = str( exp_pkt ) |
| 1083 | verify_packet( self, pkt, out_port ) |
| 1084 | verify_no_other_packets( self ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1085 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1086 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| 1087 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 1088 | pkt = str( parsed_pkt ) |
| 1089 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1090 | # build expected packet |
| 1091 | mac_dst = '00:00:00:22:22:%02X' % out_port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1092 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| 1093 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst ) |
| 1094 | pkt = str( exp_pkt ) |
| 1095 | verify_packet( self, pkt, out_port ) |
| 1096 | verify_no_other_packets( self ) |
| 1097 | delete_all_flows( self.controller ) |
| 1098 | delete_groups( self.controller, Groups ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1099 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1100 | class L3McastToL3( base_tests.SimpleDataPlane ): |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1101 | """ |
| 1102 | Mcast routing, in this test case the traffic comes in tagged. |
| 1103 | port+1 is used as ingress vlan_id. The packet goes out tagged on |
| 1104 | different ports. 4094-port is used as egress vlan_id. |
| 1105 | """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1106 | def runTest( self ): |
Pier | 7b031af | 2016-08-25 15:00:22 -0700 | [diff] [blame] | 1107 | """ |
| 1108 | port1 (vlan 300)-> All Ports (vlan 300) |
| 1109 | """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1110 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1111 | try: |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1112 | # We can forward on the in_port but egress_vlan has to be different from ingress_vlan |
| 1113 | if len( config[ "port_map" ] ) < 1: |
| 1114 | logging.info( "Port count less than 1, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1115 | assert (False) |
| 1116 | return |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1117 | ports = config[ "port_map" ].keys( ) |
| 1118 | dst_ip_str = "224.0.0.1" |
| 1119 | ( |
| 1120 | port_to_in_vlan, |
| 1121 | port_to_out_vlan, |
| 1122 | port_to_src_mac_str, |
| 1123 | port_to_dst_mac_str, |
| 1124 | port_to_src_ip_str, |
| 1125 | port_to_intf_src_mac_str, |
| 1126 | Groups) = fill_mcast_pipeline_L3toL3( |
| 1127 | self.controller, |
| 1128 | logging, |
| 1129 | ports, |
| 1130 | is_ingress_tagged = True, |
| 1131 | is_egress_tagged = True, |
| 1132 | is_vlan_translated = True, |
| 1133 | is_max_vlan = False |
| 1134 | ) |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 1135 | |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1136 | for in_port in ports: |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 1137 | |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1138 | parsed_pkt = simple_udp_packet( |
| 1139 | pktlen = 100, |
| 1140 | dl_vlan_enable = True, |
| 1141 | vlan_vid = port_to_in_vlan[in_port], |
| 1142 | eth_dst = port_to_dst_mac_str[in_port], |
| 1143 | eth_src = port_to_src_mac_str[in_port], |
| 1144 | ip_ttl = 64, |
| 1145 | ip_src = port_to_src_ip_str[in_port], |
| 1146 | ip_dst = dst_ip_str |
| 1147 | ) |
| 1148 | pkt = str( parsed_pkt ) |
| 1149 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 1150 | |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1151 | for out_port in ports: |
Flavio Castro | 1229631 | 2015-12-15 17:48:26 -0500 | [diff] [blame] | 1152 | |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1153 | parsed_pkt = simple_udp_packet( |
| 1154 | pktlen = 100, |
| 1155 | dl_vlan_enable = True, |
| 1156 | vlan_vid = port_to_out_vlan[out_port], |
| 1157 | eth_dst = port_to_dst_mac_str[in_port], |
| 1158 | eth_src = port_to_intf_src_mac_str[out_port], |
| 1159 | ip_ttl = 63, |
| 1160 | ip_src = port_to_src_ip_str[in_port], |
| 1161 | ip_dst = dst_ip_str |
| 1162 | ) |
| 1163 | pkt = str( parsed_pkt ) |
| 1164 | verify_packet( self, pkt, out_port ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1165 | |
Pier | bbdf378 | 2016-08-22 17:58:26 -0700 | [diff] [blame] | 1166 | verify_no_other_packets( self ) |
| 1167 | |
Pier | 7b031af | 2016-08-25 15:00:22 -0700 | [diff] [blame] | 1168 | finally: |
| 1169 | delete_all_flows( self.controller ) |
| 1170 | delete_groups( self.controller, Groups ) |
| 1171 | delete_all_groups( self.controller ) |
| 1172 | |
| 1173 | class L3McastToL2UntagToUntag( base_tests.SimpleDataPlane ): |
| 1174 | """ |
| 1175 | Mcast routing, in this test case the traffic is untagged. |
| 1176 | 4094 is used as internal vlan_id. The packet goes out |
| 1177 | untagged. |
| 1178 | """ |
| 1179 | def runTest( self ): |
| 1180 | Groups = Queue.LifoQueue( ) |
| 1181 | try: |
| 1182 | if len( config[ "port_map" ] ) < 2: |
| 1183 | logging.info( "Port count less than 2, can't run this case" ) |
| 1184 | assert (False) |
| 1185 | return |
| 1186 | ports = config[ "port_map" ].keys( ) |
| 1187 | dst_ip_str = "224.0.0.1" |
| 1188 | ( |
| 1189 | port_to_in_vlan, |
| 1190 | port_to_out_vlan, |
| 1191 | port_to_src_mac_str, |
| 1192 | port_to_dst_mac_str, |
| 1193 | port_to_src_ip_str, |
| 1194 | Groups) = fill_mcast_pipeline_L3toL2( |
| 1195 | self.controller, |
| 1196 | logging, |
| 1197 | ports, |
| 1198 | is_ingress_tagged = False, |
| 1199 | is_egress_tagged = False, |
| 1200 | is_vlan_translated = False, |
| 1201 | is_max_vlan = True |
| 1202 | ) |
| 1203 | |
| 1204 | for in_port in ports: |
| 1205 | |
| 1206 | parsed_pkt = simple_udp_packet( |
| 1207 | pktlen = 96, |
| 1208 | eth_dst = port_to_dst_mac_str[in_port], |
| 1209 | eth_src = port_to_src_mac_str[in_port], |
| 1210 | ip_ttl = 64, |
| 1211 | ip_src = port_to_src_ip_str[in_port], |
| 1212 | ip_dst = dst_ip_str |
| 1213 | ) |
| 1214 | pkt = str( parsed_pkt ) |
| 1215 | self.dataplane.send( in_port, pkt ) |
| 1216 | |
| 1217 | for out_port in ports: |
| 1218 | |
| 1219 | parsed_pkt = simple_udp_packet( |
| 1220 | pktlen = 96, |
| 1221 | eth_dst = port_to_dst_mac_str[in_port], |
| 1222 | eth_src = port_to_src_mac_str[in_port], |
| 1223 | ip_ttl = 64, |
| 1224 | ip_src = port_to_src_ip_str[in_port], |
| 1225 | ip_dst = dst_ip_str |
| 1226 | ) |
| 1227 | pkt = str( parsed_pkt ) |
| 1228 | if out_port == in_port: |
| 1229 | verify_no_packet( self, pkt, in_port ) |
| 1230 | continue |
| 1231 | verify_packet( self, pkt, out_port ) |
| 1232 | verify_no_other_packets( self ) |
| 1233 | finally: |
| 1234 | delete_all_flows( self.controller ) |
| 1235 | delete_groups( self.controller, Groups ) |
| 1236 | delete_all_groups( self.controller ) |
| 1237 | |
| 1238 | class L3McastToL2UntagToTag( base_tests.SimpleDataPlane ): |
| 1239 | """ |
| 1240 | Mcast routing, in this test case the traffic is untagged. |
| 1241 | 300 is used as vlan_id. The packet goes out |
| 1242 | tagged. |
| 1243 | """ |
| 1244 | def runTest( self ): |
| 1245 | Groups = Queue.LifoQueue( ) |
| 1246 | try: |
| 1247 | if len( config[ "port_map" ] ) < 2: |
| 1248 | logging.info( "Port count less than 2, can't run this case" ) |
| 1249 | assert (False) |
| 1250 | return |
| 1251 | ports = config[ "port_map" ].keys( ) |
| 1252 | dst_ip_str = "224.0.0.1" |
| 1253 | ( |
| 1254 | port_to_in_vlan, |
| 1255 | port_to_out_vlan, |
| 1256 | port_to_src_mac_str, |
| 1257 | port_to_dst_mac_str, |
| 1258 | port_to_src_ip_str, |
| 1259 | Groups) = fill_mcast_pipeline_L3toL2( |
| 1260 | self.controller, |
| 1261 | logging, |
| 1262 | ports, |
| 1263 | is_ingress_tagged = False, |
| 1264 | is_egress_tagged = True, |
| 1265 | is_vlan_translated = False, |
| 1266 | is_max_vlan = False |
| 1267 | ) |
| 1268 | |
| 1269 | for in_port in ports: |
| 1270 | |
| 1271 | parsed_pkt = simple_udp_packet( |
| 1272 | pktlen = 96, |
| 1273 | eth_dst = port_to_dst_mac_str[in_port], |
| 1274 | eth_src = port_to_src_mac_str[in_port], |
| 1275 | ip_ttl = 64, |
| 1276 | ip_src = port_to_src_ip_str[in_port], |
| 1277 | ip_dst = dst_ip_str |
| 1278 | ) |
| 1279 | pkt = str( parsed_pkt ) |
| 1280 | self.dataplane.send( in_port, pkt ) |
| 1281 | |
| 1282 | for out_port in ports: |
| 1283 | |
| 1284 | parsed_pkt = simple_udp_packet( |
| 1285 | pktlen = 100, |
| 1286 | dl_vlan_enable = True, |
| 1287 | vlan_vid = port_to_out_vlan[in_port], |
| 1288 | eth_dst = port_to_dst_mac_str[in_port], |
| 1289 | eth_src = port_to_src_mac_str[in_port], |
| 1290 | ip_ttl = 64, |
| 1291 | ip_src = port_to_src_ip_str[in_port], |
| 1292 | ip_dst = dst_ip_str |
| 1293 | ) |
| 1294 | pkt = str( parsed_pkt ) |
| 1295 | if out_port == in_port: |
| 1296 | verify_no_packet( self, pkt, in_port ) |
| 1297 | continue |
| 1298 | verify_packet( self, pkt, out_port ) |
| 1299 | verify_no_other_packets( self ) |
| 1300 | finally: |
| 1301 | delete_all_flows( self.controller ) |
| 1302 | delete_groups( self.controller, Groups ) |
| 1303 | delete_all_groups( self.controller ) |
| 1304 | |
| 1305 | |
| 1306 | class L3McastToL2TagToUntag( base_tests.SimpleDataPlane ): |
| 1307 | """ |
| 1308 | Mcast routing, in this test case the traffic is tagged. |
| 1309 | 300 is used as vlan_id. The packet goes out |
| 1310 | untagged. |
| 1311 | """ |
| 1312 | def runTest( self ): |
| 1313 | Groups = Queue.LifoQueue( ) |
| 1314 | try: |
| 1315 | if len( config[ "port_map" ] ) < 2: |
| 1316 | logging.info( "Port count less than 2, can't run this case" ) |
| 1317 | assert (False) |
| 1318 | return |
| 1319 | ports = config[ "port_map" ].keys( ) |
| 1320 | dst_ip_str = "224.0.0.1" |
| 1321 | ( |
| 1322 | port_to_in_vlan, |
| 1323 | port_to_out_vlan, |
| 1324 | port_to_src_mac_str, |
| 1325 | port_to_dst_mac_str, |
| 1326 | port_to_src_ip_str, |
| 1327 | Groups) = fill_mcast_pipeline_L3toL2( |
| 1328 | self.controller, |
| 1329 | logging, |
| 1330 | ports, |
| 1331 | is_ingress_tagged = True, |
| 1332 | is_egress_tagged = False, |
| 1333 | is_vlan_translated = False, |
| 1334 | is_max_vlan = False |
| 1335 | ) |
| 1336 | |
| 1337 | for in_port in ports: |
| 1338 | |
| 1339 | parsed_pkt = simple_udp_packet( |
| 1340 | pktlen = 100, |
| 1341 | dl_vlan_enable = True, |
| 1342 | vlan_vid = port_to_in_vlan[in_port], |
| 1343 | eth_dst = port_to_dst_mac_str[in_port], |
| 1344 | eth_src = port_to_src_mac_str[in_port], |
| 1345 | ip_ttl = 64, |
| 1346 | ip_src = port_to_src_ip_str[in_port], |
| 1347 | ip_dst = dst_ip_str |
| 1348 | ) |
| 1349 | pkt = str( parsed_pkt ) |
| 1350 | self.dataplane.send( in_port, pkt ) |
| 1351 | |
| 1352 | for out_port in ports: |
| 1353 | |
| 1354 | parsed_pkt = simple_udp_packet( |
| 1355 | pktlen = 96, |
| 1356 | eth_dst = port_to_dst_mac_str[in_port], |
| 1357 | eth_src = port_to_src_mac_str[in_port], |
| 1358 | ip_ttl = 64, |
| 1359 | ip_src = port_to_src_ip_str[in_port], |
| 1360 | ip_dst = dst_ip_str |
| 1361 | ) |
| 1362 | pkt = str( parsed_pkt ) |
| 1363 | if out_port == in_port: |
| 1364 | verify_no_packet( self, pkt, in_port ) |
| 1365 | continue |
| 1366 | verify_packet( self, pkt, out_port ) |
| 1367 | verify_no_other_packets( self ) |
| 1368 | finally: |
| 1369 | delete_all_flows( self.controller ) |
| 1370 | delete_groups( self.controller, Groups ) |
| 1371 | delete_all_groups( self.controller ) |
| 1372 | |
| 1373 | class L3McastToL2TagToTag( base_tests.SimpleDataPlane ): |
| 1374 | """ |
| 1375 | Mcast routing, in this test case the traffic is tagged. |
| 1376 | 300 is used as vlan_id. The packet goes out tagged. |
| 1377 | """ |
| 1378 | def runTest( self ): |
| 1379 | Groups = Queue.LifoQueue( ) |
| 1380 | try: |
| 1381 | if len( config[ "port_map" ] ) < 2: |
| 1382 | logging.info( "Port count less than 2, can't run this case" ) |
| 1383 | assert (False) |
| 1384 | return |
| 1385 | ports = config[ "port_map" ].keys( ) |
| 1386 | dst_ip_str = "224.0.0.1" |
| 1387 | ( |
| 1388 | port_to_in_vlan, |
| 1389 | port_to_out_vlan, |
| 1390 | port_to_src_mac_str, |
| 1391 | port_to_dst_mac_str, |
| 1392 | port_to_src_ip_str, |
| 1393 | Groups) = fill_mcast_pipeline_L3toL2( |
| 1394 | self.controller, |
| 1395 | logging, |
| 1396 | ports, |
| 1397 | is_ingress_tagged = True, |
| 1398 | is_egress_tagged = True, |
| 1399 | is_vlan_translated = False, |
| 1400 | is_max_vlan = False |
| 1401 | ) |
| 1402 | |
| 1403 | for in_port in ports: |
| 1404 | |
| 1405 | parsed_pkt = simple_udp_packet( |
| 1406 | pktlen = 100, |
| 1407 | dl_vlan_enable = True, |
| 1408 | vlan_vid = port_to_in_vlan[in_port], |
| 1409 | eth_dst = port_to_dst_mac_str[in_port], |
| 1410 | eth_src = port_to_src_mac_str[in_port], |
| 1411 | ip_ttl = 64, |
| 1412 | ip_src = port_to_src_ip_str[in_port], |
| 1413 | ip_dst = dst_ip_str |
| 1414 | ) |
| 1415 | pkt = str( parsed_pkt ) |
| 1416 | self.dataplane.send( in_port, pkt ) |
| 1417 | |
| 1418 | for out_port in ports: |
| 1419 | |
| 1420 | parsed_pkt = simple_udp_packet( |
| 1421 | pktlen = 100, |
| 1422 | dl_vlan_enable = True, |
| 1423 | vlan_vid = port_to_in_vlan[in_port], |
| 1424 | eth_dst = port_to_dst_mac_str[in_port], |
| 1425 | eth_src = port_to_src_mac_str[in_port], |
| 1426 | ip_ttl = 64, |
| 1427 | ip_src = port_to_src_ip_str[in_port], |
| 1428 | ip_dst = dst_ip_str |
| 1429 | ) |
| 1430 | pkt = str( parsed_pkt ) |
| 1431 | if out_port == in_port: |
| 1432 | verify_no_packet( self, pkt, in_port ) |
| 1433 | continue |
| 1434 | verify_packet( self, pkt, out_port ) |
| 1435 | verify_no_other_packets( self ) |
| 1436 | finally: |
| 1437 | delete_all_flows( self.controller ) |
| 1438 | delete_groups( self.controller, Groups ) |
| 1439 | delete_all_groups( self.controller ) |
| 1440 | |
| 1441 | class L3McastToL2TagToTagTranslated( base_tests.SimpleDataPlane ): |
| 1442 | """ |
| 1443 | Mcast routing, in this test case the traffic is tagged. |
| 1444 | port+1 is used as ingress vlan_id. The packet goes out |
| 1445 | tagged. 4094-port is used as egress vlan_id |
| 1446 | """ |
| 1447 | def runTest( self ): |
| 1448 | Groups = Queue.LifoQueue( ) |
| 1449 | try: |
| 1450 | if len( config[ "port_map" ] ) < 2: |
| 1451 | logging.info( "Port count less than 2, can't run this case" ) |
| 1452 | assert (False) |
| 1453 | return |
| 1454 | ports = config[ "port_map" ].keys( ) |
| 1455 | dst_ip_str = "224.0.0.1" |
| 1456 | ( |
| 1457 | port_to_in_vlan, |
| 1458 | port_to_out_vlan, |
| 1459 | port_to_src_mac_str, |
| 1460 | port_to_dst_mac_str, |
| 1461 | port_to_src_ip_str, |
| 1462 | Groups) = fill_mcast_pipeline_L3toL2( |
| 1463 | self.controller, |
| 1464 | logging, |
| 1465 | ports, |
| 1466 | is_ingress_tagged = True, |
| 1467 | is_egress_tagged = True, |
| 1468 | is_vlan_translated = True, |
| 1469 | is_max_vlan = False |
| 1470 | ) |
| 1471 | |
| 1472 | for in_port in ports: |
| 1473 | |
| 1474 | parsed_pkt = simple_udp_packet( |
| 1475 | pktlen = 100, |
| 1476 | dl_vlan_enable = True, |
| 1477 | vlan_vid = port_to_in_vlan[in_port], |
| 1478 | eth_dst = port_to_dst_mac_str[in_port], |
| 1479 | eth_src = port_to_src_mac_str[in_port], |
| 1480 | ip_ttl = 64, |
| 1481 | ip_src = port_to_src_ip_str[in_port], |
| 1482 | ip_dst = dst_ip_str |
| 1483 | ) |
| 1484 | pkt = str( parsed_pkt ) |
| 1485 | self.dataplane.send( in_port, pkt ) |
| 1486 | |
| 1487 | for out_port in ports: |
| 1488 | |
| 1489 | parsed_pkt = simple_udp_packet( |
| 1490 | pktlen = 100, |
| 1491 | dl_vlan_enable = True, |
| 1492 | vlan_vid = port_to_out_vlan[in_port], |
| 1493 | eth_dst = port_to_dst_mac_str[in_port], |
| 1494 | eth_src = port_to_src_mac_str[in_port], |
| 1495 | ip_ttl = 64, |
| 1496 | ip_src = port_to_src_ip_str[in_port], |
| 1497 | ip_dst = dst_ip_str |
| 1498 | ) |
| 1499 | pkt = str( parsed_pkt ) |
| 1500 | if out_port == in_port: |
| 1501 | verify_no_packet( self, pkt, in_port ) |
| 1502 | continue |
| 1503 | verify_packet( self, pkt, out_port ) |
| 1504 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1505 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1506 | delete_all_flows( self.controller ) |
| 1507 | delete_groups( self.controller, Groups ) |
| 1508 | delete_all_groups( self.controller ) |
| 1509 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 1510 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1511 | class _MplsFwd( base_tests.SimpleDataPlane ): |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 1512 | """ Verify basic MPLS forwarding: Label switch router """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1513 | |
| 1514 | def runTest( self ): |
| 1515 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1516 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1517 | if len( config[ "port_map" ] ) < 2: |
| 1518 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1519 | return |
| 1520 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1521 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1522 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1523 | # 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] | 1524 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1525 | for port in ports: |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1526 | # Shift MPLS label and VLAN ID by 16 to avoid reserved values |
| 1527 | vlan_id = port + 16 |
| 1528 | mpls_label = port + 16 |
| 1529 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1530 | # add l2 interface group |
| 1531 | id = port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1532 | 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] | 1533 | dst_mac[ 5 ] = port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1534 | mpls_gid, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| 1535 | vlan_id, id ) |
| 1536 | mpls_label_gid, mpls_label_msg = add_mpls_label_group( self.controller, |
| 1537 | 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] | 1538 | push_mpls_header=False, set_mpls_label=mpls_label, set_bos=1 ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 1539 | #ecmp_gid, ecmp_msg = add_mpls_forwarding_group( self.controller, |
| 1540 | # 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] | 1541 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 1542 | 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] | 1543 | # add termination flow |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1544 | 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] | 1545 | #add_mpls_flow( self.controller, ecmp_gid, port, goto_table=29 ) |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1546 | 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] | 1547 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1548 | Groups._put( l2_gid ) |
| 1549 | Groups._put( mpls_gid ) |
| 1550 | Groups._put( mpls_label_gid ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 1551 | #Groups._put( ecmp_gid ) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1552 | do_barrier( self.controller ) |
castroflavio | 30c6cc5 | 2016-01-07 15:19:42 -0800 | [diff] [blame] | 1553 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1554 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1555 | for in_port in ports: |
| 1556 | ip_src = '192.168.%02d.1' % (in_port) |
| 1557 | for out_port in ports: |
| 1558 | if in_port == out_port: |
| 1559 | continue |
Flavio Castro | 5494794 | 2016-02-03 16:05:20 -0500 | [diff] [blame] | 1560 | |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1561 | # Shift MPLS label and VLAN ID by 16 to avoid reserved values |
| 1562 | out_mpls_label = out_port + 16 |
| 1563 | in_vlan_vid = in_port + 16 |
| 1564 | out_vlan_vid = out_port + 16 |
| 1565 | |
| 1566 | ip_dst = '192.168.%02d.1' % (out_port) |
| 1567 | label = (out_mpls_label, 0, 1, 32) |
| 1568 | 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] | 1569 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] ) |
| 1570 | pkt = str( parsed_pkt ) |
| 1571 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 5494794 | 2016-02-03 16:05:20 -0500 | [diff] [blame] | 1572 | |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1573 | # build expect packet |
| 1574 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1575 | label = (out_mpls_label, 0, 1, 31) |
| 1576 | 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] | 1577 | ip_src=ip_src, ip_dst=ip_dst, eth_src=switch_mac, eth_dst=mac_dst, |
| 1578 | label=[ label ] ) |
| 1579 | pkt = str( exp_pkt ) |
| 1580 | verify_packet( self, pkt, out_port ) |
| 1581 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1582 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1583 | delete_all_flows( self.controller ) |
| 1584 | delete_groups( self.controller, Groups ) |
| 1585 | delete_all_groups( self.controller ) |
Flavio Castro | b702a2f | 2016-04-10 22:01:48 -0400 | [diff] [blame] | 1586 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 1587 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1588 | class _MplsTermination( base_tests.SimpleDataPlane ): |
Flavio Castro | 76c5b26 | 2016-07-27 19:53:00 -0700 | [diff] [blame] | 1589 | """ Verify MPLS VPN Termination at penultimate hop """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1590 | |
| 1591 | def runTest( self ): |
| 1592 | Groups = Queue.LifoQueue( ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1593 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1594 | if len( config[ "port_map" ] ) < 2: |
| 1595 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1596 | return |
| 1597 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1598 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1599 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1600 | # 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] | 1601 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1602 | for port in ports: |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1603 | # Shift MPLS label and VLAN ID by 16 to avoid reserved values |
| 1604 | vlan_id = port + 16 |
| 1605 | mpls_label = port + 16 |
| 1606 | |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1607 | # add l2 interface group |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1608 | id, dst_mac[ 5 ] = port, port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1609 | 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] | 1610 | # add L3 Unicast group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1611 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id, |
| 1612 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1613 | # add L3 ecmp group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1614 | 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] | 1615 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 1616 | 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] | 1617 | # add termination flow |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1618 | 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] | 1619 | add_mpls_flow( self.controller, ecmp_msg.group_id, mpls_label ) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1620 | # add_mpls_flow(self.controller, label=port) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1621 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1622 | # add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0xffffff00, |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1623 | # ecmp_msg.group_id, 1) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1624 | Groups._put( l2_gid ) |
| 1625 | Groups._put( l3_msg.group_id ) |
| 1626 | Groups._put( ecmp_msg.group_id ) |
| 1627 | do_barrier( self.controller ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1628 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1629 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1630 | for in_port in ports: |
| 1631 | ip_src = '192.168.%02d.1' % (in_port) |
| 1632 | for out_port in ports: |
| 1633 | if in_port == out_port: |
| 1634 | continue |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1635 | |
| 1636 | # Shift MPLS label and VLAN ID by 16 to avoid reserved values |
| 1637 | out_mpls_label = out_port + 16 |
| 1638 | in_vlan_vid = in_port + 16 |
| 1639 | out_vlan_vid = out_port + 16 |
| 1640 | |
Flavio Castro | d80fbc3 | 2016-07-25 15:54:26 -0700 | [diff] [blame] | 1641 | ip_dst = '192.168.%02d.1' % (out_port) |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1642 | label = (out_mpls_label, 0, 1, 32) |
| 1643 | 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] | 1644 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] ) |
| 1645 | pkt = str( parsed_pkt ) |
| 1646 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1647 | # build expect packet |
| 1648 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
Charles Chan | 53cac54 | 2016-08-22 16:03:26 -0700 | [diff] [blame] | 1649 | 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] | 1650 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst ) |
| 1651 | pkt = str( exp_pkt ) |
| 1652 | verify_packet( self, pkt, out_port ) |
| 1653 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1654 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1655 | delete_all_flows( self.controller ) |
| 1656 | delete_groups( self.controller, Groups ) |
| 1657 | delete_all_groups( self.controller ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 1658 | print("Done") |
| 1659 | |
| 1660 | @disabled |
| 1661 | class One_MplsTermination( base_tests.SimpleDataPlane ): |
| 1662 | """ |
| 1663 | Verify MPLS VPN Termination at penultimate hop in only one direction |
| 1664 | """ |
| 1665 | |
| 1666 | def runTest( self ): |
| 1667 | Groups = Queue.LifoQueue( ) |
| 1668 | try: |
| 1669 | if len( config[ "port_map" ] ) < 2: |
| 1670 | logging.info( "Port count less than 2, can't run this case" ) |
| 1671 | return |
| 1672 | dip = 0xc0a80001 |
| 1673 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1674 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 1675 | # Assigns unique hardcoded test_id to make sure tests don't overlap when writing rules |
| 1676 | ports = config[ "port_map" ].keys( ) |
| 1677 | inport = ports[0] |
| 1678 | outport = ports[1] |
| 1679 | |
| 1680 | # Shift MPLS label and VLAN ID by 16 to avoid reserved values |
| 1681 | invlan_id = inport + 16 |
| 1682 | outvlan_id = outport + 16 |
| 1683 | mpls_label = outport + 16 |
| 1684 | |
| 1685 | # add l2 interface group |
| 1686 | id, dst_mac[ 5 ] = inport, outport |
| 1687 | l2_gid, l2_msg = add_one_l2_interface_group( self.controller, outport, outvlan_id, True, False ) |
| 1688 | # add L3 Unicast group |
| 1689 | l3_msg = add_l3_unicast_group( self.controller, outport, vlanid=outvlan_id, id=id, |
| 1690 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
| 1691 | # add L3 ecmp group |
| 1692 | ecmp_msg = add_l3_ecmp_group( self.controller, id, [ l3_msg.group_id ] ) |
| 1693 | # add vlan flow table |
| 1694 | add_one_vlan_table_flow( self.controller, inport, 1, invlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 1695 | # add tmac flow |
| 1696 | add_termination_flow( self.controller, inport, 0x8847, intf_src_mac, invlan_id, goto_table=24 ) |
| 1697 | # add mpls termination flow |
| 1698 | add_mpls_flow( self.controller, ecmp_msg.group_id, mpls_label, send_barrier=True ) |
| 1699 | Groups._put( l2_gid ) |
| 1700 | Groups._put( l3_msg.group_id ) |
| 1701 | Groups._put( ecmp_msg.group_id ) |
| 1702 | |
| 1703 | time.sleep(0.1) |
| 1704 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| 1705 | ip_src = '192.168.%02d.1' % (inport) |
| 1706 | # Shift MPLS label and VLAN ID by 16 to avoid reserved values |
| 1707 | out_mpls_label = outport + 16 |
| 1708 | in_vlan_vid = inport + 16 |
| 1709 | out_vlan_vid = outport + 16 |
| 1710 | |
| 1711 | ip_dst = '192.168.%02d.1' % (outport) |
| 1712 | label = (out_mpls_label, 0, 1, 32) |
| 1713 | parsed_pkt = mpls_packet( pktlen=104, dl_vlan_enable=True, vlan_vid=(in_vlan_vid), |
| 1714 | ip_src=ip_src, ip_dst=ip_dst, eth_dst=switch_mac, label=[ label ] ) |
| 1715 | pkt = str( parsed_pkt ) |
| 1716 | self.dataplane.send( inport, pkt ) |
| 1717 | # build expect packet |
| 1718 | mac_dst = '00:00:00:22:22:%02X' % (outport) |
| 1719 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(out_vlan_vid), |
| 1720 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=31, ip_src=ip_src, ip_dst=ip_dst ) |
| 1721 | pkt = str( exp_pkt ) |
| 1722 | verify_packet( self, pkt, outport ) |
| 1723 | verify_no_other_packets( self ) |
| 1724 | finally: |
| 1725 | delete_all_flows( self.controller ) |
| 1726 | delete_groups( self.controller, Groups ) |
| 1727 | delete_all_groups( self.controller ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1728 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1729 | |
| 1730 | class _24UcastTagged( base_tests.SimpleDataPlane ): |
Flavio Castro | 76c5b26 | 2016-07-27 19:53:00 -0700 | [diff] [blame] | 1731 | """ Verify /24 IP forwarding to L3 Interface """ |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1732 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1733 | def runTest( self ): |
| 1734 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1735 | try: |
| 1736 | test_id = 26 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1737 | if len( config[ "port_map" ] ) < 2: |
| 1738 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1739 | return |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1740 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1741 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1742 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1743 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1744 | for port in ports: |
| 1745 | # add l2 interface group |
| 1746 | vlan_id = port + test_id |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1747 | l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, |
| 1748 | is_tagged=True, send_barrier=False ) |
| 1749 | dst_mac[ 5 ] = vlan_id |
| 1750 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=vlan_id, |
| 1751 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1752 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 1753 | 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] | 1754 | # add termination flow |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1755 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1756 | # add unicast routing flow |
| 1757 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1758 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, l3_msg.group_id ) |
| 1759 | Groups.put( l2gid ) |
| 1760 | Groups.put( l3_msg.group_id ) |
| 1761 | do_barrier( self.controller ) |
Flavio Castro | 1c9b125 | 2016-02-04 18:42:58 -0500 | [diff] [blame] | 1762 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1763 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1764 | for in_port in ports: |
| 1765 | mac_src = '00:00:00:22:22:%02X' % (test_id + in_port) |
| 1766 | ip_src = '192.168.%02d.1' % (test_id + in_port) |
| 1767 | for out_port in ports: |
| 1768 | if in_port == out_port: |
| 1769 | continue |
| 1770 | ip_dst = '192.168.%02d.1' % (test_id + out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1771 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, |
| 1772 | vlan_vid=(test_id + in_port), eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, |
| 1773 | ip_src=ip_src, ip_dst=ip_dst ) |
| 1774 | pkt = str( parsed_pkt ) |
| 1775 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1776 | # build expected packet |
| 1777 | mac_dst = '00:00:00:22:22:%02X' % (test_id + out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1778 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, |
| 1779 | vlan_vid=(test_id + out_port), eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, |
| 1780 | ip_src=ip_src, ip_dst=ip_dst ) |
| 1781 | pkt = str( exp_pkt ) |
| 1782 | verify_packet( self, pkt, out_port ) |
| 1783 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1784 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1785 | delete_all_flows( self.controller ) |
| 1786 | delete_groups( self.controller, Groups ) |
| 1787 | delete_all_groups( self.controller ) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 1788 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1789 | |
| 1790 | class _0Ucast( base_tests.SimpleDataPlane ): |
Flavio Castro | 76c5b26 | 2016-07-27 19:53:00 -0700 | [diff] [blame] | 1791 | """ Verify default gateway IP forwarding to L3 Interface ( /0 rule ) """ |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 1792 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1793 | def runTest( self ): |
| 1794 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1795 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1796 | if len( config[ "port_map" ] ) < 2: |
| 1797 | logging.info( "Port count less than 2, can't run this case" ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1798 | return |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 1799 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1800 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1801 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1802 | dip = 0xc0a80001 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1803 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1804 | for port in ports: |
| 1805 | # add l2 interface group |
| 1806 | vlan_id = port |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1807 | l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id + 1, |
| 1808 | is_tagged=True, send_barrier=False ) |
| 1809 | dst_mac[ 5 ] = vlan_id |
| 1810 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id + 1, id=vlan_id, |
| 1811 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1812 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 1813 | 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] | 1814 | # add termination flow |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1815 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1816 | # add unicast routing flow |
| 1817 | dst_ip = dip + (vlan_id << 8) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1818 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffffff, l3_msg.group_id ) |
| 1819 | Groups.put( l2gid ) |
| 1820 | Groups.put( l3_msg.group_id ) |
| 1821 | l3_gid = encode_l3_unicast_group_id( ports[ 0 ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1822 | dst_ip = 0x0 |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1823 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0x0, l3_gid ) |
| 1824 | do_barrier( self.controller ) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 1825 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1826 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1827 | for in_port in ports: |
| 1828 | mac_src = '00:00:00:22:22:%02X' % (in_port) |
| 1829 | ip_src = '192.168.%02d.1' % (in_port) |
| 1830 | for out_port in ports: |
| 1831 | if in_port == out_port: |
| 1832 | continue |
| 1833 | ip_dst = '192.168.%02d.1' % (out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1834 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(in_port), |
| 1835 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 1836 | pkt = str( parsed_pkt ) |
| 1837 | self.dataplane.send( in_port, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1838 | # build expected packet |
| 1839 | mac_dst = '00:00:00:22:22:%02X' % (out_port) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1840 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=(out_port + 1), |
| 1841 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst ) |
| 1842 | pkt = str( exp_pkt ) |
| 1843 | verify_packet( self, pkt, out_port ) |
| 1844 | verify_no_other_packets( self ) |
| 1845 | ip_dst = '1.168.%02d.1' % ports[ 0 ] |
| 1846 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=in_port, |
| 1847 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, ip_dst=ip_dst ) |
| 1848 | pkt = str( parsed_pkt ) |
| 1849 | self.dataplane.send( in_port, pkt ) |
| 1850 | # build expect packet |
| 1851 | mac_dst = '00:00:00:22:22:%02X' % ports[ 0 ] |
| 1852 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ] + 1, |
| 1853 | ip_ttl=63, ip_src=ip_src, ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac ) |
| 1854 | pkt = str( exp_pkt ) |
| 1855 | verify_packet( self, pkt, ports[ 0 ] ) |
| 1856 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1857 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1858 | delete_all_flows( self.controller ) |
| 1859 | delete_groups( self.controller, Groups ) |
| 1860 | delete_all_groups( self.controller ) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 1861 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1862 | |
| 1863 | class Unfiltered( base_tests.SimpleDataPlane ): |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1864 | """ |
Flavio Castro | 76c5b26 | 2016-07-27 19:53:00 -0700 | [diff] [blame] | 1865 | Attempt to add an unfiltered group: [ATTENTION] this doesn't verify addition |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1866 | """ |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 1867 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1868 | def runTest( self ): |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1869 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1870 | ports = sorted( config[ "port_map" ].keys( ) ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1871 | vlan_id = 1; |
| 1872 | for port in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1873 | add_l2_unfiltered_group( self.controller, [ port ], False ) |
| 1874 | do_barrier( self.controller ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1875 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1876 | delete_all_flows( self.controller ) |
| 1877 | delete_all_groups( self.controller ) |
Flavio Castro | 91d1a55 | 2016-05-17 16:59:44 -0700 | [diff] [blame] | 1878 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 1879 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1880 | class L3McastToVPN( base_tests.SimpleDataPlane ): |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1881 | """ |
Flavio Castro | 76c5b26 | 2016-07-27 19:53:00 -0700 | [diff] [blame] | 1882 | Mcast routing and VPN initiation |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1883 | """ |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1884 | |
| 1885 | def runTest( self ): |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1886 | """ |
| 1887 | port1 (vlan 1)-> port 2 (vlan 2) |
| 1888 | """ |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1889 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1890 | delete_all_flows( self.controller ) |
| 1891 | delete_all_groups( self.controller ) |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1892 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1893 | if len( config[ "port_map" ] ) < 3: |
| 1894 | logging.info( "Port count less than 3, can't run this case" ) |
| 1895 | assert (False) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1896 | return |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1897 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1898 | vlan_id = 1 |
| 1899 | port2_out_vlan = 2 |
| 1900 | port3_out_vlan = 3 |
| 1901 | in_vlan = 1 # macast group vid shall use input vlan diffe from l3 interface use output vlan |
| 1902 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 1903 | intf_src_mac_str = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
| 1904 | dst_mac = [ 0x01, 0x00, 0x5e, 0x01, 0x01, 0x01 ] |
| 1905 | dst_mac_str = ':'.join( [ '%02X' % x for x in dst_mac ] ) |
| 1906 | port1_mac = [ 0x00, 0x11, 0x11, 0x11, 0x11, 0x11 ] |
| 1907 | port1_mac_str = ':'.join( [ '%02X' % x for x in port1_mac ] ) |
| 1908 | src_ip = 0xc0a80101 |
| 1909 | src_ip_str = "192.168.1.1" |
| 1910 | dst_ip = 0xe0010101 |
| 1911 | dst_ip_str = "224.1.1.1" |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1912 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1913 | port1 = config[ "port_map" ].keys( )[ 0 ] |
| 1914 | port2 = config[ "port_map" ].keys( )[ 1 ] |
| 1915 | # port3=config["port_map"].keys()[2] |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1916 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1917 | # add l2 interface group |
| 1918 | for port in config[ "port_map" ].keys( ): |
| 1919 | add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, is_tagged=False, |
| 1920 | send_barrier=False ) |
| 1921 | # add vlan flow table |
| 1922 | add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 1923 | vlan_id += 1 |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1924 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1925 | # add termination flow |
| 1926 | add_termination_flow( self.controller, port1, 0x0800, [ 0x01, 0x00, 0x5e, 0x00, 0x00, 0x00 ], |
| 1927 | vlan_id ) |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1928 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1929 | # add MPLS interface group |
| 1930 | l2_gid = encode_l2_interface_group_id( port2_out_vlan, port2 ) |
| 1931 | mpls_gid2, mpls_msg = add_mpls_intf_group( self.controller, l2_gid, dst_mac, intf_src_mac, |
| 1932 | port2_out_vlan, port2 ) |
| 1933 | # l2_gid3 = encode_l2_interface_group_id(port3_out_vlan, port3) |
| 1934 | # mpls_gid3, mpls_msg = add_mpls_intf_group(self.controller, l2_gid3, dst_mac, intf_src_mac, port3_out_vlan, port3) |
| 1935 | # add L3VPN groups |
| 1936 | mpls_label_gid2, mpls_label_msg = add_mpls_label_group( self.controller, |
| 1937 | subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL, index=(0x20000 + port2), ref_gid=mpls_gid2, |
| 1938 | push_mpls_header=True, set_mpls_label=port2, set_bos=1, cpy_ttl_outward=True ) |
| 1939 | # 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] | 1940 | # 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] | 1941 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1942 | mcat_group_msg = add_l3_mcast_group( self.controller, in_vlan, 2, [ mpls_label_gid2 ] ) |
| 1943 | 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] | 1944 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1945 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=1, eth_dst=dst_mac_str, |
| 1946 | eth_src=port1_mac_str, ip_ttl=64, ip_src=src_ip_str, ip_dst=dst_ip_str ) |
| 1947 | pkt = str( parsed_pkt ) |
| 1948 | self.dataplane.send( port1, pkt ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1949 | label = (12, 0, 1, 63) |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1950 | exp_pkt = mpls_packet( pktlen=100, eth_dst=dst_mac_str, eth_src=intf_src_mac_str, ip_ttl=64, |
| 1951 | ip_src=src_ip_str, label=[ label ], ip_dst=dst_ip_str ) |
| 1952 | pkt = str( exp_pkt ) |
| 1953 | verify_packet( self, pkt, port2 ) |
| 1954 | # verify_packet(self, pkt, port3) |
| 1955 | verify_no_other_packets( self ) |
| 1956 | delete_all_groups( self.controller ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1957 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1958 | delete_all_flows( self.controller ) |
| 1959 | delete_all_groups( self.controller ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1960 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 1961 | @disabled |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1962 | class PacketInSrcMacMiss( base_tests.SimpleDataPlane ): |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1963 | """ |
| 1964 | Test packet in function on a src-mac miss |
| 1965 | Send a packet to each dataplane port and verify that a packet |
| 1966 | in message is received from the controller for each |
| 1967 | #todo verify you stop receiving after adding rule |
| 1968 | """ |
| 1969 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1970 | def runTest( self ): |
| 1971 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1972 | try: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1973 | ports = sorted( config[ "port_map" ].keys( ) ) |
Flavio Castro | 423df65 | 2016-05-17 20:14:08 -0400 | [diff] [blame] | 1974 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1975 | Groups = Queue.LifoQueue( ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1976 | for port in ports: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1977 | L2gid, l2msg = add_one_l2_interface_group( self.controller, port, 1, True, False ) |
| 1978 | add_one_vlan_table_flow( self.controller, port, 1, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 1979 | Groups.put( L2gid ) |
| 1980 | parsed_vlan_pkt = simple_tcp_packet( pktlen=104, vlan_vid=0x1001, dl_vlan_enable=True ) |
| 1981 | vlan_pkt = str( parsed_vlan_pkt ) |
| 1982 | for of_port in config[ "port_map" ].keys( ): |
| 1983 | logging.info( "PacketInMiss test, port %d", of_port ) |
| 1984 | self.dataplane.send( of_port, vlan_pkt ) |
| 1985 | verify_packet_in( self, vlan_pkt, of_port, ofp.OFPR_NO_MATCH ) |
| 1986 | verify_no_other_packets( self ) |
Flavio Castro | 8c37e1c | 2016-07-19 18:26:33 -0700 | [diff] [blame] | 1987 | finally: |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1988 | delete_all_flows( self.controller ) |
| 1989 | delete_all_groups( self.controller ) |
| 1990 | |
| 1991 | |
| 1992 | class EcmpGroupMod( base_tests.SimpleDataPlane ): |
| 1993 | """ |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 1994 | Verify referenced group can be modified by adding or removing buckets |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 1995 | """ |
| 1996 | |
| 1997 | def runTest( self ): |
| 1998 | Groups = Queue.LifoQueue( ) |
| 1999 | try: |
| 2000 | if len( config[ "port_map" ] ) < 2: |
| 2001 | logging.info( "Port count less than 2, can't run this case" ) |
| 2002 | return |
| 2003 | |
| 2004 | intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ] |
| 2005 | dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ] |
| 2006 | dip = 0xc0a80001 |
| 2007 | # Hashes Test Name and uses it as id for installing unique groups |
| 2008 | ports = config[ "port_map" ].keys( ) |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 2009 | ecmp = [ ] |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2010 | dst_ips = [] |
| 2011 | # add flows for all ports but include only the egress switchport (connected to ports[1]) |
| 2012 | # in the ecmp group |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2013 | for port in ports: |
| 2014 | vlan_id = port |
| 2015 | id = port |
| 2016 | # add l2 interface group |
| 2017 | l2_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id, |
| 2018 | is_tagged=True, send_barrier=False ) |
| 2019 | dst_mac[ 5 ] = vlan_id |
| 2020 | l3_msg = add_l3_unicast_group( self.controller, port, vlanid=vlan_id, id=id, |
| 2021 | src_mac=intf_src_mac, dst_mac=dst_mac ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2022 | if port == ports[1]: |
| 2023 | ecmp += [ l3_msg.group_id ] |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2024 | Groups._put( l2_gid ) |
| 2025 | Groups._put( l3_msg.group_id ) |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 2026 | 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] | 2027 | # add vlan flow table |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 2028 | 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] | 2029 | # add termination flow |
| 2030 | add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id ) |
| 2031 | # add unicast routing flow |
| 2032 | dst_ip = dip + (vlan_id << 8) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2033 | dst_ips += [dst_ip] |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2034 | Groups._put( ecmp_msg.group_id ) |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 2035 | mod_l3_ecmp_group( self.controller, ports[ 0 ], ecmp ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2036 | for dst_ip in dst_ips: |
| 2037 | add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, ecmp_msg.group_id ) |
| 2038 | time.sleep(0.1) |
| 2039 | # 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] | 2040 | switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] ) |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 2041 | parsed_pkt = exp_pkt = 0 |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2042 | in_port = ports[0] |
| 2043 | out_port = ports[1] |
| 2044 | logging.info("\nSending packet to port: " + str(in_port) + ", expected egress on port: " + str(out_port)) |
| 2045 | mac_src = '00:00:00:22:22:%02X' % ports[ 0 ] |
| 2046 | ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1) |
| 2047 | ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1) |
| 2048 | tcp = out_port if out_port == 24 else 25 |
| 2049 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ], |
| 2050 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, |
| 2051 | ip_dst=ip_dst, tcp_dport=tcp ) |
| 2052 | pkt = str( parsed_pkt ) |
| 2053 | self.dataplane.send( ports[ 0 ], pkt ) |
| 2054 | # build expected packet at egress switchport |
| 2055 | mac_dst = '00:00:00:22:22:%02X' % out_port |
| 2056 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| 2057 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, |
| 2058 | ip_dst=ip_dst, tcp_dport=tcp ) |
| 2059 | pkt = str( exp_pkt ) |
| 2060 | verify_packet( self, pkt, out_port ) |
| 2061 | verify_no_other_packets( self ) |
| 2062 | |
| 2063 | # second part of the test - edit the ecmp group to remove the orginal egress switchport |
| 2064 | # and instead add the ingress switchport. Send packet from ingress switchport, and expect |
| 2065 | # it back on the ingress switchport |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 2066 | l3_gid = encode_l3_unicast_group_id( ports[ 0 ] ) |
| 2067 | mod_l3_ecmp_group( self.controller, ports[ 0 ], [ l3_gid ] ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2068 | time.sleep(0.1) |
| 2069 | logging.info("Sending packet to port: " + str(ports[0]) + ", expected egress on port: " + str(ports[0])) |
| 2070 | mac_src = '00:00:00:22:22:%02X' % ports[ 0 ] |
| 2071 | ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1) |
| 2072 | ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1) |
| 2073 | tcp = port if port == 24 else 25 |
| 2074 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ], |
| 2075 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, |
| 2076 | ip_dst=ip_dst,tcp_dport=tcp ) |
| 2077 | pkt = str( parsed_pkt ) |
| 2078 | self.dataplane.send( ports[ 0 ], pkt ) |
| 2079 | # build expected packet |
| 2080 | mac_dst = '00:00:00:22:22:%02X' % ports[ 0 ] |
| 2081 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ], |
| 2082 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, |
| 2083 | ip_dst=ip_dst,tcp_dport=tcp ) |
| 2084 | pkt = str( exp_pkt ) |
| 2085 | verify_packet( self, pkt, ports[ 0 ] ) |
| 2086 | verify_no_other_packets( self ) |
| 2087 | |
| 2088 | # third part of the test - edit the group to completely remove bucket. Packet sent |
| 2089 | # should be dropped by the switch |
Flavio Castro | 9debaaa | 2016-07-26 19:37:50 -0700 | [diff] [blame] | 2090 | mod_l3_ecmp_group( self.controller, ports[ 0 ], [ ] ) |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2091 | time.sleep(0.1) |
| 2092 | logging.info("Sending packet to port: " + str(ports[0]) + ", expected drop") |
| 2093 | mac_src = '00:00:00:22:22:%02X' % ports[ 0 ] |
| 2094 | ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1) |
| 2095 | ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1) |
| 2096 | tcp = port if port == 24 else 25 |
| 2097 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ], |
| 2098 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, |
| 2099 | ip_dst=ip_dst,tcp_dport=tcp ) |
| 2100 | pkt = str( parsed_pkt ) |
| 2101 | self.dataplane.send( ports[ 0 ], pkt ) |
| 2102 | verify_no_other_packets( self ) |
| 2103 | |
| 2104 | # final part of the test - edit the empty group to add back the bucket for the |
| 2105 | # original egress port, and verify packet is received on egress switch port |
| 2106 | l3_gid = encode_l3_unicast_group_id( ports[ 1 ] ) |
| 2107 | mod_l3_ecmp_group( self.controller, ports[ 0 ], [ l3_gid ] ) |
| 2108 | time.sleep(0.1) |
| 2109 | in_port = ports[0] |
| 2110 | out_port = ports[1] |
| 2111 | logging.info("Sending packet to port: " + str(in_port) + ", expected egress on port: " + str(out_port)) |
| 2112 | mac_src = '00:00:00:22:22:%02X' % ports[ 0 ] |
| 2113 | ip_src = '192.168.%02d.%02d' % (ports[ 0 ], 1) |
| 2114 | ip_dst = '192.168.%02d.%02d' % (ports[ 1 ], 1) |
| 2115 | tcp = out_port if out_port == 24 else 25 |
| 2116 | parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=ports[ 0 ], |
| 2117 | eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64, ip_src=ip_src, |
| 2118 | ip_dst=ip_dst, tcp_dport=tcp ) |
| 2119 | pkt = str( parsed_pkt ) |
| 2120 | self.dataplane.send( ports[ 0 ], pkt ) |
| 2121 | # build expected packet at egress switchport |
| 2122 | mac_dst = '00:00:00:22:22:%02X' % out_port |
| 2123 | exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=out_port, |
| 2124 | eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63, ip_src=ip_src, |
| 2125 | ip_dst=ip_dst, tcp_dport=tcp ) |
| 2126 | pkt = str( exp_pkt ) |
| 2127 | verify_packet( self, pkt, out_port ) |
| 2128 | verify_no_other_packets( self ) |
| 2129 | |
Flavio Castro | a7162bb | 2016-07-25 17:30:30 -0700 | [diff] [blame] | 2130 | finally: |
| 2131 | delete_all_flows( self.controller ) |
| 2132 | delete_groups( self.controller, Groups ) |
| 2133 | delete_all_groups( self.controller ) |
Pier | 8b22302 | 2016-08-19 22:47:49 -0700 | [diff] [blame] | 2134 | |
Saurav Das | 3499218 | 2017-04-14 15:59:48 -0700 | [diff] [blame] | 2135 | |
Pier | 8b22302 | 2016-08-19 22:47:49 -0700 | [diff] [blame] | 2136 | class Untagged( base_tests.SimpleDataPlane ): |
| 2137 | """ |
| 2138 | Verify VLAN filtering table does not require OFPVID_PRESENT bit to be 0. |
| 2139 | This should be fixed in OFDPA 2.0 GA and above, the test fails with |
| 2140 | previous versions of the OFDPA. |
| 2141 | |
| 2142 | Two rules are necessary in VLAN table (10): |
| 2143 | 1) Assignment: match 0x0000/(no mask), set_vlan_vid 0x100A, goto 20 |
| 2144 | 2) Filtering: match 0x100A/0x1FFF, goto 20 |
| 2145 | |
| 2146 | In this test case vlan_id = (MAX_INTERNAL_VLAN - port_no). |
| 2147 | The remaining part of the test is based on the use of the bridging table |
| 2148 | """ |
| 2149 | |
| 2150 | MAX_INTERNAL_VLAN = 4094 |
| 2151 | |
| 2152 | def runTest( self ): |
| 2153 | groups = Queue.LifoQueue( ) |
| 2154 | try: |
| 2155 | if len( config[ "port_map" ] ) < 2: |
| 2156 | logging.info( "Port count less than 2, can't run this case" ) |
| 2157 | return |
| 2158 | |
| 2159 | ports = sorted( config[ "port_map" ].keys( ) ) |
| 2160 | for port in ports: |
| 2161 | vlan_id = Untagged.MAX_INTERNAL_VLAN - port |
Pier | 265ad5f | 2017-02-28 17:46:28 +0100 | [diff] [blame] | 2162 | add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG ) |
| 2163 | 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] | 2164 | for other_port in ports: |
| 2165 | if other_port == port: |
| 2166 | continue |
| 2167 | L2gid, l2msg = add_one_l2_interface_group( self.controller, other_port, vlan_id, False, False ) |
| 2168 | groups.put( L2gid ) |
| 2169 | add_bridge_flow( self.controller, [ 0x00, 0x12, 0x34, 0x56, 0x78, other_port ], vlan_id, L2gid, True ) |
| 2170 | |
| 2171 | do_barrier( self.controller ) |
| 2172 | |
| 2173 | for out_port in ports: |
| 2174 | # change dest based on port number |
| 2175 | mac_dst = '00:12:34:56:78:%02X' % out_port |
| 2176 | for in_port in ports: |
| 2177 | if in_port == out_port: |
| 2178 | continue |
| 2179 | pkt = str( simple_tcp_packet( eth_dst=mac_dst ) ) |
| 2180 | self.dataplane.send( in_port, pkt ) |
| 2181 | for ofport in ports: |
| 2182 | if ofport in [ out_port ]: |
| 2183 | verify_packet( self, pkt, ofport ) |
| 2184 | else: |
| 2185 | verify_no_packet( self, pkt, ofport ) |
| 2186 | verify_no_other_packets( self ) |
| 2187 | finally: |
| 2188 | delete_all_flows( self.controller ) |
Pier | f49f79b | 2016-08-25 15:12:04 -0700 | [diff] [blame] | 2189 | delete_groups( self.controller, groups ) |
Pier | 8b22302 | 2016-08-19 22:47:49 -0700 | [diff] [blame] | 2190 | delete_all_groups( self.controller ) |