2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 06:15:47 +00:00

Support accepting and displaying port names in OVS tools.

Until now, most ovs-ofctl commands have not accepted names for ports, only
numbers, and have not been able to display port names either.  It's a lot
easier for users if they can use and see meaningful names instead of
arbitrary numbers.  This commit adds that support.

For backward compatibility, only interactive ovs-ofctl commands by default
display port names; to display them in scripts, use the new --names
option.

Signed-off-by: Ben Pfaff <blp@ovn.org>
Tested-by: Aaron Conole <aconole@redhat.com>
This commit is contained in:
Ben Pfaff
2017-05-31 16:06:12 -07:00
parent 52182c5f50
commit 50f96b10e1
45 changed files with 1383 additions and 617 deletions

View File

@@ -1066,10 +1066,11 @@ flow_clear_conntrack(struct flow *flow)
}
char *
flow_to_string(const struct flow *flow)
flow_to_string(const struct flow *flow,
const struct ofputil_port_map *port_map)
{
struct ds ds = DS_EMPTY_INITIALIZER;
flow_format(&ds, flow);
flow_format(&ds, flow, port_map);
return ds_cstr(&ds);
}
@@ -1309,7 +1310,8 @@ unknown:
}
void
flow_format(struct ds *ds, const struct flow *flow)
flow_format(struct ds *ds,
const struct flow *flow, const struct ofputil_port_map *port_map)
{
struct match match;
struct flow_wildcards *wc = &match.wc;
@@ -1371,13 +1373,14 @@ flow_format(struct ds *ds, const struct flow *flow)
WC_UNMASK_FIELD(wc, metadata);
}
match_format(&match, ds, OFP_DEFAULT_PRIORITY);
match_format(&match, port_map, ds, OFP_DEFAULT_PRIORITY);
}
void
flow_print(FILE *stream, const struct flow *flow)
flow_print(FILE *stream,
const struct flow *flow, const struct ofputil_port_map *port_map)
{
char *s = flow_to_string(flow);
char *s = flow_to_string(flow, port_map);
fputs(s, stream);
free(s);
}