Skip to main content

asterust_junos/system/
packet_forwarding_options.rs

1//! `packet-forwarding-options`
2//! `system { packet-forwarding-options { ... } }`.
3//!
4//! Most of these statements are platform specific and restart the Packet Forwarding Engine.
5//!
6//! # See also
7//!
8//! - [eracl-ip6-match](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/eracl-ip6-match-edit-system.html)
9//! - [flow-export-timer](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/flow-export-timer-edit-system-packet-fo.html)
10//! - [hw-db-profile](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/system-packet-forwarding-options-hw-db-profile.html)
11//! - [mcast stats-enable](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/mcast-stats-enable-edit-system-packet-forwarding-options.html)
12//! - [mcast-repl-type ingress-only](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/system-packet-forwarding-options-mcast-repl-type-ingress-only.html)
13//! - [mcast-repl-type ingress-egress-recycle](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/system-packet-forwarding-options-mcast-repl-type-ingress-egress-recycle.html)
14//! - [mef-forwarding-profile](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/mef-forwarding-profile-edit-system-packet-forwarding-options.html)
15//! - [mpls (packet-forwarding-options)](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/system-packet-forwarding-options-mpls.html)
16//! - [overlay (Packet Forwarding Options)](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/overlay-edit-system-packet-forwarding-options.html)
17//! - [packet-format-match](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/system-packet-forwarding-options-packet-format-match.html)
18//! - [recycle-bandwidth-profiles](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/system-packet-forwarding-options-recycle-bandwidth-profiles.html)
19//! - [vxlan-extended](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/system-packet-forwarding-options-system-profile-vxlan-extended.html)
20//! - [vxlan-stitching](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/vxlan-stitching-edit-system-packet-forwarding-options-system-profile.html)
21//! - [eracl-profile (packet-forwarding-options)](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/system-packet-forwarding-options-firewall-eracl-profile.html)
22//! - [ethernet-switching (firewall profiles)](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/ethernet-switching-edit-system-packet-forwarding-options-firewall-profiles.html)
23//! - [polling-interval (Network Management)](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/polling-interval-edit-system-packet-forwarding-options-hw-resource-monitor.html)
24//! - [monitor-profile](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/monitor-profile-edit-system-packet-forwarding-options-hw-resource-monitor.html)
25//! - [resource-list (Network Management)](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/resource-list-edit-system-packet-forwarding-options-hw-resource-monitor.html)
26//! - [counter-profiles](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/counter-profiles.html)
27//! - [hw-profile](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/hw-profile.html)
28//! - [hw-profiles](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/hw-profiles.html)
29//! - [internal-forwarding-bandwidth](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/internal-forwarding-bandwidth.html)
30//! - [reserve ingress-egress-mcast](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/reserve-ingress-egress-mcast.html)
31//! - [ipfix-sw-mode](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/ipfix-sw-mode-system-packet-forwarding-options.html)
32//! - [no-ip-tos-rewrite](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/no-ip-tos-rewrite.html)
33//! - [multicast-statistics (packet-forwarding-options)](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/autogen-system-packet-forwarding-options-multicast-statistics.html)
34//! - [force-fbf-terms](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/force-fbf-terms.html)
35//! - [egress-l2-extended-match](https://networkingdocs.hpe.com/documentation/us/en/software/junos/cli-reference/topics/ref/statement/egress-l2-extended-match.html)
36
37use crate::{
38    active_children, arg_of, args_of, child_block, has_leaf, list_values, named_children, statements, value_after,
39};
40use asterust::config::ConfigLine;
41
42/// A `profile <name>` of `recycle-bandwidth-profiles`.
43#[derive(Clone, Debug, PartialEq, Eq)]
44#[non_exhaustive]
45pub struct RecycleBandwidthProfile {
46    pub name: String,
47    /// `(application, percentage)` pairs such as `("tunnel-services", "20")`.
48    pub applications: Vec<(String, String)>,
49}
50
51/// An `app <name>` of a custom counter profile.
52#[derive(Clone, Debug, PartialEq, Eq)]
53#[non_exhaustive]
54pub struct CounterProfileApp {
55    pub name: String,
56    /// Counter engines of each size.
57    pub counter_4k: Option<String>,
58    pub counter_8k: Option<String>,
59    pub counter_16k: Option<String>,
60}
61
62/// A `counter-profiles <name>` of `custom-profiles`.
63#[derive(Clone, Debug, PartialEq, Eq)]
64#[non_exhaustive]
65pub struct CounterProfile {
66    pub name: String,
67    pub apps: Vec<CounterProfileApp>,
68}
69
70/// A `hw-profiles <name>` of `custom-profiles`: a grouping of custom profiles.
71#[derive(Clone, Debug, PartialEq, Eq)]
72#[non_exhaustive]
73pub struct HwProfile {
74    pub name: String,
75    pub counter_profile: Option<String>,
76}
77
78/// The `system-profile` block.
79#[derive(Clone, Debug, PartialEq, Eq)]
80#[non_exhaustive]
81pub struct PfeSystemProfile {
82    pub vxlan_extended: bool,
83    pub vxlan_stitching: bool,
84    /// `vxlan-stitching { control-word; }`.
85    pub vxlan_stitching_control_word: bool,
86}
87
88/// The `firewall` block of `packet-forwarding-options`.
89#[derive(Clone, Debug, PartialEq, Eq)]
90#[non_exhaustive]
91pub struct PfeFirewall {
92    /// `eracl-profile { eracl-scale; }`: egress firewall filters in scaled mode.
93    pub eracl_scale: bool,
94    pub force_fbf_terms: bool,
95    /// The profiles of `profiles ethernet-switching`, e.g. `profile1`, `udf-profile1`.
96    pub ethernet_switching_profiles: Vec<String>,
97    /// The profiles of `profiles ethernet-switching egress`.
98    pub ethernet_switching_egress_profiles: Vec<String>,
99}
100
101/// A `monitor-profile <name>` of `hw-resource-monitor`.
102#[derive(Clone, Debug, PartialEq, Eq)]
103#[non_exhaustive]
104pub struct HwMonitorProfile {
105    pub name: String,
106    pub lower_threshold: Option<String>,
107    /// `alarm`, `none` or `syslog`.
108    pub notification_type: Option<String>,
109    pub upper_threshold: Option<String>,
110}
111
112/// A `resource-list <name>` of `hw-resource-monitor`.
113#[derive(Clone, Debug, PartialEq, Eq)]
114#[non_exhaustive]
115pub struct HwResourceList {
116    pub name: String,
117    /// The `resource-names`, e.g. `lpm-ipv4`.
118    pub resource_names: Vec<String>,
119}
120
121/// The `hw-resource-monitor` block.
122#[derive(Clone, Debug, PartialEq, Eq)]
123#[non_exhaustive]
124pub struct HwResourceMonitor {
125    /// Milliseconds.
126    pub polling_interval: Option<String>,
127    pub monitor_profiles: Vec<HwMonitorProfile>,
128    pub resource_lists: Vec<HwResourceList>,
129}
130
131/// The `system packet-forwarding-options` settings.
132#[derive(Clone, Debug, PartialEq, Eq)]
133#[non_exhaustive]
134pub struct PacketForwardingOptions {
135    /// `srcip6-and-destip6` or `srcip6-only`.
136    pub eracl_ip6_match: Option<String>,
137    /// Seconds.
138    pub flow_export_timer: Option<String>,
139    /// e.g. `lean-edge`, `bng`, `carrier-ethernet` or `cloud-metro`.
140    pub hw_db_profile: Option<String>,
141    /// `mcast { stats-enable; }`.
142    pub mcast_stats_enable: bool,
143    /// `ingress-only` or `ingress-egress-recycle`.
144    pub mcast_repl_type: Option<String>,
145    pub mef_forwarding_profile: bool,
146    pub mpls_lsp_ingress_stats_enable: bool,
147    pub mpls_lsp_transit_stats_enable: bool,
148    /// From `overlay { interface-num }`.
149    pub overlay_interface_num: Option<String>,
150    /// From `overlay { next-hop }`.
151    pub overlay_next_hop: Option<String>,
152    /// e.g. `mpls-packet-format-1`.
153    pub packet_format_match: Option<String>,
154    pub recycle_bandwidth_profiles: Vec<RecycleBandwidthProfile>,
155    pub system_profile: Option<PfeSystemProfile>,
156    pub firewall: Option<PfeFirewall>,
157    pub hw_resource_monitor: Option<HwResourceMonitor>,
158    pub counter_profiles: Vec<CounterProfile>,
159    pub hw_profiles: Vec<HwProfile>,
160    /// The custom hardware profile made active with `hw-profile <name>`.
161    pub hw_profile: Option<String>,
162    /// From `internal-forwarding-bandwidth <value>`.
163    pub internal_forwarding_bandwidth: Option<String>,
164    /// Percentage, from `internal-forwarding-bandwidth { reserve ingress-egress-mcast }`.
165    pub internal_forwarding_reserve_ingress_egress_mcast: Option<String>,
166    pub ipfix_sw_mode: bool,
167    pub no_ip_tos_rewrite: bool,
168    pub multicast_statistics: bool,
169    /// From `firewall-profile { egress-l2-extended-match; }`.
170    pub egress_l2_extended_match: bool,
171}
172
173fn parse_firewall(firewall: &ConfigLine) -> PfeFirewall {
174    let switching = child_block(firewall, "profiles").and_then(|profiles| child_block(profiles, "ethernet-switching"));
175    PfeFirewall {
176        eracl_scale: child_block(firewall, "eracl-profile").is_some_and(|profile| has_leaf(profile, "eracl-scale")),
177        force_fbf_terms: has_leaf(firewall, "force-fbf-terms"),
178        ethernet_switching_profiles: switching
179            .map(|s| {
180                active_children(s)
181                    .filter(|c| c.text != "egress")
182                    .map(|c| c.text.clone())
183                    .collect()
184            })
185            .unwrap_or_default(),
186        ethernet_switching_egress_profiles: switching
187            .and_then(|s| child_block(s, "egress"))
188            .map(|egress| active_children(egress).map(|c| c.text.clone()).collect())
189            .unwrap_or_default(),
190    }
191}
192
193fn parse_hw_resource_monitor(monitor: &ConfigLine) -> HwResourceMonitor {
194    HwResourceMonitor {
195        polling_interval: arg_of(monitor, "polling-interval").map(str::to_string),
196        monitor_profiles: named_children(monitor, "monitor-profile")
197            .map(|(name, profile)| HwMonitorProfile {
198                name: name.to_string(),
199                lower_threshold: arg_of(profile, "lower-threshold").map(str::to_string),
200                notification_type: arg_of(profile, "notification-type").map(str::to_string),
201                upper_threshold: arg_of(profile, "upper-threshold").map(str::to_string),
202            })
203            .collect(),
204        resource_lists: named_children(monitor, "resource-list")
205            .map(|(name, list)| HwResourceList {
206                name: name.to_string(),
207                resource_names: args_of(list, "resource-names")
208                    .into_iter()
209                    .flat_map(list_values)
210                    .collect(),
211            })
212            .collect(),
213    }
214}
215
216/// The words of an entry written as `<name> <options...>` or `<name> { <options>; }`.
217fn entry_words(entry: &ConfigLine) -> Vec<&str> {
218    entry
219        .text
220        .split_whitespace()
221        .chain(active_children(entry).flat_map(|c| c.text.split_whitespace()))
222        .collect()
223}
224
225pub(super) fn parse_packet_forwarding_options(options: &ConfigLine) -> PacketForwardingOptions {
226    let overlay = child_block(options, "overlay");
227    let mpls = child_block(options, "mpls");
228    let profile = child_block(options, "system-profile");
229    let custom = child_block(options, "custom-profiles");
230    let bandwidth = child_block(options, "internal-forwarding-bandwidth");
231    PacketForwardingOptions {
232        eracl_ip6_match: statements(options, "eracl-ip6-match").first().map(|s| s.to_string()),
233        flow_export_timer: arg_of(options, "flow-export-timer").map(str::to_string),
234        hw_db_profile: statements(options, "hw-db-profile").first().map(|s| s.to_string()),
235        mcast_stats_enable: child_block(options, "mcast").is_some_and(|mcast| has_leaf(mcast, "stats-enable")),
236        mcast_repl_type: statements(options, "mcast-repl-type").first().map(|s| s.to_string()),
237        mef_forwarding_profile: has_leaf(options, "mef-forwarding-profile"),
238        mpls_lsp_ingress_stats_enable: mpls.is_some_and(|m| has_leaf(m, "lsp-ingress-stats-enable")),
239        mpls_lsp_transit_stats_enable: mpls.is_some_and(|m| has_leaf(m, "lsp-transit-stats-enable")),
240        overlay_interface_num: overlay.and_then(|o| arg_of(o, "interface-num")).map(str::to_string),
241        overlay_next_hop: overlay.and_then(|o| arg_of(o, "next-hop")).map(str::to_string),
242        packet_format_match: statements(options, "packet-format-match")
243            .first()
244            .map(|s| s.to_string()),
245        recycle_bandwidth_profiles: named_children(options, "recycle-bandwidth-profiles")
246            .map(|(name, profile)| RecycleBandwidthProfile {
247                name: name.to_string(),
248                applications: active_children(profile)
249                    .filter_map(|c| {
250                        let (application, percentage) = c.text.split_once(char::is_whitespace)?;
251                        Some((application.to_string(), percentage.trim().to_string()))
252                    })
253                    .collect(),
254            })
255            .collect(),
256        system_profile: profile.map(|profile| PfeSystemProfile {
257            vxlan_extended: has_leaf(profile, "vxlan-extended"),
258            vxlan_stitching: child_block(profile, "vxlan-stitching").is_some(),
259            vxlan_stitching_control_word: child_block(profile, "vxlan-stitching")
260                .is_some_and(|stitching| has_leaf(stitching, "control-word")),
261        }),
262        firewall: child_block(options, "firewall").map(parse_firewall),
263        hw_resource_monitor: child_block(options, "hw-resource-monitor").map(parse_hw_resource_monitor),
264        counter_profiles: custom
265            .map(|custom| {
266                named_children(custom, "counter-profiles")
267                    .map(|(name, profile)| CounterProfile {
268                        name: name.to_string(),
269                        apps: child_block(profile, "app")
270                            .map(|app| {
271                                active_children(app)
272                                    .map(|entry| {
273                                        let words = entry_words(entry);
274                                        CounterProfileApp {
275                                            name: words.first().unwrap_or(&"").to_string(),
276                                            counter_4k: value_after(&words, "counter-4k"),
277                                            counter_8k: value_after(&words, "counter-8k"),
278                                            counter_16k: value_after(&words, "counter-16k"),
279                                        }
280                                    })
281                                    .collect()
282                            })
283                            .unwrap_or_default(),
284                    })
285                    .collect()
286            })
287            .unwrap_or_default(),
288        hw_profiles: custom
289            .map(|custom| {
290                named_children(custom, "hw-profiles")
291                    .map(|(name, profile)| HwProfile {
292                        name: name.to_string(),
293                        counter_profile: arg_of(profile, "counter-profile").map(str::to_string),
294                    })
295                    .collect()
296            })
297            .unwrap_or_default(),
298        hw_profile: arg_of(options, "hw-profile").map(str::to_string),
299        internal_forwarding_bandwidth: arg_of(options, "internal-forwarding-bandwidth").map(str::to_string),
300        internal_forwarding_reserve_ingress_egress_mcast: bandwidth
301            .and_then(|b| arg_of(b, "reserve"))
302            .and_then(|reserve| value_after(&reserve.split_whitespace().collect::<Vec<_>>(), "ingress-egress-mcast")),
303        ipfix_sw_mode: has_leaf(options, "ipfix-sw-mode"),
304        no_ip_tos_rewrite: has_leaf(options, "no-ip-tos-rewrite"),
305        multicast_statistics: has_leaf(options, "multicast-statistics"),
306        egress_l2_extended_match: child_block(options, "firewall-profile")
307            .is_some_and(|profile| has_leaf(profile, "egress-l2-extended-match")),
308    }
309}
310
311#[cfg(test)]
312mod tests {
313    use crate::system::system;
314    use asterust::config::juniper;
315
316    // Not from documentation: written from the CLI Reference syntax pages. See the README "Sources".
317    #[test]
318    fn extracts_the_packet_forwarding_options() {
319        let options = system(&juniper::parse_braces(
320            r#"
321system {
322    packet-forwarding-options {
323        eracl-ip6-match {
324            srcip6-only;
325        }
326        flow-export-timer 30;
327        hw-db-profile {
328            cloud-metro;
329        }
330        mcast {
331            stats-enable;
332        }
333        mcast-repl-type {
334            ingress-only;
335        }
336        mef-forwarding-profile;
337        mpls {
338            lsp-ingress-stats-enable;
339        }
340        overlay {
341            interface-num 2048;
342            next-hop 8192;
343        }
344        packet-format-match {
345            mpls-packet-format-3;
346        }
347        recycle-bandwidth-profiles lab {
348            tunnel-services 20;
349            srv6 30;
350        }
351        system-profile {
352            vxlan-extended;
353            vxlan-stitching {
354                control-word;
355            }
356        }
357        firewall {
358            eracl-profile {
359                eracl-scale;
360            }
361            profiles {
362                ethernet-switching {
363                    profile1;
364                    udf-profile1;
365                    egress {
366                        profile1;
367                    }
368                }
369            }
370        }
371        hw-resource-monitor {
372            polling-interval 5000;
373            monitor-profile alarms {
374                lower-threshold 60;
375                notification-type syslog;
376                upper-threshold 90;
377            }
378            resource-list lpm {
379                resource-names [ lpm-ipv4 lpm-ipv6-64 ];
380            }
381        }
382    }
383}
384"#,
385        ))
386        .unwrap()
387        .packet_forwarding_options
388        .unwrap();
389        assert_eq!(options.eracl_ip6_match.as_deref(), Some("srcip6-only"));
390        assert_eq!(options.flow_export_timer.as_deref(), Some("30"));
391        assert_eq!(options.hw_db_profile.as_deref(), Some("cloud-metro"));
392        assert!(options.mcast_stats_enable);
393        assert_eq!(options.mcast_repl_type.as_deref(), Some("ingress-only"));
394        assert!(options.mef_forwarding_profile);
395        assert!(options.mpls_lsp_ingress_stats_enable);
396        assert!(!options.mpls_lsp_transit_stats_enable);
397        assert_eq!(options.overlay_interface_num.as_deref(), Some("2048"));
398        assert_eq!(options.overlay_next_hop.as_deref(), Some("8192"));
399        assert_eq!(options.packet_format_match.as_deref(), Some("mpls-packet-format-3"));
400        assert_eq!(options.recycle_bandwidth_profiles[0].name, "lab");
401        assert_eq!(
402            options.recycle_bandwidth_profiles[0].applications,
403            [
404                ("tunnel-services".to_string(), "20".to_string()),
405                ("srv6".to_string(), "30".to_string())
406            ]
407        );
408        let profile = options.system_profile.unwrap();
409        assert!(profile.vxlan_extended);
410        assert!(profile.vxlan_stitching);
411        assert!(profile.vxlan_stitching_control_word);
412
413        let firewall = options.firewall.unwrap();
414        assert!(firewall.eracl_scale);
415        assert_eq!(firewall.ethernet_switching_profiles, ["profile1", "udf-profile1"]);
416        assert_eq!(firewall.ethernet_switching_egress_profiles, ["profile1"]);
417
418        let monitor = options.hw_resource_monitor.unwrap();
419        assert_eq!(monitor.polling_interval.as_deref(), Some("5000"));
420        assert_eq!(monitor.monitor_profiles[0].name, "alarms");
421        assert_eq!(monitor.monitor_profiles[0].lower_threshold.as_deref(), Some("60"));
422        assert_eq!(monitor.monitor_profiles[0].notification_type.as_deref(), Some("syslog"));
423        assert_eq!(monitor.monitor_profiles[0].upper_threshold.as_deref(), Some("90"));
424        assert_eq!(monitor.resource_lists[0].name, "lpm");
425        assert_eq!(monitor.resource_lists[0].resource_names, ["lpm-ipv4", "lpm-ipv6-64"]);
426    }
427
428    #[test]
429    fn extracts_the_custom_profiles_and_other_statements() {
430        let options = system(&juniper::parse_braces(
431            r#"
432system {
433    packet-forwarding-options {
434        custom-profiles {
435            counter-profiles flows {
436                app {
437                    acl {
438                        counter-4k 2;
439                        counter-8k 1;
440                    }
441                    telemetry {
442                        counter-16k 4;
443                    }
444                }
445            }
446            hw-profiles edge {
447                counter-profile flows;
448            }
449        }
450        hw-profile edge;
451        internal-forwarding-bandwidth {
452            reserve ingress-egress-mcast 40;
453        }
454        ipfix-sw-mode;
455        no-ip-tos-rewrite;
456        multicast-statistics;
457        firewall {
458            force-fbf-terms;
459        }
460        firewall-profile {
461            egress-l2-extended-match;
462        }
463    }
464}
465"#,
466        ))
467        .unwrap()
468        .packet_forwarding_options
469        .unwrap();
470        assert_eq!(options.counter_profiles[0].name, "flows");
471        let acl = &options.counter_profiles[0].apps[0];
472        assert_eq!(acl.name, "acl");
473        assert_eq!(acl.counter_4k.as_deref(), Some("2"));
474        assert_eq!(acl.counter_8k.as_deref(), Some("1"));
475        assert_eq!(acl.counter_16k, None);
476        assert_eq!(options.counter_profiles[0].apps[1].counter_16k.as_deref(), Some("4"));
477        assert_eq!(options.hw_profiles[0].name, "edge");
478        assert_eq!(options.hw_profiles[0].counter_profile.as_deref(), Some("flows"));
479        assert_eq!(options.hw_profile.as_deref(), Some("edge"));
480        assert_eq!(options.internal_forwarding_bandwidth, None);
481        assert_eq!(
482            options.internal_forwarding_reserve_ingress_egress_mcast.as_deref(),
483            Some("40")
484        );
485        assert!(options.ipfix_sw_mode);
486        assert!(options.no_ip_tos_rewrite);
487        assert!(options.multicast_statistics);
488        assert!(options.firewall.unwrap().force_fbf_terms);
489        assert!(options.egress_l2_extended_match);
490    }
491
492    #[test]
493    fn reads_the_inline_internal_forwarding_bandwidth() {
494        let options = system(&juniper::parse_braces(
495            "system {\n    packet-forwarding-options {\n        internal-forwarding-bandwidth 50g;\n    }\n}\n",
496        ))
497        .unwrap()
498        .packet_forwarding_options
499        .unwrap();
500        assert_eq!(options.internal_forwarding_bandwidth.as_deref(), Some("50g"));
501        assert_eq!(options.internal_forwarding_reserve_ingress_egress_mcast, None);
502        assert!(options.counter_profiles.is_empty());
503    }
504
505    #[test]
506    fn accepts_the_inline_forms() {
507        let options = system(&juniper::parse_braces(
508            "system {\n    packet-forwarding-options {\n        hw-db-profile bng;\n        mcast-repl-type ingress-egress-recycle;\n        mcast {\n            stats-enable;\n        }\n    }\n}\n",
509        ))
510        .unwrap()
511        .packet_forwarding_options
512        .unwrap();
513        assert_eq!(options.hw_db_profile.as_deref(), Some("bng"));
514        assert_eq!(options.mcast_repl_type.as_deref(), Some("ingress-egress-recycle"));
515        assert!(options.system_profile.is_none());
516        assert!(options.firewall.is_none());
517    }
518
519    #[test]
520    fn no_packet_forwarding_options_is_none() {
521        let system = system(&juniper::parse_braces("system {\n    host-name pe1;\n}\n")).unwrap();
522        assert!(system.packet_forwarding_options.is_none());
523    }
524}