Skip to content

Commit

Permalink
Add support for DHCP options 35 and 38
Browse files Browse the repository at this point in the history
This patch is adding support for two new DHCP options:

* Option 35, ARP timeout:
  http://www.networksorcery.com/enp/protocol/bootp/option035.htm
* Option 38, TCP Keepalive interval:
  http://www.networksorcery.com/enp/protocol/bootp/option038.htm

I noticed that these two options were missing in OVN while working in
DHCP related code for OpenStack.

Signed-off-by: Lucas Alvares Gomes <lucasagomes@gmail.com>
Acked-by: Flavio Fernandes <flavio@flaviof.com>
Signed-off-by: Numan Siddique <numans@ovn.org>
  • Loading branch information
umago authored and numansiddique committed Apr 27, 2020
1 parent 093f229 commit feb5d6e
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 3 deletions.
5 changes: 5 additions & 0 deletions lib/ovn-l7.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ struct gen_opts_map {
#define DHCP_OPT_TFTP_SERVER_ADDRESS \
DHCP_OPTION("tftp_server_address", 150, "ipv4")

#define DHCP_OPT_ARP_CACHE_TIMEOUT \
DHCP_OPTION("arp_cache_timeout", 35, "uint32")
#define DHCP_OPT_TCP_KEEPALIVE_INTERVAL \
DHCP_OPTION("tcp_keepalive_interval", 38, "uint32")

static inline uint32_t
gen_opt_hash(char *opt_name)
{
Expand Down
2 changes: 2 additions & 0 deletions northd/ovn-northd.c
Original file line number Diff line number Diff line change
Expand Up @@ -11304,6 +11304,8 @@ static struct gen_opts_map supported_dhcp_opts[] = {
DHCP_OPT_PATH_PREFIX,
DHCP_OPT_TFTP_SERVER_ADDRESS,
DHCP_OPT_DOMAIN_NAME,
DHCP_OPT_ARP_CACHE_TIMEOUT,
DHCP_OPT_TCP_KEEPALIVE_INTERVAL,
};

static struct gen_opts_map supported_dhcpv6_opts[] = {
Expand Down
13 changes: 13 additions & 0 deletions ovn-nb.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2852,6 +2852,19 @@
client begins trying to rebind its address. The DHCPv4 option code
for this option is 59.
</column>

<column name="options" key="arp_cache_timeout"
type='{"type": "integer", "minInteger": 0, "maxInteger": 255}'>
The DHCPv4 option code for this option is 35. This option
specifies the timeout in seconds for ARP cache entries.
</column>

<column name="options" key="tcp_keepalive_interval"
type='{"type": "integer", "minInteger": 0, "maxInteger": 255}'>
The DHCPv4 option code for this option is 38. This option
specifies the interval that the client TCP should wait before
sending a keepalive message on a TCP connection.
</column>
</group>

<group title="String DHCP Options">
Expand Down
6 changes: 3 additions & 3 deletions tests/ovn.at
Original file line number Diff line number Diff line change
Expand Up @@ -1188,9 +1188,9 @@ reg1[0] = put_dhcp_opts(offerip = 1.2.3.4, router = 10.0.0.1);
reg2[5] = put_dhcp_opts(offerip=10.0.0.4,router=10.0.0.1,netmask=255.255.254.0,mtu=1400,domain_name="ovn.org",wpad="https://example.org",bootfile_name="https://127.0.0.1/boot.ipxe",path_prefix="/tftpboot");
formats as reg2[5] = put_dhcp_opts(offerip = 10.0.0.4, router = 10.0.0.1, netmask = 255.255.254.0, mtu = 1400, domain_name = "ovn.org", wpad = "https://example.org", bootfile_name = "https://127.0.0.1/boot.ipxe", path_prefix = "/tftpboot");
encodes as controller(userdata=00.00.00.02.00.00.00.00.00.01.de.10.00.00.00.25.0a.00.00.04.03.04.0a.00.00.01.01.04.ff.ff.fe.00.1a.02.05.78.0f.07.6f.76.6e.2e.6f.72.67.fc.13.68.74.74.70.73.3a.2f.2f.65.78.61.6d.70.6c.65.2e.6f.72.67.43.1b.68.74.74.70.73.3a.2f.2f.31.32.37.2e.30.2e.30.2e.31.2f.62.6f.6f.74.2e.69.70.78.65.d2.09.2f.74.66.74.70.62.6f.6f.74,pause)
reg0[15] = put_dhcp_opts(offerip=10.0.0.4,router=10.0.0.1,netmask=255.255.255.0,mtu=1400,ip_forward_enable=1,default_ttl=121,dns_server={8.8.8.8,7.7.7.7},classless_static_route={30.0.0.0/24,10.0.0.4,40.0.0.0/16,10.0.0.6,0.0.0.0/0,10.0.0.1},ethernet_encap=1,router_discovery=0,tftp_server_address={10.0.0.4,10.0.0.5});
formats as reg0[15] = put_dhcp_opts(offerip = 10.0.0.4, router = 10.0.0.1, netmask = 255.255.255.0, mtu = 1400, ip_forward_enable = 1, default_ttl = 121, dns_server = {8.8.8.8, 7.7.7.7}, classless_static_route = {30.0.0.0/24, 10.0.0.4, 40.0.0.0/16, 10.0.0.6, 0.0.0.0/0, 10.0.0.1}, ethernet_encap = 1, router_discovery = 0, tftp_server_address = {10.0.0.4, 10.0.0.5});
encodes as controller(userdata=00.00.00.02.00.00.00.00.00.01.de.10.00.00.00.6f.0a.00.00.04.03.04.0a.00.00.01.01.04.ff.ff.ff.00.1a.02.05.78.13.01.01.17.01.79.06.08.08.08.08.08.07.07.07.07.79.14.18.1e.00.00.0a.00.00.04.10.28.00.0a.00.00.06.00.0a.00.00.01.24.01.01.1f.01.00.96.08.0a.00.00.04.0a.00.00.05,pause)
reg0[15] = put_dhcp_opts(offerip=10.0.0.4,router=10.0.0.1,netmask=255.255.255.0,mtu=1400,ip_forward_enable=1,default_ttl=121,dns_server={8.8.8.8,7.7.7.7},classless_static_route={30.0.0.0/24,10.0.0.4,40.0.0.0/16,10.0.0.6,0.0.0.0/0,10.0.0.1},ethernet_encap=1,router_discovery=0,tftp_server_address={10.0.0.4,10.0.0.5},arp_cache_timeout=10,tcp_keepalive_interval=10);
formats as reg0[15] = put_dhcp_opts(offerip = 10.0.0.4, router = 10.0.0.1, netmask = 255.255.255.0, mtu = 1400, ip_forward_enable = 1, default_ttl = 121, dns_server = {8.8.8.8, 7.7.7.7}, classless_static_route = {30.0.0.0/24, 10.0.0.4, 40.0.0.0/16, 10.0.0.6, 0.0.0.0/0, 10.0.0.1}, ethernet_encap = 1, router_discovery = 0, tftp_server_address = {10.0.0.4, 10.0.0.5}, arp_cache_timeout = 10, tcp_keepalive_interval = 10);
encodes as controller(userdata=00.00.00.02.00.00.00.00.00.01.de.10.00.00.00.6f.0a.00.00.04.03.04.0a.00.00.01.01.04.ff.ff.ff.00.1a.02.05.78.13.01.01.17.01.79.06.08.08.08.08.08.07.07.07.07.79.14.18.1e.00.00.0a.00.00.04.10.28.00.0a.00.00.06.00.0a.00.00.01.24.01.01.1f.01.00.96.08.0a.00.00.04.0a.00.00.05.23.04.00.00.00.0a.26.04.00.00.00.0a,pause)

reg1[0..1] = put_dhcp_opts(offerip = 1.2.3.4, router = 10.0.0.1);
Cannot use 2-bit field reg1[0..1] where 1-bit field is required.
Expand Down
2 changes: 2 additions & 0 deletions tests/test-ovn.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ create_gen_opts(struct hmap *dhcp_opts, struct hmap *dhcpv6_opts,
dhcp_opt_add(dhcp_opts, "bootfile_name", 67, "str");
dhcp_opt_add(dhcp_opts, "path_prefix", 210, "str");
dhcp_opt_add(dhcp_opts, "tftp_server_address", 150, "ipv4");
dhcp_opt_add(dhcp_opts, "arp_cache_timeout", 35, "uint32");
dhcp_opt_add(dhcp_opts, "tcp_keepalive_interval", 38, "uint32");

/* DHCPv6 options. */
hmap_init(dhcpv6_opts);
Expand Down

0 comments on commit feb5d6e

Please sign in to comment.