2 * Copyright (c) 2015 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.
16 * ip/ip_lookup.c: ip4/6 adjacency and lookup table managment
18 * Copyright (c) 2008 Eliot Dresselhaus
20 * Permission is hereby granted, free of charge, to any person obtaining
21 * a copy of this software and associated documentation files (the
22 * "Software"), to deal in the Software without restriction, including
23 * without limitation the rights to use, copy, modify, merge, publish,
24 * distribute, sublicense, and/or sell copies of the Software, and to
25 * permit persons to whom the Software is furnished to do so, subject to
26 * the following conditions:
28 * The above copyright notice and this permission notice shall be
29 * included in all copies or substantial portions of the Software.
31 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
32 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
33 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
34 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
35 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
36 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
37 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
40 #include <vnet/ip/ip.h>
41 #include <vnet/adj/adj_alloc.h>
42 #include <vnet/fib/fib_table.h>
43 #include <vnet/fib/ip4_fib.h>
44 #include <vnet/fib/ip6_fib.h>
45 #include <vnet/mpls/mpls.h>
46 #include <vnet/dpo/drop_dpo.h>
47 #include <vnet/dpo/classify_dpo.h>
48 #include <vnet/dpo/punt_dpo.h>
49 #include <vnet/dpo/receive_dpo.h>
52 ip_interface_address_add_del (ip_lookup_main_t * lm,
57 u32 * result_if_address_index)
59 vnet_main_t * vnm = vnet_get_main();
60 ip_interface_address_t * a, * prev, * next;
61 uword * p = mhash_get (&lm->address_to_if_address_index, addr_fib);
63 vec_validate_init_empty (lm->if_address_pool_index_by_sw_if_index, sw_if_index, ~0);
64 a = p ? pool_elt_at_index (lm->if_address_pool, p[0]) : 0;
66 /* Verify given length. */
67 if ((a && (address_length != a->address_length)) || (address_length == 0))
69 vnm->api_errno = VNET_API_ERROR_ADDRESS_LENGTH_MISMATCH;
70 return clib_error_create
71 ( "%U wrong length (expected %d) for interface %U",
72 lm->format_address_and_length, addr_fib,
73 address_length, a? a->address_length : -1,
74 format_vnet_sw_if_index_name, vnm, sw_if_index);
81 vnet_sw_interface_t * si = vnet_get_sw_interface (vnm, sw_if_index);
82 vnm->api_errno = VNET_API_ERROR_ADDRESS_NOT_FOUND_FOR_INTERFACE;
83 return clib_error_create ("%U not found for interface %U",
84 lm->format_address_and_length,
85 addr_fib, address_length,
86 format_vnet_sw_interface_name, vnm, si);
89 if (a->prev_this_sw_interface != ~0)
91 prev = pool_elt_at_index (lm->if_address_pool, a->prev_this_sw_interface);
92 prev->next_this_sw_interface = a->next_this_sw_interface;
94 if (a->next_this_sw_interface != ~0)
96 next = pool_elt_at_index (lm->if_address_pool, a->next_this_sw_interface);
97 next->prev_this_sw_interface = a->prev_this_sw_interface;
99 if(a->prev_this_sw_interface == ~0)
100 lm->if_address_pool_index_by_sw_if_index[sw_if_index] = a->next_this_sw_interface;
103 if ((a->next_this_sw_interface == ~0) && (a->prev_this_sw_interface == ~0))
104 lm->if_address_pool_index_by_sw_if_index[sw_if_index] = ~0;
106 mhash_unset (&lm->address_to_if_address_index, addr_fib,
108 pool_put (lm->if_address_pool, a);
110 if (result_if_address_index)
111 *result_if_address_index = ~0;
116 u32 pi; /* previous index */
118 u32 hi; /* head index */
120 pool_get (lm->if_address_pool, a);
121 memset (a, ~0, sizeof (a[0]));
122 ai = a - lm->if_address_pool;
124 hi = pi = lm->if_address_pool_index_by_sw_if_index[sw_if_index];
126 while (pi != (u32)~0)
128 prev = pool_elt_at_index(lm->if_address_pool, pi);
129 pi = prev->next_this_sw_interface;
131 pi = prev ? prev - lm->if_address_pool : (u32)~0;
133 a->address_key = mhash_set (&lm->address_to_if_address_index,
134 addr_fib, ai, /* old_value */ 0);
135 a->address_length = address_length;
136 a->sw_if_index = sw_if_index;
138 a->prev_this_sw_interface = pi;
139 a->next_this_sw_interface = ~0;
141 prev->next_this_sw_interface = ai;
143 lm->if_address_pool_index_by_sw_if_index[sw_if_index] =
144 (hi != ~0) ? hi : ai;
145 if (result_if_address_index)
146 *result_if_address_index = ai;
150 if (result_if_address_index)
151 *result_if_address_index = a - lm->if_address_pool;
155 return /* no error */ 0;
158 void ip_lookup_init (ip_lookup_main_t * lm, u32 is_ip6)
160 /* ensure that adjacency is cacheline aligned and sized */
161 ASSERT(STRUCT_OFFSET_OF(ip_adjacency_t, cacheline0) == 0);
162 ASSERT(STRUCT_OFFSET_OF(ip_adjacency_t, cacheline1) == CLIB_CACHE_LINE_BYTES);
164 /* Preallocate three "special" adjacencies */
165 lm->adjacency_heap = adj_heap;
167 if (! lm->fib_result_n_bytes)
168 lm->fib_result_n_bytes = sizeof (uword);
173 lm->format_address_and_length = format_ip6_address_and_length;
174 mhash_init (&lm->address_to_if_address_index, sizeof (uword),
175 sizeof (ip6_address_fib_t));
179 lm->format_address_and_length = format_ip4_address_and_length;
180 mhash_init (&lm->address_to_if_address_index, sizeof (uword),
181 sizeof (ip4_address_fib_t));
187 /* Setup all IP protocols to be punted and builtin-unknown. */
188 for (i = 0; i < 256; i++)
190 lm->local_next_by_ip_protocol[i] = IP_LOCAL_NEXT_PUNT;
191 lm->builtin_protocol_by_ip_protocol[i] = IP_BUILTIN_PROTOCOL_UNKNOWN;
194 lm->local_next_by_ip_protocol[IP_PROTOCOL_UDP] = IP_LOCAL_NEXT_UDP_LOOKUP;
195 lm->local_next_by_ip_protocol[is_ip6 ? IP_PROTOCOL_ICMP6 : IP_PROTOCOL_ICMP] = IP_LOCAL_NEXT_ICMP;
196 lm->builtin_protocol_by_ip_protocol[IP_PROTOCOL_UDP] = IP_BUILTIN_PROTOCOL_UDP;
197 lm->builtin_protocol_by_ip_protocol[is_ip6 ? IP_PROTOCOL_ICMP6 : IP_PROTOCOL_ICMP] = IP_BUILTIN_PROTOCOL_ICMP;
201 u8 * format_ip_flow_hash_config (u8 * s, va_list * args)
203 flow_hash_config_t flow_hash_config = va_arg (*args, u32);
205 #define _(n,v) if (flow_hash_config & v) s = format (s, "%s ", #n);
206 foreach_flow_hash_bit;
212 u8 * format_ip_lookup_next (u8 * s, va_list * args)
214 ip_lookup_next_t n = va_arg (*args, ip_lookup_next_t);
220 s = format (s, "unknown %d", n);
223 case IP_LOOKUP_NEXT_DROP: t = "drop"; break;
224 case IP_LOOKUP_NEXT_PUNT: t = "punt"; break;
225 case IP_LOOKUP_NEXT_ARP: t = "arp"; break;
226 case IP_LOOKUP_NEXT_MIDCHAIN: t="midchain"; break;
227 case IP_LOOKUP_NEXT_GLEAN: t="glean"; break;
228 case IP_LOOKUP_NEXT_REWRITE:
233 vec_add (s, t, strlen (t));
238 u8 * format_ip_adjacency_packet_data (u8 * s, va_list * args)
240 vnet_main_t * vnm = va_arg (*args, vnet_main_t *);
241 u32 adj_index = va_arg (*args, u32);
242 u8 * packet_data = va_arg (*args, u8 *);
243 u32 n_packet_data_bytes = va_arg (*args, u32);
244 ip_adjacency_t * adj = adj_get(adj_index);
246 switch (adj->lookup_next_index)
248 case IP_LOOKUP_NEXT_REWRITE:
250 format_vnet_rewrite_header,
251 vnm->vlib_main, &adj->rewrite_header, packet_data, n_packet_data_bytes);
261 static uword unformat_dpo (unformat_input_t * input, va_list * args)
263 dpo_id_t *dpo = va_arg (*args, dpo_id_t *);
264 fib_protocol_t fp = va_arg (*args, int);
267 proto = fib_proto_to_dpo(fp);
269 if (unformat (input, "drop"))
270 dpo_copy(dpo, drop_dpo_get(proto));
271 else if (unformat (input, "punt"))
272 dpo_copy(dpo, punt_dpo_get(proto));
273 else if (unformat (input, "local"))
274 receive_dpo_add_or_lock(proto, ~0, NULL, dpo);
275 else if (unformat (input, "classify"))
277 u32 classify_table_index;
279 if (!unformat (input, "%d", &classify_table_index))
281 clib_warning ("classify adj must specify table index");
285 dpo_set(dpo, DPO_CLASSIFY, proto,
286 classify_dpo_create(fp, classify_table_index));
294 const ip46_address_t zero_addr = {
301 fib_table_id_find_fib_index (fib_protocol_t proto,
304 ip4_main_t *im4 = &ip4_main;
305 ip6_main_t *im6 = &ip6_main;
310 case FIB_PROTOCOL_IP4:
311 p = hash_get(im4->fib_index_by_table_id, table_id);
313 case FIB_PROTOCOL_IP6:
314 p = hash_get(im6->fib_index_by_table_id, table_id);
328 vnet_ip_route_cmd (vlib_main_t * vm,
329 unformat_input_t * main_input,
330 vlib_cli_command_t * cmd)
332 unformat_input_t _line_input, * line_input = &_line_input;
333 fib_route_path_t *rpaths = NULL, rpath;
334 dpo_id_t dpo = DPO_NULL, *dpos = NULL;
335 fib_prefix_t *prefixs = NULL, pfx;
336 clib_error_t * error = NULL;
337 mpls_label_t out_label;
338 u32 table_id, is_del;
344 vnm = vnet_get_main();
349 /* Get a line of input. */
350 if (! unformat_user (main_input, unformat_line_input, line_input))
353 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
355 memset(&rpath, 0, sizeof(rpath));
356 memset(&pfx, 0, sizeof(pfx));
358 if (unformat (line_input, "table %d", &table_id))
360 else if (unformat (line_input, "del"))
362 else if (unformat (line_input, "add"))
364 else if (unformat (line_input, "resolve-via-host"))
366 if (vec_len(rpaths) == 0)
368 error = clib_error_return(0 , "Paths then flags");
371 rpaths[vec_len(rpaths)-1].frp_flags |= FIB_ROUTE_PATH_RESOLVE_VIA_HOST;
373 else if (unformat (line_input, "resolve-via-attached"))
375 if (vec_len(rpaths) == 0)
377 error = clib_error_return(0 , "Paths then flags");
380 rpaths[vec_len(rpaths)-1].frp_flags |=
381 FIB_ROUTE_PATH_RESOLVE_VIA_ATTACHED;
383 else if (unformat (line_input, "out-label %U",
384 unformat_mpls_unicast_label, &out_label))
386 if (vec_len(rpaths) == 0)
388 error = clib_error_return(0 , "Paths then labels");
391 rpaths[vec_len(rpaths)-1].frp_label = out_label;
393 else if (unformat (line_input, "count %f", &count))
396 else if (unformat (line_input, "%U/%d",
397 unformat_ip4_address,
401 pfx.fp_proto = FIB_PROTOCOL_IP4;
402 vec_add1(prefixs, pfx);
404 else if (unformat (line_input, "%U/%d",
405 unformat_ip6_address,
409 pfx.fp_proto = FIB_PROTOCOL_IP6;
410 vec_add1(prefixs, pfx);
412 else if (unformat (line_input, "via %U %U weight %u",
413 unformat_ip4_address,
415 unformat_vnet_sw_interface, vnm,
416 &rpath.frp_sw_if_index,
419 rpath.frp_label = MPLS_LABEL_INVALID;
420 rpath.frp_proto = FIB_PROTOCOL_IP4;
421 vec_add1(rpaths, rpath);
424 else if (unformat (line_input, "via %U %U weight %u",
425 unformat_ip6_address,
427 unformat_vnet_sw_interface, vnm,
428 &rpath.frp_sw_if_index,
431 rpath.frp_label = MPLS_LABEL_INVALID;
432 rpath.frp_proto = FIB_PROTOCOL_IP6;
433 vec_add1(rpaths, rpath);
436 else if (unformat (line_input, "via %U %U",
437 unformat_ip4_address,
439 unformat_vnet_sw_interface, vnm,
440 &rpath.frp_sw_if_index))
442 rpath.frp_label = MPLS_LABEL_INVALID;
443 rpath.frp_weight = 1;
444 rpath.frp_proto = FIB_PROTOCOL_IP4;
445 vec_add1(rpaths, rpath);
448 else if (unformat (line_input, "via %U %U",
449 unformat_ip6_address,
451 unformat_vnet_sw_interface, vnm,
452 &rpath.frp_sw_if_index))
454 rpath.frp_label = MPLS_LABEL_INVALID;
455 rpath.frp_weight = 1;
456 rpath.frp_proto = FIB_PROTOCOL_IP6;
457 vec_add1(rpaths, rpath);
459 else if (unformat (line_input, "via %U next-hop-table %d",
460 unformat_ip4_address,
462 &rpath.frp_fib_index))
464 rpath.frp_weight = 1;
465 rpath.frp_sw_if_index = ~0;
466 rpath.frp_label = MPLS_LABEL_INVALID;
467 rpath.frp_proto = FIB_PROTOCOL_IP4;
468 vec_add1(rpaths, rpath);
470 else if (unformat (line_input, "via %U next-hop-table %d",
471 unformat_ip6_address,
473 &rpath.frp_fib_index))
475 rpath.frp_weight = 1;
476 rpath.frp_sw_if_index = ~0;
477 rpath.frp_label = MPLS_LABEL_INVALID;
478 rpath.frp_proto = FIB_PROTOCOL_IP6;
479 vec_add1(rpaths, rpath);
481 else if (unformat (line_input, "via %U",
482 unformat_ip4_address,
483 &rpath.frp_addr.ip4))
486 * the recursive next-hops are by default in the same table
489 rpath.frp_fib_index = table_id;
490 rpath.frp_weight = 1;
491 rpath.frp_sw_if_index = ~0;
492 rpath.frp_label = MPLS_LABEL_INVALID;
493 rpath.frp_proto = FIB_PROTOCOL_IP4;
494 vec_add1(rpaths, rpath);
496 else if (unformat (line_input, "via %U",
497 unformat_ip6_address,
498 &rpath.frp_addr.ip6))
500 rpath.frp_fib_index = table_id;
501 rpath.frp_weight = 1;
502 rpath.frp_sw_if_index = ~0;
503 rpath.frp_label = MPLS_LABEL_INVALID;
504 rpath.frp_proto = FIB_PROTOCOL_IP6;
505 vec_add1(rpaths, rpath);
507 else if (unformat (line_input,
508 "lookup in table %d",
509 &rpath.frp_fib_index))
511 rpath.frp_label = MPLS_LABEL_INVALID;
512 rpath.frp_proto = pfx.fp_proto;
513 vec_add1(rpaths, rpath);
515 else if (vec_len (prefixs) > 0 &&
516 unformat (line_input, "via %U",
517 unformat_dpo, &dpo, prefixs[0].fp_proto))
519 rpath.frp_label = MPLS_LABEL_INVALID;
520 vec_add1 (dpos, dpo);
524 error = unformat_parse_error (line_input);
529 unformat_free (line_input);
531 if (vec_len (prefixs) == 0)
533 error = clib_error_return (0, "expected ip4/ip6 destination address/length.");
537 if (!is_del && vec_len (rpaths) + vec_len (dpos) == 0)
539 error = clib_error_return (0, "expected paths.");
546 * if no table_id is passed we will manipulate the default
552 fib_index = fib_table_id_find_fib_index(prefixs[0].fp_proto,
557 error = clib_error_return (0,
558 "Nonexistent table id %d",
564 for (i = 0; i < vec_len (prefixs); i++)
566 if (is_del && 0 == vec_len (rpaths))
568 fib_table_entry_delete(fib_index,
572 else if (!is_del && 1 == vec_len (dpos))
574 fib_table_entry_special_dpo_add(fib_index,
577 FIB_ENTRY_FLAG_EXCLUSIVE,
581 else if (vec_len (dpos) > 0)
583 error = clib_error_return(0 , "Load-balancing over multiple special adjacencies is unsupported");
586 else if (0 < vec_len (rpaths))
589 ip46_address_t dst = prefixs[i].fp_addr;
592 t[0] = vlib_time_now (vm);
593 incr = 1 << ((FIB_PROTOCOL_IP4 == prefixs[0].fp_proto ? 32 : 128) -
596 for (k = 0; k < n; k++)
598 for (j = 0; j < vec_len (rpaths); j++)
601 * the CLI parsing stored table Ids, swap to FIB indicies
603 rpaths[i].frp_fib_index =
604 fib_table_id_find_fib_index(prefixs[i].fp_proto,
605 rpaths[i].frp_fib_index);
607 fib_prefix_t rpfx = {
608 .fp_len = prefixs[i].fp_len,
609 .fp_proto = prefixs[i].fp_proto,
614 fib_table_entry_path_remove2(fib_index,
619 fib_table_entry_path_add2(fib_index,
626 if (FIB_PROTOCOL_IP4 == prefixs[0].fp_proto)
629 clib_host_to_net_u32(incr +
630 clib_net_to_host_u32 (dst.ip4.as_u32));
634 int bucket = (incr < 64 ? 0 : 1);
635 dst.ip6.as_u64[bucket] =
636 clib_host_to_net_u64(incr +
637 clib_net_to_host_u64 (
638 dst.ip6.as_u64[bucket]));
642 t[1] = vlib_time_now (vm);
644 vlib_cli_output (vm, "%.6e routes/sec", count / (t[1] - t[0]));
648 error = clib_error_return(0 , "Don't understand what you want...");
661 VLIB_CLI_COMMAND (vlib_cli_ip_command, static) = {
663 .short_help = "Internet protocol (IP) commands",
666 VLIB_CLI_COMMAND (vlib_cli_show_ip_command, static) = {
668 .short_help = "Internet protocol (IP) show commands",
671 VLIB_CLI_COMMAND (vlib_cli_show_ip4_command, static) = {
673 .short_help = "Internet protocol version 4 (IP4) show commands",
676 VLIB_CLI_COMMAND (vlib_cli_show_ip6_command, static) = {
678 .short_help = "Internet protocol version 6 (IP6) show commands",
682 * To add or delete routes, use ip route add / del
684 * @cliexstart{ip route}
685 * To add or delete straightforward static routes, use ip route add / del:
686 * vpp# ip route add 6.0.1.2/32 via 6.0.0.1 GigabitEthernet2/0/0
687 * vpp# ip route del 6.0.1.2/32 via 6.0.0.1 GigabitEthernet2/0/0
691 * Mainly for route add/del performance testing, one can add or delete
692 * multiple routes by adding 'count N' to the previous item:
693 * vpp# ip route add count 10 7.0.0.0/24 via 6.0.0.1 GigabitEthernet2/0/0
697 * Add multiple routes for the same destination to create equal-cost multipath:
698 * vpp# ip route add 7.0.0.1/32 via 6.0.0.1 GigabitEthernet2/0/0
699 * vpp# ip route add 7.0.0.1/32 via 6.0.0.2 GigabitEthernet2/0/0
701 * For unequal-cost multipath, specify the desired weights:
702 * vpp# ip route add 7.0.0.1/32 via 6.0.0.1 GigabitEthernet2/0/0 weight 1
703 * vpp# ip route add 7.0.0.1/32 via 6.0.0.2 GigabitEthernet2/0/0 weight 3
705 * This combination of weights results in 3/4 of the traffic following the second path, 1/4 following the first path.
708 VLIB_CLI_COMMAND (ip_route_command, static) = {
710 .short_help = "Add/delete IP routes",
711 .function = vnet_ip_route_cmd,
716 * The next two routines address a longstanding script hemorrhoid.
717 * Probing a v4 or v6 neighbor needs to appear to be synchronous,
718 * or dependent route-adds will simply fail.
720 static clib_error_t *
721 ip6_probe_neighbor_wait (vlib_main_t *vm, ip6_address_t * a, u32 sw_if_index,
724 vnet_main_t * vnm = vnet_get_main();
729 uword *event_data = 0;
731 ASSERT (vlib_in_process_context(vm));
734 vnet_register_ip6_neighbor_resolution_event
735 (vnm, a, vlib_get_current_process (vm)->node_runtime.node_index,
736 1 /* event */, 0 /* data */);
738 for (i = 0; i < retry_count; i++)
740 /* The interface may be down, etc. */
741 e = ip6_probe_neighbor (vm, a, sw_if_index);
746 vlib_process_wait_for_event_or_clock (vm, 1.0);
747 event_type = vlib_process_get_events (vm, &event_data);
750 case 1: /* resolved... */
751 vlib_cli_output (vm, "Resolved %U",
752 format_ip6_address, a);
756 case ~0: /* timeout */
760 clib_warning ("unknown event_type %d", event_type);
762 vec_reset_length (event_data);
768 return clib_error_return (0, "Resolution failed for %U",
769 format_ip6_address, a);
773 static clib_error_t *
774 ip4_probe_neighbor_wait (vlib_main_t *vm, ip4_address_t * a, u32 sw_if_index,
777 vnet_main_t * vnm = vnet_get_main();
782 uword *event_data = 0;
784 ASSERT (vlib_in_process_context(vm));
787 vnet_register_ip4_arp_resolution_event
788 (vnm, a, vlib_get_current_process (vm)->node_runtime.node_index,
789 1 /* event */, 0 /* data */);
791 for (i = 0; i < retry_count; i++)
793 /* The interface may be down, etc. */
794 e = ip4_probe_neighbor (vm, a, sw_if_index);
799 vlib_process_wait_for_event_or_clock (vm, 1.0);
800 event_type = vlib_process_get_events (vm, &event_data);
803 case 1: /* resolved... */
804 vlib_cli_output (vm, "Resolved %U",
805 format_ip4_address, a);
809 case ~0: /* timeout */
813 clib_warning ("unknown event_type %d", event_type);
815 vec_reset_length (event_data);
820 vec_reset_length (event_data);
823 return clib_error_return (0, "Resolution failed for %U",
824 format_ip4_address, a);
828 static clib_error_t *
829 probe_neighbor_address (vlib_main_t * vm,
830 unformat_input_t * input,
831 vlib_cli_command_t * cmd)
833 vnet_main_t * vnm = vnet_get_main();
834 unformat_input_t _line_input, * line_input = &_line_input;
837 clib_error_t * error = 0;
838 u32 sw_if_index = ~0;
843 /* Get a line of input. */
844 if (! unformat_user (input, unformat_line_input, line_input))
847 while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
849 if (unformat_user (line_input, unformat_vnet_sw_interface, vnm,
852 else if (unformat (line_input, "retry %d", &retry_count))
855 else if (unformat (line_input, "%U", unformat_ip4_address, &a4))
857 else if (unformat (line_input, "%U", unformat_ip6_address, &a6))
863 return clib_error_return (0, "unknown input '%U'",
864 format_unformat_error, line_input);
867 unformat_free (line_input);
869 if (sw_if_index == ~0)
870 return clib_error_return (0, "Interface required, not set.");
871 if (address_set == 0)
872 return clib_error_return (0, "ip address required, not set.");
874 return clib_error_return (0, "Multiple ip addresses not supported.");
877 error = ip4_probe_neighbor_wait (vm, &a4, sw_if_index, retry_count);
879 error = ip6_probe_neighbor_wait (vm, &a6, sw_if_index, retry_count);
884 VLIB_CLI_COMMAND (ip_probe_neighbor_command, static) = {
885 .path = "ip probe-neighbor",
886 .function = probe_neighbor_address,
887 .short_help = "ip probe-neighbor <intfc> <ip4-addr> | <ip6-addr> [retry nn]",