summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2019-07-06 02:03:02 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2019-07-11 15:37:00 +0200
commit73854ba1a01f67fec45b767c8f4f69858545264d (patch)
tree49afbab44cd3643127a047266e00d4c16987956c
parentnetwork: rework route_scope_from_address() (diff)
downloadsystemd-73854ba1a01f67fec45b767c8f4f69858545264d.tar.xz
systemd-73854ba1a01f67fec45b767c8f4f69858545264d.zip
network: process address reply message
-rw-r--r--src/network/networkd-dhcp4.c4
-rw-r--r--src/network/networkd-dhcp6.c5
-rw-r--r--src/network/networkd-ndisc.c33
3 files changed, 33 insertions, 9 deletions
diff --git a/src/network/networkd-dhcp4.c b/src/network/networkd-dhcp4.c
index 0056c9d9b6..7ed91cebd1 100644
--- a/src/network/networkd-dhcp4.c
+++ b/src/network/networkd-dhcp4.c
@@ -460,8 +460,8 @@ static int dhcp4_address_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *
link_enter_failed(link);
return 1;
}
-
- manager_rtnl_process_address(rtnl, m, link->manager);
+ if (r >= 0)
+ manager_rtnl_process_address(rtnl, m, link->manager);
r = link_set_dhcp_routes(link);
if (r < 0) {
diff --git a/src/network/networkd-dhcp6.c b/src/network/networkd-dhcp6.c
index 286b9071ae..b34fe5931c 100644
--- a/src/network/networkd-dhcp6.c
+++ b/src/network/networkd-dhcp6.c
@@ -408,8 +408,9 @@ static int dhcp6_address_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *
log_link_error_errno(link, r, "Could not set DHCPv6 address: %m");
link_enter_failed(link);
-
- } else if (r >= 0)
+ return 1;
+ }
+ if (r >= 0)
manager_rtnl_process_address(rtnl, m, link->manager);
return 1;
diff --git a/src/network/networkd-ndisc.c b/src/network/networkd-ndisc.c
index 78f89e026e..dcf9aac1c5 100644
--- a/src/network/networkd-ndisc.c
+++ b/src/network/networkd-ndisc.c
@@ -10,6 +10,7 @@
#include "missing_network.h"
#include "networkd-dhcp6.h"
+#include "networkd-manager.h"
#include "networkd-ndisc.h"
#include "networkd-route.h"
#include "strv.h"
@@ -18,7 +19,7 @@
#define NDISC_RDNSS_MAX 64U
#define NDISC_PREFIX_LFT_MIN 7200U
-static int ndisc_netlink_message_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
+static int ndisc_netlink_route_message_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
int r;
assert(link);
@@ -38,6 +39,28 @@ static int ndisc_netlink_message_handler(sd_netlink *rtnl, sd_netlink_message *m
return 1;
}
+static int ndisc_netlink_address_message_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
+ int r;
+
+ assert(link);
+ assert(link->ndisc_messages > 0);
+
+ link->ndisc_messages--;
+
+ r = sd_netlink_message_get_errno(m);
+ if (r < 0 && r != -EEXIST)
+ log_link_error_errno(link, r, "Could not set NDisc route or address: %m");
+ else if (r >= 0)
+ manager_rtnl_process_address(rtnl, m, link->manager);
+
+ if (link->ndisc_messages == 0) {
+ link->ndisc_configured = true;
+ link_check_ready(link);
+ }
+
+ return 1;
+}
+
static int ndisc_router_process_default(Link *link, sd_ndisc_router *rt) {
_cleanup_(route_freep) Route *route = NULL;
union in_addr_union gateway;
@@ -116,7 +139,7 @@ static int ndisc_router_process_default(Link *link, sd_ndisc_router *rt) {
route->lifetime = time_now + lifetime * USEC_PER_SEC;
route->mtu = mtu;
- r = route_configure(route, link, ndisc_netlink_message_handler);
+ r = route_configure(route, link, ndisc_netlink_route_message_handler);
if (r < 0) {
log_link_warning_errno(link, r, "Could not set default route: %m");
link_enter_failed(link);
@@ -204,7 +227,7 @@ static int ndisc_router_process_autonomous_prefix(Link *link, sd_ndisc_router *r
if (address->cinfo.ifa_valid == 0)
return 0;
- r = address_configure(address, link, ndisc_netlink_message_handler, true);
+ r = address_configure(address, link, ndisc_netlink_address_message_handler, true);
if (r < 0) {
log_link_warning_errno(link, r, "Could not set SLAAC address: %m");
link_enter_failed(link);
@@ -254,7 +277,7 @@ static int ndisc_router_process_onlink_prefix(Link *link, sd_ndisc_router *rt) {
if (r < 0)
return log_link_error_errno(link, r, "Failed to get prefix address: %m");
- r = route_configure(route, link, ndisc_netlink_message_handler);
+ r = route_configure(route, link, ndisc_netlink_route_message_handler);
if (r < 0) {
log_link_warning_errno(link, r, "Could not set prefix route: %m");
link_enter_failed(link);
@@ -315,7 +338,7 @@ static int ndisc_router_process_route(Link *link, sd_ndisc_router *rt) {
if (r < 0)
return log_link_error_errno(link, r, "Failed to get route address: %m");
- r = route_configure(route, link, ndisc_netlink_message_handler);
+ r = route_configure(route, link, ndisc_netlink_route_message_handler);
if (r < 0) {
log_link_warning_errno(link, r, "Could not set additional route: %m");
link_enter_failed(link);