History log of /openbmc/bmcweb/features/redfish/include/subscription.hpp (Results 1 – 9 of 9)
Revision Date Author Comments
# f86cdd7d 12-Aug-2025 Ed Tanous <etanous@nvidia.com>

Move common structures

It's ideal if the various BMCWEB_ROUTE lib calls do not call from one
another. This reduces the amount of code that's compiled each time
separately.

Tested: Code compiles.

Move common structures

It's ideal if the various BMCWEB_ROUTE lib calls do not call from one
another. This reduces the amount of code that's compiled each time
separately.

Tested: Code compiles.

Change-Id: I4822ce66c122f261cc6aa34bbd99371b7eff48c8
Signed-off-by: Ed Tanous <etanous@nvidia.com>

show more ...


# 99ff0ddc 22-Apr-2025 Myung Bae <myungbae@us.ibm.com>

Fix race condition between subscription deletions

After the connection max-retry with the policy of
"TerminateAfterRetries", coredump may have been occurred although it
seems rare.

Stack frame of O

Fix race condition between subscription deletions

After the connection max-retry with the policy of
"TerminateAfterRetries", coredump may have been occurred although it
seems rare.

Stack frame of One occurrency indicates that an invalid memory access
happened inside deleteSubscription().

1) http_client is waiting for async_read() to handle
sendEventToSubscriber().

```
- recvMessage via async_read() [hold Connection with shared_from_this()] --> call afterRead().
- afterRead() find the invalid response (i.e. probably disconnected from the other end?), and call waitAndRetry()
- waitAndRetry() detects the maxRetryAttempts (with the policy of "TerminateAfterRetries"),
and invokes callback callback is ConnectionPool::afterSendData().
```

2) Meanwhile, the subscription is explicitly requested to delete via
Redfish API.

```
BMCWEB_ROUTE(app, "/redfish/v1/EventService/Subscriptions/<str>/")
...
.methods(boost::beast::http::verb::delete_)(
...
if (!event.deleteSubscription(param))
```

3) Later on, http_client invokes resHandler() but this resHandler() is
bound with its own subscription object like this.

```
bool Subscription::sendEventToSubscriber(std::string&& msg)
{
client->sendDataWithCallback(
std::move(msg), userSub->destinationUrl,
static_cast<ensuressl::VerifyCertificate>(
userSub->verifyCertificate),
httpHeadersCopy, boost::beast::http::verb::post,
std::bind_front(&Subscription::resHandler, this)); <==
```

As the result, if the subscription object is already deleted outside
(i.e. Redfish API delete), resHandler() which is from async_read
callback may be accessing the invalid object.

```
void Subscription::resHandler(const crow::Response& res)
{
...
if (client->isTerminated())
{
hbTimer.cancel();
if (deleter)
{
deleter(); --> This invokes deleteSubscription()
}
}
}
```

Quick summary of stack frame:

```
0 __GI_memcmp (s1=<optimized out>, s2=<optimized out>, len=<optimized out>)
at memcmp.c:342

warning: 342 memcmp.c: No such file or directory
at memcmp.c:342
at /usr/include/c++/13.2.0/bits/basic_string.h:3177
...
this=0x814fa8 <redfish::EventServiceManager::getInstance(boost::asio::io_context*)::handler>, id=...)
at /usr/src/debug/bmcweb/1.0+git/redfish-core/include/event_service_manager.hpp:537
resHandler=..., keepAlive=false, connId=0, res=...)
at /usr/src/debug/bmcweb/1.0+git/http/http_client.hpp:803
...
at /usr/src/debug/bmcweb/1.0+git/http/http_client.hpp:461
at /usr/src/debug/bmcweb/1.0+git/http/http_client.hpp:440
bytesTransferred=<optimized out>)
at /usr/src/debug/bmcweb/1.0+git/http/http_client.hpp:398
```

So, we would need to hold the subscription object until resHandler() is
completed by holding up using `shared_from_this()` for
sendEventToSubscriber()..

```
bool Subscription::sendEventToSubscriber(std::string&& msg)
{
client->sendDataWithCallback(
...
std::bind_front(&Subscription::resHandler, this, shared_from_this())); <===
```

Tested:
- Compiles
- Event Listener works
- Attempt to delete subscriptions

Change-Id: I5172c96e9d1bd2f03831916a95167e0ea532e9f2
Signed-off-by: Myung Bae <myungbae@us.ibm.com>

show more ...


