From: Yu Watanabe Date: Sun, 17 Mar 2024 06:33:32 +0000 (+0900) Subject: ndisc-option: sort options in sent message X-Git-Tag: v256-rc1~398 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=073f4383657b7811b3b6934cdcdb94732d5723c8;p=thirdparty%2Fsystemd.git ndisc-option: sort options in sent message To make the sent message reproducible. --- diff --git a/src/libsystemd-network/ndisc-option.c b/src/libsystemd-network/ndisc-option.c index 7de83bcb12e..61c58d29717 100644 --- a/src/libsystemd-network/ndisc-option.c +++ b/src/libsystemd-network/ndisc-option.c @@ -1177,11 +1177,17 @@ int ndisc_send(int fd, const struct sockaddr_in6 *dst, const struct icmp6_hdr *h assert(dst); assert(hdr); + size_t n; + _cleanup_free_ sd_ndisc_option **list = NULL; + r = set_dump_sorted(options, (void***) &list, &n); + if (r < 0) + return r; + struct iovec *iov = NULL; size_t n_iov = 0; CLEANUP_ARRAY(iov, n_iov, iovec_array_free); - iov = new(struct iovec, 1 + set_size(options)); + iov = new(struct iovec, 1 + n); if (!iov) return -ENOMEM; @@ -1196,9 +1202,9 @@ int ndisc_send(int fd, const struct sockaddr_in6 *dst, const struct icmp6_hdr *h iov[n_iov++] = IOVEC_MAKE(TAKE_PTR(copy), hdr_size); - const sd_ndisc_option *option; - SET_FOREACH(option, options) { + FOREACH_ARRAY(p, list, n) { _cleanup_free_ uint8_t *buf = NULL; + sd_ndisc_option *option = *p; switch (option->type) { case 0: