diff options
author | zvfvrv <franclombardo@gmail.com> | 2021-06-18 12:06:43 +0200 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@gmail.com> | 2021-06-30 07:38:00 +0900 |
commit | edda6899101cca31e21a2eec079dc418d5213fd4 (patch) | |
tree | 1b43fe0dc06f8ed57c82c382983f506925d16380 /internal | |
parent | 8aaeb6d33902c725e2980256c0e83a9edd853124 (diff) |
add support of the optional "SRv6 Endpoint Behavior and SID Structure" in segment type b
Diffstat (limited to 'internal')
-rw-r--r-- | internal/pkg/apiutil/attribute.go | 49 |
1 files changed, 37 insertions, 12 deletions
diff --git a/internal/pkg/apiutil/attribute.go b/internal/pkg/apiutil/attribute.go index 30737cc4..1b4a73e7 100644 --- a/internal/pkg/apiutil/attribute.go +++ b/internal/pkg/apiutil/attribute.go @@ -1830,15 +1830,26 @@ func UnmarshalSRBSID(bsid *any.Any) (bgp.TunnelEncapSubTLVInterface, error) { if err != nil { return nil, err } - return &bgp.TunnelEncapSubTLVSRv6BSID{ + result := &bgp.TunnelEncapSubTLVSRv6BSID{ TunnelEncapSubTLV: bgp.TunnelEncapSubTLV{ Type: bgp.ENCAP_SUBTLV_TYPE_SRBINDING_SID, Length: uint16(2 + b.Len()), }, Flags: 0, BSID: b, - EPBAS: &bgp.SRv6EndpointBehaviorStructure{}, - }, nil + } + + if v.EndpointBehaviorStructure != nil { + result.EPBAS = &bgp.SRv6EndpointBehaviorStructure{ + Behavior: bgp.SRBehavior(v.EndpointBehaviorStructure.Behavior), + BlockLen: uint8(v.EndpointBehaviorStructure.BlockLen), + NodeLen: uint8(v.EndpointBehaviorStructure.NodeLen), + FuncLen: uint8(v.EndpointBehaviorStructure.FuncLen), + ArgLen: uint8(v.EndpointBehaviorStructure.ArgLen), + } + } + + return result, nil default: return nil, fmt.Errorf("unknown binding sid type %+v", v) } @@ -1862,15 +1873,29 @@ func MarshalSRSegments(segs []bgp.TunnelEncapSubTLVInterface) []*any.Any { } // TODO (sbezverk) Add Type B Segment when SRv6 Binding SID gets finalized. case *bgp.SegmentTypeB: - r = &api.SegmentTypeB{ - Flags: &api.SegmentFlags{ - VFlag: s.Flags&0x80 == 0x80, - AFlag: s.Flags&0x40 == 0x40, - SFlag: s.Flags&0x20 == 0x20, - BFlag: s.Flags&0x10 == 0x10, - }, - Sid: s.SID, - //EndpointBehaviorStructure: &api.SRv6EndPointBehavior{}, + flags := &api.SegmentFlags{ + VFlag: s.Flags&0x80 == 0x80, + AFlag: s.Flags&0x40 == 0x40, + SFlag: s.Flags&0x20 == 0x20, + BFlag: s.Flags&0x10 == 0x10, + } + if s.SRv6EBS != nil { + r = &api.SegmentTypeB{ + Flags: flags, + Sid: s.SID, + EndpointBehaviorStructure: &api.SRv6EndPointBehavior{ + Behavior: api.SRv6Behavior(s.SRv6EBS.Behavior), + BlockLen: uint32(s.SRv6EBS.BlockLen), + NodeLen: uint32(s.SRv6EBS.NodeLen), + FuncLen: uint32(s.SRv6EBS.FuncLen), + ArgLen: uint32(s.SRv6EBS.ArgLen), + }, + } + } else { + r = &api.SegmentTypeB{ + Flags: flags, + Sid: s.SID, + } } default: // Unrecognize Segment type, skip it |