ref: 3f52f47b9b698045b3948a9321264390b268b3d8
parent: 14f0eae74a9a9f5c5caebbecb11b136a12e65a22
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sat Nov 18 12:59:56 EST 2023
ip/ipconfig: allow "del" verb in addition to "remove"
--- a/sys/man/8/ipconfig
+++ b/sys/man/8/ipconfig
@@ -100,7 +100,7 @@
The verb (default
.IR add )
determines the action performed. The usual verbs are:
-.TF remove
+.TF del
.TP
.B add
if the device is not bound to the IP stack, bind it.
@@ -107,8 +107,8 @@
Add the given local address, mask, and remote address to the interface.
An interface may have multiple addresses.
.TP
-.B remove
-remove the address from the device interface.
+.B del
+delete the address from the device interface.
.TP
.B unbind
unbind the device interface and all its addresses from the
@@ -253,7 +253,7 @@
.TP
.B u
disable IPv6 duplicate discovery detection,
-which removes any existing ARP table entry for one of our IPv6 addresses
+which deletes any existing ARP table entry for one of our IPv6 addresses
before adding new ones.
.TP
.B f
@@ -309,7 +309,7 @@
If DHCP is requested, a process is forked
off to renew the lease before it
runs out. If the lease does run out, this
-process will remove any configured addresses
+process will delete any configured addresses
from the interface.
.PP
.I Rip
--- a/sys/src/cmd/ip/ipconfig/ipconfig.h
+++ b/sys/src/cmd/ip/ipconfig/ipconfig.h
@@ -3,7 +3,7 @@
{
/* commands */
Vadd,
- Vremove,
+ Vdel,
Vunbind,
Vaddpref6,
Vra6,
@@ -123,7 +123,7 @@
void ipunconfig(void);
void adddefroute(uchar*, uchar*, uchar*, uchar*);
-void removedefroute(uchar*, uchar*, uchar*, uchar*);
+void deldefroute(uchar*, uchar*, uchar*, uchar*);
int myip(Ipifc*, uchar*);
int isether(void);
--- a/sys/src/cmd/ip/ipconfig/ipv6.c
+++ b/sys/src/cmd/ip/ipconfig/ipv6.c
@@ -662,7 +662,7 @@
DEBUG("purging RA from %I on %s; pfx %I %M",
r->src, conf.dev, r->laddr, r->mask);
if(!noconfig && validip(r->gaddr))
- removedefroute(r->gaddr, conf.lladdr, r->laddr, r->mask);
+ deldefroute(r->gaddr, conf.lladdr, r->laddr, r->mask);
*rr = r->next;
free(r);
continue;
--- a/sys/src/cmd/ip/ipconfig/main.c
+++ b/sys/src/cmd/ip/ipconfig/main.c
@@ -45,7 +45,7 @@
extern void pppbinddev(void);
static void doadd(void);
-static void doremove(void);
+static void dodel(void);
static void dounbind(void);
static void ndbconfig(void);
@@ -171,7 +171,7 @@
{
static char *verbs[] = {
[Vadd] "add",
- [Vremove] "remove",
+ [Vdel] "del",
[Vunbind] "unbind",
[Vether] "ether",
[Vgbe] "gbe",
@@ -188,6 +188,10 @@
for(i = 0; i < nelem(verbs); i++)
if(verbs[i] != nil && strcmp(name, verbs[i]) == 0)
return i;
+
+ if(strcmp(name, "remove")==0)
+ return Vdel;
+
return -1;
}
@@ -248,7 +252,7 @@
case Vpkt:
sysfatal("medium %s already specified", conf.type);
case Vadd:
- case Vremove:
+ case Vdel:
case Vunbind:
case Vaddpref6:
case Vra6:
@@ -262,7 +266,7 @@
/* get verb-dependent arguments */
switch (action) {
case Vadd:
- case Vremove:
+ case Vdel:
case Vunbind:
parsenorm(argc, argv);
break;
@@ -462,12 +466,12 @@
findmyifc();
case Vunbind:
break;
- case Vremove:
+ case Vdel:
/*
* interface gone, just remove
* default route and ndb entries.
*/
- doremove();
+ dodel();
exits(nil);
}
if(myifc == nil)
@@ -493,8 +497,8 @@
mkclientid();
doipv6(action);
break;
- case Vremove:
- doremove();
+ case Vdel:
+ dodel();
break;
case Vunbind:
dounbind();
@@ -549,20 +553,21 @@
}
static void
-doremove(void)
+dodel(void)
{
if(!validip(conf.laddr))
- sysfatal("remove requires an address");
+ sysfatal("del requires an address");
- DEBUG("removing address %I %M on %s", conf.laddr, conf.mask, conf.dev);
+ DEBUG("deleting address %I %M on %s", conf.laddr, conf.mask, conf.dev);
if(noconfig)
return;
if(validip(conf.gaddr))
- removedefroute(conf.gaddr, conf.laddr, conf.laddr, conf.mask);
+ deldefroute(conf.gaddr, conf.laddr, conf.laddr, conf.mask);
+ /* use "remove" verb instead of "del" for older kernels */
if(conf.cfd >= 0 && fprint(conf.cfd, "remove %I %M", conf.laddr, conf.mask) < 0)
- warning("can't remove %I %M: %r", conf.laddr, conf.mask);
+ warning("can't delete %I %M: %r", conf.laddr, conf.mask);
/* remove ndb entries matching our ip address */
putndb(0);
@@ -691,7 +696,7 @@
if(!validip(conf.mask))
ipmove(conf.mask, defmask(conf.laddr));
- doremove();
+ dodel();
ipmove(conf.laddr, IPnoaddr);
ipmove(conf.raddr, IPnoaddr);
@@ -870,8 +875,9 @@
}
void
-removedefroute(uchar *gaddr, uchar *ia, uchar *src, uchar *smask)
+deldefroute(uchar *gaddr, uchar *ia, uchar *src, uchar *smask)
{
+ /* use "remove" verb instead of "del" for older kernels */
defroutectl("remove", gaddr, ia, src, smask);
}