From 1ba7f6c63f94a825d4412b712d078abbea9f4282 Mon Sep 17 00:00:00 2001
From: Srini Seetharaman <srini.seetharaman@gmail.com>
Date: Sat, 21 Dec 2013 09:16:39 -0800
Subject: [PATCH] 1. Fixing incorrect match_append in to_match() of
 ofctl_v1_3.py 2. Setting the default priority 32768 for the
 FlowMod in OF1.3

Signed-off-by: Srini Seetharaman <srini.seetharaman@gmail.com>
---
 ryu/lib/ofctl_v1_3.py              |    2 +-
 ryu/ofproto/ofproto_v1_3.py        |    3 +++
 ryu/ofproto/ofproto_v1_3_parser.py |    3 ++-
 3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/ryu/lib/ofctl_v1_3.py b/ryu/lib/ofctl_v1_3.py
index 37f67d0..7f67a71 100644
--- a/ryu/lib/ofctl_v1_3.py
+++ b/ryu/lib/ofctl_v1_3.py
@@ -238,7 +238,7 @@ def to_match(dp, attrs):
                 match_append[key](ip, mask)
             elif key == 'tp_src' or key == 'tp_dst':
                 # tp_src/dst
-                match = match_append[key](value, match, attrs)
+                match_append[key](value, match, attrs)
             elif key == 'metadata':
                 # metadata
                 metadata = value[0]
diff --git a/ryu/ofproto/ofproto_v1_3.py b/ryu/ofproto/ofproto_v1_3.py
index 95c03c7..e7a8593 100644
--- a/ryu/ofproto/ofproto_v1_3.py
+++ b/ryu/ofproto/ofproto_v1_3.py
@@ -357,6 +357,9 @@ OFPFC_MODIFY_STRICT = 2    # Modify entry strictly matching wildcards
 OFPFC_DELETE = 3    # Delete all matching flows.
 OFPFC_DELETE_STRICT = 4    # Strictly match wildcards and priority.
 
+# By default, choose a priority in the middle.
+OFP_DEFAULT_PRIORITY = 0x8000
+
 # enum ofp_flow_mod_flags
 OFPFF_SEND_FLOW_REM = 1 << 0    # Send flow removed message when flow
                                 # expires or is deleted.
diff --git a/ryu/ofproto/ofproto_v1_3_parser.py b/ryu/ofproto/ofproto_v1_3_parser.py
index 3d1c110..78ad9fc 100644
--- a/ryu/ofproto/ofproto_v1_3_parser.py
+++ b/ryu/ofproto/ofproto_v1_3_parser.py
@@ -2359,7 +2359,8 @@ class OFPFlowMod(MsgBase):
     """
     def __init__(self, datapath, cookie=0, cookie_mask=0, table_id=0,
                  command=ofproto_v1_3.OFPFC_ADD,
-                 idle_timeout=0, hard_timeout=0, priority=0,
+                 idle_timeout=0, hard_timeout=0,
+                 priority=ofproto_v1_3.OFP_DEFAULT_PRIORITY,
                  buffer_id=ofproto_v1_3.OFP_NO_BUFFER,
                  out_port=0, out_group=0, flags=0,
                  match=None,
-- 
1.7.9

