Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SIG: Pass both control and data address in probes #3689

Merged
merged 1 commit into from
Mar 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions go/lib/ctrl/sig_mgmt/addr.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ import (
var _ proto.Cerealizable = (*Addr)(nil)

type Addr struct {
Ctrl *hostinfo.Host
EncapPort uint16
Ctrl *hostinfo.Host
Data *hostinfo.Host
}

func NewAddr(host addr.HostAddr, ctrlPort, encapPort uint16) *Addr {
func NewAddr(ctrl addr.HostAddr, ctrlPort uint16, data addr.HostAddr, dataPort uint16) *Addr {
return &Addr{
Ctrl: hostinfo.FromHostAddr(host, ctrlPort),
EncapPort: encapPort,
Ctrl: hostinfo.FromHostAddr(ctrl, ctrlPort),
Data: hostinfo.FromHostAddr(data, dataPort),
}
}

Expand All @@ -52,6 +52,6 @@ func (a *Addr) Write(b common.RawBytes) (int, error) {
}

func (a *Addr) String() string {
return fmt.Sprintf("Host: %s CtrlPort: %d EncapPort: %d",
a.Ctrl.Host(), a.Ctrl.Port, a.EncapPort)
return fmt.Sprintf("Ctrl: %s CtrlPort: %d Data: %s DataPort: %d",
a.Ctrl.Host(), a.Ctrl.Port, a.Data.Host(), a.Data.Port)
}
81 changes: 51 additions & 30 deletions go/proto/sig.capnp.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion go/sig/egress/session/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func NewSession(dstIA addr.IA, sessId sig_mgmt.SessionType, logger log.Logger,
s.ring = ringbuf.New(64, nil, fmt.Sprintf("egress_%s_%s", dstIA, sessId))
// Not using a fixed local port, as this is for outgoing data only.
s.conn, err = sigcmn.Network.Listen(context.Background(), "udp",
&net.UDPAddr{IP: sigcmn.Host.IP()}, addr.SvcNone)
&net.UDPAddr{IP: sigcmn.DataAddr}, addr.SvcNone)
s.sessMonStop = make(chan struct{})
s.sessMonStopped = make(chan struct{})
s.pktDispStop = make(chan struct{})
Expand Down
5 changes: 3 additions & 2 deletions go/sig/egress/session/sessmon.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@ func (sm *sessMonitor) sendReq() {
return
}
sm.updateMsgId = sig_mgmt.MsgIdType(time.Now().UnixNano())
spld, err := sig_mgmt.NewPld(sm.updateMsgId, sig_mgmt.NewPollReq(sigcmn.MgmtAddr,
mgmtAddr := sigcmn.GetMgmtAddr()
spld, err := sig_mgmt.NewPld(sm.updateMsgId, sig_mgmt.NewPollReq(&mgmtAddr,
sm.sess.SessId))
if err != nil {
sm.logger.Error("sessMonitor: Error creating SIGCtrl payload", "err", err)
Expand Down Expand Up @@ -321,7 +322,7 @@ func (sm *sessMonitor) handleRep(rpld *sigdisp.RegPld) {
IA: sm.smRemote.Sig.IA,
Host: pollRep.Addr.Ctrl.Host(),
CtrlL4Port: int(pollRep.Addr.Ctrl.Port),
EncapL4Port: int(pollRep.Addr.EncapPort),
EncapL4Port: int(pollRep.Addr.Data.Port),
}
// Update session's remote, if needed.
sessRemote := sm.sess.Remote()
Expand Down
1 change: 1 addition & 0 deletions go/sig/egress/worker/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ go_library(
importpath = "github.com/scionproto/scion/go/sig/egress/worker",
visibility = ["//visibility:public"],
deps = [
"//go/lib/addr:go_default_library",
"//go/lib/common:go_default_library",
"//go/lib/ctrl/sig_mgmt:go_default_library",
"//go/lib/l4:go_default_library",
Expand Down
4 changes: 3 additions & 1 deletion go/sig/egress/worker/worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"net"
"time"

"github.com/scionproto/scion/go/lib/addr"
"github.com/scionproto/scion/go/lib/common"
"github.com/scionproto/scion/go/lib/ctrl/sig_mgmt"
"github.com/scionproto/scion/go/lib/l4"
Expand Down Expand Up @@ -220,7 +221,8 @@ func (w *worker) resetFrame(f *frame) {
if remote != nil {
w.currSig = remote.Sig
if w.currSig != nil {
addrLen = uint16(spkt.AddrHdrLen(w.currSig.Host, sigcmn.Host))
addrLen = uint16(spkt.AddrHdrLen(w.currSig.Host,
addr.HostFromIP(sigcmn.DataAddr)))
}
w.currPathEntry = nil
if remote.SessPath != nil {
Expand Down
7 changes: 4 additions & 3 deletions go/sig/internal/base/pollhdlr.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package base

import (
"github.com/scionproto/scion/go/lib/addr"
"github.com/scionproto/scion/go/lib/common"
"github.com/scionproto/scion/go/lib/ctrl"
"github.com/scionproto/scion/go/lib/ctrl/sig_mgmt"
Expand All @@ -35,9 +36,9 @@ func PollReqHdlr() {
"src", rpld.Addr, "type", common.TypeOf(rpld.P), "Id", rpld.Id, "pld", rpld.P)
continue
}
//log.Debug("PollReqHdlr: got PollReq", "src", rpld.Addr, "pld", req,
// "replyAddr", sigcmn.MgmtAddr, "replySession", req.Session)
spld, err := sig_mgmt.NewPld(rpld.Id, sig_mgmt.NewPollRep(sigcmn.MgmtAddr, req.Session))
addr := sig_mgmt.NewAddr(addr.HostFromIP(sigcmn.CtrlAddr), uint16(sigcmn.CtrlPort),
addr.HostFromIP(sigcmn.DataAddr), uint16(sigcmn.DataPort))
spld, err := sig_mgmt.NewPld(rpld.Id, sig_mgmt.NewPollRep(addr, req.Session))
if err != nil {
log.Error("PollReqHdlr: Error creating SIGCtrl payload", "err", err)
break
Expand Down
3 changes: 2 additions & 1 deletion go/sig/internal/ingress/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package ingress
import (
"context"
"io"
"net"

"github.com/scionproto/scion/go/lib/addr"
"github.com/scionproto/scion/go/lib/fatal"
Expand All @@ -28,7 +29,7 @@ import (
func Init(tunIO io.ReadWriteCloser) {
fatal.Check()
conn, err := sigcmn.Network.Listen(context.Background(), "udp",
sigcmn.EncapSnetAddr().Host, addr.SvcNone)
&net.UDPAddr{IP: sigcmn.DataAddr, Port: sigcmn.DataPort}, addr.SvcNone)
if err != nil {
log.Crit("Unable to initialize ingress connection", "err", err)
fatal.Fatal(err)
Expand Down
29 changes: 15 additions & 14 deletions go/sig/internal/sigcmn/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,29 +46,29 @@ var (
)

var (
IA addr.IA
Host addr.HostAddr

IA addr.IA
PathMgr pathmgr.Resolver
Dispatcher reliable.Dispatcher
Network *snet.SCIONNetwork
CtrlAddr net.IP
CtrlPort int
DataAddr net.IP
DataPort int
CtrlConn snet.Conn
MgmtAddr *sig_mgmt.Addr
encapPort uint16
)

func Init(cfg sigconfig.SigConf, sdCfg env.SCIONDClient) error {
IA = cfg.IA
Host = addr.HostFromIP(cfg.IP)
MgmtAddr = sig_mgmt.NewAddr(Host, cfg.CtrlPort, cfg.EncapPort)
encapPort = cfg.EncapPort

CtrlAddr = cfg.IP
CtrlPort = int(cfg.CtrlPort)
DataAddr = cfg.IP
DataPort = int(cfg.EncapPort)
network, resolver, err := initNetwork(cfg, sdCfg)
if err != nil {
return common.NewBasicError("Error creating local SCION Network context", err)
}
conn, err := network.Listen(context.Background(), "udp",
&net.UDPAddr{IP: Host.IP(), Port: int(cfg.CtrlPort)}, addr.SvcSIG)
&net.UDPAddr{IP: CtrlAddr, Port: CtrlPort}, addr.SvcSIG)
if err != nil {
return common.NewBasicError("Error creating ctrl socket", err)
}
Expand Down Expand Up @@ -151,14 +151,15 @@ func newDispatcher(cfg sigconfig.SigConf) (reliable.Dispatcher, error) {
return dispServer, nil
}

func EncapSnetAddr() *snet.UDPAddr {
return &snet.UDPAddr{IA: IA, Host: &net.UDPAddr{IP: Host.IP(), Port: int(encapPort)}}
}

func ValidatePort(desc string, port int) error {
if port < 1 || port > MaxPort {
return common.NewBasicError("Invalid port", nil,
"min", 1, "max", MaxPort, "actual", port, "desc", desc)
}
return nil
}

func GetMgmtAddr() sig_mgmt.Addr {
return *sig_mgmt.NewAddr(addr.HostFromIP(CtrlAddr), uint16(CtrlPort),
addr.HostFromIP(DataAddr), uint16(DataPort))
}
8 changes: 4 additions & 4 deletions go/sig/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,16 +150,16 @@ func setupTun() (io.ReadWriteCloser, error) {
return nil, err
}
src := cfg.Sig.SrcIP4
if len(src) == 0 && cfg.Sig.IP.To4() != nil {
src = cfg.Sig.IP
if len(src) == 0 && sigcmn.CtrlAddr.To4() != nil {
src = sigcmn.CtrlAddr
}
if err = xnet.AddRoute(cfg.Sig.TunRTableId, tunLink, sigcmn.DefV4Net, src); err != nil {
return nil,
common.NewBasicError("Unable to add default IPv4 route to SIG routing table", err)
}
src = cfg.Sig.SrcIP6
if len(src) == 0 && cfg.Sig.IP.To16() != nil && cfg.Sig.IP.To4() == nil {
src = cfg.Sig.IP
if len(src) == 0 && sigcmn.CtrlAddr.To16() != nil && sigcmn.CtrlAddr.To4() == nil {
src = sigcmn.CtrlAddr
}
if err = xnet.AddRoute(cfg.Sig.TunRTableId, tunLink, sigcmn.DefV6Net, src); err != nil {
return nil,
Expand Down
2 changes: 1 addition & 1 deletion proto/sig.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ struct SIGPoll {

struct SIGAddr {
ctrl @0 :Sciond.HostInfo;
encapPort @1 :UInt16;
data @1 :Sciond.HostInfo;
}