Blob Blame History Raw
From 9c5c3d0a9c58d8385424193fbd3467c29483d3d2 Mon Sep 17 00:00:00 2001
From: Phil Sutter <psutter@redhat.com>
Date: Wed, 20 Jul 2016 20:45:56 +0200
Subject: [PATCH] route: allow routes to be configured with expire values

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1357020
Upstream Status: iproute2.git commit 68eede2505005
Conflicts: Context changes due to missing commits:
           * 194e9b855d053 ("ip: support RFC4191 router preference")
	   * f638e9f7c8718 ("mpls: always set type RTN_UNICAST and scope
	                    RT_SCOPE_UNIVERSE for")

commit 68eede2505005ea919e2fb43afc91bad0601faea
Author: Hangbin Liu <liuhangbin@gmail.com>
Date:   Mon Dec 21 16:29:36 2015 +0800

    route: allow routes to be configured with expire values

    Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
 ip/iproute.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/ip/iproute.c b/ip/iproute.c
index 94dacbb..a13e6f3 100644
--- a/ip/iproute.c
+++ b/ip/iproute.c
@@ -82,6 +82,7 @@ static void usage(void)
 	fprintf(stderr, "           [ ssthresh NUMBER ] [ realms REALM ] [ src ADDRESS ]\n");
 	fprintf(stderr, "           [ rto_min TIME ] [ hoplimit NUMBER ] [ initrwnd NUMBER ]\n");
 	fprintf(stderr, "           [ features FEATURES ] [ quickack BOOL ] [ congctl NAME ]\n");
+	fprintf(stderr, "           [ expires TIME ]\n");
 	fprintf(stderr, "TYPE := { unicast | local | broadcast | multicast | throw |\n");
 	fprintf(stderr, "          unreachable | prohibit | blackhole | nat }\n");
 	fprintf(stderr, "TABLE_ID := [ local | main | default | all | NUMBER ]\n");
@@ -746,6 +747,7 @@ static int iproute_modify(int cmd, unsigned flags, int argc, char **argv)
 	int scope_ok = 0;
 	int table_ok = 0;
 	int raw = 0;
+	static int hz;
 
 	memset(&req, 0, sizeof(req));
 
@@ -797,6 +799,14 @@ static int iproute_modify(int cmd, unsigned flags, int argc, char **argv)
 			if (rtnl_dsfield_a2n(&tos, *argv))
 				invarg("\"tos\" value is invalid\n", *argv);
 			req.r.rtm_tos = tos;
+		} else if (strcmp(*argv, "expires") == 0 ) {
+			__u32 expires;
+			NEXT_ARG();
+			if (get_u32(&expires, *argv, 0))
+				invarg("\"expires\" value is invalid\n", *argv);
+			if (!hz)
+				hz = get_user_hz();
+			addattr32(&req.n, sizeof(req), RTA_EXPIRES, expires*hz);
 		} else if (matches(*argv, "metric") == 0 ||
 			   matches(*argv, "priority") == 0 ||
 			   matches(*argv, "preference") == 0) {
-- 
1.8.3.1