Skip to content
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

"Invalid PVA header 16" / "Bad request ... CA 01 00 16" #135

Open
mdavidsaver opened this issue Oct 24, 2018 · 3 comments
Open

"Invalid PVA header 16" / "Bad request ... CA 01 00 16" #135

mdavidsaver opened this issue Oct 24, 2018 · 3 comments
Assignees

Comments

@mdavidsaver
Copy link
Member

Log files at SLAC have been filling up with:

Hexdump [Invalid PVA header 16, its payload buffer] size = 16
00 00 00 00 00 00 00 00 00 00 FF FF AC 1B 00 18 .... .... .... ....

Note that "header 16" is really 0x16.

Hexdump [Bad request] size = 65487
CA 01 00 16 10 00 00 00 00 00 00 00 00 00 00 00 .... .... .... ....
00 00 FF FF 86 4F 97 24 CA 01 00 03 38 00 00 00 .... .O.$ .... 8...
01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .... .... .... ....
00 00 FF FF AC 1B 08 1F 97 B8 01 03 74 63 70 01 .... .... .... tcp.
00 01 00 00 00 12 51 55 41 44 3A 4C 54 55 31 3A .... ..QU AD:L TU1:
38 38 30 3A 52 4D 41 54 3A 4C 49 32 36 3A 33 31 880: RMAT :LI2 6:31
...
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 .... .... .... ....

@mdavidsaver
Copy link
Member Author

It look like somehow CMD_ORIGIN_TAG message have been getting past, or going around, the special case handling for them in BlockingUDPTransport::processBuffer() and triggering warnings in the regular server processing in ServerResponseHandler::handleResponse() and ServerBadResponse::handleResponse().

@mdavidsaver
Copy link
Member Author

As background:

CMD_ORIGIN_TAG is part of the "local multicast hack" (my name for it). A unicast UDP message (according to it's sender) is redirected, by whichever socket happens to receive it (client or server), to 224.0.0.128 on which all local clients and servers are listening. When this happens a CMD_ORIGIN_TAG message is prepended to the packet body.

The idea (as I understand it) is to allow unicast UDP search to "just work" for hosts with multiple PVA servers, without having to manually manage TCP port numbers.

The only (as yet hypothetical) problem which I know of with this idea is that it will cause both sides of a PVA gateway to see unicast searches or beacons from either sides.

redirection on the server side:

if ((qosCode & 0x80) == 0x80)
{
BlockingUDPTransport::shared_pointer bt = dynamic_pointer_cast<BlockingUDPTransport>(transport);
if (bt && bt->hasLocalMulticastAddress())
{
// RECEIVE_BUFFER_PRE_RESERVE allows to pre-fix message
size_t newStartPos = (startPosition-PVA_MESSAGE_HEADER_SIZE)-PVA_MESSAGE_HEADER_SIZE-16;
payloadBuffer->setPosition(newStartPos);
// copy part of a header, and add: command, payloadSize, NIF address
payloadBuffer->put(payloadBuffer->getArray(), startPosition-PVA_MESSAGE_HEADER_SIZE, PVA_MESSAGE_HEADER_SIZE-5);
payloadBuffer->putByte(CMD_ORIGIN_TAG);

redirection on the client side:

if ((qosCode & 0x80) == 0x80)
{
// TODO optimize
ClientContextImpl::shared_pointer context = _context.lock();
if (!context)
return;
BlockingUDPTransport::shared_pointer bt = dynamic_pointer_cast<BlockingUDPTransport>(transport);
if (bt && bt->hasLocalMulticastAddress())
{
// RECEIVE_BUFFER_PRE_RESERVE allows to pre-fix message
size_t newStartPos = (startPosition-PVA_MESSAGE_HEADER_SIZE)-PVA_MESSAGE_HEADER_SIZE-16;
payloadBuffer->setPosition(newStartPos);
// copy part of a header, and add: command, payloadSize, NIF address
payloadBuffer->put(payloadBuffer->getArray(), startPosition-PVA_MESSAGE_HEADER_SIZE, PVA_MESSAGE_HEADER_SIZE-5);
payloadBuffer->putByte(CMD_ORIGIN_TAG);

Handling in UDP receiver common to both client and server:

if (unlikely(command == CMD_ORIGIN_TAG))

@mdavidsaver
Copy link
Member Author

// TODO remove debug output
std::ostringstream name;
name<<"Invalid PVA header "<<hex<<(int)(0xFF&command);
name<<", its payload buffer";

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant