How can I flexibly use 'BGP' that supports the heart of the Internet?

Many people have seen the words 'IP address' and 'provider' when using the Internet. The Internet uses a large number of protocols such as

IP and TCP for communication. Among them, the protocol used in the center of the Internet is the ' Border Gateway Protocol (BGP) '. Network engineer Jordan Whited has released a library ' CoreBGP ' that provides plugins for more flexible use of BPG.

CoreBGP-Plugging in to BGP | Jordan Whited

BGP is a type of routing protocol that determines the destination of communication, and typical routing protocols include RIP and OSPF in addition to BGP. Since BGP is a protocol used in the center of the Internet, it is likely to be affected by misconfigurations. The failure that occurred in Cloudflare in July 2020 was also due to a BGP misconfiguration.

Cloudflare impacts large-scale failures that bring down 50% of the network, large sites such as Discord and Feedly-GIGAZINE

Routing protocols are roughly classified into a distance vector type in which the distance and direction to the destination are exchanged between adjacent routers, and a link state type in which all routers hold a route diagram of the entire network, and BGP is classified into a distance vector type. Protocol to be used. To be precise, path vector type route control, which is an extension of the distance vector type, is performed.

A router that operates BGP is called a 'BGP speaker', and BGP speakers can establish a 'BGP peer' and exchange route information to control the destination of communication automatically. BGP speakers interact with other BGP speakers via the following four messages.

-OPEN: A message sent to establish a BGP peer after establishing a TCP connection with an adjacent router (BGP neighbor).
-UPDATE: A message containing route information. Sent when the settings of the BGP speaker are changed.
-KEEPALIVE: Message to confirm whether communication with the BGP neighbor is possible.
-NOTIFICATION: A message reporting an error.

In addition, the establishment of BGP peers has the following six stages.

-Idle: A state in which BGP is set and nothing is done yet.
-Connect: Waiting for the establishment of a TCP connection with a BGP neighbor.
-Active: A state in which an attempt is being made to establish a TCP connection.
-OpenSent: Waiting for an OPEN message from a BGP neighbor. After receiving, if there is no problem, send KEEPALIVE message, and if there is a problem, send NOTIFICATION message.
-OpenConfirm: Waiting for KEEPALIVED or NOTIFICATION message from the BGP neighbor. If there is a problem receiving the KEEPALIVED message or if you receive the NOTIFICATION message, return to the Idle state.
-Established: A state in which a BGP peer is established and UPDATE messages can be sent and received.

There are

BIRD , GoBGP , OpenDaylight , Quagga, etc. as open source BGP implementations, all of which are stable enough to be used by large-scale Internet providers, cloud providers, and Internet Exchange (IX) , Whited said. However, it is difficult to use the original data structure as the routing table or customize the notation method of the setting contents with the existing implementation. In addition, when extending the functions of routing protocols, it is necessary to convince the manufacturer of the router and the IETF , and it takes a long time.

In order to solve these problems, the paper '

The Case for Pluginized Routing Protocols ' presented at IEEE ICNP 2019 advocated 'plug-in of routing protocol'. Using ' FRRouting ', which is an open source BGP implementation, we have proposed a function extension by a plug-in mainly for message reception and branching operation with the received content as a flag. The function 'eBPF' of the Linux kernel that executes the program executed in the user space in the virtual machine in the kernel space is used to implement the plug-in, and the plug-in can be loaded without affecting the original protocol. It is said that.

Whited points out that the approach in The Case for Pluginized Routing Protocols is 'stimulating', but focuses only on receiving messages. Therefore, Whited developed the BGP library 'CoreBGP' that can be used in the entire application that supports BGP. CoreBGP is written in Go and has functions such as sending and verifying OPEN messages, processing received UPDATE messages, and sending UPDATE messages.

GitHub-jwhited/corebgp: CoreBGP is a BGP library written in Go that implements the BGP FSM with an event-driven, pluggable model.

CoreBGP will serve as the basis for a full-fledged BGP daemon, or simply as logging UPDATE messages. Code examples are

published on GitHub, and you can send and receive BGP messages by specifying IP number and AS number.

The concrete implementation of CoreBGP is as follows. 'Get Capabilities' that acquires information such as OPEN messages in the Connect state and...

When receiving an OPEN message in the OpenSent state, send a NOTIFICATION message to put the BGP peer in the Idle state 'OnOpenMessage'

'On Established' to exchange UPDATE messages in the Established state

You can use 'OnClose' that occurs when the state of the BGP piano is no longer Established.

Sample code using CoreBGP is also available, and you can process BGP messages by specifying the IP address, AS number, etc.

in Software, Posted by darkhorse_log