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)
29 .fp_proto = FIB_PROTOCOL_IP6,
38 fib_index = ip6_fib_table_get_index_for_sw_if_index (sw_if_index);
41 return VNET_API_ERROR_NO_SUCH_FIB;
45 fib_table_entry_path_remove (fib_index,
47 FIB_SOURCE_IP6_ND_PROXY,
51 ~0, 1, FIB_ROUTE_PATH_FLAG_NONE);
52 /* flush the ND cache of this address if it's there */
57 ip_neighbor_del (&ip, sw_if_index);
61 fib_table_entry_path_add (fib_index,
63 FIB_SOURCE_IP6_ND_PROXY,
68 ~0, 1, NULL, FIB_ROUTE_PATH_FLAG_NONE);
74 ip6_nd_proxy_add (u32 sw_if_index, const ip6_address_t * addr)
76 return (ip6_nd_proxy_add_del (sw_if_index, addr, 0));
80 ip6_nd_proxy_del (u32 sw_if_index, const ip6_address_t * addr)
82 return (ip6_nd_proxy_add_del (sw_if_index, addr, 1));
86 set_ip6_nd_proxy_cmd (vlib_main_t * vm,
87 unformat_input_t * input, vlib_cli_command_t * cmd)
89 vnet_main_t *vnm = vnet_get_main ();
90 clib_error_t *error = 0;
95 if (unformat_user (input, unformat_vnet_sw_interface, vnm, &sw_if_index))
97 /* get the rest of the command */
98 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
100 if (unformat (input, "%U", unformat_ip6_address, &addr))
102 else if (unformat (input, "delete") || unformat (input, "del"))
105 return (unformat_parse_error (input));
113 ip6_nd_proxy_add_del (sw_if_index, &addr, is_del);
118 VLIB_CLI_COMMAND (set_ip6_nd_proxy_command, static) =
120 .path = "set ip6 nd proxy",
121 .short_help = "set ip6 nd proxy <interface> [del] <host-ip>",
122 .function = set_ip6_nd_proxy_cmd,
126 * fd.io coding-style-patch-verification: ON
129 * eval: (c-set-style "gnu")