From 11006e73494dd7213f4f59fbc3370fb1aa85314c Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Wed, 25 Dec 2013 01:04:50 +0900 Subject: [PATCH] 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 Signed-off-by: FUJITA Tomonori --- ryu/ofproto/oxm_fields.py | 4 ++++ 1 file changed, 4 insertions(+) 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