Skip to content

Commit

Permalink
be more resilient trying to replace the interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
aojea committed Feb 19, 2024
1 parent ff53217 commit 24d362e
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,11 @@ func sync(v4net, v6net *net.IPNet) error {

log.Printf("adding eBPF nat64 prog to the interface %s", nat64If)
if err := netlink.FilterAdd(filter); err != nil {
return fmt.Errorf("replacing tc filter for interface %s: %w", link.Attrs().Name, err)
log.Printf("filter %s already exist on interface %s, replacing it ...", filter.Name, nat64If)
// it may already exist, try to replace it
if err := netlink.FilterReplace(filter); err != nil {
return fmt.Errorf("replacing tc filter for interface %s: %w", link.Attrs().Name, err)
}
}

nat46, ok := coll.Programs["nat46"]
Expand All @@ -312,7 +316,10 @@ func sync(v4net, v6net *net.IPNet) error {

log.Printf("adding eBPF nat46 prog to the interface %s", nat64If)
if err := netlink.FilterAdd(filter); err != nil {
return fmt.Errorf("replacing tc filter for interface %s: %w", link.Attrs().Name, err)
log.Printf("filter %s already exist on interface %s, replacing it ...", filter.Name, nat64If)
if err := netlink.FilterReplace(filter); err != nil {
return fmt.Errorf("replacing tc filter for interface %s: %w", link.Attrs().Name, err)
}
}

return nil
Expand Down

0 comments on commit 24d362e

Please sign in to comment.