chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
journalctl: allow globbing in --unit and --user-unit
[elogind.git]
/
src
/
core
/
loopback-setup.c
diff --git
a/src/core/loopback-setup.c
b/src/core/loopback-setup.c
index 5172a6984b83fda3a654599b0287a8ff9cc91b6b..ffe661aa9e31d3e751d593d87bd14020aaf396f8 100644
(file)
--- a/
src/core/loopback-setup.c
+++ b/
src/core/loopback-setup.c
@@
-47,15
+47,16
@@
static int pipe_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) {
return r == -EEXIST ? 0 : r;
}
return r == -EEXIST ? 0 : r;
}
-static int add_ad
resses(sd_rtnl *rtnl, int if_loopback, uint32_t
ipv4_address, int *counter) {
+static int add_ad
dresses(sd_rtnl *rtnl, int if_loopback, struct in_addr *
ipv4_address, int *counter) {
_cleanup_sd_rtnl_message_unref_ sd_rtnl_message *ipv4 = NULL, *ipv6 = NULL;
int r;
_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, 8,
+ IFA_F_PERMANENT, RT_SCOPE_HOST, &ipv4);
if (r < 0)
return r;
if (r < 0)
return r;
- r = sd_rtnl_message_append
(ipv4, IFA_LOCAL, &
ipv4_address);
+ r = sd_rtnl_message_append
_in_addr(ipv4, IFA_LOCAL,
ipv4_address);
if (r < 0)
return r;
if (r < 0)
return r;
@@
-68,11
+69,12
@@
static int add_adresses(sd_rtnl *rtnl, int if_loopback, uint32_t ipv4_address, i
if (!socket_ipv6_is_supported())
return 0;
if (!socket_ipv6_is_supported())
return 0;
- r = sd_rtnl_message_addr_new(RTM_NEWADDR, if_loopback, AF_INET6, 128, 0, 0, &ipv6);
+ r = sd_rtnl_message_addr_new(RTM_NEWADDR, if_loopback, AF_INET6, 128,
+ IFA_F_PERMANENT, RT_SCOPE_HOST, &ipv6);
if (r < 0)
return r;
if (r < 0)
return r;
- r = sd_rtnl_message_append(ipv6, IFA_LOCAL, &in6addr_loopback);
+ r = sd_rtnl_message_append
_in6_addr
(ipv6, IFA_LOCAL, &in6addr_loopback);
if (r < 0)
return r;
if (r < 0)
return r;
@@
-85,15
+87,15
@@
static int add_adresses(sd_rtnl *rtnl, int if_loopback, uint32_t ipv4_address, i
return 0;
}
return 0;
}
-static int start_interface(sd_rtnl *rtnl, int if_loopback,
uint32_t
ipv4_address, int *counter) {
+static int start_interface(sd_rtnl *rtnl, int if_loopback,
struct in_addr *
ipv4_address, int *counter) {
_cleanup_sd_rtnl_message_unref_ sd_rtnl_message *req = NULL;
int r;
_cleanup_sd_rtnl_message_unref_ sd_rtnl_message *req = NULL;
int r;
- r = sd_rtnl_message_link_new(RTM_
NEWLINK, if_loopback, 0, IFF_UP
, &req);
+ r = sd_rtnl_message_link_new(RTM_
SETLINK, if_loopback
, &req);
if (r < 0)
return r;
if (r < 0)
return r;
- r = sd_rtnl_message_
append(req, IFA_LOCAL, &ipv4_address
);
+ r = sd_rtnl_message_
link_set_flags(req, IFF_UP
);
if (r < 0)
return r;
if (r < 0)
return r;
@@
-136,22
+138,24
@@
int loopback_setup(void) {
_cleanup_sd_rtnl_unref_ sd_rtnl *rtnl = NULL;
int r, if_loopback, counter = 0;
bool eperm = false;
_cleanup_sd_rtnl_unref_ sd_rtnl *rtnl = NULL;
int r, if_loopback, counter = 0;
bool eperm = false;
-
uint32_t ipv4_address = htonl(INADDR_LOOPBACK)
;
+
struct in_addr ipv4_address
;
errno = 0;
if_loopback = (int) if_nametoindex("lo");
if (if_loopback <= 0)
return errno ? -errno : -ENODEV;
errno = 0;
if_loopback = (int) if_nametoindex("lo");
if (if_loopback <= 0)
return errno ? -errno : -ENODEV;
+ ipv4_address.s_addr = htonl(INADDR_LOOPBACK);
+
r = sd_rtnl_open(0, &rtnl);
if (r < 0)
return r;
r = sd_rtnl_open(0, &rtnl);
if (r < 0)
return r;
- r = add_ad
resses(rtnl, if_loopback,
ipv4_address, &counter);
+ r = add_ad
dresses(rtnl, if_loopback, &
ipv4_address, &counter);
if (r < 0)
return r;
if (r < 0)
return r;
- r = start_interface(rtnl, if_loopback, ipv4_address, &counter);
+ r = start_interface(rtnl, if_loopback,
&
ipv4_address, &counter);
if (r < 0)
return r;
if (r < 0)
return r;