public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Christian Ebner <c.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH manager 2/3] fix #5255: node: wol: configurable broadcast address
Date: Tue,  5 Mar 2024 13:54:30 +0100	[thread overview]
Message-ID: <20240305125431.273796-3-c.ebner@proxmox.com> (raw)
In-Reply-To: <20240305125431.273796-1-c.ebner@proxmox.com>

Allows to configure a custom broadcast address to use when sending a
wake on lan packet to wake a remote node.

Default behaviour remains to fallback to 255.255.255.255.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
---
 PVE/API2/Nodes.pm | 3 ++-
 PVE/NodeConfig.pm | 6 ++++++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/PVE/API2/Nodes.pm b/PVE/API2/Nodes.pm
index 620dac1c..e73fc28f 100644
--- a/PVE/API2/Nodes.pm
+++ b/PVE/API2/Nodes.pm
@@ -697,11 +697,12 @@ __PACKAGE__->register_method({
 
 	my $local_config = PVE::NodeConfig::load_config($local_node);
 	my $bind_iface = $local_config->{'wakeonlan-bind-interface'};
+	my $broadcast_addr = $local_config->{'wakeonlan-broadcast-address'} // '255.255.255.255';
 
 	$mac_addr =~ s/://g;
 	my $packet = chr(0xff) x 6 . pack('H*', $mac_addr) x 16;
 
-	my $addr = gethostbyname('255.255.255.255');
+	my $addr = gethostbyname($broadcast_addr);
 	my $port = getservbyname('discard', 'udp');
 	my $to = Socket::pack_sockaddr_in($port, $addr);
 
diff --git a/PVE/NodeConfig.pm b/PVE/NodeConfig.pm
index 5450ab2f..e3feaaa6 100644
--- a/PVE/NodeConfig.pm
+++ b/PVE/NodeConfig.pm
@@ -97,6 +97,12 @@ my $confdesc = {
 	format => 'pve-iface',
 	optional => 1,
     },
+    'wakeonlan-broadcast-address' => {
+	type => 'string',
+	description => 'IPv4 broadcast address to use when sending wake on LAN packet',
+	format => 'ipv4',
+	optional => 1,
+    },
     'startall-onboot-delay' => {
 	description => 'Initial delay in seconds, before starting all the Virtual Guests with on-boot enabled.',
 	type => 'integer',
-- 
2.39.2





  parent reply	other threads:[~2024-03-05 12:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-05 12:54 [pve-devel] [PATCH manager docs 0/3] add optional WoL config options Christian Ebner
2024-03-05 12:54 ` [pve-devel] [PATCH manager 1/3] fix #5255: node: wol: add optional bind interface Christian Ebner
2024-03-21 17:27   ` Thomas Lamprecht
2024-03-22 14:37     ` Christian Ebner
2024-03-26  9:21       ` Christian Ebner
2024-03-05 12:54 ` Christian Ebner [this message]
2024-03-05 12:54 ` [pve-devel] [PATCH docs 3/3] pvenode/wake-on-lan: mention optional config options Christian Ebner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240305125431.273796-3-c.ebner@proxmox.com \
    --to=c.ebner@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal