net: ipv6: Add sysctl entry to disable MTU updates from RA
Subsystems (5)
PATCH 1/1 net: ipv6: Add sysctl entry to disable MTU updates from RA
The kernel forcefully applies MTU values received in router advertisements provided the new MTU is less than the current. This behavior is undesirable when the user space is managing the MTU. Instead a sysctl flag 'accept_ra_mtu' is introduced such that the user space can control whether or not RA provided MTU updates should be applied. The default behavior is unchanged; user space must explicitly set this flag to 0 for RA MTUs to be ignored.
--- Documentation/networking/ip-sysctl.txt | 7 +++++++ include/linux/ipv6.h | 1 + include/uapi/linux/ipv6.h | 1 + kernel/sysctl_binary.c | 1 + net/ipv6/addrconf.c | 9 +++++++++ net/ipv6/ndisc.c | 2 +- 6 files changed, 20 insertions(+), 1 deletion(-)
Documentation/networking/ip-sysctl.txt +7 -0
@@ -1287,6 +1287,13 @@ accept_ra_rtr_pref - BOOLEAN Functional default: enabled if accept_ra is enabled. disabled if accept_ra is disabled. +accept_ra_mtu - BOOLEAN + Apply the MTU value specified in RA option 5 (RFC4861). If + disabled, the MTU specified in the RA will be ignored. + + Functional default: enabled if accept_ra is enabled. + disabled if accept_ra is disabled. + accept_redirects - BOOLEAN Accept Redirects.
include/linux/ipv6.h +1 -0
@@ -52,6 +52,7 @@ struct ipv6_devconf {__s32 force_tllao;__s32 ndisc_notify;__s32 suppress_frag_ndisc; +__s32 accept_ra_mtu;void *sysctl; };
include/uapi/linux/ipv6.h +1 -0
@@ -169,6 +169,7 @@ enum {DEVCONF_SUPPRESS_FRAG_NDISC ,DEVCONF_ACCEPT_RA_FROM_LOCAL ,DEVCONF_USE_OPTIMISTIC , +DEVCONF_ACCEPT_RA_MTU , DEVCONF_MAX };
kernel/sysctl_binary.c +1 -0
@@ -523,6 +523,7 @@ static const struct bin_table bin_net_ipv6_conf_var_table[] = { { CTL_INT, NET_IPV6_PROXY_NDP, "proxy_ndp" }, { CTL_INT, NET_IPV6_ACCEPT_SOURCE_ROUTE, "accept_source_route" }, { CTL_INT, NET_IPV6_ACCEPT_RA_FROM_LOCAL, "accept_ra_from_local" }, + { CTL_INT, NET_IPV6_ACCEPT_RA_MTU, "accept_ra_mtu" }, {} };
net/ipv6/addrconf.c +9 -0
@@ -201,6 +201,7 @@ static struct ipv6_devconf ipv6_devconf __read_mostly = { .disable_ipv6 = 0, .accept_dad = 1, .suppress_frag_ndisc = 1, + .accept_ra_mtu = 1, };static struct ipv6_devconf ipv6_devconf_dflt__read_mostly = {
@@ -238,6 +239,7 @@ static struct ipv6_devconf ipv6_devconf_dflt __read_mostly = { .disable_ipv6 = 0, .accept_dad = 1, .suppress_frag_ndisc = 1, + .accept_ra_mtu = 1, };/* Check if a valid qdisc is available */
@@ -5253,6 +5255,13 @@ static struct addrconf_sysctl_table .proc_handler = proc_dointvec, }, { + .procname = "accept_ra_mtu", + .data = &ipv6_devconf.accept_ra_mtu, + .maxlen = sizeof(int), + .mode = 0644, + .proc_handler = proc_dointvec, + }, + {/* sentinel */ } },
net/ipv6/ndisc.c +1 -1
@@ -1348,7 +1348,7 @@ skip_routeinfo: } } -if (ndopts.nd_opts_mtu) { +if (ndopts.nd_opts_mtu && in6_dev->cnf.accept_ra_mtu) {__be32 n;u32 mtu;
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
Quoted 9 lines · Harout Hedeshian
The kernel forcefully applies MTU values received in router advertisements provided the new MTU is less than the current. This behavior is undesirable when the user space is managing the MTU. Instead a sysctl flag '
accept_ra_mtu' is introduced such that the user space can control whether or not RA provided MTU updates should be applied. The default behavior is unchanged; user space must explicitly set this flag to 0 for RA MTUs to be ignored.Signed-off-by Harout Hedeshian <[email protected]>
Makes sense!
Thanks,
Hannes
David Miller
maintainerFrom: Harout Hedeshian <[email protected]>
Date: Fri, 16 Jan 2015 18:02:38 -0700
Quoted 9 lines
The kernel forcefully applies MTU values received in router advertisements provided the new MTU is less than the current. This behavior is undesirable when the user space is managing the MTU. Instead a sysctl flag '
accept_ra_mtu' is introduced such that the user space can control whether or not RA provided MTU updates should be applied. The default behavior is unchanged; user space must explicitly set this flag to 0 for RA MTUs to be ignored.Signed-off-by Harout Hedeshian <[email protected]>
A really sloppy submission, sorry I can't apply this.
kernel/sysctl_binary.c static const struct bin_table bin_net_ipv6_conf_var_table[] = { · line 526
Quoted 1 line
kernel/sysctl_binary.c +1
-0+ { CTL_INT, NET_IPV6_ACCEPT_RA_MTU, "accept_ra_mtu" },
This isn't defined anywhere, you left out some file while creating your patch.
kernel/sysctl_binary.c:526:13: error: ‘NET_IPV6_ACCEPT_RA_MTU’ undeclared here (not in a function)
net/ipv6/ndisc.c skip_routeinfo: · line 1351
Quoted 2 lines
net/ipv6/ndisc.c +1
-1-if (ndopts.nd_opts_mtu) { +if (ndopts.nd_opts_mtu && in6_dev->cnf.accept_ra_mtu) {
Too many spaced before the &&
Quoted 21 lines
-----Original Message-----
From: David Miller [mailto:[email protected]]
Sent: Monday, January 19, 2015 1:58 PM
To: [email protected]
Cc: [email protected]
Subject: Re: [PATCH net-next] net: ipv6: Add sysctl entry to disable MTU updates from RAFrom: Harout Hedeshian <[email protected]>
Date: Fri, 16 Jan 2015 18:02:38 -0700Quoted 8 lines
The kernel forcefully applies MTU values received in router advertisements provided the new MTU is less than the current. This behavior is undesirable when the user space is managing the MTU. Instead a sysctl flag '
accept_ra_mtu' is introduced such that the user space can control whether or not RA provided MTU updates should be applied. The default behavior is unchanged; user space must explicitly set this flag to 0 for RA MTUs to be ignored.
Quoted 6 lines
Quoted 1 line
Signed-off-by Harout Hedeshian <[email protected]>A really sloppy submission, sorry I can't apply this.
Review
Quoted 1 line
(quoted diff) +1
-0+ { CTL_INT, NET_IPV6_ACCEPT_RA_MTU,"accept_ra_mtu" },
Yes, it appears include/uapi/linux/sysctl.h was missed during a rebase. I will correct this.
Quoted 1 line
This isn't defined anywhere, you left out some file while creating your
patch.
Quoted 9 lines
kernel/sysctl_binary.c:526:13: error: ?NET_IPV6_ACCEPT_RA_MTU? undeclared here (not in a function)net/ipv6/ndisc.c skip_routeinfo: · line 1351
Quoted 2 lines
net/ipv6/ndisc.c +1
-1-if (ndopts.nd_opts_mtu) { +if (ndopts.nd_opts_mtu && in6_dev->cnf.accept_ra_mtu) {Too many spaced before the &&
Hmm. Looks like checkpatch.pl did does not catch this mistake. I only get one warning about a line being too long:
harouth@harouth-lnx:/local/vg_local/lv_mainline/net_next/net-next$ ./scripts/checkpatch.pl 0001-net-ipv6-Add-sysctl-entry-to-disable-MTU-updates-fro.patch
WARNING: line over 80 characters
#74: FILE: kernel/sysctl_binary.c:526:
+ { CTL_INT, NET_IPV6_ACCEPT_RA_MTU,
"accept_ra_mtu" },
total: 0 errors, 1 warnings, 0 checks, 69 lines checked
0001-net-ipv6-Add-sysctl-entry-to-disable-MTU-updates-fro.patch has style problems, please review.
I will send an updated patch (v2) in a moment.
V2 patch passes compilation in sysctl_binary.c:
harouth@harouth-lnx:/local/vg_local/lv_mainline/net_next/net-next$ make -j8 ARCH=um .. CC kernel/sysctl.o CC kernel/sysctl_binary.o ..
Thanks,
Harout
--
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project