summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorWei-Li Tang <alextwl@xinguard.com>2013-11-06 15:01:35 +0800
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2013-11-07 14:24:42 +0900
commitfb846daa7ac3a306e5a7292d0cc01270696cf499 (patch)
tree5de1ca6db197ae2cfa0cb33b1ae20bd329c4680b
parent805ae1f7964706b04d6d7dcfb4555276f4eabde5 (diff)
ofctl_rest.py: Fix compatibily for both OF 1.0 & 1.3 datapaths.
dp.ofproto.OFP_VERSION is a single value which represents only one version, so determining OFP_VERSION by two 'if's breaks compatibility for both OF 1.0 & 1.3 datapaths. The patch fixes get_flow_stats & mod_flow_entry broken in OF1.0 dp and get_desc_stats, get_port_stats & delete_flow_entry broken in OF1.3 dp. It makes delete_flow_entry as a flow mod wrapper with empty flow entry for 1.3 instead of adding more methods into ofctl_v1_3.py. This is based on my last patch to ofctl_v1_3.py. Signed-off-by: Wei-Li Tang <alextwl@xinguard.com> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--ryu/app/ofctl_rest.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/ryu/app/ofctl_rest.py b/ryu/app/ofctl_rest.py
index 4e3e46f4..9840b0f0 100644
--- a/ryu/app/ofctl_rest.py
+++ b/ryu/app/ofctl_rest.py
@@ -82,6 +82,8 @@ class StatsController(ControllerBase):
if dp.ofproto.OFP_VERSION == ofproto_v1_0.OFP_VERSION:
desc = ofctl_v1_0.get_desc_stats(dp, self.waiters)
+ elif dp.ofproto.OFP_VERSION == ofproto_v1_3.OFP_VERSION:
+ desc = ofctl_v1_3.get_desc_stats(dp, self.waiters)
else:
LOG.debug('Unsupported OF protocol')
return Response(status=501)
@@ -96,7 +98,7 @@ class StatsController(ControllerBase):
if dp.ofproto.OFP_VERSION == ofproto_v1_0.OFP_VERSION:
flows = ofctl_v1_0.get_flow_stats(dp, self.waiters)
- if dp.ofproto.OFP_VERSION == ofproto_v1_3.OFP_VERSION:
+ elif dp.ofproto.OFP_VERSION == ofproto_v1_3.OFP_VERSION:
flows = ofctl_v1_3.get_flow_stats(dp, self.waiters)
else:
LOG.debug('Unsupported OF protocol')
@@ -112,6 +114,8 @@ class StatsController(ControllerBase):
if dp.ofproto.OFP_VERSION == ofproto_v1_0.OFP_VERSION:
ports = ofctl_v1_0.get_port_stats(dp, self.waiters)
+ elif dp.ofproto.OFP_VERSION == ofproto_v1_3.OFP_VERSION:
+ ports = ofctl_v1_3.get_port_stats(dp, self.waiters)
else:
LOG.debug('Unsupported OF protocol')
return Response(status=501)
@@ -142,7 +146,7 @@ class StatsController(ControllerBase):
if dp.ofproto.OFP_VERSION == ofproto_v1_0.OFP_VERSION:
ofctl_v1_0.mod_flow_entry(dp, flow, cmd)
- if dp.ofproto.OFP_VERSION == ofproto_v1_3.OFP_VERSION:
+ elif dp.ofproto.OFP_VERSION == ofproto_v1_3.OFP_VERSION:
ofctl_v1_3.mod_flow_entry(dp, flow, cmd)
else:
LOG.debug('Unsupported OF protocol')
@@ -157,6 +161,8 @@ class StatsController(ControllerBase):
if dp.ofproto.OFP_VERSION == ofproto_v1_0.OFP_VERSION:
ofctl_v1_0.delete_flow_entry(dp)
+ elif dp.ofproto.OFP_VERSION == ofproto_v1_3.OFP_VERSION:
+ ofctl_v1_3.mod_flow_entry(dp, {}, dp.ofproto.OFPFC_DELETE)
else:
LOG.debug('Unsupported OF protocol')
return Response(status=501)