Commit Graph

83 Commits

Author SHA1 Message Date
Fabian Grünbichler
efef5c53e4 build: bump env_logger to 0.11
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2025-03-13 15:07:46 +01:00
Wolfgang Bumiller
57aac70bbe bump d/control
proxmox-ve-config currently still has a non-standard d/control, so
that one needs manual fixing, but the rest follows the usual
conventions...

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2025-03-13 14:16:02 +01:00
Stefan Hanreich
5841bef7f2 tests: add test for security groups in cluster config
There was a bug where rulesets with security groups bound to a
specific interface would cause the firewall to fail to create a new
ruleset. Catch this by adding a security group bound to an interface
to the ruleset.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
2025-03-13 13:59:08 +01:00
Stefan Hanreich
b3f3d7209b security groups: skip in forward chain when interface is specified
Security groups can be bound to a specific interface. The notion of
this breaks down when considering the forward direction, since there
are two interfaces involved: incoming and outgoing, which can be
different depending on the kind of traffic.

With the current implementation, the firewall refuses to generate
rulesets with security groups that are bound to specific interfaces.
Check for this case explicitly and skip creating rules in the forward
chain when a security group bound to a specific interface is
encountered.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
Tested-by: Hannes Duerr <h.duerr@proxmox.com>
2025-03-13 13:59:08 +01:00
Stefan Hanreich
697da0168e cargo: update proxmox-ve-config
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
2025-03-13 13:57:54 +01:00
Christoph Heiss
b0e756d5e2 d/control: drop unused build dependencies
These are simply just of the proxmox-ve-config crate, which was
moved to a separate repository in

  aa7692036 ("add proxmox-ve-rs crate - move proxmox-ve-config there")

