2

I'm trying to set up an environment similar to the one described here in which OVN will provide DHCP service to logical networks.

I have a logical switch named `net0 with two ports:

[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"]

Those ports are bound on two chassis named ovn1 and 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 is part of the br-int switch:

[root@ovn1 ~]# ovs-vsctl list-ports br-int
ovn-ovn0-0
ovn-ovn2-0
port1

And it has the appropriate 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

I have configured dhcp options on that port:

[root@ovn0 ~]# ovn-nbctl lsp-get-dhcpv4-options port1
29f9e321-93d1-4974-8cd7-7f65ad376f51 (10.0.0.0/24)

Which map to:

[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 has been added to a network namespace named 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

The MAC address matches the MAC address configured earlier in the logical port database.

If I run a dhcp client against port1 in that network namespace, it never gets a reply:

[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.

What else is necessary to get OVN to respond to DHCP requests on this port?

Update 1

ovn-trace suggests that a dhcp request just gets broadcast out all 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 "" */
larsks
  • 41,276
  • 13
  • 117
  • 170

1 Answers1

2

I eventually figured this out. I've put together a complete write-up at https://blog.oddbit.com/post/2019-12-19-ovn-and-dhcp/ that walks through the whole process.

I think the key problem in my earlier test was that in order for the OVN DHCP service to respond you must set some mandatory options in the dhcp_options entry. These aren't documented anywhere, but if we look at the source we see:

    const char *server_ip = smap_get(
        &op->nbsp->dhcpv4_options->options, "server_id");
    const char *server_mac = smap_get(
        &op->nbsp->dhcpv4_options->options, "server_mac");
    const char *lease_time = smap_get(
        &op->nbsp->dhcpv4_options->options, "lease_time");

    if (!(server_ip && server_mac && lease_time)) {
        /* "server_id", "server_mac" and "lease_time" should be
         * present in the dhcp_options. */
        static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
        VLOG_WARN_RL(&rl, "Required DHCPv4 options not defined for lport - %s",
                     op->json_key);
        return false;
    }

So, we must set server_id, server_mac, and lease_time. I was missing server_mac in my earlier test.

larsks
  • 41,276
  • 13
  • 117
  • 170