1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-11 05:17:44 +03:00

network/netdev: introduce .iftype to netdev vtable

And disable .generate_mac flag for non-ether interfaces.
This commit is contained in:
Yu Watanabe 2021-11-07 16:27:33 +09:00
parent a67e0507c3
commit 9f0cf80dd0
23 changed files with 78 additions and 12 deletions

View File

@ -1,6 +1,9 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later
* Copyright © 2020 VMware, Inc. */
#include <netinet/in.h>
#include <linux/if_arp.h>
#include "bareudp.h"
#include "netlink-util.h"
#include "networkd-manager.h"
@ -79,4 +82,5 @@ const NetDevVTable bare_udp_vtable = {
.config_verify = netdev_bare_udp_verify,
.fill_message_create = netdev_bare_udp_fill_message_create,
.create_type = NETDEV_CREATE_INDEPENDENT,
.iftype = ARPHRD_NONE,
};

View File

@ -1,7 +1,9 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <inttypes.h>
#include <netinet/in.h>
#include <linux/genetlink.h>
#include <linux/if_arp.h>
#include "batadv.h"
#include "fileio.h"
@ -200,4 +202,5 @@ const NetDevVTable batadv_vtable = {
.fill_message_create = netdev_batadv_fill_message_create,
.post_create = netdev_batadv_post_create,
.create_type = NETDEV_CREATE_MASTER,
.iftype = ARPHRD_ETHER,
};

View File

@ -1,5 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <netinet/in.h>
#include <linux/if_arp.h>
#include "alloc-util.h"
#include "bond.h"
#include "bond-util.h"
@ -449,5 +452,6 @@ const NetDevVTable bond_vtable = {
.sections = NETDEV_COMMON_SECTIONS "Bond\0",
.fill_message_create = netdev_bond_fill_message_create,
.create_type = NETDEV_CREATE_MASTER,
.iftype = ARPHRD_ETHER,
.generate_mac = true,
};

View File

@ -2,6 +2,7 @@
#include <net/if.h>
#include <netinet/in.h>
#include <linux/if_arp.h>
#include <linux/if_bridge.h>
#include "bridge.h"
@ -276,4 +277,5 @@ const NetDevVTable bridge_vtable = {
.sections = NETDEV_COMMON_SECTIONS "Bridge\0",
.post_create = netdev_bridge_post_create,
.create_type = NETDEV_CREATE_MASTER,
.iftype = ARPHRD_ETHER,
};

View File

@ -1,10 +1,13 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <linux/if_arp.h>
#include "dummy.h"
const NetDevVTable dummy_vtable = {
.object_size = sizeof(Dummy),
.sections = NETDEV_COMMON_SECTIONS,
.create_type = NETDEV_CREATE_INDEPENDENT,
.iftype = ARPHRD_ETHER,
.generate_mac = true,
};

View File

@ -1,6 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <net/if.h>
#include <netinet/in.h>
#include <linux/if_arp.h>
#include "alloc-util.h"
#include "conf-parser.h"
@ -292,5 +294,6 @@ const NetDevVTable geneve_vtable = {
.fill_message_create = netdev_geneve_fill_message_create,
.create_type = NETDEV_CREATE_INDEPENDENT,
.config_verify = netdev_geneve_verify,
.iftype = ARPHRD_ETHER,
.generate_mac = true,
};

View File

@ -1,11 +1,14 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later
* Copyright © 2019 VMware, Inc. */
#include <linux/if_arp.h>
#include "ifb.h"
const NetDevVTable ifb_vtable = {
.object_size = sizeof(IntermediateFunctionalBlock),
.sections = NETDEV_COMMON_SECTIONS,
.create_type = NETDEV_CREATE_INDEPENDENT,
.iftype = ARPHRD_ETHER,
.generate_mac = true,
};

View File

