netcfg: suppress RTNETLINK errors from policy route cleanup
Use runQuiet for ip rule/route del commands that may fail harmlessly when no existing rule exists (e.g. first run after deploy). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
47e06b525c
commit
857733863c
1 changed files with 7 additions and 3 deletions
|
|
@ -99,7 +99,7 @@ func ConfigurePolicyRoute(ifname string, lease *dhcp.Lease, table int) func() {
|
||||||
clientIP := lease.ClientIP.String()
|
clientIP := lease.ClientIP.String()
|
||||||
gw := lease.Gateway.String()
|
gw := lease.Gateway.String()
|
||||||
|
|
||||||
run("ip", "rule", "del", "table", t)
|
runQuiet("ip", "rule", "del", "table", t)
|
||||||
run("ip", "route", "replace", "default", "via", gw, "dev", ifname, "table", t)
|
run("ip", "route", "replace", "default", "via", gw, "dev", ifname, "table", t)
|
||||||
if err := run("ip", "rule", "add", "from", clientIP, "table", t); err != nil {
|
if err := run("ip", "rule", "add", "from", clientIP, "table", t); err != nil {
|
||||||
log.Printf("warning: policy rule: %v", err)
|
log.Printf("warning: policy rule: %v", err)
|
||||||
|
|
@ -108,8 +108,8 @@ func ConfigurePolicyRoute(ifname string, lease *dhcp.Lease, table int) func() {
|
||||||
}
|
}
|
||||||
|
|
||||||
return func() {
|
return func() {
|
||||||
run("ip", "rule", "del", "table", t)
|
runQuiet("ip", "rule", "del", "table", t)
|
||||||
run("ip", "route", "del", "default", "table", t)
|
runQuiet("ip", "route", "del", "default", "table", t)
|
||||||
log.Printf("policy route: cleaned up table %s", t)
|
log.Printf("policy route: cleaned up table %s", t)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -233,3 +233,7 @@ func run(name string, args ...string) error {
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
return cmd.Run()
|
return cmd.Run()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func runQuiet(name string, args ...string) error {
|
||||||
|
return exec.Command(name, args...).Run()
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue