public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Cosmin Ratiu <cratiu@ixiacom•com>
To: netdev@vger•kernel.org
Subject: SIOCSARP auto resolve
Date: Mon, 13 Apr 2009 20:41:45 +0300	[thread overview]
Message-ID: <49E37959.7030502@ixiacom.com> (raw)

Hello,

Is there a way to make the kernel send an ARP request from a user space 
program?

If not, then I'd like to hear your opinions on the patch below, which 
extends SIOCSARP with a flag ATF_AUTORESOLVE that when set, will send 
out an ARP request instead of adding an entry to the cache.

Thanks,
Cosmin.


--- include/linux/if_arp.h
+++ include/linux/if_arp.h
@@ -124,6 +124,7 @@
 #define ATF_NETMASK     0x20            /* want to use a netmask (only
                                           for proxy entries) */
 #define ATF_DONTPUB    0x40            /* don't answer this addresses  */
+#define ATF_AUTORESOLVE        0x80            /* send ARP request 
instead     */
 
 /*
  *     This structure defines an ethernet arp header.
--- net/ipv4/arp.c
+++ net/ipv4/arp.c
@@ -1028,13 +1028,18 @@
        neigh = __neigh_lookup_errno(&arp_tbl, &ip, dev);
        err = PTR_ERR(neigh);
        if (!IS_ERR(neigh)) {
-               unsigned state = NUD_STALE;
-               if (r->arp_flags & ATF_PERM)
-                       state = NUD_PERMANENT;
-               err = neigh_update(neigh, (r->arp_flags&ATF_COM) ?
-                                  r->arp_ha.sa_data : NULL, state,
-                                  NEIGH_UPDATE_F_OVERRIDE|
-                                  NEIGH_UPDATE_F_ADMIN);
+               if (r->arp_flags & ATF_AUTORESOLVE) {
+                       neigh_event_send(neigh, NULL);
+                       err = 0;
+               } else {
+                       unsigned state = NUD_STALE;
+                       if (r->arp_flags & ATF_PERM)
+                               state = NUD_PERMANENT;
+                       err = neigh_update(neigh, (r->arp_flags&ATF_COM) ?
+                                          r->arp_ha.sa_data : NULL, state,
+                                          NEIGH_UPDATE_F_OVERRIDE|
+                                          NEIGH_UPDATE_F_ADMIN);
+               }
                neigh_release(neigh);
        }
        return err;


                 reply	other threads:[~2009-04-13 17:41 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=49E37959.7030502@ixiacom.com \
    --to=cratiu@ixiacom$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox