summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLubomir Rintel <lkundrak@v3.sk>2017-03-16 14:51:59 +0000
committerLubomir Rintel <lkundrak@v3.sk>2017-03-17 19:54:59 +0100
commit9403a602302249c1641fb6760726eaa9fea67f39 (patch)
tree640f4e527ac2cf37db5287762ef2d0e2701bbdc4
parent9a3e0c76994e2751208ef1a7793e41ac4a42198a (diff)
downloadNetworkManager-9403a602302249c1641fb6760726eaa9fea67f39.tar.gz
device: add convenience routines for IPv4 sysctls
-rw-r--r--src/devices/nm-device.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c
index 10f870f3ff..9373c762f0 100644
--- a/src/devices/nm-device.c
+++ b/src/devices/nm-device.c
@@ -704,6 +704,38 @@ init_ip6_config_dns_priority (NMDevice *self, NMIP6Config *config)
/*****************************************************************************/
+static gboolean
+nm_device_ipv4_sysctl_set (NMDevice *self, const char *property, const char *value)
+{
+ NMPlatform *platform = NM_PLATFORM_GET;
+ gs_free char *value_to_free = NULL;
+ const char *value_to_set;
+
+ if (value) {
+ value_to_set = value;
+ } else {
+ /* Set to a default value when we've got a NULL @value. */
+ value_to_free = nm_platform_sysctl_get (platform,
+ NMP_SYSCTL_PATHID_ABSOLUTE (nm_utils_ip4_property_path ("default", property)));
+ value_to_set = value_to_free;
+ }
+
+ return nm_platform_sysctl_set (platform,
+ NMP_SYSCTL_PATHID_ABSOLUTE (nm_utils_ip4_property_path (nm_device_get_ip_iface (self), property)),
+ value_to_set);
+}
+
+static guint32
+nm_device_ipv4_sysctl_get_uint32 (NMDevice *self, const char *property, guint32 fallback)
+{
+ return nm_platform_sysctl_get_int_checked (NM_PLATFORM_GET,
+ NMP_SYSCTL_PATHID_ABSOLUTE (nm_utils_ip4_property_path (nm_device_get_ip_iface (self), property)),
+ 10,
+ 0,
+ G_MAXUINT32,
+ fallback);
+}
+
gboolean
nm_device_ipv6_sysctl_set (NMDevice *self, const char *property, const char *value)
{