diff options
author | Roopa Prabhu <roopa@cumulusnetworks.com> | 2015-07-30 16:34:54 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-07-31 18:21:30 -0400 |
commit | bf21563acc1de2391d21ac2141c3471aa4815c1a (patch) | |
tree | 4cf1e6e3ec1d76e730778ec0d8b2a7efbe6b9499 /net/mpls | |
parent | 343d60aada5a358ca186d6e9e353230379c426d8 (diff) |
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>
Diffstat (limited to 'net/mpls')
-rw-r--r-- | net/mpls/af_mpls.c | 41 |
1 files changed, 33 insertions, 8 deletions
diff --git a/net/mpls/af_mpls.c b/net/mpls/af_mpls.c index 49f1b0e41bdf..88cfaa241c07 100644 --- a/net/mpls/af_mpls.c +++ b/net/mpls/af_mpls.c | |||
@@ -15,7 +15,10 @@ | |||
15 | #include <net/ip_fib.h> | 15 | #include <net/ip_fib.h> |
16 | #include <net/netevent.h> | 16 | #include <net/netevent.h> |
17 | #include <net/netns/generic.h> | 17 | #include <net/netns/generic.h> |
18 | #include <net/ip6_route.h> | 18 | #if IS_ENABLED(CONFIG_IPV6) |
19 | #include <net/ipv6.h> | ||
20 | #include <net/addrconf.h> | ||
21 | #endif | ||
19 | #include "internal.h" | 22 | #include "internal.h" |
20 | 23 | ||
21 | #define LABEL_NOT_SPECIFIED (1<<20) | 24 | #define LABEL_NOT_SPECIFIED (1<<20) |
@@ -331,6 +334,7 @@ static unsigned find_free_label(struct net *net) | |||
331 | return LABEL_NOT_SPECIFIED; | 334 | return LABEL_NOT_SPECIFIED; |
332 | } | 335 | } |
333 | 336 | ||
337 | #if IS_ENABLED(CONFIG_INET) | ||
334 | static struct net_device *inet_fib_lookup_dev(struct net *net, void *addr) | 338 | static struct net_device *inet_fib_lookup_dev(struct net *net, void *addr) |
335 | { | 339 | { |
336 | struct net_device *dev = NULL; | 340 | struct net_device *dev = NULL; |
@@ -347,30 +351,49 @@ static struct net_device *inet_fib_lookup_dev(struct net *net, void *addr) | |||
347 | 351 | ||
348 | ip_rt_put(rt); | 352 | ip_rt_put(rt); |
349 | 353 | ||
350 | errout: | ||
351 | return dev; | 354 | return dev; |
355 | errout: | ||
356 | return ERR_PTR(-ENODEV); | ||
357 | } | ||
358 | #else | ||
359 | static struct net_device *inet_fib_lookup_dev(struct net *net, void *addr) | ||
360 | { | ||
361 | return ERR_PTR(-EAFNOSUPPORT); | ||
352 | } | 362 | } |
363 | #endif | ||
353 | 364 | ||
365 | #if IS_ENABLED(CONFIG_IPV6) | ||
354 | static struct net_device *inet6_fib_lookup_dev(struct net *net, void *addr) | 366 | static struct net_device *inet6_fib_lookup_dev(struct net *net, void *addr) |
355 | { | 367 | { |
356 | struct net_device *dev = NULL; | 368 | struct net_device *dev = NULL; |
357 | struct dst_entry *dst; | 369 | struct dst_entry *dst; |
358 | struct flowi6 fl6; | 370 | struct flowi6 fl6; |
371 | int err; | ||
372 | |||
373 | if (!ipv6_stub) | ||
374 | return ERR_PTR(-EAFNOSUPPORT); | ||
359 | 375 | ||
360 | memset(&fl6, 0, sizeof(fl6)); | 376 | memset(&fl6, 0, sizeof(fl6)); |
361 | memcpy(&fl6.daddr, addr, sizeof(struct in6_addr)); | 377 | memcpy(&fl6.daddr, addr, sizeof(struct in6_addr)); |
362 | dst = ip6_route_output(net, NULL, &fl6); | 378 | err = ipv6_stub->ipv6_dst_lookup(net, NULL, &dst, &fl6); |
363 | if (dst->error) | 379 | if (err) |
364 | goto errout; | 380 | goto errout; |
365 | 381 | ||
366 | dev = dst->dev; | 382 | dev = dst->dev; |
367 | dev_hold(dev); | 383 | dev_hold(dev); |
368 | |||
369 | errout: | ||
370 | dst_release(dst); | 384 | dst_release(dst); |
371 | 385 | ||
372 | return dev; | 386 | return dev; |
387 | |||
388 | errout: | ||
389 | return ERR_PTR(err); | ||
373 | } | 390 | } |
391 | #else | ||
392 | static struct net_device *inet6_fib_lookup_dev(struct net *net, void *addr) | ||
393 | { | ||
394 | return ERR_PTR(-EAFNOSUPPORT); | ||
395 | } | ||
396 | #endif | ||
374 | 397 | ||
375 | static struct net_device *find_outdev(struct net *net, | 398 | static struct net_device *find_outdev(struct net *net, |
376 | struct mpls_route_config *cfg) | 399 | struct mpls_route_config *cfg) |
@@ -425,10 +448,12 @@ static int mpls_route_add(struct mpls_route_config *cfg) | |||
425 | if (cfg->rc_output_labels > MAX_NEW_LABELS) | 448 | if (cfg->rc_output_labels > MAX_NEW_LABELS) |
426 | goto errout; | 449 | goto errout; |
427 | 450 | ||
428 | err = -ENODEV; | ||
429 | dev = find_outdev(net, cfg); | 451 | dev = find_outdev(net, cfg); |
430 | if (!dev) | 452 | if (IS_ERR(dev)) { |
453 | err = PTR_ERR(dev); | ||
454 | dev = NULL; | ||
431 | goto errout; | 455 | goto errout; |
456 | } | ||
432 | 457 | ||
433 | /* Ensure this is a supported device */ | 458 | /* Ensure this is a supported device */ |
434 | err = -EINVAL; | 459 | err = -EINVAL; |