aboutsummaryrefslogtreecommitdiffstats
path: root/adapter
AgeCommit message (Collapse)AuthorFilesLines
2022-08-02Change module name to go.fd.io/govppHEADv0.6.0-alphamasterNathan Skrzypczak11-16/+16
We are changing the module name from git.fd.io/govpp.git to go.fd.io/govpp to make repository migration easier. Signed-off-by: Nathan Skrzypczak <nathan.skrzypczak@gmail.com> Change-Id: Idd6e0d583a92f6b82fe9adeffd026cd6b856038b
2022-07-29Fix stats API for vpp 22.06Lukas Vogel4-8/+9
VPP changed the error counters to be simple counters in https://gerrit.fd.io/r/c/vpp/+/35640, that broke goVPP stats extraction. This was partially fixed by https://gerrit.fd.io/r/c/govpp/+/36085, however this fix didn't make it work completely. There were some leftover conversions from dirType (== int) to StatType (== string). Unfortunately the Go compiler does not flag those, they would however be catched by go vet. The fixes that are done here makes the stats extraction work for us partially: We noticed that error counters are now of type symlink and unfortunately updating a stat dir that contains symlink counters doesn't work correctly. CopyEntryData, that is called when initializing the dir, correctly handles the symlink counters. But updateStatOnIndex simply ignores symlink counters because `dirType != entry.Type` will hold. We didn't really figure out how to correctly handle this so this would need to be picked up by someone who is more familiar with the code. For now we work around this limitation by not using the GetErrorStats API and instead manually read the dir everytime we want to access error counters. Co-authored-by: Sergio Gonzalez Monroy <monroy@anapaya.net> Change-Id: I322133f362e782fea3e8a2be70967a796ba87b75 Signed-off-by: Lukas Vogel <vogel@anapaya.net>
2022-07-25Fix statseg v1 error offset zeroNathan Skrzypczak1-4/+1
This is the same fix as [0] for the statsseg v1 implementation [0] https://gerrit.fd.io/r/c/govpp/+/36442 Signed-off-by: Nathan Skrzypczak <nathan.skrzypczak@gmail.com> Change-Id: Ie22956152a83abe6371fe89482a66f2253b8493c
2022-07-25Fix statseg v2 error index zero id skipDmitry Valter1-1/+1
Don't skip zero id error counters as it's not a pointer. Type: fix Signed-off-by: Dmitry Valter <d-valter@yandex-team.ru> Change-Id: I907bb9f110d8bf5db6326ae654206ddc83187044
2022-05-05support error counters also as normal countersVladimir Lavor4-63/+59
https://gerrit.fd.io/r/c/vpp/+/35640 Signed-off-by: Vladimir Lavor <vlavor@cisco.com> Change-Id: I91820bb15655e7b309af814c659eb9f5e7cd08a4
2022-03-17Properly close the socket watcherVladimir Lavor1-0/+1
Signed-off-by: Vladimir Lavor <vlavor@cisco.com> Change-Id: I40665a0413f273e52bcaeaabacdf1bd55afcfd67
2021-06-01statsclient: fix retrieving stats typeVladimir Lavor2-4/+10
Signed-off-by: Vladimir Lavor <vlavor@cisco.com> Change-Id: Id51fa03ac69a2fc29aca5ff644178cdfcabe523c
2021-05-26statsclient: added symlinksVladimir Lavor6-25/+127
Symlink support based on https://gerrit.fd.io/r/c/vpp/+/31636 Added new stat types `CounterStat` and `CombinedCounterStat` which represent simple/combined value of a single item (interface, node) as a array of values by workers. Example: /if/names NameVector [local0 tap0 tap1] /if/ip6 SimpleCounterVector [[0 9 0] [0 25 3] [0 0 60] [0 0 0]] /interfaces/tap0/ip6 SimpleCounterVector [[9] [25] [0] [0]] /interfaces/tap1/ip6 SimpleCounterVector [[0] [3] [60] [0]] Field `Symlink` added to StatEntry to mark symlink stats. For stats v2 only Change-Id: Iadc825f3c42b05bfc9a91462dba8a0b0068c7cd6 Signed-off-by: Vladimir Lavor <vlavor@cisco.com>
2021-05-05statsclient: allow index as patternVladimir Lavor8-184/+246
* ListStats() returns stats identifiers containing the stat name and index * New method PrepareDirOnIndex(indexes...). Instead of the name filter it does not browse through all available indexes * Stats example shows how to get the last epoch value (added "e" or "epoch" command) Change-Id: Ibb15090fb0dfdb7f9b0ecf8ac07a5eb9a9ace8f8 Signed-off-by: Vladimir Lavor <vlavor@cisco.com>
2021-04-20Recognize stat_dir_type_emptyVladimir Lavor2-0/+11
Do not to handle empty stats directory as unknown. Empty dir's value is always treated as zero. Change-Id: I40a3829675c5b7c9da80ceaa7e2d0a87fe02dc7c Signed-off-by: Vladimir Lavor <vlavor@cisco.com>
2021-04-07Add statsclient options and fix wait for socketVladimir Lavor1-10/+44
Change-Id: Ib5674fee5862a2b16f4b0044b6f6af533a7b6b33 Signed-off-by: Vladimir Lavor <vlavor@cisco.com>
2021-03-19Fix panic during disconnectionAlexander Demidenko1-8/+11
Sometimes there are situations when the callback is called during the processing of the disconnect. To avoid problems with races (for example, when using race-detector), use atomic pointers. Signed-off-by: Alexander Demidenko <hurd@yandex-team.ru> Change-Id: Ic825872ac620d68a191bc88889a096b15ea57464
2021-03-03Provide error counters per worker for statsclientVladimir Lavor4-12/+20
Instead of a single value, the ErrorCounter now contains an array representing couter values per workers. Change-Id: I2b869e5b228bcb3e155b1fef08a4cd00e7d2e16a Signed-off-by: Vladimir Lavor <vlavor@cisco.com>
2021-02-23Added asynchronous connection for stats socketVladimir Lavor2-30/+74
The stats socket now allows an option to connect asynchronously in the same manner as the api socket connection. New method AsyncConnectStats returns a channel where notificaitons of type ConnectionEvent will be sent. Fixed the stats reconnect procedure which sometimes failed to re-eneable the connection. Change-Id: I0bdb19f0d57e3a1ea259b8b1ba0a5e5fa49a09db Signed-off-by: Vladimir Lavor <vlavor@cisco.com>
2020-12-21Remove socket warnings from client adaptersOndrej Fabry2-120/+58
Change-Id: I5e72df39c0e4ba4f0a70d561d7f9b220b4e72a4c Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
2020-12-03Fixed incorrect message error in the stream APIVladimir Lavor1-11/+17
The message package is passed to the stream object and used to evaluate correct reply message type Change-Id: I2c9844d6447d024af1693205efd5721e2f89f22d Signed-off-by: Vladimir Lavor <vlavor@cisco.com>
2020-09-22Reload stats socket when VPP restartsVladimir Lavor1-25/+100
The current implementation loads the stats socket and maps it to the memory. If VPP restarts, the socket file is recreated while the mapped data remain unchanged, silently failing since it does not get any updates. This change adds socket file monitoring which reconnects and remaps the socket file in such a case. Change-Id: I061f7400410f4dfe5de66ba7844c4ae1567bbcbe Signed-off-by: Vladimir Lavor <vlavor@cisco.com>
2020-09-07Remove unnecessary allocationVladimir Lavor4-52/+51
Change-Id: If77b7b37ae736fdf21f4c337350905480e6fb011 Signed-off-by: Vladimir Lavor <vlavor@cisco.com>
2020-09-04Update VPP config warnings and change log level in proxyOndrej Fabry2-2/+2
Change-Id: I8f965a0758c4b7459f27a46c095dad232e331032 Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
2020-09-04Stats APIv2Vladimir Lavor6-700/+1042
* Compatible with stats v2 API * Compatibility with stats v1 was persisted * 19.04 (legacy) dropped Change-Id: I91a3ab0c007fed6d972eee01d7caf69af29305d1 Signed-off-by: Vladimir Lavor <vlavor@cisco.com>
2020-09-02fixed data race in mock vpp adapterSergey Elantsev1-1/+4
There was a race in reading VppAdapter.mode in SendMsg and writing in MockReply/MockReplyHandler/MockReplyWithContext. All these *Reply* methods hold VppAdapter.repliesLock, so this fix uses this lock to safely read the value of a mode field. Signed-off-by: Sergey Elantsev <elantsev.s@yandex.ru> Change-Id: I6c8873b766df6ea866196a9b96a48ebd08689772
2020-08-04Add SetLogger for setting global loggerOndrej Fabry1-4/+9
- list prerequisites in README - avoid calling go list by hard-coding module path Change-Id: Ib8af1934f55b7e112a8124a20f1f4d39ce651133 Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
2020-07-17Improve binapi generatorOndrej Fabry4-1492/+57
- simplified Size/Marshal/Unmarshal methods - replace struc in unions with custom marshal/unmarshal - fix imports in generated files - fix mock adapter - generate rpc service using low-level stream API (dumps generate control ping or stream msg..) - move examples/binapi to binapi and generate all API for latest release - add binapigen.Plugin for developing custom generator plugins - optionally generate HTTP handlers (REST API) for RPC services - add govpp program for browsing VPP API Change-Id: I092e9ed2b0c17972b3476463c3d4b14dd76ed42b Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
2020-07-14socket adapter: don't bother sending sockclnt_delete messagesDave Barach1-45/+2
vpp cleans up socket clients when the socket closes. I verified that sending a correctly-marshalled sockclnt_delete message results in duplicate close complaints. The marshalling code wasn't right - the (important) client_index field is in a non-standard position - and there's no point in sending a message we don't need to send. Signed-off-by: Dave Barach <dave@barachs.net> Change-Id: Ia32980b08a99cc878835f5db21f64de391759fa4
2020-07-10Fix: generate (un)marshall for memory client messagesVladimir Lavor4-124/+1466
* use generated Marshall/Unmarshall for socket client connection messages instead of the generic wrapper Change-Id: Ie1049e080630dbc60085debc6875e17962e93a0e Signed-off-by: Vladimir Lavor <vlavor@cisco.com>
2020-06-25Introduce Stream - experimental API for low-level access to VPP APIOndrej Fabry1-0/+3
Change-Id: I2698e11b76ff55d9730b47d4fee990be93349516 Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
2020-06-24Fix codec fallback and generate type importsOndrej Fabry1-2/+2
Change-Id: Idd76c7f19d952939caf153928ac60175845078ff Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
2020-06-16Optimize socketclient adapter and add various code improvementsOndrej Fabry2-189/+261
This commit includes: Features - optimized [socketclient](adapter/socketclient) adapter and add method to set client name - added list of compatible messages to `CompatibilityError` Fixes - `MsgCodec` will recover panic occurring during a message decoding - calling `Unsubscibe` will close the notification channel Other - improved log messages to provide more relevant info Examples - added more code samples of working with unions in [union example](examples/union-example) - added profiling mode to [perf bench](examples/perf-bench) example - improved [simple client](examples/simple-client) example to work properly even with multiple runs Dependencies - updated `github.com/sirupsen/logrus` dep to `v1.6.0` - updated `github.com/lunixbochs/struc` dep to `v0.0.0-20200521075829-a4cb8d33dbbe` Change-Id: I136a3968ccf9e93760d7ee2b9902fc7e6390a09d Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
2020-05-18Fix stats data errors and panic for VPP 20.05Ondrej Fabry1-20/+37
- fixes panic occurring when updating error counters - fixes stat data length errors when updating stats Change-Id: If2d4bcb7df084bf1999ba469f128b7a01aa6be5e Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
2020-03-20Fix statsclient for VPP 20.05-rc0 (master)v0.3.2Ondrej Fabry4-74/+95
- this change fixes panic that was occurring with recent VPP that was caused by incorrectly calculated vector length - converting returned vector length from uint64 to uint32 results in correct length value Change-Id: I76a4b9d147c3df3bea9d3e5ef5853e2809dc42e8 Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
2019-11-15Improve compatibility checkingOndrej Fabry3-2/+14
- added CompatibilityError to api package to represent error with list of incompatible messages - added UnknownMsgError to adapter package to represent error for unknown message - added list of registered message types Change-Id: I2623b45135521d52612ba91e4605fc064a7fc76e Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
2019-10-03Optimizations for statsclientOndrej Fabry8-318/+700
- this dramatically improves performance for stats data collection - memory allocation is now done only when stat dirs change - updating prepared stat dir does not need to allocate memory - created integration test for testing stats client - added NumWorkerThreads and VectorRatePerWorker to SystemStats - added ReduceSimpleCounterStatIndex, ReduceCombinedCounterStatIndex for aggregating specific index Change-Id: I702731a69024ab5dd0832bb5cfe2773a987359e5 Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
2019-09-09add MockClearReplyHandlers() api for mock vpp adapterRavi Raju1-0/+10
Change-Id: I12285c77c9cf09a24c957a777b26ae54f082f317 Signed-off-by: Ravi Raju <ravir@employees.org>
2019-09-09Fix compatibility with latest master (20.01-rc0)Ondrej Fabry2-8/+126
- fixed generator for new string types - update simple client example - regenerate examples binapi for VPP 19.08 Change-Id: If4fe78c130d95641f35f75cd0262b35b032acaf8 Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
2019-09-09Use new default binapi socket with fallback to legacyOndrej Fabry2-21/+59
Change-Id: I1a6839e3bbb8d599fcbdbc2b1aff7c81f7d263c9 Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
2019-08-08Add tag beyond18.10 to prevent build stat_clientRinat Baygildin1-1/+1
There is a problem to use upstream govpp with vpp 18.04 because of lack stat_client.h file. Build tag allows to exclude stat client from old vpp versions. Signed-off-by: Rinat Baygildin <bayrinat@yandex-team.ru> Change-Id: Ic39029b0c4577f88ff8796dfd14e6a2696f85f4c
2019-08-02Migrate to modules, refactor Makefile and use Travis for CIOndrej Fabry4-4/+4
- migrate to Go modules and remove vendor - refactor Makefile - add version package and store version - split extras from the rest - use travis for CI Change-Id: I81b35220653b0f7c9a0fcdd4c527d691ec1e96c1 Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
2019-07-19Print info for users to stderr when socket files are missingOndrej Fabry3-18/+47
Change-Id: Ibdbfcb78b05cf80945a93ed424a7a2a03b6ea06d Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
2019-07-10Fix socketclient for VPP 19.08Ondrej Fabry2-79/+91
- in VPP 19.08 the socket type has changed to STREAM and data has to be writtento VPP with single flush, otherwise msg might get mixed with next header and cause VPP to stop responding - this also fixes WaitReady for socketclient and vppapiclient Change-Id: I022724c0c09c9b92d4c695d1cf2be15994fff717 Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
2019-07-03Fix error counters for VPP 19.04Ondrej Fabry5-138/+160
Change-Id: I87251362668bbe9a31f52c1b5e9b3ab596f7b2f3 Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
2019-07-01Fix reading statsclient entriesOndrej Fabry2-28/+36
- omit entries with empty/invalid names - change log level to debug for invalid entries - remove some excessive debug logs - improve log message when falling back to old stat segment version Change-Id: If9ceae9a42e586172bbec130452fba9dfbab2cd7 Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
2019-06-27Improvements for binapi-generator and support VPP 19.04 in statsclientOndrej Fabry4-188/+324
- RPC service client implementation for dumps requests now streams responses - RPC service generation is now enabled by default - examples now allow setting binapi socket address - input dir flag for binapi-generator will recursively look into dirs to support core/plugins in /usr/share/vpp/api - minor improvements in debug logs - add support for VPP 19.04 for statsclient Change-Id: I0939ee3aa6e9f850d073fc5c87aff4ccc56b0d70 Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
2019-06-20Add statsclient - pure Go implementation for stats APIOndrej Fabry4-16/+490
Change-Id: Ia5bab652c6089378697459f477f9060dc7a53e90 Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
2019-06-06Add various generator improvementsOndrej Fabry2-1/+34
- generate service implementation for modules - generate conversion maps and String() method for enums - generate module name and version as constants - rename Union_data field to XXX_UnionData for consistency - generate constant GoVppAPIPackageIsVersionN for checking compatibility with API - add example for using service clients - add some documentation to socketclient adapter - cleanup gen.go file used for generating binapi - regenerate binapi with latest VPP release (19.04.1) - change global variables Messages into a function AllMessages Change-Id: Id1ef97764570759eaa3e5a4dc14ecda7a168ee39 Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
2019-06-04Fix union data size for types with enumsOndrej Fabry1-1/+1
- this also fixed proper alphabetical order for struct tags - env var DEBUG_BINAPI_GENERATOR=y can be used to enable debug mode Change-Id: I5b08a696ad2ff2a297872f231f9229cd956ee443 Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
2019-05-31Support for error vectorsOndrej Fabry3-5/+24
- this fixes compilation error for VPP 19.08 and keeps backwards compatibility with previous versions Change-Id: Ib58557a090caa5e8342c0cb21de8af684cb18137 Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
2019-05-21Change default adapter to socketclient and cleanup some logsOndrej Fabry1-12/+10
Change-Id: I16ae8dbb5214e022304f4e8ae60798b370567fc8 Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
2019-05-15Try using different type of unix socket connectionOndrej Fabry1-3/+8
Change-Id: I6abde10043c4ff4d42d15a39cca10f82327d83dc Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
2019-05-06Fix compilation for VPP 19.01Ondrej Fabry4-189/+252
This commit introduces header files for wrapping vppapiclient library. The stat_client_wrapper.h now uses macro to determine version of stats API. Change-Id: Ife218e0e90742e9a22fd12ca77307fbd0cc7d714 Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
2019-04-23Add comments to provide info about VPP requirementsOndrej Fabry1-3/+3
Change-Id: I116b9c0ab064418940eec82fb1442d30816386d7 Signed-off-by: Ondrej Fabry <ofabry@cisco.com>