From ceae9f9a384b1485449a151503e9aa4f1c2ec33d Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 30 Oct 2024 01:36:10 +0900 Subject: [PATCH] network/ipvlan: do not try to update MAC address --- src/network/netdev/ipvlan.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/network/netdev/ipvlan.c b/src/network/netdev/ipvlan.c index 892678b4add..5cfae1eb643 100644 --- a/src/network/netdev/ipvlan.c +++ b/src/network/netdev/ipvlan.c @@ -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, }; -- 2.47.3