2 * Copyright (c) 2011-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:
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 * @brief BFD UDP transport layer implementation
19 #include <vppinfra/types.h>
20 #include <vlibmemory/api.h>
21 #include <vlib/vlib.h>
22 #include <vlib/buffer.h>
23 #include <vnet/ip/format.h>
24 #include <vnet/ethernet/packet.h>
25 #include <vnet/udp/udp_packet.h>
26 #include <vnet/udp/udp.h>
27 #include <vnet/ip/lookup.h>
28 #include <vnet/ip/icmp46_packet.h>
29 #include <vnet/ip/ip4.h>
30 #include <vnet/ip/ip6.h>
31 #include <vnet/ip/ip6_packet.h>
32 #include <vnet/adj/adj.h>
33 #include <vnet/adj/adj_nbr.h>
34 #include <vnet/dpo/receive_dpo.h>
35 #include <vnet/fib/fib_entry.h>
36 #include <vnet/fib/fib_table.h>
37 #include <vnet/bfd/bfd_debug.h>
38 #include <vnet/bfd/bfd_udp.h>
39 #include <vnet/bfd/bfd_main.h>
40 #include <vnet/bfd/bfd_api.h>
45 /* hashmap - bfd session index by bfd key - used for CLI/API lookup, where
46 * discriminator is unknown */
47 mhash_t bfd_session_idx_by_bfd_key;
48 /* convenience variable */
49 vnet_main_t *vnet_main;
50 /* flag indicating whether echo_source_sw_if_index holds a valid value */
51 int echo_source_is_set;
52 /* loopback interface used to get echo source ip */
53 u32 echo_source_sw_if_index;
54 /* node index of "ip4-arp" node */
56 /* node index of "ip6-discover-neighbor" node */
58 /* node index of "ip4-rewrite" node */
60 /* node index of "ip6-rewrite" node */
63 vlib_log_class_t log_class;
66 static vlib_node_registration_t bfd_udp4_input_node;
67 static vlib_node_registration_t bfd_udp6_input_node;
68 static vlib_node_registration_t bfd_udp_echo4_input_node;
69 static vlib_node_registration_t bfd_udp_echo6_input_node;
71 bfd_udp_main_t bfd_udp_main;
74 bfd_udp_set_echo_source (u32 sw_if_index)
76 vnet_sw_interface_t *sw_if =
77 vnet_get_sw_interface_safe (bfd_udp_main.vnet_main, sw_if_index);
80 bfd_udp_main.echo_source_sw_if_index = sw_if_index;
81 bfd_udp_main.echo_source_is_set = 1;
84 return VNET_API_ERROR_BFD_ENOENT;
88 bfd_udp_del_echo_source (u32 sw_if_index)
90 bfd_udp_main.echo_source_sw_if_index = ~0;
91 bfd_udp_main.echo_source_is_set = 0;
96 bfd_udp_is_echo_available (bfd_transport_e transport)
98 if (!bfd_udp_main.echo_source_is_set)
100 BFD_DBG ("UDP echo source not set - echo not available");
104 * for the echo to work, we need a loopback interface with at least one
105 * address with netmask length at most 31 (ip4) or 127 (ip6) so that we can
106 * pick an unused address from that subnet
108 vnet_sw_interface_t *sw_if =
109 vnet_get_sw_interface_safe (bfd_udp_main.vnet_main,
110 bfd_udp_main.echo_source_sw_if_index);
111 if (sw_if && sw_if->flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP)
113 if (BFD_TRANSPORT_UDP4 == transport)
115 ip4_main_t *im = &ip4_main;
116 ip_interface_address_t *ia = NULL;
118 foreach_ip_interface_address (&im->lookup_main, ia,
119 bfd_udp_main.echo_source_sw_if_index,
120 0 /* honor unnumbered */, ({
121 if (ia->address_length <= 31)
128 else if (BFD_TRANSPORT_UDP6 == transport)
130 ip6_main_t *im = &ip6_main;
131 ip_interface_address_t *ia = NULL;
133 foreach_ip_interface_address (&im->lookup_main, ia,
134 bfd_udp_main.echo_source_sw_if_index,
135 0 /* honor unnumbered */, ({
136 if (ia->address_length <= 127)
144 BFD_DBG ("No usable IP address for UDP echo - echo not available");
149 bfd_udp_bs_idx_to_sport (u32 bs_idx)
151 /* The source port MUST be in the range 49152 through 65535. The same UDP
152 * source port number MUST be used for all BFD Control packets associated
153 * with a particular session. The source port number SHOULD be unique among
154 * all BFD sessions on the system. If more than 16384 BFD sessions are
155 * simultaneously active, UDP source port numbers MAY be reused on
156 * multiple sessions, but the number of distinct uses of the same UDP
157 * source port number SHOULD be minimized.
159 return 49152 + bs_idx % (65535 - 49152 + 1);
163 bfd_udp_get_echo_src_ip4 (ip4_address_t * addr)
165 if (!bfd_udp_main.echo_source_is_set)
167 BFD_ERR ("cannot find ip4 address, echo source not set");
170 ip_interface_address_t *ia = NULL;
171 ip4_main_t *im = &ip4_main;
174 foreach_ip_interface_address (
175 &im->lookup_main, ia, bfd_udp_main.echo_source_sw_if_index,
176 0 /* honor unnumbered */, ({
178 ip_interface_address_get_address (&im->lookup_main, ia);
179 if (ia->address_length <= 31)
181 addr->as_u32 = clib_host_to_net_u32 (x->as_u32);
183 * flip the last bit to get a different address, might be network,
187 addr->as_u32 = clib_net_to_host_u32 (addr->as_u32);
192 BFD_ERR ("cannot find ip4 address, no usable address found");
197 bfd_udp_get_echo_src_ip6 (ip6_address_t * addr)
199 if (!bfd_udp_main.echo_source_is_set)
201 BFD_ERR ("cannot find ip6 address, echo source not set");
204 ip_interface_address_t *ia = NULL;
205 ip6_main_t *im = &ip6_main;
208 foreach_ip_interface_address (
209 &im->lookup_main, ia, bfd_udp_main.echo_source_sw_if_index,
210 0 /* honor unnumbered */, ({
212 ip_interface_address_get_address (&im->lookup_main, ia);
213 if (ia->address_length <= 127)
216 addr->as_u8[15] ^= 1; /* flip the last bit of the address */
221 BFD_ERR ("cannot find ip6 address, no usable address found");
226 bfd_udp_get_echo_source (int *is_set, u32 * sw_if_index,
227 int *have_usable_ip4, ip4_address_t * ip4,
228 int *have_usable_ip6, ip6_address_t * ip6)
230 if (bfd_udp_main.echo_source_is_set)
233 *sw_if_index = bfd_udp_main.echo_source_sw_if_index;
234 *have_usable_ip4 = bfd_udp_get_echo_src_ip4 (ip4);
235 *have_usable_ip6 = bfd_udp_get_echo_src_ip6 (ip6);
244 bfd_add_udp4_transport (vlib_main_t * vm, u32 bi, const bfd_session_t * bs,
247 const bfd_udp_session_t *bus = &bs->udp;
248 const bfd_udp_key_t *key = &bus->key;
249 vlib_buffer_t *b = vlib_get_buffer (vm, bi);
251 b->flags |= VNET_BUFFER_F_LOCALLY_ORIGINATED;
252 vnet_buffer (b)->ip.adj_index[VLIB_RX] = bus->adj_index;
253 vnet_buffer (b)->ip.adj_index[VLIB_TX] = bus->adj_index;
254 vnet_buffer (b)->sw_if_index[VLIB_RX] = 0;
255 vnet_buffer (b)->sw_if_index[VLIB_TX] = ~0;
261 ip4_udp_headers *headers = NULL;
262 vlib_buffer_advance (b, -sizeof (*headers));
263 headers = vlib_buffer_get_current (b);
264 clib_memset (headers, 0, sizeof (*headers));
265 headers->ip4.ip_version_and_header_length = 0x45;
266 headers->ip4.ttl = 255;
267 headers->ip4.protocol = IP_PROTOCOL_UDP;
268 headers->udp.src_port =
269 clib_host_to_net_u16 (bfd_udp_bs_idx_to_sport (bs->bs_idx));
273 if (!(rv = bfd_udp_get_echo_src_ip4 (&headers->ip4.src_address)))
277 headers->ip4.dst_address.as_u32 = key->local_addr.ip4.as_u32;
278 headers->udp.dst_port = clib_host_to_net_u16 (UDP_DST_PORT_bfd_echo4);
282 headers->ip4.src_address.as_u32 = key->local_addr.ip4.as_u32;
283 headers->ip4.dst_address.as_u32 = key->peer_addr.ip4.as_u32;
284 headers->udp.dst_port = clib_host_to_net_u16 (UDP_DST_PORT_bfd4);
287 /* fix ip length, checksum and udp length */
288 const u16 ip_length = vlib_buffer_length_in_chain (vm, b);
290 headers->ip4.length = clib_host_to_net_u16 (ip_length);
291 headers->ip4.checksum = ip4_header_checksum (&headers->ip4);
293 const u16 udp_length = ip_length - (sizeof (headers->ip4));
294 headers->udp.length = clib_host_to_net_u16 (udp_length);
299 bfd_add_udp6_transport (vlib_main_t * vm, u32 bi, const bfd_session_t * bs,
302 const bfd_udp_session_t *bus = &bs->udp;
303 const bfd_udp_key_t *key = &bus->key;
304 vlib_buffer_t *b = vlib_get_buffer (vm, bi);
306 b->flags |= VNET_BUFFER_F_LOCALLY_ORIGINATED;
307 vnet_buffer (b)->ip.adj_index[VLIB_RX] = bus->adj_index;
308 vnet_buffer (b)->ip.adj_index[VLIB_TX] = bus->adj_index;
309 vnet_buffer (b)->sw_if_index[VLIB_RX] = 0;
310 vnet_buffer (b)->sw_if_index[VLIB_TX] = 0;
316 ip6_udp_headers *headers = NULL;
317 vlib_buffer_advance (b, -sizeof (*headers));
318 headers = vlib_buffer_get_current (b);
319 clib_memset (headers, 0, sizeof (*headers));
320 headers->ip6.ip_version_traffic_class_and_flow_label =
321 clib_host_to_net_u32 (0x6 << 28);
322 headers->ip6.hop_limit = 255;
323 headers->ip6.protocol = IP_PROTOCOL_UDP;
324 headers->udp.src_port =
325 clib_host_to_net_u16 (bfd_udp_bs_idx_to_sport (bs->bs_idx));
329 if (!(rv = bfd_udp_get_echo_src_ip6 (&headers->ip6.src_address)))
333 clib_memcpy_fast (&headers->ip6.dst_address, &key->local_addr.ip6,
334 sizeof (headers->ip6.dst_address));
336 headers->udp.dst_port = clib_host_to_net_u16 (UDP_DST_PORT_bfd_echo6);
340 clib_memcpy_fast (&headers->ip6.src_address, &key->local_addr.ip6,
341 sizeof (headers->ip6.src_address));
342 clib_memcpy_fast (&headers->ip6.dst_address, &key->peer_addr.ip6,
343 sizeof (headers->ip6.dst_address));
344 headers->udp.dst_port = clib_host_to_net_u16 (UDP_DST_PORT_bfd6);
347 /* fix ip payload length and udp length */
348 const u16 udp_length =
349 vlib_buffer_length_in_chain (vm, b) - (sizeof (headers->ip6));
350 headers->udp.length = clib_host_to_net_u16 (udp_length);
351 headers->ip6.payload_length = headers->udp.length;
353 /* IPv6 UDP checksum is mandatory */
355 headers->udp.checksum =
356 ip6_tcp_udp_icmp_compute_checksum (vm, b, &headers->ip6, &bogus);
358 if (headers->udp.checksum == 0)
360 headers->udp.checksum = 0xffff;
366 bfd_create_frame_to_next_node (vlib_main_t * vm, u32 bi, u32 next_node)
368 vlib_frame_t *f = vlib_get_frame_to_node (vm, next_node);
369 u32 *to_next = vlib_frame_vector_args (f);
372 vlib_put_frame_to_node (vm, next_node, f);
376 bfd_udp_calc_next_node (const struct bfd_session_s *bs, u32 * next_node)
378 const bfd_udp_session_t *bus = &bs->udp;
379 ip_adjacency_t *adj = adj_get (bus->adj_index);
380 switch (adj->lookup_next_index)
382 case IP_LOOKUP_NEXT_ARP:
383 switch (bs->transport)
385 case BFD_TRANSPORT_UDP4:
386 *next_node = bfd_udp_main.ip4_arp_idx;
388 case BFD_TRANSPORT_UDP6:
389 *next_node = bfd_udp_main.ip6_ndp_idx;
393 case IP_LOOKUP_NEXT_REWRITE:
394 switch (bs->transport)
396 case BFD_TRANSPORT_UDP4:
397 *next_node = bfd_udp_main.ip4_rewrite_idx;
399 case BFD_TRANSPORT_UDP6:
400 *next_node = bfd_udp_main.ip6_rewrite_idx;
412 bfd_transport_udp4 (vlib_main_t * vm, u32 bi, const struct bfd_session_s *bs)
415 int rv = bfd_udp_calc_next_node (bs, &next_node);
418 bfd_create_frame_to_next_node (vm, bi, next_node);
424 bfd_transport_udp6 (vlib_main_t * vm, u32 bi, const struct bfd_session_s *bs)
427 int rv = bfd_udp_calc_next_node (bs, &next_node);
430 bfd_create_frame_to_next_node (vm, bi, next_node);
435 static bfd_session_t *
436 bfd_lookup_session (bfd_udp_main_t * bum, const bfd_udp_key_t * key)
438 uword *p = mhash_get (&bum->bfd_session_idx_by_bfd_key, key);
441 return bfd_find_session_by_idx (bum->bfd_main, *p);
447 bfd_udp_key_init (bfd_udp_key_t * key, u32 sw_if_index,
448 const ip46_address_t * local_addr,
449 const ip46_address_t * peer_addr)
451 clib_memset (key, 0, sizeof (*key));
452 key->sw_if_index = sw_if_index;
453 key->local_addr.as_u64[0] = local_addr->as_u64[0];
454 key->local_addr.as_u64[1] = local_addr->as_u64[1];
455 key->peer_addr.as_u64[0] = peer_addr->as_u64[0];
456 key->peer_addr.as_u64[1] = peer_addr->as_u64[1];
459 static vnet_api_error_t
460 bfd_udp_add_session_internal (bfd_udp_main_t * bum, u32 sw_if_index,
461 u32 desired_min_tx_usec,
462 u32 required_min_rx_usec, u8 detect_mult,
463 const ip46_address_t * local_addr,
464 const ip46_address_t * peer_addr,
465 bfd_session_t ** bs_out)
467 /* get a pool entry and if we end up not needing it, give it back */
468 bfd_transport_e t = BFD_TRANSPORT_UDP4;
469 if (!ip46_address_is_ip4 (local_addr))
471 t = BFD_TRANSPORT_UDP6;
473 bfd_session_t *bs = bfd_get_session (bum->bfd_main, t);
476 return VNET_API_ERROR_BFD_EAGAIN;
478 bfd_udp_session_t *bus = &bs->udp;
479 clib_memset (bus, 0, sizeof (*bus));
480 bfd_udp_key_t *key = &bus->key;
481 bfd_udp_key_init (key, sw_if_index, local_addr, peer_addr);
482 const bfd_session_t *tmp = bfd_lookup_session (bum, key);
485 vlib_log_err (bum->log_class,
486 "duplicate bfd-udp session, existing bs_idx=%d",
488 bfd_put_session (bum->bfd_main, bs);
489 return VNET_API_ERROR_BFD_EEXIST;
491 mhash_set (&bum->bfd_session_idx_by_bfd_key, key, bs->bs_idx, NULL);
492 BFD_DBG ("session created, bs_idx=%u, sw_if_index=%d, local=%U, peer=%U",
493 bs->bs_idx, key->sw_if_index, format_ip46_address,
494 &key->local_addr, IP46_TYPE_ANY, format_ip46_address,
495 &key->peer_addr, IP46_TYPE_ANY);
496 vlib_log_info (bum->log_class, "create BFD session: %U",
497 format_bfd_session, bs);
498 if (BFD_TRANSPORT_UDP4 == t)
500 bus->adj_index = adj_nbr_add_or_lock (FIB_PROTOCOL_IP4, VNET_LINK_IP4,
503 BFD_DBG ("adj_nbr_add_or_lock(FIB_PROTOCOL_IP4, VNET_LINK_IP4, %U, %d) "
504 "returns %d", format_ip46_address, &key->peer_addr,
505 IP46_TYPE_ANY, key->sw_if_index, bus->adj_index);
509 bus->adj_index = adj_nbr_add_or_lock (FIB_PROTOCOL_IP6, VNET_LINK_IP6,
512 BFD_DBG ("adj_nbr_add_or_lock(FIB_PROTOCOL_IP6, VNET_LINK_IP6, %U, %d) "
513 "returns %d", format_ip46_address, &key->peer_addr,
514 IP46_TYPE_ANY, key->sw_if_index, bus->adj_index);
517 return bfd_session_set_params (bum->bfd_main, bs, desired_min_tx_usec,
518 required_min_rx_usec, detect_mult);
521 static vnet_api_error_t
522 bfd_udp_validate_api_input (u32 sw_if_index,
523 const ip46_address_t * local_addr,
524 const ip46_address_t * peer_addr)
526 bfd_udp_main_t *bum = &bfd_udp_main;
527 vnet_sw_interface_t *sw_if =
528 vnet_get_sw_interface_safe (bfd_udp_main.vnet_main, sw_if_index);
529 u8 local_ip_valid = 0;
530 ip_interface_address_t *ia = NULL;
533 vlib_log_err (bum->log_class,
534 "got NULL sw_if when getting interface by index %u",
536 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
538 if (ip46_address_is_ip4 (local_addr))
540 if (!ip46_address_is_ip4 (peer_addr))
542 vlib_log_err (bum->log_class,
543 "IP family mismatch (local is ipv4, peer is ipv6)");
544 return VNET_API_ERROR_INVALID_ARGUMENT;
546 ip4_main_t *im = &ip4_main;
549 foreach_ip_interface_address (
550 &im->lookup_main, ia, sw_if_index, 0 /* honor unnumbered */, ({
552 ip_interface_address_get_address (&im->lookup_main, ia);
553 if (x->as_u32 == local_addr->ip4.as_u32)
555 /* valid address for this interface */
564 if (ip46_address_is_ip4 (peer_addr))
566 vlib_log_err (bum->log_class,
567 "IP family mismatch (local is ipv6, peer is ipv4)");
568 return VNET_API_ERROR_INVALID_ARGUMENT;
570 ip6_main_t *im = &ip6_main;
572 foreach_ip_interface_address (
573 &im->lookup_main, ia, sw_if_index, 0 /* honor unnumbered */, ({
575 ip_interface_address_get_address (&im->lookup_main, ia);
576 if (local_addr->ip6.as_u64[0] == x->as_u64[0] &&
577 local_addr->ip6.as_u64[1] == x->as_u64[1])
579 /* valid address for this interface */
589 vlib_log_err (bum->log_class,
590 "local address %U not found on interface with index %u",
591 format_ip46_address, local_addr, IP46_TYPE_ANY,
593 return VNET_API_ERROR_ADDRESS_NOT_FOUND_FOR_INTERFACE;
599 static vnet_api_error_t
600 bfd_udp_find_session_by_api_input (u32 sw_if_index,
601 const ip46_address_t * local_addr,
602 const ip46_address_t * peer_addr,
603 bfd_session_t ** bs_out)
605 vnet_api_error_t rv =
606 bfd_udp_validate_api_input (sw_if_index, local_addr, peer_addr);
609 bfd_udp_main_t *bum = &bfd_udp_main;
611 bfd_udp_key_init (&key, sw_if_index, local_addr, peer_addr);
612 bfd_session_t *bs = bfd_lookup_session (bum, &key);
619 vlib_log_err (bum->log_class,
620 "BFD session not found, sw_if_index=%u, local=%U, peer=%U",
621 sw_if_index, format_ip46_address, local_addr,
622 IP46_TYPE_ANY, format_ip46_address, peer_addr,
624 return VNET_API_ERROR_BFD_ENOENT;
630 static vnet_api_error_t
631 bfd_api_verify_common (u32 sw_if_index, u32 desired_min_tx_usec,
632 u32 required_min_rx_usec, u8 detect_mult,
633 const ip46_address_t * local_addr,
634 const ip46_address_t * peer_addr)
636 bfd_udp_main_t *bum = &bfd_udp_main;
637 vnet_api_error_t rv =
638 bfd_udp_validate_api_input (sw_if_index, local_addr, peer_addr);
645 vlib_log_err (bum->log_class, "detect_mult < 1");
646 return VNET_API_ERROR_INVALID_ARGUMENT;
648 if (desired_min_tx_usec < 1)
650 vlib_log_err (bum->log_class, "desired_min_tx_usec < 1");
651 return VNET_API_ERROR_INVALID_ARGUMENT;
657 bfd_udp_del_session_internal (bfd_session_t * bs)
659 bfd_udp_main_t *bum = &bfd_udp_main;
660 BFD_DBG ("free bfd-udp session, bs_idx=%d", bs->bs_idx);
661 mhash_unset (&bum->bfd_session_idx_by_bfd_key, &bs->udp.key, NULL);
662 adj_unlock (bs->udp.adj_index);
663 bfd_put_session (bum->bfd_main, bs);
667 bfd_udp_add_session (u32 sw_if_index, const ip46_address_t * local_addr,
668 const ip46_address_t * peer_addr,
669 u32 desired_min_tx_usec, u32 required_min_rx_usec,
670 u8 detect_mult, u8 is_authenticated, u32 conf_key_id,
673 bfd_main_t *bm = &bfd_main;
676 vnet_api_error_t rv =
677 bfd_api_verify_common (sw_if_index, desired_min_tx_usec,
678 required_min_rx_usec, detect_mult,
679 local_addr, peer_addr);
680 bfd_session_t *bs = NULL;
684 bfd_udp_add_session_internal (&bfd_udp_main, sw_if_index,
686 required_min_rx_usec, detect_mult,
687 local_addr, peer_addr, &bs);
689 if (!rv && is_authenticated)
692 rv = bfd_auth_activate (bs, conf_key_id, bfd_key_id,
693 0 /* is not delayed */ );
695 vlib_log_err (bfd_udp_main.log_class,
696 "SSL missing, cannot add authenticated BFD session");
697 rv = VNET_API_ERROR_BFD_NOTSUPP;
701 bfd_udp_del_session_internal (bs);
706 bfd_session_start (bfd_udp_main.bfd_main, bs);
714 bfd_udp_mod_session (u32 sw_if_index,
715 const ip46_address_t * local_addr,
716 const ip46_address_t * peer_addr,
717 u32 desired_min_tx_usec,
718 u32 required_min_rx_usec, u8 detect_mult)
720 bfd_session_t *bs = NULL;
721 bfd_main_t *bm = &bfd_main;
722 vnet_api_error_t error;
724 vnet_api_error_t rv =
725 bfd_udp_find_session_by_api_input (sw_if_index, local_addr, peer_addr,
733 error = bfd_session_set_params (bfd_udp_main.bfd_main, bs,
734 desired_min_tx_usec, required_min_rx_usec,
741 bfd_udp_del_session (u32 sw_if_index,
742 const ip46_address_t * local_addr,
743 const ip46_address_t * peer_addr)
745 bfd_session_t *bs = NULL;
746 bfd_main_t *bm = &bfd_main;
748 vnet_api_error_t rv =
749 bfd_udp_find_session_by_api_input (sw_if_index, local_addr, peer_addr,
756 bfd_udp_del_session_internal (bs);
762 bfd_udp_session_set_flags (u32 sw_if_index,
763 const ip46_address_t * local_addr,
764 const ip46_address_t * peer_addr, u8 admin_up_down)
766 bfd_session_t *bs = NULL;
767 bfd_main_t *bm = &bfd_main;
769 vnet_api_error_t rv =
770 bfd_udp_find_session_by_api_input (sw_if_index, local_addr, peer_addr,
777 bfd_session_set_flags (bs, admin_up_down);
783 bfd_udp_auth_activate (u32 sw_if_index,
784 const ip46_address_t * local_addr,
785 const ip46_address_t * peer_addr,
786 u32 conf_key_id, u8 key_id, u8 is_delayed)
788 bfd_main_t *bm = &bfd_main;
790 vnet_api_error_t error;
793 bfd_session_t *bs = NULL;
794 vnet_api_error_t rv =
795 bfd_udp_find_session_by_api_input (sw_if_index, local_addr, peer_addr,
802 error = bfd_auth_activate (bs, conf_key_id, key_id, is_delayed);
806 vlib_log_err (bfd_udp_main->log_class,
807 "SSL missing, cannot activate BFD authentication");
809 return VNET_API_ERROR_BFD_NOTSUPP;
814 bfd_udp_auth_deactivate (u32 sw_if_index,
815 const ip46_address_t * local_addr,
816 const ip46_address_t * peer_addr, u8 is_delayed)
818 bfd_main_t *bm = &bfd_main;
819 vnet_api_error_t error;
821 bfd_session_t *bs = NULL;
822 vnet_api_error_t rv =
823 bfd_udp_find_session_by_api_input (sw_if_index, local_addr, peer_addr,
830 error = bfd_auth_deactivate (bs, is_delayed);
837 BFD_UDP_INPUT_NEXT_NORMAL,
838 BFD_UDP_INPUT_NEXT_REPLY_ARP,
839 BFD_UDP_INPUT_NEXT_REPLY_REWRITE,
840 BFD_UDP_INPUT_N_NEXT,
841 } bfd_udp_input_next_t;
843 /* Packet counters - BFD control frames */
844 #define foreach_bfd_udp_error(F) \
845 F (NONE, "good bfd packets (processed)") \
846 F (BAD, "invalid bfd packets")
848 #define F(sym, string) static char BFD_UDP_ERR_##sym##_STR[] = string;
849 foreach_bfd_udp_error (F);
852 static char *bfd_udp_error_strings[] = {
853 #define F(sym, string) BFD_UDP_ERR_##sym##_STR,
854 foreach_bfd_udp_error (F)
860 #define F(sym, str) BFD_UDP_ERROR_##sym,
861 foreach_bfd_udp_error (F)
866 /* Packet counters - BFD ECHO packets */
867 #define foreach_bfd_udp_echo_error(F) \
868 F (NONE, "good bfd echo packets (processed)") \
869 F (BAD, "invalid bfd echo packets")
871 #define F(sym, string) static char BFD_UDP_ECHO_ERR_##sym##_STR[] = string;
872 foreach_bfd_udp_echo_error (F);
875 static char *bfd_udp_echo_error_strings[] = {
876 #define F(sym, string) BFD_UDP_ECHO_ERR_##sym##_STR,
877 foreach_bfd_udp_echo_error (F)
883 #define F(sym, str) BFD_UDP_ECHO_ERROR_##sym,
884 foreach_bfd_udp_echo_error (F)
886 BFD_UDP_ECHO_N_ERROR,
887 } bfd_udp_echo_error_t;
890 bfd_udp4_find_headers (vlib_buffer_t * b, ip4_header_t ** ip4,
893 /* sanity check first */
894 const i32 start = vnet_buffer (b)->l3_hdr_offset;
895 if (start < 0 && start < sizeof (b->pre_data))
897 BFD_ERR ("Start of ip header is before pre_data, ignoring");
902 *ip4 = (ip4_header_t *) (b->data + start);
903 if ((u8 *) * ip4 > (u8 *) vlib_buffer_get_current (b))
905 BFD_ERR ("Start of ip header is beyond current data, ignoring");
910 *udp = (udp_header_t *) ((*ip4) + 1);
913 static bfd_udp_error_t
914 bfd_udp4_verify_transport (const ip4_header_t * ip4,
915 const udp_header_t * udp, const bfd_session_t * bs)
917 const bfd_udp_session_t *bus = &bs->udp;
918 const bfd_udp_key_t *key = &bus->key;
919 if (ip4->src_address.as_u32 != key->peer_addr.ip4.as_u32)
921 BFD_ERR ("IPv4 src addr mismatch, got %U, expected %U",
922 format_ip4_address, ip4->src_address.as_u8, format_ip4_address,
923 key->peer_addr.ip4.as_u8);
924 return BFD_UDP_ERROR_BAD;
926 if (ip4->dst_address.as_u32 != key->local_addr.ip4.as_u32)
928 BFD_ERR ("IPv4 dst addr mismatch, got %U, expected %U",
929 format_ip4_address, ip4->dst_address.as_u8, format_ip4_address,
930 key->local_addr.ip4.as_u8);
931 return BFD_UDP_ERROR_BAD;
933 const u8 expected_ttl = 255;
934 if (ip4->ttl != expected_ttl)
936 BFD_ERR ("IPv4 unexpected TTL value %u, expected %u", ip4->ttl,
938 return BFD_UDP_ERROR_BAD;
940 if (clib_net_to_host_u16 (udp->src_port) < 49152)
942 BFD_ERR ("Invalid UDP src port %u, out of range <49152,65535>",
945 return BFD_UDP_ERROR_NONE;
955 bfd_rpc_update_session (u32 bs_idx, const bfd_pkt_t * pkt)
957 bfd_main_t *bm = &bfd_main;
959 bfd_consume_pkt (bm, pkt, bs_idx);
963 static bfd_udp_error_t
964 bfd_udp4_scan (vlib_main_t * vm, vlib_node_runtime_t * rt,
965 vlib_buffer_t * b, bfd_session_t ** bs_out)
967 const bfd_pkt_t *pkt = vlib_buffer_get_current (b);
968 if (sizeof (*pkt) > b->current_length)
971 ("Payload size %d too small to hold bfd packet of minimum size %d",
972 b->current_length, sizeof (*pkt));
973 return BFD_UDP_ERROR_BAD;
977 bfd_udp4_find_headers (b, &ip4, &udp);
980 BFD_ERR ("Couldn't find ip4 or udp header");
981 return BFD_UDP_ERROR_BAD;
983 const u32 udp_payload_length = udp->length - sizeof (*udp);
984 if (pkt->head.length > udp_payload_length)
987 ("BFD packet length is larger than udp payload length (%u > %u)",
988 pkt->head.length, udp_payload_length);
989 return BFD_UDP_ERROR_BAD;
991 if (!bfd_verify_pkt_common (pkt))
993 return BFD_UDP_ERROR_BAD;
995 bfd_session_t *bs = NULL;
998 BFD_DBG ("Looking up BFD session using discriminator %u",
1000 bs = bfd_find_session_by_disc (bfd_udp_main.bfd_main, pkt->your_disc);
1005 clib_memset (&key, 0, sizeof (key));
1006 key.sw_if_index = vnet_buffer (b)->sw_if_index[VLIB_RX];
1007 key.local_addr.ip4.as_u32 = ip4->dst_address.as_u32;
1008 key.peer_addr.ip4.as_u32 = ip4->src_address.as_u32;
1009 BFD_DBG ("Looking up BFD session using key (sw_if_index=%u, local=%U, "
1011 key.sw_if_index, format_ip4_address, key.local_addr.ip4.as_u8,
1012 format_ip4_address, key.peer_addr.ip4.as_u8);
1013 bs = bfd_lookup_session (&bfd_udp_main, &key);
1017 BFD_ERR ("BFD session lookup failed - no session matches BFD pkt");
1018 return BFD_UDP_ERROR_BAD;
1020 BFD_DBG ("BFD session found, bs_idx=%u", bs->bs_idx);
1021 if (!bfd_verify_pkt_auth (pkt, b->current_length, bs))
1023 BFD_ERR ("Packet verification failed, dropping packet");
1024 return BFD_UDP_ERROR_BAD;
1026 bfd_udp_error_t err;
1027 if (BFD_UDP_ERROR_NONE != (err = bfd_udp4_verify_transport (ip4, udp, bs)))
1031 bfd_rpc_update_session (bs->bs_idx, pkt);
1033 return BFD_UDP_ERROR_NONE;
1037 bfd_udp6_find_headers (vlib_buffer_t * b, ip6_header_t ** ip6,
1038 udp_header_t ** udp)
1040 /* sanity check first */
1041 const i32 start = vnet_buffer (b)->l3_hdr_offset;
1042 if (start < 0 && start < sizeof (b->pre_data))
1044 BFD_ERR ("Start of ip header is before pre_data, ignoring");
1049 *ip6 = (ip6_header_t *) (b->data + start);
1050 if ((u8 *) * ip6 > (u8 *) vlib_buffer_get_current (b))
1052 BFD_ERR ("Start of ip header is beyond current data, ignoring");
1057 if ((*ip6)->protocol != IP_PROTOCOL_UDP)
1059 BFD_ERR ("Unexpected protocol in IPv6 header '%u', expected '%u' (== "
1060 "IP_PROTOCOL_UDP)", (*ip6)->protocol, IP_PROTOCOL_UDP);
1065 *udp = (udp_header_t *) ((*ip6) + 1);
1068 static bfd_udp_error_t
1069 bfd_udp6_verify_transport (const ip6_header_t * ip6,
1070 const udp_header_t * udp, const bfd_session_t * bs)
1072 const bfd_udp_session_t *bus = &bs->udp;
1073 const bfd_udp_key_t *key = &bus->key;
1074 if (ip6->src_address.as_u64[0] != key->peer_addr.ip6.as_u64[0] &&
1075 ip6->src_address.as_u64[1] != key->peer_addr.ip6.as_u64[1])
1077 BFD_ERR ("IP src addr mismatch, got %U, expected %U",
1078 format_ip6_address, ip6, format_ip6_address,
1079 &key->peer_addr.ip6);
1080 return BFD_UDP_ERROR_BAD;
1082 if (ip6->dst_address.as_u64[0] != key->local_addr.ip6.as_u64[0] &&
1083 ip6->dst_address.as_u64[1] != key->local_addr.ip6.as_u64[1])
1085 BFD_ERR ("IP dst addr mismatch, got %U, expected %U",
1086 format_ip6_address, ip6, format_ip6_address,
1087 &key->local_addr.ip6);
1088 return BFD_UDP_ERROR_BAD;
1090 const u8 expected_hop_limit = 255;
1091 if (ip6->hop_limit != expected_hop_limit)
1093 BFD_ERR ("IPv6 unexpected hop-limit value %u, expected %u",
1094 ip6->hop_limit, expected_hop_limit);
1095 return BFD_UDP_ERROR_BAD;
1097 if (clib_net_to_host_u16 (udp->src_port) < 49152)
1099 BFD_ERR ("Invalid UDP src port %u, out of range <49152,65535>",
1102 return BFD_UDP_ERROR_NONE;
1105 static bfd_udp_error_t
1106 bfd_udp6_scan (vlib_main_t * vm, vlib_node_runtime_t * rt,
1107 vlib_buffer_t * b, bfd_session_t ** bs_out)
1109 const bfd_pkt_t *pkt = vlib_buffer_get_current (b);
1110 if (sizeof (*pkt) > b->current_length)
1113 ("Payload size %d too small to hold bfd packet of minimum size %d",
1114 b->current_length, sizeof (*pkt));
1115 return BFD_UDP_ERROR_BAD;
1119 bfd_udp6_find_headers (b, &ip6, &udp);
1122 BFD_ERR ("Couldn't find ip6 or udp header");
1123 return BFD_UDP_ERROR_BAD;
1125 const u32 udp_payload_length = udp->length - sizeof (*udp);
1126 if (pkt->head.length > udp_payload_length)
1129 ("BFD packet length is larger than udp payload length (%u > %u)",
1130 pkt->head.length, udp_payload_length);
1131 return BFD_UDP_ERROR_BAD;
1133 if (!bfd_verify_pkt_common (pkt))
1135 return BFD_UDP_ERROR_BAD;
1137 bfd_session_t *bs = NULL;
1140 BFD_DBG ("Looking up BFD session using discriminator %u",
1142 bs = bfd_find_session_by_disc (bfd_udp_main.bfd_main, pkt->your_disc);
1147 clib_memset (&key, 0, sizeof (key));
1148 key.sw_if_index = vnet_buffer (b)->sw_if_index[VLIB_RX];
1149 key.local_addr.ip6.as_u64[0] = ip6->dst_address.as_u64[0];
1150 key.local_addr.ip6.as_u64[1] = ip6->dst_address.as_u64[1];
1151 key.peer_addr.ip6.as_u64[0] = ip6->src_address.as_u64[0];
1152 key.peer_addr.ip6.as_u64[1] = ip6->src_address.as_u64[1];
1153 BFD_DBG ("Looking up BFD session using key (sw_if_index=%u, local=%U, "
1155 key.sw_if_index, format_ip6_address, &key.local_addr,
1156 format_ip6_address, &key.peer_addr);
1157 bs = bfd_lookup_session (&bfd_udp_main, &key);
1161 BFD_ERR ("BFD session lookup failed - no session matches BFD pkt");
1162 return BFD_UDP_ERROR_BAD;
1164 BFD_DBG ("BFD session found, bs_idx=%u", bs->bs_idx);
1165 if (!bfd_verify_pkt_auth (pkt, b->current_length, bs))
1167 BFD_ERR ("Packet verification failed, dropping packet");
1168 return BFD_UDP_ERROR_BAD;
1170 bfd_udp_error_t err;
1171 if (BFD_UDP_ERROR_NONE != (err = bfd_udp6_verify_transport (ip6, udp, bs)))
1175 bfd_rpc_update_session (bs->bs_idx, pkt);
1177 return BFD_UDP_ERROR_NONE;
1181 * Process a frame of bfd packets
1182 * Expect 1 packet / frame
1185 bfd_udp_input (vlib_main_t * vm, vlib_node_runtime_t * rt,
1186 vlib_frame_t * f, int is_ipv6)
1188 u32 n_left_from, *from;
1189 bfd_input_trace_t *t0;
1190 bfd_main_t *bm = &bfd_main;
1192 from = vlib_frame_vector_args (f); /* array of buffer indices */
1193 n_left_from = f->n_vectors; /* number of buffer indices */
1195 while (n_left_from > 0)
1202 b0 = vlib_get_buffer (vm, bi0);
1204 bfd_session_t *bs = NULL;
1206 /* If this pkt is traced, snapshot the data */
1207 if (b0->flags & VLIB_BUFFER_IS_TRACED)
1210 t0 = vlib_add_trace (vm, rt, b0, sizeof (*t0));
1211 len = (b0->current_length < sizeof (t0->data)) ? b0->current_length
1212 : sizeof (t0->data);
1214 clib_memcpy_fast (t0->data, vlib_buffer_get_current (b0), len);
1217 /* scan this bfd pkt. error0 is the counter index to bmp */
1221 error0 = bfd_udp6_scan (vm, rt, b0, &bs);
1225 error0 = bfd_udp4_scan (vm, rt, b0, &bs);
1227 b0->error = rt->errors[error0];
1229 next0 = BFD_UDP_INPUT_NEXT_NORMAL;
1230 if (BFD_UDP_ERROR_NONE == error0)
1233 * if everything went fine, check for poll bit, if present, re-use
1234 * the buffer and based on (now updated) session parameters, send
1235 * the final packet back
1237 const bfd_pkt_t *pkt = vlib_buffer_get_current (b0);
1238 if (bfd_pkt_get_poll (pkt))
1240 b0->current_data = 0;
1241 b0->current_length = 0;
1242 bfd_init_final_control_frame (vm, b0, bfd_udp_main.bfd_main, bs,
1246 vlib_node_increment_counter (vm, bfd_udp6_input_node.index,
1251 vlib_node_increment_counter (vm, bfd_udp4_input_node.index,
1254 const bfd_udp_session_t *bus = &bs->udp;
1255 ip_adjacency_t *adj = adj_get (bus->adj_index);
1256 switch (adj->lookup_next_index)
1258 case IP_LOOKUP_NEXT_ARP:
1259 next0 = BFD_UDP_INPUT_NEXT_REPLY_ARP;
1261 case IP_LOOKUP_NEXT_REWRITE:
1262 next0 = BFD_UDP_INPUT_NEXT_REPLY_REWRITE;
1271 vlib_set_next_frame_buffer (vm, rt, next0, bi0);
1277 return f->n_vectors;
1281 bfd_udp4_input (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f)
1283 return bfd_udp_input (vm, rt, f, 0);
1287 * bfd input graph node declaration
1290 VLIB_REGISTER_NODE (bfd_udp4_input_node, static) = {
1291 .function = bfd_udp4_input,
1292 .name = "bfd-udp4-input",
1293 .vector_size = sizeof (u32),
1294 .type = VLIB_NODE_TYPE_INTERNAL,
1296 .n_errors = BFD_UDP_N_ERROR,
1297 .error_strings = bfd_udp_error_strings,
1299 .format_trace = bfd_input_format_trace,
1301 .n_next_nodes = BFD_UDP_INPUT_N_NEXT,
1304 [BFD_UDP_INPUT_NEXT_NORMAL] = "error-drop",
1305 [BFD_UDP_INPUT_NEXT_REPLY_ARP] = "ip4-arp",
1306 [BFD_UDP_INPUT_NEXT_REPLY_REWRITE] = "ip4-lookup",
1312 bfd_udp6_input (vlib_main_t * vm, vlib_node_runtime_t * rt, vlib_frame_t * f)
1314 return bfd_udp_input (vm, rt, f, 1);
1318 VLIB_REGISTER_NODE (bfd_udp6_input_node, static) = {
1319 .function = bfd_udp6_input,
1320 .name = "bfd-udp6-input",
1321 .vector_size = sizeof (u32),
1322 .type = VLIB_NODE_TYPE_INTERNAL,
1324 .n_errors = BFD_UDP_N_ERROR,
1325 .error_strings = bfd_udp_error_strings,
1327 .format_trace = bfd_input_format_trace,
1329 .n_next_nodes = BFD_UDP_INPUT_N_NEXT,
1332 [BFD_UDP_INPUT_NEXT_NORMAL] = "error-drop",
1333 [BFD_UDP_INPUT_NEXT_REPLY_ARP] = "ip6-discover-neighbor",
1334 [BFD_UDP_INPUT_NEXT_REPLY_REWRITE] = "ip6-lookup",
1340 * Process a frame of bfd echo packets
1341 * Expect 1 packet / frame
1344 bfd_udp_echo_input (vlib_main_t * vm, vlib_node_runtime_t * rt,
1345 vlib_frame_t * f, int is_ipv6)
1347 u32 n_left_from, *from;
1348 bfd_input_trace_t *t0;
1349 bfd_main_t *bm = &bfd_main;
1351 from = vlib_frame_vector_args (f); /* array of buffer indices */
1352 n_left_from = f->n_vectors; /* number of buffer indices */
1354 while (n_left_from > 0)
1361 b0 = vlib_get_buffer (vm, bi0);
1363 /* If this pkt is traced, snapshot the data */
1364 if (b0->flags & VLIB_BUFFER_IS_TRACED)
1367 t0 = vlib_add_trace (vm, rt, b0, sizeof (*t0));
1368 len = (b0->current_length < sizeof (t0->data)) ? b0->current_length
1369 : sizeof (t0->data);
1371 clib_memcpy_fast (t0->data, vlib_buffer_get_current (b0), len);
1375 if (bfd_consume_echo_pkt (bfd_udp_main.bfd_main, b0))
1377 b0->error = rt->errors[BFD_UDP_ERROR_NONE];
1378 next0 = BFD_UDP_INPUT_NEXT_NORMAL;
1382 /* loop back the packet */
1383 b0->error = rt->errors[BFD_UDP_ERROR_NONE];
1386 vlib_node_increment_counter (vm, bfd_udp_echo6_input_node.index,
1391 vlib_node_increment_counter (vm, bfd_udp_echo4_input_node.index,
1394 next0 = BFD_UDP_INPUT_NEXT_REPLY_REWRITE;
1398 vlib_set_next_frame_buffer (vm, rt, next0, bi0);
1404 return f->n_vectors;
1408 bfd_udp_echo4_input (vlib_main_t * vm, vlib_node_runtime_t * rt,
1411 return bfd_udp_echo_input (vm, rt, f, 0);
1415 bfd_echo_input_format_trace (u8 * s, va_list * args)
1417 CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
1418 CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
1419 const bfd_udp_echo_input_trace_t *t =
1420 va_arg (*args, bfd_udp_echo_input_trace_t *);
1421 if (t->len > STRUCT_SIZE_OF (bfd_pkt_t, head))
1423 s = format (s, "BFD ECHO:\n");
1424 s = format (s, " data: %U", format_hexdump, t->data, t->len);
1431 * bfd input graph node declaration
1434 VLIB_REGISTER_NODE (bfd_udp_echo4_input_node, static) = {
1435 .function = bfd_udp_echo4_input,
1436 .name = "bfd-udp-echo4-input",
1437 .vector_size = sizeof (u32),
1438 .type = VLIB_NODE_TYPE_INTERNAL,
1440 .n_errors = BFD_UDP_ECHO_N_ERROR,
1441 .error_strings = bfd_udp_error_strings,
1443 .format_trace = bfd_echo_input_format_trace,
1445 .n_next_nodes = BFD_UDP_INPUT_N_NEXT,
1448 [BFD_UDP_INPUT_NEXT_NORMAL] = "error-drop",
1449 [BFD_UDP_INPUT_NEXT_REPLY_ARP] = "ip4-arp",
1450 [BFD_UDP_INPUT_NEXT_REPLY_REWRITE] = "ip4-lookup",
1456 bfd_udp_echo6_input (vlib_main_t * vm, vlib_node_runtime_t * rt,
1459 return bfd_udp_echo_input (vm, rt, f, 1);
1463 VLIB_REGISTER_NODE (bfd_udp_echo6_input_node, static) = {
1464 .function = bfd_udp_echo6_input,
1465 .name = "bfd-udp-echo6-input",
1466 .vector_size = sizeof (u32),
1467 .type = VLIB_NODE_TYPE_INTERNAL,
1469 .n_errors = BFD_UDP_ECHO_N_ERROR,
1470 .error_strings = bfd_udp_echo_error_strings,
1472 .format_trace = bfd_echo_input_format_trace,
1474 .n_next_nodes = BFD_UDP_INPUT_N_NEXT,
1477 [BFD_UDP_INPUT_NEXT_NORMAL] = "error-drop",
1478 [BFD_UDP_INPUT_NEXT_REPLY_ARP] = "ip6-discover-neighbor",
1479 [BFD_UDP_INPUT_NEXT_REPLY_REWRITE] = "ip6-lookup",
1485 static clib_error_t *
1486 bfd_udp_sw_if_add_del (vnet_main_t * vnm, u32 sw_if_index, u32 is_create)
1488 bfd_session_t **to_be_freed = NULL;
1489 bfd_udp_main_t *bum = &bfd_udp_main;
1490 BFD_DBG ("sw_if_add_del called, sw_if_index=%u, is_create=%u", sw_if_index,
1495 pool_foreach (bs, bfd_udp_main.bfd_main->sessions,
1497 if (bs->transport != BFD_TRANSPORT_UDP4 &&
1498 bs->transport != BFD_TRANSPORT_UDP6)
1501 if (bs->udp.key.sw_if_index != sw_if_index)
1504 vec_add1 (to_be_freed, bs);}
1508 vec_foreach (bs, to_be_freed)
1510 vlib_log_notice (bum->log_class,
1511 "removal of sw_if_index=%u forces removal of bfd session "
1512 "with bs_idx=%u", sw_if_index, (*bs)->bs_idx);
1513 bfd_session_set_flags (*bs, 0);
1514 bfd_udp_del_session_internal (*bs);
1519 VNET_SW_INTERFACE_ADD_DEL_FUNCTION (bfd_udp_sw_if_add_del);
1524 static clib_error_t *
1525 bfd_udp_init (vlib_main_t * vm)
1527 mhash_init (&bfd_udp_main.bfd_session_idx_by_bfd_key, sizeof (uword),
1528 sizeof (bfd_udp_key_t));
1529 bfd_udp_main.bfd_main = &bfd_main;
1530 bfd_udp_main.vnet_main = vnet_get_main ();
1531 udp_register_dst_port (vm, UDP_DST_PORT_bfd4, bfd_udp4_input_node.index, 1);
1532 udp_register_dst_port (vm, UDP_DST_PORT_bfd6, bfd_udp6_input_node.index, 0);
1533 udp_register_dst_port (vm, UDP_DST_PORT_bfd_echo4,
1534 bfd_udp_echo4_input_node.index, 1);
1535 udp_register_dst_port (vm, UDP_DST_PORT_bfd_echo6,
1536 bfd_udp_echo6_input_node.index, 0);
1537 vlib_node_t *node = vlib_get_node_by_name (vm, (u8 *) "ip4-arp");
1539 bfd_udp_main.ip4_arp_idx = node->index;
1540 node = vlib_get_node_by_name (vm, (u8 *) "ip6-discover-neighbor");
1542 bfd_udp_main.ip6_ndp_idx = node->index;
1543 node = vlib_get_node_by_name (vm, (u8 *) "ip4-rewrite");
1545 bfd_udp_main.ip4_rewrite_idx = node->index;
1546 node = vlib_get_node_by_name (vm, (u8 *) "ip6-rewrite");
1548 bfd_udp_main.ip6_rewrite_idx = node->index;
1550 bfd_udp_main.log_class = vlib_log_register_class ("bfd", "udp");
1551 vlib_log_debug (bfd_udp_main.log_class, "initialized");
1555 VLIB_INIT_FUNCTION (bfd_udp_init);
1558 * fd.io coding-style-patch-verification: ON
1561 * eval: (c-set-style "gnu")