From c737364230652fffd4b9d986cd0d8b1762457532 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Mon, 2 Sep 2013 12:09:54 +0900 Subject: [PATCH] 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 --- ryu/ofproto/ofproto_v1_2_parser.py | 5 +++++ ryu/ofproto/ofproto_v1_3_parser.py | 5 +++++ 2 files changed, 10 insertions(+) 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)