Hello there,<br><br>I need to mangle rtp packets in kernel space. So far I am new in kernel module programming. I am trying to implement a module for netfilter hooks. For the first time as exercise, I am trying to write smaller modules. Let me explain what I am actually doing now.<br>
<br>I have an echo client and server. The server runs on port 6000. Both are on different machines (May be VMs in bridge filter mode). The client sends udp message and the server just echoes it back. Let us suppose the client sends &quot;some message&quot; as data. Then now I am trying to write a module for the client machine that will append &quot;12345&quot; after the data so that the server will get &quot;some message12345&quot; and echo it back. Now there are various things I did faced. I relied on the NF_IP_POST_ROUTING hook.<br>
<br>At first, I copied the data to a temporary storage, and then add 12345 with that. Then I increase skb-&gt;tail using skb_put(). Then I memset()  0 to the packet data, and copy the temporary storage with that. Then as the procedure, NF_ACCEPT is returned. There are certain checking points like the udph-&gt;dest == 6000 etc. etc. When I use skb_put(), my system hangs out after two or three minutes. When I dmesg to be certain that everything goes right, I find it OK. But, suppose once I send a message like &quot;This is a pretty big message&quot; and another time I send &quot;small message&quot; then I get just &quot;small message12345g message&quot; that means, the bigger message is stored somewhere I don&#39;t understand. I tried with skb_add_data() but that works incorrectly here, I understand it&#39;s my fault. I just can&#39;t figure it out.<br>
<br>Now, one thing came in my mind, if it&#39;s not possible, should I create new packets for that data appending? I find skb-&gt;end - skb-&gt;tail is not so big. But ultimately I have to merge two or three packets into one packet and then skb_put() will not suffice for me. Then the point comes, I can use alloc_skb(), skb_reserve(), skb_header_pointer() and other skb manipulation functions, but I don&#39;t understand how can I drop the packet got (should I return NF_DROP?) and how can I route my created packets in the packet flowing path? I saw in the xtables_addons for help (file xt_ECHO.c) but found they used ip_route_me_harder() for it. But the function they used is quite different, it is their own. Then I need suggestions about how to route the newly created packet in kernel space. This is the point I am stuck for a few days. If anyone can help me, I will be highly grateful. I understand my knowledge is poor about Linux kernel, but I need a definite way to understand, otherwise the code is not helping me much. <br>
<br>Thanks in advance.<br clear="all"> <br>-- <br>Rifat Rahman<div><br></div><br>