diff options
author | David S. Miller <davem@davemloft.net> | 2012-07-12 03:08:07 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-07-12 03:08:07 -0400 |
commit | 3a5ad2ee5e2c5030d8a303d06f9148a2f893a369 (patch) | |
tree | 946aa295174ef8605d9e91eb44755aeebfc7a0da /net/ipv6 | |
parent | 6e157b6ac61aa7758ccd643d4aafdf3cc17b9f04 (diff) |
ipv6: Add ip6_redirect() and ip6_sk_redirect() helper functions.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6')
-rw-r--r-- | net/ipv6/route.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 545b1526c143..f52cf83bb1e0 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c | |||
@@ -1114,6 +1114,33 @@ void ip6_sk_update_pmtu(struct sk_buff *skb, struct sock *sk, __be32 mtu) | |||
1114 | } | 1114 | } |
1115 | EXPORT_SYMBOL_GPL(ip6_sk_update_pmtu); | 1115 | EXPORT_SYMBOL_GPL(ip6_sk_update_pmtu); |
1116 | 1116 | ||
1117 | void ip6_redirect(struct sk_buff *skb, struct net *net, int oif, u32 mark) | ||
1118 | { | ||
1119 | const struct ipv6hdr *iph = (struct ipv6hdr *) skb->data; | ||
1120 | struct dst_entry *dst; | ||
1121 | struct flowi6 fl6; | ||
1122 | |||
1123 | memset(&fl6, 0, sizeof(fl6)); | ||
1124 | fl6.flowi6_oif = oif; | ||
1125 | fl6.flowi6_mark = mark; | ||
1126 | fl6.flowi6_flags = 0; | ||
1127 | fl6.daddr = iph->daddr; | ||
1128 | fl6.saddr = iph->saddr; | ||
1129 | fl6.flowlabel = (*(__be32 *) iph) & IPV6_FLOWINFO_MASK; | ||
1130 | |||
1131 | dst = ip6_route_output(net, NULL, &fl6); | ||
1132 | if (!dst->error) | ||
1133 | rt6_do_redirect(dst, skb); | ||
1134 | dst_release(dst); | ||
1135 | } | ||
1136 | EXPORT_SYMBOL_GPL(ip6_redirect); | ||
1137 | |||
1138 | void ip6_sk_redirect(struct sk_buff *skb, struct sock *sk) | ||
1139 | { | ||
1140 | ip6_redirect(skb, sock_net(sk), sk->sk_bound_dev_if, sk->sk_mark); | ||
1141 | } | ||
1142 | EXPORT_SYMBOL_GPL(ip6_sk_redirect); | ||
1143 | |||
1117 | static unsigned int ip6_default_advmss(const struct dst_entry *dst) | 1144 | static unsigned int ip6_default_advmss(const struct dst_entry *dst) |
1118 | { | 1145 | { |
1119 | struct net_device *dev = dst->dev; | 1146 | struct net_device *dev = dst->dev; |