0
votes

This is 2 example: How to append data on a packet from kernel space? How to route the splitted packets using netfilter hooks in kernel space I just want change data coming server at hook LOCAL_IN, this is similar spllitted example. At append data example, that is ok. But splitted example, that is not work. I think problem is update length, checksum udp,ip packet(example: the value offset in calculating checksum at hook LOCAL_IN and LOCAL_OUT is different( int offset = skb_transport_offset(skb)) because when a packet goes in, packet is processed before go to udp layer).I try to alter htons -> ntohs but that is not work.

Anyone have idea to solve? Thanks

1

1 Answers

0
votes

the problem is different function checksum. In side sender, when you update udp checksum at hook(POST_ROUTING or LOCAL_OUT), checksum just for pseudo header, not include udp datagrams.

In side receiver, when you updata udp checksum at hook(PRE_ROUTING or LOCAL_IN), checksum must include pseudo header+udp datagrams.