Estou tentando configurar um ambiente semelhante ao descrito aqui no qual a OVN fornecerá serviço DHCP para redes lógicas.
Eu tenho um switch lógico chamado `net0 com duas portas:
[root@ovn0 ~]# ovn-nbctl show
[root@ovn0 ~]# ovn-nbctl show
switch 0507d649-0730-4fdc-95cd-943b25e613ab (net0
port port2
addresses: ["c0:ff:ee:00:00:12 10.0.0.12"]
port port1
addresses: ["c0:ff:ee:00:00:11 10.0.0.11"]
Essas portas estão vinculadas em dois chassis denominados ovn1
e ovn2
:
[root@ovn0 ~]# ovn-sbctl show
Chassis ovn0
hostname: ovn0.virt
Encap geneve
ip: "192.168.122.80"
options: {csum="true"}
Chassis ovn1
hostname: ovn1.virt
Encap geneve
ip: "192.168.122.99"
options: {csum="true"}
Port_Binding port1
Chassis ovn2
hostname: ovn2.virt
Encap geneve
ip: "192.168.122.109"
options: {csum="true"}
Port_Binding port2
On ovn1
, port1
faz parte do br-int
switch:
[root@ovn1 ~]# ovs-vsctl list-ports br-int
ovn-ovn0-0
ovn-ovn2-0
port1
E tem o apropriado iface-id
:
[root@ovn1 ~]# ovs-vsctl list interface port1 |egrep -v '\[]|{}'
_uuid : 63101ec6-be8c-4df7-bdab-e43f8bc4f7f9
admin_state : up
external_ids : {iface-id="port1"}
ifindex : 0
ingress_policing_burst: 0
ingress_policing_rate: 0
link_resets : 1
link_state : up
mac : "c0:ff:ee:00:00:11"
mac_in_use : "c0:ff:ee:00:00:11"
mtu : 1500
name : "port1"
ofport : 2
statistics : {collisions=0, rx_bytes=0, rx_crc_err=0, rx_dropped=0, rx_errors=0, rx_frame_err=0, rx_over_err=0, rx_packets=0, tx_bytes=3672, tx_dropped=0, tx_errors=0, tx_packets=20}
status : {driver_name=openvswitch}
type : internal
Eu configurei as opções do dhcp nessa porta:
[root@ovn0 ~]# ovn-nbctl lsp-get-dhcpv4-options port1
29f9e321-93d1-4974-8cd7-7f65ad376f51 (10.0.0.0/24)
Qual mapa para:
[root@ovn0 ~]# ovn-nbctl list dhcp_options
_uuid : 29f9e321-93d1-4974-8cd7-7f65ad376f51
cidr : "10.0.0.0/24"
external_ids : {}
options : {lease_time="3600", router="10.0.0.1", server_id="10.0.0.1"}
On ovn1
, port1
foi adicionado a um namespace de rede chamado vm1
:
[root@ovn1 ~]# ip netns exec vm1 ip addr
1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
6: port1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default qlen 1000
link/ether c0:ff:ee:00:00:11 brd ff:ff:ff:ff:ff:ff
inet6 fe80::2c8b:65ff:fe00:4/64 scope link
valid_lft forever preferred_lft forever
O endereço MAC corresponde ao endereço MAC configurado anteriormente no banco de dados da porta lógica.
Se eu executar um cliente dhcp no port1 nesse namespace de rede, ele nunca receberá uma resposta:
[root@ovn1 ~]# ip netns exec vm1 dhclient -d port1
Internet Systems Consortium DHCP Client 4.4.1
Copyright 2004-2018 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
Listening on LPF/port1/c0:ff:ee:00:00:11
Sending on LPF/port1/c0:ff:ee:00:00:11
Sending on Socket/fallback
DHCPDISCOVER on port1 to 255.255.255.255 port 67 interval 7 (xid=0x75a05a70)
DHCPDISCOVER on port1 to 255.255.255.255 port 67 interval 21 (xid=0x75a05a70)
.
.
.
No DHCPOFFERS received.
O que mais é necessário para que o OVN responda às solicitações DHCP nesta porta?
Atualização 1
ovn-trace
sugere que uma solicitação dhcp seja transmitida para todas as interfaces:
[root@ovn0 ~]# ovn-trace net0 'inport=="port1" && eth.src==c0:ff:ee:00:00:11 && ip4.src==0.0.0.0 && eth.dst==ff:ff:ff:ff:ff:ff && ip4.dst==255.255.255.255 && udp.src==68 && udp.dst==67'
# udp,reg14=0x2,vlan_tci=0x0000,dl_src=c0:ff:ee:00:00:11,dl_dst=ff:ff:ff:ff:ff:ff,nw_src=0.0.0.0,nw_dst=255.255.255.255,nw_tos=0,nw_ecn=0,nw_ttl=0,tp_src=68,tp_dst=67
ingress(dp="net0", inport="port1")
----------------------------------
0. ls_in_port_sec_l2 (ovn-northd.c:4028): inport == "port1" && eth.src == {c0:ff:ee:00:00:11}, priority 50, uuid e155c87e
next;
1. ls_in_port_sec_ip (ovn-northd.c:3642): inport == "port1" && eth.src == c0:ff:ee:00:00:11 && ip4.src == 0.0.0.0 && ip4.dst == 255.255.255.255 && udp.src == 68 && udp.dst == 67, priority 90, uuid 5548c089
next;
17. ls_in_l2_lkup (ovn-northd.c:5678): eth.mcast, priority 70, uuid 51b48b77
outport = "_MC_flood";
output;
multicast(dp="net0", mcgroup="_MC_flood")
-----------------------------------------
egress(dp="net0", inport="port1", outport="net0-gw")
----------------------------------------------------
9. ls_out_port_sec_l2 (ovn-northd.c:4115): eth.mcast, priority 100, uuid 7db51d27
output;
/* output to "net0-gw", type "" */
egress(dp="net0", inport="port1", outport="port1")
--------------------------------------------------
/* omitting output because inport == outport && !flags.loopback */
egress(dp="net0", inport="port1", outport="port2")
--------------------------------------------------
9. ls_out_port_sec_l2 (ovn-northd.c:4115): eth.mcast, priority 100, uuid 7db51d27
output;
/* output to "port2", type "" */
Acabei descobrindo isso. Eu montei um artigo completo em https://blog.oddbit.com/post/2019-12-19-ovn-and-dhcp/ que percorre todo o processo.
Acho que o principal problema no meu teste anterior foi que, para que o serviço DHCP da OVN responda, você deve definir algumas opções obrigatórias na
dhcp_options
entrada. Eles não estão documentados em nenhum lugar, mas se olharmos para a fonte , veremos:Então, devemos definir
server_id
,server_mac
, elease_time
. Eu estava faltandoserver_mac
no meu teste anterior.