Avnu / detd

Proof-of-concept for a developer-friendly system service to handle time-sensitive applications.
BSD 3-Clause "New" or "Revised" License
17 stars 6 forks source link

Null bytes in protobuf messages sent via unix datagram socket #2

Open koalo opened 1 year ago

koalo commented 1 year ago

Hi, I just noticed that when the service sends a StreamQosResponse with ok = False, an empty packet is received on receiver side. The reason for that is that protobuf messages are allowed to contain null bytes (and a False boolean is encoded as null byte \0). Unfortunately, that is also the terminator of a datagram. In the current implementation that probably got unnoticed, because if ok = False the subsequent fields are ignored anyway. However, I still think we should avoid sending raw protobuf messages via unix datagram sockets.

I am happy to provide a fix, but since there are many different options to solve this, I would appreciate your opinion on this topic:

  1. We could further encode the protobuf message to prevent null bytes (e.g. as Base64).
  2. We could avoid using datagram sockets and use stream sockets instead. We would then need a method for separating the messages in the stream again.
  3. We completely avoid protobuf and use another IPC method. One option that you already mentioned in the README would be to replace it by DBus.

What do you think?

xtor commented 1 year ago

Hi!

Ey, good catch! Thanks a lot for your brilliant assessment and proposals to improve the IPC interface!

I would +1 the D-BUS choice. Some comments below.

Schönes Wochenende!

magnus-karlsson commented 1 year ago

There was a C-based example in samples/bpf/xdpsock_ctrl_proc.c and xdpsock_user.c in kernels prior to 6.0 (I removed it in that release). Do not know if that will help you. If you are looking for a higher level example, maybe @garylough has something?

koalo commented 1 year ago

Thanks a lot for providing these details! Sounds very reasonable to wait until your upcoming release before implementing it. I am looking forward to the release and will have a look again after that.