Skip to content

Commit

Permalink
pass
Browse files Browse the repository at this point in the history
  • Loading branch information
JordiSubira committed Sep 29, 2023
1 parent 768a442 commit d81d71f
Show file tree
Hide file tree
Showing 12 changed files with 21 additions and 125 deletions.
16 changes: 4 additions & 12 deletions dispatcher/dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 0 additions & 2 deletions gateway/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 0 additions & 2 deletions gateway/pathhealth/pathwatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
2 changes: 1 addition & 1 deletion private/app/path/pathprobe/paths.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
3 changes: 3 additions & 0 deletions private/env/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions private/service/statuspages.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion private/topology/topology.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
93 changes: 0 additions & 93 deletions private/underlay/conn/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
}
}
14 changes: 7 additions & 7 deletions private/underlay/conn/conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
},
Expand All @@ -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)
Expand All @@ -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() {
Expand Down
5 changes: 0 additions & 5 deletions router/dataplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion tools/topology/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tools/topology/go.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit d81d71f

Please sign in to comment.