Skip to content

Commit

Permalink
Fix switchlink_link_test (#166)
Browse files Browse the repository at this point in the history
The switchlink_link unit test fails when run with the command

  bazel test --define target=dpdk --//flags:ovs=true //switchlink:all

- Addressed the issue by conditionalizing out the two VxLAN test
  cases when OVSP4RT support is enabled.

- Introduced an internal VXLAN_OPTION conditional to indicate
  whether VxLAN support is enabled.

Signed-off-by: Derek Foster <[email protected]>
  • Loading branch information
ffoulkes authored Oct 31, 2024
1 parent 673c45f commit db0a394
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
17 changes: 15 additions & 2 deletions krnlmon_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,33 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* ---------------------------------------------------------------------
* This header file maps compile-time symbol definitions (such as
* ES2K_TARGET) to internal symbol definitions that specify which
* features the compile-time symbols enable (such as LAG_OPTION).
*
* This is infinitely better than leaving the reader scratching
* their head, trying to figure out why some random piece of code
* is wrapped in an "#if !defined(OVSP4RT_SUPPORT)" conditional
* (which the original author didn't bother to comment).
* ---------------------------------------------------------------------
*/

#ifndef KRNLMON_OPTIONS_H_
#define KRNLMON_OPTIONS_H_

#if defined(DPDK_TARGET)
// DPDK options

#elif defined(ES2K_TARGET)
// ES2K options
#define LAG_OPTION 1

#else
#error "ASSERT: Unknown TARGET type!"
#endif

#if !defined(OVSP4RT_SUPPORT)
#define VXLAN_OPTION 1
#endif

#endif // KRNLMON_OPTIONS_H_
4 changes: 2 additions & 2 deletions switchlink/switchlink_link.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ void switchlink_process_link_msg(const struct nlmsghdr* nlmsg, int msgtype) {
case SWITCHLINK_LINK_TYPE_ETH:
break;

#if !defined(OVSP4RT_SUPPORT)
#ifdef VXLAN_OPTION
case SWITCHLINK_LINK_TYPE_VXLAN: {
switchlink_db_tunnel_interface_info_t tnl_intf_info = {0};
snprintf(tnl_intf_info.ifname, sizeof(tnl_intf_info.ifname), "%s",
Expand Down Expand Up @@ -405,7 +405,7 @@ void switchlink_process_link_msg(const struct nlmsghdr* nlmsg, int msgtype) {
} else {
krnlmon_assert(msgtype == RTM_DELLINK);

#if !defined(OVSP4RT_SUPPORT)
#ifdef VXLAN_OPTION
if (link_type == SWITCHLINK_LINK_TYPE_VXLAN) {
switchlink_delete_tunnel_interface(ifmsg->ifi_index);
return;
Expand Down
8 changes: 8 additions & 0 deletions switchlink/switchlink_link_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ TEST_F(SwitchlinkTest, can_create_generic_link) {
0);
}

#ifdef VXLAN_OPTION

/**
* Creates a vxlan link.
*
Expand Down Expand Up @@ -300,6 +302,8 @@ TEST_F(SwitchlinkTest, can_create_vxlan_link) {
EXPECT_EQ(results[0].tunnel_info.ttl, vxlan_ttl);
}

#endif // VXLAN_OPTION

/**
* Attempts to create a bridge link.
*
Expand Down Expand Up @@ -362,6 +366,8 @@ TEST_F(SwitchlinkTest, does_not_create_bridge_link) {
ASSERT_EQ(results.size(), 0);
}

#ifdef VXLAN_OPTION

/**
* Deletes a vxlan link.
*
Expand Down Expand Up @@ -411,6 +417,8 @@ TEST_F(SwitchlinkTest, can_delete_vxlan_link) {
EXPECT_EQ(results[0].ifindex, hdr.ifi_index);
}

#endif // VXLAN_OPTION

/**
* Deletes a tunnel ("tun") link.
*
Expand Down

0 comments on commit db0a394

Please sign in to comment.