network/ipvlan: do not try to update MAC address

This commit is contained in:
Yu Watanabe
2024-10-30 01:36:10 +09:00
parent 6804bbdaf1
commit ceae9f9a38

View File

@@ -37,6 +37,13 @@ static int netdev_ipvlan_fill_message_create(NetDev *netdev, Link *link, sd_netl
return 0;
}
static bool ipvlan_can_set_mac(NetDev *netdev, const struct hw_addr_data *hw_addr) {
assert(netdev);
/* MAC address cannot be updated. Even unchanged, IFLA_ADDRESS attribute cannot be set in the message. */
return netdev->ifindex <= 0;
}
static void ipvlan_init(NetDev *netdev) {
IPVlan *m = ASSERT_PTR(netdev)->kind == NETDEV_KIND_IPVLAN ? IPVLAN(netdev) : IPVTAP(netdev);
@@ -50,6 +57,7 @@ const NetDevVTable ipvlan_vtable = {
.sections = NETDEV_COMMON_SECTIONS "IPVLAN\0",
.fill_message_create = netdev_ipvlan_fill_message_create,
.create_type = NETDEV_CREATE_STACKED,
.can_set_mac = ipvlan_can_set_mac,
.iftype = ARPHRD_ETHER,
.generate_mac = true,
};
@@ -60,6 +68,7 @@ const NetDevVTable ipvtap_vtable = {
.sections = NETDEV_COMMON_SECTIONS "IPVTAP\0",
.fill_message_create = netdev_ipvlan_fill_message_create,
.create_type = NETDEV_CREATE_STACKED,
.can_set_mac = ipvlan_can_set_mac,
.iftype = ARPHRD_ETHER,
.generate_mac = true,
};