Added L3MPLSVPN test case
diff --git a/ofdpa/onos.py b/ofdpa/onos.py
index cf9796f..7857597 100644
--- a/ofdpa/onos.py
+++ b/ofdpa/onos.py
@@ -289,6 +289,7 @@
class L3UcastTagged(base_tests.SimpleDataPlane):
"""
+ Explain better
Port1(vlan1, 0x00, 0x00, 0x00, 0x22, 0x22, 0x01, 192.168.1.1) ,
Port2(vlan2, 0x00, 0x00, 0x00, 0x22, 0x22, 0x02, 19.168.2.1)
"""
@@ -317,7 +318,6 @@
#add unicast routing flow
dst_ip = dip + (vlan_id<<8)
add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0, l3_msg.group_id)
-
#add entries in the Bridging table to avoid packet-in from mac learning
group_id = encode_l2_interface_group_id(vlan_id, port)
add_bridge_flow(self.controller, dst_mac, vlan_id, group_id, True)
@@ -337,7 +337,7 @@
ip_dst=ip_dst)
pkt=str(parsed_pkt)
self.dataplane.send(in_port, pkt)
- #build expect packet
+ #build expected packet
mac_dst='00:00:00:22:22:%02X' % out_port
exp_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=out_port,
eth_dst=mac_dst, eth_src=switch_mac, ip_ttl=63,
@@ -346,3 +346,62 @@
verify_packet(self, pkt, out_port)
verify_no_other_packets(self)
+class L3VPNMPLS(base_tests.SimpleDataPlane):
+ def runTest(self):
+ delete_all_flows(self.controller)
+ delete_all_groups(self.controller)
+
+ 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
+ index=1
+ ports = config["port_map"].keys()
+ for port in ports:
+ #add l2 interface group
+ vlan_id=port
+ l2_gid, l2_msg = add_one_l2_interface_grouop(self.controller, port, vlan_id, True, False)
+ dst_mac[5]=vlan_id
+ mpls_gid, mpls_msg = add_mpls_intf_group(self.controller, l2_gid, dst_mac, intf_src_mac, vlan_id, port)
+ mpls_label_gid, mpls_label_msg = add_mpls_label_group(self.controller, subtype=OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL,
+ index=port, ref_gid= mpls_gid, push_mpls_header=True, set_mpls_label=port, set_bos=1, set_ttl=32)
+ #add vlan flow table
+ add_one_vlan_table_flow(self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_BOTH)
+ #add termination flow
+ add_termination_flow(self.controller, port, 0x0800, intf_src_mac, vlan_id)
+ #add unicast routing flow
+ dst_ip = dip + (vlan_id<<8)
+ add_unicast_routing_flow(self.controller, 0x0800, dst_ip, 0, mpls_label_gid)
+
+ #add entries in the Bridging table to avoid packet-in from mac learning
+ group_id = encode_l2_interface_group_id(vlan_id, port)
+ add_bridge_flow(self.controller, dst_mac, vlan_id, group_id, True)
+
+ 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' % in_port
+ ip_src='192.168.%02d.1' % in_port
+ for out_port in ports:
+ if in_port == out_port:
+ continue
+ ip_dst='192.168.%02d.1' % out_port
+ parsed_pkt = simple_tcp_packet(pktlen=100, dl_vlan_enable=True, vlan_vid=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 expect packet
+ mac_dst='00:00:00:22:22:%02X' % out_port
+ label = (out_port, 0, 1, 32)
+ exp_pkt = mpls_packet(dl_vlan_enable=True, vlan_vid=out_port, ip_ttl=64, ip_src=ip_src,
+ ip_dst=ip_dst, eth_dst=mac_dst, eth_src=switch_mac, label=[label])
+ pkt=str(exp_pkt)
+ verify_packet(self, pkt, out_port)
+ verify_no_other_packets(self)
+
+
diff --git a/src/python/oftest/testutils.py b/src/python/oftest/testutils.py
index f419c21..7c6978b 100755
--- a/src/python/oftest/testutils.py
+++ b/src/python/oftest/testutils.py
@@ -392,7 +392,47 @@
return pkt
-
+def mpls_packet(pktlen=100,
+ eth_dst='00:01:02:03:04:05',
+ eth_src='00:06:07:08:09:0a',
+ dl_vlan_enable=False,
+ vlan_vid=0,
+ vlan_pcp=0,
+ dl_vlan_cfi=0,
+ ip_src='192.168.0.1',
+ ip_dst='192.168.0.2',
+ ip_tos=0,
+ ip_ttl=64,
+ tcp_sport=1234,
+ tcp_dport=80,
+ tcp_flags="S",
+ ip_ihl=None,
+ ip_options=False,
+ label=None,
+ inner_payload=None
+ ):
+ if MINSIZE > pktlen:
+ pktlen = MINSIZE
+
+ # Note Dot1Q.id is really CFI
+ if (dl_vlan_enable):
+ pkt = scapy.Ether(dst=eth_dst, src=eth_src)/ \
+ scapy.Dot1Q(prio=vlan_pcp, id=dl_vlan_cfi, vlan=vlan_vid)
+ else:
+ pkt = scapy.Ether(dst=eth_dst, src=eth_src)
+
+ #add MPLS header
+ for i in range(len(label)):
+ l,c,s,t=label[i]
+ pkt = pkt/scapy.MPLS(label=l, cos=c, s=s, ttl=t)
+
+ #add innder payload
+ if inner_payload!=None:
+ pkt=pkt / \
+ scapy.IP(src=ip_src, dst=ip_dst, tos=ip_tos, ttl=ip_ttl, ihl=ip_ihl)/ \
+ scapy.TCP(sport=tcp_sport, dport=tcp_dport, flags=tcp_flags)
+
+ return pkt
def simple_mpls_packet(eth_dst='00:01:02:03:04:05',
eth_src='00:06:07:08:09:0a',