asterust-junos 0.5.12

Typed Juniper JunOS config views (interfaces, protocols, routing instances and options, policy options, firewall filters, class of service, system, services) extracted from an asterust config tree.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
//! `unit`
//! `interfaces { <name> { unit <n> { ... } } }`.
//!
//! # See also
//!
//! - [unit (interfaces)](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/unit-edit-interfaces.html)
//! - [encapsulation (Logical Interface)](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/encapsulation-edit-interfaces-logical.html)
//! - [demux-options](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/demux-options-edit-interfaces.html)
//! - [demux (Interfaces)](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/demux-edit-interfaces.html)
//! - [advisory-options](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/advisory-options-edit-interfaces-unit.html)
//! - [targeted-distribution](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/targeted-distribution-edit-interfaces.html)
//! - [pppoe-options](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/pppoe-options-edit-interfaces.html)
//! - [pppoe-underlying-options](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/pppoe-underlying-options-edit-interfaces-pppoe.html)
//! - [ppp-options](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/ppp-options-edit-interfaces.html)
//! - [vlan-id (VLAN ID to Be Bound to a Logical Interface)](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/vlan-id-edit-interfaces.html)

mod demux;
mod demux_options;
mod family;
mod pppoe_options;
mod pppoe_underlying_options;
mod tunnel;
mod vlan_map;
mod vlan_tags;

pub use demux::{
    Demux, DemuxAddressRanges, DemuxDynamicProfile, DemuxFamily, DemuxNetwork, DemuxRange, DemuxUsernameInclude,
};
pub use demux_options::{AdvisoryOptions, DemuxOptions};
pub use family::{
    AddressArp, BandwidthThreshold, DhcpClient, DhcpClientIdentifier, Dhcpv6Client, EthernetSwitching, FamilyFilter,
    FamilyPolicer, FamilySampling, PrefixDelegating, RouterAdvertisementInterface, RpfCheck, TrackedInterface,
    TrackedRoute, UnitAddress, UnitFamily, VrrpGroup, VrrpInheritFrom, VrrpTrack,
};
pub use pppoe_options::PppoeOptions;
pub use pppoe_underlying_options::{DuplicateProtection, PppoeUnderlyingOptions, ShortCycleProtection};
pub use tunnel::UnitTunnel;
pub use vlan_map::VlanMap;
pub use vlan_tags::VlanTags;

use super::esi::{parse_esi, Esi};
use super::ppp_options::{parse_ppp_options, PppOptions};
use crate::{active_children, arg_of, args_of, child_block, has_leaf, named_children};
use asterust::config::ConfigLine;
use demux::parse_demux;
use demux_options::{parse_advisory_options, parse_demux_options};
use family::parse_family;
use pppoe_options::parse_pppoe_options;
use pppoe_underlying_options::parse_pppoe_underlying_options;
use tunnel::parse_tunnel;
use vlan_map::parse_vlan_map;
use vlan_tags::parse_vlan_tags;

/// A logical `unit <n>` of an interface. Addresses are the raw `address` values (e.g.
/// `"10.0.0.1/24"`; IS-IS NETs for `family iso`).
#[derive(Clone, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub struct InterfaceUnit {
    pub number: String,
    pub description: Option<String>,
    pub vlan_id: Option<u32>,
    /// `vlan-id unmatched`.
    pub vlan_id_unmatched: bool,
    /// e.g. `"100-200"`.
    pub vlan_id_range: Option<String>,
    pub vlan_tags: Option<VlanTags>,
    pub tunnel: Option<UnitTunnel>,
    pub esi: Option<Esi>,
    pub ppp_options: Option<PppOptions>,
    /// The `pppoe-options` of a `pp0` unit.
    pub pppoe_options: Option<PppoeOptions>,
    pub pppoe_underlying_options: Option<PppoeUnderlyingOptions>,
    pub demux: Option<Demux>,
    pub demux_options: Option<DemuxOptions>,
    /// The families of each `demux-source`.
    pub demux_source: Vec<String>,
    /// The families of each `demux-destination`.
    pub demux_destination: Vec<String>,
    pub advisory_options: Option<AdvisoryOptions>,
    /// `replicate` or `scale`.
    pub targeted_distribution: Option<String>,
    /// `proxy-macip-advertisement` on an IRB unit.
    pub proxy_macip_advertisement: bool,
    /// `enhanced-convergence` on an IRB unit.
    pub enhanced_convergence: bool,
    pub virtual_gateway_v4_mac: Option<String>,
    pub virtual_gateway_v6_mac: Option<String>,
    /// The `virtual-gateway-esi` of an IRB unit.
    pub virtual_gateway_esi: Option<VirtualGatewayEsi>,
    /// `proxy-arp` is configured; `proxy_arp_mode` is its `restricted` or `unrestricted` argument.
    pub proxy_arp: bool,
    pub proxy_arp_mode: Option<String>,
    pub ip_address_owner: Option<String>,
    pub input_vlan_map: Option<VlanMap>,
    pub output_vlan_map: Option<VlanMap>,
    /// Logical encapsulation, e.g. `"vlan-bridge"` or `"vlan-ccc"`.
    pub encapsulation: Option<String>,
    /// Every `family <name>` present, e.g. `"inet"`, `"inet6"`, `"iso"`, `"mpls"`.
    pub families: Vec<String>,
    pub inet_addresses: Vec<String>,
    pub inet6_addresses: Vec<String>,
    pub iso_addresses: Vec<String>,
    /// The settings of each `family`, in the order written.
    pub family_settings: Vec<UnitFamily>,
}

