2 This file is part of systemd.
4 Copyright 2014 Susant Sahani <susant@redhat.com>
6 systemd is free software; you can redistribute it and/or modify it
7 under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version.
11 systemd is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public License
17 along with systemd; If not, see <http://www.gnu.org/licenses/>.
21 #include <linux/veth.h>
23 #include "sd-netlink.h"
25 #include "networkd-netdev-veth.h"
27 static int netdev_veth_fill_message_create(NetDev
*netdev
, Link
*link
, sd_netlink_message
*m
) {
39 r
= sd_netlink_message_open_container(m
, VETH_INFO_PEER
);
41 return log_netdev_error_errno(netdev
, r
, "Could not append VETH_INFO_PEER attribute: %m");
44 r
= sd_netlink_message_append_string(m
, IFLA_IFNAME
, v
->ifname_peer
);
46 return log_error_errno(r
, "Failed to add netlink interface name: %m");
50 r
= sd_netlink_message_append_ether_addr(m
, IFLA_ADDRESS
, v
->mac_peer
);
52 return log_netdev_error_errno(netdev
, r
, "Could not append IFLA_ADDRESS attribute: %m");
55 r
= sd_netlink_message_close_container(m
);
57 return log_netdev_error_errno(netdev
, r
, "Could not append IFLA_INFO_DATA attribute: %m");
62 static int netdev_veth_verify(NetDev
*netdev
, const char *filename
) {
73 if (!v
->ifname_peer
) {
74 log_warning("Veth NetDev without peer name configured in %s. Ignoring",
80 r
= netdev_get_mac(v
->ifname_peer
, &v
->mac_peer
);
82 log_warning("Failed to generate predictable MAC address for %s. Ignoring",
91 static void veth_done(NetDev
*n
) {
100 free(v
->ifname_peer
);
104 const NetDevVTable veth_vtable
= {
105 .object_size
= sizeof(Veth
),
106 .sections
= "Match\0NetDev\0Peer\0",
108 .fill_message_create
= netdev_veth_fill_message_create
,
109 .create_type
= NETDEV_CREATE_INDEPENDENT
,
110 .config_verify
= netdev_veth_verify
,