diff --git a/BUILD.bazel b/BUILD.bazel index a5a75c7462..ba817ae8f8 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -133,6 +133,7 @@ pkg_tar( srcs = [ "//control/cmd/control", "//daemon/cmd/daemon", + "//dispatcher/cmd/dispatcher", "//gateway/cmd/gateway", "//router/cmd/router", "//scion-pki/cmd/scion-pki", diff --git a/acceptance/common/topogen.bzl b/acceptance/common/topogen.bzl index 5e77e86e73..7a98f953ac 100644 --- a/acceptance/common/topogen.bzl +++ b/acceptance/common/topogen.bzl @@ -110,6 +110,7 @@ def container_loaders(tester, gateway): images = { "control:latest": "//docker:control", "daemon:latest": "//docker:daemon", + "dispatcher:latest": "//docker:disptacher", "tester:latest": tester, "posix-router:latest": "//docker:posix_router", } diff --git a/acceptance/sig_short_exp_time/docker-compose.yml b/acceptance/sig_short_exp_time/docker-compose.yml index fedda02b3d..338d4a8255 100644 --- a/acceptance/sig_short_exp_time/docker-compose.yml +++ b/acceptance/sig_short_exp_time/docker-compose.yml @@ -42,6 +42,22 @@ services: ipv4_address: 242.254.100.4 bridge2: ipv4_address: 242.254.200.4 + dispatcher1: + container_name: dispatcher1 + image: bazel/acceptance/sig_short_exp_time:dispatcher1 + networks: + bridge1: + ipv4_address: 242.254.100.2 + volumes: + - vol_scion_disp_sig1-ff00_0_110:/run/shm/dispatcher:rw + dispatcher2: + container_name: dispatcher2 + image: bazel/acceptance/sig_short_exp_time:dispatcher2 + networks: + bridge2: + ipv4_address: 242.254.200.2 + volumes: + - vol_scion_disp_sig1-ff00_0_111:/run/shm/dispatcher:rw sig1: cap_add: - NET_ADMIN diff --git a/acceptance/sig_short_exp_time/test b/acceptance/sig_short_exp_time/test index e2988720c0..b1606260a1 100755 --- a/acceptance/sig_short_exp_time/test +++ b/acceptance/sig_short_exp_time/test @@ -10,7 +10,6 @@ # short lifetime expires, the first path is taken down and a ping sent out. If # the failover was correct, this ping should not be lost. -# TODO(JordiSubira): Remove dispatcher from schema. # Docker topology: # # +---------------------------+ +---------------------------+ @@ -51,10 +50,12 @@ run_test() {(set -e # Register with the docker daemon the docker images bazel created docker image load -i acceptance/sig_short_exp_time/udpproxy.tar + docker image load -i acceptance/sig_short_exp_time/dispatcher1.tar + docker image load -i acceptance/sig_short_exp_time/dispatcher2.tar docker image load -i acceptance/sig_short_exp_time/sig1.tar docker image load -i acceptance/sig_short_exp_time/sig2.tar - docker-compose -f acceptance/sig_short_exp_time/docker-compose.yml up -d sig1 sig2 patha pathb + docker-compose -f acceptance/sig_short_exp_time/docker-compose.yml up -d dispatcher1 dispatcher2 sig1 sig2 patha pathb # Set up forward route on network stack 1 and 2 through the sig tunnel # device. The route is a property of the network stack, and persists after @@ -102,7 +103,7 @@ RC=$? OUTPUT_DIR=$TEST_UNDECLARED_OUTPUTS_DIR mkdir -p $OUTPUT_DIR/logs -for CNTR in sig1 sig2; do +for CNTR in sig1 sig2 dispatcher1 dispatcher2; do docker-compose -f acceptance/sig_short_exp_time/docker-compose.yml logs "$CNTR" > "$OUTPUT_DIR/logs/$CNTR.log" done diff --git a/acceptance/sig_short_exp_time/testdata/1-ff00_0_110/dispatcher/disp.toml b/acceptance/sig_short_exp_time/testdata/1-ff00_0_110/dispatcher/disp.toml new file mode 100644 index 0000000000..6c11642ad6 --- /dev/null +++ b/acceptance/sig_short_exp_time/testdata/1-ff00_0_110/dispatcher/disp.toml @@ -0,0 +1,5 @@ +[dispatcher] +id = "disp_1-ff00_0_110" + +[log.console] +level = "debug" \ No newline at end of file diff --git a/acceptance/sig_short_exp_time/testdata/1-ff00_0_111/dispatcher/disp.toml b/acceptance/sig_short_exp_time/testdata/1-ff00_0_111/dispatcher/disp.toml new file mode 100644 index 0000000000..9984dfec2a --- /dev/null +++ b/acceptance/sig_short_exp_time/testdata/1-ff00_0_111/dispatcher/disp.toml @@ -0,0 +1,5 @@ +[dispatcher] +id = "disp_1-ff00_0_111" + +[log.console] +level = "debug" \ No newline at end of file diff --git a/acceptance/topo_cs_reload/BUILD.bazel b/acceptance/topo_cs_reload/BUILD.bazel index 0327bf788c..303b533e98 100644 --- a/acceptance/topo_cs_reload/BUILD.bazel +++ b/acceptance/topo_cs_reload/BUILD.bazel @@ -14,6 +14,7 @@ go_test( "docker-compose.yml", "testdata/topology_reload.json", ":control.tar", + ":dispatcher.tar", ":invalid_changed_ip", ":invalid_changed_port", ":testdata/gen_crypto.sh", @@ -55,6 +56,17 @@ container_image( ], ) +container_image( + name = "dispatcher", + base = "//docker:dispatcher", + cmd = [ + "--config", + "/disp.toml", + ], + entrypoint = ["/app/dispatcher"], + files = ["testdata/disp.toml"], +) + genrule( name = "invalid_changed_ip", srcs = ["//acceptance/topo_common:topology"], diff --git a/acceptance/topo_cs_reload/docker-compose.yml b/acceptance/topo_cs_reload/docker-compose.yml index d2d4fac7d5..73ebc94b50 100644 --- a/acceptance/topo_cs_reload/docker-compose.yml +++ b/acceptance/topo_cs_reload/docker-compose.yml @@ -7,14 +7,20 @@ networks: config: - subnet: 242.253.100.0/24 services: + topo_cs_reload_dispatcher: + container_name: topo_cs_reload_dispatcher + image: bazel/acceptance/topo_cs_reload:dispatcher + networks: + bridge1: + ipv4_address: 242.253.100.2 topo_cs_reload_control_srv: container_name: topo_cs_reload_control_srv image: bazel/acceptance/topo_cs_reload:control + depends_on: + - topo_cs_reload_dispatcher volumes: - "${TOPO_CS_RELOAD_CONFIG_DIR}/certs:/certs:ro" - "${TOPO_CS_RELOAD_CONFIG_DIR}/keys:/keys:ro" - "${TOPO_CS_RELOAD_CONFIG_DIR}/crypto:/crypto:ro" - networks: - bridge1: - ipv4_address: 242.253.100.2 -version: '2.4' + network_mode: service:topo_cs_reload_dispatcher +version: '2.4' \ No newline at end of file diff --git a/acceptance/topo_cs_reload/reload_test.go b/acceptance/topo_cs_reload/reload_test.go index 85453b04f0..790f4a0120 100644 --- a/acceptance/topo_cs_reload/reload_test.go +++ b/acceptance/topo_cs_reload/reload_test.go @@ -105,6 +105,7 @@ func setupTest(t *testing.T) testState { s.mustExec(t, "tar", "-xf", "crypto.tar", "-C", tmpDir) // first load the docker images from bazel into the docker deamon, the // tars are in the same folder as this test runs in bazel. + s.mustExec(t, "docker", "image", "load", "-i", "dispatcher.tar") s.mustExec(t, "docker", "image", "load", "-i", "control.tar") // now start the docker containers s.mustExec(t, "docker-compose", "-f", "docker-compose.yml", "up", "-d") @@ -123,6 +124,7 @@ func (s testState) teardownTest(t *testing.T) { require.NoError(t, os.MkdirAll(fmt.Sprintf("%s/logs", outdir), os.ModePerm|os.ModeDir)) // collect logs for service, file := range map[string]string{ + "topo_cs_reload_dispatcher": "disp.log", "topo_cs_reload_control_srv": "control.log", } { cmd := exec.Command("docker-compose", "-f", "docker-compose.yml", "logs", "--no-color", diff --git a/acceptance/topo_cs_reload/testdata/disp.toml b/acceptance/topo_cs_reload/testdata/disp.toml new file mode 100644 index 0000000000..6c11642ad6 --- /dev/null +++ b/acceptance/topo_cs_reload/testdata/disp.toml @@ -0,0 +1,5 @@ +[dispatcher] +id = "disp_1-ff00_0_110" + +[log.console] +level = "debug" \ No newline at end of file diff --git a/acceptance/topo_daemon_reload/BUILD.bazel b/acceptance/topo_daemon_reload/BUILD.bazel index 516d79224c..b777f9d14b 100644 --- a/acceptance/topo_daemon_reload/BUILD.bazel +++ b/acceptance/topo_daemon_reload/BUILD.bazel @@ -22,6 +22,17 @@ go_test( ], ) +container_image( + name = "dispatcher", + base = "//docker:dispatcher", + cmd = [ + "--config", + "/disp.toml", + ], + entrypoint = ["/app/dispatcher"], + files = ["testdata/disp.toml"], +) + container_image( name = "daemon", base = "//docker:daemon", diff --git a/acceptance/topo_daemon_reload/docker-compose.yml b/acceptance/topo_daemon_reload/docker-compose.yml index 14074f14c3..5eb96b5034 100644 --- a/acceptance/topo_daemon_reload/docker-compose.yml +++ b/acceptance/topo_daemon_reload/docker-compose.yml @@ -7,14 +7,18 @@ networks: config: - subnet: 242.254.100.0/24 services: - topo_daemon_reload_daemon: - container_name: topo_daemon_reload_daemon - image: bazel/acceptance/topo_daemon_reload:daemon + topo_daemon_reload_dispatcher: + container_name: topo_daemon_reload_dispatcher + image: bazel/acceptance/topo_daemon_reload:dispatcher networks: bridge1: ipv4_address: 242.254.100.2 + topo_daemon_reload_daemon: + container_name: topo_daemon_reload_daemon + image: bazel/acceptance/topo_daemon_reload:daemon volumes: - vol_topo_daemon_reload_certs:/certs:ro + network_mode: service:topo_daemon_reload_dispatcher version: '2.4' volumes: - vol_topo_daemon_reload_certs: null + vol_topo_daemon_reload_certs: null \ No newline at end of file diff --git a/acceptance/topo_daemon_reload/reload_test.go b/acceptance/topo_daemon_reload/reload_test.go index 9ee971b892..243cb133aa 100644 --- a/acceptance/topo_daemon_reload/reload_test.go +++ b/acceptance/topo_daemon_reload/reload_test.go @@ -68,10 +68,11 @@ func TestSDTopoReload(t *testing.T) { func setupTest(t *testing.T) { // first load the docker images from bazel into the docker deamon, the // tars are in the same folder as this test runs in bazel. + mustExec(t, "docker", "image", "load", "-i", "dispatcher.tar") mustExec(t, "docker", "image", "load", "-i", "daemon.tar") // now start the docker containers mustExec(t, "docker-compose", "-f", "docker-compose.yml", "up", - "-d", "topo_daemon_reload_daemon") + "-d", "topo_daemon_reload_dispatcher", "topo_daemon_reload_daemon") // wait a bit to make sure the containers are ready. time.Sleep(time.Second / 2) t.Log("Test setup done") @@ -86,7 +87,8 @@ func teardownTest(t *testing.T) { require.NoError(t, os.MkdirAll(fmt.Sprintf("%s/logs", outdir), os.ModePerm|os.ModeDir)) // collect logs for service, file := range map[string]string{ - "topo_daemon_reload_daemon": "daemon.log", + "topo_daemon_reload_dispatcher": "disp.log", + "topo_daemon_reload_daemon": "daemon.log", } { cmd := exec.Command("docker-compose", "-f", "docker-compose.yml", "logs", "--no-color", service) diff --git a/acceptance/topo_daemon_reload/testdata/disp.toml b/acceptance/topo_daemon_reload/testdata/disp.toml new file mode 100644 index 0000000000..6c11642ad6 --- /dev/null +++ b/acceptance/topo_daemon_reload/testdata/disp.toml @@ -0,0 +1,5 @@ +[dispatcher] +id = "disp_1-ff00_0_110" + +[log.console] +level = "debug" \ No newline at end of file diff --git a/dispatcher/dispatcher.go b/dispatcher/dispatcher.go index c3c07a98ef..80a0578506 100644 --- a/dispatcher/dispatcher.go +++ b/dispatcher/dispatcher.go @@ -39,7 +39,6 @@ const ( ReceiveBufferSize = 1 << 20 // SendBufferSize is the size of the send buffers used by the dispatcher. SendBufferSize = 1 << 20 - mtu = 1920 - 20 - 8 ) // Server is the main object allowing to create new SCION connections. @@ -66,7 +65,7 @@ func NewServer(topo *topology.Loader, conn *net.UDPConn) *Server { server := Server{ topo: topo, conn: conn, - buf: make([]byte, mtu), + buf: make([]byte, common.SupportedMTU), decoded: make([]gopacket.LayerType, 4), outBuffer: gopacket.NewSerializeBuffer(), options: gopacket.SerializeOptions{ diff --git a/docker/BUILD.bazel b/docker/BUILD.bazel index 3f01c7ef89..9744290598 100644 --- a/docker/BUILD.bazel +++ b/docker/BUILD.bazel @@ -7,6 +7,7 @@ container_bundle( images = { "control:latest": ":control", "daemon:latest": ":daemon", + "dispatcher:latest": ":dispatcher", "posix-gateway:latest": ":posix_gateway", "posix-router:latest": "posix_router", }, @@ -45,6 +46,16 @@ scion_app_images( entrypoint = ["/app/control"], ) +scion_app_images( + name = "dispatcher", + src = "//dispatcher/cmd/dispatcher", + cmd = [ + "--config", + "/share/conf/disp.toml", + ], + entrypoint = ["/app/dispatcher"], +) + scion_app_images( name = "daemon", src = "//daemon/cmd/daemon", diff --git a/spec/BUILD.bazel b/spec/BUILD.bazel index 84016cd14d..49b6a8e3bf 100644 --- a/spec/BUILD.bazel +++ b/spec/BUILD.bazel @@ -27,6 +27,16 @@ openapi_bundle( visibility = ["//visibility:public"], ) +openapi_bundle( + name = "dispatcher", + srcs = [ + "//spec/common:base.yml", + "//spec/common:process.yml", + ], + entrypoint = "//spec/dispatcher:spec.yml", + visibility = ["//visibility:public"], +) + openapi_bundle( name = "daemon", srcs = [