ipset: fix bitmap:port entry add failing with invalid protocol#1177
ipset: fix bitmap:port entry add failing with invalid protocol#1177chent1996 wants to merge 1 commit intovishvananda:mainfrom
Conversation
buildEntryData() unconditionally sends IPSET_ATTR_PROTO (defaulting to TCP) whenever Port is set. For bitmap:port ipsets, this protocol attribute is not expected and newer kernels reject it with "invalid protocol". Decouple Protocol and Port attributes: only send IPSET_ATTR_PROTO when entry.Protocol is explicitly set. This matches the behavior of the ipset CLI tool, which does not send protocol for bitmap:port. Note: callers using hash:ip,port or hash:net,port,net must now explicitly set entry.Protocol, as the implicit TCP default is removed. Also add a bitmap:port test case to TestIpsetCreateListAddDelDestroy and fix the port/protocol assertion to handle nil Protocol. Fixes vishvananda#1054
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis change modifies ipset attribute encoding in Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
ProtocolandPortattributes inbuildEntryData()so they are sent independentlyIPSET_ATTR_PROTOwhenentry.Protocolis explicitly set (non-nil)Portwas setbitmap:porttest case for entry add/delProtocolContext
bitmap:portipsets use only port numbers without a protocol dimension. The old code unconditionally sentIPSET_ATTR_PROTO(defaulting to TCP) wheneverPortwas set, which newer kernels reject with "invalid protocol" forbitmap:portsets.This matches the behavior of the
ipsetCLI tool, which does not send the protocol attribute forbitmap:portoperations.Note: Callers using
hash:ip,portorhash:net,port,netmust now explicitly setentry.Protocol, as the implicit TCP default is removed. The kernel requires protocol for these set types and will return an error if omitted.Test plan
hash:ip,portandhash:net,port,nettests pass (they already set Protocol explicitly)bitmap:porttest case verifies entry add without Protocolgo build ./...compiles cleanlyFixes #1054
Summary by CodeRabbit