SIOCSARP auto resolve
Subsystems (2)
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.
linux/if_arp.h +0 -0
@@ -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.
ipv4/arp.c +12 -7
@@ -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;