mirror of
https://github.com/openvswitch/ovs
synced 2025-08-30 22:05:19 +00:00
netdev-linux: Don't close(0) when closing an ordinary netdev.
Calling close(0) at random points is bad. It means that the next call to socket() or open() returns fd 0. Then the next time a netdev gets closed, that socket or file fd gets closed too, and you end up with weird "Bad file descriptor" errors. Found by installing the following as lib/unistd.h in the source tree: #ifndef UNISTD_H #define UNISTD_H 1 #include <stdlib.h> #include_next <unistd.h> #undef close #define close(fd) rpl_close(fd) static inline int rpl_close(int fd) { if (!fd) { abort(); } return (close)(fd); } #endif
This commit is contained in:
@@ -821,7 +821,6 @@ netdev_linux_open(struct netdev_dev *netdev_dev_, int ethertype,
|
||||
|
||||
if (!strcmp(netdev_dev_get_type(netdev_dev_), "tap")) {
|
||||
netdev->fd = netdev_dev->state.tap.fd;
|
||||
|
||||
} else if (ethertype != NETDEV_ETH_TYPE_NONE) {
|
||||
struct sockaddr_ll sll;
|
||||
int protocol;
|
||||
@@ -869,6 +868,8 @@ netdev_linux_open(struct netdev_dev *netdev_dev_, int ethertype,
|
||||
if (error) {
|
||||
goto error;
|
||||
}
|
||||
} else {
|
||||
netdev->fd = -1;
|
||||
}
|
||||
|
||||
*netdevp = &netdev->netdev;
|
||||
|
Reference in New Issue
Block a user