Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CalcRtable array parameter bug #259

Merged
merged 1 commit into from
Nov 13, 2017
Merged

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

@@ -370,14 +370,6 @@ func TestFilterFwAddDel(t *testing.T) {
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
@@ -141,12 +141,12 @@ func classPayload(req *nl.NetlinkRequest, class Class) error {
var rtab [256]uint32
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
@@ -552,7 +552,7 @@ func AdjustSize(sz uint, mpu uint, linklayer int) uint {
}
}

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
@@ -567,7 +567,7 @@ func CalcRtable(rate *nl.TcRateSpec, rtab [256]uint32, cellLog int, mtu uint32,
}
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
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 {
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