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:
Remark:
dev_queue_xmit
if I had the
destination mac address. So the code building the skb is not an
issue.If you still want to use ip_local_out
or ip_queue_xmit
, then you can create your flowinfo like this.
struct flowi4 fl4 = {
.flowi4_oif = skb->dev->ifindex,
.daddr = iph->daddr,
.saddr = iph->saddr,
};
then create dst(rtable) with
ip_route_output_key
set to skb_buff with
skb_dst_set
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With