summaryrefslogtreecommitdiffstats
path: root/src/network/networkctl.c
diff options
context:
space:
mode:
authorSusant Sahani <ssahani@vmware.com>2019-09-09 16:27:40 +0200
committerSusant Sahani <ssahani@vmware.com>2019-09-09 16:31:54 +0200
commitcdf01b36dbd5ac4ff9c733b71aab3d7cc6487bea (patch)
tree4173ab863a3281f70624a3b147bd28de3d340ec6 /src/network/networkctl.c
parentsd-network: add support to get DHCP4 address (diff)
downloadsystemd-cdf01b36dbd5ac4ff9c733b71aab3d7cc6487bea.tar.xz
systemd-cdf01b36dbd5ac4ff9c733b71aab3d7cc6487bea.zip
networkctl: Display address is a DHCP4 address
CLoses https://github.com/systemd/systemd/issues/10839
Diffstat (limited to 'src/network/networkctl.c')
-rw-r--r--src/network/networkctl.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/network/networkctl.c b/src/network/networkctl.c
index 3100a2e04e..a7cccbc690 100644
--- a/src/network/networkctl.c
+++ b/src/network/networkctl.c
@@ -678,6 +678,7 @@ static int dump_addresses(
int ifindex) {
_cleanup_free_ struct local_address *local = NULL;
+ _cleanup_free_ char *dhcp4_address = NULL;
int r, n, i;
assert(rtnl);
@@ -687,6 +688,8 @@ static int dump_addresses(
if (n < 0)
return n;
+ (void) sd_network_link_get_dhcp4_address(ifindex, &dhcp4_address);
+
for (i = 0; i < n; i++) {
_cleanup_free_ char *pretty = NULL;
@@ -700,6 +703,15 @@ static int dump_addresses(
if (r < 0)
return r;
+ if (dhcp4_address && streq(pretty, dhcp4_address)) {
+ _cleanup_free_ char *p = NULL;
+
+ p = pretty;
+ pretty = strjoin(pretty , " (DHCP4)");
+ if (!pretty)
+ return log_oom();
+ }
+
if (ifindex <= 0) {
char name[IF_NAMESIZE+1];