ovn学习-4-mac学习

前言

localnet port,动态学习ip-mac关系,不走内核,存储在MAC_Binding表里。

分析

过程是这样的,
logic router确定了nexthop的转发端口,用get_arp action来查找nexthop的mac是否已经学习到(在table 66里面)。如果没有,则使用arp action(在table=24里)从转发端口广播一个arp request,logic switch会广播到它下的每一个端口,如果有arp应答,logic switch会回给logic router,logic router会执行put_arp action(在table=17里),同时,ovn-controller会在MAC_Binding表里增加一行记录。ovn-controller收到MAC_Binding表的更新后,添加一条flow到table=66里面。
涉及到的flow如下,

1
2
3
4
5
6
7
8
9
10
table=17, n_packets=1, n_bytes=42, idle_age=65534, hard_age=65534, priority=90,arp,metadata=0x3,arp_op=2 actions=push:NXM_NX_REG0[],push:N
XM_OF_ETH_SRC[],push:NXM_NX_ARP_SHA[],push:NXM_OF_ARP_SPA[],pop:NXM_NX_REG0[],pop:NXM_OF_ETH_SRC[],controller(userdata=00.00.00.01.00.00.00.00),pop:NXM_OF_ETH_SRC[],pop:NXM_NX_REG0[
]
table=22, n_packets=4703, n_bytes=460837, idle_age=0, hard_age=65534, priority=0,ip,metadata=0x3 actions=push:NXM_NX_REG0[],push:NXM_NX_XX
REG0[96..127],pop:NXM_NX_REG0[],mod_dl_dst:00:00:00:00:00:00,resubmit(,66),pop:NXM_NX_REG0[],resubmit(,23)
table=66, n_packets=4702, n_bytes=460739, idle_age=0, hard_age=65534, priority=100,reg0=0xa7f0082,reg15=0x2,metadata=0x3 actions=mod_dl_dst:f6:ba
:43:3d:44:07
table=23, n_packets=5876, n_bytes=575963, idle_age=630, hard_age=65534, priority=0,metadata=0x3 actions=resubmit(,24)
table=24, n_packets=1, n_bytes=98, idle_age=65534, hard_age=65534, priority=100,ip,metadata=0x3,dl_dst=00:00:00:00:00:00 actions=controller(userdata=00.00.00.00.00.00.00.00.00.19.00.10.80.00.06.06.ff.ff.ff.ff.ff.ff.00.00.ff.ff.00.18.00.00.23.20.00.06.00.20.00.40.00.00.00.01.de.10.00.00.20.04.ff.ff.00.18.00.00.23.20.00.06.00.20.00.60.00.00.00.01.de.10.00.00.22.04.00.19.00.10.80.00.2a.02.00.01.00.00.00.00.00.00.ff.ff.00.10.00.00.23.20.00.0e.ff.f8.20.00.00.00)

table=17这条flow解释下(代码函数是pinctrl_handle_put_mac_binding),
执行controller这个action时,reg0=arp_spadl_src=arp_sha,再加上logic input port值,实现了action=(put_arp(inport, arp.spa, arp.sha)),
后面是恢复寄存器的值。userdata的前四个字节是opcode,这里是0x01,表示opcode是ACTION_OPCODE_PUT_ARP