Skip to content

Commit

Permalink
BR: reconnect to dispatcher support
Browse files Browse the repository at this point in the history
Add logic to support automatic reconnect to dispatcher in case of socket
error.
The feature is enable in the config with the ReconnectToDispatcher
option in the General config section.
  • Loading branch information
sgmonroy committed Aug 23, 2019
1 parent b070422 commit 1fb8ac7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions go/border/rctrl/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ go_library(
"//go/lib/log:go_default_library",
"//go/lib/snet:go_default_library",
"//go/lib/sock/reliable:go_default_library",
"//go/lib/sock/reliable/reconnect:go_default_library",
],
)
16 changes: 12 additions & 4 deletions go/border/rctrl/ctrl.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/scionproto/scion/go/lib/log"
"github.com/scionproto/scion/go/lib/snet"
"github.com/scionproto/scion/go/lib/sock/reliable"
"github.com/scionproto/scion/go/lib/sock/reliable/reconnect"
)

const (
Expand All @@ -40,21 +41,28 @@ var (
logger log.Logger
)

func Control(sRevInfoQ chan rpkt.RawSRevCallbackArgs) {
func Control(sRevInfoQ chan rpkt.RawSRevCallbackArgs, dispatcherReconnect bool) {
var err error
logger = log.New("Part", "Control")
ctx := rctx.Get()
ia = ctx.Conf.IA
if err = snet.Init(ia, "", reliable.NewDispatcherService("")); err != nil {
fatal.Fatal(common.NewBasicError("Initializing SNET", err))
dispatcherService := reliable.NewDispatcherService("")
if dispatcherReconnect {
dispatcherService = reconnect.NewDispatcherService(dispatcherService)
}
scionNetwork := snet.NewCustomNetworkWithPR(ia,
&snet.DefaultPacketDispatcherService{
Dispatcher: dispatcherService,
},
nil,
)
ctrlAddr := ctx.Conf.BR.CtrlAddrs
pub := &snet.Addr{IA: ia, Host: ctrlAddr.IPv4.PublicAddr()}
bind := &snet.Addr{IA: ia, Host: ctrlAddr.IPv4.BindAddr()}
if bind.Host == nil {
bind = nil
}
snetConn, err = snet.ListenSCIONWithBindSVC("udp4", pub, bind, addr.SvcNone)
snetConn, err = scionNetwork.ListenSCIONWithBindSVC("udp4", pub, bind, addr.SvcNone, 0)
if err != nil {
fatal.Fatal(common.NewBasicError("Listening on address", err, "addr", ctrlAddr))
}
Expand Down
2 changes: 1 addition & 1 deletion go/border/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func (r *Router) Start() {
}()
go func() {
defer log.LogPanicAndExit()
rctrl.Control(r.sRevInfoQ)
rctrl.Control(r.sRevInfoQ, cfg.General.ReconnectToDispatcher)
}()
if err := r.startDiscovery(); err != nil {
fatal.Fatal(common.NewBasicError("Unable to start discovery", err))
Expand Down

0 comments on commit 1fb8ac7

Please sign in to comment.