From patchwork Tue Oct 20 16:22:01 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 36476 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by ozlabs.org (Postfix) with ESMTP id 33895B7B9D for ; Wed, 21 Oct 2009 03:22:33 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752670AbZJTQWC (ORCPT ); Tue, 20 Oct 2009 12:22:02 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752664AbZJTQWA (ORCPT ); Tue, 20 Oct 2009 12:22:00 -0400 Received: from xenbox.codefidence.com ([92.48.73.16]:54961 "EHLO xenbox.codefidence.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752660AbZJTQV6 (ORCPT ); Tue, 20 Oct 2009 12:21:58 -0400 Received: by xenbox.codefidence.com (Postfix, from userid 56) id 96BDB245A7; Tue, 20 Oct 2009 12:22:02 -0400 (EDT) Received: (nullmailer pid 22088 invoked by uid 1000); Tue, 20 Oct 2009 16:22:01 -0000 From: Gilad Ben-Yossef To: netdev@vger.kernel.org Cc: ori@comsleep.com, ilpo.jarvinen@helsinki.fi, Gilad Ben-Yossef Subject: [PATCH TESTING] Add support for configuring route entry features Date: Tue, 20 Oct 2009 18:22:01 +0200 Message-Id: <1256055721-22065-1-git-send-email-gilad@codefidence.com> X-Mailer: git-send-email 1.5.6.3 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 CC: Ilpo Järvinen --- 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();