summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-06-13 19:05:57 +0200
committerGitHub <noreply@github.com>2018-06-13 19:05:57 +0200
commitf0d97606e9857b82752f70e4fd87d199ee368a73 (patch)
treebf58f5e7347159ce38a97e34ee9580e711924913
parentmachine: ignore containers which disable private user namespace in MapToMachi... (diff)
parentsd-radv: use strv_isempty() where we can (diff)
downloadsystemd-f0d97606e9857b82752f70e4fd87d199ee368a73.tar.xz
systemd-f0d97606e9857b82752f70e4fd87d199ee368a73.zip
Merge pull request #9290 from poettering/radv-fixlets
tiny sd-radv fixlets
-rw-r--r--src/libsystemd-network/sd-radv.c13
-rw-r--r--src/systemd/sd-radv.h6
2 files changed, 11 insertions, 8 deletions
diff --git a/src/libsystemd-network/sd-radv.c b/src/libsystemd-network/sd-radv.c
index cf7fe0997b..54857dc786 100644
--- a/src/libsystemd-network/sd-radv.c
+++ b/src/libsystemd-network/sd-radv.c
@@ -77,6 +77,7 @@ _public_ sd_event *sd_radv_get_event(sd_radv *ra) {
}
static void radv_reset(sd_radv *ra) {
+ assert(ra);
ra->timeout_event_source =
sd_event_source_unref(ra->timeout_event_source);
@@ -120,6 +121,9 @@ _public_ sd_radv *sd_radv_unref(sd_radv *ra) {
radv_reset(ra);
sd_radv_detach_event(ra);
+
+ ra->fd = safe_close(ra->fd);
+
return mfree(ra);
}
@@ -607,8 +611,8 @@ _public_ int sd_radv_add_prefix(sd_radv *ra, sd_radv_prefix *p, bool dynamic) {
}
_public_ sd_radv_prefix *sd_radv_remove_prefix(sd_radv *ra,
- struct in6_addr *prefix,
- uint8_t prefixlen) {
+ const struct in6_addr *prefix,
+ unsigned char prefixlen) {
sd_radv_prefix *cur, *next;
assert_return(ra, NULL);
@@ -675,9 +679,8 @@ _public_ int sd_radv_set_dnssl(sd_radv *ra, uint32_t lifetime,
assert_return(ra, -EINVAL);
- if (!search_list || *search_list == NULL) {
+ if (strv_isempty(search_list)) {
ra->dnssl = mfree(ra->dnssl);
-
return 0;
}
@@ -768,7 +771,7 @@ _public_ sd_radv_prefix *sd_radv_prefix_unref(sd_radv_prefix *p) {
return mfree(p);
}
-_public_ int sd_radv_prefix_set_prefix(sd_radv_prefix *p, struct in6_addr *in6_addr,
+_public_ int sd_radv_prefix_set_prefix(sd_radv_prefix *p, const struct in6_addr *in6_addr,
unsigned char prefixlen) {
assert_return(p, -EINVAL);
assert_return(in6_addr, -EINVAL);
diff --git a/src/systemd/sd-radv.h b/src/systemd/sd-radv.h
index e319a82dbf..9d4ba87447 100644
--- a/src/systemd/sd-radv.h
+++ b/src/systemd/sd-radv.h
@@ -64,8 +64,8 @@ int sd_radv_set_managed_information(sd_radv *ra, int managed);
int sd_radv_set_other_information(sd_radv *ra, int other);
int sd_radv_set_preference(sd_radv *ra, unsigned preference);
int sd_radv_add_prefix(sd_radv *ra, sd_radv_prefix *p, bool dynamic);
-sd_radv_prefix *sd_radv_remove_prefix(sd_radv *ra, struct in6_addr *prefix,
- uint8_t prefixlen);
+sd_radv_prefix *sd_radv_remove_prefix(sd_radv *ra, const struct in6_addr *prefix,
+ unsigned char prefixlen);
int sd_radv_set_rdnss(sd_radv *ra, uint32_t lifetime,
const struct in6_addr *dns, size_t n_dns);
int sd_radv_set_dnssl(sd_radv *ra, uint32_t lifetime, char **search_list);
@@ -75,7 +75,7 @@ int sd_radv_prefix_new(sd_radv_prefix **ret);
sd_radv_prefix *sd_radv_prefix_ref(sd_radv_prefix *ra);
sd_radv_prefix *sd_radv_prefix_unref(sd_radv_prefix *ra);
-int sd_radv_prefix_set_prefix(sd_radv_prefix *p, struct in6_addr *in6_addr,
+int sd_radv_prefix_set_prefix(sd_radv_prefix *p, const struct in6_addr *in6_addr,
unsigned char prefixlen);
int sd_radv_prefix_set_onlink(sd_radv_prefix *p, int onlink);
int sd_radv_prefix_set_address_autoconfiguration(sd_radv_prefix *p,