Skip to content

Commit

Permalink
topology: add gateway,interface ID mapping (#3919)
Browse files Browse the repository at this point in the history
The DS will then attach the mapping to Gateway discovery replies. This
means all traffic that targets a remote gateway should flow only through
the interface IDs attached to it.

Co-authored-by: Konstantinos <karampogias@anapaya.net>
  • Loading branch information
oncilla and karampok authored Oct 26, 2020
1 parent 002463e commit d303079
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
5 changes: 3 additions & 2 deletions go/lib/topology/json/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@ type BRInfo struct {

// GatewayInfo contains SCION gateway information.
type GatewayInfo struct {
CtrlAddr string `json:"ctrl_addr"`
DataAddr string `json:"data_addr"`
CtrlAddr string `json:"ctrl_addr"`
DataAddr string `json:"data_addr"`
Interfaces []int `json:"allow_interfaces,omitempty"`
}

// BRInterface contains the information for an data-plane BR socket that is external (i.e., facing
Expand Down
3 changes: 2 additions & 1 deletion go/lib/topology/testdata/basic.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@
"sigs": {
"sig1-ff00:0:311-1": {
"ctrl_addr": "127.0.0.82:30100",
"data_addr": "127.0.0.82:30101"
"data_addr": "127.0.0.82:30101",
"allow_interfaces": [1,3,5]
},
"sig2-ff00:0:311-1": {
"ctrl_addr": "[2001:db8:f00:b43::1%some-zone]:23425",
Expand Down
6 changes: 6 additions & 0 deletions go/lib/topology/topology.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ type (
GatewayInfo struct {
CtrlAddr *TopoAddr
DataAddr *net.UDPAddr
AllowIFs []common.IFIDType
}

// BRInfo is a list of AS-wide unique interface IDs for a router. These IDs are also used
Expand Down Expand Up @@ -484,9 +485,14 @@ func gatewayMapFromRaw(ras map[string]*jsontopo.GatewayInfo) (map[string]Gateway
return nil, serrors.WrapStr("could not parse data address", err,
"address", svc.DataAddr, "process_name", name)
}
var ifs []common.IFIDType
for _, i := range svc.Interfaces {
ifs = append(ifs, common.IFIDType(i))
}
ret[name] = GatewayInfo{
CtrlAddr: c,
DataAddr: d,
AllowIFs: ifs,
}
}
return ret, nil
Expand Down
1 change: 1 addition & 0 deletions go/lib/topology/topology_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ func TestServiceDetails(t *testing.T) {
IP: net.IP{127, 0, 0, 82},
Port: 30101,
},
AllowIFs: []common.IFIDType{1, 3, 5},
},
"sig2-ff00:0:311-1": {
CtrlAddr: &TopoAddr{
Expand Down

0 comments on commit d303079

Please sign in to comment.