From 59d7878c04eb9571c58baf78bfd07b169d3e5c0d Mon Sep 17 00:00:00 2001 From: =?ISO-8859-1?q?Ilpo=20J=E4rvinen?= Date: Fri, 22 Aug 2008 14:49:00 +0300 Subject: [PATCH] iproute2: enable setting of per route features MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit The kernel has had an entry for per route RTAX_FEATURES which was added as unused back in 2003. Allow setting them now. It seems that it's much more sensible to have the meaning negated because otherwise the meaning of zero is very ambiguous, ie., does it mean that feature is turned off or not given. Besides, this matches what one would expect in the intented use-case, where we have global settings from sysctl and want to work-around something per route (ie., disable an otherwise enabled feature). Signed-off-by: Ilpo Järvinen --- include/linux/rtnetlink.h | 1 + ip/iproute.c | 58 +++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 54 insertions(+), 5 deletions(-) diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h index c1f2d50..354a6f1 100644 --- a/include/linux/rtnetlink.h +++ b/include/linux/rtnetlink.h @@ -373,6 +373,7 @@ enum #define RTAX_FEATURE_SACK 0x00000002 #define RTAX_FEATURE_TIMESTAMP 0x00000004 #define RTAX_FEATURE_ALLFRAG 0x00000008 +#define RTAX_FEATURE_FRTO 0x00000010 struct rta_session { diff --git a/ip/iproute.c b/ip/iproute.c index 2a8f3f8..d4a90fc 100644 --- a/ip/iproute.c +++ b/ip/iproute.c @@ -52,6 +52,20 @@ static const char *mx_names[RTAX_MAX+1] = { [RTAX_FEATURES] = "features", [RTAX_RTO_MIN] = "rto_min", }; + +struct valname { + unsigned int val; + const char *name; +}; + +static const struct valname features[] = { + { RTAX_FEATURE_ECN, "ecn" }, + { RTAX_FEATURE_SACK, "sack" }, + { RTAX_FEATURE_TIMESTAMP, "timestamps" }, + { RTAX_FEATURE_TIMESTAMP, "ts" }, + { RTAX_FEATURE_FRTO, "frto"}, +}; + static void usage(void) __attribute__((noreturn)); static void usage(void) @@ -73,7 +87,7 @@ static void usage(void) fprintf(stderr, " [ rtt TIME ] [ rttvar TIME ]\n"); fprintf(stderr, " [ window NUMBER] [ cwnd NUMBER ] [ initcwnd NUMBER ]\n"); fprintf(stderr, " [ ssthresh NUMBER ] [ realms REALM ] [ src ADDRESS ]\n"); - fprintf(stderr, " [ rto_min TIME ]\n"); + fprintf(stderr, " [ rto_min TIME ] [ features DISABLED_FEATURES ]\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"); @@ -83,6 +97,8 @@ static void usage(void) fprintf(stderr, "NHFLAGS := [ onlink | pervasive ]\n"); fprintf(stderr, "RTPROTO := [ kernel | boot | static | NUMBER ]\n"); fprintf(stderr, "TIME := NUMBER[s|ms|us|ns|j]\n"); + fprintf(stderr, "DISABLED_FEATURES := sack | timestamps | ts | ecn | frto |\n"); + fprintf(stderr, " [ DISABLED_FEATURES ]\n"); exit(-1); } @@ -505,10 +521,8 @@ int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg) if (mxlock & (1<