Open
Conversation
Adds OobData []byte to the Message struct. During the Recieve() function, this field is populated with the raw bytes of any control messages recieved from the recvmsg call. An example of how to process the OobData field has been included. This feature requires the user to set EnableControlMessages in the Config. This is to avoid allocating an additional page per recvmsg call unless it's absolutely necessary. Signed-off-by: Dave Tucker <dave@dtucker.co.uk>
mdlayher
reviewed
Mar 14, 2024
Owner
mdlayher
left a comment
There was a problem hiding this comment.
Seems reasonable overall, some code nits. I'll pull this locally and play around too.
| Data []byte | ||
| Header Header | ||
| Data []byte | ||
| OobData []byte |
Owner
There was a problem hiding this comment.
Suggested change
| OobData []byte | |
| OOBData []byte |
In canonical Go style.
| return nil, err | ||
| } | ||
|
|
||
| var rawOob []byte |
Owner
There was a problem hiding this comment.
Suggested change
| var rawOob []byte | |
| var rawOOB []byte |
| // EnableControlMessages enables the use of control messages for | ||
| // netlink. This option is intended for advanced use cases where the | ||
| // caller needs to receive control messages that contain ancillary data. | ||
| // For example, when using options like `ListenAllNSID`. |
Owner
There was a problem hiding this comment.
Add another sentence like:
// When enabled, the Message.OOBData field will be populated with control message data.
| log.Fatalf("failed to dial netlink: %v", err) | ||
| } | ||
| defer c.Close() | ||
| c.SetOption(netlink.ListenAllNSID, true) |
| // Iterate over recieved messages and print them | ||
| for _, msg := range msgs { | ||
| // If the message contains oob data, parse it and print the netnsid | ||
| if msg.OobData != nil { |
Owner
There was a problem hiding this comment.
Invert conditional and continue if nil rather than adding indentation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds OobData []byte to the Message struct.
During the Recieve() function, this field is populated with the raw bytes of any control messages recieved from the recvmsg call.
An example of how to process the OobData field has been included.