summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@openvz.org>2007-12-05 21:20:50 -0800
committerDavid S. Miller <davem@davemloft.net>2008-01-28 14:56:38 -0800
commitf8b33fdfafea0f909712a55fbb3d83b89f70f3f5 (patch)
treea933c08d0302ae39ea1aa5e2c09382954d4c2453 /net
parent46479b432989d61c6f676adf21b4f4d8abd7bc26 (diff)
downloadlinux-3.10-f8b33fdfafea0f909712a55fbb3d83b89f70f3f5.tar.gz
linux-3.10-f8b33fdfafea0f909712a55fbb3d83b89f70f3f5.tar.bz2
linux-3.10-f8b33fdfafea0f909712a55fbb3d83b89f70f3f5.zip
[ARP]: Consolidate some code in arp_req_set/delete_publc
The PROXY_ARP is set on devconfigs in a similar way in both calls. Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/ipv4/arp.c41
1 files changed, 19 insertions, 22 deletions
diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c
index e947ad9409b..477f3e5fe8d 100644
--- a/net/ipv4/arp.c
+++ b/net/ipv4/arp.c
@@ -952,6 +952,19 @@ out_of_mem:
* Set (create) an ARP cache entry.
*/
+static int arp_req_set_proxy(struct net_device *dev, int on)
+{
+ if (dev == NULL) {
+ IPV4_DEVCONF_ALL(PROXY_ARP) = on;
+ return 0;
+ }
+ if (__in_dev_get_rtnl(dev)) {
+ IN_DEV_CONF_SET(__in_dev_get_rtnl(dev), PROXY_ARP, on);
+ return 0;
+ }
+ return -ENXIO;
+}
+
static int arp_req_set_public(struct arpreq *r, struct net_device *dev)
{
__be32 ip = ((struct sockaddr_in *)&r->arp_pa)->sin_addr.s_addr;
@@ -970,15 +983,8 @@ static int arp_req_set_public(struct arpreq *r, struct net_device *dev)
return -ENOBUFS;
return 0;
}
- if (dev == NULL) {
- IPV4_DEVCONF_ALL(PROXY_ARP) = 1;
- return 0;
- }
- if (__in_dev_get_rtnl(dev)) {
- IN_DEV_CONF_SET(__in_dev_get_rtnl(dev), PROXY_ARP, 1);
- return 0;
- }
- return -ENXIO;
+
+ return arp_req_set_proxy(dev, 1);
}
static int arp_req_set(struct arpreq *r, struct net_device * dev)
@@ -1082,19 +1088,10 @@ static int arp_req_delete_public(struct arpreq *r, struct net_device *dev)
if (mask == htonl(0xFFFFFFFF))
return pneigh_delete(&arp_tbl, &ip, dev);
- if (mask == 0) {
- if (dev == NULL) {
- IPV4_DEVCONF_ALL(PROXY_ARP) = 0;
- return 0;
- }
- if (__in_dev_get_rtnl(dev)) {
- IN_DEV_CONF_SET(__in_dev_get_rtnl(dev),
- PROXY_ARP, 0);
- return 0;
- }
- return -ENXIO;
- }
- return -EINVAL;
+ if (mask)
+ return -EINVAL;
+
+ return arp_req_set_proxy(dev, 0);
}
static int arp_req_delete(struct arpreq *r, struct net_device * dev)