netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 03/16] ipv4: Pull redirect instantiation out into a helper function.
@ 2012-07-12  8:10 David Miller
  2012-07-12  8:59 ` Joe Perches
  0 siblings, 1 reply; 2+ messages in thread
From: David Miller @ 2012-07-12  8:10 UTC (permalink / raw)
  To: netdev


Signed-off-by: David S. Miller <davem@davemloft.net>
---
 net/ipv4/route.c |   37 ++++++++++++++++++++++---------------
 1 file changed, 22 insertions(+), 15 deletions(-)

diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 95bfa1b..a4de87f 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1271,6 +1271,26 @@ static void rt_del(unsigned int hash, struct rtable *rt)
 	spin_unlock_bh(rt_hash_lock_addr(hash));
 }
 
+static void ip_do_redirect(struct rtable *rt, __be32 old_gw, __be32 new_gw)
+{
+	struct neighbour *n;
+
+	if (rt->rt_gateway != old_gw)
+		return;
+
+	n = ipv4_neigh_lookup(&rt->dst, NULL, &new_gw);
+	if (n) {
+		if (!(n->nud_state & NUD_VALID)) {
+			neigh_event_send(n, NULL);
+		} else {
+			rt->rt_gateway = new_gw;
+			rt->rt_flags |= RTCF_REDIRECTED;
+			call_netevent_notifiers(NETEVENT_NEIGH_UPDATE, n);
+		}
+		neigh_release(n);
+	}
+}
+
 /* called in rcu_read_lock() section */
 void ip_rt_redirect(__be32 old_gw, __be32 daddr, __be32 new_gw,
 		    __be32 saddr, struct net_device *dev)
@@ -1311,8 +1331,6 @@ void ip_rt_redirect(__be32 old_gw, __be32 daddr, __be32 new_gw,
 			rthp = &rt_hash_table[hash].chain;
 
 			while ((rt = rcu_dereference(*rthp)) != NULL) {
-				struct neighbour *n;
-
 				rthp = &rt->dst.rt_next;
 
 				if (rt->rt_key_dst != daddr ||
@@ -1322,21 +1340,10 @@ void ip_rt_redirect(__be32 old_gw, __be32 daddr, __be32 new_gw,
 				    rt_is_expired(rt) ||
 				    !net_eq(dev_net(rt->dst.dev), net) ||
 				    rt->dst.error ||
-				    rt->dst.dev != dev ||
-				    rt->rt_gateway != old_gw)
+				    rt->dst.dev != dev)
 					continue;
 
-				n = ipv4_neigh_lookup(&rt->dst, NULL, &new_gw);
-				if (n) {
-					if (!(n->nud_state & NUD_VALID)) {
-						neigh_event_send(n, NULL);
-					} else {
-						rt->rt_gateway = new_gw;
-						rt->rt_flags |= RTCF_REDIRECTED;
-						call_netevent_notifiers(NETEVENT_NEIGH_UPDATE, n);
-					}
-					neigh_release(n);
-				}
+				ip_do_redirect(rt, old_gw, new_gw);
 			}
 		}
 	}
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH 03/16] ipv4: Pull redirect instantiation out into a helper function.
  2012-07-12  8:10 [PATCH 03/16] ipv4: Pull redirect instantiation out into a helper function David Miller
@ 2012-07-12  8:59 ` Joe Perches
  0 siblings, 0 replies; 2+ messages in thread
From: Joe Perches @ 2012-07-12  8:59 UTC (permalink / raw)
  To: David Miller; +Cc: netdev

On Thu, 2012-07-12 at 01:10 -0700, David Miller wrote:
[]
> diff --git a/net/ipv4/route.c b/net/ipv4/route.c

just a trivial style note:

> @@ -1271,6 +1271,26 @@ static void rt_del(unsigned int hash, struct rtable *rt)
>  	spin_unlock_bh(rt_hash_lock_addr(hash));
>  }
>  
> +static void ip_do_redirect(struct rtable *rt, __be32 old_gw, __be32 new_gw)
> +{
> +	struct neighbour *n;
> +
> +	if (rt->rt_gateway != old_gw)
> +		return;
> +
> +	n = ipv4_neigh_lookup(&rt->dst, NULL, &new_gw);
> +	if (n) {

Might as well use
	if (!n)
		return;
and save an indent level.

> +		if (!(n->nud_state & NUD_VALID)) {
> +			neigh_event_send(n, NULL);
> +		} else {
> +			rt->rt_gateway = new_gw;
> +			rt->rt_flags |= RTCF_REDIRECTED;
> +			call_netevent_notifiers(NETEVENT_NEIGH_UPDATE, n);
> +		}
> +		neigh_release(n);
> +	}
> +}
> +

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-07-12  8:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-12  8:10 [PATCH 03/16] ipv4: Pull redirect instantiation out into a helper function David Miller
2012-07-12  8:59 ` Joe Perches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).