ret = system_bonding_set_port(&bdev->dev, bp->dev.dev, true, bp->set_primary);
if (ret < 0) {
- D(DEVICE, "Bonding port %s could not be added\n", bp->dev.dev->ifname);
+ D(DEVICE, "Bonding port %s could not be added", bp->dev.dev->ifname);
goto error;
}
if (!bm->active) {
ret = system_bridge_addif(&bst->dev, bm->dev.dev);
if (ret < 0) {
- D(DEVICE, "Bridge device %s could not be added\n", bm->dev.dev->ifname);
+ D(DEVICE, "Bridge device %s could not be added", bm->dev.dev->ifname);
goto error;
}
uci_blob_diff(tb_dev, otb_dev, &device_attr_list, diff);
if (diff[0] | diff[1]) {
ret = DEV_CONFIG_RESTART;
- D(DEVICE, "Bridge %s device attributes have changed, diff=[%lx %lx]\n",
+ D(DEVICE, "Bridge %s device attributes have changed, diff=[%lx %lx]",
dev->ifname, diff[1], diff[0]);
}
uci_blob_diff(tb_br, otb_br, &bridge_attr_list, diff);
if (diff[0] & ~(1 << BRIDGE_ATTR_PORTS)) {
ret = DEV_CONFIG_RESTART;
- D(DEVICE, "Bridge %s attributes have changed, diff=[%lx %lx]\n",
+ D(DEVICE, "Bridge %s attributes have changed, diff=[%lx %lx]",
dev->ifname, diff[1], diff[0]);
}
config_fixup_bridge_vlan_filtering(s, name);
uci_to_blob(&b, s, devtype->config_params);
if (!device_create(name, devtype, b.head)) {
- D(INTERFACE, "Failed to create '%s' device for interface '%s'\n",
+ D(INTERFACE, "Failed to create '%s' device for interface '%s'",
devtype->name, s->e.name);
}
const char *dev_name;
if (!uci_wireless) {
- D(WIRELESS, "No wireless configuration found\n");
+ D(WIRELESS, "No wireless configuration found");
return;
}
wdev = vlist_find(&wireless_devices, dev_name, wdev, node);
if (!wdev) {
- D(WIRELESS, "device %s not found!\n", dev_name);
+ D(WIRELESS, "device %s not found!", dev_name);
continue;
}
if (system_resolve_rpfilter(blobmsg_data(cur), &s->rpfilter))
s->flags |= DEV_OPT_RPFILTER;
else
- D(DEVICE, "Failed to resolve rpfilter: %s\n", (char *) blobmsg_data(cur));
+ D(DEVICE, "Failed to resolve rpfilter: %s", (char *) blobmsg_data(cur));
}
if ((cur = tb[DEV_ATTR_ACCEPTLOCAL])) {
if (s->igmpversion >= 1 && s->igmpversion <= 3)
s->flags |= DEV_OPT_IGMPVERSION;
else
- D(DEVICE, "Failed to resolve igmpversion: %d\n", blobmsg_get_u32(cur));
+ D(DEVICE, "Failed to resolve igmpversion: %d", blobmsg_get_u32(cur));
}
if ((cur = tb[DEV_ATTR_MLDVERSION])) {
if (s->mldversion >= 1 && s->mldversion <= 2)
s->flags |= DEV_OPT_MLDVERSION;
else
- D(DEVICE, "Failed to resolve mldversion: %d\n", blobmsg_get_u32(cur));
+ D(DEVICE, "Failed to resolve mldversion: %d", blobmsg_get_u32(cur));
}
if ((cur = tb[DEV_ATTR_NEIGHREACHABLETIME])) {
if (s->multicast_router <= 2)
s->flags |= DEV_OPT_MULTICAST_ROUTER;
else
- D(DEVICE, "Invalid value: %d - (Use 0: never, 1: learn, 2: always)\n", blobmsg_get_u32(cur));
+ D(DEVICE, "Invalid value: %d - (Use 0: never, 1: learn, 2: always)", blobmsg_get_u32(cur));
}
if ((cur = tb[DEV_ATTR_MULTICAST_FAST_LEAVE])) {
return -1;
dep->claimed = true;
- D(DEVICE, "Claim %s %s, new active count: %d\n", dev->type->name, dev->ifname, dev->active + 1);
+ D(DEVICE, "Claim %s %s, new active count: %d", dev->type->name, dev->ifname, dev->active + 1);
if (++dev->active != 1)
return 0;
if (ret == 0)
device_broadcast_event(dev, DEV_EVENT_UP);
else {
- D(DEVICE, "claim %s %s failed: %d\n", dev->type->name, dev->ifname, ret);
+ D(DEVICE, "claim %s %s failed: %d", dev->type->name, dev->ifname, ret);
dev->active = 0;
dep->claimed = false;
}
dep->claimed = false;
dev->active--;
- D(DEVICE, "Release %s %s, new active count: %d\n", dev->type->name, dev->ifname, dev->active);
+ D(DEVICE, "Release %s %s, new active count: %d", dev->type->name, dev->ifname, dev->active);
assert(dev->active >= 0);
if (dev->active)
assert(dev);
assert(type);
- D(DEVICE, "Initialize device '%s'\n", name ? name : "");
+ D(DEVICE, "Initialize device '%s'", name ? name : "");
INIT_SAFE_LIST(&dev->users);
INIT_SAFE_LIST(&dev->aliases);
dev->type = type;
if (!external && system_if_force_external(name))
return NULL;
- D(DEVICE, "Create simple device '%s'\n", name);
+ D(DEVICE, "Create simple device '%s'", name);
dev = calloc(1, sizeof(*dev));
if (!dev)
return NULL;
if (!dev->avl.key)
return;
- D(DEVICE, "Delete device '%s' from list\n", dev->ifname);
+ D(DEVICE, "Delete device '%s' from list", dev->ifname);
avl_delete(&devices, &dev->avl);
dev->avl.key = NULL;
}
void device_cleanup(struct device *dev)
{
- D(DEVICE, "Clean up device '%s'\n", dev->ifname);
+ D(DEVICE, "Clean up device '%s'", dev->ifname);
safe_list_for_each(&dev->users, device_cleanup_cb, NULL);
safe_list_for_each(&dev->aliases, device_cleanup_cb, NULL);
device_delete(dev);
if (dev->sys_present == state)
return;
- D(DEVICE, "%s '%s' %s present\n", dev->type->name, dev->ifname, state ? "is now" : "is no longer" );
+ D(DEVICE, "%s '%s' %s present", dev->type->name, dev->ifname, state ? "is now" : "is no longer" );
dev->sys_present = state;
if (!state)
__device_set_present(dev, state, true);
head = &dev->users;
safe_list_add(&dep->list, head);
- D(DEVICE, "Add user for device '%s', refcount=%d\n", dev->ifname, device_refcount(dev));
+ D(DEVICE, "Add user for device '%s', refcount=%d", dev->ifname, device_refcount(dev));
if (dep->cb && dev->present) {
dep->cb(dep, DEV_EVENT_ADD);
safe_list_del(&dep->list);
dep->dev = NULL;
- D(DEVICE, "Remove user for device '%s', refcount=%d\n", dev->ifname, device_refcount(dev));
+ D(DEVICE, "Remove user for device '%s', refcount=%d", dev->ifname, device_refcount(dev));
device_free_unused();
}
switch (change) {
case DEV_CONFIG_RESTART:
case DEV_CONFIG_APPLIED:
- D(DEVICE, "Device '%s': config applied\n", dev->ifname);
+ D(DEVICE, "Device '%s': config applied", dev->ifname);
config = blob_memdup(config);
free(dev->config);
dev->config = config;
}
break;
case DEV_CONFIG_NO_CHANGE:
- D(DEVICE, "Device '%s': no configuration change\n", dev->ifname);
+ D(DEVICE, "Device '%s': no configuration change", dev->ifname);
break;
case DEV_CONFIG_RECREATE:
break;
change = device_apply_config(odev, type, config);
switch (change) {
case DEV_CONFIG_RECREATE:
- D(DEVICE, "Device '%s': recreate device\n", odev->ifname);
+ D(DEVICE, "Device '%s': recreate device", odev->ifname);
device_delete(odev);
break;
default:
return odev;
}
} else
- D(DEVICE, "Create new device '%s' (%s)\n", name, type->name);
+ D(DEVICE, "Create new device '%s' (%s)", name, type->name);
config = blob_memdup(config);
if (!config)
static inline int
netifd_extdev_create(struct extdev_device *edev, struct blob_attr *msg)
{
- D(DEVICE, "create %s '%s' at external device handler\n", edev->dev.type->name,
+ D(DEVICE, "create %s '%s' at external device handler", edev->dev.type->name,
edev->dev.ifname);
return netifd_extdev_invoke(edev->etype->peer_id, __extdev_methods[METHOD_CREATE], msg,
NULL, NULL);
static inline int
netifd_extdev_reload(struct extdev_device *edev, struct blob_attr *msg)
{
- D(DEVICE, "reload %s '%s' at external device handler\n", edev->dev.type->name,
+ D(DEVICE, "reload %s '%s' at external device handler", edev->dev.type->name,
edev->dev.ifname);
return netifd_extdev_invoke(edev->etype->peer_id, __extdev_methods[METHOD_RELOAD], msg,
NULL, NULL);
static inline int
netifd_extdev_free(struct extdev_device *edev, struct blob_attr *msg)
{
- D(DEVICE, "delete %s '%s' with external device handler\n", edev->dev.type->name,
+ D(DEVICE, "delete %s '%s' with external device handler", edev->dev.type->name,
edev->dev.ifname);
return netifd_extdev_invoke(edev->etype->peer_id, __extdev_methods[METHOD_FREE], msg,
NULL, NULL);
static inline int
netifd_extdev_prepare(struct extdev_bridge *ebr, struct blob_attr *msg)
{
- D(DEVICE, "prepare %s bridge '%s' at external device handler\n", ebr->edev.dev.type->name,
+ D(DEVICE, "prepare %s bridge '%s' at external device handler", ebr->edev.dev.type->name,
ebr->edev.dev.ifname);
return netifd_extdev_invoke(ebr->edev.etype->peer_id,
__extdev_methods[METHOD_HOTPLUG_PREPARE], msg, NULL, NULL);
static inline int
netifd_extdev_add(struct extdev_bridge *ebr, struct blob_attr *msg)
{
- D(DEVICE, "add a member to %s bridge '%s' at external device handler\n",
+ D(DEVICE, "add a member to %s bridge '%s' at external device handler",
ebr->edev.dev.type->name, ebr->edev.dev.ifname);
return netifd_extdev_invoke(ebr->edev.etype->peer_id,
__extdev_methods[METHOD_HOTPLUG_ADD], msg,NULL, NULL);
static inline int
netifd_extdev_remove(struct extdev_bridge *ebr, struct blob_attr *msg)
{
- D(DEVICE, "remove a member from %s bridge '%s' at external device handler\n",
+ D(DEVICE, "remove a member from %s bridge '%s' at external device handler",
ebr->edev.dev.type->name, ebr->edev.dev.ifname);
return netifd_extdev_invoke(ebr->edev.etype->peer_id,
__extdev_methods[METHOD_HOTPLUG_REMOVE], msg, NULL, NULL);
int ret;
struct extdev_bridge *ebr = ubm->parent_br;
- D(DEVICE, "%s enable member %s\n", ebr->edev.dev.ifname, ubm->name);
+ D(DEVICE, "%s enable member %s", ebr->edev.dev.ifname, ubm->name);
if (!ubm->present)
return 0;
return 0;
error:
- D(DEVICE, "%s: failed to enable member '%s'\n", ebr->edev.dev.ifname, ubm->name);
+ D(DEVICE, "%s: failed to enable member '%s'", ebr->edev.dev.ifname, ubm->name);
ebr->n_failed++;
ubm->present = false;
if (!ubm->present)
return 0;
- D(DEVICE, "%s disable member %s\n", ubm->parent_br->edev.dev.ifname, ubm->name);
+ D(DEVICE, "%s disable member %s", ubm->parent_br->edev.dev.ifname, ubm->name);
blob_buf_init(&b, 0);
blobmsg_add_string(&b, "bridge", ebr->edev.dev.ifname);
static int
extdev_bridge_set_down(struct extdev_bridge *ebr)
{
- D(DEVICE, "set %s bridge %s down\n", ebr->edev.dev.type->name, ebr->edev.dev.ifname);
+ D(DEVICE, "set %s bridge %s down", ebr->edev.dev.type->name, ebr->edev.dev.ifname);
struct extdev_bridge_member *ubm;
static int
extdev_bridge_set_up(struct extdev_bridge *ebr)
{
- D(DEVICE, "set %s bridge %s up\n", ebr->edev.dev.type->name, ebr->edev.dev.ifname);
+ D(DEVICE, "set %s bridge %s up", ebr->edev.dev.type->name, ebr->edev.dev.ifname);
struct extdev_bridge_member *ubm;
int ret;
{
struct extdev_bridge *ebr = container_of(timeout, struct extdev_bridge, retry);
- D(DEVICE, "%s retry enable members\n", ebr->edev.dev.ifname);
+ D(DEVICE, "%s retry enable members", ebr->edev.dev.ifname);
__bridge_enable_members(ebr);
}
static void
extdev_bridge_add_member(struct extdev_bridge *ebr, const char *name)
{
- D(DEVICE, "%s add member %s\n", ebr->edev.dev.ifname, name);
+ D(DEVICE, "%s add member %s", ebr->edev.dev.ifname, name);
struct device *dev;
static int
extdev_hotplug_add(struct device *ebr_dev, struct device *ebm_dev, struct blob_attr *vlan)
{
- D(DEVICE, "%s hotplug add member %s\n", ebr_dev->ifname, ebm_dev->ifname);
+ D(DEVICE, "%s hotplug add member %s", ebr_dev->ifname, ebm_dev->ifname);
struct extdev_bridge *ebr;
struct extdev_bridge_member *ubm;
if (ebr->edev.dep_name) {
dev = device_get(ebr->edev.dep_name, 0);
if (!(dev && dev->current_config)) {
- D(DEVICE, "%s: cannot yet init config since dependency '%s' is not ready\n",
+ D(DEVICE, "%s: cannot yet init config since dependency '%s' is not ready",
ebr->edev.dev.ifname, ebr->edev.dep_name);
ebr->edev.retry.cb = bridge_dependency_retry;
uloop_timeout_set(&ebr->edev.retry, 200);
if ((current_ev == IFEV_UP || current_ev == IFEV_UPDATE) && current->l3_dev.dev)
device = current->l3_dev.dev->ifname;
- D(SYSTEM, "Call hotplug handler for interface '%s', event '%s' (%s)\n",
+ D(SYSTEM, "Call hotplug handler for interface '%s', event '%s' (%s)",
current->name, eventnames[current_ev], device ? device : "none");
run_cmd(current->name, device, current_ev, current->updated);
}
task_complete(struct uloop_process *proc, int ret)
{
if (current)
- D(SYSTEM, "Complete hotplug handler for interface '%s'\n", current->name);
+ D(SYSTEM, "Complete hotplug handler for interface '%s'", current->name);
current = NULL;
call_hotplug();
}
static void
interface_queue_event(struct interface *iface, enum interface_event ev)
{
- D(SYSTEM, "Queue hotplug handler for interface '%s', event '%s'\n",
+ D(SYSTEM, "Queue hotplug handler for interface '%s', event '%s'",
iface->name, eventnames[ev]);
if (ev == IFEV_UP || ev == IFEV_DOWN)
netifd_ubus_interface_event(iface, ev == IFEV_UP);
if ((cur = tb[ROUTE_TARGET]) != NULL) {
if (!parse_ip_and_netmask(af, blobmsg_data(cur), &route->addr, &route->mask)) {
- D(INTERFACE, "Failed to parse route target: %s\n", (char *) blobmsg_data(cur));
+ D(INTERFACE, "Failed to parse route target: %s", (char *) blobmsg_data(cur));
goto error;
}
if ((cur = tb[ROUTE_GATEWAY]) != NULL) {
if (!inet_pton(af, blobmsg_data(cur), &route->nexthop)) {
- D(INTERFACE, "Failed to parse route gateway: %s\n", (char *) blobmsg_data(cur));
+ D(INTERFACE, "Failed to parse route gateway: %s", (char *) blobmsg_data(cur));
goto error;
}
}
const char *mask = strtok_r(NULL, "/", &saveptr);
if (!addr || inet_pton(af, addr, &route->source) < 1) {
- D(INTERFACE, "Failed to parse route source: %s\n", addr ? addr : "NULL");
+ D(INTERFACE, "Failed to parse route source: %s", addr ? addr : "NULL");
goto error;
}
if ((cur = tb[ROUTE_TABLE]) != NULL) {
if (!system_resolve_rt_table(blobmsg_data(cur), &route->table)) {
- D(INTERFACE, "Failed to resolve routing table: %s\n", (char *) blobmsg_data(cur));
+ D(INTERFACE, "Failed to resolve routing table: %s", (char *) blobmsg_data(cur));
goto error;
}
if ((cur = tb[ROUTE_TYPE]) != NULL) {
if (!system_resolve_rt_type(blobmsg_data(cur), &route->type)) {
- D(INTERFACE, "Failed to resolve routing type: %s\n", (char *) blobmsg_data(cur));
+ D(INTERFACE, "Failed to resolve routing type: %s", (char *) blobmsg_data(cur));
goto error;
}
route->flags |= DEVROUTE_TYPE;
if ((cur = tb[ROUTE_PROTO]) != NULL) {
if (!system_resolve_rt_proto(blobmsg_data(cur), &route->proto)) {
- D(INTERFACE, "Failed to resolve proto type: %s\n", (char *) blobmsg_data(cur));
+ D(INTERFACE, "Failed to resolve proto type: %s", (char *) blobmsg_data(cur));
goto error;
}
route->flags |= DEVROUTE_PROTO;
return;
add:
- D(INTERFACE, "Add IPv%c DNS server: %s\n",
+ D(INTERFACE, "Add IPv%c DNS server: %s",
s->af == AF_INET6 ? '6' : '4', str);
vlist_simple_add(&ip->dns_servers, &s->node);
}
if (!s)
return;
- D(INTERFACE, "Add DNS search domain: %s\n", str);
+ D(INTERFACE, "Add DNS search domain: %s", str);
memcpy(s->name, str, len);
vlist_simple_add(&ip->dns_search, &s->node);
}
unlink(tmppath);
f = fopen(tmppath, "w+");
if (!f) {
- D(INTERFACE, "Failed to open %s for writing\n", path);
+ D(INTERFACE, "Failed to open %s for writing", path);
return;
}
if (crcold == crcnew) {
unlink(tmppath);
} else if (rename(tmppath, path) < 0) {
- D(INTERFACE, "Failed to replace %s\n", path);
+ D(INTERFACE, "Failed to replace %s", path);
unlink(tmppath);
}
}
if (iface->available == new_state)
return;
- D(INTERFACE, "Interface '%s', available=%d\n", iface->name, new_state);
+ D(INTERFACE, "Interface '%s', available=%d", iface->name, new_state);
iface->available = new_state;
if (new_state) {
if ((cur = tb[IFACE_ATTR_IP4TABLE])) {
if (!system_resolve_rt_table(blobmsg_data(cur), &iface->ip4table))
- D(INTERFACE, "Failed to resolve routing table: %s\n", (char *) blobmsg_data(cur));
+ D(INTERFACE, "Failed to resolve routing table: %s", (char *) blobmsg_data(cur));
}
if ((cur = tb[IFACE_ATTR_IP6TABLE])) {
if (!system_resolve_rt_table(blobmsg_data(cur), &iface->ip6table))
- D(INTERFACE, "Failed to resolve routing table: %s\n", (char *) blobmsg_data(cur));
+ D(INTERFACE, "Failed to resolve routing table: %s", (char *) blobmsg_data(cur));
}
iface->proto_ip.no_delegation = !blobmsg_get_bool_default(tb[IFACE_ATTR_DELEGATE], true);
reload = true;
if (!if_old->proto_handler->config_params)
- D(INTERFACE, "No config parameters for interface '%s'\n",
+ D(INTERFACE, "No config parameters for interface '%s'",
if_old->name);
else if (!uci_blob_check_equal(if_old->config, if_new->config,
if_old->proto_handler->config_params))
#undef UPDATE
if (reload) {
- D(INTERFACE, "Reload interface '%s' because of config changes\n",
+ D(INTERFACE, "Reload interface '%s' because of config changes",
if_old->name);
interface_clear_errors(if_old);
set_config_state(if_old, IFC_RELOAD);
struct interface *if_new = container_of(node_new, struct interface, node);
if (node_old && node_new) {
- D(INTERFACE, "Update interface '%s'\n", if_new->name);
+ D(INTERFACE, "Update interface '%s'", if_new->name);
interface_change_config(if_old, if_new);
} else if (node_old) {
- D(INTERFACE, "Remove interface '%s'\n", if_old->name);
+ D(INTERFACE, "Remove interface '%s'", if_old->name);
set_config_state(if_old, IFC_REMOVE);
} else if (node_new) {
- D(INTERFACE, "Create interface '%s'\n", if_new->name);
+ D(INTERFACE, "Create interface '%s'", if_new->name);
interface_event(if_new, IFEV_CREATE);
proto_init_interface(if_new, if_new->config);
interface_claim_device(if_new);
if ((cur = tb[RULE_SRC]) != NULL) {
if (!parse_ip_and_netmask(af, blobmsg_data(cur), &rule->src_addr, &rule->src_mask)) {
- D(INTERFACE, "Failed to parse rule source: %s\n", (char *) blobmsg_data(cur));
+ D(INTERFACE, "Failed to parse rule source: %s", (char *) blobmsg_data(cur));
goto error;
}
rule->flags |= IPRULE_SRC;
if ((cur = tb[RULE_DEST]) != NULL) {
if (!parse_ip_and_netmask(af, blobmsg_data(cur), &rule->dest_addr, &rule->dest_mask)) {
- D(INTERFACE, "Failed to parse rule destination: %s\n", (char *) blobmsg_data(cur));
+ D(INTERFACE, "Failed to parse rule destination: %s", (char *) blobmsg_data(cur));
goto error;
}
rule->flags |= IPRULE_DEST;
if ((cur = tb[RULE_TOS]) != NULL) {
if ((rule->tos = blobmsg_get_u32(cur)) > 255) {
- D(INTERFACE, "Invalid TOS value: %u\n", blobmsg_get_u32(cur));
+ D(INTERFACE, "Invalid TOS value: %u", blobmsg_get_u32(cur));
goto error;
}
rule->flags |= IPRULE_TOS;
if ((cur = tb[RULE_FWMARK]) != NULL) {
if (!iprule_parse_mark(blobmsg_data(cur), rule)) {
- D(INTERFACE, "Failed to parse rule fwmark: %s\n", (char *) blobmsg_data(cur));
+ D(INTERFACE, "Failed to parse rule fwmark: %s", (char *) blobmsg_data(cur));
goto error;
}
/* flags set by iprule_parse_mark() */
if ((cur = tb[RULE_LOOKUP]) != NULL) {
if (!system_resolve_rt_table(blobmsg_data(cur), &rule->lookup)) {
- D(INTERFACE, "Failed to parse rule lookup table: %s\n", (char *) blobmsg_data(cur));
+ D(INTERFACE, "Failed to parse rule lookup table: %s", (char *) blobmsg_data(cur));
goto error;
}
rule->flags |= IPRULE_LOOKUP;
if (ret == 1)
rule->uidrange_end = rule->uidrange_start;
else if (ret != 2) {
- D(INTERFACE, "Failed to parse UID range: %s\n", (char *) blobmsg_data(cur));
+ D(INTERFACE, "Failed to parse UID range: %s", (char *) blobmsg_data(cur));
goto error;
}
rule->flags |= IPRULE_UIDRANGE;
if ((cur = tb[RULE_ACTION]) != NULL) {
if (!system_resolve_iprule_action(blobmsg_data(cur), &rule->action)) {
- D(INTERFACE, "Failed to parse rule action: %s\n", (char *) blobmsg_data(cur));
+ D(INTERFACE, "Failed to parse rule action: %s", (char *) blobmsg_data(cur));
goto error;
}
rule->flags |= IPRULE_ACTION;
{
struct macvlan_device *mvdev;
- D(SYSTEM, "macvlan_set_state(%s, %u)\n", dev->ifname, up);
+ D(SYSTEM, "macvlan_set_state(%s, %u)", dev->ifname, up);
mvdev = container_of(dev, struct macvlan_device, dev);
if (up)
#define DPRINTF(format, ...) fprintf(stderr, "%s(%d): " format, __func__, __LINE__, ## __VA_ARGS__)
#define D(level, format, ...) do { \
netifd_udebug_printf("[" #level "] %s(%d): " format, __func__, __LINE__, ## __VA_ARGS__); \
- if (debug_mask & (1 << (DEBUG_ ## level))) \
- DPRINTF(format, ##__VA_ARGS__); \
+ if (debug_mask & (1 << (DEBUG_ ## level))) { \
+ DPRINTF(format, ##__VA_ARGS__); \
+ fprintf(stderr, "\n"); \
+ } \
} while (0)
#else
#define DPRINTF(format, ...) no_debug(0, format, ## __VA_ARGS__)
}
}
- D(INTERFACE, "run %s for interface '%s'\n", action, proto->iface->name);
+ D(INTERFACE, "run %s for interface '%s'", action, proto->iface->name);
config = blobmsg_format_json(state->config, true);
if (!config)
return -1;
blobmsg_for_each_attr(cur, attr, rem) {
if (blobmsg_type(cur) != BLOBMSG_TYPE_TABLE) {
- D(INTERFACE, "Ignore wrong route type: %d\n", blobmsg_type(cur));
+ D(INTERFACE, "Ignore wrong route type: %d", blobmsg_type(cur));
continue;
}
blobmsg_for_each_attr(cur, attr, rem) {
if (blobmsg_type(cur) != BLOBMSG_TYPE_TABLE) {
- D(INTERFACE, "Ignore wrong neighbor type: %d\n", blobmsg_type(cur));
+ D(INTERFACE, "Ignore wrong neighbor type: %d", blobmsg_type(cur));
continue;
}
if (iface->state == IFS_UP)
return;
- D(INTERFACE, "Interface '%s' is not up after %d sec\n",
+ D(INTERFACE, "Interface '%s' is not up after %d sec",
iface->name, state->checkup_interval);
proto_shell_handler(proto, PROTO_CMD_TEARDOWN, false);
}
if (config)
handler->config_buf = netifd_handler_parse_config(&handler->config, config);
- D(INTERFACE, "Add handler for script %s: %s\n", script, proto->name);
+ D(INTERFACE, "Add handler for script %s: %s", script, proto->name);
add_proto_handler(proto);
}
int system_bridge_addbr(struct device *bridge, struct bridge_config *cfg)
{
- D(SYSTEM, "brctl addbr %s vlan_filtering=%d\n",
+ D(SYSTEM, "brctl addbr %s vlan_filtering=%d",
bridge->ifname, cfg->vlan_filtering);
return 0;
}
int system_bridge_delbr(struct device *bridge)
{
- D(SYSTEM, "brctl delbr %s\n", bridge->ifname);
+ D(SYSTEM, "brctl delbr %s", bridge->ifname);
return 0;
}
int system_bridge_addif(struct device *bridge, struct device *dev)
{
- D(SYSTEM, "brctl addif %s %s\n", bridge->ifname, dev->ifname);
+ D(SYSTEM, "brctl addif %s %s", bridge->ifname, dev->ifname);
return 0;
}
int system_bridge_delif(struct device *bridge, struct device *dev)
{
- D(SYSTEM, "brctl delif %s %s\n", bridge->ifname, dev->ifname);
+ D(SYSTEM, "brctl delif %s %s", bridge->ifname, dev->ifname);
return 0;
}
int system_bridge_vlan(const char *iface, uint16_t vid, int16_t vid_end, bool add, unsigned int vflags)
{
- D(SYSTEM, "brctl vlan %s %s %s vid=%d vid_end=%d pvid=%d untag=%d\n",
+ D(SYSTEM, "brctl vlan %s %s %s vid=%d vid_end=%d pvid=%d untag=%d",
add ? "add" : "remove",
(vflags & BRVLAN_F_SELF) ? "self" : "master",
iface, vid, vid_end,
int system_link_netns_move(struct device *dev, int netns_fd, const char *target_ifname)
{
- D(SYSTEM, "ip link set %s name %s netns %d\n", dev->ifname, target_ifname, netns_fd);
+ D(SYSTEM, "ip link set %s name %s netns %d", dev->ifname, target_ifname, netns_fd);
return 0;
}
int system_netns_open(const pid_t target_ns)
{
- D(SYSTEM, "open netns of pid %d\n", target_ns);
+ D(SYSTEM, "open netns of pid %d", target_ns);
return 1;
}
int system_netns_set(int netns_fd)
{
- D(SYSTEM, "set netns %d\n", netns_fd);
+ D(SYSTEM, "set netns %d", netns_fd);
return 0;
}
int system_vlan_add(struct device *dev, int id)
{
- D(SYSTEM, "vconfig add %s %d\n", dev->ifname, id);
+ D(SYSTEM, "vconfig add %s %d", dev->ifname, id);
return 0;
}
int system_vlan_del(struct device *dev)
{
- D(SYSTEM, "vconfig rem %s\n", dev->ifname);
+ D(SYSTEM, "vconfig rem %s", dev->ifname);
return 0;
}
int system_if_up(struct device *dev)
{
- D(SYSTEM, "ifconfig %s up\n", dev->ifname);
+ D(SYSTEM, "ifconfig %s up", dev->ifname);
return 0;
}
int system_if_down(struct device *dev)
{
- D(SYSTEM, "ifconfig %s down\n", dev->ifname);
+ D(SYSTEM, "ifconfig %s down", dev->ifname);
return 0;
}
apply_mask &= s->flags;
if ((apply_mask & (DEV_OPT_MACADDR | DEV_OPT_DEFAULT_MACADDR)) && !dev->external) {
- D(SYSTEM, "ifconfig %s hw ether %s\n",
+ D(SYSTEM, "ifconfig %s hw ether %s",
dev->ifname, format_macaddr(s->macaddr));
}
}
char ipaddr[64];
int af = system_get_addr_family(addr->flags);
- D(SYSTEM, "ifconfig %s %s %s/%u\n",
+ D(SYSTEM, "ifconfig %s %s %s/%u",
dev->ifname, type, inet_ntop(af, &addr->addr.in, ipaddr, sizeof(ipaddr)),
addr->mask);
if (route->metric > 0)
sprintf(devstr, " metric %d", route->metric);
- D(SYSTEM, "route %s %s%s%s\n", type, addr, gw, devstr);
+ D(SYSTEM, "route %s %s%s%s", type, addr, gw, devstr);
return 0;
}
int af = system_get_addr_family(neighbor->flags);
inet_ntop(af, &neighbor->addr.in , addr, sizeof(addr));
- D(SYSTEM, "neigh %s %s%s%s %s\n", type, addr, neighbor->proxy ? "proxy " : "",
+ D(SYSTEM, "neigh %s %s%s%s %s", type, addr, neighbor->proxy ? "proxy " : "",
(neighbor->flags & DEVNEIGH_MAC) ? format_macaddr(neighbor->macaddr) : "",
neighbor->router ? "router": "");
return 0;
if (!ret)
break;
- D(SYSTEM, "Failed to add device '%s' to bridge '%s' (tries=%d): %s\n",
+ D(SYSTEM, "Failed to add device '%s' to bridge '%s' (tries=%d): %s",
dev->ifname, bridge->ifname, tries, strerror(errno));
}
return NL_SKIP;
if (type == RTM_DELRULE)
- D(SYSTEM, "Remove a rule\n");
+ D(SYSTEM, "Remove a rule");
else
- D(SYSTEM, "Remove %s from device %s\n",
+ D(SYSTEM, "Remove %s from device %s",
type == RTM_DELADDR ? "an address" : "a route",
clr->dev->ifname);
ret = nl_send_auto_complete(sock_rtnl, clr->msg);
if (ret < 0) {
if (type == RTM_DELRULE)
- D(SYSTEM, "Error deleting a rule: %d\n", ret);
+ D(SYSTEM, "Error deleting a rule: %d", ret);
else
- D(SYSTEM, "Error deleting %s from device '%s': %d\n",
+ D(SYSTEM, "Error deleting %s from device '%s': %d",
type == RTM_DELADDR ? "an address" : "a route",
clr->dev->ifname, ret);
}
system_if_flags(dev->ifname, 0, IFF_UP);
if (system_is_bridge(dev->ifname)) {
- D(SYSTEM, "Delete existing bridge named '%s'\n", dev->ifname);
+ D(SYSTEM, "Delete existing bridge named '%s'", dev->ifname);
system_bridge_delbr(dev);
return;
}
bridge = system_get_bridge(dev->ifname, buf, sizeof(buf));
if (bridge) {
- D(SYSTEM, "Remove device '%s' from bridge '%s'\n", dev->ifname, bridge);
+ D(SYSTEM, "Remove device '%s' from bridge '%s'", dev->ifname, bridge);
system_bridge_if(bridge, dev, SIOCBRDELIF, NULL);
}
rv = system_rtnl_call(msg);
if (rv)
- D(SYSTEM, "Error adding bridge '%s': %d\n", bridge->ifname, rv);
+ D(SYSTEM, "Error adding bridge '%s': %d", bridge->ifname, rv);
return rv;
rv = system_rtnl_call(msg);
if (rv)
- D(SYSTEM, "Error adding macvlan '%s' over '%s': %d\n", macvlan->ifname, dev->ifname, rv);
+ D(SYSTEM, "Error adding macvlan '%s' over '%s': %d", macvlan->ifname, dev->ifname, rv);
return rv;
rv = system_rtnl_call(msg);
if (rv) {
if (cfg->flags & VETH_OPT_PEER_NAME)
- D(SYSTEM, "Error adding veth '%s' with peer '%s': %d\n", veth->ifname, cfg->peer_name, rv);
+ D(SYSTEM, "Error adding veth '%s' with peer '%s': %d", veth->ifname, cfg->peer_name, rv);
else
- D(SYSTEM, "Error adding veth '%s': %d\n", veth->ifname, rv);
+ D(SYSTEM, "Error adding veth '%s': %d", veth->ifname, rv);
}
return rv;
rv = system_rtnl_call(msg);
if (rv)
- D(SYSTEM, "Error adding vlandev '%s' over '%s': %d\n", vlandev->ifname, dev->ifname, rv);
+ D(SYSTEM, "Error adding vlandev '%s' over '%s': %d", vlandev->ifname, dev->ifname, rv);
return rv;
ret = system_rtnl_call(msg);
if (ret)
- D(SYSTEM, "Error adding vxlan '%s': %d\n", name, ret);
+ D(SYSTEM, "Error adding vxlan '%s': %d", name, ret);
return ret;
int t = 2;
if (ubus_reconnect(ubus_ctx, ubus_path) != 0) {
- D(SYSTEM, "failed to reconnect, trying again in %d seconds\n", t);
+ D(SYSTEM, "failed to reconnect, trying again in %d seconds", t);
uloop_timeout_set(&retry, t * 1000);
return;
}
- D(SYSTEM, "reconnected to ubus, new id: %08x\n", ubus_ctx->local_id);
+ D(SYSTEM, "reconnected to ubus, new id: %08x", ubus_ctx->local_id);
netifd_ubus_add_fd();
}
if (!ubus_ctx)
return -EIO;
- D(SYSTEM, "connected as %08x\n", ubus_ctx->local_id);
+ D(SYSTEM, "connected as %08x", ubus_ctx->local_id);
ubus_ctx->connection_lost = netifd_ubus_connection_lost;
netifd_ubus_add_fd();
obj->methods = iface_object_methods;
obj->n_methods = ARRAY_SIZE(iface_object_methods);
if (ubus_add_object(ubus_ctx, &iface->ubus)) {
- D(SYSTEM, "failed to publish ubus object for interface '%s'\n", iface->name);
+ D(SYSTEM, "failed to publish ubus object for interface '%s'", iface->name);
free(name);
obj->name = NULL;
}
{
struct veth *veth;
- D(SYSTEM, "veth_set_state(%s, %u)\n", dev->ifname, up);
+ D(SYSTEM, "veth_set_state(%s, %u)", dev->ifname, up);
veth = container_of(dev, struct veth, dev);
if (up)
if (snprintf(name, sizeof(name), "%s.%d", dev->ifname, id) >= (int)sizeof(name) - 1)
return NULL;
- D(DEVICE, "Create vlan device '%s'\n", name);
+ D(DEVICE, "Create vlan device '%s'", name);
vldev = calloc(1, sizeof(*vldev));
if (!vldev)
{
struct vlandev_device *mvdev;
- D(SYSTEM, "vlandev_set_state(%s, %u)\n", dev->ifname, up);
+ D(SYSTEM, "vlandev_set_state(%s, %u)", dev->ifname, up);
mvdev = container_of(dev, struct vlandev_device, dev);
if (up)
static void
wireless_process_free(struct wireless_device *wdev, struct wireless_process *proc)
{
- D(WIRELESS, "Wireless device '%s' free pid %d\n", wdev->name, proc->pid);
+ D(WIRELESS, "Wireless device '%s' free pid %d", wdev->name, proc->pid);
list_del(&proc->list);
free(proc);
bool check = wireless_process_check(proc);
if (check && !proc->keep) {
- D(WIRELESS, "Wireless device '%s' kill pid %d\n", wdev->name, proc->pid);
+ D(WIRELESS, "Wireless device '%s' kill pid %d", wdev->name, proc->pid);
kill(proc->pid, signal);
}
return;
wireless_handler_stop(wdev);
- D(WIRELESS, "Cancel wireless device '%s' setup\n", wdev->name);
+ D(WIRELESS, "Cancel wireless device '%s' setup", wdev->name);
wdev->cancel = true;
uloop_timeout_set(&wdev->timeout, 10 * 1000);
}
if (wdev->serialize)
handler_pending = true;
- D(WIRELESS, "Wireless device '%s' run %s handler\n", wdev->name, action);
+ D(WIRELESS, "Wireless device '%s' run %s handler", wdev->name, action);
if (!up && wdev->prev_config) {
config = blobmsg_format_json(wdev->prev_config, true);
free(wdev->prev_config);
if (blob_attr_equal(wdev->config, new_config) && wdev->disabled == disabled)
return;
- D(WIRELESS, "Update configuration of wireless device '%s'\n", wdev->name);
+ D(WIRELESS, "Update configuration of wireless device '%s'", wdev->name);
free(wdev->config);
wdev->config = blob_memdup(new_config);
wdev->disabled = disabled;
struct wireless_device *wd_new = container_of(node_new, struct wireless_device, node);
if (wd_old && wd_new) {
- D(WIRELESS, "Update wireless device '%s'\n", wd_old->name);
+ D(WIRELESS, "Update wireless device '%s'", wd_old->name);
wdev_change_config(wd_old, wd_new);
} else if (wd_old) {
- D(WIRELESS, "Delete wireless device '%s'\n", wd_old->name);
+ D(WIRELESS, "Delete wireless device '%s'", wd_old->name);
wdev_set_config_state(wd_old, IFC_REMOVE);
} else if (wd_new) {
- D(WIRELESS, "Create wireless device '%s'\n", wd_new->name);
+ D(WIRELESS, "Create wireless device '%s'", wd_new->name);
wdev_create(wd_new);
}
}
drv->node.key = drv->name;
avl_insert(&wireless_drivers, &drv->node);
- D(WIRELESS, "Add handler for script %s: %s\n", script, name);
+ D(WIRELESS, "Add handler for script %s: %s", script, name);
}
void wireless_init(void)
return;
}
- D(WIRELESS, "Update wireless interface %s on device %s\n", vif_new->name, wdev->name);
+ D(WIRELESS, "Update wireless interface %s on device %s", vif_new->name, wdev->name);
wireless_interface_handle_link(vif_old, NULL, false);
free(vif_old->config);
vif_old->config = blob_memdup(vif_new->config);
wireless_interface_init_config(vif_old);
free(vif_new);
} else if (vif_new) {
- D(WIRELESS, "Create new wireless interface %s on device %s\n", vif_new->name, wdev->name);
+ D(WIRELESS, "Create new wireless interface %s on device %s", vif_new->name, wdev->name);
vif_new->section = strdup(vif_new->section);
vif_new->config = blob_memdup(vif_new->config);
wireless_interface_init_config(vif_new);
} else if (vif_old) {
- D(WIRELESS, "Delete wireless interface %s on device %s\n", vif_old->name, wdev->name);
+ D(WIRELESS, "Delete wireless interface %s on device %s", vif_old->name, wdev->name);
wireless_interface_handle_link(vif_old, NULL, false);
vif_free(vif_old);
}
return;
}
- D(WIRELESS, "Update wireless vlan %s on device %s\n", vlan_new->name, wdev->name);
+ D(WIRELESS, "Update wireless vlan %s on device %s", vlan_new->name, wdev->name);
wireless_vlan_handle_link(vlan_old, false);
free(vlan_old->config);
vlan_old->config = blob_memdup(vlan_new->config);
wireless_vlan_init_config(vlan_old);
free(vlan_new);
} else if (vlan_new) {
- D(WIRELESS, "Create new wireless vlan %s on device %s\n", vlan_new->name, wdev->name);
+ D(WIRELESS, "Create new wireless vlan %s on device %s", vlan_new->name, wdev->name);
vlan_new->section = strdup(vlan_new->section);
vlan_new->config = blob_memdup(vlan_new->config);
wireless_vlan_init_config(vlan_new);
} else if (vlan_old) {
- D(WIRELESS, "Delete wireless vlan %s on device %s\n", vlan_old->name, wdev->name);
+ D(WIRELESS, "Delete wireless vlan %s on device %s", vlan_old->name, wdev->name);
wireless_vlan_handle_link(vlan_old, false);
free((void *) vlan_old->section);
free(vlan_old->config);
return;
}
- D(WIRELESS, "Update wireless station %s on device %s\n", sta_new->name, wdev->name);
+ D(WIRELESS, "Update wireless station %s on device %s", sta_new->name, wdev->name);
free(sta_old->config);
sta_old->config = blob_memdup(sta_new->config);
free(sta_new);
} else if (sta_new) {
- D(WIRELESS, "Create new wireless station %s on device %s\n", sta_new->name, wdev->name);
+ D(WIRELESS, "Create new wireless station %s on device %s", sta_new->name, wdev->name);
sta_new->section = strdup(sta_new->section);
sta_new->config = blob_memdup(sta_new->config);
} else if (sta_old) {
- D(WIRELESS, "Delete wireless station %s on device %s\n", sta_old->name, wdev->name);
+ D(WIRELESS, "Delete wireless station %s on device %s", sta_old->name, wdev->name);
free((void *) sta_old->section);
free(sta_old->config);
free(sta_old);
if (wireless_process_check(proc))
continue;
- D(WIRELESS, "Wireless device '%s' pid %d has terminated\n", wdev->name, proc->pid);
+ D(WIRELESS, "Wireless device '%s' pid %d has terminated", wdev->name, proc->pid);
if (proc->required)
restart = true;
if (tb[PROC_ATTR_KEEP])
proc->keep = blobmsg_get_bool(tb[PROC_ATTR_KEEP]);
- D(WIRELESS, "Wireless device '%s' add pid %d\n", wdev->name, proc->pid);
+ D(WIRELESS, "Wireless device '%s' add pid %d", wdev->name, proc->pid);
list_add(&proc->list, &wdev->script_proc);
uloop_timeout_set(&wdev->script_check, 0);