diff options
author | Tatsushi Demachi <tdemachi@gmail.com> | 2017-02-10 20:38:17 +0900 |
---|---|---|
committer | Tatsushi Demachi <tdemachi@gmail.com> | 2017-02-10 20:57:11 +0900 |
commit | e84bf755a9740d5bca3405da494d3c4a85d30679 (patch) | |
tree | 295c691d7537bacbb00a232a91f2724b763bb20f /zebra/zapi.go | |
parent | 3703916e558624e383794b015b8f8e69422654c1 (diff) |
zebra: Process per-route MTU zebra message
Since Quagga 1.0.20160309, it implements per-route MTU handling which
adds MTU attribute to every ZEBRA_IPV4_ROUTE_ADD and
ZEBRA_IPV6_ROUTE_ADD messages. It causes "message length invalid" error
when GoBGP receives messages from Zebra and as the result, routes from
Zebra are no longer added to GoBGP.
This fixes the issue by decoding/encoding MTU attribute properly.
Now parsed MTU attribute is not used anywhere, just kept in an internal
structure.
Diffstat (limited to 'zebra/zapi.go')
-rw-r--r-- | zebra/zapi.go | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/zebra/zapi.go b/zebra/zapi.go index 25647257..dcee2d7a 100644 --- a/zebra/zapi.go +++ b/zebra/zapi.go @@ -211,6 +211,7 @@ const ( MESSAGE_IFINDEX = 0x02 MESSAGE_DISTANCE = 0x04 MESSAGE_METRIC = 0x08 + MESSAGE_MTU = 0x10 ) // Message Flags @@ -662,6 +663,7 @@ type IPRouteBody struct { Ifindexs []uint32 Distance uint8 Metric uint32 + Mtu uint32 Api API_TYPE } @@ -716,6 +718,11 @@ func (b *IPRouteBody) Serialize() ([]byte, error) { binary.BigEndian.PutUint32(bbuf, b.Metric) buf = append(buf, bbuf...) } + if b.Message&MESSAGE_MTU > 0 { + bbuf := make([]byte, 4) + binary.BigEndian.PutUint32(bbuf, b.Mtu) + buf = append(buf, bbuf...) + } return buf, nil } @@ -769,6 +776,11 @@ func (b *IPRouteBody) DecodeFromBytes(data []byte, version uint8) error { rest += 4 } + if b.Message&MESSAGE_MTU > 0 { + // mtu(4) + rest += 4 + } + if len(data[pos:]) != rest { return fmt.Errorf("message length invalid") } @@ -803,13 +815,17 @@ func (b *IPRouteBody) DecodeFromBytes(data []byte, version uint8) error { pos += 1 b.Metric = binary.BigEndian.Uint32(data[pos : pos+4]) } + if b.Message&MESSAGE_MTU > 0 { + pos += 4 + b.Mtu = binary.BigEndian.Uint32(data[pos : pos+4]) + } return nil } func (b *IPRouteBody) String() string { - s := fmt.Sprintf("type: %s, flags: %s, message: %d, prefix: %s, length: %d, nexthop: %s, distance: %d, metric: %d", - b.Type.String(), b.Flags.String(), b.Message, b.Prefix.String(), b.PrefixLength, b.Nexthops[0].String(), b.Distance, b.Metric) + s := fmt.Sprintf("type: %s, flags: %s, message: %d, prefix: %s, length: %d, nexthop: %s, distance: %d, metric: %d, mtu: %d", + b.Type.String(), b.Flags.String(), b.Message, b.Prefix.String(), b.PrefixLength, b.Nexthops[0].String(), b.Distance, b.Metric, b.Mtu) return s } |