Commit 3522956c authored by Paolo Abeni's avatar Paolo Abeni Committed by Jiri Slaby

net/route: enforce hoplimit max value

[ Upstream commit 626abd59 ]

Currently, when creating or updating a route, no check is performed
in both ipv4 and ipv6 code to the hoplimit value.

The caller can i.e. set hoplimit to 256, and when such route will
 be used, packets will be sent with hoplimit/ttl equal to 0.

This commit adds checks for the RTAX_HOPLIMIT value, in both ipv4
ipv6 route code, substituting any value greater than 255 with 255.

This is consistent with what is currently done for ADVMSS and MTU
in the ipv4 code.

[js] backport to 3.12: no ip6_convert_metrics yet, fix applied to
     ip6_route_add directly.
Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
parent cc07dedc
......@@ -860,6 +860,8 @@ struct fib_info *fib_create_info(struct fib_config *cfg)
val = 65535 - 40;
if (type == RTAX_MTU && val > 65535 - 15)
val = 65535 - 15;
if (type == RTAX_HOPLIMIT && val > 255)
val = 255;
fi->fib_metrics[type - 1] = val;
}
}
......
......@@ -1670,7 +1670,11 @@ int ip6_route_add(struct fib6_config *cfg)
goto out;
}
dst_metric_set(&rt->dst, type, nla_get_u32(nla));
if (type == RTAX_HOPLIMIT && nla_get_u32(nla) > 255)
dst_metric_set(&rt->dst, type, 255);
else
dst_metric_set(&rt->dst, type,
nla_get_u32(nla));
}
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment