Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: openvswitch: add log message for error case

As requested by upstream OVS, added some error messages in the
validate_and_copy_dec_ttl function.

Includes a small cleanup, which removes an unnecessary parameter
from the dec_ttl_exception_handler() function.

Reported-by: Flavio Leitner <fbl@sysclose.org>
Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
Acked-by: Flavio Leitner <fbl@sysclose.org>
Link: https://lore.kernel.org/r/161054576573.26637.18396634650212670580.stgit@ebuild
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Eelco Chaudron and committed by
Jakub Kicinski
a5317f3b 3bf679e2

+18 -10
+5 -7
net/openvswitch/actions.c
··· 957 957 958 958 static int dec_ttl_exception_handler(struct datapath *dp, struct sk_buff *skb, 959 959 struct sw_flow_key *key, 960 - const struct nlattr *attr, bool last) 960 + const struct nlattr *attr) 961 961 { 962 962 /* The first attribute is always 'OVS_DEC_TTL_ATTR_ACTION'. */ 963 963 struct nlattr *actions = nla_data(attr); 964 964 965 965 if (nla_len(actions)) 966 966 return clone_execute(dp, skb, key, 0, nla_data(actions), 967 - nla_len(actions), last, false); 967 + nla_len(actions), true, false); 968 968 969 969 consume_skb(skb); 970 970 return 0; ··· 1418 1418 1419 1419 case OVS_ACTION_ATTR_DEC_TTL: 1420 1420 err = execute_dec_ttl(skb, key); 1421 - if (err == -EHOSTUNREACH) { 1422 - err = dec_ttl_exception_handler(dp, skb, key, 1423 - a, true); 1424 - return err; 1425 - } 1421 + if (err == -EHOSTUNREACH) 1422 + return dec_ttl_exception_handler(dp, skb, 1423 + key, a); 1426 1424 break; 1427 1425 } 1428 1426
+13 -3
net/openvswitch/flow_netlink.c
··· 2515 2515 if (type > OVS_DEC_TTL_ATTR_MAX) 2516 2516 continue; 2517 2517 2518 - if (!type || attrs[type]) 2518 + if (!type || attrs[type]) { 2519 + OVS_NLERR(log, "Duplicate or invalid key (type %d).", 2520 + type); 2519 2521 return -EINVAL; 2522 + } 2520 2523 2521 2524 attrs[type] = a; 2522 2525 } 2523 2526 2524 - actions = attrs[OVS_DEC_TTL_ATTR_ACTION]; 2525 - if (rem || !actions || (nla_len(actions) && nla_len(actions) < NLA_HDRLEN)) 2527 + if (rem) { 2528 + OVS_NLERR(log, "Message has %d unknown bytes.", rem); 2526 2529 return -EINVAL; 2530 + } 2531 + 2532 + actions = attrs[OVS_DEC_TTL_ATTR_ACTION]; 2533 + if (!actions || (nla_len(actions) && nla_len(actions) < NLA_HDRLEN)) { 2534 + OVS_NLERR(log, "Missing valid actions attribute."); 2535 + return -EINVAL; 2536 + } 2527 2537 2528 2538 start = add_nested_action_start(sfa, OVS_ACTION_ATTR_DEC_TTL, log); 2529 2539 if (start < 0)