summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYAMAMOTO Takashi <yamamoto@valinux.co.jp>2013-09-02 12:09:54 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2013-09-14 08:01:34 +0900
commitc737364230652fffd4b9d986cd0d8b1762457532 (patch)
tree14b6b8398d0396524c9b6068cb34e6214264941a
parent8c6c2e458a1119a8ab541a1d82d187c76b43e70e (diff)
ofproto: raise an exception for unsupported operation
explicitly desupport repeated serializations of an OFPMatch composed with old API, rather than silently producing corrupted packets. Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp>
-rw-r--r--ryu/ofproto/ofproto_v1_2_parser.py5
-rw-r--r--ryu/ofproto/ofproto_v1_3_parser.py5
2 files changed, 10 insertions, 0 deletions
diff --git a/ryu/ofproto/ofproto_v1_2_parser.py b/ryu/ofproto/ofproto_v1_2_parser.py
index c055ae80..c066d518 100644
--- a/ryu/ofproto/ofproto_v1_2_parser.py
+++ b/ryu/ofproto/ofproto_v1_2_parser.py
@@ -3454,6 +3454,11 @@ class OFPMatch(StringifyMixin):
return length + pad_len
def serialize_old(self, buf, offset):
+ if hasattr(self, '_serialized'):
+ raise Exception('serializing an OFPMatch composed with '
+ 'old API multiple times is not supported')
+ self._serialized = True
+
if self._wc.ft_test(ofproto_v1_2.OFPXMT_OFB_IN_PORT):
self.append_field(ofproto_v1_2.OXM_OF_IN_PORT,
self._flow.in_port)
diff --git a/ryu/ofproto/ofproto_v1_3_parser.py b/ryu/ofproto/ofproto_v1_3_parser.py
index 743eb85f..7d13c656 100644
--- a/ryu/ofproto/ofproto_v1_3_parser.py
+++ b/ryu/ofproto/ofproto_v1_3_parser.py
@@ -876,6 +876,11 @@ class OFPMatch(StringifyMixin):
return length + pad_len
def serialize_old(self, buf, offset):
+ if hasattr(self, '_serialized'):
+ raise Exception('serializing an OFPMatch composed with '
+ 'old API multiple times is not supported')
+ self._serialized = True
+
if self._wc.ft_test(ofproto_v1_3.OFPXMT_OFB_IN_PORT):
self.append_field(ofproto_v1_3.OXM_OF_IN_PORT,
self._flow.in_port)