summaryrefslogtreecommitdiff
path: root/src/network/networkd-util.c
diff options
context:
space:
mode:
authorDaniel Dao <dqminh89@gmail.com>2018-02-26 14:33:16 +0000
committerDaniel Dao <dqminh89@gmail.com>2018-03-12 11:36:25 +0000
commitf02ba163891bab73a80332b4599a9d73083cb6c2 (patch)
tree6cb5850a946f469b9fe65b9bc8148fefe4cdb0f2 /src/network/networkd-util.c
parent332b0908370a1c5484df8084ea98743a25a24c50 (diff)
downloadsystemd-f02ba163891bab73a80332b4599a9d73083cb6c2.tar.gz
setup route expiration in kernel if supported
kernel >= 4.5 (with commit https://github.com/torvalds/linux/commit/32bc201e1974976b7d3fea9a9b17bb7392ca6394) supports RTA_EXPIRES netlink attribute to set router lifetime. This simply detect the kernel version (>=4.5) and set the lifetime properly, fallback to expiring route in userspace for kernel that doesnt support it. Signed-off-by: Daniel Dao <dqminh89@gmail.com>
Diffstat (limited to 'src/network/networkd-util.c')
-rw-r--r--src/network/networkd-util.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/network/networkd-util.c b/src/network/networkd-util.c
index b9c533fcc7..7ea14155b6 100644
--- a/src/network/networkd-util.c
+++ b/src/network/networkd-util.c
@@ -18,6 +18,7 @@
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
+#include "condition.h"
#include "conf-parser.h"
#include "networkd-util.h"
#include "parse-util.h"
@@ -99,3 +100,23 @@ int config_parse_address_family_boolean_with_kernel(
return 0;
}
+
+/* Router lifetime can be set with netlink interface since kernel >= 4.5
+ * so for the supported kernel we dont need to expire routes in userspace */
+int kernel_route_expiration_supported(void) {
+ static int cached = -1;
+ int r;
+
+ if (cached < 0) {
+ Condition c = {
+ .type = CONDITION_KERNEL_VERSION,
+ .parameter = (char *) ">= 4.5"
+ };
+ r = condition_test(&c);
+ if (r < 0)
+ return r;
+
+ cached = r;
+ }
+ return cached;
+}