阅读:1592回复:2
ip hook问题(20分)
linux在ip层有ip hook,总共有5个地方可以hook:NF_IP_PRE_ROUTING,NF_IP_LOCAL_IN,NF_IP_LOCAL_OUT,NF_IP_POST_ROUTING,NF_IP_FORWARD。我在NF_IP_LOCAL_IN和NF_IP_LOCAL_OUT两个地方各register了一个hook,然后会有struct skb_buf **skb传给我处理,对于每一个数据包我需要修改(*skb)->data和(*skb)->data所指向的数据。在机子上运行时正常工作,可是有时会系统崩溃,其中一次崩溃后提示信息大致如下:
EIP is at skb_under_panic [kernel] 0x38 (2.4.20-8) call Trace: ip_finish_output2 [kernel] 0xa4 ip_finish_output2 [kernel] 0x98 ip_mc_output [kernel] 0xfd nf_iterate [kernel] 0x54 output_maybe_reroute [kernel] 0x10 nf_hook_slow [kernel] 0xb3 output_may_reroute [kernel] 0x0 udp_sendmsg [kernel] 0x255 udp_getfrag [kernel] 0x0 inet_sendmsg [kernel] 0x42 sock_sendmsg [kernel] 0x78 sys_sendto [kernel] 0xe3 poll_freewait [kernel] 0x44 do_select [kernel] 0x133 sys_socketcall [kernel] 0x199 system_call [kernel] 0x33 kernel panic: Aiee killing interrupt handler In interrupt handler - not syncing 我检查了一下udp的发送部分也专门针对它测试过都没有问题的,哎,内核崩溃,烦死我了。我只能给20分了--论坛只允许我放20分 谢谢各位的帮助 |
|
沙发#
发布于:2004-06-17 18:17
unsigned int
send_our_tcp_packet(struct sk_buff **skb) { unsigned char *old_data; unsigned char *old_head; struct tcphdr *tcp_header; // point to the old packet tcp header. struct iphdr *ip_header; // point to the old packet ip header. old_data = (*skb)->data; old_head = (*skb)->head; if((old_data==NULL)||(old_head==NULL)) return NF_ACCEPT; ip_header = (struct iphdr*)old_data; tcp_header = (struct tcphdr*)((char *)ip_header + ip_header->ihl*4); if(((*skb)->data - (*skb)->head) > sizeof(struct tcphdr)) { // (*skb)->len += sizeof(struct tcphdr); // (*skb)->data -= sizeof(struct tcphdr); skb_push(*skb, sizeof(struct tcphdr));//等价于上面被注释掉的两行 memmove((void*)(*skb)->data, (void*)old_data,// 等价于复制了tcp头,有两个tcp头 ip_header->ihl*4 + sizeof(struct tcphdr)); ip_header = (struct iphdr*)(*skb)->data; // point to new packet. tcp_header = (struct tcphdr*)((*skb)->data + ip_header->ihl*4); (*skb)->nh.iph = ip_header; (*skb)->h.th = tcp_header; ip_header->tot_len = htons(ntohs(ip_header->tot_len) + sizeof(struct tcphdr)); tcp_header->dest = htons(WEB_PORT); tcp_header->doff = 0x05; tcp_header->urg_ptr = 0; return NF_ACCEPT; } return NF_ACCEPT; // Finished repackaging. } 该函数在nf_ip_local_out例程中被调用,一旦进入if内部执行就会内核崩溃,出现上贴中的信息 [编辑 - 6/18/04 by nicklezhang] |
|
板凳#
发布于:2004-06-18 15:31
现在的问题是跑了十来个小时结果当机,真他令堂的,搞死我了!!!有的时候几个小时即当机
|
|