BGP

BGP可能是交换机里面最常用,最重要,或者线上使用的最多的功能了。这一节,我们就来深入的看一下BGP相关的工作流。

BGP相关进程

SONiC使用FRRouting作为BGP的实现,用于负责BGP的协议处理。FRRouting是一个开源的路由软件,支持多种路由协议,包括BGP,OSPF,IS-IS,RIP,PIM,LDP等等。当FRR发布新版本后,SONiC会将其同步到SONiC的FRR实现仓库:sonic-frr中,每一个版本都对应这一个分支,比如frr/8.2

FRR consists of two main parts, the first part is the implementation of each protocol, these processes are named *d, and when they receive notification of routing updates, they tell the second part, which is the zebra process, and then the zebra process will make the route selection and synchronize the optimal routing information to the kernel, the main structure of which is shown in the following figure The main structure is as follows

+----+  +----+  +-----+  +----+  +----+  +----+  +-----+
|bgpd|  |ripd|  |ospfd|  |ldpd|  |pbrd|  |pimd|  |.....|
+----+  +----+  +-----+  +----+  +----+  +----+  +-----+
     |       |        |       |       |       |        |
+----v-------v--------v-------v-------v-------v--------v
|                                                      |
|                         Zebra                        |
|                                                      |
+------------------------------------------------------+
       |                    |                   |
       |                    |                   |
+------v------+   +---------v--------+   +------v------+
|             |   |                  |   |             |
| *NIX Kernel |   | Remote dataplane |   | ........... |
|             |   |                  |   |             |
+-------------+   +------------------+   +-------------+

在SONiC中,这些FRR的进程都跑在bgp的容器中。另外,为了将FRR和Redis连接起来,SONiC在bgp容器中还会运行一个叫做fpgsyncd的进程(Forwarding Plane Manager syncd),它的主要功能是监听kernel的路由更新,然后将其同步到APP_DB中。但是因为这个进程不是FRR的一部分,所以它的实现被放在了sonic-swss仓库中。

参考资料

  1. SONiC Architecture
  2. Github repo: sonic-swss
  3. Github repo: sonic-frr
  4. RFC 4271: A Border Gateway Protocol 4 (BGP-4)
  5. FRRouting