Skip to content

Commit

Permalink
odp-util: Fix reporting unknown keys as keys with bad length.
Browse files Browse the repository at this point in the history
check_attr_len() currently reports all unknown keys as keys with bad
length.  For example, IPv6 extension headers are printed out like this
in flow dumps:

  eth_type(0x86dd),ipv6(...)
  (bad key length 2, expected -1)(00 00/(bad mask length 2, expected -1)(00 00),
  icmpv6(type=0/0,code=0/0)

However, since the key is unknown, the length check on it makes no
sense and should be ignored.  This will allow the unknown key to be
caught later by the format_unknown_key() function and printed in a
more user-friendly way:

  eth_type(0x86dd),ipv6(...),key32(00 00/00 00),icmpv6(type=0/0,code=0/0)

'32' here is the actual index of the key attribute, so we know
that it is unknown attribute openvswitch#32 with the value/mask pair printed
out inside the parenthesis.

Acked-by: Aaron Conole <[email protected]>
Signed-off-by: Ilya Maximets <[email protected]>
  • Loading branch information
igsilya committed Nov 30, 2022
1 parent cd475f9 commit 954ae38
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/odp-util.c
Original file line number Diff line number Diff line change
Expand Up @@ -3594,9 +3594,16 @@ static bool
check_attr_len(struct ds *ds, const struct nlattr *a, const struct nlattr *ma,
const struct attr_len_tbl tbl[], int max_type, bool need_key)
{
uint16_t type = nl_attr_type(a);
int expected_len;

expected_len = odp_key_attr_len(tbl, max_type, nl_attr_type(a));
if (type > max_type) {
/* Unknown attribute, can't check the length. */
return true;
}

expected_len = odp_key_attr_len(tbl, max_type, type);

if (expected_len != ATTR_LEN_VARIABLE &&
expected_len != ATTR_LEN_NESTED) {

Expand All @@ -3605,7 +3612,7 @@ check_attr_len(struct ds *ds, const struct nlattr *a, const struct nlattr *ma,

if (bad_key_len || bad_mask_len) {
if (need_key) {
ds_put_format(ds, "key%u", nl_attr_type(a));
ds_put_format(ds, "key%u", type);
}
if (bad_key_len) {
ds_put_format(ds, "(bad key length %"PRIuSIZE", expected %d)(",
Expand Down

0 comments on commit 954ae38

Please sign in to comment.