parse_int_string() returns an error if the field overflows, not if there is a bad hex digit.
Signed-off-by: Ben Pfaff <b...@nicira.com> --- lib/learn.c | 4 ++-- tests/learn.at | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/learn.c b/lib/learn.c index 8ff1e0a..a0e32c6 100644 --- a/lib/learn.c +++ b/lib/learn.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, 2013, 2014 Nicira, Inc. + * Copyright (c) 2011, 2012, 2013, 2014, 2015 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -197,7 +197,7 @@ learn_parse_load_immediate(const char *s, struct ofpact_learn_spec *spec) err = parse_int_string(s, imm.u8, sizeof imm.u8, (char **) &s); if (err) { - return xasprintf("%s: bad hex digit in value", full_s); + return xasprintf("%s: too many bits in immediate value", full_s); } if (strncmp(s, "->", 2)) { diff --git a/tests/learn.at b/tests/learn.at index 322ab84..0372e4a 100644 --- a/tests/learn.at +++ b/tests/learn.at @@ -91,6 +91,20 @@ ovs-ofctl: actions are invalid with specified match (OFPBAC_MATCH_INCONSISTENT) ]]) AT_CLEANUP +AT_SETUP([learning action - too-long immediate value]) +dnl 129 bits is too long. +AT_CHECK([[ovs-ofctl parse-flow 'actions=learn(load:0x1fedbca9876543210fedbca9876543210->NXM_NX_IPV6_DST[])']], + [1], [], [[ovs-ofctl: 0x1fedbca9876543210fedbca9876543210->NXM_NX_IPV6_DST[]: too many bits in immediate value +]]) + +dnl 128 bits is merely a bad prerequisite. +AT_CHECK([[ovs-ofctl parse-flow 'actions=learn(load:0xfedbca9876543210fedbca9876543210->NXM_NX_IPV6_DST[])']], [1], [], [stderr]) +AT_CHECK([sed -e 's/.*|meta_flow|WARN|//' < stderr], [0], + [[destination field ipv6_dst lacks correct prerequisites +ovs-ofctl: actions are invalid with specified match (OFPBAC_MATCH_INCONSISTENT) +]], [[]]) +AT_CLEANUP + AT_SETUP([learning action - standard VLAN+MAC learning]) OVS_VSWITCHD_START( [add-port br0 p1 -- set Interface p1 type=dummy ofport_request=1 -- \ -- 2.1.3 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev