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;
}
/* 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;
}
/* 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));
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;
}
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);
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)
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],
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],
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],
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;
}
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;
}
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;
}
}
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,
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)) {
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);
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)))
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);
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);
}
}
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);
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);
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;
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;
}
/* 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) {
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);
}
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);
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;
}
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;
}
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));
} 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;
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 */
}
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;
}
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());
}
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;
}
}
- 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;
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;
}
}
- odhcpd_send(router_event.uloop.fd, &all_nodes, &iov, 1, iface);
+ odhcpd_send(router_event.uloop.fd, &all_nodes, &iov, 1, c);
}
}