2 This file is part of systemd.
4 Copyright 2013 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 "networkd-netdev-macvlan.h"
24 #include "string-table.h"
26 static const char* const macvlan_mode_table
[_NETDEV_MACVLAN_MODE_MAX
] = {
27 [NETDEV_MACVLAN_MODE_PRIVATE
] = "private",
28 [NETDEV_MACVLAN_MODE_VEPA
] = "vepa",
29 [NETDEV_MACVLAN_MODE_BRIDGE
] = "bridge",
30 [NETDEV_MACVLAN_MODE_PASSTHRU
] = "passthru",
33 DEFINE_STRING_TABLE_LOOKUP(macvlan_mode
, MacVlanMode
);
34 DEFINE_CONFIG_PARSE_ENUM(config_parse_macvlan_mode
, macvlan_mode
, MacVlanMode
, "Failed to parse macvlan mode");
36 static int netdev_macvlan_fill_message_create(NetDev
*netdev
, Link
*link
, sd_netlink_message
*req
) {
42 assert(netdev
->ifname
);
44 if (netdev
->kind
== NETDEV_KIND_MACVLAN
)
51 if (m
->mode
!= _NETDEV_MACVLAN_MODE_INVALID
) {
52 r
= sd_netlink_message_append_u32(req
, IFLA_MACVLAN_MODE
, m
->mode
);
54 return log_netdev_error_errno(netdev
, r
, "Could not append IFLA_MACVLAN_MODE attribute: %m");
60 static void macvlan_init(NetDev
*n
) {
65 if (n
->kind
== NETDEV_KIND_MACVLAN
)
72 m
->mode
= _NETDEV_MACVLAN_MODE_INVALID
;
75 const NetDevVTable macvtap_vtable
= {
76 .object_size
= sizeof(MacVlan
),
78 .sections
= "Match\0NetDev\0MACVTAP\0",
79 .fill_message_create
= netdev_macvlan_fill_message_create
,
80 .create_type
= NETDEV_CREATE_STACKED
,
83 const NetDevVTable macvlan_vtable
= {
84 .object_size
= sizeof(MacVlan
),
86 .sections
= "Match\0NetDev\0MACVLAN\0",
87 .fill_message_create
= netdev_macvlan_fill_message_create
,
88 .create_type
= NETDEV_CREATE_STACKED
,