BGP implemented in the Go Programming Language

GoBGP: BGP implementation in Go

Build Status

GoBGP is an open source BGP implementation designed from scratch for modern environment and implemented in a modern programming language, the Go Programming Language.


Install

Try a binary release.

Documentation

Using GoBGP

Externals

Community, discussion and support

We have the Slack for questions, discussion, suggestions, etc.

You have code or documentation for GoBGP? Awesome! Send a pull request. No CLA, board members, governance, or other mess. See BUILD.md for info on code contributing.

Licensing

GoBGP is licensed under the Apache License, Version 2.0. See LICENSE for the full license text.

Comments
  • Support for Administrative Shutdown Communication

    Support for Administrative Shutdown Communication

    These patch enable to send and log "Administrative Shutdown Communication". issues: #1200 Reference: https://tools.ietf.org/html/draft-ietf-idr-shutdown-03

  • EVPN address family can not work

    EVPN address family can not work

    Here is my config file:

    $ more conf/evpn.conf 
    [global.config]
      as = 100
      router-id = "192.168.1.2"
    
    [global.listen-config]
    # listen port (by default 179)
    port = 179
    
    # listen address list (by default "0.0.0.0" and "::")
    local-address-list = ["192.168.1.2"]
    
    [[neighbors]]
    [neighbors.config]
      neighbor-address = "192.168.1.3"
      peer-as = 100
    [[neighbors.afi-safis]]
      [neighbors.afi-safis.config]
      afi-safi-name = "l2vpn-evpn"
    

    But the Open Message that gobgp send to the peer 192.168.1.3 only can support IPv4 unicast.

    screen shot 2016-04-27 at 10 03 06 am
  • Big challenge with default export filters

    Big challenge with default export filters

    Hello!

    I'm using GoBGP as client for 2 BGP router servers. And I hit very_popular and ugly issue - I have reannounced all received prefixes from first uplink to the second and vice versa.

    So fortunately I have filters on opposite side and I haven;t broken Internet.

    So I have multiple questions / suggestions.

    First of all, I want to ask to set default export policy to reject or just reject re-announce prefixes received from other uplink to another.

    If somebody want it it should explicitly enable this.

    I have achieved this with following CLI command:

    gobgp global policy export set default reject    
    

    But I haven't any idea how to do same with configuration file. Could you help me here?

  • extend attributes proto for Prefix SID support

    extend attributes proto for Prefix SID support

    Signed-off-by: Serguei Bezverkhi [email protected]

    It is work in progress, nevertheless comments/suggestions/critics is very welcome.

    Apologies for the large change, VSCode reformatted proto file according to the latest formatting rules.

  • Refactor code that configures a server from config file

    Refactor code that configures a server from config file

    Issue: https://github.com/osrg/gobgp/issues/2106

    Straight-forward refactoring change which greatly simplifies cmd/gobgpd/main.go making it easier to read and follow. It refactors the config file processing code from gobgpd into smaller methods which are easier to understand and makes the flow clearer.

  • Compilation breaks on x86

    Compilation breaks on x86

    Commit 68d2478e2ea1d8607f85e6ab3d4a792e054ce6c2 introduced a change, in packet/bgp/bgp.go:3370 that overflows an int on 32bit architectures. Compiler line: src/github.com/osrg/gobgp/packet/bgp/bgp.go:3370:18: constant 1099511627775 overflows int

  • C/C++ integration code

    C/C++ integration code

    Hello, folks!

    I'm developer of https://github.com/FastVPSEestiOu/fastnetmon and I widely use BGP and Flow Spec.

    My Customers asked me about GoBGP integration https://github.com/FastVPSEestiOu/fastnetmon/issues/389 And I really like your project!

    So I have found this nice page https://github.com/osrg/gobgp/blob/master/docs/sources/grpc-client.md and looking for some way for C++/C integration.

    Thus I could add GoBGP syntax to my BGP Flow Spec library (it's generates flow spec from C structures): https://github.com/FastVPSEestiOu/fastnetmon/blob/master/src/bgp_flow_spec.h and feed it with CLI.

    But I looking for some way for more deeper integration :) Could you help me?

  • Error: Missing mandatory attribute: 01

    Error: Missing mandatory attribute: 01

    Hello, if you try to install a path using the grpc interface and you forget to set the Origin field the grpc interface will install it successfully without the attribute set and will advertise that to neighbors causing the neighbors to drop the connection because a mandatory field is missing.

    Regards.

  • server: Implement TTL security

    server: Implement TTL security

    This patch enable to configure Generalized TTL Security Mechanism (GTSM).

    TTL security enables to specify the minimum TTL(IPv4)/HOPLIMIT(IPv6) which can be accepted. For example, "ttl-min = 255" means that only directly connected peer is acceptable.

    Note: TTL Security feature is mututally exclusive with "neighbors.ebgp-multihop.config".

    fixes https://github.com/osrg/gobgp/issues/1268

  • deletePath not sending withdraw when connected to RR

    deletePath not sending withdraw when connected to RR

    Hello,

    Doing some experimentation. I have gobgp configured (54.54.54.54) to talk to a vendor route reflector (35.121.146.13). Using the gobgp CLI or Java GRPC, when I addPath (ipv4), goBgp correctly sends the route and it is received on the RR.

    The RR then echo's back the route with the RR cluster ID back to gobgp. I can see this route come in via monitor and also in the global rib dump.

    When I try to deletePath, via CLI or Java GRPC, i do NOT see the [DELROUTE] log message. The entry is deleted from the gobgp but a withdraw message is not received on the RR. Therefore the route is not withdrawn.

    **Note: if i disable route-reflector on the other node, gobgp can successful add and withdraw the route. My guess is gobgp is not withdrawing the route it generated due to a collision with the reflected route **

    Here's a step through of what's happening:

    
    # Add the route in gobgp
    
    # ./gobgp global rib -a ipv4 add 5.5.5.5/24 nexthop 10.10.10.10
    
    
    # gobgp monitor outputs the new route :
    
    [ROUTE] 5.5.5.0/24 via 10.10.10.10 aspath [] attrs [{Origin: ?}]
    
    # RR receives the update
    
    116 2018/08/15 17:50:13.443 UTC MINOR: DEBUG #2001 Base Peer 1: 172.10.54.2
    "Peer 1: 172.10.54.2: UPDATE
    Peer 1: 172.10.54.2 - Received BGP UPDATE:
        Withdrawn Length = 0
        Total Path Attr Length = 21
        Flag: 0x40 Type: 1 Len: 1 Origin: 2
        Flag: 0x40 Type: 2 Len: 0 AS Path:
        Flag: 0x40 Type: 3 Len: 4 Nexthop: 10.10.10.10
        Flag: 0x40 Type: 5 Len: 4 Local Preference: 100
        NLRI: Length = 4
            5.5.5.0/24
    "
    
    
    # RR sends a bgp update with the cluster is
    
    117 2018/08/15 17:50:36.951 UTC MINOR: DEBUG #2001 Base Peer 1: 172.10.54.2
    "Peer 1: 172.10.54.2: UPDATE
    Peer 1: 172.10.54.2 - Send BGP UPDATE:
        Withdrawn Length = 0
        Total Path Attr Length = 35
        Flag: 0x40 Type: 1 Len: 1 Origin: 2
        Flag: 0x40 Type: 2 Len: 0 AS Path:
        Flag: 0x40 Type: 3 Len: 4 Nexthop: 10.10.10.10
        Flag: 0x40 Type: 5 Len: 4 Local Preference: 100
        Flag: 0x80 Type: 9 Len: 4 Originator ID: 54.54.54.54
        Flag: 0x80 Type: 10 Len: 4 Cluster ID:
            35.121.146.13
        NLRI: Length = 4
            5.5.5.0/24
    "
    
    # note: gobgp monitor does not have any new output
    
    # gobgp rib output sees both paths
    # ./gobgp global rib
       Network              Next Hop             AS_PATH              Age        Attrs
    *> 5.5.5.0/24           10.10.10.10                               00:02:51   [{Origin: ?}]
    *  5.5.5.0/24           10.10.10.10                               00:02:27   [{Origin: ?} {LocalPref: 100} {Originator: 54.54.54.54} {ClusterList: [35.121.146.13]}]
    
    
    # Sending a delete, log on the RR is empty. Log on gobgp does not show [DELROUTE] but shows [ROUTE] of the entry from the RR
    
    ./gobgp global rib -a ipv4 del 5.5.5.5/24 nexthop 10.10.10.10
    
    [ROUTE] 5.5.5.0/24 via 10.10.10.10 aspath [] attrs [{Origin: ?} {LocalPref: 100} {Originator: 54.54.54.54} {ClusterList: [35.121.146.13]}]
    
    # Attempting to delete the route again is met with:
    
    {"Key":"5.5.5.0/24","Path":{"nlri":{"prefix":"5.5.5.0/24"},"attrs":[{"type":1,"value":2},{"type":3,"nexthop":"10.10.10.10"}],"age":1534355705,"withdrawal":true,"validation":"none"},"Topic":"Table","level":"warning","msg":"No matching path for withdraw found, may be path was not installed into table","time":"2018-08-15T13:55:05-04:00"}
    
  • Radix tree implementation, bytes not strings

    Radix tree implementation, bytes not strings

    I notice in some parts of the code, you're using go-radix to produce a radix tree, however you're doing this by converting the prefix into a string and then converting it back with net.ParseCIDR when the result is found.

    I wondered if you'd considered using critbitgo instead, https://godoc.org/github.com/k-sone/critbitgo allows you to store prefix data in the natural []byte format that is used with the net package. It should produce some nice speedups and reduction in memory -- not just for removing the string dependency, but also because you'll be storing the data in a proper compressed trie.

    Not urgent by any means, as I don't actually tend to use the codepaths this would affect, but I figured it would be nice to remove all the string artefacts :)

  • Add max_batch_size flag to grpc ListPath method

    Add max_batch_size flag to grpc ListPath method

    Adding max_batch_size allows to limit memory consumption on the storing destinations. It is crutial on the full-view scenario, where keeping a huge slice in memory doesn't make any sense.

    Lack of this flag doesn't change previous behaviour.

    This change doesn't break backward compatibility.

  • panic: runtime error: invalid memory address or nil pointer dereference

    panic: runtime error: invalid memory address or nil pointer dereference

    gobgp n 192.168.2.1 adj-in -a ls panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x70 pc=0xa5ad4e]

    goroutine 1 [running]: main.makeShowRouteArgs(0xc00029cb00, 0xc000082220?, {0xc0001217e0?, 0x8?, 0x203000?}, 0x1, 0x0, 0x0, 0x1) /home/runner/work/gobgp/gobgp/cmd/gobgp/neighbor.go:611 +0x90e main.showRoute({0xc0003b6700, 0x63, 0xc0000ae000?}, 0x1, 0xbc?, 0x0, 0x1) /home/runner/work/gobgp/gobgp/cmd/gobgp/neighbor.go:621 +0x9aa main.showNeighborRib({0xc0ca76, 0x6}, {0xc000036490, 0xb}, {0xc000207210, 0x0, 0x1}) /home/runner/work/gobgp/gobgp/cmd/gobgp/neighbor.go:989 +0xc12 main.newNeighborCmd.func1(0xc000230a00?, {0xc000207210?, 0x1?, 0x1?}) /home/runner/work/gobgp/gobgp/cmd/gobgp/neighbor.go:1386 +0x21a github.com/spf13/cobra.(*Command).execute(0xc000230a00, {0xc0002071e0, 0x1, 0x1}) /home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:860 +0x663 github.com/spf13/cobra.(*Command).ExecuteC(0xc000230280) /home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:974 +0x3b4 github.com/spf13/cobra.(*Command).Execute(...) /home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:902 main.newNeighborCmd.func6(0xc000234500?, {0xc0000add00?, 0x4?, 0x4?}) /home/runner/work/gobgp/gobgp/cmd/gobgp/neighbor.go:1475 +0xff github.com/spf13/cobra.(*Command).execute(0xc000234500, {0xc0000adcc0, 0x4, 0x4}) /home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:860 +0x663 github.com/spf13/cobra.(*Command).ExecuteC(0xc00021b180) /home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:974 +0x3b4 github.com/spf13/cobra.(*Command).Execute(...) /home/runner/go/pkg/mod/github.com/spf13/[email protected]/command.go:902 main.main() /home/runner/work/gobgp/gobgp/cmd/gobgp/main.go:32 +0xc5

  • Make generated BGP configuration code public

    Make generated BGP configuration code public

    Move internal/pkg/config -> pkg/bgpconfig

    Please advise if there are internal stuff here and I can try to figure out if I can move them back to internal.

    Background: https://github.com/osrg/gobgp/issues/2593

  • Crash when parsing BGP OPEN

    Crash when parsing BGP OPEN

    A BGP open message where the length of a capability optional parameter is incorrect can cause a crash. For instance the following message will cause GoBGP to crash:

    echo -e '\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\x00\x2c\x01\x04\xfd\xe9\x00\x5a\x01\x02\x03\x04\x0f\x02\x0d\x02\x01\x04\x00\x01\x00\x01\x41\x04\x00\x00\xfd\xe9' | nc localhost 1791

    Crash message:

    goroutine 71 [running]:
    github.com/osrg/gobgp/packet/bgp.(*OptionParameterCapability).DecodeFromBytes(0xc420118460, 0xc420034252, 0x7, 0x7, 0x4, 0x14)
    	/go/src/github.com/osrg/gobgp/packet/bgp/bgp.go:892 +0x2b4
    github.com/osrg/gobgp/packet/bgp.(*BGPOpen).DecodeFromBytes(0xc420030400, 0xc42003424a, 0xf, 0xf, 0xc42000e058, 0x1, 0x1, 0x0, 0xc420053800)
    	/go/src/github.com/osrg/gobgp/packet/bgp/bgp.go:971 +0x2bd
    github.com/osrg/gobgp/packet/bgp.parseBody(0xc42033b870, 0xc420034240, 0x19, 0x19, 0xc42000e058, 0x1, 0x1, 0xb14f40, 0x38a8c201, 0xc42000e058)
    	/go/src/github.com/osrg/gobgp/packet/bgp/bgp.go:8903 +0x2f5
    github.com/osrg/gobgp/packet/bgp.ParseBGPBody(0xc42033b870, 0xc420034240, 0x19, 0x19, 0xc42000e058, 0x1, 0x1, 0x0, 0x0, 0xc42005ee38)
    	/go/src/github.com/osrg/gobgp/packet/bgp/bgp.go:8917 +0x74
    github.com/osrg/gobgp/server.(*FSMHandler).recvMessageWithError(0xc4201910e0, 0xc99208, 0xc4201cd960, 0x0)
    	/go/src/github.com/osrg/gobgp/server/fsm.go:825 +0x70a
    github.com/osrg/gobgp/server.(*FSMHandler).recvMessage(0xc4201910e0, 0x0, 0x0)
    	/go/src/github.com/osrg/gobgp/server/fsm.go:967 +0x61
    github.com/osrg/gobgp/server.(*FSMHandler).(github.com/osrg/gobgp/server.recvMessage)-fm(0x0, 0x0)
    	/go/src/github.com/osrg/gobgp/server/fsm.go:1043 +0x2a
    gopkg.in/tomb%2ev2.(*Tomb).run(0xc4201910e0, 0xc4202e2c10)
    	/go/src/gopkg.in/tomb.v2/tomb.go:163 +0x2b
    created by gopkg.in/tomb%2ev2.(*Tomb).Go
    	/go/src/gopkg.in/tomb.v2/tomb.go:159 +0xb9
    panic: runtime error: slice bounds out of range
    

    I believe this happens because the length field from the message is used to index into the data on line 1074 of bgp.go, and the error is not caught:

    func (o *OptionParameterCapability) DecodeFromBytes(data []byte) error {
      if uint8(len(data)) < o.ParamLen {
        return NewMessageError(BGP_ERROR_OPEN_MESSAGE_ERROR, BGP_ERROR_SUB_UNSUPPORTED_OPTIONAL_PARAMETER, nil, "Not all OptionParameterCapability bytes available")
      }
      for len(data) >= 2 {
        c, err := DecodeCapability(data)
        if err != nil {
          return err
        }
        o.Capability = append(o.Capability, c)
        if c.Len() == 0 || len(data) < c.Len() {
          return NewMessageError(BGP_ERROR_MESSAGE_HEADER_ERROR, BGP_ERROR_SUB_BAD_MESSAGE_LENGTH, nil, "Bad capability length")
        }
        data = data[c.Len():] // <------------------
      }
      return nil
    }
    
Related tags
A simple wrapper around libpcap for the Go programming language

PCAP This is a simple wrapper around libpcap for Go. Originally written by Andreas Krennmair [email protected] and only minorly touched up by Mark Smith

Dec 5, 2022
Diameter stack and Base Protocol (RFC 6733) for the Go programming language

Diameter Base Protocol Package go-diameter is an implementation of the Diameter Base Protocol RFC 6733 and a stack for the Go programming language. St

Dec 28, 2022
SMPP 3.4 Protocol for the Go programming language

SMPP 3.4 This is an implementation of SMPP 3.4 for Go, based on the original smpp34 from Kevin Patel. The API has been refactored to idiomatic Go code

Dec 13, 2022
Basic LDAP v3 functionality for the GO programming language.

Basic LDAP v3 functionality for the GO programming language. Install For the latest version use: go get gopkg.in/ldap.v2 Import the latest version wi

May 24, 2022
Go-web-dev - Web Development With Google's Golang Programming Language Code Snippet and Exercises.

Web Development With Google's Golang Programming Language Code Snippet and Exercises This repository contains my code snippets, hands on exercises and

Jan 16, 2022
A persistent queue implemented in Go.

goq goq is a persistent queue implemented in Go. Features Communication over HTTP RESTful with JSON responses (trivial to write client libraries) Mini

