diff options
author | Neale Ranns <nranns@cisco.com> | 2020-08-20 08:22:56 +0000 |
---|---|---|
committer | Ole Tr�an <otroan@employees.org> | 2020-11-20 10:27:01 +0000 |
commit | dc617b8df442f3e25197ec64ffd58d11411b0470 (patch) | |
tree | a573462413e12b71d71515f84e53900686424917 /src/vnet/ip-neighbor/ip_neighbor_api.c | |
parent | d01d2ce4498dae4cbcba65784babe91d56d4bae9 (diff) |
ip-neighbor: Use ip_address_t rather than ip46_address_t
Type: improvement
Change-Id: Ica5f395075677bda5f38d28e704f65350af88610
Signed-off-by: Neale Ranns <nranns@cisco.com>
Diffstat (limited to 'src/vnet/ip-neighbor/ip_neighbor_api.c')
-rw-r--r-- | src/vnet/ip-neighbor/ip_neighbor_api.c | 49 |
1 files changed, 18 insertions, 31 deletions
diff --git a/src/vnet/ip-neighbor/ip_neighbor_api.c b/src/vnet/ip-neighbor/ip_neighbor_api.c index 02952c7ba24..39d77855e9f 100644 --- a/src/vnet/ip-neighbor/ip_neighbor_api.c +++ b/src/vnet/ip-neighbor/ip_neighbor_api.c @@ -37,13 +37,6 @@ static u16 msg_id_base; #include <vnet/format_fns.h> - -static ip46_type_t -ip46_type_from_af (ip_address_family_t af) -{ - return (AF_IP4 == af ? IP46_TYPE_IP4 : IP46_TYPE_IP6); -} - static vl_api_ip_neighbor_flags_t ip_neighbor_flags_encode (ip_neighbor_flags_t f) { @@ -63,8 +56,7 @@ ip_neighbor_encode (vl_api_ip_neighbor_t * api, const ip_neighbor_t * ipn) api->sw_if_index = htonl (ipn->ipn_key->ipnk_sw_if_index); api->flags = ip_neighbor_flags_encode (ipn->ipn_flags); - ip_address_encode (&ipn->ipn_key->ipnk_ip, - ipn->ipn_key->ipnk_type, &api->ip_address); + ip_address_encode2 (&ipn->ipn_key->ipnk_ip, &api->ip_address); mac_address_encode (&ipn->ipn_mac, api->mac_address); } @@ -108,8 +100,8 @@ ip_neighbor_handle_event (const ip_neighbor_event_t * ipne) if (vlib_time_now (vlib_get_main ()) > last_time + 10.0) { clib_warning ("ip6 nd event for %U to pid %d: queue stuffed!", - format_ip46_address, &ipn->ipn_key->ipnk_ip, - IP46_TYPE_ANY, ipne->ipne_watch.ipw_pid); + format_ip_address, &ipn->ipn_key->ipnk_ip, + ipne->ipne_watch.ipw_pid); last_time = vlib_time_now (vlib_get_main ()); } } @@ -167,10 +159,7 @@ vl_api_ip_neighbor_dump_t_handler (vl_api_ip_neighbor_dump_t * mp) }; // walk all neighbours on all interfaces - ip_neighbor_walk ((af == AF_IP4 ? - IP46_TYPE_IP4 : - IP46_TYPE_IP6), - sw_if_index, send_ip_neighbor_details, &ctx); + ip_neighbor_walk (af, sw_if_index, send_ip_neighbor_details, &ctx); } static ip_neighbor_flags_t @@ -193,15 +182,14 @@ vl_api_ip_neighbor_add_del_t_handler (vl_api_ip_neighbor_add_del_t * mp, vl_api_ip_neighbor_add_del_reply_t *rmp; ip_neighbor_flags_t flags; u32 stats_index = ~0; - ip46_address_t ip = ip46_address_initializer; + ip_address_t ip = ip_address_initializer; mac_address_t mac; - ip46_type_t type; int rv; VALIDATE_SW_IF_INDEX ((&mp->neighbor)); flags = ip_neighbor_flags_decode (mp->neighbor.flags); - type = ip_address_decode (&mp->neighbor.ip_address, &ip); + ip_address_decode2 (&mp->neighbor.ip_address, &ip); mac_address_decode (mp->neighbor.mac_address, &mac); /* must be static or dynamic, default to dynamic */ @@ -215,11 +203,11 @@ vl_api_ip_neighbor_add_del_t_handler (vl_api_ip_neighbor_add_del_t * mp, * will come of adding bogus entries. */ if (mp->is_add) - rv = ip_neighbor_add (&ip, type, &mac, + rv = ip_neighbor_add (&ip, &mac, ntohl (mp->neighbor.sw_if_index), flags, &stats_index); else - rv = ip_neighbor_del (&ip, type, ntohl (mp->neighbor.sw_if_index)); + rv = ip_neighbor_del (&ip, ntohl (mp->neighbor.sw_if_index)); BAD_SW_IF_INDEX_LABEL; @@ -236,13 +224,12 @@ vl_api_want_ip_neighbor_events_t_handler (vl_api_want_ip_neighbor_events_t * mp) { vl_api_want_ip_neighbor_events_reply_t *rmp; - ip46_address_t ip; - ip46_type_t itype; + ip_address_t ip; int rv = 0; if (mp->sw_if_index != ~0) VALIDATE_SW_IF_INDEX (mp); - itype = ip_address_decode (&mp->ip, &ip); + ip_address_decode2 (&mp->ip, &ip); ip_neighbor_watcher_t watch = { .ipw_client = mp->client_index, @@ -250,9 +237,9 @@ vl_api_want_ip_neighbor_events_t_handler (vl_api_want_ip_neighbor_events_t * }; if (mp->enable) - ip_neighbor_watch (&ip, itype, ntohl (mp->sw_if_index), &watch); + ip_neighbor_watch (&ip, ntohl (mp->sw_if_index), &watch); else - ip_neighbor_unwatch (&ip, itype, ntohl (mp->sw_if_index), &watch); + ip_neighbor_unwatch (&ip, ntohl (mp->sw_if_index), &watch); BAD_SW_IF_INDEX_LABEL; REPLY_MACRO (VL_API_WANT_IP_NEIGHBOR_EVENTS_REPLY); @@ -268,7 +255,7 @@ vl_api_ip_neighbor_config_t_handler (vl_api_ip_neighbor_config_t * mp) rv = ip_address_family_decode (mp->af, &af); if (!rv) - rv = ip_neighbor_config (ip46_type_from_af (af), + rv = ip_neighbor_config (af, ntohl (mp->max_number), ntohl (mp->max_age), mp->recycle); @@ -282,8 +269,8 @@ vl_api_ip_neighbor_replace_begin_t_handler (vl_api_ip_neighbor_replace_begin_t vl_api_ip_neighbor_replace_begin_reply_t *rmp; int rv = 0; - ip_neighbor_mark (IP46_TYPE_IP4); - ip_neighbor_mark (IP46_TYPE_IP6); + ip_neighbor_mark (AF_IP4); + ip_neighbor_mark (AF_IP6); REPLY_MACRO (VL_API_IP_NEIGHBOR_REPLACE_BEGIN_REPLY); } @@ -295,8 +282,8 @@ vl_api_ip_neighbor_replace_end_t_handler (vl_api_ip_neighbor_replace_end_t * vl_api_ip_neighbor_replace_end_reply_t *rmp; int rv = 0; - ip_neighbor_sweep (IP46_TYPE_IP4); - ip_neighbor_sweep (IP46_TYPE_IP6); + ip_neighbor_sweep (AF_IP4); + ip_neighbor_sweep (AF_IP6); REPLY_MACRO (VL_API_IP_NEIGHBOR_REPLACE_END_REPLY); } @@ -314,7 +301,7 @@ vl_api_ip_neighbor_flush_t_handler (vl_api_ip_neighbor_flush_t * mp) rv = ip_address_family_decode (mp->af, &af); if (!rv) - ip_neighbor_del_all (ip46_type_from_af (af), ntohl (mp->sw_if_index)); + ip_neighbor_del_all (af, ntohl (mp->sw_if_index)); BAD_SW_IF_INDEX_LABEL; REPLY_MACRO (VL_API_IP_NEIGHBOR_FLUSH_REPLY); |