diff mbox series

[ovs-dev] ovn-controller: Support processing DHCPv6 information request message type

Message ID 20181010171859.28097-1-nusiddiq@redhat.com
State Accepted
Headers show
Series [ovs-dev] ovn-controller: Support processing DHCPv6 information request message type | expand

Commit Message

Numan Siddique Oct. 10, 2018, 5:18 p.m. UTC
From: Numan Siddique <nusiddiq@redhat.com>

When 'dhcpv6_stateless' is configured on the logical router ports,
the client will send DHCPv6 information request message type (using
dhclient -6 -S) to get additional options like dns-server. This
patch supports this option. Ideally we should have supported this
option when the DHCPv6 support was added.

Signed-off-by: Numan Siddique <nusiddiq@redhat.com>
---
 ovn/controller/pinctrl.c | 16 +++++++++++++---
 ovn/lib/ovn-l7.h         |  1 +
 tests/ovn.at             | 35 ++++++++++++++++++++++++++++++-----
 3 files changed, 44 insertions(+), 8 deletions(-)

Comments

Ben Pfaff Oct. 11, 2018, 8:13 p.m. UTC | #1
On Wed, Oct 10, 2018 at 10:48:59PM +0530, nusiddiq@redhat.com wrote:
> From: Numan Siddique <nusiddiq@redhat.com>
> 
> When 'dhcpv6_stateless' is configured on the logical router ports,
> the client will send DHCPv6 information request message type (using
> dhclient -6 -S) to get additional options like dns-server. This
> patch supports this option. Ideally we should have supported this
> option when the DHCPv6 support was added.
> 
> Signed-off-by: Numan Siddique <nusiddiq@redhat.com>

Applied, thanks!
Numan Siddique Oct. 12, 2018, 12:37 a.m. UTC | #2
On Fri, Oct 12, 2018, 1:43 AM Ben Pfaff <blp@ovn.org> wrote:

> On Wed, Oct 10, 2018 at 10:48:59PM +0530, nusiddiq@redhat.com wrote:
> > From: Numan Siddique <nusiddiq@redhat.com>
> >
> > When 'dhcpv6_stateless' is configured on the logical router ports,
> > the client will send DHCPv6 information request message type (using
> > dhclient -6 -S) to get additional options like dns-server. This
> > patch supports this option. Ideally we should have supported this
> > option when the DHCPv6 support was added.
> >
> > Signed-off-by: Numan Siddique <nusiddiq@redhat.com>
>
> Applied, thanks!
>

Thanks for the review.
Is it possible to backport to 2.10 ? Even though this seems like a feature
but it fixes the dhcpc6 stateless configuration.

Thanks
Numan
Ben Pfaff Oct. 12, 2018, 12:53 a.m. UTC | #3
On Fri, Oct 12, 2018 at 06:07:51AM +0530, Numan Siddique wrote:
> On Fri, Oct 12, 2018, 1:43 AM Ben Pfaff <blp@ovn.org> wrote:
> 
> > On Wed, Oct 10, 2018 at 10:48:59PM +0530, nusiddiq@redhat.com wrote:
> > > From: Numan Siddique <nusiddiq@redhat.com>
> > >
> > > When 'dhcpv6_stateless' is configured on the logical router ports,
> > > the client will send DHCPv6 information request message type (using
> > > dhclient -6 -S) to get additional options like dns-server. This
> > > patch supports this option. Ideally we should have supported this
> > > option when the DHCPv6 support was added.
> > >
> > > Signed-off-by: Numan Siddique <nusiddiq@redhat.com>
> >
> > Applied, thanks!
> >
> 
> Thanks for the review.

You're welcome.

> Is it possible to backport to 2.10 ? Even though this seems like a feature
> but it fixes the dhcpc6 stateless configuration.

Done.
diff mbox series

Patch

diff --git a/ovn/controller/pinctrl.c b/ovn/controller/pinctrl.c
index 69a811902..e3ee516e4 100644
--- a/ovn/controller/pinctrl.c
+++ b/ovn/controller/pinctrl.c
@@ -788,6 +788,11 @@  compose_out_dhcpv6_opts(struct ofpbuf *userdata,
                 return false;
             }
 
