On Wed, Jul 27, 2016 at 12:54:39AM +0530, Numan Siddique wrote:
> OVN implements a native DHCPv4 support which caters to the common
> use case of providing an IP address to a booting instance by
> providing stateless replies to DHCPv4 requests based on statically
> configured address mappings. To do this it allows a short list of
> DHCPv4 options to be configured and applied at each compute host
> running ovn-controller.
>
> A new table 'DHCP_Options' is added in OVN NB DB to store the DHCP
> options. Logical ports refer to this table to configure the DHCPv4
> options.
>
> For each logical port configured with DHCPv4 Options following flows
> are added
> - A logical flow which copies the DHCPv4 options to the DHCPv4
> request packets using the 'put_dhcp_opts' action and advances the
> packet to the next stage.
>
> - A logical flow which implements the DHCP reponder by sending
> the DHCPv4 reply back to the inport once the 'put_dhcp_opts' action
> is applied.
>
> Signed-off-by: Numan Siddique <[email protected]>
> Co-authored-by: Ben Pfaff <[email protected]>
> Signed-off-by: Ben Pfaff <[email protected]>
Thanks for the revision!
The check_and_add_supported_dhcp_opts_to_sb_db() function seems awfully
optimistic that, once it adds the DHCP options, nothing could ever make
them go away. I think that's unrealistic: we want ovn-northd to be
resilient against changes to the southbound database, which might be
inadvertent or due to the database getting rolled back or recreated for
various reasons. So I removed the nothing_to_add check there.
I also made some improvements to the documentation.
I'm appending the changes I folded in. With those changes, I applied
this to master. Thanks again!
--8<--------------------------cut here-------------------------->8--
diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c
index 578fbbb..aecc1d8 100644
--- a/ovn/northd/ovn-northd.c
+++ b/ovn/northd/ovn-northd.c
@@ -3288,12 +3288,6 @@ static struct dhcp_opts_map supported_dhcp_opts[] = {
static void
check_and_add_supported_dhcp_opts_to_sb_db(struct northd_context *ctx)
{
- static bool nothing_to_add = false;
-
- if (nothing_to_add) {
- return;
- }
-
struct hmap dhcp_opts_to_add = HMAP_INITIALIZER(&dhcp_opts_to_add);
for (size_t i = 0; (i < sizeof(supported_dhcp_opts) /
sizeof(supported_dhcp_opts[0])); i++) {
@@ -3307,18 +3301,13 @@ check_and_add_supported_dhcp_opts_to_sb_db(struct
northd_context *ctx)
dhcp_opts_find(&dhcp_opts_to_add, opt_row->name);
if (dhcp_opt) {
hmap_remove(&dhcp_opts_to_add, &dhcp_opt->hmap_node);
- }
- else {
+ } else {
sbrec_dhcp_options_delete(opt_row);
}
}
- if (!dhcp_opts_to_add.n) {
- nothing_to_add = true;
- }
-
struct dhcp_opts_map *opt;
- HMAP_FOR_EACH_POP(opt, hmap_node, &dhcp_opts_to_add) {
+ HMAP_FOR_EACH (opt, hmap_node, &dhcp_opts_to_add) {
struct sbrec_dhcp_options *sbrec_dhcp_option =
sbrec_dhcp_options_insert(ctx->ovnsb_txn);
sbrec_dhcp_options_set_name(sbrec_dhcp_option, opt->name);
diff --git a/ovn/ovn-nb.xml b/ovn/ovn-nb.xml
index 86dbfa7..abd0340 100644
--- a/ovn/ovn-nb.xml
+++ b/ovn/ovn-nb.xml
@@ -932,7 +932,7 @@
</column>
</table>
- <table name="DHCP_Options" title="DHCP options.">
+ <table name="DHCP_Options" title="DHCP options">
<p>
OVN implements a native DHCPv4 support which caters to the common
use case of providing an IPv4 address to a booting instance by
@@ -952,34 +952,59 @@
<group title="DHCPv4 options">
<p>
CMS should define the set of DHCPv4 options as key/value pairs in the
- <ref column="options"/> column of this table. In order for the
+ <ref column="options"/> column of this table. For
<code>ovn-controller</code> to include these DHCPv4 options, the
<ref column="dhcpv4_options"/> of <ref table="Logical_Switch_Port"/>
should refer to an entry in this table.
</p>
- <group title="Supported v4 options">
+ <group title="Mandatory DHCPv4 options">
<p>
- Below are the supported DHCPv4 options whose values are IPv4 address
- or addresses. If the value has more than one IPv4 address, then it
- should be enclosed within '{}' braces. Please refer to the
- RFC 2132 <code>"https://tools.ietf.org/html/rfc2132"</code> for
- more details on the DHCPv4 options and their codes.
+ The following options must be defined.
</p>
- <column name="options" key="netmask">
+ <column name="options" key="server_id">
+ The IP address for the DHCP server to use. This should be in the
+ subnet of the offered IP. This is also included in the DHCP offer as
+ option 54, ``server identifier.''
+ </column>
+
+ <column name="options" key="server_mac">
+ The Ethernet address for the DHCP server to use.
+ </column>
+
+ <column name="options" key="router">
<p>
- The DHCPv4 option code for this option is 1.
+ The IP address of a gateway for the client to use. This should be
+ in the subnet of the offered IP. The DHCPv4 option code for this
+ option is 3.
</p>
+ </column>
+ <column name="options" key="lease_time"
+ type='{"type": "integer", "minInteger": 0, "maxInteger":
4294967295}'>
<p>
- Example. key="netmask", value="255.255.255.0"
+ The offered lease time in seconds,
+ </p>
+
+ <p>
+ The DHCPv4 option code for this option is 51.
</p>
</column>
+ </group>
- <column name="options" key="router">
+ <group title="IPv4 DHCP Options">
+ <p>
+ Below are the supported DHCPv4 options whose values are an IPv4
+ address, e.g. <code>192.168.1.1</code>. Some options accept multiple
+ IPv4 addresses enclosed within curly braces, e.g. <code>{192.168.1.2,
+ 192.168.1.3}</code>. Please refer to RFC 2132 for more details on
+ DHCPv4 options and their codes.
+ </p>
+
+ <column name="options" key="netmask">
<p>
- The DHCPv4 option code for this option is 3.
+ The DHCPv4 option code for this option is 1.
</p>
</column>
@@ -1031,12 +1056,6 @@
</p>
</column>
- <column name="options" key="server_id">
- <p>
- The DHCPv4 option code for this option is 54.
- </p>
- </column>
-
<column name="options" key="tftp_server">
<p>
The DHCPv4 option code for this option is 66.
@@ -1056,9 +1075,7 @@
</p>
<p>
- Example.
- key="classless_static_route"
- value="{30.0.0.0/24,10.0.0.10, 0.0.0.0/0,10.0.0.1}"
+ Example: <code>{30.0.0.0/24,10.0.0.10, 0.0.0.0/0,10.0.0.1}</code>
</p>
</column>
@@ -1069,125 +1086,70 @@
Microsoft Windows DHCPv4 clients.
</p>
</column>
-
- <column name="options" key="server_mac">
- <p>
- <code>eth.src</code> will be set to this value in the DHCPv4
- response packet.
- </p>
- </column>
</group>
- <group title="Other supported DHCPv4 options">
- <column name="options" key="ip_forward_enable">
- <p>
- The DHCPv4 option code for this option is 19.
- </p>
+ <group title="Boolean DHCP Options">
+ <p>
+ These options accept a Boolean value, expressed as <code>0</code> for
+ false or <code>1</code> for true.
+ </p>
+ <column name="options" key="ip_forward_enable"
+ type='{"type": "string", "enum": ["set", ["0", "1"]]}'>
<p>
- The value of this DHCPv4 option is of type <code>bool</code>.
-
- Example. key="ip_forward_enable", value="1"
+ The DHCPv4 option code for this option is 19.
</p>
</column>
- <column name="options" key="router_discovery">
+ <column name="options" key="router_discovery"
+ type='{"type": "string", "enum": ["set", ["0", "1"]]}'>
<p>
The DHCPv4 option code for this option is 31.
</p>
-
- <p>
- The value of this DHCPv4 option is of type <code>bool</code>.
- </p>
</column>
- <column name="options" key="ethernet_encap">
+ <column name="options" key="ethernet_encap"
+ type='{"type": "string", "enum": ["set", ["0", "1"]]}'>
<p>
The DHCPv4 option code for this option is 36.
</p>
-
- <p>
- The value of this DHCPv4 option is of type <code>bool</code>.
- </p>
- </column>
-
- <column name="options" key="default_ttl">
- <p>
- The DHCPv4 option code for this option is 23.
- </p>
-
- <p>
- The value of this DHCPv4 option is of type <code>uint8</code>.
-
- Example. key="default_ttl", value="128".
- </p>
</column>
+ </group>
- <column name="options" key="tcp_ttl">
- <p>
- The DHCPv4 option code for this option is 37.
- </p>
+ <group title="Integer DHCP Options">
+ <p>
+ These options accept a nonnegative integer value.
+ </p>
- <p>
- The value of this DHCPv4 option is of type <code>uint8</code>.
- </p>
+ <column name="options" key="default_ttl"
+ type='{"type": "integer", "minInteger": 0, "maxInteger": 255}'>
+ The DHCPv4 option code for this option is 23.
</column>
- <column name="options" key="mtu">
- <p>
- The DHCPv4 option code for this option is 26.
- </p>
-
- <p>
- The value of this DHCPv4 option is of type <code>uint16</code>.
- </p>
+ <column name="options" key="tcp_ttl"
+ type='{"type": "integer", "minInteger": 0, "maxInteger": 255}'>
+ The DHCPv4 option code for this option is 37.
</column>
- <column name="options" key="lease_time">
- <p>
- The DHCPv4 option code for this option is 51.
- </p>
-
- <p>
- The value of this DHCPv4 option is of type <code>uint32</code>.
-
- Example. key="lease_time", value="42000"
- </p>
+ <column name="options" key="mtu"
+ type='{"type": "integer", "minInteger": 68, "maxInteger":
65535}'>
+ The DHCPv4 option code for this option is 26.
</column>
- <column name="options" key="T1">
- <p>
- The DHCPv4 option code for this option is 58.
- </p>
-
- <p>
- The value of this DHCPv4 option is of type <code>uint32</code>.
-
- Example. key="T1", value="30000"
- </p>
+ <column name="options" key="T1"
+ type='{"type": "integer", "minInteger": 68, "maxInteger":
4294967295}'>
+ This specifies the time interval from address assignment until the
+ client begins trying to renew its address. The DHCPv4 option code
+ for this option is 58.
</column>
- <column name="options" key="T2">
- <p>
- The DHCPv4 option code for this option is 59.
- </p>
-
- <p>
- The value of this DHCPv4 option is of type <code>uint32</code>.
-
- Example. key="T2", value="40000"
- </p>
+ <column name="options" key="T2"
+ type='{"type": "integer", "minInteger": 68, "maxInteger":
4294967295}'>
+ This specifies the time interval from address assignment until the
+ client begins trying to rebind its address. The DHCPv4 option code
+ for this option is 59.
</column>
</group>
-
- <group title="Mandatory DHCPv4 options">
- <p>
- DHCPv4 options <code>"server_id"</code>, <code>"server_mac"</code>,
- <code>"router"</code> and <code>"lease_time"</code> are mandatory
- options which CMS should define for <code>OVN</code> to support
- native DHCPv4.
- </p>
- </group>
</group>
<group title="Common Columns">
_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev