Skip to content

Commit 74128a6

Browse files
committed
illumos/solaris support rebased onto main
1 parent 189e03e commit 74128a6

14 files changed

+461
-6
lines changed

.github/workflows/cross-illumos.yaml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: illumos-Cross
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- 'illumos-*'
8+
pull_request:
9+
branches:
10+
- '*'
11+
12+
jobs:
13+
build:
14+
runs-on: ubuntu-latest
15+
16+
if: "!contains(github.event.head_commit.message, '[ci skip]')"
17+
18+
steps:
19+
- name: Check out code
20+
uses: actions/checkout@v3
21+
with:
22+
fetch-depth: 0
23+
24+
- name: Set up Go
25+
uses: actions/setup-go@v4
26+
with:
27+
go-version-file: 'go.mod'
28+
check-latest: true
29+
id: go
30+
31+
- name: SunOS build script
32+
run: bash -x build.sh
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
---
2+
name: "tagged-release"
3+
4+
on:
5+
push:
6+
tags:
7+
- "v*-sunos"
8+
9+
jobs:
10+
tagged-release:
11+
name: "SunOS Tagged Release"
12+
runs-on: "ubuntu-latest"
13+
14+
steps:
15+
- name: Check out code
16+
uses: actions/checkout@v3
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Set up Go
21+
uses: actions/setup-go@v4
22+
with:
23+
go-version-file: 'go.mod'
24+
check-latest: true
25+
id: go
26+
27+
- name: SunOS build script
28+
run: bash -x build.sh
29+
30+
- name: Create Release
31+
uses: "marvinpinto/action-automatic-releases@latest"
32+
with:
33+
repo_token: "${{ secrets.GITHUB_TOKEN }}"
34+
prerelease: false
35+
files: |
36+
cmd/tailscaled/tailscale.xml
37+
sha256sums
38+
tailscaled-illumos
39+
tailscaled-solaris

AUTHORS

+1
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@
1515
# company that owns the rights to your contribution.
1616

1717
Tailscale Inc.
18+
Nahum Shalman <[email protected]>

build.sh

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
3+
set -o xtrace
4+
set -o errexit
5+
6+
export TS_USE_TOOLCHAIN=true
7+
# This prevents illumos libc from leaking into Solaris binaries when built on illumos
8+
export CGO_ENABLED=0
9+
10+
fix_osabi () {
11+
if [[ $(uname -s) == SunOS ]]; then
12+
/usr/bin/elfedit \
13+
-e "ehdr:ei_osabi ELFOSABI_SOLARIS" \
14+
-e "ehdr:ei_abiversion EAV_SUNW_CURRENT" \
15+
"${1?}"
16+
else
17+
elfedit --output-osabi "Solaris" --output-abiversion "1" "${1?}"
18+
fi
19+
}
20+
21+
for GOOS in illumos solaris; do
22+
export GOOS
23+
bash -x ./build_dist.sh --box ./cmd/tailscaled
24+
fix_osabi tailscaled
25+
mv tailscaled{,-${GOOS}}
26+
done
27+
28+
ln cmd/tailscaled/tailscale.xml .
29+
shasum -a 256 tailscaled-* tailscale.xml >sha256sums
30+
rm ./tailscale.xml
+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version='1.0'?>
2+
<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
3+
<service_bundle type='manifest' name='export'>
4+
<service name='vpn/tailscale' type='service' version='0'>
5+
<create_default_instance enabled='true'/>
6+
<single_instance/>
7+
<dependency name='network' grouping='require_all' restart_on='error' type='service'>
8+
<service_fmri value='svc:/milestone/network:default'/>
9+
</dependency>
10+
<dependency name='filesystem' grouping='require_all' restart_on='error' type='service'>
11+
<service_fmri value='svc:/system/filesystem/local'/>
12+
</dependency>
13+
<method_context>
14+
<method_credential group='root' user='root'/>
15+
</method_context>
16+
<exec_method name='start' type='method' exec='/opt/local/sbin/tailscaled' timeout_seconds='60'>
17+
<method_context>
18+
<method_environment>
19+
<envvar name='SSL_CERT_FILE' value='/opt/tools/share/mozilla-rootcerts/cacert.pem'/>
20+
</method_environment>
21+
</method_context>
22+
</exec_method>
23+
<exec_method name='stop' type='method' exec=':kill' timeout_seconds='60'/>
24+
<property_group name='application' type='application'/>
25+
<property_group name='startd' type='framework'>
26+
<propval name='duration' type='astring' value='child'/>
27+
<propval name='ignore_error' type='astring' value='core,signal'/>
28+
</property_group>
29+
<stability value='Evolving'/>
30+
<template>
31+
<common_name>
32+
<loctext xml:lang='C'>Tailscale</loctext>
33+
</common_name>
34+
</template>
35+
</service>
36+
</service_bundle>

cmd/tailscaled/tailscale.xml

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version='1.0'?>
2+
<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
3+
<service_bundle type='manifest' name='export'>
4+
<service name='vpn/tailscale' type='service' version='0'>
5+
<create_default_instance enabled='true'/>
6+
<single_instance/>
7+
<dependency name='network' grouping='require_all' restart_on='error' type='service'>
8+
<service_fmri value='svc:/milestone/network:default'/>
9+
</dependency>
10+
<dependency name='filesystem' grouping='require_all' restart_on='error' type='service'>
11+
<service_fmri value='svc:/system/filesystem/local'/>
12+
</dependency>
13+
<method_context>
14+
<method_credential group='root' user='root'/>
15+
</method_context>
16+
<exec_method name='start' type='method' exec='/usr/local/sbin/tailscaled' timeout_seconds='60'/>
17+
<exec_method name='stop' type='method' exec=':kill' timeout_seconds='60'/>
18+
<property_group name='application' type='application'/>
19+
<property_group name='startd' type='framework'>
20+
<propval name='duration' type='astring' value='child'/>
21+
<propval name='ignore_error' type='astring' value='core,signal'/>
22+
</property_group>
23+
<stability value='Evolving'/>
24+
<template>
25+
<common_name>
26+
<loctext xml:lang='C'>Tailscale</loctext>
27+
</common_name>
28+
</template>
29+
</service>
30+
</service_bundle>

