Commit 70880343 authored by Hangbin Liu's avatar Hangbin Liu Committed by Greg Kroah-Hartman

geneve: should not call rt6_lookup() when ipv6 was disabled

[ Upstream commit c0a47e44 ]

When we add a new GENEVE device with IPv6 remote, checking only for
IS_ENABLED(CONFIG_IPV6) is not enough as we may disable IPv6 in the
kernel command line (ipv6.disable=1), and calling rt6_lookup() would
cause a NULL pointer dereference.

- don't mix declarations and code (reported by Stefano Brivio, Eric Dumazet)
- there's no need to use in6_dev_get() as we only need to check that
  idev exists (reported by David Ahern). This is under RTNL, so we can
  simply use __in6_dev_get() instead (Stefano, Eric).
Reported-by: default avatarJianlin Shi <>
Fixes: c40e89fd ("geneve: configure MTU based on a lower device")
Cc: Alexey Kodanev <>
Signed-off-by: Hangbin Liu's avatarHangbin Liu <>
Reviewed-by: default avatarStefano Brivio <>
Signed-off-by: default avatarDavid S. Miller <>
Signed-off-by: default avatarGreg Kroah-Hartman <>
parent f96ea091
......@@ -1426,9 +1426,13 @@ static void geneve_link_config(struct net_device *dev,
case AF_INET6: {
struct rt6_info *rt = rt6_lookup(geneve->net,
&info->key.u.ipv6.dst, NULL, 0,
NULL, 0);
struct rt6_info *rt;
if (!__in6_dev_get(dev))
rt = rt6_lookup(geneve->net, &info->key.u.ipv6.dst, NULL, 0,
NULL, 0);
if (rt && rt->
ldev_mtu = rt->>mtu - GENEVE_IPV6_HLEN;
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