X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fodp-util.c;h=29f536dae2173dd79591d311dfefece36f5bc8a8;hb=a46c577af5c5855939ca3192a56396e15bebf0f8;hp=91320c458b714d4b93a31c15082dfff5e048d829;hpb=cf22f8cba328c0fb47a7e6811563f773fc232904;p=openvswitch diff --git a/lib/odp-util.c b/lib/odp-util.c index 91320c45..29f536da 100644 --- a/lib/odp-util.c +++ b/lib/odp-util.c @@ -24,6 +24,7 @@ #include "dynamic-string.h" #include "flow.h" #include "netlink.h" +#include "openvswitch/tunnel.h" #include "packets.h" #include "timeval.h" #include "util.h" @@ -83,13 +84,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]); } @@ -103,9 +106,9 @@ format_odp_action(struct ds *ds, const struct nlattr *a) const uint8_t *eth; ovs_be32 ip; - if (nl_attr_get_size(a) != odp_action_len(a->nla_len)) { - ds_put_format(ds, "***bad action: length is %zu, expected %d*** ", - nl_attr_get_size(a), odp_action_len(a->nla_len)); + if (nl_attr_get_size(a) != odp_action_len(nl_attr_type(a))) { + 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; } @@ -214,6 +217,35 @@ format_odp_flow(struct ds *ds, const struct odp_flow *f) ds_put_cstr(ds, ", actions:"); format_odp_actions(ds, f->actions, f->actions_len); } + +void +format_odp_port_type(struct ds *ds, const struct odp_port *p) +{ + if (!strcmp(p->type, "gre") + || !strcmp(p->type, "ipsec_gre") + || !strcmp(p->type, "capwap")) { + const struct tnl_port_config *config; + + config = (struct tnl_port_config *)p->config; + + ds_put_format(ds, " (%s: remote_ip="IP_FMT, + p->type, IP_ARGS(&config->daddr)); + + if (config->saddr) { + ds_put_format(ds, ", local_ip="IP_FMT, IP_ARGS(&config->saddr)); + } + + if (config->in_key) { + ds_put_format(ds, ", in_key=%#"PRIx64, ntohll(config->in_key)); + } + + ds_put_cstr(ds, ")"); + } else if (!strcmp(p->type, "patch")) { + ds_put_format(ds, " (%s: peer=%s)", p->type, (char *)p->config); + } else if (strcmp(p->type, "system")) { + ds_put_format(ds, " (%s)", p->type); + } +} void odp_flow_key_from_flow(struct odp_flow_key *key, const struct flow *flow)