zl程序教程

您现在的位置是:首页 >  其他

当前栏目

learning:vpp bonding lacp

2023-02-19 12:21:04 时间

前面两篇文章介绍了bond静态模式的基本配置及转发流程。learning:vpp bond learning:vpp bond(2)本文主要介绍一下bond mode lacp 动态链路聚合模式的配置,lacp相关协议的学习请阅读参考资料内容,本文不过多介绍。

基本介绍

lcap相关介绍可以参考文章中H3c的基本介绍,下面通过思维导图方式来从以下几个方面来了解.

LACPDU(Link Aggregation Control Protocol Data Unit,链路聚合控制协议数据单元)

目前vpp代码中只支持设置工作模式和超时时间,其他参数是默认设置,不支持用户配置。工作模式,默认为active模式,可以在成员口在加入bond时设置为passive模式;超时时间默认为3s,同样也可以在成员口加入bond时设置为long-timeout为90S。

bond add <BondEthernetx> <member-interface> [passive] [long-timeout]

LACPDU基本字段包含以下信息:系统LACP优先级(默认0xffff,不支持设置)、系统MAC地址(bond接口mac地址)、端口优先级(默认0xff,不支持设置)、端口编号(根据加入bond顺序动态编号)和操作Key(等于bond接口软件索引)。

组网及配置

基本配置组网如下图所示,其中vpp1中设置为passive模式,vpp2设置成active模式。

1、learning vpp1配置

set interface state GigabitEthernet13/0/0 up
set interface state GigabitEthernet1b/0/0 up
create bond mode lacp load-balance l34 hw-addr 11:22:33:44:55:66 id 2
bond add BondEthernet2 GigabitEthernet13/0/0 passive long-timeout
bond add BondEthernet2 GigabitEthernet1b/0/0 passive long-timeout

set interface state BondEthernet2 up
set interface ip address BondEthernet2 192.168.100.1/24

ip route add 200.1.2.0/24 via 192.168.100.2

set interface state GigabitEthernetb/0/0 up
set interface ip address GigabitEthernetb/0/0 200.1.1.1/24

ifconfig ens161 up
ifconfig ens161 200.1.1.2/24
ip route add 200.1.2.0/24 via 200.1.1.1 dev ens161

2、learning vpp2配置

set interface state GigabitEthernet13/0/0 up
set interface state GigabitEthernet1b/0/0 up
create bond mode lacp load-balance l34 hw-addr 11:22:33:44:55:77 id 2
bond add BondEthernet2 GigabitEthernet13/0/0 long-timeout
bond add BondEthernet2 GigabitEthernet1b/0/0 long-timeout
set interface state BondEthernet2 up
set interface ip address BondEthernet2 192.168.100.2/24
ip route add 200.1.1.0/24 via 192.168.100.1

set interface state GigabitEthernetb/0/0 up
set interface ip address GigabitEthernetb/0/0 200.1.2.1/24
ifconfig ens33 up
ifconfig ens33 200.1.2.2/24
ip route add 200.1.1.0/24 via 200.1.2.1 dev ens33

3、lacp协商过程中详细信息

learning_vpp2# show lacp GigabitEthernet13/0/0 details
Number of interfaces: 2
  GigabitEthernet13/0/0
    Good LACP PDUs received: 1003
    Bad LACP PDUs received: 0
    LACP PDUs sent: 39
    last LACP PDU received:        .31 seconds ago
    last LACP PDU sent:      29.94 seconds ago
    Good Marker PDUs received: 0
    Bad Marker PDUs received: 0
    debug: 0
    loopback port: 0
    port_enabled: 1
    port moved: 0
    ready_n: 1
    ready: 1
    Actor #当前设备lacp信息
      system: 11:22:33:44:55:77
      system priority: 65535
      key: 4 #数值等于bond接口索引
      port priority: 255
      port number: 1
      state: 0x3f
        LACP_STATE_LACP_ACTIVITY (0)
        LACP_STATE_LACP_TIMEOUT (1)
        LACP_STATE_AGGREGATION (2)
        LACP_STATE_SYNCHRONIZATION (3)
        LACP_STATE_COLLECTIING (4)
        LACP_STATE_DISTRIBUTING (5)
    Partner #对端设备lacp基本信息
      system: 11:22:33:44:55:66
      system priority: 65535
      key: 4 #数值等于对端设备bond接口索引。
      port priority: 255
      port number: 1
      state: 0x3c
        LACP_STATE_AGGREGATION (2)
        LACP_STATE_SYNCHRONIZATION (3)
        LACP_STATE_COLLECTIING (4)
        LACP_STATE_DISTRIBUTING (5)
      wait while timer: not running
      current while timer:       2.69 seconds
      periodic timer:        .06 seconds
    RX-state: CURRENT
    TX-state: TRANSMIT
    MUX-state: COLLECTING_DISTRIBUTING
    PTX-state: PERIODIC_TX

