Updated quota test,match kernel fields terminology
This commit is contained in:
parent
877d8d5d6b
commit
8297c4730e
|
@ -24,15 +24,15 @@ import (
|
||||||
|
|
||||||
// Quota defines a threshold against a number of bytes.
|
// Quota defines a threshold against a number of bytes.
|
||||||
type Quota struct {
|
type Quota struct {
|
||||||
Bytes uint64
|
Bytes uint64
|
||||||
Used uint64
|
Consumed uint64
|
||||||
Over bool
|
Over bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (q *Quota) marshal() ([]byte, error) {
|
func (q *Quota) marshal() ([]byte, error) {
|
||||||
attrs := []netlink.Attribute{
|
attrs := []netlink.Attribute{
|
||||||
{Type: unix.NFTA_QUOTA_BYTES, Data: binaryutil.BigEndian.PutUint64(q.Bytes)},
|
{Type: unix.NFTA_QUOTA_BYTES, Data: binaryutil.BigEndian.PutUint64(q.Bytes)},
|
||||||
{Type: unix.NFTA_QUOTA_CONSUMED, Data: binaryutil.BigEndian.PutUint64(q.Used)},
|
{Type: unix.NFTA_QUOTA_CONSUMED, Data: binaryutil.BigEndian.PutUint64(q.Consumed)},
|
||||||
}
|
}
|
||||||
|
|
||||||
flags := uint32(0)
|
flags := uint32(0)
|
||||||
|
@ -67,7 +67,7 @@ func (q *Quota) unmarshal(data []byte) error {
|
||||||
case unix.NFTA_QUOTA_BYTES:
|
case unix.NFTA_QUOTA_BYTES:
|
||||||
q.Bytes = ad.Uint64()
|
q.Bytes = ad.Uint64()
|
||||||
case unix.NFTA_QUOTA_CONSUMED:
|
case unix.NFTA_QUOTA_CONSUMED:
|
||||||
q.Used = ad.Uint64()
|
q.Consumed = ad.Uint64()
|
||||||
case unix.NFTA_QUOTA_FLAGS:
|
case unix.NFTA_QUOTA_FLAGS:
|
||||||
q.Over = (ad.Uint32() & unix.NFT_QUOTA_F_INV) == 1
|
q.Over = (ad.Uint32() & unix.NFT_QUOTA_F_INV) == 1
|
||||||
}
|
}
|
||||||
|
|
|
@ -4827,9 +4827,9 @@ func TestQuota(t *testing.T) {
|
||||||
Exprs: []expr.Any{
|
Exprs: []expr.Any{
|
||||||
// [ quota bytes 6 consumed 0 flags 1 ]
|
// [ quota bytes 6 consumed 0 flags 1 ]
|
||||||
&expr.Quota{
|
&expr.Quota{
|
||||||
Bytes: uint64(6),
|
Bytes: 6,
|
||||||
Used: uint64(0),
|
Consumed: 0,
|
||||||
Over: true,
|
Over: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue