On Mon, Nov 14, 2022 at 2:57 AM Donald Hunter <donald.hunter@xxxxxxxxx> wrote: > > Andrii Nakryiko <andrii.nakryiko@xxxxxxxxx> writes: > > > On Wed, Nov 9, 2022 at 9:46 AM Donald Hunter <donald.hunter@xxxxxxxxx> wrote: > >> > >> +This example BPF program shows how to access an array element. > >> + > >> +.. code-block:: c > >> + > >> + int bpf_prog(struct __sk_buff *skb) > >> + { > >> + struct iphdr ip; > >> + int index; > >> + long *value; > >> + > >> + if (bpf_skb_load_bytes(skb, ETH_HLEN, &ip, sizeof(ip)) < 0) > >> + return 0; > >> + > >> + index = ip.protocol; > >> + value = bpf_map_lookup_elem(&my_map, &index); > >> + if (value) > >> + __sync_fetch_and_add(value, skb->len); > > > > should be &value > > > > I fixed it up and applied to bpf-next, thanks. > > I double checked and it really should be value, which is already a > pointer. > > Do you want me to send a patch to fix it up? Oh, my bad, value is a pointer already and I was (wrongly) convinced that it's just a stack variable. Yes, please send a patch, thanks!