Skip to content

Commit

Permalink
ovn-controller: Add 'put_dhcpv6_opts' action in ovn-controller
Browse files Browse the repository at this point in the history
This patch adds a new OVN action 'put_dhcpv6_opts' to support native
DHCPv6 in OVN.

ovn-controller parses this action and adds a NXT_PACKET_IN2
OF flow with 'pause' flag set and the DHCPv6 options stored in
'userdata' field.

When the valid DHCPv6 packet is received by ovn-controller, it frames a
new DHCPv6 reply packet with the DHCPv6 options present in the
'userdata' field and resumes the packet and stores 1 in the 1-bit subfield.
If the packet is invalid, it resumes the packet without any modifying and
stores 0 in the 1-bit subfield.

Eg. reg0[3] = put_dhcpv6_opts(ia_addr = aef0::4, server_id = 00:00:00:00:10:02,
                     dns_server = {ae70::1,ae70::2}....)

A new 'DHCPv6_Options' table is added in SB DB which stores
the supported DHCPv6 options with DHCPv6 code and type. ovn-northd is
expected to popule this table.

Upcoming patch will add logical flows using this action.

Signed-off-by: Numan Siddique <[email protected]>
Signed-off-by: Ben Pfaff <[email protected]>
  • Loading branch information
numansiddique authored and blp committed Aug 14, 2016
1 parent d3254e2 commit 01cfdb2
Show file tree
Hide file tree
Showing 9 changed files with 667 additions and 6 deletions.
12 changes: 12 additions & 0 deletions include/ovn/actions.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@ enum action_opcode {
* MFF_ETH_SRC = mac
*/
ACTION_OPCODE_PUT_ND,

/* "result = put_dhcpv6_opts(option, ...)".
*
* Arguments follow the action_header, in this format:
* - A 32-bit or 64-bit OXM header designating the result field.
* - A 32-bit integer specifying a bit offset within the result field.
* - Any number of DHCPv6 options.
*/
ACTION_OPCODE_PUT_DHCPV6_OPTS,
};

/* Header. */
Expand All @@ -107,6 +116,9 @@ struct action_params {
/* hmap of 'struct dhcp_opts_map' to support 'put_dhcp_opts' action */
const struct hmap *dhcp_opts;

/* hmap of 'struct dhcp_opts_map' to support 'put_dhcpv6_opts' action */
const struct hmap *dhcpv6_opts;

/* Looks up logical port 'port_name'. If found, stores its port number in
* '*portp' and returns true; otherwise, returns false. */
bool (*lookup_port)(const void *aux, const char *port_name,
Expand Down
16 changes: 14 additions & 2 deletions ovn/controller/lflow.c
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ static void consider_logical_flow(const struct lport_index *lports,
struct group_table *group_table,
const struct simap *ct_zones,
struct hmap *dhcp_opts_p,
struct hmap *dhcpv6_opts_p,
uint32_t *conj_id_ofs_p);

static bool
Expand Down Expand Up @@ -271,17 +272,25 @@ add_logical_flows(struct controller_ctx *ctx, const struct lport_index *lports,
}

struct hmap dhcp_opts = HMAP_INITIALIZER(&dhcp_opts);
struct hmap dhcpv6_opts = HMAP_INITIALIZER(&dhcpv6_opts);
const struct sbrec_dhcp_options *dhcp_opt_row;
SBREC_DHCP_OPTIONS_FOR_EACH(dhcp_opt_row, ctx->ovnsb_idl) {
dhcp_opt_add(&dhcp_opts, dhcp_opt_row->name, dhcp_opt_row->code,
dhcp_opt_row->type);
}


const struct sbrec_dhcpv6_options *dhcpv6_opt_row;
SBREC_DHCPV6_OPTIONS_FOR_EACH(dhcpv6_opt_row, ctx->ovnsb_idl) {
dhcp_opt_add(&dhcpv6_opts, dhcpv6_opt_row->name, dhcpv6_opt_row->code,
dhcpv6_opt_row->type);
}

if (full_logical_flow_processing) {
SBREC_LOGICAL_FLOW_FOR_EACH (lflow, ctx->ovnsb_idl) {
consider_logical_flow(lports, mcgroups, lflow, local_datapaths,
patched_datapaths, group_table, ct_zones,
&dhcp_opts, &conj_id_ofs);
&dhcp_opts, &dhcpv6_opts, &conj_id_ofs);
}
full_logical_flow_processing = false;
} else {
Expand All @@ -299,12 +308,13 @@ add_logical_flows(struct controller_ctx *ctx, const struct lport_index *lports,
consider_logical_flow(lports, mcgroups, lflow,
local_datapaths, patched_datapaths,
group_table, ct_zones,
&dhcp_opts, &conj_id_ofs);
&dhcp_opts, &dhcpv6_opts, &conj_id_ofs);
}
}
}

dhcp_opts_destroy(&dhcp_opts);
dhcp_opts_destroy(&dhcpv6_opts);
}

static void
Expand All @@ -316,6 +326,7 @@ consider_logical_flow(const struct lport_index *lports,
struct group_table *group_table,
const struct simap *ct_zones,
struct hmap *dhcp_opts_p,
struct hmap *dhcpv6_opts_p,
uint32_t *conj_id_ofs_p)
{
/* Determine translation of logical table IDs to physical table IDs. */
Expand Down Expand Up @@ -388,6 +399,7 @@ consider_logical_flow(const struct lport_index *lports,
struct action_params ap = {
.symtab = &symtab,
.dhcp_opts = dhcp_opts_p,
.dhcpv6_opts = dhcpv6_opts_p,
.lookup_port = lookup_port_cb,
.aux = &aux,
.ct_zones = ct_zones,
Expand Down
Loading

0 comments on commit 01cfdb2

Please sign in to comment.