Skip to content

Commit

Permalink
mctpd: Fix Message Type Support query
Browse files Browse the repository at this point in the history
In e7d64b0 ("mctpd: check IIDs and opcodes in control protocol
responses"), we dropped the store to peer->num_message_types, so
endpoints would report support for no types over dbus.

Fix the missing store, and add a simple testcase for Get Message Type
Support.

Reported-by: John Chung <[email protected]>
Fixes: e7d64b0 ("mctpd: check IIDs and opcodes in control protocol responses")
Signed-off-by: Jeremy Kerr <[email protected]>
  • Loading branch information
jk-ozlabs committed Nov 7, 2024
1 parent 91dbd23 commit 5c3b15d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

2. Fixed some header includes where we were previously assuming a glibc layout

3. Fixed incorrect setup of peer message type data, where peer endpoints would
report no types supported over dbus.

### Changed

1. We now enforce IID checks on MCTP control protocol responses; this
Expand Down
1 change: 1 addition & 0 deletions src/mctpd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1809,6 +1809,7 @@ static int query_get_peer_msgtypes(peer *peer) {
rc = -ENOMEM;
goto out;
}
peer->num_message_types = resp->msg_type_count;
memcpy(peer->message_types, (void*)(resp+1), resp->msg_type_count);
rc = 0;
out:
Expand Down
22 changes: 22 additions & 0 deletions tests/test_mctpd.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from mctp_test_utils import (
mctpd_mctp_iface_obj,
mctpd_mctp_endpoint_common_obj,
mctpd_mctp_endpoint_control_obj
)
from conftest import Endpoint, MCTPSockAddr
Expand Down Expand Up @@ -433,3 +434,24 @@ async def handle_mctp_control(self, sock, src_addr, msg):
await mctp.call_learn_endpoint(ep.lladdr)

assert str(ex.value) == "Request failed"

""" Ensure we're parsing Get Message Type Support responses"""
async def test_query_message_types(dbus, mctpd):
iface = mctpd.system.interfaces[0]
ep = mctpd.network.endpoints[0]
ep_types = [0, 1, 5]
ep.types = ep_types

mctp = await mctpd_mctp_iface_obj(dbus, iface)

(eid, net, path, new) = await mctp.call_setup_endpoint(ep.lladdr)

assert eid == ep.eid

ep = await mctpd_mctp_endpoint_common_obj(dbus, path)

query_types = list(await ep.get_supported_message_types())
ep_types.sort()
query_types.sort()

assert ep_types == query_types

0 comments on commit 5c3b15d

Please sign in to comment.