Commit 8c0b73d3 authored by Kevin Darbyshire-Bryant's avatar Kevin Darbyshire-Bryant Committed by Simon Kelley

Add --quiet-* options.

parent 6bd3a09f
...@@ -137,6 +137,9 @@ version 2.67 ...@@ -137,6 +137,9 @@ version 2.67
servers where the original client is. Thanks to DNSthingy servers where the original client is. Thanks to DNSthingy
for sponsoring this feature. for sponsoring this feature.
Add --quiet-dhcp, --quiet-dhcp6 and --quiet-ra. Thanks to
Kevin Darbyshire-Bryant for the initial patch.
version 2.66 version 2.66
Add the ability to act as an authoritative DNS Add the ability to act as an authoritative DNS
......
...@@ -1260,6 +1260,11 @@ tried. This flag disables this check. Use with caution. ...@@ -1260,6 +1260,11 @@ tried. This flag disables this check. Use with caution.
Extra logging for DHCP: log all the options sent to DHCP clients and Extra logging for DHCP: log all the options sent to DHCP clients and
the tags used to determine them. the tags used to determine them.
.TP .TP
.B --quiet-dhcp, --quiet-dhcp6, --quiet-ra
Suppress logging of the routine operation of these protocols. Errors and
problems will still be logged. --quiet-dhcp and quiet-dhcp6 are
over-ridden by --log-dhcp.
.TP
.B \-l, --dhcp-leasefile=<path> .B \-l, --dhcp-leasefile=<path>
Use the specified file to store DHCP lease information. Use the specified file to store DHCP lease information.
.TP .TP
......
...@@ -222,7 +222,10 @@ struct event_desc { ...@@ -222,7 +222,10 @@ struct event_desc {
#define OPT_CLEVERBIND 39 #define OPT_CLEVERBIND 39
#define OPT_TFTP 40 #define OPT_TFTP 40
#define OPT_CLIENT_SUBNET 41 #define OPT_CLIENT_SUBNET 41
#define OPT_LAST 42 #define OPT_QUIET_DHCP 42
#define OPT_QUIET_DHCP6 43
#define OPT_QUIET_RA 44
#define OPT_LAST 45
/* extra flags for my_syslog, we use a couple of facilities since they are known /* extra flags for my_syslog, we use a couple of facilities since they are known
not to occupy the same bits as priorities, no matter how syslog.h is set up. */ not to occupy the same bits as priorities, no matter how syslog.h is set up. */
......
...@@ -64,77 +64,80 @@ struct myoption { ...@@ -64,77 +64,80 @@ struct myoption {
#define OPTSTRING "951yZDNLERKzowefnbvhdkqr:m:p:c:l:s:i:t:u:g:a:x:S:C:A:T:H:Q:I:B:F:G:O:M:X:V:U:j:P:J:W:Y:2:4:6:7:8:0:3:" #define OPTSTRING "951yZDNLERKzowefnbvhdkqr:m:p:c:l:s:i:t:u:g:a:x:S:C:A:T:H:Q:I:B:F:G:O:M:X:V:U:j:P:J:W:Y:2:4:6:7:8:0:3:"
/* options which don't have a one-char version */ /* options which don't have a one-char version */
#define LOPT_RELOAD 256 #define LOPT_RELOAD 256
#define LOPT_NO_NAMES 257 #define LOPT_NO_NAMES 257
#define LOPT_TFTP 258 #define LOPT_TFTP 258
#define LOPT_SECURE 259 #define LOPT_SECURE 259
#define LOPT_PREFIX 260 #define LOPT_PREFIX 260
#define LOPT_PTR 261 #define LOPT_PTR 261
#define LOPT_BRIDGE 262 #define LOPT_BRIDGE 262
#define LOPT_TFTP_MAX 263 #define LOPT_TFTP_MAX 263
#define LOPT_FORCE 264 #define LOPT_FORCE 264
#define LOPT_NOBLOCK 265 #define LOPT_NOBLOCK 265
#define LOPT_LOG_OPTS 266 #define LOPT_LOG_OPTS 266
#define LOPT_MAX_LOGS 267 #define LOPT_MAX_LOGS 267
#define LOPT_CIRCUIT 268 #define LOPT_CIRCUIT 268
#define LOPT_REMOTE 269 #define LOPT_REMOTE 269
#define LOPT_SUBSCR 270 #define LOPT_SUBSCR 270
#define LOPT_INTNAME 271 #define LOPT_INTNAME 271
#define LOPT_BANK 272 #define LOPT_BANK 272
#define LOPT_DHCP_HOST 273 #define LOPT_DHCP_HOST 273
#define LOPT_APREF 274 #define LOPT_APREF 274
#define LOPT_OVERRIDE 275 #define LOPT_OVERRIDE 275
#define LOPT_TFTPPORTS 276 #define LOPT_TFTPPORTS 276
#define LOPT_REBIND 277 #define LOPT_REBIND 277
#define LOPT_NOLAST 278 #define LOPT_NOLAST 278
#define LOPT_OPTS 279 #define LOPT_OPTS 279
#define LOPT_DHCP_OPTS 280 #define LOPT_DHCP_OPTS 280
#define LOPT_MATCH 281 #define LOPT_MATCH 281
#define LOPT_BROADCAST 282 #define LOPT_BROADCAST 282
#define LOPT_NEGTTL 283 #define LOPT_NEGTTL 283
#define LOPT_ALTPORT 284 #define LOPT_ALTPORT 284
#define LOPT_SCRIPTUSR 285 #define LOPT_SCRIPTUSR 285
#define LOPT_LOCAL 286 #define LOPT_LOCAL 286
#define LOPT_NAPTR 287 #define LOPT_NAPTR 287
#define LOPT_MINPORT 288 #define LOPT_MINPORT 288
#define LOPT_DHCP_FQDN 289 #define LOPT_DHCP_FQDN 289
#define LOPT_CNAME 290 #define LOPT_CNAME 290
#define LOPT_PXE_PROMT 291 #define LOPT_PXE_PROMT 291
#define LOPT_PXE_SERV 292 #define LOPT_PXE_SERV 292
#define LOPT_TEST 293 #define LOPT_TEST 293
#define LOPT_TAG_IF 294 #define LOPT_TAG_IF 294
#define LOPT_PROXY 295 #define LOPT_PROXY 295
#define LOPT_GEN_NAMES 296 #define LOPT_GEN_NAMES 296
#define LOPT_MAXTTL 297 #define LOPT_MAXTTL 297
#define LOPT_NO_REBIND 298 #define LOPT_NO_REBIND 298
#define LOPT_LOC_REBND 299 #define LOPT_LOC_REBND 299
#define LOPT_ADD_MAC 300 #define LOPT_ADD_MAC 300
#define LOPT_DNSSEC 301 #define LOPT_DNSSEC 301
#define LOPT_INCR_ADDR 302 #define LOPT_INCR_ADDR 302
#define LOPT_CONNTRACK 303 #define LOPT_CONNTRACK 303
#define LOPT_FQDN 304 #define LOPT_FQDN 304
#define LOPT_LUASCRIPT 305 #define LOPT_LUASCRIPT 305
#define LOPT_RA 306 #define LOPT_RA 306
#define LOPT_DUID 307 #define LOPT_DUID 307
#define LOPT_HOST_REC 308 #define LOPT_HOST_REC 308
#define LOPT_TFTP_LC 309 #define LOPT_TFTP_LC 309
#define LOPT_RR 310 #define LOPT_RR 310
#define LOPT_CLVERBIND 311 #define LOPT_CLVERBIND 311
#define LOPT_MAXCTTL 312 #define LOPT_MAXCTTL 312
#define LOPT_AUTHZONE 313 #define LOPT_AUTHZONE 313
#define LOPT_AUTHSERV 314 #define LOPT_AUTHSERV 314
#define LOPT_AUTHTTL 315 #define LOPT_AUTHTTL 315
#define LOPT_AUTHSOA 316 #define LOPT_AUTHSOA 316
#define LOPT_AUTHSFS 317 #define LOPT_AUTHSFS 317
#define LOPT_AUTHPEER 318 #define LOPT_AUTHPEER 318
#define LOPT_IPSET 319 #define LOPT_IPSET 319
#define LOPT_SYNTH 320 #define LOPT_SYNTH 320
#ifdef OPTION6_PREFIX_CLASS #ifdef OPTION6_PREFIX_CLASS
#define LOPT_PREF_CLSS 321 #define LOPT_PREF_CLSS 321
#endif #endif
#define LOPT_RELAY 323 #define LOPT_RELAY 323
#define LOPT_RA_PARAM 324 #define LOPT_RA_PARAM 324
#define LOPT_ADD_SBNET 325 #define LOPT_ADD_SBNET 325
#define LOPT_QUIET_DHCP 326
#define LOPT_QUIET_DHCP6 327
#define LOPT_QUIET_RA 328
#ifdef HAVE_GETOPT_LONG #ifdef HAVE_GETOPT_LONG
...@@ -276,6 +279,9 @@ static const struct myoption opts[] = ...@@ -276,6 +279,9 @@ static const struct myoption opts[] =
#endif #endif
{ "dhcp-relay", 1, 0, LOPT_RELAY }, { "dhcp-relay", 1, 0, LOPT_RELAY },
{ "ra-param", 1, 0, LOPT_RA_PARAM }, { "ra-param", 1, 0, LOPT_RA_PARAM },
{ "quiet-dhcp", 0, 0, LOPT_QUIET_DHCP },
{ "quiet-dhcp6", 0, 0, LOPT_QUIET_DHCP6 },
{ "quiet-ra", 0, 0, LOPT_QUIET_RA },
{ NULL, 0, 0, 0 } { NULL, 0, 0, 0 }
}; };
...@@ -422,6 +428,9 @@ static struct { ...@@ -422,6 +428,9 @@ static struct {
{ LOPT_PREF_CLSS, ARG_DUP, "set:tag,<class>", gettext_noop("Specify DHCPv6 prefix class"), NULL }, { LOPT_PREF_CLSS, ARG_DUP, "set:tag,<class>", gettext_noop("Specify DHCPv6 prefix class"), NULL },
#endif #endif
{ LOPT_RA_PARAM, ARG_DUP, "<interface>,[high,|low,]<interval>[,<lifetime>]", gettext_noop("Set priority, resend-interval and router-lifetime"), NULL }, { LOPT_RA_PARAM, ARG_DUP, "<interface>,[high,|low,]<interval>[,<lifetime>]", gettext_noop("Set priority, resend-interval and router-lifetime"), NULL },
{ LOPT_QUIET_DHCP, OPT_QUIET_DHCP, NULL, gettext_noop("Do not log routine DHCP."), NULL },
{ LOPT_QUIET_DHCP6, OPT_QUIET_DHCP6, NULL, gettext_noop("Do not log routine DHCPv6."), NULL },
{ LOPT_QUIET_RA, OPT_QUIET_RA, NULL, gettext_noop("Do not log RA."), NULL },
{ 0, 0, NULL, NULL, NULL } { 0, 0, NULL, NULL, NULL }
}; };
......
...@@ -189,7 +189,8 @@ void icmp6_packet(time_t now) ...@@ -189,7 +189,8 @@ void icmp6_packet(time_t now)
mac = daemon->namebuff; mac = daemon->namebuff;
} }
my_syslog(MS_DHCP | LOG_INFO, "RTR-SOLICIT(%s) %s", interface, mac); if (!option_bool(OPT_QUIET_RA))
my_syslog(MS_DHCP | LOG_INFO, "RTR-SOLICIT(%s) %s", interface, mac);
/* source address may not be valid in solicit request. */ /* source address may not be valid in solicit request. */
send_ra(now, if_index, interface, !IN6_IS_ADDR_UNSPECIFIED(&from.sin6_addr) ? &from.sin6_addr : NULL); send_ra(now, if_index, interface, !IN6_IS_ADDR_UNSPECIFIED(&from.sin6_addr) ? &from.sin6_addr : NULL);
} }
...@@ -288,7 +289,8 @@ static void send_ra(time_t now, int iface, char *iface_name, struct in6_addr *de ...@@ -288,7 +289,8 @@ static void send_ra(time_t now, int iface, char *iface_name, struct in6_addr *de
opt->prefix = local; opt->prefix = local;
inet_ntop(AF_INET6, &local, daemon->addrbuff, ADDRSTRLEN); inet_ntop(AF_INET6, &local, daemon->addrbuff, ADDRSTRLEN);
my_syslog(MS_DHCP | LOG_INFO, "RTR-ADVERT(%s) %s old prefix", iface_name, daemon->addrbuff); if (!option_bool(OPT_QUIET_RA))
my_syslog(MS_DHCP | LOG_INFO, "RTR-ADVERT(%s) %s old prefix", iface_name, daemon->addrbuff);
} }
up = &context->next; up = &context->next;
...@@ -536,7 +538,8 @@ static int add_prefixes(struct in6_addr *local, int prefix, ...@@ -536,7 +538,8 @@ static int add_prefixes(struct in6_addr *local, int prefix,
opt->prefix = *local; opt->prefix = *local;
inet_ntop(AF_INET6, local, daemon->addrbuff, ADDRSTRLEN); inet_ntop(AF_INET6, local, daemon->addrbuff, ADDRSTRLEN);
my_syslog(MS_DHCP | LOG_INFO, "RTR-ADVERT(%s) %s", param->if_name, daemon->addrbuff); if (!option_bool(OPT_QUIET_RA))
my_syslog(MS_DHCP | LOG_INFO, "RTR-ADVERT(%s) %s", param->if_name, daemon->addrbuff);
} }
} }
......
...@@ -34,7 +34,7 @@ static void option_put_string(struct dhcp_packet *mess, unsigned char *end, ...@@ -34,7 +34,7 @@ static void option_put_string(struct dhcp_packet *mess, unsigned char *end,
static struct in_addr option_addr(unsigned char *opt); static struct in_addr option_addr(unsigned char *opt);
static unsigned int option_uint(unsigned char *opt, int i, int size); static unsigned int option_uint(unsigned char *opt, int i, int size);
static void log_packet(char *type, void *addr, unsigned char *ext_mac, static void log_packet(char *type, void *addr, unsigned char *ext_mac,
int mac_len, char *interface, char *string, u32 xid); int mac_len, char *interface, char *string, char *err, u32 xid);
static unsigned char *option_find(struct dhcp_packet *mess, size_t size, int opt_type, int minsize); static unsigned char *option_find(struct dhcp_packet *mess, size_t size, int opt_type, int minsize);
static unsigned char *option_find1(unsigned char *p, unsigned char *end, int opt, int minsize); static unsigned char *option_find1(unsigned char *p, unsigned char *end, int opt, int minsize);
static size_t dhcp_packet_size(struct dhcp_packet *mess, unsigned char *agent_id, unsigned char *real_end); static size_t dhcp_packet_size(struct dhcp_packet *mess, unsigned char *agent_id, unsigned char *real_end);
...@@ -610,7 +610,7 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index, ...@@ -610,7 +610,7 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
} }
} }
log_packet("BOOTP", logaddr, mess->chaddr, mess->hlen, iface_name, message, mess->xid); log_packet("BOOTP", logaddr, mess->chaddr, mess->hlen, iface_name, NULL, message, mess->xid);
return message ? 0 : dhcp_packet_size(mess, agent_id, real_end); return message ? 0 : dhcp_packet_size(mess, agent_id, real_end);
} }
...@@ -827,7 +827,7 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index, ...@@ -827,7 +827,7 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
opt71.next = daemon->dhcp_opts; opt71.next = daemon->dhcp_opts;
do_encap_opts(&opt71, OPTION_VENDOR_CLASS_OPT, DHOPT_VENDOR_MATCH, mess, end, 0); do_encap_opts(&opt71, OPTION_VENDOR_CLASS_OPT, DHOPT_VENDOR_MATCH, mess, end, 0);
log_packet("PXE", &mess->yiaddr, emac, emac_len, iface_name, (char *)mess->file, mess->xid); log_packet("PXE", &mess->yiaddr, emac, emac_len, iface_name, (char *)mess->file, NULL, mess->xid);
log_tags(tagif_netid, ntohl(mess->xid)); log_tags(tagif_netid, ntohl(mess->xid));
return dhcp_packet_size(mess, agent_id, real_end); return dhcp_packet_size(mess, agent_id, real_end);
} }
...@@ -887,7 +887,7 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index, ...@@ -887,7 +887,7 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
prune_vendor_opts(tagif_netid); prune_vendor_opts(tagif_netid);
do_encap_opts(pxe_opts(pxearch, tagif_netid, context->local, now), OPTION_VENDOR_CLASS_OPT, DHOPT_VENDOR_MATCH, mess, end, 0); do_encap_opts(pxe_opts(pxearch, tagif_netid, context->local, now), OPTION_VENDOR_CLASS_OPT, DHOPT_VENDOR_MATCH, mess, end, 0);
log_packet("PXE", NULL, emac, emac_len, iface_name, ignore ? "proxy-ignored" : "proxy", mess->xid); log_packet("PXE", NULL, emac, emac_len, iface_name, ignore ? "proxy-ignored" : "proxy", NULL, mess->xid);
log_tags(tagif_netid, ntohl(mess->xid)); log_tags(tagif_netid, ntohl(mess->xid));
return ignore ? 0 : dhcp_packet_size(mess, agent_id, real_end); return ignore ? 0 : dhcp_packet_size(mess, agent_id, real_end);
} }
...@@ -919,7 +919,7 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index, ...@@ -919,7 +919,7 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
if (!(opt = option_find(mess, sz, OPTION_REQUESTED_IP, INADDRSZ))) if (!(opt = option_find(mess, sz, OPTION_REQUESTED_IP, INADDRSZ)))
return 0; return 0;
log_packet("DHCPDECLINE", option_ptr(opt, 0), emac, emac_len, iface_name, daemon->dhcp_buff, mess->xid); log_packet("DHCPDECLINE", option_ptr(opt, 0), emac, emac_len, iface_name, NULL, daemon->dhcp_buff, mess->xid);
if (lease && lease->addr.s_addr == option_addr(opt).s_addr) if (lease && lease->addr.s_addr == option_addr(opt).s_addr)
lease_prune(lease, now); lease_prune(lease, now);
...@@ -951,7 +951,7 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index, ...@@ -951,7 +951,7 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
else else
message = _("unknown lease"); message = _("unknown lease");
log_packet("DHCPRELEASE", &mess->ciaddr, emac, emac_len, iface_name, message, mess->xid); log_packet("DHCPRELEASE", &mess->ciaddr, emac, emac_len, iface_name, NULL, message, mess->xid);
return 0; return 0;
...@@ -1015,7 +1015,7 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index, ...@@ -1015,7 +1015,7 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
message = _("no address available"); message = _("no address available");
} }
log_packet("DHCPDISCOVER", opt ? option_ptr(opt, 0) : NULL, emac, emac_len, iface_name, message, mess->xid); log_packet("DHCPDISCOVER", opt ? option_ptr(opt, 0) : NULL, emac, emac_len, iface_name, NULL, message, mess->xid);
if (message || !(context = narrow_context(context, mess->yiaddr, tagif_netid))) if (message || !(context = narrow_context(context, mess->yiaddr, tagif_netid)))
return 0; return 0;
...@@ -1028,7 +1028,7 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index, ...@@ -1028,7 +1028,7 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
log_tags(tagif_netid, ntohl(mess->xid)); log_tags(tagif_netid, ntohl(mess->xid));
log_packet("DHCPOFFER" , &mess->yiaddr, emac, emac_len, iface_name, NULL, mess->xid); log_packet("DHCPOFFER" , &mess->yiaddr, emac, emac_len, iface_name, NULL, NULL, mess->xid);
time = calc_time(context, config, option_find(mess, sz, OPTION_LEASE_TIME, 4)); time = calc_time(context, config, option_find(mess, sz, OPTION_LEASE_TIME, 4));
clear_packet(mess, end); clear_packet(mess, end);
...@@ -1144,7 +1144,7 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index, ...@@ -1144,7 +1144,7 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
mess->yiaddr = mess->ciaddr; mess->yiaddr = mess->ciaddr;
} }
log_packet("DHCPREQUEST", &mess->yiaddr, emac, emac_len, iface_name, NULL, mess->xid); log_packet("DHCPREQUEST", &mess->yiaddr, emac, emac_len, iface_name, NULL, NULL, mess->xid);
if (!message) if (!message)
{ {
...@@ -1216,7 +1216,7 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index, ...@@ -1216,7 +1216,7 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
if (message) if (message)
{ {
log_packet("DHCPNAK", &mess->yiaddr, emac, emac_len, iface_name, message, mess->xid); log_packet("DHCPNAK", &mess->yiaddr, emac, emac_len, iface_name, NULL, message, mess->xid);
mess->yiaddr.s_addr = 0; mess->yiaddr.s_addr = 0;
clear_packet(mess, end); clear_packet(mess, end);
...@@ -1355,7 +1355,7 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index, ...@@ -1355,7 +1355,7 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
else else
override = lease->override; override = lease->override;
log_packet("DHCPACK", &mess->yiaddr, emac, emac_len, iface_name, hostname, mess->xid); log_packet("DHCPACK", &mess->yiaddr, emac, emac_len, iface_name, hostname, NULL, mess->xid);
clear_packet(mess, end); clear_packet(mess, end);
option_put(mess, end, OPTION_MESSAGE_TYPE, 1, DHCPACK); option_put(mess, end, OPTION_MESSAGE_TYPE, 1, DHCPACK);
...@@ -1378,7 +1378,7 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index, ...@@ -1378,7 +1378,7 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
if (ignore || have_config(config, CONFIG_DISABLE)) if (ignore || have_config(config, CONFIG_DISABLE))
message = _("ignored"); message = _("ignored");
log_packet("DHCPINFORM", &mess->ciaddr, emac, emac_len, iface_name, message, mess->xid); log_packet("DHCPINFORM", &mess->ciaddr, emac, emac_len, iface_name, message, NULL, mess->xid);
if (message || mess->ciaddr.s_addr == 0) if (message || mess->ciaddr.s_addr == 0)
return 0; return 0;
...@@ -1404,7 +1404,7 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index, ...@@ -1404,7 +1404,7 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
log_tags(tagif_netid, ntohl(mess->xid)); log_tags(tagif_netid, ntohl(mess->xid));
log_packet("DHCPACK", &mess->ciaddr, emac, emac_len, iface_name, hostname, mess->xid); log_packet("DHCPACK", &mess->ciaddr, emac, emac_len, iface_name, hostname, NULL, mess->xid);
if (lease) if (lease)
{ {
...@@ -1538,10 +1538,13 @@ static void add_extradata_opt(struct dhcp_lease *lease, unsigned char *opt) ...@@ -1538,10 +1538,13 @@ static void add_extradata_opt(struct dhcp_lease *lease, unsigned char *opt)
#endif #endif
static void log_packet(char *type, void *addr, unsigned char *ext_mac, static void log_packet(char *type, void *addr, unsigned char *ext_mac,
int mac_len, char *interface, char *string, u32 xid) int mac_len, char *interface, char *string, char *err, u32 xid)
{ {
struct in_addr a; struct in_addr a;
if (!err && (!option_bool(OPT_LOG_OPTS) || option_bool(OPT_QUIET_DHCP)))
return;
/* addr may be misaligned */ /* addr may be misaligned */
if (addr) if (addr)
memcpy(&a, addr, sizeof(a)); memcpy(&a, addr, sizeof(a));
...@@ -1549,22 +1552,24 @@ static void log_packet(char *type, void *addr, unsigned char *ext_mac, ...@@ -1549,22 +1552,24 @@ static void log_packet(char *type, void *addr, unsigned char *ext_mac,
print_mac(daemon->namebuff, ext_mac, mac_len); print_mac(daemon->namebuff, ext_mac, mac_len);
if(option_bool(OPT_LOG_OPTS)) if(option_bool(OPT_LOG_OPTS))
my_syslog(MS_DHCP | LOG_INFO, "%u %s(%s) %s%s%s %s", my_syslog(MS_DHCP | LOG_INFO, "%u %s(%s) %s%s%s %s%s",
ntohl(xid), ntohl(xid),
type, type,
interface, interface,
addr ? inet_ntoa(a) : "", addr ? inet_ntoa(a) : "",
addr ? " " : "", addr ? " " : "",
daemon->namebuff, daemon->namebuff,
string ? string : ""); string ? string : "",
err ? err : "");
else else
my_syslog(MS_DHCP | LOG_INFO, "%s(%s) %s%s%s %s", my_syslog(MS_DHCP | LOG_INFO, "%s(%s) %s%s%s %s%s",
type, type,
interface, interface,
addr ? inet_ntoa(a) : "", addr ? inet_ntoa(a) : "",
addr ? " " : "", addr ? " " : "",
daemon->namebuff, daemon->namebuff,
string ? string : ""); string ? string : "",
err ? err : "");
} }
static void log_options(unsigned char *start, u32 xid) static void log_options(unsigned char *start, u32 xid)
......
...@@ -41,6 +41,7 @@ static int dhcp6_maybe_relay(struct state *state, void *inbuff, size_t sz, ...@@ -41,6 +41,7 @@ static int dhcp6_maybe_relay(struct state *state, void *inbuff, size_t sz,
static int dhcp6_no_relay(struct state *state, int msg_type, void *inbuff, size_t sz, int is_unicast, time_t now); static int dhcp6_no_relay(struct state *state, int msg_type, void *inbuff, size_t sz, int is_unicast, time_t now);
static void log6_opts(int nest, unsigned int xid, void *start_opts, void *end_opts); static void log6_opts(int nest, unsigned int xid, void *start_opts, void *end_opts);
static void log6_packet(struct state *state, char *type, struct in6_addr *addr, char *string); static void log6_packet(struct state *state, char *type, struct in6_addr *addr, char *string);
static void log6_quiet(struct state *state, char *type, struct in6_addr *addr, char *string);
static void *opt6_find (void *opts, void *end, unsigned int search, unsigned int minsize); static void *opt6_find (void *opts, void *end, unsigned int search, unsigned int minsize);
static void *opt6_next(void *opts, void *end); static void *opt6_next(void *opts, void *end);
static unsigned int opt6_uint(unsigned char *opt, int offset, int size); static unsigned int opt6_uint(unsigned char *opt, int offset, int size);
...@@ -595,7 +596,7 @@ static int dhcp6_no_relay(struct state *state, int msg_type, void *inbuff, size_ ...@@ -595,7 +596,7 @@ static int dhcp6_no_relay(struct state *state, int msg_type, void *inbuff, size_
end_opt6(o); end_opt6(o);
} }
log6_packet(state, "DHCPSOLICIT", NULL, ignore ? _("ignored") : NULL); log6_quiet(state, "DHCPSOLICIT", NULL, ignore ? _("ignored") : NULL);
request_no_address: request_no_address:
solicit_tags = tagif; solicit_tags = tagif;
...@@ -815,7 +816,7 @@ static int dhcp6_no_relay(struct state *state, int msg_type, void *inbuff, size_ ...@@ -815,7 +816,7 @@ static int dhcp6_no_relay(struct state *state, int msg_type, void *inbuff, size_
*outmsgtypep = DHCP6REPLY; *outmsgtypep = DHCP6REPLY;
state->lease_allocate = 1; state->lease_allocate = 1;
log6_packet(state, "DHCPREQUEST", NULL, ignore ? _("ignored") : NULL); log6_quiet(state, "DHCPREQUEST", NULL, ignore ? _("ignored") : NULL);
if (ignore) if (ignore)
return 0; return 0;
...@@ -928,7 +929,7 @@ static int dhcp6_no_relay(struct state *state, int msg_type, void *inbuff, size_ ...@@ -928,7 +929,7 @@ static int dhcp6_no_relay(struct state *state, int msg_type, void *inbuff, size_
/* set reply message type */ /* set reply message type */
*outmsgtypep = DHCP6REPLY; *outmsgtypep = DHCP6REPLY;
log6_packet(state, "DHCPRENEW", NULL, NULL); log6_quiet(state, "DHCPRENEW", NULL, NULL);
for (opt = state->packet_options; opt; opt = opt6_next(opt, state->end)) for (opt = state->packet_options; opt; opt = opt6_next(opt, state->end))
{ {
...@@ -1011,8 +1012,11 @@ static int dhcp6_no_relay(struct state *state, int msg_type, void *inbuff, size_ ...@@ -1011,8 +1012,11 @@ static int dhcp6_no_relay(struct state *state, int msg_type, void *inbuff, size_
message = _("address invalid"); message = _("address invalid");
} }
log6_packet(state, "DHCPREPLY", req_addr, message); if (message)
log6_packet(state, "DHCPREPLY", req_addr, message);
else
log6_quiet(state, "DHCPREPLY", req_addr, message);
o1 = new_opt6(OPTION6_IAADDR); o1 = new_opt6(OPTION6_IAADDR);
put_opt6(req_addr, sizeof(*req_addr)); put_opt6(req_addr, sizeof(*req_addr));
put_opt6_long(preferred_time); put_opt6_long(preferred_time);
...@@ -1034,7 +1038,7 @@ static int dhcp6_no_relay(struct state *state, int msg_type, void *inbuff, size_ ...@@ -1034,7 +1038,7 @@ static int dhcp6_no_relay(struct state *state, int msg_type, void *inbuff, size_
/* set reply message type */ /* set reply message type */
*outmsgtypep = DHCP6REPLY; *outmsgtypep = DHCP6REPLY;
log6_packet(state, "DHCPCONFIRM", NULL, NULL); log6_quiet(state, "DHCPCONFIRM", NULL, NULL);
for (opt = state->packet_options; opt; opt = opt6_next(opt, state->end)) for (opt = state->packet_options; opt; opt = opt6_next(opt, state->end))
{ {
...@@ -1055,7 +1059,7 @@ static int dhcp6_no_relay(struct state *state, int msg_type, void *inbuff, size_ ...@@ -1055,7 +1059,7 @@ static int dhcp6_no_relay(struct state *state, int msg_type, void *inbuff, size_
return 1; return 1;
} }
log6_packet(state, "DHCPREPLY", req_addr, state->hostname); log6_quiet(state, "DHCPREPLY", req_addr, state->hostname);
} }
} }
...@@ -1084,7 +1088,7 @@ static int dhcp6_no_relay(struct state *state, int msg_type, void *inbuff, size_ ...@@ -1084,7 +1088,7 @@ static int dhcp6_no_relay(struct state *state, int msg_type, void *inbuff, size_
else else
state->send_domain = get_domain6(NULL); state->send_domain = get_domain6(NULL);
log6_packet(state, "DHCPINFORMATION-REQUEST", NULL, ignore ? _("ignored") : state->hostname); log6_quiet(state, "DHCPINFORMATION-REQUEST", NULL, ignore ? _("ignored") : state->hostname);
if (ignore) if (ignore)
return 0; return 0;
*outmsgtypep = DHCP6REPLY; *outmsgtypep = DHCP6REPLY;
...@@ -1098,7 +1102,7 @@ static int dhcp6_no_relay(struct state *state, int msg_type, void *inbuff, size_ ...@@ -1098,7 +1102,7 @@ static int dhcp6_no_relay(struct state *state, int msg_type, void *inbuff, size_
/* set reply message type */ /* set reply message type */
*outmsgtypep = DHCP6REPLY; *outmsgtypep = DHCP6REPLY;
log6_packet(state, "DHCPRELEASE", NULL, NULL); log6_quiet(state, "DHCPRELEASE", NULL, NULL);
for (opt = state->packet_options; opt; opt = opt6_next(opt, state->end)) for (opt = state->packet_options; opt; opt = opt6_next(opt, state->end))
{ {
...@@ -1160,7 +1164,7 @@ static int dhcp6_no_relay(struct state *state, int msg_type, void *inbuff, size_ ...@@ -1160,7 +1164,7 @@ static int dhcp6_no_relay(struct state *state, int msg_type, void *inbuff, size_
/* set reply message type */ /* set reply message type */
*outmsgtypep = DHCP6REPLY; *outmsgtypep = DHCP6REPLY;
log6_packet(state, "DHCPDECLINE", NULL, NULL); log6_quiet(state, "DHCPDECLINE", NULL, NULL);
for (opt = state->packet_options; opt; opt = opt6_next(opt, state->end)) for (opt = state->packet_options; opt; opt = opt6_next(opt, state->end))
{ {
...@@ -1610,7 +1614,7 @@ static void add_address(struct state *state, struct dhcp_context *context, unsig ...@@ -1610,7 +1614,7 @@ static void add_address(struct state *state, struct dhcp_context *context, unsig
} }
} }
log6_packet(state, state->lease_allocate ? "DHCPREPLY" : "DHCPADVERTISE", addr, state->hostname); log6_quiet(state, state->lease_allocate ? "DHCPREPLY" : "DHCPADVERTISE", addr, state->hostname);
} }
...@@ -1880,6 +1884,12 @@ static void log6_opts(int nest, unsigned int xid, void *start_opts, void *end_op ...@@ -1880,6 +1884,12 @@ static void log6_opts(int nest, unsigned int xid, void *start_opts, void *end_op
} }
} }
static void log6_quiet(struct state *state, char *type, struct in6_addr *addr, char *string)
{
if (option_bool(OPT_LOG_OPTS) || !option_bool(OPT_QUIET_DHCP6))
log6_packet(state, type, addr, string);
}
static void log6_packet(struct state *state, char *type, struct in6_addr *addr, char *string) static void log6_packet(struct state *state, char *type, struct in6_addr *addr, char *string)
{ {
int clid_len = state->clid_len; int clid_len = state->clid_len;
......
...@@ -200,7 +200,8 @@ void slaac_ping_reply(struct in6_addr *sender, unsigned char *packet, char *inte ...@@ -200,7 +200,8 @@ void slaac_ping_reply(struct in6_addr *sender, unsigned char *packet, char *inte
slaac->backoff = 0; slaac->backoff = 0;
gotone = 1; gotone = 1;
inet_ntop(AF_INET6, sender, daemon->addrbuff, ADDRSTRLEN); inet_ntop(AF_INET6, sender, daemon->addrbuff, ADDRSTRLEN);
my_syslog(MS_DHCP | LOG_INFO, "SLAAC-CONFIRM(%s) %s %s", interface, daemon->addrbuff, lease->hostname); if (!option_bool(OPT_QUIET_DHCP6))
my_syslog(MS_DHCP | LOG_INFO, "SLAAC-CONFIRM(%s) %s %s", interface, daemon->addrbuff, lease->hostname);
} }
lease_update_dns(gotone); lease_update_dns(gotone);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment