fixes for vnfs
This commit is contained in:
parent
f92a2ceba4
commit
4c06b8eec1
7 changed files with 64 additions and 17 deletions
|
|
@ -156,6 +156,7 @@ rpcMuxThread(void *v)
|
||||||
Out *o, **out;
|
Out *o, **out;
|
||||||
SunRpc rpc;
|
SunRpc rpc;
|
||||||
SunClient *cli;
|
SunClient *cli;
|
||||||
|
SunStatus ok;
|
||||||
|
|
||||||
cli = v;
|
cli = v;
|
||||||
mout = 16;
|
mout = 16;
|
||||||
|
|
@ -262,7 +263,7 @@ if(cli->chatty) fprint(2, "resend %lux %lud %lud\n", o->xid, t, o->t);
|
||||||
n = (p[0]<<24)|(p[1]<<16)|(p[2]<<8)|p[3];
|
n = (p[0]<<24)|(p[1]<<16)|(p[2]<<8)|p[3];
|
||||||
p += 4;
|
p += 4;
|
||||||
ep = p+n;
|
ep = p+n;
|
||||||
if(sunrpcunpack(p, ep, &p, &rpc) < 0){
|
if((ok = sunrpcunpack(p, ep, &p, &rpc)) != SunSuccess){
|
||||||
fprint(2, "%s: in: %.*H unpack failed\n", argv0, n, buf+4);
|
fprint(2, "%s: in: %.*H unpack failed\n", argv0, n, buf+4);
|
||||||
free(buf);
|
free(buf);
|
||||||
break;
|
break;
|
||||||
|
|
@ -288,9 +289,9 @@ if(cli->chatty) fprint(2, "resend %lux %lud %lud\n", o->xid, t, o->t);
|
||||||
out[i] = out[--nout];
|
out[i] = out[--nout];
|
||||||
free(o->p);
|
free(o->p);
|
||||||
o->p = nil;
|
o->p = nil;
|
||||||
|
o->rpc = rpc;
|
||||||
if(rpc.status == SunSuccess){
|
if(rpc.status == SunSuccess){
|
||||||
o->p = buf;
|
o->p = buf;
|
||||||
o->rpc = rpc;
|
|
||||||
}else{
|
}else{
|
||||||
o->p = nil;
|
o->p = nil;
|
||||||
free(buf);
|
free(buf);
|
||||||
|
|
@ -353,9 +354,9 @@ sunclientclose(SunClient *cli)
|
||||||
if(!cli->timertid)
|
if(!cli->timertid)
|
||||||
n++;
|
n++;
|
||||||
while(n < 2){
|
while(n < 2){
|
||||||
threadint(cli->nettid);
|
// threadint(cli->nettid);
|
||||||
if(cli->timertid)
|
// if(cli->timertid)
|
||||||
threadint(cli->timertid);
|
// threadint(cli->timertid);
|
||||||
yield();
|
yield();
|
||||||
while(nbrecv(cli->dying, nil) == 1)
|
while(nbrecv(cli->dying, nil) == 1)
|
||||||
n++;
|
n++;
|
||||||
|
|
@ -469,6 +470,13 @@ sunclientrpc(SunClient *cli, ulong tag, SunCall *tx, SunCall *rx, uchar **tofree
|
||||||
rx->rpc.prog = tx->rpc.prog;
|
rx->rpc.prog = tx->rpc.prog;
|
||||||
rx->rpc.vers = tx->rpc.vers;
|
rx->rpc.vers = tx->rpc.vers;
|
||||||
rx->type = (rx->rpc.proc<<1)|1;
|
rx->type = (rx->rpc.proc<<1)|1;
|
||||||
|
if(rx->rpc.status != SunSuccess){
|
||||||
|
sunerrstr(rx->rpc.status);
|
||||||
|
werrstr("unpack: %r");
|
||||||
|
free(o.p);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
if((ok = suncallunpack(prog, p, ep, &p, rx)) != SunSuccess){
|
if((ok = suncallunpack(prog, p, ep, &p, rx)) != SunSuccess){
|
||||||
sunerrstr(ok);
|
sunerrstr(ok);
|
||||||
werrstr("unpack: %r");
|
werrstr("unpack: %r");
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
#include <libc.h>
|
#include <libc.h>
|
||||||
|
#include <ip.h>
|
||||||
#include <thread.h>
|
#include <thread.h>
|
||||||
#include <sunrpc.h>
|
#include <sunrpc.h>
|
||||||
|
|
||||||
|
|
@ -16,7 +17,10 @@ sunnetlisten(void *v)
|
||||||
{
|
{
|
||||||
int fd, lcfd;
|
int fd, lcfd;
|
||||||
char ldir[40];
|
char ldir[40];
|
||||||
|
uchar ip[IPaddrlen];
|
||||||
|
int port;
|
||||||
Arg *a = v;
|
Arg *a = v;
|
||||||
|
NetConnInfo *nci;
|
||||||
|
|
||||||
for(;;){
|
for(;;){
|
||||||
lcfd = listen(a->adir, ldir);
|
lcfd = listen(a->adir, ldir);
|
||||||
|
|
@ -26,6 +30,19 @@ sunnetlisten(void *v)
|
||||||
close(lcfd);
|
close(lcfd);
|
||||||
if(fd < 0)
|
if(fd < 0)
|
||||||
continue;
|
continue;
|
||||||
|
if(a->srv->ipokay){
|
||||||
|
if((nci = getnetconninfo(nil, fd)) == nil){
|
||||||
|
close(fd);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
port = atoi(nci->rserv);
|
||||||
|
parseip(ip, nci->raddr);
|
||||||
|
freenetconninfo(nci);
|
||||||
|
if(!a->srv->ipokay(ip, port)){
|
||||||
|
close(fd);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
if(!sunsrvfd(a->srv, fd))
|
if(!sunsrvfd(a->srv, fd))
|
||||||
close(fd);
|
close(fd);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -489,7 +489,7 @@ static SunProc proc[] = {
|
||||||
(P)portRCallitPack, (P)portRCallitUnpack, (S)portRCallitSize, (F)portRCallitPrint, sizeof(PortRCallit),
|
(P)portRCallitPack, (P)portRCallitUnpack, (S)portRCallitSize, (F)portRCallitPrint, sizeof(PortRCallit),
|
||||||
};
|
};
|
||||||
|
|
||||||
SunProg portProg =
|
SunProg portprog =
|
||||||
{
|
{
|
||||||
PortProgram,
|
PortProgram,
|
||||||
PortVersion,
|
PortVersion,
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ suncallunpack(SunProg *prog, uchar *a, uchar *ea, uchar **pa, SunCall *c)
|
||||||
if(c->type < 0 || c->type >= prog->nproc || (unpack=prog->proc[c->type].unpack) == nil)
|
if(c->type < 0 || c->type >= prog->nproc || (unpack=prog->proc[c->type].unpack) == nil)
|
||||||
return SunProcUnavail;
|
return SunProcUnavail;
|
||||||
if((*unpack)(a, ea, pa, c) < 0){
|
if((*unpack)(a, ea, pa, c) < 0){
|
||||||
fprint(2, "%lud %d: %.*H unpack failed\n", prog->prog, c->type, (int)(ea-a), a);
|
fprint(2, "%lud %d: '%.*H' unpack failed\n", prog->prog, c->type, (int)(ea-a), a);
|
||||||
return SunGarbageArgs;
|
return SunGarbageArgs;
|
||||||
}
|
}
|
||||||
return SunSuccess;
|
return SunSuccess;
|
||||||
|
|
|
||||||
|
|
@ -68,12 +68,17 @@ sunrpcpack(uchar *a, uchar *ea, uchar **pa, SunRpc *rpc)
|
||||||
|| sunauthinfopack(a, ea, &a, &rpc->verf) < 0)
|
|| sunauthinfopack(a, ea, &a, &rpc->verf) < 0)
|
||||||
goto Err;
|
goto Err;
|
||||||
break;
|
break;
|
||||||
|
case SunAuthError:
|
||||||
|
if(sunuint32pack(a, ea, &a, (x=MsgDenied, &x)) < 0
|
||||||
|
|| sunuint32pack(a, ea, &a, (x=MsgAuthError, &x)) < 0)
|
||||||
|
goto Err;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
if(sunuint32pack(a, ea, &a, (x=MsgDenied, &x)) < 0)
|
if(sunuint32pack(a, ea, &a, (x=MsgDenied, &x)) < 0)
|
||||||
goto Err;
|
goto Err;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(rpc->status){
|
switch(rpc->status){
|
||||||
case SunSuccess:
|
case SunSuccess:
|
||||||
if(sunuint32pack(a, ea, &a, (x=MsgSuccess, &x)) < 0
|
if(sunuint32pack(a, ea, &a, (x=MsgSuccess, &x)) < 0
|
||||||
|
|
@ -90,6 +95,7 @@ sunrpcpack(uchar *a, uchar *ea, uchar **pa, SunRpc *rpc)
|
||||||
default:
|
default:
|
||||||
if(sunuint32pack(a, ea, &a, (x=rpc->status&0xFFFF, &x)) < 0)
|
if(sunuint32pack(a, ea, &a, (x=rpc->status&0xFFFF, &x)) < 0)
|
||||||
goto Err;
|
goto Err;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -119,6 +125,9 @@ sunrpcsize(SunRpc *rpc)
|
||||||
case SunAcceptError:
|
case SunAcceptError:
|
||||||
a += 4+sunauthinfosize(&rpc->verf);
|
a += 4+sunauthinfosize(&rpc->verf);
|
||||||
break;
|
break;
|
||||||
|
case SunAuthError:
|
||||||
|
a += 4+4;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
a += 4;
|
a += 4;
|
||||||
break;
|
break;
|
||||||
|
|
@ -169,6 +178,7 @@ sunrpcunpack(uchar *a, uchar *ea, uchar **pa, SunRpc *rpc)
|
||||||
rpc->iscall = 0;
|
rpc->iscall = 0;
|
||||||
if(sunuint32unpack(a, ea, &a, &x) < 0)
|
if(sunuint32unpack(a, ea, &a, &x) < 0)
|
||||||
goto Err;
|
goto Err;
|
||||||
|
fprint(2, "x %x\n", x);
|
||||||
switch(x){
|
switch(x){
|
||||||
default:
|
default:
|
||||||
goto Err;
|
goto Err;
|
||||||
|
|
@ -200,6 +210,7 @@ sunrpcunpack(uchar *a, uchar *ea, uchar **pa, SunRpc *rpc)
|
||||||
case MsgDenied:
|
case MsgDenied:
|
||||||
if(sunuint32unpack(a, ea, &a, &x) < 0)
|
if(sunuint32unpack(a, ea, &a, &x) < 0)
|
||||||
goto Err;
|
goto Err;
|
||||||
|
fprint(2, "xx %ux\n", x);
|
||||||
switch(x){
|
switch(x){
|
||||||
default:
|
default:
|
||||||
goto Err;
|
goto Err;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#include <u.h>
|
#include <u.h>
|
||||||
#include <libc.h>
|
#include <libc.h>
|
||||||
|
#include <ip.h>
|
||||||
#include <thread.h>
|
#include <thread.h>
|
||||||
#include <sunrpc.h>
|
#include <sunrpc.h>
|
||||||
|
|
||||||
|
|
@ -79,6 +80,7 @@ sunsrvthreadcreate(SunSrv *srv, void (*fn)(void*), void *arg)
|
||||||
static void
|
static void
|
||||||
sunrpcrequestthread(void *v)
|
sunrpcrequestthread(void *v)
|
||||||
{
|
{
|
||||||
|
int status;
|
||||||
uchar *p, *ep;
|
uchar *p, *ep;
|
||||||
Channel *c;
|
Channel *c;
|
||||||
SunSrv *srv = v;
|
SunSrv *srv = v;
|
||||||
|
|
@ -93,6 +95,7 @@ if(srv->chatty) fprint(2, "sun msg %p count %d\n", m, m->count);
|
||||||
m->srv = srv;
|
m->srv = srv;
|
||||||
p = m->data;
|
p = m->data;
|
||||||
ep = p+m->count;
|
ep = p+m->count;
|
||||||
|
status = m->rpc.status;
|
||||||
if(sunrpcunpack(p, ep, &p, &m->rpc) != SunSuccess){
|
if(sunrpcunpack(p, ep, &p, &m->rpc) != SunSuccess){
|
||||||
fprint(2, "in: %.*H unpack failed\n", m->count, m->data);
|
fprint(2, "in: %.*H unpack failed\n", m->count, m->data);
|
||||||
sunmsgdrop(m);
|
sunmsgdrop(m);
|
||||||
|
|
@ -100,7 +103,10 @@ if(srv->chatty) fprint(2, "sun msg %p count %d\n", m, m->count);
|
||||||
}
|
}
|
||||||
if(srv->chatty)
|
if(srv->chatty)
|
||||||
fprint(2, "in: %B\n", &m->rpc);
|
fprint(2, "in: %B\n", &m->rpc);
|
||||||
|
if(status){
|
||||||
|
sunmsgreplyerror(m, status);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if(srv->alwaysreject){
|
if(srv->alwaysreject){
|
||||||
if(srv->chatty)
|
if(srv->chatty)
|
||||||
fprint(2, "\trejecting\n");
|
fprint(2, "\trejecting\n");
|
||||||
|
|
|
||||||
|
|
@ -48,8 +48,18 @@ sunudpread(void *v)
|
||||||
while((n = udpread(arg.fd, &udp, buf, UdpMaxRead)) > 0){
|
while((n = udpread(arg.fd, &udp, buf, UdpMaxRead)) > 0){
|
||||||
if(arg.srv->chatty)
|
if(arg.srv->chatty)
|
||||||
fprint(2, "udpread got %d (%d) from %I\n", n, Udphdrsize, udp.raddr);
|
fprint(2, "udpread got %d (%d) from %I\n", n, Udphdrsize, udp.raddr);
|
||||||
|
msg = emalloc(sizeof(SunMsgUdp));
|
||||||
|
msg->udp = udp;
|
||||||
|
msg->msg.data = emalloc(n);
|
||||||
|
msg->msg.count = n;
|
||||||
|
memmove(msg->msg.data, buf, n);
|
||||||
|
msg->msg.creply = arg.creply;
|
||||||
|
msg->msg.srv = arg.srv;
|
||||||
|
if(arg.srv->chatty)
|
||||||
|
fprint(2, "message %p count %d\n", msg, msg->msg.count);
|
||||||
if((srv->localonly || srv->localparanoia) && ipcmp(udp.raddr, localip) != 0){
|
if((srv->localonly || srv->localparanoia) && ipcmp(udp.raddr, localip) != 0){
|
||||||
fprint(2, "dropping message from %I: not local\n", udp.raddr);
|
fprint(2, "dropping message from %I: not local\n", udp.raddr);
|
||||||
|
sunmsgreplyerror(&msg->msg, SunAuthTooWeak);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(srv->localparanoia){
|
if(srv->localparanoia){
|
||||||
|
|
@ -59,17 +69,12 @@ sunudpread(void *v)
|
||||||
paraport = port;
|
paraport = port;
|
||||||
}else if(paraport != port){
|
}else if(paraport != port){
|
||||||
fprint(2, "dropping message from %I: not port %d\n", udp.raddr, port);
|
fprint(2, "dropping message from %I: not port %d\n", udp.raddr, port);
|
||||||
|
sunmsgreplyerror(&msg->msg, SunAuthTooWeak);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
msg = emalloc(sizeof(SunMsgUdp));
|
if(srv->ipokay && !srv->ipokay(udp.raddr, nhgets(udp.rport)))
|
||||||
msg->udp = udp;
|
msg->msg.rpc.status = SunProgUnavail;
|
||||||
msg->msg.data = emalloc(n);
|
|
||||||
msg->msg.count = n;
|
|
||||||
memmove(msg->msg.data, buf, n);
|
|
||||||
msg->msg.creply = arg.creply;
|
|
||||||
if(arg.srv->chatty)
|
|
||||||
fprint(2, "message %p count %d\n", msg, msg->msg.count);
|
|
||||||
sendp(arg.srv->crequest, msg);
|
sendp(arg.srv->crequest, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue