本文主要是介绍BOND 动态链路聚合 lacp配置及相关问题,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
内容基本都是参考的,哪里有雷同或者错的地方,请批评指正。
针对802.3ad模式的业务分析:
场景:两个千兆网口,聚合成bond0
动态链路聚合抓取数据包格式分析:
后台bond的配置信息:
查看目录 cat /proc/net/bonding/bond0
root@2009:/# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)
Bonding Mode: IEEE 802.3ad Dynamic link aggregation
Transmit Hash Policy: layer3+4 (1)
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0
802.3ad info
LACP rate: fast
Min links: 0
Aggregator selection policy (ad_select): count
System priority: 0
System MAC address: 00:32:12:45:36:ee
Active Aggregator Info:
Aggregator ID: 1
Number of ports: 2
Actor Key: 9
Partner Key: 1
Partner Mac Address: b0:44:14:1d:5e:16
Slave Interface: eth4
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 1
Permanent HW addr: 00:32:12:45:36:ee
Slave queue ID: 0
Aggregator ID: 1
Actor Churn State: none
Partner Churn State: none
Actor Churned Count: 0
Partner Churned Count: 0
details actor lacp pdu:
system priority: 0
system mac address: 00:32:12:45:36:ee
port key: 9
port priority: 255
port number: 1
port state: 63
details partner lacp pdu:
system priority: 32768
system mac address: b0:44:14:1d:5e:16
oper key: 1
port priority: 32768
port number: 2
port state: 61
Slave Interface: eth3
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 1
Permanent HW addr: 00:32:12:45:36:ee
Slave queue ID: 0
Aggregator ID: 1
Actor Churn State: none
Partner Churn State: none
Actor Churned Count: 0
Partner Churned Count: 0
details actor lacp pdu:
system priority: 0
system mac address: 00:32:12:45:36:ee
port key: 9
port priority: 255
port number: 2
port state: 63
details partner lacp pdu:
system priority: 32768
system mac address: b0:44:14:1d:5e:16
oper key: 1
port priority: 32768
port number: 1
port state: 61
注意是事项:Aggregator ID 必须相同才能聚合成功。
双工模式尽量都要配置成自动协商
root@2009:/# ethtool bond0
Settings for bond0:
Supported ports: [ ]
Supported link modes: Not reported
Supported pause frame use: No
Supports auto-negotiation: No
Supported FEC modes: Not reported
Advertised link modes: Not reported
Advertised pause frame use: No
Advertised auto-negotiation: No
Advertised FEC modes: Not reported
Speed: 2000Mb/s
Duplex: Full
Port: Other
PHYAD: 0
Transceiver: internal
Auto-negotiation: off
Link detected: yes
第一次使用必须配置参数:
cat /sys/class/net/bond0/bonding/miimon 链路状态检测,这个或者arp两种检测机制,选择配置一种。
cat /sys/class/net/bond0/bonding/ad_actor_sys_prio bond的优先级 配置成0 吧,这样优先级最高
cat /sys/class/net/bond0/bonding/lacp_rate 发送lacp的速率 配置成fast 吧
困惑及疑问:
1)是不是使用链路聚合,带宽就翻倍?
不是,这个要看具体的聚合mode,并且数据流要多,越多越均匀。
2)802.3ad 怎么查看是否聚合成功?
答:见抓包
3)静态聚合和动态聚合是否可以混合配置,就是一端静态,一端动态?
答:目前通过实验网络可以通,但是没有聚合成功(这个我不确认),因为协商后,速率是1000M
通过最近查的资料,这个是不能协商成功的,因为聚合模式必须相同
4)lacp 报文是哪里发出来了?
答:这个是bond 驱动里面,起了workqueue工作队列,周期性的发送lacpup报文。
5)lacp两端都是动态的,但是hash的算法不同,能协商成功吗,比如一端layer 1,而另一端是layer 3?
答:
6)动态链路聚合遇到坑。
一条流是不能在两个端口,均衡的,它根据hash算法,只能选择一个口。
两条流,内核版本不同,可能在一个口上,也可能在两个口上。
三条流,在两个口上一定是打不满2000M的(这个是错的,看网络拓扑)。
5)lay3+4 最新的hash算法,kernel 4.1以上就变成如下,很多资料现在写的还是老的
hash = (__force u32)flow.ports.ports; //端口号
hash ^= (__force u32)flow_get_u32_dst(&flow) ^ //目的地址
(__force u32)flow_get_u32_src(&flow); //源地址
hash ^= (hash >> 16);
hash ^= (hash >> 8);
return hash >> 1;
slave_agg_no = hash % slaves_in_agg;
802.3ad链路聚合的前提条件:
1)速率必须相同,并且是全双工
2)lacp只能与lacp进行聚合,不能与静态混合聚合
3) 其他细节参考下面文档
内核bond 代码(kernel 2.6.32)处理流程:
收包:netif_receive_skb->__netif_receive_skb->bond_handle_frame(bond_3ad_lacpdu_recv(收lacp))->__netif_receive_skb->ip_rcv
发包:dev_queue_xmit(bond0)->__dev_xmit_skb->sch_direct_xmit->dev_hard_start_xmit->ops->ndo_start_xmit(skb, dev)->bond_start_xmit->__bond_start_xmit->bond_3ad_xor_xmit->bond_dev_queue_xmit->dev_queue_xmit(dev 是eth3)
周期性发lacp报文:bond_work_init_all->INIT_DELAYED_WORK->bond_3ad_state_machine_handler->ad_tx_machine->ad_lacpdu_send
连接地址:
https://www.kernel.org/doc/Documentation/networking/bonding.txt
LACP笔记 - 百度文库
https://en.wikipedia.org/wiki/Link_aggregation#Same_link_speed
LACP报文格式
What is Ethernet Auto-Negotiation? – Fosco Connect
NTRON技术白皮书:网络自动协商机制 - 百度文库
这篇关于BOND 动态链路聚合 lacp配置及相关问题的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!