aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/route.c
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2012-07-11 20:38:08 -0700
committerDavid S. Miller <davem@davemloft.net>2012-07-11 20:38:08 -0700
commit94206125c4aac32e43c25bfe1b827e7ab993b7dc (patch)
tree6cfbc21c6b69efd90ccec6575a3a3c91e0bd8cad /net/ipv4/route.c
parentipv4: Pull redirect instantiation out into a helper function. (diff)
downloadlinux-dev-94206125c4aac32e43c25bfe1b827e7ab993b7dc.tar.xz
linux-dev-94206125c4aac32e43c25bfe1b827e7ab993b7dc.zip
ipv4: Rearrange arguments to ip_rt_redirect()
Pass in the SKB rather than just the IP addresses, so that policy and other aspects can reside in ip_rt_redirect() rather then icmp_redirect(). Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/route.c')
-rw-r--r--net/ipv4/route.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index a4de87f44c30..f8921b448c39 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1292,18 +1292,33 @@ static void ip_do_redirect(struct rtable *rt, __be32 old_gw, __be32 new_gw)
}
/* called in rcu_read_lock() section */
-void ip_rt_redirect(__be32 old_gw, __be32 daddr, __be32 new_gw,
- __be32 saddr, struct net_device *dev)
+void ip_rt_redirect(struct sk_buff *skb, __be32 new_gw)
{
- int s, i;
+ const struct iphdr *iph = (const struct iphdr *) skb->data;
+ __be32 old_gw = ip_hdr(skb)->saddr;
+ __be32 daddr = iph->daddr;
+ __be32 saddr = iph->saddr;
+ struct net_device *dev = skb->dev;
struct in_device *in_dev = __in_dev_get_rcu(dev);
- __be32 skeys[2] = { saddr, 0 };
int ikeys[2] = { dev->ifindex, 0 };
+ __be32 skeys[2] = { saddr, 0 };
struct net *net;
+ int s, i;
if (!in_dev)
return;
+ switch (icmp_hdr(skb)->code & 7) {
+ case ICMP_REDIR_NET:
+ case ICMP_REDIR_NETTOS:
+ case ICMP_REDIR_HOST:
+ case ICMP_REDIR_HOSTTOS:
+ break;
+
+ default:
+ return;
+ }
+
net = dev_net(dev);
if (new_gw == old_gw || !IN_DEV_RX_REDIRECTS(in_dev) ||
ipv4_is_multicast(new_gw) || ipv4_is_lbcast(new_gw) ||