On Wed, Nov 9, 2022 at 9:46 AM Donald Hunter <donald.hunter@xxxxxxxxx> wrote: > > From: Dave Tucker <dave@xxxxxxxxxxxxx> > > Add documentation for the BPF_MAP_TYPE_ARRAY including kernel version > introduced, usage and examples. Also document BPF_MAP_TYPE_PERCPU_ARRAY > which is similar. > > Signed-off-by: Dave Tucker <dave@xxxxxxxxxxxxx> > Co-developed-by: Donald Hunter <donald.hunter@xxxxxxxxx> > Signed-off-by: Donald Hunter <donald.hunter@xxxxxxxxx> > Reviewed-by: Maryam Tahhan <mtahhan@xxxxxxxxxx> > --- > Documentation/bpf/map_array.rst | 250 ++++++++++++++++++++++++++++++++ > 1 file changed, 250 insertions(+) > create mode 100644 Documentation/bpf/map_array.rst > [...] > +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. > + > + return 0; > + } > + > +Userspace > +--------- > + > +BPF_MAP_TYPE_ARRAY > +~~~~~~~~~~~~~~~~~~ > + > +This snippet shows how to create an array, using ``bpf_map_create_opts`` to > +set flags. > + [...]