diff options
-rw-r--r-- | src/dhcpv4.c | 25 | ||||
-rw-r--r-- | src/dhcpv6-ia.c | 8 | ||||
-rw-r--r-- | src/dhcpv6.c | 2 | ||||
-rw-r--r-- | src/ndp.c | 16 | ||||
-rw-r--r-- | src/netlink.c | 12 | ||||
-rw-r--r-- | src/odhcpd.c | 16 | ||||
-rw-r--r-- | src/router.c | 40 |
7 files changed, 59 insertions, 60 deletions
diff --git a/src/dhcpv4.c b/src/dhcpv4.c index 2cc6278..4a74b8a 100644 --- a/src/dhcpv4.c +++ b/src/dhcpv4.c @@ -229,12 +229,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_ERR, "Invalid DHCP range for %s", iface->name); return -1; } if (!iface->addr4_len) { - syslog(LOG_WARNING, "no network(s) available on %s", iface->name); + syslog(LOG_WARNING, "No network(s) available on %s", iface->name); return -1; } @@ -264,7 +264,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_WARNING, "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; } @@ -321,8 +321,7 @@ static void update_static_assignments(struct interface *iface) /* Construct entry */ a = calloc(1, sizeof(*a)); if (!a) { - syslog(LOG_ERR, "Calloc failed for static lease on interface %s", - iface->ifname); + syslog(LOG_ERR, "Calloc failed for static lease on %s", iface->name); continue; } memcpy(a->hwaddr, lease->mac.ether_addr_octet, sizeof(a->hwaddr)); @@ -455,7 +454,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"); + syslog(LOG_ERR, "Failed to add ip address on %s", iface->name); return; } @@ -674,7 +673,7 @@ static void handle_dhcpv4(void *addr, void *data, size_t len, return; - syslog(LOG_NOTICE, "Got DHCPv4 request"); + syslog(LOG_NOTICE, "Got DHCPv4 request on %s", iface->name); if (!iface->dhcpv4_start_ip.s_addr && !iface->dhcpv4_end_ip.s_addr) { syslog(LOG_WARNING, "No DHCP range available on %s", iface->name); @@ -800,8 +799,8 @@ static void handle_dhcpv4(void *addr, void *data, size_t len, req->ciaddr.s_addr = INADDR_ANY; } - syslog(LOG_WARNING, "received %s from %s", dhcpv4_msg_to_string(reqmsg), - odhcpd_print_mac(req->chaddr, req->hlen)); + syslog(LOG_WARNING, "Received %s from %s on %s", dhcpv4_msg_to_string(reqmsg), + odhcpd_print_mac(req->chaddr, req->hlen), iface->name); #ifdef WITH_UBUS if (reqmsg == DHCPV4_MSG_RELEASE) @@ -977,7 +976,7 @@ static bool dhcpv4_assign(struct interface *iface, if (start <= ntohl(raddr) && ntohl(raddr) <= end && !find_assignment_by_addr(iface, raddr)) { assign->addr = raddr; - syslog(LOG_INFO, "assigning the IP the client asked for: %u.%u.%u.%u", + syslog(LOG_INFO, "Assigning the IP the client asked for: %u.%u.%u.%u", ((uint8_t *)&assign->addr)[0], ((uint8_t *)&assign->addr)[1], ((uint8_t *)&assign->addr)[2], @@ -999,7 +998,7 @@ static bool dhcpv4_assign(struct interface *iface, if (list_empty(&iface->dhcpv4_assignments)) { assign->addr = htonl(try); - syslog(LOG_INFO, "assigning mapped IP (empty list): %u.%u.%u.%u", + syslog(LOG_INFO, "Assigning mapped IP (empty list): %u.%u.%u.%u", ((uint8_t *)&assign->addr)[0], ((uint8_t *)&assign->addr)[1], ((uint8_t *)&assign->addr)[2], @@ -1011,7 +1010,7 @@ static bool dhcpv4_assign(struct interface *iface, if (!find_assignment_by_addr(iface, htonl(try))) { /* test was successful: IP address is not assigned, assign it */ assign->addr = htonl(try); - syslog(LOG_DEBUG, "assigning mapped IP: %u.%u.%u.%u (try %u of %u)", + syslog(LOG_DEBUG, "Assigning mapped IP: %u.%u.%u.%u (try %u of %u)", ((uint8_t *)&assign->addr)[0], ((uint8_t *)&assign->addr)[1], ((uint8_t *)&assign->addr)[2], @@ -1022,7 +1021,7 @@ static bool dhcpv4_assign(struct interface *iface, try = (((try - start) + 1) % count) + start; } - syslog(LOG_WARNING, "can't assign any IP address -> address space is full"); + syslog(LOG_WARNING, "Can't assign any IP address -> address space is full"); return false; } diff --git a/src/dhcpv6-ia.c b/src/dhcpv6-ia.c index b9120d3..06e418a 100644 --- a/src/dhcpv6-ia.c +++ b/src/dhcpv6-ia.c @@ -83,7 +83,7 @@ int dhcpv6_setup_ia_interface(struct interface *iface, bool enable) border = calloc(1, sizeof(*border)); if (!border) { - syslog(LOG_ERR, "Calloc failed for border on interface %s", iface->ifname); + syslog(LOG_ERR, "Calloc failed for border on %s", iface->name); return -1; } @@ -100,8 +100,8 @@ int dhcpv6_setup_ia_interface(struct interface *iface, bool enable) size_t duid_len = lease->duid_len ? lease->duid_len : 14; struct dhcpv6_assignment *a = calloc(1, sizeof(*a) + duid_len); if (!a) { - syslog(LOG_ERR, "Calloc failed for static lease assignment on interface %s", - iface->ifname); + syslog(LOG_ERR, "Calloc failed for static lease assignment on %s", + iface->name); return -1; } @@ -1111,7 +1111,7 @@ static void dhcpv6_log(uint8_t msgtype, struct interface *iface, time_t now, } syslog(LOG_WARNING, "DHCPV6 %s %s from %s on %s: %s %s", type, (is_pd) ? "IA_PD" : "IA_NA", - duidbuf, iface->ifname, status, leasebuf); + duidbuf, iface->name, status, leasebuf); } static bool dhcpv6_ia_on_link(const struct dhcpv6_ia_hdr *ia, struct dhcpv6_assignment *a, diff --git a/src/dhcpv6.c b/src/dhcpv6.c index 59bc422..58b3bd7 100644 --- a/src/dhcpv6.c +++ b/src/dhcpv6.c @@ -239,7 +239,7 @@ static void handle_client_request(void *addr, void *data, size_t len, if (len < sizeof(*hdr)) return; - syslog(LOG_NOTICE, "Got DHCPv6 request"); + syslog(LOG_NOTICE, "Got DHCPv6 request on %s", iface->name); /* Construct reply message */ struct __attribute__((packed)) { @@ -270,7 +270,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%%%s", ipbuf, iface->ifname); + syslog(LOG_NOTICE, "Pinging for %s on %s", ipbuf, iface->name); netlink_setup_route(addr, 128, iface->ifindex, NULL, 128, true); odhcpd_send(ping_socket, &dest, &iov, 1, iface); @@ -305,7 +305,7 @@ static void handle_solicit(void *addr, void *data, size_t len, return; /* Invalid target */ inet_ntop(AF_INET6, &req->nd_ns_target, ipbuf, sizeof(ipbuf)); - syslog(LOG_DEBUG, "Got a NS for %s%%%s", ipbuf, iface->ifname); + syslog(LOG_DEBUG, "Got a NS for %s on %s", ipbuf, iface->name); odhcpd_get_mac(iface, mac); if (!memcmp(ll->sll_addr, mac, sizeof(mac))) @@ -324,10 +324,10 @@ 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%%%s", + syslog(LOG_NOTICE, "%s about %s%s on %s", (add) ? "Learning" : "Forgetting", iface->learn_routes ? "proxy routing for " : "", - ipbuf, iface->ifname); + ipbuf, iface->name); if (iface->learn_routes) netlink_setup_route(addr, 128, iface->ifindex, NULL, 1024, add); @@ -347,10 +347,10 @@ static void setup_addr_for_relaying(struct in6_addr *addr, struct interface *ifa bool neigh_add = (c->ndp == MODE_RELAY ? add : false); if (netlink_setup_proxy_neigh(addr, c->ifindex, neigh_add)) - syslog(LOG_DEBUG, "Failed to %s proxy neighbour entry %s%%%s", - neigh_add ? "add" : "delete", ipbuf, c->ifname); + syslog(LOG_DEBUG, "Failed to %s proxy neighbour entry %s on %s", + neigh_add ? "add" : "delete", ipbuf, c->name); else - syslog(LOG_DEBUG, "%s proxy neighbour entry %s%%%s", - neigh_add ? "Added" : "Deleted", ipbuf, c->ifname); + syslog(LOG_DEBUG, "%s proxy neighbour entry %s on %s", + neigh_add ? "Added" : "Deleted", ipbuf, c->name); } } diff --git a/src/netlink.c b/src/netlink.c index e502be0..9ed91b1 100644 --- a/src/netlink.c +++ b/src/netlink.c @@ -278,8 +278,8 @@ static int cb_rtnl_valid(struct nl_msg *msg, _unused void *arg) return NL_SKIP; inet_ntop(AF_INET6, &event_info.addr, ipbuf, sizeof(ipbuf)); - syslog(LOG_DEBUG, "Netlink %s %s%%%s", add ? "newaddr" : "deladdr", - ipbuf, event_info.iface->ifname); + syslog(LOG_DEBUG, "Netlink %s %s on %s", add ? "newaddr" : "deladdr", + ipbuf, event_info.iface->name); call_netevent_handler_list(add ? NETEV_ADDR6_ADD : NETEV_ADDR6_DEL, &event_info); @@ -292,8 +292,8 @@ static int cb_rtnl_valid(struct nl_msg *msg, _unused void *arg) nla_memcpy(&event_info.addr, nla[IFA_LOCAL], sizeof(event_info.addr)); inet_ntop(AF_INET, &event_info.addr, ipbuf, sizeof(ipbuf)); - syslog(LOG_DEBUG, "Netlink %s %s%%%s", add ? "newaddr" : "deladdr", - ipbuf, event_info.iface->ifname); + syslog(LOG_DEBUG, "Netlink %s %s on %s", add ? "newaddr" : "deladdr", + ipbuf, event_info.iface->name); call_netevent_handler_list(add ? NETEV_ADDR_ADD : NETEV_ADDR_DEL, &event_info); @@ -329,8 +329,8 @@ static int cb_rtnl_valid(struct nl_msg *msg, _unused void *arg) return NL_SKIP; inet_ntop(AF_INET6, &event_info.neigh.dst, ipbuf, sizeof(ipbuf)); - syslog(LOG_DEBUG, "Netlink %s %s%%%s", true ? "newneigh" : "delneigh", - ipbuf, event_info.iface->ifname); + syslog(LOG_DEBUG, "Netlink %s %s on %s", true ? "newneigh" : "delneigh", + ipbuf, event_info.iface->name); event_info.neigh.state = ndm->ndm_state; event_info.neigh.flags = ndm->ndm_flags; diff --git a/src/odhcpd.c b/src/odhcpd.c index bb7aba6..8a61148 100644 --- a/src/odhcpd.c +++ b/src/odhcpd.c @@ -209,11 +209,11 @@ ssize_t odhcpd_send(int socket, struct sockaddr_in6 *dest, ssize_t sent = sendmsg(socket, &msg, MSG_DONTWAIT); if (sent < 0) - syslog(LOG_NOTICE, "Failed to send to %s%%%s (%m)", - ipbuf, iface->ifname); + syslog(LOG_NOTICE, "Failed to send to %s%%%s@%s (%m)", + ipbuf, iface->name, iface->ifname); else - syslog(LOG_DEBUG, "Sent %li bytes to %s%%%s", - (long)sent, ipbuf, iface->ifname); + syslog(LOG_DEBUG, "Sent %zd bytes to %s%%%s@%s", + sent, ipbuf, iface->name, iface->ifname); return sent; } @@ -411,8 +411,8 @@ static void odhcpd_receive_packets(struct uloop_fd *u, _unused unsigned int even /* From netlink */ if (addr.nl.nl_family == AF_NETLINK) { - syslog(LOG_DEBUG, "Received %li Bytes from %s%%%s", (long)len, - ipbuf, "netlink"); + syslog(LOG_DEBUG, "Received %zd Bytes from %s%%netlink", len, + ipbuf); e->handle_dgram(&addr, data_buf, len, NULL, dest); return; } else if (destiface != 0) { @@ -421,8 +421,8 @@ static void odhcpd_receive_packets(struct uloop_fd *u, _unused unsigned int even if (iface->ifindex != destiface) continue; - syslog(LOG_DEBUG, "Received %li Bytes from %s%%%s", (long)len, - ipbuf, iface->ifname); + syslog(LOG_DEBUG, "Received %zd Bytes from %s%%%s@%s", len, + ipbuf, iface->name, iface->ifname); e->handle_dgram(&addr, data_buf, len, iface, dest); } diff --git a/src/router.c b/src/router.c index 2f02147..a79f09c 100644 --- a/src/router.c +++ b/src/router.c @@ -31,7 +31,7 @@ static void forward_router_solicitation(const struct interface *iface); -static void forward_router_advertisement(uint8_t *data, size_t len); +static void forward_router_advertisement(const struct interface *iface, uint8_t *data, size_t len); static void handle_icmpv6(void *addr, void *data, size_t len, struct interface *iface, void *dest); @@ -451,7 +451,7 @@ static uint64_t send_router_advert(struct interface *iface, const struct in6_add if (addr->prefix > 96 || addr->valid <= (uint32_t)now) { syslog(LOG_INFO, "Address %s (prefix %d, valid %u) not suitable as RA prefix on %s", inet_ntop(AF_INET6, &addr->addr.in6, buf, sizeof(buf)), addr->prefix, - addr->valid, iface->ifname); + addr->valid, iface->name); continue; } @@ -473,7 +473,7 @@ static uint64_t send_router_advert(struct interface *iface, const struct in6_add tmp = realloc(pfxs, sizeof(*pfxs) * (pfxs_cnt + 1)); if (!tmp) { - syslog(LOG_ERR, "Realloc failed for RA prefix option on interface %s", iface->ifname); + syslog(LOG_ERR, "Realloc failed for RA prefix option on %s", iface->name); continue; } @@ -523,7 +523,7 @@ static uint64_t send_router_advert(struct interface *iface, const struct in6_add if (default_route) { if (!valid_prefix) { syslog(LOG_WARNING, "A default route is present but there is no public prefix " - "on %s thus we don't announce a default route!", iface->ifname); + "on %s thus we don't announce a default route!", iface->name); adv.h.nd_ra_router_lifetime = 0; } else adv.h.nd_ra_router_lifetime = htons(calc_ra_lifetime(iface, maxival)); @@ -531,7 +531,7 @@ static uint64_t send_router_advert(struct interface *iface, const struct in6_add } 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->ifname); + syslog(LOG_INFO, "Using a RA lifetime of %d seconds on %s", ntohs(adv.h.nd_ra_router_lifetime), iface->name); struct { uint8_t type; @@ -598,7 +598,7 @@ static uint64_t send_router_advert(struct interface *iface, const struct in6_add if (addr->dprefix > 64 || addr->dprefix == 0 || addr->valid <= (uint32_t)now) { syslog(LOG_INFO, "Address %s (dprefix %d, valid %u) not suitable as RA route on %s", inet_ntop(AF_INET6, &addr->addr.in6, buf, sizeof(buf)), - addr->dprefix, addr->valid, iface->ifname); + addr->dprefix, addr->valid, iface->name); continue; /* Address not suitable */ } @@ -617,7 +617,7 @@ static uint64_t send_router_advert(struct interface *iface, const struct in6_add tmp = realloc(routes, sizeof(*routes) * (routes_cnt + 1)); if (!tmp) { - syslog(LOG_ERR, "Realloc failed for RA route option on interface %s", iface->ifname); + syslog(LOG_ERR, "Realloc failed for RA route option on %s", iface->name); continue; } @@ -704,7 +704,7 @@ static void handle_icmpv6(void *addr, void *data, size_t len, send_router_advert(iface, &from->sin6_addr); } else if (iface->ra == MODE_RELAY) { /* Relay mode */ if (hdr->icmp6_type == ND_ROUTER_ADVERT && iface->master) - forward_router_advertisement(data, len); + forward_router_advertisement(iface, data, len); else if (hdr->icmp6_type == ND_ROUTER_SOLICIT && !iface->master) forward_router_solicitation(odhcpd_get_master_interface()); } @@ -726,13 +726,13 @@ static void forward_router_solicitation(const struct interface *iface) inet_pton(AF_INET6, ALL_IPV6_ROUTERS, &all_routers.sin6_addr); all_routers.sin6_scope_id = iface->ifindex; - syslog(LOG_NOTICE, "Sending RS to %s", iface->ifname); + syslog(LOG_NOTICE, "Sending RS to %s", iface->name); odhcpd_send(router_event.uloop.fd, &all_routers, &iov, 1, iface); } /* Handler for incoming router solicitations on slave interfaces */ -static void forward_router_advertisement(uint8_t *data, size_t len) +static void forward_router_advertisement(const struct interface *iface, uint8_t *data, size_t len) { struct nd_router_advert *adv = (struct nd_router_advert *)data; struct sockaddr_in6 all_nodes; @@ -755,7 +755,7 @@ static void forward_router_advertisement(uint8_t *data, size_t len) } } - syslog(LOG_NOTICE, "Got a RA"); + syslog(LOG_NOTICE, "Got a RA on %s", iface->name); /* Indicate a proxy, however we don't follow the rest of RFC 4389 yet */ adv->nd_ra_flags_reserved |= ND_RA_FLAG_PROXY; @@ -767,23 +767,23 @@ static void forward_router_advertisement(uint8_t *data, size_t len) struct iovec iov = {data, len}; - struct interface *iface; - list_for_each_entry(iface, &interfaces, head) { - if (iface->ra != MODE_RELAY || iface->master) + struct interface *c; + list_for_each_entry(c, &interfaces, head) { + if (c->ra != MODE_RELAY || c->master) continue; /* Fixup source hardware address option */ if (mac_ptr) - odhcpd_get_mac(iface, mac_ptr); + odhcpd_get_mac(c, mac_ptr); /* If we have to rewrite DNS entries */ - if (iface->always_rewrite_dns && dns_ptr && dns_count > 0) { - const struct in6_addr *rewrite = iface->dns; + if (c->always_rewrite_dns && dns_ptr && dns_count > 0) { + const struct in6_addr *rewrite = c->dns; struct in6_addr addr; - size_t rewrite_cnt = iface->dns_cnt; + size_t rewrite_cnt = c->dns_cnt; if (rewrite_cnt == 0) { - if (odhcpd_get_interface_dns_addr(iface, &addr)) + if (odhcpd_get_interface_dns_addr(c, &addr)) continue; /* Unable to comply */ rewrite = &addr; @@ -797,6 +797,6 @@ static void forward_router_advertisement(uint8_t *data, size_t len) } } - odhcpd_send(router_event.uloop.fd, &all_nodes, &iov, 1, iface); + odhcpd_send(router_event.uloop.fd, &all_nodes, &iov, 1, c); } } |