The calculation of padding size was wrong. Calculate correct padding size.

Following the sample frame.

0000  00 23 5d 76 13 c2 00 26  b9 76 5c 81 08 00 45 00
0010  00 a4 43 8b 40 00 40 06  5e c0 ac 10 03 21 ac 11
0020  3c c6 19 e9 ae 7a 18 cf  dd ef d7 26 45 ec 80 18
0030  00 7a 98 9f 00 00 01 01  08 0a 50 db 9e 5e 01 30
0040  7e 3d

            03 0e 00 70 e4 f7  ea 88
            Start of OF packet

                                     00 00 00 00 00 00
0050  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
0060  00 00 ff ff ff ff ff ff  ff ff ff ff ff ff 00 00
                                                 flags

0070  00 00
      pad

            00 01 00 0c 80 00  00 04 00 00 00 01 00 00
            type  len   oxm_header   value
            ofp_match   in_port
            Start of matching
                        Start of OXM TLV

0080  00 00

            00 04 00 30 00 00  00 00
            type  len   pad[4]
            apply_actions
            start of instruction

                                     00 19 00 18
                                     type  len
                                     start of set_field

                                                 80 00
                                                 oxm_header
                                                 oxm class
0090  08 06
      ETH_SRC

            22 22 22 22 22 22  00 00
                                      00 00 00 00 00 00
                                      <--Wrong padding-
00a0  00 00
      ---->
             00 00 00 10 00 00  00 02 05 dc 00 00 00 00
             type  len   port         maxlen
             start of ofp_action_output

00b0  00 00

Signed-off-by: Isaku Yamahata <[email protected]>
---
 ryu/ofproto/ofproto_v1_2_parser.py |   12 +++++-------
 1 files changed, 5 insertions(+), 7 deletions(-)

diff --git a/ryu/ofproto/ofproto_v1_2_parser.py 
b/ryu/ofproto/ofproto_v1_2_parser.py
index 02ea421..de5d9b9 100644
--- a/ryu/ofproto/ofproto_v1_2_parser.py
+++ b/ryu/ofproto/ofproto_v1_2_parser.py
@@ -735,16 +735,14 @@ class OFPActionSetField(OFPAction):
         return action
 
     def serialize(self, buf, offset):
-        oxm_len = self.field.oxm_len()
-        oxm_pad = utils.round_up(oxm_len + 4, 8) - (oxm_len + 4)
-        self.len = ofproto_v1_2.OFP_ACTION_SET_FIELD_SIZE + oxm_len + oxm_pad
-        pad_len = utils.round_up(self.len, 8) - self.len
-        self.len += pad_len
+        len_ = ofproto_v1_2.OFP_ACTION_SET_FIELD_SIZE + self.field.oxm_len()
+        self.len = utils.round_up(len_, 8)
+        pad_len = self.len - len_
 
         msg_pack_into('!HH', buf, offset, self.type, self.len)
         self.field.serialize(buf, offset + 4)
-        offset += ofproto_v1_2.OFP_ACTION_SET_FIELD_SIZE + oxm_len
-        ofproto_parser.msg_pack_into("%dx" % (oxm_pad + pad_len), buf, offset)
+        offset += len_
+        ofproto_parser.msg_pack_into("%dx" % pad_len, buf, offset)
 
 
 @OFPAction.register_action_type(
-- 
1.7.1.1


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to