af_inet_sock = socket(AF_INET, SOCK_DGRAM, 0);
status = af_inet_sock >= 0 ? 0 : errno;
if (status) {
- VLOG_ERR("failed to create inet socket: %s", strerror(status));
+ VLOG_ERR("failed to create inet socket: %s", ovs_strerror(status));
return status;
}
af_link_sock = socket(AF_LINK, SOCK_DGRAM, 0);
status = af_link_sock >= 0 ? 0 : errno;
if (status) {
- VLOG_ERR("failed to create link socket: %s", strerror(status));
+ VLOG_ERR("failed to create link socket: %s", Ovs_strerror(status));
close(af_inet_sock);
af_inet_sock = -1;
}
netdev->change_seq = 1;
if (netdev->tap_fd < 0) {
error = errno;
- VLOG_WARN("opening \"/dev/tap\" failed: %s", strerror(error));
+ VLOG_WARN("opening \"/dev/tap\" failed: %s", ovs_strerror(error));
goto error_undef_notifier;
}
* buffer becomes full or a timeout occurs. */
if (ioctl(fd, BIOCIMMEDIATE, &one) < 0 ) {
VLOG_ERR_RL(&rl, "ioctl(BIOCIMMEDIATE) on %s device failed: %s",
- name, strerror(errno));
+ name, ovs_strerror(errno));
error = errno;
goto error;
}
} else if (errno != EINTR) {
if (errno != EAGAIN) {
VLOG_WARN_RL(&rl, "error receiving Ethernet packet on %s: %s",
- strerror(errno), netdev_rx_get_name(&rx->up));
+ ovs_strerror(errno), netdev_rx_get_name(&rx->up));
}
return -errno;
}
strcpy(ifr.ifr_name, netdev_get_kernel_name(netdev_rx_get_netdev(rx_)));
if (ioctl(rx->fd, BIOCFLUSH, &ifr) == -1) {
VLOG_DBG_RL(&rl, "%s: ioctl(BIOCFLUSH) failed: %s",
- netdev_rx_get_name(rx_), strerror(errno));
+ netdev_rx_get_name(rx_), ovs_strerror(errno));
return errno;
}
return 0;
continue;
} else if (errno != EAGAIN) {
VLOG_WARN_RL(&rl, "error sending Ethernet packet on %s: %s",
- name, strerror(errno));
+ name, ovs_strerror(errno));
}
return errno;
} else if (retval != size) {
if (ioctl(af_inet_sock, SIOCGIFMEDIA, &ifmr) == -1) {
VLOG_DBG_RL(&rl, "%s: ioctl(SIOCGIFMEDIA) failed: %s",
- netdev_get_name(netdev_), strerror(errno));
+ netdev_get_name(netdev_), ovs_strerror(errno));
return errno;
}
return 0;
}
+static void
+convert_stats(struct netdev_stats *stats, const struct if_data *ifd)
+{
+ /*
+ * note: UINT64_MAX means unsupported
+ */
+ stats->rx_packets = ifd->ifi_ipackets;
+ stats->tx_packets = ifd->ifi_opackets;
+ stats->rx_bytes = ifd->ifi_obytes;
+ stats->tx_bytes = ifd->ifi_ibytes;
+ stats->rx_errors = ifd->ifi_ierrors;
+ stats->tx_errors = ifd->ifi_oerrors;
+ stats->rx_dropped = ifd->ifi_iqdrops;
+ stats->tx_dropped = UINT64_MAX;
+ stats->multicast = ifd->ifi_imcasts;
+ stats->collisions = ifd->ifi_collisions;
+ stats->rx_length_errors = UINT64_MAX;
+ stats->rx_over_errors = UINT64_MAX;
+ stats->rx_crc_errors = UINT64_MAX;
+ stats->rx_frame_errors = UINT64_MAX;
+ stats->rx_fifo_errors = UINT64_MAX;
+ stats->rx_missed_errors = UINT64_MAX;
+ stats->tx_aborted_errors = UINT64_MAX;
+ stats->tx_carrier_errors = UINT64_MAX;
+ stats->tx_fifo_errors = UINT64_MAX;
+ stats->tx_heartbeat_errors = UINT64_MAX;
+ stats->tx_window_errors = UINT64_MAX;
+}
+
/* Retrieves current device stats for 'netdev'. */
static int
netdev_bsd_get_stats(const struct netdev *netdev_, struct netdev_stats *stats)
if (sysctl(mib, 5, &if_count, &len, (void *)0, 0) == -1) {
VLOG_DBG_RL(&rl, "%s: sysctl failed: %s",
- netdev_get_name(netdev_), strerror(errno));
+ netdev_get_name(netdev_), ovs_strerror(errno));
return errno;
}
mib[4] = i; //row
if (sysctl(mib, 6, &ifmd, &len, (void *)0, 0) == -1) {
VLOG_DBG_RL(&rl, "%s: sysctl failed: %s",
- netdev_get_name(netdev_), strerror(errno));
+ netdev_get_name(netdev_), ovs_strerror(errno));
return errno;
} else if (!strcmp(ifmd.ifmd_name, netdev_get_name(netdev_))) {
- stats->rx_packets = ifmd.ifmd_data.ifi_ipackets;
- stats->tx_packets = ifmd.ifmd_data.ifi_opackets;
- stats->rx_bytes = ifmd.ifmd_data.ifi_ibytes;
- stats->tx_bytes = ifmd.ifmd_data.ifi_obytes;
- stats->rx_errors = ifmd.ifmd_data.ifi_ierrors;
- stats->tx_errors = ifmd.ifmd_data.ifi_oerrors;
- stats->rx_dropped = ifmd.ifmd_data.ifi_iqdrops;
- stats->tx_dropped = UINT64_MAX;
- stats->multicast = ifmd.ifmd_data.ifi_imcasts;
- stats->collisions = ifmd.ifmd_data.ifi_collisions;
-
- stats->rx_length_errors = UINT64_MAX;
- stats->rx_over_errors = UINT64_MAX;
- stats->rx_crc_errors = UINT64_MAX;
- stats->rx_frame_errors = UINT64_MAX;
- stats->rx_fifo_errors = UINT64_MAX;
- stats->rx_missed_errors = UINT64_MAX;
-
- stats->tx_aborted_errors = UINT64_MAX;
- stats->tx_carrier_errors = UINT64_MAX;
- stats->tx_fifo_errors = UINT64_MAX;
- stats->tx_heartbeat_errors = UINT64_MAX;
- stats->tx_window_errors = UINT64_MAX;
+ convert_stats(stats, &ifmd.ifmd_data);
break;
}
}
return 0;
#elif defined(__NetBSD__)
struct ifdatareq ifdr;
- struct if_data *ifd;
int saved_errno;
int ret;
if (ret == -1) {
return saved_errno;
}
- ifd = &ifdr.ifdr_data;
- /*
- * note: UINT64_MAX means unsupported
- */
- stats->rx_packets = ifd->ifi_ipackets;
- stats->tx_packets = ifd->ifi_opackets;
- stats->rx_bytes = ifd->ifi_obytes;
- stats->tx_bytes = ifd->ifi_ibytes;
- stats->rx_errors = ifd->ifi_ierrors;
- stats->tx_errors = ifd->ifi_oerrors;
- stats->rx_dropped = ifd->ifi_iqdrops;
- stats->tx_dropped = UINT64_MAX;
- stats->multicast = ifd->ifi_imcasts;
- stats->collisions = ifd->ifi_collisions;
- stats->rx_length_errors = UINT64_MAX;
- stats->rx_over_errors = UINT64_MAX;
- stats->rx_crc_errors = UINT64_MAX;
- stats->rx_frame_errors = UINT64_MAX;
- stats->rx_fifo_errors = UINT64_MAX;
- stats->rx_missed_errors = UINT64_MAX;
- stats->tx_aborted_errors = UINT64_MAX;
- stats->tx_carrier_errors = UINT64_MAX;
- stats->tx_fifo_errors = UINT64_MAX;
- stats->tx_heartbeat_errors = UINT64_MAX;
- stats->tx_window_errors = UINT64_MAX;
+ convert_stats(stats, &ifdr.ifdr_data);
return 0;
#else
#error not implemented
* them. */
if (ioctl(af_inet_sock, SIOCGIFMEDIA, &ifmr) == -1) {
VLOG_DBG_RL(&rl, "%s: ioctl(SIOCGIFMEDIA) failed: %s",
- netdev_get_name(netdev), strerror(errno));
+ netdev_get_name(netdev), ovs_strerror(errno));
return errno;
}
if (ioctl(af_inet_sock, SIOCGIFMEDIA, &ifmr) == -1) {
VLOG_DBG_RL(&rl, "%s: ioctl(SIOCGIFMEDIA) failed: %s",
- netdev_get_name(netdev), strerror(errno));
+ netdev_get_name(netdev), ovs_strerror(errno));
error = errno;
goto cleanup;
}
if (getifaddrs(&head) != 0) {
VLOG_ERR("getifaddrs on %s device failed: %s", netdev_name,
- strerror(errno));
+ ovs_strerror(errno));
return errno;
}
#endif
static int
-netdev_bsd_get_next_hop(const struct in_addr *host, struct in_addr *next_hop,
- char **netdev_name)
+netdev_bsd_get_next_hop(const struct in_addr *host OVS_UNUSED,
+ struct in_addr *next_hop OVS_UNUSED,
+ char **netdev_name OVS_UNUSED)
{
#if defined(__NetBSD__)
static int seq = 0;
if (getifaddrs(&head) != 0) {
VLOG_ERR("getifaddrs on %s device failed: %s", netdev_name,
- strerror(errno));
+ ovs_strerror(errno));
return errno;
}
memcpy(ifr.ifr_addr.sa_data, mac, hwaddr_len);
if (ioctl(af_inet_sock, SIOCSIFLLADDR, &ifr) < 0) {
VLOG_ERR("ioctl(SIOCSIFLLADDR) on %s device failed: %s",
- netdev_name, strerror(errno));
+ netdev_name, ovs_strerror(errno));
return errno;
}
return 0;
strncpy(ifr->ifr_name, name, sizeof ifr->ifr_name);
if (ioctl(af_inet_sock, cmd, ifr) == -1) {
VLOG_DBG_RL(&rl, "%s: ioctl(%s) failed: %s", name, cmd_name,
- strerror(errno));
+ ovs_strerror(errno));
return errno;
}
return 0;
ifr_get_flags(const struct ifreq *ifr)
{
#ifdef HAVE_STRUCT_IFREQ_IFR_FLAGSHIGH
- return (ifr.ifr_flagshigh << 16) | ifr.ifr_flags;
+ return (ifr->ifr_flagshigh << 16) | ifr->ifr_flags;
#else
- return ifr.ifr_flags;
+ return ifr->ifr_flags;
#endif
}