]>
Commit | Line | Data |
---|---|---|
0372cb2b TG |
1 | /*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ |
2 | ||
3 | /*** | |
4 | This file is part of systemd. | |
5 | ||
6 | Copyright 2013 Tom Gundersen <teg@jklm.no> | |
7 | ||
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. | |
12 | ||
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. | |
17 | ||
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/>. | |
20 | ***/ | |
21 | ||
22 | #include <net/if.h> | |
23 | ||
3be1d7e0 | 24 | #include "networkd-netdev-macvlan.h" |
0372cb2b | 25 | #include "conf-parser.h" |
0372cb2b TG |
26 | |
27 | static const char* const macvlan_mode_table[_NETDEV_MACVLAN_MODE_MAX] = { | |
28 | [NETDEV_MACVLAN_MODE_PRIVATE] = "private", | |
29 | [NETDEV_MACVLAN_MODE_VEPA] = "vepa", | |
30 | [NETDEV_MACVLAN_MODE_BRIDGE] = "bridge", | |
31 | [NETDEV_MACVLAN_MODE_PASSTHRU] = "passthru", | |
32 | }; | |
33 | ||
34 | DEFINE_STRING_TABLE_LOOKUP(macvlan_mode, MacVlanMode); | |
35 | DEFINE_CONFIG_PARSE_ENUM(config_parse_macvlan_mode, macvlan_mode, MacVlanMode, "Failed to parse macvlan mode"); | |
36 | ||
3be1d7e0 | 37 | static int netdev_macvlan_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_message *req) { |
aa9f1140 | 38 | MacVlan *m = MACVLAN(netdev); |
0372cb2b TG |
39 | int r; |
40 | ||
41 | assert(netdev); | |
aa9f1140 | 42 | assert(m); |
0372cb2b | 43 | assert(link); |
0372cb2b | 44 | assert(netdev->ifname); |
0372cb2b | 45 | |
aa9f1140 TG |
46 | if (m->mode != _NETDEV_MACVLAN_MODE_INVALID) { |
47 | r = sd_rtnl_message_append_u32(req, IFLA_MACVLAN_MODE, m->mode); | |
0372cb2b | 48 | if (r < 0) { |
79008bdd | 49 | log_netdev_error(netdev, |
0372cb2b TG |
50 | "Could not append IFLA_MACVLAN_MODE attribute: %s", |
51 | strerror(-r)); | |
52 | return r; | |
53 | } | |
54 | } | |
55 | ||
aa9f1140 TG |
56 | return 0; |
57 | } | |
0372cb2b | 58 | |
aa9f1140 TG |
59 | static void macvlan_init(NetDev *n) { |
60 | MacVlan *m = MACVLAN(n); | |
0372cb2b | 61 | |
aa9f1140 TG |
62 | assert(n); |
63 | assert(m); | |
64 | ||
65 | m->mode = _NETDEV_MACVLAN_MODE_INVALID; | |
0372cb2b | 66 | } |
3be1d7e0 TG |
67 | |
68 | const NetDevVTable macvlan_vtable = { | |
aa9f1140 TG |
69 | .object_size = sizeof(MacVlan), |
70 | .init = macvlan_init, | |
71 | .sections = "Match\0NetDev\0MACVLAN\0", | |
72 | .fill_message_create = netdev_macvlan_fill_message_create, | |
73 | .create_type = NETDEV_CREATE_STACKED, | |
3be1d7e0 | 74 | }; |