Skip to content

Commit

Permalink
fixup: pmtud state machine
Browse files Browse the repository at this point in the history
  • Loading branch information
expressvpn-tom-l committed Oct 10, 2023
1 parent 3e5559f commit 76a3358
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/he/pmtud.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void he_internal_change_pmtud_state(he_conn_t *conn, he_pmtud_state_t state) {
return;
}

switch(conn->state) {
switch(conn->pmtud_state) {
case HE_PMTUD_STATE_DISABLED:
switch(state) {
case HE_PMTUD_STATE_BASE:
Expand Down Expand Up @@ -121,7 +121,7 @@ void he_internal_change_pmtud_state(he_conn_t *conn, he_pmtud_state_t state) {
}

// State changed
conn->state = state;
conn->pmtud_state = state;
}

void he_internal_pmtud_update(he_conn_t *conn) {
Expand Down
15 changes: 13 additions & 2 deletions test/he/test_pmtud.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <unity.h>

#include "he.h"
#include "he_internal.h"

#include <unity.h>
#include "test_defs.h"

// Unit under test
Expand Down Expand Up @@ -71,3 +70,15 @@ void test_he_internal_pmtud_send_probe_invalid_probe_mtu(void) {
TEST_ASSERT_EQUAL(HE_ERR_INVALID_MTU_SIZE, he_internal_pmtud_send_probe(&conn, 120));
TEST_ASSERT_EQUAL(HE_ERR_INVALID_MTU_SIZE, he_internal_pmtud_send_probe(&conn, HE_MAX_WIRE_MTU));
}

void test_he_internal_change_pmtud_state_disabled_to_base(void) {
conn.state = HE_STATE_ONLINE;
conn.pmtud_state = HE_PMTUD_STATE_DISABLED;

he_internal_generate_event_Expect(&conn, HE_EVENT_PMTU_DISCOVERY_STARTED);
he_internal_change_pmtud_state(&conn, HE_PMTUD_STATE_BASE);

TEST_ASSERT_EQUAL(HE_PMTUD_STATE_BASE, conn.pmtud_state);
TEST_ASSERT_EQUAL(HE_MAX_MTU, conn.pmtud_base);
TEST_ASSERT_EQUAL(0, conn.pmtud_probe_count);
}

0 comments on commit 76a3358

Please sign in to comment.