以配置MTU 了解SONIC网络操作系统命令配置流程

介绍

总览

本文档介绍了SONiC中的最大传输单元(MTU)配置和行为。在计算机网络中,层的通信协议的MTU定义了允许该层通过一个接口传输的最大协议数据单元的大小(以字节为单位)。每个接口,层和协议都与一个MTU关联。

在SONiC中,基于层的接口有两种类型的MTU。
1.端口MTU(第2层):以太网帧可以携带的最大字节数。
2. IP MTU(第3层):允许通过L3接口传输的IP有效负载的最大大小,不包括L2标头和尾部。

要求

1.默认的MTU为1500,可配置范围为68字节至9216字节。最小以太网帧为64字节,但我们的Linux主机只能占用68字节作为最小MTU。因此,我们选择68个字节作为下限。
2.在ASIC上配置的MTU比在相应主机接口上配置的MTU多22字节,其中包括L2头(14字节),FCS头(4字节)和Vlan标签(4字节)的开销。
3.端口MTU和IP MTU可以在同一接口上配置为不同的值。但是,IP MTU应该由端口MTU限制。否则,端口MTU较大的IP数据包可能仍会退出主机接口,但会被ASIC丢弃。

条件

1.通过新的Config DB模型配置端口MTU和IP MTU设置。

Port MTU

通过与CFG管理器通信的CLI或Restful API配置端口MTU,后者将更新CFG DB中的相应端口对象。然后portsyncd将在Linux环境下通过ip link set / ifconfig命令设置主机接口的MTU。成功后,portsyncd会将配置推送到APP DB内的PORT_TABLE中。如果PORT_TABLE有任何更改,则其订户PortsOrch将向相应的MTU添加额外的22个字节,写入SAI DB并对ASIC进行编程。
在这里插入图片描述

Host Interface MTU
	admin@sonic:~$ sudo ifconfig Ethernet0
Ethernet0 Link encap:Ethernet  HWaddr 00:05:64:30:17:ec  
          inet addr:10.1.0.1  Bcast:10.1.0.255  Mask:255.255.255.0
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
APP DB Schema

PORT_TABLE
Stores information for physical switch ports managed by the switch chip.

    ;Defines layer 2 ports
    ;In SONiC, Data is loaded from configuration file by portsyncd
    ;Status: Mandatory
    port_table_key      = PORT_TABLE:ifname    ; ifname must be unique across PORT,INTF,VLAN,LAG TABLES
    device_name         = 1*64VCHAR     ; must be unique across PORT,INTF,VLAN,LAG TABLES and must map to PORT_TABLE.name
    admin_status        = BIT           ; is the port enabled (1) or disabled (0)
    oper_status         = BIT           ; physical status up (1) or down (0) of the link attached to this port
    lanes               = list of lanes ; (need format spec???)
ifname              = 1*64VCHAR     ; name of the port, must be unique
    mtu         = 1*4DIGIT                  ; MTU for the interface
    mac                 = 12HEXDIG      ;
example:
127.0.0.1:6379> hgetall PORT_TABLE:Ethernet0
 1) "lanes"
 2) "1"
 3) "alias"
 4) "Ethernet0"
 5) "oper_status"
 6) "down"
 7) "admin_status"
 8) "down"
 9) "mtu"
10) "1500"

请注意,相同的架构适用于LAG。因此,也可以在LAG上配置端口MTU,并且每个LAG成员端口都将从LAG继承端口MTU。

例如,我们为LAG team0配置了3个成员端口Etherent10,Ethernet11和Ethernet12,其默认MTU为1500。更改team0的MTU后,成员端口MTU也将进行相应更新。

	admin@sonic:~$ sudo ifconfig team0 mtu 1600
	admin@sonic:~$ redis-cli -n 0 keys *LAG*
1) "LAG_MEMBER_TABLE:team0:Ethernet10"
2) "LAG_MEMBER_TABLE:team0:Ethernet12"
3) "LAG_MEMBER_TABLE:team0:Ethernet11"
4) "LAG_TABLE:team0"
admin@sonic:~$ redis-cli -n 0 hgetall LAG_TABLE:team0
1) "admin_status"
2) "down"
3) "oper_status"
4) "down"
5) "mtu"
6) "1600"
admin@sonic:~$ redis-cli -n 0 hgetall "PORT_TABLE:Ethernet10"
 1) "lanes"
 2) "11"
 3) "alias"
 4) "Ethernet10"
 5) "oper_status"
 6) "up"
 7) "admin_status"
 8) "up"
 9) "mtu"
