ref: 934d81ae4e55fb48f7d15ee7302d455f3ba33a82
parent: 8a1c1c951066705b98b417f26eebcb293e3b549d
author: cinap_lenrek <[email protected]>
date: Sun Jul 23 18:22:09 EDT 2023
devip: add gratious arp ctl message to /net/arp writing "garp <ip>" will send a gratious arp for the provided ip address (if it can be found on any interface).
--- a/sys/src/9/ip/arp.c
+++ b/sys/src/9/ip/arp.c
@@ -501,9 +501,9 @@
}
runlock(ifc);
} else if(strcmp(f[0], "del") == 0){
- if (n != 2)
+ if(n != 2)
error(Ebadarg);
- if (parseip(ip, f[1]) == -1)
+ if(parseip(ip, f[1]) == -1)
error(Ebadip);
wlock(arp);
for(a = arp->hash[hashipa(ip)]; a != nil; a = x){
@@ -512,6 +512,26 @@
cleanarpent(arp, a);
}
wunlock(arp);
+ } else if(strcmp(f[0], "garp") == 0){
+ Iplifc *lifc;
+
+ if(n != 2)
+ error(Ebadarg);
+ if(parseip(ip, f[1]) == -1)
+ error(Ebadip);
+
+ if((ifc = findipifc(fs, ip, ip, Runi)) == nil)
+ error("no interface");
+
+ rlock(ifc);
+ if(waserror()){
+ runlock(ifc);
+ nexterror();
+ }
+ if(ifc->m != nil && ifc->m->areg != nil && (lifc = iplocalonifc(ifc, ip)) != nil)
+ (*ifc->m->areg)(fs, ifc, lifc, ip);
+ runlock(ifc);
+ poperror();
} else
error(Ebadarp);