sync patches from 22.03-LTS to 22.03-LTS-Next

This commit is contained in:
renmingshuai 2022-08-24 19:23:05 +08:00
parent a75b395f60
commit dd9a42c065
3 changed files with 169 additions and 1 deletions

View File

@ -0,0 +1,100 @@
From bd6db12aaeecbc4f76462b4016c7e74e43d532f3 Mon Sep 17 00:00:00 2001
From: zhangqiumiao <zhangqiumiao1@huawei.com>
Date: Tue, 10 Nov 2020 02:10:57 -0500
Subject: [PATCH] add a test case to parse code93 in option_unittest
---
common/tests/option_unittest.c | 70 ++++++++++++++++++++++++++++++++++
1 file changed, 70 insertions(+)
diff --git a/common/tests/option_unittest.c b/common/tests/option_unittest.c
index cd52cfb..0bb6517 100644
--- a/common/tests/option_unittest.c
+++ b/common/tests/option_unittest.c
@@ -129,6 +129,75 @@ ATF_TC_BODY(pretty_print_option, tc)
}
}
+ATF_TC(parse_code93_option);
+
+ATF_TC_HEAD(parse_code93_option, tc)
+{
+ atf_tc_set_md_var(tc, "descr",
+ "Verify that code93 can be parsed.");
+}
+
+ATF_TC_BODY(parse_code93_option, tc)
+{
+ struct option *option;
+ unsigned code;
+ unsigned char bad_data[32*1024];
+ unsigned char good_data1[] = { 0,0 };
+ unsigned char good_data2[] = { 0,7 };
+ unsigned char good_data3[] = { 0,11 };
+ int emit_commas = 1;
+ int emit_quotes = 1;
+ const char *output_buf;
+
+ /* Initialize whole thing to non-printable chars */
+ memset(bad_data, 0x1f, sizeof(bad_data));
+
+ initialize_common_option_spaces();
+
+ /* We'll use pxe-system-type and it happens to be format Sa */
+ code = 93;
+ option = NULL;
+ if (!option_code_hash_lookup(&option, dhcp_universe.code_hash,
+ &code, 0, MDL)) {
+ atf_tc_fail("can't find option %d", code);
+ }
+
+ if (option == NULL) {
+ atf_tc_fail("option is NULL");
+ }
+
+ /* First we will try a good value we know should fit. */
+ output_buf = pretty_print_option (option, good_data1, sizeof(good_data1),
+ emit_commas, emit_quotes);
+
+ /* Make sure we get what we expect */
+ if (!output_buf || strcmp(output_buf, "0")) {
+ atf_tc_fail("pretty_print_option 1 did not return \"<error>\"");
+ }
+
+ output_buf = pretty_print_option (option, good_data2, sizeof(good_data3),
+ emit_commas, emit_quotes);
+ /* Make sure we get what we expect */
+ if (!output_buf || strcmp(output_buf, "7")) {
+ atf_tc_fail("pretty_print_option 2 did not return \"<error>\"");
+ }
+
+ output_buf = pretty_print_option (option, good_data3, sizeof(good_data3),
+ emit_commas, emit_quotes);
+ /* Make sure we get what we expect */
+ if (!output_buf || strcmp(output_buf, "11")) {
+ atf_tc_fail("pretty_print_option 3 did not return \"<error>\"");
+ }
+
+ /* Now we'll try a data value that's too large */
+ output_buf = pretty_print_option (option, bad_data, sizeof(bad_data),
+ emit_commas, emit_quotes);
+
+ /* Make sure we safely get an error */
+ if (!output_buf || strcmp(output_buf, "<error>")) {
+ atf_tc_fail("pretty_print_option did not return \"<error>\"");
+ }
+}
/* This macro defines main() method that will call specified
test cases. tp and simple_test_case names can be whatever you want
@@ -137,6 +206,7 @@ ATF_TP_ADD_TCS(tp)
{
ATF_TP_ADD_TC(tp, option_refcnt);
ATF_TP_ADD_TC(tp, pretty_print_option);
+ ATF_TP_ADD_TC(tp, parse_code93_option);
return (atf_no_error());
}
--
2.19.1

View File

@ -3,7 +3,7 @@
Name: dhcp
Version: 4.4.2
Release: 11
Release: 12
Summary: Dynamic host configuration protocol software
#Please don't change the epoch on this package
Epoch: 12
@ -58,6 +58,8 @@ Patch36: fix-multiple-definition-with-gcc-10-1.patch
Patch37: fix-multiple-definition-with-gcc-10-2.patch
Patch38: fix-coredump-when-client-active-is-NULL.patch
Patch39: bugfix-error-message-display.patch
Patch40: feature-lease-time-config-ipv6.patch
Patch41: add-a-test-case-to-parse-code93-in-option_unittest.patch
BuildRequires: gcc autoconf automake libtool openldap-devel krb5-devel libcap-ng-devel
BuildRequires: systemd systemd-devel
@ -296,6 +298,13 @@ exit 0
%{_mandir}/man3/omapi.3.gz
%changelog
* Wed Aug 24 2022 renmingshuai <renmingshuai@huawei.com> - 4.4.2-12
- Type:bugfix
- ID:NA
- SUG:restart
- DESC:add a test case for PXE to support ipv6
support lease time config for ipv6
* Tue Feb 8 2022 renmingshuai <renmingshuai@huawei.com> - 4.4.2-11
- Type:bugfix
- ID:NA

View File

@ -0,0 +1,59 @@
From 8fb8c0fcd63917fc500fe6f14436234edc6677ed Mon Sep 17 00:00:00 2001
From: majun <majun65@huawei.com>
Date: Tue, 1 Sep 2020 11:50:17 +0800
Subject: [PATCH] lease-time-config
Signed-off-by: majun <majun65@huawei.com>
---
client/clparse.c | 5 +++++
common/conflex.c | 3 +++
includes/dhctoken.h | 3 ++-
3 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/client/clparse.c b/client/clparse.c
index d445bae..d43e8ae 100644
--- a/client/clparse.c
+++ b/client/clparse.c
@@ -453,6 +453,11 @@ void parse_client_statement (cfile, ip, config)
struct option ***append_list, **new_list, **cat_list;
switch (peek_token (&val, (unsigned *)0, cfile)) {
+ case LEASE_TIME_IPV6:
+ skip_token(&val, (unsigned *)0, cfile);
+ parse_lease_time (cfile, &config -> requested_lease);
+ return;
+
case INCLUDE:
skip_token(&val, (unsigned *)0, cfile);
token = next_token (&val, (unsigned *)0, cfile);
diff --git a/common/conflex.c b/common/conflex.c
index 71c0bf5..fa3acb8 100644
--- a/common/conflex.c
+++ b/common/conflex.c
@@ -1146,6 +1146,9 @@ intern(char *atom, enum dhcp_token dfv) {
if (!strcasecmp (atom + 1, "ease-id-format")) {
return LEASE_ID_FORMAT;
}
+ if (!strcasecmp (atom + 1, "ease-time-ipv6")) {
+ return LEASE_TIME_IPV6;
+ }
break;
case 'm':
if (!strncasecmp (atom + 1, "ax", 2)) {
diff --git a/includes/dhctoken.h b/includes/dhctoken.h
index b4d93ba..0bc31ca 100644
--- a/includes/dhctoken.h
+++ b/includes/dhctoken.h
@@ -378,7 +378,8 @@ enum dhcp_token {
TOKEN_OCTAL = 678,
KEY_ALGORITHM = 679,
BOOTP_BROADCAST_ALWAYS = 680,
- DESTINATION_DESCRIPTOR = 681
+ DESTINATION_DESCRIPTOR = 681,
+ LEASE_TIME_IPV6 = 682
};
#define is_identifier(x) ((x) >= FIRST_TOKEN && \
--
2.23.0