WireGuard / wgctrl-go

Package wgctrl enables control of WireGuard interfaces on multiple platforms.
https://godoc.org/golang.zx2c4.com/wireguard/wgctrl
MIT License
753 stars 84 forks source link

Deleting 400 keys takes 10 seconds #95

Closed g00nix closed 3 years ago

g00nix commented 4 years ago

Here is the code I use to delete keys:

    peers := []wgtypes.PeerConfig{}
    peers = append(peers, wgtypes.PeerConfig{
        PublicKey: p.PublicKey,
        Remove:    true,
    })
    newConfig := wgtypes.Config{
        ReplacePeers: false,
        Peers:        peers,
    }
    err := c.ConfigureDevice(wgI.Name(), newConfig)

I've been running some unit tests and I saw that deletion takes more time than expected. I can add 1000 keys in 1 second, however deleting 400 keys takes 10 seconds and deleting 1000 keys takes 30 seconds.

Is this behavior normal? Can the deletion time be reduced?

mdlayher commented 3 years ago

This library doesn't have to do much work to issue a command to the kernel, so if deleting keys is slow, I would contact the mailing list to see if there are known limitations or areas for improvement in this regard. Closing.