public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Hannes Laimer <h.laimer@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH pve-network v3 28/45] sdn: microseg: expose protocol, port and macro rule options
Date: Tue, 27 Oct 2026 09:55:10 +0100	[thread overview]
Message-ID: <20261027085527.702738-29-h.laimer@proxmox.com> (raw)
In-Reply-To: <20261027085527.702738-1-h.laimer@proxmox.com>

The options take the values of the firewall rule options of the same
name. The config library checks them with its firewall parsers, so the
schema here only limits their length.

The options are part of what a rule's id is derived from, so the same
groups can carry one rule per narrowing. As with the groups, changing
them means replacing the rule.

At the same priority a rule with a protocol or macro is checked ahead
of one without, so the priorities alone do not show the evaluation
order. The overview reports each rule's place in it and each
assignment's place in the match order.

Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---
 src/PVE/API2/Network/SDN/Microseg.pm      | 10 +++++
 src/PVE/API2/Network/SDN/Microseg/Rule.pm |  6 +--
 src/PVE/Network/SDN/Microseg.pm           | 51 +++++++++++++++++++++--
 3 files changed, 60 insertions(+), 7 deletions(-)

diff --git a/src/PVE/API2/Network/SDN/Microseg.pm b/src/PVE/API2/Network/SDN/Microseg.pm
index 525fa429ae50..5d4062f7db30 100644
--- a/src/PVE/API2/Network/SDN/Microseg.pm
+++ b/src/PVE/API2/Network/SDN/Microseg.pm
@@ -124,6 +124,14 @@ __PACKAGE__->register_method({
                                 },
                             },
                         },
+                        rank => {
+                            type => 'integer',
+                            optional => 1,
+                            description =>
+                                "The object's place in the order its kind is looked at, rules"
+                                . ' in evaluation order and assignments in match order. The'
+                                . ' first has the lowest number.',
+                        },
                         $OBJECT_PROPERTIES->%*,
                     },
                 },
