Skip to content

Fix CalcRtable array parameter bug#259

Merged
aboch merged 1 commit intovishvananda:masterfrom
yandd:master
Nov 13, 2017
Merged

Fix CalcRtable array parameter bug#259
aboch merged 1 commit intovishvananda:masterfrom
yandd:master

Conversation

@yandd
Copy link
Contributor

@yandd yandd commented Aug 21, 2017

No description provided.

@yandd
Copy link
Contributor Author

yandd commented Aug 22, 2017

@vishvananda

@tfukushima tfukushima mentioned this pull request Aug 28, 2017
@vishvananda
Copy link
Owner

CI is now fixed, but it looks like you need to update the test as well.

@yandd
Copy link
Contributor Author

yandd commented Sep 7, 2017

@vishvananda parseFwData cannot get TCA_POLICE_RATE or TCA_POLICE_PEAKRATE data, so TestFilterFwAddDel cannot get success. I cannot solve this problem

@yandd
Copy link
Contributor Author

yandd commented Sep 27, 2017

https://github.com/torvalds/linux/blob/master/net/sched/act_police.c#L265

Linux kernel does not return "TCA_POLICE_RATE" in tcf_act_police_dump, so need remove the test about rtab.

@vishvananda

if fw.Police.Rate.Rate != filter.Police.Rate.Rate {
t.Fatal("Police Rate doesn't match")
}
for i := range fw.Rtab {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So this test was passing because the two arrays fw.Rtab and filter.Rtab were actually empty because of the bug, correct ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

@aboch
Copy link
Collaborator

aboch commented Nov 10, 2017

@yandd Please squash the two commits in one (they are about the same thing) and sign the commit.

class_linux.go Outdated
var ctab [256]uint32
tcrate := nl.TcRateSpec{Rate: uint32(htb.Rate)}
if CalcRtable(&tcrate, rtab, cellLog, uint32(mtu), linklayer) < 0 {
if CalcRtable(&tcrate, &rtab, cellLog, uint32(mtu), linklayer) < 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of passing array by reference better use slices: rtab[:]

filter_linux.go Outdated
}

func CalcRtable(rate *nl.TcRateSpec, rtab [256]uint32, cellLog int, mtu uint32, linklayer int) int {
func CalcRtable(rate *nl.TcRateSpec, rtab *[256]uint32, cellLog int, mtu uint32, linklayer int) int {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[]uint32

filter_linux.go Outdated
for i := 0; i < 256; i++ {
sz = AdjustSize(uint((i+1)<<uint32(cellLog)), uint(mpu), linklayer)
rtab[i] = uint32(Xmittime(uint64(bps), uint32(sz)))
(*rtab)[i] = uint32(Xmittime(uint64(bps), uint32(sz)))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rtab[i]

class_linux.go Outdated
opt.Rate = tcrate
tcceil := nl.TcRateSpec{Rate: uint32(htb.Ceil)}
if CalcRtable(&tcceil, ctab, ccellLog, uint32(mtu), linklayer) < 0 {
if CalcRtable(&tcceil, &ctab, ccellLog, uint32(mtu), linklayer) < 0 {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

@fcrisciani
Copy link
Collaborator

LGTM

@aboch
Copy link
Collaborator

aboch commented Nov 13, 2017

Thanks @yandd @fcrisciani LGTM as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants