Check nftables is enabled before applying updates

Signed-off-by: Rob Murray <rob.murray@docker.com>
This commit is contained in:
Rob Murray
2025-05-14 10:03:42 +01:00
parent 976f855f68
commit 06afbe9618

View File

@@ -259,9 +259,12 @@ table {{$family}} {{$tableName}} {
// Apply makes incremental updates to nftables, corresponding to changes to the [TableRef]
// since Apply was last called.
func (t TableRef) Apply(ctx context.Context) error {
var buf bytes.Buffer
if !Enabled() {
return errors.New("nftables is not enabled")
}
// Update nftables.
var buf bytes.Buffer
if err := incrementalUpdateTempl.Execute(&buf, t.t); err != nil {
return fmt.Errorf("failed to execute template nft ruleset: %w", err)
}