add set element expires field (#223)

This commit is contained in:
Liu Xiangchao 2023-04-21 14:26:50 +08:00 committed by GitHub
parent 1510be9a55
commit a58e58ca6b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

7
set.go
View File

@ -277,6 +277,9 @@ type SetElement struct {
VerdictData *expr.Verdict
// To support aging of set elements
Timeout time.Duration
// Life left of the "timeout" elements
Expires time.Duration
}
func (s *SetElement) decode() func(b []byte) error {
@ -308,7 +311,9 @@ func (s *SetElement) decode() func(b []byte) error {
flags := ad.Uint32()
s.IntervalEnd = (flags & unix.NFT_SET_ELEM_INTERVAL_END) != 0
case unix.NFTA_SET_ELEM_TIMEOUT:
s.Timeout = time.Duration(time.Millisecond * time.Duration(ad.Uint64()))
s.Timeout = time.Millisecond * time.Duration(ad.Uint64())
case unix.NFTA_SET_ELEM_EXPIRATION:
s.Expires = time.Millisecond * time.Duration(ad.Uint64())
}
}
return ad.Err()