bio-routing / bio-rd

bio routing is a project to create a versatile, fast and reliable routing daemon in Golang. bio = BGP + IS-IS + OSPF
Apache License 2.0
283 stars 44 forks source link

BGP: Local Pref 100 not set as default for received eBGP routes #400

Closed mordner closed 1 year ago

mordner commented 1 year ago

Describe the bug When a route from an eBGP neighbor is received and no policies are configured for this neighbor, the Local-Pref will be set to 0. Without any policies configured the Local-Pref should instead be set to 100, which is the correct default value.

Steps to Reproduce Build examples/bgp and peer with another BGP speaker which has a different AS. Announce a route from the other BGP speaker towards bio-rd.

Expected behavior I expect bio-rd to set a default Local-Pref of 100 for all received routes which do not have Local-Pref set, before any policies are evaluated.

Configuration used Peer config for examples/bgp:

func addPeersIPv4(b server.BGPServer, v *vrf.VRF) {
    b.AddPeer(server.PeerConfig{
        AdminEnabled:      true,
        LocalAS:           65200,
        PeerAS:            65300,
        PeerAddress:       bnet.IPv4FromOctets(127, 0, 0, 1).Ptr(),
        LocalAddress:      bnet.IPv4FromOctets(127, 0, 0, 1).Ptr(),
        ReconnectInterval: time.Second * 15,
        HoldTime:          time.Second * 90,
        KeepAlive:         time.Second * 30,
        Passive:           true,
        //RouterID:          b.RouterID(),
        RouterID: uint32(1),
        IPv4: &server.AddressFamilyConfig{
            //ImportFilterChain: filter.NewAcceptAllFilterChain(),
            ExportFilterChain: filter.NewAcceptAllFilterChain(),
            AddPathSend: routingtable.ClientOptions{
                MaxPaths: 10,
            },
        },
        RouteServerClient: true,
        VRF:               v,
    })
}

Other BGP speaker was gobgp. Config:

[global.config]
  as = 65300
  router-id = "192.168.255.1"
  port = 1790

[[neighbors]]
  [neighbors.config]
    neighbor-address = "127.0.0.1"
    peer-as = 65200
  [neighbors.transport.config]
    local-address = "127.0.0.1"
    remote-port = 179

Inject route:

$ gobgp global rib add 192.168.1.1/32 -a ipv4

Check route in bio-rd:

$ go run ./cmd/bio-rdc/main.go -bio-rd localhost:1337 -cmd "show routes receive-protocol bgp 127.0.0.1"
192.168.1.1/32:
All Paths:
        Protocol: BGP
        Hidden: no
                Local Pref: 0
                Origin: Incomplete
                AS Path: 65300
                BGP type: external
                NEXT HOP: 127.0.0.1
                MED: 0
                Path ID: 0
                Source: 127.0.0.1

Local-Pref should be 100 not 0.

BarbarossaTM commented 1 year ago

Fair point, although RFC4271 doesn't mandate this, we should definitely do so for interoperability. I guess RFC4277 is a good guideline here.