summaryrefslogtreecommitdiff
path: root/src/libsystemd-network
diff options
context:
space:
mode:
authorUmut Tezduyar Lindskog <umut.tezduyar@axis.com>2014-04-29 22:40:38 +0200
committerTom Gundersen <teg@jklm.no>2014-04-30 00:05:28 +0200
commit8ddbeaa23c20659fe3b1b79502d746aceb396ce8 (patch)
tree13cad63b8eb176509ee4b3eb69f1fd121c5da61a /src/libsystemd-network
parent7e141e498c73ec7c8b61a0df37c4937f1d6becc7 (diff)
networkd: dont configure route if lease doesn't have one
Diffstat (limited to 'src/libsystemd-network')
-rw-r--r--src/libsystemd-network/sd-dhcp-lease.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/libsystemd-network/sd-dhcp-lease.c b/src/libsystemd-network/sd-dhcp-lease.c
index acdcca87ec..3e43ab635f 100644
--- a/src/libsystemd-network/sd-dhcp-lease.c
+++ b/src/libsystemd-network/sd-dhcp-lease.c
@@ -126,7 +126,10 @@ int sd_dhcp_lease_get_router(sd_dhcp_lease *lease, struct in_addr *addr) {
assert_return(lease, -EINVAL);
assert_return(addr, -EINVAL);
- addr->s_addr = lease->router;
+ if (lease->router != INADDR_ANY)
+ addr->s_addr = lease->router;
+ else
+ return -ENOENT;
return 0;
}
@@ -297,6 +300,7 @@ int dhcp_lease_new(sd_dhcp_lease **ret) {
if (!lease)
return -ENOMEM;
+ lease->router = INADDR_ANY;
lease->n_ref = REFCNT_INIT;
*ret = lease;
@@ -370,18 +374,16 @@ int dhcp_lease_save(sd_dhcp_lease *lease, const char *lease_file) {
"# This is private data. Do not parse.\n"
"ADDRESS=%s\n", inet_ntoa(address));
- r = sd_dhcp_lease_get_router(lease, &address);
- if (r < 0)
- goto finish;
-
- fprintf(f, "ROUTER=%s\n", inet_ntoa(address));
-
r = sd_dhcp_lease_get_netmask(lease, &address);
if (r < 0)
goto finish;
fprintf(f, "NETMASK=%s\n", inet_ntoa(address));
+ r = sd_dhcp_lease_get_router(lease, &address);
+ if (r >= 0)
+ fprintf(f, "ROUTER=%s\n", inet_ntoa(address));
+
r = sd_dhcp_lease_get_server_identifier(lease, &address);
if (r >= 0)
fprintf(f, "SERVER_ADDRESS=%s\n",
@@ -474,11 +476,13 @@ int dhcp_lease_load(const char *lease_file, sd_dhcp_lease **ret) {
lease->address = addr.s_addr;
- r = inet_pton(AF_INET, router, &addr);
- if (r < 0)
- return r;
+ if (router) {
+ r = inet_pton(AF_INET, router, &addr);
+ if (r < 0)
+ return r;
- lease->router = addr.s_addr;
+ lease->router = addr.s_addr;
+ }
r = inet_pton(AF_INET, netmask, &addr);
if (r < 0)