ref: 988845a13e6b254e79d602c6b154f46d7a4c41b4
parent: fc8df2c9ce66ed92b126146598ebc0af30e475b7
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun May 28 12:15:21 EDT 2023
ip/ipconfig: leave ipnet= entries alone when updating /net/ndb, use ndbvalfmt()
--- a/sys/src/cmd/ip/ipconfig/main.c
+++ b/sys/src/cmd/ip/ipconfig/main.c
@@ -51,6 +51,8 @@
static int Ufmt(Fmt*);
#pragma varargck type "U" char*
+/* for ndbvalfmt */
+#pragma varargck type "$" char*
void
usage(void)
@@ -73,6 +75,8 @@
fmtinstall('M', eipfmt);
fmtinstall('V', eipfmt);
fmtinstall('U', Ufmt);
+ fmtinstall('$', ndbvalfmt);
+
nsec(); /* make sure time file is open before forking */
conf.cfd = -1;
@@ -787,13 +791,14 @@
while((t = ndbparse(db)) != nil){
uchar ip[IPaddrlen];
- if((nt = ndbfindattr(t, t, "ip")) == nil
+ if(ndbfindattr(t, t, "ipnet") != nil
+ || (nt = ndbfindattr(t, t, "ip")) == nil
|| parseip(ip, nt->val) == -1
|| ipcmp(ip, conf.laddr) != 0 && myip(allifcs, ip)){
if(p > buf)
p = seprint(p, e, "\n");
for(nt = t; nt != nil; nt = nt->entry)
- p = seprint(p, e, "%s=%s%s", nt->attr, nt->val,
+ p = seprint(p, e, "%s=%$%s", nt->attr, nt->val,
nt->entry==nil? "\n": nt->line!=nt->entry? "\n\t": " ");
}
ndbfree(t);