cmd/tailscaled/tailscaled.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ import (
7474
// defaultTunName returns the default tun device name for the platform.
7575
func defaultTunName() string {
7676
switch runtime.GOOS {
77-
case "openbsd":
77+
case "openbsd", "illumos", "solaris":
7878
return "tun"
7979
case "windows":
8080
return "Tailscale"
@@ -84,7 +84,7 @@ func defaultTunName() string {
8484
return "utun"
8585
case "plan9":
8686
return "auto"
87-
case "aix", "solaris", "illumos":
87+
case "aix":
8888
return "userspace-networking"
8989
case "linux":
9090
switch distro.Get() {

go.mod

+2
Original file line numberDiff line numberDiff line change
@@ -410,3 +410,5 @@ require (
410410
sigs.k8s.io/json v0.0.0-20241010143419-9aa6b5e7a4b3 // indirect
411411
sigs.k8s.io/structured-merge-diff/v4 v4.4.2 // indirect
412412
)
413+
414+
replace github.com/tailscale/wireguard-go => github.com/nshalman/wireguard-go v0.0.20200321-0.20250114140547-94bec3171972

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -748,6 +748,8 @@ github.com/nishanths/exhaustive v0.12.0 h1:vIY9sALmw6T/yxiASewa4TQcFsVYZQQRUQJhK
748748
github.com/nishanths/exhaustive v0.12.0/go.mod h1:mEZ95wPIZW+x8kC4TgC+9YCUgiST7ecevsVDTgc2obs=
749749
github.com/nishanths/predeclared v0.2.2 h1:V2EPdZPliZymNAn79T8RkNApBjMmVKh5XRpLm/w98Vk=
750750
github.com/nishanths/predeclared v0.2.2/go.mod h1:RROzoN6TnGQupbC+lqggsOlcgysk3LMK/HI84Mp280c=
751+
github.com/nshalman/wireguard-go v0.0.20200321-0.20250114140547-94bec3171972 h1:BzBBQHKXmdv6L2qivoRY2cz06R0REDlkc/JrPDXsHC4=
752+
github.com/nshalman/wireguard-go v0.0.20200321-0.20250114140547-94bec3171972/go.mod h1:BOm5fXUBFM+m9woLNBoxI9TaBXXhGNP50LX/TGIvGb4=
751753
github.com/nunnatsa/ginkgolinter v0.16.1 h1:uDIPSxgVHZ7PgbJElRDGzymkXH+JaF7mjew+Thjnt6Q=
752754
github.com/nunnatsa/ginkgolinter v0.16.1/go.mod h1:4tWRinDN1FeJgU+iJANW/kz7xKN5nYRAOfJDQUS9dOQ=
753755
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
@@ -963,8 +965,6 @@ github.com/tailscale/web-client-prebuilt v0.0.0-20250124233751-d4cd19a26976 h1:U
963965
github.com/tailscale/web-client-prebuilt v0.0.0-20250124233751-d4cd19a26976/go.mod h1:agQPE6y6ldqCOui2gkIh7ZMztTkIQKH049tv8siLuNQ=
964966
github.com/tailscale/wf v0.0.0-20240214030419-6fbb0a674ee6 h1:l10Gi6w9jxvinoiq15g8OToDdASBni4CyJOdHY1Hr8M=
965967
github.com/tailscale/wf v0.0.0-20240214030419-6fbb0a674ee6/go.mod h1:ZXRML051h7o4OcI0d3AaILDIad/Xw0IkXaHM17dic1Y=
966-
github.com/tailscale/wireguard-go v0.0.0-20250304000100-91a0587fb251 h1:h/41LFTrwMxB9Xvvug0kRdQCU5TlV1+pAMQw0ZtDE3U=
967-
github.com/tailscale/wireguard-go v0.0.0-20250304000100-91a0587fb251/go.mod h1:BOm5fXUBFM+m9woLNBoxI9TaBXXhGNP50LX/TGIvGb4=
968968
github.com/tailscale/xnet v0.0.0-20240729143630-8497ac4dab2e h1:zOGKqN5D5hHhiYUp091JqK7DPCqSARyUfduhGUY8Bek=
969969
github.com/tailscale/xnet v0.0.0-20240729143630-8497ac4dab2e/go.mod h1:orPd6JZXXRyuDusYilywte7k094d7dycXXU5YnWsrwg=
970970
github.com/tc-hib/winres v0.2.1 h1:YDE0FiP0VmtRaDn7+aaChp1KiF4owBiJa5l964l5ujA=

net/tstun/tstun_stub.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Tailscale Inc & AUTHORS
22
// SPDX-License-Identifier: BSD-3-Clause
33

4-
//go:build aix || solaris || illumos
4+
//go:build aix
55

66
package tstun
77

net/tstun/tun.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Copyright (c) Tailscale Inc & AUTHORS
22
// SPDX-License-Identifier: BSD-3-Clause
33

4-
//go:build !wasm && !tamago && !aix && !solaris && !illumos
4+
//go:build !wasm && !tamago && !aix
55

66
// Package tun creates a tuntap device, working around OS-specific
77
// quirks if necessary.

tool/go

+6
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,10 @@
44
# currently-desired version from https://github.com/tailscale/go,
55
# downloading it first if necessary.
66

7+
case $(uname -s) in
8+
SunOS)
9+
exec go "$@"
10+
;;
11+
esac
12+
713
exec "$(dirname "$0")/../tool/gocross/gocross-wrapper.sh" "$@"

wgengine/router/router_solaris.go

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Copyright (c) Tailscale Inc & AUTHORS
2+
// SPDX-License-Identifier: BSD-3-Clause
3+
4+
package router
5+
6+
import (
7+
"strings"
8+
9+
"github.com/tailscale/wireguard-go/tun"
10+
"tailscale.com/health"
11+
"tailscale.com/net/netmon"
12+
"tailscale.com/types/logger"
13+
)
14+
15+
// For now this router only supports the userspace WireGuard implementations.
16+
17+
func newUserspaceRouter(logf logger.Logf, tundev tun.Device, linkMon *netmon.Monitor, health *health.Tracker) (Router, error) {
18+
return newUserspaceSunosRouter(logf, tundev, linkMon, health)
19+
}
20+
21+
func cleanUp(logf logger.Logf, interfaceName string) {
22+
ipadm := []string{"ipadm", "show-addr", "-p", "-o", "addrobj"}
23+
out, err := cmd(ipadm...).Output()
24+
if err != nil {
25+
logf("ipadm show-addr: %v\n%s", err, out)
26+
}
27+
for _, a := range strings.Fields(string(out)) {
28+
s := strings.Split(a, "/")
29+
if len(s) > 1 && strings.Contains(s[1], "tailscale") {
30+
ipadm = []string{"ipadm", "down-addr", "-t", a}
31+
cmdVerbose(logf, ipadm)
32+
ipadm = []string{"ipadm", "delete-addr", a}
33+
cmdVerbose(logf, ipadm)
34+
ipadm = []string{"ipadm", "delete-if", s[0]}
35+
cmdVerbose(logf, ipadm)
36+
}
37+
}
38+
ifcfg := []string{"ifconfig", interfaceName, "unplumb"}
39+
if out, err := cmd(ifcfg...).CombinedOutput(); err != nil {
40+
logf("ifconfig unplumb: %v\n%s", err, out)
41+
}
42+
ifcfg = []string{"ifconfig", interfaceName, "inet6", "unplumb"}
43+
if out, err := cmd(ifcfg...).CombinedOutput(); err != nil {
44+
logf("ifconfig inet6 unplumb: %v\n%s", err, out)
45+
}
46+
}

0 commit comments

Comments
 (0)