FD.io VPP  v21.06-3-gbb25fbf28
Vector Packet Processing
fib_types.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016 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 #include <vnet/ip/ip.h>
17 
18 #include <vnet/fib/fib_types.h>
19 #include <vnet/fib/fib_internal.h>
20 #include <vnet/fib/fib_table.h>
21 #include <vnet/mfib/mfib_types.h>
22 #include <vnet/mpls/mpls.h>
23 
24 /*
25  * arrays of protocol and link names
26  */
27 static const char* fib_protocol_names[] = FIB_PROTOCOLS;
28 static const char* vnet_link_names[] = VNET_LINKS;
29 static const char* fib_forw_chain_names[] = FIB_FORW_CHAINS;
31 
32 u8 *
33 format_fib_protocol (u8 * s, va_list * ap)
34 {
35  fib_protocol_t proto = va_arg(*ap, int); // fib_protocol_t promotion
36 
37  return (format (s, "%s", fib_protocol_names[proto]));
38 }
39 
40 u8 *
41 format_vnet_link (u8 * s, va_list * ap)
42 {
43  vnet_link_t link = va_arg(*ap, int); // vnet_link_t promotion
44 
45  return (format (s, "%s", vnet_link_names[link]));
46 }
47 
48 u8 *
49 format_fib_forw_chain_type (u8 * s, va_list * args)
50 {
51  fib_forward_chain_type_t fct = va_arg(*args, int);
52 
53  return (format (s, "%s", fib_forw_chain_names[fct]));
54 }
55 
56 u8 *
57 format_fib_mpls_lsp_mode(u8 *s, va_list *ap)
58 {
59  fib_mpls_lsp_mode_t mode = va_arg(*ap, int);
60 
61  return (format (s, "%s", fib_mpls_lsp_mode_names[mode]));
62 }
63 
64 u8 *
65 format_fib_mpls_label (u8 *s, va_list *ap)
66 {
67  fib_mpls_label_t *label = va_arg(*ap, fib_mpls_label_t *);
68 
69  s = format(s, "%U %U ttl:%d exp:%d",
71  label->fml_value,
73  label->fml_mode,
74  label->fml_ttl,
75  label->fml_exp);
76 
77  return (s);
78 }
79 
80 void
81 fib_prefix_from_ip46_addr (const ip46_address_t *addr,
82  fib_prefix_t *pfx)
83 {
85 
89  pfx->fp_len = ((ip46_address_is_ip4(addr) ?
90  32 : 128));
91  pfx->fp_addr = *addr;
92  pfx->___fp___pad = 0;
93 }
94 
95 u8 *
97 {
99 
101  s = format (s, "via-host");
103  s = format (s, "via-attached,");
105  s = format (s, "local,");
107  s = format (s, "attached,");
109  s = format (s, "drop,");
111  s = format (s, "exclusive,");
113  s = format (s, "intf-rx,");
115  s = format (s, "rpf-id,");
117  s = format (s, "src-lkup,");
119  s = format (s, "udp-encap,");
121  s = format (s, "bier-fmask,");
123  s = format (s, "bier-table,");
125  s = format (s, "bier-imp,");
127  s = format (s, "deag,");
129  s = format (s, "dvr,");
131  s = format (s, "imcp-unreach,");
133  s = format (s, "icmp-prohibit,");
135  s = format (s, "classify,");
137  s = format (s, "pop-pw-cw,");
138 
139  return (s);
140 }
141 
142 u8 *
143 format_fib_route_path (u8 *s, va_list *ap)
144 {
145  fib_route_path_t *rpath = va_arg (*ap, fib_route_path_t*);
146 
147  s = format (s, "%U %U, %U, [%U]",
148  format_dpo_proto, rpath->frp_proto,
151  rpath->frp_sw_if_index,
153 
154  return (s);
155 }
156 
157 void
159  mpls_eos_bit_t eos,
160  fib_prefix_t *pfx)
161 {
163  pfx->fp_len = 21;
164  pfx->fp_label = label;
165  pfx->fp_eos = eos;
166  pfx->___fp___pad = 0;
167 }
168 
169 void
171  const fib_prefix_t *src)
172 {
173  clib_memcpy(dst, src, sizeof(*dst));
174 }
175 
176 int
178  const fib_prefix_t *p2)
179 {
180  int res;
181 
182  res = (p1->fp_proto - p2->fp_proto);
183 
184  if (0 == res)
185  {
186  switch (p1->fp_proto)
187  {
188  case FIB_PROTOCOL_IP4:
189  case FIB_PROTOCOL_IP6:
190  res = (p1->fp_len - p2->fp_len);
191 
192  if (0 == res)
193  {
194  res = ip46_address_cmp(&p1->fp_addr, &p2->fp_addr);
195  }
196  break;
197  case FIB_PROTOCOL_MPLS:
198  res = (p1->fp_label - p2->fp_label);
199 
200  if (0 == res)
201  {
202  res = (p1->fp_eos - p2->fp_eos);
203  }
204  break;
205  }
206  }
207 
208  return (res);
209 }
210 
211 int
213  const fib_prefix_t *p2)
214 {
215  switch (p1->fp_proto)
216  {
217  case FIB_PROTOCOL_IP4:
219  &p1->fp_addr.ip4,
220  &p2->fp_addr.ip4,
221  p1->fp_len));
222  case FIB_PROTOCOL_IP6:
224  &p1->fp_addr.ip6,
225  &p2->fp_addr.ip6,
226  p1->fp_len));
227  case FIB_PROTOCOL_MPLS:
228  break;
229  }
230  return (0);
231 }
232 
233 u8
235 {
236  switch (proto)
237  {
238  case FIB_PROTOCOL_IP4:
239  return (32);
240  case FIB_PROTOCOL_IP6:
241  return (128);
242  case FIB_PROTOCOL_MPLS:
243  return (21);
244  }
245  return (0);
246 }
247 
248 int
250 {
251  switch (prefix->fp_proto)
252  {
253  case FIB_PROTOCOL_IP4:
254  return (prefix->fp_len == 32);
255  case FIB_PROTOCOL_IP6:
256  return (prefix->fp_len == 128);
257  case FIB_PROTOCOL_MPLS:
258  return (!0);
259  }
260  return (0);
261 }
262 
263 void
265  fib_prefix_t *out)
266 {
267  fib_prefix_copy (out, p);
268 
269  switch (p->fp_proto)
270  {
271  case FIB_PROTOCOL_IP4:
272  ip4_address_normalize(&out->fp_addr.ip4, out->fp_len);
273  break;
274  case FIB_PROTOCOL_IP6:
275  ip6_address_normalize(&out->fp_addr.ip6, out->fp_len);
276  break;
277  case FIB_PROTOCOL_MPLS:
278  break;
279  }
280 }
281 
282 u8 *
283 format_fib_prefix (u8 * s, va_list * args)
284 {
285  fib_prefix_t *fp = va_arg (*args, fib_prefix_t *);
286 
287  /*
288  * protocol specific so it prints ::/0 correctly.
289  */
290  switch (fp->fp_proto)
291  {
292  case FIB_PROTOCOL_IP6:
293  {
294  ip6_address_t p6 = fp->fp_addr.ip6;
295 
297  s = format (s, "%U", format_ip6_address, &p6);
298  break;
299  }
300  case FIB_PROTOCOL_IP4:
301  {
302  ip4_address_t p4 = fp->fp_addr.ip4;
303  p4.as_u32 &= ip4_main.fib_masks[fp->fp_len];
304 
305  s = format (s, "%U", format_ip4_address, &p4);
306  break;
307  }
308  case FIB_PROTOCOL_MPLS:
309  s = format (s, "%U:%U",
312  break;
313  }
314  s = format (s, "/%d", fp->fp_len);
315 
316  return (s);
317 }
318 
319 int
321  const fib_route_path_t *rpath2)
322 {
323  int res;
324 
325  res = ip46_address_cmp(&rpath1->frp_addr,
326  &rpath2->frp_addr);
327 
328  if (0 != res) return (res);
329 
330  res = (rpath1->frp_sw_if_index - rpath2->frp_sw_if_index);
331 
332  if (0 != res) return (res);
333 
334  if (ip46_address_is_zero(&rpath1->frp_addr))
335  {
336  res = rpath1->frp_fib_index - rpath2->frp_fib_index;
337  }
338 
339  return (res);
340 }
341 
344 {
345  switch (fib_proto)
346  {
347  case FIB_PROTOCOL_IP6:
348  return (DPO_PROTO_IP6);
349  case FIB_PROTOCOL_IP4:
350  return (DPO_PROTO_IP4);
351  case FIB_PROTOCOL_MPLS:
352  return (DPO_PROTO_MPLS);
353  }
354  ASSERT(0);
355  return (0);
356 }
357 
360 {
361  switch (dpo_proto)
362  {
363  case DPO_PROTO_IP6:
364  return (FIB_PROTOCOL_IP6);
365  case DPO_PROTO_IP4:
366  return (FIB_PROTOCOL_IP4);
367  case DPO_PROTO_MPLS:
368  return (FIB_PROTOCOL_MPLS);
369  default:
370  break;
371  }
372  ASSERT(0);
373  return (0);
374 }
375 
378 {
379  switch (proto)
380  {
381  case FIB_PROTOCOL_IP4:
382  return (VNET_LINK_IP4);
383  case FIB_PROTOCOL_IP6:
384  return (VNET_LINK_IP6);
385  case FIB_PROTOCOL_MPLS:
386  return (VNET_LINK_MPLS);
387  }
388  ASSERT(0);
389  return (0);
390 }
391 
394 {
395  switch (fproto)
396  {
397  case FIB_PROTOCOL_IP4:
398  return (IP46_TYPE_IP4);
399  case FIB_PROTOCOL_IP6:
400  return (IP46_TYPE_IP6);
401  case FIB_PROTOCOL_MPLS:
402  return (IP46_TYPE_ANY);
403  }
404  ASSERT(0);
405  return (IP46_TYPE_ANY);
406 }
407 
410 {
411  switch (iproto)
412  {
413  case IP46_TYPE_IP4:
414  return FIB_PROTOCOL_IP4;
415  case IP46_TYPE_IP6:
416  return FIB_PROTOCOL_IP6;
417  case IP46_TYPE_ANY:
418  ASSERT(0);
419  return FIB_PROTOCOL_IP4;
420  }
421 
422  ASSERT(0);
423  return FIB_PROTOCOL_IP4;
424 }
425 
428 {
429  switch (proto)
430  {
431  case DPO_PROTO_IP4:
433  case DPO_PROTO_IP6:
435  case DPO_PROTO_MPLS:
437  case DPO_PROTO_ETHERNET:
439  case DPO_PROTO_NSH:
440  return (FIB_FORW_CHAIN_TYPE_NSH);
441  case DPO_PROTO_BIER:
442  return (FIB_FORW_CHAIN_TYPE_BIER);
443  }
444  ASSERT(0);
446 }
447 
450 {
451  switch (proto)
452  {
453  case FIB_PROTOCOL_IP4:
455  case FIB_PROTOCOL_IP6:
457  case FIB_PROTOCOL_MPLS:
459  }
460  ASSERT(0);
462 }
463 
466 {
467  switch (fct)
468  {
471  return (VNET_LINK_IP4);
474  return (VNET_LINK_IP6);
476  return (VNET_LINK_ETHERNET);
478  return (VNET_LINK_NSH);
481  /*
482  * insufficient information to to convert
483  */
484  ASSERT(0);
485  break;
487  return (VNET_LINK_MPLS);
488  }
489  return (VNET_LINK_IP4);
490 }
491 
494 {
495  switch (link_type)
496  {
497  case VNET_LINK_IP4:
499  case VNET_LINK_IP6:
501  case VNET_LINK_MPLS:
503  case VNET_LINK_ETHERNET:
505  case VNET_LINK_NSH:
506  return (FIB_FORW_CHAIN_TYPE_NSH);
507  case VNET_LINK_ARP:
508  break;
509  }
510 
511  ASSERT(0);
513 }
514 
517 {
518  switch (fct)
519  {
522  return (DPO_PROTO_IP4);
525  return (DPO_PROTO_IP6);
527  return (DPO_PROTO_ETHERNET);
529  return (DPO_PROTO_NSH);
531  return (DPO_PROTO_BIER);
534  return (DPO_PROTO_MPLS);
535  }
536  return (DPO_PROTO_IP4);
537 }
538 
539 uword
540 unformat_fib_route_path (unformat_input_t * input, va_list * args)
541 {
542  fib_route_path_t *rpath = va_arg (*args, fib_route_path_t *);
543  dpo_proto_t *payload_proto = va_arg (*args, void*);
544  u32 weight, preference, udp_encap_id, fi;
545  mpls_label_t out_label;
546  vnet_main_t *vnm;
547 
548  vnm = vnet_get_main ();
549  clib_memset(rpath, 0, sizeof(*rpath));
550  rpath->frp_weight = 1;
551  rpath->frp_sw_if_index = ~0;
552 
554  {
555  if (unformat (input, "%U %U",
557  &rpath->frp_addr.ip4,
559  &rpath->frp_sw_if_index))
560  {
561  rpath->frp_proto = DPO_PROTO_IP4;
562  }
563  else if (unformat (input, "%U %U",
565  &rpath->frp_addr.ip6,
567  &rpath->frp_sw_if_index))
568  {
569  rpath->frp_proto = DPO_PROTO_IP6;
570  }
571  else if (unformat (input, "weight %u", &weight))
572  {
573  rpath->frp_weight = weight;
574  }
575  else if (unformat (input, "preference %u", &preference))
576  {
577  rpath->frp_preference = preference;
578  }
579  else if (unformat (input, "%U next-hop-table %d",
581  &rpath->frp_addr.ip4,
582  &rpath->frp_fib_index))
583  {
584  rpath->frp_sw_if_index = ~0;
585  rpath->frp_proto = DPO_PROTO_IP4;
586 
587  /*
588  * the user enter table-ids, convert to index
589  */
591  if (~0 == fi)
592  return 0;
593  rpath->frp_fib_index = fi;
594  }
595  else if (unformat (input, "%U next-hop-table %d",
597  &rpath->frp_addr.ip6,
598  &rpath->frp_fib_index))
599  {
600  rpath->frp_sw_if_index = ~0;
601  rpath->frp_proto = DPO_PROTO_IP6;
603  if (~0 == fi)
604  return 0;
605  rpath->frp_fib_index = fi;
606  }
607  else if (unformat (input, "%U",
609  &rpath->frp_addr.ip4))
610  {
611  /*
612  * the recursive next-hops are by default in the default table
613  */
614  rpath->frp_fib_index = 0;
615  rpath->frp_sw_if_index = ~0;
616  rpath->frp_proto = DPO_PROTO_IP4;
617  }
618  else if (unformat (input, "%U",
620  &rpath->frp_addr.ip6))
621  {
622  rpath->frp_fib_index = 0;
623  rpath->frp_sw_if_index = ~0;
624  rpath->frp_proto = DPO_PROTO_IP6;
625  }
626  else if (unformat (input, "udp-encap %d", &udp_encap_id))
627  {
628  rpath->frp_udp_encap_id = udp_encap_id;
630  rpath->frp_proto = *payload_proto;
631  }
632  else if (unformat (input, "lookup in table %d", &rpath->frp_fib_index))
633  {
634  rpath->frp_proto = *payload_proto;
635  rpath->frp_sw_if_index = ~0;
636  rpath->frp_flags |= FIB_ROUTE_PATH_DEAG;
637  }
638  else if (unformat (input, "resolve-via-host"))
639  {
641  }
642  else if (unformat (input, "resolve-via-attached"))
643  {
645  }
646  else if (unformat (input, "pop-pw-cw"))
647  {
649  }
650  else if (unformat (input,
651  "ip4-lookup-in-table %d",
652  &rpath->frp_fib_index))
653  {
654  rpath->frp_proto = DPO_PROTO_IP4;
655  *payload_proto = DPO_PROTO_IP4;
657  if (~0 == fi)
658  return 0;
659  rpath->frp_fib_index = fi;
660  }
661  else if (unformat (input,
662  "ip6-lookup-in-table %d",
663  &rpath->frp_fib_index))
664  {
665  rpath->frp_proto = DPO_PROTO_IP6;
666  *payload_proto = DPO_PROTO_IP6;
668  if (~0 == fi)
669  return 0;
670  rpath->frp_fib_index = fi;
671  }
672  else if (unformat (input,
673  "mpls-lookup-in-table %d",
674  &rpath->frp_fib_index))
675  {
676  rpath->frp_proto = DPO_PROTO_MPLS;
677  *payload_proto = DPO_PROTO_MPLS;
679  if (~0 == fi)
680  return 0;
681  rpath->frp_fib_index = fi;
682  }
683  else if (unformat (input, "src-lookup"))
684  {
686  }
687  else if (unformat (input,
688  "l2-input-on %U",
690  &rpath->frp_sw_if_index))
691  {
692  rpath->frp_proto = DPO_PROTO_ETHERNET;
693  *payload_proto = DPO_PROTO_ETHERNET;
695  }
696  else if (unformat (input, "via-label %U",
698  &rpath->frp_local_label))
699  {
700  rpath->frp_eos = MPLS_NON_EOS;
701  rpath->frp_proto = DPO_PROTO_MPLS;
702  rpath->frp_sw_if_index = ~0;
703  }
704  else if (unformat (input, "rx-ip4 %U",
706  &rpath->frp_sw_if_index))
707  {
708  rpath->frp_proto = DPO_PROTO_IP4;
710  }
711  else if (unformat (input, "local"))
712  {
713  clib_memset (&rpath->frp_addr, 0, sizeof (rpath->frp_addr));
714  rpath->frp_sw_if_index = ~0;
715  rpath->frp_weight = 1;
717  }
718  else if (unformat (input, "%U",
720  ;
721  else if (unformat (input, "out-labels"))
722  {
723  while (unformat (input, "%U",
724  unformat_mpls_unicast_label, &out_label))
725  {
726  fib_mpls_label_t fml = {
727  .fml_value = out_label,
728  };
729  vec_add1(rpath->frp_label_stack, fml);
730  }
731  }
732  else if (unformat (input, "%U",
734  &rpath->frp_sw_if_index))
735  {
736  rpath->frp_proto = *payload_proto;
737  }
738  else if (unformat (input, "via"))
739  {
740  /* new path, back up and return */
741  unformat_put_input (input);
742  unformat_put_input (input);
743  unformat_put_input (input);
744  unformat_put_input (input);
745  break;
746  }
747  else
748  {
749  return (0);
750  }
751  }
752 
753  return (1);
754 }
fib_proto_from_ip46
fib_protocol_t fib_proto_from_ip46(ip46_type_t iproto)
Convert from ip46_type to fib_protocol.
Definition: fib_types.c:409
fib_route_path_t_::frp_fib_index
u32 frp_fib_index
The FIB index to lookup the nexthop Only valid for recursive paths.
Definition: fib_types.h:556
weight
u8 weight
Definition: fib_types.api:120
fib_route_path_t_::frp_mitf_flags
u32 frp_mitf_flags
MFIB interface flags.
Definition: fib_types.h:568
label
u32 label
Definition: fib_types.api:25
format_vnet_link
u8 * format_vnet_link(u8 *s, va_list *ap)
Definition: fib_types.c:41
fib_prefix_cmp
int fib_prefix_cmp(const fib_prefix_t *p1, const fib_prefix_t *p2)
Compare two prefixes for equality.
Definition: fib_types.c:177
format_ip4_address
format_function_t format_ip4_address
Definition: format.h:73
clib_memcpy
#define clib_memcpy(d, s, n)
Definition: string.h:197
fib_route_path_t_::frp_weight
u8 frp_weight
[un]equal cost path weight
Definition: fib_types.h:599
ip4_main
ip4_main_t ip4_main
Global ip4 main structure.
Definition: ip4_forward.c:1105
dpo_proto_t
enum dpo_proto_t_ dpo_proto_t
Data path protocol.
format_fib_forw_chain_type
u8 * format_fib_forw_chain_type(u8 *s, va_list *args)
Definition: fib_types.c:49
VNET_LINK_ETHERNET
@ VNET_LINK_ETHERNET
Definition: interface.h:350
FIB_ROUTE_PATH_ICMP_PROHIBIT
@ FIB_ROUTE_PATH_ICMP_PROHIBIT
Definition: fib_types.h:396
fib_prefix_copy
void fib_prefix_copy(fib_prefix_t *dst, const fib_prefix_t *src)
Copy a prefix.
Definition: fib_types.c:170
format_fib_mpls_label
u8 * format_fib_mpls_label(u8 *s, va_list *ap)
Format an MPLS label.
Definition: fib_types.c:65
FIB_FORW_CHAIN_TYPE_MPLS_EOS
@ FIB_FORW_CHAIN_TYPE_MPLS_EOS
Contribute an object that is to be used to forward end-of-stack MPLS packets.
Definition: fib_types.h:128
vnet_link_names
static const char * vnet_link_names[]
Definition: fib_types.c:28
ip46_address_cmp
static int ip46_address_cmp(const ip46_address_t *ip46_1, const ip46_address_t *ip46_2)
Definition: ip46_address.h:80
ip46_address_is_ip4
static u8 ip46_address_is_ip4(const ip46_address_t *ip46)
Definition: ip46_address.h:55
unformat_mfib_itf_flags
uword unformat_mfib_itf_flags(unformat_input_t *input, va_list *args)
Definition: mfib_types.c:198
IP46_TYPE_IP4
@ IP46_TYPE_IP4
Definition: ip46_address.h:26
ip4_address_t::as_u32
u32 as_u32
Definition: ip4_packet.h:57
fib_table.h
fib_route_path_t_::frp_addr
ip46_address_t frp_addr
The next-hop address.
Definition: fib_types.h:516
FIB_FORW_CHAIN_TYPE_MCAST_IP4
@ FIB_FORW_CHAIN_TYPE_MCAST_IP4
Contribute an object that is to be used to forward IP4 packets.
Definition: fib_types.h:132
mode
vl_api_tunnel_mode_t mode
Definition: gre.api:48
FIB_FORW_CHAIN_TYPE_ETHERNET
@ FIB_FORW_CHAIN_TYPE_ETHERNET
Contribute an object that is to be used to forward Ethernet packets.
Definition: fib_types.h:140
fib_prefix_t_::fp_len
u16 fp_len
The mask length.
Definition: fib_types.h:206
fib_route_path_t_::frp_eos
mpls_eos_bit_t frp_eos
EOS bit for the resolving label.
Definition: fib_types.h:527
fib_route_path_t_::frp_sw_if_index
u32 frp_sw_if_index
The interface.
Definition: fib_types.h:545
DPO_PROTO_BIER
@ DPO_PROTO_BIER
Definition: dpo.h:68
fib_prefix_from_ip46_addr
void fib_prefix_from_ip46_addr(const ip46_address_t *addr, fib_prefix_t *pfx)
Host prefix from ip.
Definition: fib_types.c:81
fib_prefix_t_::fp_eos
mpls_eos_bit_t fp_eos
Definition: fib_types.h:229
VNET_LINK_ARP
@ VNET_LINK_ARP
Definition: interface.h:351
ip4_main_t::fib_masks
u32 fib_masks[33]
Definition: ip4.h:120
mpls.h
format_mpls_eos_bit
format_function_t format_mpls_eos_bit
Definition: mpls.h:69
unformat_input_t
struct _unformat_input_t unformat_input_t
fib_route_path_t_::frp_proto
dpo_proto_t frp_proto
The protocol of the address below.
Definition: fib_types.h:505
addr
vhost_vring_addr_t addr
Definition: vhost_user.h:130
FIB_ROUTE_PATH_DVR
@ FIB_ROUTE_PATH_DVR
A path that resolves via a DVR DPO.
Definition: fib_types.h:393
fib_route_path_t_::frp_label_stack
fib_mpls_label_t * frp_label_stack
The outgoing MPLS label Stack.
Definition: fib_types.h:560
FIB_FORW_CHAIN_TYPE_NSH
@ FIB_FORW_CHAIN_TYPE_NSH
Contribute an object that is to be used to forward NSH packets.
Definition: fib_types.h:146
unformat
uword unformat(unformat_input_t *i, const char *fmt,...)
Definition: unformat.c:978
ip6_destination_matches_route
static uword ip6_destination_matches_route(const ip6_main_t *im, const ip6_address_t *key, const ip6_address_t *dest, uword dest_length)
Definition: ip6.h:189
FIB_FORW_CHAIN_TYPE_UNICAST_IP4
@ FIB_FORW_CHAIN_TYPE_UNICAST_IP4
Contribute an object that is to be used to forward IP4 packets.
Definition: fib_types.h:108
FIB_PROTOCOLS
#define FIB_PROTOCOLS
Definition: fib_types.h:41
unformat_put_input
static void unformat_put_input(unformat_input_t *input)
Definition: format.h:197
FIB_ROUTE_PATH_INTF_RX
@ FIB_ROUTE_PATH_INTF_RX
A path that result in received traffic being recieved/recirculated so that it appears to have arrived...
Definition: fib_types.h:361
VNET_LINK_IP4
@ VNET_LINK_IP4
Definition: interface.h:344
vec_add1
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
Definition: vec.h:606
fib_forward_chain_type_t
enum fib_forward_chain_type_t_ fib_forward_chain_type_t
FIB output chain type.
fib_forw_chain_type_to_link_type
vnet_link_t fib_forw_chain_type_to_link_type(fib_forward_chain_type_t fct)
Convert from a chain type to the adjacency's link type.
Definition: fib_types.c:465
fib_forw_chain_type_to_dpo_proto
dpo_proto_t fib_forw_chain_type_to_dpo_proto(fib_forward_chain_type_t fct)
Convert from a chain type to the DPO proto it will install.
Definition: fib_types.c:516
vnet_get_main
vnet_main_t * vnet_get_main(void)
Definition: pnat_test_stubs.h:56
fib_types.h
unformat_check_input
static uword unformat_check_input(unformat_input_t *i)
Definition: format.h:163
FIB_ROUTE_PATH_BIER_TABLE
@ FIB_ROUTE_PATH_BIER_TABLE
A path that resolves via a BIER [ECMP] Table.
Definition: fib_types.h:381
fib_protocol_names
static const char * fib_protocol_names[]
Definition: fib_types.c:27
FIB_ROUTE_PATH_SOURCE_LOOKUP
@ FIB_ROUTE_PATH_SOURCE_LOOKUP
A deag path using the packet's source not destination address.
Definition: fib_types.h:369
VNET_LINK_NSH
@ VNET_LINK_NSH
Definition: interface.h:352
uword
u64 uword
Definition: types.h:112
VNET_LINK_MPLS
@ VNET_LINK_MPLS
Definition: interface.h:349
FIB_ROUTE_PATH_RESOLVE_VIA_HOST
@ FIB_ROUTE_PATH_RESOLVE_VIA_HOST
Recursion constraint of via a host prefix.
Definition: fib_types.h:336
FIB_ROUTE_PATH_DEAG
@ FIB_ROUTE_PATH_DEAG
A path that resolves via another table.
Definition: fib_types.h:389
FIB_MPLS_LSP_MODES
#define FIB_MPLS_LSP_MODES
Definition: fib_types.h:442
fib_prefix_t_::fp_label
mpls_label_t fp_label
Definition: fib_types.h:228
fib_mpls_lsp_mode_t
enum fib_mpls_lsp_mode_t_ fib_mpls_lsp_mode_t
MPLS LSP mode - only valid at the head and tail.
ip6_address_normalize
void ip6_address_normalize(ip6_address_t *ip6, u8 preflen)
Definition: ip_types.c:471
fib_proto_to_link
vnet_link_t fib_proto_to_link(fib_protocol_t proto)
Convert from a protocol to a link type.
Definition: fib_types.c:377
unformat_mpls_unicast_label
unformat_function_t unformat_mpls_unicast_label
Definition: mpls.h:81
FIB_ROUTE_PATH_UDP_ENCAP
@ FIB_ROUTE_PATH_UDP_ENCAP
A path via a UDP encap object.
Definition: fib_types.h:373
FIB_ROUTE_PATH_RPF_ID
@ FIB_ROUTE_PATH_RPF_ID
A local path with a RPF-ID => multicast traffic.
Definition: fib_types.h:365
src
vl_api_address_t src
Definition: gre.api:54
fib_protocol_t
enum fib_protocol_t_ fib_protocol_t
Protocol Type.
ip4_address_t
Definition: ip4_packet.h:50
FIB_PROTOCOL_IP4
@ FIB_PROTOCOL_IP4
Definition: fib_types.h:36
IP46_TYPE_IP6
@ IP46_TYPE_IP6
Definition: ip46_address.h:27
fib_prefix_normalize
void fib_prefix_normalize(const fib_prefix_t *p, fib_prefix_t *out)
normalise a prefix (i.e.
Definition: fib_types.c:264
fib_proto_to_dpo
dpo_proto_t fib_proto_to_dpo(fib_protocol_t fib_proto)
Definition: fib_types.c:343
fib_prefix_t_::fp_addr
ip46_address_t fp_addr
The address type is not deriveable from the fp_addr member.
Definition: fib_types.h:225
ip46_address_is_zero
static u8 ip46_address_is_zero(const ip46_address_t *ip46)
Definition: ip46_address.h:87
ip6_main
ip6_main_t ip6_main
Definition: ip6_forward.c:2787
fib_mpls_label_t_::fml_value
mpls_label_t fml_value
The label value.
Definition: fib_types.h:460
ip6_address_mask
static void ip6_address_mask(ip6_address_t *a, const ip6_address_t *mask)
Definition: ip6_packet.h:195
ip4_destination_matches_route
static uword ip4_destination_matches_route(const ip4_main_t *im, const ip4_address_t *key, const ip4_address_t *dest, uword dest_length)
Definition: ip4.h:188
format_fib_route_path
u8 * format_fib_route_path(u8 *s, va_list *ap)
Format route path flags.
Definition: fib_types.c:143
vnet_main_t
Definition: vnet.h:76
format_fib_protocol
u8 * format_fib_protocol(u8 *s, va_list *ap)
Definition: fib_types.c:33
FIB_ROUTE_PATH_RESOLVE_VIA_ATTACHED
@ FIB_ROUTE_PATH_RESOLVE_VIA_ATTACHED
Recursion constraint of via an attahced prefix.
Definition: fib_types.h:340
FIB_FORW_CHAIN_TYPE_MPLS_NON_EOS
@ FIB_FORW_CHAIN_TYPE_MPLS_NON_EOS
Contribute an object that is to be used to forward non-end-of-stack MPLS packets.
Definition: fib_types.h:117
fib_forw_chain_type_from_link_type
fib_forward_chain_type_t fib_forw_chain_type_from_link_type(vnet_link_t link_type)
Convert from a adjacency's link type to chain type.
Definition: fib_types.c:493
fib_route_path_t_::frp_flags
fib_route_path_flags_t frp_flags
flags on the path
Definition: fib_types.h:609
dpo_proto_to_fib
fib_protocol_t dpo_proto_to_fib(dpo_proto_t dpo_proto)
Definition: fib_types.c:359
format_vnet_sw_if_index_name
format_function_t format_vnet_sw_if_index_name
Definition: interface_funcs.h:455
format_fib_route_path_flags
u8 * format_fib_route_path_flags(u8 *s, va_list *ap)
Format route path flags.
Definition: fib_types.c:96
FIB_ROUTE_PATH_POP_PW_CW
@ FIB_ROUTE_PATH_POP_PW_CW
Pop a Psuedo Wire Control Word.
Definition: fib_types.h:402
unformat_vnet_sw_interface
unformat_function_t unformat_vnet_sw_interface
Definition: interface_funcs.h:459
fib_forw_chain_type_from_fib_proto
fib_forward_chain_type_t fib_forw_chain_type_from_fib_proto(fib_protocol_t proto)
Convert from a fib-protocol to a chain type.
Definition: fib_types.c:449
format
description fragment has unexpected format
Definition: map.api:433
ASSERT
#define ASSERT(truth)
Definition: error_bootstrap.h:69
MPLS_NON_EOS
@ MPLS_NON_EOS
Definition: packet.h:38
format_ip46_address
format_function_t format_ip46_address
Definition: ip46_address.h:50
FIB_PROTOCOL_MPLS
@ FIB_PROTOCOL_MPLS
Definition: fib_types.h:38
DPO_PROTO_IP6
@ DPO_PROTO_IP6
Definition: dpo.h:65
DPO_PROTO_MPLS
@ DPO_PROTO_MPLS
Definition: dpo.h:66
ip.h
fib_forw_chain_type_from_dpo_proto
fib_forward_chain_type_t fib_forw_chain_type_from_dpo_proto(dpo_proto_t proto)
Convert from a payload-protocol to a chain type.
Definition: fib_types.c:427
u32
unsigned int u32
Definition: types.h:88
mfib_types.h
ip6_main_t::fib_masks
ip6_address_t fib_masks[129]
Definition: ip6.h:124
FIB_PROTOCOL_IP6
@ FIB_PROTOCOL_IP6
Definition: fib_types.h:37
dst
vl_api_ip4_address_t dst
Definition: pnat.api:41
preference
u8 preference
Definition: fib_types.api:121
fib_route_path_t_
A representation of a path as described by a route producer.
Definition: fib_types.h:500
format_fib_prefix
u8 * format_fib_prefix(u8 *s, va_list *args)
Definition: fib_types.c:283
FIB_ROUTE_PATH_ICMP_UNREACH
@ FIB_ROUTE_PATH_ICMP_UNREACH
Definition: fib_types.h:395
fib_prefix_is_cover
int fib_prefix_is_cover(const fib_prefix_t *p1, const fib_prefix_t *p2)
Compare two prefixes for covering relationship.
Definition: fib_types.c:212
FIB_ROUTE_PATH_ATTACHED
@ FIB_ROUTE_PATH_ATTACHED
Attached path.
Definition: fib_types.h:348
FIB_FORW_CHAIN_TYPE_BIER
@ FIB_FORW_CHAIN_TYPE_BIER
Contribute an object that is to be used to forward BIER packets.
Definition: fib_types.h:121
fib_prefix_t_::fp_proto
fib_protocol_t fp_proto
protocol type
Definition: fib_types.h:211
FIB_FORW_CHAIN_TYPE_MCAST_IP6
@ FIB_FORW_CHAIN_TYPE_MCAST_IP6
Contribute an object that is to be used to forward IP6 packets.
Definition: fib_types.h:136
clib_memset
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
fib_mpls_label_t_
Configuration for each label value in the output-stack.
Definition: fib_types.h:455
vnet_link_t
enum vnet_link_t_ vnet_link_t
Link Type: A description of the protocol of packets on the link.
format_dpo_proto
u8 * format_dpo_proto(u8 *s, va_list *args)
format a DPO protocol
Definition: dpo.c:180
VNET_LINKS
#define VNET_LINKS
Definition: interface.h:355
u8
unsigned char u8
Definition: types.h:56
VNET_LINK_IP6
@ VNET_LINK_IP6
Definition: interface.h:348
format_ip6_address
format_function_t format_ip6_address
Definition: format.h:91
fib_internal.h
ip46_type_t
ip46_type_t
Definition: ip46_address.h:22
fib_prefix_get_host_length
u8 fib_prefix_get_host_length(fib_protocol_t proto)
Definition: fib_types.c:234
DPO_PROTO_IP4
@ DPO_PROTO_IP4
Definition: dpo.h:64
fib_route_path_flags_t
enum fib_route_path_flags_t_ fib_route_path_flags_t
Path flags from the control plane.
FIB_ROUTE_PATH_DROP
@ FIB_ROUTE_PATH_DROP
A Drop path - resolve the path on the drop DPO.
Definition: fib_types.h:352
fib_prefix_is_host
int fib_prefix_is_host(const fib_prefix_t *prefix)
Return true is the prefix is a host prefix.
Definition: fib_types.c:249
unformat_ip6_address
unformat_function_t unformat_ip6_address
Definition: format.h:89
mpls_label_t
u32 mpls_label_t
A label value only, i.e.
Definition: packet.h:26
fib_route_path_t_::frp_preference
u8 frp_preference
A path preference.
Definition: fib_types.h:605
IP46_TYPE_ANY
@ IP46_TYPE_ANY
Definition: ip46_address.h:24
unformat_ip4_address
unformat_function_t unformat_ip4_address
Definition: format.h:68
DPO_PROTO_NSH
@ DPO_PROTO_NSH
Definition: dpo.h:69
fib_forw_chain_names
static const char * fib_forw_chain_names[]
Definition: fib_types.c:29
fib_route_path_t_::frp_udp_encap_id
u32 frp_udp_encap_id
UDP encap ID.
Definition: fib_types.h:579
FIB_ROUTE_PATH_EXCLUSIVE
@ FIB_ROUTE_PATH_EXCLUSIVE
Don't resolve the path, use the DPO the client provides.
Definition: fib_types.h:356
FIB_FORW_CHAINS
#define FIB_FORW_CHAINS
Definition: fib_types.h:149
FIB_ROUTE_PATH_BIER_IMP
@ FIB_ROUTE_PATH_BIER_IMP
A path that resolves via a BIER impostion object.
Definition: fib_types.h:385
DPO_PROTO_ETHERNET
@ DPO_PROTO_ETHERNET
Definition: dpo.h:67
fib_prefix_from_mpls_label
void fib_prefix_from_mpls_label(mpls_label_t label, mpls_eos_bit_t eos, fib_prefix_t *pfx)
Definition: fib_types.c:158
FIB_FORW_CHAIN_TYPE_UNICAST_IP6
@ FIB_FORW_CHAIN_TYPE_UNICAST_IP6
Contribute an object that is to be used to forward IP6 packets.
Definition: fib_types.h:112
FIB_ROUTE_PATH_BIER_FMASK
@ FIB_ROUTE_PATH_BIER_FMASK
A path that resolves via a BIER F-Mask.
Definition: fib_types.h:377
mpls_eos_bit_t
enum mpls_eos_bit_t_ mpls_eos_bit_t
proto
vl_api_ip_proto_t proto
Definition: acl_types.api:51
fib_table_find
u32 fib_table_find(fib_protocol_t proto, u32 table_id)
Get the index of the FIB for a Table-ID.
Definition: fib_table.c:1106
fib_mpls_lsp_mode_names
static const char * fib_mpls_lsp_mode_names[]
Definition: fib_types.c:30
format_mpls_unicast_label
format_function_t format_mpls_unicast_label
Definition: mpls.h:71
ip4_address_normalize
void ip4_address_normalize(ip4_address_t *ip4, u8 preflen)
Definition: ip_types.c:461
format_fib_mpls_lsp_mode
u8 * format_fib_mpls_lsp_mode(u8 *s, va_list *ap)
Format an LSP mode type.
Definition: fib_types.c:57
fib_route_path_cmp
int fib_route_path_cmp(const fib_route_path_t *rpath1, const fib_route_path_t *rpath2)
Definition: fib_types.c:320
fib_route_path_t_::frp_local_label
mpls_label_t frp_local_label
The MPLS local Label to reursively resolve through.
Definition: fib_types.h:523
FIB_ROUTE_PATH_CLASSIFY
@ FIB_ROUTE_PATH_CLASSIFY
Definition: fib_types.h:397
fib_proto_to_ip46
ip46_type_t fib_proto_to_ip46(fib_protocol_t fproto)
Convert from fib_protocol to ip46_type.
Definition: fib_types.c:393
unformat_fib_route_path
uword unformat_fib_route_path(unformat_input_t *input, va_list *args)
Unformat a fib_route_path_t from CLI input.
Definition: fib_types.c:540
fib_prefix_t_
Aggregate type for a prefix.
Definition: fib_types.h:202
FIB_ROUTE_PATH_LOCAL
@ FIB_ROUTE_PATH_LOCAL
A for-us/local path.
Definition: fib_types.h:344
UNFORMAT_END_OF_INPUT
#define UNFORMAT_END_OF_INPUT
Definition: format.h:137
prefix
vl_api_prefix_t prefix
Definition: ip.api:146
flags
vl_api_wireguard_peer_flags_t flags
Definition: wireguard.api:105