]> git.hungrycats.org Git - linux/commitdiff
[IPV6] Use macro for M-Flag and clean-up.
authorHideaki Yoshifuji <yoshfuji@linux-ipv6.org>
Mon, 30 Jun 2003 06:38:55 +0000 (16:38 +1000)
committerHideaki Yoshifuji <yoshfuji@linux-ipv6.org>
Mon, 30 Jun 2003 06:38:55 +0000 (16:38 +1000)
Use macro IP6_MF for the M-Flag.
Clean-up for readability (commented by <aj@dungeon.inka.de>).

include/net/ipv6.h
net/ipv6/ip6_output.c
net/ipv6/reassembly.c

index f166ef5569aafdc281d00a3846d473f4e563c859..8c11fb6a03677d9849c65f6bff7279aa2dad3b4b 100644 (file)
@@ -101,6 +101,8 @@ struct frag_hdr {
        __u32           identification;
 };
 
+#define        IP6_MF  0x0001
+
 #ifdef __KERNEL__
 
 #include <net/sock.h>
index 5ab5fa319a0520ad5978c7217e4a90c88428c0da..9edc73163d060058ccfd464d39d04ec98797cc21 100644 (file)
@@ -984,7 +984,7 @@ static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff*))
                ipv6_select_ident(skb, fh);
                fh->nexthdr = nexthdr;
                fh->reserved = 0;
-               fh->frag_off = htons(0x0001);
+               fh->frag_off = htons(IP6_MF);
                frag_id = fh->identification;
 
                first_len = skb_pagelen(skb);
@@ -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);
                                fh->nexthdr = nexthdr;
                                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;
                                frag->nh.ipv6h->payload_len = htons(frag->len - sizeof(struct ipv6hdr));
                                ip6_copy_metadata(frag, skb);
@@ -1111,7 +1113,9 @@ slow_path:
                        BUG();
                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));
 
                ptr += len;
index d7b87588434fc359109e5644fb924d4763cd9792..26cb8a0f4fee35040da2d988ae9bd068bb4553c8 100644 (file)
@@ -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));
 
        /* 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
                 * or have different end, the segment is corrupted.
                 */