summaryrefslogtreecommitdiff
path: root/src/network/networkd-dhcp4.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2015-10-09 23:43:52 +0200
committerTom Gundersen <teg@jklm.no>2015-10-21 03:24:23 +0200
commited9e361a8a798f9fee353b5c7e0e23308e0d329f (patch)
tree7364a91ea53be278359af58c8b002d8c3e3d0cd9 /src/network/networkd-dhcp4.c
parentadda1ed94a04742ddacdc76dfa311816e1ed9f68 (diff)
networkd: route - simplify route_new()
Diffstat (limited to 'src/network/networkd-dhcp4.c')
-rw-r--r--src/network/networkd-dhcp4.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/network/networkd-dhcp4.c b/src/network/networkd-dhcp4.c
index 6ba16581f8..22594a9415 100644
--- a/src/network/networkd-dhcp4.c
+++ b/src/network/networkd-dhcp4.c
@@ -72,11 +72,13 @@ static int link_set_dhcp_routes(Link *link) {
if (r < 0)
return log_link_warning_errno(link, r, "DHCP error: could not get address: %m");
- r = route_new(&route, RTPROT_DHCP);
+ r = route_new(&route);
if (r < 0)
return log_link_error_errno(link, r, "Could not allocate route: %m");
- r = route_new(&route_gw, RTPROT_DHCP);
+ route->protocol = RTPROT_DHCP;
+
+ r = route_new(&route_gw);
if (r < 0)
return log_link_error_errno(link, r, "Could not allocate route: %m");
@@ -88,6 +90,7 @@ static int link_set_dhcp_routes(Link *link) {
route_gw->dst_prefixlen = 32;
route_gw->prefsrc_addr.in = address;
route_gw->scope = RT_SCOPE_LINK;
+ route_gw->protocol = RTPROT_DHCP;
route_gw->metrics = link->network->dhcp_route_metric;
r = route_configure(route_gw, link, &dhcp4_route_handler);
@@ -120,11 +123,12 @@ static int link_set_dhcp_routes(Link *link) {
for (i = 0; i < n; i++) {
_cleanup_route_free_ Route *route = NULL;
- r = route_new(&route, RTPROT_DHCP);
+ r = route_new(&route);
if (r < 0)
return log_link_error_errno(link, r, "Could not allocate route: %m");
route->family = AF_INET;
+ route->protocol = RTPROT_DHCP;
route->in_addr.in = static_routes[i].gw_addr;
route->dst_addr.in = static_routes[i].dst_addr;
route->dst_prefixlen = static_routes[i].dst_prefixlen;
@@ -162,7 +166,7 @@ static int dhcp_lease_lost(Link *link) {
for (i = 0; i < n; i++) {
_cleanup_route_free_ Route *route = NULL;
- r = route_new(&route, RTPROT_UNSPEC);
+ r = route_new(&route);
if (r >= 0) {
route->family = AF_INET;
route->in_addr.in = routes[i].gw_addr;
@@ -183,7 +187,7 @@ static int dhcp_lease_lost(Link *link) {
_cleanup_route_free_ Route *route_gw = NULL;
_cleanup_route_free_ Route *route = NULL;
- r = route_new(&route_gw, RTPROT_UNSPEC);
+ r = route_new(&route_gw);
if (r >= 0) {
route_gw->family = AF_INET;
route_gw->dst_addr.in = gateway;
@@ -194,7 +198,7 @@ static int dhcp_lease_lost(Link *link) {
&link_route_remove_handler);
}
- r = route_new(&route, RTPROT_UNSPEC);
+ r = route_new(&route);
if (r >= 0) {
route->family = AF_INET;
route->in_addr.in = gateway;