Ticket #716: 0002-XXX-fix-fragment-seems-not-needed.patch

File 0002-XXX-fix-fragment-seems-not-needed.patch, 3.9 KB (added by Steffan Karger, 5 years ago)
  • src/openvpn/fragment.c

    From 2296f56d77c977b5d56300b9485f320f18e9b0f6 Mon Sep 17 00:00:00 2001
    From: Steffan Karger <steffan@karger.me>
    Date: Mon, 15 Aug 2016 22:58:43 +0200
    Subject: [PATCH 2/2] XXX fix fragment?  (seems not needed)
    
    ---
     src/openvpn/fragment.c |  8 +++++---
     src/openvpn/fragment.h |  9 ++++++---
     src/openvpn/init.c     | 23 ++++++-----------------
     3 files changed, 17 insertions(+), 23 deletions(-)
    
    diff --git a/src/openvpn/fragment.c b/src/openvpn/fragment.c
    index 7ad1d61..93d658d 100644
    a b fragment_init (struct frame *frame) 
    109109}
    110110
    111111void
    112 fragment_free (struct fragment_master *f)
     112fragment_cleanup (struct fragment_master *f)
    113113{
    114114  fragment_list_buf_free (&f->incoming);
    115115  free_buf (&f->outgoing);
    116116  free_buf (&f->outgoing_return);
    117   free (f);
    118117}
    119118
    120119void
    121 fragment_frame_init (struct fragment_master *f, const struct frame *frame)
     120fragment_frame_init (struct fragment_master *f, struct frame *frame, int mtu)
    122121{
     122  frame_set_mtu_dynamic (frame, mtu, SET_MTU_UPPER_BOUND);
     123
     124  fragment_cleanup (f);
    123125  fragment_list_buf_init (&f->incoming, frame);
    124126  f->outgoing = alloc_buf (BUF_SIZE (frame));
    125127  f->outgoing_return = alloc_buf (BUF_SIZE (frame));
  • src/openvpn/fragment.h

    diff --git a/src/openvpn/fragment.h b/src/openvpn/fragment.h
    index 866573b..9e627bf 100644
    a b struct fragment_master *fragment_init (struct frame *frame); 
    275275
    276276
    277277/**
    278  * Allocate internal packet buffers for a \c fragment_master structure.
     278 * Update frame parameters and allocate internal packet buffers for a
     279 * \c fragment_master structure.
    279280 *
    280281 * @param f            - The \c fragment_master structure for which to
    281282 *                       allocate the internal buffers.
    282283 * @param frame        - The packet geometry parameters for this VPN
    283284 *                       tunnel, used to determine how much memory to
    284285 *                       allocate for each packet buffer.
     286 * @param mtu          - The MTU value for fragments.
    285287 */
    286 void fragment_frame_init (struct fragment_master *f, const struct frame *frame);
     288void fragment_frame_init (struct fragment_master *f, struct frame *frame,
     289    int mtu);
    287290
    288291
    289292/**
    void fragment_frame_init (struct fragment_master *f, const struct frame *frame); 
    291294 *
    292295 * @param f            - The \c fragment_master structure to free.
    293296 */
    294 void fragment_free (struct fragment_master *f);
     297void fragment_cleanup (struct fragment_master *f);
    295298
    296299/** @} name Functions for initialization and cleanup *//*******************/
    297300
  • src/openvpn/init.c

    diff --git a/src/openvpn/init.c b/src/openvpn/init.c
    index 2d262f0..3a98041 100644
    a b do_init_buffers (struct context *c) 
    27862786  c->c2.buffers_owned = true;
    27872787}
    27882788
    2789 #ifdef ENABLE_FRAGMENT
    2790 /*
    2791  * Fragmenting code has buffers to initialize
    2792  * once frame parameters are known.
    2793  */
    2794 static void
    2795 do_init_fragment (struct context *c)
    2796 {
    2797   ASSERT (c->options.ce.fragment);
    2798   frame_set_mtu_dynamic (&c->c2.frame_fragment,
    2799                          c->options.ce.fragment, SET_MTU_UPPER_BOUND);
    2800   fragment_frame_init (c->c2.fragment, &c->c2.frame_fragment);
    2801 }
    2802 #endif
    2803 
    28042789/*
    28052790 * Allocate our socket object.
    28062791 */
    do_close_fragment (struct context *c) 
    30683053{
    30693054  if (c->c2.fragment)
    30703055    {
    3071       fragment_free (c->c2.fragment);
     3056      fragment_cleanup (c->c2.fragment);
     3057      free (c->c2.fragment);
    30723058      c->c2.fragment = NULL;
    30733059    }
    30743060}
    init_instance (struct context *c, const struct env_set *env, const unsigned int 
    36393625#ifdef ENABLE_FRAGMENT
    36403626  /* initialize internal fragmentation capability with known frame size */
    36413627  if (options->ce.fragment && (c->mode == CM_P2P || child))
    3642     do_init_fragment (c);
     3628    {
     3629      fragment_frame_init (c->c2.fragment, &c->c2.frame_fragment,
     3630          options->ce.fragment);
     3631    }
    36433632#endif
    36443633
    36453634  /* initialize dynamic MTU variable */