]>
Commit | Line | Data |
---|---|---|
db9ecf05 | 1 | /* SPDX-License-Identifier: LGPL-2.1-or-later */ |
d6df583c | 2 | |
9714c020 | 3 | #include <linux/can/vxcan.h> |
9714c020 | 4 | |
737f1405 | 5 | #include "vxcan.h" |
d6df583c SS |
6 | |
7 | static int netdev_vxcan_fill_message_create(NetDev *netdev, Link *link, sd_netlink_message *m) { | |
8 | VxCan *v; | |
9 | int r; | |
10 | ||
11 | assert(netdev); | |
12 | assert(!link); | |
13 | assert(m); | |
14 | ||
15 | v = VXCAN(netdev); | |
16 | ||
17 | assert(v); | |
18 | ||
19 | r = sd_netlink_message_open_container(m, VXCAN_INFO_PEER); | |
20 | if (r < 0) | |
21 | return log_netdev_error_errno(netdev, r, "Could not append VXCAN_INFO_PEER attribute: %m"); | |
22 | ||
23 | if (v->ifname_peer) { | |
24 | r = sd_netlink_message_append_string(m, IFLA_IFNAME, v->ifname_peer); | |
25 | if (r < 0) | |
98b02994 | 26 | return log_netdev_error_errno(netdev, r, "Failed to add vxcan netlink interface peer name: %m"); |
d6df583c SS |
27 | } |
28 | ||
29 | r = sd_netlink_message_close_container(m); | |
30 | if (r < 0) | |
31 | return log_netdev_error_errno(netdev, r, "Could not append VXCAN_INFO_PEER attribute: %m"); | |
32 | ||
33 | return r; | |
34 | } | |
35 | ||
36 | static int netdev_vxcan_verify(NetDev *netdev, const char *filename) { | |
37 | VxCan *v; | |
38 | ||
39 | assert(netdev); | |
40 | assert(filename); | |
41 | ||
42 | v = VXCAN(netdev); | |
43 | ||
44 | assert(v); | |
45 | ||
46 | if (!v->ifname_peer) { | |
98b02994 | 47 | log_netdev_warning(netdev, "VxCan NetDev without peer name configured in %s. Ignoring", filename); |
d6df583c SS |
48 | return -EINVAL; |
49 | } | |
50 | ||
51 | return 0; | |
52 | } | |
53 | ||
54 | static void vxcan_done(NetDev *n) { | |
55 | VxCan *v; | |
56 | ||
57 | assert(n); | |
58 | ||
59 | v = VXCAN(n); | |
60 | ||
61 | assert(v); | |
62 | ||
63 | free(v->ifname_peer); | |
64 | } | |
65 | ||
66 | const NetDevVTable vxcan_vtable = { | |
67 | .object_size = sizeof(VxCan), | |
130b812f | 68 | .sections = NETDEV_COMMON_SECTIONS "VXCAN\0", |
d6df583c SS |
69 | .done = vxcan_done, |
70 | .fill_message_create = netdev_vxcan_fill_message_create, | |
71 | .create_type = NETDEV_CREATE_INDEPENDENT, | |
72 | .config_verify = netdev_vxcan_verify, | |
daf0f8ca | 73 | .generate_mac = true, |
d6df583c | 74 | }; |