skb_reset_tail_pointer(skb);
        skb->tail += offset;
 }
+
+static inline unsigned long skb_tail_offset(const struct sk_buff *skb)
+{
+       return skb->tail;
+}
 #else /* NET_SKBUFF_DATA_USES_OFFSET */
 static inline unsigned char *skb_tail_pointer(const struct sk_buff *skb)
 {
        skb->tail = skb->data + offset;
 }
 
+static inline unsigned long skb_tail_offset(const struct sk_buff *skb)
+{
+       return skb->tail - skb->head;
+}
 #endif /* NET_SKBUFF_DATA_USES_OFFSET */
 
 /*
 
 
                spin_lock_irqsave(&npinfo->rx_lock, flags);
                list_for_each_entry_safe(np, tmp, &npinfo->rx_np, rx) {
+                       unsigned long tail_offset;
+
                        if (!ipv6_addr_equal(daddr, &np->local_ip.in6))
                                continue;
 
                        hdr->saddr = *saddr;
                        hdr->daddr = *daddr;
 
-                       send_skb->transport_header = send_skb->tail;
+                       tail_offset = skb_tail_offset(skb);
+                       if (tail_offset > 0xffff) {
+                               kfree_skb(send_skb);
+                               continue;
+                       }
+                       skb_set_network_header(send_skb, tail_offset);
                        skb_put(send_skb, size);
 
                        icmp6h = (struct icmp6hdr *)skb_transport_header(skb);
 
        __be16 *svlan_tci = NULL;                /* Encapsulates priority and SVLAN ID */
        __be16 *svlan_encapsulated_proto = NULL; /* packet type ID field (or len) for SVLAN tag */
        u16 queue_map;
+       unsigned long tail_offset;
 
        if (pkt_dev->nr_labels)
                protocol = htons(ETH_P_MPLS_UC);
                *vlan_encapsulated_proto = htons(ETH_P_IP);
        }
 
-       skb->network_header = skb->tail;
+       tail_offset = skb_tail_offset(skb);
+       if (tail_offset > 0xffff) {
+               kfree_skb(skb);
+               return NULL;
+       }
+       skb_set_network_header(skb, tail_offset);
        skb->transport_header = skb->network_header + sizeof(struct iphdr);
        skb_put(skb, sizeof(struct iphdr) + sizeof(struct udphdr));
        skb_set_queue_mapping(skb, queue_map);
        __be16 *svlan_tci = NULL;                /* Encapsulates priority and SVLAN ID */
        __be16 *svlan_encapsulated_proto = NULL; /* packet type ID field (or len) for SVLAN tag */
        u16 queue_map;
+       unsigned long tail_offset;
 
        if (pkt_dev->nr_labels)
                protocol = htons(ETH_P_MPLS_UC);
                *vlan_encapsulated_proto = htons(ETH_P_IPV6);
        }
 
-       skb->network_header = skb->tail;
+       tail_offset = skb_tail_offset(skb);
+       if (tail_offset > 0xffff) {
+               kfree_skb(skb);
+               return NULL;
+       }
+       skb_set_network_header(skb, tail_offset);
        skb->transport_header = skb->network_header + sizeof(struct ipv6hdr);
        skb_put(skb, sizeof(struct ipv6hdr) + sizeof(struct udphdr));
        skb_set_queue_mapping(skb, queue_map);
 
        struct igmpmsg *msg;
        struct sock *mroute_sk;
        int ret;
+       unsigned long tail_offset;
 
 #ifdef CONFIG_IP_PIMSM
        if (assert == IGMPMSG_WHOLEPKT)
 
        /* Copy the IP header */
 
-       skb->network_header = skb->tail;
+       tail_offset = skb_tail_offset(skb);
+       if (tail_offset > 0xffff) {
+               kfree_skb(skb);
+               return -EINVAL;
+       }
+       skb_set_network_header(skb, tail_offset);
        skb_put(skb, ihl);
        skb_copy_to_linear_data(skb, pkt->data, ihl);
        ip_hdr(skb)->protocol = 0;      /* Flag to the kernel this is a route add */