@@ -197,9 +205,11 @@ __PACKAGE__->register_method({
         my $members = $config->assigned_members(
             PVE::Network::SDN::Microseg::audited_guest_inventory(),
         );
+        my $rank = { $config->rule_order()->%*, $config->assignment_order()->%* };
         for my $object (@$objects) {
             my $id = $object->{id};
             $object->{members} = $members->{$id} if defined($members->{$id});
+            $object->{rank} = $rank->{$id} if defined($rank->{$id});
         }
 
         my $registry = ($running_cfg->{microseg} // {})->{identities};
diff --git a/src/PVE/API2/Network/SDN/Microseg/Rule.pm b/src/PVE/API2/Network/SDN/Microseg/Rule.pm
index 575ca1286ed9..ed34d83b2c5c 100644
--- a/src/PVE/API2/Network/SDN/Microseg/Rule.pm
+++ b/src/PVE/API2/Network/SDN/Microseg/Rule.pm
@@ -12,9 +12,9 @@ __PACKAGE__->register_handlers({
     types => ['rule'],
     name => 'rule',
     properties => \&PVE::Network::SDN::Microseg::rule_properties,
-    create_details => "The id is derived from the src and dst predicates and from the"
-        . " direction. Creating the same rule again is refused as a duplicate. Change an existing"
-        . " rule's priority or verdict by updating it rather than creating a second rule.",
+    create_details => "The id is derived from what the rule matches, so creating the same rule"
+        . " again is refused as a duplicate. Change an existing rule's priority or verdict by"
+        . " updating it rather than creating a second rule.",
     generated_id => 1,
     generated_id_description => "The generated rule id.",
 });
diff --git a/src/PVE/Network/SDN/Microseg.pm b/src/PVE/Network/SDN/Microseg.pm
index bdfde447b320..c5023c17b1d9 100644
--- a/src/PVE/Network/SDN/Microseg.pm
+++ b/src/PVE/Network/SDN/Microseg.pm
@@ -128,13 +128,55 @@ sub rule_properties {
             optional => 1,
             ($update ? () : (default => 0)),
             description => "Priority. The highest-priority matching rule wins."
-                . " At a tie, a deny overrides an allow.",
+                . " At a tie, a deny overrides an allow."
+                . " A narrowed rule is checked ahead of an unnarrowed rule at the same priority.",
         },
         comment => $COMMENT_PROPERTY,
     };
 
     # the id is derived from these
     if (!$update) {
+        my $port_descr =
+            "A service name or number (0-65535) as defined in '/etc/services', a range such"
+            . " as '80:85', or a comma-separated list of those. Requires a protocol with ports.";
+        $properties->{proto} = {
+            type => 'string',
+            minLength => 1,
+            maxLength => 32,
+            optional => 1,
+            description => "Restrict the rule to an IP protocol, a name or number from"
+                . " '/etc/protocols'. Without a protocol or macro the rule decides all traffic"
+                . " between the matched interfaces.",
+        };
+        $properties->{sport} = {
+            type => 'string',
+            minLength => 1,
+            maxLength => 128,
+            optional => 1,
+            description => "Restrict the source port. $port_descr",
+        };
+        $properties->{dport} = {
+            type => 'string',
+            minLength => 1,
+            maxLength => 128,
+            optional => 1,
+            description => "Restrict the destination port. $port_descr",
+        };
+        $properties->{'icmp-type'} = {
+            type => 'string',
+            minLength => 1,
+            maxLength => 64,
+            optional => 1,
+            description => "Restrict the ICMP type. Only with an ICMP protocol.",
+        };
+        $properties->{macro} = {
+            type => 'string',
+            minLength => 1,
+            maxLength => 128,
+            optional => 1,
+            description => "A firewall macro standing in for the protocol, ports and ICMP type."
+                . " Cannot be combined with them.",
+        };
         $properties->{src} = {
             type => 'array',
             items => get_standard_option('pve-sdn-microseg-id'),
@@ -174,9 +216,10 @@ sub rule_properties {
             type => 'boolean',
             optional => 1,
             default => 0,
-            description => "Also apply the rule with the source and destination predicates"
-                . " swapped. It is exactly that pair of rules and adds no connection tracking."
-                . " Not with the 'untagged' group.",
+            description => "Also apply the rule with the source and destination predicates and"
+                . " ports swapped. It is exactly that pair of rules and adds no connection"
+                . " tracking. Not with the 'untagged' group or an ICMP type, including one a macro"
+                . " expands to.",
         };
     } else {
         $properties->{delete} = delete_property('comment');
-- 
2.47.3





  parent reply	other threads:[~2026-10-27  9:00 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-27  8:54 [PATCH access-control/cluster/container/docs/manager/network/proxmox{-ebpf,-ve-rs,-perl-rs}/qemu-server v3 00/45] sdn: add microsegmentation support Hannes Laimer
2026-10-27  8:54 ` [PATCH proxmox-ebpf v3 01/45] build: keep the build directory out of the BPF objects Hannes Laimer
2026-10-27  8:54 ` [PATCH proxmox-ebpf v3 02/45] policy: add the enforcement subsystem for guest interfaces Hannes Laimer
2026-10-27  8:54 ` [PATCH proxmox-ebpf v3 03/45] policy: add a check for non-first fragments Hannes Laimer
2026-10-27  8:54 ` [PATCH proxmox-ve-rs v3 04/45] ve-config: firewall: add a constructor for sctp matches Hannes Laimer
2026-10-27  8:54 ` [PATCH proxmox-ve-rs v3 05/45] ve-config: sdn: microseg: add identity allocation for group sets Hannes Laimer
2026-10-27  8:54 ` [PATCH proxmox-ve-rs v3 06/45] ve-config: sdn: microseg: add config types Hannes Laimer
2026-10-27  8:54 ` [PATCH proxmox-ve-rs v3 07/45] ve-config: sdn: microseg: add tag matcher Hannes Laimer
2026-10-27  8:54 ` [PATCH proxmox-ve-rs v3 08/45] ve-config: sdn: microseg: add name regex matcher Hannes Laimer
2026-10-27  8:54 ` [PATCH proxmox-ve-rs v3 09/45] ve-config: sdn: microseg: narrow rules by protocol and ports Hannes Laimer
2026-10-27  8:54 ` [PATCH proxmox-ve-rs v3 10/45] ve-config: sdn: microseg: add group hierarchy Hannes Laimer
2026-10-27  8:54 ` [PATCH proxmox-ve-rs v3 11/45] ve-config: firewall: expose protocol, icmp type and code numbers Hannes Laimer
2026-10-27  8:54 ` [PATCH proxmox-ve-rs v3 12/45] ve-config: sdn: microseg: add the desired state Hannes Laimer
2026-10-27  8:54 ` [PATCH proxmox-ve-rs v3 13/45] microseg: add a crate that applies the policy to a node's guest NICs Hannes Laimer
2026-10-27  8:54 ` [PATCH proxmox-ve-rs v3 14/45] microseg: add a rule option that matches non-first fragments Hannes Laimer
2026-10-27  8:54 ` [PATCH pve-cluster v3 15/45] cfs: add 'sdn/microseg.cfg' to observed files Hannes Laimer
2026-10-27  8:54 ` [PATCH pve-access-control v3 16/45] permissions: add ACL path for SDN microsegmentation Hannes Laimer
2026-10-27  8:54 ` [PATCH proxmox-perl-rs v3 17/45] pve-rs: sdn: add microseg config binding Hannes Laimer
2026-10-27  8:55 ` [PATCH proxmox-perl-rs v3 18/45] pve-rs: sdn: microseg: bind the data plane Hannes Laimer
2026-10-27  8:55 ` [PATCH proxmox-perl-rs v3 19/45] pve-rs: sdn: microseg: check the data plane limits on render Hannes Laimer
2026-10-27  8:55 ` [PATCH proxmox-perl-rs v3 20/45] pve-rs: debian: fire the pve-microseg-update trigger on upgrade Hannes Laimer
2026-10-27  8:55 ` [PATCH pve-network v3 21/45] sdn: zones: add vxlan-gbp option to vxlan and evpn zones Hannes Laimer
2026-10-27  8:55 ` [PATCH pve-network v3 22/45] sdn: microseg: add config, API and guest inventory Hannes Laimer
2026-10-27  8:55 ` [PATCH pve-network v3 23/45] sdn: dry-run: show pending microseg changes Hannes Laimer
2026-10-27  8:55 ` [PATCH pve-network v3 24/45] sdn: microseg: enforce the policy on guest NICs Hannes Laimer
2026-10-27  8:55 ` [PATCH pve-network v3 25/45] sdn: microseg: add tag matcher Hannes Laimer
2026-10-27  8:55 ` [PATCH pve-network v3 26/45] sdn: microseg: add name regex matcher Hannes Laimer
2026-10-27  8:55 ` [PATCH pve-network v3 27/45] sdn: microseg: add an update for a running NIC Hannes Laimer
2026-10-27  8:55 ` Hannes Laimer [this message]
2026-10-27  8:55 ` [PATCH pve-network v3 29/45] sdn: microseg: allow nesting groups under a parent Hannes Laimer
2026-10-27  8:55 ` [PATCH pve-network v3 30/45] sdn: microseg: expose the fragments rule option Hannes Laimer
2026-10-27  8:55 ` [PATCH pve-manager v3 31/45] network: apply the microseg policy on reload Hannes Laimer
2026-10-27  8:55 ` [PATCH pve-manager v3 32/45] pve-sdn-commit: apply the microseg policy at boot Hannes Laimer
2026-10-27  8:55 ` [PATCH pve-manager v3 33/45] ui: sdn: zones: add vxlan-gbp checkbox to vxlan and evpn Hannes Laimer
2026-10-27  8:55 ` [PATCH pve-manager v3 34/45] ui: sdn: add microsegmentation panel Hannes Laimer
2026-10-27  8:55 ` [PATCH pve-manager v3 35/45] ui: sdn: dry-run: show pending microseg diff Hannes Laimer
2026-10-27  8:55 ` [PATCH pve-manager v3 36/45] ui: sdn: microseg: add tag matcher Hannes Laimer
2026-10-27  8:55 ` [PATCH pve-manager v3 37/45] ui: sdn: microseg: add name regex matcher Hannes Laimer
2026-10-27  8:55 ` [PATCH pve-manager v3 38/45] ui: sdn: microseg: add narrowing to the rule form Hannes Laimer
2026-10-27  8:55 ` [PATCH pve-manager v3 39/45] ui: sdn: microseg: show and edit the group hierarchy Hannes Laimer
2026-10-27  8:55 ` [PATCH pve-manager v3 40/45] ui: sdn: microseg: add fragments option to the rule form Hannes Laimer
2026-10-27  8:55 ` [PATCH pve-manager v3 41/45] ui: sdn: microseg: add a guest tab with its groups and rules Hannes Laimer
2026-10-27  8:55 ` [PATCH qemu-server v3 42/45] network: update the microseg enforcement on a tag or name change Hannes Laimer
2026-10-27  8:55 ` [PATCH pve-container v3 43/45] lxc: update the microseg enforcement on a tag or hostname change Hannes Laimer
2026-10-27  8:55 ` [PATCH pve-docs v3 44/45] sdn: zones: document the VXLAN-GBP option Hannes Laimer
2026-10-27  8:55 ` [PATCH pve-docs v3 45/45] sdn: add microsegmentation section Hannes Laimer

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=20261027085527.702738-29-h.laimer@proxmox.com \
    --to=h.laimer@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal