Added test for mpls swap functionality
Change-Id: I9e4e1a9c5935740ddaffd569a40c740a01178c17
diff --git a/accton/accton_util.py b/accton/accton_util.py
index dd01dd1..ac729a4 100755
--- a/accton/accton_util.py
+++ b/accton/accton_util.py
@@ -1089,7 +1089,6 @@
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)
@@ -1163,7 +1162,7 @@
return request
-def add_mpls_flow(ctrl, action_group_id=0x0, label=100 ,ethertype=0x0800, bos=1, vrf=1, goto_table=27, send_barrier=False):
+def add_mpls_flow(ctrl, action_group_id=0x0, label=100 ,ethertype=0x0800, bos=1, vrf=1, goto_table=27, dec_ttl=False, send_barrier=False):
match = ofp.match()
match.oxm_list.append(ofp.oxm.eth_type(0x8847))
match.oxm_list.append(ofp.oxm.mpls_label(label))
@@ -1225,6 +1224,38 @@
return request
+def add_mpls_flow_swap(ctrl, action_group_id, label, ethertype, bos, goto_table=MPLS_TYPE_FLOW_TABLE, of_port=0, send_barrier=False):
+ match = ofp.match()
+ match.oxm_list.append(ofp.oxm.eth_type(0x8847))
+ match.oxm_list.append(ofp.oxm.mpls_label(label))
+ match.oxm_list.append(ofp.oxm.mpls_bos(1))
+
+ apply_actions = []
+ write_actions = []
+ apply_actions.append(ofp.action.dec_mpls_ttl())
+ write_actions.append(ofp.action.group(action_group_id))
+
+ request = ofp.message.flow_add(
+ table_id=24,
+ cookie=43,
+ match=match,
+ instructions=[
+ ofp.instruction.apply_actions(actions=apply_actions),
+ ofp.instruction.write_actions(actions=write_actions),
+ ofp.instruction.goto_table(goto_table)
+ ],
+ buffer_id=ofp.OFP_NO_BUFFER,
+ priority=1)
+
+ logging.info("Inserting MPLS flow , label %ld", label)
+ ctrl.message_send(request)
+
+ if send_barrier:
+ do_barrier(ctrl)
+
+ return request
+
+
def add_mpls_flow_pw(ctrl, action_group_id, label, ethertype, bos, tunnel_index, goto_table=MPLS_TYPE_FLOW_TABLE, popMPLS=True, popL2=False, of_port=0, send_barrier=False):
match = ofp.match()
match.oxm_list.append(ofp.oxm.eth_type(0x8847))
@@ -1723,11 +1754,12 @@
group_id=mpls_group_id,
buckets=buckets
)
+
+ logging.debug("Adding MPLS interface group %02x, src_mac %s , dst_mac %s , vid %d", mpls_group_id, src_mac, dst_mac, vid)
ctrl.message_send(request)
if send_barrier:
do_barrier(ctrl)
-
return mpls_group_id, request
def add_mpls_tunnel_label_group(
@@ -1771,6 +1803,7 @@
group_id=mpls_group_id,
buckets=buckets
)
+ logging.debug("Adding MPLS Swap group %02x, label %d", mpls_group_id, label)
ctrl.message_send(request)
return mpls_group_id, request