New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve message sanity checks in camessage.c #141
base: 7.0
Are you sure you want to change the base?
Conversation
using CA_PROTO_VERSION messages
receiving the version from the client
beside the payload field (m_postsize) being set to 0xffff, the data count field (m_count) must also be set to 0
against LAST_BUFFER_TYPE
field. Although the type is not actually important for this command, we should check if the data type is valid, as a sanity check of the received message
With this changes, when I reproduce the issue as described in #128 (i.e. sending a HTTP GET request to the IOC), I see this error instead in the IOC shell:
Note: After some discussions, this log message is now controlled using |
❌ Build EPICS Base 7 base-7.0-236 failed (commit a6d18b09b7 by @jesusvasquez333) |
error messages only to TCP clients, and by default do not log the error to avoid flooding the logs
❌ Build EPICS Base 7 base-7.0-262 failed (commit b04ba3c0c9 by @jesusvasquez333) |
Do not try to make this check compatible with < CA_V49 clients
❌ Build EPICS Base 7 base-7.0-283 failed (commit 1df6da7b7d by @jesusvasquez333) |
Core Group 7/28: AI on MAD. |
…put as we've discovered that libca only switches from standard to extended protocol header when the payload size is greater than 0xffff. This way, the payload alone is valid with any number. A function was created to compare command type against one other field to check for valid CA messages.
…st regarding the size of the payload for the extended protocol
I've created the function validate_camessage to check for valid commands (current last command number + 16 for making space for newer clients with more commands) and a few combinations of expected value for a field based on the command type. When trying an HTTP GET, the IOC prints the message below and close the connection:
I've tested with caput, caget, and camonitor, using scalars and waveform with elements below the standard protocol size and above it, to have tests covering both standard and extended sizes. Versions of caput, caget, and camonitor used: 3.14.12, 3.15.5, and the ones from this pull request. Let me know if you'd like to print the message only if CASDEBUG is set. I've merged the branch of this pull request with the most recent 7.0 to make sure the previous changes in 7.0 would work with the changes made by this PR and check for conflicts. |
✅ Build EPICS Base 7 base-7.0-577 completed (commit 6685bbe52b by @marciodo) |
Ping @mdavidsaver please. |
This change looks ok to me. However, on reflection I'm not comfortable taking sole responsibility for review and testing of this PR. Changes to message handling code carry a risk of breaking wire compatibility. After having been responsible for one such accidental break, I hesitate to risk another. wrt. #128 my now less than long term answer for confusing RSRV log messages is to disable RSRV in favor of PVA (with its own confusing messages ;) ). |
This PR improves the sanity checks perform to incoming messages. This improvements will resolve #128 .
The following improvements are implemented:
One issue is that the test to detect deprecated client versions fails when we haven't receive a client version yet (and therefore(This situation happens with clients <client->minor_version_number
is0
). So, I added an extra condition to that test to check is client->minor_version_number!=0.CA_V49
, but the proposed change was not enough to make this test backward compatible, so I removed it from the PR).I couldn't figure out a way to detect deprecated clients on the first message. When the first message arrives, we still do not know the client version; clients starting at
CA_V49
will send aCA_PROTO_VERSION
message which does includes the version number. However, the deprecated clients we are trying to detect ( <CA_V44
) do not implement theCA_PROTO_VERSION
messages, but instead use the oldCA_PROTO_NOOP
message which doesn't include the version number.So, I just added a comment in the code describing this.(this topic is left to be revisit in the future).I also added a few more fixes:
payload
set to0xffff
anddata count
set to0
. The code however, was only checking the payload field. So, I added the check for the data count filed as well.CA_PROTO_EVENT_CANCEL
message contains thedata type
filed. Although the type is not actually important for this command, I added a check for that field as a sanity check of the received message.LAST_BUFFER_TYPE
, for the macroINVALID_DB_REQ()
instead.