Dave Barach | aff7077 | 2016-10-31 11:59:07 -0400 | [diff] [blame] | 1 | /* |
| 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 Fabian | d162f3d | 2016-12-05 01:05:35 -0800 | [diff] [blame] | 25 | #include <vnet/ethernet/ethernet.h> |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 26 | #include <vnet/ip/ip.h> |
| 27 | #include <vnet/fib/fib_table.h> |
Neale Ranns | 4008ac9 | 2017-02-13 23:20:04 -0800 | [diff] [blame] | 28 | #include <vnet/mfib/mfib_table.h> |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 29 | #include <vnet/l2/l2_vtr.h> |
Dave Barach | aff7077 | 2016-10-31 11:59:07 -0400 | [diff] [blame] | 30 | #include <vnet/vnet_msg_enum.h> |
Dave Barach | b5e8a77 | 2016-12-06 12:04:42 -0500 | [diff] [blame] | 31 | #include <vnet/fib/fib_api.h> |
Neale Ranns | 358425b | 2017-02-20 09:42:36 -0800 | [diff] [blame] | 32 | #include <vnet/mfib/mfib_table.h> |
Dave Barach | aff7077 | 2016-10-31 11:59:07 -0400 | [diff] [blame] | 33 | |
| 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 Barach | f158661 | 2017-03-30 09:33:01 -0400 | [diff] [blame] | 49 | vpe_api_main_t vpe_api_main; |
Dave Barach | aff7077 | 2016-10-31 11:59:07 -0400 | [diff] [blame] | 50 | |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 51 | #define foreach_vpe_api_msg \ |
| 52 | _(SW_INTERFACE_SET_FLAGS, sw_interface_set_flags) \ |
Ole Troan | d723161 | 2018-06-07 10:17:57 +0200 | [diff] [blame] | 53 | _(HW_INTERFACE_SET_MTU, hw_interface_set_mtu) \ |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 54 | _(SW_INTERFACE_SET_MTU, sw_interface_set_mtu) \ |
| 55 | _(WANT_INTERFACE_EVENTS, want_interface_events) \ |
| 56 | _(SW_INTERFACE_DUMP, sw_interface_dump) \ |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 57 | _(SW_INTERFACE_ADD_DEL_ADDRESS, sw_interface_add_del_address) \ |
Steven | ad8015b | 2017-10-29 22:10:46 -0700 | [diff] [blame] | 58 | _(SW_INTERFACE_SET_RX_MODE, sw_interface_set_rx_mode) \ |
Mohsin Kazmi | f0b42f4 | 2018-09-10 18:11:00 +0200 | [diff] [blame] | 59 | _(SW_INTERFACE_RX_PLACEMENT_DUMP, sw_interface_rx_placement_dump) \ |
Mohsin Kazmi | 54f7c51 | 2018-08-23 18:28:11 +0200 | [diff] [blame] | 60 | _(SW_INTERFACE_SET_RX_PLACEMENT, sw_interface_set_rx_placement) \ |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 61 | _(SW_INTERFACE_SET_TABLE, sw_interface_set_table) \ |
Juraj Sloboda | dfc1923 | 2016-12-05 13:20:37 +0100 | [diff] [blame] | 62 | _(SW_INTERFACE_GET_TABLE, sw_interface_get_table) \ |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 63 | _(SW_INTERFACE_SET_UNNUMBERED, sw_interface_set_unnumbered) \ |
| 64 | _(SW_INTERFACE_CLEAR_STATS, sw_interface_clear_stats) \ |
Jon Loeliger | 10c273b | 2017-03-30 08:39:33 -0500 | [diff] [blame] | 65 | _(SW_INTERFACE_TAG_ADD_DEL, sw_interface_tag_add_del) \ |
Neale Ranns | b8d4481 | 2017-11-10 06:53:54 -0800 | [diff] [blame] | 66 | _(SW_INTERFACE_SET_MAC_ADDRESS, sw_interface_set_mac_address) \ |
Juraj Sloboda | c037423 | 2018-02-01 15:18:49 +0100 | [diff] [blame] | 67 | _(SW_INTERFACE_GET_MAC_ADDRESS, sw_interface_get_mac_address) \ |
Neale Ranns | b8d4481 | 2017-11-10 06:53:54 -0800 | [diff] [blame] | 68 | _(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 Ranns | 6f4a6be | 2018-03-16 16:26:21 -0700 | [diff] [blame] | 74 | _(INTERFACE_NAME_RENUMBER, interface_name_renumber) \ |
Neale Ranns | 1855b8e | 2018-07-11 10:31:26 -0700 | [diff] [blame] | 75 | _(COLLECT_DETAILED_INTERFACE_STATS, collect_detailed_interface_stats) \ |
| 76 | _(SW_INTERFACE_SET_IP_DIRECTED_BROADCAST, \ |
| 77 | sw_interface_set_ip_directed_broadcast) |
Dave Barach | aff7077 | 2016-10-31 11:59:07 -0400 | [diff] [blame] | 78 | |
| 79 | static void |
| 80 | vl_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øan | 3b0d7e4 | 2019-03-15 16:14:41 +0000 | [diff] [blame] | 90 | flags = mp->admin_up_down ? VNET_SW_INTERFACE_FLAG_ADMIN_UP : 0; |
Dave Barach | aff7077 | 2016-10-31 11:59:07 -0400 | [diff] [blame] | 91 | |
| 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 Fabian | d162f3d | 2016-12-05 01:05:35 -0800 | [diff] [blame] | 103 | static void |
Ole Troan | d723161 | 2018-06-07 10:17:57 +0200 | [diff] [blame] | 104 | vl_api_hw_interface_set_mtu_t_handler (vl_api_hw_interface_set_mtu_t * mp) |
Matus Fabian | d162f3d | 2016-12-05 01:05:35 -0800 | [diff] [blame] | 105 | { |
Ole Troan | d723161 | 2018-06-07 10:17:57 +0200 | [diff] [blame] | 106 | vl_api_hw_interface_set_mtu_reply_t *rmp; |
Matus Fabian | d162f3d | 2016-12-05 01:05:35 -0800 | [diff] [blame] | 107 | vnet_main_t *vnm = vnet_get_main (); |
Matus Fabian | d162f3d | 2016-12-05 01:05:35 -0800 | [diff] [blame] | 108 | u32 sw_if_index = ntohl (mp->sw_if_index); |
| 109 | u16 mtu = ntohs (mp->mtu); |
Damjan Marion | fe7d4a2 | 2018-04-13 19:43:39 +0200 | [diff] [blame] | 110 | ethernet_main_t *em = ðernet_main; |
Matus Fabian | d162f3d | 2016-12-05 01:05:35 -0800 | [diff] [blame] | 111 | int rv = 0; |
| 112 | |
| 113 | VALIDATE_SW_IF_INDEX (mp); |
| 114 | |
Damjan Marion | fe7d4a2 | 2018-04-13 19:43:39 +0200 | [diff] [blame] | 115 | 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 Fabian | d162f3d | 2016-12-05 01:05:35 -0800 | [diff] [blame] | 144 | |
| 145 | BAD_SW_IF_INDEX_LABEL; |
Ole Troan | d723161 | 2018-06-07 10:17:57 +0200 | [diff] [blame] | 146 | REPLY_MACRO (VL_API_HW_INTERFACE_SET_MTU_REPLY); |
| 147 | } |
| 148 | |
| 149 | static void |
| 150 | vl_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 Fabian | d162f3d | 2016-12-05 01:05:35 -0800 | [diff] [blame] | 167 | REPLY_MACRO (VL_API_SW_INTERFACE_SET_MTU_REPLY); |
| 168 | } |
| 169 | |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 170 | static void |
Neale Ranns | 1855b8e | 2018-07-11 10:31:26 -0700 | [diff] [blame] | 171 | 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 | |
| 187 | static void |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 188 | send_sw_interface_details (vpe_api_main_t * am, |
Dave Barach | 59b2565 | 2017-09-10 15:04:27 -0400 | [diff] [blame] | 189 | vl_api_registration_t * rp, |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 190 | vnet_sw_interface_t * swif, |
| 191 | u8 * interface_name, u32 context) |
| 192 | { |
Eyal Bari | 1c82cd4 | 2017-03-14 14:39:51 +0200 | [diff] [blame] | 193 | vnet_hw_interface_t *hi = |
| 194 | vnet_get_sup_hw_interface (am->vnet_main, swif->sw_if_index); |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 195 | |
Ole Trøan | 3b0d7e4 | 2019-03-15 16:14:41 +0000 | [diff] [blame] | 196 | vl_api_sw_interface_details_t *mp = vl_msg_api_alloc (sizeof (*mp)); |
| 197 | clib_memset (mp, 0, sizeof (*mp)); |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 198 | 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øan | 3b0d7e4 | 2019-03-15 16:14:41 +0000 | [diff] [blame] | 201 | 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 Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 203 | mp->link_duplex = ((hi->flags & VNET_HW_INTERFACE_FLAG_DUPLEX_MASK) >> |
| 204 | VNET_HW_INTERFACE_FLAG_DUPLEX_SHIFT); |
Ole Troan | 8ee7251 | 2018-11-20 11:03:10 +0100 | [diff] [blame] | 205 | mp->link_speed = ntohl (hi->link_speed); |
Damjan Marion | fe7d4a2 | 2018-04-13 19:43:39 +0200 | [diff] [blame] | 206 | mp->link_mtu = ntohs (hi->max_packet_bytes); |
Ole Troan | d723161 | 2018-06-07 10:17:57 +0200 | [diff] [blame] | 207 | 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 Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 212 | mp->context = context; |
| 213 | |
Ole Trøan | 3b0d7e4 | 2019-03-15 16:14:41 +0000 | [diff] [blame] | 214 | strncpy ((char *) mp->interface_name, |
| 215 | (char *) interface_name, ARRAY_LEN (mp->interface_name) - 1); |
| 216 | |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 217 | /* 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øan | 3b0d7e4 | 2019-03-15 16:14:41 +0000 | [diff] [blame] | 226 | clib_memcpy (mp->l2_address, ei->address, sizeof (ei->address)); |
| 227 | mp->l2_address_length = ntohl (sizeof (ei->address)); |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 228 | } |
| 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øan | 3b0d7e4 | 2019-03-15 16:14:41 +0000 | [diff] [blame] | 233 | mp->sub_dot1ad = sub->eth.flags.dot1ad; |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 234 | 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øan | 3b0d7e4 | 2019-03-15 16:14:41 +0000 | [diff] [blame] | 238 | 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; |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 242 | |
| 243 | /* vlan tag rewrite data */ |
| 244 | u32 vtr_op = L2_VTR_DISABLED; |
| 245 | u32 vtr_push_dot1q = 0, vtr_tag1 = 0, vtr_tag2 = 0; |
| 246 | |
| 247 | if (l2vtr_get (am->vlib_main, am->vnet_main, swif->sw_if_index, |
| 248 | &vtr_op, &vtr_push_dot1q, &vtr_tag1, &vtr_tag2) != 0) |
| 249 | { |
| 250 | // error - default to disabled |
| 251 | mp->vtr_op = ntohl (L2_VTR_DISABLED); |
| 252 | clib_warning ("cannot get vlan tag rewrite for sw_if_index %d", |
| 253 | swif->sw_if_index); |
| 254 | } |
| 255 | else |
| 256 | { |
| 257 | mp->vtr_op = ntohl (vtr_op); |
| 258 | mp->vtr_push_dot1q = ntohl (vtr_push_dot1q); |
| 259 | mp->vtr_tag1 = ntohl (vtr_tag1); |
| 260 | mp->vtr_tag2 = ntohl (vtr_tag2); |
| 261 | } |
| 262 | } |
| 263 | |
Pavel Kotucek | 65e8457 | 2017-01-16 17:01:56 +0100 | [diff] [blame] | 264 | /* pbb tag rewrite data */ |
Gabriel Ganne | f7f2a9f | 2017-03-06 15:19:40 +0100 | [diff] [blame] | 265 | ethernet_header_t eth_hdr; |
Pavel Kotucek | 65e8457 | 2017-01-16 17:01:56 +0100 | [diff] [blame] | 266 | u32 vtr_op = L2_VTR_DISABLED; |
| 267 | u16 outer_tag = 0; |
Pavel Kotucek | 65e8457 | 2017-01-16 17:01:56 +0100 | [diff] [blame] | 268 | u16 b_vlanid = 0; |
| 269 | u32 i_sid = 0; |
Dave Barach | b7b9299 | 2018-10-17 10:38:51 -0400 | [diff] [blame] | 270 | clib_memset (ð_hdr, 0, sizeof (eth_hdr)); |
Pavel Kotucek | 65e8457 | 2017-01-16 17:01:56 +0100 | [diff] [blame] | 271 | |
| 272 | if (!l2pbb_get (am->vlib_main, am->vnet_main, swif->sw_if_index, |
Gabriel Ganne | f7f2a9f | 2017-03-06 15:19:40 +0100 | [diff] [blame] | 273 | &vtr_op, &outer_tag, ð_hdr, &b_vlanid, &i_sid)) |
Pavel Kotucek | 65e8457 | 2017-01-16 17:01:56 +0100 | [diff] [blame] | 274 | { |
Ole Trøan | 3b0d7e4 | 2019-03-15 16:14:41 +0000 | [diff] [blame] | 275 | 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 Kotucek | 65e8457 | 2017-01-16 17:01:56 +0100 | [diff] [blame] | 280 | mp->b_vlanid = b_vlanid; |
| 281 | mp->i_sid = i_sid; |
| 282 | } |
| 283 | |
Ole Trøan | 3b0d7e4 | 2019-03-15 16:14:41 +0000 | [diff] [blame] | 284 | 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 Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 287 | |
Florin Coras | e86a8ed | 2018-01-05 03:20:25 -0800 | [diff] [blame] | 288 | vl_api_send_msg (rp, (u8 *) mp); |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 289 | } |
| 290 | |
| 291 | static void |
| 292 | vl_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 Barach | 59b2565 | 2017-09-10 15:04:27 -0400 | [diff] [blame] | 297 | vl_api_registration_t *rp; |
Paul Vinciguerra | 6407ba5 | 2019-04-04 13:22:20 -0700 | [diff] [blame] | 298 | u32 sw_if_index; |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 299 | |
Dave Barach | 59b2565 | 2017-09-10 15:04:27 -0400 | [diff] [blame] | 300 | 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 Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 307 | |
Eyal Bari | 1c82cd4 | 2017-03-14 14:39:51 +0200 | [diff] [blame] | 308 | u8 *filter = 0, *name = 0; |
Paul Vinciguerra | 6407ba5 | 2019-04-04 13:22:20 -0700 | [diff] [blame] | 309 | sw_if_index = ntohl (mp->sw_if_index); |
| 310 | |
Vratko Polak | b8591ac | 2019-04-23 12:26:44 +0200 | [diff] [blame] | 311 | if (!mp->name_filter_valid && sw_if_index != ~0 && sw_if_index != 0) |
Paul Vinciguerra | 6407ba5 | 2019-04-04 13:22:20 -0700 | [diff] [blame] | 312 | { |
Vratko Polak | b8591ac | 2019-04-23 12:26:44 +0200 | [diff] [blame] | 313 | /* is it a valid sw_if_index? */ |
Paul Vinciguerra | 6407ba5 | 2019-04-04 13:22:20 -0700 | [diff] [blame] | 314 | if (vec_len (im->sw_interfaces) <= sw_if_index) |
| 315 | return; |
| 316 | |
| 317 | swif = vec_elt_at_index (im->sw_interfaces, sw_if_index); |
| 318 | |
Paul Vinciguerra | 6407ba5 | 2019-04-04 13:22:20 -0700 | [diff] [blame] | 319 | 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 Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 328 | if (mp->name_filter_valid) |
| 329 | { |
Ole Trøan | 3b0d7e4 | 2019-03-15 16:14:41 +0000 | [diff] [blame] | 330 | mp->name_filter[ARRAY_LEN (mp->name_filter) - 1] = 0; |
| 331 | filter = format (0, "%s%c", mp->name_filter, 0); |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 332 | } |
| 333 | |
Eyal Bari | 1c82cd4 | 2017-03-14 14:39:51 +0200 | [diff] [blame] | 334 | char *strcasestr (char *, char *); /* lnx hdr file botch */ |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 335 | /* *INDENT-OFF* */ |
| 336 | pool_foreach (swif, im->sw_interfaces, |
| 337 | ({ |
Eyal Bari | 1c82cd4 | 2017-03-14 14:39:51 +0200 | [diff] [blame] | 338 | 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 Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 343 | |
Eyal Bari | 1c82cd4 | 2017-03-14 14:39:51 +0200 | [diff] [blame] | 344 | if (filter && !strcasestr((char *) name, (char *) filter)) |
| 345 | continue; |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 346 | |
Dave Barach | 59b2565 | 2017-09-10 15:04:27 -0400 | [diff] [blame] | 347 | send_sw_interface_details (am, rp, swif, name, mp->context); |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 348 | })); |
| 349 | /* *INDENT-ON* */ |
| 350 | |
Eyal Bari | 1c82cd4 | 2017-03-14 14:39:51 +0200 | [diff] [blame] | 351 | vec_free (name); |
| 352 | vec_free (filter); |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 353 | } |
| 354 | |
| 355 | static 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 Loeliger | 35ffa3e | 2017-09-28 13:54:16 -0500 | [diff] [blame] | 360 | vnet_main_t *vnm = vnet_get_main (); |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 361 | vl_api_sw_interface_add_del_address_reply_t *rmp; |
| 362 | int rv = 0; |
| 363 | u32 is_del; |
Jon Loeliger | 35ffa3e | 2017-09-28 13:54:16 -0500 | [diff] [blame] | 364 | clib_error_t *error = 0; |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 365 | |
| 366 | VALIDATE_SW_IF_INDEX (mp); |
| 367 | |
| 368 | is_del = mp->is_add == 0; |
Jon Loeliger | 35ffa3e | 2017-09-28 13:54:16 -0500 | [diff] [blame] | 369 | vnm->api_errno = 0; |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 370 | |
| 371 | if (mp->del_all) |
| 372 | ip_del_all_interface_addresses (vm, ntohl (mp->sw_if_index)); |
Ole Trøan | 3b0d7e4 | 2019-03-15 16:14:41 +0000 | [diff] [blame] | 373 | else if (mp->is_ipv6) |
Jon Loeliger | 35ffa3e | 2017-09-28 13:54:16 -0500 | [diff] [blame] | 374 | error = ip6_add_del_interface_address (vm, ntohl (mp->sw_if_index), |
Ole Trøan | 3b0d7e4 | 2019-03-15 16:14:41 +0000 | [diff] [blame] | 375 | (void *) mp->address, |
| 376 | mp->address_length, is_del); |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 377 | else |
Jon Loeliger | 35ffa3e | 2017-09-28 13:54:16 -0500 | [diff] [blame] | 378 | error = ip4_add_del_interface_address (vm, ntohl (mp->sw_if_index), |
Ole Trøan | 3b0d7e4 | 2019-03-15 16:14:41 +0000 | [diff] [blame] | 379 | (void *) mp->address, |
| 380 | mp->address_length, is_del); |
Jon Loeliger | 35ffa3e | 2017-09-28 13:54:16 -0500 | [diff] [blame] | 381 | |
| 382 | if (error) |
| 383 | { |
| 384 | rv = vnm->api_errno; |
| 385 | clib_error_report (error); |
| 386 | goto done; |
| 387 | } |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 388 | |
| 389 | BAD_SW_IF_INDEX_LABEL; |
| 390 | |
Jon Loeliger | 35ffa3e | 2017-09-28 13:54:16 -0500 | [diff] [blame] | 391 | done: |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 392 | REPLY_MACRO (VL_API_SW_INTERFACE_ADD_DEL_ADDRESS_REPLY); |
| 393 | } |
| 394 | |
| 395 | void stats_dslock_with_hint (int hint, int tag) __attribute__ ((weak)); |
| 396 | void |
| 397 | stats_dslock_with_hint (int hint, int tag) |
| 398 | { |
| 399 | } |
| 400 | |
| 401 | void stats_dsunlock (void) __attribute__ ((weak)); |
| 402 | void |
| 403 | stats_dsunlock (void) |
| 404 | { |
| 405 | } |
| 406 | |
| 407 | static void |
| 408 | vl_api_sw_interface_set_table_t_handler (vl_api_sw_interface_set_table_t * mp) |
| 409 | { |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 410 | vl_api_sw_interface_set_table_reply_t *rmp; |
Neale Ranns | 1500254 | 2017-09-10 04:39:11 -0700 | [diff] [blame] | 411 | u32 sw_if_index = ntohl (mp->sw_if_index); |
| 412 | u32 table_id = ntohl (mp->vrf_id); |
| 413 | int rv = 0; |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 414 | |
| 415 | VALIDATE_SW_IF_INDEX (mp); |
| 416 | |
| 417 | stats_dslock_with_hint (1 /* release hint */ , 4 /* tag */ ); |
| 418 | |
| 419 | if (mp->is_ipv6) |
Neale Ranns | 1500254 | 2017-09-10 04:39:11 -0700 | [diff] [blame] | 420 | rv = ip_table_bind (FIB_PROTOCOL_IP6, sw_if_index, table_id, 1); |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 421 | else |
Neale Ranns | 1500254 | 2017-09-10 04:39:11 -0700 | [diff] [blame] | 422 | rv = ip_table_bind (FIB_PROTOCOL_IP4, sw_if_index, table_id, 1); |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 423 | |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 424 | stats_dsunlock (); |
| 425 | |
| 426 | BAD_SW_IF_INDEX_LABEL; |
| 427 | |
| 428 | REPLY_MACRO (VL_API_SW_INTERFACE_SET_TABLE_REPLY); |
| 429 | } |
| 430 | |
Neale Ranns | 1500254 | 2017-09-10 04:39:11 -0700 | [diff] [blame] | 431 | int |
| 432 | ip_table_bind (fib_protocol_t fproto, |
Neale Ranns | 6b3a8ef | 2017-09-11 10:34:33 -0700 | [diff] [blame] | 433 | u32 sw_if_index, u32 table_id, u8 is_api) |
Neale Ranns | 1500254 | 2017-09-10 04:39:11 -0700 | [diff] [blame] | 434 | { |
| 435 | CLIB_UNUSED (ip_interface_address_t * ia); |
| 436 | u32 fib_index, mfib_index; |
| 437 | fib_source_t src; |
| 438 | mfib_source_t msrc; |
| 439 | |
| 440 | if (is_api) |
| 441 | { |
| 442 | src = FIB_SOURCE_API; |
| 443 | msrc = MFIB_SOURCE_API; |
| 444 | } |
| 445 | else |
| 446 | { |
| 447 | src = FIB_SOURCE_CLI; |
| 448 | msrc = MFIB_SOURCE_CLI; |
| 449 | } |
| 450 | |
Florin Coras | d0a5972 | 2017-10-15 17:41:21 +0000 | [diff] [blame] | 451 | /* |
Florin Coras | d0a5972 | 2017-10-15 17:41:21 +0000 | [diff] [blame] | 452 | * This if table does not exist = error is what we want in the end. |
| 453 | */ |
Neale Ranns | 8f6dd32 | 2018-05-17 06:34:24 -0700 | [diff] [blame] | 454 | fib_index = fib_table_find (fproto, table_id); |
| 455 | mfib_index = mfib_table_find (fproto, table_id); |
Florin Coras | d0a5972 | 2017-10-15 17:41:21 +0000 | [diff] [blame] | 456 | |
Neale Ranns | 8f6dd32 | 2018-05-17 06:34:24 -0700 | [diff] [blame] | 457 | if (~0 == fib_index || ~0 == mfib_index) |
| 458 | { |
| 459 | return (VNET_API_ERROR_NO_SUCH_FIB); |
| 460 | } |
Florin Coras | d0a5972 | 2017-10-15 17:41:21 +0000 | [diff] [blame] | 461 | |
Neale Ranns | 1500254 | 2017-09-10 04:39:11 -0700 | [diff] [blame] | 462 | if (FIB_PROTOCOL_IP6 == fproto) |
| 463 | { |
| 464 | /* |
| 465 | * If the interface already has in IP address, then a change int |
| 466 | * VRF is not allowed. The IP address applied must first be removed. |
| 467 | * We do not do that automatically here, since VPP has no knowledge |
Paul Vinciguerra | bdc0e6b | 2018-09-22 05:32:50 -0700 | [diff] [blame] | 468 | * of whether those subnets are valid in the destination VRF. |
Neale Ranns | 1500254 | 2017-09-10 04:39:11 -0700 | [diff] [blame] | 469 | */ |
| 470 | /* *INDENT-OFF* */ |
| 471 | foreach_ip_interface_address (&ip6_main.lookup_main, |
| 472 | ia, sw_if_index, |
| 473 | 1 /* honor unnumbered */ , |
| 474 | ({ |
| 475 | return (VNET_API_ERROR_ADDRESS_FOUND_FOR_INTERFACE); |
| 476 | })); |
| 477 | /* *INDENT-ON* */ |
| 478 | |
| 479 | vec_validate (ip6_main.fib_index_by_sw_if_index, sw_if_index); |
| 480 | vec_validate (ip6_main.mfib_index_by_sw_if_index, sw_if_index); |
| 481 | |
| 482 | /* |
| 483 | * tell those that are interested that the binding is changing. |
| 484 | */ |
| 485 | ip6_table_bind_callback_t *cb; |
| 486 | vec_foreach (cb, ip6_main.table_bind_callbacks) |
| 487 | cb->function (&ip6_main, cb->function_opaque, |
| 488 | sw_if_index, |
| 489 | fib_index, |
| 490 | ip6_main.fib_index_by_sw_if_index[sw_if_index]); |
| 491 | |
| 492 | if (0 == table_id) |
| 493 | { |
| 494 | /* reset back to default */ |
| 495 | if (0 != ip6_main.fib_index_by_sw_if_index[sw_if_index]) |
| 496 | fib_table_unlock (ip6_main.fib_index_by_sw_if_index[sw_if_index], |
| 497 | FIB_PROTOCOL_IP6, src); |
| 498 | if (0 != ip6_main.mfib_index_by_sw_if_index[sw_if_index]) |
| 499 | mfib_table_unlock (ip6_main.mfib_index_by_sw_if_index |
| 500 | [sw_if_index], FIB_PROTOCOL_IP6, msrc); |
| 501 | |
| 502 | } |
| 503 | else |
| 504 | { |
| 505 | /* we need to lock the table now it's inuse */ |
| 506 | fib_table_lock (fib_index, FIB_PROTOCOL_IP6, src); |
| 507 | mfib_table_lock (mfib_index, FIB_PROTOCOL_IP6, msrc); |
| 508 | } |
| 509 | |
| 510 | ip6_main.fib_index_by_sw_if_index[sw_if_index] = fib_index; |
| 511 | ip6_main.mfib_index_by_sw_if_index[sw_if_index] = mfib_index; |
| 512 | } |
| 513 | else |
| 514 | { |
| 515 | /* |
| 516 | * If the interface already has in IP address, then a change int |
| 517 | * VRF is not allowed. The IP address applied must first be removed. |
| 518 | * We do not do that automatically here, since VPP has no knowledge |
Paul Vinciguerra | bdc0e6b | 2018-09-22 05:32:50 -0700 | [diff] [blame] | 519 | * of whether those subnets are valid in the destination VRF. |
Neale Ranns | 1500254 | 2017-09-10 04:39:11 -0700 | [diff] [blame] | 520 | */ |
| 521 | /* *INDENT-OFF* */ |
| 522 | foreach_ip_interface_address (&ip4_main.lookup_main, |
| 523 | ia, sw_if_index, |
| 524 | 1 /* honor unnumbered */ , |
| 525 | ({ |
| 526 | return (VNET_API_ERROR_ADDRESS_FOUND_FOR_INTERFACE); |
| 527 | })); |
| 528 | /* *INDENT-ON* */ |
| 529 | |
| 530 | vec_validate (ip4_main.fib_index_by_sw_if_index, sw_if_index); |
| 531 | vec_validate (ip4_main.mfib_index_by_sw_if_index, sw_if_index); |
| 532 | |
| 533 | /* |
| 534 | * tell those that are interested that the binding is changing. |
| 535 | */ |
| 536 | ip4_table_bind_callback_t *cb; |
| 537 | vec_foreach (cb, ip4_main.table_bind_callbacks) |
| 538 | cb->function (&ip4_main, cb->function_opaque, |
| 539 | sw_if_index, |
| 540 | fib_index, |
| 541 | ip4_main.fib_index_by_sw_if_index[sw_if_index]); |
| 542 | |
| 543 | if (0 == table_id) |
| 544 | { |
| 545 | /* reset back to default */ |
| 546 | if (0 != ip4_main.fib_index_by_sw_if_index[sw_if_index]) |
| 547 | fib_table_unlock (ip4_main.fib_index_by_sw_if_index[sw_if_index], |
| 548 | FIB_PROTOCOL_IP4, src); |
| 549 | if (0 != ip4_main.mfib_index_by_sw_if_index[sw_if_index]) |
| 550 | mfib_table_unlock (ip4_main.mfib_index_by_sw_if_index |
| 551 | [sw_if_index], FIB_PROTOCOL_IP4, msrc); |
| 552 | |
| 553 | } |
| 554 | else |
| 555 | { |
| 556 | /* we need to lock the table now it's inuse */ |
| 557 | fib_index = fib_table_find_or_create_and_lock (FIB_PROTOCOL_IP4, |
| 558 | table_id, src); |
| 559 | |
| 560 | mfib_index = mfib_table_find_or_create_and_lock (FIB_PROTOCOL_IP4, |
| 561 | table_id, msrc); |
| 562 | } |
| 563 | |
| 564 | ip4_main.fib_index_by_sw_if_index[sw_if_index] = fib_index; |
| 565 | ip4_main.mfib_index_by_sw_if_index[sw_if_index] = mfib_index; |
| 566 | } |
| 567 | |
Neale Ranns | 1500254 | 2017-09-10 04:39:11 -0700 | [diff] [blame] | 568 | return (0); |
| 569 | } |
| 570 | |
Juraj Sloboda | dfc1923 | 2016-12-05 13:20:37 +0100 | [diff] [blame] | 571 | static void |
Florin Coras | 6c4dae2 | 2018-01-09 06:39:23 -0800 | [diff] [blame] | 572 | send_sw_interface_get_table_reply (vl_api_registration_t * reg, |
Juraj Sloboda | dfc1923 | 2016-12-05 13:20:37 +0100 | [diff] [blame] | 573 | u32 context, int retval, u32 vrf_id) |
| 574 | { |
| 575 | vl_api_sw_interface_get_table_reply_t *mp; |
| 576 | |
| 577 | mp = vl_msg_api_alloc (sizeof (*mp)); |
Dave Barach | b7b9299 | 2018-10-17 10:38:51 -0400 | [diff] [blame] | 578 | clib_memset (mp, 0, sizeof (*mp)); |
Juraj Sloboda | dfc1923 | 2016-12-05 13:20:37 +0100 | [diff] [blame] | 579 | mp->_vl_msg_id = ntohs (VL_API_SW_INTERFACE_GET_TABLE_REPLY); |
| 580 | mp->context = context; |
| 581 | mp->retval = htonl (retval); |
| 582 | mp->vrf_id = htonl (vrf_id); |
| 583 | |
Florin Coras | 6c4dae2 | 2018-01-09 06:39:23 -0800 | [diff] [blame] | 584 | vl_api_send_msg (reg, (u8 *) mp); |
Juraj Sloboda | dfc1923 | 2016-12-05 13:20:37 +0100 | [diff] [blame] | 585 | } |
| 586 | |
| 587 | static void |
| 588 | vl_api_sw_interface_get_table_t_handler (vl_api_sw_interface_get_table_t * mp) |
| 589 | { |
Florin Coras | 6c4dae2 | 2018-01-09 06:39:23 -0800 | [diff] [blame] | 590 | vl_api_registration_t *reg; |
Juraj Sloboda | dfc1923 | 2016-12-05 13:20:37 +0100 | [diff] [blame] | 591 | fib_table_t *fib_table = 0; |
| 592 | u32 sw_if_index = ~0; |
| 593 | u32 fib_index = ~0; |
| 594 | u32 table_id = ~0; |
| 595 | fib_protocol_t fib_proto = FIB_PROTOCOL_IP4; |
| 596 | int rv = 0; |
| 597 | |
Florin Coras | 6c4dae2 | 2018-01-09 06:39:23 -0800 | [diff] [blame] | 598 | reg = vl_api_client_index_to_registration (mp->client_index); |
| 599 | if (!reg) |
Juraj Sloboda | dfc1923 | 2016-12-05 13:20:37 +0100 | [diff] [blame] | 600 | return; |
| 601 | |
| 602 | VALIDATE_SW_IF_INDEX (mp); |
| 603 | |
| 604 | sw_if_index = ntohl (mp->sw_if_index); |
| 605 | |
| 606 | if (mp->is_ipv6) |
| 607 | fib_proto = FIB_PROTOCOL_IP6; |
| 608 | |
| 609 | fib_index = fib_table_get_index_for_sw_if_index (fib_proto, sw_if_index); |
| 610 | if (fib_index != ~0) |
| 611 | { |
| 612 | fib_table = fib_table_get (fib_index, fib_proto); |
| 613 | table_id = fib_table->ft_table_id; |
| 614 | } |
| 615 | |
| 616 | BAD_SW_IF_INDEX_LABEL; |
| 617 | |
Florin Coras | 6c4dae2 | 2018-01-09 06:39:23 -0800 | [diff] [blame] | 618 | send_sw_interface_get_table_reply (reg, mp->context, rv, table_id); |
Juraj Sloboda | dfc1923 | 2016-12-05 13:20:37 +0100 | [diff] [blame] | 619 | } |
| 620 | |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 621 | static void vl_api_sw_interface_set_unnumbered_t_handler |
| 622 | (vl_api_sw_interface_set_unnumbered_t * mp) |
| 623 | { |
| 624 | vl_api_sw_interface_set_unnumbered_reply_t *rmp; |
| 625 | int rv = 0; |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 626 | vnet_main_t *vnm = vnet_get_main (); |
Eyal Bari | 1c82cd4 | 2017-03-14 14:39:51 +0200 | [diff] [blame] | 627 | u32 sw_if_index = ntohl (mp->sw_if_index); |
| 628 | u32 unnumbered_sw_if_index = ntohl (mp->unnumbered_sw_if_index); |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 629 | |
| 630 | /* |
| 631 | * The API message field names are backwards from |
| 632 | * the underlying data structure names. |
| 633 | * It's not worth changing them now. |
| 634 | */ |
Eyal Bari | 1c82cd4 | 2017-03-14 14:39:51 +0200 | [diff] [blame] | 635 | if (!vnet_sw_interface_is_api_valid (vnm, unnumbered_sw_if_index)) |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 636 | { |
| 637 | rv = VNET_API_ERROR_INVALID_SW_IF_INDEX; |
| 638 | goto done; |
| 639 | } |
| 640 | |
| 641 | /* Only check the "use loop0" field when setting the binding */ |
Eyal Bari | 1c82cd4 | 2017-03-14 14:39:51 +0200 | [diff] [blame] | 642 | if (mp->is_add && !vnet_sw_interface_is_api_valid (vnm, sw_if_index)) |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 643 | { |
| 644 | rv = VNET_API_ERROR_INVALID_SW_IF_INDEX_2; |
| 645 | goto done; |
| 646 | } |
| 647 | |
Neale Ranns | 2ae2bc5 | 2018-03-16 03:22:39 -0700 | [diff] [blame] | 648 | vnet_sw_interface_update_unnumbered (unnumbered_sw_if_index, |
| 649 | sw_if_index, mp->is_add); |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 650 | done: |
| 651 | REPLY_MACRO (VL_API_SW_INTERFACE_SET_UNNUMBERED_REPLY); |
| 652 | } |
| 653 | |
| 654 | static void |
| 655 | vl_api_sw_interface_clear_stats_t_handler (vl_api_sw_interface_clear_stats_t * |
| 656 | mp) |
| 657 | { |
| 658 | vl_api_sw_interface_clear_stats_reply_t *rmp; |
| 659 | |
| 660 | vnet_main_t *vnm = vnet_get_main (); |
| 661 | vnet_interface_main_t *im = &vnm->interface_main; |
| 662 | vlib_simple_counter_main_t *sm; |
| 663 | vlib_combined_counter_main_t *cm; |
| 664 | static vnet_main_t **my_vnet_mains; |
| 665 | int i, j, n_counters; |
| 666 | int rv = 0; |
| 667 | |
| 668 | if (mp->sw_if_index != ~0) |
| 669 | VALIDATE_SW_IF_INDEX (mp); |
| 670 | |
| 671 | vec_reset_length (my_vnet_mains); |
| 672 | |
| 673 | for (i = 0; i < vec_len (vnet_mains); i++) |
| 674 | { |
| 675 | if (vnet_mains[i]) |
| 676 | vec_add1 (my_vnet_mains, vnet_mains[i]); |
| 677 | } |
| 678 | |
| 679 | if (vec_len (vnet_mains) == 0) |
| 680 | vec_add1 (my_vnet_mains, vnm); |
| 681 | |
| 682 | n_counters = vec_len (im->combined_sw_if_counters); |
| 683 | |
| 684 | for (j = 0; j < n_counters; j++) |
| 685 | { |
| 686 | for (i = 0; i < vec_len (my_vnet_mains); i++) |
| 687 | { |
| 688 | im = &my_vnet_mains[i]->interface_main; |
| 689 | cm = im->combined_sw_if_counters + j; |
| 690 | if (mp->sw_if_index == (u32) ~ 0) |
| 691 | vlib_clear_combined_counters (cm); |
| 692 | else |
| 693 | vlib_zero_combined_counter (cm, ntohl (mp->sw_if_index)); |
| 694 | } |
| 695 | } |
| 696 | |
| 697 | n_counters = vec_len (im->sw_if_counters); |
| 698 | |
| 699 | for (j = 0; j < n_counters; j++) |
| 700 | { |
| 701 | for (i = 0; i < vec_len (my_vnet_mains); i++) |
| 702 | { |
| 703 | im = &my_vnet_mains[i]->interface_main; |
| 704 | sm = im->sw_if_counters + j; |
| 705 | if (mp->sw_if_index == (u32) ~ 0) |
| 706 | vlib_clear_simple_counters (sm); |
| 707 | else |
| 708 | vlib_zero_simple_counter (sm, ntohl (mp->sw_if_index)); |
| 709 | } |
| 710 | } |
| 711 | |
| 712 | BAD_SW_IF_INDEX_LABEL; |
| 713 | |
| 714 | REPLY_MACRO (VL_API_SW_INTERFACE_CLEAR_STATS_REPLY); |
| 715 | } |
| 716 | |
Ole Troan | 2e1c896 | 2019-04-10 09:44:23 +0200 | [diff] [blame] | 717 | /* |
| 718 | * Events used for sw_interface_events |
| 719 | */ |
| 720 | enum api_events |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 721 | { |
Ole Troan | 2e1c896 | 2019-04-10 09:44:23 +0200 | [diff] [blame] | 722 | API_LINK_STATE_UP_EVENT = 1 << 1, |
| 723 | API_LINK_STATE_DOWN_EVENT = 1 << 2, |
| 724 | API_ADMIN_UP_EVENT = 1 << 3, |
| 725 | API_ADMIN_DOWN_EVENT = 1 << 4, |
| 726 | API_SW_INTERFACE_ADD_EVENT = 1 << 5, |
| 727 | API_SW_INTERFACE_DEL_EVENT = 1 << 6, |
| 728 | }; |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 729 | |
| 730 | static void |
Neale Ranns | a07bd70 | 2017-08-07 07:53:49 -0700 | [diff] [blame] | 731 | send_sw_interface_event (vpe_api_main_t * am, |
Neale Ranns | d292ab1 | 2017-08-15 12:29:48 -0700 | [diff] [blame] | 732 | vpe_client_registration_t * reg, |
Florin Coras | 6c4dae2 | 2018-01-09 06:39:23 -0800 | [diff] [blame] | 733 | vl_api_registration_t * vl_reg, |
Ole Troan | 2e1c896 | 2019-04-10 09:44:23 +0200 | [diff] [blame] | 734 | u32 sw_if_index, enum api_events events) |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 735 | { |
Neale Ranns | a07bd70 | 2017-08-07 07:53:49 -0700 | [diff] [blame] | 736 | vl_api_sw_interface_event_t *mp; |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 737 | |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 738 | mp = vl_msg_api_alloc (sizeof (*mp)); |
Dave Barach | b7b9299 | 2018-10-17 10:38:51 -0400 | [diff] [blame] | 739 | clib_memset (mp, 0, sizeof (*mp)); |
Neale Ranns | a07bd70 | 2017-08-07 07:53:49 -0700 | [diff] [blame] | 740 | mp->_vl_msg_id = ntohs (VL_API_SW_INTERFACE_EVENT); |
Ole Troan | 2e1c896 | 2019-04-10 09:44:23 +0200 | [diff] [blame] | 741 | mp->sw_if_index = ntohl (sw_if_index); |
Neale Ranns | d292ab1 | 2017-08-15 12:29:48 -0700 | [diff] [blame] | 742 | mp->client_index = reg->client_index; |
| 743 | mp->pid = reg->client_pid; |
Ole Troan | 2e1c896 | 2019-04-10 09:44:23 +0200 | [diff] [blame] | 744 | mp->admin_up_down = events & API_ADMIN_UP_EVENT ? 1 : 0; |
| 745 | mp->link_up_down = events & API_LINK_STATE_UP_EVENT ? 1 : 0; |
| 746 | mp->deleted = events & API_SW_INTERFACE_DEL_EVENT ? 1 : 0; |
Florin Coras | 6c4dae2 | 2018-01-09 06:39:23 -0800 | [diff] [blame] | 747 | vl_api_send_msg (vl_reg, (u8 *) mp); |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 748 | } |
| 749 | |
| 750 | static uword |
| 751 | link_state_process (vlib_main_t * vm, |
| 752 | vlib_node_runtime_t * rt, vlib_frame_t * f) |
| 753 | { |
| 754 | vpe_api_main_t *vam = &vpe_api_main; |
Ole Troan | 2e1c896 | 2019-04-10 09:44:23 +0200 | [diff] [blame] | 755 | uword *event_by_sw_if_index = 0; |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 756 | vpe_client_registration_t *reg; |
| 757 | int i; |
Florin Coras | 6c4dae2 | 2018-01-09 06:39:23 -0800 | [diff] [blame] | 758 | vl_api_registration_t *vl_reg; |
Ole Troan | 2e1c896 | 2019-04-10 09:44:23 +0200 | [diff] [blame] | 759 | uword event_type; |
| 760 | uword *event_data = 0; |
| 761 | u32 sw_if_index; |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 762 | |
| 763 | vam->link_state_process_up = 1; |
| 764 | |
| 765 | while (1) |
| 766 | { |
| 767 | vlib_process_wait_for_event (vm); |
| 768 | |
Ole Troan | 2e1c896 | 2019-04-10 09:44:23 +0200 | [diff] [blame] | 769 | /* Batch up events */ |
| 770 | while ((event_type = vlib_process_get_events (vm, &event_data)) != ~0) |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 771 | { |
Ole Troan | 2e1c896 | 2019-04-10 09:44:23 +0200 | [diff] [blame] | 772 | for (i = 0; i < vec_len (event_data); i++) |
| 773 | { |
| 774 | sw_if_index = event_data[i]; |
| 775 | vec_validate_init_empty (event_by_sw_if_index, sw_if_index, 0); |
| 776 | event_by_sw_if_index[sw_if_index] |= event_type; |
| 777 | } |
| 778 | vec_reset_length (event_data); |
| 779 | } |
| 780 | |
| 781 | for (i = 0; i < vec_len (event_by_sw_if_index); i++) |
| 782 | { |
| 783 | if (event_by_sw_if_index[i] == 0) |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 784 | continue; |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 785 | |
| 786 | /* *INDENT-OFF* */ |
| 787 | pool_foreach(reg, vam->interface_events_registrations, |
| 788 | ({ |
Florin Coras | 6c4dae2 | 2018-01-09 06:39:23 -0800 | [diff] [blame] | 789 | vl_reg = vl_api_client_index_to_registration (reg->client_index); |
| 790 | if (vl_reg) |
Ole Troan | 2e1c896 | 2019-04-10 09:44:23 +0200 | [diff] [blame] | 791 | send_sw_interface_event (vam, reg, vl_reg, i, event_by_sw_if_index[i]); |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 792 | })); |
| 793 | /* *INDENT-ON* */ |
| 794 | } |
Ole Troan | 2e1c896 | 2019-04-10 09:44:23 +0200 | [diff] [blame] | 795 | vec_reset_length (event_by_sw_if_index); |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 796 | } |
| 797 | |
| 798 | return 0; |
| 799 | } |
| 800 | |
| 801 | static clib_error_t *link_up_down_function (vnet_main_t * vm, u32 hw_if_index, |
| 802 | u32 flags); |
| 803 | static clib_error_t *admin_up_down_function (vnet_main_t * vm, |
| 804 | u32 hw_if_index, u32 flags); |
Ole Troan | 2e1c896 | 2019-04-10 09:44:23 +0200 | [diff] [blame] | 805 | static clib_error_t *sw_interface_add_del_function (vnet_main_t * vm, |
| 806 | u32 sw_if_index, |
| 807 | u32 flags); |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 808 | |
| 809 | /* *INDENT-OFF* */ |
| 810 | VLIB_REGISTER_NODE (link_state_process_node,static) = { |
| 811 | .function = link_state_process, |
| 812 | .type = VLIB_NODE_TYPE_PROCESS, |
| 813 | .name = "vpe-link-state-process", |
| 814 | }; |
| 815 | /* *INDENT-ON* */ |
| 816 | |
| 817 | VNET_SW_INTERFACE_ADMIN_UP_DOWN_FUNCTION (admin_up_down_function); |
| 818 | VNET_HW_INTERFACE_LINK_UP_DOWN_FUNCTION (link_up_down_function); |
Ole Troan | 2e1c896 | 2019-04-10 09:44:23 +0200 | [diff] [blame] | 819 | VNET_SW_INTERFACE_ADD_DEL_FUNCTION (sw_interface_add_del_function); |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 820 | |
| 821 | static clib_error_t * |
| 822 | link_up_down_function (vnet_main_t * vm, u32 hw_if_index, u32 flags) |
| 823 | { |
| 824 | vpe_api_main_t *vam = &vpe_api_main; |
| 825 | vnet_hw_interface_t *hi = vnet_get_hw_interface (vm, hw_if_index); |
| 826 | |
| 827 | if (vam->link_state_process_up) |
Ole Troan | 2e1c896 | 2019-04-10 09:44:23 +0200 | [diff] [blame] | 828 | { |
| 829 | enum api_events event = |
| 830 | flags ? API_LINK_STATE_UP_EVENT : API_LINK_STATE_DOWN_EVENT; |
| 831 | vlib_process_signal_event (vam->vlib_main, |
| 832 | link_state_process_node.index, event, |
| 833 | hi->sw_if_index); |
| 834 | } |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 835 | return 0; |
| 836 | } |
| 837 | |
| 838 | static clib_error_t * |
| 839 | admin_up_down_function (vnet_main_t * vm, u32 sw_if_index, u32 flags) |
| 840 | { |
| 841 | vpe_api_main_t *vam = &vpe_api_main; |
| 842 | |
| 843 | /* |
| 844 | * Note: it's perfectly fair to set a subif admin up / admin down. |
| 845 | * Note the subtle distinction between this routine and the previous |
| 846 | * routine. |
| 847 | */ |
| 848 | if (vam->link_state_process_up) |
Ole Troan | 2e1c896 | 2019-04-10 09:44:23 +0200 | [diff] [blame] | 849 | { |
| 850 | enum api_events event = |
| 851 | flags ? API_ADMIN_UP_EVENT : API_ADMIN_DOWN_EVENT; |
| 852 | vlib_process_signal_event (vam->vlib_main, |
| 853 | link_state_process_node.index, event, |
| 854 | sw_if_index); |
| 855 | } |
| 856 | return 0; |
| 857 | } |
| 858 | |
| 859 | static clib_error_t * |
| 860 | sw_interface_add_del_function (vnet_main_t * vm, u32 sw_if_index, u32 flags) |
| 861 | { |
| 862 | vpe_api_main_t *vam = &vpe_api_main; |
| 863 | |
| 864 | if (vam->link_state_process_up) |
| 865 | { |
| 866 | enum api_events event = |
| 867 | flags ? API_SW_INTERFACE_ADD_EVENT : API_SW_INTERFACE_DEL_EVENT; |
| 868 | vlib_process_signal_event (vam->vlib_main, |
| 869 | link_state_process_node.index, event, |
| 870 | sw_if_index); |
| 871 | } |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 872 | return 0; |
| 873 | } |
| 874 | |
| 875 | static void vl_api_sw_interface_tag_add_del_t_handler |
| 876 | (vl_api_sw_interface_tag_add_del_t * mp) |
| 877 | { |
| 878 | vnet_main_t *vnm = vnet_get_main (); |
| 879 | vl_api_sw_interface_tag_add_del_reply_t *rmp; |
| 880 | int rv = 0; |
| 881 | u8 *tag; |
| 882 | u32 sw_if_index = ntohl (mp->sw_if_index); |
| 883 | |
| 884 | VALIDATE_SW_IF_INDEX (mp); |
| 885 | |
| 886 | if (mp->is_add) |
| 887 | { |
Ole Trøan | 3b0d7e4 | 2019-03-15 16:14:41 +0000 | [diff] [blame] | 888 | if (mp->tag[0] == 0) |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 889 | { |
| 890 | rv = VNET_API_ERROR_INVALID_VALUE; |
| 891 | goto out; |
| 892 | } |
| 893 | |
Ole Trøan | 3b0d7e4 | 2019-03-15 16:14:41 +0000 | [diff] [blame] | 894 | mp->tag[ARRAY_LEN (mp->tag) - 1] = 0; |
| 895 | tag = format (0, "%s%c", mp->tag, 0); |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 896 | vnet_set_sw_interface_tag (vnm, tag, sw_if_index); |
| 897 | } |
| 898 | else |
| 899 | vnet_clear_sw_interface_tag (vnm, sw_if_index); |
| 900 | |
| 901 | BAD_SW_IF_INDEX_LABEL; |
| 902 | out: |
| 903 | REPLY_MACRO (VL_API_SW_INTERFACE_TAG_ADD_DEL_REPLY); |
| 904 | } |
| 905 | |
Jon Loeliger | 10c273b | 2017-03-30 08:39:33 -0500 | [diff] [blame] | 906 | static void vl_api_sw_interface_set_mac_address_t_handler |
| 907 | (vl_api_sw_interface_set_mac_address_t * mp) |
| 908 | { |
| 909 | vl_api_sw_interface_set_mac_address_reply_t *rmp; |
| 910 | vnet_main_t *vnm = vnet_get_main (); |
| 911 | u32 sw_if_index = ntohl (mp->sw_if_index); |
Neale Ranns | d867a7c | 2017-10-04 02:29:07 -0700 | [diff] [blame] | 912 | vnet_sw_interface_t *si; |
Jon Loeliger | 10c273b | 2017-03-30 08:39:33 -0500 | [diff] [blame] | 913 | clib_error_t *error; |
| 914 | int rv = 0; |
| 915 | |
| 916 | VALIDATE_SW_IF_INDEX (mp); |
| 917 | |
Neale Ranns | d867a7c | 2017-10-04 02:29:07 -0700 | [diff] [blame] | 918 | si = vnet_get_sw_interface (vnm, sw_if_index); |
Ole Trøan | 3b0d7e4 | 2019-03-15 16:14:41 +0000 | [diff] [blame] | 919 | error = vnet_hw_interface_change_mac_address (vnm, si->hw_if_index, |
| 920 | mp->mac_address); |
Jon Loeliger | 10c273b | 2017-03-30 08:39:33 -0500 | [diff] [blame] | 921 | if (error) |
| 922 | { |
| 923 | rv = VNET_API_ERROR_UNIMPLEMENTED; |
| 924 | clib_error_report (error); |
| 925 | goto out; |
| 926 | } |
| 927 | |
| 928 | BAD_SW_IF_INDEX_LABEL; |
| 929 | out: |
| 930 | REPLY_MACRO (VL_API_SW_INTERFACE_SET_MAC_ADDRESS_REPLY); |
| 931 | } |
| 932 | |
Juraj Sloboda | c037423 | 2018-02-01 15:18:49 +0100 | [diff] [blame] | 933 | static void vl_api_sw_interface_get_mac_address_t_handler |
| 934 | (vl_api_sw_interface_get_mac_address_t * mp) |
| 935 | { |
| 936 | vl_api_sw_interface_get_mac_address_reply_t *rmp; |
| 937 | vl_api_registration_t *reg; |
| 938 | vnet_main_t *vnm = vnet_get_main (); |
| 939 | u32 sw_if_index = ntohl (mp->sw_if_index); |
| 940 | vnet_sw_interface_t *si; |
| 941 | ethernet_interface_t *eth_if = 0; |
| 942 | int rv = 0; |
| 943 | |
| 944 | VALIDATE_SW_IF_INDEX (mp); |
| 945 | |
| 946 | si = vnet_get_sup_sw_interface (vnm, sw_if_index); |
| 947 | if (si->type == VNET_SW_INTERFACE_TYPE_HARDWARE) |
| 948 | eth_if = ethernet_get_interface (ðernet_main, si->hw_if_index); |
| 949 | |
| 950 | BAD_SW_IF_INDEX_LABEL; |
| 951 | |
| 952 | reg = vl_api_client_index_to_registration (mp->client_index); |
| 953 | if (!reg) |
| 954 | return; |
| 955 | rmp = vl_msg_api_alloc (sizeof (*rmp)); |
| 956 | rmp->_vl_msg_id = htons (VL_API_SW_INTERFACE_GET_MAC_ADDRESS_REPLY); |
| 957 | rmp->context = mp->context; |
| 958 | rmp->retval = htonl (rv); |
| 959 | if (!rv && eth_if) |
Ole Trøan | 3b0d7e4 | 2019-03-15 16:14:41 +0000 | [diff] [blame] | 960 | memcpy (rmp->mac_address, eth_if->address, 6); |
Juraj Sloboda | c037423 | 2018-02-01 15:18:49 +0100 | [diff] [blame] | 961 | vl_api_send_msg (reg, (u8 *) rmp); |
| 962 | } |
| 963 | |
Steven | ad8015b | 2017-10-29 22:10:46 -0700 | [diff] [blame] | 964 | static void vl_api_sw_interface_set_rx_mode_t_handler |
| 965 | (vl_api_sw_interface_set_rx_mode_t * mp) |
| 966 | { |
| 967 | vl_api_sw_interface_set_rx_mode_reply_t *rmp; |
| 968 | vnet_main_t *vnm = vnet_get_main (); |
| 969 | u32 sw_if_index = ntohl (mp->sw_if_index); |
| 970 | vnet_sw_interface_t *si; |
| 971 | clib_error_t *error; |
| 972 | int rv = 0; |
| 973 | |
| 974 | VALIDATE_SW_IF_INDEX (mp); |
| 975 | |
| 976 | si = vnet_get_sw_interface (vnm, sw_if_index); |
Mohsin Kazmi | 54f7c51 | 2018-08-23 18:28:11 +0200 | [diff] [blame] | 977 | if (si->type != VNET_SW_INTERFACE_TYPE_HARDWARE) |
| 978 | { |
| 979 | rv = VNET_API_ERROR_INVALID_VALUE; |
| 980 | goto bad_sw_if_index; |
| 981 | } |
| 982 | |
Steven | ad8015b | 2017-10-29 22:10:46 -0700 | [diff] [blame] | 983 | error = set_hw_interface_change_rx_mode (vnm, si->hw_if_index, |
| 984 | mp->queue_id_valid, |
| 985 | ntohl (mp->queue_id), mp->mode); |
| 986 | if (error) |
| 987 | { |
| 988 | rv = VNET_API_ERROR_UNIMPLEMENTED; |
| 989 | clib_error_report (error); |
| 990 | goto out; |
| 991 | } |
| 992 | |
| 993 | BAD_SW_IF_INDEX_LABEL; |
| 994 | out: |
| 995 | REPLY_MACRO (VL_API_SW_INTERFACE_SET_RX_MODE_REPLY); |
| 996 | } |
| 997 | |
Mohsin Kazmi | f0b42f4 | 2018-09-10 18:11:00 +0200 | [diff] [blame] | 998 | static void |
| 999 | send_interface_rx_placement_details (vpe_api_main_t * am, |
| 1000 | vl_api_registration_t * rp, |
| 1001 | u32 sw_if_index, u32 worker_id, |
| 1002 | u32 queue_id, u8 mode, u32 context) |
| 1003 | { |
| 1004 | vl_api_sw_interface_rx_placement_details_t *mp; |
| 1005 | mp = vl_msg_api_alloc (sizeof (*mp)); |
Dave Barach | b7b9299 | 2018-10-17 10:38:51 -0400 | [diff] [blame] | 1006 | clib_memset (mp, 0, sizeof (*mp)); |
Mohsin Kazmi | f0b42f4 | 2018-09-10 18:11:00 +0200 | [diff] [blame] | 1007 | |
| 1008 | mp->_vl_msg_id = htons (VL_API_SW_INTERFACE_RX_PLACEMENT_DETAILS); |
| 1009 | mp->sw_if_index = htonl (sw_if_index); |
| 1010 | mp->queue_id = htonl (queue_id); |
| 1011 | mp->worker_id = htonl (worker_id); |
| 1012 | mp->mode = mode; |
| 1013 | mp->context = context; |
| 1014 | |
| 1015 | vl_api_send_msg (rp, (u8 *) mp); |
| 1016 | } |
| 1017 | |
| 1018 | static void vl_api_sw_interface_rx_placement_dump_t_handler |
| 1019 | (vl_api_sw_interface_rx_placement_dump_t * mp) |
| 1020 | { |
| 1021 | vnet_main_t *vnm = vnet_get_main (); |
| 1022 | vpe_api_main_t *am = &vpe_api_main; |
| 1023 | u32 sw_if_index = ntohl (mp->sw_if_index); |
| 1024 | vl_api_registration_t *reg; |
| 1025 | |
| 1026 | reg = vl_api_client_index_to_registration (mp->client_index); |
| 1027 | if (!reg) |
| 1028 | return; |
| 1029 | |
| 1030 | if (sw_if_index == ~0) |
| 1031 | { |
| 1032 | vnet_device_input_runtime_t *rt; |
| 1033 | vnet_device_and_queue_t *dq; |
| 1034 | vlib_node_t *pn = vlib_get_node_by_name (am->vlib_main, |
| 1035 | (u8 *) "device-input"); |
| 1036 | uword si; |
| 1037 | int index = 0; |
| 1038 | |
| 1039 | /* *INDENT-OFF* */ |
| 1040 | foreach_vlib_main (({ |
| 1041 | clib_bitmap_foreach (si, pn->sibling_bitmap, |
| 1042 | ({ |
| 1043 | rt = vlib_node_get_runtime_data (this_vlib_main, si); |
| 1044 | vec_foreach (dq, rt->devices_and_queues) |
| 1045 | { |
| 1046 | vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm, |
| 1047 | dq->hw_if_index); |
| 1048 | send_interface_rx_placement_details (am, reg, hw->sw_if_index, index, |
| 1049 | dq->queue_id, dq->mode, mp->context); |
| 1050 | } |
| 1051 | })); |
| 1052 | index++; |
| 1053 | })); |
| 1054 | /* *INDENT-ON* */ |
| 1055 | } |
| 1056 | else |
| 1057 | { |
| 1058 | int i; |
| 1059 | vnet_sw_interface_t *si; |
| 1060 | |
| 1061 | if (!vnet_sw_if_index_is_api_valid (sw_if_index)) |
| 1062 | { |
| 1063 | clib_warning ("sw_if_index %u does not exist", sw_if_index); |
| 1064 | goto bad_sw_if_index; |
| 1065 | } |
| 1066 | |
| 1067 | si = vnet_get_sw_interface (vnm, sw_if_index); |
| 1068 | if (si->type != VNET_SW_INTERFACE_TYPE_HARDWARE) |
| 1069 | { |
| 1070 | clib_warning ("interface type is not HARDWARE! P2P, PIPE and SUB" |
| 1071 | " interfaces are not supported"); |
| 1072 | goto bad_sw_if_index; |
| 1073 | } |
| 1074 | |
| 1075 | vnet_hw_interface_t *hw = vnet_get_hw_interface (vnm, si->hw_if_index); |
| 1076 | |
| 1077 | for (i = 0; i < vec_len (hw->dq_runtime_index_by_queue); i++) |
| 1078 | { |
| 1079 | send_interface_rx_placement_details (am, reg, hw->sw_if_index, |
| 1080 | hw->input_node_thread_index_by_queue |
| 1081 | [i], i, |
| 1082 | hw->rx_mode_by_queue[i], |
| 1083 | mp->context); |
| 1084 | } |
| 1085 | } |
| 1086 | |
| 1087 | BAD_SW_IF_INDEX_LABEL; |
| 1088 | } |
| 1089 | |
Mohsin Kazmi | 54f7c51 | 2018-08-23 18:28:11 +0200 | [diff] [blame] | 1090 | static void vl_api_sw_interface_set_rx_placement_t_handler |
| 1091 | (vl_api_sw_interface_set_rx_placement_t * mp) |
| 1092 | { |
| 1093 | vl_api_sw_interface_set_rx_placement_reply_t *rmp; |
| 1094 | vnet_main_t *vnm = vnet_get_main (); |
| 1095 | u32 sw_if_index = ntohl (mp->sw_if_index); |
| 1096 | vnet_sw_interface_t *si; |
| 1097 | clib_error_t *error = 0; |
| 1098 | int rv = 0; |
| 1099 | |
| 1100 | VALIDATE_SW_IF_INDEX (mp); |
| 1101 | |
| 1102 | si = vnet_get_sw_interface (vnm, sw_if_index); |
| 1103 | if (si->type != VNET_SW_INTERFACE_TYPE_HARDWARE) |
| 1104 | { |
| 1105 | rv = VNET_API_ERROR_INVALID_VALUE; |
| 1106 | goto bad_sw_if_index; |
| 1107 | } |
| 1108 | |
| 1109 | error = set_hw_interface_rx_placement (si->hw_if_index, |
| 1110 | ntohl (mp->queue_id), |
| 1111 | ntohl (mp->worker_id), mp->is_main); |
| 1112 | if (error) |
| 1113 | { |
| 1114 | rv = VNET_API_ERROR_UNIMPLEMENTED; |
| 1115 | clib_error_report (error); |
| 1116 | goto out; |
| 1117 | } |
| 1118 | |
| 1119 | BAD_SW_IF_INDEX_LABEL; |
| 1120 | out: |
| 1121 | REPLY_MACRO (VL_API_SW_INTERFACE_SET_RX_PLACEMENT_REPLY); |
| 1122 | } |
| 1123 | |
Neale Ranns | b8d4481 | 2017-11-10 06:53:54 -0800 | [diff] [blame] | 1124 | static void |
| 1125 | vl_api_create_vlan_subif_t_handler (vl_api_create_vlan_subif_t * mp) |
| 1126 | { |
| 1127 | vl_api_create_vlan_subif_reply_t *rmp; |
| 1128 | vnet_main_t *vnm = vnet_get_main (); |
| 1129 | u32 sw_if_index = (u32) ~ 0; |
| 1130 | vnet_hw_interface_t *hi; |
| 1131 | int rv = 0; |
| 1132 | u32 id; |
| 1133 | vnet_sw_interface_t template; |
| 1134 | uword *p; |
| 1135 | vnet_interface_main_t *im = &vnm->interface_main; |
| 1136 | u64 sup_and_sub_key; |
Florin Coras | 6c4dae2 | 2018-01-09 06:39:23 -0800 | [diff] [blame] | 1137 | vl_api_registration_t *reg; |
Neale Ranns | b8d4481 | 2017-11-10 06:53:54 -0800 | [diff] [blame] | 1138 | clib_error_t *error; |
| 1139 | |
| 1140 | VALIDATE_SW_IF_INDEX (mp); |
| 1141 | |
| 1142 | hi = vnet_get_sup_hw_interface (vnm, ntohl (mp->sw_if_index)); |
| 1143 | |
| 1144 | if (hi->bond_info == VNET_HW_INTERFACE_BOND_INFO_SLAVE) |
| 1145 | { |
| 1146 | rv = VNET_API_ERROR_BOND_SLAVE_NOT_ALLOWED; |
| 1147 | goto out; |
| 1148 | } |
| 1149 | |
| 1150 | id = ntohl (mp->vlan_id); |
| 1151 | if (id == 0 || id > 4095) |
| 1152 | { |
| 1153 | rv = VNET_API_ERROR_INVALID_VLAN; |
| 1154 | goto out; |
| 1155 | } |
| 1156 | |
| 1157 | sup_and_sub_key = ((u64) (hi->sw_if_index) << 32) | (u64) id; |
| 1158 | |
| 1159 | p = hash_get_mem (im->sw_if_index_by_sup_and_sub, &sup_and_sub_key); |
| 1160 | if (p) |
| 1161 | { |
| 1162 | rv = VNET_API_ERROR_VLAN_ALREADY_EXISTS; |
| 1163 | goto out; |
| 1164 | } |
| 1165 | |
Dave Barach | b7b9299 | 2018-10-17 10:38:51 -0400 | [diff] [blame] | 1166 | clib_memset (&template, 0, sizeof (template)); |
Neale Ranns | b8d4481 | 2017-11-10 06:53:54 -0800 | [diff] [blame] | 1167 | template.type = VNET_SW_INTERFACE_TYPE_SUB; |
Joe Zhou | 715f94e | 2019-03-06 23:05:32 -0800 | [diff] [blame] | 1168 | template.flood_class = VNET_FLOOD_CLASS_NORMAL; |
Neale Ranns | b8d4481 | 2017-11-10 06:53:54 -0800 | [diff] [blame] | 1169 | template.sup_sw_if_index = hi->sw_if_index; |
| 1170 | template.sub.id = id; |
| 1171 | template.sub.eth.raw_flags = 0; |
| 1172 | template.sub.eth.flags.one_tag = 1; |
| 1173 | template.sub.eth.outer_vlan_id = id; |
| 1174 | template.sub.eth.flags.exact_match = 1; |
| 1175 | |
| 1176 | error = vnet_create_sw_interface (vnm, &template, &sw_if_index); |
| 1177 | if (error) |
| 1178 | { |
| 1179 | clib_error_report (error); |
| 1180 | rv = VNET_API_ERROR_INVALID_REGISTRATION; |
| 1181 | goto out; |
| 1182 | } |
| 1183 | |
| 1184 | u64 *kp = clib_mem_alloc (sizeof (*kp)); |
| 1185 | *kp = sup_and_sub_key; |
| 1186 | |
| 1187 | hash_set (hi->sub_interface_sw_if_index_by_id, id, sw_if_index); |
| 1188 | hash_set_mem (im->sw_if_index_by_sup_and_sub, kp, sw_if_index); |
| 1189 | |
| 1190 | BAD_SW_IF_INDEX_LABEL; |
| 1191 | |
| 1192 | out: |
Florin Coras | 6c4dae2 | 2018-01-09 06:39:23 -0800 | [diff] [blame] | 1193 | reg = vl_api_client_index_to_registration (mp->client_index); |
| 1194 | if (!reg) |
Neale Ranns | b8d4481 | 2017-11-10 06:53:54 -0800 | [diff] [blame] | 1195 | return; |
| 1196 | |
| 1197 | rmp = vl_msg_api_alloc (sizeof (*rmp)); |
| 1198 | rmp->_vl_msg_id = htons (VL_API_CREATE_VLAN_SUBIF_REPLY); |
| 1199 | rmp->context = mp->context; |
| 1200 | rmp->retval = htonl (rv); |
| 1201 | rmp->sw_if_index = htonl (sw_if_index); |
Florin Coras | 6c4dae2 | 2018-01-09 06:39:23 -0800 | [diff] [blame] | 1202 | vl_api_send_msg (reg, (u8 *) rmp); |
Neale Ranns | b8d4481 | 2017-11-10 06:53:54 -0800 | [diff] [blame] | 1203 | } |
| 1204 | |
| 1205 | static void |
| 1206 | vl_api_create_subif_t_handler (vl_api_create_subif_t * mp) |
| 1207 | { |
| 1208 | vl_api_create_subif_reply_t *rmp; |
| 1209 | vnet_main_t *vnm = vnet_get_main (); |
| 1210 | u32 sw_if_index = ~0; |
| 1211 | int rv = 0; |
| 1212 | u32 sub_id; |
| 1213 | vnet_sw_interface_t *si; |
| 1214 | vnet_hw_interface_t *hi; |
| 1215 | vnet_sw_interface_t template; |
| 1216 | uword *p; |
| 1217 | vnet_interface_main_t *im = &vnm->interface_main; |
| 1218 | u64 sup_and_sub_key; |
| 1219 | clib_error_t *error; |
| 1220 | |
| 1221 | VALIDATE_SW_IF_INDEX (mp); |
| 1222 | |
| 1223 | si = vnet_get_sup_sw_interface (vnm, ntohl (mp->sw_if_index)); |
| 1224 | hi = vnet_get_sup_hw_interface (vnm, ntohl (mp->sw_if_index)); |
| 1225 | |
| 1226 | if (hi->bond_info == VNET_HW_INTERFACE_BOND_INFO_SLAVE) |
| 1227 | { |
| 1228 | rv = VNET_API_ERROR_BOND_SLAVE_NOT_ALLOWED; |
| 1229 | goto out; |
| 1230 | } |
| 1231 | |
| 1232 | sw_if_index = si->sw_if_index; |
| 1233 | sub_id = ntohl (mp->sub_id); |
| 1234 | |
| 1235 | sup_and_sub_key = ((u64) (sw_if_index) << 32) | (u64) sub_id; |
| 1236 | |
| 1237 | p = hash_get_mem (im->sw_if_index_by_sup_and_sub, &sup_and_sub_key); |
| 1238 | if (p) |
| 1239 | { |
| 1240 | if (CLIB_DEBUG > 0) |
| 1241 | clib_warning ("sup sw_if_index %d, sub id %d already exists\n", |
| 1242 | sw_if_index, sub_id); |
| 1243 | rv = VNET_API_ERROR_SUBIF_ALREADY_EXISTS; |
| 1244 | goto out; |
| 1245 | } |
| 1246 | |
Dave Barach | b7b9299 | 2018-10-17 10:38:51 -0400 | [diff] [blame] | 1247 | clib_memset (&template, 0, sizeof (template)); |
Neale Ranns | b8d4481 | 2017-11-10 06:53:54 -0800 | [diff] [blame] | 1248 | template.type = VNET_SW_INTERFACE_TYPE_SUB; |
Joe Zhou | 715f94e | 2019-03-06 23:05:32 -0800 | [diff] [blame] | 1249 | template.flood_class = VNET_FLOOD_CLASS_NORMAL; |
Neale Ranns | b8d4481 | 2017-11-10 06:53:54 -0800 | [diff] [blame] | 1250 | template.sup_sw_if_index = sw_if_index; |
| 1251 | template.sub.id = sub_id; |
Ole Trøan | 3b0d7e4 | 2019-03-15 16:14:41 +0000 | [diff] [blame] | 1252 | template.sub.eth.flags.no_tags = mp->no_tags; |
| 1253 | template.sub.eth.flags.one_tag = mp->one_tag; |
| 1254 | template.sub.eth.flags.two_tags = mp->two_tags; |
| 1255 | template.sub.eth.flags.dot1ad = mp->dot1ad; |
| 1256 | template.sub.eth.flags.exact_match = mp->exact_match; |
| 1257 | template.sub.eth.flags.default_sub = mp->default_sub; |
| 1258 | template.sub.eth.flags.outer_vlan_id_any = mp->outer_vlan_id_any; |
| 1259 | template.sub.eth.flags.inner_vlan_id_any = mp->inner_vlan_id_any; |
Neale Ranns | b8d4481 | 2017-11-10 06:53:54 -0800 | [diff] [blame] | 1260 | template.sub.eth.outer_vlan_id = ntohs (mp->outer_vlan_id); |
| 1261 | template.sub.eth.inner_vlan_id = ntohs (mp->inner_vlan_id); |
| 1262 | |
| 1263 | error = vnet_create_sw_interface (vnm, &template, &sw_if_index); |
| 1264 | if (error) |
| 1265 | { |
| 1266 | clib_error_report (error); |
| 1267 | rv = VNET_API_ERROR_SUBIF_CREATE_FAILED; |
| 1268 | goto out; |
| 1269 | } |
| 1270 | |
| 1271 | u64 *kp = clib_mem_alloc (sizeof (*kp)); |
| 1272 | *kp = sup_and_sub_key; |
| 1273 | |
| 1274 | hash_set (hi->sub_interface_sw_if_index_by_id, sub_id, sw_if_index); |
| 1275 | hash_set_mem (im->sw_if_index_by_sup_and_sub, kp, sw_if_index); |
| 1276 | |
| 1277 | BAD_SW_IF_INDEX_LABEL; |
| 1278 | |
| 1279 | out: |
| 1280 | |
| 1281 | /* *INDENT-OFF* */ |
| 1282 | REPLY_MACRO2(VL_API_CREATE_SUBIF_REPLY, |
| 1283 | ({ |
| 1284 | rmp->sw_if_index = ntohl(sw_if_index); |
| 1285 | })); |
| 1286 | /* *INDENT-ON* */ |
| 1287 | } |
| 1288 | |
| 1289 | static void |
| 1290 | vl_api_delete_subif_t_handler (vl_api_delete_subif_t * mp) |
| 1291 | { |
| 1292 | vl_api_delete_subif_reply_t *rmp; |
| 1293 | int rv; |
| 1294 | |
| 1295 | rv = vnet_delete_sub_interface (ntohl (mp->sw_if_index)); |
| 1296 | |
| 1297 | REPLY_MACRO (VL_API_DELETE_SUBIF_REPLY); |
| 1298 | } |
| 1299 | |
| 1300 | static void |
| 1301 | vl_api_interface_name_renumber_t_handler (vl_api_interface_name_renumber_t * |
| 1302 | mp) |
| 1303 | { |
| 1304 | vl_api_interface_name_renumber_reply_t *rmp; |
| 1305 | int rv = 0; |
| 1306 | |
| 1307 | VALIDATE_SW_IF_INDEX (mp); |
| 1308 | |
| 1309 | rv = vnet_interface_name_renumber |
| 1310 | (ntohl (mp->sw_if_index), ntohl (mp->new_show_dev_instance)); |
| 1311 | |
| 1312 | BAD_SW_IF_INDEX_LABEL; |
| 1313 | |
| 1314 | REPLY_MACRO (VL_API_INTERFACE_NAME_RENUMBER_REPLY); |
| 1315 | } |
| 1316 | |
| 1317 | static void |
| 1318 | vl_api_create_loopback_t_handler (vl_api_create_loopback_t * mp) |
| 1319 | { |
| 1320 | vl_api_create_loopback_reply_t *rmp; |
| 1321 | u32 sw_if_index; |
| 1322 | int rv; |
| 1323 | |
Ole Trøan | 3b0d7e4 | 2019-03-15 16:14:41 +0000 | [diff] [blame] | 1324 | rv = vnet_create_loopback_interface (&sw_if_index, mp->mac_address, 0, 0); |
Neale Ranns | b8d4481 | 2017-11-10 06:53:54 -0800 | [diff] [blame] | 1325 | |
| 1326 | /* *INDENT-OFF* */ |
| 1327 | REPLY_MACRO2(VL_API_CREATE_LOOPBACK_REPLY, |
| 1328 | ({ |
| 1329 | rmp->sw_if_index = ntohl (sw_if_index); |
| 1330 | })); |
| 1331 | /* *INDENT-ON* */ |
| 1332 | } |
| 1333 | |
| 1334 | static void vl_api_create_loopback_instance_t_handler |
| 1335 | (vl_api_create_loopback_instance_t * mp) |
| 1336 | { |
| 1337 | vl_api_create_loopback_instance_reply_t *rmp; |
| 1338 | u32 sw_if_index; |
| 1339 | u8 is_specified = mp->is_specified; |
| 1340 | u32 user_instance = ntohl (mp->user_instance); |
| 1341 | int rv; |
| 1342 | |
Ole Trøan | 3b0d7e4 | 2019-03-15 16:14:41 +0000 | [diff] [blame] | 1343 | rv = vnet_create_loopback_interface (&sw_if_index, mp->mac_address, |
Neale Ranns | b8d4481 | 2017-11-10 06:53:54 -0800 | [diff] [blame] | 1344 | is_specified, user_instance); |
| 1345 | |
| 1346 | /* *INDENT-OFF* */ |
| 1347 | REPLY_MACRO2(VL_API_CREATE_LOOPBACK_INSTANCE_REPLY, |
| 1348 | ({ |
| 1349 | rmp->sw_if_index = ntohl (sw_if_index); |
| 1350 | })); |
| 1351 | /* *INDENT-ON* */ |
| 1352 | } |
| 1353 | |
| 1354 | static void |
| 1355 | vl_api_delete_loopback_t_handler (vl_api_delete_loopback_t * mp) |
| 1356 | { |
| 1357 | vl_api_delete_loopback_reply_t *rmp; |
| 1358 | u32 sw_if_index; |
| 1359 | int rv; |
| 1360 | |
| 1361 | sw_if_index = ntohl (mp->sw_if_index); |
| 1362 | rv = vnet_delete_loopback_interface (sw_if_index); |
| 1363 | |
| 1364 | REPLY_MACRO (VL_API_DELETE_LOOPBACK_REPLY); |
| 1365 | } |
| 1366 | |
Neale Ranns | 6f4a6be | 2018-03-16 16:26:21 -0700 | [diff] [blame] | 1367 | static void |
| 1368 | vl_api_collect_detailed_interface_stats_t_handler |
| 1369 | (vl_api_collect_detailed_interface_stats_t * mp) |
| 1370 | { |
| 1371 | vl_api_collect_detailed_interface_stats_reply_t *rmp; |
| 1372 | int rv = 0; |
| 1373 | |
Neale Ranns | 871dc42 | 2018-03-29 01:28:09 -0700 | [diff] [blame] | 1374 | rv = |
| 1375 | vnet_sw_interface_stats_collect_enable_disable (ntohl (mp->sw_if_index), |
| 1376 | mp->enable_disable); |
Neale Ranns | 6f4a6be | 2018-03-16 16:26:21 -0700 | [diff] [blame] | 1377 | |
| 1378 | REPLY_MACRO (VL_API_COLLECT_DETAILED_INTERFACE_STATS_REPLY); |
| 1379 | } |
| 1380 | |
Dave Barach | aff7077 | 2016-10-31 11:59:07 -0400 | [diff] [blame] | 1381 | /* |
| 1382 | * vpe_api_hookup |
| 1383 | * Add vpe's API message handlers to the table. |
Paul Vinciguerra | bdc0e6b | 2018-09-22 05:32:50 -0700 | [diff] [blame] | 1384 | * vlib has already mapped shared memory and |
Dave Barach | aff7077 | 2016-10-31 11:59:07 -0400 | [diff] [blame] | 1385 | * added the client registration handlers. |
| 1386 | * See .../vlib-api/vlibmemory/memclnt_vlib.c:memclnt_process() |
| 1387 | */ |
| 1388 | #define vl_msg_name_crc_list |
Dave Barach | b5e8a77 | 2016-12-06 12:04:42 -0500 | [diff] [blame] | 1389 | #include <vnet/interface.api.h> |
Dave Barach | aff7077 | 2016-10-31 11:59:07 -0400 | [diff] [blame] | 1390 | #undef vl_msg_name_crc_list |
| 1391 | |
| 1392 | static void |
| 1393 | setup_message_id_table (api_main_t * am) |
| 1394 | { |
| 1395 | #define _(id,n,crc) vl_msg_api_add_msg_name_crc (am, #n "_" #crc, id); |
| 1396 | foreach_vl_msg_name_crc_interface; |
| 1397 | #undef _ |
| 1398 | } |
| 1399 | |
Dave Barach | 6d963c2 | 2016-12-05 09:50:05 -0500 | [diff] [blame] | 1400 | pub_sub_handler (interface_events, INTERFACE_EVENTS); |
| 1401 | |
Dave Barach | aff7077 | 2016-10-31 11:59:07 -0400 | [diff] [blame] | 1402 | static clib_error_t * |
| 1403 | interface_api_hookup (vlib_main_t * vm) |
| 1404 | { |
| 1405 | api_main_t *am = &api_main; |
| 1406 | |
| 1407 | #define _(N,n) \ |
| 1408 | vl_msg_api_set_handlers(VL_API_##N, #n, \ |
| 1409 | vl_api_##n##_t_handler, \ |
| 1410 | vl_noop_handler, \ |
| 1411 | vl_api_##n##_t_endian, \ |
| 1412 | vl_api_##n##_t_print, \ |
| 1413 | sizeof(vl_api_##n##_t), 1); |
| 1414 | foreach_vpe_api_msg; |
| 1415 | #undef _ |
| 1416 | |
| 1417 | /* |
| 1418 | * Set up the (msg_name, crc, message-id) table |
| 1419 | */ |
| 1420 | setup_message_id_table (am); |
| 1421 | |
| 1422 | return 0; |
| 1423 | } |
| 1424 | |
| 1425 | VLIB_API_INIT_FUNCTION (interface_api_hookup); |
| 1426 | |
| 1427 | /* |
| 1428 | * fd.io coding-style-patch-verification: ON |
| 1429 | * |
| 1430 | * Local Variables: |
| 1431 | * eval: (c-set-style "gnu") |
| 1432 | * End: |
| 1433 | */ |