Skip to content

Commit 132229d

Browse files
yuwatabluca
authored andcommitted
sd-dhcp-server: propagate error on parsing DHCP packet
Otherwise, we silently ignore the received packet and that makes hard to debug issue. (cherry picked from commit 809da72) (cherry picked from commit 7483f75)
1 parent 55a69c7 commit 132229d

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/libsystemd-network/sd-dhcp-server.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1079,7 +1079,7 @@ int dhcp_server_handle_message(sd_dhcp_server *server, DHCPMessage *message, siz
10791079

10801080
type = dhcp_option_parse(message, length, parse_request, req, &error_message);
10811081
if (type < 0)
1082-
return 0;
1082+
return type;
10831083

10841084
r = ensure_sane_request(server, req, message);
10851085
if (r < 0)

src/libsystemd-network/test-dhcp-server.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ static void test_message_handler(void) {
138138
test.option_type.code = 0;
139139
test.option_type.length = 0;
140140
test.option_type.type = 0;
141-
assert_se(dhcp_server_handle_message(server, (DHCPMessage*)&test, sizeof(test)) == 0);
141+
assert_se(dhcp_server_handle_message(server, (DHCPMessage*)&test, sizeof(test)) == -ENOMSG);
142142
test.option_type.code = SD_DHCP_OPTION_MESSAGE_TYPE;
143143
test.option_type.length = 1;
144144
test.option_type.type = DHCP_DISCOVER;

0 commit comments

Comments
 (0)