summaryrefslogtreecommitdiffstats
path: root/src/vpp-api
AgeCommit message (Collapse)AuthorFilesLines
2021-02-09papi: expose vpp_papi version to clientPaul Vinciguerra1-0/+6
root@ae2a2e85c5d4:/vpp/src/vpp-api/python# python3 Python 3.6.9 (default, Oct 8 2020, 12:12:24) [GCC 8.4.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import vpp_papi >>> vpp_papi.__version__ '1.6.2' Type: feature Change-Id: I73025427a58214a842245fceaa77daa7acd3e6f8 Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2021-02-05papi: remove unused name from __all__Paul Vinciguerra1-1/+1
missed in https://gerrit.fd.io/r/c/vpp/+/30238 Type: fix Change-Id: I342868a77d7ca87896d97847ca6525ad1abcd1b6 Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2020-12-18papi: remove import vpp_transport_socketPaul Vinciguerra1-2/+2
See discussion in: https://gerrit.fd.io/r/c/vpp/+/19472 Type: refactor Change-Id: Icbf686f615f13898d12fd211f68c3498d373a5d7 Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2020-12-08tests: restore vapi C++ test under Centos-8Paul Vinciguerra1-2/+1
The Centos-7 compiler had problems with vapi_cpp_test.cpp. The Centos-8 compiler does not. This change adds back the test. ============================================================================== VAPI test ============================================================================== run C VAPI tests 1.55 OK run C++ VAPI tests 0.44 OK ============================================================================== TEST RESULTS: Scheduled tests: 2 Executed tests: 2 Passed tests: 2 ============================================================================== Type: test Change-Id: Ic6a655ae99eb3ba0e73b7feef4436a0ca5fd92be Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2020-12-08papi: remove old client referencePaul Vinciguerra2-4/+1
deprecated in 3/19 Type: refactor Change-Id: Ia8eebaa0cd89d1e95166a62645400946d8db2f75 Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2020-12-04papi: add support for enumflag part 1 of 2Paul Vinciguerra5-19/+160
Allow for papi to accept the new enumflag type. Change-Id: I8d8dc8fdb122e9a1b1881f5b2558635c75e4a299 Type: feature Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com> (cherry picked from commit 299abebe2942b4c78b85f9f3b8843f8213bf1efe)
2020-12-03papi: remove python2 patternsPaul Vinciguerra6-40/+18
Type: refactor Change-Id: I541759b4b788acf08599661eb9e7abc58e9283d2 Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2020-12-03papi: allow client control over loggersPaul Vinciguerra6-8/+56
This change enables a client to set debug levels globally as well as individually. exposes loggers as vpp_papi vpp_papi.serializer vpp_papi.transport Type: improvement Change-Id: Ib6bd1a1f552b51a22c9fe3de819a5fb970963ae5 Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2020-12-03stats: char-pointer arithmetic style-upVratko Polak1-6/+4
Char* typed shared_header value appears multiple times, so store it is a variable. Pointer "p" value is used more frequently casted to char*, so use that type for it, and convert to void* only at return. Type: style Fixes: 41f15ae1dfd4ac1777b684fdc763d12496209418 Change-Id: I7b3f1e6a43c020acd7ae561f87d12237b07fcd66 Signed-off-by: Vratko Polak <vrpolak@cisco.com>
2020-12-02papi: improve unit testabilityPaul Vinciguerra3-23/+133
refactor the code so that snippets of json can be used to test vpp_papi example unit test provided Type: improvement Change-Id: Ibec608fd2e5b12515aa4db17d85d4319134c22ea Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2020-12-02stats: void-pointer arithmetic fixElias Rudberg1-2/+3
Cast to (char *) to avoid pointer arithmetic for (void *) pointers. Type: fix Signed-off-by: Elias Rudberg <elias.rudberg@bahnhof.net> Change-Id: I62607b4cbc553449e2c60d514b4b17dbb4f88216
2020-12-02papi: fix copy/paste errorPaul Vinciguerra1-2/+2
Type: fix Change-Id: I8bd20fb38e132f6ab8cbc0e73095b649b5946498 Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2020-11-25api: vat2 and json autogeneration for api messagesOle Troan2-4/+4
VAT2: A completely auto-generated replacement of VAT. Reads input message in JSON from stdin and outputs received messages in JSON. A VAT2 plugin is automatically built for a .api file. There no longer a need for a separate _test.c. Example: vat2 show_version {} { "_msgname": "show_version_reply", "retval": 0, "program": "vpe", "version": "21.01-rc0~411-gf6eb348a6", "build_date": "2020-11-19T09:49:25", "build_directory": "/vpp/autogen3" } vat2 sw_interface_dump '{"sw_if_index": -1, "name_filter_valid": 0, "name_filter": ""}' [{ "_msgname": "sw_interface_details", "sw_if_index": 0, "sup_sw_if_index": 0, "l2_address": "00:00:00:00:00:00", "flags": "Invalid ENUM", "type": "IF_API_TYPE_HARDWARE", "link_duplex": "LINK_DUPLEX_API_UNKNOWN", "link_speed": 0, "link_mtu": 0, "mtu": [0, 0, 0, 0], "sub_id": 0, "sub_number_of_tags": 0, "sub_outer_vlan_id": 0, "sub_inner_vlan_id": 0, "sub_if_flags": "Invalid ENUM", "vtr_op": 0, "vtr_push_dot1q": 0, "vtr_tag1": 0, "vtr_tag2": 0, "outer_tag": 0, "b_dmac": "00:00:00:00:00:00", "b_smac": "00:00:00:00:00:00", "b_vlanid": 0, "i_sid": 0, "interface_name": "local0", "interface_dev_type": "local", "tag": "" }] This is the first phase and vat2 is not integrated in packaging yet. Type: feature Signed-off-by: Ole Troan <ot@cisco.com> Change-Id: Ib45ddeafb180ea7da8c5dc274a9274d7a4edc876 Signed-off-by: Ole Troan <ot@cisco.com>
2020-11-17papi: remove dependency on aenumPaul Vinciguerra2-18/+2
remove the dependency on the aenum package which was used to provide Enum.IntFlag which is now available in the python stdlib. aenum is not provided as a .deb and causes issues in packaging. Type: fix Change-Id: Ie45ec2130a767345f0aad038451780a5ddc7e8db Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2020-11-17tests: move vpp-api tests to src/vpe-api/testDave Wallace3-0/+174
- Refactor make test code to be co-located with the vpp feature source code Type: test Signed-off-by: Dave Wallace <dwallacelf@gmail.com> Change-Id: Ic42bbd4e13606a5fdc91143ecc6452102ec337fe
2020-10-21stats: missing dimension in stat_set_simple_counterOle Troan2-8/+24
A simple counter is a two dimensional array by threads and counter index. 28017 introduced an error missing the first dimension. If a vector is updated at the same time as a client reads, an invalid pointer my result. This will be caught by the optimistic locking after copying out the data, but if following a pointer outside of the stat segment then the stat client would crash. Add suitable boundary checks for access to stat memory segment. Fixes: 7d29e320fb2855a1ddb7a6af09078b8ed636de01 Type: fix Signed-off-by: Ole Troan <ot@cisco.com> Change-Id: I94f124ec71d98218c4eda5d124ac5594743d93d6
2020-10-07api: add heap alloc to vpp statsOle Troan3-1/+9
The Python VPP Stats module also used the VPP heap. Fix so it now explicitly allocates a heap. Fixes: f68fccfe7e188fec2c9f91da38ca9acf6f67d811 Type: fix Signed-off-by: Ole Troan <ot@cisco.com> Change-Id: I0bd4ae64d6c89cdf634d8d9a91c23ab38017c5cc Signed-off-by: Ole Troan <ot@cisco.com>
2020-09-28vppinfra: don't call dlmalloc API directly from the codeDamjan Marion1-1/+1
- it is confusing from end consumer perspective that some thing is somewhere called heap and somewhere mspace - this is base for additional work where heap pointer is not the same thing like mspace Type: improvement Change-Id: I644d5a0de17690d65d164d8cec3c5654571629ef Signed-off-by: Damjan Marion <damarion@cisco.com>
2020-09-28api: remove clib_mem_init from vppapiclient contructorOle Troan3-25/+23
Having the constructor in the vppapiclient library led to conflicts with applications wanting to allocate their own heap. Note: Change of behaviour, applications that do not use a CLIB heap must now call vac_mem_init() before using any functions from vppapiclient. Type: fix Signed-off-by: Ole Troan <ot@cisco.com> Change-Id: Ib155a54579ea5a0dbc26cb4b6daca1274e1dfdfa
2020-09-09stats: Fix stat_segment to set timeout directlyRajesh Goel1-0/+13
Type: fix Signed-off-by: Rajesh Goel <rajegoel@cisco.com> Change-Id: Ib37802f4270fe894a31e871c7fbb12b5a1cdf058
2020-08-17stats: Move misplaced comment blockVratko Polak1-3/+3
Type: fix Fixes: fdc678081ca5f0971b8bcbf312c1e83017365c33 Change-Id: I64d15b050cfd3d88923bf996cb68b13504dbf6af Signed-off-by: Vratko Polak <vrpolak@cisco.com>
2020-08-13stats: remove offsets on vpp sideOle Troan3-51/+37
Represent pointers directly in shared memory and require clients to adjust for shared memory segment being mapped at different base address. Deprecated: stat_segment_pointer() / stat_segment_offset() Added: stat_segment_adjust() Bumped the stat segment version to 2. Type: refactor Signed-off-by: Ole Troan <ot@cisco.com> Change-Id: I33e756187b8903b45dcd353e6c1a101b7a4acb79
2020-08-11papi: allow unknown address familyOle Troan2-10/+71
In unions all representations of the union are decoded. Which means trying to decode something that isn't an address might have invalid address family types. Type: fix Ticket: VPP-1884 Signed-off-by: Ole Troan <ot@cisco.com> Change-Id: Id3381ef8cc885952c1eb488ebc70e276eaceb366
2020-08-11stats: add timeout for in_progress access to stat segmentOle Troan2-8/+50
add new api stat_segment_set_timeout_nsec to limit time waiting for vpp in_progress state. Change-Id: Ic78a97bc5013d67d7e4bbcc4a6f0ef918f9f9b33 Type: improvement Signed-off-by: Ole Troan <ot@cisco.com>
2020-08-10stats: name and error index client memory leakOle Troan3-27/+77
Type: fix Change-Id: I6c9999b93d4f4ad4b8540a21e793c9a90e7c8ecf Signed-off-by: Ole Troan <ot@cisco.com>
2020-06-10vapi: memset allocated messages to zeroKlement Sekera1-0/+4
This avoids using dirty data from shared memory by client. Type: fix Signed-off-by: Klement Sekera <ksekera@cisco.com> Change-Id: I96eecf655bf344ec29609cedbd8dc891b572e207
2020-05-25api: add new stream message conventionOle Troan1-14/+36
Instead of having to wrap dump/detail calls in control ping, send details messages in between a normal reply / request pair. As expressed in the below service statement. Example: service { rpc map_domains_gets returns map_domains_get_reply stream map_domain_details; }; define map_domains_get { u32 client_index; u32 context; u32 cursor; }; define map_domains_get_reply { u32 context; i32 retval; u32 cursor; }; To avoid blocking the main thread for too long, the replies are now sent in client message queue size chunks. The reply message returns VNET_API_ERROR_EAGAIN when there is more to read. The API handler must also include a "cursor" that is used to the next call to the get function. API handler example: REPLY_AND_DETAILS_MACRO (VL_API_MAP_DOMAINS_GET_REPLY, mm->domains, ({ send_domain_details (cursor, rp, mp->context); })); The macro starts from cursor and iterates through the pool until vl_api_process_may_suspend() returns true or the iteration reaches the end of the list. Client Example: cursor = 0 d = [] while True: rv, details = map_domains_get(cursor=cursor) d += details if rv.retval == 0 or rv.retval != -165: break cursor = rv.cursor or the convenience iterator: for x in vpp.details_iter(vpp.api.map_domains_get): pass or list(details_iter(map_domains_get)) Change-Id: Iad9f6b41b0ef886adb584c97708dd91cf552749e Type: feature Signed-off-by: Ole Troan <ot@cisco.com>
2020-05-15misc: fix ubuntu 20.04 python depsDamjan Marion1-1/+5
Type: fix Change-Id: I9cdfbffd6333d090f970422bf047aaa90c1e4c65 Signed-off-by: Damjan Marion <damarion@cisco.com>
2020-05-08build: various improvementsDamjan Marion1-1/+1
- add option to install only host tools - add option to specify lib and runtime dir Type: improvement Change-Id: I6356b52df459120fc9b0127948bae7679fb10e52 Signed-off-by: Damjan Marion <damarion@cisco.com>
2020-05-08papi: use python3 for papi installOle Troan1-1/+1
Breaks on Ubuntu 20.04 otherwise. Type: fix Signed-off-by: Ole Troan <ot@cisco.com> Change-Id: I407215a03948d6e49152ee97099539bb625c12ef
2020-05-04vapi: add support for defaults in typedefsPaul Vinciguerra2-3/+7
refactored out of Neale's change: https://gerrit.fd.io/r/c/vpp/+/26276 Type: refactor Change-Id: Ibb0c019856dc44640e94d6d80a5d119a6296d95c Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com> (cherry picked from commit a751d8d61fe5880f6d447e63b81e2df30561e9f9)
2020-05-01api: fix include_guard when path contains a plusRuslan Babayev1-1/+1
The path to VPP source might contain a '+' when building it with Yocto/OpenEmbedded. Type: fix Signed-off-by: Ruslan Babayev <ruslan@babayev.com> Change-Id: I205ac0de7d8726724af0e30f5b199391e05dc615
2020-04-28tests: implement ipaddress convenience methodsPaul Vinciguerra2-1/+34
Add vpp specific properties to ip addresses for use in the api. .vapi_af -- returns [ADDRESS_IP4, ADDRESS_IP6] .vapi_af_name -- returns the string ['ip4', 'ip6'] Update tests to demonstrate usage. Type: feature Change-Id: I43447a1522769d99f89debdc714c51700068d771 Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2020-04-24vapi: packed enum type generationNeale Ranns1-1/+14
Type: fix if the ,api/.json specifies that a enum should be u8/u16 that the generated c enum needs to be packed. Signed-off-by: Neale Ranns <nranns@cisco.com> Change-Id: Ia0497b45e4c510a5c63cd02e966769bf20686838
2020-02-11vppinfra: remove the historical mheap memory allocatorDave Barach1-11/+0
The mheap allocator has been turned off for several releases. This commit removes the cmake config parameter, parallel support for dlmalloc and mheap, and the mheap allocator itself. Type: refactor Signed-off-by: Dave Barach <dave@barachs.net> Change-Id: I104f88a1f06e47e90e5f7fb3e11cd1ca66467903
2020-02-05stats: fix state counter removalVladimir Isaev1-0/+3
Avoid using vec_del1() for directory vector to keep indexes valid all the time. There are state counters for each slave in LACP bond mode which can be dynamically created and removed. Vector index is used to access these counters. But also vec_del1() is used to remove counter from vector. This function changes the index of the last element, so after this we are unable to access ex-last element using old index. As a result it is not possible to add-del-add two interfaces to the LACP bond: DBGvpp# create bond mode lacp BondEthernet0 DBGvpp# create packet-generator interface pg1 DBGvpp# create packet-generator interface pg2 DBGvpp# bond add BondEthernet0 pg1 DBGvpp# bond add BondEthernet0 pg2 DBGvpp# bond del pg1 DBGvpp# bond del pg2 DBGvpp# bond add BondEthernet0 pg1 DBGvpp# bond add BondEthernet0 pg2 bond add: /if/lacp/1/3/partner-state is already register Type: fix Signed-off-by: Vladimir Isaev <visaev@netgate.com> Change-Id: I2c86e13905eefdef6233369cd4ab5c1b53d123bd
2019-12-19papi: lazily initialize stats clientPaul Vinciguerra1-5/+25
remove wait-loop on stats socket from test framework. Type: refactor Change-Id: I5bb95a7c597707a87f9d9a471215c4b4af1a2280 Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2019-12-17build: export vapi generation in vpp-devOliver Giles1-48/+11
Adds the higher-level vapi generation to cmake/api.cmake and exposes the necessary python scripts in vpp-dev, so that out-of-tree/downstream plugins can also leverage the more convenient API. Type: feature Signed-off-by: Oliver Giles <oliver_g@radwin.com> Change-Id: I8c40a14d27ba3cb972c6907632e03c0e7b0ce982
2019-12-10api: multiple connections per processDave Barach3-15/+15
Type: feature Signed-off-by: Dave Barach <dave@barachs.net> Change-Id: I2272521d6e69edcd385ef684af6dd4eea5eaa953
2019-12-05papi: add call statsOle Troan1-1/+23
Type: feature Change-Id: Ic6d44122d3e62e09402e3f1946f7e57e9b5e7c5f Signed-off-by: Ole Troan <ot@cisco.com>
2019-12-03papi: add a per-call _timeout optionPaul Vinciguerra3-8/+14
add the ability to override the default timeout value on a per-call basis. Use: rv = self.vapi.papi.cli_inband(cmd='wait 10', _timeout=15) Type: feature Change-Id: Ia90a58586a1f63e02118599a2a4b7141e5a0b90d Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2019-11-27misc: add address sanitizer heap instrumentationBenoît Ganne2-0/+7
Introduce AddressSanitizer support: https://github.com/google/sanitizers/ This starts with heap instrumentation. vlib_buffer, bihash and stack instrumentation should follow. Type: feature Change-Id: I7f20e235b2f79db72efd0e756f22c75f717a9884 Signed-off-by: Benoît Ganne <bganne@cisco.com>
2019-11-27papi: fix typo in reprPaul Vinciguerra1-1/+1
Reported by Vratko's review. (Thanks for the review) Fixes: 14b0b4791c0b8c886e7b5c9ca667d060f0bada0b Type: fix Change-Id: I9c080c0c40060cc77977e76edae03d60eb393ce2 Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2019-11-24papi: fix papi default handlingOle Troan1-17/+18
Type: fix Change-Id: I91063e2096fb09c34898a611184c8381fccdb333 Signed-off-by: Ole Troan <ot@cisco.com>
2019-11-24papi: add missing base types to serializerPaul Vinciguerra1-2/+4
File "/vpp/src/vpp-api/python/vpp_papi/vpp_serializer.py", line 512, in __init__ 'Unknown message type {}'.format(f_type)) vpp_papi.vpp_serializer.VPPSerializerValueError: Unknown message type i16 Type: fix Change-Id: Ibf73dc8df90153db586afe614e47be49739bac2f Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2019-11-23papi: add repr to packer types for troubleshootingPaul Vinciguerra1-0/+47
Type: feature Change-Id: Id3cd89eca0deddb70f506239f9d0543fc28cf7f4 Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2019-11-22papi: support default for type alias decaying to basetypeOle Troan1-18/+63
Add PAPI support for VppTypeAlias decaying to BaseType. E.g vl_api_interface_index_t sw_if_index [default=0xffffffff] Type: feature Signed-off-by: Ole Troan <ot@cisco.com> Change-Id: I2061392157c9c11fbb0ff9e5406ea65489b017e9
2019-11-13papi: enhance MACAddress() equalityPaul Vinciguerra1-1/+7
Allows for comparison without needing str(MACAddress()) Traceback (most recent call last): File "/vpp/test/test_ip6.py", line 1074, in test_icmpv6_echo self.assertEqual(ether.dst, self.pg0.remote_mac) AssertionError: '02:01:00:00:ff:02' != MACAddress(02:01:00:00:ff:02) Type: feature Change-Id: Ife1cbfc74d477695d15b33a19da7dd2fa241a348 Signed-off-by: Paul Vinciguerra <pvinci@vinciconsulting.com>
2019-11-12papi: add wrapper to validate crc manifestOle Troan1-0/+28
If a client application is built against 19.08, it can dump the "manifest" of API signatures. Either the all APIs (--dump) or the APIs it is interested in (--dumpfiltered). When the developers of said client application wants to verify that it works with VPP 20.01. It can connect to VPP and --validate the old mainfest file, and will be told a list of messages (both request and reply) that has changed. import argparse from vpp_papi import VPP import sys import argparse parser = argparse.ArgumentParser() group = parser.add_mutually_exclusive_group() group.add_argument("--dump", action="store_true") group.add_argument("--dumpfiltered", action="store_true") group.add_argument("--validate", action="store_true") args = parser.parse_args() vpp = VPP(use_socket=True) vpp.connect(name='apimanifest') if args.validate: # Verify manifest message_table = eval(sys.stdin.read()) missing = vpp.validate_message_table(message_table) print ('Changed message signatures: {}'.format(missing)) elif args.dump: # Output manifest to stdout print('{}'.format(vpp.dump_message_table())) elif args.dumpfiltered: # Output manifest to stdout filterlist = eval(sys.stdin.read()) print('{}'.format(vpp.dump_message_table_filtered(filterlist))) vpp.disconnect() Type: feature Change-Id: I7e708b36f599ed88e4864970c8593cc2fe5fbf61 Signed-off-by: Ole Troan <ot@cisco.com>
2019-11-05misc: Fix python scripts shebang lineRenato Botelho do Couto4-4/+4
Type: fix Since CentOS 8, RPM build script doesn't accept '#!/usr/bin/env python' as a valid shebang line. It requires scripts to explicitly chose between python2 or python3. Change all to use python3 as suggested by Paul Vinciguerra. Depends-On: https://gerrit.fd.io/r/23170 Signed-off-by: Renato Botelho do Couto <renato@netgate.com> Change-Id: Ie72af9f60fd0609e07f05b70f8d96e738b2754d1