Skip to content

Commit

Permalink
Update VXLANTest destination port number
Browse files Browse the repository at this point in the history
Based on RFC 7348, the default IANA-assigned destination UDP port number
for VXLAN is 4789, not the source port number. Update the value in the
VXLANTest class to align with the RFC.

The VXLAN implementation still allows for the destination port number to
be configurable to allow interoperability (as specified by the RFC),
such as with the Linux kernel's default value of 8472.

Signed-off-by: James Raphael Tiovalen <jamestiotio@gmail.com>
  • Loading branch information
jamestiotio committed Mar 10, 2024
1 parent 00619e0 commit 316f7a0
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions tests/src/vxlan_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ const uint8_t VXLANTest::expected_packet[PACKET_SIZE] = {
};

const uint8_t VXLANTest::flags = 8;
const uint16_t VXLANTest::dport = 19627;
const uint16_t VXLANTest::sport = 4789;
const uint16_t VXLANTest::dport = 4789;
const uint16_t VXLANTest::sport = 19627;
const uint16_t VXLANTest::p_type = 0xd0ab;
const small_uint<24> VXLANTest::vni = 0xffffff;
const IP::address_type VXLANTest::dst_ip = IP::address_type{"2.2.2.2"};
Expand Down Expand Up @@ -83,7 +83,11 @@ TEST_F(VXLANTest, ConstructorFromBuffer) {

TEST_F(VXLANTest, OuterUDP) {
auto pkt = IP{dst_ip, src_ip} / UDP{dport, sport} / VXLAN{expected_packet, PACKET_SIZE};
auto const vxlan = pkt.find_pdu<VXLAN>();
auto const udp = pkt.find_pdu<UDP>();
ASSERT_TRUE(udp != nullptr);
EXPECT_EQ(udp->dport(), dport);
EXPECT_EQ(udp->sport(), sport);
auto const vxlan = udp.find_pdu<VXLAN>();
ASSERT_TRUE(vxlan != nullptr);
EXPECT_EQ(vxlan->get_flags(), flags);
EXPECT_EQ(vxlan->get_vni(), vni);
Expand Down

0 comments on commit 316f7a0

Please # to comment.