summaryrefslogtreecommitdiffstats
path: root/src/libsystemd-network
diff options
context:
space:
mode:
Diffstat (limited to 'src/libsystemd-network')
-rw-r--r--src/libsystemd-network/fuzz-ndisc-rs.c8
-rw-r--r--src/libsystemd-network/icmp6-util-unix.c2
-rw-r--r--src/libsystemd-network/icmp6-util.c10
-rw-r--r--src/libsystemd-network/icmp6-util.h2
-rw-r--r--src/libsystemd-network/ndisc-option.c2
-rw-r--r--src/libsystemd-network/ndisc-option.h2
-rw-r--r--src/libsystemd-network/sd-ndisc.c6
-rw-r--r--src/libsystemd-network/test-ndisc-send.c7
8 files changed, 16 insertions, 23 deletions
diff --git a/src/libsystemd-network/fuzz-ndisc-rs.c b/src/libsystemd-network/fuzz-ndisc-rs.c
index ae780f4382..54737e4a06 100644
--- a/src/libsystemd-network/fuzz-ndisc-rs.c
+++ b/src/libsystemd-network/fuzz-ndisc-rs.c
@@ -35,11 +35,6 @@ static void test_with_sd_ndisc(const uint8_t *data, size_t size) {
}
static void test_with_icmp6_packet(const uint8_t *data, size_t size) {
- static const struct sockaddr_in6 dst = {
- .sin6_family = AF_INET6,
- .sin6_addr = IN6_ADDR_ALL_ROUTERS_MULTICAST,
- };
-
_cleanup_close_pair_ int fd_pair[2] = EBADF_PAIR;
_cleanup_(icmp6_packet_unrefp) ICMP6Packet *packet = NULL;
_cleanup_set_free_ Set *options = NULL;
@@ -53,7 +48,8 @@ static void test_with_icmp6_packet(const uint8_t *data, size_t size) {
if (ndisc_parse_options(packet, &options) < 0)
return;
- if (ndisc_send(fd_pair[1], &dst, icmp6_packet_get_header(packet), options, /* timestamp = */ 0) < 0)
+ if (ndisc_send(fd_pair[1], &IN6_ADDR_ALL_ROUTERS_MULTICAST,
+ icmp6_packet_get_header(packet), options, /* timestamp = */ 0) < 0)
return;
packet = icmp6_packet_unref(packet);
diff --git a/src/libsystemd-network/icmp6-util-unix.c b/src/libsystemd-network/icmp6-util-unix.c
index c400e4205e..d6d505717d 100644
--- a/src/libsystemd-network/icmp6-util-unix.c
+++ b/src/libsystemd-network/icmp6-util-unix.c
@@ -23,7 +23,7 @@ int icmp6_bind(int ifindex, bool is_router) {
return test_fd[is_router];
}
-int icmp6_send(int fd, const struct sockaddr_in6 *dst, const struct iovec *iov, size_t n_iov) {
+int icmp6_send(int fd, const struct in6_addr *dst, const struct iovec *iov, size_t n_iov) {
return writev(fd, iov, n_iov);
}
diff --git a/src/libsystemd-network/icmp6-util.c b/src/libsystemd-network/icmp6-util.c
index 804da7652e..a28f175b5e 100644
--- a/src/libsystemd-network/icmp6-util.c
+++ b/src/libsystemd-network/icmp6-util.c
@@ -91,14 +91,20 @@ int icmp6_bind(int ifindex, bool is_router) {
return TAKE_FD(s);
}
-int icmp6_send(int fd, const struct sockaddr_in6 *dst, const struct iovec *iov, size_t n_iov) {
+int icmp6_send(int fd, const struct in6_addr *dst, const struct iovec *iov, size_t n_iov) {
+ struct sockaddr_in6 sa = {
+ .sin6_family = AF_INET6,
+ .sin6_addr = *ASSERT_PTR(dst),
+ };
struct msghdr msg = {
- .msg_name = (struct sockaddr_in6*) dst,
+ .msg_name = &sa,
.msg_namelen = sizeof(struct sockaddr_in6),
.msg_iov = (struct iovec*) iov,
.msg_iovlen = n_iov,
};
+ assert(fd >= 0);
+
if (sendmsg(fd, &msg, 0) < 0)
return -errno;
diff --git a/src/libsystemd-network/icmp6-util.h b/src/libsystemd-network/icmp6-util.h
index 74acd4124c..9e5063f51b 100644
--- a/src/libsystemd-network/icmp6-util.h
+++ b/src/libsystemd-network/icmp6-util.h
@@ -25,7 +25,7 @@
} } } )
int icmp6_bind(int ifindex, bool is_router);
-int icmp6_send(int fd, const struct sockaddr_in6 *dst, const struct iovec *iov, size_t n_iov);
+int icmp6_send(int fd, const struct in6_addr *dst, const struct iovec *iov, size_t n_iov);
int icmp6_receive(
int fd,
void *buffer,
diff --git a/src/libsystemd-network/ndisc-option.c b/src/libsystemd-network/ndisc-option.c
index 96c357ced4..972047b0d1 100644
--- a/src/libsystemd-network/ndisc-option.c
+++ b/src/libsystemd-network/ndisc-option.c
@@ -1399,7 +1399,7 @@ int ndisc_option_get_mac(Set *options, uint8_t type, struct ether_addr *ret) {
return 0;
}
-int ndisc_send(int fd, const struct sockaddr_in6 *dst, const struct icmp6_hdr *hdr, Set *options, usec_t timestamp) {
+int ndisc_send(int fd, const struct in6_addr *dst, const struct icmp6_hdr *hdr, Set *options, usec_t timestamp) {
int r;
assert(fd >= 0);
diff --git a/src/libsystemd-network/ndisc-option.h b/src/libsystemd-network/ndisc-option.h
index da52858caa..d7bd86147b 100644
--- a/src/libsystemd-network/ndisc-option.h
+++ b/src/libsystemd-network/ndisc-option.h
@@ -327,4 +327,4 @@ static inline int ndisc_option_set_prefix64(
return ndisc_option_add_prefix64_internal(options, 0, prefixlen, prefix, lifetime, valid_until);
}
-int ndisc_send(int fd, const struct sockaddr_in6 *dst, const struct icmp6_hdr *hdr, Set *options, usec_t timestamp);
+int ndisc_send(int fd, const struct in6_addr *dst, const struct icmp6_hdr *hdr, Set *options, usec_t timestamp);
diff --git a/src/libsystemd-network/sd-ndisc.c b/src/libsystemd-network/sd-ndisc.c
index faa0ea2701..b4136563e1 100644
--- a/src/libsystemd-network/sd-ndisc.c
+++ b/src/libsystemd-network/sd-ndisc.c
@@ -341,10 +341,6 @@ static int ndisc_recv(sd_event_source *s, int fd, uint32_t revents, void *userda
}
static int ndisc_send_router_solicitation(sd_ndisc *nd) {
- static const struct sockaddr_in6 dst = {
- .sin6_family = AF_INET6,
- .sin6_addr = IN6_ADDR_ALL_ROUTERS_MULTICAST,
- };
static const struct nd_router_solicit header = {
.nd_rs_type = ND_ROUTER_SOLICIT,
};
@@ -360,7 +356,7 @@ static int ndisc_send_router_solicitation(sd_ndisc *nd) {
return r;
}
- return ndisc_send(nd->fd, &dst, &header.nd_rs_hdr, options, USEC_INFINITY);
+ return ndisc_send(nd->fd, &IN6_ADDR_ALL_ROUTERS_MULTICAST, &header.nd_rs_hdr, options, USEC_INFINITY);
}
static usec_t ndisc_timeout_compute_random(usec_t val) {
diff --git a/src/libsystemd-network/test-ndisc-send.c b/src/libsystemd-network/test-ndisc-send.c
index 7b9c0e5f17..1b1b27d634 100644
--- a/src/libsystemd-network/test-ndisc-send.c
+++ b/src/libsystemd-network/test-ndisc-send.c
@@ -348,12 +348,7 @@ static int send_icmp6(int fd, const struct icmp6_hdr *hdr) {
return r;
}
- struct sockaddr_in6 dst_sockaddr = {
- .sin6_family = AF_INET6,
- .sin6_addr = arg_dest.in6,
- };
-
- return ndisc_send(fd, &dst_sockaddr, hdr, options, now(CLOCK_BOOTTIME));
+ return ndisc_send(fd, &arg_dest.in6, hdr, options, now(CLOCK_BOOTTIME));
}
static int send_router_solicit(int fd) {