GithubHelp home page GithubHelp logo

bio-routing / bio-rd Goto Github PK

View Code? Open in Web Editor NEW
281.0 281.0 44.0 30.69 MB

bio routing is a project to create a versatile, fast and reliable routing daemon in Golang. bio = BGP + IS-IS + OSPF

License: Apache License 2.0

Go 99.89% Makefile 0.08% Shell 0.01% Dockerfile 0.03%
hacktoberfest

bio-rd's People

Contributors

awlx avatar barbarossatm avatar benjojo avatar cedi avatar corny avatar costela avatar czerwonk avatar dependabot[bot] avatar dotwaffle avatar gebi avatar hikhvar avatar istvan91 avatar jayay avatar joao-reis avatar leoluk avatar margau avatar mordner avatar netixx avatar pberndro avatar q3k avatar sasakovacevicmsft avatar sebageek avatar taktv6 avatar tklauser avatar tobikris avatar totallyunknown avatar vincentbernat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bio-rd's Issues

Allow a user to specify its own logger

When using bio-rd as a library, this is not possible to override the global logrus logger (well it is, as long as you only have one dependency using logrus, but that's not super clean). Instead, each component should use its own logger. bgp/server.Router already has its own logger, but it is not user-settable.

I would propose to add a Logger field to each structure needed it. It will be set to log.New() by default or inherited if it is sensible. As long as the "New" methods don't try to log, this should work good enough. This does not require modifying any signature.

I can do the work if it is deemed acceptable. More complex alternatives would be to define a logging interface to avoid depending on logrus, but I don't need that myself and this is far more work.

Allow to configure which Prometheus metrics to emit

Describe the feature

Currently Bio collects a lot of metrics on different sub-systems (BGP, BMP, VRFs) and all metrics are enabled by default. It would be nice if a BGP/BMP server, could be configured to emit only desired metrics, ideally having some presets but also allowing to configure this individually.

Use cases / additional context

Usually it's better to have than to be in need, however at scale a lot of metrics can easily become an issue, for example when using Bio as a BMP receiver for a large number of routers having a lot of peer and/or full tables. In this case it would be particularly neat to be able to disable some metrics, which are less relevant (e.g. some of the BMP message type counters, etc.).

MP-BGP support in Daemon

Currently the daemon does not support MP-BGP thus sessions with exabgp and the like are not exchanging routes.

11:44:22 | 50889  | outgoing-1    | --------------------------------------------------------------------
11:44:22 | 50889  | outgoing-1    | the connection can not carry the following family/families
11:44:22 | 50889  | outgoing-1    |  - peer is not configured for ipv4/multicast
11:44:22 | 50889  | outgoing-1    |  - peer is not configured for bgp-ls/bgp-ls
11:44:22 | 50889  | outgoing-1    |  - peer is not configured for ipv6/flow-vpn
11:44:22 | 50889  | outgoing-1    |  - peer is not configured for bgp-ls/bgp-ls-vpn
11:44:22 | 50889  | outgoing-1    |  - peer is not configured for l2vpn/evpn
11:44:22 | 50889  | outgoing-1    |  - peer is not configured for ipv4/rtc
11:44:22 | 50889  | outgoing-1    |  - peer is not configured for ipv4/nlri-mpls
11:44:22 | 50889  | outgoing-1    |  - peer is not configured for ipv6/unicast
11:44:22 | 50889  | outgoing-1    |  - peer is not configured for ipv4/flow
11:44:22 | 50889  | outgoing-1    |  - peer is not configured for ipv6/mpls-vpn
11:44:22 | 50889  | outgoing-1    |  - peer is not configured for ipv4/unicast
11:44:22 | 50889  | outgoing-1    |  - peer is not configured for ipv4/flow-vpn
11:44:22 | 50889  | outgoing-1    |  - peer is not configured for l2vpn/vpls
11:44:22 | 50889  | outgoing-1    |  - peer is not configured for ipv6/multicast
11:44:22 | 50889  | outgoing-1    |  - peer is not configured for ipv4/mpls-vpn
11:44:22 | 50889  | outgoing-1    |  - peer is not configured for ipv6/nlri-mpls
11:44:22 | 50889  | outgoing-1    |  - peer is not configured for ipv6/flow
11:44:22 | 50889  | outgoing-1    | therefore no routes of this kind can be announced on the connection
11:44:22 | 50889  | outgoing-1    | --------------------------------------------------------------------

Allow defining routingtable.ClientOptions from ObserveRIBRequest

Describe the feature
I would like to be able to specify options of the routingtable.ClientOptions when I do my ObserveRIB request, such as:

  • MaxPaths
  • EcmpOnly
  • BestOnly

This way the client can decide what type of paths it wants to receive.
Currently the options are hard-coded:

rib.RegisterWithOptions(rc, routingtable.ClientOptions{
		MaxPaths: 100,
	})

It would also be nice if we could specify those options for the DumpRIB request.

Use cases / additional context
I have a client that uses ObserveRIB to re-build a router RIB locally,
but I only need ECMP best paths, so I would like to be able to specify those options.

On other clients, we may want to get the full feed for observability purposes.

Bind is always 0.0.0.0 regardless of specified address in listener

Describe the bug
A clear and concise description of what the bug is.

Steps to Reproduce
in cmd/bio-rd/main.go, configure a bind IP for

listenAddrsByVRF := map[string][]string{
		vrf.DefaultVRFName: {
			"10.0.0.1:179",
		},
	}

Expected behavior
The program should bind the socket on the provided IP address.

Configuration used

routing_options:
  autonomous_system: 111
  router_id: 10.0.0.1
policy_options:
  policy_statements:
    - name: "ACCEPT_ALL"
      terms:
        - name: "ACCEPT_ALL"
          then:
            accept: true
    - name: "REJECT_ALL"
      terms:
        - name: "REJECT_ALL"
          then:
            reject: true
protocols:
  bgp:
    groups:
      - name: "IXP RS Clients"
        local_address: 10.0.0.1
        #route_server_client: true
        passive: true
        neighbors:
          - peer_address: 10.0.0.2
            peer_as: 111
            import: ["ACCEPT_ALL"]
            export: ["REJECT_ALL"]
  • change bind address in code

Additional context
By modifying the code in net/tcp/listen.go the following way:

fmt.Println(laddr.IP)
    fmt.Println(ipv4AddrToArray(laddr.IP))
    if laddr.IP.To4() != nil {
        err = unix.Bind(fd, &unix.SockaddrInet4{
            Port: laddr.Port,
            Addr: ipv4AddrToArray(laddr.IP),
        })
    } else {
        err = unix.Bind(fd, &unix.SockaddrInet6{
            Port: laddr.Port,
            Addr: ipv6AddrToArray(laddr.IP),
        })
    }

I was able to produce the following output:

strace -e trace=network ./bio-rd
10.0.0.1
[0 0 0 0]
bind(13, {sa_family=AF_INET, sin_port=htons(2179), sin_addr=inet_addr("0.0.0.0")}, 16) = 0

As you can see the bind call is 0.0.0.0 beccause ipv4AddrToArray returns [0 0 0 0].

Extra RAM being used by BGP process ?

Describe the bug
I am running the BGP server with around 20 peers, each with around 1M routes.

I am seeing high RAM usage. Running a pprof heap dump, I get the following flamegraph:
image

It looks to me like some resources are not released when the routes are processed by the filters ?

Steps to Reproduce
Run the router and check for RAM allocation.

Expected behavior
Only the RIB component should use a lot of RAM

Configuration used

b.AddPeer(server.PeerConfig{
			LocalAS: 16276,
			PeerAS: 16276,
			RouterID: addr.ToUint32(),
			PeerAddress: ip.Ptr(),
			LocalAddress: locAddr.Ptr(),
			AdminEnabled: true,
			VRF: defaultVRF,
			Passive: true,
			AdvertiseIPv4MultiProtocol: true,
			IPv4: &server.AddressFamilyConfig{
				AddPathRecv: true,
				ImportFilterChain: filter.NewAcceptAllFilterChain(),
				ExportFilterChain: filter.NewDrainFilterChain(),
			},
			IPv6: &server.AddressFamilyConfig{
				AddPathRecv: true,
				ImportFilterChain: filter.NewAcceptAllFilterChain(),
				ExportFilterChain: filter.NewDrainFilterChain(),
			},

**Additional context **

We are running add-path with both IPv4 and IPv6 AFIs and unicast SAFI.

Add BGP template neighbor feature (accept BGP connection from range/prefix)

I would like templates for BGP neighbor configuration. OpenBGPD does this as follows:

Instead of the neighbor's IP address, an address/netmask pair may be given:
neighbor 10.0.0.0/8
In this case, the neighbor specification becomes a template, and if a neighbor connects from an IP address within the given network, the template is cloned, inheriting everything from the template but the remote address, which is replaced by the connecting neighbor's address. With a template specification it is valid to omit remote-as; bgpd(8) will then accept any AS the neighbor presents in the OPEN message.

Newbie seeking improved README.md with build and test instructions (better than the examples)

Describe the feature
README.md improvement

Use cases / additional context
For new people curious about this project (like me), the current README.md leaves me stuck/unable to perceive how to build/test/run this project. Building the examples and testing coverage do currently work. But doing that left me ignorant about how to use/test bio-rd.

Rather than an issue report, it would be far better to have a mail-list for a conversation about assisting a newbie. But I could not find an email group or chat group.

Q. How do I build bio-rd?
Q. How do I run bio-rd?
(kindof expecting suggestions about docker setup??)

panic: runtime error: slice bounds out of range

Found with #101

panic: runtime error: slice bounds out of range

goroutine 1 [running]:
github.com/bio-routing/bio-rd/protocols/bgp/packet.deserializeMultiProtocolReachNLRI(0xc420018188, 0x8, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/tmp/go-fuzz-build543490251/gopath/src/github.com/bio-routing/bio-rd/protocols/bgp/packet/mp_reach_nlri.go:54 +0x8ae
github.com/bio-routing/bio-rd/protocols/bgp/packet.(*PathAttribute).decodeMultiProtocolReachNLRI(0xc42000c060, 0xc4200c2000, 0x1, 0x0)
	/tmp/go-fuzz-build543490251/gopath/src/github.com/bio-routing/bio-rd/protocols/bgp/packet/path_attributes.go:146 +0x1f8
github.com/bio-routing/bio-rd/protocols/bgp/packet.decodePathAttr(0xc4200c2000, 0xc42005bee5, 0x5181e0, 0x5b6bb0, 0x4d8e60, 0xc42008e520)
	/tmp/go-fuzz-build543490251/gopath/src/github.com/bio-routing/bio-rd/protocols/bgp/packet/path_attributes.go:112 +0xb1e
github.com/bio-routing/bio-rd/protocols/bgp/packet.decodePathAttrs(0xc4200c2000, 0xc420053030, 0xc42005bee5, 0x1, 0x0, 0x0)
	/tmp/go-fuzz-build543490251/gopath/src/github.com/bio-routing/bio-rd/protocols/bgp/packet/path_attributes.go:23 +0x6d
github.com/bio-routing/bio-rd/protocols/bgp/packet.decodeUpdateMsg(0xc4200c2000, 0x1d, 0xc42005bee5, 0x68, 0x12, 0x4d8e60)
	/tmp/go-fuzz-build543490251/gopath/src/github.com/bio-routing/bio-rd/protocols/bgp/packet/decoder.go:63 +0x15f
github.com/bio-routing/bio-rd/protocols/bgp/packet.decodeMsgBody(0xc4200c2000, 0xc4001d8102, 0xc42005bee5, 0x0, 0x5, 0x6, 0xc4200143a0)
	/tmp/go-fuzz-build543490251/gopath/src/github.com/bio-routing/bio-rd/protocols/bgp/packet/decoder.go:36 +0xe7
github.com/bio-routing/bio-rd/protocols/bgp/packet.Decode(0xc4200c2000, 0xc42005bee5, 0xa, 0x45f576, 0x5b52081a)
	/tmp/go-fuzz-build543490251/gopath/src/github.com/bio-routing/bio-rd/protocols/bgp/packet/decoder.go:20 +0x102
github.com/bio-routing/bio-rd/protocols/bgp/packet.Fuzz(0x7f12f6716000, 0x22, 0x200000, 0x4f98c0)
	/tmp/go-fuzz-build543490251/gopath/src/github.com/bio-routing/bio-rd/protocols/bgp/packet/fuzzing.go:22 +0xbd
go-fuzz-dep.Main(0x50ac10)
	/tmp/go-fuzz-build543490251/goroot/src/go-fuzz-dep/main.go:49 +0xad
main.main()
	/tmp/go-fuzz-build543490251/gopath/src/github.com/bio-routing/bio-rd/protocols/bgp/packet/go.fuzz.main/main.go:10 +0x2d
exit status 2

Quoted input:

	"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x000\x02\x00" +
	"\x0000a\x0e\b00000000"

documentation: Document returned path order for ris

Describe the feature
Document the slice order of paths in ris responses.

Use cases / additional context
For every route, the ris does return a list of paths. ris tries to imitate the path selection algorithm of the router, and returns the assumed best path at first. This is not documented properly.

panic: runtime error: makeslice: len out of range

Panic found with #101 ๐Ÿ‘

panic: runtime error: makeslice: len out of range

goroutine 1 [running]:
github.com/bio-routing/bio-rd/protocols/bgp/packet.deserializeMultiProtocolUnreachNLRI(0xc420018540, 0x1, 0x1, 0x1, 0x1, 0x0, 0x0, 0x5b6bb0, 0x4d8f20)
	/tmp/go-fuzz-build543490251/gopath/src/github.com/bio-routing/bio-rd/protocols/bgp/packet/mp_unreach_nlri.go:33 +0x8c
github.com/bio-routing/bio-rd/protocols/bgp/packet.(*PathAttribute).decodeMultiProtocolUnreachNLRI(0xc42000c180, 0xc4200b0150, 0x1, 0x0)
	/tmp/go-fuzz-build543490251/gopath/src/github.com/bio-routing/bio-rd/protocols/bgp/packet/path_attributes.go:165 +0x1c2
github.com/bio-routing/bio-rd/protocols/bgp/packet.decodePathAttr(0xc4200b0150, 0xc42005bee5, 0x5181e0, 0x5b6bb0, 0x4d8e60, 0xc4200885b0)
	/tmp/go-fuzz-build543490251/gopath/src/github.com/bio-routing/bio-rd/protocols/bgp/packet/path_attributes.go:116 +0xa59
github.com/bio-routing/bio-rd/protocols/bgp/packet.decodePathAttrs(0xc4200b0150, 0xc420053030, 0xc42005bee5, 0x1, 0x0, 0x0)
	/tmp/go-fuzz-build543490251/gopath/src/github.com/bio-routing/bio-rd/protocols/bgp/packet/path_attributes.go:23 +0x6d
github.com/bio-routing/bio-rd/protocols/bgp/packet.decodeUpdateMsg(0xc4200b0150, 0x1d, 0xc42005bee5, 0x68, 0x12, 0x4d8e60)
	/tmp/go-fuzz-build543490251/gopath/src/github.com/bio-routing/bio-rd/protocols/bgp/packet/decoder.go:63 +0x15f
github.com/bio-routing/bio-rd/protocols/bgp/packet.decodeMsgBody(0xc4200b0150, 0xc4001d8402, 0xc42005bee5, 0x0, 0x5, 0x6, 0xc420014480)
	/tmp/go-fuzz-build543490251/gopath/src/github.com/bio-routing/bio-rd/protocols/bgp/packet/decoder.go:36 +0xe7
github.com/bio-routing/bio-rd/protocols/bgp/packet.Decode(0xc4200b0150, 0xc42005bee5, 0xa, 0x45f576, 0x5b52081b)
	/tmp/go-fuzz-build543490251/gopath/src/github.com/bio-routing/bio-rd/protocols/bgp/packet/decoder.go:20 +0x102
github.com/bio-routing/bio-rd/protocols/bgp/packet.Fuzz(0x7f17bc462000, 0x1b, 0x200000, 0x3)
	/tmp/go-fuzz-build543490251/gopath/src/github.com/bio-routing/bio-rd/protocols/bgp/packet/fuzzing.go:22 +0xbd
go-fuzz-dep.Main(0x50ac10)
	/tmp/go-fuzz-build543490251/goroot/src/go-fuzz-dep/main.go:49 +0xad
main.main()
	/tmp/go-fuzz-build543490251/gopath/src/github.com/bio-routing/bio-rd/protocols/bgp/packet/go.fuzz.main/main.go:10 +0x2d
exit status 2```
Quoted input:
"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x000\x02\x00" +
"\x0000\x00\x0f\x010"

Documents

I want to use this in my project. However, I do not found any documents. Do you hava a website or something else?
Thanks.

panic: runtime error: makeslice: len out of range

Found with #101:

panic: runtime error: makeslice: len out of range

goroutine 1 [running]:
github.com/bio-routing/bio-rd/protocols/bgp/packet.deserializeMultiProtocolReachNLRI(0x5b6bb0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/tmp/go-fuzz-build543490251/gopath/src/github.com/bio-routing/bio-rd/protocols/bgp/packet/mp_reach_nlri.go:41 +0xd3
github.com/bio-routing/bio-rd/protocols/bgp/packet.(*PathAttribute).decodeMultiProtocolReachNLRI(0xc42000c0c0, 0xc4200aa000, 0x1, 0x0)
	/tmp/go-fuzz-build543490251/gopath/src/github.com/bio-routing/bio-rd/protocols/bgp/packet/path_attributes.go:146 +0x1f8
github.com/bio-routing/bio-rd/protocols/bgp/packet.decodePathAttr(0xc4200aa000, 0xc42005bee5, 0x5181e0, 0x5b6bb0, 0x4d8e60, 0xc42007a520)
	/tmp/go-fuzz-build543490251/gopath/src/github.com/bio-routing/bio-rd/protocols/bgp/packet/path_attributes.go:112 +0xb1e
github.com/bio-routing/bio-rd/protocols/bgp/packet.decodePathAttrs(0xc4200aa000, 0xc420053030, 0xc42005bee5, 0x1, 0x0, 0x0)
	/tmp/go-fuzz-build543490251/gopath/src/github.com/bio-routing/bio-rd/protocols/bgp/packet/path_attributes.go:23 +0x6d
github.com/bio-routing/bio-rd/protocols/bgp/packet.decodeUpdateMsg(0xc4200aa000, 0x1d, 0xc42005bee5, 0x68, 0x12, 0x4d8e60)
	/tmp/go-fuzz-build543490251/gopath/src/github.com/bio-routing/bio-rd/protocols/bgp/packet/decoder.go:63 +0x15f
github.com/bio-routing/bio-rd/protocols/bgp/packet.decodeMsgBody(0xc4200aa000, 0xc4001d8302, 0xc42005bee5, 0x0, 0x5, 0x6, 0xc4200143e0)
	/tmp/go-fuzz-build543490251/gopath/src/github.com/bio-routing/bio-rd/protocols/bgp/packet/decoder.go:36 +0xe7
github.com/bio-routing/bio-rd/protocols/bgp/packet.Decode(0xc4200aa000, 0xc42005bee5, 0xa, 0x45f576, 0x5b520819)
	/tmp/go-fuzz-build543490251/gopath/src/github.com/bio-routing/bio-rd/protocols/bgp/packet/decoder.go:20 +0x102
github.com/bio-routing/bio-rd/protocols/bgp/packet.Fuzz(0x7f2cde870000, 0x1a, 0x200000, 0x4f98c0)
	/tmp/go-fuzz-build543490251/gopath/src/github.com/bio-routing/bio-rd/protocols/bgp/packet/fuzzing.go:22 +0xbd
go-fuzz-dep.Main(0x50ac10)
	/tmp/go-fuzz-build543490251/goroot/src/go-fuzz-dep/main.go:49 +0xad
main.main()
	/tmp/go-fuzz-build543490251/gopath/src/github.com/bio-routing/bio-rd/protocols/bgp/packet/go.fuzz.main/main.go:10 +0x2d
exit status 2

Quoted input:

	"\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x000\x02\x00" +
	"\x0000\x01\x0e\x00"

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

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.

Rename pfxlen field

Please rename pfxlen into length, because prefix.pfxlen stutters.

net/api/net.proto

message Prefix {
    IP address = 1;
    uint32 length = 2; // before: pfxlen
}

net/prefix.go

type Prefix struct {
	addr   IP
	pfxlen uint8 // better: len or length
}

Build on Darwin is broken

The build on Darwin (OS X) is broken due to dependencies on the Netlink library.
I'd prefer not to have a working netlink at all in favour of not being able to build.
Please fix.

Add config option for `always-compare-med`

Describe the feature
Currently bio-routing always compares MED values, even if the ASes of different paths are different - this should be configurable as it is in other implementations.

Also add a config option for the RIS/BMP Monitoring station which allows setting this.

bio-rd: BGP: Enforce setting local-address or better detect it automatically

Describe the bug
When local_address is not specified on a BGP neighbor bio-rd crashes on startup.

Steps to Reproduce
Create bio-rd config with a BGP neighbor without specifying local_address and start bio-rd.

Expected behavior
It must not crash but should either throw an error asking for the complete config or detect the local address automatically.

bgpPathACache leaks memory

Describe the bug
bgpPathACache causes large memory leaks and is itself not caching anything that can be retrieved. The result is an ever increasing map which consumes all memory until depletion. This is a combination of issues described in detail below.

Issue 1 - BGPPathA duplication

p (type BGPPathA) is copied and added to the map index, resulting in a duplication of the contents.

bgpc.cache[*p] = p

Issue 2 - impossible cache hit

BGPPathA contains ptrs that always reference new memory (line 131 & 138). The map index therefore becomes unique for each new BGPPathA created. No dedup happens here.

bio-rd/route/bgp_path.go

Lines 129 to 145 in 63eef2b

p := &BGPPath{
BGPPathA: &BGPPathA{
NextHop: bnet.IPFromProtoIP(pb.NextHop).Ptr(),
LocalPref: pb.LocalPref,
OriginatorID: pb.OriginatorId,
Origin: uint8(pb.Origin),
MED: pb.Med,
EBGP: pb.Ebgp,
BGPIdentifier: pb.BgpIdentifier,
Source: bnet.IPFromProtoIP(pb.Source).Ptr(),
OnlyToCustomer: pb.OnlyToCustomer,
},
PathIdentifier: pb.PathIdentifier,
ASPath: asPath,
ASPathLen: asPath.Length(),
BMPPostPolicy: pb.BmpPostPolicy,
}

Issue 3 - missing cache eviction

Even if this cache would work, there is no mechanism for cache eviction. For very long running instances and many changes, this would always grow until no memory is available anymore.

Steps to Reproduce
run ris-mirror, have route updates, ram go brrr and poof

Expected behavior
ris-mirros shouldn't leak memory and can run for long times

Configuration used
this is config independent as the code path is always used in ris-mirror

Additional context
I've done a lot of profiling on this issue und very confident this is the major source of leaks for ris-mirror. Simply running without cache works very nicely and shows generally better peformance.
Happy to provide a PR to fix this, depening on what solution is preferred. Removing cache seems like a better tradeoff than redesigning the entire cache strategy for probably marginal benefits.

docker build with given Dockerfile fails.

Describe the bug
Cannot build a docker image with given Dockerfile in docker/bio-rd/Dockerfile

Steps to Reproduce
cd docker/bio-rd
docker build --tag 'rickys' .

(attempted workaround)
cp ../../go.mod .
docker build --tag 'rickys' .

(2nd attempted workaround)
cd ../.. (top dir of bio-rd)
docker build --tag 'rickys' docker/bio-rd/

Expected behavior
successfully build a docker image which contains bio-rd binary

Configuration used
charletr@hpnsw4371:/ws/charletr/bio-rd$ uname -a
Linux hpnsw4371.rose.rdlabs.hpecorp.net 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
charletr@hpnsw4371:/ws/charletr/bio-rd$ cat /etc/issue
Ubuntu 16.04.7 LTS \n \l
(FYI, I can try on a much more modern ubuntu tonight)

charletr@hpnsw4371:/ws/charletr/bio-rd$ go version
go version go1.21.5 linux/amd64
charletr@hpnsw4371:/ws/charletr/bio-rd$ docker --version
Docker version 19.03.5, build 633a0ea838

Additional context

charletr@hpnsw4371:/ws/charletr/bio-rd/docker/bio-rd$ docker build --tag 'rickys' .
Sending build context to Docker daemon 2.048kB
Step 1/14 : FROM golang as builder
---> 0505a58fa464
Step 2/14 : ADD . /go/bio-rd
---> Using cache
---> 8c33e3997e5b
Step 3/14 : WORKDIR /go/bio-rd/cmd/bio-rd
---> Using cache
---> a1c5c3f03c71
Step 4/14 : RUN GOOS=linux go build -o /go/bin/bio-rd
---> Running in 0a6717ac9217
go: go.mod file not found in current directory or any parent directory; see 'go help modules'
The command '/bin/sh -c GOOS=linux go build -o /go/bin/bio-rd' returned a non-zero code: 1
charletr@hpnsw4371:/ws/charletr/bio-rd/docker/bio-rd$
charletr@hpnsw4371:/ws/charletr/bio-rd/docker/bio-rd$
charletr@hpnsw4371:/ws/charletr/bio-rd/docker/bio-rd$
charletr@hpnsw4371:/ws/charletr/bio-rd/docker/bio-rd$
charletr@hpnsw4371:/ws/charletr/bio-rd/docker/bio-rd$ cp ../../go.mod .
charletr@hpnsw4371:/ws/charletr/bio-rd/docker/bio-rd$ docker build --tag 'rickys' .
Sending build context to Docker daemon 4.096kB
Step 1/14 : FROM golang as builder
---> 0505a58fa464
Step 2/14 : ADD . /go/bio-rd
---> Using cache
---> 3ba4b8eb2ff0
Step 3/14 : WORKDIR /go/bio-rd/cmd/bio-rd
---> Using cache
---> 4055e5f810c9
Step 4/14 : RUN GOOS=linux go build -o /go/bin/bio-rd
---> Running in f35ac8f4b014
no Go files in /go/bio-rd/cmd/bio-rd
The command '/bin/sh -c GOOS=linux go build -o /go/bin/bio-rd' returned a non-zero code: 1
charletr@hpnsw4371:/ws/charletr/bio-rd/docker/bio-rd$
charletr@hpnsw4371:/ws/charletr/bio-rd/docker/bio-rd$
charletr@hpnsw4371:/ws/charletr/bio-rd/docker/bio-rd$
charletr@hpnsw4371:/ws/charletr/bio-rd/docker/bio-rd$
charletr@hpnsw4371:/ws/charletr/bio-rd/docker/bio-rd$
charletr@hpnsw4371:/ws/charletr/bio-rd/docker/bio-rd$
charletr@hpnsw4371:/ws/charletr/bio-rd/docker/bio-rd$ cd ..
charletr@hpnsw4371:/ws/charletr/bio-rd/docker$ cd ..
charletr@hpnsw4371:/ws/charletr/bio-rd$ docker build --tag 'rickys' .
unable to prepare context: unable to evaluate symlinks in Dockerfile path: lstat /ws/charletr/bio-rd/Dockerfile: no such file or directory
charletr@hpnsw4371:/ws/charletr/bio-rd$ docker build --tag 'rickys' docker/bio-rd/
Sending build context to Docker daemon 4.096kB
Step 1/14 : FROM golang as builder
---> 0505a58fa464
Step 2/14 : ADD . /go/bio-rd
---> Using cache
---> 3ba4b8eb2ff0
Step 3/14 : WORKDIR /go/bio-rd/cmd/bio-rd
---> Using cache
---> 4055e5f810c9
Step 4/14 : RUN GOOS=linux go build -o /go/bin/bio-rd
---> Running in 4f20223002b8
no Go files in /go/bio-rd/cmd/bio-rd
The command '/bin/sh -c GOOS=linux go build -o /go/bin/bio-rd' returned a non-zero code: 1
charletr@hpnsw4371:/ws/charletr/bio-rd$

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.