@@ -2952,6 +2952,11 @@ frame_finalize_options(struct context *c, const struct options *o)
29522952 tailroom += COMP_EXTRA_BUFFER (payload_size );
29532953#endif
29542954
2955+ if (frame -> bulk_size > 0 )
2956+ {
2957+ payload_size = BAT_SIZE (TUN_BAT_ONE , frame -> tun_mtu , TUN_BAT_OFF );
2958+ }
2959+
29552960 frame -> buf .payload_size = payload_size ;
29562961 frame -> buf .headroom = headroom ;
29572962 frame -> buf .tailroom = tailroom ;
@@ -3457,6 +3462,10 @@ do_init_frame_tls(struct context *c)
34573462 if (c -> c2 .tls_multi )
34583463 {
34593464 tls_multi_init_finalize (c -> c2 .tls_multi , c -> options .ce .tls_mtu );
3465+ if (c -> c2 .frame .bulk_size > 0 )
3466+ {
3467+ c -> c2 .tls_multi -> opt .frame .buf .payload_size = c -> c2 .frame .tun_mtu ;
3468+ }
34603469 ASSERT (c -> c2 .tls_multi -> opt .frame .buf .payload_size <= c -> c2 .frame .buf .payload_size );
34613470 frame_print (& c -> c2 .tls_multi -> opt .frame , D_MTU_INFO , "Control Channel MTU parms" );
34623471
@@ -3524,6 +3533,14 @@ do_init_frame(struct context *c)
35243533 c -> c2 .frame .extra_tun += c -> options .ce .tun_mtu_extra ;
35253534 }
35263535
3536+ /*
3537+ * Adjust bulk size based on the --bulk-mode parameter.
3538+ */
3539+ if (c -> options .ce .bulk_mode )
3540+ {
3541+ c -> c2 .frame .bulk_size = c -> options .ce .tun_mtu ;
3542+ }
3543+
35273544 /*
35283545 * Fill in the blanks in the frame parameters structure,
35293546 * make sure values are rational, etc.
@@ -3664,9 +3681,45 @@ init_context_buffers(const struct frame *frame)
36643681
36653682 size_t buf_size = BUF_SIZE (frame );
36663683
3684+ if (frame -> bulk_size > 0 )
3685+ {
3686+ size_t off_size = (frame -> buf .headroom + TUN_BAT_OFF + frame -> buf .tailroom );
3687+ buf_size = BAT_SIZE (TUN_BAT_MAX , frame -> tun_mtu , off_size );
3688+ }
3689+
3690+ dmsg (M_INFO , "BULK bufs [%ld] [%d+%d+%d]" , buf_size , frame -> buf .headroom , frame -> buf .payload_size , frame -> buf .tailroom );
3691+
36673692 b -> read_link_buf = alloc_buf (buf_size );
36683693 b -> read_tun_buf = alloc_buf (buf_size );
36693694
3695+ if (frame -> bulk_size > 0 )
3696+ {
3697+ size_t off_size = (frame -> buf .headroom + TUN_BAT_OFF + frame -> buf .tailroom );
3698+ size_t one_size = BAT_SIZE (TUN_BAT_ONE , frame -> tun_mtu , off_size );
3699+
3700+ for (int x = 0 ; x < TUN_BAT_MAX ; ++ x )
3701+ {
3702+ b -> read_tun_bufs [x ] = alloc_buf (one_size );
3703+ b -> read_tun_bufs [x ].offset = TUN_BAT_OFF ;
3704+ b -> read_tun_bufs [x ].len = 0 ;
3705+ }
3706+
3707+ b -> read_tun_max = alloc_buf (buf_size );
3708+ b -> read_tun_max .offset = TUN_BAT_OFF ;
3709+ b -> read_tun_max .len = 0 ;
3710+
3711+ b -> send_tun_max = alloc_buf (buf_size );
3712+ b -> send_tun_max .offset = TUN_BAT_OFF ;
3713+ b -> send_tun_max .len = 0 ;
3714+
3715+ b -> to_tun_max = alloc_buf (buf_size );
3716+ b -> to_tun_max .offset = TUN_BAT_OFF ;
3717+ b -> to_tun_max .len = 0 ;
3718+ }
3719+
3720+ b -> bulk_indx = -1 ;
3721+ b -> bulk_leng = -1 ;
3722+
36703723 b -> aux_buf = alloc_buf (buf_size );
36713724
36723725 b -> encrypt_buf = alloc_buf (buf_size );
@@ -3689,6 +3742,17 @@ free_context_buffers(struct context_buffers *b)
36893742 free_buf (& b -> read_tun_buf );
36903743 free_buf (& b -> aux_buf );
36913744
3745+ if (b -> to_tun_max .data )
3746+ {
3747+ free_buf (& b -> to_tun_max );
3748+ free_buf (& b -> send_tun_max );
3749+ free_buf (& b -> read_tun_max );
3750+ for (int x = 0 ; x < TUN_BAT_MAX ; ++ x )
3751+ {
3752+ free_buf (& b -> read_tun_bufs [x ]);
3753+ }
3754+ }
3755+
36923756#ifdef USE_COMP
36933757 free_buf (& b -> compress_buf );
36943758 free_buf (& b -> decompress_buf );
0 commit comments