2 * ip/ip6_neighbor.c: IP6 neighbor handling
4 * Copyright (c) 2010 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 agreed 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.
18 #include <vnet/ip6-nd/ip6_nd.h>
19 #include <vnet/ip-neighbor/ip_neighbor.h>
21 #include <vnet/fib/ip6_fib.h>
24 ip6_nd_proxy_add_del (u32 sw_if_index, const ip6_address_t * addr, u8 is_del)
30 .fp_proto = FIB_PROTOCOL_IP6,
40 fib_index = ip6_fib_table_get_index_for_sw_if_index (sw_if_index);
43 return VNET_API_ERROR_NO_SUCH_FIB;
47 fib_table_entry_path_remove (fib_index,
49 FIB_SOURCE_IP6_ND_PROXY,
53 ~0, 1, FIB_ROUTE_PATH_FLAG_NONE);
54 /* flush the ND cache of this address if it's there */
59 ip_neighbor_del (&ip, sw_if_index);
63 fib_table_entry_path_add (fib_index,
65 FIB_SOURCE_IP6_ND_PROXY,
70 ~0, 1, NULL, FIB_ROUTE_PATH_FLAG_NONE);
76 ip6_nd_proxy_add (u32 sw_if_index, const ip6_address_t * addr)
78 return (ip6_nd_proxy_add_del (sw_if_index, addr, 0));
82 ip6_nd_proxy_del (u32 sw_if_index, const ip6_address_t * addr)
84 return (ip6_nd_proxy_add_del (sw_if_index, addr, 1));
88 set_ip6_nd_proxy_cmd (vlib_main_t * vm,
89 unformat_input_t * input, vlib_cli_command_t * cmd)
91 vnet_main_t *vnm = vnet_get_main ();
92 clib_error_t *error = 0;
97 if (unformat_user (input, unformat_vnet_sw_interface, vnm, &sw_if_index))
99 /* get the rest of the command */
100 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
102 if (unformat (input, "%U", unformat_ip6_address, &addr))
104 else if (unformat (input, "delete") || unformat (input, "del"))
107 return (unformat_parse_error (input));
111 ip6_nd_proxy_add_del (sw_if_index, &addr, is_del);
117 VLIB_CLI_COMMAND (set_ip6_nd_proxy_command, static) =
119 .path = "set ip6 nd proxy",
120 .short_help = "set ip6 nd proxy <interface> [del] <host-ip>",
121 .function = set_ip6_nd_proxy_cmd,
126 * fd.io coding-style-patch-verification: ON
129 * eval: (c-set-style "gnu")