Here is how you recalculate ip and tcp checksums if your netfilter kernel module tinkers with packets.
TCP->
len = skb->len;
th->check = 0;
th->check = tcp_v4_check(len - 4*iph->ihl,
iph->saddr, iph->daddr,
csum_partial((char *)th, len-4*iph->ihl,
0));
IP->
iph->check = 0;
iph->check = ip_fast_csum((u8 *)iph, iph->ihl);
Friendship
3 months ago