转:http://blog.csdn.net/nerdx/article/details/12717817
-
-
-
-
-
-
-
-
-
-
-
-
1.1 static struct sk_buff *ip_frag_reasm(struct ipq *qp, struct net_device *dev)
-
{
-
struct iphdr *iph;
-
struct sk_buff *fp, *head = qp->fragments;
-
int len;
-
int ihlen;
-
-
ipq_kill(qp);
-
-
-
-
ihlen = head->nh.iph->ihl*4;
-
-
len = ihlen + qp->len;
-
-
if(len > 65535)
-
goto out_oversize;
-
-
-
-
-
if (skb_cloned(head) && pskb_expand_head(head, 0, 0, GFP_ATOMIC))
-
goto out_nomem;
-
-
-
-
-
-
-
if (skb_shinfo(head)->frag_list) {
-
struct sk_buff *clone;
-
int i, plen = 0;
-
-
if ((clone = alloc_skb(0, GFP_ATOMIC)) == NULL)
-
goto out_nomem;
-
clone->next = head->next;
-
head->next = clone;
-
skb_shinfo(clone)->frag_list = skb_shinfo(head)->frag_list;
-
skb_shinfo(head)->frag_list = NULL;
-
for (i=0; inr_frags; i++)
-
plen += skb_shinfo(head)->frags[i].size;
-
clone->len = clone->data_len = head->data_len - plen;
-
head->data_len -= clone->len;
-
head->len -= clone->len;
-
clone->csum = 0;
-
clone->ip_summed = head->ip_summed;
-
atomic_add(clone->truesize, &ip_frag_mem);
-
}
-
-
-
-
skb_shinfo(head)->frag_list = head->next;
-
skb_push(head, head->data - head->nh.raw);
-
atomic_sub(head->truesize, &ip_frag_mem);
-
-
-
for (fp=head->next; fp; fp = fp->next) {
-
head->data_len += fp->len;
-
head->len += fp->len;
-
if (head->ip_summed != fp->ip_summed)
-
head->ip_summed = CHECKSUM_NONE;
-
else if (head->ip_summed == CHECKSUM_HW)
-
head->csum = csum_add(head->csum, fp->csum);
-
head->truesize += fp->truesize;
-
atomic_sub(fp->truesize, &ip_frag_mem);
-
}
-
-
head->next = NULL;
-
head->dev = dev;
-
head->stamp = qp->stamp;
-
-
iph = head->nh.iph;
-
iph->frag_off = 0;
-
iph->tot_len = htons(len);
-
IP_INC_STATS_BH(IPSTATS_MIB_REASMOKS);
-
qp->fragments = NULL;
-
return head;
-
-
out_nomem:
-
NETDEBUG(if (net_ratelimit())
-
printk(KERN_ERR
-
"IP: queue_glue: no memory for gluing queue %p\n",
-
qp));
-
goto out_fail;
-
out_oversize:
-
if (net_ratelimit())
-
printk(KERN_INFO
-
"Oversized IP packet from %d.%d.%d.%d.\n",
-
NIPQUAD(qp->saddr));
-
out_fail:
-
IP_INC_STATS_BH(IPSTATS_MIB_REASMFAILS);
-
return NULL;
-
}
-
阅读(747) | 评论(0) | 转发(0) |