/// The `virtual-gateway-esi` of an IRB unit: an ESI identifier and `all-active`.
#[derive(Clone, Debug, Default, PartialEq, Eq)]
#[non_exhaustive]
pub struct VirtualGatewayEsi {
    pub identifier: Option<String>,
    pub all_active: bool,
}

fn parse_virtual_gateway_esi(unit: &ConfigLine) -> Option<VirtualGatewayEsi> {
    let line =
        active_children(unit).find(|c| c.text == "virtual-gateway-esi" || c.arg("virtual-gateway-esi").is_some())?;
    let inline = line.arg("virtual-gateway-esi");
    Some(VirtualGatewayEsi {
        identifier: inline.filter(|v| *v != "all-active").map(str::to_string).or_else(|| {
            active_children(line)
                .find(|c| !c.text.contains(' ') && c.text != "all-active")
                .map(|c| c.text.clone())
        }),
        all_active: inline == Some("all-active") || has_leaf(line, "all-active"),
    })
}

pub(super) fn parse_unit(number: &str, unit: &ConfigLine) -> InterfaceUnit {
    let families: Vec<_> = named_children(unit, "family").collect();
    let addresses = |family: &str| -> Vec<String> {
        families
            .iter()
            .filter(|(name, _)| *name == family)
            .flat_map(|(_, f)| args_of(f, "address"))
            .map(str::to_string)
            .collect()
    };
    InterfaceUnit {
        number: number.to_string(),
        description: arg_of(unit, "description").map(str::to_string),
        vlan_id: arg_of(unit, "vlan-id").and_then(|v| v.parse().ok()),
        vlan_id_unmatched: arg_of(unit, "vlan-id") == Some("unmatched"),
        vlan_id_range: arg_of(unit, "vlan-id-range").map(str::to_string),
        vlan_tags: parse_vlan_tags(unit),
        tunnel: parse_tunnel(unit),
        esi: parse_esi(unit),
        ppp_options: child_block(unit, "ppp-options").map(parse_ppp_options),
        pppoe_options: child_block(unit, "pppoe-options").map(parse_pppoe_options),
        pppoe_underlying_options: child_block(unit, "pppoe-underlying-options").map(parse_pppoe_underlying_options),
        demux: child_block(unit, "demux").map(parse_demux),
        demux_options: child_block(unit, "demux-options").map(parse_demux_options),
        demux_source: args_of(unit, "demux-source").into_iter().map(str::to_string).collect(),
        demux_destination: args_of(unit, "demux-destination")
            .into_iter()
            .map(str::to_string)
            .collect(),
        advisory_options: child_block(unit, "advisory-options").map(parse_advisory_options),
        targeted_distribution: arg_of(unit, "targeted-distribution").map(str::to_string),
        proxy_macip_advertisement: has_leaf(unit, "proxy-macip-advertisement"),
        enhanced_convergence: has_leaf(unit, "enhanced-convergence"),
        virtual_gateway_v4_mac: arg_of(unit, "virtual-gateway-v4-mac").map(str::to_string),
        virtual_gateway_v6_mac: arg_of(unit, "virtual-gateway-v6-mac").map(str::to_string),
        virtual_gateway_esi: parse_virtual_gateway_esi(unit),
        proxy_arp: has_leaf(unit, "proxy-arp") || arg_of(unit, "proxy-arp").is_some(),
        proxy_arp_mode: arg_of(unit, "proxy-arp").map(str::to_string),
        ip_address_owner: arg_of(unit, "ip-address-owner").map(str::to_string),
        input_vlan_map: parse_vlan_map(unit, "input-vlan-map"),
        output_vlan_map: parse_vlan_map(unit, "output-vlan-map"),
        encapsulation: arg_of(unit, "encapsulation").map(str::to_string),
        inet_addresses: addresses("inet"),
        inet6_addresses: addresses("inet6"),
        iso_addresses: addresses("iso"),
        families: families.iter().map(|(name, _)| name.to_string()).collect(),
        family_settings: families
            .iter()
            .map(|(name, family)| parse_family(name, family))
            .collect(),
    }
}

