1. 08 Oct, 2019 14 commits
  2. 07 Oct, 2019 5 commits
  3. 06 Oct, 2019 7 commits
    • Toke Høiland-Jørgensen's avatar
      libbpf: Add cscope and tags targets to Makefile · a9eb048d
      Toke Høiland-Jørgensen authored
      Using cscope and/or TAGS files for navigating the source code is useful.
      Add simple targets to the Makefile to generate the index files for both
      tools.
      Signed-off-by: default avatarToke Høiland-Jørgensen <toke@redhat.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Tested-by: default avatarAndrii Nakryiko <andriin@fb.com>
      Acked-by: default avatarAndrii Nakryiko <andriin@fb.com>
      Link: https://lore.kernel.org/bpf/20191004153444.1711278-1-toke@redhat.com
      a9eb048d
    • Alexei Starovoitov's avatar
      Merge branch 'libbpf-api' · b84fbfe2
      Alexei Starovoitov authored
      Andrii Nakryiko says:
      
      ====================
      Add bpf_object__open_file() and bpf_object__open_mem() APIs that use a new
      approach to providing future-proof non-ABI-breaking API changes. It relies on
      APIs accepting optional self-describing "opts" struct, containing its own
      size, filled out and provided by potentially outdated (as well as
      newer-than-libbpf) user application. A set of internal helper macros
      (OPTS_VALID, OPTS_HAS, and OPTS_GET) streamline and simplify a graceful
      handling forward and backward compatibility for user applications dynamically
      linked against different versions of libbpf shared library.
      
      Users of libbpf are provided with convenience macro LIBBPF_OPTS that takes
      care of populating correct structure size and zero-initializes options struct,
      which helps avoid obscure issues of unitialized padding. Uninitialized padding
      in a struct might turn into garbage-populated new fields understood by future
      versions of libbpf.
      
      Patch #1 removes enforcement of kern_version in libbpf and always populates
      correct one on behalf of users.
      Patch #2 defines necessary infrastructure for options and two new open APIs
      relying on it.
      Patch #3 fixes bug in bpf_object__name().
      Patch #4 switches two of test_progs' tests to use new APIs as a validation
      that they work as expected.
      
      v2->v3:
      - fix LIBBPF_OPTS() to ensure zero-initialization of padded bytes;
      - pass through name override and relaxed maps flag for open_file() (Toke);
      - fix bpf_object__name() to actually return object name;
      - don't bother parsing and verifying version section (John);
      
      v1->v2:
      - use better approach for tracking last field in opts struct;
      - convert few tests to new APIs for validation;
      - fix bug with using offsetof(last_field) instead of offsetofend(last_field).
      ====================
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      b84fbfe2
    • Andrii Nakryiko's avatar
      selftests/bpf: switch tests to new bpf_object__open_{file, mem}() APIs · 928ca75e
      Andrii Nakryiko authored
      Verify new bpf_object__open_mem() and bpf_object__open_file() APIs work
      as expected by switching test_attach_probe test to use embedded BPF
      object and bpf_object__open_mem() and test_reference_tracking to
      bpf_object__open_file().
      Signed-off-by: default avatarAndrii Nakryiko <andriin@fb.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      928ca75e
    • Andrii Nakryiko's avatar
      libbpf: fix bpf_object__name() to actually return object name · c9e4c301
      Andrii Nakryiko authored
      bpf_object__name() was returning file path, not name. Fix this.
      Signed-off-by: default avatarAndrii Nakryiko <andriin@fb.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      c9e4c301
    • Andrii Nakryiko's avatar
      libbpf: add bpf_object__open_{file, mem} w/ extensible opts · 2ce8450e
      Andrii Nakryiko authored
      Add new set of bpf_object__open APIs using new approach to optional
      parameters extensibility allowing simpler ABI compatibility approach.
      
      This patch demonstrates an approach to implementing libbpf APIs that
      makes it easy to extend existing APIs with extra optional parameters in
      such a way, that ABI compatibility is preserved without having to do
      symbol versioning and generating lots of boilerplate code to handle it.
      To facilitate succinct code for working with options, add OPTS_VALID,
      OPTS_HAS, and OPTS_GET macros that hide all the NULL, size, and zero
      checks.
      
      Additionally, newly added libbpf APIs are encouraged to follow similar
      pattern of having all mandatory parameters as formal function parameters
      and always have optional (NULL-able) xxx_opts struct, which should
      always have real struct size as a first field and the rest would be
      optional parameters added over time, which tune the behavior of existing
      API, if specified by user.
      Signed-off-by: default avatarAndrii Nakryiko <andriin@fb.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      2ce8450e
    • Andrii Nakryiko's avatar
      libbpf: stop enforcing kern_version, populate it for users · 5e61f270
      Andrii Nakryiko authored
      Kernel version enforcement for kprobes/kretprobes was removed from
      5.0 kernel in 6c4fc209 ("bpf: remove useless version check for prog load").
      Since then, BPF programs were specifying SEC("version") just to please
      libbpf. We should stop enforcing this in libbpf, if even kernel doesn't
      care. Furthermore, libbpf now will pre-populate current kernel version
      of the host system, in case we are still running on old kernel.
      
      This patch also removes __bpf_object__open_xattr from libbpf.h, as
      nothing in libbpf is relying on having it in that header. That function
      was never exported as LIBBPF_API and even name suggests its internal
      version. So this should be safe to remove, as it doesn't break ABI.
      Signed-off-by: default avatarAndrii Nakryiko <andriin@fb.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      5e61f270
    • Andrii Nakryiko's avatar
      libbpf: Fix BTF-defined map's __type macro handling of arrays · a53ba15d
      Andrii Nakryiko authored
      Due to a quirky C syntax of declaring pointers to array or function
      prototype, existing __type() macro doesn't work with map key/value types
      that are array or function prototype. One has to create a typedef first
      and use it to specify key/value type for a BPF map.  By using typeof(),
      pointer to type is now handled uniformly for all kinds of types. Convert
      one of self-tests as a demonstration.
      Signed-off-by: default avatarAndrii Nakryiko <andriin@fb.com>
      Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
      Link: https://lore.kernel.org/bpf/20191004040211.2434033-1-andriin@fb.com
      a53ba15d
  4. 04 Oct, 2019 2 commits
  5. 03 Oct, 2019 2 commits
    • Ivan Khoronzhuk's avatar
      selftests/bpf: Correct path to include msg + path · c5881463
      Ivan Khoronzhuk authored
      The "path" buf is supposed to contain path + printf msg up to 24 bytes.
      It will be cut anyway, but compiler generates truncation warns like:
      
      "
      samples/bpf/../../tools/testing/selftests/bpf/cgroup_helpers.c: In
      function ‘setup_cgroup_environment’:
      samples/bpf/../../tools/testing/selftests/bpf/cgroup_helpers.c:52:34:
      warning: ‘/cgroup.controllers’ directive output may be truncated
      writing 19 bytes into a region of size between 1 and 4097
      [-Wformat-truncation=]
      snprintf(path, sizeof(path), "%s/cgroup.controllers", cgroup_path);
      				  ^~~~~~~~~~~~~~~~~~~
      samples/bpf/../../tools/testing/selftests/bpf/cgroup_helpers.c:52:2:
      note: ‘snprintf’ output between 20 and 4116 bytes into a destination
      of size 4097
      snprintf(path, sizeof(path), "%s/cgroup.controllers", cgroup_path);
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      samples/bpf/../../tools/testing/selftests/bpf/cgroup_helpers.c:72:34:
      warning: ‘/cgroup.subtree_control’ directive output may be truncated
      writing 23 bytes into a region of size between 1 and 4097
      [-Wformat-truncation=]
      snprintf(path, sizeof(path), "%s/cgroup.subtree_control",
      				  ^~~~~~~~~~~~~~~~~~~~~~~
      cgroup_path);
      samples/bpf/../../tools/testing/selftests/bpf/cgroup_helpers.c:72:2:
      note: ‘snprintf’ output between 24 and 4120 bytes into a destination
      of size 4097
      snprintf(path, sizeof(path), "%s/cgroup.subtree_control",
      cgroup_path);
      "
      
      In order to avoid warns, lets decrease buf size for cgroup workdir on
      24 bytes with assumption to include also "/cgroup.subtree_control" to
      the address. The cut will never happen anyway.
      Signed-off-by: default avatarIvan Khoronzhuk <ivan.khoronzhuk@linaro.org>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarSong Liu <songliubraving@fb.com>
      Link: https://lore.kernel.org/bpf/20191002120404.26962-3-ivan.khoronzhuk@linaro.org
      c5881463
    • Ivan Khoronzhuk's avatar
      selftests/bpf: Add static to enable_all_controllers() · fb27dcd2
      Ivan Khoronzhuk authored
      Add static to enable_all_controllers() to get rid from annoying warning
      during samples/bpf build:
      
      samples/bpf/../../tools/testing/selftests/bpf/cgroup_helpers.c:44:5:
      warning: no previous prototype for ‘enable_all_controllers’
      [-Wmissing-prototypes]
       int enable_all_controllers(char *cgroup_path)
      Signed-off-by: default avatarIvan Khoronzhuk <ivan.khoronzhuk@linaro.org>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarSong Liu <songliubraving@fb.com>
      Link: https://lore.kernel.org/bpf/20191002120404.26962-2-ivan.khoronzhuk@linaro.org
      fb27dcd2
  6. 01 Oct, 2019 10 commits
    • Andrii Nakryiko's avatar
      libbpf: Bump current version to v0.0.6 · 03bd4773
      Andrii Nakryiko authored
      New release cycle started, let's bump to v0.0.6 proactively.
      Signed-off-by: default avatarAndrii Nakryiko <andriin@fb.com>
      Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
      Acked-by: default avatarSong Liu <songliubraving@fb.com>
      Link: https://lore.kernel.org/bpf/20190930222503.519782-1-andriin@fb.com
      03bd4773
    • Simon Horman's avatar
      dt-bindings: sh_eth convert bindings to json-schema · 37a2fce0
      Simon Horman authored
      Convert Renesas Electronics SH EtherMAC bindings documentation to
      json-schema.  Also name bindings documentation file according to the compat
      string being documented.
      Signed-off-by: default avatarSimon Horman <horms+renesas@verge.net.au>
      Reviewed-by: default avatarSergei Shtylyov <sergei.shtylyov@cogentembedded.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      37a2fce0
    • Peter Fink's avatar
      net: usb: ax88179_178a: allow optionally getting mac address from device tree · 9fb137ae
      Peter Fink authored
      Adopt and integrate the feature to pass the MAC address via device tree
      from asix_device.c (03fc5d4f) also to other ax88179 based asix chips.
      E.g. the bootloader fills in local-mac-address and the driver will then
      pick up and use this MAC address.
      Signed-off-by: default avatarPeter Fink <pfink@christ-es.de>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      9fb137ae
    • Nicolas Dichtel's avatar
      ipv6: minor code reorg in inet6_fill_ifla6_attrs() · 0d7982ce
      Nicolas Dichtel authored
      Just put related code together to ease code reading: the memcpy() is
      related to the nla_reserve().
      Signed-off-by: default avatarNicolas Dichtel <nicolas.dichtel@6wind.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      0d7982ce
    • David S. Miller's avatar
      Merge branch 'netdev-altnames' · 7a56493f
      David S. Miller authored
      Jiri Pirko says:
      
      ====================
      net: introduce alternative names for network interfaces
      
      In the past, there was repeatedly discussed the IFNAMSIZ (16) limit for
      netdevice name length. Now when we have PF and VF representors
      with port names like "pfXvfY", it became quite common to hit this limit:
      0123456789012345
      enp131s0f1npf0vf6
      enp131s0f1npf0vf22
      
      Udev cannot rename these interfaces out-of-the-box and user needs to
      create custom rules to handle them.
      
      Also, udev has multiple schemes of netdev names. From udev code:
       * Type of names:
       *   b<number>                             - BCMA bus core number
       *   c<bus_id>                             - bus id of a grouped CCW or CCW device,
       *                                           with all leading zeros stripped [s390]
       *   o<index>[n<phys_port_name>|d<dev_port>]
       *                                         - on-board device index number
       *   s<slot>[f<function>][n<phys_port_name>|d<dev_port>]
       *                                         - hotplug slot index number
       *   x<MAC>                                - MAC address
       *   [P<domain>]p<bus>s<slot>[f<function>][n<phys_port_name>|d<dev_port>]
       *                                         - PCI geographical location
       *   [P<domain>]p<bus>s<slot>[f<function>][u<port>][..][c<config>][i<interface>]
       *                                         - USB port number chain
       *   v<slot>                               - VIO slot number (IBM PowerVM)
       *   a<vendor><model>i<instance>           - Platform bus ACPI instance id
       *   i<addr>n<phys_port_name>              - Netdevsim bus address and port name
      
      One device can be often renamed by multiple patterns at the
      same time (e.g. pci address/mac).
      
      This patchset introduces alternative names for network interfaces.
      Main goal is to:
      1) Overcome the IFNAMSIZ limitation (altname limitation is 128 bytes)
      2) Allow to have multiple names at the same time (multiple udev patterns)
      3) Allow to use alternative names as handle for commands
      
      The patchset introduces two new commands to add/delete list of properties.
      Currently only alternative names are implemented but the ifrastructure
      could be easily extended later on. This is very similar to the list of vlan
      and tunnels being added/deleted to/from bridge ports.
      
      See following examples.
      
      $ ip link
      1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
          link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
      2: dummy0: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
          link/ether ae:67:a9:67:46:86 brd ff:ff:ff:ff:ff:ff
      
      -> Add alternative names for dummy0:
      
      $ ip link prop add dummy0 altname someothername
      $ ip link prop add dummy0 altname someotherveryveryveryverylongname
      $ ip link
      1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
          link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
      2: dummy0: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
          link/ether ae:67:a9:67:46:86 brd ff:ff:ff:ff:ff:ff
          altname someothername
          altname someotherveryveryveryverylongname
      $ ip link show someotherveryveryveryverylongname
      2: dummy0: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
          link/ether ae:67:a9:67:46:86 brd ff:ff:ff:ff:ff:ff
          altname someothername
          altname someotherveryveryveryverylongname
      
      -> Add bridge brx, add it's alternative name and use alternative names to
         do enslavement.
      
      $ ip link add name brx type bridge
      $ ip link prop add brx altname mypersonalsuperspecialbridge
      $ ip link set someotherveryveryveryverylongname master mypersonalsuperspecialbridge
      $ ip link
      1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
          link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
      2: dummy0: <BROADCAST,NOARP> mtu 1500 qdisc noop master brx state DOWN mode DEFAULT group default qlen 1000
          link/ether ae:67:a9:67:46:86 brd ff:ff:ff:ff:ff:ff
          altname someothername
          altname someotherveryveryveryverylongname
      3: brx: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
          link/ether ae:67:a9:67:46:86 brd ff:ff:ff:ff:ff:ff
          altname mypersonalsuperspecialbridge
      
      -> Add ipv4 address to the bridge using alternative name:
      
      $ ip addr add 192.168.0.1/24 dev mypersonalsuperspecialbridge
      $ ip addr show mypersonalsuperspecialbridge
      3: brx: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
          link/ether ae:67:a9:67:46:86 brd ff:ff:ff:ff:ff:ff
          altname mypersonalsuperspecialbridge
          inet 192.168.0.1/24 scope global brx
             valid_lft forever preferred_lft forever
      
      -> Delete one of dummy0 alternative names:
      
      $ ip link prop del dummy0 altname someotherveryveryveryverylongname
      $ ip link
      1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
          link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
      2: dummy0: <BROADCAST,NOARP> mtu 1500 qdisc noop master brx state DOWN mode DEFAULT group default qlen 1000
          link/ether ae:67:a9:67:46:86 brd ff:ff:ff:ff:ff:ff
          altname someothername
      3: brx: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
          link/ether ae:67:a9:67:46:86 brd ff:ff:ff:ff:ff:ff
          altname mypersonalsuperspecialbridge
      
      -> Add multiple alternative names at once
      
      $ ip link prop add dummy0 altname a altname b altname c altname d
      $ ip link
      1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
          link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
      2: dummy0: <BROADCAST,NOARP> mtu 1500 qdisc noop master brx state DOWN mode DEFAULT group default qlen 1000
          link/ether ae:67:a9:67:46:86 brd ff:ff:ff:ff:ff:ff
          altname someothername
          altname a
          altname b
          altname c
          altname d
      3: brx: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
          link/ether ae:67:a9:67:46:86 brd ff:ff:ff:ff:ff:ff
          altname mypersonalsuperspecialbridge
      ====================
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      7a56493f
    • Jiri Pirko's avatar
      net: rtnetlink: add possibility to use alternative names as message handle · 76c9ac0e
      Jiri Pirko authored
      Extend the basic rtnetlink commands to use alternative interface names
      as a handle instead of ifindex and ifname.
      Signed-off-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      76c9ac0e
    • Jiri Pirko's avatar
      net: rtnetlink: introduce helper to get net_device instance by ifname · cc6090e9
      Jiri Pirko authored
      Introduce helper function rtnl_get_dev() that gets net_device structure
      instance pointer according to passed ifname or ifname attribute.
      Signed-off-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      cc6090e9
    • Jiri Pirko's avatar
      net: rtnetlink: unify the code in __rtnl_newlink get dev with the rest · 7af12cba
      Jiri Pirko authored
      __rtnl_newlink() code flow is a bit different around tb[IFLA_IFNAME]
      processing comparing to the other places. Change that to be unified with
      the rest.
      Signed-off-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      7af12cba
    • Jiri Pirko's avatar
      net: rtnetlink: put alternative names to getlink message · 88f4fb0c
      Jiri Pirko authored
      Extend exiting getlink info message with list of properties. Now the
      only ones are alternative names.
      Signed-off-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      88f4fb0c
    • Jiri Pirko's avatar
      net: rtnetlink: add linkprop commands to add and delete alternative ifnames · 36fbf1e5
      Jiri Pirko authored
      Add two commands to add and delete list of link properties. Implement
      the first property type along - alternative ifnames.
      Each net device can have multiple alternative names.
      Signed-off-by: default avatarJiri Pirko <jiri@mellanox.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      36fbf1e5