Commit 5a9348b5 authored by Dan Carpenter's avatar Dan Carpenter Committed by David S. Miller

mpls: small cleanup in inet/inet6_fib_lookup_dev()

We recently changed this code from returning NULL to returning ERR_PTR.
There are some left over NULL assignments which we can remove.  We can
preserve the error code from ip_route_output() instead of always
returning -ENODEV.  Also these functions use a mix of gotos and direct
returns.  There is no cleanup necessary so I changed the gotos to
direct returns.
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Acked-by: default avatarRoopa Prabhu <roopa@cumulusnetworks.com>
Acked-by: default avatarRobert Shearman <rshearma@brocade.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 02b52428
...@@ -338,14 +338,14 @@ static unsigned find_free_label(struct net *net) ...@@ -338,14 +338,14 @@ static unsigned find_free_label(struct net *net)
#if IS_ENABLED(CONFIG_INET) #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;
struct rtable *rt; struct rtable *rt;
struct in_addr daddr; struct in_addr daddr;
memcpy(&daddr, addr, sizeof(struct in_addr)); memcpy(&daddr, addr, sizeof(struct in_addr));
rt = ip_route_output(net, daddr.s_addr, 0, 0, 0); rt = ip_route_output(net, daddr.s_addr, 0, 0, 0);
if (IS_ERR(rt)) if (IS_ERR(rt))
goto errout; return ERR_CAST(rt);
dev = rt->dst.dev; dev = rt->dst.dev;
dev_hold(dev); dev_hold(dev);
...@@ -353,8 +353,6 @@ static struct net_device *inet_fib_lookup_dev(struct net *net, void *addr) ...@@ -353,8 +353,6 @@ static struct net_device *inet_fib_lookup_dev(struct net *net, void *addr)
ip_rt_put(rt); ip_rt_put(rt);
return dev; return dev;
errout:
return ERR_PTR(-ENODEV);
} }
#else #else
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)
...@@ -366,7 +364,7 @@ static struct net_device *inet_fib_lookup_dev(struct net *net, void *addr) ...@@ -366,7 +364,7 @@ static struct net_device *inet_fib_lookup_dev(struct net *net, void *addr)
#if IS_ENABLED(CONFIG_IPV6) #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;
struct dst_entry *dst; struct dst_entry *dst;
struct flowi6 fl6; struct flowi6 fl6;
int err; int err;
...@@ -378,16 +376,13 @@ static struct net_device *inet6_fib_lookup_dev(struct net *net, void *addr) ...@@ -378,16 +376,13 @@ static struct net_device *inet6_fib_lookup_dev(struct net *net, void *addr)
memcpy(&fl6.daddr, addr, sizeof(struct in6_addr)); memcpy(&fl6.daddr, addr, sizeof(struct in6_addr));
err = ipv6_stub->ipv6_dst_lookup(net, NULL, &dst, &fl6); err = ipv6_stub->ipv6_dst_lookup(net, NULL, &dst, &fl6);
if (err) if (err)
goto errout; return ERR_PTR(err);
dev = dst->dev; dev = dst->dev;
dev_hold(dev); dev_hold(dev);
dst_release(dst); dst_release(dst);
return dev; return dev;
errout:
return ERR_PTR(err);
} }
#else #else
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)
......
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