Re: [PATCH bpf-next v10 1/1] bpf, docs: document BPF_MAP_TYPE_ARRAY

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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!



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux