Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 315124
b: refs/heads/master
c: d0da720
h: refs/heads/master
v: v3
  • Loading branch information
David S. Miller committed Jul 12, 2012
1 parent c55bda9 commit bdb8182
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 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: d3351b75a7169337877fe6f6f2c019154b6ec1ea
refs/heads/master: d0da720f9f16a5023cc084bed8968702400f6e0f
37 changes: 22 additions & 15 deletions trunk/net/ipv4/route.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 ||
Expand All @@ -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);
}
}
}
Expand Down

0 comments on commit bdb8182

Please sign in to comment.