summaryrefslogtreecommitdiffhomepage
path: root/internal
diff options
context:
space:
mode:
authorMikael Magnusson <mikma@users.sourceforge.net>2018-09-01 21:51:21 +0000
committerFUJITA Tomonori <fujita.tomonori@gmail.com>2021-01-23 09:03:18 +0900
commit4c8ab0d4b5090b5b9ca115bdeb3dd8e1a627f5e2 (patch)
treef688d7e0bd48816b92e70c92830d4c5a16c05310 /internal
parent89e404be46cfa30fdb994464a1c8e4fd93d3407f (diff)
support UDP destination port sub-TLV
As specified in draft-ietf-idr-tunnel-encaps. Signed-off-by: Mikael Magnusson <mikma@users.sourceforge.net>
Diffstat (limited to 'internal')
-rw-r--r--internal/pkg/apiutil/attribute.go6
-rw-r--r--internal/pkg/apiutil/attribute_test.go5
2 files changed, 11 insertions, 0 deletions
diff --git a/internal/pkg/apiutil/attribute.go b/internal/pkg/apiutil/attribute.go
index f440772b..0e4eecae 100644
--- a/internal/pkg/apiutil/attribute.go
+++ b/internal/pkg/apiutil/attribute.go
@@ -1176,6 +1176,10 @@ func NewTunnelEncapAttributeFromNative(a *bgp.PathAttributeTunnelEncap) *api.Tun
subTlv = &api.TunnelEncapSubTLVColor{
Color: sv.Color,
}
+ case *bgp.TunnelEncapSubTLVUDPDestPort:
+ subTlv = &api.TunnelEncapSubTLVUDPDestPort{
+ Port: uint32(sv.UDPDestPort),
+ }
case *bgp.TunnelEncapSubTLVUnknown:
subTlv = &api.TunnelEncapSubTLVUnknown{
Type: uint32(sv.Type),
@@ -1658,6 +1662,8 @@ func unmarshalAttribute(an *any.Any) (bgp.PathAttributeInterface, error) {
subTlv = bgp.NewTunnelEncapSubTLVProtocol(uint16(sv.Protocol))
case *api.TunnelEncapSubTLVColor:
subTlv = bgp.NewTunnelEncapSubTLVColor(sv.Color)
+ case *api.TunnelEncapSubTLVUDPDestPort:
+ subTlv = bgp.NewTunnelEncapSubTLVUDPDestPort(uint16(sv.Port))
case *api.TunnelEncapSubTLVSRPreference:
subTlv = bgp.NewTunnelEncapSubTLVSRPreference(sv.Flags, sv.Preference)
case *api.TunnelEncapSubTLVSRPriority:
diff --git a/internal/pkg/apiutil/attribute_test.go b/internal/pkg/apiutil/attribute_test.go
index a3eff1a7..6c694030 100644
--- a/internal/pkg/apiutil/attribute_test.go
+++ b/internal/pkg/apiutil/attribute_test.go
@@ -1428,6 +1428,11 @@ func Test_TunnelEncapAttribute(t *testing.T) {
})
assert.Nil(err)
subTlvs = append(subTlvs, a)
+ a, err = ptypes.MarshalAny(&api.TunnelEncapSubTLVUDPDestPort{
+ Port: 400,
+ })
+ assert.Nil(err)
+ subTlvs = append(subTlvs, a)
a, err = ptypes.MarshalAny(&api.TunnelEncapSubTLVUnknown{
Type: 0xff, // Max of uint8
Value: []byte{0x55, 0x66, 0x77, 0x88},