|
|
049c96 |
From 5ce779716791bd07324bc6141e31336aa2f9c31e Mon Sep 17 00:00:00 2001
|
|
|
049c96 |
From: Phil Sutter <psutter@redhat.com>
|
|
|
049c96 |
Date: Thu, 18 Feb 2016 14:19:36 +0100
|
|
|
049c96 |
Subject: [PATCH] ip route: enable per-route ecn settings via 'features' option
|
|
|
049c96 |
|
|
|
049c96 |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1291832
|
|
|
049c96 |
Upstream Status: iproute2.git commit 29d1f730b8757
|
|
|
049c96 |
|
|
|
049c96 |
commit 29d1f730b87572a4e8165859dc04b0c89533ea4e
|
|
|
049c96 |
Author: Florian Westphal <fw@strlen.de>
|
|
|
049c96 |
Date: Thu Nov 6 22:15:32 2014 +0100
|
|
|
049c96 |
|
|
|
049c96 |
ip route: enable per-route ecn settings via 'features' option
|
|
|
049c96 |
|
|
|
049c96 |
This permits to selectively enable explicit congestion notification via
|
|
|
049c96 |
the routing table.
|
|
|
049c96 |
|
|
|
049c96 |
If this ecn feature is not set, the kernel will use the tcp_ecn sysctl
|
|
|
049c96 |
to decide wheter to use ECN when establising a TCP connection.
|
|
|
049c96 |
|
|
|
049c96 |
At the time of this writing, the kernel supports ecn and allfrags, but
|
|
|
049c96 |
allfrags is of dubious value and not implemented here.
|
|
|
049c96 |
|
|
|
049c96 |
Example:
|
|
|
049c96 |
|
|
|
049c96 |
ip route change 192.168.2.0/24 dev eth0 features ecn
|
|
|
049c96 |
|
|
|
049c96 |
Signed-off-by: Florian Westphal <fw@strlen.de>
|
|
|
049c96 |
---
|
|
|
049c96 |
ip/iproute.c | 32 ++++++++++++++++++++++++++++++++
|
|
|
049c96 |
man/man8/ip-route.8.in | 18 ++++++++++++++++++
|
|
|
049c96 |
2 files changed, 50 insertions(+)
|
|
|
049c96 |
|
|
|
049c96 |
diff --git a/ip/iproute.c b/ip/iproute.c
|
|
|
049c96 |
index 78b288a..ea69aa3 100644
|
|
|
049c96 |
--- a/ip/iproute.c
|
|
|
049c96 |
+++ b/ip/iproute.c
|
|
|
049c96 |
@@ -80,6 +80,7 @@ static void usage(void)
|
|
|
049c96 |
fprintf(stderr, " [ window NUMBER] [ cwnd NUMBER ] [ initcwnd NUMBER ]\n");
|
|
|
049c96 |
fprintf(stderr, " [ ssthresh NUMBER ] [ realms REALM ] [ src ADDRESS ]\n");
|
|
|
049c96 |
fprintf(stderr, " [ rto_min TIME ] [ hoplimit NUMBER ] [ initrwnd NUMBER ]\n");
|
|
|
049c96 |
+ fprintf(stderr, " [ features FEATURES ]\n");
|
|
|
049c96 |
fprintf(stderr, " [ quickack BOOL ]\n");
|
|
|
049c96 |
fprintf(stderr, "TYPE := [ unicast | local | broadcast | multicast | throw |\n");
|
|
|
049c96 |
fprintf(stderr, " unreachable | prohibit | blackhole | nat ]\n");
|
|
|
049c96 |
@@ -89,6 +90,7 @@ static void usage(void)
|
|
|
049c96 |
fprintf(stderr, "RTPROTO := [ kernel | boot | static | NUMBER ]\n");
|
|
|
049c96 |
fprintf(stderr, "TIME := NUMBER[s|ms]\n");
|
|
|
049c96 |
fprintf(stderr, "BOOL := [1|0]\n");
|
|
|
049c96 |
+ fprintf(stderr, "FEATURES := ecn\n");
|
|
|
049c96 |
exit(-1);
|
|
|
049c96 |
}
|
|
|
049c96 |
|
|
|
049c96 |
@@ -280,6 +282,19 @@ static int calc_host_len(const struct rtmsg *r)
|
|
|
049c96 |
return -1;
|
|
|
049c96 |
}
|
|
|
049c96 |
|
|
|
049c96 |
+static void print_rtax_features(FILE *fp, unsigned int features)
|
|
|
049c96 |
+{
|
|
|
049c96 |
+ unsigned int of = features;
|
|
|
049c96 |
+
|
|
|
049c96 |
+ if (features & RTAX_FEATURE_ECN) {
|
|
|
049c96 |
+ fprintf(fp, " ecn");
|
|
|
049c96 |
+ features &= ~RTAX_FEATURE_ECN;
|
|
|
049c96 |
+ }
|
|
|
049c96 |
+
|
|
|
049c96 |
+ if (features)
|
|
|
049c96 |
+ fprintf(fp, " 0x%x", of);
|
|
|
049c96 |
+}
|
|
|
049c96 |
+
|
|
|
049c96 |
int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
|
|
|
049c96 |
{
|
|
|
049c96 |
FILE *fp = (FILE*)arg;
|
|
|
049c96 |
@@ -538,6 +553,9 @@ int print_route(const struct sockaddr_nl *who, struct nlmsghdr *n, void *arg)
|
|
|
049c96 |
|
|
|
049c96 |
val = *(unsigned*)RTA_DATA(mxrta[i]);
|
|
|
049c96 |
switch (i) {
|
|
|
049c96 |
+ case RTAX_FEATURES:
|
|
|
049c96 |
+ print_rtax_features(fp, val);
|
|
|
049c96 |
+ break;
|
|
|
049c96 |
case RTAX_HOPLIMIT:
|
|
|
049c96 |
if ((int)val == -1)
|
|
|
049c96 |
val = 0;
|
|
|
049c96 |
@@ -888,6 +906,20 @@ static int iproute_modify(int cmd, unsigned flags, int argc, char **argv)
|
|
|
049c96 |
if (get_unsigned(&win, *argv, 0))
|
|
|
049c96 |
invarg("\"initrwnd\" value is invalid\n", *argv);
|
|
|
049c96 |
rta_addattr32(mxrta, sizeof(mxbuf), RTAX_INITRWND, win);
|
|
|
049c96 |
+ } else if (matches(*argv, "features") == 0) {
|
|
|
049c96 |
+ unsigned int features = 0;
|
|
|
049c96 |
+
|
|
|
049c96 |
+ while (argc > 0) {
|
|
|
049c96 |
+ NEXT_ARG();
|
|
|
049c96 |
+
|
|
|
049c96 |
+ if (strcmp(*argv, "ecn") == 0)
|
|
|
049c96 |
+ features |= RTAX_FEATURE_ECN;
|
|
|
049c96 |
+ else
|
|
|
049c96 |
+ invarg("\"features\" value not valid\n", *argv);
|
|
|
049c96 |
+ break;
|
|
|
049c96 |
+ }
|
|
|
049c96 |
+
|
|
|
049c96 |
+ rta_addattr32(mxrta, sizeof(mxbuf), RTAX_FEATURES, features);
|
|
|
049c96 |
} else if (matches(*argv, "quickack") == 0) {
|
|
|
049c96 |
unsigned quickack;
|
|
|
049c96 |
NEXT_ARG();
|
|
|
049c96 |
diff --git a/man/man8/ip-route.8.in b/man/man8/ip-route.8.in
|
|
|
049c96 |
index 1275306..05fd879 100644
|
|
|
049c96 |
--- a/man/man8/ip-route.8.in
|
|
|
049c96 |
+++ b/man/man8/ip-route.8.in
|
|
|
049c96 |
@@ -113,6 +113,8 @@ replace " } "
|
|
|
049c96 |
.IR NUMBER " ] [ "
|
|
|
049c96 |
.B initrwnd
|
|
|
049c96 |
.IR NUMBER " ] [ "
|
|
|
049c96 |
+.B features
|
|
|
049c96 |
+.IR FEATURES " ] [ "
|
|
|
049c96 |
.B quickack
|
|
|
049c96 |
.IR BOOL " ]"
|
|
|
049c96 |
|
|
|
049c96 |
@@ -140,6 +142,10 @@ throw " | " unreachable " | " prohibit " | " blackhole " | " nat " ]"
|
|
|
049c96 |
.BR kernel " | " boot " | " static " |"
|
|
|
049c96 |
.IR NUMBER " ]"
|
|
|
049c96 |
|
|
|
049c96 |
+.ti -8
|
|
|
049c96 |
+.IR FEATURES " := [ "
|
|
|
049c96 |
+.BR ecn " | ]"
|
|
|
049c96 |
+
|
|
|
049c96 |
|
|
|
049c96 |
.SH DESCRIPTION
|
|
|
049c96 |
.B ip route
|
|
|
049c96 |
@@ -411,6 +417,18 @@ Actual window size is this value multiplied by the MSS of the connection.
|
|
|
049c96 |
The default value is zero, meaning to use Slow Start value.
|
|
|
049c96 |
|
|
|
049c96 |
.TP
|
|
|
049c96 |
+.BI features " FEATURES " (3.18+ only)
|
|
|
049c96 |
+Enable or disable per-route features. Only available feature at this
|
|
|
049c96 |
+time is
|
|
|
049c96 |
+.B ecn
|
|
|
049c96 |
+to enable explicit congestion notification when initiating connections to the
|
|
|
049c96 |
+given destination network.
|
|
|
049c96 |
+When responding to a connection request from the given network, ecn will
|
|
|
049c96 |
+also be used even if the
|
|
|
049c96 |
+.B net.ipv4.tcp_ecn
|
|
|
049c96 |
+sysctl is set to 0.
|
|
|
049c96 |
+
|
|
|
049c96 |
+.TP
|
|
|
049c96 |
.BI quickack " BOOL " "(3.11+ only)"
|
|
|
049c96 |
Enable or disable quick ack for connections to this destination.
|
|
|
049c96 |
|
|
|
049c96 |
--
|
|
|
049c96 |
1.8.3.1
|
|
|
049c96 |
|