X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=lib%2Fodp-util.c;h=8fa3359493b11523fb43a729e06bf45c2e727210;hb=8017806940cfeaba963d6a6f51ae7573cbea6792;hp=ffb486ecf8b171f6440d5926d73ccbdab2d08206;hpb=c4f2731da69eaba5f4bb95583225a5399875f6fc;p=openvswitch diff --git a/lib/odp-util.c b/lib/odp-util.c index ffb486ec..8fa33594 100644 --- a/lib/odp-util.c +++ b/lib/odp-util.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2010, 2011 Nicira Networks. + * Copyright (c) 2009, 2010, 2011, 2012 Nicira Networks. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -278,10 +278,16 @@ format_odp_actions(struct ds *ds, const struct nlattr *actions, format_odp_action(ds, a); } if (left) { + int i; + if (left == actions_len) { ds_put_cstr(ds, ""); } - ds_put_format(ds, ",***%u leftover bytes***", left); + ds_put_format(ds, ",***%u leftover bytes*** (", left); + for (i = 0; i < left; i++) { + ds_put_format(ds, "%02x", ((const uint8_t *) a)[i]); + } + ds_put_char(ds, ')'); } } else { ds_put_cstr(ds, "drop"); @@ -727,10 +733,16 @@ odp_flow_key_format(const struct nlattr *key, size_t key_len, struct ds *ds) format_odp_key_attr(a, ds); } if (left) { + int i; + if (left == key_len) { ds_put_cstr(ds, ""); } - ds_put_format(ds, ",***%u leftover bytes***", left); + ds_put_format(ds, ",***%u leftover bytes*** (", left); + for (i = 0; i < left; i++) { + ds_put_format(ds, "%02x", ((const uint8_t *) a)[i]); + } + ds_put_char(ds, ')'); } } else { ds_put_cstr(ds, ""); @@ -1687,6 +1699,24 @@ odp_flow_key_to_flow(const struct nlattr *key, size_t key_len, expected_attrs, flow, key, key_len); } +/* Returns 'fitness' as a string, for use in debug messages. */ +const char * +odp_key_fitness_to_string(enum odp_key_fitness fitness) +{ + switch (fitness) { + case ODP_FIT_PERFECT: + return "OK"; + case ODP_FIT_TOO_MUCH: + return "too_much"; + case ODP_FIT_TOO_LITTLE: + return "too_little"; + case ODP_FIT_ERROR: + return "error"; + default: + return ""; + } +} + /* Appends an OVS_ACTION_ATTR_USERSPACE action to 'odp_actions' that specifies * Netlink PID 'pid'. If 'cookie' is nonnull, adds a userdata attribute whose * contents contains 'cookie' and returns the offset within 'odp_actions' of