Commit f8b33fdf authored by Pavel Emelyanov's avatar Pavel Emelyanov Committed by David S. Miller

[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: default avatarPavel Emelyanov <xemul@openvz.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 46479b43
...@@ -952,6 +952,19 @@ static int arp_rcv(struct sk_buff *skb, struct net_device *dev, ...@@ -952,6 +952,19 @@ static int arp_rcv(struct sk_buff *skb, struct net_device *dev,
* Set (create) an ARP cache entry. * 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) 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; __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) ...@@ -970,15 +983,8 @@ static int arp_req_set_public(struct arpreq *r, struct net_device *dev)
return -ENOBUFS; return -ENOBUFS;
return 0; return 0;
} }
if (dev == NULL) {
IPV4_DEVCONF_ALL(PROXY_ARP) = 1; return arp_req_set_proxy(dev, 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;
} }
static int arp_req_set(struct arpreq *r, struct net_device * dev) 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) ...@@ -1082,19 +1088,10 @@ static int arp_req_delete_public(struct arpreq *r, struct net_device *dev)
if (mask == htonl(0xFFFFFFFF)) if (mask == htonl(0xFFFFFFFF))
return pneigh_delete(&arp_tbl, &ip, dev); return pneigh_delete(&arp_tbl, &ip, dev);
if (mask == 0) { if (mask)
if (dev == NULL) { return -EINVAL;
IPV4_DEVCONF_ALL(PROXY_ARP) = 0;
return 0; return arp_req_set_proxy(dev, 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;
} }
static int arp_req_delete(struct arpreq *r, struct net_device * dev) static int arp_req_delete(struct arpreq *r, struct net_device * dev)
......
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