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

topo: allow marshalling RWTopology #3746

Merged
merged 1 commit into from
May 8, 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
1 change: 1 addition & 0 deletions go/lib/infra/modules/itopo/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ go_library(
"//go/lib/common:go_default_library",
"//go/lib/infra/modules/itopo/internal/metrics:go_default_library",
"//go/lib/log:go_default_library",
"//go/lib/scrypto/trc:go_default_library",
"//go/lib/serrors:go_default_library",
"//go/lib/topology:go_default_library",
"//go/proto:go_default_library",
Expand Down
3 changes: 2 additions & 1 deletion go/lib/infra/modules/itopo/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"reflect"

"github.com/scionproto/scion/go/lib/common"
"github.com/scionproto/scion/go/lib/scrypto/trc"
"github.com/scionproto/scion/go/lib/serrors"
"github.com/scionproto/scion/go/lib/topology"
"github.com/scionproto/scion/go/proto"
Expand Down Expand Up @@ -89,7 +90,7 @@ func (v *generalValidator) Immutable(topo, oldTopo *topology.RWTopology) error {
return common.NewBasicError("IA is immutable", nil,
"expected", oldTopo.IA, "actual", topo.IA)
}
if !topo.Attributes.Equal(oldTopo.Attributes) {
if !trc.Attributes(topo.Attributes).Equal(trc.Attributes(oldTopo.Attributes)) {
return common.NewBasicError("Attributes are immutable", nil,
"expected", oldTopo.Attributes, "actual", topo.Attributes)
}
Expand Down
2 changes: 1 addition & 1 deletion go/lib/topology/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ func (t *topologyS) MakeHostInfos(st proto.ServiceType) []net.UDPAddr {
}

func (t *topologyS) Core() bool {
return t.Topology.Attributes.Contains(trc.Core)
return trc.Attributes(t.Topology.Attributes).Contains(trc.Core)
}

func (t *topologyS) BR(name string) (BRInfo, bool) {
Expand Down
5 changes: 3 additions & 2 deletions go/lib/topology/topology.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ type (
RWTopology struct {
Timestamp time.Time
IA addr.IA
Attributes trc.Attributes
Attributes []trc.Attribute
MTU int

BR map[string]BRInfo
Expand Down Expand Up @@ -225,7 +225,8 @@ func (t *RWTopology) populateBR(raw *jsontopo.Topology) error {
return err
}
ifinfo.LinkType = LinkTypeFromString(rawIntf.LinkTo)
if err = ifinfo.CheckLinks(t.Attributes.Contains(trc.Core), name); err != nil {
isCore := trc.Attributes(t.Attributes).Contains(trc.Core)
if err = ifinfo.CheckLinks(isCore, name); err != nil {
return err
}
// These fields are only necessary for the border router.
Expand Down