summaryrefslogtreecommitdiffhomepage
path: root/internal/pkg/zebra
diff options
context:
space:
mode:
authorHitoshi Irino <irino@sfc.wide.ad.jp>2019-02-02 23:20:01 +0900
committerHitoshi Irino <irino@sfc.wide.ad.jp>2019-02-02 23:20:01 +0900
commitd6bd1e561b9414b00f54e2972b1c7970ff5467b6 (patch)
tree96f4e4dcf90f678b9d1194b31078f82789f1b161 /internal/pkg/zebra
parent1d8ffa231acf1124a431955deb4d7d692a4b009b (diff)
Fix bug: processing MPLS label in nexthop update message
Diffstat (limited to 'internal/pkg/zebra')
-rw-r--r--internal/pkg/zebra/zapi.go18
1 files changed, 11 insertions, 7 deletions
diff --git a/internal/pkg/zebra/zapi.go b/internal/pkg/zebra/zapi.go
index 7a069530..330034ec 100644
--- a/internal/pkg/zebra/zapi.go
+++ b/internal/pkg/zebra/zapi.go
@@ -1690,10 +1690,14 @@ type Nexthop struct {
}
func (n *Nexthop) String() string {
- s := fmt.Sprintf(
- "type: %s, gate: %s, ifindex: %d",
- n.Type.String(), n.Gate.String(), n.Ifindex)
- return s
+ s := make([]string, 0)
+ s = append(s, fmt.Sprintf(
+ "type: %s, gate: %s, ifindex: %d, vrfid: %d, labelnum: %d",
+ n.Type.String(), n.Gate.String(), n.Ifindex, n.VrfId, n.LabelNum))
+ for i := uint8(0); i < n.LabelNum; i++ {
+ s = append(s, fmt.Sprintf("label: %d", n.MplsLabels[i]))
+ }
+ return strings.Join(s, ", ")
}
type Prefix struct {
@@ -2229,13 +2233,13 @@ func decodeNexthopsFromBytes(nexthops *[]Nexthop, data []byte, family uint8, ver
offset += 4
}
if version >= 5 {
- nexthop.LabelNum = data[offset]
+ nexthop.LabelNum = uint8(data[offset])
offset += 1
if nexthop.LabelNum > MPLS_MAX_LABEL {
nexthop.LabelNum = MPLS_MAX_LABEL
}
- var n uint8
- for ; n < nexthop.LabelNum; n++ {
+ nexthop.MplsLabels = make([]uint32, nexthop.LabelNum)
+ for n := uint8(0); n < nexthop.LabelNum; n++ {
nexthop.MplsLabels[n] = binary.BigEndian.Uint32(data[offset : offset+4])
offset += 4
}