[ovs-dev] [PATCH 1/7] odp-util: Improve formatting of bad ODP actions.
Ben Pfaff
blp at nicira.com
Fri Dec 24 01:15:35 UTC 2010
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.
---
lib/odp-util.c | 8 +++++---
1 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/lib/odp-util.c b/lib/odp-util.c
index 547e87e..09f8b83 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;
--
1.7.1
More information about the dev
mailing list