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