I am writing a kernel module that uses Netfilter bindings to change some of the TCP header information, and obviously, before sending, I want to recalculate the checksum.
I also edit the header on the receiving side, so I need to calculate it again there.
Searching the Internet, I found that some people say that I can just set it to 0, and it will be calculated for me, apparently this did not work.
I also found this feature
tcp_v4_send_check(struct sock *sk, struct sk_buff *skb);
Although no one has explained how this is used, and whether I can actually use it when receiving / sending in the same way.
My own attempt was to set the checksum to 0, then call this function, passing skb, which I have, and skb-> sk, I have, nothing else.
So please, what is a simple way to calculate the checksum of TCP datagrams?
Fingolfin
source share