vishvananda / netlink

Simple netlink library for go.
Apache License 2.0
2.88k stars 748 forks source link

`ipset` creation error parsing seems broken #992

Open bleggett opened 4 months ago

bleggett commented 4 months ago
  1. Manually create an ipset named my-special-ipset

  2. Run the following code:

    err := netlink.IpsetCreate("my-special-ipset, "hash:ip", netlink.IpsetCreateOptions{Comments: true, Replace: true, Family: family})
    log.Debugf("IPSET ERROR IS: %s", err)
    if err == nl.IPSetError(nl.IPSET_ERR_EXIST) {
        return nil
    }
  1. does NOT return nil, as you would expect.
  2. debug log outputs IPSET ERROR IS: file exists
bleggett commented 4 months ago

I suspect this is the result of an early return that basically skips error mapping: https://github.com/vishvananda/netlink/blob/d13535d71ed3e430e26c7538cd6266d026b26f54/ipset_linux.go#L410