Linux Kernels

ipv4: Enforce max MTU metric at route insertion time.

This change “ipv4: Enforce max MTU metric at route insertion time.” (commit 710ab6c) in Linux kernel is authored by David S. Miller <davem [at] davemloft.net> on Tue Jul 10 07:02:09 2012 -0700.

Description of "ipv4: Enforce max MTU metric at route insertion time."

The change “ipv4: Enforce max MTU metric at route insertion time.” introduces changes as follows.

ipv4: Enforce max MTU metric at route insertion time.

Rather than at every struct rtable creation.

Signed-off-by: David S. Miller <davem@davemloft.net>

Linux kernel releases containing commit 710ab6c

The Linux kernel releases containing this commit are as follows.

Linux kernel code changes from "ipv4: Enforce max MTU metric at route insertion time."

There are 9 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 net/ipv4/fib_semantics.c | 2 ++
 net/ipv4/route.c         | 7 +------
 2 files changed, 3 insertions(+), 6 deletions(-)
 
diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
index ae301c897a19..d71bfbdc0bf4 100644
--- a/net/ipv4/fib_semantics.c
+++ b/net/ipv4/fib_semantics.c
@@ -794,6 +794,8 @@ struct fib_info *fib_create_info(struct fib_config *cfg)
 				val = nla_get_u32(nla);
 				if (type == RTAX_ADVMSS && val > 65535 - 40)
 					val = 65535 - 40;
+				if (type == RTAX_MTU && val > 65535 - 15)
+					val = 65535 - 15;
 				fi->fib_metrics[type - 1] = val;
 			}
 		}
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 677d65253e4c..1678b575165b 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1763,21 +1763,16 @@ static void rt_set_nexthop(struct rtable *rt, const struct flowi4 *fl4,
 			   const struct fib_result *res,
 			   struct fib_info *fi, u16 type, u32 itag)
 {
-	struct dst_entry *dst = &rt->dst;
-
 	if (fi) {
 		if (FIB_RES_GW(*res) &&
 		    FIB_RES_NH(*res).nh_scope == RT_SCOPE_LINK)
 			rt->rt_gateway = FIB_RES_GW(*res);
 		rt_init_metrics(rt, fl4, fi);
 #ifdef CONFIG_IP_ROUTE_CLASSID
-		dst->tclassid = FIB_RES_NH(*res).nh_tclassid;
+		rt->dst.tclassid = FIB_RES_NH(*res).nh_tclassid;
 #endif
 	}
 
-	if (dst_mtu(dst) > IP_MAX_MTU)
-		dst_metric_set(dst, RTAX_MTU, IP_MAX_MTU);
-
 #ifdef CONFIG_IP_ROUTE_CLASSID
 #ifdef CONFIG_IP_MULTIPLE_TABLES
 	set_class_tag(rt, fib_rules_tclass(res));

The commit for this change in Linux stable tree is 710ab6c (patch).

Last modified: 2020/01/11 09:49