Use ErrKernelModuleMissing when missing kernel module string is detected

This commit is contained in:
Quentin McGaw
2026-03-11 13:35:56 +00:00
parent eb9f1b4e36
commit 27b8e83aa5
2 changed files with 6 additions and 0 deletions
+3
View File
@@ -76,6 +76,9 @@ func (c *Config) runIP6tablesInstructionNoSave(ctx context.Context, instruction
cmd := exec.CommandContext(ctx, c.ip6Tables, flags...) // #nosec G204 cmd := exec.CommandContext(ctx, c.ip6Tables, flags...) // #nosec G204
c.logger.Debug(cmd.String()) c.logger.Debug(cmd.String())
if output, err := c.runner.Run(cmd); err != nil { if output, err := c.runner.Run(cmd); err != nil {
if strings.Contains(output, "missing kernel module") {
err = ErrKernelModuleMissing
}
return fmt.Errorf("command failed: \"%s %s\": %s: %w", return fmt.Errorf("command failed: \"%s %s\": %s: %w",
c.ip6Tables, instruction, output, err) c.ip6Tables, instruction, output, err)
} }
+3
View File
@@ -92,6 +92,9 @@ func (c *Config) runIptablesInstructionNoSave(ctx context.Context, instruction s
cmd := exec.CommandContext(ctx, c.ipTables, flags...) // #nosec G204 cmd := exec.CommandContext(ctx, c.ipTables, flags...) // #nosec G204
c.logger.Debug(cmd.String()) c.logger.Debug(cmd.String())
if output, err := c.runner.Run(cmd); err != nil { if output, err := c.runner.Run(cmd); err != nil {
if strings.Contains(output, "missing kernel module") {
err = ErrKernelModuleMissing
}
return fmt.Errorf("command failed: \"%s %s\": %s: %w", return fmt.Errorf("command failed: \"%s %s\": %s: %w",
c.ipTables, instruction, output, err) c.ipTables, instruction, output, err)
} }