summaryrefslogtreecommitdiff
path: root/src/basic/socket-util.c
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2016-12-17 02:47:02 -0500
committerLuke Shumaker <lukeshu@sbcglobal.net>2016-12-17 02:47:02 -0500
commita4d083550a7273b895b44aac8d2ff7e2fdb1f7d5 (patch)
tree6f148433641f8c92d6f1eddcb2199a78dbd111a0 /src/basic/socket-util.c
parentb6d071f1df46eb841ba3f88cdb2b248eaf5f35f8 (diff)
parent86e9bb69ae74bd960e1fd427258f41d54240d6d1 (diff)
Merge branch 'systemd/parabola' into notsystemd/premove
# Conflicts: # Makefile.amp
Diffstat (limited to 'src/basic/socket-util.c')
-rw-r--r--src/basic/socket-util.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/basic/socket-util.c b/src/basic/socket-util.c
index 6093e47172..1662c04705 100644
--- a/src/basic/socket-util.c
+++ b/src/basic/socket-util.c
@@ -441,7 +441,7 @@ const char* socket_address_get_path(const SocketAddress *a) {
}
bool socket_ipv6_is_supported(void) {
- if (access("/proc/net/sockstat6", F_OK) != 0)
+ if (access("/proc/net/if_inet6", F_OK) != 0)
return false;
return true;
@@ -1060,3 +1060,20 @@ struct cmsghdr* cmsg_find(struct msghdr *mh, int level, int type, socklen_t leng
return NULL;
}
+
+int socket_ioctl_fd(void) {
+ int fd;
+
+ /* Create a socket to invoke the various network interface ioctl()s on. Traditionally only AF_INET was good for
+ * that. Since kernel 4.6 AF_NETLINK works for this too. We first try to use AF_INET hence, but if that's not
+ * available (for example, because it is made unavailable via SECCOMP or such), we'll fall back to the more
+ * generic AF_NETLINK. */
+
+ fd = socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC, 0);
+ if (fd < 0)
+ fd = socket(AF_NETLINK, SOCK_RAW|SOCK_CLOEXEC, NETLINK_GENERIC);
+ if (fd < 0)
+ return -errno;
+
+ return fd;
+}