From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <pve-devel-bounces@lists.proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9])
	by lore.proxmox.com (Postfix) with ESMTPS id AB5B61FF176
	for <inbox@lore.proxmox.com>; Fri, 24 Jan 2025 15:35:43 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id 2E00F2C536;
	Fri, 24 Jan 2025 15:35:37 +0100 (CET)
Message-ID: <2ca39c79-14ac-4394-b2e6-2fe9c049829b@proxmox.com>
Date: Fri, 24 Jan 2025 15:35:03 +0100
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>,
 Stefan Hanreich <s.hanreich@proxmox.com>
References: <20250123101300.72647-1-s.hanreich@proxmox.com>
 <20250123101300.72647-3-s.hanreich@proxmox.com>
Content-Language: en-US
From: =?UTF-8?Q?Hannes_D=C3=BCrr?= <h.duerr@proxmox.com>
In-Reply-To: <20250123101300.72647-3-s.hanreich@proxmox.com>
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.037 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DMARC_MISSING             0.1 Missing DMARC policy
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to
 Validity was blocked. See
 https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more
 information.
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
 T_SCC_BODY_TEXT_LINE    -0.01 -
 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See
 http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more
 information. [rule.rs]
Subject: Re: [pve-devel] [PATCH proxmox-firewall 3/4] security groups: skip
 in forward chain when interface is specified
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
Reply-To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset="us-ascii"; Format="flowed"
Errors-To: pve-devel-bounces@lists.proxmox.com
Sender: "pve-devel" <pve-devel-bounces@lists.proxmox.com>

Tested this:
* enable nftables firewall
* create a security group
* insert the security group to host firewall with interface vmbr0
* enable vm firewall
* insert the security group to vm firewall with interface net0
* check for errors with journalctl -f

no more errors occur, please consider this

Tested-by: Hannes Duerr <h.duerr@proxmox.com>

On 1/23/25 11:12, Stefan Hanreich wrote:
> 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>
> ---
>   proxmox-firewall/src/rule.rs | 4 ++++
>   1 file changed, 4 insertions(+)
>
> diff --git a/proxmox-firewall/src/rule.rs b/proxmox-firewall/src/rule.rs
> index b20a9c5..14ee544 100644
> --- a/proxmox-firewall/src/rule.rs
> +++ b/proxmox-firewall/src/rule.rs
> @@ -201,6 +201,10 @@ fn handle_iface(rules: &mut [NftRule], env: &NftRuleEnv, name: &str) -> Result<(
>   
>   impl ToNftRules for RuleGroup {
>       fn to_nft_rules(&self, rules: &mut Vec<NftRule>, env: &NftRuleEnv) -> Result<(), Error> {
> +        if env.direction == Direction::Forward && self.iface().is_some() {
> +            return Ok(());
> +        }
> +
>           let chain_name = format!("group-{}-{}", self.group(), env.direction);
>   
>           rules.push(NftRule::new(Statement::jump(chain_name)));


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel