From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>,
Christian Ebner <c.ebner@proxmox.com>
Subject: Re: [pve-devel] [PATCH manager 1/3] fix #5255: node: wol: add optional bind interface
Date: Thu, 21 Mar 2024 18:27:34 +0100 [thread overview]
Message-ID: <be55ec4c-c9de-491b-83a2-534b0827dad6@proxmox.com> (raw)
In-Reply-To: <20240305125431.273796-2-c.ebner@proxmox.com>
On 05/03/2024 13:54, Christian Ebner wrote:
> Allows to optionally configure a local interface name to which to
> bind to when sending a wake on lan packet to wake a remote node.
>
> Default behaviour remains to send the packet via the interface for
> the default gateway.
>
> Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
> ---
> PVE/API2/Nodes.pm | 13 ++++++++++++-
> PVE/NodeConfig.pm | 6 ++++++
> 2 files changed, 18 insertions(+), 1 deletion(-)
>
> diff --git a/PVE/API2/Nodes.pm b/PVE/API2/Nodes.pm
> index cc5ee65e..620dac1c 100644
> --- a/PVE/API2/Nodes.pm
> +++ b/PVE/API2/Nodes.pm
> @@ -682,9 +682,10 @@ __PACKAGE__->register_method({
> my ($param) = @_;
>
> my $node = $param->{node};
> + my $local_node = PVE::INotify::nodename();
>
> die "'$node' is local node, cannot wake my self!\n"
> - if $node eq 'localhost' || $node eq PVE::INotify::nodename();
> + if $node eq 'localhost' || $node eq $local_node;
>
> PVE::Cluster::check_node_exists($node);
>
> @@ -694,6 +695,9 @@ __PACKAGE__->register_method({
> die "No wake on LAN MAC address defined for '$node'!\n";
> }
>
> + my $local_config = PVE::NodeConfig::load_config($local_node);
> + my $bind_iface = $local_config->{'wakeonlan-bind-interface'};
> +
> $mac_addr =~ s/://g;
> my $packet = chr(0xff) x 6 . pack('H*', $mac_addr) x 16;
>
> @@ -706,6 +710,13 @@ __PACKAGE__->register_method({
> setsockopt($sock, Socket::SOL_SOCKET, Socket::SO_BROADCAST, 1)
> || die "Unable to set socket option: $!\n";
>
> + if (defined($bind_iface)) {
> + # Null terminated interface name
> + my $bind_iface_raw = pack('Z*', $bind_iface);
> + setsockopt($sock, Socket::SOL_SOCKET, Socket::SO_BINDTODEVICE, $bind_iface_raw)
> + || die "Unable to bind socket to interface '$bind_iface': $!\n";
> + }
> +
> send($sock, $packet, 0, $to)
> || die "Unable to send packet: $!\n";
>
> diff --git a/PVE/NodeConfig.pm b/PVE/NodeConfig.pm
> index 941e6009..5450ab2f 100644
> --- a/PVE/NodeConfig.pm
> +++ b/PVE/NodeConfig.pm
> @@ -91,6 +91,12 @@ my $confdesc = {
> format => 'mac-addr',
> optional => 1,
> },
> + 'wakeonlan-bind-interface' => {
> + type => 'string',
> + description => 'Bind to this interface when sending wake on LAN packet',
> + format => 'pve-iface',
> + optional => 1,
> + },
we could transform the existing "wakeonlan" property into a format string,
keep the new mac property as default_key there for backwards compat, kinda
like "acme" is a format string in the same config.
For such a config option that would be IMO fitting and avoid bloating the
"top-level" format.
> 'startall-onboot-delay' => {
> description => 'Initial delay in seconds, before starting all the Virtual Guests with on-boot enabled.',
> type => 'integer',
next prev parent reply other threads:[~2024-03-21 17:28 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 [this message]
2024-03-22 14:37 ` Christian Ebner
2024-03-26 9:21 ` Christian Ebner
2024-03-05 12:54 ` [pve-devel] [PATCH manager 2/3] fix #5255: node: wol: configurable broadcast address Christian Ebner
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=be55ec4c-c9de-491b-83a2-534b0827dad6@proxmox.com \
--to=t.lamprecht@proxmox.com \
--cc=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal