Re: [PATCH v2 06/27] util: rename virNetFilterAction to iptablesAction, and add VIR_ENUM_DECL/IMPL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Apr 21, 2024 at 10:53:14PM -0400, Laine Stump wrote:
> I had originally named these as VIR_NETFILTER_* because I assumed the
> same enum would eventually be used by our nftables backend as well as
> iptables. But it turns out that in most cases it's not possible to
> delete an nftables rule, so we just never used the enum anyway, so
> this patch is renaming the values to IPTABLES_ACTION_*, and taking
> advantage of the newly defined (via VIR_ENUM_DECL/IMPL)
> iptablesActionTypeToString() to replace all the ternary operators used
> to translate the enum into a string for the iptables commandline with
> iptablesActionTypeToString().
> 
> Signed-off-by: Laine Stump <laine@xxxxxxxxxx>
> ---
>  src/network/network_iptables.c | 125 ++++++++++++++++++---------------
>  1 file changed, 68 insertions(+), 57 deletions(-)

Reviewed-by: Daniel P. Berrangé <berrange@xxxxxxxxxx>

> 
> diff --git a/src/network/network_iptables.c b/src/network/network_iptables.c
> index 31af9e0db6..d7e749adf0 100644
> --- a/src/network/network_iptables.c
> +++ b/src/network/network_iptables.c
> @@ -46,10 +46,21 @@ VIR_LOG_INIT("network.iptables");
>  #define VIR_IPTABLES_FWD_X_CHAIN "LIBVIRT_FWX"
>  #define VIR_IPTABLES_NAT_POSTROUTE_CHAIN "LIBVIRT_PRT"

This is where the extra '#include "virenum.h"'  from patch 1 ought to
have instead arrived I presume.

>  
> -enum {
> -    VIR_NETFILTER_INSERT = 0,
> -    VIR_NETFILTER_DELETE
> -};
> +typedef enum {
> +    IPTABLES_ACTION_INSERT,
> +    IPTABLES_ACTION_APPEND,
> +    IPTABLES_ACTION_DELETE,
> +
> +    IPTABLES_ACTION_LAST
> +} iptablesAction;
> +
> +VIR_ENUM_DECL(iptablesAction);
> +VIR_ENUM_IMPL(iptablesAction,
> +              IPTABLES_ACTION_LAST,
> +              "--insert",
> +              "--append",
> +              "--delete",
> +);
>  
>  typedef struct {
>      const char *parent;

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|
_______________________________________________
Devel mailing list -- devel@xxxxxxxxxxxxxxxxx
To unsubscribe send an email to devel-leave@xxxxxxxxxxxxxxxxx




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux