/*
- * Copyright (c) 2009, 2010, 2011, 2012 Nicira Networks.
+ * Copyright (c) 2009, 2010, 2011, 2012 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <linux/gen_stats.h>
#include <linux/if_ether.h>
#include <linux/if_tun.h>
-#include <linux/ip.h>
#include <linux/types.h>
#include <linux/ethtool.h>
#include <linux/mii.h>
int ether_addr_error; /* Cached error code from set/get etheraddr. */
int netdev_policing_error; /* Cached error code from set policing. */
int get_features_error; /* Cached error code from ETHTOOL_GSET. */
+ int get_ifindex_error; /* Cached error code from SIOCGIFINDEX. */
- uint32_t current; /* Cached from ETHTOOL_GSET. */
- uint32_t advertised; /* Cached from ETHTOOL_GSET. */
- uint32_t supported; /* Cached from ETHTOOL_GSET. */
- uint32_t peer; /* Cached from ETHTOOL_GSET. */
+ enum netdev_features current; /* Cached from ETHTOOL_GSET. */
+ enum netdev_features advertised; /* Cached from ETHTOOL_GSET. */
+ enum netdev_features supported; /* Cached from ETHTOOL_GSET. */
+ enum netdev_features peer; /* Cached from ETHTOOL_GSET. */
struct ethtool_drvinfo drvinfo; /* Cached from ETHTOOL_GDRVINFO. */
struct tc *tc;
/* Keep drv-info */
netdev_dev_linux_changed(dev, change->ifi_flags, VALID_DRVINFO);
+ /* Update netdev from rtnl-change msg. */
if (change->mtu) {
dev->mtu = change->mtu;
dev->cache_valid |= VALID_MTU;
dev->ether_addr_error = 0;
}
+ dev->ifindex = change->ifi_index;
+ dev->cache_valid |= VALID_IFINDEX;
+ dev->get_ifindex_error = 0;
+
} else {
netdev_dev_linux_changed(dev, change->ifi_flags, 0);
}
* errno value. */
static int
netdev_linux_get_features(const struct netdev *netdev_,
- uint32_t *current, uint32_t *advertised,
- uint32_t *supported, uint32_t *peer)
+ enum netdev_features *current,
+ enum netdev_features *advertised,
+ enum netdev_features *supported,
+ enum netdev_features *peer)
{
struct netdev_dev_linux *netdev_dev =
netdev_dev_linux_cast(netdev_get_dev(netdev_));
{
struct netdev_dev_linux *netdev_dev =
netdev_dev_linux_cast(netdev_get_dev(netdev));
- struct tc_queue *queue;
+ struct tc_queue *queue, *next_queue;
struct shash details;
int last_error;
int error;
last_error = 0;
shash_init(&details);
- HMAP_FOR_EACH (queue, hmap_node, &netdev_dev->tc->queues) {
+ HMAP_FOR_EACH_SAFE (queue, next_queue, hmap_node,
+ &netdev_dev->tc->queues) {
shash_clear(&details);
error = netdev_dev->tc->ops->class_get(netdev, queue, &details);
}
static int
-netdev_linux_get_status(const struct netdev *netdev, struct shash *sh)
+netdev_linux_get_drv_info(const struct netdev *netdev, struct shash *sh)
{
int error;
struct netdev_dev_linux *netdev_dev =
}
static int
-netdev_internal_get_status(const struct netdev *netdev OVS_UNUSED, struct shash *sh)
+netdev_internal_get_drv_info(const struct netdev *netdev OVS_UNUSED, struct shash *sh)
{
shash_add(sh, "driver_name", xstrdup("openvswitch"));
return 0;
netdev_linux_get_stats,
NULL, /* set_stats */
netdev_linux_get_features,
- netdev_linux_get_status);
+ netdev_linux_get_drv_info);
const struct netdev_class netdev_tap_class =
NETDEV_LINUX_CLASS(
netdev_tap_get_stats,
NULL, /* set_stats */
netdev_linux_get_features,
- netdev_linux_get_status);
+ netdev_linux_get_drv_info);
const struct netdev_class netdev_internal_class =
NETDEV_LINUX_CLASS(
netdev_internal_get_stats,
netdev_vport_set_stats,
NULL, /* get_features */
- netdev_internal_get_status);
+ netdev_internal_get_drv_info);
\f
/* HTB traffic control class. */
max_rate_s = shash_find_data(details, "max-rate");
hc->max_rate = max_rate_s ? strtoull(max_rate_s, NULL, 10) / 8 : 0;
if (!hc->max_rate) {
- uint32_t current;
+ enum netdev_features current;
netdev_get_features(netdev, ¤t, NULL, NULL, NULL);
hc->max_rate = netdev_features_to_bps(current) / 8;
max_rate = max_rate_s ? strtoull(max_rate_s, NULL, 10) / 8 : 0;
if (!max_rate) {
- uint32_t current;
+ enum netdev_features current;
netdev_get_features(netdev, ¤t, NULL, NULL, NULL);
max_rate = netdev_features_to_bps(current) / 8;
{
struct netdev_dev_linux *netdev_dev =
netdev_dev_linux_cast(netdev_get_dev(netdev_));
- *ifindexp = 0;
+
if (!(netdev_dev->cache_valid & VALID_IFINDEX)) {
int ifindex = do_get_ifindex(netdev_get_name(netdev_));
+
if (ifindex < 0) {
- return -ifindex;
+ netdev_dev->get_ifindex_error = -ifindex;
+ netdev_dev->ifindex = 0;
+ } else {
+ netdev_dev->get_ifindex_error = 0;
+ netdev_dev->ifindex = ifindex;
}
netdev_dev->cache_valid |= VALID_IFINDEX;
- netdev_dev->ifindex = ifindex;
}
+
*ifindexp = netdev_dev->ifindex;
- return 0;
+ return netdev_dev->get_ifindex_error;
}
static int