mirror of
https://github.com/systemd/systemd
synced 2024-09-16 06:43:18 +00:00
tree-wide: add a single version of "static const int one = 1"
All over the place we define local variables for the various sockopts that take a bool-like "int" value. Sometimes they are const, sometimes static, sometimes both, sometimes neither. Let's clean this up, introduce a common const variable "const_int_one" (as well as one matching "const_int_zero") and use it everywhere, all acorss the codebase.
This commit is contained in:
parent
8e8132c6b8
commit
6d5e65f645
|
@ -35,7 +35,7 @@ int socket_address_listen(
|
|||
|
||||
_cleanup_close_ int fd = -1;
|
||||
const char *p;
|
||||
int r, one;
|
||||
int r;
|
||||
|
||||
assert(a);
|
||||
|
||||
|
@ -74,26 +74,22 @@ int socket_address_listen(
|
|||
return -errno;
|
||||
|
||||
if (reuse_port) {
|
||||
one = 1;
|
||||
if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &one, sizeof(one)) < 0)
|
||||
if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &const_int_one, sizeof(const_int_one)) < 0)
|
||||
log_warning_errno(errno, "SO_REUSEPORT failed: %m");
|
||||
}
|
||||
|
||||
if (free_bind) {
|
||||
one = 1;
|
||||
if (setsockopt(fd, IPPROTO_IP, IP_FREEBIND, &one, sizeof(one)) < 0)
|
||||
if (setsockopt(fd, IPPROTO_IP, IP_FREEBIND, &const_int_one, sizeof(const_int_one)) < 0)
|
||||
log_warning_errno(errno, "IP_FREEBIND failed: %m");
|
||||
}
|
||||
|
||||
if (transparent) {
|
||||
one = 1;
|
||||
if (setsockopt(fd, IPPROTO_IP, IP_TRANSPARENT, &one, sizeof(one)) < 0)
|
||||
if (setsockopt(fd, IPPROTO_IP, IP_TRANSPARENT, &const_int_one, sizeof(const_int_one)) < 0)
|
||||
log_warning_errno(errno, "IP_TRANSPARENT failed: %m");
|
||||
}
|
||||
}
|
||||
|
||||
one = 1;
|
||||
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one)) < 0)
|
||||
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &const_int_one, sizeof(const_int_one)) < 0)
|
||||
return -errno;
|
||||
|
||||
p = socket_address_get_path(a);
|
||||
|
|
|
@ -51,6 +51,9 @@ int saved_argc = 0;
|
|||
char **saved_argv = NULL;
|
||||
static int saved_in_initrd = -1;
|
||||
|
||||
const int const_int_zero = 0;
|
||||
const int const_int_one = 1;
|
||||
|
||||
size_t page_size(void) {
|
||||
static thread_local size_t pgsz = 0;
|
||||
long r;
|
||||
|
|
|
@ -232,3 +232,6 @@ int version(void);
|
|||
int str_verscmp(const char *s1, const char *s2);
|
||||
|
||||
void disable_coredumps(void);
|
||||
|
||||
extern const int const_int_zero;
|
||||
extern const int const_int_one;
|
||||
|
|
|
@ -873,7 +873,6 @@ static int manager_setup_notify(Manager *m) {
|
|||
if (m->notify_fd < 0) {
|
||||
_cleanup_close_ int fd = -1;
|
||||
union sockaddr_union sa = {};
|
||||
static const int one = 1;
|
||||
int salen;
|
||||
|
||||
/* First free all secondary fields */
|
||||
|
@ -901,7 +900,7 @@ static int manager_setup_notify(Manager *m) {
|
|||
if (r < 0)
|
||||
return log_error_errno(errno, "bind(%s) failed: %m", m->notify_socket);
|
||||
|
||||
r = setsockopt(fd, SOL_SOCKET, SO_PASSCRED, &one, sizeof(one));
|
||||
r = setsockopt(fd, SOL_SOCKET, SO_PASSCRED, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0)
|
||||
return log_error_errno(errno, "SO_PASSCRED failed: %m");
|
||||
|
||||
|
|
|
@ -1018,8 +1018,7 @@ static void socket_apply_socket_options(Socket *s, int fd) {
|
|||
assert(fd >= 0);
|
||||
|
||||
if (s->keep_alive) {
|
||||
int one = 1;
|
||||
if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &one, sizeof(one)) < 0)
|
||||
if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &const_int_one, sizeof(const_int_one)) < 0)
|
||||
log_unit_warning_errno(UNIT(s), errno, "SO_KEEPALIVE failed: %m");
|
||||
}
|
||||
|
||||
|
@ -1048,32 +1047,27 @@ static void socket_apply_socket_options(Socket *s, int fd) {
|
|||
}
|
||||
|
||||
if (s->no_delay) {
|
||||
int one = 1;
|
||||
|
||||
if (s->socket_protocol == IPPROTO_SCTP) {
|
||||
if (setsockopt(fd, SOL_SCTP, SCTP_NODELAY, &one, sizeof(one)) < 0)
|
||||
if (setsockopt(fd, SOL_SCTP, SCTP_NODELAY, &const_int_one, sizeof(const_int_one)) < 0)
|
||||
log_unit_warning_errno(UNIT(s), errno, "SCTP_NODELAY failed: %m");
|
||||
} else {
|
||||
if (setsockopt(fd, SOL_TCP, TCP_NODELAY, &one, sizeof(one)) < 0)
|
||||
if (setsockopt(fd, SOL_TCP, TCP_NODELAY, &const_int_one, sizeof(const_int_one)) < 0)
|
||||
log_unit_warning_errno(UNIT(s), errno, "TCP_NODELAY failed: %m");
|
||||
}
|
||||
}
|
||||
|
||||
if (s->broadcast) {
|
||||
int one = 1;
|
||||
if (setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &one, sizeof(one)) < 0)
|
||||
if (setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &const_int_one, sizeof(const_int_one)) < 0)
|
||||
log_unit_warning_errno(UNIT(s), errno, "SO_BROADCAST failed: %m");
|
||||
}
|
||||
|
||||
if (s->pass_cred) {
|
||||
int one = 1;
|
||||
if (setsockopt(fd, SOL_SOCKET, SO_PASSCRED, &one, sizeof(one)) < 0)
|
||||
if (setsockopt(fd, SOL_SOCKET, SO_PASSCRED, &const_int_one, sizeof(const_int_one)) < 0)
|
||||
log_unit_warning_errno(UNIT(s), errno, "SO_PASSCRED failed: %m");
|
||||
}
|
||||
|
||||
if (s->pass_sec) {
|
||||
int one = 1;
|
||||
if (setsockopt(fd, SOL_SOCKET, SO_PASSSEC, &one, sizeof(one)) < 0)
|
||||
if (setsockopt(fd, SOL_SOCKET, SO_PASSSEC, &const_int_one, sizeof(const_int_one)) < 0)
|
||||
log_unit_warning_errno(UNIT(s), errno, "SO_PASSSEC failed: %m");
|
||||
}
|
||||
|
||||
|
|
|
@ -584,7 +584,6 @@ static int manager_new(Manager **ret) {
|
|||
.un.sun_family = AF_UNIX,
|
||||
.un.sun_path = "/run/systemd/import/notify",
|
||||
};
|
||||
static const int one = 1;
|
||||
int r;
|
||||
|
||||
assert(ret);
|
||||
|
@ -613,7 +612,7 @@ static int manager_new(Manager **ret) {
|
|||
if (bind(m->notify_fd, &sa.sa, SOCKADDR_UN_LEN(sa.un)) < 0)
|
||||
return -errno;
|
||||
|
||||
if (setsockopt(m->notify_fd, SOL_SOCKET, SO_PASSCRED, &one, sizeof(one)) < 0)
|
||||
if (setsockopt(m->notify_fd, SOL_SOCKET, SO_PASSCRED, &const_int_one, sizeof(const_int_one)) < 0)
|
||||
return -errno;
|
||||
|
||||
r = sd_event_add_io(m->event, &m->notify_event_source, m->notify_fd, EPOLLIN, manager_on_notify, m);
|
||||
|
|
|
@ -497,7 +497,6 @@ static int enable_audit(int fd, bool b) {
|
|||
}
|
||||
|
||||
int server_open_audit(Server *s) {
|
||||
static const int one = 1;
|
||||
int r;
|
||||
|
||||
if (s->audit_fd < 0) {
|
||||
|
@ -528,7 +527,7 @@ int server_open_audit(Server *s) {
|
|||
} else
|
||||
(void) fd_nonblock(s->audit_fd, true);
|
||||
|
||||
r = setsockopt(s->audit_fd, SOL_SOCKET, SO_PASSCRED, &one, sizeof(one));
|
||||
r = setsockopt(s->audit_fd, SOL_SOCKET, SO_PASSCRED, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0)
|
||||
return log_error_errno(errno, "Failed to set SO_PASSCRED on audit socket: %m");
|
||||
|
||||
|
|
|
@ -443,7 +443,6 @@ int server_open_native_socket(Server*s) {
|
|||
.un.sun_family = AF_UNIX,
|
||||
.un.sun_path = "/run/systemd/journal/socket",
|
||||
};
|
||||
static const int one = 1;
|
||||
int r;
|
||||
|
||||
assert(s);
|
||||
|
@ -463,19 +462,19 @@ int server_open_native_socket(Server*s) {
|
|||
} else
|
||||
(void) fd_nonblock(s->native_fd, true);
|
||||
|
||||
r = setsockopt(s->native_fd, SOL_SOCKET, SO_PASSCRED, &one, sizeof(one));
|
||||
r = setsockopt(s->native_fd, SOL_SOCKET, SO_PASSCRED, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0)
|
||||
return log_error_errno(errno, "SO_PASSCRED failed: %m");
|
||||
|
||||
#if HAVE_SELINUX
|
||||
if (mac_selinux_use()) {
|
||||
r = setsockopt(s->native_fd, SOL_SOCKET, SO_PASSSEC, &one, sizeof(one));
|
||||
r = setsockopt(s->native_fd, SOL_SOCKET, SO_PASSSEC, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0)
|
||||
log_warning_errno(errno, "SO_PASSSEC failed: %m");
|
||||
}
|
||||
#endif
|
||||
|
||||
r = setsockopt(s->native_fd, SOL_SOCKET, SO_TIMESTAMP, &one, sizeof(one));
|
||||
r = setsockopt(s->native_fd, SOL_SOCKET, SO_TIMESTAMP, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0)
|
||||
return log_error_errno(errno, "SO_TIMESTAMP failed: %m");
|
||||
|
||||
|
|
|
@ -447,7 +447,6 @@ int server_open_syslog_socket(Server *s) {
|
|||
.un.sun_family = AF_UNIX,
|
||||
.un.sun_path = "/run/systemd/journal/dev-log",
|
||||
};
|
||||
static const int one = 1;
|
||||
int r;
|
||||
|
||||
assert(s);
|
||||
|
@ -467,19 +466,19 @@ int server_open_syslog_socket(Server *s) {
|
|||
} else
|
||||
(void) fd_nonblock(s->syslog_fd, true);
|
||||
|
||||
r = setsockopt(s->syslog_fd, SOL_SOCKET, SO_PASSCRED, &one, sizeof(one));
|
||||
r = setsockopt(s->syslog_fd, SOL_SOCKET, SO_PASSCRED, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0)
|
||||
return log_error_errno(errno, "SO_PASSCRED failed: %m");
|
||||
|
||||
#if HAVE_SELINUX
|
||||
if (mac_selinux_use()) {
|
||||
r = setsockopt(s->syslog_fd, SOL_SOCKET, SO_PASSSEC, &one, sizeof(one));
|
||||
r = setsockopt(s->syslog_fd, SOL_SOCKET, SO_PASSSEC, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0)
|
||||
log_warning_errno(errno, "SO_PASSSEC failed: %m");
|
||||
}
|
||||
#endif
|
||||
|
||||
r = setsockopt(s->syslog_fd, SOL_SOCKET, SO_TIMESTAMP, &one, sizeof(one));
|
||||
r = setsockopt(s->syslog_fd, SOL_SOCKET, SO_TIMESTAMP, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0)
|
||||
return log_error_errno(errno, "SO_TIMESTAMP failed: %m");
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ static int _bind_raw_socket(int ifindex, union sockaddr_union *link,
|
|||
.filter = filter
|
||||
};
|
||||
_cleanup_close_ int s = -1;
|
||||
int r, on = 1;
|
||||
int r;
|
||||
|
||||
assert(ifindex > 0);
|
||||
assert(link);
|
||||
|
@ -87,7 +87,7 @@ static int _bind_raw_socket(int ifindex, union sockaddr_union *link,
|
|||
if (s < 0)
|
||||
return -errno;
|
||||
|
||||
r = setsockopt(s, SOL_PACKET, PACKET_AUXDATA, &on, sizeof(on));
|
||||
r = setsockopt(s, SOL_PACKET, PACKET_AUXDATA, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0)
|
||||
return -errno;
|
||||
|
||||
|
@ -149,7 +149,7 @@ int dhcp_network_bind_udp_socket(int ifindex, be32_t address, uint16_t port) {
|
|||
};
|
||||
_cleanup_close_ int s = -1;
|
||||
char ifname[IF_NAMESIZE] = "";
|
||||
int r, on = 1, tos = IPTOS_CLASS_CS6;
|
||||
int r, tos = IPTOS_CLASS_CS6;
|
||||
|
||||
s = socket(AF_INET, SOCK_DGRAM | SOCK_CLOEXEC | SOCK_NONBLOCK, 0);
|
||||
if (s < 0)
|
||||
|
@ -159,7 +159,7 @@ int dhcp_network_bind_udp_socket(int ifindex, be32_t address, uint16_t port) {
|
|||
if (r < 0)
|
||||
return -errno;
|
||||
|
||||
r = setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
|
||||
r = setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0)
|
||||
return -errno;
|
||||
|
||||
|
@ -173,16 +173,16 @@ int dhcp_network_bind_udp_socket(int ifindex, be32_t address, uint16_t port) {
|
|||
}
|
||||
|
||||
if (address == INADDR_ANY) {
|
||||
r = setsockopt(s, IPPROTO_IP, IP_PKTINFO, &on, sizeof(on));
|
||||
r = setsockopt(s, IPPROTO_IP, IP_PKTINFO, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0)
|
||||
return -errno;
|
||||
|
||||
r = setsockopt(s, SOL_SOCKET, SO_BROADCAST, &on, sizeof(on));
|
||||
r = setsockopt(s, SOL_SOCKET, SO_BROADCAST, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0)
|
||||
return -errno;
|
||||
|
||||
} else {
|
||||
r = setsockopt(s, IPPROTO_IP, IP_FREEBIND, &on, sizeof(on));
|
||||
r = setsockopt(s, IPPROTO_IP, IP_FREEBIND, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0)
|
||||
return -errno;
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ int dhcp6_network_bind_udp_socket(int index, struct in6_addr *local_address) {
|
|||
.in6.sin6_scope_id = index,
|
||||
};
|
||||
_cleanup_close_ int s = -1;
|
||||
int r, off = 0, on = 1;
|
||||
int r;
|
||||
|
||||
assert(index > 0);
|
||||
assert(local_address);
|
||||
|
@ -36,15 +36,15 @@ int dhcp6_network_bind_udp_socket(int index, struct in6_addr *local_address) {
|
|||
if (s < 0)
|
||||
return -errno;
|
||||
|
||||
r = setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on));
|
||||
r = setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0)
|
||||
return -errno;
|
||||
|
||||
r = setsockopt(s, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, &off, sizeof(off));
|
||||
r = setsockopt(s, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, &const_int_zero, sizeof(const_int_zero));
|
||||
if (r < 0)
|
||||
return -errno;
|
||||
|
||||
r = setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
|
||||
r = setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0)
|
||||
return -errno;
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ static int icmp6_bind_router_message(const struct icmp6_filter *filter,
|
|||
int index = mreq->ipv6mr_interface;
|
||||
_cleanup_close_ int s = -1;
|
||||
char ifname[IF_NAMESIZE] = "";
|
||||
static const int zero = 0, one = 1, hops = 255;
|
||||
static const int hops = 255;
|
||||
int r;
|
||||
|
||||
s = socket(AF_INET6, SOCK_RAW | SOCK_CLOEXEC | SOCK_NONBLOCK, IPPROTO_ICMPV6);
|
||||
|
@ -56,7 +56,7 @@ static int icmp6_bind_router_message(const struct icmp6_filter *filter,
|
|||
if (r < 0)
|
||||
return -errno;
|
||||
|
||||
r = setsockopt(s, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, &zero, sizeof(zero));
|
||||
r = setsockopt(s, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, &const_int_zero, sizeof(const_int_zero));
|
||||
if (r < 0)
|
||||
return -errno;
|
||||
|
||||
|
@ -68,11 +68,11 @@ static int icmp6_bind_router_message(const struct icmp6_filter *filter,
|
|||
if (r < 0)
|
||||
return -errno;
|
||||
|
||||
r = setsockopt(s, SOL_IPV6, IPV6_RECVHOPLIMIT, &one, sizeof(one));
|
||||
r = setsockopt(s, SOL_IPV6, IPV6_RECVHOPLIMIT, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0)
|
||||
return -errno;
|
||||
|
||||
r = setsockopt(s, SOL_SOCKET, SO_TIMESTAMP, &one, sizeof(one));
|
||||
r = setsockopt(s, SOL_SOCKET, SO_TIMESTAMP, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0)
|
||||
return -errno;
|
||||
|
||||
|
|
|
@ -88,9 +88,9 @@ static int broadcast_groups_get(sd_netlink *nl) {
|
|||
|
||||
int socket_bind(sd_netlink *nl) {
|
||||
socklen_t addrlen;
|
||||
int r, one = 1;
|
||||
int r;
|
||||
|
||||
r = setsockopt(nl->fd, SOL_NETLINK, NETLINK_PKTINFO, &one, sizeof(one));
|
||||
r = setsockopt(nl->fd, SOL_NETLINK, NETLINK_PKTINFO, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0)
|
||||
return -errno;
|
||||
|
||||
|
|
|
@ -337,7 +337,6 @@ int udev_monitor_allow_unicast_sender(struct udev_monitor *udev_monitor, struct
|
|||
* Returns: 0 on success, otherwise a negative error value.
|
||||
*/
|
||||
_public_ int udev_monitor_enable_receiving(struct udev_monitor *udev_monitor) {
|
||||
const int on = 1;
|
||||
int r;
|
||||
|
||||
assert_return(udev_monitor, -EINVAL);
|
||||
|
@ -358,7 +357,7 @@ _public_ int udev_monitor_enable_receiving(struct udev_monitor *udev_monitor) {
|
|||
return log_debug_errno(r, "Failed to set address: %m");
|
||||
|
||||
/* enable receiving of sender credentials */
|
||||
if (setsockopt(udev_monitor->sock, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on)) < 0)
|
||||
if (setsockopt(udev_monitor->sock, SOL_SOCKET, SO_PASSCRED, &const_int_one, sizeof(const_int_one)) < 0)
|
||||
return log_debug_errno(errno, "Failed to set socket option SO_PASSCRED: %m");
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -2812,7 +2812,6 @@ static int inner_child(
|
|||
}
|
||||
|
||||
static int setup_sd_notify_child(void) {
|
||||
static const int one = 1;
|
||||
int fd = -1;
|
||||
union sockaddr_union sa = {
|
||||
.un.sun_family = AF_UNIX,
|
||||
|
@ -2839,7 +2838,7 @@ static int setup_sd_notify_child(void) {
|
|||
return log_error_errno(r, "Failed to chown " NSPAWN_NOTIFY_SOCKET_PATH ": %m");
|
||||
}
|
||||
|
||||
r = setsockopt(fd, SOL_SOCKET, SO_PASSCRED, &one, sizeof(one));
|
||||
r = setsockopt(fd, SOL_SOCKET, SO_PASSCRED, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0) {
|
||||
safe_close(fd);
|
||||
return log_error_errno(errno, "SO_PASSCRED failed: %m");
|
||||
|
|
|
@ -313,7 +313,6 @@ static int dns_scope_socket(
|
|||
_cleanup_close_ int fd = -1;
|
||||
union sockaddr_union sa;
|
||||
socklen_t salen;
|
||||
static const int one = 1;
|
||||
int r, ifindex;
|
||||
|
||||
assert(s);
|
||||
|
@ -379,7 +378,7 @@ static int dns_scope_socket(
|
|||
return -errno;
|
||||
|
||||
if (type == SOCK_STREAM) {
|
||||
r = setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &one, sizeof(one));
|
||||
r = setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0)
|
||||
return -errno;
|
||||
}
|
||||
|
@ -402,11 +401,11 @@ static int dns_scope_socket(
|
|||
/* RFC 4795, section 2.5 requires the TTL to be set to 1 */
|
||||
|
||||
if (sa.sa.sa_family == AF_INET) {
|
||||
r = setsockopt(fd, IPPROTO_IP, IP_TTL, &one, sizeof(one));
|
||||
r = setsockopt(fd, IPPROTO_IP, IP_TTL, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0)
|
||||
return -errno;
|
||||
} else if (sa.sa.sa_family == AF_INET6) {
|
||||
r = setsockopt(fd, IPPROTO_IPV6, IPV6_UNICAST_HOPS, &one, sizeof(one));
|
||||
r = setsockopt(fd, IPPROTO_IPV6, IPV6_UNICAST_HOPS, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0)
|
||||
return -errno;
|
||||
}
|
||||
|
|
|
@ -392,7 +392,6 @@ static int on_dns_stub_packet(sd_event_source *s, int fd, uint32_t revents, void
|
|||
}
|
||||
|
||||
static int manager_dns_stub_udp_fd(Manager *m) {
|
||||
static const int one = 1;
|
||||
union sockaddr_union sa = {
|
||||
.in.sin_family = AF_INET,
|
||||
.in.sin_port = htobe16(53),
|
||||
|
@ -408,13 +407,13 @@ static int manager_dns_stub_udp_fd(Manager *m) {
|
|||
if (fd < 0)
|
||||
return -errno;
|
||||
|
||||
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof one) < 0)
|
||||
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &const_int_one, sizeof const_int_one) < 0)
|
||||
return -errno;
|
||||
|
||||
if (setsockopt(fd, IPPROTO_IP, IP_PKTINFO, &one, sizeof one) < 0)
|
||||
if (setsockopt(fd, IPPROTO_IP, IP_PKTINFO, &const_int_one, sizeof const_int_one) < 0)
|
||||
return -errno;
|
||||
|
||||
if (setsockopt(fd, IPPROTO_IP, IP_RECVTTL, &one, sizeof one) < 0)
|
||||
if (setsockopt(fd, IPPROTO_IP, IP_RECVTTL, &const_int_one, sizeof const_int_one) < 0)
|
||||
return -errno;
|
||||
|
||||
/* Make sure no traffic from outside the local host can leak to onto this socket */
|
||||
|
@ -479,7 +478,6 @@ static int on_dns_stub_stream(sd_event_source *s, int fd, uint32_t revents, void
|
|||
}
|
||||
|
||||
static int manager_dns_stub_tcp_fd(Manager *m) {
|
||||
static const int one = 1;
|
||||
union sockaddr_union sa = {
|
||||
.in.sin_family = AF_INET,
|
||||
.in.sin_addr.s_addr = htobe32(INADDR_DNS_STUB),
|
||||
|
@ -495,16 +493,16 @@ static int manager_dns_stub_tcp_fd(Manager *m) {
|
|||
if (fd < 0)
|
||||
return -errno;
|
||||
|
||||
if (setsockopt(fd, IPPROTO_IP, IP_TTL, &one, sizeof one) < 0)
|
||||
if (setsockopt(fd, IPPROTO_IP, IP_TTL, &const_int_one, sizeof const_int_one) < 0)
|
||||
return -errno;
|
||||
|
||||
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof one) < 0)
|
||||
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &const_int_one, sizeof const_int_one) < 0)
|
||||
return -errno;
|
||||
|
||||
if (setsockopt(fd, IPPROTO_IP, IP_PKTINFO, &one, sizeof one) < 0)
|
||||
if (setsockopt(fd, IPPROTO_IP, IP_PKTINFO, &const_int_one, sizeof const_int_one) < 0)
|
||||
return -errno;
|
||||
|
||||
if (setsockopt(fd, IPPROTO_IP, IP_RECVTTL, &one, sizeof one) < 0)
|
||||
if (setsockopt(fd, IPPROTO_IP, IP_RECVTTL, &const_int_one, sizeof const_int_one) < 0)
|
||||
return -errno;
|
||||
|
||||
/* Make sure no traffic from outside the local host can leak to onto this socket */
|
||||
|
|
|
@ -115,7 +115,7 @@ int manager_llmnr_ipv4_udp_fd(Manager *m) {
|
|||
.in.sin_family = AF_INET,
|
||||
.in.sin_port = htobe16(LLMNR_PORT),
|
||||
};
|
||||
static const int one = 1, pmtu = IP_PMTUDISC_DONT, ttl = 255;
|
||||
static const int pmtu = IP_PMTUDISC_DONT, ttl = 255;
|
||||
int r;
|
||||
|
||||
assert(m);
|
||||
|
@ -140,19 +140,19 @@ int manager_llmnr_ipv4_udp_fd(Manager *m) {
|
|||
goto fail;
|
||||
}
|
||||
|
||||
r = setsockopt(m->llmnr_ipv4_udp_fd, IPPROTO_IP, IP_MULTICAST_LOOP, &one, sizeof(one));
|
||||
r = setsockopt(m->llmnr_ipv4_udp_fd, IPPROTO_IP, IP_MULTICAST_LOOP, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0) {
|
||||
r = log_error_errno(errno, "LLMNR-IPv4(UDP): Failed to set IP_MULTICAST_LOOP: %m");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
r = setsockopt(m->llmnr_ipv4_udp_fd, IPPROTO_IP, IP_PKTINFO, &one, sizeof(one));
|
||||
r = setsockopt(m->llmnr_ipv4_udp_fd, IPPROTO_IP, IP_PKTINFO, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0) {
|
||||
r = log_error_errno(errno, "LLMNR-IPv4(UDP): Failed to set IP_PKTINFO: %m");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
r = setsockopt(m->llmnr_ipv4_udp_fd, IPPROTO_IP, IP_RECVTTL, &one, sizeof(one));
|
||||
r = setsockopt(m->llmnr_ipv4_udp_fd, IPPROTO_IP, IP_RECVTTL, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0) {
|
||||
r = log_error_errno(errno, "LLMNR-IPv4(UDP): Failed to set IP_RECVTTL: %m");
|
||||
goto fail;
|
||||
|
@ -176,7 +176,7 @@ int manager_llmnr_ipv4_udp_fd(Manager *m) {
|
|||
log_warning("LLMNR-IPv4(UDP): There appears to be another LLMNR responder running, or previously systemd-resolved crashed with some outstanding transfers.");
|
||||
|
||||
/* try again with SO_REUSEADDR */
|
||||
r = setsockopt(m->llmnr_ipv4_udp_fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
|
||||
r = setsockopt(m->llmnr_ipv4_udp_fd, SOL_SOCKET, SO_REUSEADDR, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0) {
|
||||
r = log_error_errno(errno, "LLMNR-IPv4(UDP): Failed to set SO_REUSEADDR: %m");
|
||||
goto fail;
|
||||
|
@ -189,7 +189,7 @@ int manager_llmnr_ipv4_udp_fd(Manager *m) {
|
|||
}
|
||||
} else {
|
||||
/* enable SO_REUSEADDR for the case that the user really wants multiple LLMNR responders */
|
||||
r = setsockopt(m->llmnr_ipv4_udp_fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
|
||||
r = setsockopt(m->llmnr_ipv4_udp_fd, SOL_SOCKET, SO_REUSEADDR, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0) {
|
||||
r = log_error_errno(errno, "LLMNR-IPv4(UDP): Failed to set SO_REUSEADDR: %m");
|
||||
goto fail;
|
||||
|
@ -214,7 +214,7 @@ int manager_llmnr_ipv6_udp_fd(Manager *m) {
|
|||
.in6.sin6_family = AF_INET6,
|
||||
.in6.sin6_port = htobe16(LLMNR_PORT),
|
||||
};
|
||||
static const int one = 1, ttl = 255;
|
||||
static const int ttl = 255;
|
||||
int r;
|
||||
|
||||
assert(m);
|
||||
|
@ -239,25 +239,25 @@ int manager_llmnr_ipv6_udp_fd(Manager *m) {
|
|||
goto fail;
|
||||
}
|
||||
|
||||
r = setsockopt(m->llmnr_ipv6_udp_fd, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, &one, sizeof(one));
|
||||
r = setsockopt(m->llmnr_ipv6_udp_fd, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0) {
|
||||
r = log_error_errno(errno, "LLMNR-IPv6(UDP): Failed to set IPV6_MULTICAST_LOOP: %m");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
r = setsockopt(m->llmnr_ipv6_udp_fd, IPPROTO_IPV6, IPV6_V6ONLY, &one, sizeof(one));
|
||||
r = setsockopt(m->llmnr_ipv6_udp_fd, IPPROTO_IPV6, IPV6_V6ONLY, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0) {
|
||||
r = log_error_errno(errno, "LLMNR-IPv6(UDP): Failed to set IPV6_V6ONLY: %m");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
r = setsockopt(m->llmnr_ipv6_udp_fd, IPPROTO_IPV6, IPV6_RECVPKTINFO, &one, sizeof(one));
|
||||
r = setsockopt(m->llmnr_ipv6_udp_fd, IPPROTO_IPV6, IPV6_RECVPKTINFO, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0) {
|
||||
r = log_error_errno(errno, "LLMNR-IPv6(UDP): Failed to set IPV6_RECVPKTINFO: %m");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
r = setsockopt(m->llmnr_ipv6_udp_fd, IPPROTO_IPV6, IPV6_RECVHOPLIMIT, &one, sizeof(one));
|
||||
r = setsockopt(m->llmnr_ipv6_udp_fd, IPPROTO_IPV6, IPV6_RECVHOPLIMIT, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0) {
|
||||
r = log_error_errno(errno, "LLMNR-IPv6(UDP): Failed to set IPV6_RECVHOPLIMIT: %m");
|
||||
goto fail;
|
||||
|
@ -274,7 +274,7 @@ int manager_llmnr_ipv6_udp_fd(Manager *m) {
|
|||
log_warning("LLMNR-IPv6(UDP): There appears to be another LLMNR responder running, or previously systemd-resolved crashed with some outstanding transfers.");
|
||||
|
||||
/* try again with SO_REUSEADDR */
|
||||
r = setsockopt(m->llmnr_ipv6_udp_fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
|
||||
r = setsockopt(m->llmnr_ipv6_udp_fd, SOL_SOCKET, SO_REUSEADDR, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0) {
|
||||
r = log_error_errno(errno, "LLMNR-IPv6(UDP): Failed to set SO_REUSEADDR: %m");
|
||||
goto fail;
|
||||
|
@ -287,7 +287,7 @@ int manager_llmnr_ipv6_udp_fd(Manager *m) {
|
|||
}
|
||||
} else {
|
||||
/* enable SO_REUSEADDR for the case that the user really wants multiple LLMNR responders */
|
||||
r = setsockopt(m->llmnr_ipv6_udp_fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
|
||||
r = setsockopt(m->llmnr_ipv6_udp_fd, SOL_SOCKET, SO_REUSEADDR, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0) {
|
||||
r = log_error_errno(errno, "LLMNR-IPv6(UDP): Failed to set SO_REUSEADDR: %m");
|
||||
goto fail;
|
||||
|
@ -355,7 +355,7 @@ int manager_llmnr_ipv4_tcp_fd(Manager *m) {
|
|||
.in.sin_family = AF_INET,
|
||||
.in.sin_port = htobe16(LLMNR_PORT),
|
||||
};
|
||||
static const int one = 1, pmtu = IP_PMTUDISC_DONT;
|
||||
static const int pmtu = IP_PMTUDISC_DONT;
|
||||
int r;
|
||||
|
||||
assert(m);
|
||||
|
@ -368,19 +368,19 @@ int manager_llmnr_ipv4_tcp_fd(Manager *m) {
|
|||
return log_error_errno(errno, "LLMNR-IPv4(TCP): Failed to create socket: %m");
|
||||
|
||||
/* RFC 4795, section 2.5. requires setting the TTL of TCP streams to 1 */
|
||||
r = setsockopt(m->llmnr_ipv4_tcp_fd, IPPROTO_IP, IP_TTL, &one, sizeof(one));
|
||||
r = setsockopt(m->llmnr_ipv4_tcp_fd, IPPROTO_IP, IP_TTL, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0) {
|
||||
r = log_error_errno(errno, "LLMNR-IPv4(TCP): Failed to set IP_TTL: %m");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
r = setsockopt(m->llmnr_ipv4_tcp_fd, IPPROTO_IP, IP_PKTINFO, &one, sizeof(one));
|
||||
r = setsockopt(m->llmnr_ipv4_tcp_fd, IPPROTO_IP, IP_PKTINFO, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0) {
|
||||
r = log_error_errno(errno, "LLMNR-IPv4(TCP): Failed to set IP_PKTINFO: %m");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
r = setsockopt(m->llmnr_ipv4_tcp_fd, IPPROTO_IP, IP_RECVTTL, &one, sizeof(one));
|
||||
r = setsockopt(m->llmnr_ipv4_tcp_fd, IPPROTO_IP, IP_RECVTTL, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0) {
|
||||
r = log_error_errno(errno, "LLMNR-IPv4(TCP): Failed to set IP_RECVTTL: %m");
|
||||
goto fail;
|
||||
|
@ -404,7 +404,7 @@ int manager_llmnr_ipv4_tcp_fd(Manager *m) {
|
|||
log_warning("LLMNR-IPv4(TCP): There appears to be another LLMNR responder running, or previously systemd-resolved crashed with some outstanding transfers.");
|
||||
|
||||
/* try again with SO_REUSEADDR */
|
||||
r = setsockopt(m->llmnr_ipv4_tcp_fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
|
||||
r = setsockopt(m->llmnr_ipv4_tcp_fd, SOL_SOCKET, SO_REUSEADDR, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0) {
|
||||
r = log_error_errno(errno, "LLMNR-IPv4(TCP): Failed to set SO_REUSEADDR: %m");
|
||||
goto fail;
|
||||
|
@ -417,7 +417,7 @@ int manager_llmnr_ipv4_tcp_fd(Manager *m) {
|
|||
}
|
||||
} else {
|
||||
/* enable SO_REUSEADDR for the case that the user really wants multiple LLMNR responders */
|
||||
r = setsockopt(m->llmnr_ipv4_tcp_fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
|
||||
r = setsockopt(m->llmnr_ipv4_tcp_fd, SOL_SOCKET, SO_REUSEADDR, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0) {
|
||||
r = log_error_errno(errno, "LLMNR-IPv4(TCP): Failed to set SO_REUSEADDR: %m");
|
||||
goto fail;
|
||||
|
@ -448,7 +448,6 @@ int manager_llmnr_ipv6_tcp_fd(Manager *m) {
|
|||
.in6.sin6_family = AF_INET6,
|
||||
.in6.sin6_port = htobe16(LLMNR_PORT),
|
||||
};
|
||||
static const int one = 1;
|
||||
int r;
|
||||
|
||||
assert(m);
|
||||
|
@ -461,25 +460,25 @@ int manager_llmnr_ipv6_tcp_fd(Manager *m) {
|
|||
return log_error_errno(errno, "LLMNR-IPv6(TCP): Failed to create socket: %m");
|
||||
|
||||
/* RFC 4795, section 2.5. requires setting the TTL of TCP streams to 1 */
|
||||
r = setsockopt(m->llmnr_ipv6_tcp_fd, IPPROTO_IPV6, IPV6_UNICAST_HOPS, &one, sizeof(one));
|
||||
r = setsockopt(m->llmnr_ipv6_tcp_fd, IPPROTO_IPV6, IPV6_UNICAST_HOPS, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0) {
|
||||
r = log_error_errno(errno, "LLMNR-IPv6(TCP): Failed to set IPV6_UNICAST_HOPS: %m");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
r = setsockopt(m->llmnr_ipv6_tcp_fd, IPPROTO_IPV6, IPV6_V6ONLY, &one, sizeof(one));
|
||||
r = setsockopt(m->llmnr_ipv6_tcp_fd, IPPROTO_IPV6, IPV6_V6ONLY, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0) {
|
||||
r = log_error_errno(errno, "LLMNR-IPv6(TCP): Failed to set IPV6_V6ONLY: %m");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
r = setsockopt(m->llmnr_ipv6_tcp_fd, IPPROTO_IPV6, IPV6_RECVPKTINFO, &one, sizeof(one));
|
||||
r = setsockopt(m->llmnr_ipv6_tcp_fd, IPPROTO_IPV6, IPV6_RECVPKTINFO, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0) {
|
||||
r = log_error_errno(errno, "LLMNR-IPv6(TCP): Failed to set IPV6_RECVPKTINFO: %m");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
r = setsockopt(m->llmnr_ipv6_tcp_fd, IPPROTO_IPV6, IPV6_RECVHOPLIMIT, &one, sizeof(one));
|
||||
r = setsockopt(m->llmnr_ipv6_tcp_fd, IPPROTO_IPV6, IPV6_RECVHOPLIMIT, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0) {
|
||||
r = log_error_errno(errno, "LLMNR-IPv6(TCP): Failed to set IPV6_RECVHOPLIMIT: %m");
|
||||
goto fail;
|
||||
|
@ -496,7 +495,7 @@ int manager_llmnr_ipv6_tcp_fd(Manager *m) {
|
|||
log_warning("LLMNR-IPv6(TCP): There appears to be another LLMNR responder running, or previously systemd-resolved crashed with some outstanding transfers.");
|
||||
|
||||
/* try again with SO_REUSEADDR */
|
||||
r = setsockopt(m->llmnr_ipv6_tcp_fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
|
||||
r = setsockopt(m->llmnr_ipv6_tcp_fd, SOL_SOCKET, SO_REUSEADDR, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0) {
|
||||
r = log_error_errno(errno, "LLMNR-IPv6(TCP): Failed to set SO_REUSEADDR: %m");
|
||||
goto fail;
|
||||
|
@ -509,7 +508,7 @@ int manager_llmnr_ipv6_tcp_fd(Manager *m) {
|
|||
}
|
||||
} else {
|
||||
/* enable SO_REUSEADDR for the case that the user really wants multiple LLMNR responders */
|
||||
r = setsockopt(m->llmnr_ipv6_tcp_fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
|
||||
r = setsockopt(m->llmnr_ipv6_tcp_fd, SOL_SOCKET, SO_REUSEADDR, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0) {
|
||||
r = log_error_errno(errno, "LLMNR-IPv6(TCP): Failed to set SO_REUSEADDR: %m");
|
||||
goto fail;
|
||||
|
|
|
@ -344,7 +344,7 @@ int manager_mdns_ipv4_fd(Manager *m) {
|
|||
.in.sin_family = AF_INET,
|
||||
.in.sin_port = htobe16(MDNS_PORT),
|
||||
};
|
||||
static const int one = 1, pmtu = IP_PMTUDISC_DONT, ttl = 255;
|
||||
static const int pmtu = IP_PMTUDISC_DONT, ttl = 255;
|
||||
int r;
|
||||
|
||||
assert(m);
|
||||
|
@ -368,19 +368,19 @@ int manager_mdns_ipv4_fd(Manager *m) {
|
|||
goto fail;
|
||||
}
|
||||
|
||||
r = setsockopt(m->mdns_ipv4_fd, IPPROTO_IP, IP_MULTICAST_LOOP, &one, sizeof(one));
|
||||
r = setsockopt(m->mdns_ipv4_fd, IPPROTO_IP, IP_MULTICAST_LOOP, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0) {
|
||||
r = log_error_errno(errno, "mDNS-IPv4: Failed to set IP_MULTICAST_LOOP: %m");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
r = setsockopt(m->mdns_ipv4_fd, IPPROTO_IP, IP_PKTINFO, &one, sizeof(one));
|
||||
r = setsockopt(m->mdns_ipv4_fd, IPPROTO_IP, IP_PKTINFO, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0) {
|
||||
r = log_error_errno(errno, "mDNS-IPv4: Failed to set IP_PKTINFO: %m");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
r = setsockopt(m->mdns_ipv4_fd, IPPROTO_IP, IP_RECVTTL, &one, sizeof(one));
|
||||
r = setsockopt(m->mdns_ipv4_fd, IPPROTO_IP, IP_RECVTTL, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0) {
|
||||
r = log_error_errno(errno, "mDNS-IPv4: Failed to set IP_RECVTTL: %m");
|
||||
goto fail;
|
||||
|
@ -405,7 +405,7 @@ int manager_mdns_ipv4_fd(Manager *m) {
|
|||
log_warning("mDNS-IPv4: There appears to be another mDNS responder running, or previously systemd-resolved crashed with some outstanding transfers.");
|
||||
|
||||
/* try again with SO_REUSEADDR */
|
||||
r = setsockopt(m->mdns_ipv4_fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
|
||||
r = setsockopt(m->mdns_ipv4_fd, SOL_SOCKET, SO_REUSEADDR, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0) {
|
||||
r = log_error_errno(errno, "mDNS-IPv4: Failed to set SO_REUSEADDR: %m");
|
||||
goto fail;
|
||||
|
@ -418,7 +418,7 @@ int manager_mdns_ipv4_fd(Manager *m) {
|
|||
}
|
||||
} else {
|
||||
/* enable SO_REUSEADDR for the case that the user really wants multiple mDNS responders */
|
||||
r = setsockopt(m->mdns_ipv4_fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
|
||||
r = setsockopt(m->mdns_ipv4_fd, SOL_SOCKET, SO_REUSEADDR, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0) {
|
||||
r = log_error_errno(errno, "mDNS-IPv4: Failed to set SO_REUSEADDR: %m");
|
||||
goto fail;
|
||||
|
@ -441,7 +441,7 @@ int manager_mdns_ipv6_fd(Manager *m) {
|
|||
.in6.sin6_family = AF_INET6,
|
||||
.in6.sin6_port = htobe16(MDNS_PORT),
|
||||
};
|
||||
static const int one = 1, ttl = 255;
|
||||
static const int ttl = 255;
|
||||
int r;
|
||||
|
||||
assert(m);
|
||||
|
@ -466,25 +466,25 @@ int manager_mdns_ipv6_fd(Manager *m) {
|
|||
goto fail;
|
||||
}
|
||||
|
||||
r = setsockopt(m->mdns_ipv6_fd, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, &one, sizeof(one));
|
||||
r = setsockopt(m->mdns_ipv6_fd, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0) {
|
||||
r = log_error_errno(errno, "mDNS-IPv6: Failed to set IPV6_MULTICAST_LOOP: %m");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
r = setsockopt(m->mdns_ipv6_fd, IPPROTO_IPV6, IPV6_V6ONLY, &one, sizeof(one));
|
||||
r = setsockopt(m->mdns_ipv6_fd, IPPROTO_IPV6, IPV6_V6ONLY, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0) {
|
||||
r = log_error_errno(errno, "mDNS-IPv6: Failed to set IPV6_V6ONLY: %m");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
r = setsockopt(m->mdns_ipv6_fd, IPPROTO_IPV6, IPV6_RECVPKTINFO, &one, sizeof(one));
|
||||
r = setsockopt(m->mdns_ipv6_fd, IPPROTO_IPV6, IPV6_RECVPKTINFO, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0) {
|
||||
r = log_error_errno(errno, "mDNS-IPv6: Failed to set IPV6_RECVPKTINFO: %m");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
r = setsockopt(m->mdns_ipv6_fd, IPPROTO_IPV6, IPV6_RECVHOPLIMIT, &one, sizeof(one));
|
||||
r = setsockopt(m->mdns_ipv6_fd, IPPROTO_IPV6, IPV6_RECVHOPLIMIT, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0) {
|
||||
r = log_error_errno(errno, "mDNS-IPv6: Failed to set IPV6_RECVHOPLIMIT: %m");
|
||||
goto fail;
|
||||
|
@ -502,7 +502,7 @@ int manager_mdns_ipv6_fd(Manager *m) {
|
|||
log_warning("mDNS-IPv6: There appears to be another mDNS responder running, or previously systemd-resolved crashed with some outstanding transfers.");
|
||||
|
||||
/* try again with SO_REUSEADDR */
|
||||
r = setsockopt(m->mdns_ipv6_fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
|
||||
r = setsockopt(m->mdns_ipv6_fd, SOL_SOCKET, SO_REUSEADDR, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0) {
|
||||
r = log_error_errno(errno, "mDNS-IPv6: Failed to set SO_REUSEADDR: %m");
|
||||
goto fail;
|
||||
|
@ -515,7 +515,7 @@ int manager_mdns_ipv6_fd(Manager *m) {
|
|||
}
|
||||
} else {
|
||||
/* enable SO_REUSEADDR for the case that the user really wants multiple mDNS responders */
|
||||
r = setsockopt(m->mdns_ipv6_fd, SOL_SOCKET, SO_REUSEADDR, &one, sizeof(one));
|
||||
r = setsockopt(m->mdns_ipv6_fd, SOL_SOCKET, SO_REUSEADDR, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0) {
|
||||
r = log_error_errno(errno, "mDNS-IPv6: Failed to set SO_REUSEADDR: %m");
|
||||
goto fail;
|
||||
|
|
|
@ -455,7 +455,6 @@ static int create_socket(char **ret) {
|
|||
_cleanup_free_ char *path = NULL;
|
||||
union sockaddr_union sa = {};
|
||||
_cleanup_close_ int fd = -1;
|
||||
static const int one = 1;
|
||||
int salen;
|
||||
|
||||
assert(ret);
|
||||
|
@ -476,7 +475,7 @@ static int create_socket(char **ret) {
|
|||
return -errno;
|
||||
}
|
||||
|
||||
if (setsockopt(fd, SOL_SOCKET, SO_PASSCRED, &one, sizeof(one)) < 0)
|
||||
if (setsockopt(fd, SOL_SOCKET, SO_PASSCRED, &const_int_one, sizeof(const_int_one)) < 0)
|
||||
return -errno;
|
||||
|
||||
*ret = TAKE_PTR(path);
|
||||
|
|
|
@ -630,7 +630,6 @@ static int manager_receive_response(sd_event_source *source, int fd, uint32_t re
|
|||
static int manager_listen_setup(Manager *m) {
|
||||
union sockaddr_union addr = {};
|
||||
static const int tos = IPTOS_LOWDELAY;
|
||||
static const int on = 1;
|
||||
int r;
|
||||
|
||||
assert(m);
|
||||
|
@ -651,7 +650,7 @@ static int manager_listen_setup(Manager *m) {
|
|||
if (r < 0)
|
||||
return -errno;
|
||||
|
||||
r = setsockopt(m->server_socket, SOL_SOCKET, SO_TIMESTAMPNS, &on, sizeof(on));
|
||||
r = setsockopt(m->server_socket, SOL_SOCKET, SO_TIMESTAMPNS, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0)
|
||||
return -errno;
|
||||
|
||||
|
|
|
@ -73,7 +73,6 @@ struct udev_ctrl_connection {
|
|||
|
||||
struct udev_ctrl *udev_ctrl_new_from_fd(int fd) {
|
||||
struct udev_ctrl *uctrl;
|
||||
const int on = 1;
|
||||
int r;
|
||||
|
||||
uctrl = new0(struct udev_ctrl, 1);
|
||||
|
@ -97,7 +96,7 @@ struct udev_ctrl *udev_ctrl_new_from_fd(int fd) {
|
|||
* FIXME: remove it as soon as we can depend on this:
|
||||
* http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=90c6bd34f884cd9cee21f1d152baf6c18bcac949
|
||||
*/
|
||||
r = setsockopt(uctrl->sock, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on));
|
||||
r = setsockopt(uctrl->sock, SOL_SOCKET, SO_PASSCRED, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0)
|
||||
log_warning_errno(errno, "could not set SO_PASSCRED: %m");
|
||||
|
||||
|
@ -164,7 +163,6 @@ int udev_ctrl_get_fd(struct udev_ctrl *uctrl) {
|
|||
struct udev_ctrl_connection *udev_ctrl_get_connection(struct udev_ctrl *uctrl) {
|
||||
struct udev_ctrl_connection *conn;
|
||||
struct ucred ucred = {};
|
||||
const int on = 1;
|
||||
int r;
|
||||
|
||||
conn = new(struct udev_ctrl_connection, 1);
|
||||
|
@ -192,7 +190,7 @@ struct udev_ctrl_connection *udev_ctrl_get_connection(struct udev_ctrl *uctrl) {
|
|||
}
|
||||
|
||||
/* enable receiving of the sender credentials in the messages */
|
||||
r = setsockopt(conn->sock, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on));
|
||||
r = setsockopt(conn->sock, SOL_SOCKET, SO_PASSCRED, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0)
|
||||
log_warning_errno(errno, "could not set SO_PASSCRED: %m");
|
||||
|
||||
|
|
|
@ -1392,17 +1392,12 @@ static void add_rule(struct udev_rules *rules, char *line,
|
|||
rule_add_key(&rule_tmp, TK_A_DB_PERSIST, op, NULL, NULL);
|
||||
|
||||
pos = strstr(value, "nowatch");
|
||||
if (pos != NULL) {
|
||||
const int off = 0;
|
||||
|
||||
rule_add_key(&rule_tmp, TK_A_INOTIFY_WATCH, op, NULL, &off);
|
||||
} else {
|
||||
if (pos)
|
||||
rule_add_key(&rule_tmp, TK_A_INOTIFY_WATCH, op, NULL, &const_int_zero);
|
||||
else {
|
||||
pos = strstr(value, "watch");
|
||||
if (pos != NULL) {
|
||||
const int on = 1;
|
||||
|
||||
rule_add_key(&rule_tmp, TK_A_INOTIFY_WATCH, op, NULL, &on);
|
||||
}
|
||||
if (pos)
|
||||
rule_add_key(&rule_tmp, TK_A_INOTIFY_WATCH, op, NULL, &const_int_one);
|
||||
}
|
||||
|
||||
pos = strstr(value, "static_node=");
|
||||
|
|
|
@ -1508,7 +1508,7 @@ static int parse_argv(int argc, char *argv[]) {
|
|||
|
||||
static int manager_new(Manager **ret, int fd_ctrl, int fd_uevent, const char *cgroup) {
|
||||
_cleanup_(manager_freep) Manager *manager = NULL;
|
||||
int r, fd_worker, one = 1;
|
||||
int r, fd_worker;
|
||||
|
||||
assert(ret);
|
||||
assert(fd_ctrl >= 0);
|
||||
|
@ -1548,7 +1548,7 @@ static int manager_new(Manager **ret, int fd_ctrl, int fd_uevent, const char *cg
|
|||
|
||||
fd_worker = manager->worker_watch[READ_END];
|
||||
|
||||
r = setsockopt(fd_worker, SOL_SOCKET, SO_PASSCRED, &one, sizeof(one));
|
||||
r = setsockopt(fd_worker, SOL_SOCKET, SO_PASSCRED, &const_int_one, sizeof(const_int_one));
|
||||
if (r < 0)
|
||||
return log_error_errno(errno, "could not enable SO_PASSCRED: %m");
|
||||
|
||||
|
|
Loading…
Reference in a new issue