2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-30 22:05:19 +00:00

netdev: Add 'change_seq' back to netdev.

This commit can be seen as a partial revert of commit
da4a619179 (netdev: Globally track port status changes)
by adding the 'change_seq' to 'struct netdev'.

Signed-off-by: Alex Wang <alexw@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
This commit is contained in:
Alex Wang
2014-04-03 00:17:34 -07:00
parent 6105999daf
commit 3e912ffcbb
8 changed files with 41 additions and 25 deletions

View File

@@ -47,7 +47,6 @@
#endif
#include "rtbsd.h"
#include "connectivity.h"
#include "coverage.h"
#include "dpif-netdev.h"
#include "dynamic-string.h"
@@ -57,7 +56,6 @@
#include "ovs-thread.h"
#include "packets.h"
#include "poll-loop.h"
#include "seq.h"
#include "shash.h"
#include "socket-util.h"
#include "svec.h"
@@ -217,7 +215,7 @@ netdev_bsd_cache_cb(const struct rtbsd_change *change,
if (is_netdev_bsd_class(netdev_class)) {
dev = netdev_bsd_cast(base_dev);
dev->cache_valid = 0;
seq_change(connectivity_seq_get());
netdev_change_seq_changed(base_dev);
}
netdev_close(base_dev);
}
@@ -235,7 +233,7 @@ netdev_bsd_cache_cb(const struct rtbsd_change *change,
struct netdev *netdev = node->data;
dev = netdev_bsd_cast(netdev);
dev->cache_valid = 0;
seq_change(connectivity_seq_get());
netdev_change_seq_changed(netdev);
netdev_close(netdev);
}
shash_destroy(&device_shash);
@@ -774,7 +772,7 @@ netdev_bsd_set_etheraddr(struct netdev *netdev_,
if (!error) {
netdev->cache_valid |= VALID_ETHERADDR;
memcpy(netdev->etheraddr, mac, ETH_ADDR_LEN);
seq_change(connectivity_seq_get());
netdev_change_seq_changed(netdev_);
}
}
ovs_mutex_unlock(&netdev->mutex);
@@ -1228,7 +1226,7 @@ netdev_bsd_set_in4(struct netdev *netdev_, struct in_addr addr,
netdev->netmask = mask;
}
}
seq_change(connectivity_seq_get());
netdev_change_seq_changed(netdev_);
}
ovs_mutex_unlock(&netdev->mutex);
@@ -1526,7 +1524,7 @@ netdev_bsd_update_flags(struct netdev *netdev_, enum netdev_flags off,
new_flags = (old_flags & ~nd_to_iff_flags(off)) | nd_to_iff_flags(on);
if (new_flags != old_flags) {
error = set_flags(netdev_get_kernel_name(netdev_), new_flags);
seq_change(connectivity_seq_get());
netdev_change_seq_changed(netdev_);
}
}
return error;

View File

