Commit 6df6efbb authored by Hideaki Yoshifuji's avatar Hideaki Yoshifuji Committed by James Morris

[IPV6] use macro for maximum payload length

parent 2a7dd335
...@@ -23,6 +23,8 @@ ...@@ -23,6 +23,8 @@
#define SIN6_LEN_RFC2133 24 #define SIN6_LEN_RFC2133 24
#define IPV6_MAXPLEN 65535
/* /*
* NextHeader field of IPv6 header * NextHeader field of IPv6 header
*/ */
......
...@@ -432,7 +432,7 @@ static int ipv6_hop_jumbo(struct sk_buff *skb, int optoff) ...@@ -432,7 +432,7 @@ static int ipv6_hop_jumbo(struct sk_buff *skb, int optoff)
} }
pkt_len = ntohl(*(u32*)(skb->nh.raw+optoff+2)); pkt_len = ntohl(*(u32*)(skb->nh.raw+optoff+2));
if (pkt_len < 0x10000) { if (pkt_len <= IPV6_MAXPLEN) {
icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, optoff+2); icmpv6_param_prob(skb, ICMPV6_HDR_FIELD, optoff+2);
return 0; return 0;
} }
......
...@@ -621,7 +621,7 @@ int ip6_build_xmit(struct sock *sk, inet_getfrag_t getfrag, const void *data, ...@@ -621,7 +621,7 @@ int ip6_build_xmit(struct sock *sk, inet_getfrag_t getfrag, const void *data,
if (opt) if (opt)
pktlength += opt->opt_flen + opt->opt_nflen; pktlength += opt->opt_flen + opt->opt_nflen;
if (pktlength > 0xFFFF + sizeof(struct ipv6hdr)) { if (pktlength > sizeof(struct ipv6hdr) + IPV6_MAXPLEN) {
/* Jumbo datagram. /* Jumbo datagram.
It is assumed, that in the case of hdrincl It is assumed, that in the case of hdrincl
jumbo option is supplied by user. jumbo option is supplied by user.
...@@ -1264,8 +1264,8 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to, int offse ...@@ -1264,8 +1264,8 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to, int offse
fragheaderlen = sizeof(struct ipv6hdr) + (opt ? opt->opt_nflen : 0); fragheaderlen = sizeof(struct ipv6hdr) + (opt ? opt->opt_nflen : 0);
maxfraglen = ((mtu - fragheaderlen) & ~7) + fragheaderlen - sizeof(struct frag_hdr); maxfraglen = ((mtu - fragheaderlen) & ~7) + fragheaderlen - sizeof(struct frag_hdr);
if (mtu < 65576) { if (mtu <= sizeof(struct ipv6hdr) + IPV6_MAXPLEN) {
if (inet->cork.length + length > 0xFFFF - fragheaderlen) { if (inet->cork.length + length > IPV6_MAXPLEN - fragheaderlen) {
ipv6_local_error(sk, EMSGSIZE, fl, mtu-exthdrlen); ipv6_local_error(sk, EMSGSIZE, fl, mtu-exthdrlen);
return -EMSGSIZE; return -EMSGSIZE;
} }
...@@ -1461,7 +1461,7 @@ int ip6_push_pending_frames(struct sock *sk) ...@@ -1461,7 +1461,7 @@ int ip6_push_pending_frames(struct sock *sk)
*(u32*)hdr = fl->fl6_flowlabel | htonl(0x60000000); *(u32*)hdr = fl->fl6_flowlabel | htonl(0x60000000);
if (skb->len < 65536) if (skb->len <= IPV6_MAXPLEN)
hdr->payload_len = htons(skb->len - sizeof(struct ipv6hdr)); hdr->payload_len = htons(skb->len - sizeof(struct ipv6hdr));
else else
hdr->payload_len = 0; hdr->payload_len = 0;
......
...@@ -425,7 +425,7 @@ static void ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb, ...@@ -425,7 +425,7 @@ static void ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb,
end = offset + (ntohs(skb->nh.ipv6h->payload_len) - end = offset + (ntohs(skb->nh.ipv6h->payload_len) -
((u8 *) (fhdr + 1) - (u8 *) (skb->nh.ipv6h + 1))); ((u8 *) (fhdr + 1) - (u8 *) (skb->nh.ipv6h + 1)));
if ((unsigned int)end >= 65536) { if ((unsigned int)end > IPV6_MAXPLEN) {
icmpv6_param_prob(skb,ICMPV6_HDR_FIELD, (u8*)&fhdr->frag_off - skb->nh.raw); icmpv6_param_prob(skb,ICMPV6_HDR_FIELD, (u8*)&fhdr->frag_off - skb->nh.raw);
return; return;
} }
...@@ -597,7 +597,7 @@ static int ip6_frag_reasm(struct frag_queue *fq, struct sk_buff **skb_in, ...@@ -597,7 +597,7 @@ static int ip6_frag_reasm(struct frag_queue *fq, struct sk_buff **skb_in,
/* Unfragmented part is taken from the first segment. */ /* Unfragmented part is taken from the first segment. */
payload_len = (head->data - head->nh.raw) - sizeof(struct ipv6hdr) + fq->len - sizeof(struct frag_hdr); payload_len = (head->data - head->nh.raw) - sizeof(struct ipv6hdr) + fq->len - sizeof(struct frag_hdr);
if (payload_len > 65535) if (payload_len > IPV6_MAXPLEN)
goto out_oversize; goto out_oversize;
/* Head of list must not be cloned. */ /* Head of list must not be cloned. */
......
...@@ -606,13 +606,13 @@ static inline unsigned int ipv6_advmss(unsigned int mtu) ...@@ -606,13 +606,13 @@ static inline unsigned int ipv6_advmss(unsigned int mtu)
mtu = ip6_rt_min_advmss; mtu = ip6_rt_min_advmss;
/* /*
* Maximal non-jumbo IPv6 payload is 65535 and * Maximal non-jumbo IPv6 payload is IPV6_MAXPLEN and
* corresponding MSS is 65535 - tcp_header_size. * corresponding MSS is IPV6_MAXPLEN - tcp_header_size.
* 65535 is also valid and means: "any MSS, * IPV6_MAXPLEN is also valid and means: "any MSS,
* rely only on pmtu discovery" * rely only on pmtu discovery"
*/ */
if (mtu > 65535 - sizeof(struct tcphdr)) if (mtu > IPV6_MAXPLEN - sizeof(struct tcphdr))
mtu = 65535; mtu = IPV6_MAXPLEN;
return mtu; return mtu;
} }
......
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