# 5ffbc9ae 24-Apr-2025 Gunnar Mills <gmills@us.ibm.com>

Use SPDX identifiers everywhere

https://gerrit.openbmc.org/c/openbmc/bmcweb/+/74513 moved most places
over to SPDX but forgot a few, fix the ones found with grep.

SPDX identifiers are simpler, and

Use SPDX identifiers everywhere

https://gerrit.openbmc.org/c/openbmc/bmcweb/+/74513 moved most places
over to SPDX but forgot a few, fix the ones found with grep.

SPDX identifiers are simpler, and reduce the amount of cruft we have in
code files. They are recommended by linux foundation, and therefore we
should do as they allow.

This patchset does not intend to modify any intent on any existing
copyrights or licenses, only to standardize their inclusion.

[1] https://www.linuxfoundation.org/blog/blog/copyright-notices-in-open-source-software-projects

Change-Id: Ie4c2ea53f7bc8d902bf87fef6df2a67c6b1de613
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>

show more ...


# 4a19a7b5 27-Jan-2025 Ed Tanous <etanous@nvidia.com>

Deduplicate event ids

Redfish specification states:
```
The value of the id field shall be the same as the Id property in the
event payload. The value of the Id property in the event payload should

Deduplicate event ids

Redfish specification states:
```
The value of the id field shall be the same as the Id property in the
event payload. The value of the Id property in the event payload should
be the same as the EventId property of the last event record in the
Events array. The value of the EventId property for an event record
should be a positive integer value and should be generated in a
sequential manner.
```

The event service code did not implement that correctly. So:
1. Add ID fields for all events.
2. Remove the per-sse connection id field and rely solely on
EventServiceManager.
3. Make sure all paths, (including metric report) are generating an
event id that's based on the eventservice event id

Tested: Redfish event listener now sees events populated.
LastEventId when sent to the SSE socket now sees a contiguous id.

```
uri=$(curl -s --user "root:0penBmc" -k "https://192.168.7.2/redfish/v1/EventService" | jq -r .ServerSentEventUri)
curl -u root:0penBmc -vvv -k -N -H "Accept: text/event-stream" -H "Last-Event-Id: 0" "https://192.168.7.2$uri"
```

Change-Id: Ic32e036f40a53a9b2715639ae384d7891c768260
Signed-off-by: Ed Tanous <etanous@nvidia.com>

show more ...


# d7857201 28-Jan-2025 Ed Tanous <etanous@nvidia.com>

Fix includes

Clang-tidy misc-include-cleaner appears to now be enforcing
significantly more headers than previously. That is overall a good
thing, but forces us to fix some issues. This commit is

Fix includes

Clang-tidy misc-include-cleaner appears to now be enforcing
significantly more headers than previously. That is overall a good
thing, but forces us to fix some issues. This commit is largely just
taking the clang-recommended fixes and checking them in. Subsequent
patches will fix the more unique issues.

Note, that a number of new ignores are added into the .clang-tidy file.
These can be cleaned up over time as they're understood. The majority
are places where boost includes a impl/x.hpp and x.hpp, but expects you
to use the later. include-cleaner opts for the impl, but it isn't clear
why.

Change-Id: Id3fdd7ee6df6c33b2fd35626898523048dd51bfb
Signed-off-by: Ed Tanous <etanous@nvidia.com>
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>

show more ...


# f2656d1b 13-Jan-2025 Alexander Hansen <alexander.hansen@9elements.com>

ci: fix ci ubasan failure

remove an unused std::shared_ptr<Subscription>& from
void Subscription::resHandler(...)

Since it was just a reference, it was non-owning anyways and removing it
should not

ci: fix ci ubasan failure

remove an unused std::shared_ptr<Subscription>& from
void Subscription::resHandler(...)

Since it was just a reference, it was non-owning anyways and removing it
should not have any impact to the lifetime of the managed object.

Tested: Inspection only.

Change-Id: Iab57e456d5a7ae32305e1a38ddcc37c0f0156ed4
Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>

show more ...


# 81ee0e74 20-Dec-2024 Chandramohan Harkude <Chandramohan.harkude@gmail.com>

Update Submit Test event feature to send custom data

Changes Added : Updated the submit test event feature to send test
data as per spec

https://www.dmtf.org/sites/default/files/standards/documents

Update Submit Test event feature to send custom data

Changes Added : Updated the submit test event feature to send test
data as per spec

https://www.dmtf.org/sites/default/files/standards/documents/
DSP2046_2019.1.pdf


Testing :

Tested sending custom test data
and same data received at the event listener
Change-Id: I2c2363a676aafd39c121c9fe4e16402c0f5961e2
Signed-off-by: Chandramohan Harkude <chandramohan.harkude@gmail.com>

show more ...


# fb546105 29-Oct-2024 Myung Bae <myungbae@us.ibm.com>

Implement Subscription Heartbeat Logic

This implements the subscription heartbeat logic which will send the
message `RedfishServiceFunctional` periodically with the interval of
`HeartbeatIntervalMin

