summaryrefslogtreecommitdiff
path: root/src/socket.c
diff options
context:
space:
mode:
authorFabiano Fidencio <fidencio@profusion.mobi>2010-09-20 16:33:14 -0300
committerLennart Poettering <lennart@poettering.net>2010-09-21 01:00:38 +0200
commit5bfcc1c6ef48af20996412dbaac1daa0492a4d41 (patch)
treecd8831c84f81bb550242e351998f0f6efcbb8e1f /src/socket.c
parent918f4c69fabadc328b5ca3bbd9eb73c3e486e103 (diff)
socket: Support IPv6-less systems with runtime check.
This patch introduces socket_ipv6_is_supported() call that checks for IPv6 availability. Code then check for it before using specific calls. In order to be less intrusive, this patch avoids IPv6 entries being parsed at all, this way we don't get such entries in the system and all other code paths are automatically ignored. However an extra check is done at socket_address_listen() to make sure of that. As the number of Netlink messages is not know upfront anymore, loopback-setup.c was refactored to dynamically calculate the sequence number and count. Lennart's suggestions were fixed and squashed with the original patch, that was sent by Gustavo Sverzut Barbieri (barbieri@profusion.mobi).
Diffstat (limited to 'src/socket.c')
-rw-r--r--src/socket.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/socket.c b/src/socket.c
index da85ca7e8b..aacf9bed9f 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -634,7 +634,13 @@ static void socket_apply_socket_options(Socket *s, int fd) {
int r, x;
r = setsockopt(fd, IPPROTO_IP, IP_TTL, &s->ip_ttl, sizeof(s->ip_ttl));
- x = setsockopt(fd, IPPROTO_IPV6, IPV6_UNICAST_HOPS, &s->ip_ttl, sizeof(s->ip_ttl));
+
+ if (socket_ipv6_is_supported())
+ x = setsockopt(fd, IPPROTO_IPV6, IPV6_UNICAST_HOPS, &s->ip_ttl, sizeof(s->ip_ttl));
+ else {
+ x = -1;
+ errno = EAFNOSUPPORT;
+ }
if (r < 0 && x < 0)
log_warning("IP_TTL/IPV6_UNICAST_HOPS failed: %m");