Results 1 to 6 of 6
Hi,
Iam writing a small kernelmodule with net filters to modify a packet and send it on the wire using dev_queue_xmit().
The problem is the modification is done in an ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 04-18-2009 #1Just Joined!
- Join Date
- Jan 2009
- Posts
- 7
How to get the destination mac-address without using arp_find ()
Hi,
Iam writing a small kernelmodule with net filters to modify a packet and send it on the wire using dev_queue_xmit().
The problem is the modification is done in an asyncronous context after receiving the packet from a post routing hook. The Linux ip is informed that the packet is STOLEN and hand over the packet to an accelearator to operate on the packet data.
Before sending the packet on to the wire, i need to prepend the ethernet header to the packet. I have seen an API : arp_find (hw_addr, skb), but the description above the API in arp.c says that this is an OBSOLETE function and is recommended not to use it.
I have tried using arp_find () and it works fine, if the arp-entry is already learnt. But if there is no entry for the said IP, the kernel panics.
Is there any other way to get the destination mac-address.
Any help will be appreciated.
Thanks in advance
Narender
- 04-20-2009 #2Just Joined!
- Join Date
- Jan 2009
- Posts
- 7
Hi All,
Any updates or views on the issue.
- 04-24-2009 #3Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 10,143
I don't know if you can make a call to gethostbyname() to resolve the IP address in kernel module code, though there are kernel-safe versions of most of the tcp socket functions declared in <linux/syscalls.h>
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 04-25-2009 #4Just Joined!
- Join Date
- Jan 2009
- Posts
- 7
Hi Rubberman,
Thanks for the reply. But I was asking about the Mac address(ARP Entry) (How to fetch the Mac - address of the next gateway without using the API arp_find() as it is marked as OBSOLETE and not reliable) and not about Host name to IP address resolving.
Regards
Narender
- 04-25-2009 #5Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 10,143
Ah! Sorry, but I misunderstood what you were asking for. Sorry, but I don't know what the replacement function(s) for arp_find() would be. You need to do some more digging regarding that.
My ignorance aside, after some searching I find that there are two versions of arp_find() - an old version with this signature: int arp_find (unsigned char *, unsigned long, struct device *dev, unsigned long);
and one in a more recent linux kernel (CentOS/RHEL 5.3, 2.6.18 kernel): int arp_find(unsigned char *haddr, struct sk_buff *skb);
Which are you using? Also, FWIW, there is an arp_ioctl() kernel function which probably will do something of what you want with the proper ioctl command and data structure passed to it.
In any case, I don't know if this version of arp_find() is deprecated or not. I haven't been able to dig up enough data to say, but it should give you some leads in your search.
Remember, Google is your friend!Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!
- 02-16-2012 #6Just Joined!
- Join Date
- Feb 2012
- Posts
- 1
How to get the destination mac-address without using arp_find ()
Hello Narender, its very old post but am going through a similar situation, where i would like to get mac address of remote host. arp_find() retrieves mac address properly only when its entry exists in arptable. in other case encountering kernel crash.
did u solved the prob? Please post the solution if you did.


Reply With Quote