@ -1,6 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <net/if.h>
#include <netinet/in.h>
#include <linux/if_arp.h>
#include "conf-parser.h"
#include "ipvlan.h"
@ -63,6 +65,7 @@ const NetDevVTable ipvlan_vtable = {
.sections = NETDEV_COMMON_SECTIONS "IPVLAN\0",
.fill_message_create = netdev_ipvlan_fill_message_create,
.create_type = NETDEV_CREATE_STACKED,
.iftype = ARPHRD_ETHER,
.generate_mac = true,
};
@ -72,6 +75,7 @@ const NetDevVTable ipvtap_vtable = {
.sections = NETDEV_COMMON_SECTIONS "IPVTAP\0",
.fill_message_create = netdev_ipvlan_fill_message_create,
.create_type = NETDEV_CREATE_STACKED,
.iftype = ARPHRD_ETHER,
.generate_mac = true,
};

View File

@ -1,6 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <netinet/in.h>
#include <linux/if_arp.h>
#include <linux/if_ether.h>
#include <linux/if_macsec.h>
#include <linux/genetlink.h>
@ -1230,5 +1231,6 @@ const NetDevVTable macsec_vtable = {
.done = macsec_done,
.create_type = NETDEV_CREATE_STACKED,
.config_verify = netdev_macsec_verify,
.iftype = ARPHRD_ETHER,
.generate_mac = true,
};

View File

@ -1,6 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <net/if.h>
#include <netinet/in.h>
#include <linux/if_arp.h>
#include "conf-parser.h"
#include "macvlan.h"
@ -153,6 +155,7 @@ const NetDevVTable macvtap_vtable = {
.sections = NETDEV_COMMON_SECTIONS "MACVTAP\0",
.fill_message_create = netdev_macvlan_fill_message_create,
.create_type = NETDEV_CREATE_STACKED,
.iftype = ARPHRD_ETHER,
.generate_mac = true,
};
@ -163,5 +166,6 @@ const NetDevVTable macvlan_vtable = {
.sections = NETDEV_COMMON_SECTIONS "MACVLAN\0",
.fill_message_create = netdev_macvlan_fill_message_create,
.create_type = NETDEV_CREATE_STACKED,
.iftype = ARPHRD_ETHER,
.generate_mac = true,
};

View File

@ -159,6 +159,9 @@ typedef struct NetDevVTable {
/* verify that compulsory configuration options were specified */
int (*config_verify)(NetDev *netdev, const char *filename);
/* expected iftype, e.g. ARPHRD_ETHER. */
uint16_t iftype;
/* Generate MAC address when MACAddress= is not specified. */
bool generate_mac;
} NetDevVTable;

View File

@ -1,10 +1,13 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <linux/if_arp.h>
#include "netdevsim.h"
const NetDevVTable netdevsim_vtable = {
.object_size = sizeof(NetDevSim),
.sections = NETDEV_COMMON_SECTIONS,
.create_type = NETDEV_CREATE_INDEPENDENT,
.iftype = ARPHRD_ETHER,
.generate_mac = true,
};

View File

