diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2021-10-19 13:32:40 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2021-10-21 15:40:03 +0200 |
commit | 113e124f9b930418ba7e3491c9de4bc026f4e9bc (patch) | |
tree | fcaa18bd0dfe043cb3fa50aededbe4ade4d3ea44 /src/libsystemd-network | |
parent | dhcp: shorten BPF code a bit (diff) | |
download | systemd-113e124f9b930418ba7e3491c9de4bc026f4e9bc.tar.xz systemd-113e124f9b930418ba7e3491c9de4bc026f4e9bc.zip |
icmp6: shorten code a bit
Diffstat (limited to 'src/libsystemd-network')
-rw-r--r-- | src/libsystemd-network/icmp6-util.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/libsystemd-network/icmp6-util.c b/src/libsystemd-network/icmp6-util.c index 3832bbd920..b669531487 100644 --- a/src/libsystemd-network/icmp6-util.c +++ b/src/libsystemd-network/icmp6-util.c @@ -34,16 +34,17 @@ static int icmp6_bind_router_message(const struct icmp6_filter *filter, _cleanup_close_ int s = -1; int r; + assert(filter); + assert(mreq); + s = socket(AF_INET6, SOCK_RAW | SOCK_CLOEXEC | SOCK_NONBLOCK, IPPROTO_ICMPV6); if (s < 0) return -errno; - r = setsockopt(s, IPPROTO_ICMPV6, ICMP6_FILTER, filter, sizeof(*filter)); - if (r < 0) + if (setsockopt(s, IPPROTO_ICMPV6, ICMP6_FILTER, filter, sizeof(*filter)) < 0) return -errno; - r = setsockopt(s, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, mreq, sizeof(*mreq)); - if (r < 0) + if (setsockopt(s, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP, mreq, sizeof(*mreq)) < 0) return -errno; /* RFC 3315, section 6.7, bullet point 2 may indicate that an @@ -131,15 +132,13 @@ int icmp6_send_router_solicitation(int s, const struct ether_addr *ether_addr) { .msg_iov = &iov, .msg_iovlen = 1, }; - int r; assert(s >= 0); assert(ether_addr); rs.rs_opt_mac = *ether_addr; - r = sendmsg(s, &msg, 0); - if (r < 0) + if (sendmsg(s, &msg, 0) < 0) return -errno; return 0; |