Commit graph

534 commits

Author SHA1 Message Date
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
Fabian Grünbichler 0eda9b9aad sdn: config generation : check if interfaces.d/sdn is sourced
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2023-07-19 11:46:51 +02:00
Alexandre Derumier fd1ae5044e zones: fix status
Vnets were wrongly displayed in the main tree because of this,
and error was not set on zone

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2023-06-13 11:41:50 +02:00
Alexandre Derumier d7c1620043 fix permissions && use new /sdn/zones/<zone>/<vnet> path
- use new /sdn/zones/zone/<vnet> path for vnet && subnets permissions

- fix some permissions on /sdn/zones  && /sdn

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2023-06-12 12:55:12 +02:00
Fabian Grünbichler cbf906daae fix tests for bookworm
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2023-06-07 13:25:02 +02:00
Alexandre Derumier f048b81513 get_local_vnets: fix permission path && perm
new path is /zones/<zone>/<vnetid>

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
2023-06-07 12:05:18 +02:00
Thomas Lamprecht a38775c818 bump version to 0.8.1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-06 10:23:57 +02:00
Thomas Lamprecht fa9c1ddd8d skip tests in sbuild environment for now
they access pmxcfs directly and so cannot really work, this needs to
be mocked some day (soon!), but as stop-gap just skip the tests if a
sbuild lock is present

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-06 10:23:57 +02:00
Thomas Lamprecht 13c75e8619 d/control: update dependencies
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-06 10:23:57 +02:00
Alexandre Derumier 243fa522b6 evpn: update config to frr 8.5.1
add default values:
 "no bgp hard-administrative-reset"
 "no bgp graceful-restart notification"

to avoid frr-reload warning

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-06 10:23:57 +02:00
Alexandre Derumier 0626bbf7b3 network reload: fix UPID parsing
When warning or error from ifreload are logged they are received in
1 line in result of pvesh.

So, the UPID might not always start at the beginning, which was
assumed by the old code, failing parsing it, throwing a warning like:

> Use of uninitialized value $upid in pattern match (m//) at /usr/share/perl5/PVE/Tools.pm line 1106.
> Use of uninitialized value $upid in concatenation (.) or string at /usr/share/perl5/PVE/Tools.pm line 1120.

Drop the start anchor of the regex.

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-06 10:23:57 +02:00
Alexandre Derumier de4e2b9cf4 fix #4683: zones: QinQ: fix vlan-protocol when bridge is VLAN aware
The tagged bridge interface need to also have to correct
vlan-protocol

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-06 10:23:57 +02:00
Alexandre Derumier 91b2f632c0 fix #4389: evpn: exit nodes: null routes subnets from other zones
We don't want to routes subnets between different zones when same
exit node is used.

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-06 10:23:57 +02:00
Alexandre Derumier f56311de97 fix #4662: frr: fix config generation ordering
vrf and router bgp vrf need to be ordered by vrf name

ip protocol need to be at the end

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-06 10:23:57 +02:00
Alexandre Derumier b84eacc86a fix #4425: vxlan, evpn: add vxlan-port option to override default
Some users requested it as their physical network equipments don't
use standard vxlan port

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-06 10:23:57 +02:00
Alexandre Derumier 5d5b4099d1 fix #4657: evpn: fix exit-node with multiple vrf
Currently, if a node is primary exit-node for 1 vrf, and secondary
exit-node for another vrf,

The deny route-map is filtering routes imports for both vrf.

This patch adds filtering only for the vrf's where the node is
secondary.

Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-06-06 10:23:57 +02:00
Thomas Lamprecht 2bff8ab755 bump version to 0.8.0
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-05-25 18:18:57 +02:00
Thomas Lamprecht 11f3cfd9a1 d/control: raise compat level to 13
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2023-05-25 18:18:57 +02:00