Commit ac7a6d02 authored by Thomas Haller's avatar Thomas Haller

systemd: merge branch 'systemd' into master

parents 4b535205 606ad7e6
......@@ -60,7 +60,6 @@ noinst_LTLIBRARIES = \
SYSTEMD_NM_CFLAGS_PATHS = \
-I$(top_srcdir)/src/systemd/src/systemd \
-I$(top_srcdir)/src/systemd/src/libsystemd-network \
-I$(top_srcdir)/src/systemd/src/libsystemd/sd-event \
-I$(top_srcdir)/src/systemd/src/basic \
-I$(top_srcdir)/src/systemd
......@@ -143,7 +142,6 @@ libsystemd_nm_la_SOURCES = \
systemd/src/libsystemd-network/lldp-tlv.h \
systemd/src/libsystemd-network/lldp-port.c \
systemd/src/libsystemd-network/lldp-port.h \
systemd/src/libsystemd-network/lldp-util.h \
systemd/src/libsystemd-network/lldp-internal.h \
systemd/src/libsystemd-network/lldp-internal.c \
systemd/src/libsystemd-network/network-internal.c \
......@@ -156,7 +154,6 @@ libsystemd_nm_la_SOURCES = \
systemd/src/libsystemd-network/sd-ipv4ll.c \
systemd/src/libsystemd-network/sd-lldp.c \
systemd/src/libsystemd/sd-id128/sd-id128.c \
systemd/src/libsystemd/sd-event/event-util.h \
systemd/src/shared/dns-domain.c \
systemd/src/shared/dns-domain.h \
systemd/src/systemd/_sd-common.h \
......@@ -166,7 +163,6 @@ libsystemd_nm_la_SOURCES = \
systemd/src/systemd/sd-dhcp6-lease.h \
systemd/src/systemd/sd-lldp.h \
systemd/src/systemd/sd-event.h \
systemd/src/systemd/sd-icmp6-nd.h \
systemd/src/systemd/sd-id128.h \
systemd/src/systemd/sd-ipv4acd.h \
systemd/src/systemd/sd-ipv4ll.h \
......
......@@ -451,7 +451,7 @@ nm_lldp_listener_start (NMLldpListener *self, int ifindex, const char *iface,
err:
sd_lldp_detach_event (priv->lldp_handle);
err_free:
sd_lldp_free (priv->lldp_handle);
sd_lldp_unref (priv->lldp_handle);
priv->lldp_handle = NULL;
return FALSE;
}
......@@ -468,7 +468,7 @@ nm_lldp_listener_stop (NMLldpListener *self)
if (priv->lldp_handle) {
sd_lldp_stop (priv->lldp_handle);
sd_lldp_detach_event (priv->lldp_handle);
sd_lldp_free (priv->lldp_handle);
sd_lldp_unref (priv->lldp_handle);
g_clear_pointer (&priv->iface, g_free);
priv->lldp_handle = NULL;
......
......@@ -150,7 +150,7 @@ test_ip6_address_general (void)
/* Remove address again */
nmtstp_ip6_address_del (EX, ifindex, addr, IP6_PLEN);
/* ensure no pending signal. */
/* ensure not pending signal. */
accept_signals (address_changed, 0, 1);
free_signal (address_added);
......
......@@ -21,7 +21,11 @@
#include "nm-sd-adapt.h"
#include <stdint.h>
#include <string.h>
#include "alloc-util.h"
#include "macro.h"
#include "util.h"
void* memdup(const void *p, size_t l) {
......
......@@ -24,6 +24,7 @@
#include "nm-sd-adapt.h"
#include <alloca.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
......
......@@ -21,12 +21,15 @@
#include "nm-sd-adapt.h"
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include "alloc-util.h"
#include "escape.h"
#include "hexdecoct.h"
#include "string-util.h"
#include "macro.h"
#include "utf8.h"
#include "util.h"
size_t cescape_char(char c, char *buf) {
char * buf_old = buf;
......@@ -91,20 +94,20 @@ size_t cescape_char(char c, char *buf) {
return buf - buf_old;
}
char *cescape(const char *s) {
char *r, *t;
char *cescape_length(const char *s, size_t n) {
const char *f;
char *r, *t;
assert(s);
assert(s || n == 0);
/* Does C style string escaping. May be reversed with
* cunescape(). */
r = new(char, strlen(s)*4 + 1);
r = new(char, n*4 + 1);
if (!r)
return NULL;
for (f = s, t = r; *f; f++)
for (f = s, t = r; f < s + n; f++)
t += cescape_char(*f, t);
*t = 0;
......@@ -112,6 +115,12 @@ char *cescape(const char *s) {
return r;
}
char *cescape(const char *s) {
assert(s);
return cescape_length(s, strlen(s));
}
int cunescape_one(const char *p, size_t length, char *ret, uint32_t *ret_unicode) {
int r = 1;
......
......@@ -24,8 +24,12 @@
#include "nm-sd-adapt.h"
#include <inttypes.h>
#include <stddef.h>
#include <stdint.h>
#include <sys/types.h>
#include "string-util.h"
/* What characters are special in the shell? */
/* must be escaped outside and inside double-quotes */
#define SHELL_NEED_ESCAPE "\"\\`$"
......@@ -37,6 +41,7 @@ typedef enum UnescapeFlags {
} UnescapeFlags;
char *cescape(const char *s);
char *cescape_length(const char *s, size_t n);
size_t cescape_char(char c, char *buf);
int cunescape(const char *s, UnescapeFlags flags, char **ret);
......
......@@ -21,13 +21,20 @@
#include "nm-sd-adapt.h"
#if 0 /* NM_IGNORED */
#include "dirent-util.h"
#endif /* NM_IGNORED */
#include <errno.h>
#include <fcntl.h>
#include <sys/resource.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <unistd.h>
#include "fd-util.h"
#include "macro.h"
#if 0 /* NM_IGNORED */
#include "parse-util.h"
#include "missing.h"
#endif /* NM_IGNORED */
#include "parse-util.h"
#include "path-util.h"
#include "socket-util.h"
#include "util.h"
......
......@@ -21,6 +21,15 @@
#include "nm-sd-adapt.h"
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include "alloc-util.h"
......@@ -30,6 +39,8 @@
#include "fileio.h"
#include "fs-util.h"
#include "hexdecoct.h"
#include "log.h"
#include "macro.h"
#include "parse-util.h"
#include "path-util.h"
#include "random-util.h"
......@@ -38,9 +49,9 @@
#endif /* NM_IGNORED */
#include "string-util.h"
#include "strv.h"
#include "time-util.h"
#include "umask-util.h"
#include "utf8.h"
#include "util.h"
int write_string_stream(FILE *f, const char *line, bool enforce_newline) {
......
......@@ -21,6 +21,16 @@
#include "nm-sd-adapt.h"
#include <dirent.h>
#include <errno.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <time.h>
#include <unistd.h>
#include "alloc-util.h"
#if 0 /* NM_IGNORED */
#include "dirent-util.h"
......@@ -28,13 +38,17 @@
#include "fd-util.h"
#include "fileio.h"
#include "fs-util.h"
#include "log.h"
#include "macro.h"
#if 0 /* NM_IGNORED */
#include "missing.h"
#include "mkdir.h"
#endif /* NM_IGNORED */
#include "parse-util.h"
#include "path-util.h"
#include "string-util.h"
#include "strv.h"
#include "time-util.h"
#if 0 /* NM_IGNORED */
#include "user-util.h"
#endif /* NM_IGNORED */
......
......@@ -25,6 +25,8 @@
#include <fcntl.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <sys/inotify.h>
#include <sys/types.h>
#include <unistd.h>
......
......@@ -23,8 +23,9 @@
#include "nm-sd-adapt.h"
#include <errno.h>
#include <pthread.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include "alloc-util.h"
#include "hashmap.h"
......@@ -40,6 +41,7 @@
#include "util.h"
#ifdef ENABLE_DEBUG_HASHMAP
#include <pthread.h>
#include "list.h"
#endif
......
......@@ -24,7 +24,9 @@
#include "nm-sd-adapt.h"
#include <limits.h>
#include <stdbool.h>
#include <stddef.h>
#include "macro.h"
#include "siphash24.h"
......
......@@ -22,11 +22,13 @@
#include "nm-sd-adapt.h"
#include <ctype.h>
#include <inttypes.h>
#include <errno.h>
#include <stdint.h>
#include <stdlib.h>
#include "alloc-util.h"
#include "hexdecoct.h"
#include "util.h"
#include "macro.h"
char octchar(int x) {
return '0' + (x & 7);
......
......@@ -24,6 +24,7 @@
#include "nm-sd-adapt.h"
#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>
#include <sys/types.h>
......
......@@ -21,14 +21,19 @@
#include "nm-sd-adapt.h"
#include <ctype.h>
#include <bits/local_lim.h>
#include <errno.h>
#include <limits.h>
#include <stdio.h>
#include <string.h>
#include <sys/utsname.h>
#include <unistd.h>
#include "fd-util.h"
#include "fileio.h"
#include "hostname-util.h"
#include "macro.h"
#include "string-util.h"
#include "util.h"
bool hostname_is_set(void) {
struct utsname u;
......
......@@ -22,9 +22,15 @@
#include "nm-sd-adapt.h"
#include <arpa/inet.h>
#include <endian.h>
#include <errno.h>
#include <stdint.h>
#include <stdlib.h>
#include "alloc-util.h"
#include "in-addr-util.h"
#include "macro.h"
#include "util.h"
int in_addr_is_null(int family, const union in_addr_union *u) {
assert(u);
......@@ -46,7 +52,7 @@ int in_addr_is_link_local(int family, const union in_addr_union *u) {
assert(u);
if (family == AF_INET)
return (be32toh(u->in.s_addr) & 0xFFFF0000) == (169U << 24 | 254U << 16);
return (be32toh(u->in.s_addr) & UINT32_C(0xFFFF0000)) == (UINT32_C(169) << 24 | UINT32_C(254) << 16);
if (family == AF_INET6)
return IN6_IS_ADDR_LINKLOCAL(&u->in6);
......@@ -54,6 +60,19 @@ int in_addr_is_link_local(int family, const union in_addr_union *u) {
return -EAFNOSUPPORT;
}
int in_addr_is_localhost(int family, const union in_addr_union *u) {
assert(u);
if (family == AF_INET)
/* All of 127.x.x.x is localhost. */
return (be32toh(u->in.s_addr) & UINT32_C(0xFF000000)) == UINT32_C(127) << 24;
if (family == AF_INET6)
return IN6_IS_ADDR_LOOPBACK(&u->in6);
return -EAFNOSUPPORT;
}
int in_addr_equal(int family, const union in_addr_union *a, const union in_addr_union *b) {
assert(a);
assert(b);
......
......@@ -24,6 +24,8 @@
#include "nm-sd-adapt.h"
#include <netinet/in.h>
#include <stddef.h>
#include <sys/socket.h>
#include "macro.h"
#include "util.h"
......@@ -35,6 +37,7 @@ union in_addr_union {
int in_addr_is_null(int family, const union in_addr_union *u);
int in_addr_is_link_local(int family, const union in_addr_union *u);
int in_addr_is_localhost(int family, const union in_addr_union *u);
int in_addr_equal(int family, const union in_addr_union *a, const union in_addr_union *b);
int in_addr_prefix_intersect(int family, const union in_addr_union *a, unsigned aprefixlen, const union in_addr_union *b, unsigned bprefixlen);
int in_addr_prefix_next(int family, union in_addr_union *u, unsigned prefixlen);
......
......@@ -21,10 +21,15 @@
#include "nm-sd-adapt.h"
#include <errno.h>
#include <limits.h>
#include <poll.h>
#include <stdio.h>
#include <time.h>
#include <unistd.h>
#include "io-util.h"
#include "time-util.h"
int flush_fd(int fd) {
struct pollfd pollfd = {
......
......@@ -24,9 +24,12 @@
#include "nm-sd-adapt.h"
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include <sys/types.h>
#include <sys/uio.h>
#include "macro.h"
#include "time-util.h"
int flush_fd(int fd);
......
......@@ -359,17 +359,15 @@ static inline unsigned long ALIGN_POWER2(unsigned long u) {
#endif
#endif
#if 0 /* NM_IGNORED */
/* Define C11 noreturn without <stdnoreturn.h> and even on older gcc
* compiler versions */
#ifndef noreturn
#if __STDC_VERSION__ >= 201112L
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L
#define noreturn _Noreturn
#else
#define noreturn __attribute__((noreturn))
#endif
#endif
#endif /* NM_IGNORED */
#define DEFINE_TRIVIAL_CLEANUP_FUNC(type, func) \
static inline void func##p(type *p) { \
......
......@@ -22,6 +22,9 @@
#include "nm-sd-adapt.h"
#include <stdint.h>
#include <stdlib.h>
#include "macro.h"
#include "mempool.h"
#include "util.h"
......
......@@ -21,13 +21,21 @@
#include "nm-sd-adapt.h"
#include <errno.h>
#include <inttypes.h>
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <xlocale.h>
#include "alloc-util.h"
#if 0 /* NM_IGNORED */
#include "extract-word.h"
#endif /* NM_IGNORED */
#include "macro.h"
#include "parse-util.h"
#include "string-util.h"
#include "util.h"
int parse_boolean(const char *v) {
assert(v);
......
......@@ -24,6 +24,9 @@
#include "nm-sd-adapt.h"
#include <inttypes.h>
#include <limits.h>
#include <stddef.h>
#include <stdint.h>
#include <sys/types.h>
#include "macro.h"
......
......@@ -22,11 +22,11 @@
#include "nm-sd-adapt.h"
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/statvfs.h>
#include <sys/stat.h>
#include <unistd.h>
/* When we include libgen.h because we need dirname() we immediately
......@@ -37,23 +37,21 @@
#include "alloc-util.h"
#if 0 /* NM_IGNORED */
#include "fd-util.h"
#include "fileio.h"
#include "extract-word.h"
#endif /* NM_IGNORED */
#include "fs-util.h"
#include "log.h"
#include "macro.h"
#if 0 /* NM_IGNORED */
#include "missing.h"
#include "parse-util.h"
#endif /* NM_IGNORED */
#include "path-util.h"
#if 0 /* NM_IGNORED */
#include "stat-util.h"
#endif /* NM_IGNORED */
#include "string-util.h"
#if 0 /* NM_IGNORED */
#include "strv.h"
#endif /* NM_IGNORED */
#include "util.h"
#include "time-util.h"
#if 0 /* NM_IGNORED */
bool path_is_absolute(const char *p) {
......
......@@ -23,7 +23,9 @@
#include "nm-sd-adapt.h"
#include <alloca.h>
#include <stdbool.h>
#include <stddef.h>
#include "macro.h"
#include "time-util.h"
......
......@@ -31,9 +31,12 @@
#include "nm-sd-adapt.h"
#include <errno.h>
#include <stdlib.h>
#include "alloc-util.h"
#include "hashmap.h"
#include "prioq.h"
#include "util.h"
struct prioq_item {
void *data;
......
......@@ -23,7 +23,10 @@
#include "nm-sd-adapt.h"
#include <stdbool.h>
#include "hashmap.h"
#include "macro.h"
typedef struct Prioq Prioq;
......
......@@ -19,16 +19,18 @@
#include "nm-sd-adapt.h"
#include <elf.h>
#include <errno.h>
#include <fcntl.h>
#include <stdbool.h>
#include <stdlib.h>
#include <sys/time.h>
#include <linux/random.h>
#include <stdint.h>
#ifdef HAVE_SYS_AUXV_H
#include <sys/auxv.h>
#endif
#include <sys/stat.h>
#include <sys/types.h>
#include <time.h>
#include "fd-util.h"
#include "io-util.h"
......@@ -37,7 +39,6 @@
#endif
#include "random-util.h"
#include "time-util.h"
#include "util.h"
int dev_urandom(void *p, size_t n) {
#if 0 /* NM_IGNORED */
......
......@@ -21,6 +21,7 @@
#include "nm-sd-adapt.h"
#include <stddef.h>
#include <stdint.h>
int dev_urandom(void *p, size_t n);
......
......@@ -29,7 +29,6 @@
Set *internal_set_new(const struct hash_ops *hash_ops HASHMAP_DEBUG_PARAMS);
#define set_new(ops) internal_set_new(ops HASHMAP_DEBUG_SRC_ARGS)
static inline Set *set_free(Set *s) {
internal_hashmap_free(HASHMAP_BASE(s));
return NULL;
......
......@@ -19,10 +19,9 @@
#include "nm-sd-adapt.h"
#include "macro.h"
#include "siphash24.h"
#include "sparse-endian.h"
#include "unaligned.h"
#include "util.h"
static inline uint64_t rotate_left(uint64_t x, uint8_t b) {
assert(b < 64);
......
......@@ -3,6 +3,8 @@
#include "nm-sd-adapt.h"
#include <inttypes.h>
#include <stddef.h>
#include <stdint.h>
#include <sys/types.h>
struct siphash {
......
......@@ -25,7 +25,10 @@
#include <netinet/ether.h>
#include <netinet/in.h>
#include <stdbool.h>
#include <stddef.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/un.h>
#include <linux/netlink.h>
#include <linux/if_packet.h>
......@@ -127,7 +130,11 @@ int ip_tos_from_string(const char *s);
int getpeercred(int fd, struct ucred *ucred);
int getpeersec(int fd, char **ret);
int send_one_fd(int transport_fd, int fd, int flags);
int send_one_fd_sa(int transport_fd,
int fd,
const struct sockaddr *sa, socklen_t len,
int flags);
#define send_one_fd(transport_fd, fd, flags) send_one_fd_sa(transport_fd, fd, NULL, 0, flags)
int receive_one_fd(int transport_fd, int flags);
#define CMSG_FOREACH(cmsg, mh) \
......
......@@ -22,6 +22,7 @@
#include "nm-sd-adapt.h"
#include "string-table.h"
#include "string-util.h"
ssize_t string_table_lookup(const char * const *table, size_t len, const char *key) {
size_t i;
......
......@@ -24,6 +24,7 @@
#include "nm-sd-adapt.h"
#include <errno.h>
#include <stddef.h>
#include <stdio.h>
#include <string.h>
......
......@@ -21,10 +21,17 @@
#include "nm-sd-adapt.h"
#include <errno.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include "alloc-util.h"
#if 0 /* NM_IGNORED */
#include "gunicode.h"
#endif /* NM_IGNORED */
#include "macro.h"
#include "string-util.h"
#include "utf8.h"
#include "util.h"
......
......@@ -23,7 +23,9 @@
#include "nm-sd-adapt.h"
#include <alloca.h>
#include <stdbool.h>
#include <stddef.h>
#include <string.h>
#include "macro.h"
......
......@@ -22,12 +22,17 @@
#include "nm-sd-adapt.h"
#include <errno.h>
#include <fnmatch.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "alloc-util.h"
#include "escape.h"
#if 0 /* NM_IGNORED */
#include "extract-word.h"