Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FreeBSD kernel support #128

Merged
merged 10 commits into from
Nov 4, 2022
Prev Previous commit
Next Next commit
test: skip integration test configure_peers_update_only on FreeBSD
Signed-off-by: Steffen Vogel <post@steffenvogel.de>
  • Loading branch information
stv0g committed Oct 11, 2022
commit 846054fa57c4fac96c9063e8723a139e5d3c55b5
6 changes: 6 additions & 0 deletions client_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,12 @@ func testConfigurePeersUpdateOnly(t *testing.T, c *wgctrl.Client, d *wgtypes.Dev
}

if err := c.ConfigureDevice(d.Name, cfg); err != nil {
if d.Type == wgtypes.FreeBSDKernel && err == wgtypes.ErrUpdateOnlyNotSupported {
// TODO(stv0g): remove as soon as the FreeBSD kernel module supports it
t.Skip("FreeBSD kernel devices do not support UpdateOnly flag")
}


t.Fatalf("failed to configure second time on %q: %v", d.Name, err)
}

Expand Down
14 changes: 14 additions & 0 deletions internal/wgfreebsd/client_freebsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,20 @@ func (c *Client) Device(name string) (*wgtypes.Device, error) {

// ConfigureDevice implements wginternal.Client.
func (c *Client) ConfigureDevice(name string, cfg wgtypes.Config) error {
// Check if there is a peer with the UpdateOnly flag set.
// This is not supported on FreeBSD yet. So error out..
// TODO(stv0g): remove this check once kernel support has landed.
for _, peer := range cfg.Peers {
if peer.UpdateOnly {
// Check that this device is really an existing kernel
// device
if _, err := c.Device(name); err != os.ErrNotExist {
return wgtypes.ErrUpdateOnlyNotSupported
}
}
}


m := unparseConfig(cfg)
mem, sz, err := nv.Marshal(m)
if err != nil {
Expand Down
10 changes: 10 additions & 0 deletions wgtypes/errors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package wgtypes

import (
"errors"
)

// ErrUpdateOnlyNotSupported is returned due to missing kernel support of
// the PeerConfig UpdateOnly flag.
var ErrUpdateOnlyNotSupported = errors.New("the UpdateOnly flag is not supported by this platform")