2
0
mirror of https://github.com/openvswitch/ovs synced 2025-10-27 15:18:06 +00:00

learn: Improve error reporting.

parse_int_string() returns an error if the field overflows, not if there
is a bad hex digit.

Signed-off-by: Ben Pfaff <blp@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
This commit is contained in:
Ben Pfaff
2015-05-29 15:15:01 -07:00
parent db8bb9a51e
commit 6f17821ed3
2 changed files with 16 additions and 2 deletions

View File

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

View File

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