* SIOCSARP auto resolve
@ 2009-04-13 17:41 Cosmin Ratiu
0 siblings, 0 replies; only message in thread
From: Cosmin Ratiu @ 2009-04-13 17:41 UTC (permalink / raw)
To: netdev
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;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-04-13 17:41 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-13 17:41 SIOCSARP auto resolve Cosmin Ratiu
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.