summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/network/networkd-netdev-gperf.gperf2
-rw-r--r--src/network/networkd-netdev.c14
-rw-r--r--src/network/networkd-tunnel.c40
-rw-r--r--src/network/networkd-veth.c22
-rw-r--r--src/network/networkd.h2
5 files changed, 78 insertions, 2 deletions
diff --git a/src/network/networkd-netdev-gperf.gperf b/src/network/networkd-netdev-gperf.gperf
index dff0ae6a16..82cc8583dc 100644
--- a/src/network/networkd-netdev-gperf.gperf
+++ b/src/network/networkd-netdev-gperf.gperf
@@ -23,6 +23,7 @@ NetDev.Description, config_parse_string, 0,
NetDev.Name, config_parse_ifname, 0, offsetof(NetDev, ifname)
NetDev.Kind, config_parse_netdev_kind, 0, offsetof(NetDev, kind)
NetDev.MTUBytes, config_parse_iec_size, 0, offsetof(NetDev, mtu)
+NetDev.MACAddress, config_parse_hwaddr, 0, offsetof(NetDev, mac)
VLAN.Id, config_parse_uint64, 0, offsetof(NetDev, vlanid)
MACVLAN.Mode, config_parse_macvlan_mode, 0, offsetof(NetDev, macvlan_mode)
Tunnel.Local, config_parse_tunnel_address, 0, offsetof(NetDev, tunnel_local)
@@ -31,3 +32,4 @@ Tunnel.TOS, config_parse_unsigned, 0,
Tunnel.TTL, config_parse_unsigned, 0, offsetof(NetDev, tunnel_ttl)
Tunnel.DiscoverPathMTU, config_parse_bool, 0, offsetof(NetDev, tunnel_pmtudisc)
Peer.Name, config_parse_ifname, 0, offsetof(NetDev, ifname_peer)
+Peer.MACAddress, config_parse_hwaddr, 0, offsetof(NetDev, mac_peer)
diff --git a/src/network/networkd-netdev.c b/src/network/networkd-netdev.c
index 1519419c1f..0d08e564e5 100644
--- a/src/network/networkd-netdev.c
+++ b/src/network/networkd-netdev.c
@@ -92,6 +92,8 @@ static void netdev_free(NetDev *netdev) {
free(netdev->description);
free(netdev->ifname);
+ free(netdev->mac);
+ free(netdev->mac_peer);
condition_free_list(netdev->match_host);
condition_free_list(netdev->match_virt);
@@ -301,7 +303,7 @@ static int netdev_create(NetDev *netdev, Link *link, sd_rtnl_message_handler_t c
return r;
}
- if(netdev->mtu) {
+ if (netdev->mtu) {
r = sd_rtnl_message_append_u32(req, IFLA_MTU, netdev->mtu);
if (r < 0) {
log_error_netdev(netdev,
@@ -311,6 +313,16 @@ static int netdev_create(NetDev *netdev, Link *link, sd_rtnl_message_handler_t c
}
}
+ if (netdev->mac) {
+ r = sd_rtnl_message_append_ether_addr(req, IFLA_ADDRESS, netdev->mac);
+ if (r < 0) {
+ log_error_netdev(netdev,
+ "Colud not append IFLA_ADDRESS attribute: %s",
+ strerror(-r));
+ return r;
+ }
+ }
+
r = sd_rtnl_message_open_container(req, IFLA_LINKINFO);
if (r < 0) {
log_error_netdev(netdev,
diff --git a/src/network/networkd-tunnel.c b/src/network/networkd-tunnel.c
index 60b16ba849..885347ab25 100644
--- a/src/network/networkd-tunnel.c
+++ b/src/network/networkd-tunnel.c
@@ -60,6 +60,16 @@ static int netdev_fill_ipip_rtnl_message(Link *link, sd_rtnl_message *m) {
}
}
+ if (netdev->mac) {
+ r = sd_rtnl_message_append_ether_addr(m, IFLA_ADDRESS, netdev->mac);
+ if (r < 0) {
+ log_error_netdev(netdev,
+ "Colud not append IFLA_ADDRESS attribute: %s",
+ strerror(-r));
+ return r;
+ }
+ }
+
r = sd_rtnl_message_open_container(m, IFLA_LINKINFO);
if (r < 0) {
log_error_netdev(netdev,
@@ -157,6 +167,16 @@ static int netdev_fill_sit_rtnl_message(Link *link, sd_rtnl_message *m) {
}
}
+ if (netdev->mac) {
+ r = sd_rtnl_message_append_ether_addr(m, IFLA_ADDRESS, netdev->mac);
+ if (r < 0) {
+ log_error_netdev(netdev,
+ "Colud not append IFLA_ADDRESS attribute: %s",
+ strerror(-r));
+ return r;
+ }
+ }
+
r = sd_rtnl_message_open_container(m, IFLA_LINKINFO);
if (r < 0) {
log_error_netdev(netdev,
@@ -262,6 +282,16 @@ static int netdev_fill_ipgre_rtnl_message(Link *link, sd_rtnl_message *m) {
}
}
+ if (netdev->mac) {
+ r = sd_rtnl_message_append_ether_addr(m, IFLA_ADDRESS, netdev->mac);
+ if (r < 0) {
+ log_error_netdev(netdev,
+ "Colud not append IFLA_ADDRESS attribute: %s",
+ strerror(-r));
+ return r;
+ }
+ }
+
r = sd_rtnl_message_open_container(m, IFLA_LINKINFO);
if (r < 0) {
log_error_netdev(netdev,
@@ -367,6 +397,16 @@ static int netdev_fill_vti_rtnl_message(Link *link, sd_rtnl_message *m) {
}
}
+ if (netdev->mac) {
+ r = sd_rtnl_message_append_ether_addr(m, IFLA_ADDRESS, netdev->mac);
+ if (r < 0) {
+ log_error_netdev(netdev,
+ "Colud not append IFLA_ADDRESS attribute: %s",
+ strerror(-r));
+ return r;
+ }
+ }
+
r = sd_rtnl_message_open_container(m, IFLA_LINKINFO);
if (r < 0) {
log_error_netdev(netdev,
diff --git a/src/network/networkd-veth.c b/src/network/networkd-veth.c
index 1a5d880ac2..3584981cbc 100644
--- a/src/network/networkd-veth.c
+++ b/src/network/networkd-veth.c
@@ -42,6 +42,16 @@ static int netdev_fill_veth_rtnl_message(NetDev *netdev, sd_rtnl_message *m) {
return r;
}
+ if (netdev->mac) {
+ r = sd_rtnl_message_append_ether_addr(m, IFLA_ADDRESS, netdev->mac);
+ if (r < 0) {
+ log_error_netdev(netdev,
+ "Colud not append IFLA_ADDRESS attribute: %s",
+ strerror(-r));
+ return r;
+ }
+ }
+
r = sd_rtnl_message_open_container(m, IFLA_LINKINFO);
if (r < 0) {
log_error_netdev(netdev,
@@ -67,7 +77,7 @@ static int netdev_fill_veth_rtnl_message(NetDev *netdev, sd_rtnl_message *m) {
return r;
}
- if(netdev->ifname_peer) {
+ if (netdev->ifname_peer) {
r = sd_rtnl_message_append_string(m, IFLA_IFNAME, netdev->ifname_peer);
if (r < 0) {
log_error("Failed to add netlink interface name: %s", strerror(-r));
@@ -75,6 +85,16 @@ static int netdev_fill_veth_rtnl_message(NetDev *netdev, sd_rtnl_message *m) {
}
}
+ if (netdev->mac_peer) {
+ r = sd_rtnl_message_append_ether_addr(m, IFLA_ADDRESS, netdev->mac_peer);
+ if (r < 0) {
+ log_error_netdev(netdev,
+ "Colud not append IFLA_ADDRESS attribute: %s",
+ strerror(-r));
+ return r;
+ }
+ }
+
r = sd_rtnl_message_close_container(m);
if (r < 0) {
log_error_netdev(netdev,
diff --git a/src/network/networkd.h b/src/network/networkd.h
index 102744d4b7..f079473758 100644
--- a/src/network/networkd.h
+++ b/src/network/networkd.h
@@ -103,6 +103,8 @@ struct NetDev {
char *ifname;
char *ifname_peer;
size_t mtu;
+ struct ether_addr *mac;
+ struct ether_addr *mac_peer;
NetDevKind kind;
uint64_t vlanid;