Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015 Cisco and/or its affiliates. |
| 3 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | * you may not use this file except in compliance with the License. |
| 5 | * You may obtain a copy of the License at: |
| 6 | * |
| 7 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | * |
| 9 | * Unless required by applicable law or agreed to in writing, software |
| 10 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | * See the License for the specific language governing permissions and |
| 13 | * limitations under the License. |
| 14 | */ |
| 15 | /* |
| 16 | * rewrite.c: packet rewrite |
| 17 | * |
| 18 | * Copyright (c) 2008 Eliot Dresselhaus |
| 19 | * |
| 20 | * Permission is hereby granted, free of charge, to any person obtaining |
| 21 | * a copy of this software and associated documentation files (the |
| 22 | * "Software"), to deal in the Software without restriction, including |
| 23 | * without limitation the rights to use, copy, modify, merge, publish, |
| 24 | * distribute, sublicense, and/or sell copies of the Software, and to |
| 25 | * permit persons to whom the Software is furnished to do so, subject to |
| 26 | * the following conditions: |
| 27 | * |
| 28 | * The above copyright notice and this permission notice shall be |
| 29 | * included in all copies or substantial portions of the Software. |
| 30 | * |
| 31 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
| 32 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
| 33 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
| 34 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE |
| 35 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION |
| 36 | * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION |
| 37 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 38 | */ |
| 39 | |
| 40 | #include <vnet/vnet.h> |
| 41 | #include <vnet/ip/lookup.h> |
| 42 | |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 43 | void |
| 44 | vnet_rewrite_copy_slow_path (vnet_rewrite_data_t * p0, |
| 45 | vnet_rewrite_data_t * rw0, |
| 46 | word n_left, uword most_likely_size) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 47 | { |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 48 | uword n_done = |
| 49 | round_pow2 (most_likely_size, sizeof (rw0[0])) / sizeof (rw0[0]); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 50 | |
| 51 | p0 -= n_done; |
| 52 | rw0 -= n_done; |
| 53 | |
| 54 | /* As we enter the cleanup loop, p0 and rw0 point to the last chunk written |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 55 | by the fast path. Hence, the constant 1, which the |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 56 | vnet_rewrite_copy_one macro renders as p0[-1] = rw0[-1]. */ |
| 57 | |
| 58 | while (n_left > 0) |
| 59 | { |
| 60 | vnet_rewrite_copy_one (p0, rw0, 1); |
| 61 | p0--; |
| 62 | rw0--; |
| 63 | n_left--; |
| 64 | } |
| 65 | } |
| 66 | |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 67 | u8 * |
| 68 | format_vnet_rewrite (u8 * s, va_list * args) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 69 | { |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 70 | vlib_main_t *vm = va_arg (*args, vlib_main_t *); |
| 71 | vnet_rewrite_header_t *rw = va_arg (*args, vnet_rewrite_header_t *); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 72 | u32 max_data_bytes = va_arg (*args, u32); |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 73 | CLIB_UNUSED (uword indent) = va_arg (*args, u32); |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 74 | vnet_main_t *vnm = vnet_get_main (); |
| 75 | vlib_node_t *next; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 76 | |
| 77 | next = vlib_get_next_node (vm, rw->node_index, rw->next_index); |
| 78 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 79 | if (rw->sw_if_index != ~0) |
| 80 | { |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 81 | vnet_sw_interface_t *si; |
Neale Ranns | 7515228 | 2017-01-09 01:00:45 -0800 | [diff] [blame] | 82 | si = vnet_get_sw_interface_safe (vnm, rw->sw_if_index); |
| 83 | if (NULL != si) |
| 84 | s = format (s, "%U: ", format_vnet_sw_interface_name, vnm, si); |
| 85 | else |
| 86 | s = format (s, "DELETED"); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 87 | } |
| 88 | else |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 89 | s = format (s, "%v: ", next->name); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 90 | |
| 91 | /* Format rewrite string. */ |
| 92 | if (rw->data_bytes > 0) |
Neale Ranns | 0bfe5d8 | 2016-08-25 15:29:12 +0100 | [diff] [blame] | 93 | |
| 94 | s = format (s, "%U", |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 95 | next->format_buffer ? next->format_buffer : format_hex_bytes, |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 96 | rw->data + max_data_bytes - rw->data_bytes, rw->data_bytes); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 97 | |
| 98 | return s; |
| 99 | } |
| 100 | |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 101 | u8 * |
| 102 | format_vnet_rewrite_header (u8 * s, va_list * args) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 103 | { |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 104 | vlib_main_t *vm = va_arg (*args, vlib_main_t *); |
| 105 | vnet_rewrite_header_t *rw = va_arg (*args, vnet_rewrite_header_t *); |
| 106 | u8 *packet_data = va_arg (*args, u8 *); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 107 | u32 packet_data_bytes = va_arg (*args, u32); |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 108 | vlib_node_t *next; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 109 | |
| 110 | next = vlib_get_next_node (vm, rw->node_index, rw->next_index); |
| 111 | |
| 112 | /* Format rewrite string. */ |
| 113 | s = format (s, "%U", |
| 114 | next->format_buffer ? next->format_buffer : format_hex_bytes, |
| 115 | packet_data, packet_data_bytes); |
| 116 | |
| 117 | return s; |
| 118 | } |
| 119 | |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 120 | uword |
| 121 | unformat_vnet_rewrite (unformat_input_t * input, va_list * args) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 122 | { |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 123 | vlib_main_t *vm = va_arg (*args, vlib_main_t *); |
| 124 | vnet_rewrite_header_t *rw = va_arg (*args, vnet_rewrite_header_t *); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 125 | u32 max_data_bytes = va_arg (*args, u32); |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 126 | vnet_main_t *vnm = vnet_get_main (); |
| 127 | vlib_node_t *next; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 128 | u32 next_index, sw_if_index, max_packet_bytes, error; |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 129 | u8 *rw_data; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 130 | |
| 131 | rw_data = 0; |
| 132 | sw_if_index = ~0; |
| 133 | max_packet_bytes = ~0; |
| 134 | error = 1; |
| 135 | |
| 136 | /* Parse sw interface. */ |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 137 | if (unformat (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index)) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 138 | { |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 139 | vnet_hw_interface_t *hi; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 140 | |
| 141 | hi = vnet_get_sup_hw_interface (vnm, sw_if_index); |
| 142 | |
| 143 | next_index = hi->output_node_index; |
| 144 | max_packet_bytes = hi->max_l3_packet_bytes[VLIB_RX]; |
| 145 | } |
| 146 | |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 147 | else if (unformat (input, "%U", unformat_vlib_node, vm, &next_index)) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 148 | ; |
| 149 | |
| 150 | else |
| 151 | goto done; |
| 152 | |
| 153 | next = vlib_get_node (vm, next_index); |
| 154 | |
| 155 | if (next->unformat_buffer |
| 156 | && unformat_user (input, next->unformat_buffer, &rw_data)) |
| 157 | ; |
| 158 | |
| 159 | else if (unformat_user (input, unformat_hex_string, &rw_data) |
| 160 | || unformat (input, "0x%U", unformat_hex_string, &rw_data)) |
| 161 | ; |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 162 | |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 163 | else |
| 164 | goto done; |
| 165 | |
| 166 | /* Re-write does not fit. */ |
| 167 | if (vec_len (rw_data) >= max_data_bytes) |
| 168 | goto done; |
| 169 | |
| 170 | { |
| 171 | u32 tmp; |
| 172 | |
| 173 | if (unformat (input, "mtu %d", &tmp) |
| 174 | && tmp < (1 << BITS (rw->max_l3_packet_bytes))) |
| 175 | max_packet_bytes = tmp; |
| 176 | } |
| 177 | |
| 178 | error = 0; |
| 179 | rw->sw_if_index = sw_if_index; |
| 180 | rw->max_l3_packet_bytes = max_packet_bytes; |
| 181 | rw->next_index = vlib_node_add_next (vm, rw->node_index, next_index); |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 182 | vnet_rewrite_set_data_internal (rw, max_data_bytes, rw_data, |
| 183 | vec_len (rw_data)); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 184 | |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 185 | done: |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 186 | vec_free (rw_data); |
| 187 | return error == 0; |
| 188 | } |
| 189 | |
Neale Ranns | b80c536 | 2016-10-08 13:03:40 +0100 | [diff] [blame] | 190 | u32 |
| 191 | vnet_tx_node_index_for_sw_interface (vnet_main_t * vnm, u32 sw_if_index) |
| 192 | { |
| 193 | vnet_hw_interface_t *hw = vnet_get_sup_hw_interface (vnm, sw_if_index); |
| 194 | return (hw->output_node_index); |
| 195 | } |
| 196 | |
| 197 | void |
| 198 | vnet_rewrite_init (vnet_main_t * vnm, |
| 199 | u32 sw_if_index, |
| 200 | u32 this_node, u32 next_node, vnet_rewrite_header_t * rw) |
| 201 | { |
| 202 | rw->sw_if_index = sw_if_index; |
| 203 | rw->node_index = this_node; |
| 204 | rw->next_index = vlib_node_add_next (vnm->vlib_main, this_node, next_node); |
| 205 | rw->max_l3_packet_bytes = |
| 206 | vnet_sw_interface_get_mtu (vnm, sw_if_index, VLIB_TX); |
| 207 | } |
| 208 | |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 209 | void |
| 210 | vnet_rewrite_for_sw_interface (vnet_main_t * vnm, |
Neale Ranns | b80c536 | 2016-10-08 13:03:40 +0100 | [diff] [blame] | 211 | vnet_link_t link_type, |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 212 | u32 sw_if_index, |
| 213 | u32 node_index, |
| 214 | void *dst_address, |
| 215 | vnet_rewrite_header_t * rw, |
| 216 | u32 max_rewrite_bytes) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 217 | { |
Neale Ranns | b80c536 | 2016-10-08 13:03:40 +0100 | [diff] [blame] | 218 | |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 219 | vnet_hw_interface_t *hw = vnet_get_sup_hw_interface (vnm, sw_if_index); |
| 220 | vnet_hw_interface_class_t *hc = |
| 221 | vnet_get_hw_interface_class (vnm, hw->hw_class_index); |
Neale Ranns | b80c536 | 2016-10-08 13:03:40 +0100 | [diff] [blame] | 222 | u8 *rewrite = NULL; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 223 | |
Neale Ranns | b80c536 | 2016-10-08 13:03:40 +0100 | [diff] [blame] | 224 | vnet_rewrite_init (vnm, sw_if_index, node_index, |
| 225 | vnet_tx_node_index_for_sw_interface (vnm, sw_if_index), |
| 226 | rw); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 227 | |
Neale Ranns | b80c536 | 2016-10-08 13:03:40 +0100 | [diff] [blame] | 228 | ASSERT (hc->build_rewrite); |
| 229 | rewrite = hc->build_rewrite (vnm, sw_if_index, link_type, dst_address); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 230 | |
Neale Ranns | b80c536 | 2016-10-08 13:03:40 +0100 | [diff] [blame] | 231 | ASSERT (vec_len (rewrite) < max_rewrite_bytes); |
| 232 | vnet_rewrite_set_data_internal (rw, max_rewrite_bytes, rewrite, |
| 233 | vec_len (rewrite)); |
| 234 | vec_free (rewrite); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 235 | } |
| 236 | |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 237 | void |
| 238 | vnet_rewrite_for_tunnel (vnet_main_t * vnm, |
| 239 | u32 tx_sw_if_index, |
| 240 | u32 rewrite_node_index, |
| 241 | u32 post_rewrite_node_index, |
| 242 | vnet_rewrite_header_t * rw, |
| 243 | u8 * rewrite_data, u32 rewrite_length) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 244 | { |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 245 | ip_adjacency_t *adj = 0; |
| 246 | /* |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 247 | * Installed into vnet_buffer(b)->sw_if_index[VLIB_TX] e.g. |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 248 | * by ip4_rewrite_inline. If the post-rewrite node injects into |
| 249 | * ipX-forward, this will be interpreted as a FIB number. |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 250 | */ |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 251 | rw->sw_if_index = tx_sw_if_index; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 252 | rw->node_index = rewrite_node_index; |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 253 | rw->next_index = vlib_node_add_next (vnm->vlib_main, rewrite_node_index, |
| 254 | post_rewrite_node_index); |
| 255 | rw->max_l3_packet_bytes = (u16) ~ 0; /* we can't know at this point */ |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 256 | |
| 257 | ASSERT (rewrite_length < sizeof (adj->rewrite_data)); |
| 258 | /* Leave room for ethernet + VLAN tag */ |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 259 | vnet_rewrite_set_data_internal (rw, sizeof (adj->rewrite_data), |
| 260 | rewrite_data, rewrite_length); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 261 | } |
| 262 | |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 263 | void |
| 264 | serialize_vnet_rewrite (serialize_main_t * m, va_list * va) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 265 | { |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 266 | vnet_rewrite_header_t *rw = va_arg (*va, vnet_rewrite_header_t *); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 267 | u32 max_data_bytes = va_arg (*va, u32); |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 268 | u8 *p; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 269 | |
| 270 | serialize_integer (m, rw->sw_if_index, sizeof (rw->sw_if_index)); |
| 271 | serialize_integer (m, rw->data_bytes, sizeof (rw->data_bytes)); |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 272 | serialize_integer (m, rw->max_l3_packet_bytes, |
| 273 | sizeof (rw->max_l3_packet_bytes)); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 274 | p = serialize_get (m, rw->data_bytes); |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 275 | clib_memcpy (p, vnet_rewrite_get_data_internal (rw, max_data_bytes), |
| 276 | rw->data_bytes); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 277 | } |
| 278 | |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 279 | void |
| 280 | unserialize_vnet_rewrite (serialize_main_t * m, va_list * va) |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 281 | { |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 282 | vnet_rewrite_header_t *rw = va_arg (*va, vnet_rewrite_header_t *); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 283 | u32 max_data_bytes = va_arg (*va, u32); |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 284 | u8 *p; |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 285 | |
| 286 | /* It is up to user to fill these in. */ |
| 287 | rw->node_index = ~0; |
| 288 | rw->next_index = ~0; |
| 289 | |
| 290 | unserialize_integer (m, &rw->sw_if_index, sizeof (rw->sw_if_index)); |
| 291 | unserialize_integer (m, &rw->data_bytes, sizeof (rw->data_bytes)); |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 292 | unserialize_integer (m, &rw->max_l3_packet_bytes, |
| 293 | sizeof (rw->max_l3_packet_bytes)); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 294 | p = unserialize_get (m, rw->data_bytes); |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 295 | clib_memcpy (vnet_rewrite_get_data_internal (rw, max_data_bytes), p, |
| 296 | rw->data_bytes); |
Ed Warnicke | cb9cada | 2015-12-08 15:45:58 -0700 | [diff] [blame] | 297 | } |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 298 | |
Neale Ranns | b80c536 | 2016-10-08 13:03:40 +0100 | [diff] [blame] | 299 | u8 * |
| 300 | vnet_build_rewrite_for_sw_interface (vnet_main_t * vnm, |
| 301 | u32 sw_if_index, |
| 302 | vnet_link_t link_type, |
| 303 | const void *dst_address) |
| 304 | { |
| 305 | vnet_hw_interface_t *hw = vnet_get_sup_hw_interface (vnm, sw_if_index); |
| 306 | vnet_hw_interface_class_t *hc = |
| 307 | vnet_get_hw_interface_class (vnm, hw->hw_class_index); |
| 308 | |
| 309 | ASSERT (hc->build_rewrite); |
| 310 | return (hc->build_rewrite (vnm, sw_if_index, link_type, dst_address)); |
| 311 | } |
| 312 | |
| 313 | |
| 314 | void |
| 315 | vnet_update_adjacency_for_sw_interface (vnet_main_t * vnm, |
| 316 | u32 sw_if_index, u32 ai) |
| 317 | { |
| 318 | vnet_hw_interface_t *hw = vnet_get_sup_hw_interface (vnm, sw_if_index); |
| 319 | vnet_hw_interface_class_t *hc = |
| 320 | vnet_get_hw_interface_class (vnm, hw->hw_class_index); |
| 321 | |
| 322 | ASSERT (hc->update_adjacency); |
| 323 | hc->update_adjacency (vnm, sw_if_index, ai); |
| 324 | } |
| 325 | |
Dave Barach | ba868bb | 2016-08-08 09:51:21 -0400 | [diff] [blame] | 326 | /* |
| 327 | * fd.io coding-style-patch-verification: ON |
| 328 | * |
| 329 | * Local Variables: |
| 330 | * eval: (c-set-style "gnu") |
| 331 | * End: |
| 332 | */ |