From d60f0a6284e8f5fac733a1b269ea614ccdf47fcd Mon Sep 17 00:00:00 2001 From: Hans Dedecker Date: Sun, 15 Dec 2019 20:17:32 +0100 Subject: [PATCH] treewide: optimize syslog priority values Signed-off-by: Hans Dedecker --- src/dhcpv4.c | 31 ++++++++++++++++--------------- src/dhcpv6-ia.c | 6 +++--- src/dhcpv6.c | 12 ++++++------ src/ndp.c | 4 ++-- src/router.c | 2 +- 5 files changed, 28 insertions(+), 27 deletions(-) diff --git a/src/dhcpv4.c b/src/dhcpv4.c index 34d925c..1deb097 100644 --- a/src/dhcpv4.c +++ b/src/dhcpv4.c @@ -214,12 +214,12 @@ static int setup_dhcpv4_addresses(struct interface *iface) if (iface->dhcpv4_start.s_addr & htonl(0xffff0000) || iface->dhcpv4_end.s_addr & htonl(0xffff0000) || ntohl(iface->dhcpv4_start.s_addr) > ntohl(iface->dhcpv4_end.s_addr)) { - syslog(LOG_ERR, "Invalid DHCP range for %s", iface->name); + syslog(LOG_WARNING, "Invalid DHCP range for %s", iface->name); return -1; } if (!iface->addr4_len) { - syslog(LOG_ERR, "No network(s) available on %s", iface->name); + syslog(LOG_WARNING, "No network(s) available on %s", iface->name); return -1; } @@ -250,7 +250,7 @@ static int setup_dhcpv4_addresses(struct interface *iface) /* Don't allocate IP range for subnets bigger than 28 */ if (iface->addr4[0].prefix > 28) { - syslog(LOG_ERR, "Auto allocation of DHCP range fails on %s", iface->name); + syslog(LOG_WARNING, "Auto allocation of DHCP range fails on %s", iface->name); return -1; } @@ -383,7 +383,7 @@ static void handle_addrlist_change(struct interface *iface) a = list_first_entry(&iface->dhcpv4_fr_ips, struct odhcpd_ref_ip, head); if (netlink_setup_addr(&a->addr, iface->ifindex, false, true)) { - syslog(LOG_ERR, "Failed to add ip address on %s", iface->name); + syslog(LOG_WARNING, "Failed to add ip address on %s", iface->name); return; } @@ -533,7 +533,7 @@ static void dhcpv4_fr_send(struct dhcp_assignment *a) syslog(LOG_ERR, "Failed to send %s to %s - %s: %m", dhcpv4_msg_to_string(msg), odhcpd_print_mac(a->hwaddr, sizeof(a->hwaddr)), inet_ntoa(dest.sin_addr)); else - syslog(LOG_NOTICE, "Sent %s to %s - %s", dhcpv4_msg_to_string(msg), + syslog(LOG_DEBUG, "Sent %s to %s - %s", dhcpv4_msg_to_string(msg), odhcpd_print_mac(a->hwaddr, sizeof(a->hwaddr)), inet_ntoa(dest.sin_addr)); } @@ -601,10 +601,10 @@ static void handle_dhcpv4(void *addr, void *data, size_t len, req->op != DHCPV4_BOOTREQUEST || req->hlen != 6) return; - syslog(LOG_NOTICE, "Got DHCPv4 request on %s", iface->name); + syslog(LOG_DEBUG, "Got DHCPv4 request on %s", iface->name); if (!iface->dhcpv4_start_ip.s_addr && !iface->dhcpv4_end_ip.s_addr) { - syslog(LOG_ERR, "No DHCP range available on %s", iface->name); + syslog(LOG_WARNING, "No DHCP range available on %s", iface->name); return; } @@ -734,7 +734,7 @@ static void handle_dhcpv4(void *addr, void *data, size_t len, req->ciaddr.s_addr = INADDR_ANY; } - syslog(LOG_NOTICE, "Received %s from %s on %s", dhcpv4_msg_to_string(reqmsg), + syslog(LOG_INFO, "Received %s from %s on %s", dhcpv4_msg_to_string(reqmsg), odhcpd_print_mac(req->chaddr, req->hlen), iface->name); #ifdef WITH_UBUS @@ -886,7 +886,7 @@ static void handle_dhcpv4(void *addr, void *data, size_t len, "ff:ff:ff:ff:ff:ff": odhcpd_print_mac(req->chaddr, req->hlen), inet_ntoa(dest.sin_addr)); else - syslog(LOG_NOTICE, "Sent %s to %s - %s", + syslog(LOG_DEBUG, "Sent %s to %s - %s", dhcpv4_msg_to_string(msg), dest.sin_addr.s_addr == INADDR_BROADCAST ? "ff:ff:ff:ff:ff:ff": odhcpd_print_mac(req->chaddr, req->hlen), @@ -949,7 +949,7 @@ static bool dhcpv4_assign(struct interface *iface, struct dhcp_assignment *a, a, a->addr); if (assigned) - syslog(LOG_INFO, "Assigning static IP: %s", ip4toa(a->addr)); + syslog(LOG_DEBUG, "Assigning static IP: %s", ip4toa(a->addr)); return assigned; } @@ -961,7 +961,7 @@ static bool dhcpv4_assign(struct interface *iface, struct dhcp_assignment *a, a, raddr); if (assigned) { - syslog(LOG_INFO, "Assigning the IP the client asked for: %s", + syslog(LOG_DEBUG, "Assigning the IP the client asked for: %s", ip4toa(a->addr)); return true; @@ -988,14 +988,15 @@ static bool dhcpv4_assign(struct interface *iface, struct dhcp_assignment *a, a, n_try); if (assigned) { - syslog(LOG_INFO, "Assigning mapped IP: %s (try %u of %u)", + syslog(LOG_DEBUG, "Assigning mapped IP: %s (try %u of %u)", ip4toa(a->addr), i + 1, count); return true; } } - syslog(LOG_WARNING, "Can't assign any IP address -> address space is full"); + syslog(LOG_NOTICE, "Can't assign any IP address -> address space is full"); + return false; } @@ -1028,8 +1029,8 @@ dhcpv4_lease(struct interface *iface, enum dhcpv4_msg msg, const uint8_t *mac, /* Create new binding */ a = alloc_assignment(0); if (!a) { - syslog(LOG_ERR, "Failed to alloc assignment on interface %s", - iface->ifname); + syslog(LOG_WARNING, "Failed to alloc assignment on interface %s", + iface->ifname); return NULL; } memcpy(a->hwaddr, mac, sizeof(a->hwaddr)); diff --git a/src/dhcpv6-ia.c b/src/dhcpv6-ia.c index da2501f..6a09b2f 100644 --- a/src/dhcpv6-ia.c +++ b/src/dhcpv6-ia.c @@ -71,7 +71,7 @@ int dhcpv6_ia_setup_interface(struct interface *iface, bool enable) border = alloc_assignment(0); if (!border) { - syslog(LOG_ERR, "Failed to alloc border on %s", iface->name); + syslog(LOG_WARNING, "Failed to alloc border on %s", iface->name); return -1; } @@ -1065,8 +1065,8 @@ static void dhcpv6_log(uint8_t msgtype, struct interface *iface, time_t now, dhcpv6_ia_enum_addrs(iface, a, now, dhcpv6_log_ia_addr, &ctxt); } - syslog(LOG_NOTICE, "DHCPV6 %s %s from %s on %s: %s %s", type, (is_pd) ? "IA_PD" : "IA_NA", - duidbuf, iface->name, status, leasebuf); + syslog(LOG_INFO, "DHCPV6 %s %s from %s on %s: %s %s", type, (is_pd) ? "IA_PD" : "IA_NA", + duidbuf, iface->name, status, leasebuf); } static bool dhcpv6_ia_on_link(const struct dhcpv6_ia_hdr *ia, struct dhcp_assignment *a, diff --git a/src/dhcpv6.c b/src/dhcpv6.c index c61a8aa..21b95fa 100644 --- a/src/dhcpv6.c +++ b/src/dhcpv6.c @@ -246,7 +246,7 @@ static void handle_client_request(void *addr, void *data, size_t len, if (len < sizeof(*hdr)) return; - syslog(LOG_NOTICE, "Got a DHCPv6-request on %s", iface->name); + syslog(LOG_DEBUG, "Got a DHCPv6-request on %s", iface->name); /* Construct reply message */ struct __attribute__((packed)) { @@ -452,7 +452,7 @@ static void handle_client_request(void *addr, void *data, size_t len, iov[IOV_CERID].iov_len + iov[IOV_DHCPV6_RAW].iov_len - (4 + opts_end - opts)); - syslog(LOG_NOTICE, "Sending a DHCPv6-%s on %s", iov[IOV_NESTED].iov_len ? "relay-reply" : "reply", iface->name); + syslog(LOG_DEBUG, "Sending a DHCPv6-%s on %s", iov[IOV_NESTED].iov_len ? "relay-reply" : "reply", iface->name); odhcpd_send(iface->dhcpv6_event.uloop.fd, addr, iov, ARRAY_SIZE(iov), iface); } @@ -487,7 +487,7 @@ static void relay_server_response(uint8_t *data, size_t len) /* Relay DHCPv6 reply from server to client */ struct dhcpv6_relay_header *h = (void*)data; - syslog(LOG_NOTICE, "Got a DHCPv6-relay-reply"); + syslog(LOG_DEBUG, "Got a DHCPv6-relay-reply"); if (len < sizeof(*h) || h->msg_type != DHCPV6_MSG_RELAY_REPL) return; @@ -557,7 +557,7 @@ static void relay_server_response(uint8_t *data, size_t len) struct iovec iov = {payload_data, payload_len}; - syslog(LOG_NOTICE, "Sending a DHCPv6-reply on %s", iface->name); + syslog(LOG_DEBUG, "Sending a DHCPv6-reply on %s", iface->name); odhcpd_send(iface->dhcpv6_event.uloop.fd, &target, &iov, 1, iface); } @@ -608,7 +608,7 @@ static void relay_client_request(struct sockaddr_in6 *source, h->msg_type == DHCPV6_MSG_ADVERTISE) return; /* Invalid message types for client */ - syslog(LOG_NOTICE, "Got a DHCPv6-request on %s", iface->name); + syslog(LOG_DEBUG, "Got a DHCPv6-request on %s", iface->name); if (h->msg_type == DHCPV6_MSG_RELAY_FORW) { /* handle relay-forward */ if (h->hop_count >= DHCPV6_HOP_COUNT_LIMIT) @@ -649,7 +649,7 @@ static void relay_client_request(struct sockaddr_in6 *source, ip = NULL; } - syslog(LOG_NOTICE, "Sending a DHCPv6-relay-forward on %s", c->name); + syslog(LOG_DEBUG, "Sending a DHCPv6-relay-forward on %s", c->name); odhcpd_send(c->dhcpv6_event.uloop.fd, &s, iov, 2, c); } diff --git a/src/ndp.c b/src/ndp.c index 1facceb..dfbb111 100644 --- a/src/ndp.c +++ b/src/ndp.c @@ -288,7 +288,7 @@ static void ping6(struct in6_addr *addr, char ipbuf[INET6_ADDRSTRLEN]; inet_ntop(AF_INET6, addr, ipbuf, sizeof(ipbuf)); - syslog(LOG_NOTICE, "Pinging for %s on %s", ipbuf, iface->name); + syslog(LOG_DEBUG, "Pinging for %s on %s", ipbuf, iface->name); netlink_setup_route(addr, 128, iface->ifindex, NULL, 128, true); odhcpd_send(iface->ndp_ping_fd, &dest, &iov, 1, iface); @@ -381,7 +381,7 @@ static void setup_route(struct in6_addr *addr, struct interface *iface, bool add char ipbuf[INET6_ADDRSTRLEN]; inet_ntop(AF_INET6, addr, ipbuf, sizeof(ipbuf)); - syslog(LOG_NOTICE, "%s about %s%s on %s", + syslog(LOG_DEBUG, "%s about %s%s on %s", (add) ? "Learning" : "Forgetting", iface->learn_routes ? "proxy routing for " : "", ipbuf, iface->name); diff --git a/src/router.c b/src/router.c index 700e1ff..7c97672 100644 --- a/src/router.c +++ b/src/router.c @@ -600,7 +600,7 @@ static int send_router_advert(struct interface *iface, const struct in6_addr *fr } else adv.h.nd_ra_router_lifetime = 0; - syslog(LOG_INFO, "Using a RA lifetime of %d seconds on %s", ntohs(adv.h.nd_ra_router_lifetime), iface->name); + syslog(LOG_DEBUG, "Using a RA lifetime of %d seconds on %s", ntohs(adv.h.nd_ra_router_lifetime), iface->name); /* DNS options */ if (iface->ra_dns) { -- 2.25.1