Find the answer to your Linux question:
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.
  1. #1
    Just 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

  2. #2
    Just Joined!
    Join Date
    Jan 2009
    Posts
    7
    Hi All,
    Any updates or views on the issue.

  3. #3
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,665
    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!

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined!
    Join Date
    Jan 2009
    Posts
    7
    Quote Originally Posted by Rubberman View Post
    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>
    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

  6. #5
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,665
    Quote Originally Posted by narender View Post
    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.
    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!

  7. #6
    Just Joined!
    Join Date
    Feb 2012
    Posts
    1

    How to get the destination mac-address without using arp_find ()

    Quote Originally Posted by narender View Post
    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
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •