1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
4 This file is part of systemd.
6 Copyright 2013 Tom Gundersen <teg@jklm.no>
8 systemd is free software; you can redistribute it and/or modify it
9 under the terms of the GNU Lesser General Public License as published by
10 the Free Software Foundation; either version 2.1 of the License, or
11 (at your option) any later version.
13 systemd is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Lesser General Public License for more details.
18 You should have received a copy of the GNU Lesser General Public License
19 along with systemd; If not, see <http://www.gnu.org/licenses/>.
24 #include "networkd-netdev-vlan.h"
25 #include "network-internal.h"
28 static int netdev_vlan_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_message *req) {
32 assert(netdev->ifname);
33 assert(netdev->kind == NETDEV_KIND_VLAN);
37 r = sd_rtnl_message_append_u32(req, IFLA_LINK, link->ifindex);
39 log_error_netdev(netdev,
40 "Could not append IFLA_LINK attribute: %s",
45 r = sd_rtnl_message_append_string(req, IFLA_IFNAME, netdev->ifname);
47 log_error_netdev(netdev,
48 "Could not append IFLA_IFNAME attribute: %s",
54 r = sd_rtnl_message_append_u32(req, IFLA_MTU, netdev->mtu);
56 log_error_netdev(netdev,
57 "Could not append IFLA_MTU attribute: %s",
64 r = sd_rtnl_message_append_ether_addr(req, IFLA_ADDRESS, netdev->mac);
66 log_error_netdev(netdev,
67 "Could not append IFLA_ADDRESS attribute: %s",
73 r = sd_rtnl_message_open_container(req, IFLA_LINKINFO);
75 log_error_netdev(netdev,
76 "Could not open IFLA_LINKINFO container: %s",
81 r = sd_rtnl_message_open_container_union(req, IFLA_INFO_DATA, "vlan");
83 log_error_netdev(netdev,
84 "Could not open IFLA_INFO_DATA container: %s",
89 if (netdev->vlanid <= VLANID_MAX) {
90 r = sd_rtnl_message_append_u16(req, IFLA_VLAN_ID, netdev->vlanid);
92 log_error_netdev(netdev,
93 "Could not append IFLA_VLAN_ID attribute: %s",
99 r = sd_rtnl_message_close_container(req);
101 log_error_netdev(netdev,
102 "Could not close IFLA_INFO_DATA container %s",
107 r = sd_rtnl_message_close_container(req);
109 log_error_netdev(netdev,
110 "Could not close IFLA_LINKINFO container %s",
118 static int netdev_vlan_verify(NetDev *netdev, const char *filename) {
122 if (netdev->vlanid > VLANID_MAX) {
123 log_warning("VLAN without valid Id configured in %s. Ignoring", filename);
130 const NetDevVTable vlan_vtable = {
131 .fill_message_create_on_link = netdev_vlan_fill_message_create,
132 .config_verify = netdev_vlan_verify,