From 8cca88010f0be826510d71eeb89d34459aaf2003 Mon Sep 17 00:00:00 2001 From: Vishvananda Abrams Date: Wed, 17 Jun 2020 12:37:15 -0700 Subject: [PATCH] Fixes Issue #509 more generically The first fix #512 apparently didn't solve all cases. This generically skips values that are null to solve the problem. Also closes #548. --- link_linux.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/link_linux.go b/link_linux.go index 8f085341..cac3c43d 100644 --- a/link_linux.go +++ b/link_linux.go @@ -2139,6 +2139,13 @@ func parseVlanData(link Link, data []syscall.NetlinkRouteAttr) { func parseVxlanData(link Link, data []syscall.NetlinkRouteAttr) { vxlan := link.(*Vxlan) for _, datum := range data { + // NOTE(vish): Apparently some messages can be sent with no value. + // We special case GBP here to not change existing + // functionality. It appears that GBP sends a datum.Value + // of null. + if len(datum.Value) == 0 && datum.Attr.Type != nl.IFLA_VXLAN_GBP { + continue + } switch datum.Attr.Type { case nl.IFLA_VXLAN_ID: vxlan.VxlanId = int(native.Uint32(datum.Value[0:4])) @@ -2175,11 +2182,7 @@ func parseVxlanData(link Link, data []syscall.NetlinkRouteAttr) { case nl.IFLA_VXLAN_GBP: vxlan.GBP = true case nl.IFLA_VXLAN_FLOWBASED: - // NOTE(vish): Apparently this message can be sent with no value. - // Unclear if the others be sent that way as well. - if len(datum.Value) > 0 { - vxlan.FlowBased = int8(datum.Value[0]) != 0 - } + vxlan.FlowBased = int8(datum.Value[0]) != 0 case nl.IFLA_VXLAN_AGEING: vxlan.Age = int(native.Uint32(datum.Value[0:4])) vxlan.NoAge = vxlan.Age == 0