I want to transmit an skb that contains a valid tcp and ip header in the linux kernel. It should go out a specific interface without being routed.
My problem is, that I cannot use dev_queue_xmit
because I dont know the destination mac-address.
My attempts to find out the mac-address with arp_find
failed:
...
mh = (struct ethhdr *) skb_push(skb, sizeof(struct ethhdr));
...
arp_find(mh->h_dest, skb); //this or the next line
val = dev_queue_xmit(skb); //crashes kernel
Experiments with ip_local_out
also failed. I set the ip header information and call ip_local_out
which also results in a kernel crash.
I could not use ip_queue_xmit
because I was not able to find out, what data to provide in the struct flowi *fl
field.
So my questions:
- How can I send out an skb on a device with ip information and no knowledge about lower levels?
- If there is no answer to the first question: How can I find out the destination mac/trigger an arp request for the destination ip?
Remark:
- I would like to avoid using (raw) sockets.
- I have successfully
transmitted self-made skbs via
dev_queue_xmit
if I had the destination mac address. So the code building the skb is not an issue.