summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2023-11-18 17:59:56 +0000
committercinap_lenrek <cinap_lenrek@felloff.net>2023-11-18 17:59:56 +0000
commit3f52f47b9b698045b3948a9321264390b268b3d8 (patch)
treec941cd1fbbe17c0961d920a724e8901e7afcb20d
parent14f0eae74a9a9f5c5caebbecb11b136a12e65a22 (diff)
ip/ipconfig: allow "del" verb in addition to "remove"
-rw-r--r--sys/man/8/ipconfig10
-rw-r--r--sys/src/cmd/ip/ipconfig/ipconfig.h4
-rw-r--r--sys/src/cmd/ip/ipconfig/ipv6.c2
-rw-r--r--sys/src/cmd/ip/ipconfig/main.c36
4 files changed, 29 insertions, 23 deletions
diff --git a/sys/man/8/ipconfig b/sys/man/8/ipconfig
index ba1a264fc..615d96235 100644
--- a/sys/man/8/ipconfig
+++ b/sys/man/8/ipconfig
@@ -100,15 +100,15 @@ the device can be any byte stream device.
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.
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 @@ flag must also be given to enable DHCPv6.
.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 @@ are always requested.
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
diff --git a/sys/src/cmd/ip/ipconfig/ipconfig.h b/sys/src/cmd/ip/ipconfig/ipconfig.h
index ef3c597c0..151a2335f 100644
--- a/sys/src/cmd/ip/ipconfig/ipconfig.h
+++ b/sys/src/cmd/ip/ipconfig/ipconfig.h
@@ -3,7 +3,7 @@ enum
{
/* commands */
Vadd,
- Vremove,
+ Vdel,
Vunbind,
Vaddpref6,
Vra6,
@@ -123,7 +123,7 @@ int ip4cfg(void);
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);
diff --git a/sys/src/cmd/ip/ipconfig/ipv6.c b/sys/src/cmd/ip/ipconfig/ipv6.c
index a622e3877..e64acd073 100644
--- a/sys/src/cmd/ip/ipconfig/ipv6.c
+++ b/sys/src/cmd/ip/ipconfig/ipv6.c
@@ -662,7 +662,7 @@ recvrahost(uchar buf[], int pktlen)
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;
diff --git a/sys/src/cmd/ip/ipconfig/main.c b/sys/src/cmd/ip/ipconfig/main.c
index 256485032..4ea68d1a7 100644
--- a/sys/src/cmd/ip/ipconfig/main.c
+++ b/sys/src/cmd/ip/ipconfig/main.c
@@ -45,7 +45,7 @@ static void controldevice(void);
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 @@ parseverb(char *name)
{
static char *verbs[] = {
[Vadd] "add",
- [Vremove] "remove",
+ [Vdel] "del",
[Vunbind] "unbind",
[Vether] "ether",
[Vgbe] "gbe",
@@ -188,6 +188,10 @@ parseverb(char *name)
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 @@ parseargs(int argc, char **argv)
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 @@ parseargs(int argc, char **argv)
/* get verb-dependent arguments */
switch (action) {
case Vadd:
- case Vremove:
+ case Vdel:
case Vunbind:
parsenorm(argc, argv);
break;
@@ -462,12 +466,12 @@ main(int argc, char **argv)
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 @@ main(int argc, char **argv)
mkclientid();
doipv6(action);
break;
- case Vremove:
- doremove();
+ case Vdel:
+ dodel();
break;
case Vunbind:
dounbind();
@@ -549,20 +553,21 @@ doadd(void)
}
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 @@ ipunconfig(void)
if(!validip(conf.mask))
ipmove(conf.mask, defmask(conf.laddr));
- doremove();
+ dodel();
ipmove(conf.laddr, IPnoaddr);
ipmove(conf.raddr, IPnoaddr);
@@ -870,8 +875,9 @@ adddefroute(uchar *gaddr, uchar *ia, uchar *src, uchar *smask)
}
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);
}