From nobody Sun Feb 8 19:59:40 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1685705324; cv=none; d=zohomail.com; s=zohoarc; b=h0O5RRxfPRJPW37vUOJo8FUuJicamUBdmDUmY0ikgkJHkpVyVsnOzMy8xjt5L9s6YeNrLUlAtBIeMx6uViMMRkR3MTY9BYjh7tN97wzenPpHD4PPum/xuPCyZos85ZPPS+xBJEoY3BAcvJRcolnAyPNZP2QJb5JGSTg0iJQpBJU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685705324; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9Gc62R8Kv6xJ9hhb6qSlWhNDpDoqc16awJ31u0+2Pk0=; b=dwlShxqltayS+DGbPT2cD4PJ6lMqXZTBQDMdjD0soRDm98gX66PYZqrd+PXaigUJ50OGFSFm1BJqlp5hTiOYnLrMU8PqpMsK2YOgtJBy9+00Eo2wdIZov4ykJ0Ed+RurnfiviS5dDSTEwpV46+xZeVnqxLVEH635u9rHcIcX4Go= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 168570532487292.0520025469092; Fri, 2 Jun 2023 04:28:44 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-29-g9ev_OmrP9W5VyKa5M5VRA-1; Fri, 02 Jun 2023 07:28:39 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7E1E8811E88; Fri, 2 Jun 2023 11:28:36 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6D1C040C6EC4; Fri, 2 Jun 2023 11:28:36 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 60FF91946595; Fri, 2 Jun 2023 11:28:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 46FB219465B5 for ; Fri, 2 Jun 2023 11:28:35 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 3A2D39E68; Fri, 2 Jun 2023 11:28:35 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id A3F7D9E60 for ; Fri, 2 Jun 2023 11:28:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685705323; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=9Gc62R8Kv6xJ9hhb6qSlWhNDpDoqc16awJ31u0+2Pk0=; b=ZPMkgCXYjaEln/pyLrnv0Bzd61UP9M2Vusk6ucC+SnPperi6kj9T9UPDyUDINUNzzkgdZi /k6HAXm8zxixdymkjbOw4oIsU9PDSx6/7o5oZR/c0eLRkYXQI7Ojv/A9DZDPjJs+40ry0D 5eUDCH5VpL0RLY2BTqSHerhBB8nPzI0= X-MC-Unique: g9ev_OmrP9W5VyKa5M5VRA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 10/15] virNWFilterRuleDef: Turn 'action' and 'tt' into proper enum types Date: Fri, 2 Jun 2023 13:28:20 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1685705326491100002 Content-Type: text/plain; charset="utf-8" Convert the fields to the proper types and use virXMLPropEnum for parsing. Signed-off-by: Peter Krempa --- src/conf/nwfilter_conf.c | 32 +++-------------------- src/conf/nwfilter_conf.h | 4 +-- src/nwfilter/nwfilter_ebiptables_driver.c | 5 ++++ 3 files changed, 11 insertions(+), 30 deletions(-) diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c index 98a19f9e4b..13c6096fcd 100644 --- a/src/conf/nwfilter_conf.c +++ b/src/conf/nwfilter_conf.c @@ -2373,8 +2373,6 @@ virNWFilterRuleDefFixup(virNWFilterRuleDef *rule) static virNWFilterRuleDef * virNWFilterRuleParse(xmlNodePtr node) { - g_autofree char *action =3D NULL; - g_autofree char *direction =3D NULL; g_autofree char *prio =3D NULL; g_autofree char *statematch =3D NULL; bool found; @@ -2386,38 +2384,16 @@ virNWFilterRuleParse(xmlNodePtr node) ret =3D g_new0(virNWFilterRuleDef, 1); - action =3D virXMLPropString(node, "action"); - direction =3D virXMLPropString(node, "direction"); prio =3D virXMLPropString(node, "priority"); statematch =3D virXMLPropString(node, "statematch"); - if (!action) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", - _("rule node requires action attribute")); + if (virXMLPropEnum(node, "action", virNWFilterRuleActionTypeFromString, + VIR_XML_PROP_REQUIRED, &ret->action) < 0) return NULL; - } - if ((ret->action =3D virNWFilterRuleActionTypeFromString(action)) < 0)= { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - "%s", - _("unknown rule action attribute value")); + if (virXMLPropEnum(node, "direction", virNWFilterRuleDirectionTypeFrom= String, + VIR_XML_PROP_REQUIRED, &ret->tt) < 0) return NULL; - } - - if (!direction) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", - _("rule node requires direction attribute")); - return NULL; - } - - if ((ret->tt =3D virNWFilterRuleDirectionTypeFromString(direction)) < = 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - "%s", - _("unknown rule direction attribute value")); - return NULL; - } ret->priority =3D MAX_RULE_PRIORITY / 2; diff --git a/src/conf/nwfilter_conf.h b/src/conf/nwfilter_conf.h index 7c09b3bcb9..22c2fb51f0 100644 --- a/src/conf/nwfilter_conf.h +++ b/src/conf/nwfilter_conf.h @@ -446,8 +446,8 @@ typedef struct _virNWFilterRuleDef virNWFilterRuleDef; struct _virNWFilterRuleDef { virNWFilterRulePriority priority; virNWFilterRuleFlags flags; - int action; /* virNWFilterRuleActionType */ - int tt; /* virNWFilterRuleDirectionType */ + virNWFilterRuleActionType action; + virNWFilterRuleDirectionType tt; virNWFilterRuleProtocolType prtclType; union { ethHdrFilterDef ethHdrFilter; diff --git a/src/nwfilter/nwfilter_ebiptables_driver.c b/src/nwfilter/nwfil= ter_ebiptables_driver.c index 99a74a60e5..1c5da2ae05 100644 --- a/src/nwfilter/nwfilter_ebiptables_driver.c +++ b/src/nwfilter/nwfilter_ebiptables_driver.c @@ -2361,6 +2361,11 @@ ebtablesCreateRuleInstance(virFirewall *fw, target =3D virNWFilterJumpTargetTypeToString( VIR_NWFILTER_RULE_ACTION_DROP); break; + case VIR_NWFILTER_RULE_ACTION_DROP: + case VIR_NWFILTER_RULE_ACTION_ACCEPT: + case VIR_NWFILTER_RULE_ACTION_RETURN: + case VIR_NWFILTER_RULE_ACTION_CONTINUE: + case VIR_NWFILTER_RULE_ACTION_LAST: default: target =3D virNWFilterJumpTargetTypeToString(rule->action); } --=20 2.40.1