Pathvector

repository·main·Indexed 42 days ago

https://github.com/natesales/pathvector

A declarative edge routing platform that automates route optimization and control plane configuration through secure, repeatable routing policies. It is data-plane agnostic and features BGP route filtering (RPKI, IRR, ASPA), PeeringDB integration, and a Go plugin API for extensibility. Includes a CLI for managing configurations, interacting with BIRD via birdsh, and running a route optimization daemon.

Tokens
15.8K
Snippets
54
Records
78
Agent score
54%

What's inside Pathvector

  1. Overview of Pathvector features

    main

    Pathvector is a declarative edge routing platform designed to automate route optimization and control plane configuration using secure, repeatable routing policies.

    Key capabilities include:

    • Robust BGP Route Filtering: Supports RPKI, IRR, downstream AS cone, ASPA, never-via-RS, and more.
    • PeeringDB Integration: Automatically generates configurations from PeeringDB data.
    • Route Optimization: Enriches standard BGP attributes with latency and packet loss metrics for automated optimization.
    • Declarative Configuration: Uses a configuration model that can be managed via version control (e.g., Git).
    • Data-plane Agnostic: Compatible with servers, network switches, and embedded devices.
    • Protocol Support: Includes BFD and VRRP support.
    • Extensibility: Provides a Go plugin API for custom extensions.
  2. Pathvector Dependencies

    main

    Pathvector requires bird >= 2.0.7 as its only mandatory dependency. Depending on the features you use, you may need additional tools:

    • RPKI filtering: Requires an RTR server (e.g., gortr or Cloudflare's public RTR server at rtr.rpki.cloudflare.com:8282).
    • IRR prefix list generation: Requires bgpq4.
    • VRRP daemon: Requires keepalived.
  3. Use peer-level BIRD configuration snippets

    main

    Pathvector allows you to inject BIRD configuration snippets at specific stages of the import/export process for individual peers.

    Available peer-level options:

    • pre-import: Configuration inserted before import filters.
    • pre-export: Configuration inserted before export filters.
    • pre-import-final: Configuration inserted after import filters.
    • pre-export-final: Configuration inserted after export filters.

    To load a snippet from an external file instead of an inline string, append -file to any of these options (e.g., pre-import-file).

  4. Use string replacement in BIRD configuration snippets

    main

    Peer-level configuration snippets support dynamic string replacement using the <pathvector.$OPTION> syntax. This allows you to inject peer-specific values into your BIRD configuration blocks.

    Commonly used replacement keys include <pathvector.asn> to inject the peer's Autonomous System Number (ASN).

    pre-import: 'print "Hello from AS<pathvector.asn>";'
    // If the peer's ASN is 65530, this evaluates to: print "Hello from AS65530";
  5. Use BGP communities to control routing policy

    main

    Pathvector can use BGP communities (both Standard and Large) to tag routes based on their source and apply specific routing policies.

    In the example provided, communities are used to distinguish between routes learned from different types of neighbors:

    • Upstream: 65510,12 or 65510:0:12
    • Route Server: 65510,13 or 65510:0:13
    • Peer: 65510,14 or 65510:0:14
    • Downstream: 65510,15 or 65510:0:15
    | Standard Community | Large Community | Meaning                   |
    |:-------------------|:----------------|:--------------------------|
    | 65510,12           | 65510:0:12      | Learned from upstream     |
    | 65510,13           | 65510:0:13      | Learned from route server |
    | 65510,14           | 65510:0:14      | Learned from peer         |
    | 65510,15           | 65510:0:15      | Learned from downstream   |
  6. Use blocklists to filter ASNs and prefixes

    main

    Pathvector allows you to define a global blocklist containing specific Autonomous System Numbers (ASNs) and IP prefixes. This blocklist is used to filter traffic or routing information.

    You can populate the blocklist using three methods:

    1. Directly in the config file: Define ASNs and prefixes within the configuration.
    2. From a local text file: Point to a file on the filesystem using the blocklist-files configuration.
    3. From a remote URL: Fetch the list dynamically using the blocklist-urls configuration.

    By default, all peers honor the blocklist. If you need to disable this filtering behavior, set the filter-blocklist configuration key to false.

  7. How Pathvector plugins work

    main

    Pathvector is extensible via a plugin system. To create a plugin, you must implement the github.com/natesales/pathvector/pkg/plugin.Plugin interface.

    Plugins allow you to:

    1. Add CLI commands: By implementing the Command() method, you can inject new *cobra.Command instances into the Pathvector CLI.
    2. Modify configuration: By implementing the Modify(*config.Config) method, you can programmatically alter the Pathvector configuration at runtime.
    3. Provide metadata: You must provide a Description() and a Version() for the plugin.
    type Plugin struct{}
    var _ plugin.Plugin = (*Plugin)(nil)
    
    func (g *Plugin) Description() string { return "An example plugin" }
    func (g *Plugin) Version() string { return "1.0.0" }
    func (g *Plugin) Command() *cobra.Command { /* returns a cobra command */ }
    func (g *Plugin) Modify(c *config.Config) error { /* modifies config */ }
  8. How Pathvector Route Optimization works

    main

    Pathvector performs route optimization by monitoring network performance metrics—specifically latency and packet loss—to influence BGP routing decisions.

    It operates by:

    1. Sending ICMP or UDP pings to various peer networks.
    2. Measuring average latency and packet loss.
    3. Modifying the BGP local pref (Local Preference) attribute based on configured thresholds to steer traffic toward more performant paths.
  9. Configure Transit Locking for a peer

    main

    Transit Locking allows you to restrict the transit providers allowed for a specific peer. Using the transit-lock peer option, you define a list of authorized transit providers.

    If a route's AS path contains an ASN that is not in this authorized list, the route will be rejected, unless the AS path contains only the peer's ASN (meaning no transit providers are present in the path).

  10. Configure Downstream AS Cone filtering

    main

    Downstream AS cone filtering allows you to reject routes if their origin ASN is not part of a predefined set of ASNs associated with a peer. This is configured using the filter-as-path option on a peer. You can define the allowed ASNs in two ways:

    1. Manually: Use the as-set option to provide a specific list of ASNs.
    2. Automatically: Use the auto-as-set option to retrieve the AS-set from PeeringDB.