> On 31 Oct 2018, at 19:42, Prashant Upadhyaya <praupadhy...@gmail.com> wrote:
> 
> Hi,
> 
> I have two buffer chains whose starting vlib_buffer_t's are --
> vlib_buffer_t* chainHead1;  (let's call this chain1)
> vlib_buffer_t* chainHead2; (let's call this chain2)
> The chain1, chain2 may have one or more buffers each.
> 
> Is there any convenience function which connects the last buffer of
> first chain1 to the first buffer of chain2, so that the entire bigger
> chain can be accessed via chainHead1 as the starting point.
> 
> So I need something like this --
> void vlib_buffer_cat(vlib_buffer_t* chain1, vlib_buffer_t* chain2)
> 
> I suppose I will have to chase the last buffer of chain1 and then
> connect it to the first of chain2 and then modify the chain1 first
> buffer contents suitably for the length, flags etc. not to forget the
> possible modifications in the first buffer of chain2.
> 
> If someone has this already, that will save me some rookie mistakes
> and hours of debugging when it goofs up my packet processing at my
> business logic level :)
> 

Should be something like:

void
vlib_buffer_join (vlib_main_t * vm, vlib_buffer_t * c1, vlib_buffer_t *c2)
{
  vlib_buffer_t *c1t = c1;

  /* find c1 tail */
  while (c1t->flags & VLIB_BUFFER_NEXT_PRESENT)
    c1t = vlib_get_buffer (vm, c1t->next_buffer);

  c1t->flags &= VLIB_BUFFER_NEXT_PRESENT;
  c1t->next_buffer = vlib_get_buffer_index (vm, c2);

  if (PREDICT_TRUE (c2->flags & VLIB_BUFFER_TOTAL_LENGTH_VALID))
    c1->total_length_not_including_first_buffer +=
      c2->total_length_not_including_first_buffer + c2->current_length;
  else
    vlib_buffer_length_in_chain_slow_path (vm, c1);
}

Not tested, hope will not cause hours of debugging...


-- 
Damjan


-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#11058): https://lists.fd.io/g/vpp-dev/message/11058
Mute This Topic: https://lists.fd.io/mt/27808613/21656
Group Owner: vpp-dev+ow...@lists.fd.io
Unsubscribe: https://lists.fd.io/g/vpp-dev/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to