AddSet silently fails (!) when adding IP addresses with too many bytes (without To4() call)
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Stale
- Tech stack
- go, linux
- Domain
- networking
Research direction
Start by running the issue's Go reproducer and checking the result of AddSet with net.ParseIP("8.8.8.8"). Trace the AddSet entry point and its handling of IP address byte lengths, then compare the behavior with an address passed through To4(). Done means the oversized representation no longer causes a silent failure, with the behavior covered by a regression test.
Written by the indexing model from the issue text.
Description
Hi am facing trouble when using this package i can't load my rule this is my code :
package main
import (
"fmt"
"log"
"net"
"github.com/google/nftables"
"github.com/google/nftables/expr"
)
func main() {
c := &nftables.Conn{}
// Basic boilerplate; create a table & chain.
table := &nftables.Table{
Family: nftables.TableFamilyIPv4,
Name: "ip_filter",
}
table = c.AddTable(table)
myChain := c.AddChain(&nftables.Chain{
Name: "filter_chain",
Table: table,
Type: nftables.ChainTypeFilter,
Hooknum: nftables.ChainHookInput,
Priority: nftables.ChainPriorityFilter,
})
set := &nftables.Set{
Name: "whitelist",
Table: table,
KeyType: nftables.TypeIPAddr, // our keys are IPv4 addresses
}
// Create the set with a bunch of initial values.
if err := c.AddSet(set, []nftables.SetElement{
{Key: net.ParseIP("8.8.8.8")},
}); err != nil {
log.Fatal(err.Error())
}
c.AddRule(&nftables.Rule{
Table: table,
Chain: myChain,
Exprs: []expr.Any{
// [ payload load 4b @ network header + 16 => reg 1 ]
&expr.Payload{
DestRegister: 1,
Base: expr.PayloadBaseNetworkHeader,
Offset: 16,
Len: 4,
},
// [ lookup reg 1 set whitelist ]
&expr.Lookup{
SourceRegister: 1,
SetName: set.Name,
SetID: set.ID,
},
//[ immediate reg 0 drop ]
&expr.Verdict{
Kind: expr.VerdictDrop,
},
},
})
if err := c.Flush(); err != nil {
log.Fatal(err.Error())
}
rules, _ := c.GetRule(table, myChain)
fmt.Println(rules)
}
after executing my code and run the following command : sudo nft list ruleset i expect to found my configured config but i found nothing. is this a compatibility problem ?
- Dominant language
- Go
- Stars
- 1.4k
- Forks
- 187
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from google/nftables
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
-
Multiple Netlink Decode Paths Can Panic on Malformed or Undersized InputPossibly taken @vulragrag-star claimed this 30 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 68/100
-
New Tag release.Open
Difficulty 3/5 1-2 days Newbie friendliness 45/100
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
Similar issues
-
area/gateway kind/bug
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
vllm-project/aibrix#3226 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
gencrl: serial numbers that fail to parse are added to the CRL as 0 or a partial valuePossibly taken @sebxt claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
cloudflare/cfssl#1460 ·
Maintainers usually reply within 2 days
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 75/100
ironcore-dev/cloud-hypervisor-provider#210 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
OpenTollGate/tollgate-module-basic-go#1027 ·
Maintainers usually reply within 1 day