]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/network/netdev/vxcan.c
tree-wide: beautify remaining copyright statements
[thirdparty/systemd.git] / src / network / netdev / vxcan.c
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 /***
3 Copyright © 2017 Susant Sahani
4 ***/
5
6 #include "netdev/vxcan.h"
7 #include "missing.h"
8
9 static int netdev_vxcan_fill_message_create(NetDev *netdev, Link *link, sd_netlink_message *m) {
10 VxCan *v;
11 int r;
12
13 assert(netdev);
14 assert(!link);
15 assert(m);
16
17 v = VXCAN(netdev);
18
19 assert(v);
20
21 r = sd_netlink_message_open_container(m, VXCAN_INFO_PEER);
22 if (r < 0)
23 return log_netdev_error_errno(netdev, r, "Could not append VXCAN_INFO_PEER attribute: %m");
24
25 if (v->ifname_peer) {
26 r = sd_netlink_message_append_string(m, IFLA_IFNAME, v->ifname_peer);
27 if (r < 0)
28 return log_error_errno(r, "Failed to add vxcan netlink interface peer name: %m");
29 }
30
31 r = sd_netlink_message_close_container(m);
32 if (r < 0)
33 return log_netdev_error_errno(netdev, r, "Could not append VXCAN_INFO_PEER attribute: %m");
34
35 return r;
36 }
37
38 static int netdev_vxcan_verify(NetDev *netdev, const char *filename) {
39 VxCan *v;
40
41 assert(netdev);
42 assert(filename);
43
44 v = VXCAN(netdev);
45
46 assert(v);
47
48 if (!v->ifname_peer) {
49 log_warning("VxCan NetDev without peer name configured in %s. Ignoring", filename);
50 return -EINVAL;
51 }
52
53 return 0;
54 }
55
56 static void vxcan_done(NetDev *n) {
57 VxCan *v;
58
59 assert(n);
60
61 v = VXCAN(n);
62
63 assert(v);
64
65 free(v->ifname_peer);
66 }
67
68 const NetDevVTable vxcan_vtable = {
69 .object_size = sizeof(VxCan),
70 .sections = "Match\0NetDev\0VXCAN\0",
71 .done = vxcan_done,
72 .fill_message_create = netdev_vxcan_fill_message_create,
73 .create_type = NETDEV_CREATE_INDEPENDENT,
74 .config_verify = netdev_vxcan_verify,
75 };