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