diff options
author | Jakub Grajciar <jgrajcia@cisco.com> | 2019-10-24 13:52:42 +0200 |
---|---|---|
committer | Ole Trøan <otroan@employees.org> | 2020-03-09 13:46:29 +0000 |
commit | 145e330f019920b5ef77f4e8b3fa70de3228710d (patch) | |
tree | 7eede6c2dfa7a3f0568071c9f1bbf6aa8319fb71 /src/vnet | |
parent | 262971e7830413c58b9b45965f799f540e634437 (diff) |
l2: API cleanup
Use consistent API types.
Type: fix
Change-Id: I7ac7cd00606101864fa3422e7b9ea2f1143665dd
Signed-off-by: Jakub Grajciar <jgrajcia@cisco.com>
Diffstat (limited to 'src/vnet')
-rw-r--r-- | src/vnet/l2/l2.api | 161 | ||||
-rw-r--r-- | src/vnet/l2/l2_api.c | 39 | ||||
-rw-r--r-- | src/vnet/l2/l2_fib.c | 9 |
3 files changed, 121 insertions, 88 deletions
diff --git a/src/vnet/l2/l2.api b/src/vnet/l2/l2.api index 06663595cf7..00ff66c9019 100644 --- a/src/vnet/l2/l2.api +++ b/src/vnet/l2/l2.api @@ -14,13 +14,13 @@ * limitations under the License. */ -option version = "2.2.2"; +option version = "3.0.0"; import "vnet/ip/ip_types.api"; import "vnet/ethernet/ethernet_types.api"; import "vnet/interface_types.api"; -/** \brief Reply to l2_xconnect_dump +/** \brief Reply to l2_xconnect_dump @param context - sender context which was passed in the request @param rx_sw_if_index - Receive interface index @param tx_sw_if_index - Transmit interface index @@ -28,8 +28,8 @@ import "vnet/interface_types.api"; define l2_xconnect_details { u32 context; - u32 rx_sw_if_index; - u32 tx_sw_if_index; + vl_api_interface_index_t rx_sw_if_index; + vl_api_interface_index_t tx_sw_if_index; }; /** \brief Dump L2 XConnects @@ -54,11 +54,11 @@ define l2_fib_table_details { u32 context; u32 bd_id; - u8 mac[6]; - u32 sw_if_index; - u8 static_mac; - u8 filter_mac; - u8 bvi_mac; + vl_api_mac_address_t mac; + vl_api_interface_index_t sw_if_index; + bool static_mac; + bool filter_mac; + bool bvi_mac; }; /** \brief Dump l2 fib (aka bridge domain) table @@ -113,7 +113,7 @@ autoreply define l2fib_flush_int { u32 client_index; u32 context; - u32 sw_if_index; + vl_api_interface_index_t sw_if_index; }; /** \brief L2 FIB add entry request @@ -123,28 +123,29 @@ autoreply define l2fib_flush_int @param bd_id - the entry's bridge domain id @param sw_if_index - the interface @param is_add - If non zero add the entry, else delete it - @param static_mac - + @param static_mac - @param filter_mac - + @param bvi_mac - */ autoreply define l2fib_add_del { u32 client_index; u32 context; - u8 mac[6]; + vl_api_mac_address_t mac; u32 bd_id; - u32 sw_if_index; - u8 is_add; - u8 static_mac; - u8 filter_mac; - u8 bvi_mac; + vl_api_interface_index_t sw_if_index; + bool is_add [default=true]; + bool static_mac; + bool filter_mac; + bool bvi_mac; }; /** \brief Register to receive L2 MAC events for learned and aged MAC @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request - @param learn_limit - MAC learn limit, 0 => default to 1000 - @param scan_delay - event scan delay in 10 msec unit, 0 => default to 100 msec - @param max_macs_in_event - in units of 10 mac entries, 0 => default to 100 entries + @param learn_limit - MAC learn limit + @param scan_delay - event scan delay in 10 msec unit + @param max_macs_in_event - in units of 10 mac entries @param enable_disable - 1 => register for MAC events, 0 => cancel registration @param pid - sender's pid */ @@ -152,26 +153,33 @@ autoreply define want_l2_macs_events { u32 client_index; u32 context; - u32 learn_limit; - u8 scan_delay; - u8 max_macs_in_event; - bool enable_disable; + u32 learn_limit [default=1000]; + u8 scan_delay [default=10]; + u8 max_macs_in_event [default=10]; + bool enable_disable [default=true]; u32 pid; }; +enum mac_event_action +{ + MAC_EVENT_ACTION_API_ADD = 0, + MAC_EVENT_ACTION_API_DELETE = 1, + MAC_EVENT_ACTION_API_MOVE = 2, +}; + /** \brief Entry for learned or aged MAC in L2 MAC Events @param sw_if_index - sw_if_index in the domain @param mac_addr - mac_address @param action - 0 => newly learned MAC, 1 => MAC deleted by ager - 3 => MAC move (sw_if_index changed) + 2 => MAC move (sw_if_index changed) @param flags - flag bits to provide other info, not yet used */ typedef mac_entry { - u32 sw_if_index; - u8 mac_addr[6]; - u8 action; - u8 flags; + vl_api_interface_index_t sw_if_index; + vl_api_mac_address_t mac_addr; + vl_api_mac_event_action_t action; + u8 flags; }; /** \brief L2 MAC event for a list of learned or aged MACs @@ -193,14 +201,14 @@ service { events l2_macs_event; }; -/** \brief Set interface L2 flags (such as L2_LEARN, L2_FWD, +/** \brief Set interface L2 flags (such as L2_LEARN, L2_FWD, L2_FLOOD, L2_UU_FLOOD, or L2_ARP_TERM bits). This can be used to disable one or more of the features represented by the flag bits on an interface to override what is set as default for all interfaces in the bridge domain @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request - @param sw_if_index - interface + @param sw_if_index - interface @param is_set - if non-zero, set the bits, else clear them @param feature_bitmap - non-zero bits (as above) to set or clear */ @@ -208,8 +216,8 @@ define l2_flags { u32 client_index; u32 context; - u32 sw_if_index; - u8 is_set; + vl_api_interface_index_t sw_if_index; + bool is_set; u32 feature_bitmap; }; @@ -257,27 +265,29 @@ autoreply define bridge_domain_add_del u32 client_index; u32 context; u32 bd_id; - u8 flood; - u8 uu_flood; - u8 forward; - u8 learn; - u8 arp_term; - u8 arp_ufwd; + bool flood; + bool uu_flood; + bool forward; + bool learn; + bool arp_term; + bool arp_ufwd; u8 mac_age; - u8 bd_tag[64]; - u8 is_add; + string bd_tag[64]; + bool is_add [default=true]; }; /** \brief L2 bridge domain request operational state details @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request @param bd_id - the bridge domain id desired or ~0 to request all bds + @param sw_if_index - filter by sw_if_index UNIMPLEMENTED */ define bridge_domain_dump { u32 client_index; u32 context; - u32 bd_id; + u32 bd_id [default=0xffffffff]; + vl_api_interface_index_t sw_if_index [default=0xffffffff]; }; /** \brief L2 bridge domain sw interface operational state response @@ -288,7 +298,8 @@ define bridge_domain_dump typedef bridge_domain_sw_if { u32 context; - u32 sw_if_index; + vl_api_interface_index_t sw_if_index; + /* FIXME: set_int_l2_mode() u32/ api u8 */ u8 shg; }; @@ -308,16 +319,16 @@ manual_print manual_endian define bridge_domain_details { u32 context; u32 bd_id; - u8 flood; - u8 uu_flood; - u8 forward; - u8 learn; - u8 arp_term; - u8 arp_ufwd; + bool flood; + bool uu_flood; + bool forward; + bool learn; + bool arp_term; + bool arp_ufwd; u8 mac_age; - u8 bd_tag[64]; - u32 bvi_sw_if_index; - u32 uu_fwd_sw_if_index; + string bd_tag[64]; + vl_api_interface_index_t bvi_sw_if_index; + vl_api_interface_index_t uu_fwd_sw_if_index; u32 n_sw_ifs; vl_api_bridge_domain_sw_if_t sw_if_details[n_sw_ifs]; }; @@ -346,7 +357,7 @@ define bridge_flags u32 client_index; u32 context; u32 bd_id; - u8 is_set; + bool is_set; vl_api_bd_flags_t flags; }; @@ -375,7 +386,7 @@ autoreply define l2_interface_vlan_tag_rewrite { u32 client_index; u32 context; - u32 sw_if_index; + vl_api_interface_index_t sw_if_index; u32 vtr_op; u32 push_dot1q; // ethertype of first pushed tag is dot1q/dot1ad u32 tag1; // first pushed tag @@ -388,7 +399,7 @@ autoreply define l2_interface_vlan_tag_rewrite @param sw_if_index - interface the operation is applied to @param vtr_op - Choose from l2_vtr_op_t enum values @param inner_tag - needed for translate_qinq vtr op only - @param outer_tag - needed for translate_qinq vtr op only + @param outer_tag - needed for translate_qinq vtr op only @param b_dmac - B-tag remote mac address, needed for any push or translate_qinq vtr op @param b_smac - B-tag local mac address, needed for any push or translate qinq vtr op @param b_vlanid - B-tag vlanid, needed for any push or translate qinq vtr op @@ -398,11 +409,11 @@ autoreply define l2_interface_pbb_tag_rewrite { u32 client_index; u32 context; - u32 sw_if_index; + vl_api_interface_index_t sw_if_index; u32 vtr_op; u16 outer_tag; - u8 b_dmac[6]; - u8 b_smac[6]; + vl_api_mac_address_t b_dmac; + vl_api_mac_address_t b_smac; u16 b_vlanid; u32 i_sid; }; @@ -410,7 +421,7 @@ autoreply define l2_interface_pbb_tag_rewrite /** \brief L2 interface patch add / del request @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request - @param rx_sw_if_index - receive side interface + @param rx_sw_if_index - receive side interface @param tx_sw_if_index - transmit side interface @param is_add - if non-zero set up the interface patch, else remove it */ @@ -418,9 +429,9 @@ autoreply define l2_patch_add_del { u32 client_index; u32 context; - u32 rx_sw_if_index; - u32 tx_sw_if_index; - u8 is_add; + vl_api_interface_index_t rx_sw_if_index; + vl_api_interface_index_t tx_sw_if_index; + bool is_add [default=true]; }; /** \brief Set L2 XConnect between two interfaces request @@ -434,9 +445,9 @@ autoreply define sw_interface_set_l2_xconnect { u32 client_index; u32 context; - u32 rx_sw_if_index; - u32 tx_sw_if_index; - u8 enable; + vl_api_interface_index_t rx_sw_if_index; + vl_api_interface_index_t tx_sw_if_index; + bool enable [default=true]; }; /** @@ -468,11 +479,11 @@ autoreply define sw_interface_set_l2_bridge { u32 client_index; u32 context; - u32 rx_sw_if_index; + vl_api_interface_index_t rx_sw_if_index; u32 bd_id; vl_api_l2_port_type_t port_type; u8 shg; - u8 enable; + bool enable [default=true]; }; /** \brief Set bridge domain ip to mac entry request @@ -495,7 +506,7 @@ autoreply define bd_ip_mac_add_del { u32 client_index; u32 context; - u8 is_add; + bool is_add [default=true]; vl_api_bd_ip_mac_t entry; }; @@ -543,8 +554,8 @@ autoreply define l2_interface_efp_filter { u32 client_index; u32 context; - u32 sw_if_index; - u8 enable_disable; + vl_api_interface_index_t sw_if_index; + bool enable_disable [default=true]; }; /** \brief Interface set vpath request @@ -557,8 +568,8 @@ autoreply define sw_interface_set_vpath { u32 client_index; u32 context; - u32 sw_if_index; - u8 enable; + vl_api_interface_index_t sw_if_index; + bool enable [default=0xffffffff]; }; /** \brief Create BVI interface instance request @@ -572,7 +583,7 @@ define bvi_create u32 client_index; u32 context; vl_api_mac_address_t mac; - u32 user_instance; + u32 user_instance [default=0xffffffff]; }; /** \brief Create BVI interface instance response @@ -584,7 +595,7 @@ define bvi_create_reply { u32 context; i32 retval; - u32 sw_if_index; + vl_api_interface_index_t sw_if_index; }; /** \brief Delete BVI interface request @@ -596,7 +607,7 @@ autoreply define bvi_delete { u32 client_index; u32 context; - u32 sw_if_index; + vl_api_interface_index_t sw_if_index; }; /** \brief Register for IP4 ARP resolution event on receing ARP reply or diff --git a/src/vnet/l2/l2_api.c b/src/vnet/l2/l2_api.c index e73d420914f..ce08ab17050 100644 --- a/src/vnet/l2/l2_api.c +++ b/src/vnet/l2/l2_api.c @@ -149,7 +149,7 @@ send_l2fib_table_entry (vpe_api_main_t * am, mp->bd_id = ntohl (l2input_main.bd_configs[l2fe_key->fields.bd_index].bd_id); - clib_memcpy (mp->mac, l2fe_key->fields.mac, 6); + mac_address_encode ((mac_address_t *) l2fe_key->fields.mac, mp->mac); mp->sw_if_index = ntohl (l2fe_res->fields.sw_if_index); mp->static_mac = (l2fib_entry_result_is_set_STATIC (l2fe_res) ? 1 : 0); mp->filter_mac = (l2fib_entry_result_is_set_FILTER (l2fe_res) ? 1 : 0); @@ -215,13 +215,13 @@ vl_api_l2fib_add_del_t_handler (vl_api_l2fib_add_del_t * mp) } u32 bd_index = p[0]; - u8 mac[6]; + mac_address_t mac; - clib_memcpy (mac, mp->mac, 6); + mac_address_decode (mp->mac, &mac); if (mp->is_add) { if (mp->filter_mac) - l2fib_add_filter_entry (mac, bd_index); + l2fib_add_filter_entry (mac.bytes, bd_index); else { l2fib_entry_result_flags_t flags = L2FIB_ENTRY_RESULT_FLAG_NONE; @@ -246,13 +246,13 @@ vl_api_l2fib_add_del_t_handler (vl_api_l2fib_add_del_t * mp) flags |= L2FIB_ENTRY_RESULT_FLAG_STATIC; if (mp->bvi_mac) flags |= L2FIB_ENTRY_RESULT_FLAG_BVI; - l2fib_add_entry (mac, bd_index, sw_if_index, flags); + l2fib_add_entry (mac.bytes, bd_index, sw_if_index, flags); } } else { u32 sw_if_index = ntohl (mp->sw_if_index); - if (l2fib_del_entry (mac, bd_index, sw_if_index)) + if (l2fib_del_entry (mac.bytes, bd_index, sw_if_index)) rv = VNET_API_ERROR_NO_SUCH_ENTRY; } @@ -281,18 +281,27 @@ vl_api_want_l2_macs_events_t_handler (vl_api_want_l2_macs_events_t * mp) if (mp->max_macs_in_event) fm->max_macs_in_event = mp->max_macs_in_event * 10; else - fm->max_macs_in_event = L2FIB_EVENT_MAX_MACS_DEFAULT; + { + rv = VNET_API_ERROR_INVALID_VALUE; + goto exit; + } if (mp->scan_delay) fm->event_scan_delay = (f64) (mp->scan_delay) * 10e-3; else - fm->event_scan_delay = L2FIB_EVENT_SCAN_DELAY_DEFAULT; + { + rv = VNET_API_ERROR_INVALID_VALUE; + goto exit; + } /* change learn limit and flush all learned MACs */ if (learn_limit && (learn_limit < L2LEARN_DEFAULT_LIMIT)) lm->global_learn_limit = learn_limit; else - lm->global_learn_limit = L2FIB_EVENT_LEARN_LIMIT_DEFAULT; + { + rv = VNET_API_ERROR_INVALID_VALUE; + goto exit; + } l2fib_flush_all_mac (vlib_get_main ()); } @@ -506,12 +515,16 @@ vl_api_bridge_domain_dump_t_handler (vl_api_bridge_domain_dump_t * mp) bd_main_t *bdm = &bd_main; l2input_main_t *l2im = &l2input_main; vl_api_registration_t *reg; - u32 bd_id, bd_index, end; + u32 bd_id, bd_index, end, filter_sw_if_index; reg = vl_api_client_index_to_registration (mp->client_index); if (!reg) return; + filter_sw_if_index = ntohl (mp->sw_if_index); + if (filter_sw_if_index != ~0) + return; /* UNIMPLEMENTED */ + bd_id = ntohl (mp->bd_id); if (bd_id == 0) return; @@ -648,6 +661,7 @@ static void vlib_main_t *vm = vlib_get_main (); u32 vtr_op; int rv = 0; + mac_address_t b_dmac, b_smac; VALIDATE_SW_IF_INDEX (mp); @@ -666,8 +680,11 @@ static void goto bad_sw_if_index; } + mac_address_decode (mp->b_dmac, &b_dmac); + mac_address_decode (mp->b_smac, &b_smac); + rv = l2pbb_configure (vm, vnm, ntohl (mp->sw_if_index), vtr_op, - mp->b_dmac, mp->b_smac, ntohs (mp->b_vlanid), + b_dmac.bytes, b_smac.bytes, ntohs (mp->b_vlanid), ntohl (mp->i_sid), ntohs (mp->outer_tag)); BAD_SW_IF_INDEX_LABEL; diff --git a/src/vnet/l2/l2_fib.c b/src/vnet/l2/l2_fib.c index 57325afa496..160e4e64048 100644 --- a/src/vnet/l2/l2_fib.c +++ b/src/vnet/l2/l2_fib.c @@ -1084,7 +1084,10 @@ l2fib_scan (vlib_main_t * vm, f64 start_time, u8 event_only) key.fields.mac, 6); mp->mac[evt_idx].action = l2fib_entry_result_is_set_LRN_MOV (&result) ? - MAC_EVENT_ACTION_MOVE : MAC_EVENT_ACTION_ADD; + (vl_api_mac_event_action_t) MAC_EVENT_ACTION_MOVE + : (vl_api_mac_event_action_t) MAC_EVENT_ACTION_ADD; + mp->mac[evt_idx].action = + htonl (mp->mac[evt_idx].action); mp->mac[evt_idx].sw_if_index = htonl (result.fields.sw_if_index); /* clear event bits and update mac entry */ @@ -1127,7 +1130,9 @@ l2fib_scan (vlib_main_t * vm, f64 start_time, u8 event_only) /* copy mac entry to event msg */ clib_memcpy_fast (mp->mac[evt_idx].mac_addr, key.fields.mac, 6); - mp->mac[evt_idx].action = MAC_EVENT_ACTION_DELETE; + mp->mac[evt_idx].action = + (vl_api_mac_event_action_t) MAC_EVENT_ACTION_DELETE; + mp->mac[evt_idx].action = htonl (mp->mac[evt_idx].action); mp->mac[evt_idx].sw_if_index = htonl (result.fields.sw_if_index); evt_idx++; |