]> git.ipfire.org Git - thirdparty/systemd.git/blob - src/network/netdev/vxcan.c
Merge pull request #33386 from yuwata/journal-timestamp
[thirdparty/systemd.git] / src / network / netdev / vxcan.c
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2
3 #include <linux/can/vxcan.h>
4 #include <linux/if_arp.h>
5
6 #include "vxcan.h"
7
8 static int netdev_vxcan_fill_message_create(NetDev *netdev, Link *link, sd_netlink_message *m) {
9 assert(!link);
10 assert(m);
11
12 VxCan *v = VXCAN(netdev);
13 int r;
14
15 r = sd_netlink_message_open_container(m, VXCAN_INFO_PEER);
16 if (r < 0)
17 return r;
18
19 if (v->ifname_peer) {
20 r = sd_netlink_message_append_string(m, IFLA_IFNAME, v->ifname_peer);
21 if (r < 0)
22 return r;
23 }
24
25 r = sd_netlink_message_close_container(m);
26 if (r < 0)
27 return r;
28
29 return 0;
30 }
31
32 static int netdev_vxcan_verify(NetDev *netdev, const char *filename) {
33 assert(filename);
34
35 VxCan *v = VXCAN(netdev);
36
37 if (!v->ifname_peer)
38 return log_netdev_warning_errno(netdev, SYNTHETIC_ERRNO(EINVAL),
39 "VxCan NetDev without peer name configured in %s. Ignoring", filename);
40
41 return 0;
42 }
43
44 static void vxcan_done(NetDev *netdev) {
45 VxCan *v = VXCAN(netdev);
46
47 free(v->ifname_peer);
48 }
49
50 const NetDevVTable vxcan_vtable = {
51 .object_size = sizeof(VxCan),
52 .sections = NETDEV_COMMON_SECTIONS "VXCAN\0",
53 .done = vxcan_done,
54 .fill_message_create = netdev_vxcan_fill_message_create,
55 .create_type = NETDEV_CREATE_INDEPENDENT,
56 .config_verify = netdev_vxcan_verify,
57 .iftype = ARPHRD_CAN,
58 };