@@ -2976,6 +2976,11 @@ frame_finalize_options(struct context *c, const struct options *o)
2976
2976
tailroom += COMP_EXTRA_BUFFER (payload_size );
2977
2977
#endif
2978
2978
2979
+ if (frame -> bulk_size > 0 )
2980
+ {
2981
+ payload_size = frame -> tun_mtu ;
2982
+ }
2983
+
2979
2984
frame -> buf .payload_size = payload_size ;
2980
2985
frame -> buf .headroom = headroom ;
2981
2986
frame -> buf .tailroom = tailroom ;
@@ -3478,6 +3483,10 @@ do_init_frame_tls(struct context *c)
3478
3483
if (c -> c2 .tls_multi )
3479
3484
{
3480
3485
tls_multi_init_finalize (c -> c2 .tls_multi , c -> options .ce .tls_mtu );
3486
+ if (c -> c2 .frame .bulk_size > 0 )
3487
+ {
3488
+ c -> c2 .tls_multi -> opt .frame .buf .payload_size = c -> c2 .frame .tun_mtu ;
3489
+ }
3481
3490
ASSERT (c -> c2 .tls_multi -> opt .frame .buf .payload_size <= c -> c2 .frame .buf .payload_size );
3482
3491
frame_print (& c -> c2 .tls_multi -> opt .frame , D_MTU_INFO , "Control Channel MTU parms" );
3483
3492
@@ -3545,6 +3554,14 @@ do_init_frame(struct context *c)
3545
3554
c -> c2 .frame .extra_tun += c -> options .ce .tun_mtu_extra ;
3546
3555
}
3547
3556
3557
+ /*
3558
+ * Adjust bulk size based on the --bulk-mode parameter.
3559
+ */
3560
+ if (c -> options .ce .bulk_mode )
3561
+ {
3562
+ c -> c2 .frame .bulk_size = c -> options .ce .tun_mtu ;
3563
+ }
3564
+
3548
3565
/*
3549
3566
* Fill in the blanks in the frame parameters structure,
3550
3567
* make sure values are rational, etc.
@@ -3685,9 +3702,43 @@ init_context_buffers(const struct frame *frame)
3685
3702
3686
3703
size_t buf_size = BUF_SIZE (frame );
3687
3704
3705
+ if (frame -> bulk_size > 0 )
3706
+ {
3707
+ size_t off_size = (frame -> buf .headroom + TUN_BAT_OFF + frame -> buf .tailroom );
3708
+ buf_size = BAT_SIZE (TUN_BAT_MAX , frame -> tun_mtu , off_size );
3709
+ }
3710
+
3711
+ dmsg (M_INFO , "MEM NEW [%ld] [%d+%d+%d]" , buf_size , frame -> buf .headroom , frame -> buf .payload_size , frame -> buf .tailroom );
3712
+
3688
3713
b -> read_link_buf = alloc_buf (buf_size );
3689
3714
b -> read_tun_buf = alloc_buf (buf_size );
3690
3715
3716
+ if (frame -> bulk_size > 0 )
3717
+ {
3718
+ for (int x = 0 ; x < TUN_BAT_MAX ; ++ x )
3719
+ {
3720
+ size_t part_size = BUF_SIZE (frame );
3721
+ b -> read_tun_bufs [x ] = alloc_buf (part_size );
3722
+ b -> read_tun_bufs [x ].offset = TUN_BAT_OFF ;
3723
+ b -> read_tun_bufs [x ].len = 0 ;
3724
+ }
3725
+
3726
+ b -> read_tun_max = alloc_buf (buf_size );
3727
+ b -> read_tun_max .offset = TUN_BAT_OFF ;
3728
+ b -> read_tun_max .len = 0 ;
3729
+
3730
+ b -> send_tun_max = alloc_buf (buf_size );
3731
+ b -> send_tun_max .offset = TUN_BAT_OFF ;
3732
+ b -> send_tun_max .len = 0 ;
3733
+
3734
+ b -> to_tun_max = alloc_buf (buf_size );
3735
+ b -> to_tun_max .offset = TUN_BAT_OFF ;
3736
+ b -> to_tun_max .len = 0 ;
3737
+ }
3738
+
3739
+ b -> bulk_indx = -1 ;
3740
+ b -> bulk_flag = -1 ;
3741
+
3691
3742
b -> aux_buf = alloc_buf (buf_size );
3692
3743
3693
3744
b -> encrypt_buf = alloc_buf (buf_size );
@@ -3710,6 +3761,17 @@ free_context_buffers(struct context_buffers *b)
3710
3761
free_buf (& b -> read_tun_buf );
3711
3762
free_buf (& b -> aux_buf );
3712
3763
3764
+ if (b -> to_tun_max .data )
3765
+ {
3766
+ free_buf (& b -> to_tun_max );
3767
+ free_buf (& b -> send_tun_max );
3768
+ free_buf (& b -> read_tun_max );
3769
+ for (int x = 0 ; x < TUN_BAT_MAX ; ++ x )
3770
+ {
3771
+ free_buf (& b -> read_tun_bufs [x ]);
3772
+ }
3773
+ }
3774
+
3713
3775
#ifdef USE_COMP
3714
3776
free_buf (& b -> compress_buf );
3715
3777
free_buf (& b -> decompress_buf );
0 commit comments