|
|
bbaaef |
From 1abcdb8d6995fac449e1a06dfd5a2b25ed888daa Mon Sep 17 00:00:00 2001
|
|
|
bbaaef |
From: Ihar Hrachyshka <ihrachys@redhat.com>
|
|
|
bbaaef |
Date: Thu, 5 Mar 2020 20:44:24 -0500
|
|
|
bbaaef |
Subject: [PATCH] Broadcast DHCPREPLY when BROADCAST flag is set
|
|
|
bbaaef |
|
|
|
bbaaef |
As per RFC2131, section 4.1:
|
|
|
bbaaef |
A server or relay agent sending or relaying a DHCP message directly
|
|
|
bbaaef |
to a DHCP client (i.e., not to a relay agent specified in the
|
|
|
bbaaef |
'giaddr' field) SHOULD examine the BROADCAST bit in the 'flags'
|
|
|
bbaaef |
field. If this bit is set to 1, the DHCP message SHOULD be sent as
|
|
|
bbaaef |
an IP broadcast using an IP broadcast address (preferably 0xffffffff)
|
|
|
bbaaef |
as the IP destination address and the link-layer broadcast address as
|
|
|
bbaaef |
the link-layer destination address.
|
|
|
bbaaef |
|
|
|
bbaaef |
This patch changes destination IP address to 255.255.255.255 when client
|
|
|
bbaaef |
set BROADCAST flag in their DHCPREQUEST. Note: the offered IP address is
|
|
|
bbaaef |
still part of the DHCP payload.
|
|
|
bbaaef |
|
|
|
bbaaef |
While the new DHCP response is sent as a broadcast IP frame, it's
|
|
|
bbaaef |
handled locally, as any other DHCP reply by the native responder.
|
|
|
bbaaef |
Meaning, the reply is sent to the client port that initiated the DHCP
|
|
|
bbaaef |
session only.
|
|
|
bbaaef |
|
|
|
bbaaef |
Reported-at: https://bugzilla.redhat.com/show_bug.cgi?id=1801006
|
|
|
bbaaef |
|
|
|
bbaaef |
Backport changes:
|
|
|
bbaaef |
* ovs_srcdir -> top_srcdir in tests
|
|
|
bbaaef |
|
|
|
bbaaef |
Signed-off-by: Ihar Hrachyshka <ihrachys@redhat.com>
|
|
|
bbaaef |
Signed-off-by: Numan Siddique <numans@ovn.org>
|
|
|
bbaaef |
(cherry picked from commit 4f8045b3b5f2c3376f86f5edc4e3f7507c2b1148)
|
|
|
bbaaef |
---
|
|
|
bbaaef |
ovn/controller/pinctrl.c | 15 ++++++
|
|
|
bbaaef |
ovn/lib/ovn-l7.h | 2 +
|
|
|
bbaaef |
ovn/northd/ovn-northd.8.xml | 5 +-
|
|
|
bbaaef |
ovn/northd/ovn-northd.c | 7 ++-
|
|
|
bbaaef |
tests/ovn.at | 98 +++++++++++++++++++++++++++----------
|
|
|
bbaaef |
5 files changed, 93 insertions(+), 34 deletions(-)
|
|
|
bbaaef |
|
|
|
bbaaef |
diff --git a/ovn/controller/pinctrl.c b/ovn/controller/pinctrl.c
|
|
|
bbaaef |
index 01a1bcbe0..2c7c2b217 100644
|
|
|
bbaaef |
--- a/ovn/controller/pinctrl.c
|
|
|
bbaaef |
+++ b/ovn/controller/pinctrl.c
|
|
|
bbaaef |
@@ -972,6 +972,12 @@ pinctrl_handle_tcp_reset(struct rconn *swconn, const struct flow *ip_flow,
|
|
|
bbaaef |
dp_packet_uninit(&packet);
|
|
|
bbaaef |
}
|
|
|
bbaaef |
|
|
|
bbaaef |
+static bool
|
|
|
bbaaef |
+is_dhcp_flags_broadcast(ovs_be16 flags)
|
|
|
bbaaef |
+{
|
|
|
bbaaef |
+ return flags & htons(DHCP_BROADCAST_FLAG);
|
|
|
bbaaef |
+}
|
|
|
bbaaef |
+
|
|
|
bbaaef |
/* Called with in the pinctrl_handler thread context. */
|
|
|
bbaaef |
static void
|
|
|
bbaaef |
pinctrl_handle_put_dhcp_opts(
|
|
|
bbaaef |
@@ -1196,7 +1202,16 @@ pinctrl_handle_put_dhcp_opts(
|
|
|
bbaaef |
|
|
|
bbaaef |
udp->udp_len = htons(new_l4_size);
|
|
|
bbaaef |
|
|
|
bbaaef |
+ /* Send a broadcast IP frame when BROADCAST flag is set. */
|
|
|
bbaaef |
struct ip_header *out_ip = dp_packet_l3(&pkt_out);
|
|
|
bbaaef |
+ ovs_be32 ip_dst;
|
|
|
bbaaef |
+ if (!is_dhcp_flags_broadcast(dhcp_data->flags)) {
|
|
|
bbaaef |
+ ip_dst = *offer_ip;
|
|
|
bbaaef |
+ } else {
|
|
|
bbaaef |
+ ip_dst = htonl(0xffffffff);
|
|
|
bbaaef |
+ }
|
|
|
bbaaef |
+ put_16aligned_be32(&out_ip->ip_dst, ip_dst);
|
|
|
bbaaef |
+
|
|
|
bbaaef |
out_ip->ip_tot_len = htons(pkt_out.l4_ofs - pkt_out.l3_ofs + new_l4_size);
|
|
|
bbaaef |
udp->udp_csum = 0;
|
|
|
bbaaef |
/* Checksum needs to be initialized to zero. */
|
|
|
bbaaef |
diff --git a/ovn/lib/ovn-l7.h b/ovn/lib/ovn-l7.h
|
|
|
bbaaef |
index ae6dbfdfb..c43218224 100644
|
|
|
bbaaef |
--- a/ovn/lib/ovn-l7.h
|
|
|
bbaaef |
+++ b/ovn/lib/ovn-l7.h
|
|
|
bbaaef |
@@ -32,6 +32,8 @@ struct gen_opts_map {
|
|
|
bbaaef |
size_t code;
|
|
|
bbaaef |
};
|
|
|
bbaaef |
|
|
|
bbaaef |
+#define DHCP_BROADCAST_FLAG 0x8000
|
|
|
bbaaef |
+
|
|
|
bbaaef |
#define DHCP_OPTION(NAME, CODE, TYPE) \
|
|
|
bbaaef |
{.name = NAME, .code = CODE, .type = TYPE}
|
|
|
bbaaef |
|
|
|
bbaaef |
diff --git a/ovn/northd/ovn-northd.8.xml b/ovn/northd/ovn-northd.8.xml
|
|
|
bbaaef |
index 04be2e7c7..c09e5ff44 100644
|
|
|
bbaaef |
--- a/ovn/northd/ovn-northd.8.xml
|
|
|
bbaaef |
+++ b/ovn/northd/ovn-northd.8.xml
|
|
|
bbaaef |
@@ -855,7 +855,6 @@ next;
|
|
|
bbaaef |
|
|
|
bbaaef |
eth.dst = eth.src;
|
|
|
bbaaef |
eth.src = E;
|
|
|
bbaaef |
-ip4.dst = A;
|
|
|
bbaaef |
ip4.src = S;
|
|
|
bbaaef |
udp.src = 67;
|
|
|
bbaaef |
udp.dst = 68;
|
|
|
bbaaef |
@@ -866,8 +865,8 @@ output;
|
|
|
bbaaef |
|
|
|
bbaaef |
|
|
|
bbaaef |
where E is the server MAC address and S is the
|
|
|
bbaaef |
- server IPv4 address defined in the DHCPv4 options and A is
|
|
|
bbaaef |
- the IPv4 address defined in the logical port's addresses column.
|
|
|
bbaaef |
+ server IPv4 address defined in the DHCPv4 options. Note that
|
|
|
bbaaef |
+ ip4.dst field is handled by put_dhcp_opts .
|
|
|
bbaaef |
|
|
|
bbaaef |
|
|
|
bbaaef |
|
|
|
bbaaef |
diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c
|
|
|
bbaaef |
index b324fa8e0..abe5508c3 100644
|
|
|
bbaaef |
--- a/ovn/northd/ovn-northd.c
|
|
|
bbaaef |
+++ b/ovn/northd/ovn-northd.c
|
|
|
bbaaef |
@@ -4180,10 +4180,9 @@ build_dhcpv4_action(struct ovn_port *op, ovs_be32 offer_ip,
|
|
|
bbaaef |
ds_put_cstr(options_action, "); next;");
|
|
|
bbaaef |
|
|
|
bbaaef |
ds_put_format(response_action, "eth.dst = eth.src; eth.src = %s; "
|
|
|
bbaaef |
- "ip4.dst = "IP_FMT"; ip4.src = %s; udp.src = 67; "
|
|
|
bbaaef |
- "udp.dst = 68; outport = inport; flags.loopback = 1; "
|
|
|
bbaaef |
- "output;",
|
|
|
bbaaef |
- server_mac, IP_ARGS(offer_ip), server_ip);
|
|
|
bbaaef |
+ "ip4.src = %s; udp.src = 67; udp.dst = 68; "
|
|
|
bbaaef |
+ "outport = inport; flags.loopback = 1; output;",
|
|
|
bbaaef |
+ server_mac, server_ip);
|
|
|
bbaaef |
|
|
|
bbaaef |
ds_put_format(ipv4_addr_match,
|
|
|
bbaaef |
"ip4.src == "IP_FMT" && ip4.dst == {%s, 255.255.255.255}",
|
|
|
bbaaef |
diff --git a/tests/ovn.at b/tests/ovn.at
|
|
|
bbaaef |
index 3ce8514e5..dd94776e6 100644
|
|
|
bbaaef |
--- a/tests/ovn.at
|
|
|
bbaaef |
+++ b/tests/ovn.at
|
|
|
bbaaef |
@@ -4567,10 +4567,11 @@ sleep 2
|
|
|
bbaaef |
as hv1 ovs-vsctl show
|
|
|
bbaaef |
|
|
|
bbaaef |
# This shell function sends a DHCP request packet
|
|
|
bbaaef |
-# test_dhcp INPORT SRC_MAC DHCP_TYPE OFFER_IP REQUEST_IP ...
|
|
|
bbaaef |
+# test_dhcp INPORT SRC_MAC DHCP_TYPE BROADCAST CIADDR OFFER_IP REQUEST_IP USE_IP ...
|
|
|
bbaaef |
test_dhcp() {
|
|
|
bbaaef |
- local inport=$1 src_mac=$2 dhcp_type=$3 ciaddr=$4 offer_ip=$5 request_ip=$6 use_ip=$7
|
|
|
bbaaef |
- shift; shift; shift; shift; shift; shift; shift;
|
|
|
bbaaef |
+ local inport=$1 src_mac=$2 dhcp_type=$3 broadcast=$4 ciaddr=$5 offer_ip=$6 request_ip=$7 use_ip=$8
|
|
|
bbaaef |
+ shift; shift; shift; shift; shift; shift; shift; shift;
|
|
|
bbaaef |
+
|
|
|
bbaaef |
if test $use_ip != 0; then
|
|
|
bbaaef |
src_ip=$1
|
|
|
bbaaef |
dst_ip=$2
|
|
|
bbaaef |
@@ -4579,6 +4580,7 @@ test_dhcp() {
|
|
|
bbaaef |
src_ip=`ip_to_hex 0 0 0 0`
|
|
|
bbaaef |
dst_ip=`ip_to_hex 255 255 255 255`
|
|
|
bbaaef |
fi
|
|
|
bbaaef |
+
|
|
|
bbaaef |
if test $request_ip != 0; then
|
|
|
bbaaef |
ip_len=0120
|
|
|
bbaaef |
udp_len=010b
|
|
|
bbaaef |
@@ -4586,10 +4588,19 @@ test_dhcp() {
|
|
|
bbaaef |
ip_len=011a
|
|
|
bbaaef |
udp_len=0106
|
|
|
bbaaef |
fi
|
|
|
bbaaef |
+
|
|
|
bbaaef |
+ if test $broadcast != 0; then
|
|
|
bbaaef |
+ flags=8000
|
|
|
bbaaef |
+ reply_dst_ip=`ip_to_hex 255 255 255 255`
|
|
|
bbaaef |
+ else
|
|
|
bbaaef |
+ flags=0000
|
|
|
bbaaef |
+ reply_dst_ip=${offer_ip}
|
|
|
bbaaef |
+ fi
|
|
|
bbaaef |
+
|
|
|
bbaaef |
local request=ffffffffffff${src_mac}08004510${ip_len}0000000080110000${src_ip}${dst_ip}
|
|
|
bbaaef |
# udp header and dhcp header
|
|
|
bbaaef |
request=${request}00440043${udp_len}0000
|
|
|
bbaaef |
- request=${request}010106006359aa7600000000${ciaddr}000000000000000000000000${src_mac}
|
|
|
bbaaef |
+ request=${request}010106006359aa760000${flags}${ciaddr}000000000000000000000000${src_mac}
|
|
|
bbaaef |
# client hardware padding
|
|
|
bbaaef |
request=${request}00000000000000000000
|
|
|
bbaaef |
# server hostname
|
|
|
bbaaef |
@@ -4627,10 +4638,10 @@ test_dhcp() {
|
|
|
bbaaef |
ip_len=$(printf "%x" $ip_len)
|
|
|
bbaaef |
udp_len=$(printf "%x" $udp_len)
|
|
|
bbaaef |
# $ip_len var will be in 3 digits i.e 134. So adding a '0' before $ip_len
|
|
|
bbaaef |
- local reply=${src_mac}${srv_mac}080045100${ip_len}000000008011XXXX${srv_ip}${offer_ip}
|
|
|
bbaaef |
+ local reply=${src_mac}${srv_mac}080045100${ip_len}000000008011XXXX${srv_ip}${reply_dst_ip}
|
|
|
bbaaef |
# udp header and dhcp header.
|
|
|
bbaaef |
# $udp_len var will be in 3 digits. So adding a '0' before $udp_len
|
|
|
bbaaef |
- reply=${reply}004300440${udp_len}0000020106006359aa7600000000${ciaddr}
|
|
|
bbaaef |
+ reply=${reply}004300440${udp_len}0000020106006359aa760000${flags}${ciaddr}
|
|
|
bbaaef |
# your ip address; 0 for NAK
|
|
|
bbaaef |
if test $dhcp_reply_type = 06; then
|
|
|
bbaaef |
reply=${reply}00000000
|
|
|
bbaaef |
@@ -4701,7 +4712,7 @@ server_ip=`ip_to_hex 10 0 0 1`
|
|
|
bbaaef |
ciaddr=`ip_to_hex 0 0 0 0`
|
|
|
bbaaef |
request_ip=0
|
|
|
bbaaef |
expected_dhcp_opts=330400000e100104ffffff0003040a00000136040a000001
|
|
|
bbaaef |
-test_dhcp 1 f00000000001 01 $ciaddr $offer_ip $request_ip 0 ff1000000001 $server_ip 02 $expected_dhcp_opts
|
|
|
bbaaef |
+test_dhcp 1 f00000000001 01 0 $ciaddr $offer_ip $request_ip 0 ff1000000001 $server_ip 02 $expected_dhcp_opts
|
|
|
bbaaef |
|
|
|
bbaaef |
# NXT_RESUMEs should be 1.
|
|
|
bbaaef |
OVS_WAIT_UNTIL([test 1 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`])
|
|
|
bbaaef |
@@ -4727,7 +4738,7 @@ server_ip=`ip_to_hex 10 0 0 1`
|
|
|
bbaaef |
ciaddr=`ip_to_hex 0 0 0 0`
|
|
|
bbaaef |
request_ip=$offer_ip
|
|
|
bbaaef |
expected_dhcp_opts=330400000e100104ffffff0003040a00000136040a000001
|
|
|
bbaaef |
-test_dhcp 2 f00000000002 03 $ciaddr $offer_ip $request_ip 0 ff1000000001 $server_ip 05 $expected_dhcp_opts
|
|
|
bbaaef |
+test_dhcp 2 f00000000002 03 0 $ciaddr $offer_ip $request_ip 0 ff1000000001 $server_ip 05 $expected_dhcp_opts
|
|
|
bbaaef |
|
|
|
bbaaef |
# NXT_RESUMEs should be 2.
|
|
|
bbaaef |
OVS_WAIT_UNTIL([test 2 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`])
|
|
|
bbaaef |
@@ -4751,7 +4762,7 @@ server_ip=`ip_to_hex 10 0 0 1`
|
|
|
bbaaef |
ciaddr=`ip_to_hex 0 0 0 0`
|
|
|
bbaaef |
request_ip=`ip_to_hex 10 0 0 7`
|
|
|
bbaaef |
expected_dhcp_opts=""
|
|
|
bbaaef |
-test_dhcp 2 f00000000002 03 $ciaddr $offer_ip $request_ip 0 ff1000000001 $server_ip 06 $expected_dhcp_opts
|
|
|
bbaaef |
+test_dhcp 2 f00000000002 03 0 $ciaddr $offer_ip $request_ip 0 ff1000000001 $server_ip 06 $expected_dhcp_opts
|
|
|
bbaaef |
|
|
|
bbaaef |
# NXT_RESUMEs should be 3.
|
|
|
bbaaef |
OVS_WAIT_UNTIL([test 3 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`])
|
|
|
bbaaef |
@@ -4775,7 +4786,7 @@ rm -f 2.expected
|
|
|
bbaaef |
ciaddr=`ip_to_hex 0 0 0 0`
|
|
|
bbaaef |
offer_ip=0
|
|
|
bbaaef |
request_ip=0
|
|
|
bbaaef |
-test_dhcp 2 f00000000002 08 $ciaddr $offer_ip $request_ip 0 1 1
|
|
|
bbaaef |
+test_dhcp 2 f00000000002 08 0 $ciaddr $offer_ip $request_ip 0 1 1
|
|
|
bbaaef |
|
|
|
bbaaef |
# NXT_RESUMEs should be 4.
|
|
|
bbaaef |
OVS_WAIT_UNTIL([test 4 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`])
|
|
|
bbaaef |
@@ -4792,12 +4803,12 @@ rm -f 2.expected
|
|
|
bbaaef |
# ls2-lp2 (vif4-tx.pcap) should receive the DHCPv4 request packet once.
|
|
|
bbaaef |
|
|
|
bbaaef |
ciaddr=`ip_to_hex 0 0 0 0`
|
|
|
bbaaef |
-test_dhcp 3 f00000000003 01 $ciaddr 0 0 4 0
|
|
|
bbaaef |
+test_dhcp 3 f00000000003 01 0 $ciaddr 0 0 4 0
|
|
|
bbaaef |
|
|
|
bbaaef |
# Send DHCPv4 packet on ls2-lp2. "router" DHCPv4 option is not defined for
|
|
|
bbaaef |
# this lport.
|
|
|
bbaaef |
ciaddr=`ip_to_hex 0 0 0 0`
|
|
|
bbaaef |
-test_dhcp 4 f00000000004 01 $ciaddr 0 0 3 0
|
|
|
bbaaef |
+test_dhcp 4 f00000000004 01 0 $ciaddr 0 0 3 0
|
|
|
bbaaef |
|
|
|
bbaaef |
# NXT_RESUMEs should be 4.
|
|
|
bbaaef |
OVS_WAIT_UNTIL([test 4 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`])
|
|
|
bbaaef |
@@ -4814,7 +4825,7 @@ request_ip=0
|
|
|
bbaaef |
src_ip=$offer_ip
|
|
|
bbaaef |
dst_ip=$server_ip
|
|
|
bbaaef |
expected_dhcp_opts=330400000e100104ffffff0003040a00000136040a000001
|
|
|
bbaaef |
-test_dhcp 2 f00000000002 03 $ciaddr $offer_ip $request_ip 1 $src_ip $dst_ip ff1000000001 $server_ip 05 $expected_dhcp_opts
|
|
|
bbaaef |
+test_dhcp 2 f00000000002 03 0 $ciaddr $offer_ip $request_ip 1 $src_ip $dst_ip ff1000000001 $server_ip 05 $expected_dhcp_opts
|
|
|
bbaaef |
|
|
|
bbaaef |
# NXT_RESUMEs should be 5.
|
|
|
bbaaef |
OVS_WAIT_UNTIL([test 5 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`])
|
|
|
bbaaef |
@@ -4840,7 +4851,7 @@ request_ip=0
|
|
|
bbaaef |
src_ip=$offer_ip
|
|
|
bbaaef |
dst_ip=`ip_to_hex 255 255 255 255`
|
|
|
bbaaef |
expected_dhcp_opts=330400000e100104ffffff0003040a00000136040a000001
|
|
|
bbaaef |
-test_dhcp 2 f00000000002 03 $ciaddr $offer_ip $request_ip 1 $src_ip $dst_ip ff1000000001 $server_ip 05 $expected_dhcp_opts
|
|
|
bbaaef |
+test_dhcp 2 f00000000002 03 0 $ciaddr $offer_ip $request_ip 1 $src_ip $dst_ip ff1000000001 $server_ip 05 $expected_dhcp_opts
|
|
|
bbaaef |
|
|
|
bbaaef |
# NXT_RESUMEs should be 6.
|
|
|
bbaaef |
OVS_WAIT_UNTIL([test 6 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`])
|
|
|
bbaaef |
@@ -4866,7 +4877,7 @@ request_ip=0
|
|
|
bbaaef |
src_ip=$offer_ip
|
|
|
bbaaef |
dst_ip=`ip_to_hex 255 255 255 255`
|
|
|
bbaaef |
expected_dhcp_opts=""
|
|
|
bbaaef |
-test_dhcp 2 f00000000002 03 $ciaddr $offer_ip $request_ip 1 $src_ip $dst_ip ff1000000001 $server_ip 06 $expected_dhcp_opts
|
|
|
bbaaef |
+test_dhcp 2 f00000000002 03 0 $ciaddr $offer_ip $request_ip 1 $src_ip $dst_ip ff1000000001 $server_ip 06 $expected_dhcp_opts
|
|
|
bbaaef |
|
|
|
bbaaef |
# NXT_RESUMEs should be 7.
|
|
|
bbaaef |
OVS_WAIT_UNTIL([test 7 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`])
|
|
|
bbaaef |
@@ -4892,7 +4903,7 @@ request_ip=0
|
|
|
bbaaef |
src_ip=$offer_ip
|
|
|
bbaaef |
dst_ip=`ip_to_hex 255 255 255 255`
|
|
|
bbaaef |
expected_dhcp_opts=""
|
|
|
bbaaef |
-test_dhcp 2 f00000000002 03 $ciaddr $offer_ip $request_ip 1 $src_ip $dst_ip ff1000000001 $server_ip 06 $expected_dhcp_opts
|
|
|
bbaaef |
+test_dhcp 2 f00000000002 03 0 $ciaddr $offer_ip $request_ip 1 $src_ip $dst_ip ff1000000001 $server_ip 06 $expected_dhcp_opts
|
|
|
bbaaef |
|
|
|
bbaaef |
# NXT_RESUMEs should be 8.
|
|
|
bbaaef |
OVS_WAIT_UNTIL([test 8 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`])
|
|
|
bbaaef |
@@ -4914,7 +4925,7 @@ rm -f 2.expected
|
|
|
bbaaef |
ciaddr=`ip_to_hex 0 0 0 0`
|
|
|
bbaaef |
src_ip=`ip_to_hex 10 0 0 6`
|
|
|
bbaaef |
dst_ip=`ip_to_hex 10 0 0 4`
|
|
|
bbaaef |
-test_dhcp 2 f00000000002 03 $ciaddr 0 0 1 $src_ip $dst_ip 1
|
|
|
bbaaef |
+test_dhcp 2 f00000000002 03 0 $ciaddr 0 0 1 $src_ip $dst_ip 1
|
|
|
bbaaef |
|
|
|
bbaaef |
# NXT_RESUMEs should be 8.
|
|
|
bbaaef |
OVS_WAIT_UNTIL([test 8 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`])
|
|
|
bbaaef |
@@ -4922,6 +4933,29 @@ OVS_WAIT_UNTIL([test 8 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`])
|
|
|
bbaaef |
# vif1-tx.pcap should have received the DHCPv4 request packet
|
|
|
bbaaef |
OVN_CHECK_PACKETS([hv1/vif1-tx.pcap], [1.expected])
|
|
|
bbaaef |
|
|
|
bbaaef |
+reset_pcap_file hv1-vif1 hv1/vif1
|
|
|
bbaaef |
+reset_pcap_file hv1-vif2 hv1/vif2
|
|
|
bbaaef |
+rm -f 1.expected
|
|
|
bbaaef |
+rm -f 2.expected
|
|
|
bbaaef |
+
|
|
|
bbaaef |
+# Send DHCPDISCOVER with BROADCAST flag on.
|
|
|
bbaaef |
+offer_ip=`ip_to_hex 10 0 0 4`
|
|
|
bbaaef |
+server_ip=`ip_to_hex 10 0 0 1`
|
|
|
bbaaef |
+ciaddr=`ip_to_hex 0 0 0 0`
|
|
|
bbaaef |
+request_ip=0
|
|
|
bbaaef |
+expected_dhcp_opts=330400000e100104ffffff0003040a00000136040a000001
|
|
|
bbaaef |
+test_dhcp 1 f00000000001 01 1 $ciaddr $offer_ip $request_ip 0 ff1000000001 $server_ip 02 $expected_dhcp_opts
|
|
|
bbaaef |
+
|
|
|
bbaaef |
+# NXT_RESUMEs should be 9.
|
|
|
bbaaef |
+OVS_WAIT_UNTIL([test 9 = `cat ofctl_monitor*.log | grep -c NXT_RESUME`])
|
|
|
bbaaef |
+
|
|
|
bbaaef |
+$PYTHON "$top_srcdir/utilities/ovs-pcap.in" hv1/vif1-tx.pcap > 1.packets
|
|
|
bbaaef |
+cat 1.expected | cut -c -48 > expout
|
|
|
bbaaef |
+AT_CHECK([cat 1.packets | cut -c -48], [0], [expout])
|
|
|
bbaaef |
+# Skipping the IPv4 checksum.
|
|
|
bbaaef |
+cat 1.expected | cut -c 53- > expout
|
|
|
bbaaef |
+AT_CHECK([cat 1.packets | cut -c 53-], [0], [expout])
|
|
|
bbaaef |
+
|
|
|
bbaaef |
OVN_CLEANUP([hv1])
|
|
|
bbaaef |
|
|
|
bbaaef |
AT_CLEANUP
|
|
|
bbaaef |
@@ -12963,10 +12997,11 @@ as hv1
|
|
|
bbaaef |
ovs-vsctl show
|
|
|
bbaaef |
|
|
|
bbaaef |
# This shell function sends a DHCP request packet
|
|
|
bbaaef |
-# test_dhcp INPORT SRC_MAC DHCP_TYPE OFFER_IP ...
|
|
|
bbaaef |
+# test_dhcp INPORT SRC_MAC DHCP_TYPE BROADCAST OFFER_IP ...
|
|
|
bbaaef |
test_dhcp() {
|
|
|
bbaaef |
- local inport=$1 src_mac=$2 dhcp_type=$3 offer_ip=$4 use_ip=$5
|
|
|
bbaaef |
- shift; shift; shift; shift; shift;
|
|
|
bbaaef |
+ local inport=$1 src_mac=$2 dhcp_type=$3 broadcast=$4 offer_ip=$5 use_ip=$6
|
|
|
bbaaef |
+ shift; shift; shift; shift; shift; shift;
|
|
|
bbaaef |
+
|
|
|
bbaaef |
if test $use_ip != 0; then
|
|
|
bbaaef |
src_ip=$1
|
|
|
bbaaef |
dst_ip=$2
|
|
|
bbaaef |
@@ -12975,10 +13010,19 @@ test_dhcp() {
|
|
|
bbaaef |
src_ip=`ip_to_hex 0 0 0 0`
|
|
|
bbaaef |
dst_ip=`ip_to_hex 255 255 255 255`
|
|
|
bbaaef |
fi
|
|
|
bbaaef |
+
|
|
|
bbaaef |
+ if test $broadcast != 0; then
|
|
|
bbaaef |
+ flags=8000
|
|
|
bbaaef |
+ reply_dst_ip=`ip_to_hex 255 255 255 255`
|
|
|
bbaaef |
+ else
|
|
|
bbaaef |
+ flags=0000
|
|
|
bbaaef |
+ reply_dst_ip=${offer_ip}
|
|
|
bbaaef |
+ fi
|
|
|
bbaaef |
+
|
|
|
bbaaef |
local request=ffffffffffff${src_mac}0800451001100000000080110000${src_ip}${dst_ip}
|
|
|
bbaaef |
# udp header and dhcp header
|
|
|
bbaaef |
request=${request}0044004300fc0000
|
|
|
bbaaef |
- request=${request}010106006359aa760000000000000000000000000000000000000000${src_mac}
|
|
|
bbaaef |
+ request=${request}010106006359aa760000${flags}00000000000000000000000000000000${src_mac}
|
|
|
bbaaef |
# client hardware padding
|
|
|
bbaaef |
request=${request}00000000000000000000
|
|
|
bbaaef |
# server hostname
|
|
|
bbaaef |
@@ -13002,10 +13046,10 @@ test_dhcp() {
|
|
|
bbaaef |
ip_len=$(printf "%x" $ip_len)
|
|
|
bbaaef |
udp_len=$(printf "%x" $udp_len)
|
|
|
bbaaef |
# $ip_len var will be in 3 digits i.e 134. So adding a '0' before $ip_len
|
|
|
bbaaef |
- local reply=${src_mac}${srv_mac}080045100${ip_len}000000008011XXXX${srv_ip}${offer_ip}
|
|
|
bbaaef |
+ local reply=${src_mac}${srv_mac}080045100${ip_len}000000008011XXXX${srv_ip}${reply_dst_ip}
|
|
|
bbaaef |
# udp header and dhcp header.
|
|
|
bbaaef |
# $udp_len var will be in 3 digits. So adding a '0' before $udp_len
|
|
|
bbaaef |
- reply=${reply}004300440${udp_len}0000020106006359aa760000000000000000
|
|
|
bbaaef |
+ reply=${reply}004300440${udp_len}0000020106006359aa760000${flags}00000000
|
|
|
bbaaef |
# your ip address
|
|
|
bbaaef |
reply=${reply}${offer_ip}
|
|
|
bbaaef |
# next server ip address, relay agent ip address, client mac address
|
|
|
bbaaef |
@@ -13124,7 +13168,7 @@ offer_ip=`ip_to_hex 10 0 0 6`
|
|
|
bbaaef |
server_ip=`ip_to_hex 10 0 0 1`
|
|
|
bbaaef |
server_mac=ff1000000001
|
|
|
bbaaef |
expected_dhcp_opts=330400000e100104ffffff0003040a00000136040a000001
|
|
|
bbaaef |
-test_dhcp 1 f00000000003 01 $offer_ip 0 $server_mac $server_ip \
|
|
|
bbaaef |
+test_dhcp 1 f00000000003 01 0 $offer_ip 0 $server_mac $server_ip \
|
|
|
bbaaef |
$expected_dhcp_opts
|
|
|
bbaaef |
|
|
|
bbaaef |
# NXT_RESUMEs should be 1 in hv1.
|
|
|
bbaaef |
@@ -13222,7 +13266,7 @@ offer_ip=`ip_to_hex 10 0 0 6`
|
|
|
bbaaef |
server_ip=`ip_to_hex 10 0 0 1`
|
|
|
bbaaef |
server_mac=ff1000000001
|
|
|
bbaaef |
expected_dhcp_opts=330400000e100104ffffff0003040a00000136040a000001
|
|
|
bbaaef |
-test_dhcp 1 f00000000003 01 $offer_ip 0 $server_mac $server_ip \
|
|
|
bbaaef |
+test_dhcp 1 f00000000003 01 0 $offer_ip 0 $server_mac $server_ip \
|
|
|
bbaaef |
$expected_dhcp_opts
|
|
|
bbaaef |
|
|
|
bbaaef |
# NXT_RESUMEs should be 2 in hv1.
|
|
|
bbaaef |
@@ -13332,7 +13376,7 @@ offer_ip=`ip_to_hex 10 0 0 6`
|
|
|
bbaaef |
server_ip=`ip_to_hex 10 0 0 1`
|
|
|
bbaaef |
server_mac=ff1000000001
|
|
|
bbaaef |
expected_dhcp_opts=330400000e100104ffffff0003040a00000136040a000001
|
|
|
bbaaef |
-test_dhcp 1 f00000000003 01 $offer_ip 0 $server_mac $server_ip \
|
|
|
bbaaef |
+test_dhcp 1 f00000000003 01 0 $offer_ip 0 $server_mac $server_ip \
|
|
|
bbaaef |
$expected_dhcp_opts
|
|
|
bbaaef |
|
|
|
bbaaef |
# NXT_RESUMEs should be 3 in hv1.
|
|
|
bbaaef |
@@ -13412,7 +13456,7 @@ offer_ip=`ip_to_hex 10 0 0 6`
|
|
|
bbaaef |
server_ip=`ip_to_hex 10 0 0 1`
|
|
|
bbaaef |
server_mac=ff1000000001
|
|
|
bbaaef |
expected_dhcp_opts=330400000e100104ffffff0003040a00000136040a000001
|
|
|
bbaaef |
-test_dhcp 1 f00000000003 01 $offer_ip 0 $server_mac $server_ip \
|
|
|
bbaaef |
+test_dhcp 1 f00000000003 01 0 $offer_ip 0 $server_mac $server_ip \
|
|
|
bbaaef |
$expected_dhcp_opts
|
|
|
bbaaef |
|
|
|
bbaaef |
# NXT_RESUMEs should be 4 in hv1.
|
|
|
bbaaef |
--
|
|
|
bbaaef |
2.24.1
|
|
|
bbaaef |
|