Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 214821
b: refs/heads/master
c: 82efee1
h: refs/heads/master
i:
  214819: 59ac957
v: v3
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Oct 1, 2010
1 parent 4f44b29 commit f6d1124
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 15 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 828bac87bb074f3366621724fdfbe314f98ccc7e
refs/heads/master: 82efee1499a27c06f5afb11b07db384fdb3f7004
7 changes: 6 additions & 1 deletion trunk/include/linux/inetdevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,12 @@ struct in_ifaddr {
extern int register_inetaddr_notifier(struct notifier_block *nb);
extern int unregister_inetaddr_notifier(struct notifier_block *nb);

extern struct net_device *ip_dev_find(struct net *net, __be32 addr);
extern struct net_device *__ip_dev_find(struct net *net, __be32 addr, bool devref);
static inline struct net_device *ip_dev_find(struct net *net, __be32 addr)
{
return __ip_dev_find(net, addr, true);
}

extern int inet_addr_onlink(struct in_device *in_dev, __be32 a, __be32 b);
extern int devinet_ioctl(struct net *net, unsigned int cmd, void __user *);
extern void devinet_init(void);
Expand Down
32 changes: 19 additions & 13 deletions trunk/net/ipv4/fib_frontend.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,34 +147,40 @@ static void fib_flush(struct net *net)
rt_cache_flush(net, -1);
}

/*
* Find the first device with a given source address.
/**
* __ip_dev_find - find the first device with a given source address.
* @net: the net namespace
* @addr: the source address
* @devref: if true, take a reference on the found device
*
* If a caller uses devref=false, it should be protected by RCU
*/

struct net_device * ip_dev_find(struct net *net, __be32 addr)
struct net_device *__ip_dev_find(struct net *net, __be32 addr, bool devref)
{
struct flowi fl = { .nl_u = { .ip4_u = { .daddr = addr } },
.flags = FLOWI_FLAG_MATCH_ANY_IIF };
struct fib_result res;
struct flowi fl = {
.nl_u = {
.ip4_u = {
.daddr = addr
}
},
.flags = FLOWI_FLAG_MATCH_ANY_IIF
};
struct fib_result res = { 0 };
struct net_device *dev = NULL;

#ifdef CONFIG_IP_MULTIPLE_TABLES
res.r = NULL;
#endif

if (fib_lookup(net, &fl, &res))
return NULL;
if (res.type != RTN_LOCAL)
goto out;
dev = FIB_RES_DEV(res);

if (dev)
if (dev && devref)
dev_hold(dev);
out:
fib_res_put(&res);
return dev;
}
EXPORT_SYMBOL(ip_dev_find);
EXPORT_SYMBOL(__ip_dev_find);

/*
* Find address type as if only "dev" was present in the system. If
Expand Down

0 comments on commit f6d1124

Please sign in to comment.