mirror of
https://github.com/openvswitch/ovs
synced 2025-10-15 14:17:18 +00:00
ovs-dpctl: Print extended information about vports.
When "ovs-dpctl show" is run, return additional information about the port. For example, tunnel ports will print the remote_ip, local_ip, and in_key when defined.
This commit is contained in:
@@ -24,6 +24,7 @@
|
|||||||
#include "dynamic-string.h"
|
#include "dynamic-string.h"
|
||||||
#include "flow.h"
|
#include "flow.h"
|
||||||
#include "netlink.h"
|
#include "netlink.h"
|
||||||
|
#include "openvswitch/tunnel.h"
|
||||||
#include "packets.h"
|
#include "packets.h"
|
||||||
#include "timeval.h"
|
#include "timeval.h"
|
||||||
#include "util.h"
|
#include "util.h"
|
||||||
@@ -216,6 +217,34 @@ format_odp_flow(struct ds *ds, const struct odp_flow *f)
|
|||||||
ds_put_cstr(ds, ", actions:");
|
ds_put_cstr(ds, ", actions:");
|
||||||
format_odp_actions(ds, f->actions, f->actions_len);
|
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, "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
|
void
|
||||||
odp_flow_key_from_flow(struct odp_flow_key *key, const struct flow *flow)
|
odp_flow_key_from_flow(struct odp_flow_key *key, const struct flow *flow)
|
||||||
|
@@ -62,6 +62,7 @@ void format_odp_actions(struct ds *, const struct nlattr *odp_actions,
|
|||||||
size_t actions_len);
|
size_t actions_len);
|
||||||
void format_odp_flow_stats(struct ds *, const struct odp_flow_stats *);
|
void format_odp_flow_stats(struct ds *, const struct odp_flow_stats *);
|
||||||
void format_odp_flow(struct ds *, const struct odp_flow *);
|
void format_odp_flow(struct ds *, const struct odp_flow *);
|
||||||
|
void format_odp_port_type(struct ds *, const struct odp_port *);
|
||||||
|
|
||||||
void odp_flow_key_from_flow(struct odp_flow_key *, const struct flow *);
|
void odp_flow_key_from_flow(struct odp_flow_key *, const struct flow *);
|
||||||
void odp_flow_key_to_flow(const struct odp_flow_key *, struct flow *);
|
void odp_flow_key_to_flow(const struct odp_flow_key *, struct flow *);
|
||||||
|
@@ -375,12 +375,14 @@ show_dpif(struct dpif *dpif)
|
|||||||
query_ports(dpif, &ports, &n_ports);
|
query_ports(dpif, &ports, &n_ports);
|
||||||
for (i = 0; i < n_ports; i++) {
|
for (i = 0; i < n_ports; i++) {
|
||||||
const struct odp_port *p = &ports[i];
|
const struct odp_port *p = &ports[i];
|
||||||
|
struct ds ds;
|
||||||
|
|
||||||
printf("\tport %u: %s", p->port, p->devname);
|
printf("\tport %u: %s", p->port, p->devname);
|
||||||
if (strcmp(p->type, "system")) {
|
|
||||||
printf(" (%s)", p->type);
|
ds_init(&ds);
|
||||||
}
|
format_odp_port_type(&ds, p);
|
||||||
printf("\n");
|
printf("%s\n", ds_cstr(&ds));
|
||||||
|
ds_destroy(&ds);
|
||||||
}
|
}
|
||||||
free(ports);
|
free(ports);
|
||||||
dpif_close(dpif);
|
dpif_close(dpif);
|
||||||
|
Reference in New Issue
Block a user