devip: valid and prefered life-time should be unsigned, add remove6 ctl command
This commit is contained in:
parent
4a92a8f6b2
commit
70c6bd0397
3 changed files with 47 additions and 25 deletions
|
@ -286,6 +286,10 @@ preferred life-time in seconds
|
||||||
.RE
|
.RE
|
||||||
.PD
|
.PD
|
||||||
.TP
|
.TP
|
||||||
|
.B remove6
|
||||||
|
Remove local IPv6 addresses that have expired ther
|
||||||
|
valid life-time.
|
||||||
|
.TP
|
||||||
.BI "ra6 " "keyword value ..."
|
.BI "ra6 " "keyword value ..."
|
||||||
Set IPv6 router advertisement (RA) parameter
|
Set IPv6 router advertisement (RA) parameter
|
||||||
.IR keyword 's
|
.IR keyword 's
|
||||||
|
|
|
@ -262,9 +262,9 @@ struct Iplifc
|
||||||
uchar tentative; /* =1 => v6 dup disc on, =0 => confirmed unique */
|
uchar tentative; /* =1 => v6 dup disc on, =0 => confirmed unique */
|
||||||
uchar onlink; /* =1 => onlink, =0 offlink. */
|
uchar onlink; /* =1 => onlink, =0 offlink. */
|
||||||
uchar autoflag; /* v6 autonomous flag */
|
uchar autoflag; /* v6 autonomous flag */
|
||||||
long validlt; /* v6 valid lifetime */
|
ulong validlt; /* v6 valid lifetime */
|
||||||
long preflt; /* v6 preferred lifetime */
|
ulong preflt; /* v6 preferred lifetime */
|
||||||
long origint; /* time when addr was added */
|
ulong origint; /* time when addr was added */
|
||||||
Iplink *link; /* addresses linked to this lifc */
|
Iplink *link; /* addresses linked to this lifc */
|
||||||
Iplifc *next;
|
Iplifc *next;
|
||||||
};
|
};
|
||||||
|
@ -675,6 +675,7 @@ extern char* ipifcrem(Ipifc *ifc, char **argv, int argc);
|
||||||
extern char* ipifcadd(Ipifc *ifc, char **argv, int argc, int tentative, Iplifc *lifcp);
|
extern char* ipifcadd(Ipifc *ifc, char **argv, int argc, int tentative, Iplifc *lifcp);
|
||||||
extern long ipselftabread(Fs*, char *a, ulong offset, int n);
|
extern long ipselftabread(Fs*, char *a, ulong offset, int n);
|
||||||
extern char* ipifcadd6(Ipifc *ifc, char**argv, int argc);
|
extern char* ipifcadd6(Ipifc *ifc, char**argv, int argc);
|
||||||
|
extern char* ipifcremove6(Ipifc *ifc, char**argv, int argc);
|
||||||
/*
|
/*
|
||||||
* ip.c
|
* ip.c
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -84,7 +84,7 @@ v6addrtype(uchar *addr)
|
||||||
return globalv6;
|
return globalv6;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define v6addrcurr(lifc) ((lifc)->preflt == ~0L || \
|
#define v6addrcurr(lifc) ((lifc)->preflt == ~0UL || \
|
||||||
(lifc)->origint + (lifc)->preflt >= NOW/1000)
|
(lifc)->origint + (lifc)->preflt >= NOW/1000)
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
@ -177,15 +177,9 @@ ipifcbind(Conv *c, char **argv, int argc)
|
||||||
ifc->maxtu = ifc->m->maxtu;
|
ifc->maxtu = ifc->m->maxtu;
|
||||||
if(ifc->m->unbindonclose == 0)
|
if(ifc->m->unbindonclose == 0)
|
||||||
ifc->conv->inuse++;
|
ifc->conv->inuse++;
|
||||||
ifc->rp.mflag = 0; /* default not managed */
|
|
||||||
ifc->rp.oflag = 0;
|
/* default router paramters */
|
||||||
ifc->rp.maxraint = 600000; /* millisecs */
|
ifc->rp = c->p->f->v6p->rp;
|
||||||
ifc->rp.minraint = 200000;
|
|
||||||
ifc->rp.linkmtu = 0; /* no mtu sent */
|
|
||||||
ifc->rp.reachtime = 0;
|
|
||||||
ifc->rp.rxmitra = 0;
|
|
||||||
ifc->rp.ttl = MAXTTL;
|
|
||||||
ifc->rp.routerlt = 3 * ifc->rp.maxraint;
|
|
||||||
|
|
||||||
/* any ancillary structures (like routes) no longer pertain */
|
/* any ancillary structures (like routes) no longer pertain */
|
||||||
ifc->ifcid++;
|
ifc->ifcid++;
|
||||||
|
@ -248,9 +242,9 @@ ipifcunbind(Ipifc *ifc)
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
char sfixedformat[] = "device %s maxtu %d sendra %d recvra %d mflag %d oflag"
|
char sfixedformat[] = "device %s maxtu %d sendra %d recvra %d mflag %d oflag %d"
|
||||||
" %d maxraint %d minraint %d linkmtu %d reachtime %d rxmitra %d ttl %d routerlt"
|
" maxraint %d minraint %d linkmtu %d reachtime %d rxmitra %d ttl %d routerlt %d"
|
||||||
" %d pktin %lud pktout %lud errin %lud errout %lud speed %d delay %d\n";
|
" pktin %lud pktout %lud errin %lud errout %lud speed %d delay %d\n";
|
||||||
|
|
||||||
char slineformat[] = " %-40I %-10M %-40I %-12lud %-12lud\n";
|
char slineformat[] = " %-40I %-10M %-40I %-12lud %-12lud\n";
|
||||||
|
|
||||||
|
@ -545,7 +539,7 @@ ipifcadd(Ipifc *ifc, char **argv, int argc, int tentative, Iplifc *lifcp)
|
||||||
lifc->origint = lifcp->origint;
|
lifc->origint = lifcp->origint;
|
||||||
} else { /* default values */
|
} else { /* default values */
|
||||||
lifc->onlink = lifc->autoflag = 1;
|
lifc->onlink = lifc->autoflag = 1;
|
||||||
lifc->validlt = lifc->preflt = ~0L;
|
lifc->validlt = lifc->preflt = ~0UL;
|
||||||
lifc->origint = NOW / 1000;
|
lifc->origint = NOW / 1000;
|
||||||
}
|
}
|
||||||
lifc->next = nil;
|
lifc->next = nil;
|
||||||
|
@ -768,13 +762,13 @@ ipifcra6(Ipifc *ifc, char **argv, int argc)
|
||||||
|
|
||||||
while (argsleft > 1) {
|
while (argsleft > 1) {
|
||||||
if(strcmp(argv[i], "recvra") == 0)
|
if(strcmp(argv[i], "recvra") == 0)
|
||||||
recvra = (atoi(argv[i+1]) != 0);
|
recvra = atoi(argv[i+1]) != 0;
|
||||||
else if(strcmp(argv[i], "sendra") == 0)
|
else if(strcmp(argv[i], "sendra") == 0)
|
||||||
sendra = (atoi(argv[i+1]) != 0);
|
sendra = atoi(argv[i+1]) != 0;
|
||||||
else if(strcmp(argv[i], "mflag") == 0)
|
else if(strcmp(argv[i], "mflag") == 0)
|
||||||
rp.mflag = (atoi(argv[i+1]) != 0);
|
rp.mflag = atoi(argv[i+1]) != 0;
|
||||||
else if(strcmp(argv[i], "oflag") == 0)
|
else if(strcmp(argv[i], "oflag") == 0)
|
||||||
rp.oflag = (atoi(argv[i+1]) != 0);
|
rp.oflag = atoi(argv[i+1]) != 0;
|
||||||
else if(strcmp(argv[i], "maxraint") == 0)
|
else if(strcmp(argv[i], "maxraint") == 0)
|
||||||
rp.maxraint = atoi(argv[i+1]);
|
rp.maxraint = atoi(argv[i+1]);
|
||||||
else if(strcmp(argv[i], "minraint") == 0)
|
else if(strcmp(argv[i], "minraint") == 0)
|
||||||
|
@ -849,6 +843,8 @@ ipifcctl(Conv* c, char **argv, int argc)
|
||||||
}
|
}
|
||||||
else if(strcmp(argv[0], "add6") == 0)
|
else if(strcmp(argv[0], "add6") == 0)
|
||||||
return ipifcadd6(ifc, argv, argc);
|
return ipifcadd6(ifc, argv, argc);
|
||||||
|
else if(strcmp(argv[0], "remove6") == 0)
|
||||||
|
return ipifcremove6(ifc, argv, argc);
|
||||||
else if(strcmp(argv[0], "ra6") == 0)
|
else if(strcmp(argv[0], "ra6") == 0)
|
||||||
return ipifcra6(ifc, argv, argc);
|
return ipifcra6(ifc, argv, argc);
|
||||||
return "unsupported ctl";
|
return "unsupported ctl";
|
||||||
|
@ -1605,16 +1601,15 @@ ipifcadd6(Ipifc *ifc, char**argv, int argc)
|
||||||
|
|
||||||
lifc.onlink = 1;
|
lifc.onlink = 1;
|
||||||
lifc.autoflag = 1;
|
lifc.autoflag = 1;
|
||||||
lifc.validlt = ~0L;
|
lifc.validlt = lifc.preflt = ~0UL;
|
||||||
lifc.preflt = ~0L;
|
|
||||||
lifc.origint = NOW / 1000;
|
lifc.origint = NOW / 1000;
|
||||||
|
|
||||||
switch(argc) {
|
switch(argc) {
|
||||||
case 7:
|
case 7:
|
||||||
lifc.preflt = atoi(argv[6]);
|
lifc.preflt = strtoul(argv[6], 0, 10);
|
||||||
/* fall through */
|
/* fall through */
|
||||||
case 6:
|
case 6:
|
||||||
lifc.validlt = atoi(argv[5]);
|
lifc.validlt = strtoul(argv[5], 0, 10);
|
||||||
/* fall through */
|
/* fall through */
|
||||||
case 5:
|
case 5:
|
||||||
lifc.autoflag = atoi(argv[4]) != 0;
|
lifc.autoflag = atoi(argv[4]) != 0;
|
||||||
|
@ -1648,3 +1643,25 @@ ipifcadd6(Ipifc *ifc, char**argv, int argc)
|
||||||
|
|
||||||
return ipifcadd(ifc, params, 3, 0, &lifc);
|
return ipifcadd(ifc, params, 3, 0, &lifc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char*
|
||||||
|
ipifcremove6(Ipifc *ifc, char**, int argc)
|
||||||
|
{
|
||||||
|
Iplifc *lifc, **l;
|
||||||
|
|
||||||
|
if(argc != 1)
|
||||||
|
return Ebadarg;
|
||||||
|
|
||||||
|
wlock(ifc);
|
||||||
|
for(l = &ifc->lifc; (lifc = *l) != nil;) {
|
||||||
|
if((lifc->type & Rv4) == 0)
|
||||||
|
if(lifc->validlt != ~0UL && lifc->origint + lifc->validlt < NOW/1000){
|
||||||
|
if(ipifcremlifc(ifc, l) == nil)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
l = &lifc->next;
|
||||||
|
}
|
||||||
|
wunlock(ifc);
|
||||||
|
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue