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>
This commit is contained in:
YAMAMOTO Takashi 2013-12-25 01:04:50 +09:00 committed by FUJITA Tomonori
parent 119990d1eb
commit 11006e7349

View File

@ -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