Skip to content
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

ipset v7 bitmap:port add failed: invalid protocol #1054

Open
ws-weisb opened this issue Jan 24, 2025 · 2 comments
Open

ipset v7 bitmap:port add failed: invalid protocol #1054

ws-weisb opened this issue Jan 24, 2025 · 2 comments

Comments

@ws-weisb
Copy link

ws-weisb commented Jan 24, 2025

&IpSetCreateOption{
    Replace: true,
    PortFrom: 1,
    PortTo: 65535
}
p := 55
&IPSetEntry{Port: &p}

if remove protocol attr, is ok.
bitmap:port seems to be unrelated to the protocol. In higher versions, additional specified protocols will result in an error.
https://github.com/vishvananda/netlink/blob/main/ipset_linux.go#L318-L323

os env

Image

@aboch
Copy link
Collaborator

aboch commented Jan 24, 2025

I do not think that attribute has anything to do with IP Protocol.

https://elixir.bootlin.com/linux/v6.12.6/source/include/uapi/linux/netfilter/ipset/ip_set.h#L13

I think that refers to the version of ipset. The netlink code you referenced happens to work just because TCP is 6... We should change that, it's confusing.

@ws-weisb
Copy link
Author

ws-weisb commented Jan 26, 2025

Sorry... No new emails to notify me

I do not think that attribute has anything to do with IP Protocol.

https://elixir.bootlin.com/linux/v6.12.6/source/include/uapi/linux/netfilter/ipset/ip_set.h#L13

I think that refers to the version of ipset. The netlink code you referenced happens to work just because TCP is 6... We should change that, it's confusing.

I tried changing the version to 7 but it didn't work.
bitmap:port itself has nothing to do with the protocol.
I mean if there is an extra protocol attr, it will be considered an error.
This may be a strong check in the new version.
I compared the strace of the ipset command directly add and found two differences.

  1. protocol version 7 (top attr, not attr data)
  2. No protocol attr in the IPSetEntry(IPSET_ATTR_PROTO).
    Modification 1 did not solve the problem, modification 2 removed the extra protocol attr and worked well.
    @aboch

At the same time, the kernel is compared with the mini protocol, so this is no problem with protocol 6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants