Quellcodebibliothek Statistik Leitseite products/sources/formale Sprachen/C/Linux/tools/testing/selftests/bpf/progs/   (Open Source Betriebssystem Version 6.17.9©)  Datei vom 24.10.2025 mit Größe 1 kB image not shown  

Quelle  test_queue_stack_map.h   Sprache: C

 
/* SPDX-License-Identifier: GPL-2.0 */
// Copyright (c) 2018 Politecnico di Torino
#include <stddef.h>
#include <string.h>
#include <linux/bpf.h>
#include <linux/if_ether.h>
#include <linux/ip.h>
#include <linux/pkt_cls.h>
#include <bpf/bpf_helpers.h>

struct {
 __uint(type, MAP_TYPE);
 __uint(max_entries, 32);
 __uint(map_flags, 0);
 __uint(key_size, 0);
 __uint(value_size, sizeof(__u32));
} map_in SEC(".maps");

struct {
 __uint(type, MAP_TYPE);
 __uint(max_entries, 32);
 __uint(map_flags, 0);
 __uint(key_size, 0);
 __uint(value_size, sizeof(__u32));
} map_out SEC(".maps");

SEC("tc")
int _test(struct __sk_buff *skb)
{
 void *data_end = (void *)(long)skb->data_end;
 void *data = (void *)(long)skb->data;
 struct ethhdr *eth = (struct ethhdr *)(data);
 __u32 value;
 int err;

 if (eth + 1 > data_end)
  return TC_ACT_SHOT;

 struct iphdr *iph = (struct iphdr *)(eth + 1);

 if (iph + 1 > data_end)
  return TC_ACT_SHOT;

 err = bpf_map_pop_elem(&map_in, &value);
 if (err)
  return TC_ACT_SHOT;

 iph->daddr = value;

 err = bpf_map_push_elem(&map_out, &iph->saddr, 0);
 if (err)
  return TC_ACT_SHOT;

 return TC_ACT_OK;
}

char _license[] SEC("license") = "GPL";

Messung V0.5
C=94 H=95 G=94

¤ Dauer der Verarbeitung: 0.11 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.