Hello,
I am working on implementing an experimental network protocol. I have
netfilter hook which changes the payload after the IP header and the
destination IP in packets with a certain protocol id. This part works.
For some packets, I need to generate an extra packet. To do this, I copy
the sk_buff, modify stuff on the copy and try sending it with
dev_queue_xmit(), then modify the original and return NF_ACCEPT. The
result is: the original get through (the one with NF_ACCEPT) but the
copy doesn't.
Here's the code for copying and sending the copy:
static void send_payload(struct sk_buff *skb, struct in_addr rloc)
{
struct iphdr *ipheader;
struct sk_buff *ccgen = skb_copy_expand(skb, 0, 0, GFP_ATOMIC);
if (!ccgen)
pr_debug("packet copy failed\n");
ipheader = ip_hdr(ccgen);
ipheader->protocol = 0xfd;
ip_send_check(ipheader);
/* Not sure if the next line is necessary */
ccgen->csum = csum_partial(ccgen->data, ccgen->len, 0);
if (dev_queue_xmit(ccgen) < 0)
pr_debug("failed to send payload\n");
}
I use skb_copy_expand to create the copy. I use the expand version,
because after I get this to work, I will have to add more payload to the
packet. First step is to change the protocol number and put the packet
on the wire.
What am I doing wrong? Why is the packet not sent?
Thanks in advance!
Regards,
Loránd Jakab
--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to [email protected]
Please read the FAQ at http://kernelnewbies.org/FAQ