From: Gilad Ben-Yossef <gilad@codefidence.com>
To: netdev@vger.kernel.org
Cc: ori@comsleep.com, ilpo.jarvinen@helsinki.fi,
Gilad Ben-Yossef <gilad@codefidence.com>
Subject: [PATCH TESTING] Add support for configuring route entry features
Date: Tue, 20 Oct 2009 18:22:01 +0200 [thread overview]
Message-ID: <1256055721-22065-1-git-send-email-gilad@codefidence.com> (raw)
This is needed to test my previous per route entry TCP options patch.
Feature display is still numeric, so this is not the final version yet.
To use: add "features nows nots nosack nodsack to a route entry.
Based loosley on original patch by Ilpo Järvinen.
Signed-off-by: Gilad Ben-Yossef <gilad@codefidence.com>
CC: Ilpo Järvinen <ilpo.jarvinen@helsinki.fi>
---
include/linux/rtnetlink.h | 10 ++++++----
ip/iproute.c | 45 ++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 50 insertions(+), 5 deletions(-)
diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h
index 63d1c69..35964d4 100644
--- a/include/linux/rtnetlink.h
+++ b/include/linux/rtnetlink.h
@@ -376,10 +376,12 @@ enum
#define RTAX_MAX (__RTAX_MAX - 1)
-#define RTAX_FEATURE_ECN 0x00000001
-#define RTAX_FEATURE_SACK 0x00000002
-#define RTAX_FEATURE_TIMESTAMP 0x00000004
-#define RTAX_FEATURE_ALLFRAG 0x00000008
+#define RTAX_FEATURE_ECN 0x00000001
+#define RTAX_FEATURE_NO_SACK 0x00000002
+#define RTAX_FEATURE_NO_TSTAMP 0x00000004
+#define RTAX_FEATURE_ALLFRAG 0x00000008
+#define RTAX_FEATURE_NO_WSCALE 0x00000010
+#define RTAX_FEATURE_NO_DSACK 0x00000020
struct rta_session
{
diff --git a/ip/iproute.c b/ip/iproute.c
index aeea93d..9dcc0e0 100644
--- a/ip/iproute.c
+++ b/ip/iproute.c
@@ -54,6 +54,22 @@ 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_NO_SACK, "nosack" },
+ { RTAX_FEATURE_NO_TSTAMP, "notimestamps" },
+ { RTAX_FEATURE_NO_TSTAMP, "nots" },
+ { RTAX_FEATURE_NO_WSCALE, "nowindowscale" },
+ { RTAX_FEATURE_NO_WSCALE, "nows" },
+ { RTAX_FEATURE_NO_DSACK, "nodsack" },
+
+};
+
static void usage(void) __attribute__((noreturn));
static void usage(void)
@@ -75,7 +91,8 @@ static void usage(void)
fprintf(stderr, " [ rtt TIME ] [ rttvar TIME ] [reordering NUMBER ]\n");
fprintf(stderr, " [ window NUMBER] [ cwnd NUMBER ] [ initcwnd NUMBER ]\n");
fprintf(stderr, " [ ssthresh NUMBER ] [ realms REALM ] [ src ADDRESS ]\n");
- fprintf(stderr, " [ rto_min TIME ] [ hoplimit NUMBER ] \n");
+ fprintf(stderr, " [ rto_min TIME ] [ hoplimit NUMBER ]\n");
+ fprintf(stderr, " [ 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");
@@ -85,6 +102,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);
}
@@ -877,6 +896,30 @@ int iproute_modify(int cmd, unsigned flags, int argc, char **argv)
if (get_unsigned(&win, *argv, 0))
invarg("\"ssthresh\" value is invalid\n", *argv);
rta_addattr32(mxrta, sizeof(mxbuf), RTAX_SSTHRESH, win);
+ } else if (matches(*argv, "features") == 0) {
+ int j;
+ unsigned int f = 0;
+ NEXT_ARG();
+ while (1) {
+ for (j = 0; j < ARRAY_SIZE(features); j++) {
+ if (strcmp(*argv, features[j].name) == 0) {
+ f |= features[j].val;
+ if (!NEXT_ARG_OK())
+ goto feat_out;
+ NEXT_ARG();
+ break;
+ }
+ }
+ if (j == ARRAY_SIZE(features)) {
+ if (f)
+ PREV_ARG();
+ break;
+ }
+ }
+feat_out:
+ if (!f)
+ invarg("\"features\" list is invalid\n", *argv);
+ rta_addattr32(mxrta, sizeof(mxbuf), RTAX_FEATURES, f);
} else if (matches(*argv, "realms") == 0) {
__u32 realm;
NEXT_ARG();
--
1.5.6.3
reply other threads:[~2009-10-20 16:21 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1256055721-22065-1-git-send-email-gilad@codefidence.com \
--to=gilad@codefidence.com \
--cc=ilpo.jarvinen@helsinki.fi \
--cc=netdev@vger.kernel.org \
--cc=ori@comsleep.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox