5
0
mirror of git://git.proxmox.com/git/pve-network.git synced 2025-01-09 01:18:06 +03:00
Commit Graph

401 Commits

Author SHA1 Message Date
Wolfgang Bumiller
d4c9897507 api: take partial configs for PUT /cluster/sdn/vnets/<id>
Handle 'delete' parameter and partial updates.
See previous commit for explanation.

Cc: Alexandre Derumier <aderumier@odiso.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-11-22 12:28:25 +01:00
Wolfgang Bumiller
3e3cafabaf api: take partial configs for PUT /cluster/sdn/zones/<id>
Zones previously expected a complete config, but the API schema
also contains a 'delete' parameter via the SectionConfig's
updateSchema() helper. This was not handled, and instead failed to
validate as part of the config.

The same is true for vnets and subnets, while ipams, dns and
controller entries followed our usual update procedures (but also
ignored the 'delete' parameter).

Since all of our SectionConfig based API endpoints are supposed to
take changes, rather than complete configs, this changes these
endpoints to not replace the full configuration anymore.

This is a major break for automation tools (the web UI already passed
the full config each time).

Cc: Alexandre Derumier <aderumier@odiso.com>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-11-22 12:21:38 +01:00
Wolfgang Bumiller
9b448b0154 Revert "sdn: require ipam in simple plugin for dhcp"
This reverts commit 53ab149562.

This also affects the updateSchema which is not intentional, since the
update API calls are supposed to take changes, not full replacements.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-11-22 11:32:47 +01:00
Wolfgang Bumiller
f8407bd27e dnsmasq: fix config directory permission
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-11-22 09:51:00 +01:00
Thomas Lamprecht
f58c7169fd bump version to 0.8.5
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-11-21 20:34:48 +01:00
Stefan Hanreich
42ff574f3c subnet: fix dhcp-dns-server format
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
2023-11-21 20:34:15 +01:00
Stefan Lendl
596d9c238a sdn: register MAC in IPAM if not found
if inside add_dhcp_mapping, which is called at VM or LCX start, we do
not find an IP in IPAM, register the MAC.

This is very useful as a fallback if for some reason an IP mapping was
deleted or there is a bug somewhere that does not register an IP.

This acts more like DHCP to allocate an IP on demand.

In order to properly register the IP, the VMID and hostname is required
as a parameter.

Signed-off-by: Stefan Lendl <s.lendl@proxmox.com>
2023-11-21 20:34:10 +01:00
Wolfgang Bumiller
3bef780a5a bump version to 0.8.4
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-11-21 14:49:46 +01:00
Stefan Hanreich
04e1c8ed73 dhcp: fix allocating IP for every defined dhcp-range
Due to the wrong check an IP was allocated for every DHCP range,
instead of only allocating an IP in the first free DHCP range.

Suggested-By: Stefan Lendl <s.lendl@proxmox.com>
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
2023-11-21 14:48:36 +01:00
Wolfgang Bumiller
5ab15238af bump version to 0.8.3
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2023-11-21 14:41:53 +01:00
Stefan Hanreich
543e2b75cd sdn: simple: Improve dhcp property description and validation
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
2023-11-21 14:35:06 +01:00
Stefan Hanreich
53ab149562 sdn: require ipam in simple plugin for dhcp
Suggested-By: Wolfgang Bumiller <w.bumiller@proxmox.com>
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
2023-11-21 14:35:04 +01:00
Thomas Lamprecht
365a4072e4 d/control: downgrade frr-pythontools from recommends to suggests
avoid pulling FRR in on upgrade if we'd hard-depend on
libpve-network-perl for all those systems that kept the default
install-recommends enabled as FRR is a bit involved and might announce
stuff and break some network environments if not correctly configured.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-11-21 08:26:59 +01:00
Thomas Lamprecht
46348e8ba6 d/control: drop explicit perl dependency
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-11-21 08:26:36 +01:00
Thomas Lamprecht
8baff6bc3a d/control: update versioned dependency for pve-cluster
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-11-20 17:41:33 +01:00
Stefan Hanreich
359416aa52 api: refactor URL structure for Ipam
The initial URL structure was less than optimal due to Ipam as well as
Ipams being endpoints in the API, which are too similar and might be
confusing to users.

Move the listing of PVE IPAM to /ipams/pve/status
Move the create / update / delete endpoints to /vnets/{vnetid}/ips

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
2023-11-20 17:40:36 +01:00
Alexandre Derumier
39062bc53a dhcp : dnsmasq: generate dbus policy
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2023-11-18 16:00:10 +01:00
Alexandre Derumier
a26a43bf97 dnsmasq: fix ipv6 support
ether file should have 1 line by mac address with ip4+ip6

ip6 address should be in braced [ip6]

for now: don't update ip6 through bus as it seem to be incorrect

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2023-11-18 16:00:10 +01:00
Alexandre Derumier
e6211baee9 dnsmasq: enable dbus && purge old ip lease on reservation
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2023-11-18 16:00:10 +01:00
Alexandre Derumier
3f764f82d1 dnsmasq: configure static range for each subnet
we don't want dynamic lease, simply define each subnet as a static range.

dhcp-range defined on a subnet is only used by ipam plugin.

This will also allow to use dhcp subnet without need to define a range.
Can be usefull for external ipam like phpipam, where you can't define ranges.

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2023-11-18 16:00:10 +01:00
Alexandre Derumier
77617306c3 dhcp : remove del_ip_mapping
The cleanup is done in add_ip_mapping

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2023-11-18 16:00:10 +01:00
Alexandre Derumier
bbc34c2062 api2: ipam : remove add|del_mapping in mac/ip management
only register/del ip in ipam here.

The dhcp mapping is done a vm start.

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2023-11-18 16:00:10 +01:00
Alexandre Derumier
e45924b41f fix subnet tests
- add vmid in in ipam.db
- remove ip value in ipam.db (is already the key)

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2023-11-18 16:00:10 +01:00
Alexandre Derumier
beef73d642 add add_dhcp_mapping
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2023-11-18 15:59:50 +01:00
Alexandre Derumier
c1606bba52 sdn: fix subnets && netbox ipam tests
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2023-11-18 15:59:50 +01:00
Alexandre Derumier
f836981f43 sdn: fix tests
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
2023-11-18 15:59:50 +01:00
Stefan Hanreich
7bd6b643d5 dhcp: regenerate config for DHCP plugins on applying configuration
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
2023-11-18 15:59:50 +01:00
Stefan Hanreich
4c89e704aa api: zone: add dhcp option
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
2023-11-18 15:59:50 +01:00
Stefan Hanreich
d0e3339cc9 api: subnet: add dhcp ranges
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
2023-11-18 15:59:50 +01:00
Stefan Hanreich
8c5b7b01b5 api: add endpoints for managing PVE IPAM
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
2023-11-18 15:59:50 +01:00
Stefan Hanreich
78add5e50a sdn: dhcp: add helper for creating DHCP leases
This helper can be used to create DHCP entries for a specific zone. It
is used by the API to create DHCP leases for VMs/CTs.

Co-Authored-By: Alexandre Derumier <aderumier@odiso.com>
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
2023-11-18 15:59:50 +01:00
Stefan Hanreich
33074dfbee sdn: dhcp: add dnsmasq plugin
The plugin creates a dnsmasq@<zone> service that spawns a dnsmasq
instance that handles dhcp for that zone.

The configuration files for a dnsmasq instance lie within
/etc/dnsmasq.d/<zone>

The plugin generates the following configuration files:
* 00-default.conf
  Contains the default global configuration for dnsmasq. Disables DNS,
  enables some specific options for Windows, does some
  security-related configuration and makes dnsmasq bind only to the
  interfaces it is responsible for
* 10-<subnet>.conf
  Contains the default settings for a subnet. Sets dhcp options for
  DNS and gateway.
* 10-<subnet>.ranges.conf
  Contains the configuration of DHCP ranges for a subnet.
* ethers
  Contains the MAC address to IP mappings for a zone.

Every subnet gets assigned a tag in the dnsmasq configuration that is
equal to the subnet_id. This can be used to override / set additional
configuration options on a per-subnet basis.

Additionally it creates the file /etc/default/dnsmasq.<zone> that
provides default options for the dnsmasq service.

Leases are stored in /var/lib/misc/dnsmasq.<zone>.

Co-Authored-By: Alexandre Derumier <aderumier@odiso.com>
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
2023-11-18 15:59:50 +01:00
Stefan Hanreich
b240ff0b1f dhcp: add abstract class for DHCP plugins
This abstract class provides several hooks that should be called
during the config generation process, they expose the functionality
for the different configuration tasks required from the DHCP plugins.

add_ip_mapping
Adds a mapping from MAC address to an IP for a given DHCP server. The
DHCP server will then always assign the given IP address to the MAC.

