conlink 2.0.0 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Dockerfile +2 -1
- package/README.md +18 -14
- package/examples/net2dot.yaml +2 -2
- package/examples/test4-multiple/modes/all/deps +1 -0
- package/examples/test4-multiple/{base-compose.yaml → modes/base/compose.yaml} +3 -3
- package/examples/test4-multiple/{node1-compose.yaml → modes/node1/compose.yaml} +0 -3
- package/examples/test4-multiple/modes/node1/deps +1 -0
- package/examples/test4-multiple/{nodes2-compose.yaml → modes/nodes2/compose.yaml} +0 -5
- package/examples/test4-multiple/modes/nodes2/deps +1 -0
- package/examples/test4-multiple/modes/web/compose.yaml +5 -0
- package/examples/test4-multiple/modes/web/deps +1 -0
- package/examples/test6-cfn.yaml +1 -2
- package/mdc +108 -0
- package/net2dot +1 -1
- package/net2dot.cljs +113 -0
- package/package.json +6 -1
- package/scripts/copy.sh +48 -0
- package/scripts/wait.sh +73 -0
- package/shadow-cljs.edn +1 -1
- package/src/conlink/addrs.cljc +3 -0
- package/src/conlink/core.cljs +21 -7
- package/src/conlink/util.cljs +13 -2
- package/TODO +0 -34
- package/examples/test4-multiple/all-compose.yaml +0 -5
- package/examples/test4-multiple/web-network.yaml +0 -2
- package/host-build.yaml +0 -1
- package/inspect.json +0 -210
- package/notes.txt +0 -82
- package/old/Dockerfile.bak +0 -26
- package/old/add-link.sh +0 -82
- package/old/conlink +0 -12
- package/old/conlink.cljs +0 -131
- package/old/dot_gitignore +0 -1
- package/old/examples/test2-compose.yaml +0 -32
- package/old/examples/test2-network.yaml +0 -42
- package/old/move-link.sh +0 -108
- package/old/net2dot.py +0 -122
- package/old/notes-old.txt +0 -97
- package/old/package.json +0 -16
- package/old/schema.yaml +0 -138
- package/old/schema.yaml.bak +0 -76
- package/old/test2b-compose.yaml +0 -18
- package/old/veth-link.sh +0 -96
- package/schema-ish.yaml +0 -29
- package/src/conlink/net2dot.cljs +0 -158
- package/tests/invalid-schema-1.yaml +0 -6
- package/tests/invalid-schema-2.yaml +0 -6
- package/tests/invalid-schema-3.yaml +0 -17
- package/tests/invalid-schema-4.yaml +0 -14
- package/tests/invalid-schema-5.yaml +0 -12
- package/tests/invalid-schema-6.yaml +0 -12
- package/tmp/conlink/.env +0 -1
package/src/conlink/util.cljs
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
;; Copyright (c) 2023, Viasat, Inc
|
|
2
|
+
;; Licensed under MPL 2.0
|
|
3
|
+
|
|
1
4
|
(ns conlink.util
|
|
2
5
|
(:require [cljs.pprint :refer [pprint]]
|
|
3
6
|
[clojure.string :as S]
|
|
@@ -7,6 +10,7 @@
|
|
|
7
10
|
[cljs-bean.core :refer [->clj]]
|
|
8
11
|
["util" :refer [promisify]]
|
|
9
12
|
["fs" :as fs]
|
|
13
|
+
["path" :as path]
|
|
10
14
|
["child_process" :as cp]
|
|
11
15
|
["neodoc" :as neodoc]))
|
|
12
16
|
|
|
@@ -84,8 +88,8 @@
|
|
|
84
88
|
(condp = sep
|
|
85
89
|
":-" (if unset-or-null? value (get env braced))
|
|
86
90
|
"-" (if unset? value (get env braced))
|
|
87
|
-
":?" (
|
|
88
|
-
"?" (
|
|
91
|
+
":?" (if unset-or-null? (throw (js/Error value)) (get env braced))
|
|
92
|
+
"?" (if unset? (throw (js/Error value)) (get env braced))))
|
|
89
93
|
braced (get env braced "")
|
|
90
94
|
invalid (str "$" invalid)))))
|
|
91
95
|
|
|
@@ -138,3 +142,10 @@
|
|
|
138
142
|
(edn/read-string raw))]
|
|
139
143
|
(->clj cfg)))
|
|
140
144
|
|
|
145
|
+
(defn resolve-path
|
|
146
|
+
"Resolve 'path' using 'dirs'. If 'path' is absolute, return 'path',
|
|
147
|
+
otherwise search 'dirs' for 'path' and return resolved path.
|
|
148
|
+
Note, this uses fs/existsSync so it's more suited for startup time."
|
|
149
|
+
[path dirs]
|
|
150
|
+
(first (filter fs/existsSync
|
|
151
|
+
(map #(path/join % path) (concat ["/"] dirs)))))
|
package/TODO
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
- MVP for ViaBox:
|
|
2
|
-
- [x] compose/x-network file loading
|
|
3
|
-
- [x] multiple config sources and merging
|
|
4
|
-
- [x] link route config
|
|
5
|
-
- [x] filtering on project and workdir
|
|
6
|
-
- [x] interface and MAC iteration
|
|
7
|
-
- [x] variable templating
|
|
8
|
-
- [x] *vlan type interfaces
|
|
9
|
-
|
|
10
|
-
- Near term:
|
|
11
|
-
- [x] dummy interfaces
|
|
12
|
-
- [x] arbitrary container commands
|
|
13
|
-
- [x] schema validation
|
|
14
|
-
- [x] code comments/documentation
|
|
15
|
-
- [x] tunnel interfaces
|
|
16
|
-
- [x] tc/qdisc settings
|
|
17
|
-
- [x] fix/test all examples (6 and 9 remaining)
|
|
18
|
-
- [x] add net2dot
|
|
19
|
-
- [ ] add outer-netem (and match all link-add params to link keys)
|
|
20
|
-
|
|
21
|
-
- Further term:
|
|
22
|
-
- [ ] CNI networking support
|
|
23
|
-
- conlink runs in container listening for events on a UDS
|
|
24
|
-
(intead of docker events)
|
|
25
|
-
- an outer conlink command is the CNI client that formats
|
|
26
|
-
events to send over the UDS to the inner conlink
|
|
27
|
-
- [ ] multiple routes
|
|
28
|
-
- [ ] ovs flow config
|
|
29
|
-
- [ ] Multiple bridge-modes
|
|
30
|
-
- bridge-mode as part of the domain definition so that the
|
|
31
|
-
same conlink instances can support multiple bridge modes
|
|
32
|
-
simultaneously (with a default for links that don't
|
|
33
|
-
specify).
|
|
34
|
-
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
version: "2.4"
|
|
2
|
-
|
|
3
|
-
services:
|
|
4
|
-
network:
|
|
5
|
-
command: /app/build/conlink.js --compose-file ${COMPOSE_FILE:-examples/test4-multiple/base-compose.yaml:examples/test4-multiple/node1-compose.yaml:examples/test4-multiple/nodes2.yaml:examples/test4-multiple/all-compose.yaml} --network-file examples/test4-multiple/web-network.yaml
|
package/host-build.yaml
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
services: {network: {volumes: ["../build:/app/build"]}}
|
package/inspect.json
DELETED
|
@@ -1,210 +0,0 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"Id": "43e63a3c948443f55198f4de29fd96805fdb306398ff64d89f1103c355e28357",
|
|
4
|
-
"Created": "2023-10-11T15:55:04.428835024Z",
|
|
5
|
-
"Path": "sh",
|
|
6
|
-
"Args": [
|
|
7
|
-
"-c",
|
|
8
|
-
"while ! ip link show eth0 up; do sleep 1; done; sleep 864000"
|
|
9
|
-
],
|
|
10
|
-
"State": {
|
|
11
|
-
"Status": "running",
|
|
12
|
-
"Running": true,
|
|
13
|
-
"Paused": false,
|
|
14
|
-
"Restarting": false,
|
|
15
|
-
"OOMKilled": false,
|
|
16
|
-
"Dead": false,
|
|
17
|
-
"Pid": 10216,
|
|
18
|
-
"ExitCode": 0,
|
|
19
|
-
"Error": "",
|
|
20
|
-
"StartedAt": "2023-10-11T15:55:04.576997181Z",
|
|
21
|
-
"FinishedAt": "0001-01-01T00:00:00Z"
|
|
22
|
-
},
|
|
23
|
-
"Image": "sha256:8ca4688f4f356596b5ae539337c9941abc78eda10021d35cbc52659c74d9b443",
|
|
24
|
-
"ResolvConfPath": "/var/lib/docker/containers/43e63a3c948443f55198f4de29fd96805fdb306398ff64d89f1103c355e28357/resolv.conf",
|
|
25
|
-
"HostnamePath": "/var/lib/docker/containers/43e63a3c948443f55198f4de29fd96805fdb306398ff64d89f1103c355e28357/hostname",
|
|
26
|
-
"HostsPath": "/var/lib/docker/containers/43e63a3c948443f55198f4de29fd96805fdb306398ff64d89f1103c355e28357/hosts",
|
|
27
|
-
"LogPath": "/var/lib/docker/containers/43e63a3c948443f55198f4de29fd96805fdb306398ff64d89f1103c355e28357/43e63a3c948443f55198f4de29fd96805fdb306398ff64d89f1103c355e28357-json.log",
|
|
28
|
-
"Name": "/examples_node2_1",
|
|
29
|
-
"RestartCount": 0,
|
|
30
|
-
"Driver": "overlay2",
|
|
31
|
-
"Platform": "linux",
|
|
32
|
-
"MountLabel": "",
|
|
33
|
-
"ProcessLabel": "",
|
|
34
|
-
"AppArmorProfile": "docker-default",
|
|
35
|
-
"ExecIDs": null,
|
|
36
|
-
"HostConfig": {
|
|
37
|
-
"Binds": [],
|
|
38
|
-
"ContainerIDFile": "",
|
|
39
|
-
"LogConfig": {
|
|
40
|
-
"Type": "json-file",
|
|
41
|
-
"Config": {}
|
|
42
|
-
},
|
|
43
|
-
"NetworkMode": "none",
|
|
44
|
-
"PortBindings": {},
|
|
45
|
-
"RestartPolicy": {
|
|
46
|
-
"Name": "",
|
|
47
|
-
"MaximumRetryCount": 0
|
|
48
|
-
},
|
|
49
|
-
"AutoRemove": false,
|
|
50
|
-
"VolumeDriver": "",
|
|
51
|
-
"VolumesFrom": [],
|
|
52
|
-
"ConsoleSize": [
|
|
53
|
-
0,
|
|
54
|
-
0
|
|
55
|
-
],
|
|
56
|
-
"CapAdd": [
|
|
57
|
-
"NET_ADMIN"
|
|
58
|
-
],
|
|
59
|
-
"CapDrop": null,
|
|
60
|
-
"CgroupnsMode": "host",
|
|
61
|
-
"Dns": null,
|
|
62
|
-
"DnsOptions": null,
|
|
63
|
-
"DnsSearch": null,
|
|
64
|
-
"ExtraHosts": null,
|
|
65
|
-
"GroupAdd": null,
|
|
66
|
-
"IpcMode": "private",
|
|
67
|
-
"Cgroup": "",
|
|
68
|
-
"Links": null,
|
|
69
|
-
"OomScoreAdj": 0,
|
|
70
|
-
"PidMode": "",
|
|
71
|
-
"Privileged": false,
|
|
72
|
-
"PublishAllPorts": false,
|
|
73
|
-
"ReadonlyRootfs": false,
|
|
74
|
-
"SecurityOpt": null,
|
|
75
|
-
"UTSMode": "",
|
|
76
|
-
"UsernsMode": "",
|
|
77
|
-
"ShmSize": 67108864,
|
|
78
|
-
"Runtime": "runc",
|
|
79
|
-
"Isolation": "",
|
|
80
|
-
"CpuShares": 0,
|
|
81
|
-
"Memory": 0,
|
|
82
|
-
"NanoCpus": 0,
|
|
83
|
-
"CgroupParent": "",
|
|
84
|
-
"BlkioWeight": 0,
|
|
85
|
-
"BlkioWeightDevice": null,
|
|
86
|
-
"BlkioDeviceReadBps": null,
|
|
87
|
-
"BlkioDeviceWriteBps": null,
|
|
88
|
-
"BlkioDeviceReadIOps": null,
|
|
89
|
-
"BlkioDeviceWriteIOps": null,
|
|
90
|
-
"CpuPeriod": 0,
|
|
91
|
-
"CpuQuota": 0,
|
|
92
|
-
"CpuRealtimePeriod": 0,
|
|
93
|
-
"CpuRealtimeRuntime": 0,
|
|
94
|
-
"CpusetCpus": "",
|
|
95
|
-
"CpusetMems": "",
|
|
96
|
-
"Devices": null,
|
|
97
|
-
"DeviceCgroupRules": null,
|
|
98
|
-
"DeviceRequests": null,
|
|
99
|
-
"MemoryReservation": 0,
|
|
100
|
-
"MemorySwap": 0,
|
|
101
|
-
"MemorySwappiness": null,
|
|
102
|
-
"OomKillDisable": false,
|
|
103
|
-
"PidsLimit": null,
|
|
104
|
-
"Ulimits": null,
|
|
105
|
-
"CpuCount": 0,
|
|
106
|
-
"CpuPercent": 0,
|
|
107
|
-
"IOMaximumIOps": 0,
|
|
108
|
-
"IOMaximumBandwidth": 0,
|
|
109
|
-
"MaskedPaths": [
|
|
110
|
-
"/proc/asound",
|
|
111
|
-
"/proc/acpi",
|
|
112
|
-
"/proc/kcore",
|
|
113
|
-
"/proc/keys",
|
|
114
|
-
"/proc/latency_stats",
|
|
115
|
-
"/proc/timer_list",
|
|
116
|
-
"/proc/timer_stats",
|
|
117
|
-
"/proc/sched_debug",
|
|
118
|
-
"/proc/scsi",
|
|
119
|
-
"/sys/firmware"
|
|
120
|
-
],
|
|
121
|
-
"ReadonlyPaths": [
|
|
122
|
-
"/proc/bus",
|
|
123
|
-
"/proc/fs",
|
|
124
|
-
"/proc/irq",
|
|
125
|
-
"/proc/sys",
|
|
126
|
-
"/proc/sysrq-trigger"
|
|
127
|
-
]
|
|
128
|
-
},
|
|
129
|
-
"GraphDriver": {
|
|
130
|
-
"Data": {
|
|
131
|
-
"LowerDir": "/var/lib/docker/overlay2/f45757baf87c92f0934409fa9617bd4027e1e4472711312b1d8145ca59cdf0f3-init/diff:/var/lib/docker/overlay2/0ee1adfcd9b69bb9354db86819da1c06904d5c664f8d9e0aded8c158a24654df/diff",
|
|
132
|
-
"MergedDir": "/var/lib/docker/overlay2/f45757baf87c92f0934409fa9617bd4027e1e4472711312b1d8145ca59cdf0f3/merged",
|
|
133
|
-
"UpperDir": "/var/lib/docker/overlay2/f45757baf87c92f0934409fa9617bd4027e1e4472711312b1d8145ca59cdf0f3/diff",
|
|
134
|
-
"WorkDir": "/var/lib/docker/overlay2/f45757baf87c92f0934409fa9617bd4027e1e4472711312b1d8145ca59cdf0f3/work"
|
|
135
|
-
},
|
|
136
|
-
"Name": "overlay2"
|
|
137
|
-
},
|
|
138
|
-
"Mounts": [],
|
|
139
|
-
"Config": {
|
|
140
|
-
"Hostname": "43e63a3c9484",
|
|
141
|
-
"Domainname": "",
|
|
142
|
-
"User": "",
|
|
143
|
-
"AttachStdin": false,
|
|
144
|
-
"AttachStdout": false,
|
|
145
|
-
"AttachStderr": false,
|
|
146
|
-
"Tty": false,
|
|
147
|
-
"OpenStdin": false,
|
|
148
|
-
"StdinOnce": false,
|
|
149
|
-
"Env": [
|
|
150
|
-
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
|
|
151
|
-
],
|
|
152
|
-
"Cmd": [
|
|
153
|
-
"sh",
|
|
154
|
-
"-c",
|
|
155
|
-
"while ! ip link show eth0 up; do sleep 1; done; sleep 864000"
|
|
156
|
-
],
|
|
157
|
-
"Image": "alpine",
|
|
158
|
-
"Volumes": null,
|
|
159
|
-
"WorkingDir": "",
|
|
160
|
-
"Entrypoint": null,
|
|
161
|
-
"OnBuild": null,
|
|
162
|
-
"Labels": {
|
|
163
|
-
"com.docker.compose.config-hash": "be458eaf2e2aba67235023be9f8342d88ce0e0f7979749d6496423229a954bd3",
|
|
164
|
-
"com.docker.compose.container-number": "1",
|
|
165
|
-
"com.docker.compose.oneoff": "False",
|
|
166
|
-
"com.docker.compose.project": "examples",
|
|
167
|
-
"com.docker.compose.project.config_files": "examples/test2-compose.yaml",
|
|
168
|
-
"com.docker.compose.project.working_dir": "/home/jmartin/work/viasat/repos/conlink.cljs/examples",
|
|
169
|
-
"com.docker.compose.service": "node2",
|
|
170
|
-
"com.docker.compose.version": "1.29.2"
|
|
171
|
-
}
|
|
172
|
-
},
|
|
173
|
-
"NetworkSettings": {
|
|
174
|
-
"Bridge": "",
|
|
175
|
-
"SandboxID": "963251cd8230a51e9c658653a3fdeedfe10e9f16c03aed802b69d5a6c86f6d19",
|
|
176
|
-
"HairpinMode": false,
|
|
177
|
-
"LinkLocalIPv6Address": "",
|
|
178
|
-
"LinkLocalIPv6PrefixLen": 0,
|
|
179
|
-
"Ports": {},
|
|
180
|
-
"SandboxKey": "/var/run/docker/netns/963251cd8230",
|
|
181
|
-
"SecondaryIPAddresses": null,
|
|
182
|
-
"SecondaryIPv6Addresses": null,
|
|
183
|
-
"EndpointID": "",
|
|
184
|
-
"Gateway": "",
|
|
185
|
-
"GlobalIPv6Address": "",
|
|
186
|
-
"GlobalIPv6PrefixLen": 0,
|
|
187
|
-
"IPAddress": "",
|
|
188
|
-
"IPPrefixLen": 0,
|
|
189
|
-
"IPv6Gateway": "",
|
|
190
|
-
"MacAddress": "",
|
|
191
|
-
"Networks": {
|
|
192
|
-
"none": {
|
|
193
|
-
"IPAMConfig": null,
|
|
194
|
-
"Links": null,
|
|
195
|
-
"Aliases": null,
|
|
196
|
-
"NetworkID": "c7b50bdae4d8c2baa2dfbfcf81a783cddcfd66df84c6ce3f3506985434a161c8",
|
|
197
|
-
"EndpointID": "376d2c90a9e33a6e0fd62dc3f67c6f784d717594b54ebbb7e9d4d372ee0cf115",
|
|
198
|
-
"Gateway": "",
|
|
199
|
-
"IPAddress": "",
|
|
200
|
-
"IPPrefixLen": 0,
|
|
201
|
-
"IPv6Gateway": "",
|
|
202
|
-
"GlobalIPv6Address": "",
|
|
203
|
-
"GlobalIPv6PrefixLen": 0,
|
|
204
|
-
"MacAddress": "",
|
|
205
|
-
"DriverOpts": null
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
]
|
package/notes.txt
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
- Also see schema-ish.yaml
|
|
2
|
-
links:
|
|
3
|
-
- type: TYPE # Default: 'veth'
|
|
4
|
-
# Others: '*vlan/*vtap', 'dummy', 'tunnel', etc
|
|
5
|
-
|
|
6
|
-
container: FOO # full container name
|
|
7
|
-
# OR
|
|
8
|
-
service: FOO # compose service name
|
|
9
|
-
|
|
10
|
-
bridge: BRIDGE # name of OVS or linux bridge
|
|
11
|
-
|
|
12
|
-
base: BASE # 'conlink', 'host', or 'local'
|
|
13
|
-
# 'conlink' is default for 'type: veth'
|
|
14
|
-
# 'host' is default for 'type: *vlan/*vtap'
|
|
15
|
-
|
|
16
|
-
dev: DEV # internal container device/interface name
|
|
17
|
-
outer-dev: DEV # conlink or host (*vlan) device/interface name
|
|
18
|
-
|
|
19
|
-
# --- optional general ---
|
|
20
|
-
|
|
21
|
-
ip(s): IP # starting address, can include net slash to limit max
|
|
22
|
-
mac: MAC
|
|
23
|
-
mtu: MTU
|
|
24
|
-
route(s): ROUTE # `ip route add ROUTE`, maybe add "dev INTF" automatically
|
|
25
|
-
tc(s): TC # tc/qdisc commands/settings
|
|
26
|
-
flow(s): FLOW # `ovs-ofctl add-flow DOMAIN FLOW`. With var templating.
|
|
27
|
-
command(s): CMD # arbitrary shell cmd. After all links setup for this container
|
|
28
|
-
|
|
29
|
-
# --- optional for 'type: *vlan/*vtap' ---
|
|
30
|
-
|
|
31
|
-
mode: MODE # 'bridge', etc
|
|
32
|
-
vlanid: VLANID # VLAN #
|
|
33
|
-
nat: NAT # nat target
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
- type maps to 'ip link' type with default of 'veth'
|
|
37
|
-
- when type is 'veth', then base default is 'conlink'
|
|
38
|
-
- when type is 'veth' and base is 'conlink', then bridge is required.
|
|
39
|
-
|
|
40
|
-
- conlink veth link: {type: veth [DEFAULT], base: conlink [DEFAULT], bridge: BRIDGE, dev: DEV}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
Dependencies in python version:
|
|
45
|
-
- argparse
|
|
46
|
-
- shlex (parsing commands)
|
|
47
|
-
- compose_interpolation import TemplateWithDefaults
|
|
48
|
-
- cerberus import Validator
|
|
49
|
-
- options: joi, ajv, json-schema, and z-schema.
|
|
50
|
-
- docker
|
|
51
|
-
- psutil (pid_exists)
|
|
52
|
-
- json
|
|
53
|
-
- yaml
|
|
54
|
-
- mininet
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
- [deprecated idea] conlink sub-commands:
|
|
58
|
-
conlink spit
|
|
59
|
-
- output override docker-compose file with conlink service
|
|
60
|
-
- figure out volume mounts to get to other compose file(s)
|
|
61
|
-
conlink dc up ...
|
|
62
|
-
- generate override docker-compose file with conlink service
|
|
63
|
-
- run the compose command with override file
|
|
64
|
-
conlink start
|
|
65
|
-
- start inside compose
|
|
66
|
-
conlink run
|
|
67
|
-
- start outside compose
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
tc:
|
|
71
|
-
tc-htb:
|
|
72
|
-
- replace cbq, control outbound bandwidth
|
|
73
|
-
tc qdisc ... dev dev ( parent classid | root) [ handle major: ] htb [ default minor-id ]
|
|
74
|
-
tc class ... dev dev parent major:[minor] [ classid major:minor ] htb rate rate [ ceil rate ] burst bytes [ cburst bytes ] [ prio priority ]
|
|
75
|
-
|
|
76
|
-
tc-cbq:
|
|
77
|
-
tc qdisc ... dev dev ( parent classid | root) [ handle major: ] cbq [ allot bytes ] avpkt bytes bandwidth rate [ cell bytes ] [ ewma log ] [ mpu bytes ]
|
|
78
|
-
tc class ... dev dev parent major:[minor] [ classid major:minor ] cbq allot bytes [ bandwidth rate ] [ rate rate ] prio pri‐ority [ weight weight ] [ minburst packets ] [ maxburst packets ] [ ewma log ] [ cell bytes ] avpkt bytes [ mpu bytes ] [ bounded isolated ] [ split handle & defmap defmap ] [ estimator interval timeconstant ]
|
|
79
|
-
|
|
80
|
-
tc-netem:
|
|
81
|
-
tc qdisc ... dev DEVICE ] add netem OPTIONS
|
|
82
|
-
|
package/old/Dockerfile.bak
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
FROM node:16 as base
|
|
2
|
-
|
|
3
|
-
RUN apt-get -y update #1
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
#############################################################
|
|
7
|
-
FROM node:16-slim as conlink
|
|
8
|
-
|
|
9
|
-
RUN apt-get -y update #1
|
|
10
|
-
|
|
11
|
-
# network/debug
|
|
12
|
-
RUN apt-get -y install util-linux iproute2 bridge-utils tzdata \
|
|
13
|
-
iptables ethtool tcpdump socat iputils-ping strace socat \
|
|
14
|
-
curl wget iperf3 dnsmasq jq psutils telnet
|
|
15
|
-
|
|
16
|
-
# runtime deps
|
|
17
|
-
RUN apt-get -y install net-tools cgroup-tools \
|
|
18
|
-
openvswitch-switch openvswitch-testcontroller kmod
|
|
19
|
-
|
|
20
|
-
ADD package.json /app/
|
|
21
|
-
RUN cd /app && npm install
|
|
22
|
-
|
|
23
|
-
ADD conlink conlink.cljs /app/
|
|
24
|
-
ADD src/ /app/src/
|
|
25
|
-
RUN ln -sf /app/conlink /sbin/
|
|
26
|
-
|
package/old/add-link.sh
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# Copyright (c) 2023, Viasat, Inc
|
|
4
|
-
# Licensed under MPL 2.0
|
|
5
|
-
|
|
6
|
-
set -e
|
|
7
|
-
|
|
8
|
-
usage () {
|
|
9
|
-
echo >&2 "${0} [OPTIONS] TYPE INTF PID [-- SET ARGS]"
|
|
10
|
-
echo >&2 ""
|
|
11
|
-
echo >&2 " TYPE: interface type"
|
|
12
|
-
echo >&2 " INTF: the interface name to create in PID"
|
|
13
|
-
echo >&2 " PID: the process ID of the first namespace"
|
|
14
|
-
echo >&2 ""
|
|
15
|
-
echo >&2 " OPTIONS are:"
|
|
16
|
-
echo >&2 " --verbose - Verbose output (set -x)"
|
|
17
|
-
echo >&2 " --ip IP - IP address for INTF"
|
|
18
|
-
echo >&2 " --mac MAC - MAC address for INTF"
|
|
19
|
-
echo >&2 " --route 'ROUTE' - route to add to INTF"
|
|
20
|
-
echo >&2 " --mtu MTU - MTU for INTF"
|
|
21
|
-
echo >&2 ""
|
|
22
|
-
echo >&2 "The interface is created in PID ns, then the IP, MAC,"
|
|
23
|
-
echo >&2 "and MTU are set, and finally the following command"
|
|
24
|
-
echo >&2 "is executed:"
|
|
25
|
-
echo >&2 " ip link set INTF up SET_ARGS"
|
|
26
|
-
exit 2
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
VERBOSE=${VERBOSE:-}
|
|
30
|
-
IP= MAC= ROUTE= MTU= SET_ARGS=
|
|
31
|
-
|
|
32
|
-
info() { echo "add-link [${TYPE} - ${PID}/${IF}] ${*}"; }
|
|
33
|
-
warn() { >&2 echo "add-link [${TYPE} - ${PID}/${IF}] ${*}"; }
|
|
34
|
-
die() { warn "ERROR: ${*}"; exit 1; }
|
|
35
|
-
|
|
36
|
-
# Parse arguments
|
|
37
|
-
positional=
|
|
38
|
-
while [ "${*}" ]; do
|
|
39
|
-
param=$1; OPTARG=$2
|
|
40
|
-
case ${param} in
|
|
41
|
-
--verbose) VERBOSE=1 ;;
|
|
42
|
-
--ip) IP="${OPTARG}"; shift ;;
|
|
43
|
-
--mac) MAC="${OPTARG}"; shift ;;
|
|
44
|
-
--route) ROUTE="${OPTARG}"; shift ;;
|
|
45
|
-
--mtu) MTU="${OPTARG}"; shift ;;
|
|
46
|
-
-h|--help) usage ;;
|
|
47
|
-
--) SET_ARGS="$*"; break ;;
|
|
48
|
-
*) positional="${positional} $1" ;;
|
|
49
|
-
esac
|
|
50
|
-
shift
|
|
51
|
-
done
|
|
52
|
-
set -- ${positional}
|
|
53
|
-
|
|
54
|
-
TYPE=$1 IF=$2 PID=$3 NS=ns${PID}
|
|
55
|
-
|
|
56
|
-
[ "${VERBOSE}" ] && set -x || true
|
|
57
|
-
|
|
58
|
-
# Check arguments
|
|
59
|
-
[ "${TYPE}" -a "${IF}" -a "${PID}" ] || usage
|
|
60
|
-
|
|
61
|
-
# Sanity checks
|
|
62
|
-
[ ! -d /proc/$PID ] && die "PID $PID is no longer running!"
|
|
63
|
-
|
|
64
|
-
export PATH=$PATH:/usr/sbin
|
|
65
|
-
mkdir -p /var/run/netns
|
|
66
|
-
ln -sf /proc/${PID}/ns/net /var/run/netns/${NS}
|
|
67
|
-
|
|
68
|
-
info "Creating ${TYPE} link ${IF} in ${NS}"
|
|
69
|
-
ip link add ${IF} netns ns${PID} type ${TYPE}
|
|
70
|
-
|
|
71
|
-
ip -netns ${NS} --force -b - <<EOF
|
|
72
|
-
${IP:+addr add ${IP} dev ${IF}}
|
|
73
|
-
${MAC:+link set dev ${IF} address ${MAC}}
|
|
74
|
-
${MTU:+link set dev ${IF} mtu ${MTU}}
|
|
75
|
-
link set dev ${IF} up
|
|
76
|
-
${ROUTE:+route add ${ROUTE} dev ${IF}}
|
|
77
|
-
${SET_ARGS:+link set dev ${IF} ${SET_ARGS}}
|
|
78
|
-
EOF
|
|
79
|
-
|
|
80
|
-
info "Created ${TYPE} link ${IF} in ${NS}"
|
|
81
|
-
|
|
82
|
-
# /test/add-link.sh --verbose dummy if0 2500144 --ip 192.168.88.32/24 -- arp on
|
package/old/conlink
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
|
|
3
|
-
TOP_DIR=$(dirname $(readlink -f "${0}"))
|
|
4
|
-
SCRIPT_NAME=$(basename "${0}")
|
|
5
|
-
NBB=${TOP_DIR}/node_modules/.bin/nbb
|
|
6
|
-
|
|
7
|
-
die() { echo >&2 "${*}"; exit 1; }
|
|
8
|
-
|
|
9
|
-
[ -e "${NBB}" ] || die "Missing ${NBB}. Maybe run 'npm install' in ${TOP_DIR}?"
|
|
10
|
-
|
|
11
|
-
exec ${NBB} -cp "${TOP_DIR}/src" "${TOP_DIR}"/${SCRIPT_NAME}.cljs "${@}"
|
|
12
|
-
|
package/old/conlink.cljs
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env nbb
|
|
2
|
-
|
|
3
|
-
(ns conlink
|
|
4
|
-
(:require [clojure.string :as S]
|
|
5
|
-
[promesa.core :as P]
|
|
6
|
-
[cljs-bean.core :refer [->clj]]
|
|
7
|
-
[conlink.util :refer [parse-opts Eprintln Epprint
|
|
8
|
-
fatal spawn exec read-file]]
|
|
9
|
-
["yaml$default" :as yaml]
|
|
10
|
-
["dockerode$default" :as Docker]))
|
|
11
|
-
|
|
12
|
-
(def usage "
|
|
13
|
-
conlink: advanced container linking (networking).
|
|
14
|
-
|
|
15
|
-
Usage:
|
|
16
|
-
conlink [options]
|
|
17
|
-
|
|
18
|
-
Options:
|
|
19
|
-
-v, --verbose Show verbose output (stderr)
|
|
20
|
-
[env: VERBOSE]
|
|
21
|
-
--project PROJECT Docker compose project name
|
|
22
|
-
[env: COMPOSE_PROJECT_NAME]
|
|
23
|
-
--network-file NETWORK-FILE... Network configuration file
|
|
24
|
-
--compose-file COMPOSE-FILE... Docker compose file
|
|
25
|
-
")
|
|
26
|
-
|
|
27
|
-
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
28
|
-
|
|
29
|
-
(defn json-str [obj]
|
|
30
|
-
(js/JSON.stringify (clj->js obj)))
|
|
31
|
-
|
|
32
|
-
(defn mangle-network-config
|
|
33
|
-
"
|
|
34
|
-
- Rewrite network config to use actual container names instead of
|
|
35
|
-
the convenience aliases.
|
|
36
|
-
- Prune links, interfaces, and commands based on enabled service
|
|
37
|
-
profiles.
|
|
38
|
-
"
|
|
39
|
-
[net-cfg prefix]
|
|
40
|
-
(let [links (reduce
|
|
41
|
-
(fn [links {:keys [left right] :as link}]
|
|
42
|
-
(let [lname (str prefix (:container left))
|
|
43
|
-
rname (str prefix (:container right))]
|
|
44
|
-
(conj links
|
|
45
|
-
{:left (assoc left :container lname)
|
|
46
|
-
:right (assoc right :container rname)})))
|
|
47
|
-
[] (:links net-cfg))]
|
|
48
|
-
(assoc net-cfg :links links)))
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
(defn init-containers-state [net-cfg]
|
|
52
|
-
(let [state (into {} (for [l (:links net-cfg)
|
|
53
|
-
c [(:left l) (:right l)]]
|
|
54
|
-
[(:container c) {:state :unconnected :links []}]))]
|
|
55
|
-
(reduce
|
|
56
|
-
(fn [cfg {:keys [left right] :as link}]
|
|
57
|
-
(let [lfn (fn [me you] {:self (dissoc (me link) :container)
|
|
58
|
-
:remote (you link)})]
|
|
59
|
-
(-> cfg
|
|
60
|
-
(update-in [(:container left) :links] conj (lfn :left :right))
|
|
61
|
-
(update-in [(:container right) :links] conj (lfn :right :left)))))
|
|
62
|
-
state
|
|
63
|
-
(:links net-cfg)))
|
|
64
|
-
|
|
65
|
-
(defn handle-container [{:keys [client project config state] :as ctx} cid]
|
|
66
|
-
(P/let [container (.getContainer client cid)
|
|
67
|
-
details (P/-> container .inspect ->clj)
|
|
68
|
-
{Name :Name {Labels :Labels} :Config} details]
|
|
69
|
-
(Eprintln :handle-container :cid cid)
|
|
70
|
-
#_(Epprint details)
|
|
71
|
-
(Epprint (get @state Name))))
|
|
72
|
-
|
|
73
|
-
(P/let
|
|
74
|
-
[cfg (parse-opts usage *command-line-args*)
|
|
75
|
-
_ (when (empty? cfg) (js/process.exit 2))
|
|
76
|
-
{:keys [verbose project network-file compose-file]} cfg
|
|
77
|
-
_ (when verbose (Eprintln "Settings:"))
|
|
78
|
-
_ (when verbose (Epprint cfg))
|
|
79
|
-
_ (when (not (or network-file compose-file))
|
|
80
|
-
(fatal 2 "either --network-file or --compose-file is required"))
|
|
81
|
-
|
|
82
|
-
raw-network-config (P/-> (first network-file)
|
|
83
|
-
(read-file "utf8")
|
|
84
|
-
yaml/parse
|
|
85
|
-
->clj)
|
|
86
|
-
docker (Docker. #js {:socketPath "/var/run/docker.sock"})
|
|
87
|
-
|
|
88
|
-
_ (Eprintln "raw-network-config:")
|
|
89
|
-
_ (Epprint raw-network-config)
|
|
90
|
-
prefix (if project (str "/" project "_") "/")
|
|
91
|
-
network-config (mangle-network-config raw-network-config prefix)
|
|
92
|
-
_ (Eprintln "network-config:")
|
|
93
|
-
_ (Epprint network-config)
|
|
94
|
-
state (init-containers-state network-config)
|
|
95
|
-
_ (Eprintln "state:")
|
|
96
|
-
_ (Epprint state)
|
|
97
|
-
|
|
98
|
-
ctx {:client docker
|
|
99
|
-
:project project
|
|
100
|
-
:config network-config
|
|
101
|
-
:state (atom state)}
|
|
102
|
-
label-filters (if project
|
|
103
|
-
{"label" [(str "com.docker.compose.project=" project)]}
|
|
104
|
-
{})
|
|
105
|
-
ev-filters (merge label-filters
|
|
106
|
-
{"event" ["start"]})
|
|
107
|
-
ev-stream (.getEvents docker #js {:filters (json-str ev-filters)})
|
|
108
|
-
_ (.on ev-stream "data" (fn [ev]
|
|
109
|
-
(let [event (-> ev js/JSON.parse ->clj)]
|
|
110
|
-
(prn :event event)
|
|
111
|
-
(handle-container ctx (:id event)))))
|
|
112
|
-
|
|
113
|
-
_ (Eprintln "Handling already running containers")
|
|
114
|
-
containers (P/-> docker
|
|
115
|
-
(.listContainers #js {:filters (json-str label-filters)
|
|
116
|
-
:sparse true})
|
|
117
|
-
->clj)
|
|
118
|
-
#_#__ (Epprint containers)
|
|
119
|
-
_ (doseq [c containers] (handle-container ctx (:Id c)))
|
|
120
|
-
|
|
121
|
-
#_#_res (P/all [(spawn "sleep 1")
|
|
122
|
-
(spawn "ip link show")
|
|
123
|
-
(spawn "ip addr show")
|
|
124
|
-
(spawn "ip route show")])
|
|
125
|
-
#_#__ (prn :res res)
|
|
126
|
-
]
|
|
127
|
-
(prn :here1)
|
|
128
|
-
)
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
package/old/dot_gitignore
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
*.swp
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
# A docker-compose file with an external network configuration file
|
|
2
|
-
# and two docker containers that are connected via a switch. In
|
|
3
|
-
# addition an "internet" host is setup in the network container that
|
|
4
|
-
# is also connected to the switch and is listening on 8.8.8.8.
|
|
5
|
-
|
|
6
|
-
version: "2.4"
|
|
7
|
-
|
|
8
|
-
services:
|
|
9
|
-
network:
|
|
10
|
-
build: {context: ../}
|
|
11
|
-
image: conlink.cljs
|
|
12
|
-
pid: host
|
|
13
|
-
network_mode: none
|
|
14
|
-
cap_add: [SYS_ADMIN, NET_ADMIN, SYS_NICE, NET_BROADCAST, IPC_LOCK]
|
|
15
|
-
security_opt: [ 'apparmor:unconfined' ] # needed on Ubuntu 18.04
|
|
16
|
-
volumes:
|
|
17
|
-
- /var/run/docker.sock:/var/run/docker.sock
|
|
18
|
-
- /var/lib/docker:/var/lib/docker
|
|
19
|
-
- ./:/test
|
|
20
|
-
command: /sbin/conlink -v --project ${COMPOSE_PROJECT_NAME:?required} --compose-file /test/test2-compose.yaml --network-file /test/test2-network.yaml
|
|
21
|
-
|
|
22
|
-
node1:
|
|
23
|
-
image: alpine
|
|
24
|
-
cap_add: [NET_ADMIN]
|
|
25
|
-
network_mode: none
|
|
26
|
-
command: sleep 864000
|
|
27
|
-
|
|
28
|
-
node2:
|
|
29
|
-
image: alpine
|
|
30
|
-
cap_add: [NET_ADMIN]
|
|
31
|
-
network_mode: none
|
|
32
|
-
command: sh -c 'while ! ip link show eth0 up; do sleep 1; done; sleep 864000'
|