|
|
9219d1 |
From 9ad199184959deac21b3dbf0efbbb3d23f6baed1 Mon Sep 17 00:00:00 2001
|
|
|
9219d1 |
Message-Id: <9ad199184959deac21b3dbf0efbbb3d23f6baed1.1599568829.git.lorenzo.bianconi@redhat.com>
|
|
|
9219d1 |
From: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
|
|
|
9219d1 |
Date: Wed, 26 Aug 2020 12:15:46 +0200
|
|
|
9219d1 |
Subject: [PATCH] Introduce DHCPDECLINE msg support to OVN DHCP server
|
|
|
9219d1 |
|
|
|
9219d1 |
According to the RFC2131 (https://tools.ietf.org/html/rfc2131), if the
|
|
|
9219d1 |
server server receives a DHCPDECLINE message, the client has discovered
|
|
|
9219d1 |
through some other means that the suggested network address is already
|
|
|
9219d1 |
in use. The server SHOULD notify the local system administrator of a
|
|
|
9219d1 |
possible configuration problem.
|
|
|
9219d1 |
|
|
|
9219d1 |
Signed-off-by: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
|
|
|
9219d1 |
Signed-off-by: Numan Siddique <numans@ovn.org>
|
|
|
9219d1 |
---
|
|
|
9219d1 |
controller/pinctrl.c | 6 ++++++
|
|
|
9219d1 |
lib/ovn-l7.h | 1 +
|
|
|
9219d1 |
tests/ovn.at | 13 +++++++++++++
|
|
|
9219d1 |
3 files changed, 20 insertions(+)
|
|
|
9219d1 |
|
|
|
9219d1 |
--- a/controller/pinctrl.c
|
|
|
9219d1 |
+++ b/controller/pinctrl.c
|
|
|
9219d1 |
@@ -1889,6 +1889,12 @@ pinctrl_handle_put_dhcp_opts(
|
|
|
9219d1 |
|
|
|
9219d1 |
break;
|
|
|
9219d1 |
}
|
|
|
9219d1 |
+ case OVN_DHCP_MSG_DECLINE:
|
|
|
9219d1 |
+ if (request_ip == *offer_ip) {
|
|
|
9219d1 |
+ VLOG_INFO("DHCPDECLINE from "ETH_ADDR_FMT ", "IP_FMT" duplicated",
|
|
|
9219d1 |
+ ETH_ADDR_ARGS(in_flow->dl_src), IP_ARGS(*offer_ip));
|
|
|
9219d1 |
+ }
|
|
|
9219d1 |
+ goto exit;
|
|
|
9219d1 |
default: {
|
|
|
9219d1 |
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(1, 5);
|
|
|
9219d1 |
VLOG_WARN_RL(&rl, "Invalid DHCP message type: %d", *in_dhcp_msg_type);
|
|
|
9219d1 |
--- a/lib/ovn-l7.h
|
|
|
9219d1 |
+++ b/lib/ovn-l7.h
|
|
|
9219d1 |
@@ -180,6 +180,7 @@ struct dhcp_opt6_header {
|
|
|
9219d1 |
};
|
|
|
9219d1 |
|
|
|
9219d1 |
/* These are not defined in ovs/lib/dhcp.h, hence defining here. */
|
|
|
9219d1 |
+#define OVN_DHCP_MSG_DECLINE 4
|
|
|
9219d1 |
#define OVN_DHCP_MSG_RELEASE 7
|
|
|
9219d1 |
#define OVN_DHCP_MSG_INFORM 8
|
|
|
9219d1 |
|
|
|
9219d1 |
--- a/tests/ovn.at
|
|
|
9219d1 |
+++ b/tests/ovn.at
|
|
|
9219d1 |
@@ -5332,6 +5332,10 @@ test_dhcp() {
|
|
|
9219d1 |
reply_dst_ip=${offer_ip}
|
|
|
9219d1 |
fi
|
|
|
9219d1 |
|
|
|
9219d1 |
+ if test "$dhcp_type" == "04"; then
|
|
|
9219d1 |
+ ciaddr=$offer_ip
|
|
|
9219d1 |
+ fi
|
|
|
9219d1 |
+
|
|
|
9219d1 |
local request=ffffffffffff${src_mac}08004510${ip_len}0000000080110000${src_ip}${dst_ip}
|
|
|
9219d1 |
# udp header and dhcp header
|
|
|
9219d1 |
request=${request}00440043${udp_len}0000
|
|
|
9219d1 |
@@ -5897,6 +5901,15 @@ AT_CHECK([cat 2.packets | cut -c -48], [
|
|
|
9219d1 |
cat 2.expected | cut -c 53- > expout
|
|
|
9219d1 |
AT_CHECK([cat 2.packets | cut -c 53-], [0], [expout])
|
|
|
9219d1 |
|
|
|
9219d1 |
+# test DHCPDECLINE
|
|
|
9219d1 |
+offer_ip=`ip_to_hex 10 0 0 4`
|
|
|
9219d1 |
+server_ip=`ip_to_hex 10 0 0 1`
|
|
|
9219d1 |
+ciaddr=`ip_to_hex 0 0 0 0`
|
|
|
9219d1 |
+request_ip=0
|
|
|
9219d1 |
+expected_dhcp_opts=""
|
|
|
9219d1 |
+test_dhcp 1 f00000000001 04 0 $ciaddr $offer_ip $request_ip 0 ff1000000001 $server_ip 02 $expected_dhcp_opts
|
|
|
9219d1 |
+AT_CHECK([fgrep -iq 'DHCPDECLINE from f0:00:00:00:00:01, 10.0.0.4 duplicated' hv1/ovn-controller.log], [0], [])
|
|
|
9219d1 |
+
|
|
|
9219d1 |
OVN_CLEANUP([hv1])
|
|
|
9219d1 |
|
|
|
9219d1 |
AT_CLEANUP
|