#[cfg(test)]
mod tests {
    use crate::interfaces::interfaces;
    use asterust::config::juniper;

    // Not from documentation: written from the CLI Reference syntax pages. See the README "Sources".
    const CONFIG: &str = r#"
interfaces {
    ge-0/0/0 {
        flexible-vlan-tagging;
        encapsulation flexible-ethernet-services;
        unit 100 {
            encapsulation vlan-bridge;
            vlan-id 100;
            input-vlan-map {
                swap;
                tag-protocol-id 0x8100;
                vlan-id 200;
            }
            output-vlan-map swap;
        }
        unit 200 {
            vlan-tags outer 0x8100.200 inner 0x8100.300;
            input-vlan-map {
                push-push;
                tag-protocol-id 0x9100;
                vlan-id 10;
                inner-tag-protocol-id 0x8100;
                inner-vlan-id 20;
            }
            output-vlan-map {
                pop-pop;
            }
        }
        unit 300 {
            vlan-id unmatched;
        }
        unit 400 {
            vlan-id-range 400-499;
            vlan-tags outer 500 inner-range 1-4094;
        }
    }
}
"#;

    // Not from documentation: written from the CLI Reference syntax pages. See the README "Sources".
    #[test]
    fn extracts_unit_ppp_and_pppoe_options() {
        let ifaces = interfaces(&juniper::parse_braces(
            r#"
interfaces {
    pp0 {
        unit 0 {
            pppoe-options {
                access-concentrator AC1;
                auto-reconnect 10;
                client;
                ignore-eol-tag;
                service-name isp;
                underlying-interface ge-0/0/0.0;
                ppp-max-payload 1500;
            }
            ppp-options {
                peer-ip-address-optional;
                initiate-ncp ipv6;
                chap {
                    challenge-length minimum 8 maximum 16;
                }
            }
        }
        unit 1 {
            pppoe-options {
                server;
            }
        }
    }
    ge-0/0/1 {
        unit 100 {
            pppoe-underlying-options {
                access-concentrator AC2;
                dynamic-profile pppoe-prof;
                direct-connect;
                duplicate-protection {
                    include {
                        relay-session-id;
                    }
                }
                max-sessions 500;
                max-sessions-vsa-ignore;
                service-name-table SNT;
                short-cycle-protection lockout-time-min 1 lockout-time-max 60 filter [ aci ];
            }
        }
        unit 200 {
            family pppoe {
                max-sessions 10;
                duplicate-protection;
                short-cycle-protection;
            }
        }
        unit 300 {
            description plain;
        }
    }
}
"#,
        ));
        let pp0 = &ifaces[0].units;
        let pppoe = pp0[0].pppoe_options.as_ref().unwrap();
        assert_eq!(pppoe.access_concentrator.as_deref(), Some("AC1"));
        assert_eq!(pppoe.auto_reconnect.as_deref(), Some("10"));
        assert_eq!(pppoe.role.as_deref(), Some("client"));
        assert!(pppoe.ignore_eol_tag);
        assert_eq!(pppoe.service_name.as_deref(), Some("isp"));
        assert_eq!(pppoe.underlying_interface.as_deref(), Some("ge-0/0/0.0"));
        assert_eq!(pppoe.ppp_max_payload.as_deref(), Some("1500"));
        let ppp = pp0[0].ppp_options.as_ref().unwrap();
        assert!(ppp.peer_ip_address_optional);
        assert_eq!(ppp.initiate_ncp.as_deref(), Some("ipv6"));
        assert_eq!(
            ppp.chap.as_ref().unwrap().challenge_length_maximum.as_deref(),
            Some("16")
        );
        assert_eq!(pp0[1].pppoe_options.as_ref().unwrap().role.as_deref(), Some("server"));
        assert!(pp0[1].ppp_options.is_none());

        let units = &ifaces[1].units;
        let underlying = units[0].pppoe_underlying_options.as_ref().unwrap();
        assert_eq!(underlying.access_concentrator.as_deref(), Some("AC2"));
        assert_eq!(underlying.dynamic_profile.as_deref(), Some("pppoe-prof"));
        assert!(underlying.direct_connect && underlying.max_sessions_vsa_ignore);
        assert!(
            underlying
                .duplicate_protection
                .as_ref()
                .unwrap()
                .include_relay_session_id
        );
        assert_eq!(underlying.max_sessions.as_deref(), Some("500"));
        assert_eq!(underlying.service_name_table.as_deref(), Some("SNT"));
        let cycle = underlying.short_cycle_protection.as_ref().unwrap();
        assert_eq!(cycle.lockout_time_min.as_deref(), Some("1"));
        assert_eq!(cycle.lockout_time_max.as_deref(), Some("60"));
        assert_eq!(cycle.filter, ["aci"]);

        let family = units[1].family_settings[0].pppoe.as_ref().unwrap();
        assert_eq!(family.max_sessions.as_deref(), Some("10"));
        assert!(!family.duplicate_protection.as_ref().unwrap().include_relay_session_id);
        let bare = family.short_cycle_protection.as_ref().unwrap();
        assert!(bare.lockout_time_min.is_none() && bare.filter.is_empty());

        assert!(units[2].pppoe_underlying_options.is_none() && units[2].pppoe_options.is_none());
        assert!(units[2].ppp_options.is_none());
    }

