]>
Commit | Line | Data |
---|---|---|
c4a5ddc9 TG |
1 | /*** |
2 | This file is part of systemd. | |
3 | ||
4 | Copyright 2013-2015 Tom Gundersen <teg@jklm.no> | |
5 | ||
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. | |
10 | ||
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. | |
15 | ||
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/>. | |
18 | ***/ | |
19 | ||
20 | #include <net/if.h> | |
c4a5ddc9 | 21 | |
c4a5ddc9 | 22 | #include "conf-parser.h" |
8b43440b LP |
23 | #include "networkd-netdev-ipvlan.h" |
24 | #include "string-table.h" | |
c4a5ddc9 TG |
25 | |
26 | static const char* const ipvlan_mode_table[_NETDEV_IPVLAN_MODE_MAX] = { | |
27 | [NETDEV_IPVLAN_MODE_L2] = "L2", | |
28 | [NETDEV_IPVLAN_MODE_L3] = "L3", | |
29 | }; | |
30 | ||
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"); | |
33 | ||
1c4baffc | 34 | static int netdev_ipvlan_fill_message_create(NetDev *netdev, Link *link, sd_netlink_message *req) { |
0695cb45 | 35 | IPVlan *m; |
c4a5ddc9 TG |
36 | int r; |
37 | ||
38 | assert(netdev); | |
c4a5ddc9 TG |
39 | assert(link); |
40 | assert(netdev->ifname); | |
41 | ||
0695cb45 SS |
42 | m = IPVLAN(netdev); |
43 | ||
44 | assert(m); | |
45 | ||
c4a5ddc9 | 46 | if (m->mode != _NETDEV_IPVLAN_MODE_INVALID) { |
1c4baffc | 47 | r = sd_netlink_message_append_u16(req, IFLA_IPVLAN_MODE, m->mode); |
f6a0ea85 SS |
48 | if (r < 0) |
49 | return log_netdev_error_errno(netdev, r, "Could not append IFLA_IPVLAN_MODE attribute: %m"); | |
c4a5ddc9 TG |
50 | } |
51 | ||
52 | return 0; | |
53 | } | |
54 | ||
55 | static void ipvlan_init(NetDev *n) { | |
0695cb45 | 56 | IPVlan *m; |
c4a5ddc9 TG |
57 | |
58 | assert(n); | |
0695cb45 SS |
59 | |
60 | m = IPVLAN(n); | |
61 | ||
c4a5ddc9 TG |
62 | assert(m); |
63 | ||
64 | m->mode = _NETDEV_IPVLAN_MODE_INVALID; | |
65 | } | |
66 | ||
67 | const NetDevVTable ipvlan_vtable = { | |
68 | .object_size = sizeof(IPVlan), | |
69 | .init = ipvlan_init, | |
70 | .sections = "Match\0NetDev\0IPVLAN\0", | |
71 | .fill_message_create = netdev_ipvlan_fill_message_create, | |
72 | .create_type = NETDEV_CREATE_STACKED, | |
73 | }; |