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

compile client under freebsd #1620

Merged
merged 40 commits into from
May 30, 2024
Merged

Conversation

skillcoder
Copy link

@skillcoder skillcoder commented Feb 24, 2024

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

#1505

Checklist

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

@CLAassistant
Copy link

CLAassistant commented Feb 24, 2024

CLA assistant check
All committers have signed the CLA.

@braginini
Copy link
Contributor

Great stuff @skillcoder! Thank you for the contribution.

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

@skillcoder skillcoder marked this pull request as ready for review March 31, 2024 20:00
@skillcoder
Copy link
Author

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
Copy link
Author

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 skillcoder force-pushed the freebsd-client branch 3 times, most recently from cb64609 to bb25bb0 Compare April 12, 2024 19:17
@lixmal
Copy link
Contributor

lixmal commented Apr 14, 2024

manager.go:224 needs another case for freebsd

@pappz
Copy link
Contributor

pappz commented May 23, 2024

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

@mlsmaycon mlsmaycon changed the base branch from main to 0.28.0 May 23, 2024 18:35
Copy link

sonarcloud bot commented May 29, 2024

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

@pappz pappz merged commit e070f37 into netbirdio:0.28.0 May 30, 2024
24 checks passed
pascal-fischer pushed a commit that referenced this pull request May 31, 2024
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants