Skip to content

Commit b3a4aec

Browse files
committed
controller: use link.delay_override to set isis metric when set in valid range
1 parent d80cf0c commit b3a4aec

16 files changed

+197
-20
lines changed

controlplane/controller/internal/controller/fixtures/e2e.tmpl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,18 @@ interface Switch1/1/2.100
101101
isis hello padding
102102
isis network point-to-point
103103
!
104+
interface Switch1/1/3
105+
mtu 2048
106+
no switchport
107+
ip address 172.16.0.4/31
108+
pim ipv4 sparse-mode
109+
isis enable 1
110+
isis circuit-type level-2
111+
isis hello-interval 1
112+
isis metric 50
113+
isis hello padding
114+
isis network point-to-point
115+
!
104116
interface Loopback1000
105117
description RP Address
106118
ip address 10.0.0.0/32

controlplane/controller/internal/controller/server.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,15 @@ func (c *Controller) updateStateCache(ctx context.Context) error {
364364
}
365365

366366
microseconds := math.Ceil(float64(link.DelayNs) / 1000.0)
367+
368+
if link.DelayOverrideNs != 0 {
369+
if link.DelayOverrideNs < 10000 || link.DelayOverrideNs > 1_000_000_000 {
370+
c.log.Warn("link delay override is outside valid range (10us - 1s), ignoring", "link_pubkey", base58.Encode(link.PubKey[:]), "device_code", device.Code, "interface", iface.Name, "delay_override_ns", link.DelayOverrideNs)
371+
} else {
372+
microseconds = math.Ceil(float64(link.DelayOverrideNs) / 1000.0)
373+
}
374+
}
375+
367376
d.Interfaces[i].Metric = uint32(microseconds)
368377
d.Interfaces[i].IsLink = true
369378
linkMetrics.WithLabelValues(device.Code, iface.Name, d.PubKey).Set(float64(d.Interfaces[i].Metric))

controlplane/controller/internal/controller/server_test.go

