Skip to content

Commit

Permalink
fix(netlink): consider file exists error as success for rule addition
Browse files Browse the repository at this point in the history
  • Loading branch information
qdm12 committed Nov 3, 2024
1 parent 96a8015 commit e92d07f
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions internal/netlink/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package netlink

import (
"fmt"
"strings"

"github.com/vishvananda/netlink"
)
Expand Down Expand Up @@ -40,10 +41,15 @@ func (n *NetLink) RuleList(family int) (rules []Rule, err error) {
return rules, nil
}

func (n *NetLink) RuleAdd(rule Rule) error {
func (n *NetLink) RuleAdd(rule Rule) (err error) {
n.debugLogger.Debug(ruleDbgMsg(true, rule))
netlinkRule := ruleToNetlinkRule(rule)
return netlink.RuleAdd(&netlinkRule)
err = netlink.RuleAdd(&netlinkRule)
if err != nil && strings.HasSuffix(err.Error(), "file exists") {
// See https://github.com/qdm12/gluetun/issues/2521
return nil
}
return err
}

func (n *NetLink) RuleDel(rule Rule) error {
Expand Down

0 comments on commit e92d07f

Please sign in to comment.