4 * Copyright (c) 2018 Cisco and/or its affiliates.
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at:
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or aipiped to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
19 #include <vnet/adj/adj_midchain.h>
20 #include <vnet/ipip/ipip.h>
21 #include <vnet/vnet.h>
22 #include <vnet/adj/adj_nbr.h>
23 #include <vnet/adj/adj_midchain.h>
24 #include <vnet/fib/ip4_fib.h>
25 #include <vnet/fib/ip6_fib.h>
26 #include <vnet/ip/format.h>
27 #include <vnet/ipip/ipip.h>
28 #include <vnet/teib/teib.h>
29 #include <vnet/tunnel/tunnel_dp.h>
31 ipip_main_t ipip_main;
33 /* Packet trace structure */
43 format_ipip_tx_trace (u8 * s, va_list * args)
45 CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
46 CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
47 ipip_tx_trace_t *t = va_arg (*args, ipip_tx_trace_t *);
50 format (s, "IPIP: tunnel %d len %d src %U dst %U", t->tunnel_id,
51 t->length, format_ip46_address, &t->src, IP46_TYPE_ANY,
52 format_ip46_address, &t->dst, IP46_TYPE_ANY);
57 ipip_build_rewrite (vnet_main_t * vnm, u32 sw_if_index,
58 vnet_link_t link_type, const void *dst_address)
60 const ip46_address_t *dst;
67 t = ipip_tunnel_db_find_by_sw_if_index (sw_if_index);
75 case IPIP_TRANSPORT_IP4:
76 vec_validate (rewrite, sizeof (*ip4) - 1);
77 ip4 = (ip4_header_t *) rewrite;
78 ip4->ip_version_and_header_length = 0x45;
80 /* fixup ip4 header length, protocol and checksum after-the-fact */
81 ip4->src_address.as_u32 = t->tunnel_src.ip4.as_u32;
82 ip4->dst_address.as_u32 = dst->ip4.as_u32;
83 if (!(t->flags & TUNNEL_ENCAP_DECAP_FLAG_ENCAP_COPY_DSCP))
84 ip4_header_set_dscp (ip4, t->dscp);
85 if (t->flags & TUNNEL_ENCAP_DECAP_FLAG_ENCAP_SET_DF)
86 ip4_header_set_df (ip4);
91 ip4->protocol = IP_PROTOCOL_IPV6;
94 ip4->protocol = IP_PROTOCOL_IP_IN_IP;
99 ip4->checksum = ip4_header_checksum (ip4);
102 case IPIP_TRANSPORT_IP6:
103 vec_validate (rewrite, sizeof (*ip6) - 1);
104 ip6 = (ip6_header_t *) rewrite;
105 ip6->ip_version_traffic_class_and_flow_label =
106 clib_host_to_net_u32 (6 << 28);
108 /* fixup ip6 header length and protocol after-the-fact */
109 ip6->src_address.as_u64[0] = t->tunnel_src.ip6.as_u64[0];
110 ip6->src_address.as_u64[1] = t->tunnel_src.ip6.as_u64[1];
111 ip6->dst_address.as_u64[0] = dst->ip6.as_u64[0];
112 ip6->dst_address.as_u64[1] = dst->ip6.as_u64[1];
113 if (!(t->flags & TUNNEL_ENCAP_DECAP_FLAG_ENCAP_COPY_DSCP))
114 ip6_set_dscp_network_order (ip6, t->dscp);
119 ip6->protocol = IP_PROTOCOL_IPV6;
122 ip6->protocol = IP_PROTOCOL_IP_IN_IP;
133 ipip64_fixup (vlib_main_t * vm, const ip_adjacency_t * adj, vlib_buffer_t * b,
136 tunnel_encap_decap_flags_t flags;
139 flags = pointer_to_uword (data);
141 ip4 = vlib_buffer_get_current (b);
142 ip4->length = clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b));
143 tunnel_encap_fixup_6o4 (flags, ((ip6_header_t *) (ip4 + 1)), ip4);
145 ip4->checksum = ip4_header_checksum (ip4);
149 ipip44_fixup (vlib_main_t * vm, const ip_adjacency_t * adj, vlib_buffer_t * b,
152 tunnel_encap_decap_flags_t flags;
155 flags = pointer_to_uword (data);
157 ip4 = vlib_buffer_get_current (b);
158 ip4->length = clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b));
159 tunnel_encap_fixup_4o4 (flags, ip4 + 1, ip4);
161 ip4->checksum = ip4_header_checksum (ip4);
165 ipip46_fixup (vlib_main_t * vm, const ip_adjacency_t * adj, vlib_buffer_t * b,
168 tunnel_encap_decap_flags_t flags;
171 flags = pointer_to_uword (data);
173 /* Must set locally originated otherwise we're not allowed to
174 fragment the packet later */
175 b->flags |= VNET_BUFFER_F_LOCALLY_ORIGINATED;
177 ip6 = vlib_buffer_get_current (b);
178 ip6->payload_length =
179 clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b) -
181 tunnel_encap_fixup_4o6 (flags, ((ip4_header_t *) (ip6 + 1)), ip6);
185 ipip66_fixup (vlib_main_t * vm,
186 const ip_adjacency_t * adj, vlib_buffer_t * b, const void *data)
188 tunnel_encap_decap_flags_t flags;
191 flags = pointer_to_uword (data);
193 /* Must set locally originated otherwise we're not allowed to
194 fragment the packet later */
195 b->flags |= VNET_BUFFER_F_LOCALLY_ORIGINATED;
197 ip6 = vlib_buffer_get_current (b);
198 ip6->payload_length =
199 clib_host_to_net_u16 (vlib_buffer_length_in_chain (vm, b) -
201 tunnel_encap_fixup_6o6 (flags, ip6 + 1, ip6);
205 ipip_tunnel_stack (adj_index_t ai)
212 sw_if_index = adj->rewrite_header.sw_if_index;
214 t = ipip_tunnel_db_find_by_sw_if_index (sw_if_index);
218 if ((vnet_hw_interface_get_flags (vnet_get_main (), t->hw_if_index) &
219 VNET_HW_INTERFACE_FLAG_LINK_UP) == 0)
221 adj_midchain_delegate_unstack (ai);
227 .fp_len = t->transport == IPIP_TRANSPORT_IP6 ? 128 : 32,
228 .fp_proto = (t->transport == IPIP_TRANSPORT_IP6 ?
231 .fp_addr = t->tunnel_dst
235 adj_midchain_delegate_stack (ai, t->fib_index, &dst);
240 ipip_adj_walk_cb (adj_index_t ai, void *ctx)
242 ipip_tunnel_stack (ai);
244 return (ADJ_WALK_RC_CONTINUE);
248 ipip_tunnel_restack (ipip_tunnel_t * gt)
250 fib_protocol_t proto;
253 * walk all the adjacencies on th IPIP interface and restack them
255 FOR_EACH_FIB_IP_PROTOCOL (proto)
257 adj_nbr_walk (gt->sw_if_index, proto, ipip_adj_walk_cb, NULL);
261 static adj_midchain_fixup_t
262 ipip_get_fixup (const ipip_tunnel_t * t, vnet_link_t lt, adj_flags_t * aflags)
264 if (t->transport == IPIP_TRANSPORT_IP6 && lt == VNET_LINK_IP6)
265 return (ipip66_fixup);
266 if (t->transport == IPIP_TRANSPORT_IP6 && lt == VNET_LINK_IP4)
267 return (ipip46_fixup);
268 if (t->transport == IPIP_TRANSPORT_IP4 && lt == VNET_LINK_IP6)
269 return (ipip64_fixup);
270 if (t->transport == IPIP_TRANSPORT_IP4 && lt == VNET_LINK_IP4)
272 *aflags = *aflags | ADJ_FLAG_MIDCHAIN_FIXUP_IP4O4_HDR;
273 return (ipip44_fixup);
277 return (ipip44_fixup);
281 ipip_update_adj (vnet_main_t * vnm, u32 sw_if_index, adj_index_t ai)
283 adj_midchain_fixup_t fixup;
287 t = ipip_tunnel_db_find_by_sw_if_index (sw_if_index);
291 if (t->flags & TUNNEL_ENCAP_DECAP_FLAG_ENCAP_INNER_HASH)
292 af = ADJ_FLAG_MIDCHAIN_FIXUP_FLOW_HASH;
294 af = ADJ_FLAG_MIDCHAIN_IP_STACK;
296 if (VNET_LINK_ETHERNET == adj_get_link_type (ai))
297 af |= ADJ_FLAG_MIDCHAIN_NO_COUNT;
299 fixup = ipip_get_fixup (t, adj_get_link_type (ai), &af);
300 adj_nbr_midchain_update_rewrite
302 uword_to_pointer (t->flags, void *), af,
303 ipip_build_rewrite (vnm, sw_if_index,
304 adj_get_link_type (ai), &t->tunnel_dst));
305 ipip_tunnel_stack (ai);
308 typedef struct mipip_walk_ctx_t_
310 const ipip_tunnel_t *t;
311 const teib_entry_t *ne;
315 mipip_mk_complete_walk (adj_index_t ai, void *data)
317 adj_midchain_fixup_t fixup;
318 mipip_walk_ctx_t *ctx = data;
322 fixup = ipip_get_fixup (ctx->t, adj_get_link_type (ai), &af);
324 if (ctx->t->flags & TUNNEL_ENCAP_DECAP_FLAG_ENCAP_INNER_HASH)
325 af = ADJ_FLAG_MIDCHAIN_FIXUP_FLOW_HASH;
327 af = ADJ_FLAG_MIDCHAIN_IP_STACK;
329 adj_nbr_midchain_update_rewrite
331 uword_to_pointer (ctx->t->flags, void *),
332 af, ipip_build_rewrite (vnet_get_main (),
334 adj_get_link_type (ai),
335 &teib_entry_get_nh (ctx->ne)->fp_addr));
337 teib_entry_adj_stack (ctx->ne, ai);
339 return (ADJ_WALK_RC_CONTINUE);
343 mipip_mk_incomplete_walk (adj_index_t ai, void *data)
345 adj_midchain_fixup_t fixup;
346 ipip_tunnel_t *t = data;
350 fixup = ipip_get_fixup (t, adj_get_link_type (ai), &af);
352 adj_nbr_midchain_update_rewrite (ai, fixup, NULL, ADJ_FLAG_NONE, NULL);
354 adj_midchain_delegate_unstack (ai);
356 return (ADJ_WALK_RC_CONTINUE);
360 mipip_update_adj (vnet_main_t * vnm, u32 sw_if_index, adj_index_t ai)
362 ipip_main_t *gm = &ipip_main;
363 adj_midchain_fixup_t fixup;
372 ti = gm->tunnel_index_by_sw_if_index[sw_if_index];
373 t = pool_elt_at_index (gm->tunnels, ti);
375 ne = teib_entry_find_46 (sw_if_index,
376 adj->ia_nh_proto, &adj->sub_type.nbr.next_hop);
380 // no TEIB entry to provide the next-hop
381 fixup = ipip_get_fixup (t, adj_get_link_type (ai), &af);
382 adj_nbr_midchain_update_rewrite
383 (ai, fixup, uword_to_pointer (t->flags, void *), ADJ_FLAG_NONE, NULL);
387 mipip_walk_ctx_t ctx = {
391 adj_nbr_walk_nh (sw_if_index,
393 &adj->sub_type.nbr.next_hop, mipip_mk_complete_walk, &ctx);
397 format_ipip_tunnel_name (u8 * s, va_list * args)
399 u32 dev_instance = va_arg (*args, u32);
400 ipip_main_t *gm = &ipip_main;
403 if (dev_instance >= vec_len (gm->tunnels))
404 return format (s, "<improperly-referenced>");
406 t = pool_elt_at_index (gm->tunnels, dev_instance);
407 return format (s, "ipip%d", t->user_instance);
411 format_ipip_device (u8 * s, va_list * args)
413 u32 dev_instance = va_arg (*args, u32);
414 CLIB_UNUSED (int verbose) = va_arg (*args, int);
416 s = format (s, "IPIP tunnel: id %d\n", dev_instance);
420 static clib_error_t *
421 ipip_interface_admin_up_down (vnet_main_t * vnm, u32 hw_if_index, u32 flags)
423 vnet_hw_interface_t *hi;
426 hi = vnet_get_hw_interface (vnm, hw_if_index);
428 t = ipip_tunnel_db_find_by_sw_if_index (hi->sw_if_index);
432 if (flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP)
433 vnet_hw_interface_set_flags (vnm, hw_if_index,
434 VNET_HW_INTERFACE_FLAG_LINK_UP);
436 vnet_hw_interface_set_flags (vnm, hw_if_index, 0 /* down */ );
438 ipip_tunnel_restack (t);
440 return /* no error */ 0;
444 ipip_tunnel_desc (u32 sw_if_index,
445 ip46_address_t * src, ip46_address_t * dst, u8 * is_l2)
449 t = ipip_tunnel_db_find_by_sw_if_index (sw_if_index);
453 *src = t->tunnel_src;
454 *dst = t->tunnel_dst;
461 VNET_DEVICE_CLASS(ipip_device_class) = {
462 .name = "IPIP tunnel device",
463 .format_device_name = format_ipip_tunnel_name,
464 .format_device = format_ipip_device,
465 .format_tx_trace = format_ipip_tx_trace,
466 .admin_up_down_function = ipip_interface_admin_up_down,
467 .ip_tun_desc = ipip_tunnel_desc,
473 VNET_HW_INTERFACE_CLASS(ipip_hw_interface_class) = {
475 //.format_header = format_ipip_header_with_length,
476 //.unformat_header = unformat_ipip_header,
477 .build_rewrite = ipip_build_rewrite,
478 .update_adjacency = ipip_update_adj,
479 .flags = VNET_HW_INTERFACE_CLASS_FLAG_P2P,
482 VNET_HW_INTERFACE_CLASS(mipip_hw_interface_class) = {
484 //.format_header = format_ipip_header_with_length,
485 //.unformat_header = unformat_ipip_header,
486 .build_rewrite = ipip_build_rewrite,
487 .update_adjacency = mipip_update_adj,
488 .flags = VNET_HW_INTERFACE_CLASS_FLAG_NBMA,
493 ipip_tunnel_db_find (const ipip_tunnel_key_t * key)
495 ipip_main_t *gm = &ipip_main;
498 p = hash_get_mem (gm->tunnel_by_key, key);
501 return (pool_elt_at_index (gm->tunnels, p[0]));
505 ipip_tunnel_db_find_by_sw_if_index (u32 sw_if_index)
507 ipip_main_t *gm = &ipip_main;
508 if (vec_len (gm->tunnel_index_by_sw_if_index) <= sw_if_index)
510 u32 ti = gm->tunnel_index_by_sw_if_index[sw_if_index];
513 return pool_elt_at_index (gm->tunnels, ti);
517 ipip_tunnel_db_add (ipip_tunnel_t * t, const ipip_tunnel_key_t * key)
519 ipip_main_t *gm = &ipip_main;
521 hash_set_mem_alloc (&gm->tunnel_by_key, key, t->dev_instance);
525 ipip_tunnel_db_remove (ipip_tunnel_t * t, const ipip_tunnel_key_t * key)
527 ipip_main_t *gm = &ipip_main;
529 hash_unset_mem_free (&gm->tunnel_by_key, key);
533 ipip_mk_key_i (ipip_transport_t transport,
535 const ip46_address_t * src,
536 const ip46_address_t * dst,
537 u32 fib_index, ipip_tunnel_key_t * key)
539 key->transport = transport;
543 key->fib_index = fib_index;
548 ipip_mk_key (const ipip_tunnel_t * t, ipip_tunnel_key_t * key)
550 ipip_mk_key_i (t->transport, t->mode,
551 &t->tunnel_src, &t->tunnel_dst, t->fib_index, key);
555 ipip_teib_mk_key (const ipip_tunnel_t * t,
556 const teib_entry_t * ne, ipip_tunnel_key_t * key)
558 const fib_prefix_t *nh;
560 nh = teib_entry_get_nh (ne);
562 /* construct the key using mode P2P so it can be found in the DP */
563 ipip_mk_key_i (t->transport, IPIP_MODE_P2P,
564 &t->tunnel_src, &nh->fp_addr,
565 teib_entry_get_fib_index (ne), key);
569 ipip_teib_entry_added (const teib_entry_t * ne)
571 ipip_main_t *gm = &ipip_main;
572 const ip_address_t *nh;
573 ipip_tunnel_key_t key;
578 sw_if_index = teib_entry_get_sw_if_index (ne);
579 if (vec_len (gm->tunnel_index_by_sw_if_index) < sw_if_index)
582 t_idx = gm->tunnel_index_by_sw_if_index[sw_if_index];
584 if (INDEX_INVALID == t_idx)
587 t = pool_elt_at_index (gm->tunnels, t_idx);
589 ipip_teib_mk_key (t, ne, &key);
590 ipip_tunnel_db_add (t, &key);
592 // update the rewrites for each of the adjacencies for this next-hop
593 mipip_walk_ctx_t ctx = {
597 nh = teib_entry_get_peer (ne);
598 adj_nbr_walk_nh (teib_entry_get_sw_if_index (ne),
599 (AF_IP4 == ip_addr_version (nh) ?
602 &ip_addr_46 (nh), mipip_mk_complete_walk, &ctx);
606 ipip_teib_entry_deleted (const teib_entry_t * ne)
608 ipip_main_t *gm = &ipip_main;
609 const ip_address_t *nh;
610 ipip_tunnel_key_t key;
615 sw_if_index = teib_entry_get_sw_if_index (ne);
616 if (vec_len (gm->tunnel_index_by_sw_if_index) < sw_if_index)
619 t_idx = gm->tunnel_index_by_sw_if_index[sw_if_index];
621 if (INDEX_INVALID == t_idx)
624 t = pool_elt_at_index (gm->tunnels, t_idx);
626 ipip_teib_mk_key (t, ne, &key);
627 ipip_tunnel_db_remove (t, &key);
629 nh = teib_entry_get_peer (ne);
631 /* make all the adjacencies incomplete */
632 adj_nbr_walk_nh (teib_entry_get_sw_if_index (ne),
633 (AF_IP4 == ip_addr_version (nh) ?
636 &ip_addr_46 (nh), mipip_mk_incomplete_walk, t);
640 ipip_tunnel_delete_teib_walk (index_t nei, void *ctx)
642 ipip_tunnel_t *t = ctx;
643 ipip_tunnel_key_t key;
645 ipip_teib_mk_key (t, teib_entry_get (nei), &key);
646 ipip_tunnel_db_remove (t, &key);
648 return (WALK_CONTINUE);
652 ipip_tunnel_add_teib_walk (index_t nei, void *ctx)
654 ipip_tunnel_t *t = ctx;
655 ipip_tunnel_key_t key;
657 ipip_teib_mk_key (t, teib_entry_get (nei), &key);
658 ipip_tunnel_db_add (t, &key);
660 return (WALK_CONTINUE);
664 ipip_add_tunnel (ipip_transport_t transport,
665 u32 instance, ip46_address_t * src, ip46_address_t * dst,
666 u32 fib_index, tunnel_encap_decap_flags_t flags,
667 ip_dscp_t dscp, tunnel_mode_t tmode, u32 * sw_if_indexp)
669 ipip_main_t *gm = &ipip_main;
670 vnet_main_t *vnm = gm->vnet_main;
671 ip4_main_t *im4 = &ip4_main;
672 ip6_main_t *im6 = &ip6_main;
674 vnet_hw_interface_t *hi;
675 u32 hw_if_index, sw_if_index;
676 ipip_tunnel_key_t key;
679 if (tmode == TUNNEL_MODE_MP && !ip46_address_is_zero (dst))
680 return (VNET_API_ERROR_INVALID_DST_ADDRESS);
682 mode = (tmode == TUNNEL_MODE_P2P ? IPIP_MODE_P2P : IPIP_MODE_P2MP);
683 ipip_mk_key_i (transport, mode, src, dst, fib_index, &key);
685 t = ipip_tunnel_db_find (&key);
689 sw_if_indexp[0] = t->sw_if_index;
690 return VNET_API_ERROR_IF_ALREADY_EXISTS;
693 pool_get_aligned (gm->tunnels, t, CLIB_CACHE_LINE_BYTES);
694 clib_memset (t, 0, sizeof (*t));
696 /* Reconcile the real dev_instance and a possible requested instance */
697 u32 t_idx = t - gm->tunnels; /* tunnel index (or instance) */
698 u32 u_idx = instance; /* user specified instance */
701 if (hash_get (gm->instance_used, u_idx))
703 pool_put (gm->tunnels, t);
704 return VNET_API_ERROR_INSTANCE_IN_USE;
706 hash_set (gm->instance_used, u_idx, 1);
708 t->dev_instance = t_idx; /* actual */
709 t->user_instance = u_idx; /* name */
711 hw_if_index = vnet_register_interface (vnm, ipip_device_class.index, t_idx,
712 (mode == IPIP_MODE_P2P ?
713 ipip_hw_interface_class.index :
714 mipip_hw_interface_class.index),
717 hi = vnet_get_hw_interface (vnm, hw_if_index);
718 sw_if_index = hi->sw_if_index;
721 t->hw_if_index = hw_if_index;
722 t->fib_index = fib_index;
723 t->sw_if_index = sw_if_index;
726 t->transport = transport;
728 vec_validate_init_empty (gm->tunnel_index_by_sw_if_index, sw_if_index, ~0);
729 gm->tunnel_index_by_sw_if_index[sw_if_index] = t_idx;
731 if (t->transport == IPIP_TRANSPORT_IP4)
733 vec_validate (im4->fib_index_by_sw_if_index, sw_if_index);
734 hi->min_packet_bytes = 64 + sizeof (ip4_header_t);
738 vec_validate (im6->fib_index_by_sw_if_index, sw_if_index);
739 hi->min_packet_bytes = 64 + sizeof (ip6_header_t);
742 /* Standard default ipip MTU. */
743 vnet_sw_interface_set_mtu (vnm, sw_if_index, 9000);
745 t->tunnel_src = *src;
746 t->tunnel_dst = *dst;
748 ipip_tunnel_db_add (t, &key);
750 if (t->mode == IPIP_MODE_P2MP)
751 teib_walk_itf (t->sw_if_index, ipip_tunnel_add_teib_walk, t);
754 *sw_if_indexp = sw_if_index;
756 if (t->transport == IPIP_TRANSPORT_IP6 && !gm->ip6_protocol_registered)
758 ip6_register_protocol (IP_PROTOCOL_IP_IN_IP, ipip6_input_node.index);
759 ip6_register_protocol (IP_PROTOCOL_IPV6, ipip6_input_node.index);
760 gm->ip6_protocol_registered = true;
762 else if (t->transport == IPIP_TRANSPORT_IP4 && !gm->ip4_protocol_registered)
764 ip4_register_protocol (IP_PROTOCOL_IP_IN_IP, ipip4_input_node.index);
765 ip4_register_protocol (IP_PROTOCOL_IPV6, ipip4_input_node.index);
766 gm->ip4_protocol_registered = true;
772 ipip_del_tunnel (u32 sw_if_index)
774 ipip_main_t *gm = &ipip_main;
775 vnet_main_t *vnm = gm->vnet_main;
777 ipip_tunnel_key_t key;
779 t = ipip_tunnel_db_find_by_sw_if_index (sw_if_index);
781 return VNET_API_ERROR_NO_SUCH_ENTRY;
783 if (t->mode == IPIP_MODE_P2MP)
784 teib_walk_itf (t->sw_if_index, ipip_tunnel_delete_teib_walk, t);
786 vnet_sw_interface_set_flags (vnm, sw_if_index, 0 /* down */ );
787 gm->tunnel_index_by_sw_if_index[sw_if_index] = ~0;
788 vnet_delete_hw_interface (vnm, t->hw_if_index);
789 hash_unset (gm->instance_used, t->user_instance);
791 ipip_mk_key (t, &key);
792 ipip_tunnel_db_remove (t, &key);
793 pool_put (gm->tunnels, t);
798 const static teib_vft_t ipip_teib_vft = {
799 .nv_added = ipip_teib_entry_added,
800 .nv_deleted = ipip_teib_entry_deleted,
803 static clib_error_t *
804 ipip_init (vlib_main_t * vm)
806 ipip_main_t *gm = &ipip_main;
808 clib_memset (gm, 0, sizeof (gm[0]));
810 gm->vnet_main = vnet_get_main ();
812 hash_create_mem (0, sizeof (ipip_tunnel_key_t), sizeof (uword));
814 teib_register (&ipip_teib_vft);
819 VLIB_INIT_FUNCTION (ipip_init);
822 * fd.io coding-style-patch-verification: ON
825 * eval: (c-set-style "gnu")