this post was submitted on 26 Jan 2024
28 points (93.8% liked)
Linux
48328 readers
659 users here now
From Wikipedia, the free encyclopedia
Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).
Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.
Rules
- Posts must be relevant to operating systems running the Linux kernel. GNU/Linux or otherwise.
- No misinformation
- No NSFW content
- No hate speech, bigotry, etc
Related Communities
Community icon by Alpár-Etele Méder, licensed under CC BY 3.0
founded 5 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
I don't have any previous knowledge of this at all, but from reading the docs, nothing you're describing sounds wrong.
A u32 selector will match 4 bytes (u32 meaning unsigned 32bit presumably, which is 4 bytes).
It makes sense that you'd only be able to configure the matches on 4 byte intervals, because keeping them aligned may make the implementation simpler and more efficient. You can still match any set of bits this way.
Perhaps you could describe what you're trying to match exactly and the selectors you tried.
Edit: also if you look at 'raw payload expressions' in nft: https://netfilter.org/projects/nftables/manpage.html
That seems like it would do what you want, and you can actually access the ethernet header in a documented way. You have to switch to nft though.
I really appreciate this, thank you. I think I had confused myself by playing with 'u16' and 'u8' and somehow coming to the conclusion that they were matching the right side of a 32-bit string. (Which may still be true, but, I'm just masking u32s now).
This is what I ended up with, which is working the way I'd expect:
This sends Ethernet frames destined for 30:d6:c9:2d:19:05 to flow 1:20, and it doesn't seem to match a second device I tested. So, all good! Thank you again.