Documentation ¶
Index ¶
- Constants
- func FilterLoop(beacon Beacon, next addr.IA, allowIsdLoop bool) error
- type Beacon
- type BeaconOrErr
- type CorePolicies
- type CoreStore
- func (s *CoreStore) BeaconsToPropagate(ctx context.Context) (<-chan BeaconOrErr, error)
- func (s *CoreStore) Close() error
- func (s *CoreStore) DeleteExpiredBeacons(ctx context.Context) (int, error)
- func (s *CoreStore) DeleteExpiredRevocations(ctx context.Context) (int, error)
- func (s *CoreStore) DeleteRevocation(ctx context.Context, ia addr.IA, ifid common.IFIDType) error
- func (s *CoreStore) InsertBeacon(ctx context.Context, beacon Beacon) (InsertStats, error)
- func (s *CoreStore) InsertRevocations(ctx context.Context, revocations ...*path_mgmt.SignedRevInfo) error
- func (s *CoreStore) MaxExpTime(policyType PolicyType) spath.ExpTimeType
- func (s *CoreStore) PreFilter(beacon Beacon) error
- func (s *CoreStore) SegmentsToRegister(ctx context.Context, segType proto.PathSegType) (<-chan BeaconOrErr, error)
- func (s *CoreStore) UpdatePolicy(ctx context.Context, policy Policy) error
- type DB
- type DBRead
- type DBReadWrite
- type DBWrite
- type Filter
- type HPGroup
- type HPPolicies
- type HPPolicy
- type HPRegistration
- type InsertStats
- type MetricsDB
- func (e MetricsDB) AllRevocations(ctx context.Context) (<-chan RevocationOrErr, error)
- func (e MetricsDB) BeaconSources(ctx context.Context) ([]addr.IA, error)
- func (db *MetricsDB) BeginTransaction(ctx context.Context, opts *sql.TxOptions) (Transaction, error)
- func (e MetricsDB) CandidateBeacons(ctx context.Context, setSize int, usage Usage, src addr.IA) (<-chan BeaconOrErr, error)
- func (db *MetricsDB) Close() error
- func (e MetricsDB) DeleteExpiredBeacons(ctx context.Context, now time.Time) (int, error)
- func (e MetricsDB) DeleteExpiredRevocations(ctx context.Context, now time.Time) (int, error)
- func (e MetricsDB) DeleteRevocation(ctx context.Context, ia addr.IA, ifid common.IFIDType) error
- func (e MetricsDB) DeleteRevokedBeacons(ctx context.Context, now time.Time) (int, error)
- func (e MetricsDB) InsertBeacon(ctx context.Context, beacon Beacon, usage Usage) (InsertStats, error)
- func (e MetricsDB) InsertRevocation(ctx context.Context, revocation *path_mgmt.SignedRevInfo) error
- func (db *MetricsDB) SetMaxIdleConns(maxIdleConns int)
- func (db *MetricsDB) SetMaxOpenConns(maxOpenConns int)
- type MetricsTransaction
- func (e MetricsTransaction) AllRevocations(ctx context.Context) (<-chan RevocationOrErr, error)
- func (e MetricsTransaction) BeaconSources(ctx context.Context) ([]addr.IA, error)
- func (e MetricsTransaction) CandidateBeacons(ctx context.Context, setSize int, usage Usage, src addr.IA) (<-chan BeaconOrErr, error)
- func (tx *MetricsTransaction) Commit() error
- func (e MetricsTransaction) DeleteExpiredBeacons(ctx context.Context, now time.Time) (int, error)
- func (e MetricsTransaction) DeleteExpiredRevocations(ctx context.Context, now time.Time) (int, error)
- func (e MetricsTransaction) DeleteRevocation(ctx context.Context, ia addr.IA, ifid common.IFIDType) error
- func (e MetricsTransaction) DeleteRevokedBeacons(ctx context.Context, now time.Time) (int, error)
- func (e MetricsTransaction) InsertBeacon(ctx context.Context, beacon Beacon, usage Usage) (InsertStats, error)
- func (e MetricsTransaction) InsertRevocation(ctx context.Context, revocation *path_mgmt.SignedRevInfo) error
- func (tx *MetricsTransaction) Rollback() error
- type Policies
- type Policy
- type PolicyType
- type RegPolicy
- type RevocationOrErr
- type Store
- func (s *Store) BeaconsToPropagate(ctx context.Context) (<-chan BeaconOrErr, error)
- func (s *Store) Close() error
- func (s *Store) DeleteExpiredBeacons(ctx context.Context) (int, error)
- func (s *Store) DeleteExpiredRevocations(ctx context.Context) (int, error)
- func (s *Store) DeleteRevocation(ctx context.Context, ia addr.IA, ifid common.IFIDType) error
- func (s *Store) InsertBeacon(ctx context.Context, beacon Beacon) (InsertStats, error)
- func (s *Store) InsertRevocations(ctx context.Context, revocations ...*path_mgmt.SignedRevInfo) error
- func (s *Store) MaxExpTime(policyType PolicyType) spath.ExpTimeType
- func (s *Store) PreFilter(beacon Beacon) error
- func (s *Store) SegmentsToRegister(ctx context.Context, segType proto.PathSegType) (<-chan BeaconOrErr, error)
- func (s *Store) UpdatePolicy(ctx context.Context, policy Policy) error
- type Transaction
- type Usage
Constants ¶
const ( // ErrReadingRows is the error message in case we fail to read more from // the database. ErrReadingRows common.ErrMsg = "Failed to read rows" // ErrParse is the error message in case the parsing a db entry fails. ErrParse common.ErrMsg = "Failed to parse entry" )
const ( // DefaultBestSetSize is the default BestSetSize value. DefaultBestSetSize = 5 // DefaultCandidateSetSize is the default CandidateSetSize value. DefaultCandidateSetSize = 100 // DefaultMaxHopsLength is the default MaxHopsLength value. DefaultMaxHopsLength = 10 // DefaultMaxExpTime is the default MaxExpTime value. DefaultMaxExpTime = spath.DefaultHopFExpiry )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Beacon ¶
type Beacon struct { // Segment is the path segment. Segment *seg.PathSegment // InIfId is the interface the beacon is received on. InIfId common.IFIDType }
Beacon consists of the path segment and the interface it was received on.
type BeaconOrErr ¶
BeaconOrErr contains a read-only beacon or an error.
type CorePolicies ¶
type CorePolicies struct { // Prop is the propagation policy. Prop Policy // CoreReg is the core segment policy. CoreReg Policy }
CorePolicies keeps track of all policies for a core beacon store.
func (*CorePolicies) Filter ¶
func (p *CorePolicies) Filter(beacon Beacon) error
Filter applies all filters and returns an error if all of them filter the beacon. If at least one does not filter, no error is returned.
func (*CorePolicies) InitDefaults ¶
func (p *CorePolicies) InitDefaults()
InitDefaults sets the defaults for all policies.
func (*CorePolicies) Usage ¶
func (p *CorePolicies) Usage(beacon Beacon) Usage
Usage returns the allowed usage of the beacon based on all available policies. For missing policies, the usage is not permitted.
func (*CorePolicies) Validate ¶
func (p *CorePolicies) Validate() error
Validate checks that each policy is of the correct type.
type CoreStore ¶
type CoreStore struct {
// contains filtered or unexported fields
}
CoreStore provides abstracted access to the beacon database in a core AS. The store helps inserting beacons and revocations, and selects the best beacons for given purposes based on the configured policies. It should not be used in a non-core AS.
func NewCoreBeaconStore ¶
func NewCoreBeaconStore(policies CorePolicies, db DB) (*CoreStore, error)
NewCoreBeaconStore creates a new beacon store for a non-core AS.
func (*CoreStore) BeaconsToPropagate ¶
func (s *CoreStore) BeaconsToPropagate(ctx context.Context) (<-chan BeaconOrErr, error)
BeaconsToPropagate returns a channel that provides all beacons to propagate at the time of the call. The selection is based on the configured propagation policy.
func (*CoreStore) Close ¶
func (s *CoreStore) Close() error
Close closes the store and the underlying database connection.
func (*CoreStore) DeleteExpiredBeacons ¶
DeleteExpiredBeacons deletes expired Beacons from the store.
func (*CoreStore) DeleteExpiredRevocations ¶
DeleteExpiredRevocations deletes expired Revocations from the store.
func (*CoreStore) DeleteRevocation ¶
DeleteRevocation deletes the revocation from the BeaconDB.
func (*CoreStore) InsertBeacon ¶
func (s *CoreStore) InsertBeacon(ctx context.Context, beacon Beacon) (InsertStats, error)
InsertBeacon adds a verified beacon to the store. Beacon that contains revoked interfaces is inserted and does not cause an error. If the beacon does not match any policy, it is not inserted, but does not cause an error.
func (*CoreStore) InsertRevocations ¶
func (s *CoreStore) InsertRevocations(ctx context.Context, revocations ...*path_mgmt.SignedRevInfo) error
InsertRevocations inserts the revocation into the BeaconDB. The provided revocation must be verified by the caller.
func (*CoreStore) MaxExpTime ¶
func (s *CoreStore) MaxExpTime(policyType PolicyType) spath.ExpTimeType
MaxExpTime returns the segment maximum expiration time for the given policy.
func (*CoreStore) PreFilter ¶
PreFilter indicates whether the beacon will be filtered on insert by returning an error with the reason. This allows the caller to drop ignored beacons.
func (*CoreStore) SegmentsToRegister ¶
func (s *CoreStore) SegmentsToRegister(ctx context.Context, segType proto.PathSegType) ( <-chan BeaconOrErr, error)
SegmentsToRegister returns a channel that provides all beacons to register at the time of the call. The selections is based on the configured policy for the requested segment type.
type DB ¶
type DB interface { DBReadWrite BeginTransaction(ctx context.Context, opts *sql.TxOptions) (Transaction, error) db.LimitSetter io.Closer }
DB defines the interface that all beacon DB backends have to implement.
type DBRead ¶
type DBRead interface { // CandidateBeacons returns up to setSize beacons that are allowed for the // given usage. The result channel either carries beacons or errors. The // beacons in the channel are ordered by segment length from shortest to // longest. The channel must be drained, since the db might spawn go routines // to fill the channel. CandidateBeacons(ctx context.Context, setSize int, usage Usage, src addr.IA) ( <-chan BeaconOrErr, error) // BeaconSources returns all source ISD-AS of the beacons in the database. BeaconSources(ctx context.Context) ([]addr.IA, error) // AllRevocations returns all revocations in the database as a channel. The // result channel either carries revocations or errors. The error can // either be ErrReadingRows or ErrParse. After a ErrReadingRows occurs the // channel is closed and the result might be incomplete. The channel must // be drained, since the implementation might spawn go routines to fill the // channel. AllRevocations(ctx context.Context) (<-chan RevocationOrErr, error) }
DBRead defines all read operations of the beacon DB.
type DBReadWrite ¶
DBReadWrite defines all read an write operations of the beacon DB.
type DBWrite ¶
type DBWrite interface { InsertBeacon(ctx context.Context, beacon Beacon, usage Usage) (InsertStats, error) DeleteExpiredBeacons(ctx context.Context, now time.Time) (int, error) DeleteRevokedBeacons(ctx context.Context, now time.Time) (int, error) InsertRevocation(ctx context.Context, revocation *path_mgmt.SignedRevInfo) error DeleteRevocation(ctx context.Context, ia addr.IA, ifid common.IFIDType) error DeleteExpiredRevocations(ctx context.Context, now time.Time) (int, error) }
DBWrite defines all write operations of the beacon DB.
type Filter ¶
type Filter struct { // MaxHopsLength is the maximum number of hops a segment can have. MaxHopsLength int `yaml:"MaxHopsLength"` // ASBlackList contains all ASes that may not appear in a segment. AsBlackList []addr.AS `yaml:"AsBlackList"` // IsdBlackList contains all ISD that may not appear in a segment. IsdBlackList []addr.ISD `yaml:"IsdBlackList"` // AllowIsdLoop indicates whether ISD loops should not be filtered. AllowIsdLoop *bool `yaml:"AllowIsdLoop"` }
Filter filters beacons.
func (*Filter) InitDefaults ¶
func (f *Filter) InitDefaults()
InitDefaults initializes the default values for unset fields.
type HPGroup ¶
type HPGroup struct { GroupCfgPath string `yaml:"CfgFilePath"` Group hiddenpath.Group }
HPGroup holds a hidden path group
type HPPolicies ¶
type HPPolicies struct { DefaultAction string `yaml:"DefaultAction"` HiddenAndPublic bool `yaml:"HiddenAndPublic"` Policies map[common.IFIDType]HPPolicy `yaml:"Policies"` }
HPPolicies holds all the hidden path registration policies for a BS
type HPPolicy ¶
type HPPolicy struct { Public RegPolicy `yaml:"PS"` Hidden map[hiddenpath.GroupId]RegPolicy `yaml:"HPS"` }
HPPolicy holds the public and hidden registration policies for an interface
type HPRegistration ¶
type HPRegistration struct { HPPolicies HPPolicies `yaml:"SegmentRegistration"` HPGroups map[hiddenpath.GroupId]*HPGroup `yaml:"HPGroups"` }
HPRegistration holds all the information required for hidden path segment registrations
func LoadHPRegFromYaml ¶
func LoadHPRegFromYaml(path string) (*HPRegistration, error)
LoadHPRegFromYaml loads the HPRegistration from a yaml file and performs validation. Hidden path groups pointed to by config file paths are loaded.
func ParseHPRegYaml ¶
func ParseHPRegYaml(b common.RawBytes) (*HPRegistration, error)
ParseHPRegYaml parses the registration policies in yaml format and performs validation. Hidden path groups pointed to by config file paths are loaded.
func (*HPRegistration) Validate ¶
func (hp *HPRegistration) Validate() error
Validate verifies that for all hidden path policies the referenced Group exists and checks if all GroupId keys match the initialized HPGroup
type InsertStats ¶
type InsertStats struct {
Inserted, Updated, Filtered int
}
InsertStats provides statistics about an insertion.
type MetricsDB ¶
type MetricsDB struct {
// contains filtered or unexported fields
}
MetricsDB is a wrapper around the beacon db that exports metrics.
func DBWithMetrics ¶
DBWithMetrics wraps the given db into a db that exports metrics.
func (MetricsDB) AllRevocations ¶
func (e MetricsDB) AllRevocations(ctx context.Context) (<-chan RevocationOrErr, error)
func (MetricsDB) BeaconSources ¶
func (*MetricsDB) BeginTransaction ¶
func (MetricsDB) CandidateBeacons ¶
func (MetricsDB) DeleteExpiredBeacons ¶
func (MetricsDB) DeleteExpiredRevocations ¶
func (MetricsDB) DeleteRevocation ¶
func (MetricsDB) DeleteRevokedBeacons ¶
func (MetricsDB) InsertBeacon ¶
func (MetricsDB) InsertRevocation ¶
func (e MetricsDB) InsertRevocation(ctx context.Context, revocation *path_mgmt.SignedRevInfo) error
func (*MetricsDB) SetMaxIdleConns ¶
func (*MetricsDB) SetMaxOpenConns ¶
type MetricsTransaction ¶
type MetricsTransaction struct {
// contains filtered or unexported fields
}
MetricsTransaction is a wrapper around a beacon db transaction that exports metrics.
func (MetricsTransaction) AllRevocations ¶
func (e MetricsTransaction) AllRevocations(ctx context.Context) (<-chan RevocationOrErr, error)
func (MetricsTransaction) BeaconSources ¶
func (MetricsTransaction) CandidateBeacons ¶
func (*MetricsTransaction) Commit ¶
func (tx *MetricsTransaction) Commit() error
func (MetricsTransaction) DeleteExpiredBeacons ¶
func (MetricsTransaction) DeleteExpiredRevocations ¶
func (MetricsTransaction) DeleteRevocation ¶
func (MetricsTransaction) DeleteRevokedBeacons ¶
func (MetricsTransaction) InsertBeacon ¶
func (MetricsTransaction) InsertRevocation ¶
func (e MetricsTransaction) InsertRevocation(ctx context.Context, revocation *path_mgmt.SignedRevInfo) error
func (*MetricsTransaction) Rollback ¶
func (tx *MetricsTransaction) Rollback() error
type Policies ¶
type Policies struct { // Prop is the propagation policy. Prop Policy // UpReg is the up segment policy. UpReg Policy // DownReg is the down segment policy. DownReg Policy }
Policies keeps track of all policies for a non-core beacon store.
func (*Policies) Filter ¶
Filter applies all filters and returns an error if all of them filter the beacon. If at least one does not filter, no error is returned.
func (*Policies) InitDefaults ¶
func (p *Policies) InitDefaults()
InitDefaults sets the defaults for all policies.
type Policy ¶
type Policy struct { // BestSetSize is the number of segments to propagate or register. BestSetSize int `yaml:"BestSetSize"` // CandidateSetSize is the number of segments to consider for // selection. CandidateSetSize int `yaml:"CandidateSetSize"` // MaxExpTime indicates the maximum value for the expiration time when // extending the segment. MaxExpTime *spath.ExpTimeType `yaml:"MaxExpTime"` // Filter is the filter applied to segments. Filter Filter `yaml:"Filter"` // Type is the policy type. Type PolicyType `yaml:"Type"` }
Policy contains the policy parameters when handling beacons.
func LoadPolicyFromYaml ¶
func LoadPolicyFromYaml(path string, t PolicyType) (*Policy, error)
LoadPolicyFromYaml loads the policy from a yaml file and initializes the default values.
func ParsePolicyYaml ¶
func ParsePolicyYaml(b common.RawBytes, t PolicyType) (*Policy, error)
ParsePolicyYaml parses the policy in yaml format and initializes the default values.
func (*Policy) InitDefaults ¶
func (p *Policy) InitDefaults()
InitDefaults initializes the default values for unset fields.
type PolicyType ¶
type PolicyType string
PolicyType is the policy type.
const ( // PropPolicy is the propagation policy. PropPolicy PolicyType = "Propagation" // UpRegPolicy is the registration policy for up segments. UpRegPolicy PolicyType = "UpSegmentRegistration" // DownRegPolicy is the registration policy for down segments. DownRegPolicy PolicyType = "DownSegmentRegistration" // CoreRegPolicy is the registration policy for core segments. CoreRegPolicy PolicyType = "CoreSegmentRegistration" )
type RegPolicy ¶
type RegPolicy struct { RegUp bool `yaml:"RegUp"` RegDown bool `yaml:"RegDown"` MaxExpiration util.DurWrap `yaml:"MaxExpiration"` }
RegPolicy holds a segmentregistration policy
type RevocationOrErr ¶
type RevocationOrErr struct { Rev *path_mgmt.SignedRevInfo Err error }
RevocationOrErr contains a signed revocation or an error.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store provides abstracted access to the beacon database in a non-core AS. The store helps inserting beacons and revocations, and selects the best beacons for given purposes based on the configured policies. It should not be used in a core AS.
func NewBeaconStore ¶
NewBeaconStore creates a new beacon store for a non-core AS.
func (*Store) BeaconsToPropagate ¶
func (s *Store) BeaconsToPropagate(ctx context.Context) (<-chan BeaconOrErr, error)
BeaconsToPropagate returns a channel that provides all beacons to propagate at the time of the call. The selection is based on the configured propagation policy.
func (*Store) Close ¶
func (s *Store) Close() error
Close closes the store and the underlying database connection.
func (*Store) DeleteExpiredBeacons ¶
DeleteExpiredBeacons deletes expired Beacons from the store.
func (*Store) DeleteExpiredRevocations ¶
DeleteExpiredRevocations deletes expired Revocations from the store.
func (*Store) DeleteRevocation ¶
DeleteRevocation deletes the revocation from the BeaconDB.
func (*Store) InsertBeacon ¶
func (s *Store) InsertBeacon(ctx context.Context, beacon Beacon) (InsertStats, error)
InsertBeacon adds a verified beacon to the store. Beacon that contains revoked interfaces is inserted and does not cause an error. If the beacon does not match any policy, it is not inserted, but does not cause an error.
func (*Store) InsertRevocations ¶
func (s *Store) InsertRevocations(ctx context.Context, revocations ...*path_mgmt.SignedRevInfo) error
InsertRevocations inserts the revocation into the BeaconDB. The provided revocation must be verified by the caller.
func (*Store) MaxExpTime ¶
func (s *Store) MaxExpTime(policyType PolicyType) spath.ExpTimeType
MaxExpTime returns the segment maximum expiration time for the given policy.
func (*Store) PreFilter ¶
PreFilter indicates whether the beacon will be filtered on insert by returning an error with the reason. This allows the caller to drop ignored beacons.
func (*Store) SegmentsToRegister ¶
func (s *Store) SegmentsToRegister(ctx context.Context, segType proto.PathSegType) ( <-chan BeaconOrErr, error)
SegmentsToRegister returns a channel that provides all beacons to register at the time of the call. The selections is based on the configured policy for the requested segment type.
type Transaction ¶
type Transaction interface { DBReadWrite Commit() error Rollback() error }
Transaction defines all operations of a transaction on the beacon DB.
type Usage ¶
type Usage int
Usage indicates what the beacon is allowed to be used for according to the policies.
const ( // UsageUpReg indicates the beacon is allowed to be registered as an up segment. UsageUpReg Usage = 0x01 // UsageDownReg indicates the beacon is allowed to be registered as a down segment. UsageDownReg Usage = 0x02 // UsageCoreReg indicates the beacon is allowed to be registered as a core segment. UsageCoreReg Usage = 0x04 // UsageProp indicates the beacon is allowed to be propagated. UsageProp Usage = 0x08 )
func UsageFromPolicyType ¶
func UsageFromPolicyType(policyType PolicyType) Usage
UsageFromPolicyType maps the policy type to the usage flag.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package mock_beacon is a generated GoMock package.
|
Package mock_beacon is a generated GoMock package. |