X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fnetdev-vport.c;h=d85d528454b46201675ff252ab022482bd914217;hb=f613a0d72c521ca3a4eeb2c29ac523f6fdf72667;hp=df7c9a5b6bb1622f112c9e64b295ae4638c819ee;hpb=df2c07f4338faac04f4969f243fe4e8083b309ac;p=sliver-openvswitch.git diff --git a/lib/netdev-vport.c b/lib/netdev-vport.c index df7c9a5b6..d85d52845 100644 --- a/lib/netdev-vport.c +++ b/lib/netdev-vport.c @@ -35,13 +35,13 @@ #include "netdev-linux.h" #include "netdev-provider.h" #include "netlink.h" +#include "netlink-notifier.h" #include "netlink-socket.h" #include "ofpbuf.h" #include "openvswitch/datapath-protocol.h" #include "openvswitch/tunnel.h" #include "packets.h" #include "route-table.h" -#include "rtnetlink.h" #include "shash.h" #include "socket-util.h" #include "vlog.h" @@ -361,19 +361,43 @@ netdev_vport_get_etheraddr(const struct netdev *netdev, return error; } -static int -netdev_vport_get_mtu(const struct netdev *netdev, int *mtup) -{ - struct dpif_linux_vport reply; - struct ofpbuf *buf; - int error; +#define COPY_OVS_STATS \ + dst->rx_packets = src->rx_packets; \ + dst->tx_packets = src->tx_packets; \ + dst->rx_bytes = src->rx_bytes; \ + dst->tx_bytes = src->tx_bytes; \ + dst->rx_errors = src->rx_errors; \ + dst->tx_errors = src->tx_errors; \ + dst->rx_dropped = src->rx_dropped; \ + dst->tx_dropped = src->tx_dropped; - error = dpif_linux_vport_get(netdev_get_name(netdev), &reply, &buf); - if (!error) { - *mtup = reply.mtu; - ofpbuf_delete(buf); - } - return error; +/* Copies 'src' into 'dst', performing format conversion in the process. */ +static void +netdev_stats_from_ovs_vport_stats(struct netdev_stats *dst, + const struct ovs_vport_stats *src) +{ + COPY_OVS_STATS + dst->multicast = 0; + dst->collisions = 0; + dst->rx_length_errors = 0; + dst->rx_over_errors = 0; + dst->rx_crc_errors = 0; + dst->rx_frame_errors = 0; + dst->rx_fifo_errors = 0; + dst->rx_missed_errors = 0; + dst->tx_aborted_errors = 0; + dst->tx_carrier_errors = 0; + dst->tx_fifo_errors = 0; + dst->tx_heartbeat_errors = 0; + dst->tx_window_errors = 0; +} + +/* Copies 'src' into 'dst', performing format conversion in the process. */ +static void +netdev_stats_to_ovs_vport_stats(struct ovs_vport_stats *dst, + const struct netdev_stats *src) +{ + COPY_OVS_STATS } int @@ -391,7 +415,7 @@ netdev_vport_get_stats(const struct netdev *netdev, struct netdev_stats *stats) return EOPNOTSUPP; } - netdev_stats_from_rtnl_link_stats64(stats, reply.stats); + netdev_stats_from_ovs_vport_stats(stats, reply.stats); ofpbuf_delete(buf); @@ -401,11 +425,11 @@ netdev_vport_get_stats(const struct netdev *netdev, struct netdev_stats *stats) int netdev_vport_set_stats(struct netdev *netdev, const struct netdev_stats *stats) { - struct rtnl_link_stats64 rtnl_stats; + struct ovs_vport_stats rtnl_stats; struct dpif_linux_vport vport; int err; - netdev_stats_to_rtnl_link_stats64(&rtnl_stats, stats); + netdev_stats_to_ovs_vport_stats(&rtnl_stats, stats); dpif_linux_vport_init(&vport); vport.cmd = OVS_VPORT_CMD_SET; @@ -634,9 +658,9 @@ parse_tunnel_config(const char *name, const char *type, || !strcmp(node->name, "private_key") || !strcmp(node->name, "use_ssl_cert"))) { /* Ignore options not used by the netdev. */ - } else if (is_gre && (!strcmp(node->name, "key") || - !strcmp(node->name, "in_key") || - !strcmp(node->name, "out_key"))) { + } else if (!strcmp(node->name, "key") || + !strcmp(node->name, "in_key") || + !strcmp(node->name, "out_key")) { /* Handled separately below. */ } else { VLOG_WARN("%s: unknown %s argument '%s'", name, type, node->name); @@ -666,10 +690,8 @@ parse_tunnel_config(const char *name, const char *type, } } - if (is_gre) { - set_key(args, "in_key", OVS_TUNNEL_ATTR_IN_KEY, options); - set_key(args, "out_key", OVS_TUNNEL_ATTR_OUT_KEY, options); - } + set_key(args, "in_key", OVS_TUNNEL_ATTR_IN_KEY, options); + set_key(args, "out_key", OVS_TUNNEL_ATTR_OUT_KEY, options); if (!daddr) { VLOG_ERR("%s: %s type requires valid 'remote_ip' argument", @@ -875,7 +897,8 @@ unparse_patch_config(const char *name OVS_UNUSED, const char *type OVS_UNUSED, \ netdev_vport_set_etheraddr, \ netdev_vport_get_etheraddr, \ - netdev_vport_get_mtu, \ + NULL, /* get_mtu */ \ + NULL, /* set_mtu */ \ NULL, /* get_ifindex */ \ NULL, /* get_carrier */ \ NULL, /* get_miimon */ \