@ -1,5 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <linux/if_arp.h>
#include "nlmon.h"
static int netdev_nlmon_verify(NetDev *netdev, const char *filename) {
@ -19,4 +21,5 @@ const NetDevVTable nlmon_vtable = {
.sections = NETDEV_COMMON_SECTIONS,
.create_type = NETDEV_CREATE_INDEPENDENT,
.config_verify = netdev_nlmon_verify,
.iftype = ARPHRD_NETLINK,
};

View File

@ -2,8 +2,9 @@
#include <netinet/in.h>
#include <linux/fou.h>
#include <linux/ip.h>
#include <linux/if_arp.h>
#include <linux/if_tunnel.h>
#include <linux/ip.h>
#include <linux/ip6_tunnel.h>
#include "conf-parser.h"
@ -817,7 +818,7 @@ const NetDevVTable ipip_vtable = {
.fill_message_create = netdev_ipip_sit_fill_message_create,
.create_type = NETDEV_CREATE_STACKED,
.config_verify = netdev_tunnel_verify,
.generate_mac = true,
.iftype = ARPHRD_TUNNEL,
};
const NetDevVTable sit_vtable = {
@ -827,7 +828,7 @@ const NetDevVTable sit_vtable = {
.fill_message_create = netdev_ipip_sit_fill_message_create,
.create_type = NETDEV_CREATE_STACKED,
.config_verify = netdev_tunnel_verify,
.generate_mac = true,
.iftype = ARPHRD_SIT,
};
const NetDevVTable vti_vtable = {
@ -837,7 +838,7 @@ const NetDevVTable vti_vtable = {
.fill_message_create = netdev_vti_fill_message_create,
.create_type = NETDEV_CREATE_STACKED,
.config_verify = netdev_tunnel_verify,
.generate_mac = true,
.iftype = ARPHRD_TUNNEL,
};
const NetDevVTable vti6_vtable = {
@ -847,7 +848,7 @@ const NetDevVTable vti6_vtable = {
.fill_message_create = netdev_vti_fill_message_create,
.create_type = NETDEV_CREATE_STACKED,
.config_verify = netdev_tunnel_verify,
.generate_mac = true,
.iftype = ARPHRD_TUNNEL6,
};
const NetDevVTable gre_vtable = {
@ -857,7 +858,7 @@ const NetDevVTable gre_vtable = {
.fill_message_create = netdev_gre_erspan_fill_message_create,
.create_type = NETDEV_CREATE_STACKED,
.config_verify = netdev_tunnel_verify,
.generate_mac = true,
.iftype = ARPHRD_IPGRE,
};
const NetDevVTable gretap_vtable = {
@ -867,6 +868,7 @@ const NetDevVTable gretap_vtable = {
.fill_message_create = netdev_gre_erspan_fill_message_create,
.create_type = NETDEV_CREATE_STACKED,
.config_verify = netdev_tunnel_verify,
.iftype = ARPHRD_ETHER,
.generate_mac = true,
};
@ -877,7 +879,7 @@ const NetDevVTable ip6gre_vtable = {
.fill_message_create = netdev_ip6gre_fill_message_create,
.create_type = NETDEV_CREATE_STACKED,
.config_verify = netdev_tunnel_verify,
.generate_mac = true,
.iftype = ARPHRD_IP6GRE,
};
const NetDevVTable ip6gretap_vtable = {
@ -887,6 +889,7 @@ const NetDevVTable ip6gretap_vtable = {
.fill_message_create = netdev_ip6gre_fill_message_create,
.create_type = NETDEV_CREATE_STACKED,
.config_verify = netdev_tunnel_verify,
.iftype = ARPHRD_ETHER,
.generate_mac = true,
};
@ -897,7 +900,7 @@ const NetDevVTable ip6tnl_vtable = {
.fill_message_create = netdev_ip6tnl_fill_message_create,
.create_type = NETDEV_CREATE_STACKED,
.config_verify = netdev_tunnel_verify,
.generate_mac = true,
.iftype = ARPHRD_TUNNEL6,
};
const NetDevVTable erspan_vtable = {
@ -907,5 +910,6 @@ const NetDevVTable erspan_vtable = {
.fill_message_create = netdev_gre_erspan_fill_message_create,
.create_type = NETDEV_CREATE_STACKED,
.config_verify = netdev_tunnel_verify,
.iftype = ARPHRD_ETHER,
.generate_mac = true,
};

View File

@ -152,6 +152,7 @@ const NetDevVTable tun_vtable = {
.done = tuntap_done,
.create = netdev_create_tuntap,
.create_type = NETDEV_CREATE_INDEPENDENT,
.iftype = ARPHRD_NONE,
};
const NetDevVTable tap_vtable = {
@ -161,4 +162,5 @@ const NetDevVTable tap_vtable = {
.done = tuntap_done,
.create = netdev_create_tuntap,
.create_type = NETDEV_CREATE_INDEPENDENT,
.iftype = ARPHRD_ETHER,
};

View File

@ -1,10 +1,12 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <linux/if_arp.h>
#include "vcan.h"
const NetDevVTable vcan_vtable = {
.object_size = sizeof(VCan),
.sections = NETDEV_COMMON_SECTIONS,
.create_type = NETDEV_CREATE_INDEPENDENT,
.generate_mac = true,
.iftype = ARPHRD_CAN,
};

View File

@ -2,6 +2,8 @@
#include <errno.h>
#include <net/if.h>
#include <netinet/in.h>
#include <linux/if_arp.h>
#include <linux/veth.h>
#include "veth.h"
@ -94,5 +96,6 @@ const NetDevVTable veth_vtable = {
.fill_message_create = netdev_veth_fill_message_create,
.create_type = NETDEV_CREATE_INDEPENDENT,
.config_verify = netdev_veth_verify,
.iftype = ARPHRD_ETHER,
.generate_mac = true,
};

View File

@ -2,6 +2,7 @@
#include <errno.h>
#include <net/if.h>
#include <linux/if_arp.h>
#include <linux/if_vlan.h>
#include "parse-util.h"
@ -229,4 +230,5 @@ const NetDevVTable vlan_vtable = {
.create_type = NETDEV_CREATE_STACKED,
.config_verify = netdev_vlan_verify,
.done = vlan_done,
.iftype = ARPHRD_ETHER,
};

View File

@ -1,6 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <net/if.h>
#include <netinet/in.h>
#include <linux/if_arp.h>
#include "vrf.h"
@ -28,5 +30,6 @@ const NetDevVTable vrf_vtable = {
.sections = NETDEV_COMMON_SECTIONS "VRF\0",
.fill_message_create = netdev_vrf_fill_message_create,
.create_type = NETDEV_CREATE_MASTER,
.iftype = ARPHRD_ETHER,
.generate_mac = true,
};

View File

@ -1,6 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <linux/can/vxcan.h>
#include <linux/if_arp.h>
#include "vxcan.h"
@ -70,5 +71,5 @@ const NetDevVTable vxcan_vtable = {
.fill_message_create = netdev_vxcan_fill_message_create,
.create_type = NETDEV_CREATE_INDEPENDENT,
.config_verify = netdev_vxcan_verify,
.generate_mac = true,
.iftype = ARPHRD_CAN,
};

View File

@ -1,6 +1,8 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <net/if.h>
#include <netinet/in.h>
#include <linux/if_arp.h>
#include "conf-parser.h"
#include "alloc-util.h"
@ -394,5 +396,6 @@ const NetDevVTable vxlan_vtable = {
.fill_message_create = netdev_vxlan_fill_message_create,
.create_type = NETDEV_CREATE_STACKED,
.config_verify = netdev_vxlan_verify,
.iftype = ARPHRD_ETHER,
.generate_mac = true,
};

View File

@ -5,6 +5,8 @@
#include <sys/ioctl.h>
#include <net/if.h>
#include <netinet/in.h>
#include <linux/if_arp.h>
#include "sd-resolve.h"
@ -937,5 +939,5 @@ const NetDevVTable wireguard_vtable = {
.done = wireguard_done,
.create_type = NETDEV_CREATE_INDEPENDENT,
.config_verify = wireguard_verify,
.generate_mac = true,
.iftype = ARPHRD_NONE,
};

View File

@ -1,5 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include <linux/if_arp.h>
#include "missing_network.h"
#include "xfrm.h"
@ -29,5 +31,6 @@ const NetDevVTable xfrm_vtable = {
.object_size = sizeof(Xfrm),
.sections = NETDEV_COMMON_SECTIONS "Xfrm\0",
.fill_message_create = xfrm_fill_message_create,
.create_type = NETDEV_CREATE_STACKED
.create_type = NETDEV_CREATE_STACKED,
.iftype = ARPHRD_NONE,
};