    #[test]
    fn extracts_unit_vlan_id_forms_and_encapsulation() {
        let units = &interfaces(&juniper::parse_braces(CONFIG))[0].units;
        assert_eq!(units[0].vlan_id, Some(100));
        assert!(!units[0].vlan_id_unmatched);
        assert_eq!(units[0].encapsulation.as_deref(), Some("vlan-bridge"));

        assert_eq!(units[2].vlan_id, None);
        assert!(units[2].vlan_id_unmatched);

        assert_eq!(units[3].vlan_id_range.as_deref(), Some("400-499"));
        assert_eq!(units[1].encapsulation, None);
    }

    #[test]
    fn extracts_vlan_tags() {
        let units = &interfaces(&juniper::parse_braces(CONFIG))[0].units;
        let tags = units[1].vlan_tags.as_ref().unwrap();
        assert_eq!(tags.outer.as_deref(), Some("0x8100.200"));
        assert_eq!(tags.inner.as_deref(), Some("0x8100.300"));
        assert_eq!(tags.inner_range, None);

        let ranged = units[3].vlan_tags.as_ref().unwrap();
        assert_eq!(ranged.outer.as_deref(), Some("500"));
        assert_eq!(ranged.inner, None);
        assert_eq!(ranged.inner_range.as_deref(), Some("1-4094"));

        assert!(units[0].vlan_tags.is_none());
    }

    #[test]
    fn extracts_vlan_maps_in_block_and_one_line_form() {
        let units = &interfaces(&juniper::parse_braces(CONFIG))[0].units;

        let input = units[0].input_vlan_map.as_ref().unwrap();
        assert_eq!(input.operation.as_deref(), Some("swap"));
        assert_eq!(input.tag_protocol_id.as_deref(), Some("0x8100"));
        assert_eq!(input.vlan_id.as_deref(), Some("200"));
        assert_eq!(input.inner_vlan_id, None);
        assert_eq!(
            units[0].output_vlan_map.as_ref().unwrap().operation.as_deref(),
            Some("swap")
        );

        let input = units[1].input_vlan_map.as_ref().unwrap();
        assert_eq!(input.operation.as_deref(), Some("push-push"));
        assert_eq!(input.tag_protocol_id.as_deref(), Some("0x9100"));
        assert_eq!(input.vlan_id.as_deref(), Some("10"));
        assert_eq!(input.inner_tag_protocol_id.as_deref(), Some("0x8100"));
        assert_eq!(input.inner_vlan_id.as_deref(), Some("20"));
        assert_eq!(
            units[1].output_vlan_map.as_ref().unwrap().operation.as_deref(),
            Some("pop-pop")
        );

        assert!(units[2].input_vlan_map.is_none());
        assert!(units[2].output_vlan_map.is_none());
    }

