summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorYAMAMOTO Takashi <yamamoto@valinux.co.jp>2013-12-25 01:04:50 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2013-12-25 06:35:12 +0900
commit11006e73494dd7213f4f59fbc3370fb1aa85314c (patch)
tree438b7f996c00d5e5a7c17b6b2fc727a3960595a0
parent119990d1eba339e1088cf87b32d39eb3169ddcde (diff)
oxm_fields: make a crash less cryptic
when oxm length is not what we expect, explicitly raise an exception with descriptive message like the following. Exception: Unexpected OXM payload length 3 for ipv6_flabel (expected 4) This often happens if you are using LINC and IPv6. https://github.com/FlowForwarding/of_protocol/pull/57 Signed-off-by: YAMAMOTO Takashi <yamamoto@valinux.co.jp> Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
-rw-r--r--ryu/ofproto/oxm_fields.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/ryu/ofproto/oxm_fields.py b/ryu/ofproto/oxm_fields.py
index 1f83a70e..e89d1ebc 100644
--- a/ryu/ofproto/oxm_fields.py
+++ b/ryu/ofproto/oxm_fields.py
@@ -188,6 +188,10 @@ def to_user(num_to_field, n, v, m):
t = UnknownType
name = 'field_%d' % n
if not v is None:
+ if hasattr(t, 'size') and t.size != len(v):
+ raise Exception(
+ 'Unexpected OXM payload length %d for %s (expected %d)'
+ % (len(v), name, t.size))
value = t.to_user(v)
else:
value = None