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"
29 #include "conf-parser.h"
32 static int netdev_vxlan_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_message *m) {
33 VxLan *v = VXLAN(netdev);
42 if (v->id <= VXLAN_VID_MAX) {
43 r = sd_rtnl_message_append_u32(m, IFLA_VXLAN_ID, v->id);
45 log_netdev_error(netdev,
46 "Could not append IFLA_VXLAN_ID attribute: %s",
52 r = sd_rtnl_message_append_in_addr(m, IFLA_VXLAN_GROUP, &v->group.in);
54 log_netdev_error(netdev,
55 "Could not append IFLA_VXLAN_GROUP attribute: %s",
60 r = sd_rtnl_message_append_u32(m, IFLA_VXLAN_LINK, link->ifindex);
62 log_netdev_error(netdev,
63 "Could not append IFLA_VXLAN_LINK attribute: %s",
69 r = sd_rtnl_message_append_u8(m, IFLA_VXLAN_TTL, v->ttl);
71 log_netdev_error(netdev,
72 "Could not append IFLA_VXLAN_TTL attribute: %s",
79 r = sd_rtnl_message_append_u8(m, IFLA_VXLAN_TOS, v->tos);
81 log_netdev_error(netdev,
82 "Could not append IFLA_VXLAN_TOS attribute: %s",
88 r = sd_rtnl_message_append_u8(m, IFLA_VXLAN_LEARNING, v->learning);
90 log_netdev_error(netdev,
91 "Could not append IFLA_VXLAN_LEARNING attribute: %s",
96 r = sd_rtnl_message_append_u8(m, IFLA_VXLAN_RSC, v->route_short_circuit);
98 log_netdev_error(netdev,
99 "Could not append IFLA_VXLAN_RSC attribute: %s",
104 r = sd_rtnl_message_append_u8(m, IFLA_VXLAN_PROXY, v->arp_proxy);
106 log_netdev_error(netdev,
107 "Could not append IFLA_VXLAN_PROXY attribute: %s",
112 r = sd_rtnl_message_append_u8(m, IFLA_VXLAN_L2MISS, v->l2miss);
114 log_netdev_error(netdev,
115 "Could not append IFLA_VXLAN_L2MISS attribute: %s",
120 r = sd_rtnl_message_append_u8(m, IFLA_VXLAN_L3MISS, v->l3miss);
122 log_netdev_error(netdev,
123 "Could not append IFLA_VXLAN_L3MISS attribute: %s",
129 r = sd_rtnl_message_append_u32(m, IFLA_VXLAN_AGEING, v->fdb_ageing / USEC_PER_SEC);
131 log_netdev_error(netdev,
132 "Could not append IFLA_VXLAN_AGEING attribute: %s",
141 int config_parse_vxlan_group_address(const char *unit,
142 const char *filename,
145 unsigned section_line,
152 union in_addr_union *addr = data, buffer;
160 r = in_addr_from_string_auto(rvalue, &f, &buffer);
162 log_syntax(unit, LOG_ERR, filename, line, EINVAL,
163 "vxlan multicast group address is invalid, ignoring assignment: %s", rvalue);
167 if(v->family != AF_UNSPEC && v->family != f) {
168 log_syntax(unit, LOG_ERR, filename, line, EINVAL,
169 "vxlan multicast group incompatible, ignoring assignment: %s", rvalue);
179 static int netdev_vxlan_verify(NetDev *netdev, const char *filename) {
180 VxLan *v = VXLAN(netdev);
186 if (v->id > VXLAN_VID_MAX) {
187 log_warning("VXLAN without valid Id configured in %s. Ignoring", filename);
194 static void vxlan_init(NetDev *netdev) {
195 VxLan *v = VXLAN(netdev);
200 v->id = VXLAN_VID_MAX + 1;
204 const NetDevVTable vxlan_vtable = {
205 .object_size = sizeof(VxLan),
207 .sections = "Match\0NetDev\0VXLAN\0",
208 .fill_message_create = netdev_vxlan_fill_message_create,
209 .create_type = NETDEV_CREATE_STACKED,
210 .config_verify = netdev_vxlan_verify,