add verf routing case
diff --git a/accton/accton_util.py b/accton/accton_util.py
index e20e0fd..1871849 100755
--- a/accton/accton_util.py
+++ b/accton/accton_util.py
@@ -377,19 +377,23 @@
return msgs
-def add_one_vlan_table_flow(ctrl, of_port, vlan_id=1, flag=VLAN_TABLE_FLAG_ONLY_BOTH, send_barrier=False):
+def add_one_vlan_table_flow(ctrl, of_port, vlan_id=1, vrf=0, flag=VLAN_TABLE_FLAG_ONLY_BOTH, send_barrier=False):
# table 10: vlan
# goto to table 20
if (flag == VLAN_TABLE_FLAG_ONLY_TAG) or (flag == VLAN_TABLE_FLAG_ONLY_BOTH):
match = ofp.match()
match.oxm_list.append(ofp.oxm.in_port(of_port))
match.oxm_list.append(ofp.oxm.vlan_vid(0x1000+vlan_id))
+
request = ofp.message.flow_add(
table_id=10,
cookie=42,
match=match,
instructions=[
- ofp.instruction.goto_table(20)
+ ofp.instruction.apply_actions(
+ actions=[ofp.action.set_field(ofp.oxm.exp2ByteValue(exp_type=1, value=vrf))]
+ ),
+ ofp.instruction.goto_table(20)
],
priority=0)
logging.info("Add vlan %d tagged packets on port %d and go to table 20" %( vlan_id, of_port))
@@ -399,6 +403,7 @@
match = ofp.match()
match.oxm_list.append(ofp.oxm.in_port(of_port))
match.oxm_list.append(ofp.oxm.vlan_vid(0))
+
request = ofp.message.flow_add(
table_id=10,
cookie=42,
@@ -486,7 +491,8 @@
match.oxm_list.append(ofp.oxm.eth_dst_masked(dst_mac, [0xff, 0xff, 0xff, 0x80, 0x00, 0x00]))
goto_table=40
else:
- match.oxm_list.append(ofp.oxm.in_port(in_port))
+ if in_port!=0:
+ match.oxm_list.append(ofp.oxm.in_port(in_port))
match.oxm_list.append(ofp.oxm.eth_dst(dst_mac))
match.oxm_list.append(ofp.oxm.vlan_vid(0x1000+vlanid))
goto_table=30
@@ -509,14 +515,18 @@
return request
-def add_unicast_routing_flow(ctrl, eth_type, dst_ip, mask, action_group_id, send_barrier=False):
+def add_unicast_routing_flow(ctrl, eth_type, dst_ip, mask, action_group_id, vrf=0, send_barrier=False):
match = ofp.match()
match.oxm_list.append(ofp.oxm.eth_type(eth_type))
+ if vrf != 0:
+ match.oxm_list.append(ofp.oxm.exp2ByteValue(ofp.oxm.OFDPA_EXP_TYPE_VRF, vrf))
+
if mask!=0:
match.oxm_list.append(ofp.oxm.ipv4_dst_masked(dst_ip, mask))
else:
match.oxm_list.append(ofp.oxm.ipv4_dst(dst_ip))
+
request = ofp.message.flow_add(
table_id=30,
cookie=42,
diff --git a/accton/flow_test.py b/accton/flow_test.py
index fe80d9e..2dd7cf4 100755
--- a/accton/flow_test.py
+++ b/accton/flow_test.py
@@ -552,6 +552,167 @@
verify_packet(self, pkt, port)
verify_no_other_packets(self)
+class L3UcastVrfRouteOnSamVLANSamPort(base_tests.SimpleDataPlane):
+ """
+ Port1(vlan1, VRF1, 0x00, 0x00, 0x00, 0x22, 0x22, 0x01, 192.168.1.1) ,
+ Port1(vlan1, VRF1, 0x00, 0x00, 0x00, 0x22, 0x22, 0x02, 19.168.2.1)
+ Port1(vlan2, VRF2, 0x00, 0x00, 0x00, 0x22, 0x22, 0x01, 192.168.1.1) ,
+ Port1(vlan2, VRF2, 0x00, 0x00, 0x00, 0x22, 0x22, 0x02, 19.168.2.1)
+
+ """
+ def runTest(self):
+ delete_all_flows(self.controller)
+ delete_all_groups(self.controller)
+ port = config["port_map"].keys()[0]
+
+ vrf1=1
+ vrf2=2
+ vrf1_vlan_id=1
+ vrf2_vlan_id=2
+ intf_src_mac=[0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc]
+ port_mac1=[0x00, 0x00, 0x00, 0x22, 0x22, 0x01]
+ port_mac2=[0x00, 0x00, 0x00, 0x22, 0x22, 0x02]
+ port_ip1=0xc0a80101
+ port_ip1_str=convertIP4toStr(port_ip1)
+ port_ip2=0xc0a80201
+ port_ip2_str=convertIP4toStr(port_ip2)
+ #add l2 interface group
+ add_one_l2_interface_grouop(self.controller, port, vlan_id=vrf1_vlan_id, is_tagged=True, send_barrier=False)
+ add_one_l2_interface_grouop(self.controller, port, vlan_id=vrf2_vlan_id, is_tagged=True, send_barrier=False)
+ #add vlan flow table
+ add_one_vlan_table_flow(self.controller, port, vrf1_vlan_id, vrf=vrf1, flag=VLAN_TABLE_FLAG_ONLY_TAG)
+ add_one_vlan_table_flow(self.controller, port, vrf2_vlan_id, vrf=vrf2, flag=VLAN_TABLE_FLAG_ONLY_TAG)
+
+ #add termination flow
+ add_termination_flow(self.controller, 0, 0x0800, intf_src_mac, vrf1_vlan_id)
+ add_termination_flow(self.controller, 0, 0x0800, intf_src_mac, vrf2_vlan_id)
+
+ """192.168.1.1->192.168.2.1"""
+ l3_msg=add_l3_unicast_group(self.controller, port, vlanid=vrf1_vlan_id, id=1, src_mac=intf_src_mac, dst_mac=port_mac2)
+ add_unicast_routing_flow(self.controller, 0x0800, port_ip2, 0, l3_msg.group_id, vrf1)
+ l3_msg=add_l3_unicast_group(self.controller, port, vlanid=vrf2_vlan_id, id=2, src_mac=intf_src_mac, dst_mac=port_mac2)
+ add_unicast_routing_flow(self.controller, 0x0800, port_ip2, 0, l3_msg.group_id, vrf2)
+
+ """192.168.1.1->192.168.2.1"""
+ l3_msg=add_l3_unicast_group(self.controller, port, vlanid=vrf1_vlan_id, id=3, src_mac=intf_src_mac, dst_mac=port_mac1)
+ add_unicast_routing_flow(self.controller, 0x0800, port_ip1, 0, l3_msg.group_id, vrf1)
+ l3_msg=add_l3_unicast_group(self.controller, port, vlanid=vrf2_vlan_id, id=4, src_mac=intf_src_mac, dst_mac=port_mac1)
+ add_unicast_routing_flow(self.controller, 0x0800, port_ip1, 0, l3_msg.group_id, vrf2)
+
+ do_barrier(self.controller)
+
+ """send packet to verify on VRF vrf1"""
+ """192.168.1.1->192.168.2.1"""
+ switch_mac_str = convertMACtoStr(intf_src_mac)
+ port_mac1_str = convertMACtoStr(port_mac1)
+ port_mac2_str = convertMACtoStr(port_mac2)
+ ttl=64
+ #send packet
+ parsed_pkt = simple_tcp_packet(pktlen=100,
+ eth_dst=switch_mac_str,
+ eth_src=port_mac1_str,
+ dl_vlan_enable=True,
+ vlan_vid=vrf1_vlan_id,
+ ip_ttl=ttl,
+ ip_src=port_ip1_str,
+ ip_dst=port_ip2_str)
+ pkt=str(parsed_pkt)
+ self.dataplane.send(port, pkt)
+ #build expect packet
+ exp_pkt = simple_tcp_packet(pktlen=100,
+ eth_dst=port_mac2_str,
+ eth_src=switch_mac_str,
+ dl_vlan_enable=True,
+ vlan_vid=vrf1_vlan_id,
+ ip_ttl=(ttl-1),
+ ip_src=port_ip1_str,
+ ip_dst=port_ip2_str)
+ pkt=str(exp_pkt)
+ verify_packet(self, pkt, port)
+ verify_no_other_packets(self)
+
+ """192.168.2.1->192.168.1.1"""
+ parsed_pkt = simple_tcp_packet(pktlen=100,
+ eth_dst=switch_mac_str,
+ eth_src=port_mac2_str,
+ dl_vlan_enable=True,
+ vlan_vid=vrf1_vlan_id,
+ ip_ttl=ttl,
+ ip_src=port_ip2_str,
+ ip_dst=port_ip1_str)
+ pkt=str(parsed_pkt)
+ self.dataplane.send(port, pkt)
+ #build expect packet
+ exp_pkt = simple_tcp_packet(pktlen=100,
+ eth_dst=port_mac1_str,
+ eth_src=switch_mac_str,
+ dl_vlan_enable=True,
+ vlan_vid=vrf1_vlan_id,
+ ip_ttl=(ttl-1),
+ ip_src=port_ip2_str,
+ ip_dst=port_ip1_str)
+ pkt=str(exp_pkt)
+ verify_packet(self, pkt, port)
+ verify_no_other_packets(self)
+
+
+ """send packet to verify on VRF vrf2"""
+ """192.168.1.1->192.168.2.1"""
+ switch_mac_str = convertMACtoStr(intf_src_mac)
+ port_mac1_str = convertMACtoStr(port_mac1)
+ port_mac2_str = convertMACtoStr(port_mac2)
+ ttl=64
+ #send packet
+ parsed_pkt = simple_tcp_packet(pktlen=100,
+ eth_dst=switch_mac_str,
+ eth_src=port_mac1_str,
+ dl_vlan_enable=True,
+ vlan_vid=vrf2_vlan_id,
+ ip_ttl=ttl,
+ ip_src=port_ip1_str,
+ ip_dst=port_ip2_str)
+ pkt=str(parsed_pkt)
+ self.dataplane.send(port, pkt)
+ #build expect packet
+ exp_pkt = simple_tcp_packet(pktlen=100,
+ eth_dst=port_mac2_str,
+ eth_src=switch_mac_str,
+ dl_vlan_enable=True,
+ vlan_vid=vrf2_vlan_id,
+ ip_ttl=(ttl-1),
+ ip_src=port_ip1_str,
+ ip_dst=port_ip2_str)
+ pkt=str(exp_pkt)
+ verify_packet(self, pkt, port)
+ verify_no_other_packets(self)
+
+ """192.168.2.1->192.168.1.1"""
+ parsed_pkt = simple_tcp_packet(pktlen=100,
+ eth_dst=switch_mac_str,
+ eth_src=port_mac2_str,
+ dl_vlan_enable=True,
+ vlan_vid=vrf2_vlan_id,
+ ip_ttl=ttl,
+ ip_src=port_ip2_str,
+ ip_dst=port_ip1_str)
+ pkt=str(parsed_pkt)
+ self.dataplane.send(port, pkt)
+ #build expect packet
+ exp_pkt = simple_tcp_packet(pktlen=100,
+ eth_dst=port_mac1_str,
+ eth_src=switch_mac_str,
+ dl_vlan_enable=True,
+ vlan_vid=vrf2_vlan_id,
+ ip_ttl=(ttl-1),
+ ip_src=port_ip2_str,
+ ip_dst=port_ip1_str)
+ pkt=str(exp_pkt)
+ verify_packet(self, pkt, port)
+ verify_no_other_packets(self)
+
+
+
+
class L3UcastECMP(base_tests.SimpleDataPlane):
"""
Port1(vlan1, 0x00, 0x00, 0x00, 0x22, 0x22, 0x01, 192.168.1.1) ,