From 672682a6b9d6fb6a3722c3fea1a93b4831747b54 Mon Sep 17 00:00:00 2001 From: Tom Gundersen Date: Mon, 10 Feb 2014 18:41:54 +0100 Subject: networkd: VLAN - allow multiple vlans to be created on a link Also limit the range of vlan ids. Other implementations and documentation use the ranges {0,1}-{4094,4095}, but we use the one accepted by the kernel: 0-4094. Reported-by: Oleksii Shevchuk --- src/network/networkd-link.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src/network/networkd-link.c') diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index 6468f9cd31..5e763069f3 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -866,6 +866,8 @@ static int enslave_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) { } static int link_enter_enslave(Link *link) { + NetDev *vlan; + Iterator i; int r; assert(link); @@ -874,7 +876,7 @@ static int link_enter_enslave(Link *link) { link->state = LINK_STATE_ENSLAVING; - if (!link->network->bridge && !link->network->bond && !link->network->vlan) + if (!link->network->bridge && !link->network->bond && !link->network->vlans) return link_enslaved(link); if (link->network->bridge) { @@ -898,20 +900,17 @@ static int link_enter_enslave(Link *link) { link->enslaving ++; } - if (link->network->vlan) { + HASHMAP_FOREACH(vlan, link->network->vlans, i) { log_struct_link(LOG_DEBUG, link, "MESSAGE=%s: enslaving by '%s'", - link->ifname, link->network->vlan->name, - NETDEV(link->network->vlan), - NULL); + link->ifname, vlan->name, NETDEV(vlan), NULL); - r = netdev_enslave(link->network->vlan, link, &enslave_handler); + r = netdev_enslave(vlan, link, &enslave_handler); if (r < 0) { log_struct_link(LOG_WARNING, link, "MESSAGE=%s: could not enslave by '%s': %s", - link->ifname, link->network->vlan->name, - strerror(-r), NETDEV(link->network->vlan), - NULL); + link->ifname, vlan->name, strerror(-r), + NETDEV(vlan), NULL); link_enter_failed(link); return r; } -- cgit v1.2.3-54-g00ecf