From e989cbbd99ee07d10fa4909c294997b75ae0bed4 Mon Sep 17 00:00:00 2001 From: Vojtech Bubela Date: Tue, 28 Sep 2021 20:39:05 +0200 Subject: [PATCH] nmcli: show default instead of null adress invoking nmcli command without arguments will now show "default" instead of null adress in route4 or route6 section. --- src/libnm-core-aux-extern/nm-libnm-core-aux.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/libnm-core-aux-extern/nm-libnm-core-aux.c b/src/libnm-core-aux-extern/nm-libnm-core-aux.c index 4182f59ccc..e92c234f81 100644 --- a/src/libnm-core-aux-extern/nm-libnm-core-aux.c +++ b/src/libnm-core-aux-extern/nm-libnm-core-aux.c @@ -457,10 +457,15 @@ _nm_ip_route_to_string(NMIPRoute *route, NMStrBuf *strbuf) next_hop = nm_ip_route_get_next_hop(route); metric = nm_ip_route_get_metric(route); - nm_str_buf_append_printf(strbuf, - "%s/%u", - nm_ip_route_get_dest(route), - nm_ip_route_get_prefix(route)); + if (NM_IN_STRSET(nm_ip_route_get_dest(route), "0.0.0.0", "::") + && nm_ip_route_get_prefix(route) == 0) { + nm_str_buf_append_printf(strbuf, "default"); + } else { + nm_str_buf_append_printf(strbuf, + "%s/%u", + nm_ip_route_get_dest(route), + nm_ip_route_get_prefix(route)); + } if (next_hop) { nm_str_buf_append_printf(strbuf, " via %s", next_hop);