Commit cc991563 authored by Hideaki Yoshifuji's avatar Hideaki Yoshifuji

[IPV6] Use macro for M-Flag and clean-up.

Use macro IP6_MF for the M-Flag.
Clean-up for readability (commented by <aj@dungeon.inka.de>).
parent 931aac84
...@@ -101,6 +101,8 @@ struct frag_hdr { ...@@ -101,6 +101,8 @@ struct frag_hdr {
__u32 identification; __u32 identification;
}; };
#define IP6_MF 0x0001
#ifdef __KERNEL__ #ifdef __KERNEL__
#include <net/sock.h> #include <net/sock.h>
......
...@@ -984,7 +984,7 @@ static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff*)) ...@@ -984,7 +984,7 @@ static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff*))
ipv6_select_ident(skb, fh); ipv6_select_ident(skb, fh);
fh->nexthdr = nexthdr; fh->nexthdr = nexthdr;
fh->reserved = 0; fh->reserved = 0;
fh->frag_off = htons(0x0001); fh->frag_off = htons(IP6_MF);
frag_id = fh->identification; frag_id = fh->identification;
first_len = skb_pagelen(skb); first_len = skb_pagelen(skb);
...@@ -1004,7 +1004,9 @@ static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff*)) ...@@ -1004,7 +1004,9 @@ static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff*))
offset += skb->len - hlen - sizeof(struct frag_hdr); offset += skb->len - hlen - sizeof(struct frag_hdr);
fh->nexthdr = nexthdr; fh->nexthdr = nexthdr;
fh->reserved = 0; fh->reserved = 0;
fh->frag_off = htons(offset | (frag->next != NULL ? 0x0001 : 0)); fh->frag_off = htons(offset);
if (frag->next != NULL)
fh->frag_off |= htons(IP6_MF);
fh->identification = frag_id; fh->identification = frag_id;
frag->nh.ipv6h->payload_len = htons(frag->len - sizeof(struct ipv6hdr)); frag->nh.ipv6h->payload_len = htons(frag->len - sizeof(struct ipv6hdr));
ip6_copy_metadata(frag, skb); ip6_copy_metadata(frag, skb);
...@@ -1111,7 +1113,9 @@ static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff*)) ...@@ -1111,7 +1113,9 @@ static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff*))
BUG(); BUG();
left -= len; left -= len;
fh->frag_off = htons( left > 0 ? (offset | 0x0001) : offset); fh->frag_off = htons(offset);
if (left > 0)
fh->frag_off |= htons(IP6_MF);
frag->nh.ipv6h->payload_len = htons(frag->len - sizeof(struct ipv6hdr)); frag->nh.ipv6h->payload_len = htons(frag->len - sizeof(struct ipv6hdr));
ptr += len; ptr += len;
......
...@@ -435,7 +435,7 @@ static void ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb, ...@@ -435,7 +435,7 @@ static void ip6_frag_queue(struct frag_queue *fq, struct sk_buff *skb,
csum_partial(skb->nh.raw, (u8*)(fhdr+1)-skb->nh.raw, 0)); csum_partial(skb->nh.raw, (u8*)(fhdr+1)-skb->nh.raw, 0));
/* Is this the final fragment? */ /* Is this the final fragment? */
if (!(fhdr->frag_off & htons(0x0001))) { if (!(fhdr->frag_off & htons(IP6_MF))) {
/* If we already have some bits beyond end /* If we already have some bits beyond end
* or have different end, the segment is corrupted. * or have different end, the segment is corrupted.
*/ */
......
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