]>
Commit | Line | Data |
---|---|---|
c4a5ddc9 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-2015 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> | |
c4a5ddc9 | 23 | |
c4a5ddc9 | 24 | #include "conf-parser.h" |
8b43440b LP |
25 | #include "networkd-netdev-ipvlan.h" |
26 | #include "string-table.h" | |
c4a5ddc9 TG |
27 | |
28 | static const char* const ipvlan_mode_table[_NETDEV_IPVLAN_MODE_MAX] = { | |
29 | [NETDEV_IPVLAN_MODE_L2] = "L2", | |
30 | [NETDEV_IPVLAN_MODE_L3] = "L3", | |
31 | }; | |
32 | ||
33 | DEFINE_STRING_TABLE_LOOKUP(ipvlan_mode, IPVlanMode); | |
34 | DEFINE_CONFIG_PARSE_ENUM(config_parse_ipvlan_mode, ipvlan_mode, IPVlanMode, "Failed to parse ipvlan mode"); | |
35 | ||
1c4baffc | 36 | static int netdev_ipvlan_fill_message_create(NetDev *netdev, Link *link, sd_netlink_message *req) { |
0695cb45 | 37 | IPVlan *m; |
c4a5ddc9 TG |
38 | int r; |
39 | ||
40 | assert(netdev); | |
c4a5ddc9 TG |
41 | assert(link); |
42 | assert(netdev->ifname); | |
43 | ||
0695cb45 SS |
44 | m = IPVLAN(netdev); |
45 | ||
46 | assert(m); | |
47 | ||
c4a5ddc9 | 48 | if (m->mode != _NETDEV_IPVLAN_MODE_INVALID) { |
1c4baffc | 49 | r = sd_netlink_message_append_u16(req, IFLA_IPVLAN_MODE, m->mode); |
f6a0ea85 SS |
50 | if (r < 0) |
51 | return log_netdev_error_errno(netdev, r, "Could not append IFLA_IPVLAN_MODE attribute: %m"); | |
c4a5ddc9 TG |
52 | } |
53 | ||
54 | return 0; | |
55 | } | |
56 | ||
57 | static void ipvlan_init(NetDev *n) { | |
0695cb45 | 58 | IPVlan *m; |
c4a5ddc9 TG |
59 | |
60 | assert(n); | |
0695cb45 SS |
61 | |
62 | m = IPVLAN(n); | |
63 | ||
c4a5ddc9 TG |
64 | assert(m); |
65 | ||
66 | m->mode = _NETDEV_IPVLAN_MODE_INVALID; | |
67 | } | |
68 | ||
69 | const NetDevVTable ipvlan_vtable = { | |
70 | .object_size = sizeof(IPVlan), | |
71 | .init = ipvlan_init, | |
72 | .sections = "Match\0NetDev\0IPVLAN\0", | |
73 | .fill_message_create = netdev_ipvlan_fill_message_create, | |
74 | .create_type = NETDEV_CREATE_STACKED, | |
75 | }; |