Commit 77552cfa authored by Xin Long's avatar Xin Long Committed by David S. Miller

ip6_tunnel: clean up ip4ip6 and ip6ip6's err_handlers

This patch is to remove some useless codes of redirect and fix some
indents on ip4ip6 and ip6ip6's err_handlers.

Note that redirect icmp packet is already processed in ip6_tnl_err,
the old redirect codes in ip4ip6_err actually never worked even
before this patch. Besides, there's no need to send redirect to
user's sk, it's for lower dst, so just remove it in this patch.
Signed-off-by: default avatarXin Long <lucien.xin@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent b00f5432
...@@ -563,13 +563,12 @@ static int ...@@ -563,13 +563,12 @@ static int
ip4ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, ip4ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
u8 type, u8 code, int offset, __be32 info) u8 type, u8 code, int offset, __be32 info)
{ {
int rel_msg = 0;
u8 rel_type = type;
u8 rel_code = code;
__u32 rel_info = ntohl(info); __u32 rel_info = ntohl(info);
int err;
struct sk_buff *skb2;
const struct iphdr *eiph; const struct iphdr *eiph;
struct sk_buff *skb2;
int err, rel_msg = 0;
u8 rel_type = type;
u8 rel_code = code;
struct rtable *rt; struct rtable *rt;
struct flowi4 fl4; struct flowi4 fl4;
...@@ -594,10 +593,6 @@ ip4ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, ...@@ -594,10 +593,6 @@ ip4ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
rel_type = ICMP_DEST_UNREACH; rel_type = ICMP_DEST_UNREACH;
rel_code = ICMP_FRAG_NEEDED; rel_code = ICMP_FRAG_NEEDED;
break; break;
case NDISC_REDIRECT:
rel_type = ICMP_REDIRECT;
rel_code = ICMP_REDIR_HOST;
/* fall through */
default: default:
return 0; return 0;
} }
...@@ -616,33 +611,26 @@ ip4ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, ...@@ -616,33 +611,26 @@ ip4ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
eiph = ip_hdr(skb2); eiph = ip_hdr(skb2);
/* Try to guess incoming interface */ /* Try to guess incoming interface */
rt = ip_route_output_ports(dev_net(skb->dev), &fl4, NULL, rt = ip_route_output_ports(dev_net(skb->dev), &fl4, NULL, eiph->saddr,
eiph->saddr, 0, 0, 0, 0, IPPROTO_IPIP, RT_TOS(eiph->tos), 0);
0, 0,
IPPROTO_IPIP, RT_TOS(eiph->tos), 0);
if (IS_ERR(rt)) if (IS_ERR(rt))
goto out; goto out;
skb2->dev = rt->dst.dev; skb2->dev = rt->dst.dev;
ip_rt_put(rt);
/* route "incoming" packet */ /* route "incoming" packet */
if (rt->rt_flags & RTCF_LOCAL) { if (rt->rt_flags & RTCF_LOCAL) {
ip_rt_put(rt);
rt = NULL;
rt = ip_route_output_ports(dev_net(skb->dev), &fl4, NULL, rt = ip_route_output_ports(dev_net(skb->dev), &fl4, NULL,
eiph->daddr, eiph->saddr, eiph->daddr, eiph->saddr, 0, 0,
0, 0, IPPROTO_IPIP, RT_TOS(eiph->tos), 0);
IPPROTO_IPIP, if (IS_ERR(rt) || rt->dst.dev->type != ARPHRD_TUNNEL) {
RT_TOS(eiph->tos), 0);
if (IS_ERR(rt) ||
rt->dst.dev->type != ARPHRD_TUNNEL) {
if (!IS_ERR(rt)) if (!IS_ERR(rt))
ip_rt_put(rt); ip_rt_put(rt);
goto out; goto out;
} }
skb_dst_set(skb2, &rt->dst); skb_dst_set(skb2, &rt->dst);
} else { } else {
ip_rt_put(rt);
if (ip_route_input(skb2, eiph->daddr, eiph->saddr, eiph->tos, if (ip_route_input(skb2, eiph->daddr, eiph->saddr, eiph->tos,
skb2->dev) || skb2->dev) ||
skb_dst(skb2)->dev->type != ARPHRD_TUNNEL) skb_dst(skb2)->dev->type != ARPHRD_TUNNEL)
...@@ -654,10 +642,9 @@ ip4ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, ...@@ -654,10 +642,9 @@ ip4ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
if (rel_info > dst_mtu(skb_dst(skb2))) if (rel_info > dst_mtu(skb_dst(skb2)))
goto out; goto out;
skb_dst(skb2)->ops->update_pmtu(skb_dst(skb2), NULL, skb2, rel_info); skb_dst(skb2)->ops->update_pmtu(skb_dst(skb2), NULL, skb2,
rel_info);
} }
if (rel_type == ICMP_REDIRECT)
skb_dst(skb2)->ops->redirect(skb_dst(skb2), NULL, skb2);
icmp_send(skb2, rel_type, rel_code, htonl(rel_info)); icmp_send(skb2, rel_type, rel_code, htonl(rel_info));
...@@ -670,11 +657,10 @@ static int ...@@ -670,11 +657,10 @@ static int
ip6ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, ip6ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
u8 type, u8 code, int offset, __be32 info) u8 type, u8 code, int offset, __be32 info)
{ {
int rel_msg = 0; __u32 rel_info = ntohl(info);
int err, rel_msg = 0;
u8 rel_type = type; u8 rel_type = type;
u8 rel_code = code; u8 rel_code = code;
__u32 rel_info = ntohl(info);
int err;
err = ip6_tnl_err(skb, IPPROTO_IPV6, opt, &rel_type, &rel_code, err = ip6_tnl_err(skb, IPPROTO_IPV6, opt, &rel_type, &rel_code,
&rel_msg, &rel_info, offset); &rel_msg, &rel_info, offset);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment