1 /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
4 This file is part of systemd.
6 Copyright 2014 Susant Sahani <susant@redhat.com>
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/>.
22 #include <netinet/ether.h>
23 #include <arpa/inet.h>
27 #include "networkd-netdev-vxlan.h"
30 static int netdev_vxlan_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_message *m) {
38 r = sd_rtnl_message_append_string(m, IFLA_IFNAME, netdev->ifname);
40 log_error_netdev(netdev,
41 "Could not append IFLA_IFNAME, attribute: %s",
46 r = sd_rtnl_message_open_container(m, IFLA_LINKINFO);
48 log_error_netdev(netdev,
49 "Could not append IFLA_LINKINFO attribute: %s",
54 r = sd_rtnl_message_open_container_union(m, IFLA_INFO_DATA, "vxlan");
56 log_error_netdev(netdev,
57 "Could not append IFLA_INFO_DATA attribute: %s",
62 if (netdev->vlanid <= VXLAN_VID_MAX) {
63 r = sd_rtnl_message_append_u32(m, IFLA_VXLAN_ID, netdev->vxlanid);
65 log_error_netdev(netdev,
66 "Could not append IFLA_VXLAN_ID attribute: %s",
72 r = sd_rtnl_message_append_in_addr(m, IFLA_VXLAN_GROUP, &netdev->group.in);
74 log_error_netdev(netdev,
75 "Could not append IFLA_VXLAN_GROUP attribute: %s",
80 r = sd_rtnl_message_append_u32(m, IFLA_VXLAN_LINK, link->ifindex);
82 log_error_netdev(netdev,
83 "Could not append IFLA_VXLAN_LINK attribute: %s",
89 r = sd_rtnl_message_append_u8(m, IFLA_VXLAN_TTL, netdev->ttl);
91 log_error_netdev(netdev,
92 "Could not append IFLA_VXLAN_TTL attribute: %s",
99 r = sd_rtnl_message_append_u8(m, IFLA_VXLAN_TOS, netdev->tos);
101 log_error_netdev(netdev,
102 "Could not append IFLA_VXLAN_TOS attribute: %s",
108 r = sd_rtnl_message_append_u8(m, IFLA_VXLAN_LEARNING, netdev->learning);
110 log_error_netdev(netdev,
111 "Could not append IFLA_VXLAN_LEARNING attribute: %s",
116 r = sd_rtnl_message_close_container(m);
118 log_error_netdev(netdev,
119 "Could not append IFLA_LINKINFO attribute: %s",
127 static int netdev_vxlan_verify(NetDev *netdev, const char *filename) {
131 if (netdev->vxlanid > VXLAN_VID_MAX) {
132 log_warning("VXLAN without valid Id configured in %s. Ignoring", filename);
139 const NetDevVTable vxlan_vtable = {
140 .fill_message_create_on_link = netdev_vxlan_fill_message_create,
141 .config_verify = netdev_vxlan_verify,