summaryrefslogtreecommitdiff
path: root/src/core/loopback-setup.c
diff options
context:
space:
mode:
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;