From c750a61f1836d48aacb1c74deafb05cfb549eb92 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Abrams Date: Tue, 13 Dec 2016 18:04:10 -0800 Subject: [PATCH] Set rates higher than 32bit integers --- nl/nl_linux.go | 7 +++++++ qdisc_linux.go | 4 +++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/nl/nl_linux.go b/nl/nl_linux.go index d46fff2..ab41fa1 100644 --- a/nl/nl_linux.go +++ b/nl/nl_linux.go @@ -656,6 +656,13 @@ func Uint32Attr(v uint32) []byte { return bytes } +func Uint64Attr(v uint64) []byte { + native := NativeEndian() + bytes := make([]byte, 8) + native.PutUint64(bytes, v) + return bytes +} + func ParseRouteAttr(b []byte) ([]syscall.NetlinkRouteAttr, error) { var attrs []syscall.NetlinkRouteAttr for len(b) >= syscall.SizeofRtAttr { diff --git a/qdisc_linux.go b/qdisc_linux.go index 1bb4856..77ce5b8 100644 --- a/qdisc_linux.go +++ b/qdisc_linux.go @@ -168,11 +168,13 @@ func qdiscPayload(req *nl.NetlinkRequest, qdisc Qdisc) error { options = nl.NewRtAttr(nl.TCA_OPTIONS, tcmap.Serialize()) } else if tbf, ok := qdisc.(*Tbf); ok { opt := nl.TcTbfQopt{} - // TODO: handle rate > uint32 opt.Rate.Rate = uint32(tbf.Rate) opt.Limit = tbf.Limit opt.Buffer = tbf.Buffer nl.NewRtAttrChild(options, nl.TCA_TBF_PARMS, opt.Serialize()) + if tbf.Rate >= uint64(1<<32) { + nl.NewRtAttrChild(options, nl.TCA_TBF_RATE64, nl.Uint64Attr(tbf.Rate)) + } } else if htb, ok := qdisc.(*Htb); ok { opt := nl.TcHtbGlob{} opt.Version = htb.Version