Commit 704eae1f authored by Al Viro's avatar Al Viro Committed by Linus Torvalds

ip6_tunnel - endianness annotations

Convert rel_info to host-endian before calling ip6_tnl_err().
The things become much more straightforward that way.
The key observation (and the reason why that code actually
worked) is that after ip6_tnl_err() we either immediately
bailed out or had rel_info set to 0 or had it set to host-endian
and guaranteed to hit
(rel_type == ICMP_DEST_UNREACH && rel_code == ICMP_FRAG_NEEDED)
case.  So inconsistent endianness didn't really lead to bugs,
but it had been subtle and prone to breakage.  New variant is
saner and obviously safe.
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent a34c4589
...@@ -385,7 +385,7 @@ parse_tlv_tnl_enc_lim(struct sk_buff *skb, __u8 * raw) ...@@ -385,7 +385,7 @@ parse_tlv_tnl_enc_lim(struct sk_buff *skb, __u8 * raw)
static int static int
ip6_tnl_err(struct sk_buff *skb, __u8 ipproto, struct inet6_skb_parm *opt, ip6_tnl_err(struct sk_buff *skb, __u8 ipproto, struct inet6_skb_parm *opt,
int *type, int *code, int *msg, __be32 *info, int offset) int *type, int *code, int *msg, __u32 *info, int offset)
{ {
struct ipv6hdr *ipv6h = (struct ipv6hdr *) skb->data; struct ipv6hdr *ipv6h = (struct ipv6hdr *) skb->data;
struct ip6_tnl *t; struct ip6_tnl *t;
...@@ -435,7 +435,7 @@ ip6_tnl_err(struct sk_buff *skb, __u8 ipproto, struct inet6_skb_parm *opt, ...@@ -435,7 +435,7 @@ ip6_tnl_err(struct sk_buff *skb, __u8 ipproto, struct inet6_skb_parm *opt,
if ((*code) == ICMPV6_HDR_FIELD) if ((*code) == ICMPV6_HDR_FIELD)
teli = parse_tlv_tnl_enc_lim(skb, skb->data); teli = parse_tlv_tnl_enc_lim(skb, skb->data);
if (teli && teli == ntohl(*info) - 2) { if (teli && teli == *info - 2) {
tel = (struct ipv6_tlv_tnl_enc_lim *) &skb->data[teli]; tel = (struct ipv6_tlv_tnl_enc_lim *) &skb->data[teli];
if (tel->encap_limit == 0) { if (tel->encap_limit == 0) {
if (net_ratelimit()) if (net_ratelimit())
...@@ -452,7 +452,7 @@ ip6_tnl_err(struct sk_buff *skb, __u8 ipproto, struct inet6_skb_parm *opt, ...@@ -452,7 +452,7 @@ ip6_tnl_err(struct sk_buff *skb, __u8 ipproto, struct inet6_skb_parm *opt,
} }
break; break;
case ICMPV6_PKT_TOOBIG: case ICMPV6_PKT_TOOBIG:
mtu = ntohl(*info) - offset; mtu = *info - offset;
if (mtu < IPV6_MIN_MTU) if (mtu < IPV6_MIN_MTU)
mtu = IPV6_MIN_MTU; mtu = IPV6_MIN_MTU;
t->dev->mtu = mtu; t->dev->mtu = mtu;
...@@ -478,12 +478,12 @@ out: ...@@ -478,12 +478,12 @@ out:
static int static int
ip4ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, ip4ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
int type, int code, int offset, __u32 info) int type, int code, int offset, __be32 info)
{ {
int rel_msg = 0; int rel_msg = 0;
int rel_type = type; int rel_type = type;
int rel_code = code; int rel_code = code;
__u32 rel_info = info; __u32 rel_info = ntohl(info);
int err; int err;
struct sk_buff *skb2; struct sk_buff *skb2;
struct iphdr *eiph; struct iphdr *eiph;
...@@ -564,10 +564,9 @@ ip4ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, ...@@ -564,10 +564,9 @@ ip4ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
goto out; goto out;
skb2->dst->ops->update_pmtu(skb2->dst, rel_info); skb2->dst->ops->update_pmtu(skb2->dst, rel_info);
rel_info = htonl(rel_info);
} }
icmp_send(skb2, rel_type, rel_code, rel_info); icmp_send(skb2, rel_type, rel_code, htonl(rel_info));
out: out:
kfree_skb(skb2); kfree_skb(skb2);
...@@ -576,12 +575,12 @@ out: ...@@ -576,12 +575,12 @@ out:
static int static int
ip6ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt, ip6ip6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
int type, int code, int offset, __u32 info) int type, int code, int offset, __be32 info)
{ {
int rel_msg = 0; int rel_msg = 0;
int rel_type = type; int rel_type = type;
int rel_code = code; int rel_code = code;
__u32 rel_info = info; __u32 rel_info = ntohl(info);
int err; 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,
......
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