summaryrefslogtreecommitdiff
path: root/src/libsystemd-network/icmp6-util.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2015-11-23 15:49:10 +0100
committerTom Gundersen <teg@jklm.no>2015-11-25 18:30:31 +0100
commit6d06ac1faa1b06a9fb5793c970bccd5b47825d07 (patch)
tree555d2c1804d05ceaf39586ca142be9e0e78f2b04 /src/libsystemd-network/icmp6-util.c
parent0d43d2fcb7ac5264c739dc2f67f93ed0985a418a (diff)
sd-ndisc: always send the link-layer address
We never send packets without first knowing the link-local L3 address, so we should always include the L2 address in RS packets.
Diffstat (limited to 'src/libsystemd-network/icmp6-util.c')
-rw-r--r--src/libsystemd-network/icmp6-util.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/libsystemd-network/icmp6-util.c b/src/libsystemd-network/icmp6-util.c
index 91308bf6c3..03505fc47b 100644
--- a/src/libsystemd-network/icmp6-util.c
+++ b/src/libsystemd-network/icmp6-util.c
@@ -101,25 +101,25 @@ int icmp6_send_router_solicitation(int s, const struct ether_addr *ether_addr) {
struct ether_addr rs_opt_mac;
} _packed_ rs = {
.rs.nd_rs_type = ND_ROUTER_SOLICIT,
+ .rs_opt.nd_opt_type = ND_OPT_SOURCE_LINKADDR,
+ .rs_opt.nd_opt_len = 1,
};
- struct iovec iov[1] = {
- { &rs, },
+ struct iovec iov = {
+ .iov_base = &rs,
+ .iov_len = sizeof(rs),
};
struct msghdr msg = {
.msg_name = &dst,
.msg_namelen = sizeof(dst),
- .msg_iov = iov,
+ .msg_iov = &iov,
.msg_iovlen = 1,
};
int r;
- if (ether_addr) {
- memcpy(&rs.rs_opt_mac, ether_addr, ETH_ALEN);
- rs.rs_opt.nd_opt_type = ND_OPT_SOURCE_LINKADDR;
- rs.rs_opt.nd_opt_len = 1;
- iov[0].iov_len = sizeof(rs);
- } else
- iov[0].iov_len = sizeof(rs.rs);
+ assert(s >= 0);
+ assert(ether_addr);
+
+ rs.rs_opt_mac = *ether_addr;
r = sendmsg(s, &msg, 0);
if (r < 0)