Lines changed: 58 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -815,6 +815,12 @@ func TestStateCache(t *testing.T) {
815815
IpNet: [5]uint8{172, 16, 0, 4, 31},
816816
Status: serviceability.InterfaceStatusActivated,
817817
},
818+
{
819+
InterfaceType: serviceability.InterfaceTypePhysical,
820+
Name: "Ethernet1/3",
821+
IpNet: [5]uint8{172, 16, 0, 6, 31},
822+
Status: serviceability.InterfaceStatusActivated,
823+
},
818824
},
819825
Status: serviceability.DeviceStatusActivated,
820826
Code: "abc01",
@@ -823,24 +829,37 @@ func TestStateCache(t *testing.T) {
823829
},
824830
Links: []serviceability.Link{
825831
{
826-
AccountType: serviceability.LinkType,
827-
Owner: [32]uint8{},
828-
SideAPubKey: [32]uint8{1},
829-
SideZPubKey: [32]uint8{2},
830-
DelayNs: 400000000,
831-
Status: serviceability.LinkStatusActivated,
832-
SideAIfaceName: "Ethernet1/1",
833-
SideZIfaceName: "Ethernet1/1",
832+
AccountType: serviceability.LinkType,
833+
Owner: [32]uint8{},
834+
SideAPubKey: [32]uint8{1},
835+
SideZPubKey: [32]uint8{2},
836+
DelayNs: 400000000,
837+
DelayOverrideNs: 0,
838+
Status: serviceability.LinkStatusActivated,
839+
SideAIfaceName: "Ethernet1/1",
840+
SideZIfaceName: "Ethernet1/1",
834841
},
835842
{
836-
AccountType: serviceability.LinkType,
837-
Owner: [32]uint8{},
838-
SideAPubKey: [32]uint8{1},
839-
SideZPubKey: [32]uint8{2},
840-
DelayNs: 1000,
841-
Status: serviceability.LinkStatusActivated,
842-
SideAIfaceName: "Ethernet1/2",
843-
SideZIfaceName: "Ethernet1/2",
843+
AccountType: serviceability.LinkType,
844+
Owner: [32]uint8{},
845+
SideAPubKey: [32]uint8{1},
846+
SideZPubKey: [32]uint8{2},
847+
DelayNs: 1000,
848+
DelayOverrideNs: 0,
849+
Status: serviceability.LinkStatusActivated,
850+
SideAIfaceName: "Ethernet1/2",
851+
SideZIfaceName: "Ethernet1/2",
852+
},
853+
{
854+
AccountType: serviceability.LinkType,
855+
Owner: [32]uint8{},
856+
SideAPubKey: [32]uint8{1},
857+
SideZPubKey: [32]uint8{2},
858+
DelayNs: 1000,
859+
DelayOverrideNs: 50000,
860+
Status: serviceability.LinkStatusActivated,
861+
SideAIfaceName: "Ethernet1/3",
862+
SideZIfaceName: "Ethernet1/3",
844863
},
845864
},
846865
StateCache: stateCache{
@@ -920,6 +939,13 @@ func TestStateCache(t *testing.T) {
920939
IsLink: true,
921940
Metric: 1,
922941
},
942+
{
943+
InterfaceType: InterfaceTypePhysical,
944+
Ip: netip.MustParsePrefix("172.16.0.6/31"),
945+
Name: "Ethernet1/3",
946+
IsLink: true,
947+
Metric: 50,
948+
},
923949
{
924950
InterfaceType: InterfaceTypeLoopback,
925951
LoopbackType: LoopbackTypeVpnv4,
@@ -1305,6 +1331,11 @@ func TestEndToEnd(t *testing.T) {
13051331
VlanId: 100,
13061332
IpNet: [5]uint8{172, 16, 0, 2, 31},
13071333
},
1334+
{
1335+
Name: "Switch1/1/3",
1336+
InterfaceType: serviceability.InterfaceTypePhysical,
1337+
IpNet: [5]uint8{172, 16, 0, 4, 31},
1338+
},
13081339
},
13091340
},
13101341
},
@@ -1329,6 +1360,17 @@ func TestEndToEnd(t *testing.T) {
13291360
SideAIfaceName: "Switch1/1/2.100",
13301361
SideZIfaceName: "Switch1/1/2.100",
13311362
},
1363+
{
1364+
AccountType: serviceability.LinkType,
1365+
Owner: [32]uint8{},
1366+
SideAPubKey: [32]uint8{1},
1367+
SideZPubKey: [32]uint8{2},
1368+
DelayNs: 1000,
1369+
DelayOverrideNs: 50000,
1370+
Status: serviceability.LinkStatusActivated,
1371+
SideAIfaceName: "Switch1/1/3",
1372+
SideZIfaceName: "Switch1/1/3",
1373+
},
13321374
},
13331375
AgentRequest: &pb.ConfigRequest{
13341376
Pubkey: "4uQeVj5tqViQh7yWWGStvkEG1Zmhx6uasJtWCJziofM",

e2e/fixtures/ibrl/doublezero_agent_config_peer_removed.tmpl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,18 @@ interface Ethernet2
6969
isis hello padding
7070
isis network point-to-point
7171
!
72+
interface Ethernet4
73+
mtu 2048
74+
no switchport
75+
ip address 172.16.0.22/31
76+
pim ipv4 sparse-mode
77+
isis enable 1
78+
isis circuit-type level-2
79+
isis hello-interval 1
80+
isis metric 30000
81+
isis hello padding
82+
isis network point-to-point
83+
!
7284
interface Loopback255
7385
ip address 172.16.0.1/32
7486
node-segment ipv4 index 1

e2e/fixtures/ibrl/doublezero_agent_config_user_added.tmpl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,18 @@ interface Ethernet2
6969
isis hello padding
7070
isis network point-to-point
7171
!
72+
interface Ethernet4
73+
mtu 2048
74+
no switchport
75+
ip address 172.16.0.22/31
76+
pim ipv4 sparse-mode
77+
isis enable 1
78+
isis circuit-type level-2
79+
isis hello-interval 1
80+
isis metric 30000
81+
isis hello padding
82+
isis network point-to-point
83+
!
7284
interface Loopback255
7385
ip address 172.16.0.1/32
7486
node-segment ipv4 index 1

e2e/fixtures/ibrl/doublezero_agent_config_user_removed.tmpl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,18 @@ interface Ethernet2
6969
isis hello padding
7070
isis network point-to-point
7171
!
72+
interface Ethernet4
73+
mtu 2048
74+
no switchport
75+
ip address 172.16.0.22/31
76+
pim ipv4 sparse-mode
77+
isis enable 1
78+
isis circuit-type level-2
79+
isis hello-interval 1
80+
isis metric 30000
81+
isis hello padding
82+
isis network point-to-point
83+
!
7284
interface Loopback255
7385
ip address 172.16.0.1/32
7486
node-segment ipv4 index 1

e2e/fixtures/ibrl_with_allocated_addr/doublezero_agent_config_user_added.tmpl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,18 @@ interface Ethernet2
6969
isis hello padding
7070
isis network point-to-point
7171
!
72+
interface Ethernet4
73+
mtu 2048
74+
no switchport
75+
ip address 172.16.0.22/31
76+
pim ipv4 sparse-mode
77+
isis enable 1
78+
isis circuit-type level-2
79+
isis hello-interval 1
80+
isis metric 30000
81+
isis hello padding
82+
isis network point-to-point
83+
!
7284
interface Loopback255
7385
ip address 172.16.0.1/32
7486
node-segment ipv4 index 1

e2e/fixtures/ibrl_with_allocated_addr/doublezero_agent_config_user_removed.tmpl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,18 @@ interface Ethernet2
6969
isis hello padding
7070
isis network point-to-point
7171
!
72+
interface Ethernet4
73+
mtu 2048
74+
no switchport
75+
ip address 172.16.0.22/31
76+
pim ipv4 sparse-mode
77+
isis enable 1
78+
isis circuit-type level-2
79+
isis hello-interval 1
80+
isis metric 30000
81+
isis hello padding
82+
isis network point-to-point
83+
!
7284
interface Loopback255
7385
ip address 172.16.0.1/32
7486
node-segment ipv4 index 1

e2e/fixtures/multicast_publisher/doublezero_agent_config_user_added.tmpl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,18 @@ interface Ethernet2
6969
isis hello padding
7070
isis network point-to-point
7171
!
72+
interface Ethernet4
73+
mtu 2048
74+
no switchport
75+
ip address 172.16.0.22/31
76+
pim ipv4 sparse-mode
77+
isis enable 1
78+
isis circuit-type level-2
79+
isis hello-interval 1
80+
isis metric 30000
81+
isis hello padding
82+
isis network point-to-point
83+
!
7284
interface Loopback255
7385
ip address 172.16.0.1/32
7486
node-segment ipv4 index 1

e2e/fixtures/multicast_publisher/doublezero_agent_config_user_removed.tmpl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,18 @@ interface Ethernet2
6969
isis hello padding
7070
isis network point-to-point
7171
!
72+
interface Ethernet4
73+
mtu 2048
74+
no switchport
75+
ip address 172.16.0.22/31
76+
pim ipv4 sparse-mode
77+
isis enable 1
78+
isis circuit-type level-2
79+
isis hello-interval 1
80+
isis metric 30000
81+
isis hello padding
82+
isis network point-to-point
83+
!
7284
interface Loopback255
7385
ip address 172.16.0.1/32
7486
node-segment ipv4 index 1

0 commit comments

Comments
 (0)