From 052422ec61614befa2ce462c9f0dd3278ac34845 Mon Sep 17 00:00:00 2001 From: Tobias Schmidt Date: Thu, 4 Jan 2018 12:13:02 +0100 Subject: [PATCH] Fix panic by updating github.com/ema/qdisc dependency (#778) --- vendor/github.com/ema/qdisc/get.go | 36 ++++++++++++++++++++---------- vendor/vendor.json | 6 ++--- 2 files changed, 27 insertions(+), 15 deletions(-) diff --git a/vendor/github.com/ema/qdisc/get.go b/vendor/github.com/ema/qdisc/get.go index adb822c9..b0e8430c 100644 --- a/vendor/github.com/ema/qdisc/get.go +++ b/vendor/github.com/ema/qdisc/get.go @@ -124,26 +124,34 @@ func parseTCAStats2(attr netlink.Attribute) TC_Stats2 { return stats } -func parseTC_Fq_Qd_Stats(attr netlink.Attribute) TC_Fq_Qd_Stats { +func parseTC_Fq_Qd_Stats(attr netlink.Attribute) (TC_Fq_Qd_Stats, error) { var stats TC_Fq_Qd_Stats - nested, _ := netlink.UnmarshalAttributes(attr.Data) + nested, err := netlink.UnmarshalAttributes(attr.Data) + if err != nil { + return stats, err + } + pts := []*uint64{ + &stats.GcFlows, + &stats.HighprioPackets, + &stats.TcpRetrans, + &stats.Throttled, + &stats.FlowsPlimit, + &stats.PktsTooLong, + &stats.AllocationErrors, + } for _, a := range nested { switch a.Type { case TCA_STATS_APP: - stats.GcFlows = nlenc.Uint64(a.Data[0:8]) - stats.HighprioPackets = nlenc.Uint64(a.Data[8:16]) - stats.TcpRetrans = nlenc.Uint64(a.Data[16:24]) - stats.Throttled = nlenc.Uint64(a.Data[24:32]) - stats.FlowsPlimit = nlenc.Uint64(a.Data[32:40]) - stats.PktsTooLong = nlenc.Uint64(a.Data[40:48]) - stats.AllocationErrors = nlenc.Uint64(a.Data[48:56]) + for i := 0; i < len(pts) && (i+1)*8 <= len(a.Data); i++ { + *pts[i] = nlenc.Uint64(a.Data[i*8 : (i+1)*8]) + } default: } } - return stats + return stats, nil } func getQdiscMsgs(c *netlink.Conn) ([]netlink.Message, error) { @@ -208,8 +216,10 @@ func parseMessage(msg netlink.Message) (QdiscInfo, error) { case TCA_KIND: m.Kind = nlenc.String(attr.Data) case TCA_STATS2: - s2 = parseTCAStats2(attr) - s_fq = parseTC_Fq_Qd_Stats(attr) + s_fq, err = parseTC_Fq_Qd_Stats(attr) + if err != nil { + return m, err + } if s_fq.GcFlows > 0 { m.GcFlows = s_fq.GcFlows } @@ -219,6 +229,8 @@ func parseMessage(msg netlink.Message) (QdiscInfo, error) { if s_fq.FlowsPlimit > 0 { m.FlowsPlimit = s_fq.FlowsPlimit } + + s2 = parseTCAStats2(attr) m.Bytes = s2.Bytes m.Packets = s2.Packets m.Drops = s2.Drops diff --git a/vendor/vendor.json b/vendor/vendor.json index a81a4fe4..939c5d5e 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -43,10 +43,10 @@ "versionExact": "v15" }, { - "checksumSHA1": "TcRpPaKLcq9Pk27kBcpW5lyFUHg=", + "checksumSHA1": "wPbKObbGzS/43nrskRaJVFVEW/A=", "path": "github.com/ema/qdisc", - "revision": "e2e5ae489bf8b6b1796ad921b91d5ff559414b06", - "revisionTime": "2017-05-24T21:03:24Z" + "revision": "b307c22d3ce761d351b6e6270b50195b44ee9248", + "revisionTime": "2018-01-04T10:29:28Z" }, { "checksumSHA1": "Qbh78KcLmLVoURsCp+f5xVeA/fI=",