10) "1600"
admin@sonic:~$ redis-cli -n 0 hgetall "PORT_TABLE:Ethernet11"
 1) "lanes"
 2) "12"
 3) "alias"
 4) "Ethernet11"
 5) "oper_status"
 6) "up"
 7) "admin_status"
 8) "up"
 9) "mtu"
10) "1600"
admin@sonic:~$ redis-cli -n 0 hgetall "PORT_TABLE:Ethernet12"
 1) "lanes"
 2) "21"
 3) "alias"
 4) "Ethernet12"
 5) "oper_status"
 6) "up"
 7) "admin_status"
 8) "up"
 9) "mtu"
10) "1600"

SAI Attribute

sai_attribute_t attr;
attr.id = SAI_PORT_ATTR_MTU;
attr.value.u32 = mtu;

SAI API

sai_status_t status = sai_port_api->set_port_attribute(id, &attr);

IP MTU

同样,IP MTU也通过CLI / Restful API配置,该API设置CFG DB中路由器接口对象的if_mtu值。然后,Intfsyncd将相应的更改复制到APP DB中。在收到来自APP DB的更新通知后,IntfsOrch将if_mtu值推入SAI DB,并在sai路由器接口创建期间将MTU属性添加到属性列表。

APP DB Schema
 INTF_TABLE
intfsyncd manages this table.  In SONiC, CPU (management) and logical ports (vlan, loopback, LAG) are declared in /etc/network/interface and loaded into the INTF_TABLE.

IP prefixes are formatted according to [RFC5954](https://tools.ietf.org/html/rfc5954) with a prefix length appended to the end

    ;defines logical network interfaces, an attachment to a PORT and list of 0 or more
    ;ip prefixes
    ;
    ;Status: stable
    key            = INTF_TABLE:ifname:IPprefix   ; an instance of this key will be repeated for each prefix
    IPprefix       = IPv4prefix / IPv6prefix   ; an instance of this key/value pair will be repeated for each prefix
    scope          = "global" / "local"        ; local is an interface visible on this localhost only
    if_mtu         = 1*4DIGIT                  ; MTU for the interface
family         = "IPv4" / "IPv6"           ; address family
example:
127.0.0.1:6379> hgetall INTF_TABLE:Ethernet0:10.1.0.1/24
1) "scope"
2) "global"
3) "family"
4) "IPv4"
5) "if_mtu"
6) "1500"

SAI Attribute

if_attr.id = SAI_ROUTER_INTERFACE_ATTR_MTU;
rif_attr.value.u32 = mtu;
rif_attrs.push_back(rif_attr);

SAI API

sai_status_t status = sai_rif_api->create_router_interface(&rif_id, rif_attrs.size(), rif_attrs.data());

Limitations

1.当前brcm_sai中未处理SAI_ROUTER_INTERFACE_ATTR_MTU。因此,无法使用ip mtu正确编程asic。为Broadcom提供了修复。
2.当前SONiC中没有路由器接口的属性更新路径。因此,只能在创建路由器接口时设置ip mtu。在配置数据库和接口架构就绪后,需要实现set_router_interface_attribute和get_router_interface_attribute。

MTU设计

如果在Linux主机接口上配置了内核MTU,则相应的端口将使用具有额外22个字节的内核MTU作为SAI_PORT_ATTR_MTU。在端口上创建的任何路由器接口都将使用内核MTU作为SAI_ROUTER_INTERFACE_ATTR_MTU。
总结:
Kernel MTU = IP MTU = Port MTU – 22 Bytes

Config DB Schema
"PORT": {
    "Ethernet8": {
        "alias": "Ethernet9",
         "mtu": "1500"
    },
    …
 },

"PORTCHANNEL": {
    "PortChannel10": {
        "fallback": "true", 
        "members": [
            "Ethernet10"
        ], 
         "mtu": "1500"
    },
    …
 },
  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值