mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-19 13:31:28 +02:00
Merge pull request #687 from crawford/networkd
feat(sys-apps/systemd): netdev - allow setting MACAddress in .netdev files
This commit is contained in:
commit
feee3974a2
@ -0,0 +1,74 @@
|
|||||||
|
From e846210989367233171151ae3528d65b63a9e5a8 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Tom Gundersen <teg@jklm.no>
|
||||||
|
Date: Sat, 14 Jun 2014 15:38:35 +0200
|
||||||
|
Subject: [PATCH] networkd: netdev - allow setting MACAddress in .netdev files
|
||||||
|
|
||||||
|
It may sometimes be necessary to specify the MAC address of a netdev.
|
||||||
|
Let us set the correct one from the get-go, rather than having the
|
||||||
|
kernel generate a random one, and then change it after.
|
||||||
|
|
||||||
|
Conflicts:
|
||||||
|
src/network/networkd-netdev-gperf.gperf
|
||||||
|
src/network/networkd-netdev.c
|
||||||
|
src/network/networkd-tunnel.c
|
||||||
|
src/network/networkd-veth.c
|
||||||
|
src/network/networkd.h
|
||||||
|
---
|
||||||
|
src/network/networkd-netdev-gperf.gperf | 1 +
|
||||||
|
src/network/networkd-netdev.c | 11 +++++++++++
|
||||||
|
src/network/networkd.h | 1 +
|
||||||
|
3 files changed, 13 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/src/network/networkd-netdev-gperf.gperf b/src/network/networkd-netdev-gperf.gperf
|
||||||
|
index ea7ba57..30b9333 100644
|
||||||
|
--- a/src/network/networkd-netdev-gperf.gperf
|
||||||
|
+++ b/src/network/networkd-netdev-gperf.gperf
|
||||||
|
@@ -24,3 +24,4 @@ NetDev.Name, config_parse_ifname, 0,
|
||||||
|
NetDev.Kind, config_parse_netdev_kind, 0, offsetof(NetDev, kind)
|
||||||
|
VLAN.Id, config_parse_uint64, 0, offsetof(NetDev, vlanid)
|
||||||
|
MACVLAN.Mode, config_parse_macvlan_mode, 0, offsetof(NetDev, macvlan_mode)
|
||||||
|
+NetDev.MACAddress, config_parse_hwaddr, 0, offsetof(NetDev, mac)
|
||||||
|
diff --git a/src/network/networkd-netdev.c b/src/network/networkd-netdev.c
|
||||||
|
index e333c47..07a0878 100644
|
||||||
|
--- a/src/network/networkd-netdev.c
|
||||||
|
+++ b/src/network/networkd-netdev.c
|
||||||
|
@@ -66,6 +66,7 @@ void netdev_free(NetDev *netdev) {
|
||||||
|
|
||||||
|
free(netdev->description);
|
||||||
|
free(netdev->name);
|
||||||
|
+ free(netdev->mac);
|
||||||
|
|
||||||
|
condition_free_list(netdev->match_host);
|
||||||
|
condition_free_list(netdev->match_virt);
|
||||||
|
@@ -277,6 +278,16 @@ static int netdev_create(NetDev *netdev, Link *link, sd_rtnl_message_handler_t c
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ 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.h b/src/network/networkd.h
|
||||||
|
index 8144031..877ac83 100644
|
||||||
|
--- a/src/network/networkd.h
|
||||||
|
+++ b/src/network/networkd.h
|
||||||
|
@@ -90,6 +90,7 @@ struct NetDev {
|
||||||
|
|
||||||
|
char *description;
|
||||||
|
char *name;
|
||||||
|
+ struct ether_addr *mac;
|
||||||
|
NetDevKind kind;
|
||||||
|
|
||||||
|
uint64_t vlanid;
|
||||||
|
--
|
||||||
|
1.9.3
|
||||||
|
|
@ -124,6 +124,9 @@ fi
|
|||||||
# stop scaring all our users with warnings about "X-Fleet"
|
# stop scaring all our users with warnings about "X-Fleet"
|
||||||
epatch "${FILESDIR}"/212-0005-conf-parser-silently-ignore-sections-starting-with-X.patch
|
epatch "${FILESDIR}"/212-0005-conf-parser-silently-ignore-sections-starting-with-X.patch
|
||||||
|
|
||||||
|
# networkd: netdev - allow setting MACAddress in .netdev files
|
||||||
|
epatch "${FILESDIR}"/212-0006-networkd-netdev-allow-setting-macaddress-in-netdev-files.patch
|
||||||
|
|
||||||
# patch to make journald work at first boot
|
# patch to make journald work at first boot
|
||||||
epatch "${FILESDIR}"/211-tmpfiles.patch
|
epatch "${FILESDIR}"/211-tmpfiles.patch
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user