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>
This commit is contained in:
YAMAMOTO Takashi 2013-09-02 12:09:54 +09:00 committed by FUJITA Tomonori
parent 8c6c2e458a
commit c737364230
2 changed files with 10 additions and 0 deletions

View File

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

View File

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