summaryrefslogtreecommitdiff
path: root/src/core/loopback-setup.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2014-01-21 15:55:57 +0100
committerTom Gundersen <teg@jklm.no>2014-01-22 18:01:45 +0100
commit5a72317435a39f23520b42731e53bd13d20f489e (patch)
tree482f11a74e177478689550b46fdd948b27f6e845 /src/core/loopback-setup.c
parent52433f6b65eccd1c54606dde999610640f3458ac (diff)
sd-rtnl: simplify sd_rtnl_message_addr_new()
Split out into sd_rtnl_message_addr_set_{prefixlen,flags,scope}().
Diffstat (limited to 'src/core/loopback-setup.c')
-rw-r--r--src/core/loopback-setup.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/src/core/loopback-setup.c b/src/core/loopback-setup.c
index 7eb28fc039..9058b6f1c1 100644
--- a/src/core/loopback-setup.c
+++ b/src/core/loopback-setup.c
@@ -51,8 +51,19 @@ static int add_addresses(sd_rtnl *rtnl, int if_loopback, struct in_addr *ipv4_ad
_cleanup_sd_rtnl_message_unref_ sd_rtnl_message *ipv4 = NULL, *ipv6 = NULL;
int r;
- r = sd_rtnl_message_addr_new(RTM_NEWADDR, if_loopback, AF_INET, 8,
- IFA_F_PERMANENT, RT_SCOPE_HOST, &ipv4);
+ r = sd_rtnl_message_addr_new(RTM_NEWADDR, if_loopback, AF_INET, &ipv4);
+ if (r < 0)
+ return r;
+
+ r = sd_rtnl_message_addr_set_prefixlen(ipv4, 8);
+ if (r < 0)
+ return r;
+
+ r = sd_rtnl_message_addr_set_flags(ipv4, IFA_F_PERMANENT);
+ if (r < 0)
+ return r;
+
+ r = sd_rtnl_message_addr_set_scope(ipv4, RT_SCOPE_HOST);
if (r < 0)
return r;
@@ -69,8 +80,19 @@ static int add_addresses(sd_rtnl *rtnl, int if_loopback, struct in_addr *ipv4_ad
if (!socket_ipv6_is_supported())
return 0;
- r = sd_rtnl_message_addr_new(RTM_NEWADDR, if_loopback, AF_INET6, 128,
- IFA_F_PERMANENT, RT_SCOPE_HOST, &ipv6);
+ r = sd_rtnl_message_addr_new(RTM_NEWADDR, if_loopback, AF_INET6, &ipv6);
+ if (r < 0)
+ return r;
+
+ r = sd_rtnl_message_addr_set_prefixlen(ipv6, 128);
+ if (r < 0)
+ return r;
+
+ r = sd_rtnl_message_addr_set_flags(ipv6, IFA_F_PERMANENT);
+ if (r < 0)
+ return r;
+
+ r = sd_rtnl_message_addr_set_scope(ipv6, RT_SCOPE_HOST);
if (r < 0)
return r;