ell.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: Andrew Zaborowski <andrew.zaborowski@intel.com>
To: ell@lists.01.org
Subject: [PATCH 15/15] unit: Test DHCP rapid commit
Date: Mon, 02 Aug 2021 16:04:24 +0200	[thread overview]
Message-ID: <20210802140424.170150-15-andrew.zaborowski@intel.com> (raw)
In-Reply-To: <20210802140424.170150-1-andrew.zaborowski@intel.com>

[-- Attachment #1: Type: text/plain, Size: 3850 bytes --]

---
 unit/test-dhcp.c | 34 ++++++++++++++++++++--------------
 1 file changed, 20 insertions(+), 14 deletions(-)

diff --git a/unit/test-dhcp.c b/unit/test-dhcp.c
index 079f037..11ee10e 100644
--- a/unit/test-dhcp.c
+++ b/unit/test-dhcp.c
@@ -823,7 +823,7 @@ static struct l_dhcp_client *client_init(const uint8_t *mac)
 }
 
 static void client_connect(struct l_dhcp_client *client,
-				struct l_dhcp_server *server)
+				struct l_dhcp_server *server, bool rapid_commit)
 {
 	struct dhcp_transport *srv_transport =
 					_dhcp_server_get_transport(server);
@@ -839,15 +839,17 @@ static void client_connect(struct l_dhcp_client *client,
 	assert(l2_send_called);
 	l2_send_called = false;
 
-	/* RX OFFER */
-	cli_transport->rx_cb(server_packet, server_packet_len, client);
-	assert(client_send_called);
-	client_send_called = false;
+	if (!rapid_commit) {
+		/* RX OFFER */
+		cli_transport->rx_cb(server_packet, server_packet_len, client);
+		assert(client_send_called);
+		client_send_called = false;
 
-	/* RX REQUEST */
-	srv_transport->rx_cb(client_packet, client_packet_len, server);
-	assert(l2_send_called);
-	l2_send_called = false;
+		/* RX REQUEST */
+		srv_transport->rx_cb(client_packet, client_packet_len, server);
+		assert(l2_send_called);
+		l2_send_called = false;
+	}
 
 	/* RX ACK */
 	cli_transport->rx_cb(server_packet, server_packet_len, client);
@@ -885,6 +887,7 @@ static struct l_dhcp_server *server_init()
 
 static void test_complete_run(const void *data)
 {
+	bool rapid_commit = L_PTR_TO_UINT(data);
 	static const uint8_t addr1[6] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06 };
 	static const uint8_t addr2[6] = { 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c };
 	struct dhcp_transport *srv_transport;
@@ -902,6 +905,7 @@ static void test_complete_run(const void *data)
 	char **dns_list;
 
 	server = server_init();
+	l_dhcp_server_set_enable_rapid_commit(server, rapid_commit);
 
 	assert(l_dhcp_server_set_ip_range(server, "192.168.1.2",
 						"192.168.1.100"));
@@ -910,7 +914,7 @@ static void test_complete_run(const void *data)
 
 	client1 = client_init(addr1);
 
-	client_connect(client1, server);
+	client_connect(client1, server, rapid_commit);
 
 	cli_lease = l_dhcp_client_get_lease(client1);
 	assert(cli_lease);
@@ -943,7 +947,7 @@ static void test_complete_run(const void *data)
 
 	client2 = client_init(addr2);
 
-	client_connect(client2, server);
+	client_connect(client2, server, rapid_commit);
 
 	cli_lease = l_dhcp_client_get_lease(client2);
 	assert(cli_lease);
@@ -999,6 +1003,7 @@ static void test_expired_ip_reuse(const void *data)
 
 	l_dhcp_server_set_ip_range(server, "192.168.1.2", "192.168.1.11");
 	_dhcp_server_set_max_expired_clients(server, 10);
+	l_dhcp_server_set_enable_rapid_commit(server, false);
 
 	/*
 	 * Connect and release 10 clients, this should max out the expired
@@ -1011,7 +1016,7 @@ static void test_expired_ip_reuse(const void *data)
 
 		addr[5] = i;
 		client = client_init(addr);
-		client_connect(client, server);
+		client_connect(client, server, false);
 		l_free(new_client);
 		new_client = NULL;
 
@@ -1025,7 +1030,7 @@ static void test_expired_ip_reuse(const void *data)
 
 	addr[5] = i + 1;
 	client_new = client_init(addr);
-	client_connect(client_new, server);
+	client_connect(client_new, server, false);
 	l_free(new_client);
 	new_client = NULL;
 
@@ -1064,7 +1069,8 @@ int main(int argc, char *argv[])
 
 	l_test_add("discover", test_discover, NULL);
 
-	l_test_add("complete run", test_complete_run, NULL);
+	l_test_add("complete run", test_complete_run, L_UINT_TO_PTR(false));
+	l_test_add("rapid commit", test_complete_run, L_UINT_TO_PTR(true));
 	l_test_add("expired IP reuse", test_expired_ip_reuse, NULL);
 
 	return l_test_run();
-- 
2.30.2

  parent reply	other threads:[~2021-08-02 14:04 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-02 14:04 [PATCH 01/15] dhcp-server: Add "authoritative" mode Andrew Zaborowski
2021-08-02 14:04 ` [PATCH 02/15] dhcp-server: Handle DHCPDECLINE for active leases Andrew Zaborowski
2021-08-02 14:04 ` [PATCH 03/15] dhcp-server: Respect client's broadcast flag Andrew Zaborowski
2021-08-02 14:04 ` [PATCH 04/15] dhcp-server: Look up leases by client identifier option Andrew Zaborowski
2021-08-02 14:04 ` [PATCH 05/15] dhcp-server: Copy client identifier from the client message Andrew Zaborowski
2021-08-02 14:04 ` [PATCH 06/15] dhcp-server: Save lease mac before calling add_lease Andrew Zaborowski
2021-08-02 14:04 ` [PATCH 07/15] dhcp-server: Ensure broadcast address is not selected Andrew Zaborowski
2021-08-02 14:04 ` [PATCH 08/15] dhcp-server: Reuse leases in find_free_or_expired_ip Andrew Zaborowski
2021-08-02 14:04 ` [PATCH 09/15] dhcp-server: Refactor lease lookup Andrew Zaborowski
2021-08-02 14:04 ` [PATCH 10/15] dhcp-server: Allow reactivating expired leases Andrew Zaborowski
2021-08-02 14:04 ` [PATCH 11/15] dhcp: Support RFC4039 Rapid Commit Andrew Zaborowski
2021-08-02 14:04 ` [PATCH 12/15] dhcp-server: " Andrew Zaborowski
2021-08-02 14:04 ` [PATCH 13/15] dhcp-server: Rapid commit enable/disable setter Andrew Zaborowski
2021-08-02 14:04 ` [PATCH 14/15] unit: Stricter checks in unit-dhcp Andrew Zaborowski
2021-08-02 14:04 ` Andrew Zaborowski [this message]
2021-08-02 18:15 ` [PATCH 01/15] dhcp-server: Add "authoritative" mode Denis Kenzior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210802140424.170150-15-andrew.zaborowski@intel.com \
    --to=andrew.zaborowski@intel.com \
    --cc=ell@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).