Skip to content

Commit c0a47e4

Browse files
liuhangbindavem330
authored andcommitted
geneve: should not call rt6_lookup() when ipv6 was disabled
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. v2: - 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: Jianlin Shi <jishi@redhat.com> Fixes: c40e89f ("geneve: configure MTU based on a lower device") Cc: Alexey Kodanev <alexey.kodanev@oracle.com> Signed-off-by: Hangbin Liu <liuhangbin@gmail.com> Reviewed-by: Stefano Brivio <sbrivio@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent e8c32c3 commit c0a47e4

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

drivers/net/geneve.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,9 +1512,13 @@ static void geneve_link_config(struct net_device *dev,
15121512
}
15131513
#if IS_ENABLED(CONFIG_IPV6)
15141514
case AF_INET6: {
1515-
struct rt6_info *rt = rt6_lookup(geneve->net,
1516-
&info->key.u.ipv6.dst, NULL, 0,
1517-
NULL, 0);
1515+
struct rt6_info *rt;
1516+
1517+
if (!__in6_dev_get(dev))
1518+
break;
1519+
1520+
rt = rt6_lookup(geneve->net, &info->key.u.ipv6.dst, NULL, 0,
1521+
NULL, 0);
15181522

15191523
if (rt && rt->dst.dev)
15201524
ldev_mtu = rt->dst.dev->mtu - GENEVE_IPV6_HLEN;

0 commit comments

Comments
 (0)