2 This file is part of systemd.
4 Copyright 2013-2015 Tom Gundersen <teg@jklm.no>
6 systemd is free software; you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version.
11 systemd is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public License
17 along with systemd; If not, see <http://www.gnu.org/licenses/>.
22 #include "conf-parser.h"
23 #include "netdev/ipvlan.h"
24 #include "string-table.h"
26 static const char* const ipvlan_mode_table
[_NETDEV_IPVLAN_MODE_MAX
] = {
27 [NETDEV_IPVLAN_MODE_L2
] = "L2",
28 [NETDEV_IPVLAN_MODE_L3
] = "L3",
31 DEFINE_STRING_TABLE_LOOKUP(ipvlan_mode
, IPVlanMode
);
32 DEFINE_CONFIG_PARSE_ENUM(config_parse_ipvlan_mode
, ipvlan_mode
, IPVlanMode
, "Failed to parse ipvlan mode");
34 static int netdev_ipvlan_fill_message_create(NetDev
*netdev
, Link
*link
, sd_netlink_message
*req
) {
40 assert(netdev
->ifname
);
46 if (m
->mode
!= _NETDEV_IPVLAN_MODE_INVALID
) {
47 r
= sd_netlink_message_append_u16(req
, IFLA_IPVLAN_MODE
, m
->mode
);
49 return log_netdev_error_errno(netdev
, r
, "Could not append IFLA_IPVLAN_MODE attribute: %m");
55 static void ipvlan_init(NetDev
*n
) {
64 m
->mode
= _NETDEV_IPVLAN_MODE_INVALID
;
67 const NetDevVTable ipvlan_vtable
= {
68 .object_size
= sizeof(IPVlan
),
70 .sections
= "Match\0NetDev\0IPVLAN\0",
71 .fill_message_create
= netdev_ipvlan_fill_message_create
,
72 .create_type
= NETDEV_CREATE_STACKED
,