summaryrefslogtreecommitdiff
path: root/ofproto/ofproto-dpif-xlate.c
diff options
context:
space:
mode:
authorNobuhiro MIKI <nmiki@yahoo-corp.jp>2022-08-26 16:48:53 +0900
committerIlya Maximets <i.maximets@ovn.org>2022-09-15 14:39:28 +0200
commita93d0b74dd0a4519e04441144756ffb056b4e8c5 (patch)
tree1ad2dfed5c0e947a68b107f4dc518ecc2d7062d9 /ofproto/ofproto-dpif-xlate.c
parent950aee1f7e1113a030b5e62ed036608480118b9d (diff)
downloadopenvswitch-a93d0b74dd0a4519e04441144756ffb056b4e8c5.tar.gz
ofproto-dpif-trace: add --name option for ofproto/trace.
Most of commands in ovs-ofctl and ovs-appctl can display port names instead of port numbers by using --names option. This change adds similar functionality to ofproto/trace. For backward compatibility, the default behavior is the same as before. Acked-by: Aaron Conole <aconole@redhat.com> Signed-off-by: Nobuhiro MIKI <nmiki@yahoo-corp.jp> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Diffstat (limited to 'ofproto/ofproto-dpif-xlate.c')
-rw-r--r--ofproto/ofproto-dpif-xlate.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index b695baba9..2b1ed9cfe 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -813,9 +813,20 @@ xlate_report_table(const struct xlate_ctx *ctx, struct rule_dpif *rule,
ds_put_cstr(&s, "Packets are IP fragments and "
"the fragment handling mode is \"drop\".");
} else {
+ struct ofputil_port_map map = OFPUTIL_PORT_MAP_INITIALIZER(&map);
+
+ if (ctx->xin->names) {
+ struct ofproto_dpif *ofprotop;
+ ofprotop = ofproto_dpif_lookup_by_name(ctx->xbridge->name);
+ ofproto_append_ports_to_map(&map, ofprotop->up.ports);
+ }
+
minimatch_format(&rule->up.cr.match,
ofproto_get_tun_tab(&ctx->xin->ofproto->up),
- NULL, &s, OFP_DEFAULT_PRIORITY);
+ &map, &s, OFP_DEFAULT_PRIORITY);
+
+ ofputil_port_map_destroy(&map);
+
if (ds_last(&s) != ' ') {
ds_put_cstr(&s, ", ");
}
@@ -6985,11 +6996,20 @@ do_xlate_actions(const struct ofpact *ofpacts, size_t ofpacts_len,
}
if (OVS_UNLIKELY(ctx->xin->trace)) {
+ struct ofputil_port_map map = OFPUTIL_PORT_MAP_INITIALIZER(&map);
+
+ if (ctx->xin->names) {
+ struct ofproto_dpif *ofprotop;
+ ofprotop = ofproto_dpif_lookup_by_name(ctx->xbridge->name);
+ ofproto_append_ports_to_map(&map, ofprotop->up.ports);
+ }
+
struct ds s = DS_EMPTY_INITIALIZER;
- struct ofpact_format_params fp = { .s = &s };
+ struct ofpact_format_params fp = { .s = &s, .port_map = &map };
ofpacts_format(a, OFPACT_ALIGN(a->len), &fp);
xlate_report(ctx, OFT_ACTION, "%s", ds_cstr(&s));
ds_destroy(&s);
+ ofputil_port_map_destroy(&map);
}
switch (a->type) {