Implement Subscription Heartbeat Logic

This implements the subscription heartbeat logic which will send the
message `RedfishServiceFunctional` periodically with the interval of
`HeartbeatIntervalMinutes` specified in subscription property [1][2], if
`SendHeartbeat` is enabled..

Note the heartbeat enablement is per event destination as DMTF specifies
[3] like
```
... This message shall only be sent if specifically requested by an event
destination during the creation of a subscription...
```

This also add `HeartbeatEvent` to supported registry prefixes like
```
curl -k -X GET https://${bmc}/redfish/v1/EventService/
{
...
"RegistryPrefixes": [
"Base",
"OpenBMC",
"TaskEvent",
"HeartbeatEvent"
],
"ResourceTypes": [
"Task",
"Heartbeat"
],
```

Tested:

1) A single subscription and heartbeat via Redfish Event Listener

- Create a subscription via Redfish Event Listener
- PATCH `SendHeartbeat=true` and `HeartbeatIntervalMinutes` like

```
curl -k -X PATCH https://${bmc}/redfish/v1/EventService/Subscriptions/${SUBID} \
-H "Content-Type: application/json" \
-d '{"SendHeartbeat":true, "HeartbeatIntervalMinutes":1}'
```

- Monitor the Redfish Event Listener and check the following heartbeat
messages periodically (per HeartbeatIntervalMinutes)

```
response_type: POST
headers: {'Host': '9.3.62.209', 'Content-Length': '230'}

response={
"@odata.type": "#Event.v1_4_0.Event",
"Events": [
{
"@odata.type": "#Message.v1_1_1.Message",
"EventId": "HeartbeatId",
"EventTimestamp": "2024-11-21T12:21:47+00:00",
"MemberId": "0",
"Message": "Redfish service is functional.",
"MessageArgs": [],
"MessageId": "HeartbeatEvent.1.0.1.RedfishServiceFunctional",
"MessageSeverity": "OK",
"OriginOfCondition": "/redfish/v1/EventService/Subscriptions/1521743607",
"Resolution": "None."
}
],
"Id": "HeartbeatId",
"Name": "Event Log"
}
```

- Change `SendHeartbeat` to false and see whether the heartbeat message
is stopped.

2) Multiple sbscribers with the different heartbeat setups

- create 2 event listeners with 2 different destinations (e.g., port
8080 and 8081).
- Patch sendheartbeat=true to only one subscriber.
- Check whether the only subscriber that enables `SendHeartbeat` is
receiving the heartbeat messages.

3) Redfish Service Validator passes

[1] https://github.com/openbmc/bmcweb/blob/02ea923f13de196726ac2f022766a6f80bee1c0a/redfish-core/schema/dmtf/json-schema/EventDestination.v1_15_0.json#L356
[2] https://redfish.dmtf.org/registries/HeartbeatEvent.1.0.1.json
[3] https://github.com/DMTF/Redfish/blob/d9e54fc8393d8930bd42e8b134741f5051a2680f/registries/HeartbeatEvent.1.0.1.json#L14

Change-Id: I8682e05f4459940913ba189f1ed016874e38dd4a
Signed-off-by: Myung Bae <myungbae@us.ibm.com>

show more ...


# 02c1e29f 15-Nov-2024 Alexander Hansen <alexander.hansen@9elements.com>

Refactor: break up event_service_manager.hpp

'class Subscription' can be extracted into a separate file.

No changes have been made to the code.

Tested:

- Using Redfish Event Listener, test subscr

Refactor: break up event_service_manager.hpp

'class Subscription' can be extracted into a separate file.

No changes have been made to the code.

Tested:

- Using Redfish Event Listener, test subscriptions and eventing.
- Redfish Service Validator passes

Change-Id: Id0076ef617e36cbb85629a386a4511a4fdb5e4da
Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>

show more ...