-
Notifications
You must be signed in to change notification settings - Fork 225
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
Option to easily discard bytes explicitely without label #369
Comments
Do you have an example struct that requires this? If we want to have this functionality, it needs an example attached. |
Right now I have a struct like this:
Due to alignment, it is 8 byte long. In the config, I can't use
The label "padding_bytes" is added just to get the proper map key size. In order to avoid the unnecessary label, an additional config key (e.g.
|
I see. Normally I just upsize the struct members (u8 -> u16), which doesn't change the struct size. #include <stdint.h>
struct inet_frags_counter_key_u8_t {
uint32_t ifindex;
uint8_t ip_version;
uint8_t ip_protocol;
};
struct inet_frags_counter_key_u16_t {
uint32_t ifindex;
uint16_t ip_version;
uint16_t ip_protocol;
};
struct inet_frags_counter_key_u8_t key_u8 = {};
struct inet_frags_counter_key_u16_t key_u16 = {};
struct inet_frags_counter_key_u8_t {
uint32_t ifindex; /* 0 4 */
uint8_t ip_version; /* 4 1 */
uint8_t ip_protocol; /* 5 1 */
/* size: 8, cachelines: 1, members: 3 */
/* padding: 2 */
/* last cacheline: 8 bytes */
};
struct inet_frags_counter_key_u16_t {
uint32_t ifindex; /* 0 4 */
uint16_t ip_version; /* 4 2 */
uint16_t ip_protocol; /* 6 2 */
/* size: 8, cachelines: 1, members: 3 */
/* last cacheline: 8 bytes */
}; I can see an argument to add |
Using longer types definitely is a simple workaround and would works for my use cases as well. But if it were implemented, I'd prefer your |
I'm open to a PR to add |
Padding bytes in the map key struct need to be considered in the config of the label. This is done by choosing a larger size for the label's value. For most cases this works fine. This commit adds a new config key for labels that allows to specify padding bytes explicitly so they can be skipped by decoders. Closes cloudflare#369
Padding bytes in the map key struct need to be considered in the config of the label. This is done by choosing a larger size for the label's value. For most cases this works fine. This commit adds a new config key for labels that allows to specify padding bytes explicitly so they can be skipped by decoders. Closes cloudflare#369
Padding bytes in the map key struct need to be considered in the config of the label. This is done by choosing a larger size for the label's value. For most cases this works fine. This commit adds a new config key for labels that allows to specify padding bytes explicitly so they can be skipped by decoders. Closes cloudflare#369
As described in the documentation, padding bytes in the counter key struct need to be considered when decoding the values.
The documentation suggests just to include the padding space in the previous value.
In case the structure is not as simple, it can get tricky and I need to define "reserved" fields. Those end up as label unnecessarily.
So, in order to avoid that, with a "discard" decoder I could explicitely discard such padding bytes.
I'd be happy to provide a patch, if you like the idea. Regarding the naming of such a decoder I'm open to suggestions.
Edit: It seems better to just add a simple "discard" or "skip" config flag to the label.
The text was updated successfully, but these errors were encountered: