ref: 169aa63ec5a670d0c72b7e9fb747e16d76b718c3
parent: e655f4b8bdd9da0c51bd4bece8a2ea2088e57236
author: cinap_lenrek <[email protected]>
date: Sat May 20 10:09:41 EDT 2023
devip: provide large buffer for ipifc->local() generator The ipifc->local generator is the big exception, dumping the whole link structure of the interface.
--- a/sys/src/9/ip/devip.c
+++ b/sys/src/9/ip/devip.c
@@ -93,7 +93,7 @@
p = "remote";
break;
case Qsnoop:
- if(strcmp(cv->p->name, "ipifc") != 0)
+ if(cv->p != ipfs[c->dev]->ipifc)
return -1;
devdir(c, q, "snoop", qlen(cv->sq), cv->owner, 0400, dp);
return 1;
@@ -674,13 +674,22 @@
}
goto Readstr;
case Qlocal:
+ x = f->p[PROTO(ch->qid)];
+ c = x->conv[CONV(ch->qid)];
+ if(x == f->ipifc && x->local != nil){
+ buf = smalloc(Maxstate);
+ if(waserror()){
+ free(buf);
+ nexterror();
+ }
+ (*x->local)(c, buf, Maxstate);
+ goto Readstr;
+ }
buf = smalloc(Maxstring);
if(waserror()){
free(buf);
nexterror();
}
- x = f->p[PROTO(ch->qid)];
- c = x->conv[CONV(ch->qid)];
if(x->local == nil) {
snprint(buf, Maxstring, "%I!%d\n", c->laddr, c->lport);
} else {
--- a/sys/src/9/ip/ipifc.c
+++ b/sys/src/9/ip/ipifc.c
@@ -267,7 +267,7 @@
ifc->in, ifc->out, ifc->inerr, ifc->outerr,
ifc->speed, ifc->delay);
- for(lifc = ifc->lifc; lifc != nil && n > m; lifc = lifc->next)
+ for(lifc = ifc->lifc; lifc != nil; lifc = lifc->next)
m += snprint(state+m, n - m, slineformat, lifc->local,
lifc->mask, lifc->remote, lifc->validlt, lifc->preflt);
if(ifc->lifc == nil)