Conversation
b3230d0 to
dfbbf3f
Compare
|
First of all, thank you so much for your work on this! I really appreciate the time you've put into this.
I've recently touched this code and I'll have to review it, but I would expect a payload of
I calculated the alignment and my only concern here would be on architectures other than x86. For x86, this looks reasonable.
Can you give me a little bit more detail here? There may still be a way to make this work.
|
I don't understand what you mean. What I am saying is that the
So, should I change it or not?
The connector protocol is used as a generic kernel to user space communication, each type has its own payload. Currently, these are the different types that the kernel supports: pub const CN_IDX_PROC: c_uint = 0x1;
pub const CN_VAL_PROC: c_uint = 0x1;
pub const CN_IDX_CIFS: c_uint = 0x2;
pub const CN_VAL_CIFS: c_uint = 0x1;
pub const CN_W1_IDX: c_uint = 0x3;
pub const CN_W1_VAL: c_uint = 0x1;
pub const CN_IDX_V86D: c_uint = 0x4;
pub const CN_VAL_V86D_UVESAFB: c_uint = 0x1;
pub const CN_IDX_BB: c_uint = 0x5;
pub const CN_DST_IDX: c_uint = 0x6;
pub const CN_DST_VAL: c_uint = 0x1;
pub const CN_IDX_DM: c_uint = 0x7;
pub const CN_VAL_DM_USERSPACE_LOG: c_uint = 0x1;
pub const CN_IDX_DRBD: c_uint = 0x8;
pub const CN_VAL_DRBD: c_uint = 0x1;
pub const CN_KVP_IDX: c_uint = 0x9;
pub const CN_KVP_VAL: c_uint = 0x1;
pub const CN_VSS_IDX: c_uint = 0xA;
pub const CN_VSS_VAL: c_uint = 0x1;I've only worked with proc connectors, so I do not know how the other works, but I suspect it won't be too different. I could maybe have another option that won't parse the payload if the type is unknown, and instead will keep the raw bytes. |
Ah, now I understand what you mean. Can you outline what payload you expect in the
I'm currently asking some colleagues more knowledgeable on architecture than I am about this. In the Fedora space, @decathorpe and @sbrivio-rh opened an issue about s390x so they may have thoughts here.
A pattern that may be helpful to look at for this is the attributes. I also kept the bytes and allowed parsing after the fact. That seems to have worked pretty well so far. Unfortunately, it's not quite as intuitive as just encoding it in a type parameter, but it's flexible and generally works well. |
You can look at the example I added, in the recv call (
Could you clarify this point? I think I didn't understand fully what you meant |
Will do.
The generic netlink attributes ( |
|
I think I finished everything About the other protocols, I think the best way to handle them is to let the user define the payloads in their own crates, then they will be able to use them with the If someone in the future wants to add another connector to this crate, they will only need to add the specific payload parsing for that connector (this will be a non-breaking change) I pointed that out in the module docs I added a few static parsing tests, I cannot write any real world tests because proc connectors are only available in the root PID namespace (so, not in docker). About the Here are the remaining blockers:
|
|
Thank you so much for your thorough work on this. I am assigning a target of 0.7.1 to this PR. I will try to take a look soon, but currently I'm working on getting the release out and sorting out #273. |
|
You're welcome I think you should look at the (small) change of the payload parsing in |
|
Do you mean the change in this PR? |
|
Yes |
|
@Bben01 I'm a little bit torn on this change because in the case of the DONE packet, it will require users to specify exactly which type they expect which may differ in the case of extended ACKs from the payload of the intermediate packets. I believe this will break in the case of calls like |
Sorry, my experience with s390x is limited to debugging endianness issues in various Fedora packages too :) If you need hardware access (over SSH) to an actual s390x machine for debugging and / or development, there are ways to request that through Fedora infrastructure. |
|
@jbaublitz I've looked a bit into that and I saw that the flags will contain This means that we could potentially use that to parse the payload differently. Currently we have no way to access the (parsed) flags from the payload, so I resorted to manually parsing them again from the buffer (for the POC, maybe there a better way of doing it). I don't know if there is a better solution, but the at the end there is a finite amount of netlink protocols, so parsing their payload should always be possible from the payload code directly, but I am not knowledgeable enough on this topic. |
@decathorpe Thanks for the offer. Currently QEMU s390x seems to be working better than I was expecting. Very slow but doable for what I need it for. |
|
@Bben01 Overall, I am happy with the code, but will provide a more detailed code review after I release 0.7.0. I tested your example code and the example code for DUMP directives and, while I will probably implement it differently in the 0.7.0 version, I see why you made the choice you did and I will try to preserve it in a way that doesn't require reparsing. I believe this format is slightly different due to the subscription model. It seems like that is why each packet is of type DONE and contains a payload of the expected type. Unfortunately, what I don't know is how this maps to other subscription-like netlink subsystems. I'm going to do some reading and try to see if I can find a similar protocol but honestly I would have expected an API like this to be exposed as a multicast group. That is the typical (and generally blessed way) of subscribing to a notification stream. I do support that in this library but unfortunately it seems like that is not the way it's implemented for this protocol in the kernel. |
jbaublitz
left a comment
There was a problem hiding this comment.
I'm ready to accept the code. Can you just clean up the git history into preferably one or a few commits with a linear history based on main? I won't merge anything else until I merge this.
aaa5e52 to
35d5b4b
Compare
|
Thanks, I cleaned up the git history, and fixed the new clippy lints (two separate commits) (Also, if possible, could you release a v0.7.1 when the PR is merged? I would like to use it in my crate) |
|
Thanks so much for this contribution! I believe the clippy errors are unrelated to your code, so I'm going to merge. |
Close #275
So, a very early stage of the PR, but a working connector.
A few things to notice:
Nlmsghdrto get the response from the socket, but with the connector protocol, a valid response comes withnl_typeof Done, so the Payload parsed it as an errorcb_idfrom the kernel, but I don't really know if I should do it or notTo: