aboutsummaryrefslogtreecommitdiffstats
path: root/core/connection.go
AgeCommit message (Collapse)AuthorFilesLines
2022-08-02Change module name to go.fd.io/govppHEADv0.6.0-alphamasterNathan Skrzypczak1-3/+3
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-05-05fixed data race in core.Connection.Close().Sergey Elantsev1-5/+9
The problem is triggered by the following events: 1. VPP stops. 2. core.Connection.healthCheckLoop() detects it and calls disconnectVPP(), which does close healthCheckDone channel for the first time. At this point Connection becomes unusable - re-entrance to connectLoop() will return immediately because of a closed healthCheckDone channel. But, the race is that connection may set c.vppConnected = 1 before terminating the connect loop. 3. User calls Connection.Close(), who seed c.vppConnected = 1, and tries to close already closed channel, which leads to a panic. This commit fixes this race by telling disconnectVPP() whether it is a terminal stop triggered via Close(), or a temporary one from connectLoop(). Change-Id: I555149da35ca3dc2b606bad59f2101266c0ef6b9 Signed-off-by: Sergey Elantsev <elantsev.s@yandex.ru>
2022-01-31connection: prevent channel ID overlapLukas Vogel1-4/+7
When creating a new channel and the channel ID wraps around, make sure to not re-use a channel ID that is still in use. Re-using the channel ID usually means that the connection health check will stop working and other things might break as well. Also rename maxChannelID to nextChannelID and use a lock to guard access instead of using an atomic. The lock does anyway need to be acquired because to put the entry in the map. This commit was inspired by the following PR on Github: https://github.com/FDio/govpp/pull/14. Change-Id: I8c1a4ca63a53d07a6482b6047a3005065168c0b4 Signed-off-by: Lukas Vogel <vogel@anapaya.net>
2021-10-19Fix memory leak in health checkVladimir Lavor1-51/+56
1. On connection disconnect, health check loop ends immediately and independently on probe interval setup 2. Proper resource cleanup On disconnect, health check terminates itself with a delay based on the probe interval. It causes memory usage going up if AsyncConnect() & Disconnect() are called in a loop. Signed-off-by: Vladimir Lavor <vlavor@cisco.com> Change-Id: Ibcdfec9d2d7736f9390e21039d9a917228114273
2021-09-07Refactoring and fixesmhalaj11-8/+1
* refactor creation of new channel * add missing closing of created streams * correct documentation regarding thread safety of stream Signed-off-by: mhalaj1 <matus.halaj@pantheon.tech> Change-Id: Ic601efff298fcbdecaafab83fa236253af69de21
2021-07-22feat: api-traceVladimir Lavor1-0/+27
Signed-off-by: Vladimir Lavor <vlavor@cisco.com> Change-Id: I7de363dfb3930db13a30e97f154c57d75c07f01c
2020-12-03Fixed incorrect message error in the stream APIVladimir Lavor1-39/+45
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-04Increase default health check parametersOndrej Fabry1-2/+2
Change-Id: I0b5fbbd98fc1bb6fc9d86ed81cb1b3f9755fed67 Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
2020-07-17Added VPP state 'NotResponding'Vladimir Lavor1-14/+30
This change allows informing client about the current VPP state in more detail. * In case the VPP is overloaded but keeps its configuration, client received 'NotResponding' event message * If the VPP process dies (the socket is closed), the client receives 'Disconnected' event message Additional fix: event messages are discarded if the buffer is full. This could cause GoVPP to hang after some time in case the client was not receiveing events. Change-Id: I94a4647f6643f1d97bf52e5d7996d70229b0577d Signed-off-by: Vladimir Lavor <vlavor@cisco.com>
2020-06-24Fix codec fallback and generate type importsOndrej Fabry1-1/+1
Change-Id: Idd76c7f19d952939caf153928ac60175845078ff Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
2020-06-16Optimize socketclient adapter and add various code improvementsOndrej Fabry1-4/+14
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>
2019-10-30fix data races in proxy serverMatus Mrekaj1-13/+18
Signed-off-by: Matus Mrekaj <matus.mrekaj@pantheon.tech> Change-Id: I932d560548ee816e28683243a7318a2a7fbbb24a
2019-10-03Optimizations for statsclientOndrej Fabry1-3/+3
- 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-09Use new default binapi socket with fallback to legacyOndrej Fabry1-1/+1
Change-Id: I1a6839e3bbb8d599fcbdbc2b1aff7c81f7d263c9 Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
2019-07-10Fix socketclient for VPP 19.08Ondrej Fabry1-4/+4
- 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-06-27Improvements for binapi-generator and support VPP 19.04 in statsclientOndrej Fabry1-3/+7
- 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-04-04socketclient: wait for socket to be createdVladimir Lavor1-11/+26
domain sockets are checked/watched for existence in same manner as shm prefixes also the connection attempts and timeout in between can be configured for async-connect Change-Id: I084a3efaefea10d106866968deab90d3fda77cfe Signed-off-by: Vladimir Lavor <vlavor@cisco.com>
2019-02-19Introduce higer-level API for retrieving statisticsOndrej Fabry1-5/+20
- see stats-api example Change-Id: I11d29d32b60d25238e75cb6b86ee34842348ab38 Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
2019-02-08Add support for using multiple generated versionsOndrej Fabry1-81/+85
- added CheckCompatibility for checking if given messages are compatible - generating Messages global for easier usage of compatibility check - added ReconnectInterval and MaxReconnectAttempts for reconnecting - added Failed state that is sent after exceeding max reconnect attempts Change-Id: I1062ba453f22657c1a2a31aa64cb103ef1223b0f Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
2019-01-31Generator improvementsOndrej Fabry1-1/+1
- all objects are now sorted alphabetically for more consistent output - unions now have constructor generated - log level for warnings was changed to debug - GetAllMessages renamed to GetRegisteredMessages Change-Id: I976453004a2fd8b6cb95ca0acfcef56913bf8d38 Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
2018-10-23Remove the global variable for connectionOndrej Fabry1-49/+20
- this also fixes issue where after connect failure all following connects failed 'with only one connection per process is supported' - this global was used to limit to single connection, but the actual limitation is for the adapter and with different adapter implementation multiple connections could actually be supported - the global defined in the vppapiclient package will continue to limit to single connection via VppClient implementation of the adapter Change-Id: Id06dd6e80b51d1d43f6f75bbcc6e01c6f21c605a Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
2018-10-22Introduce StatsAPI and it's initial implementationOndrej Fabry1-22/+23
- this implementation is basically Go wrapper around VPP's vppapiclient C library Change-Id: I6f53dc3e228868834bf3a8a00c686ad05e22f3dd Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
2018-08-24Simplify subscribing to events and fix eventsOndrej Fabry1-131/+104
- there is no need for sending subscription requests through channels, since all the messages are registered and no communication with VPP is needed Change-Id: Ibc29957be02a32e26309f66c369a071559b822a9 Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
2018-08-16Refactor GoVPPOndrej Fabry1-115/+174
Squashed commit of the following: commit 348930db31575e9f59b3834d9fec07411f011e05 Author: Ondrej Fabry <ofabry@cisco.com> Date: Wed Aug 15 11:30:13 2018 +0200 Use debug level for log about different context commit 9fc963c559cea67a41b85c6cdadc322fb3b1fc7c Author: Ondrej Fabry <ofabry@cisco.com> Date: Wed Aug 15 11:22:03 2018 +0200 Remove annoying logs and add env vars for debugging commit fdc9fd624d13feadb602e0d03d58f8a44b7a565f Author: Ondrej Fabry <ofabry@cisco.com> Date: Wed Aug 15 11:18:47 2018 +0200 Fix printing unknown VPPApiError commit 8f968be36a91de4d4a8ea17593ba314f82aa9583 Author: Ondrej Fabry <ofabry@cisco.com> Date: Tue Aug 14 17:25:10 2018 +0200 Refactor entire GoVPP - fix some cases with inconsistent VPP messages, causing messages to be incorrectly identified as event or request - simplify API, remove direct access to internal Go channels - add module name with message to registration of messages - start watching filesystem only when vpe-api file does not exist - simplify code in message codec and remove unneeded parts - retrieve IDs of all registered messages after connect to VPP - define fallback for control ping in core to avoid duplicate registration - add SetLogLevel function to set logger level more easily - remove lot of unused code commit 34dd1b7e10ef0324aa8c4e4cc42375bd6021c6cb Author: Ondrej Fabry <ofabry@cisco.com> Date: Mon Aug 13 11:29:54 2018 +0200 Rename VnetError to VPPApiError commit c6549d6f77847a1367a12ff47fb716e2955e973a Author: Ondrej Fabry <ofabry@cisco.com> Date: Mon Aug 13 10:23:43 2018 +0200 Fix examples and regenerate binapi commit 4612e36b416779771f5efab4fc654c2766d2cb1c Author: Ondrej Fabry <ofabry@cisco.com> Date: Mon Aug 13 09:51:22 2018 +0200 Add parsing and generation for services commit ac9c5280c5aa27e325f327609e2364cc66f3723f Author: Ondrej Fabry <ofabry@cisco.com> Date: Fri Aug 10 14:30:15 2018 +0200 Fix exit status on error and add continue-onerror flag commit 9b3f4ef9fc7c8c62037fa107085eae18a8725314 Author: Ondrej Fabry <ofabry@cisco.com> Date: Thu Aug 9 15:20:56 2018 +0200 Return VnetError when Retval != 0 commit 8fd21a907b5e628ec4d2026215b83d15da96c297 Author: Ondrej Fabry <ofabry@cisco.com> Date: Thu Aug 9 14:59:05 2018 +0200 Add all missing errors from api_errno.h commit 08450f288d3046ebaecf40203174ae342a07f1eb Author: Ondrej Fabry <ofabry@cisco.com> Date: Thu Aug 9 14:29:27 2018 +0200 Update README commit d8dced0728dd62243539be741868fb7d9b8de4cc Author: Ondrej Fabry <ofabry@cisco.com> Date: Thu Aug 9 13:59:59 2018 +0200 Regenerate vpe in core commit 254da7592cdbf634cf7aa46ae36ce7bb6d4ee555 Author: Ondrej Fabry <ofabry@cisco.com> Date: Thu Aug 9 13:37:00 2018 +0200 Add VnetError type for Retvals commit 4475c1087fb53ab4c788e530bc7fef7cfc89d2cd Author: Ondrej Fabry <ofabry@cisco.com> Date: Thu Aug 9 13:36:07 2018 +0200 Add registration API commit 892a3ea5a2c703e2f7c29331663f6a6fa706bff5 Author: Ondrej Fabry <ofabry@cisco.com> Date: Thu Aug 9 13:30:43 2018 +0200 Generate registration for messages and check all IDs on connect commit 389ed03b6e7082260281866c3449d72d72347c99 Author: Ondrej Fabry <ofabry@cisco.com> Date: Thu Aug 9 11:32:41 2018 +0200 Show error for empty adapter (on Darwin/Windows) commit ef1ea040d656ade64242432dc5f06810ed8dcde6 Author: Ondrej Fabry <ofabry@cisco.com> Date: Thu Aug 9 11:31:37 2018 +0200 Improve logged info commit d4adae3b14ed54c8d693060dd857fa9ba5ec8e06 Author: Ondrej Fabry <ofabry@cisco.com> Date: Thu Aug 9 11:27:48 2018 +0200 Update examples commit 63921e1346014701a22639a2611129563bb1eb78 Author: Ondrej Fabry <ofabry@cisco.com> Date: Thu Aug 9 11:02:56 2018 +0200 Generate unions and fix some issues - add comments between sections - define structs on single line if it has no fields - generate unions with setters/getters for each field - fix detection of message type commit 6ab3e3fa590b245898306a6ffaf32c7721eab60c Author: Ondrej Fabry <ofabry@cisco.com> Date: Wed Aug 8 15:37:10 2018 +0200 Refactor binapi-generator - split JSON parsing from code generation - parse and generate enums - parse unions (no generation yet) - change output file suffix to '.ba.go' - cleanup and simplify code - split code into files - add flag for debug mode Change-Id: I58f685e0d4c7a38e9a7b6ea0a1f47792d95d7399 Signed-off-by: Ondrej Fabry <ofabry@cisco.com>
2018-07-06make api.Channel as interfaceVladimir Lavor1-0/+403
Change-Id: I052d241ab09043b1195beebeee99df4d8536621f Signed-off-by: Vladimir Lavor <vlavor@cisco.com>