Skip to content

Commit

Permalink
BR: remove netconf package (#2966)
Browse files Browse the repository at this point in the history
Remove the border/netconf package and instead modify the topology with
the useful meta information such as the map of owned interfaces per BR.

Also add the key to both the BRInfo and IFInfo such that when references
are passed around, it is stright forward to know the BR name and
interface ID respectively.
  • Loading branch information
sgmonroy authored Aug 7, 2019
1 parent 8097edc commit 434510d
Show file tree
Hide file tree
Showing 18 changed files with 83 additions and 233 deletions.
2 changes: 0 additions & 2 deletions go/border/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ go_library(
deps = [
"//go/border/brconf:go_default_library",
"//go/border/metrics:go_default_library",
"//go/border/netconf:go_default_library",
"//go/border/rcmn:go_default_library",
"//go/border/rctrl:go_default_library",
"//go/border/rctx:go_default_library",
Expand Down Expand Up @@ -64,7 +63,6 @@ go_test(
deps = [
"//go/border/brconf:go_default_library",
"//go/border/metrics:go_default_library",
"//go/border/netconf:go_default_library",
"//go/border/rctx:go_default_library",
"//go/border/rpkt:go_default_library",
"//go/lib/addr:go_default_library",
Expand Down
1 change: 0 additions & 1 deletion go/border/brconf/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ go_library(
importpath = "github.com/scionproto/scion/go/border/brconf",
visibility = ["//visibility:public"],
deps = [
"//go/border/netconf:go_default_library",
"//go/lib/addr:go_default_library",
"//go/lib/as_conf:go_default_library",
"//go/lib/common:go_default_library",
Expand Down
18 changes: 0 additions & 18 deletions go/border/brconf/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (

"golang.org/x/crypto/pbkdf2"

"github.com/scionproto/scion/go/border/netconf"
"github.com/scionproto/scion/go/lib/addr"
"github.com/scionproto/scion/go/lib/as_conf"
"github.com/scionproto/scion/go/lib/common"
Expand All @@ -49,8 +48,6 @@ type BRConf struct {
MasterKeys keyconf.Master
// HFMacPool is the pool of Hop Field MAC generation instances.
HFMacPool *sync.Pool
// Net is the network configuration of this router.
Net *netconf.NetConf
// Dir is the configuration directory.
Dir string
}
Expand All @@ -72,9 +69,6 @@ func Load(id, confDir string) (*BRConf, error) {
if err := conf.initMacPool(); err != nil {
return nil, err
}
if err := conf.initNet(); err != nil {
return nil, err
}
return conf, nil
}

Expand All @@ -90,9 +84,6 @@ func WithNewTopo(id string, topo *topology.Topo, oldConf *BRConf) (*BRConf, erro
if err := conf.initTopo(id, topo); err != nil {
return nil, common.NewBasicError("Unable to initialize topo", err)
}
if err := conf.initNet(); err != nil {
return nil, common.NewBasicError("Unable to initialize net", err)
}
return conf, nil
}

Expand Down Expand Up @@ -164,12 +155,3 @@ func (cfg *BRConf) initMacPool() error {
}
return nil
}

// initNet initializes the network configuration.
func (cfg *BRConf) initNet() error {
var err error
if cfg.Net, err = netconf.FromTopo(cfg.BR, cfg.Topo.IFInfoMap); err != nil {
return err
}
return nil
}
16 changes: 0 additions & 16 deletions go/border/netconf/BUILD.bazel

This file was deleted.

135 changes: 0 additions & 135 deletions go/border/netconf/interface.go

This file was deleted.

2 changes: 1 addition & 1 deletion go/border/rctrl/ctrl.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func Control(sRevInfoQ chan rpkt.RawSRevCallbackArgs) {
logger.Error("Initializing SNET", "err", err)
return
}
ctrlAddr := ctx.Conf.Net.CtrlAddr
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 {
Expand Down
2 changes: 1 addition & 1 deletion go/border/rpkt/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ go_test(
embed = [":go_default_library"],
deps = [
"//go/border/brconf:go_default_library",
"//go/border/netconf:go_default_library",
"//go/border/rctx:go_default_library",
"//go/lib/addr:go_default_library",
"//go/lib/common:go_default_library",
"//go/lib/l4:go_default_library",
"//go/lib/spath:go_default_library",
"//go/lib/spkt:go_default_library",
"//go/lib/topology:go_default_library",
"@com_github_smartystreets_goconvey//convey:go_default_library",
],
)
4 changes: 2 additions & 2 deletions go/border/rpkt/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ func (rp *RtrPkt) CreateReplyScnPkt() (*spkt.ScnPkt, error) {
}
sp.SrcIA = rp.Ctx.Conf.IA
// Use the local address as the source host
pub := rp.Ctx.Conf.Net.LocAddr.PublicOverlay(rp.Ctx.Conf.Topo.Overlay)
pub := rp.Ctx.Conf.BR.InternalAddrs.PublicOverlay(rp.Ctx.Conf.Topo.Overlay)
sp.SrcHost = pub.L3()
return sp, nil
}
Expand Down Expand Up @@ -253,7 +253,7 @@ func (rp *RtrPkt) replyEgress(dir rcmn.Dir, dst *overlay.OverlayAddr, ifid commo
if err := rp.validateLocalIF(rp.ifNext); err != nil {
return err
}
if _, ok := rp.Ctx.Conf.Net.IFs[*rp.ifNext]; ok {
if _, ok := rp.Ctx.Conf.BR.IFs[*rp.ifNext]; ok {
// Egress interface is on this BR
// Re-inject to process the reply as an "Egress br"
// and make it look like it arrived in the local socket
Expand Down
4 changes: 2 additions & 2 deletions go/border/rpkt/path.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func (rp *RtrPkt) validatePath(dirFrom rcmn.Dir) error {
}
// Check for shorcuts in packets from core links
if rp.infoF.Shortcut {
currentLinkType := rp.Ctx.Conf.Net.IFs[*rp.ifCurr].Type
currentLinkType := rp.Ctx.Conf.BR.IFs[*rp.ifCurr].LinkType
if currentLinkType == proto.LinkType_core {
return common.NewBasicError("Shortcut not allowed on core segment", nil)
}
Expand Down Expand Up @@ -447,7 +447,7 @@ func (rp *RtrPkt) checkSetCurrIF(ifid *common.IFIDType) (*common.IFIDType, error
if ifid == nil {
return nil, common.NewBasicError("No interface found", nil)
}
if _, ok := rp.Ctx.Conf.Net.IFs[*ifid]; !ok {
if _, ok := rp.Ctx.Conf.BR.IFs[*ifid]; !ok {
return nil, common.NewBasicError("Unknown interface", nil, "ifid", *ifid)
}
rp.ifCurr = ifid
Expand Down
6 changes: 3 additions & 3 deletions go/border/rpkt/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,10 @@ func (rp *RtrPkt) processSCMPRevocation() error {
"Unable to decode SignedRevInfo from SCMP InfoRevocation payload", err)
}

intf := rp.Ctx.Conf.Net.IFs[*rp.ifCurr]
intf := rp.Ctx.Conf.BR.IFs[*rp.ifCurr]
rp.SrcIA() // Ensure that rp.srcIA has been set
if (rp.dstIA.I == rp.Ctx.Conf.Topo.ISD_AS.I && intf.Type == proto.LinkType_core) ||
(rp.srcIA.I == rp.Ctx.Conf.Topo.ISD_AS.I && intf.Type == proto.LinkType_parent) {
if (rp.dstIA.I == rp.Ctx.Conf.Topo.ISD_AS.I && intf.LinkType == proto.LinkType_core) ||
(rp.srcIA.I == rp.Ctx.Conf.Topo.ISD_AS.I && intf.LinkType == proto.LinkType_parent) {
// Case 1 & 2
args.Addrs = append(args.Addrs, addr.SvcBS)
if len(rp.Ctx.Conf.Topo.PS) > 0 {
Expand Down
4 changes: 2 additions & 2 deletions go/border/rpkt/route.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func (rp *RtrPkt) forwardFromExternal() (HookResult, error) {
return HookError, err
}
// Destination is in a remote ISD-AS.
if _, ok := rp.Ctx.Conf.Net.IFs[*rp.ifNext]; ok {
if _, ok := rp.Ctx.Conf.BR.IFs[*rp.ifNext]; ok {
// Egress interface is local so re-inject the packet
// and make it look like it arrived in the internal interface
rp.RefInc(1)
Expand Down Expand Up @@ -194,7 +194,7 @@ func (rp *RtrPkt) xoverFromExternal() error {
// If the segment didn't change, no more checks to make.
return nil
}
prevLink := rp.Ctx.Conf.Net.IFs[origIFCurr].Type
prevLink := rp.Ctx.Conf.BR.IFs[origIFCurr].LinkType
nextLink := rp.Ctx.Conf.Topo.IFInfoMap[*rp.ifNext].LinkType
// Never allowed to switch between core segments.
if prevLink == proto.LinkType_core && nextLink == proto.LinkType_core {
Expand Down
6 changes: 3 additions & 3 deletions go/border/rpkt/rpkt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ import (
. "github.com/smartystreets/goconvey/convey"

"github.com/scionproto/scion/go/border/brconf"
"github.com/scionproto/scion/go/border/netconf"
"github.com/scionproto/scion/go/border/rctx"
"github.com/scionproto/scion/go/lib/addr"
"github.com/scionproto/scion/go/lib/common"
"github.com/scionproto/scion/go/lib/l4"
"github.com/scionproto/scion/go/lib/spkt"
"github.com/scionproto/scion/go/lib/topology"
)

var rawUdpPkt = "testdata/udp-scion.bin"
Expand All @@ -49,8 +49,8 @@ func prepareRtrPacketSample() *RtrPkt {
// Set some other data that are required for the parsing to succeed:
var config = &brconf.BRConf{
IA: addr.IA{I: 1, A: 2},
Net: &netconf.NetConf{
IFs: map[common.IFIDType]*netconf.Interface{5: nil},
BR: &topology.BRInfo{
IFs: map[common.IFIDType]*topology.IFInfo{5: nil},
},
}
r.Ctx = rctx.New(config)
Expand Down
2 changes: 1 addition & 1 deletion go/border/rpkt/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const (
func (rp *RtrPkt) Validate() (bool, error) {
var mtu int
if rp.ifCurr != nil {
intf, ok := rp.Ctx.Conf.Net.IFs[*rp.ifCurr]
intf, ok := rp.Ctx.Conf.BR.IFs[*rp.ifCurr]
if !ok {
return false, common.NewBasicError(errCurrIntfInvalid, nil, "ifid", *rp.ifCurr)
}
Expand Down
Loading

0 comments on commit 434510d

Please sign in to comment.