    #[test]
    fn extracts_bridge_family_vlan_ids() {
        let ifaces = interfaces(&juniper::parse_braces(
            "interfaces {\n    ge-0/0/1 {\n        unit 0 {\n            family bridge {\n                vlan-id-list [ 100-200 300 ];\n                vlan-id 50;\n            }\n        }\n    }\n}\n",
        ));
        let bridge = &ifaces[0].units[0].family_settings[0];
        assert_eq!(bridge.name, "bridge");
        assert_eq!(bridge.vlan_id_list, ["100-200", "300"]);
        assert_eq!(bridge.vlan_id.as_deref(), Some("50"));
    }

    // Adapted from the EVPN-VXLAN User Guide, the IGMP snooping example: the `irb` units of the first leaf device; see
    // the README "Sources".
    #[test]
    fn reads_the_guide_virtual_gateway_address() {
        let ifaces = interfaces(&juniper::parse_braces(
            "interfaces {\n    irb {\n        unit 1 {\n            family inet {\n                address 10.1.1.1/24 {\n                    virtual-gateway-address 10.1.1.10;\n                }\n            }\n        }\n        unit 2 {\n            family inet {\n                address 10.2.1.1/24 {\n                    virtual-gateway-address 10.2.1.10;\n                }\n            }\n        }\n    }\n}\n",
        ));
        let units = &ifaces[0].units;
        let address = &units[0].family_settings[0].addresses[0];
        assert_eq!(address.address, "10.1.1.1/24");
        assert_eq!(address.virtual_gateway_address.as_deref(), Some("10.1.1.10"));
        assert_eq!(
            units[1].family_settings[0].addresses[0]
                .virtual_gateway_address
                .as_deref(),
            Some("10.2.1.10")
        );
    }

    // Not from documentation: written from the CLI Reference pages; `virtual-gateway-esi` follows the `set` commands of
    // the EVPN-VXLAN WAN example, in brace form. See the README "Sources".
    #[test]
    fn reads_the_irb_unit_statements() {
        let ifaces = interfaces(&juniper::parse_braces(
            r#"
interfaces {
    irb {
        unit 1 {
            proxy-macip-advertisement;
            enhanced-convergence;
            virtual-gateway-v4-mac 00:00:5e:00:01:01;
            virtual-gateway-v6-mac 00:00:5e:00:02:01;
            virtual-gateway-esi {
                00:11:aa:aa:aa:aa:aa:aa:aa:aa;
                all-active;
            }
            proxy-arp restricted;
            ip-address-owner SERVICE;
            family inet6 {
                nd6-max-cache 1000;
                nd6-stale-time 1200;
                nd6-new-hold-limit 5;
            }
        }
        unit 2 {
            proxy-arp;
            family inet;
        }
    }
    ge-0/0/0 {
        media-type fiber;
        ether-options {
            mdi-mode auto;
            no-auto-mdix;
        }
    }
}
"#,
        ));
        let unit = &ifaces[0].units[0];
        assert!(unit.proxy_macip_advertisement && unit.enhanced_convergence);
        assert_eq!(unit.virtual_gateway_v4_mac.as_deref(), Some("00:00:5e:00:01:01"));
        assert_eq!(unit.virtual_gateway_v6_mac.as_deref(), Some("00:00:5e:00:02:01"));
        let esi = unit.virtual_gateway_esi.as_ref().unwrap();
        assert_eq!(esi.identifier.as_deref(), Some("00:11:aa:aa:aa:aa:aa:aa:aa:aa"));
        assert!(esi.all_active);
        assert!(unit.proxy_arp);
        assert_eq!(unit.proxy_arp_mode.as_deref(), Some("restricted"));
        assert_eq!(unit.ip_address_owner.as_deref(), Some("SERVICE"));
        let inet6 = &unit.family_settings[0];
        assert_eq!(inet6.nd6_max_cache.as_deref(), Some("1000"));
        assert_eq!(inet6.nd6_stale_time.as_deref(), Some("1200"));
        assert_eq!(inet6.nd6_new_hold_limit.as_deref(), Some("5"));

        let bare = &ifaces[0].units[1];
        assert!(bare.proxy_arp);
        assert_eq!(bare.proxy_arp_mode, None);
        assert!(!bare.proxy_macip_advertisement && bare.virtual_gateway_esi.is_none());

        let port = &ifaces[1];
        assert_eq!(port.media_type.as_deref(), Some("fiber"));
        let ether = port.ether_options.as_ref().unwrap();
        assert_eq!(ether.mdi_mode.as_deref(), Some("auto"));
        assert!(ether.no_auto_mdix);
    }
}