+            if (!iaid) {
+                /* If iaid is None, it means its an DHCPv6 information request.
+                 * Don't put IA_NA option in the response. */
+                 break;
+            }
             /* IA Address option is used to specify IPv6 addresses associated
              * with an IA_NA or IA_TA. The IA Address option must be
              * encapsulated in the Options field of an IA_NA or IA_TA option.
@@ -896,7 +901,8 @@  pinctrl_handle_put_dhcpv6_opts(
     }
 
     uint8_t out_dhcpv6_msg_type;
-    switch(*in_dhcpv6_data) {
+    uint8_t in_dhcpv6_msg_type = *in_dhcpv6_data;
+    switch (in_dhcpv6_msg_type) {
     case DHCPV6_MSG_TYPE_SOLICIT:
         out_dhcpv6_msg_type = DHCPV6_MSG_TYPE_ADVT;
         break;
@@ -904,6 +910,7 @@  pinctrl_handle_put_dhcpv6_opts(
     case DHCPV6_MSG_TYPE_REQUEST:
     case DHCPV6_MSG_TYPE_CONFIRM:
     case DHCPV6_MSG_TYPE_DECLINE:
+    case DHCPV6_MSG_TYPE_INFO_REQ:
         out_dhcpv6_msg_type = DHCPV6_MSG_TYPE_REPLY;
         break;
 
@@ -916,7 +923,10 @@  pinctrl_handle_put_dhcpv6_opts(
     in_dhcpv6_data += 4;
     /* We need to extract IAID from the IA-NA option of the client's DHCPv6
      * solicit/request/confirm packet and copy the same IAID in the Server's
-     * response. */
+     * response.
+     * DHCPv6 information packet (for stateless request will not have IA-NA
+     * option. So we don't need to copy that in the Server's response.
+     * */
     ovs_be32 iaid = 0;
     struct dhcpv6_opt_header const *in_opt_client_id = NULL;
     size_t udp_len = ntohs(in_udp->udp_len);
@@ -950,7 +960,7 @@  pinctrl_handle_put_dhcpv6_opts(
         goto exit;
     }
 
-    if (!iaid) {
+    if (!iaid && in_dhcpv6_msg_type != DHCPV6_MSG_TYPE_INFO_REQ) {
         VLOG_WARN_RL(&rl, "DHCPv6 option - IA NA not present in the "
                      " DHCPv6 packet");
         goto exit;
diff --git a/ovn/lib/ovn-l7.h b/ovn/lib/ovn-l7.h
index 817e9f002..08c3da54a 100644
--- a/ovn/lib/ovn-l7.h
+++ b/ovn/lib/ovn-l7.h
@@ -151,6 +151,7 @@  struct dhcp_opt6_header {
 #define DHCPV6_MSG_TYPE_CONFIRM     4
 #define DHCPV6_MSG_TYPE_REPLY       7
 #define DHCPV6_MSG_TYPE_DECLINE     9
+#define DHCPV6_MSG_TYPE_INFO_REQ    11
 
 
 /* DHCPv6 Option codes */
diff --git a/tests/ovn.at b/tests/ovn.at
index 44475175d..eda79c3ae 100644
--- a/tests/ovn.at
+++ b/tests/ovn.at
@@ -4615,15 +4615,23 @@  trim_zeros() {
 # from the "ovs-ofctl monitor br-int resume"
 test_dhcpv6() {
     local inport=$1 src_mac=$2 src_lla=$3 msg_code=$4 offer_ip=$5
-    local request=ffffffffffff${src_mac}86dd00000000002a1101${src_lla}
+    if test $msg_code != 0b; then
+        req_len=2a
+    else
+        req_len=1a
+    fi
+    local request=ffffffffffff${src_mac}86dd0000000000${req_len}1101${src_lla}
     # dst ip ff02::1:2
     request=${request}ff020000000000000000000000010002
     # udp header and dhcpv6 header
-    request=${request}02220223002affff${msg_code}010203
+    request=${request}0222022300${req_len}ffff${msg_code}010203
     # Client identifier
     request=${request}0001000a00030001${src_mac}
-    # IA-NA (Identity Association for Non Temporary Address)
-    request=${request}0003000c0102030400000e1000001518
+    # Add IA-NA (Identity Association for Non Temporary Address) if msg_code
+    # is not 11 (information request packet)
+    if test $msg_code != 0b; then
+        request=${request}0003000c0102030400000e1000001518
+    fi
     shift; shift; shift; shift; shift;
     if test $offer_ip != 0; then
         local server_mac=000000100001
@@ -4754,7 +4762,7 @@  cat 4.expected > expout
 AT_CHECK([cat 4.packets], [0], [expout])
 
 # Send DHCPv6 packet on ls1-lp3. native DHCPv6 works as stateless mode for this port.
-# The DHCPv6 reply should doesn't contian offer_ip.
+# The DHCPv6 reply shouldn't contain offer_ip.
 src_mac=f00000000022
 src_lla=fe80000000000000f20000fffe000022
 reset_pcap_file hv1-vif5 hv1/vif5
@@ -4768,6 +4776,23 @@  $PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif5-tx.pcap | trim_zeros > 5.pa
 cat 5.expected | cut -c 1-120,125- > expout
 AT_CHECK([cat 5.packets | cut -c 1-120,125- ], [0], [expout])
 
+# Send DHCPv6 information request (code 11) on ls1-lp3. The DHCPv6 reply
+# shouldn't contain offer_ip
+src_mac=f00000000022
+src_lla=fe80000000000000f20000fffe000022
+reset_pcap_file hv1-vif5 hv1/vif5
+rm -f 5.expected
+test_dhcpv6 5 $src_mac $src_lla 0b 1 5
+
+# NXT_RESUMEs should be 4.
+OVS_WAIT_UNTIL([test 4 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`])
+
+$PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif5-tx.pcap |
+trim_zeros > 5.packets
+# Skipping the UDP checksum
+cat 5.expected | cut -c 1-120,125- > expout
+AT_CHECK([cat 5.packets | cut -c 1-120,125- ], [0], [expout])
+
 as hv1
 OVS_APP_EXIT_AND_WAIT([ovn-controller])
 OVS_APP_EXIT_AND_WAIT([ovs-vswitchd])