Skip to content

Commit 6349c15

Browse files
bugfix(controller): WAN at 2048 (#3310)
1 parent 115248c commit 6349c15

17 files changed

Lines changed: 117 additions & 82 deletions

File tree

controlplane/controller/internal/controller/fixtures/interfaces.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,12 @@ interface Switch1/1/4
154154
isis network point-to-point
155155
!
156156
interface Switch1/1/5
157-
mtu 2048
157+
mtu 1500
158158
no switchport
159159
ip address 172.16.0.14/31
160160
!
161161
interface Switch1/1/6
162-
mtu 2048
162+
mtu 1500
163163
no switchport
164164
ip address 172.16.0.16/31
165165
!

controlplane/controller/internal/controller/render_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ func TestRenderConfig(t *testing.T) {
521521
{
522522
Name: "Switch1/1/5",
523523
Ip: netip.MustParsePrefix("172.16.0.14/31"),
524-
Mtu: 2048,
524+
Mtu: 1500,
525525
InterfaceType: InterfaceTypePhysical,
526526
Metric: 20000,
527527
IsLink: true,
@@ -531,7 +531,7 @@ func TestRenderConfig(t *testing.T) {
531531
{
532532
Name: "Switch1/1/6",
533533
Ip: netip.MustParsePrefix("172.16.0.16/31"),
534-
Mtu: 2048,
534+
Mtu: 1500,
535535
InterfaceType: InterfaceTypePhysical,
536536
Metric: 25000,
537537
IsLink: true,

controlplane/controller/internal/controller/server.go

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

394394
d.Interfaces[i].Metric = uint32(microseconds)
395-
if link.Mtu > 0 && (iface.IsCYOA || iface.IsDIA) {
396-
d.Interfaces[i].Mtu = uint16(link.Mtu)
397-
}
398395
d.Interfaces[i].IsLink = true
399396
d.Interfaces[i].LinkStatus = link.Status
400397
linkMetrics.WithLabelValues(device.Code, iface.Name, d.PubKey).Set(float64(d.Interfaces[i].Metric))

controlplane/controller/internal/controller/templates/tunnel.tmpl

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,7 @@ system control-plane
8888
interface {{ .Name }}
8989
{{- if .IsPhysical }}
9090
{{- if or .IsCYOA .IsDIA }}
91-
{{- if .Mtu }}
92-
mtu {{ .Mtu }}
93-
{{- else }}
9491
mtu 1500
95-
{{- end }}
9692
{{- else }}
9793
mtu 2048
9894
{{- end }}

smartcontract/programs/doublezero-serviceability/src/processors/device/interface/create.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,24 @@ pub fn process_create_device_interface(
140140
return Err(DoubleZeroError::CyoaRequiresPhysical.into());
141141
}
142142

143+
// Validate MTU based on interface type
144+
let is_cyoa_or_dia =
145+
value.interface_cyoa != InterfaceCYOA::None || value.interface_dia != InterfaceDIA::None;
146+
if interface_type == InterfaceType::Loopback {
147+
if value.mtu != 0 {
148+
return Err(DoubleZeroError::InvalidMtu.into());
149+
}
150+
} else if is_cyoa_or_dia {
151+
if value.mtu != 1500 {
152+
return Err(DoubleZeroError::InvalidMtu.into());
153+
}
154+
} else {
155+
// WAN/DZX physical interfaces must be 2048
156+
if value.mtu != 2048 {
157+
return Err(DoubleZeroError::InvalidMtu.into());
158+
}
159+
}
160+
143161
// ip_net can only be set on CYOA, DIA, or user-tunnel-endpoint interfaces
144162
if value.ip_net.is_some()
145163
&& value.interface_cyoa == InterfaceCYOA::None

smartcontract/programs/doublezero-serviceability/src/processors/device/interface/update.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,21 @@ pub fn process_update_device_interface(
226226
iface.node_segment_idx = node_segment_idx;
227227
}
228228

229+
// Validate MTU against final interface state
230+
let is_cyoa_or_dia =
231+
iface.interface_cyoa != InterfaceCYOA::None || iface.interface_dia != InterfaceDIA::None;
232+
if iface.interface_type == InterfaceType::Loopback {
233+
if iface.mtu != 0 {
234+
return Err(DoubleZeroError::InvalidMtu.into());
235+
}
236+
} else if is_cyoa_or_dia {
237+
if iface.mtu != 1500 {
238+
return Err(DoubleZeroError::InvalidMtu.into());
239+
}
240+
} else if iface.mtu != 2048 {
241+
return Err(DoubleZeroError::InvalidMtu.into());
242+
}
243+
229244
// CYOA interfaces must have an ip_net — prevent setting CYOA without ip_net
230245
// or clearing ip_net from a CYOA interface via update
231246
if iface.interface_cyoa != InterfaceCYOA::None && iface.ip_net == NetworkV4::default() {

smartcontract/programs/doublezero-serviceability/src/processors/link/create.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,11 @@ pub fn process_create_link(
150150
return Err(DoubleZeroError::InvalidContributor.into());
151151
}
152152

153+
// WAN/DZX links must have MTU 2048
154+
if value.mtu != 2048 {
155+
return Err(DoubleZeroError::InvalidMtu.into());
156+
}
157+
153158
let side_a_iface = side_a_dev
154159
.interfaces
155160
.iter()

smartcontract/programs/doublezero-serviceability/src/processors/link/update.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ pub fn process_update_link(
164164
link.bandwidth = bandwidth;
165165
}
166166
if let Some(mtu) = value.mtu {
167+
if mtu != 2048 {
168+
return Err(DoubleZeroError::InvalidMtu.into());
169+
}
167170
link.mtu = mtu;
168171
}
169172
if let Some(delay_ns) = value.delay_ns {

smartcontract/programs/doublezero-serviceability/tests/delete_cyoa_interface_test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ async fn test_update_cyoa_interface_with_invalid_sibling() {
410410
program_id,
411411
DoubleZeroInstruction::UpdateDeviceInterface(DeviceInterfaceUpdateArgs {
412412
name: "ethernet1".to_string(),
413-
mtu: Some(9000),
413+
mtu: Some(1500),
414414
..Default::default()
415415
}),
416416
vec![
@@ -434,7 +434,7 @@ async fn test_update_cyoa_interface_with_invalid_sibling() {
434434
.unwrap();
435435

436436
let updated_iface = device.find_interface("Ethernet1").unwrap().1;
437-
assert_eq!(updated_iface.mtu, 9000, "MTU should be updated to 9000");
437+
assert_eq!(updated_iface.mtu, 1500, "MTU should be updated to 1500");
438438
assert_eq!(
439439
updated_iface.ip_net,
440440
"63.243.225.62/30".parse().unwrap(),

smartcontract/programs/doublezero-serviceability/tests/global_test.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ async fn test_doublezero_program() {
403403
ip_net: None,
404404
bandwidth: 0,
405405
cir: 0,
406-
mtu: 1500,
406+
mtu: 2048,
407407
routing_mode: RoutingMode::Static,
408408
vlan_id: 0,
409409
user_tunnel_endpoint: false,
@@ -592,7 +592,7 @@ async fn test_doublezero_program() {
592592
cir: 0,
593593
ip_net: None,
594594

595-
mtu: 1500,
595+
mtu: 2048,
596596
routing_mode: RoutingMode::Static,
597597
vlan_id: 0,
598598
user_tunnel_endpoint: false,
@@ -643,7 +643,7 @@ async fn test_doublezero_program() {
643643
code: tunnel_la_ny_code.clone(),
644644
link_type: LinkLinkType::WAN,
645645
bandwidth: 15_000_000_000,
646-
mtu: 4900,
646+
mtu: 2048,
647647
delay_ns: 1000000,
648648
jitter_ns: 100000,
649649
side_a_iface_name: "Ethernet0".to_string(),

0 commit comments

Comments
 (0)