diff options
author | Thomas Haller <thaller@redhat.com> | 2020-09-08 17:05:34 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2020-09-11 16:18:35 +0200 |
commit | 6358d10688289ef78693a763c194587c5ac2af43 (patch) | |
tree | 2db0c7f699dc38761181d02d8e42b1cfd636fb7c | |
parent | 3b8b683f8aa017642a04c4c446cb76a65ca97170 (diff) | |
download | NetworkManager-6358d10688289ef78693a763c194587c5ac2af43.tar.gz |
l3cfg: add nm_l3cfg_get_best_default_route() function
This is the best default route that we commited the last time (if any).
It may not reflect what is currently configured (in NMPlatform) and it
may not reflect the latest changes since nm_l3cfg_add_config().
-rw-r--r-- | src/nm-l3cfg.c | 20 | ||||
-rw-r--r-- | src/nm-l3cfg.h | 5 |
2 files changed, 25 insertions, 0 deletions
diff --git a/src/nm-l3cfg.c b/src/nm-l3cfg.c index 2086cd00e7..f4862a36ae 100644 --- a/src/nm-l3cfg.c +++ b/src/nm-l3cfg.c @@ -3018,6 +3018,26 @@ nm_l3cfg_commit_type_unregister (NML3Cfg *self, /*****************************************************************************/ +const NMPObject * +nm_l3cfg_get_best_default_route (NML3Cfg *self, + int addr_family) +{ + nm_assert (NM_IS_L3CFG (self)); + + /* we only consider the combined_l3cd. This is a merge of all the l3cd, and the one + * with which we called nm_l3cfg_platform_commit() the last time. + * + * In the meantime, we might have changed the tracked l3_config_datas, but we didn't + * nm_l3cfg_platform_commit() yet. These changes are ignored for this purpose, until + * the user call nm_l3cfg_platform_commit() to re-commit the changes. */ + if (!self->priv.p->combined_l3cd) + return NULL; + + return nm_l3_config_data_get_best_default_route (self->priv.p->combined_l3cd, addr_family); +} + +/*****************************************************************************/ + static void set_property (GObject *object, guint prop_id, diff --git a/src/nm-l3cfg.h b/src/nm-l3cfg.h index 13830073a2..0e92b656b7 100644 --- a/src/nm-l3cfg.h +++ b/src/nm-l3cfg.h @@ -220,4 +220,9 @@ void nm_l3cfg_commit_type_unregister (NML3Cfg *self, /*****************************************************************************/ +const NMPObject *nm_l3cfg_get_best_default_route (NML3Cfg *self, + int addr_family); + +/*****************************************************************************/ + #endif /* __NM_L3CFG_H__ */ |