MCPcopy
hub / github.com/osrg/gobgp / api2apiutilPath

Function api2apiutilPath

pkg/server/grpc_server.go:606–638  ·  view source on GitHub ↗
(path *api.Path)

Source from the content-addressed store, hash-verified

604}
605
606func api2apiutilPath(path *api.Path) (*apiutil.Path, error) {
607 nlri, err := apiutil.GetNativeNlri(path)
608 if err != nil {
609 return nil, fmt.Errorf("invalid nlri: %w", err)
610 }
611 attrs, err := apiutil.GetNativePathAttributes(path)
612 if err != nil {
613 return nil, fmt.Errorf("invalid path attributes: %w", err)
614 }
615 // source is optional
616 src, _ := netip.ParseAddr(path.SourceId)
617 neighbor, _ := netip.ParseAddr(path.NeighborIp)
618 p := &apiutil.Path{
619 Family: bgp.NewFamily(uint16(path.Family.Afi), uint8(path.Family.Safi)),
620 Nlri: nlri,
621 Attrs: attrs,
622 Age: path.Age.GetSeconds(),
623 Best: path.Best,
624 Stale: path.Stale,
625 Withdrawal: path.IsWithdraw,
626 PeerASN: path.SourceAsn,
627 PeerID: src,
628 PeerAddress: neighbor,
629 IsFromExternal: path.IsFromExternal,
630 NoImplicitWithdraw: path.NoImplicitWithdraw,
631 LocalID: path.LocalIdentifier,
632 RemoteID: path.Identifier,
633 }
634 if p.PeerASN != 0 && !p.PeerID.IsValid() {
635 return nil, fmt.Errorf("source ID must be set correctly %v", p.PeerID)
636 }
637 return p, nil
638}
639
640func (s *server) AddPath(ctx context.Context, r *api.AddPathRequest) (*api.AddPathResponse, error) {
641 if r.Path == nil {

Callers 4

TestAddBogusPathFunction · 0.85
AddPathMethod · 0.85
DeletePathMethod · 0.85
mustApi2apiutilPathFunction · 0.85

Calls 3

GetNativeNlriFunction · 0.92
GetNativePathAttributesFunction · 0.92
NewFamilyFunction · 0.92

Tested by 2

TestAddBogusPathFunction · 0.68
mustApi2apiutilPathFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…