netbird icon indicating copy to clipboard operation
netbird copied to clipboard

compile client under freebsd

Open skillcoder opened this issue 1 year ago • 7 comments

Describe your changes

Compile netbird client under freebsd and now support netstack and userspace modes. Refactoring linux specific code to share same code with FreeBSD, move to *_unix.go files.

Not implemented yet:

  • Kernel mode not supported
  • DNS probably does not work yet
  • Routing also probably does not work yet
  • SSH support did not tested yet
  • Lack of test environment for freebsd (dedicated VM for github runners under FreeBSD required)
  • Lack of tests for freebsd specific code
  • info reporting need to review and also implement, for example OS reported as GENERIC instead of FreeBSD (lack of FreeBSD icon in management interface)
  • Lack of proper client setup under FreeBSD
  • Lack of FreeBSD port/package

Issue ticket number and link

https://github.com/netbirdio/netbird/issues/1505

Checklist

  • [ ] Is it a bug fix
  • [ ] Is a typo/documentation fix
  • [x] Is a feature enhancement
  • [x] It is a refactor
  • [ ] Created tests that fail without the change (if possible)
  • [ ] Extended the README / documentation, if necessary

skillcoder avatar Feb 24 '24 16:02 skillcoder

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Feb 24 '24 16:02 CLAassistant

Great stuff @skillcoder! Thank you for the contribution.

P.S. Would you like to get a NetBird t-shirt? Ping me on Slack

braginini avatar Feb 26 '24 13:02 braginini

I need help from core team to setup github checks (tests, linters) for freebsd os. And seems currents test required root to run + do not cleanup all created interfaces Also need take into account following test warnings and error

time="2024-03-31T16:01:29Z" level=warning msg="the network 192.168.0.0/24 has not been assigned a routing peer as no peers from the list [peer1] are currently connected"
time="2024-03-31T16:01:29Z" level=warning msg="received a route to manage, but agent doesn't support router mode on freebsd OS"
time="2024-03-31T16:01:29Z" level=warning msg="the network 8.8.20.0/24 has not been assigned a routing peer as no peers from the list [remote1 remote1] are currently connected"
time="2024-03-31T16:01:29Z" level=error msg="this agent version: development, doesn't support default routes, received 0.0.0.0/0, skipping this route"
--- FAIL: TestAddRemoveRoutes (0.09s)
    --- FAIL: TestAddRemoveRoutes/Should_Not_Add_Or_Remove_Route_127.0.0.1/32 (0.03s)
        systemops_nonandroid_test.go:58: 
            	Error Trace:	/usr/home/jeff/github/skillcoder/netbird/client/internal/routemanager/systemops_nonandroid_test.go:58
            	Error:      	Received unexpected error:
            	            	exit status 1
            	Test:       	TestAddRemoveRoutes/Should_Not_Add_Or_Remove_Route_127.0.0.1/32
            	Messages:   	addToRouteTableIfNoExists should not return err
--- FAIL: TestAddExistAndRemoveRouteNonAndroid (0.14s)
    systemops_nonandroid_test.go:133: defaultGateway:  192.168.1.1
    --- FAIL: TestAddExistAndRemoveRouteNonAndroid/Should_Add_And_Remove_random_Route (0.02s)
        systemops_nonandroid_test.go:208: 
            	Error Trace:	/usr/home/jeff/github/skillcoder/netbird/client/internal/routemanager/systemops_nonandroid_test.go:208
            	Error:      	Should be true
            	Test:       	TestAddExistAndRemoveRouteNonAndroid/Should_Add_And_Remove_random_Route
            	Messages:   	route should exist
--- FAIL: TestExistsInRouteTable (0.00s)
    systemops_nonandroid_test.go:247: address 127.0.0.0/8 should exist in route table
FAIL
FAIL	github.com/netbirdio/netbird/client/internal/routemanager	0.445s

I did not touch routes on freebsd yet. And did not check dns management so highly likely it also does not work properly.

skillcoder avatar Apr 02 '24 18:04 skillcoder

Actually running tests locally is very risky. You MUST run them only in isolated VM. I noticed tests changed system state and keep it inconsistent. For example /etc/resolv.conf

skillcoder avatar Apr 06 '24 20:04 skillcoder

manager.go:224 needs another case for freebsd

lixmal avatar Apr 14 '24 15:04 lixmal

Hi! I tested the PR on FreeBSD and it works fine. Could you fix the conflict and then we will merge the PR?

pappz avatar May 23 '24 14:05 pappz

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

sonarqubecloud[bot] avatar May 29 '24 19:05 sonarqubecloud[bot]