blob: 50921f24e3f12226172f58c15fea3c2ba0ff6a71 [file] [log] [blame]
Dave Barachaff70772016-10-31 11:59:07 -04001/*
2 *------------------------------------------------------------------
3 * interface_api.c - vnet interface api
4 *
5 * Copyright (c) 2016 Cisco and/or its affiliates.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at:
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *------------------------------------------------------------------
18 */
19
20#include <vnet/vnet.h>
21#include <vlibmemory/api.h>
22
23#include <vnet/interface.h>
24#include <vnet/api_errno.h>
Matus Fabiand162f3d2016-12-05 01:05:35 -080025#include <vnet/ethernet/ethernet.h>
Dave Barach6d963c22016-12-05 09:50:05 -050026#include <vnet/ip/ip.h>
27#include <vnet/fib/fib_table.h>
Neale Ranns4008ac92017-02-13 23:20:04 -080028#include <vnet/mfib/mfib_table.h>
Dave Barach6d963c22016-12-05 09:50:05 -050029#include <vnet/l2/l2_vtr.h>
Dave Barachaff70772016-10-31 11:59:07 -040030#include <vnet/vnet_msg_enum.h>
Dave Barachb5e8a772016-12-06 12:04:42 -050031#include <vnet/fib/fib_api.h>
Neale Ranns358425b2017-02-20 09:42:36 -080032#include <vnet/mfib/mfib_table.h>
Dave Barachaff70772016-10-31 11:59:07 -040033
34#define vl_typedefs /* define message structures */
35#include <vnet/vnet_all_api_h.h>
36#undef vl_typedefs
37
38#define vl_endianfun /* define message structures */
39#include <vnet/vnet_all_api_h.h>
40#undef vl_endianfun
41
42/* instantiate all the print functions we know about */
43#define vl_print(handle, ...) vlib_cli_output (handle, __VA_ARGS__)
44#define vl_printfun
45#include <vnet/vnet_all_api_h.h>
46#undef vl_printfun
47
48#include <vlibapi/api_helper_macros.h>
Dave Barachf1586612017-03-30 09:33:01 -040049vpe_api_main_t vpe_api_main;
Dave Barachaff70772016-10-31 11:59:07 -040050
Dave Barach6d963c22016-12-05 09:50:05 -050051#define foreach_vpe_api_msg \
52_(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \
Ole Troand7231612018-06-07 10:17:57 +020053_(HW_INTERFACE_SET_MTU, hw_interface_set_mtu) \
Dave Barach6d963c22016-12-05 09:50:05 -050054_(SW_INTERFACE_SET_MTU, sw_interface_set_mtu) \
55_(WANT_INTERFACE_EVENTS, want_interface_events) \
56_(SW_INTERFACE_DUMP, sw_interface_dump) \
Dave Barach6d963c22016-12-05 09:50:05 -050057_(SW_INTERFACE_ADD_DEL_ADDRESS, sw_interface_add_del_address) \
Stevenad8015b2017-10-29 22:10:46 -070058_(SW_INTERFACE_SET_RX_MODE, sw_interface_set_rx_mode) \
Mohsin Kazmif0b42f42018-09-10 18:11:00 +020059_(SW_INTERFACE_RX_PLACEMENT_DUMP, sw_interface_rx_placement_dump) \
Mohsin Kazmi54f7c512018-08-23 18:28:11 +020060_(SW_INTERFACE_SET_RX_PLACEMENT, sw_interface_set_rx_placement) \
Dave Barach6d963c22016-12-05 09:50:05 -050061_(SW_INTERFACE_SET_TABLE, sw_interface_set_table) \
Juraj Slobodadfc19232016-12-05 13:20:37 +010062_(SW_INTERFACE_GET_TABLE, sw_interface_get_table) \
Dave Barach6d963c22016-12-05 09:50:05 -050063_(SW_INTERFACE_SET_UNNUMBERED, sw_interface_set_unnumbered) \
64_(SW_INTERFACE_CLEAR_STATS, sw_interface_clear_stats) \
Jon Loeliger10c273b2017-03-30 08:39:33 -050065_(SW_INTERFACE_TAG_ADD_DEL, sw_interface_tag_add_del) \
Neale Rannsb8d44812017-11-10 06:53:54 -080066_(SW_INTERFACE_SET_MAC_ADDRESS, sw_interface_set_mac_address) \
Juraj Slobodac0374232018-02-01 15:18:49 +010067_(SW_INTERFACE_GET_MAC_ADDRESS, sw_interface_get_mac_address) \
Neale Rannsb8d44812017-11-10 06:53:54 -080068_(CREATE_VLAN_SUBIF, create_vlan_subif) \
69_(CREATE_SUBIF, create_subif) \
70_(DELETE_SUBIF, delete_subif) \
71_(CREATE_LOOPBACK, create_loopback) \
72_(CREATE_LOOPBACK_INSTANCE, create_loopback_instance) \
73_(DELETE_LOOPBACK, delete_loopback) \
Neale Ranns6f4a6be2018-03-16 16:26:21 -070074_(INTERFACE_NAME_RENUMBER, interface_name_renumber) \
Neale Ranns1855b8e2018-07-11 10:31:26 -070075_(COLLECT_DETAILED_INTERFACE_STATS, collect_detailed_interface_stats) \
76_(SW_INTERFACE_SET_IP_DIRECTED_BROADCAST, \
77 sw_interface_set_ip_directed_broadcast)
Dave Barachaff70772016-10-31 11:59:07 -040078
79static void
80vl_api_sw_interface_set_flags_t_handler (vl_api_sw_interface_set_flags_t * mp)
81{
82 vl_api_sw_interface_set_flags_reply_t *rmp;
83 vnet_main_t *vnm = vnet_get_main ();
84 int rv = 0;
85 clib_error_t *error;
86 u16 flags;
87
88 VALIDATE_SW_IF_INDEX (mp);
89
Ole Trøan3b0d7e42019-03-15 16:14:41 +000090 flags = mp->admin_up_down ? VNET_SW_INTERFACE_FLAG_ADMIN_UP : 0;
Dave Barachaff70772016-10-31 11:59:07 -040091
92 error = vnet_sw_interface_set_flags (vnm, ntohl (mp->sw_if_index), flags);
93 if (error)
94 {
95 rv = -1;
96 clib_error_report (error);
97 }
98
99 BAD_SW_IF_INDEX_LABEL;
100 REPLY_MACRO (VL_API_SW_INTERFACE_SET_FLAGS_REPLY);
101}
102
Matus Fabiand162f3d2016-12-05 01:05:35 -0800103static void
Ole Troand7231612018-06-07 10:17:57 +0200104vl_api_hw_interface_set_mtu_t_handler (vl_api_hw_interface_set_mtu_t * mp)
Matus Fabiand162f3d2016-12-05 01:05:35 -0800105{
Ole Troand7231612018-06-07 10:17:57 +0200106 vl_api_hw_interface_set_mtu_reply_t *rmp;
Matus Fabiand162f3d2016-12-05 01:05:35 -0800107 vnet_main_t *vnm = vnet_get_main ();
Matus Fabiand162f3d2016-12-05 01:05:35 -0800108 u32 sw_if_index = ntohl (mp->sw_if_index);
109 u16 mtu = ntohs (mp->mtu);
Damjan Marionfe7d4a22018-04-13 19:43:39 +0200110 ethernet_main_t *em = &ethernet_main;
Matus Fabiand162f3d2016-12-05 01:05:35 -0800111 int rv = 0;
112
113 VALIDATE_SW_IF_INDEX (mp);
114
Damjan Marionfe7d4a22018-04-13 19:43:39 +0200115 vnet_sw_interface_t *si = vnet_get_sw_interface (vnm, sw_if_index);
116 if (si->type != VNET_SW_INTERFACE_TYPE_HARDWARE)
117 {
118 rv = VNET_API_ERROR_INVALID_VALUE;
119 goto bad_sw_if_index;
120 }
121
122 vnet_hw_interface_t *hi = vnet_get_hw_interface (vnm, si->hw_if_index);
123 ethernet_interface_t *eif = ethernet_get_interface (em, si->hw_if_index);
124
125 if (!eif)
126 {
127 rv = VNET_API_ERROR_FEATURE_DISABLED;
128 goto bad_sw_if_index;
129 }
130
131 if (mtu < hi->min_supported_packet_bytes)
132 {
133 rv = VNET_API_ERROR_INVALID_VALUE;
134 goto bad_sw_if_index;
135 }
136
137 if (mtu > hi->max_supported_packet_bytes)
138 {
139 rv = VNET_API_ERROR_INVALID_VALUE;
140 goto bad_sw_if_index;
141 }
142
143 vnet_hw_interface_set_mtu (vnm, si->hw_if_index, mtu);
Matus Fabiand162f3d2016-12-05 01:05:35 -0800144
145 BAD_SW_IF_INDEX_LABEL;
Ole Troand7231612018-06-07 10:17:57 +0200146 REPLY_MACRO (VL_API_HW_INTERFACE_SET_MTU_REPLY);
147}
148
149static void
150vl_api_sw_interface_set_mtu_t_handler (vl_api_sw_interface_set_mtu_t * mp)
151{
152 vl_api_sw_interface_set_mtu_reply_t *rmp;
153 vnet_main_t *vnm = vnet_get_main ();
154 u32 sw_if_index = ntohl (mp->sw_if_index);
155 int rv = 0;
156 int i;
157 u32 per_protocol_mtu[VNET_N_MTU];
158
159 VALIDATE_SW_IF_INDEX (mp);
160
161 for (i = 0; i < VNET_N_MTU; i++)
162 per_protocol_mtu[i] = ntohl (mp->mtu[i]);
163
164 vnet_sw_interface_set_protocol_mtu (vnm, sw_if_index, per_protocol_mtu);
165
166 BAD_SW_IF_INDEX_LABEL;
Matus Fabiand162f3d2016-12-05 01:05:35 -0800167 REPLY_MACRO (VL_API_SW_INTERFACE_SET_MTU_REPLY);
168}
169
Dave Barach6d963c22016-12-05 09:50:05 -0500170static void
Neale Ranns1855b8e2018-07-11 10:31:26 -0700171 vl_api_sw_interface_set_ip_directed_broadcast_t_handler
172 (vl_api_sw_interface_set_ip_directed_broadcast_t * mp)
173{
174 vl_api_sw_interface_set_ip_directed_broadcast_reply_t *rmp;
175 u32 sw_if_index = ntohl (mp->sw_if_index);
176 int rv = 0;
177
178 VALIDATE_SW_IF_INDEX (mp);
179
180 vnet_sw_interface_ip_directed_broadcast (vnet_get_main (),
181 sw_if_index, mp->enable);
182
183 BAD_SW_IF_INDEX_LABEL;
184 REPLY_MACRO (VL_API_SW_INTERFACE_SET_IP_DIRECTED_BROADCAST_REPLY);
185}
186
187static void
Dave Barach6d963c22016-12-05 09:50:05 -0500188send_sw_interface_details (vpe_api_main_t * am,
Dave Barach59b25652017-09-10 15:04:27 -0400189 vl_api_registration_t * rp,
Dave Barach6d963c22016-12-05 09:50:05 -0500190 vnet_sw_interface_t * swif,
191 u8 * interface_name, u32 context)
192{
Eyal Bari1c82cd42017-03-14 14:39:51 +0200193 vnet_hw_interface_t *hi =
194 vnet_get_sup_hw_interface (am->vnet_main, swif->sw_if_index);
Dave Barach6d963c22016-12-05 09:50:05 -0500195
Ole Trøan3b0d7e42019-03-15 16:14:41 +0000196 vl_api_sw_interface_details_t *mp = vl_msg_api_alloc (sizeof (*mp));
197 clib_memset (mp, 0, sizeof (*mp));
Dave Barach6d963c22016-12-05 09:50:05 -0500198 mp->_vl_msg_id = ntohs (VL_API_SW_INTERFACE_DETAILS);
199 mp->sw_if_index = ntohl (swif->sw_if_index);
200 mp->sup_sw_if_index = ntohl (swif->sup_sw_if_index);
Ole Trøan3b0d7e42019-03-15 16:14:41 +0000201 mp->admin_up_down = (swif->flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) ? 1 : 0;
202 mp->link_up_down = (hi->flags & VNET_HW_INTERFACE_FLAG_LINK_UP) ? 1 : 0;
Dave Barach6d963c22016-12-05 09:50:05 -0500203 mp->link_duplex = ((hi->flags & VNET_HW_INTERFACE_FLAG_DUPLEX_MASK) >>
204 VNET_HW_INTERFACE_FLAG_DUPLEX_SHIFT);
Ole Troan8ee72512018-11-20 11:03:10 +0100205 mp->link_speed = ntohl (hi->link_speed);
Damjan Marionfe7d4a22018-04-13 19:43:39 +0200206 mp->link_mtu = ntohs (hi->max_packet_bytes);
Ole Troand7231612018-06-07 10:17:57 +0200207 mp->mtu[VNET_MTU_L3] = ntohl (swif->mtu[VNET_MTU_L3]);
208 mp->mtu[VNET_MTU_IP4] = ntohl (swif->mtu[VNET_MTU_IP4]);
209 mp->mtu[VNET_MTU_IP6] = ntohl (swif->mtu[VNET_MTU_IP6]);
210 mp->mtu[VNET_MTU_MPLS] = ntohl (swif->mtu[VNET_MTU_MPLS]);
211
Dave Barach6d963c22016-12-05 09:50:05 -0500212 mp->context = context;
213
Ole Trøan3b0d7e42019-03-15 16:14:41 +0000214 strncpy ((char *) mp->interface_name,
215 (char *) interface_name, ARRAY_LEN (mp->interface_name) - 1);
216
Dave Barach6d963c22016-12-05 09:50:05 -0500217 /* Send the L2 address for ethernet physical intfcs */
218 if (swif->sup_sw_if_index == swif->sw_if_index
219 && hi->hw_class_index == ethernet_hw_interface_class.index)
220 {
221 ethernet_main_t *em = ethernet_get_main (am->vlib_main);
222 ethernet_interface_t *ei;
223
224 ei = pool_elt_at_index (em->interfaces, hi->hw_instance);
225 ASSERT (sizeof (mp->l2_address) >= sizeof (ei->address));
Ole Trøan3b0d7e42019-03-15 16:14:41 +0000226 clib_memcpy (mp->l2_address, ei->address, sizeof (ei->address));
227 mp->l2_address_length = ntohl (sizeof (ei->address));
Dave Barach6d963c22016-12-05 09:50:05 -0500228 }
229 else if (swif->sup_sw_if_index != swif->sw_if_index)
230 {
231 vnet_sub_interface_t *sub = &swif->sub;
232 mp->sub_id = ntohl (sub->id);
Ole Trøan3b0d7e42019-03-15 16:14:41 +0000233 mp->sub_dot1ad = sub->eth.flags.dot1ad;
Dave Barach6d963c22016-12-05 09:50:05 -0500234 mp->sub_number_of_tags =
235 sub->eth.flags.one_tag + sub->eth.flags.two_tags * 2;
236 mp->sub_outer_vlan_id = ntohs (sub->eth.outer_vlan_id);
237 mp->sub_inner_vlan_id = ntohs (sub->eth.inner_vlan_id);
Ole Trøan3b0d7e42019-03-15 16:14:41 +0000238 mp->sub_exact_match = sub->eth.flags.exact_match;
239 mp->sub_default = sub->eth.flags.default_sub;
240 mp->sub_outer_vlan_id_any = sub->eth.flags.outer_vlan_id_any;
241 mp->sub_inner_vlan_id_any = sub->eth.flags.inner_vlan_id_any;
Alexander Chernavinfdea5c62019-04-26 10:43:09 -0400242 }
Dave Barach6d963c22016-12-05 09:50:05 -0500243
Alexander Chernavinfdea5c62019-04-26 10:43:09 -0400244 /* vlan tag rewrite data */
245 u32 vtr_op = L2_VTR_DISABLED;
246 u32 vtr_push_dot1q = 0, vtr_tag1 = 0, vtr_tag2 = 0;
Dave Barach6d963c22016-12-05 09:50:05 -0500247
Alexander Chernavinfdea5c62019-04-26 10:43:09 -0400248 if (l2vtr_get (am->vlib_main, am->vnet_main, swif->sw_if_index,
249 &vtr_op, &vtr_push_dot1q, &vtr_tag1, &vtr_tag2) != 0)
250 {
251 // error - default to disabled
252 mp->vtr_op = ntohl (L2_VTR_DISABLED);
253 clib_warning ("cannot get vlan tag rewrite for sw_if_index %d",
254 swif->sw_if_index);
255 }
256 else
257 {
258 mp->vtr_op = ntohl (vtr_op);
259 mp->vtr_push_dot1q = ntohl (vtr_push_dot1q);
260 mp->vtr_tag1 = ntohl (vtr_tag1);
261 mp->vtr_tag2 = ntohl (vtr_tag2);
Dave Barach6d963c22016-12-05 09:50:05 -0500262 }
263
Pavel Kotucek65e84572017-01-16 17:01:56 +0100264 /* pbb tag rewrite data */
Gabriel Gannef7f2a9f2017-03-06 15:19:40 +0100265 ethernet_header_t eth_hdr;
Alexander Chernavinfdea5c62019-04-26 10:43:09 -0400266 u32 pbb_vtr_op = L2_VTR_DISABLED;
Pavel Kotucek65e84572017-01-16 17:01:56 +0100267 u16 outer_tag = 0;
Pavel Kotucek65e84572017-01-16 17:01:56 +0100268 u16 b_vlanid = 0;
269 u32 i_sid = 0;
Dave Barachb7b92992018-10-17 10:38:51 -0400270 clib_memset (&eth_hdr, 0, sizeof (eth_hdr));
Pavel Kotucek65e84572017-01-16 17:01:56 +0100271
272 if (!l2pbb_get (am->vlib_main, am->vnet_main, swif->sw_if_index,
Alexander Chernavinfdea5c62019-04-26 10:43:09 -0400273 &pbb_vtr_op, &outer_tag, &eth_hdr, &b_vlanid, &i_sid))
Pavel Kotucek65e84572017-01-16 17:01:56 +0100274 {
Ole Trøan3b0d7e42019-03-15 16:14:41 +0000275 mp->sub_dot1ah = 1;
276 clib_memcpy (mp->b_dmac, eth_hdr.dst_address,
277 sizeof (eth_hdr.dst_address));
278 clib_memcpy (mp->b_smac, eth_hdr.src_address,
279 sizeof (eth_hdr.src_address));
Pavel Kotucek65e84572017-01-16 17:01:56 +0100280 mp->b_vlanid = b_vlanid;
281 mp->i_sid = i_sid;
282 }
283
Ole Trøan3b0d7e42019-03-15 16:14:41 +0000284 u8 *tag = vnet_get_sw_interface_tag (vnet_get_main (), swif->sw_if_index);
285 if (tag)
286 strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
Dave Barach6d963c22016-12-05 09:50:05 -0500287
Florin Corase86a8ed2018-01-05 03:20:25 -0800288 vl_api_send_msg (rp, (u8 *) mp);
Dave Barach6d963c22016-12-05 09:50:05 -0500289}
290
291static void
292vl_api_sw_interface_dump_t_handler (vl_api_sw_interface_dump_t * mp)
293{
294 vpe_api_main_t *am = &vpe_api_main;
295 vnet_sw_interface_t *swif;
296 vnet_interface_main_t *im = &am->vnet_main->interface_main;
Dave Barach59b25652017-09-10 15:04:27 -0400297 vl_api_registration_t *rp;
Paul Vinciguerra6407ba52019-04-04 13:22:20 -0700298 u32 sw_if_index;
Dave Barach6d963c22016-12-05 09:50:05 -0500299
Dave Barach59b25652017-09-10 15:04:27 -0400300 rp = vl_api_client_index_to_registration (mp->client_index);
301
302 if (rp == 0)
303 {
304 clib_warning ("Client %d AWOL", mp->client_index);
305 return;
306 }
Dave Barach6d963c22016-12-05 09:50:05 -0500307
Eyal Bari1c82cd42017-03-14 14:39:51 +0200308 u8 *filter = 0, *name = 0;
Paul Vinciguerra6407ba52019-04-04 13:22:20 -0700309 sw_if_index = ntohl (mp->sw_if_index);
310
Vratko Polakb8591ac2019-04-23 12:26:44 +0200311 if (!mp->name_filter_valid && sw_if_index != ~0 && sw_if_index != 0)
Paul Vinciguerra6407ba52019-04-04 13:22:20 -0700312 {
Vratko Polakb8591ac2019-04-23 12:26:44 +0200313 /* is it a valid sw_if_index? */
Neale Rannsf5b01762019-06-14 08:26:21 +0000314 if (!vnet_sw_if_index_is_api_valid (sw_if_index))
Paul Vinciguerra6407ba52019-04-04 13:22:20 -0700315 return;
316
317 swif = vec_elt_at_index (im->sw_interfaces, sw_if_index);
318
Paul Vinciguerra6407ba52019-04-04 13:22:20 -0700319 vec_reset_length (name);
320 name =
321 format (name, "%U%c", format_vnet_sw_interface_name, am->vnet_main,
322 swif, 0);
323 send_sw_interface_details (am, rp, swif, name, mp->context);
324 vec_free (name);
325 return;
326 }
327
Dave Barach6d963c22016-12-05 09:50:05 -0500328 if (mp->name_filter_valid)
329 {
Ole Trøan3b0d7e42019-03-15 16:14:41 +0000330 mp->name_filter[ARRAY_LEN (mp->name_filter) - 1] = 0;
331 filter = format (0, "%s%c", mp->name_filter, 0);
Dave Barach6d963c22016-12-05 09:50:05 -0500332 }
333
Eyal Bari1c82cd42017-03-14 14:39:51 +0200334 char *strcasestr (char *, char *); /* lnx hdr file botch */
Dave Barach6d963c22016-12-05 09:50:05 -0500335 /* *INDENT-OFF* */
336 pool_foreach (swif, im->sw_interfaces,
337 ({
Eyal Bari1c82cd42017-03-14 14:39:51 +0200338 if (!vnet_swif_is_api_visible (swif))
339 continue;
340 vec_reset_length(name);
341 name = format (name, "%U%c", format_vnet_sw_interface_name, am->vnet_main,
342 swif, 0);
Dave Barach6d963c22016-12-05 09:50:05 -0500343
Eyal Bari1c82cd42017-03-14 14:39:51 +0200344 if (filter && !strcasestr((char *) name, (char *) filter))
345 continue;
Dave Barach6d963c22016-12-05 09:50:05 -0500346
Dave Barach59b25652017-09-10 15:04:27 -0400347 send_sw_interface_details (am, rp, swif, name, mp->context);
Dave Barach6d963c22016-12-05 09:50:05 -0500348 }));
349 /* *INDENT-ON* */
350
Eyal Bari1c82cd42017-03-14 14:39:51 +0200351 vec_free (name);
352 vec_free (filter);
Dave Barach6d963c22016-12-05 09:50:05 -0500353}
354
355static void
356 vl_api_sw_interface_add_del_address_t_handler
357 (vl_api_sw_interface_add_del_address_t * mp)
358{
359 vlib_main_t *vm = vlib_get_main ();
Jon Loeliger35ffa3e2017-09-28 13:54:16 -0500360 vnet_main_t *vnm = vnet_get_main ();
Dave Barach6d963c22016-12-05 09:50:05 -0500361 vl_api_sw_interface_add_del_address_reply_t *rmp;
362 int rv = 0;
363 u32 is_del;
Jon Loeliger35ffa3e2017-09-28 13:54:16 -0500364 clib_error_t *error = 0;
Dave Barach6d963c22016-12-05 09:50:05 -0500365
366 VALIDATE_SW_IF_INDEX (mp);
367
368 is_del = mp->is_add == 0;
Jon Loeliger35ffa3e2017-09-28 13:54:16 -0500369 vnm->api_errno = 0;
Dave Barach6d963c22016-12-05 09:50:05 -0500370
371 if (mp->del_all)
372 ip_del_all_interface_addresses (vm, ntohl (mp->sw_if_index));
Ole Trøan3b0d7e42019-03-15 16:14:41 +0000373 else if (mp->is_ipv6)
Jon Loeliger35ffa3e2017-09-28 13:54:16 -0500374 error = ip6_add_del_interface_address (vm, ntohl (mp->sw_if_index),
Ole Trøan3b0d7e42019-03-15 16:14:41 +0000375 (void *) mp->address,
376 mp->address_length, is_del);
Dave Barach6d963c22016-12-05 09:50:05 -0500377 else
Jon Loeliger35ffa3e2017-09-28 13:54:16 -0500378 error = ip4_add_del_interface_address (vm, ntohl (mp->sw_if_index),
Ole Trøan3b0d7e42019-03-15 16:14:41 +0000379 (void *) mp->address,
380 mp->address_length, is_del);
Jon Loeliger35ffa3e2017-09-28 13:54:16 -0500381
382 if (error)
383 {
384 rv = vnm->api_errno;
385 clib_error_report (error);
386 goto done;
387 }
Dave Barach6d963c22016-12-05 09:50:05 -0500388
389 BAD_SW_IF_INDEX_LABEL;
390
Jon Loeliger35ffa3e2017-09-28 13:54:16 -0500391done:
Dave Barach6d963c22016-12-05 09:50:05 -0500392 REPLY_MACRO (VL_API_SW_INTERFACE_ADD_DEL_ADDRESS_REPLY);
393}
394
Dave Barach6d963c22016-12-05 09:50:05 -0500395static void
396vl_api_sw_interface_set_table_t_handler (vl_api_sw_interface_set_table_t * mp)
397{
Dave Barach6d963c22016-12-05 09:50:05 -0500398 vl_api_sw_interface_set_table_reply_t *rmp;
Neale Ranns15002542017-09-10 04:39:11 -0700399 u32 sw_if_index = ntohl (mp->sw_if_index);
400 u32 table_id = ntohl (mp->vrf_id);
401 int rv = 0;
Dave Barach6d963c22016-12-05 09:50:05 -0500402
403 VALIDATE_SW_IF_INDEX (mp);
404
Dave Barach6d963c22016-12-05 09:50:05 -0500405 if (mp->is_ipv6)
Neale Ranns15002542017-09-10 04:39:11 -0700406 rv = ip_table_bind (FIB_PROTOCOL_IP6, sw_if_index, table_id, 1);
Dave Barach6d963c22016-12-05 09:50:05 -0500407 else
Neale Ranns15002542017-09-10 04:39:11 -0700408 rv = ip_table_bind (FIB_PROTOCOL_IP4, sw_if_index, table_id, 1);
Dave Barach6d963c22016-12-05 09:50:05 -0500409
Dave Barach6d963c22016-12-05 09:50:05 -0500410 BAD_SW_IF_INDEX_LABEL;
411
412 REPLY_MACRO (VL_API_SW_INTERFACE_SET_TABLE_REPLY);
413}
414
Neale Ranns15002542017-09-10 04:39:11 -0700415int
416ip_table_bind (fib_protocol_t fproto,
Neale Ranns6b3a8ef2017-09-11 10:34:33 -0700417 u32 sw_if_index, u32 table_id, u8 is_api)
Neale Ranns15002542017-09-10 04:39:11 -0700418{
419 CLIB_UNUSED (ip_interface_address_t * ia);
420 u32 fib_index, mfib_index;
421 fib_source_t src;
422 mfib_source_t msrc;
423
424 if (is_api)
425 {
426 src = FIB_SOURCE_API;
427 msrc = MFIB_SOURCE_API;
428 }
429 else
430 {
431 src = FIB_SOURCE_CLI;
432 msrc = MFIB_SOURCE_CLI;
433 }
434
Florin Corasd0a59722017-10-15 17:41:21 +0000435 /*
Florin Corasd0a59722017-10-15 17:41:21 +0000436 * This if table does not exist = error is what we want in the end.
437 */
Neale Ranns8f6dd322018-05-17 06:34:24 -0700438 fib_index = fib_table_find (fproto, table_id);
439 mfib_index = mfib_table_find (fproto, table_id);
Florin Corasd0a59722017-10-15 17:41:21 +0000440
Neale Ranns8f6dd322018-05-17 06:34:24 -0700441 if (~0 == fib_index || ~0 == mfib_index)
442 {
443 return (VNET_API_ERROR_NO_SUCH_FIB);
444 }
Florin Corasd0a59722017-10-15 17:41:21 +0000445
Neale Ranns15002542017-09-10 04:39:11 -0700446 if (FIB_PROTOCOL_IP6 == fproto)
447 {
448 /*
449 * If the interface already has in IP address, then a change int
450 * VRF is not allowed. The IP address applied must first be removed.
451 * We do not do that automatically here, since VPP has no knowledge
Paul Vinciguerrabdc0e6b2018-09-22 05:32:50 -0700452 * of whether those subnets are valid in the destination VRF.
Neale Ranns15002542017-09-10 04:39:11 -0700453 */
454 /* *INDENT-OFF* */
455 foreach_ip_interface_address (&ip6_main.lookup_main,
456 ia, sw_if_index,
457 1 /* honor unnumbered */ ,
458 ({
459 return (VNET_API_ERROR_ADDRESS_FOUND_FOR_INTERFACE);
460 }));
461 /* *INDENT-ON* */
462
463 vec_validate (ip6_main.fib_index_by_sw_if_index, sw_if_index);
464 vec_validate (ip6_main.mfib_index_by_sw_if_index, sw_if_index);
465
466 /*
467 * tell those that are interested that the binding is changing.
468 */
469 ip6_table_bind_callback_t *cb;
470 vec_foreach (cb, ip6_main.table_bind_callbacks)
471 cb->function (&ip6_main, cb->function_opaque,
472 sw_if_index,
473 fib_index,
474 ip6_main.fib_index_by_sw_if_index[sw_if_index]);
475
476 if (0 == table_id)
477 {
478 /* reset back to default */
479 if (0 != ip6_main.fib_index_by_sw_if_index[sw_if_index])
480 fib_table_unlock (ip6_main.fib_index_by_sw_if_index[sw_if_index],
481 FIB_PROTOCOL_IP6, src);
482 if (0 != ip6_main.mfib_index_by_sw_if_index[sw_if_index])
483 mfib_table_unlock (ip6_main.mfib_index_by_sw_if_index
484 [sw_if_index], FIB_PROTOCOL_IP6, msrc);
485
486 }
487 else
488 {
489 /* we need to lock the table now it's inuse */
490 fib_table_lock (fib_index, FIB_PROTOCOL_IP6, src);
491 mfib_table_lock (mfib_index, FIB_PROTOCOL_IP6, msrc);
492 }
493
494 ip6_main.fib_index_by_sw_if_index[sw_if_index] = fib_index;
495 ip6_main.mfib_index_by_sw_if_index[sw_if_index] = mfib_index;
496 }
497 else
498 {
499 /*
500 * If the interface already has in IP address, then a change int
501 * VRF is not allowed. The IP address applied must first be removed.
502 * We do not do that automatically here, since VPP has no knowledge
Paul Vinciguerrabdc0e6b2018-09-22 05:32:50 -0700503 * of whether those subnets are valid in the destination VRF.
Neale Ranns15002542017-09-10 04:39:11 -0700504 */
505 /* *INDENT-OFF* */
506 foreach_ip_interface_address (&ip4_main.lookup_main,
507 ia, sw_if_index,
508 1 /* honor unnumbered */ ,
509 ({
510 return (VNET_API_ERROR_ADDRESS_FOUND_FOR_INTERFACE);
511 }));
512 /* *INDENT-ON* */
513
514 vec_validate (ip4_main.fib_index_by_sw_if_index, sw_if_index);
515 vec_validate (ip4_main.mfib_index_by_sw_if_index, sw_if_index);
516
517 /*
518 * tell those that are interested that the binding is changing.
519 */
520 ip4_table_bind_callback_t *cb;
521 vec_foreach (cb, ip4_main.table_bind_callbacks)
522 cb->function (&ip4_main, cb->function_opaque,
523 sw_if_index,
524 fib_index,
525 ip4_main.fib_index_by_sw_if_index[sw_if_index]);
526
527 if (0 == table_id)
528 {
529 /* reset back to default */
530 if (0 != ip4_main.fib_index_by_sw_if_index[sw_if_index])
531 fib_table_unlock (ip4_main.fib_index_by_sw_if_index[sw_if_index],
532 FIB_PROTOCOL_IP4, src);
533 if (0 != ip4_main.mfib_index_by_sw_if_index[sw_if_index])
534 mfib_table_unlock (ip4_main.mfib_index_by_sw_if_index
535 [sw_if_index], FIB_PROTOCOL_IP4, msrc);
536
537 }
538 else
539 {
540 /* we need to lock the table now it's inuse */
541 fib_index = fib_table_find_or_create_and_lock (FIB_PROTOCOL_IP4,
542 table_id, src);
543
544 mfib_index = mfib_table_find_or_create_and_lock (FIB_PROTOCOL_IP4,
545 table_id, msrc);
546 }
547
548 ip4_main.fib_index_by_sw_if_index[sw_if_index] = fib_index;
549 ip4_main.mfib_index_by_sw_if_index[sw_if_index] = mfib_index;
550 }
551
Neale Ranns15002542017-09-10 04:39:11 -0700552 return (0);
553}
554
Juraj Slobodadfc19232016-12-05 13:20:37 +0100555static void
Florin Coras6c4dae22018-01-09 06:39:23 -0800556send_sw_interface_get_table_reply (vl_api_registration_t * reg,
Juraj Slobodadfc19232016-12-05 13:20:37 +0100557 u32 context, int retval, u32 vrf_id)
558{
559 vl_api_sw_interface_get_table_reply_t *mp;
560
561 mp = vl_msg_api_alloc (sizeof (*mp));
Dave Barachb7b92992018-10-17 10:38:51 -0400562 clib_memset (mp, 0, sizeof (*mp));
Juraj Slobodadfc19232016-12-05 13:20:37 +0100563 mp->_vl_msg_id = ntohs (VL_API_SW_INTERFACE_GET_TABLE_REPLY);
564 mp->context = context;
565 mp->retval = htonl (retval);
566 mp->vrf_id = htonl (vrf_id);
567
Florin Coras6c4dae22018-01-09 06:39:23 -0800568 vl_api_send_msg (reg, (u8 *) mp);
Juraj Slobodadfc19232016-12-05 13:20:37 +0100569}
570
571static void
572vl_api_sw_interface_get_table_t_handler (vl_api_sw_interface_get_table_t * mp)
573{
Florin Coras6c4dae22018-01-09 06:39:23 -0800574 vl_api_registration_t *reg;
Juraj Slobodadfc19232016-12-05 13:20:37 +0100575 fib_table_t *fib_table = 0;
576 u32 sw_if_index = ~0;
577 u32 fib_index = ~0;
578 u32 table_id = ~0;
579 fib_protocol_t fib_proto = FIB_PROTOCOL_IP4;
580 int rv = 0;
581
Florin Coras6c4dae22018-01-09 06:39:23 -0800582 reg = vl_api_client_index_to_registration (mp->client_index);
583 if (!reg)
Juraj Slobodadfc19232016-12-05 13:20:37 +0100584 return;
585
586 VALIDATE_SW_IF_INDEX (mp);
587
588 sw_if_index = ntohl (mp->sw_if_index);
589
590 if (mp->is_ipv6)
591 fib_proto = FIB_PROTOCOL_IP6;
592
593 fib_index = fib_table_get_index_for_sw_if_index (fib_proto, sw_if_index);
594 if (fib_index != ~0)
595 {
596 fib_table = fib_table_get (fib_index, fib_proto);
597 table_id = fib_table->ft_table_id;
598 }
599
600 BAD_SW_IF_INDEX_LABEL;
601
Florin Coras6c4dae22018-01-09 06:39:23 -0800602 send_sw_interface_get_table_reply (reg, mp->context, rv, table_id);
Juraj Slobodadfc19232016-12-05 13:20:37 +0100603}
604
Dave Barach6d963c22016-12-05 09:50:05 -0500605static void vl_api_sw_interface_set_unnumbered_t_handler
606 (vl_api_sw_interface_set_unnumbered_t * mp)
607{
608 vl_api_sw_interface_set_unnumbered_reply_t *rmp;
609 int rv = 0;
Dave Barach6d963c22016-12-05 09:50:05 -0500610 vnet_main_t *vnm = vnet_get_main ();
Eyal Bari1c82cd42017-03-14 14:39:51 +0200611 u32 sw_if_index = ntohl (mp->sw_if_index);
612 u32 unnumbered_sw_if_index = ntohl (mp->unnumbered_sw_if_index);
Dave Barach6d963c22016-12-05 09:50:05 -0500613
614 /*
615 * The API message field names are backwards from
616 * the underlying data structure names.
617 * It's not worth changing them now.
618 */
Eyal Bari1c82cd42017-03-14 14:39:51 +0200619 if (!vnet_sw_interface_is_api_valid (vnm, unnumbered_sw_if_index))
Dave Barach6d963c22016-12-05 09:50:05 -0500620 {
621 rv = VNET_API_ERROR_INVALID_SW_IF_INDEX;
622 goto done;
623 }
624
625 /* Only check the "use loop0" field when setting the binding */
Eyal Bari1c82cd42017-03-14 14:39:51 +0200626 if (mp->is_add && !vnet_sw_interface_is_api_valid (vnm, sw_if_index))
Dave Barach6d963c22016-12-05 09:50:05 -0500627 {
628 rv = VNET_API_ERROR_INVALID_SW_IF_INDEX_2;
629 goto done;
630 }
631
Neale Ranns2ae2bc52018-03-16 03:22:39 -0700632 vnet_sw_interface_update_unnumbered (unnumbered_sw_if_index,
633 sw_if_index, mp->is_add);
Dave Barach6d963c22016-12-05 09:50:05 -0500634done:
635 REPLY_MACRO (VL_API_SW_INTERFACE_SET_UNNUMBERED_REPLY);
636}
637
638static void
639vl_api_sw_interface_clear_stats_t_handler (vl_api_sw_interface_clear_stats_t *
640 mp)
641{
642 vl_api_sw_interface_clear_stats_reply_t *rmp;
643
644 vnet_main_t *vnm = vnet_get_main ();
645 vnet_interface_main_t *im = &vnm->interface_main;
646 vlib_simple_counter_main_t *sm;
647 vlib_combined_counter_main_t *cm;
Dave Barach8fdde3c2019-05-17 10:46:40 -0400648 int j, n_counters;
Dave Barach6d963c22016-12-05 09:50:05 -0500649 int rv = 0;
650
651 if (mp->sw_if_index != ~0)
652 VALIDATE_SW_IF_INDEX (mp);
653
Dave Barach6d963c22016-12-05 09:50:05 -0500654 n_counters = vec_len (im->combined_sw_if_counters);
655
656 for (j = 0; j < n_counters; j++)
657 {
Dave Barach8fdde3c2019-05-17 10:46:40 -0400658 im = &vnm->interface_main;
659 cm = im->combined_sw_if_counters + j;
660 if (mp->sw_if_index == (u32) ~ 0)
661 vlib_clear_combined_counters (cm);
662 else
663 vlib_zero_combined_counter (cm, ntohl (mp->sw_if_index));
Dave Barach6d963c22016-12-05 09:50:05 -0500664 }
665
666 n_counters = vec_len (im->sw_if_counters);
667
668 for (j = 0; j < n_counters; j++)
669 {
Dave Barach8fdde3c2019-05-17 10:46:40 -0400670 im = &vnm->interface_main;
671 sm = im->sw_if_counters + j;
672 if (mp->sw_if_index == (u32) ~ 0)
673 vlib_clear_simple_counters (sm);
674 else
675 vlib_zero_simple_counter (sm, ntohl (mp->sw_if_index));
Dave Barach6d963c22016-12-05 09:50:05 -0500676 }
677
678 BAD_SW_IF_INDEX_LABEL;
679
680 REPLY_MACRO (VL_API_SW_INTERFACE_CLEAR_STATS_REPLY);
681}
682
Ole Troan2e1c8962019-04-10 09:44:23 +0200683/*
684 * Events used for sw_interface_events
685 */
686enum api_events
Dave Barach6d963c22016-12-05 09:50:05 -0500687{
Ole Troan2e1c8962019-04-10 09:44:23 +0200688 API_LINK_STATE_UP_EVENT = 1 << 1,
689 API_LINK_STATE_DOWN_EVENT = 1 << 2,
690 API_ADMIN_UP_EVENT = 1 << 3,
691 API_ADMIN_DOWN_EVENT = 1 << 4,
692 API_SW_INTERFACE_ADD_EVENT = 1 << 5,
693 API_SW_INTERFACE_DEL_EVENT = 1 << 6,
694};
Dave Barach6d963c22016-12-05 09:50:05 -0500695
696static void
Neale Rannsa07bd702017-08-07 07:53:49 -0700697send_sw_interface_event (vpe_api_main_t * am,
Neale Rannsd292ab12017-08-15 12:29:48 -0700698 vpe_client_registration_t * reg,
Florin Coras6c4dae22018-01-09 06:39:23 -0800699 vl_api_registration_t * vl_reg,
Ole Troan2e1c8962019-04-10 09:44:23 +0200700 u32 sw_if_index, enum api_events events)
Dave Barach6d963c22016-12-05 09:50:05 -0500701{
Neale Rannsa07bd702017-08-07 07:53:49 -0700702 vl_api_sw_interface_event_t *mp;
Dave Barach6d963c22016-12-05 09:50:05 -0500703
Dave Barach6d963c22016-12-05 09:50:05 -0500704 mp = vl_msg_api_alloc (sizeof (*mp));
Dave Barachb7b92992018-10-17 10:38:51 -0400705 clib_memset (mp, 0, sizeof (*mp));
Neale Rannsa07bd702017-08-07 07:53:49 -0700706 mp->_vl_msg_id = ntohs (VL_API_SW_INTERFACE_EVENT);
Ole Troan2e1c8962019-04-10 09:44:23 +0200707 mp->sw_if_index = ntohl (sw_if_index);
Neale Rannsd292ab12017-08-15 12:29:48 -0700708 mp->client_index = reg->client_index;
709 mp->pid = reg->client_pid;
Ole Troan2e1c8962019-04-10 09:44:23 +0200710 mp->admin_up_down = events & API_ADMIN_UP_EVENT ? 1 : 0;
711 mp->link_up_down = events & API_LINK_STATE_UP_EVENT ? 1 : 0;
712 mp->deleted = events & API_SW_INTERFACE_DEL_EVENT ? 1 : 0;
Florin Coras6c4dae22018-01-09 06:39:23 -0800713 vl_api_send_msg (vl_reg, (u8 *) mp);
Dave Barach6d963c22016-12-05 09:50:05 -0500714}
715
716static uword
717link_state_process (vlib_main_t * vm,
718 vlib_node_runtime_t * rt, vlib_frame_t * f)
719{
720 vpe_api_main_t *vam = &vpe_api_main;
Ole Troan2e1c8962019-04-10 09:44:23 +0200721 uword *event_by_sw_if_index = 0;
Dave Barach6d963c22016-12-05 09:50:05 -0500722 vpe_client_registration_t *reg;
723 int i;
Florin Coras6c4dae22018-01-09 06:39:23 -0800724 vl_api_registration_t *vl_reg;
Ole Troan2e1c8962019-04-10 09:44:23 +0200725 uword event_type;
726 uword *event_data = 0;
727 u32 sw_if_index;
Dave Barach6d963c22016-12-05 09:50:05 -0500728
729 vam->link_state_process_up = 1;
730
731 while (1)
732 {
733 vlib_process_wait_for_event (vm);
734
Ole Troan2e1c8962019-04-10 09:44:23 +0200735 /* Batch up events */
736 while ((event_type = vlib_process_get_events (vm, &event_data)) != ~0)
Dave Barach6d963c22016-12-05 09:50:05 -0500737 {
Ole Troan2e1c8962019-04-10 09:44:23 +0200738 for (i = 0; i < vec_len (event_data); i++)
739 {
740 sw_if_index = event_data[i];
741 vec_validate_init_empty (event_by_sw_if_index, sw_if_index, 0);
742 event_by_sw_if_index[sw_if_index] |= event_type;
743 }
744 vec_reset_length (event_data);
745 }
746
747 for (i = 0; i < vec_len (event_by_sw_if_index); i++)
748 {
749 if (event_by_sw_if_index[i] == 0)
Dave Barach6d963c22016-12-05 09:50:05 -0500750 continue;
Dave Barach6d963c22016-12-05 09:50:05 -0500751
752 /* *INDENT-OFF* */
753 pool_foreach(reg, vam->interface_events_registrations,
754 ({
Florin Coras6c4dae22018-01-09 06:39:23 -0800755 vl_reg = vl_api_client_index_to_registration (reg->client_index);
756 if (vl_reg)
Ole Troan2e1c8962019-04-10 09:44:23 +0200757 send_sw_interface_event (vam, reg, vl_reg, i, event_by_sw_if_index[i]);
Dave Barach6d963c22016-12-05 09:50:05 -0500758 }));
759 /* *INDENT-ON* */
760 }
Ole Troan2e1c8962019-04-10 09:44:23 +0200761 vec_reset_length (event_by_sw_if_index);
Dave Barach6d963c22016-12-05 09:50:05 -0500762 }
763
764 return 0;
765}
766
767static clib_error_t *link_up_down_function (vnet_main_t * vm, u32 hw_if_index,
768 u32 flags);
769static clib_error_t *admin_up_down_function (vnet_main_t * vm,
770 u32 hw_if_index, u32 flags);
Ole Troan2e1c8962019-04-10 09:44:23 +0200771static clib_error_t *sw_interface_add_del_function (vnet_main_t * vm,
772 u32 sw_if_index,
773 u32 flags);
Dave Barach6d963c22016-12-05 09:50:05 -0500774
775/* *INDENT-OFF* */
776VLIB_REGISTER_NODE (link_state_process_node,static) = {
777 .function = link_state_process,
778 .type = VLIB_NODE_TYPE_PROCESS,
779 .name = "vpe-link-state-process",
780};
781/* *INDENT-ON* */
782
783VNET_SW_INTERFACE_ADMIN_UP_DOWN_FUNCTION (admin_up_down_function);
784VNET_HW_INTERFACE_LINK_UP_DOWN_FUNCTION (link_up_down_function);
Ole Troan2e1c8962019-04-10 09:44:23 +0200785VNET_SW_INTERFACE_ADD_DEL_FUNCTION (sw_interface_add_del_function);
Dave Barach6d963c22016-12-05 09:50:05 -0500786
787static clib_error_t *
788link_up_down_function (vnet_main_t * vm, u32 hw_if_index, u32 flags)
789{
790 vpe_api_main_t *vam = &vpe_api_main;
791 vnet_hw_interface_t *hi = vnet_get_hw_interface (vm, hw_if_index);
792
793 if (vam->link_state_process_up)
Ole Troan2e1c8962019-04-10 09:44:23 +0200794 {
795 enum api_events event =
796 flags ? API_LINK_STATE_UP_EVENT : API_LINK_STATE_DOWN_EVENT;
797 vlib_process_signal_event (vam->vlib_main,
798 link_state_process_node.index, event,
799 hi->sw_if_index);
800 }
Dave Barach6d963c22016-12-05 09:50:05 -0500801 return 0;
802}
803
804static clib_error_t *
805admin_up_down_function (vnet_main_t * vm, u32 sw_if_index, u32 flags)
806{
807 vpe_api_main_t *vam = &vpe_api_main;
808
809 /*
810 * Note: it's perfectly fair to set a subif admin up / admin down.
811 * Note the subtle distinction between this routine and the previous
812 * routine.
813 */
814 if (vam->link_state_process_up)
Ole Troan2e1c8962019-04-10 09:44:23 +0200815 {
816 enum api_events event =
817 flags ? API_ADMIN_UP_EVENT : API_ADMIN_DOWN_EVENT;
818 vlib_process_signal_event (vam->vlib_main,
819 link_state_process_node.index, event,
820 sw_if_index);
821 }
822 return 0;
823}
824
825static clib_error_t *
826sw_interface_add_del_function (vnet_main_t * vm, u32 sw_if_index, u32 flags)
827{
828 vpe_api_main_t *vam = &vpe_api_main;
829
830 if (vam->link_state_process_up)
831 {
832 enum api_events event =
833 flags ? API_SW_INTERFACE_ADD_EVENT : API_SW_INTERFACE_DEL_EVENT;
834 vlib_process_signal_event (vam->vlib_main,
835 link_state_process_node.index, event,
836 sw_if_index);
837 }
Dave Barach6d963c22016-12-05 09:50:05 -0500838 return 0;
839}
840
841static void vl_api_sw_interface_tag_add_del_t_handler
842 (vl_api_sw_interface_tag_add_del_t * mp)
843{
844 vnet_main_t *vnm = vnet_get_main ();
845 vl_api_sw_interface_tag_add_del_reply_t *rmp;
846 int rv = 0;
847 u8 *tag;
848 u32 sw_if_index = ntohl (mp->sw_if_index);
849
850 VALIDATE_SW_IF_INDEX (mp);
851
852 if (mp->is_add)
853 {
Ole Trøan3b0d7e42019-03-15 16:14:41 +0000854 if (mp->tag[0] == 0)
Dave Barach6d963c22016-12-05 09:50:05 -0500855 {
856 rv = VNET_API_ERROR_INVALID_VALUE;
857 goto out;
858 }
859
Ole Trøan3b0d7e42019-03-15 16:14:41 +0000860 mp->tag[ARRAY_LEN (mp->tag) - 1] = 0;
861 tag = format (0, "%s%c", mp->tag, 0);
Dave Barach6d963c22016-12-05 09:50:05 -0500862 vnet_set_sw_interface_tag (vnm, tag, sw_if_index);
863 }
864 else
865 vnet_clear_sw_interface_tag (vnm, sw_if_index);
866
867 BAD_SW_IF_INDEX_LABEL;
868out:
869 REPLY_MACRO (VL_API_SW_INTERFACE_TAG_ADD_DEL_REPLY);
870}
871
Jon Loeliger10c273b2017-03-30 08:39:33 -0500872static void vl_api_sw_interface_set_mac_address_t_handler
873 (vl_api_sw_interface_set_mac_address_t * mp)
874{
875 vl_api_sw_interface_set_mac_address_reply_t *rmp;
876 vnet_main_t *vnm = vnet_get_main ();
877 u32 sw_if_index = ntohl (mp->sw_if_index);
Neale Rannsd867a7c2017-10-04 02:29:07 -0700878 vnet_sw_interface_t *si;
Jon Loeliger10c273b2017-03-30 08:39:33 -0500879 clib_error_t *error;
880 int rv = 0;
881
882 VALIDATE_SW_IF_INDEX (mp);
883
Neale Rannsd867a7c2017-10-04 02:29:07 -0700884 si = vnet_get_sw_interface (vnm, sw_if_index);
Ole Trøan3b0d7e42019-03-15 16:14:41 +0000885 error = vnet_hw_interface_change_mac_address (vnm, si->hw_if_index,
886 mp->mac_address);
Jon Loeliger10c273b2017-03-30 08:39:33 -0500887 if (error)
888 {
889 rv = VNET_API_ERROR_UNIMPLEMENTED;
890 clib_error_report (error);
891 goto out;
892 }
893
894 BAD_SW_IF_INDEX_LABEL;
895out:
896 REPLY_MACRO (VL_API_SW_INTERFACE_SET_MAC_ADDRESS_REPLY);
897}
898
Juraj Slobodac0374232018-02-01 15:18:49 +0100899static void vl_api_sw_interface_get_mac_address_t_handler
900 (vl_api_sw_interface_get_mac_address_t * mp)
901{
902 vl_api_sw_interface_get_mac_address_reply_t *rmp;
903 vl_api_registration_t *reg;
904 vnet_main_t *vnm = vnet_get_main ();
905 u32 sw_if_index = ntohl (mp->sw_if_index);
906 vnet_sw_interface_t *si;
907 ethernet_interface_t *eth_if = 0;
908 int rv = 0;
909
910 VALIDATE_SW_IF_INDEX (mp);
911
912 si = vnet_get_sup_sw_interface (vnm, sw_if_index);
913 if (si->type == VNET_SW_INTERFACE_TYPE_HARDWARE)
914 eth_if = ethernet_get_interface (&ethernet_main, si->hw_if_index);
915
916 BAD_SW_IF_INDEX_LABEL;
917
918 reg = vl_api_client_index_to_registration (mp->client_index);
919 if (!reg)
920 return;
921 rmp = vl_msg_api_alloc (sizeof (*rmp));
922 rmp->_vl_msg_id = htons (VL_API_SW_INTERFACE_GET_MAC_ADDRESS_REPLY);
923 rmp->context = mp->context;
924 rmp->retval = htonl (rv);
925 if (!rv && eth_if)
Ole Trøan3b0d7e42019-03-15 16:14:41 +0000926 memcpy (rmp->mac_address, eth_if->address, 6);
Juraj Slobodac0374232018-02-01 15:18:49 +0100927 vl_api_send_msg (reg, (u8 *) rmp);
928}
929
Stevenad8015b2017-10-29 22:10:46 -0700930static void vl_api_sw_interface_set_rx_mode_t_handler
931 (vl_api_sw_interface_set_rx_mode_t * mp)
932{
933 vl_api_sw_interface_set_rx_mode_reply_t *rmp;
934 vnet_main_t *vnm = vnet_get_main ();
935 u32 sw_if_index = ntohl (mp->sw_if_index);
936 vnet_sw_interface_t *si;
937 clib_error_t *error;
938 int rv = 0;
939
940 VALIDATE_SW_IF_INDEX (mp);
941
942 si = vnet_get_sw_interface (vnm, sw_if_index);
Mohsin Kazmi54f7c512018-08-23 18:28:11 +0200943 if (si->type != VNET_SW_INTERFACE_TYPE_HARDWARE)
944 {
945 rv = VNET_API_ERROR_INVALID_VALUE;
946 goto bad_sw_if_index;
947 }
948
Stevenad8015b2017-10-29 22:10:46 -0700949 error = set_hw_interface_change_rx_mode (vnm, si->hw_if_index,
950 mp->queue_id_valid,
951 ntohl (mp->queue_id), mp->mode);
952 if (error)
953 {
954 rv = VNET_API_ERROR_UNIMPLEMENTED;
955 clib_error_report (error);
956 goto out;
957 }
958
959 BAD_SW_IF_INDEX_LABEL;
960out:
961 REPLY_MACRO (VL_API_SW_INTERFACE_SET_RX_MODE_REPLY);
962}
963
Mohsin Kazmif0b42f42018-09-10 18:11:00 +0200964static void
965send_interface_rx_placement_details (vpe_api_main_t * am,
966 vl_api_registration_t * rp,
967 u32 sw_if_index, u32 worker_id,
968 u32 queue_id, u8 mode, u32 context)
969{
970 vl_api_sw_interface_rx_placement_details_t *mp;
971 mp = vl_msg_api_alloc (sizeof (*mp));
Dave Barachb7b92992018-10-17 10:38:51 -0400972 clib_memset (mp, 0, sizeof (*mp));
Mohsin Kazmif0b42f42018-09-10 18:11:00 +0200973
974 mp->_vl_msg_id = htons (VL_API_SW_INTERFACE_RX_PLACEMENT_DETAILS);
975 mp->sw_if_index = htonl (sw_if_index);
976 mp->queue_id = htonl (queue_id);
977 mp->worker_id = htonl (worker_id);
978 mp->mode = mode;
979 mp->context = context;
980
981 vl_api_send_msg (rp, (u8 *) mp);
982}
983
984static void vl_api_sw_interface_rx_placement_dump_t_handler
985 (vl_api_sw_interface_rx_placement_dump_t * mp)
986{
987 vnet_main_t *vnm = vnet_get_main ();
988 vpe_api_main_t *am = &vpe_api_main;
989 u32 sw_if_index = ntohl (mp->sw_if_index);
990 vl_api_registration_t *reg;
991
992 reg = vl_api_client_index_to_registration (mp->client_index);
993 if (!reg)
994 return;
995
996 if (sw_if_index == ~0)
997 {
998 vnet_device_input_runtime_t *rt;
999 vnet_device_and_queue_t *dq;
1000 vlib_node_t *pn = vlib_get_node_by_name (am->vlib_main,
1001 (u8 *) "device-input");
1002 uword si;
1003 int index = 0;
1004
1005 /* *INDENT-OFF* */
1006 foreach_vlib_main (({
1007 clib_bitmap_foreach (si, pn->sibling_bitmap,
1008 ({
1009 rt = vlib_node_get_runtime_data (this_vlib_main, si);
1010 vec_foreach (dq, rt->devices_and_queues)
1011 {
1012 vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm,
1013 dq->hw_if_index);
1014 send_interface_rx_placement_details (am, reg, hw->sw_if_index, index,
1015 dq->queue_id, dq->mode, mp->context);
1016 }
1017 }));
1018 index++;
1019 }));
1020 /* *INDENT-ON* */
1021 }
1022 else
1023 {
1024 int i;
1025 vnet_sw_interface_t *si;
1026
1027 if (!vnet_sw_if_index_is_api_valid (sw_if_index))
1028 {
1029 clib_warning ("sw_if_index %u does not exist", sw_if_index);
1030 goto bad_sw_if_index;
1031 }
1032
1033 si = vnet_get_sw_interface (vnm, sw_if_index);
1034 if (si->type != VNET_SW_INTERFACE_TYPE_HARDWARE)
1035 {
1036 clib_warning ("interface type is not HARDWARE! P2P, PIPE and SUB"
1037 " interfaces are not supported");
1038 goto bad_sw_if_index;
1039 }
1040
1041 vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm, si->hw_if_index);
1042
1043 for (i = 0; i < vec_len (hw->dq_runtime_index_by_queue); i++)
1044 {
1045 send_interface_rx_placement_details (am, reg, hw->sw_if_index,
1046 hw->input_node_thread_index_by_queue
1047 [i], i,
1048 hw->rx_mode_by_queue[i],
1049 mp->context);
1050 }
1051 }
1052
1053 BAD_SW_IF_INDEX_LABEL;
1054}
1055
Mohsin Kazmi54f7c512018-08-23 18:28:11 +02001056static void vl_api_sw_interface_set_rx_placement_t_handler
1057 (vl_api_sw_interface_set_rx_placement_t * mp)
1058{
1059 vl_api_sw_interface_set_rx_placement_reply_t *rmp;
1060 vnet_main_t *vnm = vnet_get_main ();
1061 u32 sw_if_index = ntohl (mp->sw_if_index);
1062 vnet_sw_interface_t *si;
1063 clib_error_t *error = 0;
1064 int rv = 0;
1065
1066 VALIDATE_SW_IF_INDEX (mp);
1067
1068 si = vnet_get_sw_interface (vnm, sw_if_index);
1069 if (si->type != VNET_SW_INTERFACE_TYPE_HARDWARE)
1070 {
1071 rv = VNET_API_ERROR_INVALID_VALUE;
1072 goto bad_sw_if_index;
1073 }
1074
1075 error = set_hw_interface_rx_placement (si->hw_if_index,
1076 ntohl (mp->queue_id),
1077 ntohl (mp->worker_id), mp->is_main);
1078 if (error)
1079 {
1080 rv = VNET_API_ERROR_UNIMPLEMENTED;
1081 clib_error_report (error);
1082 goto out;
1083 }
1084
1085 BAD_SW_IF_INDEX_LABEL;
1086out:
1087 REPLY_MACRO (VL_API_SW_INTERFACE_SET_RX_PLACEMENT_REPLY);
1088}
1089
Neale Rannsb8d44812017-11-10 06:53:54 -08001090static void
1091vl_api_create_vlan_subif_t_handler (vl_api_create_vlan_subif_t * mp)
1092{
1093 vl_api_create_vlan_subif_reply_t *rmp;
1094 vnet_main_t *vnm = vnet_get_main ();
1095 u32 sw_if_index = (u32) ~ 0;
1096 vnet_hw_interface_t *hi;
1097 int rv = 0;
1098 u32 id;
1099 vnet_sw_interface_t template;
1100 uword *p;
1101 vnet_interface_main_t *im = &vnm->interface_main;
1102 u64 sup_and_sub_key;
Florin Coras6c4dae22018-01-09 06:39:23 -08001103 vl_api_registration_t *reg;
Neale Rannsb8d44812017-11-10 06:53:54 -08001104 clib_error_t *error;
1105
1106 VALIDATE_SW_IF_INDEX (mp);
1107
1108 hi = vnet_get_sup_hw_interface (vnm, ntohl (mp->sw_if_index));
1109
1110 if (hi->bond_info == VNET_HW_INTERFACE_BOND_INFO_SLAVE)
1111 {
1112 rv = VNET_API_ERROR_BOND_SLAVE_NOT_ALLOWED;
1113 goto out;
1114 }
1115
1116 id = ntohl (mp->vlan_id);
1117 if (id == 0 || id > 4095)
1118 {
1119 rv = VNET_API_ERROR_INVALID_VLAN;
1120 goto out;
1121 }
1122
1123 sup_and_sub_key = ((u64) (hi->sw_if_index) << 32) | (u64) id;
1124
1125 p = hash_get_mem (im->sw_if_index_by_sup_and_sub, &sup_and_sub_key);
1126 if (p)
1127 {
1128 rv = VNET_API_ERROR_VLAN_ALREADY_EXISTS;
1129 goto out;
1130 }
1131
Dave Barachb7b92992018-10-17 10:38:51 -04001132 clib_memset (&template, 0, sizeof (template));
Neale Rannsb8d44812017-11-10 06:53:54 -08001133 template.type = VNET_SW_INTERFACE_TYPE_SUB;
Joe Zhou715f94e2019-03-06 23:05:32 -08001134 template.flood_class = VNET_FLOOD_CLASS_NORMAL;
Neale Rannsb8d44812017-11-10 06:53:54 -08001135 template.sup_sw_if_index = hi->sw_if_index;
1136 template.sub.id = id;
1137 template.sub.eth.raw_flags = 0;
1138 template.sub.eth.flags.one_tag = 1;
1139 template.sub.eth.outer_vlan_id = id;
1140 template.sub.eth.flags.exact_match = 1;
1141
1142 error = vnet_create_sw_interface (vnm, &template, &sw_if_index);
1143 if (error)
1144 {
1145 clib_error_report (error);
1146 rv = VNET_API_ERROR_INVALID_REGISTRATION;
1147 goto out;
1148 }
1149
1150 u64 *kp = clib_mem_alloc (sizeof (*kp));
1151 *kp = sup_and_sub_key;
1152
1153 hash_set (hi->sub_interface_sw_if_index_by_id, id, sw_if_index);
1154 hash_set_mem (im->sw_if_index_by_sup_and_sub, kp, sw_if_index);
1155
1156 BAD_SW_IF_INDEX_LABEL;
1157
1158out:
Florin Coras6c4dae22018-01-09 06:39:23 -08001159 reg = vl_api_client_index_to_registration (mp->client_index);
1160 if (!reg)
Neale Rannsb8d44812017-11-10 06:53:54 -08001161 return;
1162
1163 rmp = vl_msg_api_alloc (sizeof (*rmp));
1164 rmp->_vl_msg_id = htons (VL_API_CREATE_VLAN_SUBIF_REPLY);
1165 rmp->context = mp->context;
1166 rmp->retval = htonl (rv);
1167 rmp->sw_if_index = htonl (sw_if_index);
Florin Coras6c4dae22018-01-09 06:39:23 -08001168 vl_api_send_msg (reg, (u8 *) rmp);
Neale Rannsb8d44812017-11-10 06:53:54 -08001169}
1170
1171static void
1172vl_api_create_subif_t_handler (vl_api_create_subif_t * mp)
1173{
1174 vl_api_create_subif_reply_t *rmp;
1175 vnet_main_t *vnm = vnet_get_main ();
1176 u32 sw_if_index = ~0;
1177 int rv = 0;
1178 u32 sub_id;
1179 vnet_sw_interface_t *si;
1180 vnet_hw_interface_t *hi;
1181 vnet_sw_interface_t template;
1182 uword *p;
1183 vnet_interface_main_t *im = &vnm->interface_main;
1184 u64 sup_and_sub_key;
1185 clib_error_t *error;
1186
1187 VALIDATE_SW_IF_INDEX (mp);
1188
1189 si = vnet_get_sup_sw_interface (vnm, ntohl (mp->sw_if_index));
1190 hi = vnet_get_sup_hw_interface (vnm, ntohl (mp->sw_if_index));
1191
1192 if (hi->bond_info == VNET_HW_INTERFACE_BOND_INFO_SLAVE)
1193 {
1194 rv = VNET_API_ERROR_BOND_SLAVE_NOT_ALLOWED;
1195 goto out;
1196 }
1197
1198 sw_if_index = si->sw_if_index;
1199 sub_id = ntohl (mp->sub_id);
1200
1201 sup_and_sub_key = ((u64) (sw_if_index) << 32) | (u64) sub_id;
1202
1203 p = hash_get_mem (im->sw_if_index_by_sup_and_sub, &sup_and_sub_key);
1204 if (p)
1205 {
1206 if (CLIB_DEBUG > 0)
1207 clib_warning ("sup sw_if_index %d, sub id %d already exists\n",
1208 sw_if_index, sub_id);
1209 rv = VNET_API_ERROR_SUBIF_ALREADY_EXISTS;
1210 goto out;
1211 }
1212
Dave Barachb7b92992018-10-17 10:38:51 -04001213 clib_memset (&template, 0, sizeof (template));
Neale Rannsb8d44812017-11-10 06:53:54 -08001214 template.type = VNET_SW_INTERFACE_TYPE_SUB;
Joe Zhou715f94e2019-03-06 23:05:32 -08001215 template.flood_class = VNET_FLOOD_CLASS_NORMAL;
Neale Rannsb8d44812017-11-10 06:53:54 -08001216 template.sup_sw_if_index = sw_if_index;
1217 template.sub.id = sub_id;
Ole Trøan3b0d7e42019-03-15 16:14:41 +00001218 template.sub.eth.flags.no_tags = mp->no_tags;
1219 template.sub.eth.flags.one_tag = mp->one_tag;
1220 template.sub.eth.flags.two_tags = mp->two_tags;
1221 template.sub.eth.flags.dot1ad = mp->dot1ad;
1222 template.sub.eth.flags.exact_match = mp->exact_match;
1223 template.sub.eth.flags.default_sub = mp->default_sub;
1224 template.sub.eth.flags.outer_vlan_id_any = mp->outer_vlan_id_any;
1225 template.sub.eth.flags.inner_vlan_id_any = mp->inner_vlan_id_any;
Neale Rannsb8d44812017-11-10 06:53:54 -08001226 template.sub.eth.outer_vlan_id = ntohs (mp->outer_vlan_id);
1227 template.sub.eth.inner_vlan_id = ntohs (mp->inner_vlan_id);
1228
1229 error = vnet_create_sw_interface (vnm, &template, &sw_if_index);
1230 if (error)
1231 {
1232 clib_error_report (error);
1233 rv = VNET_API_ERROR_SUBIF_CREATE_FAILED;
1234 goto out;
1235 }
1236
1237 u64 *kp = clib_mem_alloc (sizeof (*kp));
1238 *kp = sup_and_sub_key;
1239
1240 hash_set (hi->sub_interface_sw_if_index_by_id, sub_id, sw_if_index);
1241 hash_set_mem (im->sw_if_index_by_sup_and_sub, kp, sw_if_index);
1242
1243 BAD_SW_IF_INDEX_LABEL;
1244
1245out:
1246
1247 /* *INDENT-OFF* */
1248 REPLY_MACRO2(VL_API_CREATE_SUBIF_REPLY,
1249 ({
1250 rmp->sw_if_index = ntohl(sw_if_index);
1251 }));
1252 /* *INDENT-ON* */
1253}
1254
1255static void
1256vl_api_delete_subif_t_handler (vl_api_delete_subif_t * mp)
1257{
1258 vl_api_delete_subif_reply_t *rmp;
1259 int rv;
1260
1261 rv = vnet_delete_sub_interface (ntohl (mp->sw_if_index));
1262
1263 REPLY_MACRO (VL_API_DELETE_SUBIF_REPLY);
1264}
1265
1266static void
1267vl_api_interface_name_renumber_t_handler (vl_api_interface_name_renumber_t *
1268 mp)
1269{
1270 vl_api_interface_name_renumber_reply_t *rmp;
1271 int rv = 0;
1272
1273 VALIDATE_SW_IF_INDEX (mp);
1274
1275 rv = vnet_interface_name_renumber
1276 (ntohl (mp->sw_if_index), ntohl (mp->new_show_dev_instance));
1277
1278 BAD_SW_IF_INDEX_LABEL;
1279
1280 REPLY_MACRO (VL_API_INTERFACE_NAME_RENUMBER_REPLY);
1281}
1282
1283static void
1284vl_api_create_loopback_t_handler (vl_api_create_loopback_t * mp)
1285{
1286 vl_api_create_loopback_reply_t *rmp;
1287 u32 sw_if_index;
1288 int rv;
1289
Ole Trøan3b0d7e42019-03-15 16:14:41 +00001290 rv = vnet_create_loopback_interface (&sw_if_index, mp->mac_address, 0, 0);
Neale Rannsb8d44812017-11-10 06:53:54 -08001291
1292 /* *INDENT-OFF* */
1293 REPLY_MACRO2(VL_API_CREATE_LOOPBACK_REPLY,
1294 ({
1295 rmp->sw_if_index = ntohl (sw_if_index);
1296 }));
1297 /* *INDENT-ON* */
1298}
1299
1300static void vl_api_create_loopback_instance_t_handler
1301 (vl_api_create_loopback_instance_t * mp)
1302{
1303 vl_api_create_loopback_instance_reply_t *rmp;
1304 u32 sw_if_index;
1305 u8 is_specified = mp->is_specified;
1306 u32 user_instance = ntohl (mp->user_instance);
1307 int rv;
1308
Ole Trøan3b0d7e42019-03-15 16:14:41 +00001309 rv = vnet_create_loopback_interface (&sw_if_index, mp->mac_address,
Neale Rannsb8d44812017-11-10 06:53:54 -08001310 is_specified, user_instance);
1311
1312 /* *INDENT-OFF* */
1313 REPLY_MACRO2(VL_API_CREATE_LOOPBACK_INSTANCE_REPLY,
1314 ({
1315 rmp->sw_if_index = ntohl (sw_if_index);
1316 }));
1317 /* *INDENT-ON* */
1318}
1319
1320static void
1321vl_api_delete_loopback_t_handler (vl_api_delete_loopback_t * mp)
1322{
1323 vl_api_delete_loopback_reply_t *rmp;
1324 u32 sw_if_index;
1325 int rv;
1326
1327 sw_if_index = ntohl (mp->sw_if_index);
1328 rv = vnet_delete_loopback_interface (sw_if_index);
1329
1330 REPLY_MACRO (VL_API_DELETE_LOOPBACK_REPLY);
1331}
1332
Neale Ranns6f4a6be2018-03-16 16:26:21 -07001333static void
1334 vl_api_collect_detailed_interface_stats_t_handler
1335 (vl_api_collect_detailed_interface_stats_t * mp)
1336{
1337 vl_api_collect_detailed_interface_stats_reply_t *rmp;
1338 int rv = 0;
1339
Neale Ranns871dc422018-03-29 01:28:09 -07001340 rv =
1341 vnet_sw_interface_stats_collect_enable_disable (ntohl (mp->sw_if_index),
1342 mp->enable_disable);
Neale Ranns6f4a6be2018-03-16 16:26:21 -07001343
1344 REPLY_MACRO (VL_API_COLLECT_DETAILED_INTERFACE_STATS_REPLY);
1345}
1346
Dave Barachaff70772016-10-31 11:59:07 -04001347/*
1348 * vpe_api_hookup
1349 * Add vpe's API message handlers to the table.
Paul Vinciguerrabdc0e6b2018-09-22 05:32:50 -07001350 * vlib has already mapped shared memory and
Dave Barachaff70772016-10-31 11:59:07 -04001351 * added the client registration handlers.
1352 * See .../vlib-api/vlibmemory/memclnt_vlib.c:memclnt_process()
1353 */
1354#define vl_msg_name_crc_list
Dave Barachb5e8a772016-12-06 12:04:42 -05001355#include <vnet/interface.api.h>
Dave Barachaff70772016-10-31 11:59:07 -04001356#undef vl_msg_name_crc_list
1357
1358static void
1359setup_message_id_table (api_main_t * am)
1360{
1361#define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id);
1362 foreach_vl_msg_name_crc_interface;
1363#undef _
1364}
1365
Dave Barach6d963c22016-12-05 09:50:05 -05001366pub_sub_handler (interface_events, INTERFACE_EVENTS);
1367
Dave Barachaff70772016-10-31 11:59:07 -04001368static clib_error_t *
1369interface_api_hookup (vlib_main_t * vm)
1370{
1371 api_main_t *am = &api_main;
1372
1373#define _(N,n) \
1374 vl_msg_api_set_handlers(VL_API_##N, #n, \
1375 vl_api_##n##_t_handler, \
1376 vl_noop_handler, \
1377 vl_api_##n##_t_endian, \
1378 vl_api_##n##_t_print, \
1379 sizeof(vl_api_##n##_t), 1);
1380 foreach_vpe_api_msg;
1381#undef _
1382
Steven Luongc5fa2b82019-04-25 11:19:49 -07001383 /* Mark these APIs as mp safe */
1384 am->is_mp_safe[VL_API_SW_INTERFACE_DUMP] = 1;
1385 am->is_mp_safe[VL_API_SW_INTERFACE_DETAILS] = 1;
1386 am->is_mp_safe[VL_API_SW_INTERFACE_TAG_ADD_DEL] = 1;
1387
Dave Barachaff70772016-10-31 11:59:07 -04001388 /*
1389 * Set up the (msg_name, crc, message-id) table
1390 */
1391 setup_message_id_table (am);
1392
1393 return 0;
1394}
1395
1396VLIB_API_INIT_FUNCTION (interface_api_hookup);
1397
1398/*
1399 * fd.io coding-style-patch-verification: ON
1400 *
1401 * Local Variables:
1402 * eval: (c-set-style "gnu")
1403 * End:
1404 */