对原始skb进行了值得修改,但对check赋初值为0后运行校验和函数就死机..
拜托大家帮我看看....自己制作了一个synack包并发送出去,是直接对原来的skb进行了修改(因为重新构造的时候一直出错死机没找出原因所以直接修改的skb)本来可以运行的但是我发现忘记把niph->check置0.所以求出来的校验和是错的,于是我就在前面加了一句置0...结果就一直死机没法再运行了
测试发现我的niph->check = 0,和 ip_fast_csum不能同时存在,,,一同时存在就死机,,不知道为什么
我用return一句句试发现运行到487行的时候死机的(代码如下), 没加check = 0时是可以正常运行的..求大家帮我看看哪里有错呀
445 struct sk_buff *nskb = NULL;
446 struct ethhdr *neth = NULL;
447 const struct iphdr *oiph = ip_hdr(oldskb);
448 struct iphdr *niph = NULL;
449 const struct tcphdr *oth = tcp_hdr(oldskb);
450 struct tcphdr *tcph = NULL;//_otcph
451 struct ethhdr *oeth = eth_hdr(oldskb);
452 int length = 0;
459 if (oth == NULL)
460 return;
461
462 nskb = oldskb; //直接改的原来的skb
463 if(!nskb){
464 printk(KERN_EMERG "the nskb is null\n");
465 return;
466 }
467
468 niph = ip_hdr(nskb);
469 tcph = (struct tcphdr *)((void *)niph + (niph->ihl << 2));
470
471 //tcp头
472 tcph->source = 47138;
473 tcph->dest = 20500;
474 tcph->seq = htonl(isn);
475 tcph->ack_seq = htonl(isn);
476 tcph->ack = 1;
477
478 //ip头我都是直接赋值的,赋的值是正确的
479
480 niph->saddr = 16777226;
481 niph->daddr = 33554442;
482 niph->check = 0;//加了这句之后就死机了ip checksum
483 niph->check = ip_fast_csum((unsigned char *)niph,niph->ihl);
485 neth = eth_hdr(nskb);
486 ether_addr_copy(neth->h_dest,oeth->h_source);
487 ether_addr_copy(neth->h_source,key->eth.dst); //这个key->eth.dst值是正确的, 运行到这就死机了
488
597 length = tcph->doff << 2;
604 tcph->check = ~tcp_v4_check(length,niph->saddr,niph->daddr,0);
605
606 nskb->ip_summed = CHECKSUM_PARTIAL;
607
608 nskb->csum_start = (unsigned char *)tcph - nskb->head;
609 nskb->csum_offset = offsetof(struct tcphdr,check);
610 nskb->pkt_type = PACKET_OTHERHOST;
页:
[1]