root/tools/testing/selftests/bpf/progs/loop5.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. SEC

   1 // SPDX-License-Identifier: GPL-2.0
   2 // Copyright (c) 2019 Facebook
   3 #include <linux/bpf.h>
   4 #include "bpf_helpers.h"
   5 #define barrier() __asm__ __volatile__("": : :"memory")
   6 
   7 char _license[] SEC("license") = "GPL";
   8 
   9 SEC("socket")
  10 int while_true(volatile struct __sk_buff* skb)
  11 {
  12         int i = 0;
  13 
  14         while (1) {
  15                 if (skb->len)
  16                         i += 3;
  17                 else
  18                         i += 7;
  19                 if (i == 9)
  20                         break;
  21                 barrier();
  22                 if (i == 10)
  23                         break;
  24                 barrier();
  25                 if (i == 13)
  26                         break;
  27                 barrier();
  28                 if (i == 14)
  29                         break;
  30         }
  31         return i;
  32 }

/* [<][>][^][v][top][bottom][index][help] */