Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions class_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,13 +163,13 @@ func classPayload(req *nl.NetlinkRequest, class Class) error {
mtu := 1600
var rtab [256]uint32
var ctab [256]uint32
tcrate := nl.TcRateSpec{Rate: uint32(htb.Rate)}
if CalcRtable(&tcrate, rtab[:], cellLog, uint32(mtu), linklayer) < 0 {
tcrate := nl.TcRateSpec{}
if CalcRtable(htb.Rate, &tcrate, rtab[:], cellLog, uint32(mtu), linklayer) < 0 {
return errors.New("HTB: failed to calculate rate table")
}
opt.Rate = tcrate
tcceil := nl.TcRateSpec{Rate: uint32(htb.Ceil)}
if CalcRtable(&tcceil, ctab[:], ccellLog, uint32(mtu), linklayer) < 0 {
tcceil := nl.TcRateSpec{}
if CalcRtable(htb.Ceil, &tcceil, ctab[:], ccellLog, uint32(mtu), linklayer) < 0 {
return errors.New("HTB: failed to calculate ceil rate table")
}
opt.Ceil = tcceil
Expand Down Expand Up @@ -311,8 +311,14 @@ func parseHtbClassData(class Class, data []syscall.NetlinkRouteAttr) (bool, erro
switch datum.Attr.Type {
case nl.TCA_HTB_PARMS:
opt := nl.DeserializeTcHtbCopt(datum.Value)
htb.Rate = uint64(opt.Rate.Rate)
htb.Ceil = uint64(opt.Ceil.Rate)
// htb.Rate may already have been set via nl.TCA_HTB_RATE64.
if htb.Rate == 0 {
htb.Rate = uint64(opt.Rate.Rate)
}
// htb.Ceil may already have been set via nl.TCA_HTB_CEIL64.
if htb.Ceil == 0 {
htb.Ceil = uint64(opt.Ceil.Rate)
}
htb.Buffer = opt.Buffer
htb.Cbuffer = opt.Cbuffer
htb.Quantum = opt.Quantum
Expand Down
4 changes: 2 additions & 2 deletions filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,12 +366,12 @@ func NewSkbEditAction() *SkbEditAction {

type PoliceAction struct {
ActionAttrs
Rate uint32 // in byte per second
Rate uint64 // in byte per second
Burst uint32 // in byte
RCellLog int
Mtu uint32
Mpu uint16 // in byte
PeakRate uint32 // in byte per second
PeakRate uint64 // in byte per second
PCellLog int
AvRate uint32 // in byte per second
Overhead uint16
Expand Down
Loading