1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-02 10:51:20 +03:00

libsystemd-network: set SOCK_CLOEXEC and SOCK_NONBLOCK

This commit is contained in:
Yu Watanabe 2018-11-12 02:03:22 +09:00
parent f2a500eb41
commit 3e29b8895a
7 changed files with 8 additions and 8 deletions

View File

@ -988,7 +988,7 @@ int sd_dhcp_server_start(sd_dhcp_server *server) {
assert_return(server->fd < 0, -EBUSY);
assert_return(server->address != htobe32(INADDR_ANY), -EUNATCH);
r = socket(AF_PACKET, SOCK_DGRAM | SOCK_NONBLOCK, 0);
r = socket(AF_PACKET, SOCK_DGRAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0);
if (r < 0) {
r = -errno;
sd_dhcp_server_stop(server);

View File

@ -232,7 +232,7 @@ int dhcp_network_bind_raw_socket(
const uint8_t *addr, size_t addr_len,
uint16_t arp_type, uint16_t port) {
if (socketpair(AF_UNIX, SOCK_STREAM, 0, test_fd) < 0)
if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0, test_fd) < 0)
return -errno;
return test_fd[0];
@ -241,7 +241,7 @@ int dhcp_network_bind_raw_socket(
int dhcp_network_bind_udp_socket(int ifindex, be32_t address, uint16_t port) {
int fd;
fd = socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC, 0);
fd = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0);
if (fd < 0)
return -errno;

View File

@ -878,7 +878,7 @@ int dhcp6_network_send_udp_socket(int s, struct in6_addr *server_address,
int dhcp6_network_bind_udp_socket(int index, struct in6_addr *local_address) {
assert_se(index == test_index);
if (socketpair(AF_UNIX, SOCK_STREAM, 0, test_dhcp_fd) < 0)
if (socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0, test_dhcp_fd) < 0)
return -errno;
return test_dhcp_fd[0];

View File

@ -79,7 +79,7 @@ int arp_send_announcement(int fd, int ifindex,
}
int arp_network_bind_raw_socket(int index, be32_t address, const struct ether_addr *eth_mac) {
if (socketpair(AF_UNIX, SOCK_DGRAM | SOCK_NONBLOCK, 0, test_fd) < 0)
if (socketpair(AF_UNIX, SOCK_DGRAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0, test_fd) < 0)
return -errno;
return test_fd[0];

View File

@ -24,7 +24,7 @@ static int test_fd[2] = { -1, -1 };
static int lldp_handler_calls;
int lldp_network_bind_raw_socket(int ifindex) {
if (socketpair(AF_UNIX, SOCK_DGRAM | SOCK_NONBLOCK, 0, test_fd) < 0)
if (socketpair(AF_UNIX, SOCK_DGRAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0, test_fd) < 0)
return -errno;
return test_fd[0];

View File

@ -297,7 +297,7 @@ static void test_ra(void) {
printf("* %s\n", __FUNCTION__);
assert_se(socketpair(AF_UNIX, SOCK_SEQPACKET, 0, test_fd) >= 0);
assert_se(socketpair(AF_UNIX, SOCK_SEQPACKET | SOCK_CLOEXEC | SOCK_NONBLOCK, 0, test_fd) >= 0);
assert_se(sd_event_new(&e) >= 0);

View File

@ -176,7 +176,7 @@ static int test_rs_hangcheck(sd_event_source *s, uint64_t usec,
int icmp6_bind_router_solicitation(int index) {
assert_se(index == 42);
if (socketpair(AF_UNIX, SOCK_DGRAM, 0, test_fd) < 0)
if (socketpair(AF_UNIX, SOCK_DGRAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0, test_fd) < 0)
return -errno;
return test_fd[0];