del_ip_mapping
Deletes all mappings for a given MAC address for a given DHCP server.

before_regenerate
Should be called before the plugin does any configuration tasks. The
main usage for this hook is tearing down old instances.

after_regenerate
Should be called after the plugin has finished generating any
configuration. The main usage for this hook is to perform cleanup and
restart / reload services.

before_configure
Should be called before creating the configuration for a specific DHCP
instance, as defined in the dhcp.cfg. This can be used for performing
instance-specific setup.

after_configure
Should be called after the configuration for a specific DHCP instance,
as defined in the dhcp.cfg. This will mainly be used for enabling and
restarting / reloading a specific instance of a DHCP server.

configure_subnet
This function configures the settings for a specific subnet (that can
contain multiple DHCP ranges). This sets global settings for a
specific subnet such as DNS server or gateway.

configure_range
This configures a DHCP range that is available for a given Subnet.

Co-Authored-By: Alexandre Derumier <aderumier@odiso.com>
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
2023-11-18 15:59:50 +01:00
Stefan Hanreich
7ba1781725 subnet: vnet: refactor IPAM related methods
Those methods are used by the DHCP plugins to attain the next free
IP address for a given DHCP range, as well as delete all entries with
a certain MAC address.

Co-Authored-By: Alexandre Derumier <aderumier@odiso.com>
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
2023-11-18 15:59:50 +01:00
Stefan Hanreich
8a8bba7083 ipam: plugins: preparations for DHCP
Adds a new file priv/macs.db for caching the queries to IPAM.

Additionally adds and imeplements methods to the IPAM plugins that
are required for the DHCP functionality.

Co-Authored-By: Alexandre Derumier <aderumier@odiso.com>
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
2023-11-18 15:59:50 +01:00
Stefan Hanreich
1e5d8cacc6 sdn: zone: add dhcp option
Co-Authored-By: Alexandre Derumier <aderumier@odiso.com>
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
2023-11-18 15:59:50 +01:00
Stefan Hanreich
290fa5c9af subnet: add dhcp options
Additionally add a helper function for parsing the DHCP ranges of a
subnet.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
2023-11-18 15:59:50 +01:00
Stefan Hanreich
a1845dad80 sdn: preparations for DHCP plugin
Add the option to retrieve the running configuration instead of only
the pending configuration via the config methods. Refactor methods
using the running config to utilize the new parameter.

Add helper methods and return additional attributes from the getter
functions that are needed by the dhcp plugins.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
2023-11-18 15:59:50 +01:00
Thomas Lamprecht
e8ca5bc603 gitignore: sort content
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-11-17 15:53:03 +01:00
Stefan Lendl
67fd119587 gitignore: add build artefacts and .vscode to ignore list
Signed-off-by: Stefan Lendl <s.lendl@proxmox.com>
 [ TL: avoid one-word subject & make build-dir glob more specific ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-11-17 15:50:23 +01:00
Fabian Grünbichler
1f3d638995 bump version to 0.8.2
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2023-10-25 13:07:03 +02:00
Alexandre Derumier
9ce18f80bc controllers: add isis router plugin 2023-10-25 12:50:41 +02:00
Alexandre Derumier
ced9392063 controllers: frr: add parsing of "interfaces" section 2023-10-25 12:50:35 +02:00
Alexandre Derumier
e1ab3d7c28 controller: evpn: fix find_bgp_controller 2023-10-25 12:50:28 +02:00
Alexandre Derumier
e45154299d zones: evpn: add disable-bridge-learning
Allow to statically register mac address in evpn,

can be useful for silent hosts
2023-10-25 12:46:41 +02:00
Alexandre Derumier
9a03342a87 zones: add add|del_bridge_fdb to plugins
We want to be able to override it for some specific plugins.

Can be used by an sdn controller (like ovn for example), where
mac need to be registered manually.
2023-10-25 12:46:41 +02:00
Alexandre Derumier
22ac80580e zones: add|del_bridge_fdb : remove firewall param
It's not used anymore in Network.pm
2023-10-25 12:46:41 +02:00
Fabian Grünbichler
52ba64db27 zones: simplify status code
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2023-07-19 11:46:53 +02:00
Fabian Grünbichler
d227e3f488 zones: improve error message
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2023-07-19 11:46:53 +02:00
Alexandre Derumier
26e2abdbdc zones: status: display specific message if vnet is not generated.
also cleanup duplicate code in plugins

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2023-07-19 11:46:53 +02:00