diff options
author | David S. Miller <davem@davemloft.net> | 2012-07-12 00:25:45 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-07-12 00:25:45 -0400 |
commit | b42597e2f36e2043756aa7462faddf630962f061 (patch) | |
tree | 67264d31f7bf3cf2f0771260a3c7fc871423231a /net | |
parent | e47a185b31dd2acd424fac7dc0efb96fc5b31a33 (diff) |
ipv4: Add ipv4_redirect() and ipv4_sk_redirect() helper functions.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r-- | net/ipv4/route.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index f3d25656ddb0..aabece6b729a 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c | |||
@@ -1590,6 +1590,34 @@ void ipv4_sk_update_pmtu(struct sk_buff *skb, struct sock *sk, u32 mtu) | |||
1590 | } | 1590 | } |
1591 | EXPORT_SYMBOL_GPL(ipv4_sk_update_pmtu); | 1591 | EXPORT_SYMBOL_GPL(ipv4_sk_update_pmtu); |
1592 | 1592 | ||
1593 | void ipv4_redirect(struct sk_buff *skb, struct net *net, | ||
1594 | int oif, u32 mark, u8 protocol, int flow_flags) | ||
1595 | { | ||
1596 | const struct iphdr *iph = (const struct iphdr *)skb->data; | ||
1597 | struct flowi4 fl4; | ||
1598 | struct rtable *rt; | ||
1599 | |||
1600 | flowi4_init_output(&fl4, oif, mark, RT_TOS(iph->tos), RT_SCOPE_UNIVERSE, | ||
1601 | protocol, flow_flags, iph->daddr, iph->saddr, 0, 0); | ||
1602 | rt = __ip_route_output_key(net, &fl4); | ||
1603 | if (!IS_ERR(rt)) { | ||
1604 | ip_do_redirect(&rt->dst, skb); | ||
1605 | ip_rt_put(rt); | ||
1606 | } | ||
1607 | } | ||
1608 | EXPORT_SYMBOL_GPL(ipv4_redirect); | ||
1609 | |||
1610 | void ipv4_sk_redirect(struct sk_buff *skb, struct sock *sk) | ||
1611 | { | ||
1612 | const struct inet_sock *inet = inet_sk(sk); | ||
1613 | |||
1614 | return ipv4_redirect(skb, sock_net(sk), sk->sk_bound_dev_if, | ||
1615 | sk->sk_mark, | ||
1616 | inet->hdrincl ? IPPROTO_RAW : sk->sk_protocol, | ||
1617 | inet_sk_flowi_flags(sk)); | ||
1618 | } | ||
1619 | EXPORT_SYMBOL_GPL(ipv4_sk_redirect); | ||
1620 | |||
1593 | static struct dst_entry *ipv4_dst_check(struct dst_entry *dst, u32 cookie) | 1621 | static struct dst_entry *ipv4_dst_check(struct dst_entry *dst, u32 cookie) |
1594 | { | 1622 | { |
1595 | struct rtable *rt = (struct rtable *) dst; | 1623 | struct rtable *rt = (struct rtable *) dst; |