All,
 
I am trying to develop a customized NAT app based on netfilter framework. I have:
    a. Created a module
    b. Initialized and registered with netfilter
    c. Got sk_buff from the core
 
Currently, the program is very simple: just changes the receiver IP address (pre-routing)
and sender IP address (post-routing), and then forward the packets.
 
Everything worked fine except that after the packets forwarded to the destination, the
reading program on the destination machine reported reading error (-1), and errno 11
(don't know the reason).
 
After changed the IP address, I did recalculated the checksum, as follows (copied
from ip_nat_core.c):
 
            saddr = <the address to be changed to>;
            iph->check = ip_nat_cheat_check(~iph->saddr, saddr, iph->check);
            iph->saddr = saddr;
I did rechecked the checksum and it appeared to be good.
 
Having searched answers from the Internet and digged the code without results, I hope
someone here can help me out. I guess I must have messed up the packets.
 
For your information, I have attached the tiny source code at the end of this email.
 
Your help is most appreciated!!!
 
 
Chen Ding