Skip to content

Commit

Permalink
Remove the field "internal" from the dataplane structure.
Browse files Browse the repository at this point in the history
It was duplicating interfaces[0] and existed only for compatibility
(backward, I presume) with some tests.
  • Loading branch information
jiceatscion committed Nov 12, 2024
1 parent eaf0a6a commit 2ac2725
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
11 changes: 4 additions & 7 deletions router/dataplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ type DataPlane struct {
linkTypes map[uint16]topology.LinkType
neighborIAs map[uint16]addr.IA
peerInterfaces map[uint16]uint16
internal BatchConn
internalIP netip.Addr
internalNextHops map[uint16]netip.AddrPort
svc *services
Expand Down Expand Up @@ -338,14 +337,12 @@ func (d *DataPlane) AddInternalInterface(conn BatchConn, ip netip.Addr) error {
if conn == nil {
return emptyValue
}
if d.internal != nil {
return alreadySet
}
if d.interfaces == nil {
d.interfaces = make(map[uint16]BatchConn)
} else if d.interfaces[0] != nil {
return alreadySet
}
d.interfaces[0] = conn
d.internal = conn
d.internalIP = ip
return nil
}
Expand Down Expand Up @@ -481,7 +478,7 @@ func (d *DataPlane) getInterfaceState(ifID uint16) control.InterfaceState {
return control.InterfaceUp
}

func (d *DataPlane) addBFDController(ifID uint16, s *bfdSend, cfg control.BFD,
func (d *DataPlane) addBFDController(ifID uint16, s bfd.Sender, cfg control.BFD,
metrics bfd.Metrics) error {

if d.bfdSessions == nil {
Expand Down Expand Up @@ -1830,6 +1827,7 @@ func (p *scionPacketProcessor) handleEgressRouterAlert() disposition {
return pForward
}
if _, ok := p.d.external[p.pkt.egress]; !ok {
// the egress router is not this one.
return pForward
}
*alert = false
Expand Down Expand Up @@ -1999,7 +1997,6 @@ func (p *scionPacketProcessor) process() disposition {
if disp := p.validateEgressUp(); disp != pForward {
return disp
}

if _, ok := p.d.external[egressID]; ok {
// Not ASTransit in
if disp := p.processEgress(); disp != pForward {
Expand Down
4 changes: 2 additions & 2 deletions router/dataplane_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func TestReceiver(t *testing.T) {
dp.setRunning()
dp.initMetrics()
go func() {
dp.runReceiver(0, dp.internal, runConfig, procCh)
dp.runReceiver(0, dp.interfaces[0], runConfig, procCh)
}()
ptrMap := make(map[uintptr]struct{})
for i := 0; i < 21; i++ {
Expand Down Expand Up @@ -182,7 +182,7 @@ func TestForwarder(t *testing.T) {
initialPoolSize := len(dp.packetPool)
dp.setRunning()
dp.initMetrics()
go dp.runForwarder(0, dp.internal, runConfig, fwCh[0])
go dp.runForwarder(0, dp.interfaces[0], runConfig, fwCh[0])

dstAddr := &net.UDPAddr{IP: net.IP{10, 0, 200, 200}}
for i := 0; i < 255; i++ {
Expand Down
3 changes: 2 additions & 1 deletion router/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ func NewDP(
key []byte) *DataPlane {

dp := &DataPlane{
interfaces: map[uint16]BatchConn{0: internal},
localIA: local,
external: external,
linkTypes: linkTypes,
Expand All @@ -84,10 +85,10 @@ func NewDP(
dispatchedPortStart: uint16(dispatchedPortStart),
dispatchedPortEnd: uint16(dispatchedPortEnd),
svc: &services{m: svc},
internal: internal,
internalIP: netip.MustParseAddr("198.51.100.1"),
Metrics: metrics,
}

if err := dp.SetKey(key); err != nil {
panic(err)
}
Expand Down

0 comments on commit 2ac2725

Please sign in to comment.