[Dnsmasq-discuss] Patch to change dnsmasq logentries

Simon Kelley simon at thekelleys.org.uk
Fri Feb 27 15:44:02 GMT 2009


Olaf Westrik wrote:
> Hi,
> 
> 
> please consider attached patch against dnsmasq 2.47 for inclusion.
> Purpose: easily identify and separate log messages for the DHCP part. 
> Messages from dnsmasq DHCP part start with DHCP:. This allows easier 
> separation for user presentation.
> 
> Example logging:
> Feb 27 07:38:09 fw dnsmasq[29780]: started, version 2.47 cachesize 150
> Feb 27 07:38:09 fw dnsmasq[29780]: compile time options: IPv6 GNU-getopt 
> no-DBus no-I18N TFTP
> Feb 27 07:38:09 fw dnsmasq[29780]: DHCP: static leases only on 
> 192.168.3.1, lease time 1h
> Feb 27 07:38:09 fw dnsmasq[29780]: DHCP: IP range 192.168.2.2 -- 
> 192.168.2.50, lease time 1h
> Feb 27 07:38:09 fw dnsmasq[29780]: reading /var/ipcop/red/resolv.conf
> Feb 27 07:38:09 fw dnsmasq[29780]: using nameserver 192.168.1.1#53
> Feb 27 07:38:09 fw dnsmasq[29780]: read /etc/hosts - 4 addresses
> Feb 27 07:38:40 fw dnsmasq[29780]: DHCP: DHCPDISCOVER(lan-1) 
> 00:12:3F:20:11:f1
> Feb 27 07:38:40 fw dnsmasq[29780]: DHCP: DHCPOFFER(lan-1) 192.168.2.44 
> 00:12:3F:20:11:f1
> Feb 27 07:38:41 fw dnsmasq[29780]: DHCP: DHCPREQUEST(lan-1) 
> 192.168.10.44 00:3F:56:20:11:f1
> Feb 27 07:38:41 fw dnsmasq[29780]: DHCP: DHCPACK(lan-1) 192.168.2.44 
> 00:12:3F:20:11:f1
> 
> 
> 
> Some background: IPCop is a Linux Firewall distribution, which (among 
> many other things) has a webinterface including log display.
> Log messages are separated into different sections for better usability. 
> Some sections are kernel related, internet connection, IPsec tunnels, 
> etc. etc.
> Separate log sections exist for DNS and DHCP server, which is not a 
> problem in our current version where we use ISC DHCP daemon and thus can 
> easily separate messages between the dnsmasq and dhcpd process.
> However in the next major release we want to change that and use dnsmasq 
> as both DNS and DHCP server.
> 
> Now I could also use a search for DHCP in the log messages, but some 
> DHCP related log seem to lack such info.
> I think that using an easy to spot text at the start makes it easier for 
> regex-ing and improves consistency.
> 
> 
> thanks and keep up the good work
> 
> Olaf
> 
> 
> PS: while at it I also modified the TFTP part.


I'm happy with the general principle, but the method you have used has 
the effect of changing LOTS of literal strings in the code. That makes 
large amounts of the translations out of date, when the messages have 
not really changed at all.

As an alternative, how about using some of the log-facility bits in the 
first argument of my_syslog, and appending the extra text in the 
my_syslog code.


#define MS_TFTP LOG_LOCAL0
#define MS_DHCP LOG_LOCAL1

my_syslog(MS_DHCP | LOG_WARNING, _("Ignoring domain %s for DHCP host 
name %s"), config_domain, hostname);

in my_syslog()

if (level | MS_DHCP)
	{ extratext = "DHCP";
           level &= ~MS_DHCP;
	}

etc..

Also, I suspect that there are quite a few people doing pattern-matching 
on the log strings, maybe it would be less likely to break that if the 
sub-function was added to the ident:

Feb 27 07:38:41 fw dnsmasq-dhcp[29780]: DHCPREQUEST(lan-1) 192.168.10.44 
00:3F:56:20:11:f1


If you're happy with that, Olaf, I'm happy to do the coding if you're 
happy to visit each my_syslog call and add the extra bits instead of the 
extra characters.....


Cheers,

Simon.



More information about the Dnsmasq-discuss mailing list