if (strequal(value, "veth")) {
netdev->type = LXC_NET_VETH;
INIT_LIST_HEAD(&netdev->priv.veth_attr.ipv4_routes);
- lxc_list_init(&netdev->priv.veth_attr.ipv6_routes);
+ INIT_LIST_HEAD(&netdev->priv.veth_attr.ipv6_routes);
lxc_list_init(&netdev->priv.veth_attr.vlan_tagged_ids);
if (!lxc_veth_flag_to_mode(netdev->priv.veth_attr.mode))
lxc_veth_mode_to_flag(&netdev->priv.veth_attr.mode, "bridge");
{
__do_free char *valdup = NULL;
__do_free struct lxc_inet6dev *inet6dev = NULL;
- __do_free struct lxc_list *list = NULL;
int ret;
char *netmask, *slash;
struct lxc_netdev *netdev = data;
if (!inet6dev)
return ret_errno(ENOMEM);
- list = lxc_list_new();
- if (!list)
- return ret_errno(ENOMEM);
-
valdup = strdup(value);
if (!valdup)
return ret_errno(ENOMEM);
if (!ret || ret < 0)
return ret_errno(EINVAL);
- list->elem = inet6dev;
- lxc_list_add_tail(&netdev->priv.veth_attr.ipv6_routes, list);
+ list_add_tail(&inet6dev->head, &netdev->priv.veth_attr.ipv6_routes);
move_ptr(inet6dev);
- move_ptr(list);
return 0;
}
struct lxc_conf *lxc_conf, void *data)
{
struct lxc_netdev *netdev = data;
- struct lxc_list *cur, *next;
+ struct lxc_inet6dev *inet6dev, *ninet6dev;
if (!netdev)
return ret_errno(EINVAL);
if (netdev->type != LXC_NET_VETH)
return 0;
- lxc_list_for_each_safe(cur, &netdev->priv.veth_attr.ipv6_routes, next) {
- lxc_list_del(cur);
- free(cur->elem);
- free(cur);
+ list_for_each_entry_safe(inet6dev, ninet6dev, &netdev->priv.veth_attr.ipv6_routes, head) {
+ list_del(&inet6dev->head);
+ free(inet6dev);
}
return 0;
int len;
size_t listlen;
char buf[INET6_ADDRSTRLEN];
- struct lxc_list *it;
+ struct lxc_inet6dev *inet6dev;
int fulllen = 0;
struct lxc_netdev *netdev = data;
else
memset(retv, 0, inlen);
- listlen = lxc_list_len(&netdev->priv.veth_attr.ipv6_routes);
-
- lxc_list_for_each(it, &netdev->priv.veth_attr.ipv6_routes) {
- struct lxc_inet6dev *i = it->elem;
- if (!inet_ntop(AF_INET6, &i->addr, buf, sizeof(buf)))
+ listlen = list_len(&netdev->priv.veth_attr.ipv6_routes);
+ list_for_each_entry(inet6dev, &netdev->priv.veth_attr.ipv6_routes, head) {
+ if (!inet_ntop(AF_INET6, &inet6dev->addr, buf, sizeof(buf)))
return -errno;
- strprint(retv, inlen, "%s/%u%s", buf, i->prefix,
+ strprint(retv, inlen, "%s/%u%s", buf, inet6dev->prefix,
(listlen-- > 1) ? "\n" : "");
}
TRACE("ipv4 veth route: %s/%u", bufinet4, inet4dev->prefix);
}
- lxc_list_for_each_safe(cur, &netdev->priv.veth_attr.ipv6_routes, next) {
- inet6dev = cur->elem;
+ list_for_each_entry(inet6dev, &netdev->priv.veth_attr.ipv6_routes, head) {
if (!inet_ntop(AF_INET6, &inet6dev->addr, bufinet6, sizeof(bufinet6))) {
ERROR("Invalid ipv6 veth route");
return;
free(inetdev);
}
- lxc_list_for_each_safe(cur, &netdev->priv.veth_attr.ipv6_routes, next) {
- lxc_list_del(cur);
- free(cur->elem);
- free(cur);
+ list_for_each_entry_safe(inet6dev, ninet6dev, &netdev->priv.veth_attr.ipv6_routes, head) {
+ list_del(&inet6dev->head);
+ free(inet6dev);
}
lxc_list_for_each_safe(cur, &netdev->priv.veth_attr.vlan_tagged_ids, next) {
return 0;
}
-static int lxc_setup_ipv6_routes(struct lxc_list *ip, int ifindex)
+static int setup_ipv6_routes(struct lxc_netdev *netdev)
{
- struct lxc_list *iterator;
int err;
+ struct lxc_inet6dev *inet6dev;
+ int ifindex = netdev->priv.veth_attr.ifindex;
- lxc_list_for_each(iterator, ip) {
- struct lxc_inet6dev *inet6dev = iterator->elem;
-
+ list_for_each_entry(inet6dev, &netdev->priv.veth_attr.ipv6_routes, head) {
err = lxc_ipv6_dest_add(ifindex, &inet6dev->addr, inet6dev->prefix);
if (err)
return log_error_errno(-1, -err, "Failed to setup ipv6 route for network device with ifindex %d", ifindex);
}
/* setup ipv6 routes on the host interface */
- if (lxc_setup_ipv6_routes(&netdev->priv.veth_attr.ipv6_routes, netdev->priv.veth_attr.ifindex)) {
+ if (setup_ipv6_routes(netdev)) {
ERROR("Failed to setup ipv6 routes for network device \"%s\"", veth1);
goto out_delete;
}