1919use anyhow:: Result ;
2020use capsule:: fieldmap;
2121use capsule:: packets:: ethernet:: Ethernet ;
22- use capsule:: packets:: ip:: v4:: Ipv4 ;
23- use capsule:: packets:: ip:: v6:: { Ipv6 , SegmentRouting } ;
22+ use capsule:: packets:: ip:: v4:: Ip4 ;
23+ use capsule:: packets:: ip:: v6:: { Ip6 , SegmentRouting } ;
2424use capsule:: packets:: udp:: Udp4 ;
2525use capsule:: packets:: { Mbuf , Packet } ;
2626use capsule:: testils:: criterion:: BencherExt ;
@@ -32,30 +32,30 @@ use std::net::Ipv6Addr;
3232
3333const BATCH_SIZE : usize = 500 ;
3434
35- fn single_parse_udp ( ipv4 : Ipv4 ) -> Udp4 {
36- ipv4 . parse :: < Udp4 > ( ) . unwrap ( )
35+ fn single_parse_udp ( ip4 : Ip4 ) -> Udp4 {
36+ ip4 . parse :: < Udp4 > ( ) . unwrap ( )
3737}
3838
39- fn single_peek_udp ( ipv4 : Ipv4 ) -> Ipv4 {
40- ipv4 . peek :: < Udp4 > ( ) . unwrap ( ) ;
41- ipv4
39+ fn single_peek_udp ( ip4 : Ip4 ) -> Ip4 {
40+ ip4 . peek :: < Udp4 > ( ) . unwrap ( ) ;
41+ ip4
4242}
4343
4444#[ capsule:: bench( mempool_capacity = 511 ) ]
4545fn single_peek_vs_parse ( c : & mut Criterion ) {
4646 let mut group = c. benchmark_group ( "packets::single_peek_vs_parse_on_udp" ) ;
4747
4848 group. bench_function ( "packets::single_parse_udp" , |b| {
49- let s = v4_udp ( ) . prop_map ( |v| {
50- let packet = v. into_v4_udp ( ) ;
49+ let s = udp4 ( ) . prop_map ( |v| {
50+ let packet = v. into_udp4 ( ) ;
5151 packet. deparse ( )
5252 } ) ;
5353 b. iter_proptest_batched ( s, single_parse_udp, BATCH_SIZE )
5454 } ) ;
5555
5656 group. bench_function ( "packets::single_peek_udp" , |b| {
57- let s = v4_udp ( ) . prop_map ( |v| {
58- let packet = v. into_v4_udp ( ) ;
57+ let s = udp4 ( ) . prop_map ( |v| {
58+ let packet = v. into_udp4 ( ) ;
5959 packet. deparse ( )
6060 } ) ;
6161 b. iter_proptest_batched ( s, single_peek_udp, BATCH_SIZE )
@@ -66,14 +66,14 @@ fn single_peek_vs_parse(c: &mut Criterion) {
6666
6767fn multi_parse_udp ( mbuf : Mbuf ) -> Udp4 {
6868 let ethernet = mbuf. parse :: < Ethernet > ( ) . unwrap ( ) ;
69- let ipv4 = ethernet. parse :: < Ipv4 > ( ) . unwrap ( ) ;
70- ipv4 . parse :: < Udp4 > ( ) . unwrap ( )
69+ let ip4 = ethernet. parse :: < Ip4 > ( ) . unwrap ( ) ;
70+ ip4 . parse :: < Udp4 > ( ) . unwrap ( )
7171}
7272
7373fn multi_peek_udp ( mbuf : Mbuf ) -> Mbuf {
7474 let ethernet = mbuf. peek :: < Ethernet > ( ) . unwrap ( ) ;
75- let ipv4 = ethernet. peek :: < Ipv4 > ( ) . unwrap ( ) ;
76- ipv4 . peek :: < Udp4 > ( ) . unwrap ( ) ;
75+ let ip4 = ethernet. peek :: < Ip4 > ( ) . unwrap ( ) ;
76+ ip4 . peek :: < Udp4 > ( ) . unwrap ( ) ;
7777 mbuf
7878}
7979
@@ -82,70 +82,70 @@ fn multi_peek_vs_parse(c: &mut Criterion) {
8282 let mut group = c. benchmark_group ( "packets::multi_peek_vs_parse_on_udp_packets" ) ;
8383
8484 group. bench_function ( "packets::multi_parse_udp" , |b| {
85- let s = v4_udp ( ) ;
85+ let s = udp4 ( ) ;
8686 b. iter_proptest_batched ( s, multi_parse_udp, BATCH_SIZE )
8787 } ) ;
8888
8989 group. bench_function ( "packets::multi_peek_udp" , |b| {
90- let s = v4_udp ( ) ;
90+ let s = udp4 ( ) ;
9191 b. iter_proptest_batched ( s, multi_peek_udp, BATCH_SIZE )
9292 } ) ;
9393
9494 group. finish ( )
9595}
9696
97- fn single_parse_srh ( ipv6 : Ipv6 ) -> SegmentRouting < Ipv6 > {
98- ipv6 . parse :: < SegmentRouting < Ipv6 > > ( ) . unwrap ( )
97+ fn single_parse_sr ( ip6 : Ip6 ) -> SegmentRouting < Ip6 > {
98+ ip6 . parse :: < SegmentRouting < Ip6 > > ( ) . unwrap ( )
9999}
100100
101101#[ capsule:: bench( mempool_capacity = 511 ) ]
102- fn single_parse_srh_segments_sizes ( c : & mut Criterion ) {
103- let mut group = c. benchmark_group ( "packets::parsing_on_SRH_across_segment_sizes " ) ;
102+ fn single_parse_sr_segments_sizes ( c : & mut Criterion ) {
103+ let mut group = c. benchmark_group ( "packets::parsing_on_sr_across_segment_sizes " ) ;
104104
105105 let mut rvg = Rvg :: new ( ) ;
106106
107- group. bench_function ( "packets::single_parse_srh ::size=1" , |b| {
107+ group. bench_function ( "packets::single_parse_sr ::size=1" , |b| {
108108 let segments = rvg. generate_vec ( & any :: < Ipv6Addr > ( ) , 1 ) ;
109109 let s = sr_tcp_with ( fieldmap ! { field:: sr_segments => segments} )
110110 . prop_map ( |v| v. into_sr ( ) . deparse ( ) ) ;
111- b. iter_proptest_batched ( s, single_parse_srh , BATCH_SIZE )
111+ b. iter_proptest_batched ( s, single_parse_sr , BATCH_SIZE )
112112 } ) ;
113113
114- group. bench_function ( "packets::single_parse_srh ::size=2" , |b| {
114+ group. bench_function ( "packets::single_parse_sr ::size=2" , |b| {
115115 let segments = rvg. generate_vec ( & any :: < Ipv6Addr > ( ) , 2 ) ;
116116 let s = sr_tcp_with ( fieldmap ! { field:: sr_segments => segments} )
117117 . prop_map ( |v| v. into_sr ( ) . deparse ( ) ) ;
118- b. iter_proptest_batched ( s, single_parse_srh , BATCH_SIZE )
118+ b. iter_proptest_batched ( s, single_parse_sr , BATCH_SIZE )
119119 } ) ;
120120
121- group. bench_function ( "packets::single_parse_srh ::size=4" , |b| {
121+ group. bench_function ( "packets::single_parse_sr ::size=4" , |b| {
122122 let segments = rvg. generate_vec ( & any :: < Ipv6Addr > ( ) , 4 ) ;
123123 let s = sr_tcp_with ( fieldmap ! { field:: sr_segments => segments} )
124124 . prop_map ( |v| v. into_sr ( ) . deparse ( ) ) ;
125- b. iter_proptest_batched ( s, single_parse_srh , BATCH_SIZE )
125+ b. iter_proptest_batched ( s, single_parse_sr , BATCH_SIZE )
126126 } ) ;
127127
128- group. bench_function ( "packets::single_parse_srh ::size=8" , |b| {
128+ group. bench_function ( "packets::single_parse_sr ::size=8" , |b| {
129129 let segments = rvg. generate_vec ( & any :: < Ipv6Addr > ( ) , 8 ) ;
130130 let s = sr_tcp_with ( fieldmap ! { field:: sr_segments => segments} )
131131 . prop_map ( |v| v. into_sr ( ) . deparse ( ) ) ;
132- b. iter_proptest_batched ( s, single_parse_srh , BATCH_SIZE )
132+ b. iter_proptest_batched ( s, single_parse_sr , BATCH_SIZE )
133133 } ) ;
134134
135135 group. finish ( )
136136}
137137
138- fn multi_parse_srh ( mbuf : Mbuf ) -> SegmentRouting < Ipv6 > {
138+ fn multi_parse_sr ( mbuf : Mbuf ) -> SegmentRouting < Ip6 > {
139139 let ethernet = mbuf. parse :: < Ethernet > ( ) . unwrap ( ) ;
140- let ipv6 = ethernet. parse :: < Ipv6 > ( ) . unwrap ( ) ;
141- ipv6 . parse :: < SegmentRouting < Ipv6 > > ( ) . unwrap ( )
140+ let ip6 = ethernet. parse :: < Ip6 > ( ) . unwrap ( ) ;
141+ ip6 . parse :: < SegmentRouting < Ip6 > > ( ) . unwrap ( )
142142}
143143
144144#[ capsule:: bench( mempool_capacity = 511 ) ]
145- fn multi_parse_upto_variable_srh ( c : & mut Criterion ) {
146- c. bench_function ( "packets::multi_parse_srh " , |b| {
145+ fn multi_parse_upto_variable_sr ( c : & mut Criterion ) {
146+ c. bench_function ( "packets::multi_parse_sr " , |b| {
147147 let s = sr_tcp ( ) ;
148- b. iter_proptest_batched ( s, multi_parse_srh , BATCH_SIZE )
148+ b. iter_proptest_batched ( s, multi_parse_sr , BATCH_SIZE )
149149 } ) ;
150150}
151151
@@ -158,7 +158,7 @@ fn deparse_udp(udp: Udp4) -> Mbuf {
158158#[ capsule:: bench( mempool_capacity = 511 ) ]
159159fn deparse ( c : & mut Criterion ) {
160160 c. bench_function ( "packets::deparse_udp" , |b| {
161- let s = v4_udp ( ) . prop_map ( |v| v. into_v4_udp ( ) ) ;
161+ let s = udp4 ( ) . prop_map ( |v| v. into_udp4 ( ) ) ;
162162 b. iter_proptest_batched ( s, deparse_udp, BATCH_SIZE )
163163 } ) ;
164164}
@@ -170,15 +170,15 @@ fn reset_udp(udp: Udp4) -> Mbuf {
170170#[ capsule:: bench( mempool_capacity = 511 ) ]
171171fn reset ( c : & mut Criterion ) {
172172 c. bench_function ( "packets::reset_udp" , |b| {
173- let s = v4_udp ( ) . prop_map ( |v| v. into_v4_udp ( ) ) ;
173+ let s = udp4 ( ) . prop_map ( |v| v. into_udp4 ( ) ) ;
174174 b. iter_proptest_batched ( s, reset_udp, BATCH_SIZE )
175175 } ) ;
176176}
177177
178178fn multi_push_udp ( mbuf : Mbuf ) -> Udp4 {
179179 let ethernet = mbuf. push :: < Ethernet > ( ) . unwrap ( ) ;
180- let ipv4 = ethernet. push :: < Ipv4 > ( ) . unwrap ( ) ;
181- ipv4 . push :: < Udp4 > ( ) . unwrap ( )
180+ let ip4 = ethernet. push :: < Ip4 > ( ) . unwrap ( ) ;
181+ ip4 . push :: < Udp4 > ( ) . unwrap ( )
182182}
183183
184184#[ capsule:: bench( mempool_capacity = 511 ) ]
@@ -189,79 +189,79 @@ fn multi_push(c: &mut Criterion) {
189189 } ) ;
190190}
191191
192- fn single_push_udp ( ipv4 : Ipv4 ) -> Udp4 {
193- ipv4 . push :: < Udp4 > ( ) . unwrap ( )
192+ fn single_push_udp ( ip4 : Ip4 ) -> Udp4 {
193+ ip4 . push :: < Udp4 > ( ) . unwrap ( )
194194}
195195
196196#[ capsule:: bench( mempool_capacity = 511 ) ]
197197fn single_push ( c : & mut Criterion ) {
198198 c. bench_function ( "packets::single_push_udp" , |b| {
199- let s = v4_udp ( ) . prop_map ( |v| {
200- let udp = v. into_v4_udp ( ) ;
199+ let s = udp4 ( ) . prop_map ( |v| {
200+ let udp = v. into_udp4 ( ) ;
201201 udp. remove ( ) . unwrap ( )
202202 } ) ;
203203 b. iter_proptest_batched ( s, single_push_udp, BATCH_SIZE )
204204 } ) ;
205205}
206206
207- fn single_remove_udp ( udp : Udp4 ) -> Ipv4 {
207+ fn single_remove_udp ( udp : Udp4 ) -> Ip4 {
208208 udp. remove ( ) . unwrap ( )
209209}
210210
211211#[ capsule:: bench( mempool_capacity = 511 ) ]
212212fn single_remove ( c : & mut Criterion ) {
213213 c. bench_function ( "packets::single_remove_from_udp" , |b| {
214- let s = v4_udp ( ) . prop_map ( |v| v. into_v4_udp ( ) ) ;
214+ let s = udp4 ( ) . prop_map ( |v| v. into_udp4 ( ) ) ;
215215 b. iter_proptest_batched ( s, single_remove_udp, BATCH_SIZE )
216216 } ) ;
217217}
218218
219219fn multi_remove_udp ( udp : Udp4 ) -> Mbuf {
220- let ipv4 = udp. remove ( ) . unwrap ( ) ;
221- let ethernet = ipv4 . remove ( ) . unwrap ( ) ;
220+ let ip4 = udp. remove ( ) . unwrap ( ) ;
221+ let ethernet = ip4 . remove ( ) . unwrap ( ) ;
222222 ethernet. remove ( ) . unwrap ( )
223223}
224224
225225#[ capsule:: bench( mempool_capacity = 511 ) ]
226226fn multi_remove ( c : & mut Criterion ) {
227227 c. bench_function ( "packets::multi_remove_from_udp" , |b| {
228- let s = v4_udp ( ) . prop_map ( |v| v. into_v4_udp ( ) ) ;
228+ let s = udp4 ( ) . prop_map ( |v| v. into_udp4 ( ) ) ;
229229 b. iter_proptest_batched ( s, multi_remove_udp, BATCH_SIZE )
230230 } ) ;
231231}
232232
233- fn set_srh_segments ( mut args : ( SegmentRouting < Ipv6 > , Vec < Ipv6Addr > ) ) -> Result < ( ) > {
233+ fn set_sr_segments ( mut args : ( SegmentRouting < Ip6 > , Vec < Ipv6Addr > ) ) -> Result < ( ) > {
234234 args. 0 . set_segments ( & args. 1 )
235235}
236236
237237#[ capsule:: bench( mempool_capacity = 511 ) ]
238- fn set_srh_segments_sizes ( c : & mut Criterion ) {
239- let mut group = c. benchmark_group ( "packets::setting_segments_on_SRH_across_segment_sizes " ) ;
238+ fn set_sr_segments_sizes ( c : & mut Criterion ) {
239+ let mut group = c. benchmark_group ( "packets::setting_segments_on_sr_across_segment_sizes " ) ;
240240
241241 let mut rvg = Rvg :: new ( ) ;
242242
243- group. bench_function ( "packets::set_srh_segments ::size=1" , |b| {
243+ group. bench_function ( "packets::set_sr_segments ::size=1" , |b| {
244244 let segments = rvg. generate_vec ( & any :: < Ipv6Addr > ( ) , 1 ) ;
245245 let s = ( sr_tcp ( ) . prop_map ( |v| v. into_sr ( ) ) , Just ( segments) ) ;
246- b. iter_proptest_batched ( s, set_srh_segments , BATCH_SIZE )
246+ b. iter_proptest_batched ( s, set_sr_segments , BATCH_SIZE )
247247 } ) ;
248248
249- group. bench_function ( "packets::set_srh_segments ::size=2" , |b| {
249+ group. bench_function ( "packets::set_sr_segments ::size=2" , |b| {
250250 let segments = rvg. generate_vec ( & any :: < Ipv6Addr > ( ) , 2 ) ;
251251 let s = ( sr_tcp ( ) . prop_map ( |v| v. into_sr ( ) ) , Just ( segments) ) ;
252- b. iter_proptest_batched ( s, set_srh_segments , BATCH_SIZE )
252+ b. iter_proptest_batched ( s, set_sr_segments , BATCH_SIZE )
253253 } ) ;
254254
255- group. bench_function ( "packets::set_srh_segments ::size=4" , |b| {
255+ group. bench_function ( "packets::set_sr_segments ::size=4" , |b| {
256256 let segments = rvg. generate_vec ( & any :: < Ipv6Addr > ( ) , 4 ) ;
257257 let s = ( sr_tcp ( ) . prop_map ( |v| v. into_sr ( ) ) , Just ( segments) ) ;
258- b. iter_proptest_batched ( s, set_srh_segments , BATCH_SIZE )
258+ b. iter_proptest_batched ( s, set_sr_segments , BATCH_SIZE )
259259 } ) ;
260260
261- group. bench_function ( "packets::set_srh_segments ::size=8" , |b| {
261+ group. bench_function ( "packets::set_sr_segments ::size=8" , |b| {
262262 let segments = rvg. generate_vec ( & any :: < Ipv6Addr > ( ) , 8 ) ;
263263 let s = ( sr_tcp ( ) . prop_map ( |v| v. into_sr ( ) ) , Just ( segments) ) ;
264- b. iter_proptest_batched ( s, set_srh_segments , BATCH_SIZE )
264+ b. iter_proptest_batched ( s, set_sr_segments , BATCH_SIZE )
265265 } ) ;
266266
267267 group. finish ( )
@@ -276,9 +276,9 @@ criterion_group! {
276276 config=bench_config( ) ;
277277 targets=single_peek_vs_parse,
278278 multi_peek_vs_parse,
279- single_parse_srh_segments_sizes ,
280- multi_parse_upto_variable_srh ,
281- set_srh_segments_sizes ,
279+ single_parse_sr_segments_sizes ,
280+ multi_parse_upto_variable_sr ,
281+ set_sr_segments_sizes ,
282282 deparse,
283283 single_push,
284284 multi_push,
0 commit comments