Addink blackhole routing of-test. Needs OFDPA Premium 1.1.3
Change-Id: Ie172d1536b2b122a3cbfce190cb9b27880865ab1
diff --git a/accton/accton_util.py b/accton/accton_util.py
index 5cdfad3..479957c 100755
--- a/accton/accton_util.py
+++ b/accton/accton_util.py
@@ -1205,6 +1205,34 @@
return request
+def add_unicast_blackhole_flow(ctrl, eth_type, dst_ip, mask, vrf=0, send_ctrl=False, send_barrier=False, priority = 1):
+ match = ofp.match()
+ match.oxm_list.append(ofp.oxm.eth_type(eth_type))
+ if config["switch_type"] != 'xpliant' and vrf != 0:
+ match.oxm_list.append(ofp.oxm.exp2ByteValue(ofp.oxm.OFDPA_EXP_TYPE_VRF, vrf))
+
+ match.oxm_list.append(ofp.oxm.ipv4_dst_masked(dst_ip, mask))
+
+ instructions = []
+ instructions.append(ofp.instruction.goto_table(60))
+ instructions.append(ofp.instruction.clear_actions( ))
+
+ request = ofp.message.flow_add(
+ table_id=30,
+ cookie=42,
+ match=match,
+ instructions=instructions,
+ buffer_id=ofp.OFP_NO_BUFFER,
+ priority=priority)
+
+ logging.info("Inserting unicast blackhole routing flow eth_type %lx, dip %ld",eth_type, dst_ip)
+ ctrl.message_send(request)
+
+ if send_barrier:
+ do_barrier(ctrl)
+
+ return request
+
def add_unicast_v6_routing_flow(ctrl, eth_type, dst_ip, mask, action_group_id, vrf=0, send_ctrl=False, send_barrier=False):
match = ofp.match()
match.oxm_list.append(ofp.oxm.eth_type(eth_type))
diff --git a/ofdpa/flows.py b/ofdpa/flows.py
index 1ae6280..83fd1d9 100755
--- a/ofdpa/flows.py
+++ b/ofdpa/flows.py
@@ -1969,6 +1969,7 @@
add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
# add unicast routing flow
dst_ip = dip + (vlan_id << 8)
+ # def add_unicast_routing_flow(ctrl, eth_type, dst_ip, mask, action_group_id, vrf=0, send_ctrl=False, send_barrier=False, priority = 1):
add_unicast_routing_flow( self.controller, 0x0800, dst_ip, 0xffffff00, l3_msg.group_id )
Groups.put( l2gid )
Groups.put( l3_msg.group_id )
@@ -2000,6 +2001,62 @@
delete_groups( self.controller, Groups )
delete_all_groups( self.controller )
+class _24UcastRouteBlackHole( base_tests.SimpleDataPlane ):
+ """ Verify black-holing of unicast routes, feature present only from OFDPA Premium 1.1.3.0"""
+
+ def runTest( self ):
+ Groups = Queue.LifoQueue( )
+ try:
+ test_id = 27
+ if len( config[ "port_map" ] ) < 2:
+ logging.info( "Port count less than 2, can't run this case" )
+ return
+ intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
+ dst_mac = [ 0x00, 0x00, 0x00, 0x22, 0x22, 0x00 ]
+ dip = 0xc0a80001
+ ports = config[ "port_map" ].keys( )
+ for port in ports:
+ # add l2 interface group
+ vlan_id = port + test_id
+ # add vlan flow table
+ add_one_vlan_table_flow( self.controller, port, 1, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
+ # add termination flow
+ if config["switch_type"] == "qmx":
+ add_termination_flow( self.controller, 0, 0x0800, intf_src_mac, vlan_id )
+ else:
+ add_termination_flow( self.controller, port, 0x0800, intf_src_mac, vlan_id )
+ # add unicast routing flow
+ #dst ip = 10.0.0.0/8
+ dst_ip = 0x0a000000
+ add_unicast_blackhole_flow(self.controller, 0x0800, dst_ip, 0xffffff00 )
+ do_barrier( self.controller )
+
+ switch_mac = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
+ for in_port in ports:
+ mac_src = '00:00:00:22:22:%02X' % (test_id + in_port)
+ ip_src = '192.168.%02d.1' % (test_id + in_port)
+ for out_port in ports:
+ if in_port == out_port:
+ continue
+ ip_dst = '192.168.%02d.1' % (test_id + out_port)
+ parsed_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True,
+ vlan_vid=(test_id + in_port), eth_dst=switch_mac, eth_src=mac_src, ip_ttl=64,
+ ip_src=ip_src, ip_dst=ip_dst )
+ pkt = str( parsed_pkt )
+ self.dataplane.send( in_port, pkt )
+ # build expected packet
+ mac_dst = '00:00:00:22:22:%02X' % (test_id + out_port)
+ exp_pkt = simple_tcp_packet( pktlen=100, dl_vlan_enable=True,
+ vlan_vid=(test_id + out_port), eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63,
+ ip_src=ip_src, ip_dst=ip_dst )
+ pkt = str( exp_pkt )
+ verify_no_packet( self, pkt, out_port )
+ verify_no_other_packets( self )
+ finally:
+ delete_all_flows( self.controller )
+ delete_groups( self.controller, Groups )
+ delete_all_groups( self.controller )
+
class _0Ucast( base_tests.SimpleDataPlane ):
""" Verify default gateway IP forwarding to L3 Interface ( /0 rule ) """