diff options
author | Justin Pettit <jpettit@nicira.com> | 2011-11-20 15:12:36 -0800 |
---|---|---|
committer | Justin Pettit <jpettit@nicira.com> | 2011-11-23 23:22:53 -0800 |
commit | 9d24de3bca606e768dfd17f0676dd17c26241337 (patch) | |
tree | e716eeb86d17caf5a9a0b99b6750410f961638b8 /vswitchd | |
parent | 9ae7ddc08260134e4dcba618ba9dc6a09298c756 (diff) |
ovs-vswitchd: Track packet and byte statistics sent on mirrors.
This commit adds support for tracking the number of packets and bytes
sent through a mirror. The numbers are kept in the new "statistics"
column on the mirror table in the "tx_packets" and "tx_bytes" keys.
Diffstat (limited to 'vswitchd')
-rw-r--r-- | vswitchd/bridge.c | 45 | ||||
-rw-r--r-- | vswitchd/vswitch.ovsschema | 6 | ||||
-rw-r--r-- | vswitchd/vswitch.xml | 12 |
3 files changed, 59 insertions, 4 deletions
diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index 32885ebc..aadb0c7a 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -78,6 +78,7 @@ struct mirror { struct hmap_node hmap_node; /* In struct bridge's "mirrors" hmap. */ struct bridge *bridge; char *name; + const struct ovsrec_mirror *cfg; }; struct port { @@ -192,7 +193,8 @@ static void bridge_configure_mirrors(struct bridge *); static struct mirror *mirror_create(struct bridge *, const struct ovsrec_mirror *); static void mirror_destroy(struct mirror *); -static bool mirror_configure(struct mirror *, const struct ovsrec_mirror *); +static bool mirror_configure(struct mirror *); +static void mirror_refresh_stats(struct mirror *); static void iface_configure_lacp(struct iface *, struct lacp_slave_settings *); static struct iface *iface_create(struct port *port, @@ -291,6 +293,7 @@ bridge_init(const char *remote) ovsdb_idl_omit(idl, &ovsrec_queue_col_external_ids); ovsdb_idl_omit(idl, &ovsrec_mirror_col_external_ids); + ovsdb_idl_omit_alert(idl, &ovsrec_mirror_col_statistics); ovsdb_idl_omit(idl, &ovsrec_netflow_col_external_ids); @@ -1870,6 +1873,7 @@ bridge_run(void) txn = ovsdb_idl_txn_create(idl); HMAP_FOR_EACH (br, node, &all_bridges) { struct port *port; + struct mirror *m; HMAP_FOR_EACH (port, hmap_node, &br->ports) { struct iface *iface; @@ -1879,6 +1883,11 @@ bridge_run(void) iface_refresh_status(iface); } } + + HMAP_FOR_EACH (m, hmap_node, &br->mirrors) { + mirror_refresh_stats(m); + } + } refresh_system_stats(cfg); refresh_controller_status(); @@ -3145,7 +3154,8 @@ bridge_configure_mirrors(struct bridge *br) if (!m) { m = mirror_create(br, cfg); } - if (!mirror_configure(m, cfg)) { + m->cfg = cfg; + if (!mirror_configure(m)) { mirror_destroy(m); } } @@ -3211,8 +3221,9 @@ mirror_collect_ports(struct mirror *m, } static bool -mirror_configure(struct mirror *m, const struct ovsrec_mirror *cfg) +mirror_configure(struct mirror *m) { + const struct ovsrec_mirror *cfg = m->cfg; struct ofproto_mirror_settings s; /* Set name. */ @@ -3555,3 +3566,31 @@ add_vlan_splinter_ports(struct bridge *br, } } } + +static void +mirror_refresh_stats(struct mirror *m) +{ + struct ofproto *ofproto = m->bridge->ofproto; + uint64_t tx_packets, tx_bytes; + char *keys[2]; + int64_t values[2]; + size_t stat_cnt = 0; + + if (ofproto_mirror_get_stats(ofproto, m, &tx_packets, &tx_bytes)) { + ovsrec_mirror_set_statistics(m->cfg, NULL, NULL, 0); + return; + } + + if (tx_packets != UINT64_MAX) { + keys[stat_cnt] = "tx_packets"; + values[stat_cnt] = tx_packets; + stat_cnt++; + } + if (tx_bytes != UINT64_MAX) { + keys[stat_cnt] = "tx_bytes"; + values[stat_cnt] = tx_bytes; + stat_cnt++; + } + + ovsrec_mirror_set_statistics(m->cfg, keys, values, stat_cnt); +} diff --git a/vswitchd/vswitch.ovsschema b/vswitchd/vswitch.ovsschema index e2f231c8..9d91b0f9 100644 --- a/vswitchd/vswitch.ovsschema +++ b/vswitchd/vswitch.ovsschema @@ -1,6 +1,6 @@ {"name": "Open_vSwitch", "version": "6.4.0", - "cksum": "3757343995 15531", + "cksum": "923041702 15687", "tables": { "Open_vSwitch": { "columns": { @@ -299,6 +299,10 @@ "minInteger": 1, "maxInteger": 4095}, "min": 0, "max": 1}}, + "statistics": { + "type": {"key": "string", "value": "integer", + "min": 0, "max": "unlimited"}, + "ephemeral": true}, "external_ids": { "type": {"key": "string", "value": "string", "min": 0, "max": "unlimited"}}}}, diff --git a/vswitchd/vswitch.xml b/vswitchd/vswitch.xml index 55880b80..bebebe05 100644 --- a/vswitchd/vswitch.xml +++ b/vswitchd/vswitch.xml @@ -2125,6 +2125,18 @@ </column> </group> + <group title="Statistics: Mirror counters"> + <p> + Key-value pairs that report mirror statistics. + </p> + <column name="statistics" key="tx_packets"> + Number of packets transmitted through this mirror. + </column> + <column name="statistics" key="tx_bytes"> + Number of bytes transmitted through this mirror. + </column> + </group> + <group title="Common Columns"> The overall purpose of these columns is described under <code>Common Columns</code> at the beginning of this document. |