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>
This commit is contained in:
Wei-Li Tang 2013-11-06 15:01:35 +08:00 committed by FUJITA Tomonori
parent 805ae1f796
commit fb846daa7a

View File

@ -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)