On Thu, Dec 11, 2025 at 03:00:51PM +0100, Dion Bosschieter wrote:
> Introduce nwfilter_tech_driver.c which holds shared non driver specific
> methods.
> The following logic can be reused by new nwfilter drivers, which are not
> ebiptables specific:
> - data type print logic, used for constructing ascii cli arguments out
>   of nwfilter data;
> - chain jump proto type l3_proto_idx logic;
> - virNWFilterRule sorting.
> 
> Signed-off-by: Dion Bosschieter <[email protected]>
> ---
>  src/nwfilter/meson.build                  |   1 +
>  src/nwfilter/nwfilter_ebiptables_driver.c | 262 +---------------------
>  src/nwfilter/nwfilter_tech_driver.c       | 250 +++++++++++++++++++++
>  src/nwfilter/nwfilter_tech_driver.h       |  50 ++++-
>  4 files changed, 299 insertions(+), 264 deletions(-)
>  create mode 100644 src/nwfilter/nwfilter_tech_driver.c

> diff --git a/src/nwfilter/nwfilter_tech_driver.h 
> b/src/nwfilter/nwfilter_tech_driver.h
> index a4af0bf6d5..7a85c46339 100644
> --- a/src/nwfilter/nwfilter_tech_driver.h
> +++ b/src/nwfilter/nwfilter_tech_driver.h

> @@ -38,6 +36,31 @@ struct _virNWFilterRuleInst {
>  };
>  
>  
> +typedef struct _chainCreateCallbackData chainCreateCallbackData;
> +struct _chainCreateCallbackData {
> +    const char *ifname;
> +    int nrules;
> +    virNWFilterRuleInst **rules;
> +};
> +
> +struct ushort_map {
> +    unsigned short attr;
> +    const char *val;
> +};
> +
> +#define USHORTMAP_ENTRY_IDX(IDX, ATT, VAL) [IDX] = { .attr = ATT, .val = VAL 
> }
> +
> +enum l3_proto_idx {
> +    L3_PROTO_IPV4_IDX = 0,
> +    L3_PROTO_IPV6_IDX,
> +    L3_PROTO_ARP_IDX,
> +    L3_PROTO_RARP_IDX,
> +    L2_PROTO_MAC_IDX,
> +    L2_PROTO_VLAN_IDX,
> +    L2_PROTO_STP_IDX,
> +    L3_PROTO_LAST_IDX
> +};
> +


> +int printVar(virNWFilterVarCombIter *vars,
> +             char *buf, int bufsize,
> +             nwItemDesc *item,
> +             bool *done);
> +
> +int printDataType(virNWFilterVarCombIter *vars,
> +                  char *buf, int bufsize,
> +                  nwItemDesc *item);
> +
> +int printDataTypeDirection(virNWFilterVarCombIter *vars,
> +                           char *buf, int bufsize,
> +                           nwItemDesc *item, bool directionIn);
> +int printDataTypeAsHex(virNWFilterVarCombIter *vars,
> +                       char *buf, int bufsize,
> +                       nwItemDesc *item);

These data types and functions have horribly generic names.

This was a pre-existing problem but we turned a blind eye
as it was confined to the .c file. If we're moving them
to headers I'd really prefer if there was a patch that
first renamed them all to have "virNWFilter" as a name
prefix, and the ushort_map and l3_proto_idx ought to
switch to CamelCase too.

eg virNWFilterUShortMap  and virNWFilterL3ProtoIdx


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 :|

Reply via email to