Re: [PATCH ghak124 v3] audit: log nftables configuration change events

From: Florian Westphal
Date: Thu Feb 18 2021 - 11:26:58 EST


Richard Guy Briggs <rgb@xxxxxxxxxx> wrote:
> Ok, can I get one more clarification on this "hierarchy"? Is it roughly
> in the order they appear in nf_tables_commit() after step 3? It appears
> it might be mostly already. If it isn't already, would it be reasonable
> to re-order them? Would you suggest a different order?

For audit purposes I think enum nf_tables_msg_types is already in the
most relevant order, the lower numbers being more imporant.

So e.g. NEWTABLE would be more interesting than DELRULE, if both
are in same batch.

> > > such that it would be desirable to filter them out
> > > to reduce noise in that single log line if it is attempted to list all
> > > the change ops? It almost sounds like it would be better to do one
> > > audit log line for each table for each family, and possibly for each op
> > > to avoid the need to change userspace. This would already be a
> > > significant improvement picking the highest ranking op.
> >
> > I think i understand what you'd like to do. Yes, that would reduce
> > the log output a lot.
>
> Would the generation change id be useful outside the kernel?

Yes, we already announce it to interested parties via nfnetlink.

> What
> exactly does it look like?

Its just a u64 counter that gets incremented whenever there is a change.

> I don't quite understand the genmask purpose.

Thats an implementation detail only. When we process a transaction,
changes to the ruleset are being made but they should not have any
effect until the entire transaction is processed.

So there are two 'generations' at any time:
1. The active ruleset
2. The future ruleset

2) is what is being changed/modified.

When the transaction completes, then the future ruleset becomes
the active ruleset. If the transaction has to be aborted, the
pending changes are reverted and the genid/genmasks are not changed.