and are not used by the other remaining crates.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
2025-01-24 13:48:14 +01:00
Stefan Hanreich
0479539f01 clippy: useless use of format!
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
2024-11-25 21:58:41 +01:00
Thomas Lamprecht
6ef05080c6 bump version to 0.6.0
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-11-19 16:53:12 +01:00
Thomas Lamprecht
22958811c8 config: fallback to legacy path when reading PVE IPAM state
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-11-18 22:24:26 +01:00
Hannes Laimer
64dc344bb8 firewall: apply nt_conntrack_allow_invalid option to guest table
So it behaves the same way the 'old' firewall did. Since currently
ct state invalid are always dropped on the guest table, regardless
of the option. The host behaviour is not changed as it would
require `forward` to match the 'old' behaviour.

Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
 [ TL: resolve merge conflict due to recent context changes ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-11-17 13:29:58 +01:00
Stefan Hanreich
8ef2e4e6b5 use std::mem::take over drain()
This is more efficient than draining and collecting the Vec. It also
fixes the respective clippy lint.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
Reviewed-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-11-17 12:59:43 +01:00
Stefan Hanreich
646fc18d04 sdn: create forward firewall rules
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
Reviewed-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Tested-by: Hannes Dürr <h.duerr@proxmox.com>
2024-11-17 12:59:43 +01:00
Stefan Hanreich
0c8bd4ad19 sdn: add support for loading vnet-level firewall config
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
Reviewed-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Tested-by: Hannes Dürr <h.duerr@proxmox.com>
2024-11-17 12:59:43 +01:00
Stefan Hanreich
d6edc73674 nftables: derive additional traits for nftables types
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
Reviewed-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2024-11-17 12:59:43 +01:00
Stefan Hanreich
6f01ca780b ipsets: autogenerate ipsets for vnets and ipam
They act like virtual ipsets, similar to ipfilter-net, that can be
used for defining firewall rules for sdn objects dynamically.

The changes in proxmox-ve-config also introduced a dedicated struct
for representing ip ranges, so we update the existing code, so that it
uses that struct as well.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
Reviewed-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Tested-by: Gabriel Goller <g.goller@proxmox.com>
Tested-by: Hannes Dürr <h.duerr@proxmox.com>
2024-11-17 12:59:43 +01:00
Stefan Hanreich
669f99801b config: tests: add support for loading sdn and ipam config
Also add example SDN configuration files that get automatically
loaded, which can be used for future tests.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
Reviewed-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
Tested-by: Gabriel Goller <g.goller@proxmox.com>
Tested-by: Hannes Dürr <h.duerr@proxmox.com>
2024-11-17 12:59:43 +01:00
Stefan Hanreich
aa76920360 add proxmox-ve-rs crate - move proxmox-ve-config there
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
Reviewed-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
 [ TL: add dependency to d/control and update its version ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-11-17 12:59:43 +01:00
Fabian Grünbichler
bea3e651b4 firewall: cargo: use new cargo feature resolver
Virtual cargo workspaces (workspaces without a [package] section)
default to the cargo feature resolver "1" – even though this outputs a
warning on every cargo invocation. To remove the warning, explicitly set
the resolver to version "2".

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>

FG: adapted to current Cargo.toml
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2024-10-31 14:03:31 +01:00
Fabian Grünbichler
ac39ec3c66 bump serde_with to 3
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2024-07-25 13:00:21 +02:00
Thomas Lamprecht
38c9eab41c bump version to 0.5.0
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-07-22 18:06:00 +02:00
Stefan Hanreich
57f6c9221d guest: match arp packets via meta
When matching via ether type, VLAN packets are not matched. This can
cause ARP packets encapsulated in VLAN frames to be dropped.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
2024-07-22 17:56:51 +02:00
Stefan Hanreich
de75183366 conntrack: arp: move handling to guest chains
In order to make sure we are only affecting VM traffic and no host
interfaces that are bridged, move the rules into a chain that gets
executed inside the guest chain, rather than setting the rules
globally.

Since ether type matches on the respective Ethernet header, it
doesn't work for packets with VLAN header. Matching via meta protocol
ensures that VLAN encapsulated ARP packets are matched as well.
Otherwise ARP traffic inside VLANs gets dropped, due to them having
conntrack state invalid.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-07-22 17:53:54 +02:00
Stefan Hanreich
293a19c213 cargo: bump proxmox-sys and proxmox-schema dependencies
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
 [ TL: update to versions released since this patch was created and
   updated proxmox-sys tree-wide ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-07-22 17:50:11 +02:00
Stefan Hanreich
08b74961cc service: flush firewall rules on force disable
When disabling the nftables firewall again, there is a race condition
where the nftables ruleset never gets flushed and persists after
disabling.

The nftables firewall update loop does a noop when the force disable
file exists. It only flushes the ruleset when nftables is disabled in
the configuration file but the force disable file does not yet exist.

This can lead to the following situation:

* nftables is activated and created its ruleset
* user switches from nftables firewall back to iptables firewall
* pve-firewall runs and creates the force disable file
* proxmox-firewall sees that the file exists and does nothing

Reported-by: Hannes Laimer <h.laimer@proxmox.com>
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
2024-07-22 17:43:05 +02:00
Stefan Hanreich
1e16cc8827 rules: allow vital ICMP(v6) types
There are certain ICMP messages that should always pass through a
firewall irregardless of any other rules. This is particularly
important for ICMPv6. While we already handled NDP, there are certain
control messages that should always be able to pass through any
firewall, according to RFC 4890.

For ICMP we additionally allow 'Source Quench' as well.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
2024-07-10 14:54:30 +02:00
Fabian Grünbichler
aa9b2e2395 build: properly set dh-cargo env variable
Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2024-06-20 12:32:32 +02:00
Fabian Grünbichler
f39f78150b move .cargo/config to .cargo/config.toml
the old location has been deprecated for a while, and rustc 1.78 will start to warn about it.

Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
2024-06-20 12:32:19 +02:00
Thomas Lamprecht
7d1a12822d bump version to 0.4.2
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-05-21 15:44:13 +02:00
Stefan Hanreich
67eba1f525 guest out: fix conntrack handling with default block/reject policy
The output chain did not have any connection tracking (conntrack)
rules, which lead to issues when the default output policy is not
accept. Also, move the conntrack rules to the beginning of all chains.

Originally-by: Laurent Guerby <laurent@guerby.net>
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-05-21 15:40:27 +02:00
Stefan Hanreich
3500a8d833 guest out: fix handling ARP traffic with default block/reject policy
In order to be able to send outgoing ARP packets when the default
policy is set to drop or reject, we need to explicitly allow ARP
traffic in the outgoing chain of guests. We need to do this in the
guest chain itself in order to be able to filter spoofed packets via
the MAC filter.

Contrary to the out direction we can simply accept all incoming ARP
traffic, since we do not do any MAC filtering for incoming traffic.
Since we create fdb entries for every NIC, guests should only see ARP
traffic for their MAC addresses anyway.

Originally-by: Laurent Guerby <laurent@guerby.net>
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-05-21 15:40:27 +02:00
Stefan Hanreich
bc3791c59a rules: use proper ICMPv6 type for rejecting IPv6 traffic
ICMPv6 has different message types for rejecting traffic. With ICMP we
used host-prohibited as rejection type, which doesn't exist in ICMPv6.
Add an additional rule for IPv6, so it uses admin-prohibited.

Additionally, add a terminal drop statement in order to prevent any
traffic that does not get matched from bypassing the reject chain.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-05-21 15:39:48 +02:00
Thomas Lamprecht
019bf8c843 bump version to 0.4.1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-26 17:22:28 +02:00
Thomas Lamprecht
97b31ad885 service: add comment for disable flag
this is something that should be roughly covered directly in the code

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-26 17:16:24 +02:00
Thomas Lamprecht
7acba538b8 service: add flag file to force-disable nftables
This will be set in the iptables/Perl based pve-firewall service and
ensures that users pulling this service but not enabling it are
"protected" from log-spam due to some pve-firewall config not being
parsed correctly (yet).

We can remove this again once we're sure that all edge cases are
covered, or this service here becomes the default.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Tested-by: Stefan Hanreich <s.hanreich@proxmox.com>
2024-04-26 17:11:41 +02:00
Thomas Lamprecht
d0506dc1a8 bump version to 0.4.0
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-25 19:29:50 +02:00
Stefan Hanreich
3b4bc833c1 firewall: improve error handling of firewall
Error handling of the firewall binary should now be much more robust
on configuration errors. Instead of panicking in some cases it should
now log an error.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
2024-04-25 19:25:17 +02:00
Stefan Hanreich
d409750487 config: nftables: add support for icmp-type any
We support any as wildcard for matching all icmp types. Implement
parsing logic for parsing the any value and support converting the any
value into an nftables expression.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
2024-04-25 19:21:50 +02:00
Stefan Hanreich
58ebc5500c config: macros: add SPICEproxy macro
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
2024-04-25 19:21:50 +02:00
Thomas Lamprecht
514feac19c bump version to 0.3.1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-24 19:42:02 +02:00
Stefan Hanreich
b46ad3eedc fix #5410: config: fix naming scheme for names in firewall config
This should bring the allowed names on par with the pve-firewall
naming scheme, allowing also underscores together with minus, as long
it isn't the first character [1].

[1] https://git.proxmox.com/?p=pve-firewall.git;a=blob;f=src/PVE/Firewall.pm;h=0abfeccffc94cec940760e69a894e392dc33f151;hb=29b48c381d14bf425232dc65c9c0d18f95c8f222#l51

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
 [ TL: expand commit message slightly ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-24 19:38:45 +02:00
Thomas Lamprecht
2bb35160cf bump version to 0.3.0
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-23 18:35:04 +02:00
Stefan Hanreich
6a824765a7 firewall: properly handle REJECT rules
Currently we generated DROP statements for all rules involving REJECT.
We only need to generate DROP when in the postrouting chain of tables
with type bridge, since REJECT is disallowed there. Otherwise we jump
into the do-reject chain which properly handles rejects for different
protocol types.

Reported-By: Stefan Sterz <s.sterz@proxmox.com>
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
2024-04-23 18:33:15 +02:00
Thomas Lamprecht
90ac474bf3 bump version to 0.2.1
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-23 13:20:19 +02:00
Stefan Hanreich
7944ed2c63 firewall: properly cleanup tables when firewall is inactive
When executing multiple nft commands they are transactional, either
all get applied or none. When only the host or guest firewall is
active, only one table exists and this causes the delete commands to
fail. To fix this we need to send the delete commands separately.

It might make sense to support running multiple separate batches in
the NftClient in the future in order to avoid having to call nft
twice.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
2024-04-23 13:09:53 +02:00
Thomas Lamprecht
fc21474330 bump version to 0.2.0
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-19 19:43:18 +02:00
Stefan Hanreich
34dcb7589f firewall: improve systemd unit file
Explicitly mark the service as simple and remove the PIDFile
attribute, which doesn't do anything with simple services.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
2024-04-19 19:41:23 +02:00
Stefan Hanreich
7438bb262a firewall: wait for nft process
NftClient never waits for the child process to terminate leading to
defunct leftover processes.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
2024-04-19 19:41:23 +02:00
Thomas Lamprecht
11954b1a08 buildsys: add upload target
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-18 22:03:10 +02:00
Thomas Lamprecht
58f0d831d9 buildsys: drop bogus DEB variables
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-18 22:02:08 +02:00
Stefan Hanreich
69a5707354 firewall: add integration test
Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
2024-04-18 21:47:21 +02:00