mctpd: Add VendorDefinedMessageTypes property#136
mctpd: Add VendorDefinedMessageTypes property#136jk-ozlabs merged 1 commit intoCodeConstruct:mainfrom
Conversation
fa05dfb to
dad0d6c
Compare
jk-ozlabs
left a comment
There was a problem hiding this comment.
Nice! This looks good, just a few changes/comments inline.
src/mctpd.c
Outdated
| goto out; | ||
|
|
||
| resp = (void *)buf; | ||
| if (resp->vendor_id_format != |
There was a problem hiding this comment.
Minor: Since we re-use resp->vendor_id_format a few times, and the length causes a lot of wrapping, I'd suggest using a temporary (say, fmt) for this.
| peer->num_vdm_types++; | ||
|
|
||
| /* Use the next selector from the response. 0xFF indicates no more entries */ | ||
| req.vendor_id_set_selector = resp->vendor_id_set_selector; |
There was a problem hiding this comment.
Might be cleaner to do the 0xff check here, and rc = 0; break if it matches. Then your while loop can be unconditional, and the error cases can just break, rather than needing a goto between scopes.
src/mctpd.c
Outdated
| free(buf); | ||
| if (rc < 0) { | ||
| free(peer->vdm_types); | ||
| peer->vdm_types = NULL; |
There was a problem hiding this comment.
May be better to store these temporarily, and only update the peer-> members on success?
src/mctpd.c
Outdated
| } | ||
| } | ||
|
|
||
| for (unsigned int i = 0; supports_vdm && i < max_retries; i++) { |
There was a problem hiding this comment.
The intent would be more obvious with supports_vdm as an explicit conditional, rather than hiding it in the loop conditional.
tests/test_mctpd.py
Outdated
| iface = mctpd.system.interfaces[0] | ||
| mctp = await mctpd_mctp_iface_obj(dbus, iface) | ||
|
|
||
| # Test 1: Invalid PCIe length |
There was a problem hiding this comment.
If these are different tests, please make them separate test functions. You can share the endpoint classes if that makes things easier.
tests/test_mctpd.py
Outdated
| """ Test that VendorDefinedMessageTypes property is queried and populated correctly """ | ||
| async def test_query_vdm_types(dbus, mctpd): | ||
| class VDMEndpoint(Endpoint): | ||
| async def handle_mctp_control(self, sock, addr, data): |
There was a problem hiding this comment.
This could go in the main Endpoint object, like the general type support, using a vdm_msg_types member as the data source.
|
Waiting for https://gerrit.openbmc.org/c/openbmc/phosphor-dbus-interfaces/+/86652 to finalize |
171d7fd to
a964b55
Compare
jk-ozlabs
left a comment
There was a problem hiding this comment.
Looking good for the new spec, but a couple of things inline.
tests/test_mctpd.py
Outdated
| assert ep_types == query_types | ||
|
|
||
|
|
||
| """ Test that VendorDefinedMessageTypes property is queried and populated correctly """ |
There was a problem hiding this comment.
Docstrings should go inside the function definition, as the first line.
Please check out the spacing requirements in PEP257 too - no space immediately within the quotes, and """ on its own line for multi-line docstrings.
(this is all part of the new checks, which had landed since your last push)
tests/test_mctpd.py
Outdated
| assert len(vdm_types) == 0 | ||
|
|
||
|
|
||
| """ Test VDM query with invalid PCIe length """ |
There was a problem hiding this comment.
We can probably deduce this from the function name. If you add a docstring, make it a little more explanatory (or drop if not needed)
tests/mctpenv/__init__.py
Outdated
| resp = resp + list(cur_vdm[1].to_bytes(4, 'big')) | ||
| else: | ||
| await sock.send(raddr, bytes(hdr + [0x02])) | ||
| return |
There was a problem hiding this comment.
I'd suggest handing this error case before constructing the response.
However, a value other than 0 or 1 would indicate an issue in the test suite, no?
src/mctpd.c
Outdated
| if (rc < 0) | ||
| return rc; | ||
|
|
||
| rc = sd_bus_message_append(reply, "u", |
There was a problem hiding this comment.
The new spec defines this as q, no?
src/mctpd.c
Outdated
| 0, | ||
| SD_BUS_VTABLE_PROPERTY_CONST), | ||
| SD_BUS_PROPERTY("VendorDefinedMessageTypes", | ||
| "a(yvu)", |
src/mctpd.c
Outdated
| if (supports_vdm) { | ||
| for (unsigned int i = 0; i < max_retries; i++) { | ||
| rc = query_get_peer_vdm_types(peer); | ||
| // Success |
There was a problem hiding this comment.
Probably don't need this comment.
src/mctpd.c
Outdated
| break; | ||
|
|
||
| /* Check for minimum length of PCIe VDM*/ | ||
| expect_size = sizeof(*resp) + sizeof(struct mctp_vdm_pcie_data); |
There was a problem hiding this comment.
Maybe just check for the base here, then apply the full expect_size check in the same place you are doing for PCIe (and that will allow you to handle the !PCIE_FORMAT && !IANA_FORMAT as an else-case there)
Implement Get VDM Support (0x06) control command to query vendor defined message capabilities from peers. Expose via D-Bus property a(yvq) containing format, vendor_id (PCIe 16-bit or IANA 32-bit), and command set. Includes positive test for both formats and negative tests for invalid responses (wrong lengths, invalid format, unsupported command). Signed-off-by: Nidhin MS <nidhin.ms@intel.com>
a7e5ece to
cb182be
Compare
| peer->num_vdm_types = num_vdm_types; | ||
| rc = 0; | ||
| break; | ||
| } |
There was a problem hiding this comment.
We have a remote memory exhaustion problem here: the remote endpoint could return the same set selector repeatedly, causing an infinite allocation of vdm_types.
I have a fix in progress, will merge along with this.
There was a problem hiding this comment.
We have a remote memory exhaustion problem here: the remote endpoint could return the same set selector repeatedly, causing an infinite allocation of
vdm_types.I have a fix in progress, will merge along with this.
Thank You for merging and fixing the issue !!
Implement Get VDM Support (0x06) control command to query vendor defined message capabilities from peers. Expose via D-Bus property a(yvu) containing format, vendor_id (PCIe 16-bit or IANA 32-bit), and command set. Includes positive test for both formats and negative tests for invalid responses (wrong lengths, invalid format, unsupported command).