Feb 10, 2022
URI Templates (RFC 6570) implemented in Go

uritemplates -- import "github.com/jtacoma/uritemplates" Package uritemplates is a level 4 implementation of RFC 6570 (URI Template, http://tools.ietf

Jan 15, 2022
communicate with iOS devices implemented with Golang

Golang-iDevice much more easy to use ?? electricbubble/gidevice-cli Installation go get github.com/electricbubble/gidevice Devices package main impor

Dec 18, 2022
A TCP socket based chat server implemented using Go

Go Chat Server A better TCP socket chat server implemented using Go Connecting nc localhost 5000 Docker Build the container image docker build -t grub

Oct 16, 2021
many tools implemented in Golang

Go-Tools many tools implemented in Golang tools project comments abtest AB测试分流 dag_flow DAG工作流 hugo_themes Hugo主题 log_monitor 日志监控服务 pepper_cache 内存kv

Dec 12, 2021
A Twirp RPC OpenAPI generator implemented as `protoc` plugin

twirp-openapi-gen A Twirp RPC OpenAPI generator implemented as protoc plugin Currently supports only OpenAPI 2.0 Usage Installing the generator for pr

May 26, 2022
A simple FTP protocol with client and server implemented in TypeScript and Golang

websocket-ftp A simple FTP protocol with client and server implemented in TypeScript and Golang. Example (Client) const buffer: Uint8Array = (new Text

Apr 14, 2022
Pacemaker - Rate limit library. Currently implemented rate limits are

PaceMaker Rate limit library. Currently implemented rate limits are Fixed window

Nov 5, 2022
Absystem - Golang implemented absystem core api

环境初始化 export GOPROXY=https://goproxy.cn,direct && export GO111MODULE=on # OR go

Feb 16, 2022
The HomeKit Accessory Protocol (hap) implemented in Go
The HomeKit Accessory Protocol (hap) implemented in Go

hap hap (previously hc) is a lightweight library to develop HomeKit accessories in Go. It abstracts the HomeKit Accessory Protocol (HAP) and makes it

Jan 8, 2023
Go network programming framework, supports multiplexing, synchronous and asynchronous IO mode, modular design, and provides flexible custom interfaces
Go network programming framework, supports multiplexing, synchronous and asynchronous IO mode, modular design, and provides flexible custom interfaces

Go network programming framework, supports multiplexing, synchronous and asynchronous IO mode, modular design, and provides flexible custom interfaces。The key is the transport layer, application layer protocol has nothing to do

Nov 7, 2022
A go module supply Java-Like generic stream programming (while do type check at runtime)

gostream A go module supplying Java-Like generic stream programming (while do type check at runtime) Using Get a Stream To get a Stream, using SliceSt

Jan 16, 2022