d/libn/i/nftables: add trailing semicolon

The syntax for specifying the parameters of a base chain is documented
to have a mandatory semicolon terminating each parameter clause. In
practice, nft sometimes accepts a chain definition with a newline
instead of a semicolon after the terminal parameter, only to reject the
rules that follow with strange errors. Add trailing semicolons to the
policy parameters of base chain definitions to satisfy the parsers of
all versions of nft we might encounter.

Signed-off-by: Cory Snider <csnider@mirantis.com>
This commit is contained in:
Cory Snider
2026-07-14 10:46:24 -04:00
parent b0d9b6657d
commit ea57cdf1c7
2 changed files with 3 additions and 3 deletions

View File

@@ -34,7 +34,7 @@ table {{$family}} {{$tableName}} {
}
{{end}}
{{range .Chains}}{{if .MustFlush}}chain {{.Name}} {
{{if .ChainType}}type {{.ChainType}} hook {{.Hook}}{{if .Device}} device "{{.Device}}"{{end}} priority {{.Priority}}; policy {{.Policy}}{{end}}
{{if .ChainType}}type {{.ChainType}} hook {{.Hook}}{{if .Device}} device "{{.Device}}"{{end}} priority {{.Priority}}; policy {{.Policy}};{{end}}
} ; {{end}}{{end}}
}
{{if .MustFlush}}flush table {{$family}} {{$tableName}}{{end}}
@@ -52,7 +52,7 @@ table {{$family}} {{$tableName}} {
{{end}}
table {{$family}} {{$tableName}} {
{{range .Chains}}{{if .MustFlush}}chain {{.Name}} {
{{if .ChainType}}type {{.ChainType}} hook {{.Hook}}{{if .Device}} device "{{.Device}}"{{end}} priority {{.Priority}}; policy {{.Policy}}{{end}}
{{if .ChainType}}type {{.ChainType}} hook {{.Hook}}{{if .Device}} device "{{.Device}}"{{end}} priority {{.Priority}}; policy {{.Policy}};{{end}}
{{range .Rules}}{{.}}
{{end}}
}

View File

@@ -33,7 +33,7 @@ table {{$family}} {{$tableName}} {
}
{{end}}
{{range .Chains}}chain {{.Name}} {
{{if .ChainType}}type {{.ChainType}} hook {{.Hook}}{{if .Device}} device "{{.Device}}"{{end}} priority {{.Priority}}; policy {{.Policy}}{{end}}
{{if .ChainType}}type {{.ChainType}} hook {{.Hook}}{{if .Device}} device "{{.Device}}"{{end}} priority {{.Priority}}; policy {{.Policy}};{{end}}
{{range .Rules}}{{.}}
{{end}}
}