4、lacp报文trace流程。 lacp_input节点是在接口加入bond接口时挂载在ethernet-input节点上的,流程如下:

bond_add_member()/*接口加入bond组中*/
|    |--lacp_enable_disable()#钩子函数lacp动态库加载时注册。
|       |--lacp_interface_enable_disable()#动态创建lacp-process node节点 
|           |--lacp_process()lacp node处理函数
|              |--下面挂载lacp-input节点。
ethernet_register_input_type (vm, 
                  ETHERNET_TYPE_SLOW_PROTOCOLS /* LACP */ ,
                lacp_input_node.index);
#在src/vnet/ethernet/type.def定义Lacp宏,ethernet_type (0x8809, SLOW_PROTOCOLS)

lacp协议交互流程详细参见参考文章1、理解并取证:以太通道的动态协商机制的工作原理,说明比较详细,下面是vpp trace抓包如下:

00:25:34:402131: dpdk-input
  GigabitEthernet13/0/0 rx queue 0
  buffer 0x8a94c: current data 0, length 124, buffer-pool 0, ref-count 1, totlen-nifb 0, trace handle 0x0
                  ext-hdr-valid 
                  l4-cksum-computed l4-cksum-correct 
  PKT MBUF: port 1, nb_segs 1, pkt_len 124
    buf_len 2176, data_len 124, ol_flags 0x0, data_off 128, phys_addr 0x36aa5380
    packet_type 0x1 l2_len 0 l3_len 0 outer_l2_len 0 outer_l3_len 0
    rss 0x0 fdir.hi 0x0 fdir.lo 0x0
    Packet Types
      RTE_PTYPE_L2_ETHER (0x0001) Ethernet packet
  SLOW_PROTOCOLS: 00:0c:29:63:94:30 -> 01:80:c2:00:00:02
00:25:34:402169: bond-input
  src 00:0c:29:63:94:30, dst 01:80:c2:00:00:02, GigabitEthernet13/0/0 -> GigabitEthernet13/0/0
00:25:34:402189: ethernet-input
  SLOW_PROTOCOLS: 00:0c:29:63:94:30 -> 01:80:c2:00:00:02
00:25:34:402200: lacp-input
  GigabitEthernet13/0/0:
Length: 110
  LACPv1
  Actor Information TLV: length 20
    System 11:22:33:44:55:66
    System priority 65535
    Key 4
    Port priority 255
    Port number 1
    State 0x3c
      LACP_STATE_AGGREGATION (2)
      LACP_STATE_SYNCHRONIZATION (3)
      LACP_STATE_COLLECTIING (4)
      LACP_STATE_DISTRIBUTING (5)
  Partner Information TLV: length 20
    System 11:22:33:44:55:77
    System priority 65535
    Key 4
    Port priority 255
    Port number 1
    State 0x3f
      LACP_STATE_LACP_ACTIVITY (0)
      LACP_STATE_LACP_TIMEOUT (1)
      LACP_STATE_AGGREGATION (2)
      LACP_STATE_SYNCHRONIZATION (3)
      LACP_STATE_COLLECTIING (4)
      LACP_STATE_DISTRIBUTING (5)
  0x0000:  0101 0114 ffff 1122 3344 5566 0004 00ff
  0x0010:  0001 3c00 0000 0214 ffff 1122 3344 5577
  0x0020:  0004 00ff 0001 3f00 0000 0310 0000 0000
  0x0030:  0000 0000 0000 0000 0000 0000 0000 0000
  0x0040:  0000 0000 0000 0000 0000 0000 0000 0000
  0x0050:  0000 0000 0000 0000 0000 0000 0000 0000
  0x0060:  0000 0000 0000 0000 0000 0000 0000
00:25:34:402212: error-drop
  rx:GigabitEthernet13/0/0
00:25:34:402218: drop
  lacp-input: good lacp packets -- cache hit

参考资料:

1、理解并取证:以太通道的动态协商机制的工作原理 (https://blog.51cto.com/u_7658423/1727401) 2、LACP学习笔记 (http://www.jdccie.com/?p=3105) 3、VPP官方lacp介绍 (https://docs.fd.io/vpp/21.10/d6/d70/lacp_plugin_doc.html) 4、H3c lacp介绍 (http://www.h3c.com/cn/d_201905/1182224_30005_0.htm) 5、华为Lacp介绍 (https://support.huawei.com/enterprise/zh/doc/EDOC1100086517) 6、[vpp dev]LACP link bonding issue (https://www.mail-archive.com/vpp-dev@lists.fd.io/msg07308.html)