Skip to content

Commit

Permalink
Fix how to get src, dst of SR Policy from state report
Browse files Browse the repository at this point in the history
  • Loading branch information
Motok1 committed Jun 10, 2024
1 parent 26d5e2b commit d239fce
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
9 changes: 9 additions & 0 deletions pkg/packet/pcep/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -1287,6 +1287,15 @@ func (o *AssociationObject) Preference() uint32 {
return 0
}

func (o *AssociationObject) Endpoint() netip.Addr {
for _, tlv := range o.TLVs {
if t, ok := tlv.(*ExtendedAssociationID); ok {
return t.Endpoint
}
}
return netip.Addr{}
}

// VENDOR-INFORMATION Object (RFC7470 4)
const (
OT_VENDOR_SPECIFIC_CONSTRAINTS uint8 = 1
Expand Down
11 changes: 9 additions & 2 deletions pkg/server/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,12 +377,19 @@ func (ss *Session) RegisterSRPolicy(sr pcep.StateReport) {
}
} else {
// create
var src, dst netip.Addr
if src = sr.LspObject.SrcAddr; !src.IsValid() {
src = sr.AssociationObject.AssocSrc
}
if dst = sr.LspObject.DstAddr; !dst.IsValid() {
dst = sr.AssociationObject.Endpoint()
}
p := table.NewSRPolicy(
sr.LspObject.PlspID,
sr.LspObject.Name,
sr.EroObject.ToSegmentList(),
sr.LspObject.SrcAddr,
sr.LspObject.DstAddr,
src,
dst,
color,
preference,
lspID,
Expand Down

0 comments on commit d239fce

Please sign in to comment.