summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorIsaku Yamahata <yamahata@valinux.co.jp>2012-07-12 11:04:22 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2012-07-12 11:36:22 +0900
commit007d735ec1f6381dd5466805ad752a3a13081297 (patch)
tree4608689f7ebe3b77e0ccbebb18449b00766950f5
parentda26715d80845d9aef21dbed61853c629a195663 (diff)
of1.2: OFPSetField serializer pads too much
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 <yamahata@valinux.co.jp> Reviewed-by: Simon Horman <horms@verge.net.au> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--ryu/ofproto/ofproto_v1_2_parser.py12
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 b456de33..1f437d5d 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(