Revision fc7655ab9292bc496fe95ccf92b75f4faa12c834 authored by André Martins on 16 June 2024, 14:50:48 UTC, committed by André Martins on 20 June 2024, 18:58:31 UTC
If we enable auto merge for trusted dependencies we will be able to
reduce the load on reviewers by skipping the reviews of certain
trusted libraries.

Signed-off-by: André Martins <andre@cilium.io>
1 parent 8e6d288
Raw File
bpf_skb_255_tests.c
// SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
/* Copyright Authors of Cilium */

#ifndef __CLUSTERMESH_IDENTITY__
#define __CLUSTERMESH_IDENTITY__
#define CLUSTER_ID_MAX 255
#endif

#ifndef __CLUSTERMESH_HELPERS__
#define __CLUSTERMESH_HELPERS__
#define IDENTITY_LEN 8
#define IDENTITY_MAX 255
#endif

#include "common.h"

#include <bpf/ctx/skb.h>
#include <lib/overloadable.h>
#include <lib/clustermesh.h>

#define CLUSTER_LOCAL_IDENTITY 0xAAAA
#define TEST_CLUSTER_ID 0xFFu
#define IDENTITY (0x00000000u | (TEST_CLUSTER_ID << IDENTITY_LEN) | CLUSTER_LOCAL_IDENTITY)

CHECK("tc", "set_and_get_identity")
int check_get_identity(struct __ctx_buff *ctx)
{
	__u32 identity;
	__u32 cluster_id;

	test_init();

	set_identity_mark(ctx, IDENTITY, MARK_MAGIC_IDENTITY);

	identity = get_identity(ctx);
	if (identity != IDENTITY)
		test_fatal("skb->mark should contain identity %u, got %u", IDENTITY, identity);
	cluster_id = extract_cluster_id_from_identity(identity);
	if (cluster_id != TEST_CLUSTER_ID)
		test_fatal("cluster_id should be %u, got %u", TEST_CLUSTER_ID, cluster_id);

	test_finish();
}

CHECK("tc", "set_and_get_cluster_id")
int check_ctx_get_cluster_id_mark(struct __ctx_buff *ctx)
{
	__u32 cluster_id;

	test_init();

	ctx_set_cluster_id_mark(ctx, TEST_CLUSTER_ID);

	cluster_id = ctx_get_cluster_id_mark(ctx);
	if (cluster_id != TEST_CLUSTER_ID)
		test_fatal("cluster_id should be %u, got %u", TEST_CLUSTER_ID, cluster_id);

	test_finish();
}
back to top