netfilter_ops_out.hook = main_hook2;//исходящий netfilter_ops_out.pf = PF_INET; netfilter_ops_out.hooknum = 3; netfilter_ops_out.priority = NF_IP_PRI_FIRST; ---------------------------------------------------- struct tcphdr *tcph = (struct tcphdr *)(skb_network_header((skb)) + ip_hdrlen((skb))); struct iphdr *iph = (struct iphdr *)skb_network_header(skb); ---------------------------------------------------- if (iph->protocol == IPPROTO_TCP) { printk(KERN_ALERT "----------------ИСХОДЯЩИЙ ПАКЕТ TCP---------------------\n"); printk(KERN_ALERT "INFO: CHECKSUM IP old: %u.\n",iph->check); iph->daddr=in_aton("192.168.245.133"); iph->check = 0; ip_send_check(iph); printk(KERN_ALERT "INFO: CHECKSUM IP new: %u.\n",iph->check); printk(KERN_ALERT "----------------------------------------------------\n"); printk(KERN_ALERT "INFO: CHECKSUM TCP old: %u.\n",tcph->check); datalen = skb->len - (iph->ihl << 2); tcph->check = 0; tcph->check =csum_tcpudp_magic(iph->saddr, iph->daddr,datalen, iph->protocol,csum_partial((char *)tcph, datalen, 0)); Wireshark on Windows shows all the time the wrong checksum tcp package. On foreign stackoverflow, everyone works, after skb-> ip_summed = CHECKSUM_UNNECESSARY; at the end of the checksum calculation. BUT! The checksum is wrong ..
UPD: Initially I checked it like this: tritely recalculated the checksum of the outgoing tcp packet from a Linux machine to Windows. TCP offloading is enabled on Windows, turned off on linux.
linux/net/netfilter/nf_nat_proto_tcp.cdoesn't work? - Mike