@@ -28,7 +28,6 @@
#include <unistd.h>
#include <stdio.h>
#include "connectivity.h"
#include "dpif-netdev.h"
#include "list.h"
#include "netdev-dpdk.h"
@@ -41,7 +40,6 @@
#include "ovs-rcu.h"
#include "packets.h"
#include "shash.h"
#include "seq.h"
#include "sset.h"
#include "unaligned.h"
#include "timeval.h"
@@ -318,7 +316,7 @@ check_link_status(struct netdev_dpdk *dev)
rte_eth_link_get_nowait(dev->port_id, &link);
if (dev->link.link_status != link.link_status) {
seq_change(connectivity_seq_get());
netdev_change_seq_changed(&dev->up);
dev->link_reset_cnt++;
dev->link = link;

View File

@@ -20,7 +20,6 @@
#include <errno.h>
#include "connectivity.h"
#include "dpif-netdev.h"
#include "flow.h"
#include "list.h"
@@ -32,7 +31,6 @@
#include "packets.h"
#include "pcap-file.h"
#include "poll-loop.h"
#include "seq.h"
#include "shash.h"
#include "sset.h"
#include "stream.h"
@@ -873,7 +871,7 @@ netdev_dummy_set_etheraddr(struct netdev *netdev,
ovs_mutex_lock(&dev->mutex);
if (!eth_addr_equals(dev->hwaddr, mac)) {
memcpy(dev->hwaddr, mac, ETH_ADDR_LEN);
seq_change(connectivity_seq_get());
netdev_change_seq_changed(netdev);
}
ovs_mutex_unlock(&dev->mutex);
@@ -968,7 +966,7 @@ netdev_dummy_update_flags__(struct netdev_dummy *netdev,
netdev->flags |= on;
netdev->flags &= ~off;
if (*old_flagsp != netdev->flags) {
seq_change(connectivity_seq_get());
netdev_change_seq_changed(&netdev->up);
}
return 0;

View File

@@ -47,7 +47,6 @@
#include <string.h>
#include <unistd.h>
#include "connectivity.h"
#include "coverage.h"
#include "dpif-linux.h"
#include "dpif-netdev.h"
@@ -66,7 +65,6 @@
#include "packets.h"
#include "poll-loop.h"
#include "rtnetlink-link.h"
#include "seq.h"
#include "shash.h"
#include "socket-util.h"
#include "sset.h"
@@ -616,7 +614,7 @@ netdev_linux_changed(struct netdev_linux *dev,
unsigned int ifi_flags, unsigned int mask)
OVS_REQUIRES(dev->mutex)
{
seq_change(connectivity_seq_get());
netdev_change_seq_changed(&dev->up);
if ((dev->ifi_flags ^ ifi_flags) & IFF_RUNNING) {
dev->carrier_resets++;

View File

@@ -19,8 +19,10 @@
/* Generic interface to network devices. */
#include "connectivity.h"
#include "netdev.h"
#include "list.h"
#include "seq.h"
#include "shash.h"
#include "smap.h"
@@ -38,6 +40,14 @@ struct netdev {
const struct netdev_class *netdev_class; /* Functions to control
this device. */
/* A sequence number which indicates changes in one of 'netdev''s
* properties. It must be nonzero so that users have a value which
* they may use as a reset when tracking 'netdev'.
*
* Minimally, the sequence number is required to change whenever
* 'netdev''s flags, features, ethernet address, or carrier changes. */
uint64_t change_seq;
/* The following are protected by 'netdev_mutex' (internal to netdev.c). */
int n_rxq;
int ref_cnt; /* Times this devices was opened. */
@@ -45,6 +55,16 @@ struct netdev {
struct list saved_flags_list; /* Contains "struct netdev_saved_flags". */
};
static void
netdev_change_seq_changed(struct netdev *netdev)
{
seq_change(connectivity_seq_get());
netdev->change_seq++;
if (!netdev->change_seq) {
netdev->change_seq++;
}
}
const char *netdev_get_type(const struct netdev *);
const struct netdev_class *netdev_get_class(const struct netdev *);
const char *netdev_get_name(const struct netdev *);

View File

@@ -25,7 +25,6 @@
#include <sys/ioctl.h>
#include "byte-order.h"
#include "connectivity.h"
#include "daemon.h"
#include "dirs.h"
#include "dpif.h"
@@ -36,7 +35,6 @@
#include "ofpbuf.h"
#include "packets.h"
#include "route-table.h"
#include "seq.h"
#include "shash.h"
#include "socket-util.h"
#include "vlog.h"
@@ -212,7 +210,7 @@ netdev_vport_set_etheraddr(struct netdev *netdev_,
ovs_mutex_lock(&netdev->mutex);
memcpy(netdev->etheraddr, mac, ETH_ADDR_LEN);
ovs_mutex_unlock(&netdev->mutex);
seq_change(connectivity_seq_get());
netdev_change_seq_changed(netdev_);
return 0;
}
@@ -486,7 +484,7 @@ set_tunnel_config(struct netdev *dev_, const struct smap *args)
ovs_mutex_lock(&dev->mutex);
dev->tnl_cfg = tnl_cfg;
seq_change(connectivity_seq_get());
netdev_change_seq_changed(dev_);
ovs_mutex_unlock(&dev->mutex);
return 0;
@@ -660,7 +658,7 @@ set_patch_config(struct netdev *dev_, const struct smap *args)
ovs_mutex_lock(&dev->mutex);
free(dev->peer);
dev->peer = xstrdup(peer);
seq_change(connectivity_seq_get());
netdev_change_seq_changed(dev_);
ovs_mutex_unlock(&dev->mutex);
return 0;

View File

@@ -24,7 +24,6 @@
#include <string.h>
#include <unistd.h>
#include "connectivity.h"
#include "coverage.h"
#include "dpif.h"
#include "dynamic-string.h"
@@ -38,7 +37,6 @@
#include "openflow/openflow.h"
#include "packets.h"
#include "poll-loop.h"
#include "seq.h"
#include "shash.h"
#include "smap.h"
#include "sset.h"
@@ -340,6 +338,7 @@ netdev_open(const char *name, const char *type, struct netdev **netdevp)
memset(netdev, 0, sizeof *netdev);
netdev->netdev_class = rc->class;
netdev->name = xstrdup(name);
netdev->change_seq = 1;
netdev->node = shash_add(&netdev_shash, name, netdev);
/* By default enable one rx queue per netdev. */
@@ -355,7 +354,7 @@ netdev_open(const char *name, const char *type, struct netdev **netdevp)
int old_ref_cnt;
atomic_add(&rc->ref_cnt, 1, &old_ref_cnt);
seq_change(connectivity_seq_get());
netdev_change_seq_changed(netdev);
} else {
free(netdev->name);
ovs_assert(list_is_empty(&netdev->saved_flags_list));
@@ -1649,3 +1648,9 @@ restore_all_flags(void *aux OVS_UNUSED)
}
}
}
uint64_t
netdev_get_change_seq(const struct netdev *netdev)
{
return netdev->change_seq;
}

View File

@@ -284,6 +284,7 @@ int netdev_set_queue(struct netdev *,
int netdev_delete_queue(struct netdev *, unsigned int queue_id);
int netdev_get_queue_stats(const struct netdev *, unsigned int queue_id,
struct netdev_queue_stats *);
uint64_t netdev_get_change_seq(const struct netdev *);
struct netdev_queue_dump {
struct netdev *netdev;