@@ -2971,6 +2971,10 @@ frame_finalize_options(struct context *c, const struct options *o)
2971
2971
tailroom += COMP_EXTRA_BUFFER (payload_size );
2972
2972
#endif
2973
2973
2974
+ if (frame -> bulk_size > 0 ) {
2975
+ payload_size = frame -> tun_mtu ;
2976
+ }
2977
+
2974
2978
frame -> buf .payload_size = payload_size ;
2975
2979
frame -> buf .headroom = headroom ;
2976
2980
frame -> buf .tailroom = tailroom ;
@@ -3473,6 +3477,9 @@ do_init_frame_tls(struct context *c)
3473
3477
if (c -> c2 .tls_multi )
3474
3478
{
3475
3479
tls_multi_init_finalize (c -> c2 .tls_multi , c -> options .ce .tls_mtu );
3480
+ if (c -> c2 .frame .bulk_size > 0 ) {
3481
+ c -> c2 .tls_multi -> opt .frame .buf .payload_size = c -> c2 .frame .tun_mtu ;
3482
+ }
3476
3483
ASSERT (c -> c2 .tls_multi -> opt .frame .buf .payload_size <= c -> c2 .frame .buf .payload_size );
3477
3484
frame_print (& c -> c2 .tls_multi -> opt .frame , D_MTU_INFO , "Control Channel MTU parms" );
3478
3485
@@ -3536,6 +3543,14 @@ do_init_frame(struct context *c)
3536
3543
c -> c2 .frame .extra_tun += c -> options .ce .tun_mtu_extra ;
3537
3544
}
3538
3545
3546
+ /*
3547
+ * Adjust bulk size based on the --bulk-mode parameter.
3548
+ */
3549
+ if (c -> options .ce .bulk_mode )
3550
+ {
3551
+ c -> c2 .frame .bulk_size = c -> options .ce .tun_mtu ;
3552
+ }
3553
+
3539
3554
/*
3540
3555
* Fill in the blanks in the frame parameters structure,
3541
3556
* make sure values are rational, etc.
@@ -3676,9 +3691,41 @@ init_context_buffers(const struct frame *frame)
3676
3691
3677
3692
size_t buf_size = BUF_SIZE (frame );
3678
3693
3694
+ if (frame -> bulk_size > 0 ) {
3695
+ size_t off_size = (frame -> buf .headroom + TUN_BAT_OFF + frame -> buf .tailroom );
3696
+ buf_size = BAT_SIZE (TUN_BAT_MAX , frame -> tun_mtu , off_size );
3697
+ }
3698
+
3699
+ dmsg (M_INFO , "MEM NEW [%ld] [%d+%d+%d]" , buf_size , frame -> buf .headroom , frame -> buf .payload_size , frame -> buf .tailroom );
3700
+
3679
3701
b -> read_link_buf = alloc_buf (buf_size );
3680
3702
b -> read_tun_buf = alloc_buf (buf_size );
3681
3703
3704
+ if (frame -> bulk_size > 0 ) {
3705
+ for (int x = 0 ; x < TUN_BAT_MAX ; ++ x )
3706
+ {
3707
+ size_t part_size = BUF_SIZE (frame );
3708
+ b -> read_tun_bufs [x ] = alloc_buf (part_size );
3709
+ b -> read_tun_bufs [x ].offset = TUN_BAT_OFF ;
3710
+ b -> read_tun_bufs [x ].len = 0 ;
3711
+ }
3712
+
3713
+ b -> read_tun_max = alloc_buf (buf_size );
3714
+ b -> read_tun_max .offset = TUN_BAT_OFF ;
3715
+ b -> read_tun_max .len = 0 ;
3716
+
3717
+ b -> send_tun_max = alloc_buf (buf_size );
3718
+ b -> send_tun_max .offset = TUN_BAT_OFF ;
3719
+ b -> send_tun_max .len = 0 ;
3720
+
3721
+ b -> to_tun_max = alloc_buf (buf_size );
3722
+ b -> to_tun_max .offset = TUN_BAT_OFF ;
3723
+ b -> to_tun_max .len = 0 ;
3724
+ }
3725
+
3726
+ b -> bulk_indx = -1 ;
3727
+ b -> bulk_flag = -1 ;
3728
+
3682
3729
b -> aux_buf = alloc_buf (buf_size );
3683
3730
3684
3731
b -> encrypt_buf = alloc_buf (buf_size );
@@ -3701,6 +3748,16 @@ free_context_buffers(struct context_buffers *b)
3701
3748
free_buf (& b -> read_tun_buf );
3702
3749
free_buf (& b -> aux_buf );
3703
3750
3751
+ if (b -> to_tun_max .data ) {
3752
+ free_buf (& b -> to_tun_max );
3753
+ free_buf (& b -> send_tun_max );
3754
+ free_buf (& b -> read_tun_max );
3755
+ for (int x = 0 ; x < TUN_BAT_MAX ; ++ x )
3756
+ {
3757
+ free_buf (& b -> read_tun_bufs [x ]);
3758
+ }
3759
+ }
3760
+
3704
3761
#ifdef USE_COMP
3705
3762
free_buf (& b -> compress_buf );
3706
3763
free_buf (& b -> decompress_buf );
0 commit comments