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"
28 #include "networkd-link.h"
31 static int netdev_vxlan_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_message *m) {
32 VxLan *v = VXLAN(netdev);
41 if (v->id <= VXLAN_VID_MAX) {
42 r = sd_rtnl_message_append_u32(m, IFLA_VXLAN_ID, v->id);
44 log_error_netdev(netdev,
45 "Could not append IFLA_VXLAN_ID attribute: %s",
51 r = sd_rtnl_message_append_in_addr(m, IFLA_VXLAN_GROUP, &v->group.in);
53 log_error_netdev(netdev,
54 "Could not append IFLA_VXLAN_GROUP attribute: %s",
59 r = sd_rtnl_message_append_u32(m, IFLA_VXLAN_LINK, link->ifindex);
61 log_error_netdev(netdev,
62 "Could not append IFLA_VXLAN_LINK attribute: %s",
68 r = sd_rtnl_message_append_u8(m, IFLA_VXLAN_TTL, v->ttl);
70 log_error_netdev(netdev,
71 "Could not append IFLA_VXLAN_TTL attribute: %s",
78 r = sd_rtnl_message_append_u8(m, IFLA_VXLAN_TOS, v->tos);
80 log_error_netdev(netdev,
81 "Could not append IFLA_VXLAN_TOS attribute: %s",
87 r = sd_rtnl_message_append_u8(m, IFLA_VXLAN_LEARNING, v->learning);
89 log_error_netdev(netdev,
90 "Could not append IFLA_VXLAN_LEARNING attribute: %s",
98 static int netdev_vxlan_verify(NetDev *netdev, const char *filename) {
99 VxLan *v = VXLAN(netdev);
105 if (v->id > VXLAN_VID_MAX) {
106 log_warning("VXLAN without valid Id configured in %s. Ignoring", filename);
113 static void vxlan_init(NetDev *netdev) {
114 VxLan *v = VXLAN(netdev);
119 v->id = VXLAN_VID_MAX + 1;
123 const NetDevVTable vxlan_vtable = {
124 .object_size = sizeof(VxLan),
126 .sections = "Match\0NetDev\0VXLAN\0",
127 .fill_message_create = netdev_vxlan_fill_message_create,
128 .create_type = NETDEV_CREATE_STACKED,
129 .config_verify = netdev_vxlan_verify,