Since 18167ffebe54e658579835a2e0acf67ec1d14692 fd = 0 instead of -1 considered as erroneous, because pollfd.fd on Windows does not take negative values. So, we should avoid using it.
Reported-by: Nikita Kalyazin <[email protected]> Signed-off-by: Ilya Maximets <[email protected]> --- lib/netdev-linux.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c index 584e804..e1c4e35 100644 --- a/lib/netdev-linux.c +++ b/lib/netdev-linux.c @@ -729,6 +729,20 @@ netdev_linux_alloc(void) } static void +change_fd0(int *fd) +{ + int new_fd; + /* Forbiding to open fd 0 because of windows code restrictions + * inside poll_create_node(), that considers fd 0 erroneous. */ + if (*fd == 0) { + new_fd = dup(*fd); + if (close(*fd) < 0) + VLOG_WARN("closing fd 0 failed: %s", ovs_strerror(error)); + *fd = new_fd; + } +} + +static void netdev_linux_common_construct(struct netdev_linux *netdev) { ovs_mutex_init(&netdev->mutex); @@ -778,6 +792,7 @@ netdev_linux_construct_tap(struct netdev *netdev_) /* Open tap device. */ netdev->tap_fd = open(tap_dev, O_RDWR); + change_fd0(&netdev->tap_fd); if (netdev->tap_fd < 0) { error = errno; VLOG_WARN("opening \"%s\" failed: %s", tap_dev, ovs_strerror(error)); @@ -871,6 +886,7 @@ netdev_linux_rxq_construct(struct netdev_rxq *rxq_) /* Create file descriptor. */ rx->fd = socket(PF_PACKET, SOCK_RAW, 0); + change_fd0(&rx->fd); if (rx->fd < 0) { error = errno; VLOG_ERR("failed to create raw socket (%s)", ovs_strerror(error)); -- 2.1.4 _______________________________________________ dev mailing list [email protected] http://openvswitch.org/mailman/listinfo/dev
