FD.io VPP  v18.04-17-g3a0d853
Vector Packet Processing
ip_frag.c
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------
2  * Copyright (c) 2009-2014 Cisco and/or its affiliates.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  *---------------------------------------------------------------------------
15  */
16 /*
17  * IPv4 Fragmentation Node
18  *
19  *
20  */
21 
22 #include "ip_frag.h"
23 
24 #include <vnet/ip/ip.h>
25 
26 
27 typedef struct
28 {
35 
36 static u8 *
37 format_ip_frag_trace (u8 * s, va_list * args)
38 {
39  CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
40  CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
41  ip_frag_trace_t *t = va_arg (*args, ip_frag_trace_t *);
42  s = format (s, "IPv%s offset: %u mtu: %u fragments: %u",
43  t->ipv6 ? "6" : "4", t->header_offset, t->mtu, t->n_fragments);
44  return s;
45 }
46 
48 
49 static void
51  ip_frag_error_t * error)
52 {
53  vlib_buffer_t *p;
54  ip4_header_t *ip4;
55  u16 mtu, ptr, len, max, rem, offset, ip_frag_id, ip_frag_offset;
56  u8 *packet, more;
57 
58  vec_add1 (*buffer, pi);
59  p = vlib_get_buffer (vm, pi);
60  offset = vnet_buffer (p)->ip_frag.header_offset;
61  mtu = vnet_buffer (p)->ip_frag.mtu;
62  packet = (u8 *) vlib_buffer_get_current (p);
63  ip4 = (ip4_header_t *) (packet + offset);
64 
65  rem = clib_net_to_host_u16 (ip4->length) - sizeof (*ip4);
66  ptr = 0;
67  max = (mtu - sizeof (*ip4) - vnet_buffer (p)->ip_frag.header_offset) & ~0x7;
68 
69  if (rem < (p->current_length - offset - sizeof (*ip4)))
70  {
71  *error = IP_FRAG_ERROR_MALFORMED;
72  return;
73  }
74 
75  if (mtu < sizeof (*ip4))
76  {
77  *error = IP_FRAG_ERROR_CANT_FRAGMENT_HEADER;
78  return;
79  }
80 
81  if (ip4->flags_and_fragment_offset &
82  clib_host_to_net_u16 (IP4_HEADER_FLAG_DONT_FRAGMENT))
83  {
84  *error = IP_FRAG_ERROR_DONT_FRAGMENT_SET;
85  return;
86  }
87 
88  if (ip4_is_fragment (ip4))
89  {
90  ip_frag_id = ip4->fragment_id;
91  ip_frag_offset = ip4_get_fragment_offset (ip4);
92  more =
93  !(!(ip4->flags_and_fragment_offset &
94  clib_host_to_net_u16 (IP4_HEADER_FLAG_MORE_FRAGMENTS)));
95  }
96  else
97  {
98  ip_frag_id = (++running_fragment_id);
99  ip_frag_offset = 0;
100  more = 0;
101  }
102 
103  //Do the actual fragmentation
104  while (rem)
105  {
106  u32 bi;
107  vlib_buffer_t *b;
108  ip4_header_t *fip4;
109 
110  len =
111  (rem >
112  (mtu - sizeof (*ip4) -
113  vnet_buffer (p)->ip_frag.header_offset)) ? max : rem;
114 
115  if (ptr == 0)
116  {
117  bi = pi;
118  b = p;
119  fip4 = (ip4_header_t *) (vlib_buffer_get_current (b) + offset);
120  }
121  else
122  {
123  if (!vlib_buffer_alloc (vm, &bi, 1))
124  {
125  *error = IP_FRAG_ERROR_MEMORY;
126  return;
127  }
128  vec_add1 (*buffer, bi);
129  b = vlib_get_buffer (vm, bi);
130  vnet_buffer (b)->sw_if_index[VLIB_RX] =
131  vnet_buffer (p)->sw_if_index[VLIB_RX];
132  vnet_buffer (b)->sw_if_index[VLIB_TX] =
133  vnet_buffer (p)->sw_if_index[VLIB_TX];
134  /* Copy Adj_index in case DPO based node is sending for the fragmentation,
135  the packet would be sent back to the proper DPO next node and Index */
136  vnet_buffer (b)->ip.adj_index[VLIB_RX] =
137  vnet_buffer (p)->ip.adj_index[VLIB_RX];
138  vnet_buffer (b)->ip.adj_index[VLIB_TX] =
139  vnet_buffer (p)->ip.adj_index[VLIB_TX];
140  fip4 = (ip4_header_t *) (vlib_buffer_get_current (b) + offset);
141 
142  //Copy offset and ip4 header
143  clib_memcpy (b->data, packet, offset + sizeof (*ip4));
144  //Copy data
145  clib_memcpy (((u8 *) (fip4)) + sizeof (*fip4),
146  packet + offset + sizeof (*fip4) + ptr, len);
147  }
148  b->current_length = offset + len + sizeof (*fip4);
149 
150  fip4->fragment_id = ip_frag_id;
152  clib_host_to_net_u16 ((ptr >> 3) + ip_frag_offset);
154  clib_host_to_net_u16 (((len != rem) || more) << 13);
155  // ((len0 != rem0) || more0) << 13 is optimization for
156  // ((len0 != rem0) || more0) ? IP4_HEADER_FLAG_MORE_FRAGMENTS : 0
157  fip4->length = clib_host_to_net_u16 (len + sizeof (*fip4));
158  fip4->checksum = ip4_header_checksum (fip4);
159 
160  if (vnet_buffer (p)->ip_frag.flags & IP_FRAG_FLAG_IP4_HEADER)
161  {
162  //Encapsulating ipv4 header
163  ip4_header_t *encap_header4 =
165  encap_header4->length = clib_host_to_net_u16 (b->current_length);
166  encap_header4->checksum = ip4_header_checksum (encap_header4);
167  }
168  else if (vnet_buffer (p)->ip_frag.flags & IP_FRAG_FLAG_IP6_HEADER)
169  {
170  //Encapsulating ipv6 header
171  ip6_header_t *encap_header6 =
173  encap_header6->payload_length =
174  clib_host_to_net_u16 (b->current_length -
175  sizeof (*encap_header6));
176  }
177 
178  rem -= len;
179  ptr += len;
180  }
181 }
182 
183 void
185  u8 next_index, u8 flags)
186 {
187  vnet_buffer (b)->ip_frag.header_offset = offset;
188  vnet_buffer (b)->ip_frag.mtu = mtu;
189  vnet_buffer (b)->ip_frag.next_index = next_index;
190  vnet_buffer (b)->ip_frag.flags = flags;
191 }
192 
193 static uword
195 {
196  u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
197  vlib_node_runtime_t *error_node =
199  from = vlib_frame_vector_args (frame);
200  n_left_from = frame->n_vectors;
201  next_index = node->cached_next_index;
202  u32 frag_sent = 0, small_packets = 0;
203  u32 *buffer = 0;
204 
205  while (n_left_from > 0)
206  {
207  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
208 
209  while (n_left_from > 0 && n_left_to_next > 0)
210  {
211  u32 pi0, *frag_from, frag_left;
212  vlib_buffer_t *p0;
213  ip_frag_error_t error0;
214  ip4_frag_next_t next0;
215 
216  //Note: The packet is not enqueued now.
217  //It is instead put in a vector where other fragments
218  //will be put as well.
219  pi0 = from[0];
220  from += 1;
221  n_left_from -= 1;
222  error0 = IP_FRAG_ERROR_NONE;
223 
224  p0 = vlib_get_buffer (vm, pi0);
225  ip4_frag_do_fragment (vm, pi0, &buffer, &error0);
226 
227  if (PREDICT_FALSE (p0->flags & VLIB_BUFFER_IS_TRACED))
228  {
229  ip_frag_trace_t *tr =
230  vlib_add_trace (vm, node, p0, sizeof (*tr));
231  tr->header_offset = vnet_buffer (p0)->ip_frag.header_offset;
232  tr->mtu = vnet_buffer (p0)->ip_frag.mtu;
233  tr->ipv6 = 0;
234  tr->n_fragments = vec_len (buffer);
235  tr->next = vnet_buffer (p0)->ip_frag.next_index;
236  }
237 
238  if (error0 == IP_FRAG_ERROR_DONT_FRAGMENT_SET)
239  {
240  icmp4_error_set_vnet_buffer (p0, ICMP4_destination_unreachable,
241  ICMP4_destination_unreachable_fragmentation_needed_and_dont_fragment_set,
242  vnet_buffer (p0)->ip_frag.mtu);
244  vnet_buffer (p0)->ip_frag.header_offset);
245  next0 = IP4_FRAG_NEXT_ICMP_ERROR;
246  }
247  else
248  {
249  /* *INDENT-OFF* */
250  next0 = (error0 == IP_FRAG_ERROR_NONE) ? vnet_buffer (p0)->
251  ip_frag.next_index : IP4_FRAG_NEXT_DROP;
252  /* *INDENT-ON* */
253  }
254 
255  if (error0 == IP_FRAG_ERROR_NONE)
256  {
257  frag_sent += vec_len (buffer);
258  small_packets += (vec_len (buffer) == 1);
259  }
260  else
261  vlib_error_count (vm, ip4_frag_node.index, error0, 1);
262 
263  //Send fragments that were added in the frame
264  frag_from = buffer;
265  frag_left = vec_len (buffer);
266 
267  while (frag_left > 0)
268  {
269  while (frag_left > 0 && n_left_to_next > 0)
270  {
271  u32 i;
272  i = to_next[0] = frag_from[0];
273  frag_from += 1;
274  frag_left -= 1;
275  to_next += 1;
276  n_left_to_next -= 1;
277 
278  vlib_get_buffer (vm, i)->error = error_node->errors[error0];
279  vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
280  to_next, n_left_to_next, i,
281  next0);
282  }
283  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
284  vlib_get_next_frame (vm, node, next_index, to_next,
285  n_left_to_next);
286  }
287  vec_reset_length (buffer);
288  }
289  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
290  }
291  vec_free (buffer);
292 
294  IP_FRAG_ERROR_FRAGMENT_SENT, frag_sent);
296  IP_FRAG_ERROR_SMALL_PACKET, small_packets);
297 
298  return frame->n_vectors;
299 }
300 
301 
302 static void
304  ip_frag_error_t * error)
305 {
306  vlib_buffer_t *p;
307  ip6_header_t *ip6_hdr;
308  ip6_frag_hdr_t *frag_hdr;
309  u8 *payload, *next_header;
310 
311  p = vlib_get_buffer (vm, pi);
312 
313  //Parsing the IPv6 headers
314  ip6_hdr =
315  vlib_buffer_get_current (p) + vnet_buffer (p)->ip_frag.header_offset;
316  payload = (u8 *) (ip6_hdr + 1);
317  next_header = &ip6_hdr->protocol;
318  if (*next_header == IP_PROTOCOL_IP6_HOP_BY_HOP_OPTIONS)
319  {
320  next_header = payload;
321  payload += payload[1] * 8;
322  }
323 
324  if (*next_header == IP_PROTOCOL_IP6_DESTINATION_OPTIONS)
325  {
326  next_header = payload;
327  payload += payload[1] * 8;
328  }
329 
330  if (*next_header == IP_PROTOCOL_IPV6_ROUTE)
331  {
332  next_header = payload;
333  payload += payload[1] * 8;
334  }
335 
336  if (PREDICT_FALSE
337  (payload >= (u8 *) vlib_buffer_get_current (p) + p->current_length))
338  {
339  //A malicious packet could set an extension header with a too big size
340  //and make us modify another vlib_buffer
341  *error = IP_FRAG_ERROR_MALFORMED;
342  return;
343  }
344 
345  u8 has_more;
346  u16 initial_offset;
347  if (*next_header == IP_PROTOCOL_IPV6_FRAGMENTATION)
348  {
349  //The fragmentation header is already there
350  frag_hdr = (ip6_frag_hdr_t *) payload;
351  has_more = ip6_frag_hdr_more (frag_hdr);
352  initial_offset = ip6_frag_hdr_offset (frag_hdr);
353  }
354  else
355  {
356  //Insert a fragmentation header in the packet
357  u8 nh = *next_header;
358  *next_header = IP_PROTOCOL_IPV6_FRAGMENTATION;
359  vlib_buffer_advance (p, -sizeof (*frag_hdr));
360  u8 *start = vlib_buffer_get_current (p);
361  memmove (start, start + sizeof (*frag_hdr),
362  payload - (start + sizeof (*frag_hdr)));
363  frag_hdr = (ip6_frag_hdr_t *) (payload - sizeof (*frag_hdr));
364  frag_hdr->identification = ++running_fragment_id;
365  frag_hdr->next_hdr = nh;
366  frag_hdr->rsv = 0;
367  has_more = 0;
368  initial_offset = 0;
369  }
370  payload = (u8 *) (frag_hdr + 1);
371 
372  u16 headers_len = payload - (u8 *) vlib_buffer_get_current (p);
373  u16 max_payload = vnet_buffer (p)->ip_frag.mtu - headers_len;
374  u16 rem = p->current_length - headers_len;
375  u16 ptr = 0;
376 
377  if (max_payload < 8)
378  {
379  *error = IP_FRAG_ERROR_CANT_FRAGMENT_HEADER;
380  return;
381  }
382 
383  while (rem)
384  {
385  u32 bi;
386  vlib_buffer_t *b;
387  u16 len = (rem > max_payload) ? (max_payload & ~0x7) : rem;
388  rem -= len;
389 
390  if (ptr != 0)
391  {
392  if (!vlib_buffer_alloc (vm, &bi, 1))
393  {
394  *error = IP_FRAG_ERROR_MEMORY;
395  return;
396  }
397  b = vlib_get_buffer (vm, bi);
398  vnet_buffer (b)->sw_if_index[VLIB_RX] =
399  vnet_buffer (p)->sw_if_index[VLIB_RX];
400  vnet_buffer (b)->sw_if_index[VLIB_TX] =
401  vnet_buffer (p)->sw_if_index[VLIB_TX];
402 
403  /* Copy Adj_index in case DPO based node is sending for the fragmentation,
404  the packet would be sent back to the proper DPO next node and Index */
405  vnet_buffer (b)->ip.adj_index[VLIB_RX] =
406  vnet_buffer (p)->ip.adj_index[VLIB_RX];
407  vnet_buffer (b)->ip.adj_index[VLIB_TX] =
408  vnet_buffer (p)->ip.adj_index[VLIB_TX];
409 
411  vlib_buffer_get_current (p), headers_len);
412  clib_memcpy (vlib_buffer_get_current (b) + headers_len,
413  payload + ptr, len);
414  frag_hdr =
415  vlib_buffer_get_current (b) + headers_len - sizeof (*frag_hdr);
416  }
417  else
418  {
419  bi = pi;
420  b = vlib_get_buffer (vm, bi);
421  //frag_hdr already set here
422  }
423 
424  ip6_hdr =
425  vlib_buffer_get_current (b) + vnet_buffer (p)->ip_frag.header_offset;
426  frag_hdr->fragment_offset_and_more =
427  ip6_frag_hdr_offset_and_more (initial_offset + (ptr >> 3),
428  (rem || has_more));
429  b->current_length = headers_len + len;
430  ip6_hdr->payload_length =
431  clib_host_to_net_u16 (b->current_length -
432  vnet_buffer (p)->ip_frag.header_offset -
433  sizeof (*ip6_hdr));
434 
435  if (vnet_buffer (p)->ip_frag.flags & IP_FRAG_FLAG_IP4_HEADER)
436  {
437  //Encapsulating ipv4 header
438  ip4_header_t *encap_header4 =
440  encap_header4->length = clib_host_to_net_u16 (b->current_length);
441  encap_header4->checksum = ip4_header_checksum (encap_header4);
442  }
443  else if (vnet_buffer (p)->ip_frag.flags & IP_FRAG_FLAG_IP6_HEADER)
444  {
445  //Encapsulating ipv6 header
446  ip6_header_t *encap_header6 =
448  encap_header6->payload_length =
449  clib_host_to_net_u16 (b->current_length -
450  sizeof (*encap_header6));
451  }
452 
453  vec_add1 (*buffer, bi);
454 
455  ptr += len;
456  }
457 }
458 
459 static uword
461 {
462  u32 n_left_from, *from, next_index, *to_next, n_left_to_next;
463  vlib_node_runtime_t *error_node =
465  from = vlib_frame_vector_args (frame);
466  n_left_from = frame->n_vectors;
467  next_index = node->cached_next_index;
468  u32 frag_sent = 0, small_packets = 0;
469  u32 *buffer = 0;
470 
471  while (n_left_from > 0)
472  {
473  vlib_get_next_frame (vm, node, next_index, to_next, n_left_to_next);
474 
475  while (n_left_from > 0 && n_left_to_next > 0)
476  {
477  u32 pi0, *frag_from, frag_left;
478  vlib_buffer_t *p0;
479  ip_frag_error_t error0;
480  ip6_frag_next_t next0;
481 
482  pi0 = from[0];
483  from += 1;
484  n_left_from -= 1;
485  error0 = IP_FRAG_ERROR_NONE;
486 
487  p0 = vlib_get_buffer (vm, pi0);
488  ip6_frag_do_fragment (vm, pi0, &buffer, &error0);
489 
490  if (PREDICT_FALSE (p0->flags & VLIB_BUFFER_IS_TRACED))
491  {
492  ip_frag_trace_t *tr =
493  vlib_add_trace (vm, node, p0, sizeof (*tr));
494  tr->header_offset = vnet_buffer (p0)->ip_frag.header_offset;
495  tr->mtu = vnet_buffer (p0)->ip_frag.mtu;
496  tr->ipv6 = 1;
497  tr->n_fragments = vec_len (buffer);
498  tr->next = vnet_buffer (p0)->ip_frag.next_index;
499  }
500 
501  /* *INDENT-OFF* */
502  next0 = (error0 == IP_FRAG_ERROR_NONE) ? vnet_buffer (p0)->
503  ip_frag.next_index : IP6_FRAG_NEXT_DROP;
504  /* *INDENT-ON* */
505 
506  frag_sent += vec_len (buffer);
507  small_packets += (vec_len (buffer) == 1);
508 
509  //Send fragments that were added in the frame
510  frag_from = buffer;
511  frag_left = vec_len (buffer);
512  while (frag_left > 0)
513  {
514  while (frag_left > 0 && n_left_to_next > 0)
515  {
516  u32 i;
517  i = to_next[0] = frag_from[0];
518  frag_from += 1;
519  frag_left -= 1;
520  to_next += 1;
521  n_left_to_next -= 1;
522 
523  vlib_get_buffer (vm, i)->error = error_node->errors[error0];
524  vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
525  to_next, n_left_to_next, i,
526  next0);
527  }
528  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
529  vlib_get_next_frame (vm, node, next_index, to_next,
530  n_left_to_next);
531  }
532  vec_reset_length (buffer);
533  }
534  vlib_put_next_frame (vm, node, next_index, n_left_to_next);
535  }
536  vec_free (buffer);
538  IP_FRAG_ERROR_FRAGMENT_SENT, frag_sent);
540  IP_FRAG_ERROR_SMALL_PACKET, small_packets);
541 
542  return frame->n_vectors;
543 }
544 
545 static char *ip4_frag_error_strings[] = {
546 #define _(sym,string) string,
548 #undef _
549 };
550 
551 /* *INDENT-OFF* */
553  .function = ip4_frag,
554  .name = IP4_FRAG_NODE_NAME,
555  .vector_size = sizeof (u32),
556  .format_trace = format_ip_frag_trace,
557  .type = VLIB_NODE_TYPE_INTERNAL,
558 
559  .n_errors = IP_FRAG_N_ERROR,
560  .error_strings = ip4_frag_error_strings,
561 
562  .n_next_nodes = IP4_FRAG_N_NEXT,
563  .next_nodes = {
564  [IP4_FRAG_NEXT_IP4_LOOKUP] = "ip4-lookup",
565  [IP4_FRAG_NEXT_IP6_LOOKUP] = "ip6-lookup",
566  [IP4_FRAG_NEXT_ICMP_ERROR] = "ip4-icmp-error",
567  [IP4_FRAG_NEXT_DROP] = "ip4-drop"
568  },
569 };
570 /* *INDENT-ON* */
571 
572 /* *INDENT-OFF* */
574  .function = ip6_frag,
575  .name = IP6_FRAG_NODE_NAME,
576  .vector_size = sizeof (u32),
577  .format_trace = format_ip_frag_trace,
578  .type = VLIB_NODE_TYPE_INTERNAL,
579 
580  .n_errors = IP_FRAG_N_ERROR,
581  .error_strings = ip4_frag_error_strings,
582 
583  .n_next_nodes = IP6_FRAG_N_NEXT,
584  .next_nodes = {
585  [IP6_FRAG_NEXT_IP4_LOOKUP] = "ip4-lookup",
586  [IP6_FRAG_NEXT_IP6_LOOKUP] = "ip6-lookup",
587  [IP6_FRAG_NEXT_DROP] = "ip6-drop"
588  },
589 };
590 /* *INDENT-ON* */
591 
592 /*
593  * fd.io coding-style-patch-verification: ON
594  *
595  * Local Variables:
596  * eval: (c-set-style "gnu")
597  * End:
598  */
#define CLIB_UNUSED(x)
Definition: clib.h:79
#define foreach_ip_frag_error
Definition: ip_frag.h:66
void ip_frag_set_vnet_buffer(vlib_buffer_t *b, u16 offset, u16 mtu, u8 next_index, u8 flags)
Definition: ip_frag.c:184
#define IP6_FRAG_NODE_NAME
Definition: ip_frag.h:44
static void vlib_error_count(vlib_main_t *vm, uword node_index, uword counter, uword increment)
Definition: error_funcs.h:57
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:520
int i
u8 * format(u8 *s, const char *fmt,...)
Definition: format.c:419
u16 flags_and_fragment_offset
Definition: ip4_packet.h:145
u16 n_fragments
Definition: ip_frag.c:33
vlib_error_t * errors
Vector of errors for this node.
Definition: node.h:415
static u8 * format_ip_frag_trace(u8 *s, va_list *args)
Definition: ip_frag.c:37
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
static u32 running_fragment_id
Definition: ip_frag.c:47
static void ip6_frag_do_fragment(vlib_main_t *vm, u32 pi, u32 **buffer, ip_frag_error_t *error)
Definition: ip_frag.c:303
static int ip4_get_fragment_offset(ip4_header_t *i)
Definition: ip4_packet.h:192
static uword ip4_frag(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: ip_frag.c:194
static int ip4_is_fragment(ip4_header_t *i)
Definition: ip4_packet.h:205
#define ip6_frag_hdr_more(hdr)
Definition: ip6_packet.h:543
u16 current_length
Nbytes between current data and the end of this buffer.
Definition: buffer.h:108
#define IP4_FRAG_NODE_NAME
Definition: ip_frag.h:43
static void * vlib_buffer_get_current(vlib_buffer_t *b)
Get pointer to current data to process.
Definition: buffer.h:209
#define PREDICT_FALSE(x)
Definition: clib.h:105
#define vlib_validate_buffer_enqueue_x1(vm, node, next_index, to_next, n_left_to_next, bi0, next0)
Finish enqueueing one buffer forward in the graph.
Definition: buffer_node.h:218
#define vlib_get_next_frame(vm, node, next_index, vectors, n_vectors_left)
Get pointer to next frame vector data by (vlib_node_runtime_t, next_index).
Definition: node_funcs.h:364
vlib_node_registration_t ip6_frag_node
(constructor) VLIB_REGISTER_NODE (ip6_frag_node)
Definition: ip_frag.c:573
vlib_error_t error
Error code for buffers to be enqueued to error handler.
Definition: buffer.h:130
static void vlib_node_increment_counter(vlib_main_t *vm, u32 node_index, u32 counter_index, u64 increment)
Definition: node_funcs.h:1166
#define IP4_HEADER_FLAG_MORE_FRAGMENTS
Definition: ip4_packet.h:146
#define VLIB_REGISTER_NODE(x,...)
Definition: node.h:143
u16 n_vectors
Definition: node.h:344
vlib_main_t * vm
Definition: buffer.c:294
ip_frag_error_t
Definition: ip_frag.h:77
#define vec_free(V)
Free vector&#39;s memory (no header).
Definition: vec.h:336
void icmp4_error_set_vnet_buffer(vlib_buffer_t *b, u8 type, u8 code, u32 data)
Definition: icmp4.c:431
static vlib_node_runtime_t * vlib_node_get_runtime(vlib_main_t *vm, u32 node_index)
Get node runtime by node index.
Definition: node_funcs.h:89
#define clib_memcpy(a, b, c)
Definition: string.h:75
void vlib_put_next_frame(vlib_main_t *vm, vlib_node_runtime_t *r, u32 next_index, u32 n_vectors_left)
Release pointer to next frame vector data.
Definition: main.c:454
#define ip6_frag_hdr_offset(hdr)
Definition: ip6_packet.h:537
#define IP_FRAG_FLAG_IP6_HEADER
Definition: ip_frag.h:41
u16 cached_next_index
Next frame index that vector arguments were last enqueued to last time this node ran.
Definition: node.h:456
unsigned int u32
Definition: types.h:88
#define IP_FRAG_FLAG_IP4_HEADER
Definition: ip_frag.h:40
u16 header_offset
Definition: ip_frag.c:30
static void vlib_buffer_advance(vlib_buffer_t *b, word l)
Advance current data pointer by the supplied (signed!) amount.
Definition: buffer.h:222
u64 uword
Definition: types.h:112
static void * vlib_add_trace(vlib_main_t *vm, vlib_node_runtime_t *r, vlib_buffer_t *b, u32 n_data_bytes)
Definition: trace_funcs.h:55
template key/value backing page structure
Definition: bihash_doc.h:44
Definition: defs.h:47
unsigned short u16
Definition: types.h:57
u16 payload_length
Definition: ip6_packet.h:333
vlib_node_registration_t ip4_frag_node
(constructor) VLIB_REGISTER_NODE (ip4_frag_node)
Definition: ip_frag.c:552
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
unsigned char u8
Definition: types.h:56
static char * ip4_frag_error_strings[]
Definition: ip_frag.c:545
static void * vlib_frame_vector_args(vlib_frame_t *f)
Get pointer to frame vector data.
Definition: node_funcs.h:267
struct clib_bihash_value offset
template key/value backing page structure
#define vnet_buffer(b)
Definition: buffer.h:372
static void ip4_frag_do_fragment(vlib_main_t *vm, u32 pi, u32 **buffer, ip_frag_error_t *error)
Definition: ip_frag.c:50
u8 data[0]
Packet data.
Definition: buffer.h:179
static uword ip6_frag(vlib_main_t *vm, vlib_node_runtime_t *node, vlib_frame_t *frame)
Definition: ip_frag.c:460
ip6_frag_next_t
Definition: ip_frag.h:58
#define IP4_HEADER_FLAG_DONT_FRAGMENT
Definition: ip4_packet.h:147
#define ip6_frag_hdr_offset_and_more(offset, more)
Definition: ip6_packet.h:546
u32 flags
Definition: vhost-user.h:77
u32 flags
buffer flags: VLIB_BUFFER_FREE_LIST_INDEX_MASK: bits used to store free list index, VLIB_BUFFER_IS_TRACED: trace this buffer.
Definition: buffer.h:111
static u32 vlib_buffer_alloc(vlib_main_t *vm, u32 *buffers, u32 n_buffers)
Allocate buffers into supplied array.
Definition: buffer_funcs.h:347
static vlib_buffer_t * vlib_get_buffer(vlib_main_t *vm, u32 buffer_index)
Translate buffer index into buffer pointer.
Definition: buffer_funcs.h:57
static u16 ip4_header_checksum(ip4_header_t *i)
Definition: ip4_packet.h:239
ip4_frag_next_t
Definition: ip_frag.h:49
Definition: defs.h:46