Commit 86e3cadd authored by Herbert Xu's avatar Herbert Xu Committed by James Morris

[IPV4]: Make inet_select_addr() logic clearer.

It is harder to see, originally, how the
__in_dev_get() == NULL case is handled.
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: default avatarDavid S. Miller <davem@redhat.com>
parent 024338c3
...@@ -773,7 +773,7 @@ u32 inet_select_addr(const struct net_device *dev, u32 dst, int scope) ...@@ -773,7 +773,7 @@ u32 inet_select_addr(const struct net_device *dev, u32 dst, int scope)
rcu_read_lock(); rcu_read_lock();
in_dev = __in_dev_get(dev); in_dev = __in_dev_get(dev);
if (!in_dev) if (!in_dev)
goto out_unlock_inetdev; goto no_in_dev;
for_primary_ifa(in_dev) { for_primary_ifa(in_dev) {
if (ifa->ifa_scope > scope) if (ifa->ifa_scope > scope)
...@@ -785,6 +785,7 @@ u32 inet_select_addr(const struct net_device *dev, u32 dst, int scope) ...@@ -785,6 +785,7 @@ u32 inet_select_addr(const struct net_device *dev, u32 dst, int scope)
if (!addr) if (!addr)
addr = ifa->ifa_local; addr = ifa->ifa_local;
} endfor_ifa(in_dev); } endfor_ifa(in_dev);
no_in_dev:
rcu_read_unlock(); rcu_read_unlock();
if (addr) if (addr)
...@@ -810,7 +811,6 @@ u32 inet_select_addr(const struct net_device *dev, u32 dst, int scope) ...@@ -810,7 +811,6 @@ u32 inet_select_addr(const struct net_device *dev, u32 dst, int scope)
} }
out_unlock_both: out_unlock_both:
read_unlock(&dev_base_lock); read_unlock(&dev_base_lock);
out_unlock_inetdev:
rcu_read_unlock(); rcu_read_unlock();
out: out:
return addr; return 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