aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarout Hedeshian <harouth@codeaurora.org>2015-01-20 12:06:05 -0500
committerDavid S. Miller <davem@davemloft.net>2015-01-25 17:54:41 -0500
commitc2943f14534bdc4230f4da6dcd4ea03c5d8c8162 (patch)
tree1ff92b3129af4b9b711063cf2caf5c14e64fb4b4
parent46a93af29f0561064a52cdb4a1a1f42d00361eb6 (diff)
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. Signed-off-by: Harout Hedeshian <harouth@codeaurora.org> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--Documentation/networking/ip-sysctl.txt7
-rw-r--r--include/linux/ipv6.h1
-rw-r--r--include/uapi/linux/ipv6.h1
-rw-r--r--net/ipv6/addrconf.c10
-rw-r--r--net/ipv6/ndisc.c2
5 files changed, 20 insertions, 1 deletions
diff --git a/Documentation/networking/ip-sysctl.txt b/Documentation/networking/ip-sysctl.txt
index 85b022179104..a5e4c813f17f 100644
--- a/Documentation/networking/ip-sysctl.txt
+++ b/Documentation/networking/ip-sysctl.txt
@@ -1287,6 +1287,13 @@ accept_ra_rtr_pref - BOOLEAN
1287 Functional default: enabled if accept_ra is enabled. 1287 Functional default: enabled if accept_ra is enabled.
1288 disabled if accept_ra is disabled. 1288 disabled if accept_ra is disabled.
1289 1289
1290accept_ra_mtu - BOOLEAN
1291 Apply the MTU value specified in RA option 5 (RFC4861). If
1292 disabled, the MTU specified in the RA will be ignored.
1293
1294 Functional default: enabled if accept_ra is enabled.
1295 disabled if accept_ra is disabled.
1296
1290accept_redirects - BOOLEAN 1297accept_redirects - BOOLEAN
1291 Accept Redirects. 1298 Accept Redirects.
1292 1299
diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h
index c694e7baa621..2805062c013f 100644
--- a/include/linux/ipv6.h
+++ b/include/linux/ipv6.h
@@ -52,6 +52,7 @@ struct ipv6_devconf {
52 __s32 force_tllao; 52 __s32 force_tllao;
53 __s32 ndisc_notify; 53 __s32 ndisc_notify;
54 __s32 suppress_frag_ndisc; 54 __s32 suppress_frag_ndisc;
55 __s32 accept_ra_mtu;
55 void *sysctl; 56 void *sysctl;
56}; 57};
57 58
diff --git a/include/uapi/linux/ipv6.h b/include/uapi/linux/ipv6.h
index 73cb02dc3065..437a6a4b125a 100644
--- a/include/uapi/linux/ipv6.h
+++ b/include/uapi/linux/ipv6.h
@@ -169,6 +169,7 @@ enum {
169 DEVCONF_SUPPRESS_FRAG_NDISC, 169 DEVCONF_SUPPRESS_FRAG_NDISC,
170 DEVCONF_ACCEPT_RA_FROM_LOCAL, 170 DEVCONF_ACCEPT_RA_FROM_LOCAL,
171 DEVCONF_USE_OPTIMISTIC, 171 DEVCONF_USE_OPTIMISTIC,
172 DEVCONF_ACCEPT_RA_MTU,
172 DEVCONF_MAX 173 DEVCONF_MAX
173}; 174};
174 175
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index d6b4f5d08014..7dcc065e2160 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -201,6 +201,7 @@ static struct ipv6_devconf ipv6_devconf __read_mostly = {
201 .disable_ipv6 = 0, 201 .disable_ipv6 = 0,
202 .accept_dad = 1, 202 .accept_dad = 1,
203 .suppress_frag_ndisc = 1, 203 .suppress_frag_ndisc = 1,
204 .accept_ra_mtu = 1,
204}; 205};
205 206
206static struct ipv6_devconf ipv6_devconf_dflt __read_mostly = { 207static struct ipv6_devconf ipv6_devconf_dflt __read_mostly = {
@@ -238,6 +239,7 @@ static struct ipv6_devconf ipv6_devconf_dflt __read_mostly = {
238 .disable_ipv6 = 0, 239 .disable_ipv6 = 0,
239 .accept_dad = 1, 240 .accept_dad = 1,
240 .suppress_frag_ndisc = 1, 241 .suppress_frag_ndisc = 1,
242 .accept_ra_mtu = 1,
241}; 243};
242 244
243/* Check if a valid qdisc is available */ 245/* Check if a valid qdisc is available */
@@ -4380,6 +4382,7 @@ static inline void ipv6_store_devconf(struct ipv6_devconf *cnf,
4380 array[DEVCONF_NDISC_NOTIFY] = cnf->ndisc_notify; 4382 array[DEVCONF_NDISC_NOTIFY] = cnf->ndisc_notify;
4381 array[DEVCONF_SUPPRESS_FRAG_NDISC] = cnf->suppress_frag_ndisc; 4383 array[DEVCONF_SUPPRESS_FRAG_NDISC] = cnf->suppress_frag_ndisc;
4382 array[DEVCONF_ACCEPT_RA_FROM_LOCAL] = cnf->accept_ra_from_local; 4384 array[DEVCONF_ACCEPT_RA_FROM_LOCAL] = cnf->accept_ra_from_local;
4385 array[DEVCONF_ACCEPT_RA_MTU] = cnf->accept_ra_mtu;
4383} 4386}
4384 4387
4385static inline size_t inet6_ifla6_size(void) 4388static inline size_t inet6_ifla6_size(void)
@@ -5259,6 +5262,13 @@ static struct addrconf_sysctl_table
5259 .proc_handler = proc_dointvec, 5262 .proc_handler = proc_dointvec,
5260 }, 5263 },
5261 { 5264 {
5265 .procname = "accept_ra_mtu",
5266 .data = &ipv6_devconf.accept_ra_mtu,
5267 .maxlen = sizeof(int),
5268 .mode = 0644,
5269 .proc_handler = proc_dointvec,
5270 },
5271 {
5262 /* sentinel */ 5272 /* sentinel */
5263 } 5273 }
5264 }, 5274 },
diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index 682866777d53..8a9d7c19e247 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -1348,7 +1348,7 @@ skip_routeinfo:
1348 } 1348 }
1349 } 1349 }
1350 1350
1351 if (ndopts.nd_opts_mtu) { 1351 if (ndopts.nd_opts_mtu && in6_dev->cnf.accept_ra_mtu) {
1352 __be32 n; 1352 __be32 n;
1353 u32 mtu; 1353 u32 mtu;
1354 1354