diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2019-02-03 01:47:25 +0100 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2019-02-11 01:28:09 +0900 |
commit | 434094864c050c3c406067b231da782731c0ab38 (patch) | |
tree | c0acb6969eb178f36b041f5161912250c6c3617e /src/network/networkd-address.c | |
parent | 67b19a496173e0401e9f2b7a3591715e0fe22b75 (diff) | |
download | systemd-434094864c050c3c406067b231da782731c0ab38.tar.gz |
network: use netlink_message_append_{in_addr,sockaddr}_union()
Diffstat (limited to 'src/network/networkd-address.c')
-rw-r--r-- | src/network/networkd-address.c | 15 |
1 files changed, 3 insertions, 12 deletions
diff --git a/src/network/networkd-address.c b/src/network/networkd-address.c index 87345fb2d6..06e2662cdd 100644 --- a/src/network/networkd-address.c +++ b/src/network/networkd-address.c @@ -469,10 +469,7 @@ int address_remove( if (r < 0) return log_error_errno(r, "Could not set prefixlen: %m"); - if (address->family == AF_INET) - r = sd_netlink_message_append_in_addr(req, IFA_LOCAL, &address->in_addr.in); - else if (address->family == AF_INET6) - r = sd_netlink_message_append_in6_addr(req, IFA_LOCAL, &address->in_addr.in6); + r = netlink_message_append_in_addr_union(req, IFA_LOCAL, address->family, &address->in_addr); if (r < 0) return log_error_errno(r, "Could not append IFA_LOCAL attribute: %m"); @@ -618,18 +615,12 @@ int address_configure( if (r < 0) return log_error_errno(r, "Could not set scope: %m"); - if (address->family == AF_INET) - r = sd_netlink_message_append_in_addr(req, IFA_LOCAL, &address->in_addr.in); - else if (address->family == AF_INET6) - r = sd_netlink_message_append_in6_addr(req, IFA_LOCAL, &address->in_addr.in6); + r = netlink_message_append_in_addr_union(req, IFA_LOCAL, address->family, &address->in_addr); if (r < 0) return log_error_errno(r, "Could not append IFA_LOCAL attribute: %m"); if (in_addr_is_null(address->family, &address->in_addr_peer) == 0) { - if (address->family == AF_INET) - r = sd_netlink_message_append_in_addr(req, IFA_ADDRESS, &address->in_addr_peer.in); - else if (address->family == AF_INET6) - r = sd_netlink_message_append_in6_addr(req, IFA_ADDRESS, &address->in_addr_peer.in6); + r = netlink_message_append_in_addr_union(req, IFA_ADDRESS, address->family, &address->in_addr_peer); if (r < 0) return log_error_errno(r, "Could not append IFA_ADDRESS attribute: %m"); } else if (address->family == AF_INET && address->prefixlen <= 30) { |