mirror of
https://github.com/torvalds/linux.git
synced 2024-11-26 06:02:05 +00:00
af_mpls: fix undefined reference to ip6_route_output
Undefined reference to ip6_route_output and ip_route_output was reported with CONFIG_INET=n and CONFIG_IPV6=n. This patch uses ipv6_stub_impl.ipv6_dst_lookup instead of ip6_route_output. And wraps affected code under IS_ENABLED(CONFIG_INET) and IS_ENABLED(CONFIG_IPV6). Reported-by: kbuild test robot <fengguang.wu@intel.com> Reported-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: Roopa Prabhu <roopa@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
343d60aada
commit
bf21563acc
@ -15,7 +15,10 @@
|
|||||||
#include <net/ip_fib.h>
|
#include <net/ip_fib.h>
|
||||||
#include <net/netevent.h>
|
#include <net/netevent.h>
|
||||||
#include <net/netns/generic.h>
|
#include <net/netns/generic.h>
|
||||||
#include <net/ip6_route.h>
|
#if IS_ENABLED(CONFIG_IPV6)
|
||||||
|
#include <net/ipv6.h>
|
||||||
|
#include <net/addrconf.h>
|
||||||
|
#endif
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
#define LABEL_NOT_SPECIFIED (1<<20)
|
#define LABEL_NOT_SPECIFIED (1<<20)
|
||||||
@ -331,6 +334,7 @@ static unsigned find_free_label(struct net *net)
|
|||||||
return LABEL_NOT_SPECIFIED;
|
return LABEL_NOT_SPECIFIED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if IS_ENABLED(CONFIG_INET)
|
||||||
static struct net_device *inet_fib_lookup_dev(struct net *net, void *addr)
|
static struct net_device *inet_fib_lookup_dev(struct net *net, void *addr)
|
||||||
{
|
{
|
||||||
struct net_device *dev = NULL;
|
struct net_device *dev = NULL;
|
||||||
@ -347,30 +351,49 @@ static struct net_device *inet_fib_lookup_dev(struct net *net, void *addr)
|
|||||||
|
|
||||||
ip_rt_put(rt);
|
ip_rt_put(rt);
|
||||||
|
|
||||||
errout:
|
|
||||||
return dev;
|
return dev;
|
||||||
|
errout:
|
||||||
|
return ERR_PTR(-ENODEV);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
static struct net_device *inet_fib_lookup_dev(struct net *net, void *addr)
|
||||||
|
{
|
||||||
|
return ERR_PTR(-EAFNOSUPPORT);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if IS_ENABLED(CONFIG_IPV6)
|
||||||
static struct net_device *inet6_fib_lookup_dev(struct net *net, void *addr)
|
static struct net_device *inet6_fib_lookup_dev(struct net *net, void *addr)
|
||||||
{
|
{
|
||||||
struct net_device *dev = NULL;
|
struct net_device *dev = NULL;
|
||||||
struct dst_entry *dst;
|
struct dst_entry *dst;
|
||||||
struct flowi6 fl6;
|
struct flowi6 fl6;
|
||||||
|
int err;
|
||||||
|
|
||||||
|
if (!ipv6_stub)
|
||||||
|
return ERR_PTR(-EAFNOSUPPORT);
|
||||||
|
|
||||||
memset(&fl6, 0, sizeof(fl6));
|
memset(&fl6, 0, sizeof(fl6));
|
||||||
memcpy(&fl6.daddr, addr, sizeof(struct in6_addr));
|
memcpy(&fl6.daddr, addr, sizeof(struct in6_addr));
|
||||||
dst = ip6_route_output(net, NULL, &fl6);
|
err = ipv6_stub->ipv6_dst_lookup(net, NULL, &dst, &fl6);
|
||||||
if (dst->error)
|
if (err)
|
||||||
goto errout;
|
goto errout;
|
||||||
|
|
||||||
dev = dst->dev;
|
dev = dst->dev;
|
||||||
dev_hold(dev);
|
dev_hold(dev);
|
||||||
|
|
||||||
errout:
|
|
||||||
dst_release(dst);
|
dst_release(dst);
|
||||||
|
|
||||||
return dev;
|
return dev;
|
||||||
|
|
||||||
|
errout:
|
||||||
|
return ERR_PTR(err);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
static struct net_device *inet6_fib_lookup_dev(struct net *net, void *addr)
|
||||||
|
{
|
||||||
|
return ERR_PTR(-EAFNOSUPPORT);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static struct net_device *find_outdev(struct net *net,
|
static struct net_device *find_outdev(struct net *net,
|
||||||
struct mpls_route_config *cfg)
|
struct mpls_route_config *cfg)
|
||||||
@ -425,10 +448,12 @@ static int mpls_route_add(struct mpls_route_config *cfg)
|
|||||||
if (cfg->rc_output_labels > MAX_NEW_LABELS)
|
if (cfg->rc_output_labels > MAX_NEW_LABELS)
|
||||||
goto errout;
|
goto errout;
|
||||||
|
|
||||||
err = -ENODEV;
|
|
||||||
dev = find_outdev(net, cfg);
|
dev = find_outdev(net, cfg);
|
||||||
if (!dev)
|
if (IS_ERR(dev)) {
|
||||||
|
err = PTR_ERR(dev);
|
||||||
|
dev = NULL;
|
||||||
goto errout;
|
goto errout;
|
||||||
|
}
|
||||||
|
|
||||||
/* Ensure this is a supported device */
|
/* Ensure this is a supported device */
|
||||||
err = -EINVAL;
|
err = -EINVAL;
|
||||||
|
Loading…
Reference in New Issue
Block a user