diff options
Diffstat (limited to 'hicn-plugin/src/faces/app/address_mgr.c')
-rw-r--r-- | hicn-plugin/src/faces/app/address_mgr.c | 69 |
1 files changed, 32 insertions, 37 deletions
diff --git a/hicn-plugin/src/faces/app/address_mgr.c b/hicn-plugin/src/faces/app/address_mgr.c index 2d5894ab8..44729fd69 100644 --- a/hicn-plugin/src/faces/app/address_mgr.c +++ b/hicn-plugin/src/faces/app/address_mgr.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017-2020 Cisco and/or its affiliates. + * Copyright (c) 2021 Cisco and/or its affiliates. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: @@ -14,7 +14,7 @@ */ /* - * Copyright (c) 2017-2019 by cisco systems inc. All rights reserved. + * Copyright (c) 2021 by cisco systems inc. All rights reserved. * */ @@ -24,17 +24,18 @@ #include <vnet/ip/ip6_packet.h> #include <vnet/ip/ip4.h> //ip4_add_del_ip_address #include <vnet/ip/ip6.h> //ip6_add_del_ip_address -#include <vnet/fib/fib_types.h> //FIB_PROTOCOL_IP4/6, FIB_NODE_INDEX_INVALID -#include <vnet/fib/fib_entry.h> //FIB_SOURCE_PRIORITY_HI +#include <vnet/fib/fib_types.h> //FIB_PROTOCOL_IP4/6, FIB_NODE_INDEX_INVALID +#include <vnet/fib/fib_entry.h> //FIB_SOURCE_PRIORITY_HI #include <vnet/fib/fib_table.h> #include <vppinfra/format.h> -#include <vnet/interface.h> //appif_flags -#include <vnet/interface_funcs.h> //vnet_sw_interface_set_flags +#include <vnet/interface.h> //appif_flags +#include <vnet/interface_funcs.h> //vnet_sw_interface_set_flags + +#include <vpp_plugins/hicn/error.h> #include "address_mgr.h" #include "../../hicn.h" #include "../../infra.h" -#include "../../error.h" #include "../face.h" #include "../../strategy_dpo_ctx.h" #include "../../route.h" @@ -48,7 +49,7 @@ typedef struct address_mgr_main_s address_mgr_main_t address_mgr_main; static void -increment_v4_address (ip4_address_t * a, u32 val) +increment_v4_address (ip4_address_t *a, u32 val) { u32 v; @@ -57,7 +58,7 @@ increment_v4_address (ip4_address_t * a, u32 val) } static void -increment_v6_address (ip6_address_t * a, u64 val) +increment_v6_address (ip6_address_t *a, u64 val) { u64 v; @@ -66,7 +67,7 @@ increment_v6_address (ip6_address_t * a, u64 val) } void -get_two_ip4_addresses (ip4_address_t * appif_addr, ip4_address_t * nh_addr) +get_two_ip4_addresses (ip4_address_t *appif_addr, ip4_address_t *nh_addr) { /* We want two consecutives address that fall into a /31 mask */ if (address_mgr_main.next_ip4_local_addr.as_u8[3] & 0x01) @@ -85,20 +86,17 @@ get_two_ip4_addresses (ip4_address_t * appif_addr, ip4_address_t * nh_addr) do { /* Check if the route already exist in the fib */ - fib_pfx.fp_addr = to_ip46 ( /* is_v6 */ 0, appif_addr->as_u8); - fib_index = fib_table_find_or_create_and_lock (fib_pfx.fp_proto, - HICN_FIB_TABLE, - FIB_SOURCE_PRIORITY_HI); + fib_pfx.fp_addr = to_ip46 (/* is_v6 */ 0, appif_addr->as_u8); + fib_index = fib_table_find_or_create_and_lock ( + fib_pfx.fp_proto, HICN_FIB_TABLE, FIB_SOURCE_PRIORITY_HI); fib_entry_index = fib_table_lookup_exact_match (fib_index, &fib_pfx); fib_table_unlock (fib_index, fib_pfx.fp_proto, FIB_SOURCE_PRIORITY_HI); if (fib_entry_index != FIB_NODE_INDEX_INVALID) { - fib_pfx.fp_addr = to_ip46 ( /* is_v6 */ 0, nh_addr->as_u8); - fib_index = fib_table_find_or_create_and_lock (fib_pfx.fp_proto, - HICN_FIB_TABLE, - FIB_SOURCE_PRIORITY_HI); - fib_entry_index = - fib_table_lookup_exact_match (fib_index, &fib_pfx); + fib_pfx.fp_addr = to_ip46 (/* is_v6 */ 0, nh_addr->as_u8); + fib_index = fib_table_find_or_create_and_lock ( + fib_pfx.fp_proto, HICN_FIB_TABLE, FIB_SOURCE_PRIORITY_HI); + fib_entry_index = fib_table_lookup_exact_match (fib_index, &fib_pfx); fib_table_unlock (fib_index, fib_pfx.fp_proto, FIB_SOURCE_PRIORITY_HI); } @@ -115,7 +113,7 @@ get_two_ip4_addresses (ip4_address_t * appif_addr, ip4_address_t * nh_addr) } void -get_two_ip6_addresses (ip6_address_t * appif_addr, ip6_address_t * nh_addr) +get_two_ip6_addresses (ip6_address_t *appif_addr, ip6_address_t *nh_addr) { /* We want two consecutives address that fall into a /127 mask */ @@ -126,7 +124,6 @@ get_two_ip6_addresses (ip6_address_t * appif_addr, ip6_address_t * nh_addr) increment_v6_address (&(address_mgr_main.next_ip6_local_addr), 1); *nh_addr = address_mgr_main.next_ip6_local_addr; - fib_prefix_t fib_pfx; fib_node_index_t fib_entry_index = FIB_NODE_INDEX_INVALID; u32 fib_index; @@ -140,18 +137,18 @@ get_two_ip6_addresses (ip6_address_t * appif_addr, ip6_address_t * nh_addr) do { /* Check if the route already exist in the fib */ - fib_pfx.fp_addr = to_ip46 ( /* is_v6 */ 1, appif_addr->as_u8); + fib_pfx.fp_addr = to_ip46 (/* is_v6 */ 1, appif_addr->as_u8); fib_entry_index = fib_table_lookup_exact_match (fib_index, &fib_pfx); - //fib_table_unlock (fib_index, fib_pfx.fp_proto, FIB_SOURCE_PRIORITY_HI); + // fib_table_unlock (fib_index, fib_pfx.fp_proto, + // FIB_SOURCE_PRIORITY_HI); if (fib_entry_index != FIB_NODE_INDEX_INVALID) { - fib_pfx.fp_addr = to_ip46 ( /* is_v6 */ 0, nh_addr->as_u8); + fib_pfx.fp_addr = to_ip46 (/* is_v6 */ 0, nh_addr->as_u8); - fib_entry_index = - fib_table_lookup_exact_match (fib_index, &fib_pfx); - // fib_table_unlock (fib_index, fib_pfx.fp_proto, - // FIB_SOURCE_PRIORITY_HI); + fib_entry_index = fib_table_lookup_exact_match (fib_index, &fib_pfx); + // fib_table_unlock (fib_index, fib_pfx.fp_proto, + // FIB_SOURCE_PRIORITY_HI); } if (fib_entry_index != FIB_NODE_INDEX_INVALID) { @@ -179,10 +176,9 @@ get_ip4_address () do { /* Check if the route already exist in the fib */ - fib_pfx.fp_addr = to_ip46 ( /* is_v6 */ 0, prefix->as_u8); - fib_index = fib_table_find_or_create_and_lock (fib_pfx.fp_proto, - HICN_FIB_TABLE, - FIB_SOURCE_PRIORITY_HI); + fib_pfx.fp_addr = to_ip46 (/* is_v6 */ 0, prefix->as_u8); + fib_index = fib_table_find_or_create_and_lock ( + fib_pfx.fp_proto, HICN_FIB_TABLE, FIB_SOURCE_PRIORITY_HI); fib_entry_index = fib_table_lookup_exact_match (fib_index, &fib_pfx); fib_table_unlock (fib_index, fib_pfx.fp_proto, FIB_SOURCE_PRIORITY_HI); increment_v4_address (prefix, 1); @@ -206,10 +202,9 @@ get_ip6_address () do { /* Check if the route already exist in the fib */ - fib_pfx.fp_addr = to_ip46 ( /* is_v6 */ 1, prefix->as_u8); - fib_index = fib_table_find_or_create_and_lock (fib_pfx.fp_proto, - HICN_FIB_TABLE, - FIB_SOURCE_PRIORITY_HI); + fib_pfx.fp_addr = to_ip46 (/* is_v6 */ 1, prefix->as_u8); + fib_index = fib_table_find_or_create_and_lock ( + fib_pfx.fp_proto, HICN_FIB_TABLE, FIB_SOURCE_PRIORITY_HI); fib_entry_index = fib_table_lookup_exact_match (fib_index, &fib_pfx); fib_table_unlock (fib_index, fib_pfx.fp_proto, FIB_SOURCE_PRIORITY_HI); increment_v6_address (prefix, 1); |