explicitly desupport repeated serializations of an OFPMatch composed
with old API, rather than silently producing corrupted packets.

Signed-off-by: YAMAMOTO Takashi <[email protected]>
---
 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 382cc32..d99ca22 100644
--- a/ryu/ofproto/ofproto_v1_2_parser.py
+++ b/ryu/ofproto/ofproto_v1_2_parser.py
@@ -3445,6 +3445,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 3b5a4b4..c09283d 100644
--- a/ryu/ofproto/ofproto_v1_3_parser.py
+++ b/ryu/ofproto/ofproto_v1_3_parser.py
@@ -863,6 +863,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)
-- 
1.8.3.1


------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to