summaryrefslogtreecommitdiffstats
path: root/libglusterfs/src/events.c
Commit message (Collapse)AuthorAgeFilesLines
* Events: Fixing coverity issues.Srijan Sivakumar2020-09-031-3/+5
| | | | | | | | | | Fixing resource leak reported by coverity scan. CID: 1431237 Change-Id: I2bed106b3dc4296c50d80542ee678d32c6928c25 Updates: #1060 Signed-off-by: Srijan Sivakumar <ssivakum@redhat.com>
* Events: Socket creation after getaddrinfo and IPv4 and IPv6 packet capturesrijan-sivakumar2020-08-191-8/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Issue: Currently, the socket creation is done prior to getaddrinfo function being invoked. This can cause mismatch in the protocol and address families of the created socket and the result of the getaddrinfo api. Also, the glustereventsd UDP server by default only captures IPv4 packets hence IPv6 packets are not even captured. Code Changes: 1. Modified the socket creation in such a way that the parameters taken in are dependent upon the result of the getaddrinfo function. 2. Created a subclass for adding address family in glustereventsd.py for both AF_INET and AF_INET6. 3. Modified addresses in the eventsapiconf.py.in Reasoning behind the approach: 1. If we are using getaddrinfo function then socket creation should happen only after we check if we received back valid addresses. Hence socket creation should come after the call to getaddrinfo 2. The listening server which pushes the events to the webhook has to listen for both IPv4 and IPv6 messages as we would not be sure as to what address family is picked in _gf_event. Fixes: #1377 Change-Id: I568dcd1a977c8832f0fef981e1f81cac7043c760 Signed-off-by: srijan-sivakumar <ssivakum@redhat.com>
* libglusterfs: add library wrapper for time()Dmitry Antipov2020-08-171-1/+1
| | | | | | | | | Add thin convenient library wrapper gf_time(), adjust related users and comments as well. Change-Id: If8969af2f45ee69c30c3406bce5baa8305fb7f80 Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru> Updates: #1002
* events: fix IPv6 memory corruptionXavi Hernandez2020-01-171-41/+15
| | | | | | | | | | | | | When an event was generated and the target host was resolved to an IPv6 address, there was a memory overflow when that address was copied to a fixed IPv4 structure (IPv6 addresses are longer than IPv4 ones). This fix correctly handles IPv4 and IPv6 addresses returned by getaddrinfo() Change-Id: I5864a0c6e6f1b405bd85988529570140cf23b250 Fixes: bz#1790870 Signed-off-by: Xavi Hernandez <xhernandez@redhat.com>
* gf-event: Handle unix volfile-serversPranith Kumar K2019-10-301-1/+10
| | | | | | | | | | | | | | | Problem: glfsheal program uses unix-socket-based volfile server. volfile server will be the path to socket in this case. gf_event expects this to be hostname in all cases. So getaddrinfo will fail on the unix-socket path, events won't be sent in this case. Fix: In case of unix sockets, default to localhost fixes: bz#1765017 Change-Id: I60d27608792c29d83fb82beb5fde5ef4754bece8 Signed-off-by: Pranith Kumar K <pkarampu@redhat.com>
* eventsapi: Set IPv4/IPv6 family based on input IPAravinda VK2019-09-171-1/+4
| | | | | | | | | | | | server.sin_family was set to AF_INET while creating socket connection, this was failing if the input address is IPv6(`::1`). With this patch, sin_family is set by reading the ai_family of `getaddrinfo` result. Fixes: bz#1752330 Change-Id: I499f957b432842fa989c698f6e5b25b7016084eb Signed-off-by: Aravinda VK <avishwan@redhat.com>
* core: replace inet_addr with inet_ptonRinku Kothiya2019-06-241-1/+7
| | | | | | | | | | Fixes warning raised by RPMDiff on the use of inet_addr, which may impact Ipv6 support fixes: bz#1721385 Change-Id: Id2d9afa1747efa64bc79d90dd2566bff54deedeb Signed-off-by: Rinku Kothiya <rkothiya@redhat.com>
* libglusterfs: Move devel headers under glusterfs directoryShyamsundarR2018-12-051-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | libglusterfs devel package headers are referenced in code using include semantics for a program, this while it works can be better especially when dealing with out of tree xlator builds or in general out of tree devel package usage. Towards this, the following changes are done, - moved all devel headers under a glusterfs directory - Included these headers using system header notation <> in all code outside of libglusterfs - Included these headers using own program notation "" within libglusterfs This change although big, is just moving around the headers and making it correct when including these headers from other sources. This helps us correctly include libglusterfs includes without namespace conflicts. Change-Id: Id2a98854e671a7ee5d73be44da5ba1a74252423b Updates: bz#1193929 Signed-off-by: ShyamsundarR <srangana@redhat.com>
* Land part 2 of clang-format changesGluster Ant2018-09-121-100/+97
| | | | | Change-Id: Ia84cc24c8924e6d22d02ac15f611c10e26db99b4 Signed-off-by: Nigel Babu <nigelb@redhat.com>
* libglusterfs:UNUSED VALUE coverity fixSubha sree Mohankumar2017-11-131-0/+1
| | | | | | | | | | | Problem : Overwriting previous write to "ret" with value "EVENT_SEND_OK" before itr can be used. Fix: The value of ret is used in out. Change-Id: I2cdb32e441c85c94de30de89a7a4121fd54d1acd BUG: 789278 Signed-off-by: Subha sree Mohankumar <smohanku@redhat.com>
* events: use attribute(format(/printf)) to catch fmt string errorsKaleb S. KEITHLEY2017-02-261-1/+1
| | | | | | | | | | | | | and statedump too. Also "const char *" (versus just "char *") for the fmt param. Change-Id: Ic63734a673208a2cd49aebccce7659816e6179e3 BUG: 1399196 Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com> Reviewed-on: https://review.gluster.org/15881 Smoke: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
* eventsapi: Use `getaddrinfo` instead of `gethostbyname`Aravinda VK2017-01-051-6/+19
| | | | | | | | | | | | | | | `gethostbyname` is not thread safe. Use `getaddrinfo` to avoid any race or segfault while sending events BUG: 1410313 Change-Id: I164af1f8eb72501fb0ed47445e68d896f7c3e908 Signed-off-by: Aravinda VK <avishwan@redhat.com> Reviewed-on: http://review.gluster.org/16327 Reviewed-by: Atin Mukherjee <amukherj@redhat.com> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Smoke: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Raghavendra G <rgowdapp@redhat.com>
* events: Add FMT_WARN for gf_eventPranith Kumar K2016-11-181-1/+1
| | | | | | | | | | | | | | | | | Raghavendra G found that posix is trying to print %s but passing an int when HEALTH_CHECK fails in posix. These are the kind of bugs that should be caught at compilation itself. Also fixed the problematic gf_event() callers. BUG: 1386097 Change-Id: Id7bd6d9a9690237cec3ca1aefa2aac085e8a1270 Signed-off-by: Pranith Kumar K <pkarampu@redhat.com> Reviewed-on: http://review.gluster.org/15671 Smoke: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Atin Mukherjee <amukherj@redhat.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
* eventsapi: Add support for Client side EventsAravinda VK2016-08-301-28/+62
| | | | | | | | | | | | | | | | | | | | | | | | | Client side gf_event uses ctx->cmd_args.volfile_server to push notifications to the eventsd. Socket server changed from Unix domain socket to UDP to support external events. Following to be addressed in different patch - Port used for eventsd is 24009. Make it configurable Already configurable in Server side. Configurable in gf_event API is required. - Auth Token yet to be added as discussed in https://www.gluster.org/pipermail/gluster-devel/2016-August/050324.html Change-Id: I159acf80b681d10b82d52cfb3ffdf85cb896542d BUG: 1367774 Signed-off-by: Aravinda VK <avishwan@redhat.com> Reviewed-on: http://review.gluster.org/15189 Smoke: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Prashanth Pai <ppai@redhat.com> Reviewed-by: Atin Mukherjee <amukherj@redhat.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
* eventsapi: Fix disable-events issueAravinda VK2016-08-241-3/+6
| | | | | | | | | | | | | | | | | | | | | | | Events related sources are not loaded in libglusterfs when configure is run with --disable-events option. Due to this every call of gf_event should be guarded with USE_EVENTS macro. To prevent this, USE_EVENTS macro was included in events.c itself(Patch #15054) Instead of disabling building entire directory "events", selectively disabled the code. So that constants and empty function gf_event is exposed. Code will not fail even if gf_event is called when events is disabled. BUG: 1368042 Change-Id: Ia6abfe9c1e46a7640c4d8ff5ccf0e9c30c87f928 Signed-off-by: Aravinda VK <avishwan@redhat.com> Reviewed-on: http://review.gluster.org/15198 Smoke: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Niels de Vos <ndevos@redhat.com> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
* events: move conditional macro check USE_EVENTS inside gf_eventsAtin Mukherjee2016-08-021-1/+3
| | | | | | | | | | | | Change-Id: I88279b11b648e676a4544bbb55c7466fbc55ffa7 BUG: 1361983 Signed-off-by: Atin Mukherjee <amukherj@redhat.com> Reviewed-on: http://review.gluster.org/15054 Smoke: Gluster Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Kotresh HR <khiremat@redhat.com> Reviewed-by: Aravinda VK <avishwan@redhat.com>
* eventsapi: Gluster Eventing Feature implementationAravinda VK2016-07-181-0/+83
[Depends on http://review.gluster.org/14627] Design is available in `glusterfs-specs`, A change from the design is support of webhook instead of Websockets as discussed in the design http://review.gluster.org/13115 Since Websocket support depends on REST APIs, I will add Websocket support once REST APIs patch gets merged Usage: Run following command to start/stop Eventsapi server in all Peers, which will collect the notifications from any Gluster daemon and emits to configured client. gluster-eventsapi start|stop|restart|reload Status of running services can be checked using, gluster-eventsapi status Events listener is a HTTP(S) server which listens to events emited by the Gluster. Create a HTTP Server to listen on POST and register that URL using, gluster-eventsapi webhook-add <URL> [--bearer-token <TOKEN>] For example, if HTTP Server running in `http://192.168.122.188:9000` then add that URL using, gluster-eventsapi webhook-add http://192.168.122.188:9000 If it expects a Token then specify it using `--bearer-token` or `-t` We can also test Webhook if all peer nodes can send message or not using, gluster-eventsapi webhook-test <URL> [--bearer-token <TOKEN>] Configurations can be viewed/updated using, gluster-eventsapi config-get [--name] gluster-eventsapi config-set <NAME> <VALUE> gluster-eventsapi config-reset <NAME|all> If any one peer node was down during config-set/reset or webhook modifications, Run sync command from good node when a peer node comes back. Automatic update is not yet implemented. gluster-eventsapi sync Basic Events Client(HTTP Server) is included with the code, Start running the client with required port and start listening to the events. /usr/share/glusterfs/scripts/eventsdash.py --port 8080 Default port is 9000, if no port is specified, once it started running then configure gluster-eventsapi to send events to that client. Eventsapi Client can be outside of the Cluster, it can be run event on Windows. But only requirement is the client URL should be accessible by all peer nodes.(Or ngrok(https://ngrok.com) like tools can be used) Events implemented with this patch, - Volume Create - Volume Start - Volume Stop - Volume Delete - Peer Attach - Peer Detach It is easy to add/support more events, since it touches Gluster cmd code and to avoid merge conflicts I will add support for more events once this patch merges. BUG: 1334044 Change-Id: I316827ac9dd1443454df7deffe4f54835f7f6a08 Signed-off-by: Aravinda VK <avishwan@redhat.com> Reviewed-on: http://review.gluster.org/14248 Smoke: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Jeff Darcy <jdarcy@redhat.com>