summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--ryu/ofproto/ofproto_v1_3.py4
-rw-r--r--ryu/ofproto/ofproto_v1_3_parser.py13
2 files changed, 13 insertions, 4 deletions
diff --git a/ryu/ofproto/ofproto_v1_3.py b/ryu/ofproto/ofproto_v1_3.py
index ec54ef8c..e2869df3 100644
--- a/ryu/ofproto/ofproto_v1_3.py
+++ b/ryu/ofproto/ofproto_v1_3.py
@@ -763,10 +763,10 @@ assert (calcsize(OFP_ASYNC_CONFIG_PACK_STR) + OFP_HEADER_SIZE ==
OFP_ASYNC_CONFIG_SIZE)
# struct ofp_packet_in
-OFP_PACKET_IN_PACK_STR = '!IHBBQ' + _OFP_MATCH_PACK_STR
+OFP_PACKET_IN_PACK_STR = '!IHBBQ'
OFP_PACKET_IN_SIZE = 32
OFP_PACKET_IN_DATA_OFFSET = 18
-assert (calcsize(OFP_PACKET_IN_PACK_STR) + OFP_HEADER_SIZE ==
+assert (calcsize(OFP_PACKET_IN_PACK_STR) + OFP_MATCH_SIZE + OFP_HEADER_SIZE ==
OFP_PACKET_IN_SIZE)
# enum ofp_packet_in_reason
diff --git a/ryu/ofproto/ofproto_v1_3_parser.py b/ryu/ofproto/ofproto_v1_3_parser.py
index 1499ce90..db31dea8 100644
--- a/ryu/ofproto/ofproto_v1_3_parser.py
+++ b/ryu/ofproto/ofproto_v1_3_parser.py
@@ -1286,8 +1286,17 @@ class OFPPacketIn(MsgBase):
ofproto_v1_3.OFP_PACKET_IN_PACK_STR,
msg.buf, ofproto_v1_3.OFP_HEADER_SIZE)
- offset = ofproto_v1_3.OFP_HEADER_SIZE + ofproto_v1_3.OFP_PACKET_IN_SIZE
- msg.match = OFPMatch.parser(buf, offset - ofproto_v1_3.OFP_MATCH_SIZE)
+ msg.match = OFPMatch.parser(msg.buf, ofproto_v1_3.OFP_PACKET_IN_SIZE -
+ ofproto_v1_3.OFP_MATCH_SIZE)
+
+ match_len = utils.round_up(msg.match.length, 8)
+ msg.data = msg.buf[(ofproto_v1_3.OFP_PACKET_IN_SIZE -
+ ofproto_v1_3.OFP_MATCH_SIZE + match_len + 2):]
+
+ if msg.total_len < len(msg.data):
+ # discard padding for 8-byte alignment of OFP packet
+ msg.data = msg.data[:msg.total_len]
+
return msg