From: Alexandre Derumier <aderumier@odiso.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH pve-network 1/7] dhcp: add vrf support
Date: Tue, 19 Dec 2023 09:32:10 +0100 [thread overview]
Message-ID: <20231219083216.2551645-2-aderumier@odiso.com> (raw)
In-Reply-To: <20231219083216.2551645-1-aderumier@odiso.com>
launch dnsmasq in a vrf context with "ip vrf exec <vrfname> dnsmasq.."
use "default" vrf if plugin don't return a specific vrf
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
---
src/PVE/Network/SDN/Dhcp.pm | 3 ++-
src/PVE/Network/SDN/Dhcp/Dnsmasq.pm | 3 ++-
src/PVE/Network/SDN/Zones.pm | 10 ++++++++++
src/PVE/Network/SDN/Zones/EvpnPlugin.pm | 8 ++++++++
src/PVE/Network/SDN/Zones/Plugin.pm | 7 +++++++
5 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/src/PVE/Network/SDN/Dhcp.pm b/src/PVE/Network/SDN/Dhcp.pm
index 7876c08..ce72c4d 100644
--- a/src/PVE/Network/SDN/Dhcp.pm
+++ b/src/PVE/Network/SDN/Dhcp.pm
@@ -79,12 +79,13 @@ sub regenerate_config {
my $zone = $zone_cfg->{ids}->{$zoneid};
next if !$zone->{dhcp};
+ my $options = PVE::Network::SDN::Zones::get_options($zoneid);
my $dhcp_plugin_name = $zone->{dhcp};
my $dhcp_plugin = PVE::Network::SDN::Dhcp::Plugin->lookup($dhcp_plugin_name);
die "Could not find DHCP plugin: $dhcp_plugin_name" if !$dhcp_plugin;
- eval { $dhcp_plugin->before_configure($zoneid) };
+ eval { $dhcp_plugin->before_configure($zoneid, $options) };
die "Could not run before_configure for DHCP server $zoneid $@\n" if $@;
for my $vnetid (sort keys %{$vnet_cfg->{ids}}) {
diff --git a/src/PVE/Network/SDN/Dhcp/Dnsmasq.pm b/src/PVE/Network/SDN/Dhcp/Dnsmasq.pm
index 2844943..169ce56 100644
--- a/src/PVE/Network/SDN/Dhcp/Dnsmasq.pm
+++ b/src/PVE/Network/SDN/Dhcp/Dnsmasq.pm
@@ -164,7 +164,7 @@ sub configure_vnet {
}
sub before_configure {
- my ($class, $dhcpid) = @_;
+ my ($class, $dhcpid, $options) = @_;
my $dbus_config = <<DBUSCFG;
<!DOCTYPE busconfig PUBLIC
@@ -198,6 +198,7 @@ DBUSCFG
my $default_config = <<CFG;
CONFIG_DIR='$config_directory,\*.conf'
DNSMASQ_OPTS="--conf-file=/dev/null --enable-dbus=uk.org.thekelleys.dnsmasq.$dhcpid"
+VRF='$options->{vrf}'
CFG
PVE::Tools::file_set_contents(
diff --git a/src/PVE/Network/SDN/Zones.pm b/src/PVE/Network/SDN/Zones.pm
index 5bd3536..fd4e73d 100644
--- a/src/PVE/Network/SDN/Zones.pm
+++ b/src/PVE/Network/SDN/Zones.pm
@@ -104,6 +104,16 @@ sub get_vnets {
return $vnets;
}
+sub get_options {
+ my ($zoneid) = @_;
+
+ my $zone_cfg = PVE::Network::SDN::Zones::config();
+ my $plugin_config = $zone_cfg->{ids}->{$zoneid};
+
+ my $plugin = PVE::Network::SDN::Zones::Plugin->lookup($plugin_config->{type});
+ return $plugin->get_options($plugin_config, $zoneid);
+}
+
sub generate_etc_network_config {
my $cfg = PVE::Network::SDN::running_config();
diff --git a/src/PVE/Network/SDN/Zones/EvpnPlugin.pm b/src/PVE/Network/SDN/Zones/EvpnPlugin.pm
index 655a9f0..c806564 100644
--- a/src/PVE/Network/SDN/Zones/EvpnPlugin.pm
+++ b/src/PVE/Network/SDN/Zones/EvpnPlugin.pm
@@ -272,6 +272,14 @@ sub generate_sdn_config {
return $config;
}
+sub get_options {
+ my ($class, $plugin_config, $zoneid) = @_;
+
+ my $options = { vrf => "vrf_$zoneid"};
+
+ return $options;
+}
+
sub on_update_hook {
my ($class, $zoneid, $zone_cfg, $controller_cfg) = @_;
diff --git a/src/PVE/Network/SDN/Zones/Plugin.pm b/src/PVE/Network/SDN/Zones/Plugin.pm
index b55b967..07e8389 100644
--- a/src/PVE/Network/SDN/Zones/Plugin.pm
+++ b/src/PVE/Network/SDN/Zones/Plugin.pm
@@ -129,6 +129,13 @@ sub controller_reload {
die "please implement inside plugin";
}
+sub get_options {
+ my ($class, $plugin_config, $zoneid) = @_;
+
+ my $options = { vrf => 'default'};
+ return $options;
+}
+
sub on_delete_hook {
my ($class, $zoneid, $vnet_cfg) = @_;
--
2.39.2
next prev parent reply other threads:[~2023-12-19 8:32 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-19 8:32 [pve-devel] [PATCH pve-network 0/7] add dhcp support for all zones Alexandre Derumier
2023-12-19 8:32 ` Alexandre Derumier [this message]
2023-12-19 8:32 ` [pve-devel] [PATCH pve-network 2/7] dhcp: enable-ra on layer3 zones only Alexandre Derumier
2023-12-19 8:32 ` [pve-devel] [PATCH pve-network 3/7] dnsmasq service: run service in vrf Alexandre Derumier
2023-12-19 8:32 ` [pve-devel] [PATCH pve-network 4/7] zones: evpn: add dhcp support Alexandre Derumier
2023-12-19 8:32 ` [pve-devel] [PATCH pve-network 5/7] zones: vlan: " Alexandre Derumier
2023-12-19 8:32 ` [pve-devel] [PATCH pve-network 6/7] zones: qinq: " Alexandre Derumier
2023-12-19 8:32 ` [pve-devel] [PATCH pve-network 7/7] zones: vxlan: " Alexandre Derumier
2023-12-22 14:01 ` [pve-devel] [PATCH pve-network 0/7] add dhcp support for all zones Stefan Hanreich
2023-12-22 21:27 ` DERUMIER, Alexandre
2024-02-22 10:13 ` Stefan Hanreich
[not found] ` <6c7a0c383c6aee77689433815775e27f5259da91.camel@groupe-cyllene.com>
2024-02-22 10:52 ` Stefan Hanreich
2024-11-13 9:48 ` Stefan Hanreich
2024-11-13 19:09 ` Stefan Hanreich
2024-11-14 10:29 ` Aaron Lauterer
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=20231219083216.2551645-2-aderumier@odiso.com \
--to=aderumier@odiso.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.