strcpy(bm->name, name);
bm->dev.dev = dev;
vlist_add(&bst->members, &bm->node, bm->name);
- // Need to look up the bridge member again as the above
- // created pointer will be freed in case the bridge member
- // already existed
+ /*
+ * Need to look up the bridge member again as the above
+ * created pointer will be freed in case the bridge member
+ * already existed
+ */
bm = vlist_find(&bst->members, name, bm, node);
if (hotplug && bm)
bm->node.version = -1;
if (v6 != ((addr->flags & DEVADDR_FAMILY) == DEVADDR_INET6))
continue;
- // Handle offlink addresses correctly
+ /* Handle offlink addresses correctly */
unsigned int mask = addr->mask;
if ((addr->flags & DEVADDR_FAMILY) == DEVADDR_INET6 &&
(addr->flags & DEVADDR_OFFLINK))
route->flags |= DEVROUTE_MTU;
}
- // Use source-based routing
+ /* Use source-based routing */
if ((cur = tb[ROUTE_SOURCE]) != NULL) {
char *saveptr, *source = alloca(blobmsg_data_len(cur));
memcpy(source, blobmsg_data(cur), blobmsg_data_len(cur));
if ((cur = tb[ROUTE_VALID]) != NULL) {
int64_t valid = blobmsg_get_u32(cur);
int64_t valid_until = valid + (int64_t)system_get_rtime();
- if (valid_until <= LONG_MAX && valid != 0xffffffffLL) // Catch overflow
+ if (valid_until <= LONG_MAX && valid != 0xffffffffLL) /* Catch overflow */
route->valid_until = valid_until;
}
if (node_old) {
if (a_old->enabled && !keep) {
- //This is needed for source routing to work correctly. If a device
- //has two connections to a network using the same subnet, adding
- //only the network-rule will cause packets to be routed through the
- //first matching network (source IP matches both masks).
+ /*
+ * This is needed for source routing to work correctly. If a device
+ * has two connections to a network using the same subnet, adding
+ * only the network-rule will cause packets to be routed through the
+ * first matching network (source IP matches both masks)
+ */
if (a_old->policy_table)
interface_add_addr_rules(a_old, false);
struct device_prefix_assignment *c;
struct interface *iface;
- // Delete all assignments
+ /* Delete all assignments */
while (!list_empty(&prefix->assignments)) {
c = list_first_entry(&prefix->assignments,
struct device_prefix_assignment, head);
if (!setup)
return;
- // End-of-assignment sentinel
+ /* End-of-assignment sentinel */
c = malloc(sizeof(*c) + 1);
if (!c)
return;
c->addr = in6addr_any;
list_add(&c->head, &prefix->assignments);
- // Excluded prefix
+ /* Excluded prefix */
if (prefix->excl_length > 0) {
const char name[] = "!excluded";
c = malloc(sizeof(*c) + sizeof(name));
iface->assignment_length > 64)
continue;
- // Test whether there is a matching class
+ /* Test whether there is a matching class */
if (!list_empty(&iface->assignment_classes)) {
bool found = false;
c->enabled = false;
memcpy(c->name, iface->name, namelen);
- // First process all custom assignments, put all others in later-list
+ /* First process all custom assignments, put all others in later-list */
if (c->assigned == -1 || !interface_prefix_assign(&prefix->assignments, c)) {
if (c->assigned != -1) {
c->assigned = -1;
struct interface *iface;
if (node_old && node_new) {
- // Move assignments and refresh addresses to update valid times
+ /* Move assignments and refresh addresses to update valid times */
list_splice(&prefix_old->assignments, &prefix_new->assignments);
list_for_each_entry(c, &prefix_new->assignments, head)
prefix_new->valid_until != prefix_old->valid_until)
ip->iface->updated |= IUF_PREFIX;
} else if (node_new) {
- // Set null-route to avoid routing loops
+ /* Set null-route to avoid routing loops */
system_add_route(NULL, &route);
if (!prefix_new->iface || !prefix_new->iface->proto_ip.no_delegation)
interface_update_prefix_assignments(prefix_new, true);
} else if (node_old) {
- // Remove null-route
+ /* Remove null-route */
interface_update_prefix_assignments(prefix_old, false);
system_del_route(NULL, &route);
}
/* must be last */
enum device_addr_flags flags;
- int metric; // there can be multiple routes to the same target
+ int metric; /* there can be multiple routes to the same target */
unsigned int table;
unsigned int mask;
unsigned int sourcemask;
struct interface_assignment_class *c;
list_for_each_entry(c, &new->assignment_classes, head) {
- // Compare list entries one-by-one to see if there was a change
- if (list_empty(&old->assignment_classes)) // The new list is longer
+ /* Compare list entries one-by-one to see if there was a change */
+ if (list_empty(&old->assignment_classes)) /* The new list is longer */
changed = true;
if (changed)
struct interface_assignment_class *c_old = list_first_entry(&old->assignment_classes,
struct interface_assignment_class, head);
- if (strcmp(c_old->name, c->name)) // An entry didn't match
+ if (strcmp(c_old->name, c->name)) /* An entry didn't match */
break;
list_del(&c_old->head);
free(c_old);
}
- // The old list was longer than the new one or the last entry didn't match
+ /* The old list was longer than the new one or the last entry didn't match */
if (!list_empty(&old->assignment_classes)) {
interface_clear_assignment_classes(old);
changed = true;
switch(err) {
case ENOBUFS:
- // Increase rx buffer size on netlink socket
+ /* Increase rx buffer size on netlink socket */
ev->bufsize *= 2;
if (nl_socket_set_buffer_size(ev->sock, ev->bufsize, 0))
goto abort;
- // Request full dump since some info got dropped
+ /* Request full dump since some info got dropped */
struct rtgenmsg msg = { .rtgen_family = AF_UNSPEC };
nl_send_simple(ev->sock, RTM_GETLINK, NLM_F_DUMP, &msg, sizeof(msg));
break;
if (!create_raw_event_socket(ev, protocol, 0, handler_nl_event, ULOOP_ERROR_CB))
return false;
- // Install the valid custom callback handler
+ /* Install the valid custom callback handler */
nl_socket_modify_cb(ev->sock, NL_CB_VALID, NL_CB_CUSTOM, cb, NULL);
- // Disable sequence number checking on event sockets
+ /* Disable sequence number checking on event sockets */
nl_socket_disable_seq_check(ev->sock);
- // Increase rx buffer size to 65K on event sockets
+ /* Increase rx buffer size to 65K on event sockets */
ev->bufsize = 65535;
if (nl_socket_set_buffer_size(ev->sock, ev->bufsize, 0))
return false;
sock_ioctl = socket(AF_LOCAL, SOCK_DGRAM, 0);
system_fd_set_cloexec(sock_ioctl);
- // Prepare socket for routing / address control
+ /* Prepare socket for routing / address control */
sock_rtnl = create_socket(NETLINK_ROUTE, 0);
if (!sock_rtnl)
return -1;
handle_hotplug_event, 0))
return -1;
- // Receive network link events form kernel
+ /* Receive network link events form kernel */
nl_socket_add_membership(rtnl_event.sock, RTNLGRP_LINK);
return 0;
dev->ifname, buf, buf_sz);
}
-// Evaluate netlink messages
+/* Evaluate netlink messages */
static int cb_rtnl_event(struct nl_msg *msg, void *arg)
{
struct nlmsghdr *nh = nlmsg_hdr(msg);
if (cmd == RTM_NEWROUTE) {
flags |= NLM_F_CREATE | NLM_F_REPLACE;
- if (!dev) { // Add null-route
+ if (!dev) { /* Add null-route */
rtm.rtm_scope = RT_SCOPE_UNIVERSE;
rtm.rtm_type = RTN_UNREACHABLE;
}