mirror of
git://git.9front.org/plan9front/plan9front
synced 2025-01-12 11:10:06 +00:00
ipmux: implement hangup ctl
Implement a hangup ctl command that flushes the queues, but keeps the filter around. This can be usefull for low-overhead traffic blocking, as only the file-descriptor needs to be kept around and the queues can be flushed. No user-space process is needed to consume packets and no buffers are wasted. example: aux/dial -e -o hangup 'ipmux!ver=4;src=8.8.8.8' rc -c 'echo 0 > /srv/blocked' rm /srv/blocked
This commit is contained in:
parent
460b007c35
commit
67b0aeb219
1 changed files with 13 additions and 1 deletions
|
@ -815,6 +815,18 @@ ipmuxstats(Proto *p, char *buf, int len)
|
|||
return n;
|
||||
}
|
||||
|
||||
static char*
|
||||
ipmuxctl(Conv *c, char **f, int n)
|
||||
{
|
||||
if(n == 1 && strcmp(f[0], "hangup") == 0){
|
||||
/* hangup and flush the queues, but keep the filter around */
|
||||
qclose(c->rq);
|
||||
qclose(c->wq);
|
||||
return nil;
|
||||
}
|
||||
return "unknown control request";
|
||||
}
|
||||
|
||||
void
|
||||
ipmuxinit(Fs *f)
|
||||
{
|
||||
|
@ -829,7 +841,7 @@ ipmuxinit(Fs *f)
|
|||
ipmux->create = ipmuxcreate;
|
||||
ipmux->close = ipmuxclose;
|
||||
ipmux->rcv = ipmuxiput;
|
||||
ipmux->ctl = nil;
|
||||
ipmux->ctl = ipmuxctl;
|
||||
ipmux->advise = nil;
|
||||
ipmux->stats = ipmuxstats;
|
||||
ipmux->ipproto = -1;
|
||||
|
|
Loading…
Reference in a new issue