X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fnetdev-tunnel.c;h=9a7c3581df03b1103314ae88877f44f1531191e9;hb=ea7655d9f9d38a3af7250de8ba0b89115b5f4a5e;hp=91220a6c0448ef37410c2b160eb6bf7c246141cc;hpb=7a3d4b5f33a1b98ea50328edf6e1f9d82c37c853;p=sliver-openvswitch.git diff --git a/lib/netdev-tunnel.c b/lib/netdev-tunnel.c index 91220a6c0..9a7c3581d 100644 --- a/lib/netdev-tunnel.c +++ b/lib/netdev-tunnel.c @@ -73,7 +73,7 @@ is_tunnel_class(const struct netdev_class *class) static struct netdev_dev_tunnel * netdev_dev_tunnel_cast(const struct netdev_dev *netdev_dev) { - assert(is_tunnel_class(netdev_dev_get_class(netdev_dev))); + ovs_assert(is_tunnel_class(netdev_dev_get_class(netdev_dev))); return CONTAINER_OF(netdev_dev, struct netdev_dev_tunnel, netdev_dev); } @@ -81,7 +81,7 @@ static struct netdev_tunnel * netdev_tunnel_cast(const struct netdev *netdev) { struct netdev_dev *netdev_dev = netdev_get_dev(netdev); - assert(is_tunnel_class(netdev_dev_get_class(netdev_dev))); + ovs_assert(is_tunnel_class(netdev_dev_get_class(netdev_dev))); return CONTAINER_OF(netdev, struct netdev_tunnel, netdev); } @@ -170,7 +170,7 @@ netdev_tunnel_get_config(struct netdev_dev *dev_, struct smap *args) if (netdev_dev->valid_remote_ip) smap_add_format(args, "remote_ip", IP_FMT, - IP_ARGS(&netdev_dev->remote_addr.sin_addr)); + IP_ARGS(netdev_dev->remote_addr.sin_addr.s_addr)); if (netdev_dev->valid_remote_port) smap_add_format(args, "remote_port", "%"PRIu16, ntohs(netdev_dev->remote_addr.sin_port)); @@ -439,12 +439,50 @@ netdev_tunnel_get_port(struct unixctl_conn *conn, unixctl_command_reply(conn, buf); } +static void +netdev_tunnel_get_tx_bytes(struct unixctl_conn *conn, + int argc OVS_UNUSED, const char *argv[], void *aux OVS_UNUSED) +{ + struct netdev_dev_tunnel *tunnel_dev; + char buf[128]; + + tunnel_dev = shash_find_data(&tunnel_netdev_devs, argv[1]); + if (!tunnel_dev) { + unixctl_command_reply_error(conn, "no such tunnel netdev"); + return; + } + + sprintf(buf, "%"PRIu64, tunnel_dev->stats.tx_bytes); + unixctl_command_reply(conn, buf); +} + +static void +netdev_tunnel_get_rx_bytes(struct unixctl_conn *conn, + int argc OVS_UNUSED, const char *argv[], void *aux OVS_UNUSED) +{ + struct netdev_dev_tunnel *tunnel_dev; + char buf[128]; + + tunnel_dev = shash_find_data(&tunnel_netdev_devs, argv[1]); + if (!tunnel_dev) { + unixctl_command_reply_error(conn, "no such tunnel netdev"); + return; + } + + sprintf(buf, "%"PRIu64, tunnel_dev->stats.rx_bytes); + unixctl_command_reply(conn, buf); +} + static int netdev_tunnel_init(void) { unixctl_command_register("netdev-tunnel/get-port", "NAME", 1, 1, netdev_tunnel_get_port, NULL); + unixctl_command_register("netdev-tunnel/get-tx-bytes", "NAME", + 1, 1, netdev_tunnel_get_tx_bytes, NULL); + unixctl_command_register("netdev-tunnel/get-rx-bytes", "NAME", + 1, 1, netdev_tunnel_get_rx_bytes, NULL); return 0; } @@ -458,6 +496,7 @@ const struct netdev_class netdev_tunnel_class = { netdev_tunnel_destroy, netdev_tunnel_get_config, netdev_tunnel_set_config, + NULL, /* get_tunnel_config */ netdev_tunnel_open, netdev_tunnel_close,