diff options
author | Thomas Haller <thaller@redhat.com> | 2021-04-29 17:27:32 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2021-04-29 17:27:32 +0200 |
commit | 6400c339151fa1053e22c42dd4bd3e73a4267dca (patch) | |
tree | 979df6045a621de09dc6adba1113b8f79dec753e | |
parent | 12f25d965d58e1d856848f8ca8373dd8ded38d29 (diff) | |
download | NetworkManager-6400c339151fa1053e22c42dd4bd3e73a4267dca.tar.gz |
libnm/trivial: add code comment for _peers_dbus_only_synth() handling of allowed-ips
-rw-r--r-- | src/libnm-core-impl/nm-setting-wireguard.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/libnm-core-impl/nm-setting-wireguard.c b/src/libnm-core-impl/nm-setting-wireguard.c index 70862f6147..37e6b81ebf 100644 --- a/src/libnm-core-impl/nm-setting-wireguard.c +++ b/src/libnm-core-impl/nm-setting-wireguard.c @@ -1527,8 +1527,19 @@ _peers_dbus_only_synth(const NMSettInfoSetting * sett_info, gs_free const char **strv_fixed = NULL; for (i = 0; i < peer->allowed_ips->len; i++) { - if (strv[i][0] != ALLOWED_IP_INVALID_X) + /* This is a bit odd. The original peer->allowed_ips is a strv array + * of all allowed-ips, but some of them may have an ALLOWED_IP_INVALID_X prefix + * (as first character). + * + * When we serialize the array to GVariant, we need to get rid of this + * character, by pointing to the second character. + * + * In that case, first clone the strv array to strv_fixed. Once we cloned + * it, adjust the pointer to drop the first character. */ + if (strv[i][0] != ALLOWED_IP_INVALID_X) { + /* this string is valid, no need for adjustment. */ continue; + } if (!strv_fixed) { strv_fixed = nm_memdup(strv, sizeof(strv[0]) * peer->allowed_ips->len); strv = strv_fixed; |