xref: /kernel/linux/linux-6.6/tools/testing/selftests/bpf/bpf_sockopt_helpers.h
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /kernel/linux/linux-6.6/tools/testing/selftests/bpf/
162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci
362306a36Sopenharmony_ci#include <sys/socket.h>
462306a36Sopenharmony_ci#include <bpf/bpf_helpers.h>
562306a36Sopenharmony_ci
662306a36Sopenharmony_ciint get_set_sk_priority(void *ctx)
762306a36Sopenharmony_ci{
862306a36Sopenharmony_ci	int prio;
962306a36Sopenharmony_ci
1062306a36Sopenharmony_ci	/* Verify that context allows calling bpf_getsockopt and
1162306a36Sopenharmony_ci	 * bpf_setsockopt by reading and writing back socket
1262306a36Sopenharmony_ci	 * priority.
1362306a36Sopenharmony_ci	 */
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci	if (bpf_getsockopt(ctx, SOL_SOCKET, SO_PRIORITY, &prio, sizeof(prio)))
1662306a36Sopenharmony_ci		return 0;
1762306a36Sopenharmony_ci	if (bpf_setsockopt(ctx, SOL_SOCKET, SO_PRIORITY, &prio, sizeof(prio)))
1862306a36Sopenharmony_ci		return 0;
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ci	return 1;
2162306a36Sopenharmony_ci}
22

Indexes created Thu Nov 07 10:32:03 CST 2024