#include <string.h>
#include <unistd.h>
+#include "connectivity.h"
#include "coverage.h"
#include "dpif-linux.h"
#include "dynamic-string.h"
#include "packets.h"
#include "poll-loop.h"
#include "rtnetlink-link.h"
+#include "seq.h"
#include "shash.h"
#include "socket-util.h"
#include "sset.h"
struct ovs_mutex mutex;
unsigned int cache_valid;
- unsigned int change_seq;
bool miimon; /* Link status of last poll. */
long long int miimon_interval; /* Miimon Poll rate. Disabled if <= 0. */
unsigned int ifi_flags, unsigned int mask)
OVS_REQUIRES(dev->mutex)
{
- dev->change_seq++;
- if (!dev->change_seq) {
- dev->change_seq++;
- }
+ seq_change(connectivity_seq_get());
if ((dev->ifi_flags ^ ifi_flags) & IFF_RUNNING) {
dev->carrier_resets++;
netdev_linux_common_construct(struct netdev_linux *netdev)
{
ovs_mutex_init(&netdev->mutex);
- netdev->change_seq = 1;
}
/* Creates system and internal devices. */
}
return errno;
} else if (retval != size) {
- VLOG_WARN_RL(&rl, "sent partial Ethernet packet (%zd bytes of "
- "%zu) on %s", retval, size, netdev_get_name(netdev_));
+ VLOG_WARN_RL(&rl, "sent partial Ethernet packet (%"PRIuSIZE"d bytes of "
+ "%"PRIuSIZE") on %s", retval, size, netdev_get_name(netdev_));
return EMSGSIZE;
} else {
return 0;
{
uint8_t *s6 = in6->s6_addr;
#define X8 "%2"SCNx8
- return sscanf(line,
- " "X8 X8 X8 X8 X8 X8 X8 X8 X8 X8 X8 X8 X8 X8 X8 X8
- "%*x %*x %*x %*x %16s\n",
- &s6[0], &s6[1], &s6[2], &s6[3],
- &s6[4], &s6[5], &s6[6], &s6[7],
- &s6[8], &s6[9], &s6[10], &s6[11],
- &s6[12], &s6[13], &s6[14], &s6[15],
- ifname) == 17;
+ return ovs_scan(line,
+ " "X8 X8 X8 X8 X8 X8 X8 X8 X8 X8 X8 X8 X8 X8 X8 X8
+ "%*x %*x %*x %*x %16s\n",
+ &s6[0], &s6[1], &s6[2], &s6[3],
+ &s6[4], &s6[5], &s6[6], &s6[7],
+ &s6[8], &s6[9], &s6[10], &s6[11],
+ &s6[12], &s6[13], &s6[14], &s6[15],
+ ifname);
}
/* If 'netdev' has an assigned IPv6 address, sets '*in6' to that address (if
int refcnt, metric, mtu;
unsigned int flags, use, window, irtt;
- if (sscanf(line,
- "%16s %"SCNx32" %"SCNx32" %04X %d %u %d %"SCNx32
- " %d %u %u\n",
- iface, &dest, &gateway, &flags, &refcnt,
- &use, &metric, &mask, &mtu, &window, &irtt) != 11) {
-
+ if (!ovs_scan(line,
+ "%16s %"SCNx32" %"SCNx32" %04X %d %u %d %"SCNx32
+ " %d %u %u\n",
+ iface, &dest, &gateway, &flags, &refcnt,
+ &use, &metric, &mask, &mtu, &window, &irtt)) {
VLOG_WARN_RL(&rl, "%s: could not parse line %d: %s",
fn, ln, line);
continue;
return error;
}
-static unsigned int
-netdev_linux_change_seq(const struct netdev *netdev_)
-{
- struct netdev_linux *netdev = netdev_linux_cast(netdev_);
- unsigned int change_seq;
-
- ovs_mutex_lock(&netdev->mutex);
- change_seq = netdev->change_seq;
- ovs_mutex_unlock(&netdev->mutex);
-
- return change_seq;
-}
-
#define NETDEV_LINUX_CLASS(NAME, CONSTRUCT, GET_STATS, SET_STATS, \
GET_FEATURES, GET_STATUS) \
{ \
\
netdev_linux_update_flags, \
\
- netdev_linux_change_seq, \
- \
netdev_linux_rx_alloc, \
netdev_linux_rx_construct, \
netdev_linux_rx_destruct, \
if (++ln >= 3) {
char devname[16];
#define X64 "%"SCNu64
- if (sscanf(line,
- " %15[^:]:"
- X64 X64 X64 X64 X64 X64 X64 "%*u"
- X64 X64 X64 X64 X64 X64 X64 "%*u",
- devname,
- &stats->rx_bytes,
- &stats->rx_packets,
- &stats->rx_errors,
- &stats->rx_dropped,
- &stats->rx_fifo_errors,
- &stats->rx_frame_errors,
- &stats->multicast,
- &stats->tx_bytes,
- &stats->tx_packets,
- &stats->tx_errors,
- &stats->tx_dropped,
- &stats->tx_fifo_errors,
- &stats->collisions,
- &stats->tx_carrier_errors) != 15) {
+ if (!ovs_scan(line,
+ " %15[^:]:"
+ X64 X64 X64 X64 X64 X64 X64 "%*u"
+ X64 X64 X64 X64 X64 X64 X64 "%*u",
+ devname,
+ &stats->rx_bytes,
+ &stats->rx_packets,
+ &stats->rx_errors,
+ &stats->rx_dropped,
+ &stats->rx_fifo_errors,
+ &stats->rx_frame_errors,
+ &stats->multicast,
+ &stats->tx_bytes,
+ &stats->tx_packets,
+ &stats->tx_errors,
+ &stats->tx_dropped,
+ &stats->tx_fifo_errors,
+ &stats->collisions,
+ &stats->tx_carrier_errors)) {
VLOG_WARN_RL(&rl, "%s:%d: parse error", fn, ln);
} else if (!strcmp(devname, netdev_name)) {
stats->rx_length_errors = UINT64_MAX;