2 * Copyright (c) 2020 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:
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 #include <vnet/ip/vtep.h>
19 vtep_addr_ref (vtep_table_t * t, u32 fib_index, ip46_address_t * ip)
21 vtep4_key_t key4 = {.addr = ip->ip4,.fib_index = fib_index };
22 vtep6_key_t key6 = {.addr = ip->ip6,.fib_index = fib_index };
23 uword *vtep = ip46_address_is_ip4 (ip) ?
24 hash_get (t->vtep4, key4.as_u64) : hash_get_mem (t->vtep6, &key6);
27 ip46_address_is_ip4 (ip) ?
28 hash_set (t->vtep4, key4.as_u64, 1) :
29 hash_set_mem_alloc (&t->vtep6, &key6, 1);
34 vtep_addr_unref (vtep_table_t * t, u32 fib_index, ip46_address_t * ip)
36 vtep4_key_t key4 = {.addr = ip->ip4,.fib_index = fib_index };
37 vtep6_key_t key6 = {.addr = ip->ip6,.fib_index = fib_index };
38 uword *vtep = ip46_address_is_ip4 (ip) ?
39 hash_get (t->vtep4, key4.as_u64) : hash_get_mem (t->vtep6, &key6);
43 ip46_address_is_ip4 (ip) ?
44 hash_unset (t->vtep4, key4.as_u64) :
45 hash_unset_mem_free (&t->vtep6, &key6);
50 * fd.io coding-style-patch-verification: ON
53 * eval: (c-set-style "gnu")