diff --git a/dispatcher/dispatcher.go b/dispatcher/dispatcher.go index 64b44657e3..7dbb287787 100644 --- a/dispatcher/dispatcher.go +++ b/dispatcher/dispatcher.go @@ -31,19 +31,11 @@ import ( "github.com/scionproto/scion/private/topology" ) -const ( - ErrUnsupportedL4 common.ErrMsg = "unsupported SCION L4 protocol" - // ErrUnsupportedDestination common.ErrMsg = "unsupported destination address type" - // ErrUnsupportedSCMPDestination common.ErrMsg = "unsupported SCMP destination address type" - // ErrUnsupportedQuotedL4Type common.ErrMsg = "unsupported quoted L4 protocol type" - // ErrMalformedL4Quote common.ErrMsg = "malformed L4 quote" - // ReceiveBufferSize is the size of receive buffers used by the dispatcher. - ReceiveBufferSize = 1 << 20 - // SendBufferSize is the size of the send buffers used by the dispatcher. - SendBufferSize = 1 << 20 -) +const ErrUnsupportedL4 common.ErrMsg = "unsupported SCION L4 protocol" -// Server is the main object allowing to create new SCION connections. +// Server is the main object allowing to forward SCION packets coming +// from legacy BR to the final endhost application and to handle SCMP +// info packets destined to this endhost. type Server struct { // topo keeps the topology for the local AS. It can keep multiple ASes // in case we run several topologies locally, e.g., developer environment. diff --git a/gateway/gateway.go b/gateway/gateway.go index ea47c85d9a..2ba0d13809 100644 --- a/gateway/gateway.go +++ b/gateway/gateway.go @@ -474,8 +474,6 @@ func (g *Gateway) Run(ctx context.Context) error { scionNetwork := &snet.SCIONNetwork{ LocalIA: localIA, Connector: &snet.DefaultConnector{ - // Enable transparent reconnections to the dispatcher - // Forward revocations to Daemon SCMPHandler: snet.DefaultSCMPHandler{ RevocationHandler: revocationHandler, SCMPErrors: g.Metrics.SCMPErrors, diff --git a/gateway/pathhealth/pathwatcher.go b/gateway/pathhealth/pathwatcher.go index ee2cc8616b..6c7f13228b 100644 --- a/gateway/pathhealth/pathwatcher.go +++ b/gateway/pathhealth/pathwatcher.go @@ -78,8 +78,6 @@ func (f *DefaultPathWatcherFactory) New( } return create(remote) } - // FIXME(JordiSubira): Keep or change the listening port, once we decide - // how SCMP are addressed. nc, err := (&snet.DefaultConnector{ SCMPHandler: scmpHandler{ wrappedHandler: snet.DefaultSCMPHandler{ diff --git a/private/app/path/pathprobe/paths.go b/private/app/path/pathprobe/paths.go index 7bfcc3402e..84831d106b 100644 --- a/private/app/path/pathprobe/paths.go +++ b/private/app/path/pathprobe/paths.go @@ -103,7 +103,7 @@ type Prober struct { // an appropriate local IP endpoint depending on the path that should be probed. Note, LocalIP // should not be set, unless you know what you are doing. LocalIP net.IP - // Metrics injected into snet.SCIONPacketConnMetrics. + // Metrics injected into snet.DefaultConnector. SCIONPacketConnMetrics snet.SCIONPacketConnMetrics } diff --git a/private/env/logging.go b/private/env/logging.go index 889124e737..8287339711 100644 --- a/private/env/logging.go +++ b/private/env/logging.go @@ -32,6 +32,9 @@ var ( // LogAppStarted should be called by applications as soon as logging is // initialized. func LogAppStarted(svcType, elemID string) error { + // XXX(JordiSubira): Right now RunsInDocker() only is Linux-compatible. + // If we are going to run apps in docker also in macOS (and potentially in Windows) + // we should make the method compatible. inDocker := false if runtime.GOOS == "linux" { var err error diff --git a/private/service/statuspages.go b/private/service/statuspages.go index 22fcd496ad..5f893cf836 100644 --- a/private/service/statuspages.go +++ b/private/service/statuspages.go @@ -147,6 +147,9 @@ func NewConfigStatusPage(config interface{}) StatusPage { func NewInfoStatusPage() StatusPage { handler := func(w http.ResponseWriter, r *http.Request) { info := env.VersionInfo() + // XXX(JordiSubira): Right now RunsInDocker() only is Linux-compatible. + // If we are going to run apps in docker also in macOS (and potentially in Windows) + // we should make the method compatible. inDocker := false if runtime.GOOS == "linux" { var err error diff --git a/private/topology/topology.go b/private/topology/topology.go index 7317c4ae80..1d3f2a6f95 100644 --- a/private/topology/topology.go +++ b/private/topology/topology.go @@ -34,7 +34,7 @@ import ( const ( // EndhostPort is the underlay port that SCION binds to on non-routers. EndhostPort = underlay.EndhostPort - // TODO(JordiSubira): Yet to be defined. + // TODO(JordiSubira): Make it configurable. HostPortRangeLow = 0 HostPortRangeHigh = 1<<16 - 1 ) diff --git a/private/underlay/conn/conn.go b/private/underlay/conn/conn.go index a359820f60..bfec94e4c9 100644 --- a/private/underlay/conn/conn.go +++ b/private/underlay/conn/conn.go @@ -32,13 +32,6 @@ import ( "github.com/scionproto/scion/private/underlay/sockctrl" ) -const ( - // ReceiveBufferSize is the size of receive buffers used by the dispatcher. - ReceiveBufferSize = 1 << 20 - // SendBufferSize is the size of the send buffers used by the dispatcher. - SendBufferSize = 1 << 20 -) - // Messages is a list of ipX.Messages. It is necessary to hide the type alias // between ipv4.Message, ipv6.Message and socket.Message. type Messages []ipv4.Message @@ -85,42 +78,6 @@ func New(listen, remote *net.UDPAddr, cfg *Config) (Conn, error) { return newConnUDPIPv6(listen, remote, cfg) } -// OpenConn opens an underlay socket that tracks additional socket information -// such as packets dropped due to buffer full. -// -// Note that Go-style dual-stacked IPv4/IPv6 connections are not supported. If -// network is udp, it will be treated as udp4. -func OpenConn(addr *net.UDPAddr) (net.PacketConn, error) { - // We cannot allow the Go standard library to open both types of sockets - // because the socket options are specific to only one socket type, so we - // degrade udp to only udp4. - listeningAddr := copyUDPAddr(addr) - if listeningAddr == nil { - listeningAddr = &net.UDPAddr{ - IP: net.IPv4zero, - } - } - if (listeningAddr.Network() == "udp" || listeningAddr.Network() == "udp4") && - listeningAddr.IP == nil { - listeningAddr.IP = net.IPv4zero - } - if listeningAddr.Network() == "udp6" && listeningAddr.IP == nil { - listeningAddr.IP = net.IPv6zero - } - - // TODO(JordiSubira): Should we keep a default config or use the passed-through - // configuration. - c, err := New(listeningAddr, nil, &Config{ - SendBufferSize: SendBufferSize, - ReceiveBufferSize: ReceiveBufferSize, - }) - if err != nil { - return nil, serrors.WrapStr("unable to open conn", err) - } - - return &underlayConnWrapper{Conn: c}, nil -} - type connUDPIPv4 struct { connUDPBase pconn *ipv4.PacketConn @@ -334,53 +291,3 @@ func NewReadMessages(n int) Messages { } return m } - -// underlayConnWrapper wraps a specialized underlay Conn into a net.PacketConn -// implementation. Only *net.UDPAddr addressing is supported. -type underlayConnWrapper struct { - // Conn is the wrapped underlay connection object. - Conn -} - -func (o *underlayConnWrapper) ReadFrom(p []byte) (int, net.Addr, error) { - return o.Conn.ReadFrom(p) -} - -func (o *underlayConnWrapper) WriteTo(p []byte, a net.Addr) (int, error) { - udpAddr, ok := a.(*net.UDPAddr) - if !ok { - return 0, serrors.New("address is not UDP", "addr", a) - } - return o.Conn.WriteTo(p, udpAddr) -} - -func (o *underlayConnWrapper) Close() error { - return o.Conn.Close() -} - -func (o *underlayConnWrapper) LocalAddr() net.Addr { - return o.Conn.LocalAddr() -} - -func (o *underlayConnWrapper) SetDeadline(t time.Time) error { - return o.Conn.SetDeadline(t) -} - -func (o *underlayConnWrapper) SetReadDeadline(t time.Time) error { - return o.Conn.SetReadDeadline(t) -} - -func (o *underlayConnWrapper) SetWriteDeadline(t time.Time) error { - return o.Conn.SetWriteDeadline(t) -} - -func copyUDPAddr(a *net.UDPAddr) *net.UDPAddr { - if a == nil { - return nil - } - return &net.UDPAddr{ - IP: append(a.IP[:0:0], a.IP...), - Port: a.Port, - Zone: a.Zone, - } -} diff --git a/private/underlay/conn/conn_test.go b/private/underlay/conn/conn_test.go index cf17389c4c..af9a0b4d43 100644 --- a/private/underlay/conn/conn_test.go +++ b/private/underlay/conn/conn_test.go @@ -24,13 +24,10 @@ import ( "github.com/scionproto/scion/pkg/private/xtest" ) -func TestOpenConn(t *testing.T) { +func TestNew(t *testing.T) { testCases := map[string]struct { addr *net.UDPAddr }{ - "nil": { - addr: nil, - }, "undefined_addr": { addr: xtest.MustParseUDPAddr(t, "0.0.0.0:0"), }, @@ -40,10 +37,13 @@ func TestOpenConn(t *testing.T) { } for name, tc := range testCases { t.Run(name, func(t *testing.T) { - sc, err := OpenConn(tc.addr) + sc, err := New(tc.addr, nil, &Config{ + SendBufferSize: 0, + ReceiveBufferSize: 0, + }) require.NoError(t, err) defer sc.Close() - lAddr := sc.LocalAddr().(*net.UDPAddr) + lAddr := sc.LocalAddr() if tc.addr != nil && !tc.addr.IP.IsUnspecified() { assert.Equal(t, tc.addr.IP, lAddr.IP) @@ -57,7 +57,7 @@ func TestOpenConn(t *testing.T) { require.NoError(t, err) defer cc.Close() - exchangeMessages := func(sc net.PacketConn, cc Conn) { + exchangeMessages := func(sc Conn, cc Conn) { msg := []byte("hello") go func() { diff --git a/router/dataplane.go b/router/dataplane.go index b5eed6344c..55762af16c 100644 --- a/router/dataplane.go +++ b/router/dataplane.go @@ -835,7 +835,6 @@ func newPacketProcessor(d *DataPlane) *scionPacketProcessor { drkeyInput: make([]byte, spao.MACBufferSize), }, // TODO(JordiSubira): Replace this with a useful implementation. - drkeyProvider: &drkeyutil.FakeProvider{ EpochDuration: drkeyutil.LoadEpochDuration(), AcceptanceWindow: drkeyutil.LoadAcceptanceWindow(), @@ -1766,12 +1765,8 @@ func addEndhostPort(lastLayer gopacket.DecodingLayer, dst []byte) (*net.UDPAddr, if port < topology.HostPortRangeLow || port > topology.HostPortRangeHigh { port = topology.EndhostPort } - log.Debug("TBR XXXJ:", "udp port that will be rewritten", port) return &net.UDPAddr{IP: dst, Port: int(port)}, nil case slayers.L4SCMP: - // TODO(JordiSubira): On-going discussion regarding SCMP dst port - log.Debug("TBR XXXJ:", - "sending SCMP packet to", &net.UDPAddr{IP: dst, Port: topology.EndhostPort}) return &net.UDPAddr{IP: dst, Port: topology.EndhostPort}, nil default: log.Debug(fmt.Sprintf("Port rewriting not supported for protcol number %v", l4Type)) diff --git a/tools/topology/config.py b/tools/topology/config.py index 22522a373a..5fcabb91c9 100644 --- a/tools/topology/config.py +++ b/tools/topology/config.py @@ -130,7 +130,7 @@ def _generate_go(self, topo_dicts): go_gen.generate_br() go_gen.generate_sciond() go_gen.generate_control_service() - go_gen.generate_disp(topo_dicts) + go_gen.generate_disp() def _go_args(self, topo_dicts): return GoGenArgs(self.args, self.topo_config, topo_dicts, self.networks) diff --git a/tools/topology/go.py b/tools/topology/go.py index 332361633c..aee2cc6a3c 100644 --- a/tools/topology/go.py +++ b/tools/topology/go.py @@ -170,7 +170,7 @@ def _build_sciond_conf(self, topo_id, ia, base): } return raw_entry - def generate_disp(self, topo_dicts): + def generate_disp(self): if self.args.docker: self._gen_disp_docker() else: