diff options
author | Thomas Haller <thaller@redhat.com> | 2018-02-08 15:17:23 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2018-02-09 17:40:01 +0100 |
commit | 06b968a820e8af05411a1104dd569d8e19d36927 (patch) | |
tree | ac70f3b084b1289e9679909a84f3e5259482044b | |
parent | 5c4f4b354033607ac04d002da600348f0562773e (diff) | |
download | NetworkManager-06b968a820e8af05411a1104dd569d8e19d36927.tar.gz |
platform: add nm_platform_refresh_all() API
Add a function that allows to re-request all objects of a certain type.
Usually, the cache is supposed to keep itself in a consistent state and
this function is not useful.
It is however useful during testing and debugging to explicitly reload
an object type.
If you ever think to need this function in non-testing code, then
something else is probably wrong with the cache implementation.
-rw-r--r-- | src/platform/nm-linux-platform.c | 7 | ||||
-rw-r--r-- | src/platform/nm-platform.c | 15 | ||||
-rw-r--r-- | src/platform/nm-platform.h | 4 |
3 files changed, 26 insertions, 0 deletions
diff --git a/src/platform/nm-linux-platform.c b/src/platform/nm-linux-platform.c index 0128362864..1e141eeb90 100644 --- a/src/platform/nm-linux-platform.c +++ b/src/platform/nm-linux-platform.c @@ -4829,6 +4829,12 @@ link_refresh (NMPlatform *platform, int ifindex) return !!nm_platform_link_get_obj (platform, ifindex, TRUE); } +static void +refresh_all (NMPlatform *platform, NMPObjectType obj_type) +{ + do_request_one_type (platform, obj_type); +} + static gboolean link_set_netns (NMPlatform *platform, int ifindex, @@ -7196,6 +7202,7 @@ nm_linux_platform_class_init (NMLinuxPlatformClass *klass) platform_class->link_add = link_add; platform_class->link_delete = link_delete; + platform_class->refresh_all = refresh_all; platform_class->link_refresh = link_refresh; platform_class->link_set_netns = link_set_netns; diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c index 67051f7769..ec19835eee 100644 --- a/src/platform/nm-platform.c +++ b/src/platform/nm-platform.c @@ -1118,6 +1118,21 @@ nm_platform_link_supports_slaves (NMPlatform *self, int ifindex) } /** + * nm_platform_refresh_all: + * @self: platform instance + * @obj_type: The object type to request. + * + * Resync and re-request all objects from kernel of a certain @obj_type. + */ +void +nm_platform_refresh_all (NMPlatform *self, NMPObjectType obj_type) +{ + _CHECK_SELF_VOID (self, klass); + + klass->refresh_all (self, obj_type); +} + +/** * nm_platform_link_refresh: * @self: platform instance * @ifindex: Interface index diff --git a/src/platform/nm-platform.h b/src/platform/nm-platform.h index 1f4230c6c4..0f2475126a 100644 --- a/src/platform/nm-platform.h +++ b/src/platform/nm-platform.h @@ -719,6 +719,8 @@ typedef struct { gboolean (*sysctl_set) (NMPlatform *, const char *pathid, int dirfd, const char *path, const char *value); char * (*sysctl_get) (NMPlatform *, const char *pathid, int dirfd, const char *path); + void (*refresh_all) (NMPlatform *self, NMPObjectType obj_type); + gboolean (*link_add) (NMPlatform *, const char *name, NMLinkType type, @@ -1033,6 +1035,8 @@ gboolean nm_platform_sysctl_set_ip6_hop_limit_safe (NMPlatform *self, const char const char *nm_platform_if_indextoname (NMPlatform *self, int ifindex, char *out_ifname/* of size IFNAMSIZ */); int nm_platform_if_nametoindex (NMPlatform *self, const char *ifname); +void nm_platform_refresh_all (NMPlatform *self, NMPObjectType obj_type); + const NMPObject *nm_platform_link_get_obj (NMPlatform *self, int ifindex, gboolean visible_only); |