OpenVZ Forum


Home » Mailing lists » Devel » [PATCH net-2.6.25 1/3][ARP] Minus one level of indentation in arp_req_set
[PATCH net-2.6.25 1/3][ARP] Minus one level of indentation in arp_req_set [message #24508] Wed, 05 December 2007 17:15 Go to next message
Pavel Emelianov is currently offline  Pavel Emelianov
Messages: 1149
Registered: September 2006
Senior Member
The ATF_PUBL requests are handled completely separate from
the others. Emphasize it with a separate function. This also
reduces the indentation level.

The same issue exists with the arp_delete_request, but
when I tried to make it in one patch diff produced completely
unreadable patch. So I split it into two, but they may be 
done with one commit.

Signed-off-by: Pavel Emelyanov <xemul@openvz.org>

---

diff --git a/net/ipv4/arp.c b/net/ipv4/arp.c
index b3f366a..d628e6e 100644
--- a/net/ipv4/arp.c
+++ b/net/ipv4/arp.c
@@ -953,37 +953,45 @@ out_of_mem:
  *	Set (create) an ARP cache entry.
  */
 
+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 mask = ((struct sockaddr_in *)&r->arp_netmask)->sin_addr.s_addr;
+
+	if (mask && mask != htonl(0xFFFFFFFF))
+		return -EINVAL;
+	if (!dev && (r->arp_flags & ATF_COM)) {
+		dev = dev_getbyhwaddr(&init_net, r->arp_ha.sa_family,
+				r->arp_ha.sa_data);
+		if (!dev)
+			return -ENODEV;
+	}
+	if (mask) {
+		if (pneigh_lookup(&arp_tbl, &ip, dev, 1) == NULL)
+			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;
+}
+
 static int arp_req_set(struct arpreq *r, struct net_device * dev)
 {
-	__be32 ip = ((struct sockaddr_in *) &r->arp_pa)->sin_addr.s_addr;
+	__be32 ip;
 	struct neighbour *neigh;
 	int err;
 
-	if (r->arp_flags&ATF_PUBL) {
-		__be32 mask = ((struct sockaddr_in *) &r->arp_netmask)->sin_addr.s_addr;
-		if (mask && mask != htonl(0xFFFFFFFF))
-			return -EINVAL;
-		if (!dev && (r->arp_flags & ATF_COM)) {
-			dev = dev_getbyhwaddr(&init_net, r->arp_ha.sa_family, r->arp_ha.sa_data);
-			if (!dev)
-				return -ENODEV;
-		}
-		if (mask) {
-			if (pneigh_lookup(&arp_tbl, &ip, dev, 1) == NULL)
-				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;
-	}
+	if (r->arp_flags & ATF_PUBL)
+		return arp_req_set_public(r, dev);
 
+	ip = ((struct sockaddr_in *)&r->arp_pa)->sin_addr.s_addr;
 	if (r->arp_flags & ATF_PERM)
 		r->arp_flags |= ATF_COM;
 	if (dev == NULL) {
-- 
1.5.3.4
Re: [PATCH net-2.6.25 1/3][ARP] Minus one level of indentation in arp_req_set [message #24536 is a reply to message #24508] Thu, 06 December 2007 05:19 Go to previous message
davem is currently offline  davem
Messages: 463
Registered: February 2006
Senior Member
From: Pavel Emelyanov <xemul@openvz.org>
Date: Wed, 05 Dec 2007 20:15:02 +0300

> The ATF_PUBL requests are handled completely separate from
> the others. Emphasize it with a separate function. This also
> reduces the indentation level.
> 
> The same issue exists with the arp_delete_request, but
> when I tried to make it in one patch diff produced completely
> unreadable patch. So I split it into two, but they may be 
> done with one commit.
> 
> Signed-off-by: Pavel Emelyanov <xemul@openvz.org>

Applied, thanks.
Previous Topic: [PATCH net-2.6.25 3/3][ROUTE] Convert rt_hash_lock_init() macro into function
Next Topic: [PATCH net-2.6.25 2/3][ARP] Minus one level of ndentation in arp_req_delete
Goto Forum:
  


Current Time: Sat Apr 13 06:53:00 GMT 2024

Total time taken to generate the page: 0.01555 seconds