From: Ben Pfaff Date: Thu, 23 Dec 2010 22:21:01 +0000 (-0800) Subject: odp-util: Improve formatting of bad ODP actions. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8ba43fbd1f14d60a2d097bafc7d0606d860d0f72;p=openvswitch odp-util: Improve formatting of bad ODP actions. nla_len is the size of a Netlink attribute including its header, but we only want to print the attribute payload, so use nl_attr_get_size() instead. Also, make it clear that what follows the "bad action" information is a dump of the action itself. Acked-by: Jesse Gross --- diff --git a/lib/odp-util.c b/lib/odp-util.c index 547e87ed..09f8b838 100644 --- a/lib/odp-util.c +++ b/lib/odp-util.c @@ -83,13 +83,15 @@ odp_action_len(uint16_t type) static void format_generic_odp_action(struct ds *ds, const struct nlattr *a) { + size_t len = nl_attr_get_size(a); + ds_put_format(ds, "action%"PRId16, nl_attr_type(a)); - if (a->nla_len) { + if (len) { const uint8_t *unspec; unsigned int i; unspec = nl_attr_get(a); - for (i = 0; i < a->nla_len; i++) { + for (i = 0; i < len; i++) { ds_put_char(ds, i ? ' ': '('); ds_put_format(ds, "%02x", unspec[i]); } @@ -104,7 +106,7 @@ format_odp_action(struct ds *ds, const struct nlattr *a) ovs_be32 ip; if (nl_attr_get_size(a) != odp_action_len(nl_attr_type(a))) { - ds_put_format(ds, "***bad action: length is %zu, expected %d*** ", + ds_put_format(ds, "bad length %zu, expected %d for: ", nl_attr_get_size(a), odp_action_len(nl_attr_type(a))); format_generic_odp_action(ds, a); return;