[CORD-374] Fix L3McastToL3 test
Change-Id: Ib6780fb52bbf6566bf72bf8389fd00de07955c35
diff --git a/README.md b/README.md
index 1ca2172..c90c160 100755
--- a/README.md
+++ b/README.md
@@ -108,7 +108,7 @@
MplsFwd | X | ok | ok
L2FloodQinQ | ok | ok | ok
L2UnicastTagged | ok | ok | ok
-L3McastToL3 | ok | X | X
+L3McastToL3 | ok | X | ok
L3McastToL2 | ok | X | X
FloodGroupMod | X | X | ok
PacketInUDP | ok | ok | ok
diff --git a/accton/accton_util.py b/accton/accton_util.py
index d31c3a3..46e04c5 100755
--- a/accton/accton_util.py
+++ b/accton/accton_util.py
@@ -48,28 +48,28 @@
switch_cpu_mac=[int(switch_cpu_mac[i],16) for i in range(0, len(switch_cpu_mac))]
return switch_cpu_mac_str, switch_cpu_mac
-
+
def DumpGroup(stats, verify_group_stats, always_show=True):
if(len(stats) > len(verify_group_stats)):
min_len = len(verify_group_stats)
print "Stats Len is not the same, stats>verify_group_stats"
if(len(stats)< len(verify_group_stats)):
- min_len = len(stats)
+ min_len = len(stats)
print "Stats Len is not the same, stats<verify_group_stats"
- else:
+ else:
min_len = len(stats)
print "\r\n"
for i in range(min_len):
gs = stats[i]
- gv = verify_group_stats[i]
+ gv = verify_group_stats[i]
print "FromSwtich:(GID=%lx, TYPE=%lx)\r\nVerify :(GID=%lx, TYPE=%lx)"%(gs.group_id, gs.group_type, gv.group_id, gv.group_type)
if(len(gs.buckets) != len(gv.buckets)):
print "buckets len is not the same gs %lx, gv %lx",(len(gs.buckets), len(gv.buckets))
for j in range(len(gs.buckets)):
b1=gs.buckets[j]
- b2=gv.buckets[j]
+ b2=gv.buckets[j]
if(len(b1.actions) != len(b2.actions)):
print "action len is not the same"
@@ -78,26 +78,26 @@
a2=b2.actions[k]
if(always_show == True):
print "a1:"+a1.show()
- print "a2:"+a2.show()
+ print "a2:"+a2.show()
def AssertGroup(self, stats, verify_group_stats):
self.assertTrue(len(stats) ==len(verify_group_stats), "stats len is not the same")
for i in range(len(stats)):
gs = stats[i]
- gv = verify_group_stats[i]
+ gv = verify_group_stats[i]
self.assertTrue(len(gs.buckets) == len(gv.buckets), "buckets len is not the same")
for j in range(len(gs.buckets)):
b1=gs.buckets[j]
- b2=gv.buckets[j]
+ b2=gv.buckets[j]
self.assertTrue(len(b1.actions) == len(b2.actions), "action len is not the same")
for k in range(len(b1.actions)):
a1=b1.actions[k]
a2=b2.actions[k]
self.assertEquals(a1, a2, "action is not the same")
-
+
def encode_l2_interface_group_id(vlan, id):
return id + (vlan << OFDPA_VLAN_ID_SHIFT)
@@ -112,7 +112,7 @@
def encode_l2_flood_group_id(vlan, id):
return id + (vlan << OFDPA_VLAN_ID_SHIFT) + (4 << OFDPA_GROUP_TYPE_SHIFT)
-
+
def encode_l3_interface_group_id(id):
return id + (5 << OFDPA_GROUP_TYPE_SHIFT)
@@ -168,7 +168,7 @@
if is_tagged:
actions = [
ofp.action.output(of_port),
- ]
+ ]
else:
actions = [
ofp.action.pop_vlan(),
@@ -188,7 +188,7 @@
if send_barrier:
do_barrier(ctrl)
-
+
return group_id_list, msgs
def add_one_l2_interface_group(ctrl, port, vlan_id=1, is_tagged=False, send_barrier=False):
@@ -199,7 +199,7 @@
if is_tagged:
actions = [
ofp.action.output(port),
- ]
+ ]
else:
actions = [
ofp.action.pop_vlan(),
@@ -218,9 +218,9 @@
if send_barrier:
do_barrier(ctrl)
-
+
return group_id, request
-
+
def add_l2_mcast_group(ctrl, ports, vlanid, mcast_grp_index):
buckets=[]
for of_port in ports:
@@ -278,9 +278,9 @@
action.append(ofp.action.set_field(ofp.oxm.eth_dst(dst_mac)))
action.append(ofp.action.set_field(ofp.oxm.vlan_vid(0x1000+vlanid)))
-
+
action.append(ofp.action.group(group_id))
-
+
buckets = [ofp.bucket(actions=action)]
group_id =encode_l2_rewrite_group_id(id)
@@ -290,7 +290,7 @@
)
ctrl.message_send(request)
return request
-
+
def add_l3_unicast_group(ctrl, port, vlanid, id, src_mac, dst_mac):
group_id = encode_l2_interface_group_id(vlanid, port)
@@ -302,9 +302,9 @@
action.append(ofp.action.set_field(ofp.oxm.eth_dst(dst_mac)))
action.append(ofp.action.set_field(ofp.oxm.vlan_vid(0x1000+vlanid)))
-
+
action.append(ofp.action.group(group_id))
-
+
buckets = [ofp.bucket(actions=action)]
group_id =encode_l3_unicast_group_id(id)
@@ -314,15 +314,15 @@
)
ctrl.message_send(request)
return request
-
+
def add_l3_interface_group(ctrl, port, vlanid, id, src_mac):
group_id = encode_l2_interface_group_id(vlanid, port)
action=[]
action.append(ofp.action.set_field(ofp.oxm.eth_src(src_mac)))
- action.append(ofp.action.set_field(ofp.oxm.vlan_vid(0x1000+vlanid)))
+ action.append(ofp.action.set_field(ofp.oxm.vlan_vid(0x1000+vlanid)))
action.append(ofp.action.group(group_id))
-
+
buckets = [ofp.bucket(actions=action)]
group_id =encode_l3_interface_group_id(id)
@@ -363,7 +363,7 @@
buckets=[]
for group in groups_on_buckets:
buckets.append(ofp.bucket(actions=[ofp.action.group(group)]))
-
+
group_id =encode_l3_mcast_group_id(vid, mcast_group_id)
request = ofp.message.group_add(group_type=ofp.OFPGT_ALL,
group_id=group_id,
@@ -423,7 +423,7 @@
)
ctrl.message_send(request)
return request
-
+
def add_port_table_flow(ctrl, is_overlay=True):
match = ofp.match()
@@ -432,7 +432,7 @@
NEXT_TABLE=50
else:
match.oxm_list.append(ofp.oxm.in_port(0))
- NEXT_TABLE=10
+ NEXT_TABLE=10
request = ofp.message.flow_add(
table_id=0,
@@ -444,7 +444,7 @@
priority=0)
logging.info("Add port table, match port %lx" % 0x10000)
ctrl.message_send(request)
-
+
def pop_vlan_flow(ctrl, ports, vlan_id=1):
# table 10: vlan
@@ -497,7 +497,7 @@
priority=0)
logging.info("Add vlan %d tagged packets on port %d and go to table 20" %( vlan_id, of_port))
ctrl.message_send(request)
-
+
if (flag == VLAN_TABLE_FLAG_ONLY_UNTAG) or (flag == VLAN_TABLE_FLAG_ONLY_BOTH):
match = ofp.match()
match.oxm_list.append(ofp.oxm.in_port(of_port))
@@ -544,7 +544,7 @@
do_barrier(ctrl)
return msgs
-
+
def del_vlan_table_flow(ctrl, ports, vlan_id=1, flag=VLAN_TABLE_FLAG_ONLY_BOTH, send_barrier=False):
# table 10: vlan
# goto to table 20
@@ -579,22 +579,22 @@
do_barrier(ctrl)
return msgs
-
+
def add_vlan_table_flow_pvid(ctrl, in_port, match_vid=None, pvid=1, send_barrier=False):
"""it will tag pack as untagged packet wether it has tagg or not"""
match = ofp.match()
match.oxm_list.append(ofp.oxm.in_port(in_port))
actions=[]
if match_vid == None:
- match.oxm_list.append(ofp.oxm.vlan_vid(0))
+ match.oxm_list.append(ofp.oxm.vlan_vid(0))
actions.append(ofp.action.set_field(ofp.oxm.vlan_vid(0x1000+pvid)))
goto_table=20
else:
match.oxm_list.append(ofp.oxm.vlan_vid_masked(0x1000+match_vid, 0x1fff))
actions.append(ofp.action.push_vlan(0x8100))
- actions.append(ofp.action.set_field(ofp.oxm.vlan_vid(0x1000+pvid)))
+ actions.append(ofp.action.set_field(ofp.oxm.vlan_vid(0x1000+pvid)))
goto_table=20
-
+
request = ofp.message.flow_add(
table_id=10,
cookie=42,
@@ -605,8 +605,8 @@
],
priority=0)
logging.info("Add PVID %d on port %d and go to table %ld" %( pvid, in_port, goto_table))
- ctrl.message_send(request)
-
+ ctrl.message_send(request)
+
if send_barrier:
do_barrier(ctrl)
@@ -620,11 +620,11 @@
cookie=42,
match=match,
instructions=[
- ofp.instruction.goto_table(20)
+ ofp.instruction.goto_table(20)
],
priority=0)
logging.info("Add allow all vlan on port %d " %(in_port))
- ctrl.message_send(request)
+ ctrl.message_send(request)
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
@@ -637,7 +637,7 @@
actions=[]
if vrf!=0:
actions.append(ofp.action.set_field(ofp.oxm.exp2ByteValue(exp_type=1, value=vrf)))
-
+
#actions.append(ofp.action.set_field(ofp.oxm.vlan_vid(value=vlan_id)))
request = ofp.message.flow_add(
@@ -653,18 +653,18 @@
priority=0)
logging.info("Add vlan %d tagged packets on port %d and go to table 20" %( vlan_id, of_port))
ctrl.message_send(request)
-
+
if (flag == VLAN_TABLE_FLAG_ONLY_UNTAG) 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_masked(0, 0x1fff))
-
+
actions=[]
if vrf!=0:
actions.append(ofp.action.set_field(ofp.oxm.exp2ByteValue(exp_type=1, value=vrf)))
-
+
actions.append(ofp.action.set_field(ofp.oxm.vlan_vid(0x1000+vlan_id)))
-
+
request = ofp.message.flow_add(
table_id=10,
cookie=42,
@@ -678,7 +678,7 @@
priority=0)
logging.info("Add vlan %d untagged packets on port %d and go to table 20" % (vlan_id, of_port))
ctrl.message_send(request)
-
+
if (flag == 4) :
match = ofp.match()
match.oxm_list.append(ofp.oxm.in_port(of_port))
@@ -708,7 +708,7 @@
do_barrier(ctrl)
return request
-
+
def add_bridge_flow(ctrl, dst_mac, vlanid, group_id, send_barrier=False):
match = ofp.match()
priority=500
@@ -735,9 +735,9 @@
ctrl.message_send(request)
if send_barrier:
- do_barrier(ctrl)
+ do_barrier(ctrl)
- return request
+ return request
def add_overlay_bridge_flow(ctrl, dst_mac, vnid, group_id, is_group=True, send_barrier=False):
match = ofp.match()
@@ -760,16 +760,16 @@
ofp.instruction.goto_table(60)
],
buffer_id=ofp.OFP_NO_BUFFER,
- priority=1000)
+ priority=1000)
logging.info("Inserting Brdige flow vnid %d, mac %s", vnid, dst_mac)
ctrl.message_send(request)
if send_barrier:
- do_barrier(ctrl)
+ do_barrier(ctrl)
- return request
-
+ return request
+
def add_termination_flow(ctrl, in_port, eth_type, dst_mac, vlanid, goto_table=None, send_barrier=False):
match = ofp.match()
match.oxm_list.append(ofp.oxm.eth_type(eth_type))
@@ -792,16 +792,16 @@
ofp.instruction.goto_table(goto_table)
],
buffer_id=ofp.OFP_NO_BUFFER,
- priority=1)
+ priority=1)
logging.info("Inserting termination flow inport %d, eth_type %lx, vlan %d, mac %s", in_port, eth_type, vlanid, dst_mac)
ctrl.message_send(request)
if send_barrier:
- do_barrier(ctrl)
+ do_barrier(ctrl)
- return request
-
+ return request
+
def add_unicast_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))
@@ -816,7 +816,7 @@
instructions.append(ofp.instruction.write_actions(
actions=[ofp.action.output( port=ofp.OFPP_CONTROLLER,
max_len=ofp.OFPCML_NO_BUFFER)]))
- else:
+ else:
instructions.append(ofp.instruction.write_actions(
actions=[ofp.action.group(action_group_id)]))
@@ -826,13 +826,13 @@
match=match,
instructions=instructions,
buffer_id=ofp.OFP_NO_BUFFER,
- priority=1)
+ priority=1)
logging.info("Inserting unicast routing flow eth_type %lx, dip %ld",eth_type, dst_ip)
ctrl.message_send(request)
if send_barrier:
- do_barrier(ctrl)
+ do_barrier(ctrl)
return request
@@ -872,14 +872,14 @@
def add_mcast4_routing_flow(ctrl, vlan_id, src_ip, src_ip_mask, dst_ip, action_group_id, send_barrier=False):
match = ofp.match()
match.oxm_list.append(ofp.oxm.eth_type(0x0800))
- match.oxm_list.append(ofp.oxm.vlan_vid(vlan_id))
+ match.oxm_list.append(ofp.oxm.vlan_vid(vlan_id))
if src_ip_mask!=0:
match.oxm_list.append(ofp.oxm.ipv4_src_masked(src_ip, src_ip_mask))
else:
match.oxm_list.append(ofp.oxm.ipv4_src(src_ip))
-
+
match.oxm_list.append(ofp.oxm.ipv4_dst(dst_ip))
-
+
request = ofp.message.flow_add(
table_id=40,
cookie=42,
@@ -890,15 +890,15 @@
ofp.instruction.goto_table(60)
],
buffer_id=ofp.OFP_NO_BUFFER,
- priority=1)
+ priority=1)
logging.info("Inserting mcast routing flow eth_type %lx, dip %lx, sip %lx, sip_mask %lx",0x0800, dst_ip, src_ip, src_ip_mask)
ctrl.message_send(request)
if send_barrier:
- do_barrier(ctrl)
+ do_barrier(ctrl)
- return request
+ return request
#dpctl tcp:192.168.1.1:6633 flow-mod table=28,cmd=add,prio=281 eth_type=0x800,ip_dst=100.0.0.1,ip_proto=6,tcp_dst=5000 write:set_field=ip_dst:10.0.0.1,set_field=tcp_dst:2000,group=0x71000001 goto:60
def add_dnat_flow(ctrl, eth_type, ip_dst, ip_proto, tcp_dst, set_ip_dst, set_tcp_dst, action_group_id):
@@ -907,7 +907,7 @@
match.oxm_list.append(ofp.oxm.ipv4_dst(ip_dst))
match.oxm_list.append(ofp.oxm.ip_proto(ip_proto))
match.oxm_list.append(ofp.oxm.tcp_dst(tcp_dst))
-
+
request = ofp.message.flow_add(
table_id=28,
cookie=42,
@@ -920,7 +920,7 @@
ofp.instruction.goto_table(60)
],
buffer_id=ofp.OFP_NO_BUFFER,
- priority=1)
+ priority=1)
logging.info("Inserting DNAT flow eth_type %lx, dip %lx, ip_proto %ld, tcp_dst %ld, SetFeild: Dip %lx, tcp_dst %ld, action_gorup=%lx",eth_type, ip_dst, ip_proto, tcp_dst, set_ip_dst, set_tcp_dst, action_group_id)
ctrl.message_send(request)
return request
@@ -932,7 +932,7 @@
match.oxm_list.append(ofp.oxm.ipv4_src(ip_src))
match.oxm_list.append(ofp.oxm.ip_proto(ip_proto))
match.oxm_list.append(ofp.oxm.tcp_src(tcp_src))
-
+
request = ofp.message.flow_add(
table_id=29,
cookie=42,
@@ -944,12 +944,12 @@
ofp.instruction.goto_table(30)
],
buffer_id=ofp.OFP_NO_BUFFER,
- priority=1)
+ priority=1)
logging.info("Inserting DNAT flow eth_type %lx, sip %lx, ip_proto %ld, tcp_src %ld, SetFeild: sip %lx, tcp_src %ld",eth_type, ip_src, ip_proto, tcp_src, set_ip_src, set_tcp_src)
ctrl.message_send(request)
return request
-
-def get_vtap_lport_config_xml(dp_id, lport, phy_port, vlan, vnid, operation='merge'):
+
+def get_vtap_lport_config_xml(dp_id, lport, phy_port, vlan, vnid, operation='merge'):
"""
Command Example:
of-agent vtap 10001 ethernet 1/1 vid 1
@@ -962,38 +962,38 @@
<id>capable-switch-1</id>
<resources>
<port xc:operation="OPERATION">
- <resource-id >LPORT</resource-id>
+ <resource-id >LPORT</resource-id>
<features>
<current>
<rate>10Gb</rate>
<medium>fiber</medium>
- <pause>symmetric</pause>
+ <pause>symmetric</pause>
</current>
<advertised>
<rate>10Gb</rate>
<rate>100Gb</rate>
<medium>fiber</medium>
<pause>symmetric</pause>
- </advertised>
+ </advertised>
<supported>
<rate>10Gb</rate>
<rate>100Gb</rate>
<medium>fiber</medium>
<pause>symmetric</pause>
- </supported>
+ </supported>
<advertised-peer>
<rate>10Gb</rate>
<rate>100Gb</rate>
<medium>fiber</medium>
<pause>symmetric</pause>
- </advertised-peer>
+ </advertised-peer>
</features>
<ofdpa10:vtap xmlns:ofdpa10="urn:bcm:ofdpa10:accton01" xc:operation="OPERATION">
<ofdpa10:phy-port>PHY_PORT</ofdpa10:phy-port>
<ofdpa10:vid>VLAN_ID</ofdpa10:vid>
<ofdpa10:vni>VNID</ofdpa10:vni>
</ofdpa10:vtap>
- </port>
+ </port>
</resources>
<logical-switches>
<switch>
@@ -1006,7 +1006,7 @@
</logical-switches>
</capable-switch>
</config>
- """
+ """
else:
config_vtap_xml="""
<config>
@@ -1014,37 +1014,37 @@
<id>capable-switch-1</id>
<resources>
<port xc:operation="OPERATION">
- <resource-id >LPORT</resource-id>
+ <resource-id >LPORT</resource-id>
<features>
<current>
<rate>10Gb</rate>
<medium>fiber</medium>
- <pause>symmetric</pause>
+ <pause>symmetric</pause>
</current>
<advertised>
<rate>10Gb</rate>
<rate>100Gb</rate>
<medium>fiber</medium>
<pause>symmetric</pause>
- </advertised>
+ </advertised>
<supported>
<rate>10Gb</rate>
<rate>100Gb</rate>
<medium>fiber</medium>
<pause>symmetric</pause>
- </supported>
+ </supported>
<advertised-peer>
<rate>10Gb</rate>
<rate>100Gb</rate>
<medium>fiber</medium>
<pause>symmetric</pause>
- </advertised-peer>
+ </advertised-peer>
</features>
<ofdpa10:vtap xmlns:ofdpa10="urn:bcm:ofdpa10:accton01" xc:operation="OPERATION">
<ofdpa10:phy-port>PHY_PORT</ofdpa10:phy-port>
<ofdpa10:vni>VNID</ofdpa10:vni>
</ofdpa10:vtap>
- </port>
+ </port>
</resources>
<logical-switches>
<switch>
@@ -1057,22 +1057,22 @@
</logical-switches>
</capable-switch>
</config>
- """
- str_datapath_id_f= "{:016x}".format(dp_id)
- str_datapath_id=':'.join([str_datapath_id_f[i:i+2] for i in range(0, len(str_datapath_id_f), 2)])
- config_vtap_xml=config_vtap_xml.replace("DATAPATH_ID", str_datapath_id)
- config_vtap_xml=config_vtap_xml.replace("LPORT", str(int(lport)))
- config_vtap_xml=config_vtap_xml.replace("PHY_PORT", str(phy_port))
- config_vtap_xml=config_vtap_xml.replace("VLAN_ID", str(vlan))
+ """
+ str_datapath_id_f= "{:016x}".format(dp_id)
+ str_datapath_id=':'.join([str_datapath_id_f[i:i+2] for i in range(0, len(str_datapath_id_f), 2)])
+ config_vtap_xml=config_vtap_xml.replace("DATAPATH_ID", str_datapath_id)
+ config_vtap_xml=config_vtap_xml.replace("LPORT", str(int(lport)))
+ config_vtap_xml=config_vtap_xml.replace("PHY_PORT", str(phy_port))
+ config_vtap_xml=config_vtap_xml.replace("VLAN_ID", str(vlan))
config_vtap_xml=config_vtap_xml.replace("VNID", str(vnid))
config_vtap_xml=config_vtap_xml.replace("OPERATION", str(operation))
return config_vtap_xml
-
-def get_vtep_lport_config_xml(dp_id, lport, src_ip, dst_ip, next_hop_id, vnid, udp_src_port=6633, ttl=25, operation='merge'):
+
+def get_vtep_lport_config_xml(dp_id, lport, src_ip, dst_ip, next_hop_id, vnid, udp_src_port=6633, ttl=25, operation='merge'):
"""
Command Example:
of-agent vtep 10002 source user-input-src-ip destination user-input-dst-ip udp-source-port 6633 nexthop 2 ttl 25
- of-agent vtp 10001 vni 10
+ of-agent vtp 10001 vni 10
"""
config_vtep_xml="""
@@ -1081,31 +1081,31 @@
<id>capable-switch-1</id>
<resources>
<port xc:operation="OPERATION">
- <resource-id>LPORT</resource-id>
+ <resource-id>LPORT</resource-id>
<features>
<current>
<rate>10Gb</rate>
<medium>fiber</medium>
- <pause>symmetric</pause>
+ <pause>symmetric</pause>
</current>
<advertised>
<rate>10Gb</rate>
<rate>100Gb</rate>
<medium>fiber</medium>
<pause>symmetric</pause>
- </advertised>
+ </advertised>
<supported>
<rate>10Gb</rate>
<rate>100Gb</rate>
<medium>fiber</medium>
<pause>symmetric</pause>
- </supported>
+ </supported>
<advertised-peer>
<rate>10Gb</rate>
<rate>100Gb</rate>
<medium>fiber</medium>
<pause>symmetric</pause>
- </advertised-peer>
+ </advertised-peer>
</features>
<ofdpa10:vtep xmlns:ofdpa10="urn:bcm:ofdpa10:accton01">
<ofdpa10:src-ip>SRC_IP</ofdpa10:src-ip>
@@ -1117,7 +1117,7 @@
<ofdpa10:nexthop-id>NEXT_HOP_ID</ofdpa10:nexthop-id>
<ofdpa10:ttl>TTL</ofdpa10:ttl>
</ofdpa10:vtep>
- </port>
+ </port>
</resources>
<logical-switches>
<switch>
@@ -1129,23 +1129,23 @@
</switch>
</logical-switches>
</capable-switch>
- </config>
+ </config>
"""
- str_datapath_id_f= "{:016x}".format(dp_id)
- str_datapath_id=':'.join([str_datapath_id_f[i:i+2] for i in range(0, len(str_datapath_id_f), 2)])
- config_vtep_xml=config_vtep_xml.replace("DATAPATH_ID", str_datapath_id)
+ str_datapath_id_f= "{:016x}".format(dp_id)
+ str_datapath_id=':'.join([str_datapath_id_f[i:i+2] for i in range(0, len(str_datapath_id_f), 2)])
+ config_vtep_xml=config_vtep_xml.replace("DATAPATH_ID", str_datapath_id)
config_vtep_xml=config_vtep_xml.replace("LPORT", str(int(lport)))
- config_vtep_xml=config_vtep_xml.replace("SRC_IP", str(src_ip))
- config_vtep_xml=config_vtep_xml.replace("DST_IP", str(dst_ip))
- config_vtep_xml=config_vtep_xml.replace("UDP_SRC_PORT", str(udp_src_port))
- config_vtep_xml=config_vtep_xml.replace("NEXT_HOP_ID", str(next_hop_id))
- config_vtep_xml=config_vtep_xml.replace("TTL", str(ttl))
+ config_vtep_xml=config_vtep_xml.replace("SRC_IP", str(src_ip))
+ config_vtep_xml=config_vtep_xml.replace("DST_IP", str(dst_ip))
+ config_vtep_xml=config_vtep_xml.replace("UDP_SRC_PORT", str(udp_src_port))
+ config_vtep_xml=config_vtep_xml.replace("NEXT_HOP_ID", str(next_hop_id))
+ config_vtep_xml=config_vtep_xml.replace("TTL", str(ttl))
config_vtep_xml=config_vtep_xml.replace("VNID", str(vnid))
- config_vtep_xml=config_vtep_xml.replace("OPERATION", str(operation))
+ config_vtep_xml=config_vtep_xml.replace("OPERATION", str(operation))
- return config_vtep_xml
-
-def get_next_hop_config_xml(next_hop_id, dst_mac, phy_port, vlan, operation='merge'):
+ return config_vtep_xml
+
+def get_next_hop_config_xml(next_hop_id, dst_mac, phy_port, vlan, operation='merge'):
#of-agent nexthop 2 destination user-input-dst-mac ethernet 1/2 vid 2
config_nexthop_xml="""
<config>
@@ -1160,15 +1160,15 @@
</config>
"""
config_nexthop_xml=config_nexthop_xml.replace("VLAN_ID", str(vlan))
- config_nexthop_xml=config_nexthop_xml.replace("PHY_PORT", str(phy_port))
- config_nexthop_xml=config_nexthop_xml.replace("NEXT_HOP_ID", str(next_hop_id))
- config_nexthop_xml=config_nexthop_xml.replace("DST_MAC", str(dst_mac))
- config_nexthop_xml=config_nexthop_xml.replace("OPERATION", str(operation))
- return config_nexthop_xml
+ config_nexthop_xml=config_nexthop_xml.replace("PHY_PORT", str(phy_port))
+ config_nexthop_xml=config_nexthop_xml.replace("NEXT_HOP_ID", str(next_hop_id))
+ config_nexthop_xml=config_nexthop_xml.replace("DST_MAC", str(dst_mac))
+ config_nexthop_xml=config_nexthop_xml.replace("OPERATION", str(operation))
+ return config_nexthop_xml
-def get_vni_config_xml(vni_id, mcast_ipv4, next_hop_id, operation='merge'):
+def get_vni_config_xml(vni_id, mcast_ipv4, next_hop_id, operation='merge'):
#of-agent vni 10 multicast 224.1.1.1 nexthop 20
- if mcast_ipv4!=None:
+ if mcast_ipv4!=None:
config_vni_xml="""
<config>
<of11-config:capable-switch xmlns:of11-config="urn:onf:of111:config:yang" xmlns:xc="urn:ietf:params:xml:ns:netconf:base:1.0">
@@ -1179,9 +1179,9 @@
</ofdpa10:vni>
</of11-config:capable-switch>
</config>
- """
- config_vni_xml=config_vni_xml.replace("NEXT_HOP_ID", str(next_hop_id))
- config_vni_xml=config_vni_xml.replace("MCAST_IP", str(mcast_ipv4))
+ """
+ config_vni_xml=config_vni_xml.replace("NEXT_HOP_ID", str(next_hop_id))
+ config_vni_xml=config_vni_xml.replace("MCAST_IP", str(mcast_ipv4))
else:
config_vni_xml="""
<config>
@@ -1191,29 +1191,29 @@
</ofdpa10:vni>
</of11-config:capable-switch>
</config>
- """
-
- config_vni_xml=config_vni_xml.replace("VNID", str(vni_id))
- config_vni_xml=config_vni_xml.replace("OPERATION", str(operation))
+ """
+
+ config_vni_xml=config_vni_xml.replace("VNID", str(vni_id))
+ config_vni_xml=config_vni_xml.replace("OPERATION", str(operation))
return config_vni_xml
-
-def get_featureReplay(self):
+
+def get_featureReplay(self):
req = ofp.message.features_request()
res, raw = self.controller.transact(req)
- self.assertIsNotNone(res, "Did not receive a response from the DUT.")
+ self.assertIsNotNone(res, "Did not receive a response from the DUT.")
self.assertEqual(res.type, ofp.OFPT_FEATURES_REPLY,
("Unexpected packet type %d received in response to "
"OFPT_FEATURES_REQUEST") % res.type)
- return res
-
+ return res
+
def send_edit_config(switch_ip, xml, target='runing'):
NETCONF_ACCOUNT="netconfuser"
NETCONF_PASSWD="netconfuser"
with manager.connect_ssh(host=switch_ip, port=830, username=NETCONF_ACCOUNT, password=NETCONF_PASSWD, hostkey_verify=False ) as m:
try:
- m.edit_config(target='running',
- config=xml,
- default_operation='merge',
+ m.edit_config(target='running',
+ config=xml,
+ default_operation='merge',
error_option='stop-on-error')
except Exception as e:
@@ -1228,9 +1228,9 @@
NETCONF_PASSWD="netconfuser"
with manager.connect_ssh(host=switch_ip, port=830, username=NETCONF_ACCOUNT, password=NETCONF_PASSWD, hostkey_verify=False ) as m:
try:
- m.edit_config(target='running',
- config=xml,
- default_operation='delete',
+ m.edit_config(target='running',
+ config=xml,
+ default_operation='delete',
error_option='stop-on-error')
except Exception as e:
@@ -1239,7 +1239,7 @@
#return m.get_config(source='running').data_xml
return True
-
+
def get_edit_config(switch_ip, target='runing'):
NETCONF_ACCOUNT="netconfuser"
NETCONF_PASSWD="netconfuser"
@@ -1252,7 +1252,7 @@
"""
OFDPA_MPLS_SUBTYPE_SHIFT=24
-OFDPA_MPLS_GROUP_SUBTYPE_L2_VPN_LABEL=1
+OFDPA_MPLS_GROUP_SUBTYPE_L2_VPN_LABEL=1
OFDPA_MPLS_GROUP_SUBTYPE_L3_VPN_LABEL=2
OFDPA_MPLS_GROUP_SUBTYPE_TUNNEL_LABEL1=3
OFDPA_MPLS_GROUP_SUBTYPE_TUNNEL_LABEL2=4
@@ -1274,21 +1274,21 @@
#3: mpls tunnel label 1
#4: mpls tunnel lable 2
#5: mpls swap label
- return index + (9 << OFDPA_GROUP_TYPE_SHIFT)+(subtype<<OFDPA_MPLS_SUBTYPE_SHIFT)
+ return index + (9 << OFDPA_GROUP_TYPE_SHIFT)+(subtype<<OFDPA_MPLS_SUBTYPE_SHIFT)
def encode_mpls_forwarding_group_id(subtype, index):
index=index&0x00ffffff
assert(subtype==6 or subtype==8 or subtype==10)
- return index + (10 << OFDPA_GROUP_TYPE_SHIFT)+(subtype<<OFDPA_MPLS_SUBTYPE_SHIFT)
+ return index + (10 << OFDPA_GROUP_TYPE_SHIFT)+(subtype<<OFDPA_MPLS_SUBTYPE_SHIFT)
def add_mpls_intf_group(ctrl, ref_gid, dst_mac, src_mac, vid, index, subtype=0):
action=[]
action.append(ofp.action.set_field(ofp.oxm.eth_src(src_mac)))
action.append(ofp.action.set_field(ofp.oxm.eth_dst(dst_mac)))
- action.append(ofp.action.set_field(ofp.oxm.vlan_vid(0x1000+vid)))
+ action.append(ofp.action.set_field(ofp.oxm.vlan_vid(0x1000+vid)))
action.append(ofp.action.group(ref_gid))
-
+
buckets = [ofp.bucket(actions=action)]
mpls_group_id =encode_mpls_interface_group_id(subtype, index)
@@ -1299,7 +1299,7 @@
ctrl.message_send(request)
return mpls_group_id, request
-def add_mpls_label_group(ctrl, subtype, index, ref_gid,
+def add_mpls_label_group(ctrl, subtype, index, ref_gid,
lmep_id=-1,
qos_index=-1,
push_l2_header=False,
@@ -1318,7 +1318,7 @@
):
"""
@ref_gid: only can be mpls intf group or mpls tunnel label 1/2 group
- """
+ """
action=[]
if push_vlan== True:
@@ -1333,44 +1333,44 @@
assert(set_tc_from_table==False)
action.append(ofp.action.set_field(ofp.oxm.mpls_tc(set_tc)))
if set_ttl != None:
- action.append(ofp.action.set_mpls_ttl(set_ttl))
+ action.append(ofp.action.set_mpls_ttl(set_ttl))
if cpy_ttl_outward == True:
- action.append(ofp.action.copy_ttl_out())
+ action.append(ofp.action.copy_ttl_out())
"""
ofdpa experimenter
- """
+ """
if push_l2_header== True:
- action.append(ofp.action.ofdpa_push_l2_header())
+ action.append(ofp.action.ofdpa_push_l2_header())
if set_tc_from_table== True:
assert(qos_index>=0)
assert(set_tc == None)
- action.append(ofp.action.ofdpa_set_tc_from_table(qos_index))
+ action.append(ofp.action.ofdpa_set_tc_from_table(qos_index))
if cpy_tc_outward == True:
- action.append(ofp.action.ofdpa_copy_tc_out())
+ action.append(ofp.action.ofdpa_copy_tc_out())
if oam_lm_tx_count == True:
- assert(qos_index>=0 and lmep_id>=0)
- action.append(ofp.action.ofdpa_oam_lm_tx_count(lmep_id, qos_index))
+ assert(qos_index>=0 and lmep_id>=0)
+ action.append(ofp.action.ofdpa_oam_lm_tx_count(lmep_id, qos_index))
if set_pri_from_table == True:
- assert(qos_index>=0)
- action.append(ofp.action.ofdpa_set_qos_from_table(qos_index))
+ assert(qos_index>=0)
+ action.append(ofp.action.ofdpa_set_qos_from_table(qos_index))
if push_cw == True:
action.append(ofp.action.ofdpa_push_cw())
-
- action.append(ofp.action.group(ref_gid))
+
+ action.append(ofp.action.group(ref_gid))
buckets = [ofp.bucket(actions=action)]
-
+
mpls_group_id = encode_mpls_label_group_id(subtype, index)
request = ofp.message.group_add(group_type=ofp.OFPGT_INDIRECT,
group_id=mpls_group_id,
buckets=buckets
)
ctrl.message_send(request)
-
- return mpls_group_id, request
-
-def add_mpls_forwarding_group(ctrl, subtype, index, ref_gids,
- watch_port=None,
- watch_group=ofp.OFPP_ANY,
+
+ return mpls_group_id, request
+
+def add_mpls_forwarding_group(ctrl, subtype, index, ref_gids,
+ watch_port=None,
+ watch_group=ofp.OFPP_ANY,
push_vlan=None,
pop_vlan=None,
set_vid=None):
@@ -1383,14 +1383,14 @@
group_type = ofp.OFPGT_FF
for gid in ref_gids:
action=[]
- action.append(ofp.action.group(gid))
+ action.append(ofp.action.group(gid))
buckets.append(ofp.bucket(watch_port=watch_port, watch_group=watch_group,actions=action))
elif subtype == OFDPA_MPLS_GROUP_SUBTYPE_ECMP:
group_type = ofp.OFPGT_SELECT
for gid in ref_gids:
action=[]
- action.append(ofp.action.group(gid))
+ action.append(ofp.action.group(gid))
buckets.append(ofp.bucket(actions=action))
elif subtype == OFDPA_MPLS_GROUP_SUBTYPE_L2_TAG:
@@ -1399,10 +1399,10 @@
if set_vid!=None:
action.append(ofp.action.set_field(ofp.oxm.vlan_vid(0x1000+set_vid)))
if push_vlan!=None:
- action.append(ofp.action.push_vlan(push_vlan))
+ action.append(ofp.action.push_vlan(push_vlan))
if pop_vlan!=None:
- action.append(ofp.action.pop_vlan())
- action.append(ofp.action.group(ref_gids[0]))
+ action.append(ofp.action.pop_vlan())
+ action.append(ofp.action.group(ref_gids[0]))
buckets.append(ofp.bucket(actions=action))
mpls_group_id = encode_mpls_forwarding_group_id(subtype, index)
@@ -1411,12 +1411,12 @@
buckets=buckets
)
ctrl.message_send(request)
- return mpls_group_id, request
+ return mpls_group_id, request
"""
dislay
-"""
+"""
def print_current_table_flow_stat(ctrl, table_id=0xff):
stat_req=ofp.message.flow_stats_request()
response, pkt = ctrl.transact(stat_req)
diff --git a/ofdpa/README.md b/ofdpa/README.md
deleted file mode 100755
index 403ef59..0000000
--- a/ofdpa/README.md
+++ /dev/null
@@ -1,33 +0,0 @@
-Run the following command from the oftest folder
-
- sudo ./oft -V1.3 --test-dir=ofdpa onos -i 33@ethX -i 34@ethY
-
-Where 33 is the Openflow port you want to test, and ethX identifies the interface connected to it.
-
-The onos filename was chosen because these tests are being made to guarantee conformance with ONOS southbound API.
-
-The following test cases are implemented:
-
-The following tests are being done here
-- PacketIn UDP
-- PacketIn ARP
-3. PacketIn from IP table
-4. L2FloodQinQ
-5. L2 Unicast Tagged
-6. MTU 1500
-7. /32 L3 Unicast
-8. /32 L3 VPN initiation
-9. /32 L3 ECMP + VPN
-10. /32 L3 ECMP forwarding + L3 unicast
-11. /24 L3 Unicast
-12. /24 L3 VPN initiation
-13. /24 L3 ECMP + VPN
-14. /24 L3 ECMP forwarding + L3 unicast
-15. Multicast same VLAN
-16. Multicast different VLANS
-17. MPLS forwarding
-18. MPLS termination
-19. /0 Unicast
-20. Unfiltered group (Incomplete)
-21. Multicast to VPN initiation
-22. PacketInSrcMacMiss
diff --git a/ofdpa/flows.py b/ofdpa/flows.py
index c03c933..dc5d2e9 100755
--- a/ofdpa/flows.py
+++ b/ofdpa/flows.py
@@ -10,6 +10,7 @@
import ofp
from oftest.testutils import *
from accton_util import *
+from utils import *
class PacketInUDP( base_tests.SimpleDataPlane ):
@@ -935,145 +936,77 @@
delete_all_flows( self.controller )
delete_groups( self.controller, Groups )
-
-class L3McastToL2( base_tests.SimpleDataPlane ):
- """ Mcast routing in the same vlan """
-
- def runTest( self ):
- """
- port1 (vlan 300)-> All Ports (vlan 300)
- """
- Groups = Queue.LifoQueue( )
- try:
- if len( config[ "port_map" ] ) < 3:
- logging.info( "Port count less than 3, can't run this case" )
- assert (False)
- return
- vlan_id = 300
- intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
- intf_src_mac_str = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
- dst_mac = [ 0x01, 0x00, 0x5e, 0x01, 0x01, 0x01 ]
- dst_mac_str = ':'.join( [ '%02X' % x for x in dst_mac ] )
- port1_mac = [ 0x00, 0x11, 0x11, 0x11, 0x11, 0x11 ]
- port1_mac_str = ':'.join( [ '%02X' % x for x in port1_mac ] )
- src_ip = 0xc0a80101
- src_ip_str = "192.168.1.1"
- dst_ip = 0xe0010101
- dst_ip_str = "224.1.1.1"
-
- port1 = config[ "port_map" ].keys( )[ 0 ]
- port2 = config[ "port_map" ].keys( )[ 1 ]
-
- switch_mac = [ 0x01, 0x00, 0x5e, 0x00, 0x00, 0x00 ]
-
- # add l2 interface group
- l2_intf_group_list = [ ]
- for port in config[ "port_map" ].keys( ):
- add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
- if port == port2:
- continue
- l2_intf_gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id,
- is_tagged=True, send_barrier=False )
- l2_intf_group_list.append( l2_intf_gid )
- Groups.put( l2_intf_gid )
-
- # add termination flow
- add_termination_flow( self.controller, port1, 0x0800, switch_mac, vlan_id )
-
- # add l3 interface group
- mcat_group_msg = add_l3_mcast_group( self.controller, vlan_id, 2, l2_intf_group_list )
- add_mcast4_routing_flow( self.controller, vlan_id, src_ip, 0, dst_ip, mcat_group_msg.group_id )
- Groups._put( mcat_group_msg.group_id )
-
- parsed_pkt = simple_udp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=vlan_id,
- eth_dst=dst_mac_str, eth_src=port1_mac_str, ip_ttl=64, ip_src=src_ip_str,
- ip_dst=dst_ip_str )
- pkt = str( parsed_pkt )
- self.dataplane.send( port1, pkt )
- for port in config[ "port_map" ].keys( ):
- if port == port2 or port == port1:
- verify_no_packet( self, pkt, port )
- continue
- verify_packet( self, pkt, port )
- verify_no_other_packets( self )
- finally:
- delete_all_flows( self.controller )
- delete_groups( self.controller, Groups )
- delete_all_groups( self.controller )
-
-
class L3McastToL3( base_tests.SimpleDataPlane ):
- """ Mcast routing on different vlans"""
-
+ """
+ Mcast routing, in this test case the traffic comes in tagged.
+ port+1 is used as ingress vlan_id. The packet goes out tagged on
+ different ports. 4094-port is used as egress vlan_id.
+ """
def runTest( self ):
- """
- port1 (vlan 1)-> port 2 (vlan 2)
- """
Groups = Queue.LifoQueue( )
try:
- if len( config[ "port_map" ] ) < 3:
- logging.info( "Port count less than 3, can't run this case" )
+ # We can forward on the in_port but egress_vlan has to be different from ingress_vlan
+ if len( config[ "port_map" ] ) < 1:
+ logging.info( "Port count less than 1, can't run this case" )
assert (False)
return
+ ports = config[ "port_map" ].keys( )
+ dst_ip_str = "224.0.0.1"
+ (
+ port_to_in_vlan,
+ port_to_out_vlan,
+ port_to_src_mac_str,
+ port_to_dst_mac_str,
+ port_to_src_ip_str,
+ port_to_intf_src_mac_str,
+ Groups) = fill_mcast_pipeline_L3toL3(
+ self.controller,
+ logging,
+ ports,
+ is_ingress_tagged = True,
+ is_egress_tagged = True,
+ is_vlan_translated = True,
+ is_max_vlan = False
+ )
- vlan_id = 1
- port2_out_vlan = 2
- port3_out_vlan = 3
- in_vlan = 1 # macast group vid shall use input vlan diffe from l3 interface use output vlan
- intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, 0xcc ]
- intf_src_mac_str = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
- dst_mac = [ 0x01, 0x00, 0x5e, 0x01, 0x01, 0x01 ]
- dst_mac_str = ':'.join( [ '%02X' % x for x in dst_mac ] )
- port1_mac = [ 0x00, 0x11, 0x11, 0x11, 0x11, 0x11 ]
- port1_mac_str = ':'.join( [ '%02X' % x for x in port1_mac ] )
- src_ip = 0xc0a80101
- src_ip_str = "192.168.1.1"
- dst_ip = 0xe0010101
- dst_ip_str = "224.1.1.1"
+ for in_port in ports:
- port1 = config[ "port_map" ].keys( )[ 0 ]
- port2 = config[ "port_map" ].keys( )[ 1 ]
- port3 = config[ "port_map" ].keys( )[ 2 ]
+ parsed_pkt = simple_udp_packet(
+ pktlen = 100,
+ dl_vlan_enable = True,
+ vlan_vid = port_to_in_vlan[in_port],
+ eth_dst = port_to_dst_mac_str[in_port],
+ eth_src = port_to_src_mac_str[in_port],
+ ip_ttl = 64,
+ ip_src = port_to_src_ip_str[in_port],
+ ip_dst = dst_ip_str
+ )
+ pkt = str( parsed_pkt )
+ self.dataplane.send( in_port, pkt )
- # add l2 interface group
- for port in config[ "port_map" ].keys( ):
- l2gid, msg = add_one_l2_interface_group( self.controller, port, vlan_id=vlan_id,
- is_tagged=False, send_barrier=False )
- # add vlan flow table
- add_one_vlan_table_flow( self.controller, port, vlan_id, flag=VLAN_TABLE_FLAG_ONLY_TAG )
- vlan_id += 1
- Groups._put( l2gid )
+ for out_port in ports:
- # add termination flow
- add_termination_flow( self.controller, port1, 0x0800, [ 0x01, 0x00, 0x5e, 0x00, 0x00, 0x00 ],
- vlan_id )
+ parsed_pkt = simple_udp_packet(
+ pktlen = 100,
+ dl_vlan_enable = True,
+ vlan_vid = port_to_out_vlan[out_port],
+ eth_dst = port_to_dst_mac_str[in_port],
+ eth_src = port_to_intf_src_mac_str[out_port],
+ ip_ttl = 63,
+ ip_src = port_to_src_ip_str[in_port],
+ ip_dst = dst_ip_str
+ )
+ pkt = str( parsed_pkt )
+ verify_packet( self, pkt, out_port )
- # add l3 interface group
- port2_ucast_msg = add_l3_interface_group( self.controller, port2, port2_out_vlan, 2,
- intf_src_mac )
- port3_ucast_msg = add_l3_interface_group( self.controller, port3, port3_out_vlan, 3,
- intf_src_mac )
- mcat_group_msg = add_l3_mcast_group( self.controller, in_vlan, 2,
- [ port2_ucast_msg.group_id, port3_ucast_msg.group_id ] )
- add_mcast4_routing_flow( self.controller, in_vlan, src_ip, 0, dst_ip, mcat_group_msg.group_id )
- Groups._put( port2_ucast_msg.group_id )
- Groups._put( port3_ucast_msg.group_id )
- Groups._put( mcat_group_msg.group_id )
- parsed_pkt = simple_udp_packet( pktlen=100, dl_vlan_enable=True, vlan_vid=1, eth_dst=dst_mac_str,
- eth_src=port1_mac_str, ip_ttl=64, ip_src=src_ip_str, ip_dst=dst_ip_str )
- pkt = str( parsed_pkt )
- self.dataplane.send( port1, pkt )
- parsed_pkt = simple_udp_packet( pktlen=96, eth_dst=dst_mac_str, eth_src=intf_src_mac_str,
- ip_ttl=63, ip_src=src_ip_str, ip_dst=dst_ip_str )
- pkt = str( parsed_pkt )
- verify_packet( self, pkt, port2 )
- verify_packet( self, pkt, port3 )
- verify_no_other_packets( self )
+ verify_no_other_packets( self )
+
finally:
delete_all_flows( self.controller )
delete_groups( self.controller, Groups )
delete_all_groups( self.controller )
+
class _MplsFwd( base_tests.SimpleDataPlane ):
""" Verify basic MPLS forwarding: Label switch router """
diff --git a/ofdpa/utils.py b/ofdpa/utils.py
new file mode 100644
index 0000000..5bbce7f
--- /dev/null
+++ b/ofdpa/utils.py
@@ -0,0 +1,102 @@
+import Queue
+
+from oftest.testutils import *
+from accton_util import *
+
+def fill_mcast_pipeline_L3toL3(
+ controller,
+ logging,
+ ports,
+ is_ingress_tagged,
+ is_egress_tagged,
+ is_vlan_translated,
+ is_max_vlan
+ ):
+ """
+ This method, according to the scenario, fills properly
+ the pipeline. The method generates using ports data the
+ necessary information to fill the multicast pipeline and
+ fills properly the pipeline which consists in this scenario:
+
+ i) to create l2 interface groups;
+ ii)to create l3 interface groups;
+ iii) to create l3 multicast groups;
+ iv) to add multicast flows;
+ v) to add termination; flows;
+ vi) to add vlan flows
+
+ Scenarios:
+ 1) ingress tagged, egress tagged, translation
+ """
+
+ Groups = Queue.LifoQueue( )
+ MAX_INTERNAL_VLAN = 4094
+ port_to_in_vlan = {}
+ port_to_out_vlan = {}
+ port_to_src_mac = {}
+ port_to_src_mac_str = {}
+ port_to_dst_mac = {}
+ port_to_dst_mac_str = {}
+ port_to_src_ip = {}
+ port_to_src_ip_str = {}
+ port_to_intf_src_mac = {}
+ port_to_intf_src_mac_str = {}
+ src_ip_0 = 0xc0a80100
+ src_ip_0_str = "192.168.1.%s"
+ dst_ip = 0xe0000001
+ switch_mac = [ 0x01, 0x00, 0x5e, 0x00, 0x00, 0x00 ]
+
+ for port in ports:
+ in_vlan_id = port + 1
+ out_vlan_id = MAX_INTERNAL_VLAN - port
+ src_mac = [ 0x00, 0x11, 0x11, 0x11, 0x11, port ]
+ src_mac_str = ':'.join( [ '%02X' % x for x in src_mac ] )
+ dst_mac = [ 0x01, 0x00, 0x5e, 0x01, 0x01, port ]
+ dst_mac_str = ':'.join( [ '%02X' % x for x in dst_mac ] )
+ src_ip = src_ip_0 + port
+ src_ip_str = src_ip_0_str % port
+ intf_src_mac = [ 0x00, 0x00, 0x00, 0xcc, 0xcc, port ]
+ intf_src_mac_str = ':'.join( [ '%02X' % x for x in intf_src_mac ] )
+ port_to_in_vlan[port] = in_vlan_id
+ port_to_out_vlan[port] = out_vlan_id
+ port_to_src_mac[port] = src_mac
+ port_to_src_mac_str[port] = src_mac_str
+ port_to_dst_mac[port] = dst_mac
+ port_to_dst_mac_str[port] = dst_mac_str
+ port_to_src_ip[port] = src_ip
+ port_to_src_ip_str[port] = src_ip_str
+ port_to_intf_src_mac[port] = intf_src_mac
+ port_to_intf_src_mac_str[port] = intf_src_mac_str
+
+ for port in ports:
+ L3_Groups = []
+ for other_port in ports:
+ # add l2 interface group
+ l2gid, msg = add_one_l2_interface_group( controller, other_port, vlan_id=port_to_out_vlan[other_port],
+ is_tagged=True, send_barrier=False )
+ Groups._put( l2gid )
+ # add l3 interface group
+ l3group_ucast_msg = add_l3_interface_group( controller, other_port, port_to_out_vlan[other_port], port_to_in_vlan[other_port],
+ port_to_intf_src_mac[other_port] )
+ L3_Groups.append(l3group_ucast_msg.group_id)
+ Groups._put( l3group_ucast_msg.group_id )
+
+ # add mcast group
+ mcat_group_msg = add_l3_mcast_group( controller, port_to_in_vlan[port], port_to_in_vlan[port], L3_Groups )
+ Groups._put( mcat_group_msg.group_id )
+ # add mcast flow
+ add_mcast4_routing_flow( controller, port_to_in_vlan[port], port_to_src_ip[port], 0, dst_ip, mcat_group_msg.group_id )
+ # add termination flow
+ add_termination_flow( controller, port, 0x0800, switch_mac, port_to_in_vlan[port] )
+ # add vlan flow table
+ add_one_vlan_table_flow( controller, port, port_to_in_vlan[port], flag=VLAN_TABLE_FLAG_ONLY_TAG )
+
+ return (
+ port_to_in_vlan,
+ port_to_out_vlan,
+ port_to_src_mac_str,
+ port_to_dst_mac_str,
+ port_to_src_ip_str,
+ port_to_intf_src_mac_str,
+ Groups
+ )
\ No newline at end of file