From 8d61c59c3f1e05e49b89a700a1640aa9bcebc6b8 Mon Sep 17 00:00:00 2001 From: Pim van Pelt Date: Sat, 10 Jun 2023 16:46:34 +0200 Subject: mpls: add mpls_interface_dump Add an API call mpls_interface_dump() which returns a list of mpls_interface_details: - If no sw_if_index is given, all MPLS enabled sw_if_index are returned. - If a particular sw_if_index is given, and it doesn't exist, an empty list is returned. - If a sw_if_index exists and has MPLS enabled, a list of that one sw_if_index is returned. Tested: - Create 3 loopback interfaces - Call for ~0 and for sw_if_index 0..5 all return empty lists - set int mpls loop0 enable - set int mpls loop1 enable - Call for ~0 returns 2, and the call for sw_if_index=1 and =2 (the loopbacks) returns each a list of one sw_if_index 1 resp 2, the other values of sw_if_index return empty list - set int mpls loop0 disable - Call for ~0 returns 1, and the call for sw_if_index=2 (loop1) returns both a list of one sw_if_index=2, the other values of sw_if_index return empty list - set int mpls loop1 disable - Call for ~0 and for sw_if_index 0..5 all return empty lists Example Python3 API program: ``` api_response = vpp.api.mpls_interface_dump() print(f"Response is {api_response}") for i in [ 0, 1, 2, 3, 4, 5 ]: api_response = vpp.api.mpls_interface_dump(sw_if_index=i) print(f"Response[{i}] = {api_response}") ``` Type: improvement Change-Id: If87f7d7f8972d99260e859757dbcb251c6fa54a8 Signed-off-by: Pim van Pelt --- src/vnet/mpls/mpls.api | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/vnet/mpls/mpls.api') diff --git a/src/vnet/mpls/mpls.api b/src/vnet/mpls/mpls.api index 4c164bb2bf2..5d775dafdfc 100644 --- a/src/vnet/mpls/mpls.api +++ b/src/vnet/mpls/mpls.api @@ -92,6 +92,26 @@ define mpls_tunnel_details vl_api_mpls_tunnel_t mt_tunnel; }; +/** \brief Dump mpls enabled interface(s) + @param client_index - opaque cookie to identify the sender + @param sw_if_index - sw_if_index of a specific interface, or -1 (default) + to return all MPLS enabled interfaces +*/ +define mpls_interface_dump +{ + u32 client_index; + u32 context; + vl_api_interface_index_t sw_if_index [default=0xffffffff]; +}; + +/** \brief mpls enabled interface details +*/ +define mpls_interface_details +{ + u32 context; + vl_api_interface_index_t sw_if_index; +}; + /** \brief MPLS Route Add / del route @param client_index - opaque cookie to identify the sender @param context - sender context, to match reply w/ request -- cgit 1.2.3-korg