from sources: log dhcp broadcasts. would like to see dhcp logging decreased. the no binding can be very uninteresting with lots of ipmi devices hanging out on the network. Reference: /n/atom/patch/applied/dhcpdlogbcast Date: Sat Mar 1 17:12:11 CET 2014 Signed-off-by: quanstro@quanstro.net --- /sys/src/cmd/ip/dhcpd/dhcpd.c Sat Mar 1 17:09:35 2014 +++ /sys/src/cmd/ip/dhcpd/dhcpd.c Sat Mar 1 17:09:38 2014 @@ -30,6 +30,7 @@ /* parsed options */ int p9request; /* flag: this is a bootp with plan9 options */ int genrequest; /* flag: this is a bootp with generic options */ + int broadcast; /* flag: request was broadcast */ int dhcptype; /* dhcp message type */ int leasetime; /* dhcp lease */ uchar ip[IPaddrlen]; /* requested address */ @@ -63,6 +64,7 @@ int mute, mutestat; int minlease = MinLease; int staticlease = StaticLease; +int timestamps; uvlong start; @@ -201,8 +203,10 @@ { uvlong t; - t = nsec()/1000; - syslog(0, blog, "%s %lludµs", tag, t - start); + if(timestamps){ + t = nsec()/1000; + syslog(0, blog, "%s %lludµs", tag, t - start); + } } void @@ -333,8 +337,10 @@ rp->e = rp->buf + n; rp->bp = (Bootp*)rp->buf; rp->up = (Udphdr*)rp->buf; - if (ipcmp(rp->up->laddr, IPv4bcast) == 0) + if (ipcmp(rp->up->laddr, IPv4bcast) == 0){ ipmove(rp->up->laddr, rp->up->ifcaddr); + rp->broadcast = 1; + } rp->max = rp->buf + Udphdrsize + MINSUPPORTED - IPUDPHDRSIZE; rp->p = rp->bp->optdata; v4tov6(rp->giaddr, rp->bp->giaddr); @@ -404,6 +410,10 @@ timestamp("done"); } +/* + * since we are single-threaded, this causes us to effectively + * stop listening for two seconds. + */ static void slowdelay(Req *rp) { @@ -904,11 +914,11 @@ Iplifc *lifc; Info *iip; - warning(0, "bootp %s %I->%I from %s via %I, file %s", + warning(0, "bootp %s %I->%I from %s via %I, file %s %s", rp->genrequest? "generic": (rp->p9request? "p9": ""), rp->up->raddr, rp->up->laddr, rp->id, rp->gii.ipaddr, - rp->bp->file); + rp->bp->file, rp->broadcast? "broadcast": "unicast"); if(nobootp) return; @@ -1639,7 +1649,7 @@ if(rp->requested[i] != 0) p = seprint(p, e, "%s ", optname[rp->requested[i]]); p = seprint(p, e, ")"); - + p = seprint(p, e, " %s", rp->broadcast? "broadcast": "unicast"); USED(p); syslog(0, blog, "%s", buf); }