From 817d53969cd376c6297d5b51431bfbc3f78470e8 Mon Sep 17 00:00:00 2001 From: rohrerj <26304001+rohrerj@users.noreply.github.com> Date: Thu, 27 Jul 2023 17:02:53 +0200 Subject: [PATCH 1/6] implemented configuration for the restructured border router --- router/BUILD.bazel | 2 + router/cmd/router/main.go | 9 ++++- router/config/BUILD.bazel | 6 ++- router/config/config.go | 63 +++++++++++++++++++++++++++++++ router/config/sample.go | 34 +++++++++++++++++ router/connector.go | 10 ++--- router/dataplane.go | 26 +++---------- router/dataplane_internal_test.go | 5 ++- router/dataplane_test.go | 3 +- tools/topology/go.py | 6 +++ 10 files changed, 133 insertions(+), 31 deletions(-) create mode 100644 router/config/sample.go diff --git a/router/BUILD.bazel b/router/BUILD.bazel index 27ad3eb3e5..e89dcc1302 100644 --- a/router/BUILD.bazel +++ b/router/BUILD.bazel @@ -29,6 +29,7 @@ go_library( "//private/topology:go_default_library", "//private/underlay/conn:go_default_library", "//router/bfd:go_default_library", + "//router/config:go_default_library", "//router/control:go_default_library", "@com_github_google_gopacket//:go_default_library", "@com_github_google_gopacket//layers:go_default_library", @@ -62,6 +63,7 @@ go_test( "//pkg/slayers/path/scion:go_default_library", "//private/topology:go_default_library", "//private/underlay/conn:go_default_library", + "//router/config:go_default_library", "//router/control:go_default_library", "//router/mock_router:go_default_library", "@com_github_golang_mock//gomock:go_default_library", diff --git a/router/cmd/router/main.go b/router/cmd/router/main.go index ccc765f932..496d53694b 100644 --- a/router/cmd/router/main.go +++ b/router/cmd/router/main.go @@ -60,6 +60,8 @@ func realMain(ctx context.Context) error { DataPlane: router.DataPlane{ Metrics: metrics, }, + ReceiveBufferSize: globalCfg.Router.ReceiveBufferSize, + SendBufferSize: globalCfg.Router.SendBufferSize, } iaCtx := &control.IACtx{ Config: controlConfig, @@ -121,8 +123,11 @@ func realMain(ctx context.Context) error { }) g.Go(func() error { defer log.HandlePanic() - runConfig := &router.RunConfig{} - runConfig.LoadDefaults() + runConfig := &config.RunConfig{ + NumProcessors: globalCfg.Router.NumProcessors, + NumSlowPathProcessors: globalCfg.Router.NumSlowPathProcessors, + BatchSize: globalCfg.Router.BatchSize, + } if err := dp.DataPlane.Run(errCtx, runConfig); err != nil { return serrors.WrapStr("running dataplane", err) } diff --git a/router/config/BUILD.bazel b/router/config/BUILD.bazel index 7a6b13196b..7538118ee9 100644 --- a/router/config/BUILD.bazel +++ b/router/config/BUILD.bazel @@ -2,11 +2,15 @@ load("//tools/lint:go.bzl", "go_library", "go_test") go_library( name = "go_default_library", - srcs = ["config.go"], + srcs = [ + "config.go", + "sample.go", + ], importpath = "github.com/scionproto/scion/router/config", visibility = ["//visibility:public"], deps = [ "//pkg/log:go_default_library", + "//pkg/private/serrors:go_default_library", "//private/config:go_default_library", "//private/env:go_default_library", "//private/mgmtapi:go_default_library", diff --git a/router/config/config.go b/router/config/config.go index b40818d6e3..e1a35b86c7 100644 --- a/router/config/config.go +++ b/router/config/config.go @@ -18,8 +18,10 @@ package config import ( "io" + "runtime" "github.com/scionproto/scion/pkg/log" + "github.com/scionproto/scion/pkg/private/serrors" "github.com/scionproto/scion/private/config" "github.com/scionproto/scion/private/env" api "github.com/scionproto/scion/private/mgmtapi" @@ -33,6 +35,64 @@ type Config struct { Logging log.Config `toml:"log,omitempty"` Metrics env.Metrics `toml:"metrics,omitempty"` API api.Config `toml:"api,omitempty"` + Router RouterConfig `toml:"router,omitempty"` +} + +type RouterConfig struct { + ReceiveBufferSize int `toml:"receive_buffer_size,omitempty"` + SendBufferSize int `toml:"send_buffer_size,omitempty"` + NumProcessors int `toml:"num_processors,omitempty"` + NumSlowPathProcessors int `toml:"num_slow_processors,omitempty"` + BatchSize int `toml:"batch_size,omitempty"` +} + +func (cfg *RouterConfig) ConfigName() string { + return "router" +} + +func (cfg *RouterConfig) Validate() error { + if cfg.ReceiveBufferSize < 0 { + return serrors.New("Provided router config is invalid. ReceiveBufferSize < 0") + } + if cfg.SendBufferSize < 0 { + return serrors.New("Provided router config is invalid. SendBufferSize < 0") + } + if cfg.BatchSize < 1 { + return serrors.New("Provided router config is invalid. BatchSize < 1") + } + if cfg.NumProcessors < 0 { + return serrors.New("Provided router config is invalid. NumProcessors < 0") + } + if cfg.NumSlowPathProcessors <= 0 { + return serrors.New("Provided router config is invalid. NumSlowPathProcessors < 0") + } + + return nil +} + +func (cfg *RouterConfig) InitDefaults() { + if cfg.ReceiveBufferSize == 0 { + cfg.ReceiveBufferSize = 1 << 20 + } + if cfg.NumProcessors == 0 { + cfg.NumProcessors = runtime.GOMAXPROCS(0) + } + if cfg.NumSlowPathProcessors == 0 { + cfg.NumSlowPathProcessors = 1 + } + if cfg.BatchSize == 0 { + cfg.BatchSize = 256 + } +} + +func (cfg *RouterConfig) Sample(dst io.Writer, path config.Path, ctx config.CtxMap) { + config.WriteString(dst, routerConfigSample) +} + +type RunConfig struct { + NumProcessors int + NumSlowPathProcessors int + BatchSize int } func (cfg *Config) InitDefaults() { @@ -42,6 +102,7 @@ func (cfg *Config) InitDefaults() { &cfg.Logging, &cfg.Metrics, &cfg.API, + &cfg.Router, ) } @@ -52,6 +113,7 @@ func (cfg *Config) Validate() error { &cfg.Logging, &cfg.Metrics, &cfg.API, + &cfg.Router, ) } @@ -62,5 +124,6 @@ func (cfg *Config) Sample(dst io.Writer, path config.Path, _ config.CtxMap) { &cfg.Logging, &cfg.Metrics, &cfg.API, + &cfg.Router, ) } diff --git a/router/config/sample.go b/router/config/sample.go new file mode 100644 index 0000000000..480cad5d4c --- /dev/null +++ b/router/config/sample.go @@ -0,0 +1,34 @@ +// Copyright 2023 ETH Zurich +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package config + +const routerConfigSample = ` +# The receive buffer size in bytes. +# (default 1048576) +receive_buffer_size = 1048576 + +# The send buffer size in bytes. 0 means use system default. +# (default 0) +send_buffer_size = 0 + +# The number of slow path processors. +# (default 1) +num_slow_processors = 1 + +# The batch size used by the receiver and forwarder to +# read or write from / to the network socket. +# (default 256) +batch_size = 256 +` diff --git a/router/connector.go b/router/connector.go index 6944e75b2b..7b744b2c41 100644 --- a/router/connector.go +++ b/router/connector.go @@ -27,9 +27,6 @@ import ( "github.com/scionproto/scion/router/control" ) -// receiveBufferSize is the size of receive buffers used by the router. -const receiveBufferSize = 1 << 20 - // Connector implements the Dataplane API of the router control process. It sets // up connections for the DataPlane. type Connector struct { @@ -40,6 +37,9 @@ type Connector struct { internalInterfaces []control.InternalInterface externalInterfaces map[uint16]control.ExternalInterface siblingInterfaces map[uint16]control.SiblingInterface + + ReceiveBufferSize int + SendBufferSize int } var errMultiIA = serrors.New("different IA not allowed") @@ -65,7 +65,7 @@ func (c *Connector) AddInternalInterface(ia addr.IA, local net.UDPAddr) error { return serrors.WithCtx(errMultiIA, "current", c.ia, "new", ia) } connection, err := conn.New(&local, nil, - &conn.Config{ReceiveBufferSize: receiveBufferSize}) + &conn.Config{ReceiveBufferSize: c.ReceiveBufferSize, SendBufferSize: c.SendBufferSize}) if err != nil { return err } @@ -130,7 +130,7 @@ func (c *Connector) AddExternalInterface(localIfID common.IFIDType, link control } connection, err := conn.New(link.Local.Addr, link.Remote.Addr, - &conn.Config{ReceiveBufferSize: receiveBufferSize}) + &conn.Config{ReceiveBufferSize: c.ReceiveBufferSize, SendBufferSize: c.SendBufferSize}) if err != nil { return err } diff --git a/router/dataplane.go b/router/dataplane.go index 60f2001c5c..7581903e4c 100644 --- a/router/dataplane.go +++ b/router/dataplane.go @@ -27,7 +27,6 @@ import ( "math/big" "net" "net/netip" - "runtime" "strconv" "sync" "time" @@ -54,6 +53,7 @@ import ( "github.com/scionproto/scion/private/topology" underlayconn "github.com/scionproto/scion/private/underlay/conn" "github.com/scionproto/scion/router/bfd" + "github.com/scionproto/scion/router/config" "github.com/scionproto/scion/router/control" ) @@ -458,11 +458,6 @@ func (d *DataPlane) AddNextHopBFD(ifID uint16, src, dst *net.UDPAddr, cfg contro return d.addBFDController(ifID, s, cfg, m) } -type RunConfig struct { - NumProcessors int - BatchSize int -} - func max(a int, b int) int { if a > b { return a @@ -470,7 +465,7 @@ func max(a int, b int) int { return b } -func (d *DataPlane) Run(ctx context.Context, cfg *RunConfig) error { +func (d *DataPlane) Run(ctx context.Context, cfg *config.RunConfig) error { d.mtx.Lock() d.running = true d.initMetrics() @@ -513,18 +508,9 @@ func (d *DataPlane) Run(ctx context.Context, cfg *RunConfig) error { return nil } -// loadDefaults sets the default configuration for the number of -// processors and the batch size -func (r *RunConfig) LoadDefaults() { - // TODO(rohrerj) move this logic to configuration in configuration PR - r.NumProcessors = runtime.GOMAXPROCS(0) - r.BatchSize = 256 - -} - // initializePacketPool calculates the size of the packet pool based on the // current dataplane settings and allocates all the buffers -func (d *DataPlane) initPacketPool(cfg *RunConfig, processorQueueSize int) { +func (d *DataPlane) initPacketPool(cfg *config.RunConfig, processorQueueSize int) { poolSize := len(d.interfaces)*cfg.BatchSize + cfg.NumProcessors*(processorQueueSize+1) + len(d.interfaces)*(2*cfg.BatchSize) @@ -537,7 +523,7 @@ func (d *DataPlane) initPacketPool(cfg *RunConfig, processorQueueSize int) { } // initializes the processing routines and forwarders queues -func initQueues(cfg *RunConfig, interfaces map[uint16]BatchConn, +func initQueues(cfg *config.RunConfig, interfaces map[uint16]BatchConn, processorQueueSize int) ([]chan packet, map[uint16]chan packet) { procQs := make([]chan packet, cfg.NumProcessors) @@ -563,7 +549,7 @@ type packet struct { rawPacket []byte } -func (d *DataPlane) runReceiver(ifID uint16, conn BatchConn, cfg *RunConfig, +func (d *DataPlane) runReceiver(ifID uint16, conn BatchConn, cfg *config.RunConfig, procQs []chan packet) { log.Debug("Run receiver for", "interface", ifID) @@ -704,7 +690,7 @@ func (d *DataPlane) runProcessor(id int, q <-chan packet, } func (d *DataPlane) runForwarder(ifID uint16, conn BatchConn, - cfg *RunConfig, c <-chan packet) { + cfg *config.RunConfig, c <-chan packet) { log.Debug("Initialize forwarder for", "interface", ifID) writeMsgs := make(underlayconn.Messages, cfg.BatchSize) diff --git a/router/dataplane_internal_test.go b/router/dataplane_internal_test.go index 60291aaa4c..ed9fa1283f 100644 --- a/router/dataplane_internal_test.go +++ b/router/dataplane_internal_test.go @@ -38,6 +38,7 @@ import ( "github.com/scionproto/scion/pkg/slayers/path" "github.com/scionproto/scion/pkg/slayers/path/scion" underlayconn "github.com/scionproto/scion/private/underlay/conn" + "github.com/scionproto/scion/router/config" "github.com/scionproto/scion/router/mock_router" ) @@ -75,7 +76,7 @@ func TestReceiver(t *testing.T) { _ = dp.AddInternalInterface(mInternal, net.IP{}) - runConfig := &RunConfig{ + runConfig := &config.RunConfig{ NumProcessors: 1, BatchSize: 64, } @@ -169,7 +170,7 @@ func TestForwarder(t *testing.T) { return ret } dp := prepareDP(ctrl) - runConfig := &RunConfig{ + runConfig := &config.RunConfig{ NumProcessors: 20, BatchSize: 64, } diff --git a/router/dataplane_test.go b/router/dataplane_test.go index 1eb6b6d1d4..8858264e4f 100644 --- a/router/dataplane_test.go +++ b/router/dataplane_test.go @@ -46,6 +46,7 @@ import ( "github.com/scionproto/scion/private/topology" underlayconn "github.com/scionproto/scion/private/underlay/conn" "github.com/scionproto/scion/router" + "github.com/scionproto/scion/router/config" "github.com/scionproto/scion/router/control" "github.com/scionproto/scion/router/mock_router" ) @@ -538,7 +539,7 @@ func TestDataPlaneRun(t *testing.T) { name, tc := name, tc t.Run(name, func(t *testing.T) { t.Parallel() - runConfig := &router.RunConfig{ + runConfig := &config.RunConfig{ NumProcessors: 8, BatchSize: 256, } diff --git a/tools/topology/go.py b/tools/topology/go.py index 85e4c63718..c24907ec6b 100644 --- a/tools/topology/go.py +++ b/tools/topology/go.py @@ -97,6 +97,12 @@ def _build_br_conf(self, topo_id, ia, base, name, v): 'features': translate_features(self.args.features), 'api': { 'addr': prom_addr(v['internal_addr'], DEFAULT_BR_PROM_PORT+700) + }, + 'router': { + 'receive_buffer_size': 1 << 20, + 'send_buffer_size': 0, + 'num_slow_processors': 1, + 'batch_size': 256 } } return raw_entry From 411ee8718bd62c3797172793eebcae358c15e433 Mon Sep 17 00:00:00 2001 From: rohrerj <26304001+rohrerj@users.noreply.github.com> Date: Thu, 27 Jul 2023 17:13:59 +0200 Subject: [PATCH 2/6] modify error message --- router/config/config.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/router/config/config.go b/router/config/config.go index e1a35b86c7..e9876b6ca9 100644 --- a/router/config/config.go +++ b/router/config/config.go @@ -63,8 +63,8 @@ func (cfg *RouterConfig) Validate() error { if cfg.NumProcessors < 0 { return serrors.New("Provided router config is invalid. NumProcessors < 0") } - if cfg.NumSlowPathProcessors <= 0 { - return serrors.New("Provided router config is invalid. NumSlowPathProcessors < 0") + if cfg.NumSlowPathProcessors < 1 { + return serrors.New("Provided router config is invalid. NumSlowPathProcessors < 1") } return nil From 0ef1524406570d97daa20ba954ab533d8cb491c3 Mon Sep 17 00:00:00 2001 From: rohrerj <26304001+rohrerj@users.noreply.github.com> Date: Mon, 31 Jul 2023 21:45:18 +0200 Subject: [PATCH 3/6] resolve PR comments --- doc/manuals/router.rst | 23 +++++++++++++++++++++++ private/underlay/conn/conn.go | 2 +- router/BUILD.bazel | 2 -- router/cmd/router/main.go | 2 +- router/config/config.go | 9 --------- router/config/sample.go | 12 ++++++++---- router/dataplane.go | 17 +++++++++++------ router/dataplane_internal_test.go | 5 ++--- router/dataplane_test.go | 3 +-- tools/topology/go.py | 6 ------ 10 files changed, 47 insertions(+), 34 deletions(-) diff --git a/doc/manuals/router.rst b/doc/manuals/router.rst index 7bebbc39f1..e203fa44c5 100644 --- a/doc/manuals/router.rst +++ b/doc/manuals/router.rst @@ -117,6 +117,29 @@ considers the following options. If this is a relative path, it is interpreted as relative to the current working directory of the program (i.e. **not** relative to the location of this .toml configuration file). +.. object:: router + + .. option:: router.receive_buffer_size = (Default: 0) + + The receive buffer size in bytes. 0 means use system default. + + .. option:: router.send_buffer_size = (Default: 0) + + The send buffer size in bytes. 0 means use system default. + + .. option:: router.num_processors = (Default: GOMAXPROCS) + + The number of fast-path processors. + + .. option:: router.num_slow_processors = (Default: 1) + + The number of slow-path processors. + + .. option:: router.batch_size = (Default: 256) + + The batch size used by the receiver and forwarder to + read or write from / to the network socket. + .. _router-conf-topo: topology.json diff --git a/private/underlay/conn/conn.go b/private/underlay/conn/conn.go index a87724c832..c56c30225f 100644 --- a/private/underlay/conn/conn.go +++ b/private/underlay/conn/conn.go @@ -214,7 +214,7 @@ func (cc *connUDPBase) initConnUDP(network string, laddr, raddr *net.UDPAddr, cf } // Set and confirm receive buffer size - { + if cfg.ReceiveBufferSize != 0 { before, err := sockctrl.GetsockoptInt(c, syscall.SOL_SOCKET, syscall.SO_RCVBUF) if err != nil { return serrors.WrapStr("Error getting SO_RCVBUF socket option (before)", err, diff --git a/router/BUILD.bazel b/router/BUILD.bazel index e89dcc1302..27ad3eb3e5 100644 --- a/router/BUILD.bazel +++ b/router/BUILD.bazel @@ -29,7 +29,6 @@ go_library( "//private/topology:go_default_library", "//private/underlay/conn:go_default_library", "//router/bfd:go_default_library", - "//router/config:go_default_library", "//router/control:go_default_library", "@com_github_google_gopacket//:go_default_library", "@com_github_google_gopacket//layers:go_default_library", @@ -63,7 +62,6 @@ go_test( "//pkg/slayers/path/scion:go_default_library", "//private/topology:go_default_library", "//private/underlay/conn:go_default_library", - "//router/config:go_default_library", "//router/control:go_default_library", "//router/mock_router:go_default_library", "@com_github_golang_mock//gomock:go_default_library", diff --git a/router/cmd/router/main.go b/router/cmd/router/main.go index 496d53694b..c2ecdbdbf6 100644 --- a/router/cmd/router/main.go +++ b/router/cmd/router/main.go @@ -123,7 +123,7 @@ func realMain(ctx context.Context) error { }) g.Go(func() error { defer log.HandlePanic() - runConfig := &config.RunConfig{ + runConfig := &router.RunConfig{ NumProcessors: globalCfg.Router.NumProcessors, NumSlowPathProcessors: globalCfg.Router.NumSlowPathProcessors, BatchSize: globalCfg.Router.BatchSize, diff --git a/router/config/config.go b/router/config/config.go index e9876b6ca9..f3376a3021 100644 --- a/router/config/config.go +++ b/router/config/config.go @@ -71,9 +71,6 @@ func (cfg *RouterConfig) Validate() error { } func (cfg *RouterConfig) InitDefaults() { - if cfg.ReceiveBufferSize == 0 { - cfg.ReceiveBufferSize = 1 << 20 - } if cfg.NumProcessors == 0 { cfg.NumProcessors = runtime.GOMAXPROCS(0) } @@ -89,12 +86,6 @@ func (cfg *RouterConfig) Sample(dst io.Writer, path config.Path, ctx config.CtxM config.WriteString(dst, routerConfigSample) } -type RunConfig struct { - NumProcessors int - NumSlowPathProcessors int - BatchSize int -} - func (cfg *Config) InitDefaults() { config.InitAll( &cfg.General, diff --git a/router/config/sample.go b/router/config/sample.go index 480cad5d4c..43bc647a95 100644 --- a/router/config/sample.go +++ b/router/config/sample.go @@ -15,15 +15,19 @@ package config const routerConfigSample = ` -# The receive buffer size in bytes. -# (default 1048576) -receive_buffer_size = 1048576 +# The receive buffer size in bytes. 0 means use system default. +# (default 0) +receive_buffer_size = 0 # The send buffer size in bytes. 0 means use system default. # (default 0) send_buffer_size = 0 -# The number of slow path processors. +# The number of fast-path processors. +# (default GOMAXPROCS) +num_processors = 8 + +# The number of slow-path processors. # (default 1) num_slow_processors = 1 diff --git a/router/dataplane.go b/router/dataplane.go index 7581903e4c..609ba33589 100644 --- a/router/dataplane.go +++ b/router/dataplane.go @@ -53,7 +53,6 @@ import ( "github.com/scionproto/scion/private/topology" underlayconn "github.com/scionproto/scion/private/underlay/conn" "github.com/scionproto/scion/router/bfd" - "github.com/scionproto/scion/router/config" "github.com/scionproto/scion/router/control" ) @@ -465,7 +464,13 @@ func max(a int, b int) int { return b } -func (d *DataPlane) Run(ctx context.Context, cfg *config.RunConfig) error { +type RunConfig struct { + NumProcessors int + NumSlowPathProcessors int + BatchSize int +} + +func (d *DataPlane) Run(ctx context.Context, cfg *RunConfig) error { d.mtx.Lock() d.running = true d.initMetrics() @@ -510,7 +515,7 @@ func (d *DataPlane) Run(ctx context.Context, cfg *config.RunConfig) error { // initializePacketPool calculates the size of the packet pool based on the // current dataplane settings and allocates all the buffers -func (d *DataPlane) initPacketPool(cfg *config.RunConfig, processorQueueSize int) { +func (d *DataPlane) initPacketPool(cfg *RunConfig, processorQueueSize int) { poolSize := len(d.interfaces)*cfg.BatchSize + cfg.NumProcessors*(processorQueueSize+1) + len(d.interfaces)*(2*cfg.BatchSize) @@ -523,7 +528,7 @@ func (d *DataPlane) initPacketPool(cfg *config.RunConfig, processorQueueSize int } // initializes the processing routines and forwarders queues -func initQueues(cfg *config.RunConfig, interfaces map[uint16]BatchConn, +func initQueues(cfg *RunConfig, interfaces map[uint16]BatchConn, processorQueueSize int) ([]chan packet, map[uint16]chan packet) { procQs := make([]chan packet, cfg.NumProcessors) @@ -549,7 +554,7 @@ type packet struct { rawPacket []byte } -func (d *DataPlane) runReceiver(ifID uint16, conn BatchConn, cfg *config.RunConfig, +func (d *DataPlane) runReceiver(ifID uint16, conn BatchConn, cfg *RunConfig, procQs []chan packet) { log.Debug("Run receiver for", "interface", ifID) @@ -690,7 +695,7 @@ func (d *DataPlane) runProcessor(id int, q <-chan packet, } func (d *DataPlane) runForwarder(ifID uint16, conn BatchConn, - cfg *config.RunConfig, c <-chan packet) { + cfg *RunConfig, c <-chan packet) { log.Debug("Initialize forwarder for", "interface", ifID) writeMsgs := make(underlayconn.Messages, cfg.BatchSize) diff --git a/router/dataplane_internal_test.go b/router/dataplane_internal_test.go index ed9fa1283f..60291aaa4c 100644 --- a/router/dataplane_internal_test.go +++ b/router/dataplane_internal_test.go @@ -38,7 +38,6 @@ import ( "github.com/scionproto/scion/pkg/slayers/path" "github.com/scionproto/scion/pkg/slayers/path/scion" underlayconn "github.com/scionproto/scion/private/underlay/conn" - "github.com/scionproto/scion/router/config" "github.com/scionproto/scion/router/mock_router" ) @@ -76,7 +75,7 @@ func TestReceiver(t *testing.T) { _ = dp.AddInternalInterface(mInternal, net.IP{}) - runConfig := &config.RunConfig{ + runConfig := &RunConfig{ NumProcessors: 1, BatchSize: 64, } @@ -170,7 +169,7 @@ func TestForwarder(t *testing.T) { return ret } dp := prepareDP(ctrl) - runConfig := &config.RunConfig{ + runConfig := &RunConfig{ NumProcessors: 20, BatchSize: 64, } diff --git a/router/dataplane_test.go b/router/dataplane_test.go index 8858264e4f..1eb6b6d1d4 100644 --- a/router/dataplane_test.go +++ b/router/dataplane_test.go @@ -46,7 +46,6 @@ import ( "github.com/scionproto/scion/private/topology" underlayconn "github.com/scionproto/scion/private/underlay/conn" "github.com/scionproto/scion/router" - "github.com/scionproto/scion/router/config" "github.com/scionproto/scion/router/control" "github.com/scionproto/scion/router/mock_router" ) @@ -539,7 +538,7 @@ func TestDataPlaneRun(t *testing.T) { name, tc := name, tc t.Run(name, func(t *testing.T) { t.Parallel() - runConfig := &config.RunConfig{ + runConfig := &router.RunConfig{ NumProcessors: 8, BatchSize: 256, } diff --git a/tools/topology/go.py b/tools/topology/go.py index c24907ec6b..85e4c63718 100644 --- a/tools/topology/go.py +++ b/tools/topology/go.py @@ -97,12 +97,6 @@ def _build_br_conf(self, topo_id, ia, base, name, v): 'features': translate_features(self.args.features), 'api': { 'addr': prom_addr(v['internal_addr'], DEFAULT_BR_PROM_PORT+700) - }, - 'router': { - 'receive_buffer_size': 1 << 20, - 'send_buffer_size': 0, - 'num_slow_processors': 1, - 'batch_size': 256 } } return raw_entry From 895541464f7a5a015e096f859fbfd17e19d03535 Mon Sep 17 00:00:00 2001 From: rohrerj <26304001+rohrerj@users.noreply.github.com> Date: Thu, 3 Aug 2023 16:31:21 +0200 Subject: [PATCH 4/6] changed to router manual --- doc/manuals/router.rst | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/doc/manuals/router.rst b/doc/manuals/router.rst index e203fa44c5..9843b51787 100644 --- a/doc/manuals/router.rst +++ b/doc/manuals/router.rst @@ -129,11 +129,21 @@ considers the following options. .. option:: router.num_processors = (Default: GOMAXPROCS) - The number of fast-path processors. + Number of goroutines started for SCION packets processing. + These goroutines make the routing decision for the SCION packets by inspecting, validating and + updating the path information in the packet header. Packets are processed asynchronously from the + corresponding read/write operations on the individual interface sockets. + `Goroutines `_ + are the Go pramming language's light-weight user-space concurrency primitives. Go's runtime schedules + goroutines on top of a fixed number of kernel threads. The number of kernel threads is controlled by + the GOMAXPROCS environment variable. `See also `_. + By default, the router uses GOMAXPROCS packet processor goroutines, i.e. exactly one goroutine for + each kernel thread created by the runtime. .. option:: router.num_slow_processors = (Default: 1) - The number of slow-path processors. + Number of goroutines started for the slow-path processing. This feature will be implemented soon. Currently + this setting has no effect. .. option:: router.batch_size = (Default: 256) From e361454b6027356deb27ad6c995037c9ae77a9a7 Mon Sep 17 00:00:00 2001 From: rohrerj <26304001+rohrerj@users.noreply.github.com> Date: Fri, 4 Aug 2023 01:45:41 +0200 Subject: [PATCH 5/6] reformatted router manual --- doc/manuals/router.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/manuals/router.rst b/doc/manuals/router.rst index 9843b51787..7c6a2c3e6a 100644 --- a/doc/manuals/router.rst +++ b/doc/manuals/router.rst @@ -133,11 +133,13 @@ considers the following options. These goroutines make the routing decision for the SCION packets by inspecting, validating and updating the path information in the packet header. Packets are processed asynchronously from the corresponding read/write operations on the individual interface sockets. + `Goroutines `_ are the Go pramming language's light-weight user-space concurrency primitives. Go's runtime schedules goroutines on top of a fixed number of kernel threads. The number of kernel threads is controlled by - the GOMAXPROCS environment variable. `See also `_. - By default, the router uses GOMAXPROCS packet processor goroutines, i.e. exactly one goroutine for + the ``GOMAXPROCS`` environment variable. See also the `go runtime documentation `_. + + By default, the router uses ``GOMAXPROCS`` packet processor goroutines, i.e. exactly one goroutine for each kernel thread created by the runtime. .. option:: router.num_slow_processors = (Default: 1) From 847c498db824aab9428aedccac424b31adf0b0d4 Mon Sep 17 00:00:00 2001 From: rohrerj <26304001+rohrerj@users.noreply.github.com> Date: Fri, 4 Aug 2023 17:15:14 +0200 Subject: [PATCH 6/6] removed trailing spaces --- doc/manuals/router.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/manuals/router.rst b/doc/manuals/router.rst index 7c6a2c3e6a..baffcb0eab 100644 --- a/doc/manuals/router.rst +++ b/doc/manuals/router.rst @@ -138,7 +138,7 @@ considers the following options. are the Go pramming language's light-weight user-space concurrency primitives. Go's runtime schedules goroutines on top of a fixed number of kernel threads. The number of kernel threads is controlled by the ``GOMAXPROCS`` environment variable. See also the `go runtime documentation `_. - + By default, the router uses ``GOMAXPROCS`` packet processor goroutines, i.e. exactly one goroutine for each kernel thread created by the runtime.