Fix nftables interval end when range hits max address
When To() is 255.255.255.255 / ffff:...:ffff, Next() is invalid. Using From() as the end key duplicated the start element and caused EEXIST. Omit the end element so the half-open interval covers through max. Fixes SagerNet/sing-box#4316
This commit is contained in:
parent
8048acde1e
commit
7954dd6e20
1 changed files with 7 additions and 8 deletions
|
|
@ -149,17 +149,16 @@ func nftablesCreateIPSet(
|
|||
if (family == nftables.TableFamilyIPv4) != rr.From().Is4() {
|
||||
continue
|
||||
}
|
||||
endAddr := rr.To().Next()
|
||||
if !endAddr.IsValid() {
|
||||
endAddr = rr.From()
|
||||
}
|
||||
setElements = append(setElements, nftables.SetElement{
|
||||
Key: rr.From().AsSlice(),
|
||||
})
|
||||
setElements = append(setElements, nftables.SetElement{
|
||||
Key: endAddr.AsSlice(),
|
||||
IntervalEnd: true,
|
||||
})
|
||||
endAddr := rr.To().Next()
|
||||
if endAddr.IsValid() {
|
||||
setElements = append(setElements, nftables.SetElement{
|
||||
Key: endAddr.AsSlice(),
|
||||
IntervalEnd: true,
|
||||
})
|
||||
}
|
||||
}
|
||||
if appendDefault && len(setElements) == 0 {
|
||||
if family == nftables.TableFamilyIPv4 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue