Skip to content

Commit

Permalink
fix route deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
anitgandhi committed Dec 12, 2024
1 parent dac9cde commit f6a2851
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions internal/reservedipv6/reserved_ipv6.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,12 @@ func (m *mgr) Unassign() error {
}
}

// remove the default route if it existed
route := defaultIPv6Route(m.eth0Idx)
if _, err := m.nlConn.Route.Get(route); err != nil {
fmt.Errorf("failed to check if default IPv6 route already exists: %w", err)
}
if err := m.nlConn.Route.Delete(defaultIPv6Route(m.eth0Idx)); err != nil {
return fmt.Errorf("failed to remove default IPv6 route on %s: %w", eth0Iface, err)
if _, err := m.nlConn.Route.Get(route); err == nil {
if err := m.nlConn.Route.Delete(route); err != nil {
return fmt.Errorf("failed to remove default IPv6 route on %s: %w", eth0Iface, err)
}
}

return nil
Expand Down

0 comments on commit f6a2851

Please sign in to comment.