Netdev List
 help / color / mirror / Atom feed
* Re: [PATCH bpf-next 1/6] bpf: Add a bpf_sock pointer to __sk_buff and a bpf_sk_fullsock helper
From: Alexei Starovoitov @ 2019-02-02  2:38 UTC (permalink / raw)
  To: Martin KaFai Lau
  Cc: netdev, Alexei Starovoitov, Daniel Borkmann, kernel-team,
	Lawrence Brakmo, joe, john.fastabend, willemb
In-Reply-To: <20190201070356.4148323-1-kafai@fb.com>

On Thu, Jan 31, 2019 at 11:03:56PM -0800, Martin KaFai Lau wrote:
> In kernel, it is common to check "!skb->sk && sk_fullsock(skb->sk)"
> before accessing the fields in sock.  For example, in __netdev_pick_tx:
> 
> static u16 __netdev_pick_tx(struct net_device *dev, struct sk_buff *skb,
> 			    struct net_device *sb_dev)
> {
> 	/* ... */
> 
> 	struct sock *sk = skb->sk;
> 
> 		if (queue_index != new_index && sk &&
> 		    sk_fullsock(sk) &&
> 		    rcu_access_pointer(sk->sk_dst_cache))
> 			sk_tx_queue_set(sk, new_index);
> 
> 	/* ... */
> 
> 	return queue_index;
> }
> 
> This patch adds a "struct bpf_sock *sk" pointer to the "struct __sk_buff"
...
> Some of the fileds in "bpf_sock" will not be directly
> accessible through the "__sk_buff->sk" pointer.
...
> The newly added "struct bpf_sock *bpf_sk_fullsock(struct bpf_sock *sk)"
> can be used to get a sk with all accessible fields in "bpf_sock".
> This helper is added to both cg_skb and sched_(cls|act).
> 
> int cg_skb_foo(struct __sk_buff *skb) {
> 	struct bpf_sock *sk;
> 	__u32 family;
> 
> 	sk = skb->sk;
> 	if (!sk)
> 		return 1;
> 
> 	sk = bpf_sk_fullsock(sk);
> 	if (!sk)
> 		return 1;
> 
> 	if (sk->family != AF_INET6 || sk->protocol != IPPROTO_TCP)
> 		return 1;
> 
> 	/* some_traffic_shaping(); */
> 
> 	return 1;
> }
> 
> (1) The sk is read only
> 
> (2) There is no new "struct bpf_sock_common" introduced.
> 
> (3) Future kernel sock's members could be added to bpf_sock only
>     instead of repeatedly adding at multiple places like currently
>     in bpf_sock_ops_md, bpf_sock_addr_md, sk_reuseport_md...etc.

All,

this patchset sets a direction on how access to kernel socket datastructures
should be made from bpf programs of networking types.

It makes bpf program access to sk_common, sk, tcp_sock fields look and feel
like kernel code.
We think it's the most flexible and fixes the copy-paste issue of existing api.
I wish we thought of it earlier :)

Please review.

For the patch set:
Acked-by: Alexei Starovoitov <ast@kernel.org>


^ permalink raw reply

* Re: [PATCH v2] net: dp83640: expire old TX-skb
From: Richard Cochran @ 2019-02-02  2:38 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: Andrew Lunn, Florian Fainelli, Heiner Kallweit, netdev
In-Reply-To: <20190201210918.gvufqxpqzvuzfk5n@linutronix.de>

On Fri, Feb 01, 2019 at 10:09:18PM +0100, Sebastian Andrzej Siewior wrote:
> During sendmsg() a cloned skb is saved via dp83640_txtstamp() in
> ->tx_queue. After the NIC sends this packet, the PHY will reply with a
> timestamp for that TX packet. If the cable is pulled at the right time I
> don't see that packet. It might gets flushed as part of queue shutdown
> on NIC's side.
> Once the link is up again then after the next sendmsg() we enqueue
> another skb in dp83640_txtstamp() and have two on the list. Then the PHY
> will send a reply and decode_txts() attaches it to the first skb on the
> list.
> No crash occurs since refcounting works but we are one packet behind.
> linuxptp/ptp4l usually closes the socket and opens a new one (in such a
> timeout case) so those "stale" replies never get there. However it does
> not resume normal operation anymore.
> 
> Purge old skbs in decode_txts().
> 
> Cc: stable@vger.kernel.org
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
> Reviewed-by: Kurt Kanzenbach <kurt@linutronix.de>

Acked-by: Richard Cochran <richardcochran@gmail.com>

^ permalink raw reply

* pull-request: bpf-next 2019-02-01
From: Alexei Starovoitov @ 2019-02-02  2:14 UTC (permalink / raw)
  To: davem; +Cc: daniel, ast, netdev, kernel-team

Hi David,

The following pull-request contains BPF updates for your *net-next* tree.

The main changes are:

1) introduce bpf_spin_lock, from Alexei.

2) convert xdp samples to libbpf, from Maciej.

3) skip verifier tests for unsupported program/map types, from Stanislav.

4) powerpc64 JIT support for BTF line info, from Sandipan.

5) assorted fixed, from Valdis, Jesper, Jiong.

Please consider pulling these changes from:

  git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git

Thanks a lot!

----------------------------------------------------------------

The following changes since commit 630afc7734bac1229ef601b65769a898189e1b3d:

  Merge branch 'hns3-next' (2019-01-30 14:50:04 -0800)

are available in the Git repository at:

  git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git 

for you to fetch changes up to 5974b7c1e40da80a5986f0464ae47687ce4a8021:

  Merge branch 'shifts-cleanup' (2019-02-01 18:03:50 -0800)

----------------------------------------------------------------
Alexei Starovoitov (10):
      bpf: introduce bpf_spin_lock
      bpf: add support for bpf_spin_lock to cgroup local storage
      tools/bpf: sync include/uapi/linux/bpf.h
      selftests/bpf: add bpf_spin_lock verifier tests
      selftests/bpf: add bpf_spin_lock C test
      bpf: introduce BPF_F_LOCK flag
      tools/bpf: sync uapi/bpf.h
      libbpf: introduce bpf_map_lookup_elem_flags()
      selftests/bpf: test for BPF_F_LOCK
      Merge branch 'shifts-cleanup'

Daniel Borkmann (3):
      Merge branch 'bpf-tests-probe-kernel-support'
      Merge branch 'bpf-spinlocks'
      Merge branch 'bpf-xdp-sample-libbpf'

Jesper Dangaard Brouer (1):
      samples/bpf: xdp_redirect_cpu have not need for read_trace_pipe

Jiong Wang (2):
      nfp: bpf: correct the behavior for shifts by zero
      nfp: bpf: complete ALU32 logic shift supports

Maciej Fijalkowski (7):
      libbpf: Add a helper for retrieving a map fd for a given name
      samples/bpf: Convert XDP samples to libbpf usage
      samples/bpf: Extend RLIMIT_MEMLOCK for xdp_{sample_pkts, router_ipv4}
      xdp: Provide extack messages when prog attachment failed
      samples/bpf: Add a "force" flag to XDP samples
      libbpf: Add a support for getting xdp prog id on ifindex
      samples/bpf: Check the prog id before exiting

Sandipan Das (1):
      bpf: powerpc64: add JIT support for bpf line info

Stanislav Fomichev (6):
      selftests/bpf: skip sockmap in test_maps if kernel doesn't have support
      selftests/bpf: skip verifier tests for unsupported program types
      selftests/bpf: skip verifier tests for unsupported map types
      selftests/bpf: mark verifier test that uses bpf_trace_printk as BPF_PROG_TYPE_TRACEPOINT
      bpf: BPF_PROG_TYPE_CGROUP_{SKB, SOCK, SOCK_ADDR} require cgroups enabled
      selftests/bpf: remove generated verifier/tests.h on 'make clean'

Valdis Kletnieks (3):
      bpf: fix bitrotted kerneldoc
      bpf: fix missing prototype warnings
      bpf, cgroups: clean up kerneldoc warnings

 arch/powerpc/net/bpf_jit_comp64.c                |   1 +
 drivers/net/ethernet/netronome/nfp/bpf/jit.c     |  92 ++++++-
 include/linux/bpf-cgroup.h                       |   2 +-
 include/linux/bpf.h                              |  39 ++-
 include/linux/bpf_types.h                        |   2 +
 include/linux/bpf_verifier.h                     |   1 +
 include/linux/btf.h                              |   1 +
 include/linux/filter.h                           |   4 +-
 include/uapi/linux/bpf.h                         |   8 +-
 kernel/Kconfig.locks                             |   3 +
 kernel/bpf/arraymap.c                            |  23 +-
 kernel/bpf/btf.c                                 |  42 +++
 kernel/bpf/cgroup.c                              |   3 +-
 kernel/bpf/core.c                                |   5 +-
 kernel/bpf/hashtab.c                             |  63 ++++-
 kernel/bpf/helpers.c                             |  96 +++++++
 kernel/bpf/local_storage.c                       |  16 +-
 kernel/bpf/map_in_map.c                          |   5 +
 kernel/bpf/syscall.c                             |  45 ++-
 kernel/bpf/verifier.c                            | 171 +++++++++++-
 kernel/cgroup/cgroup.c                           |   2 +-
 net/core/dev.c                                   |  12 +-
 net/core/filter.c                                |  16 +-
 samples/bpf/Makefile                             |   8 +-
 samples/bpf/xdp1_user.c                          |  34 ++-
 samples/bpf/xdp_adjust_tail_user.c               |  38 ++-
 samples/bpf/xdp_redirect_cpu_user.c              | 196 ++++++++++----
 samples/bpf/xdp_redirect_map_user.c              | 106 ++++++--
 samples/bpf/xdp_redirect_user.c                  | 103 +++++--
 samples/bpf/xdp_router_ipv4_user.c               | 179 ++++++++----
 samples/bpf/xdp_rxq_info_user.c                  |  41 ++-
 samples/bpf/xdp_sample_pkts_user.c               |  81 +++++-
 samples/bpf/xdp_tx_iptunnel_user.c               |  71 +++--
 samples/bpf/xdpsock_user.c                       |  30 +-
 tools/include/uapi/linux/bpf.h                   |   8 +-
 tools/lib/bpf/bpf.c                              |  13 +
 tools/lib/bpf/bpf.h                              |   2 +
 tools/lib/bpf/libbpf.c                           |   6 +
 tools/lib/bpf/libbpf.h                           |   4 +
 tools/lib/bpf/libbpf.map                         |   3 +
 tools/lib/bpf/netlink.c                          |  85 ++++++
 tools/testing/selftests/bpf/Makefile             |  10 +-
 tools/testing/selftests/bpf/bpf_helpers.h        |   4 +
 tools/testing/selftests/bpf/test_map_lock.c      |  66 +++++
 tools/testing/selftests/bpf/test_maps.c          |  13 +-
 tools/testing/selftests/bpf/test_progs.c         | 117 +++++++-
 tools/testing/selftests/bpf/test_spin_lock.c     | 108 ++++++++
 tools/testing/selftests/bpf/test_verifier.c      | 149 +++++++++-
 tools/testing/selftests/bpf/verifier/spin_lock.c | 331 +++++++++++++++++++++++
 tools/testing/selftests/bpf/verifier/unpriv.c    |   1 +
 50 files changed, 2197 insertions(+), 262 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/test_map_lock.c
 create mode 100644 tools/testing/selftests/bpf/test_spin_lock.c
 create mode 100644 tools/testing/selftests/bpf/verifier/spin_lock.c

^ permalink raw reply

* [PATCH net-next] net: devlink: report cell size of shared buffers
From: Jakub Kicinski @ 2019-02-02  1:56 UTC (permalink / raw)
  To: davem, jiri; +Cc: idosch, netdev, oss-drivers, Jakub Kicinski

Shared buffer allocation is usually done in cell increments.
Drivers will either round up the allocation or refuse the
configuration if it's not an exact multiple of cell size.
Drivers know exactly the cell size of shared buffer, so help
out users by providing this information in dumps.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Dirk van der Merwe <dirk.vandermerwe@netronome.com>
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c | 1 +
 drivers/net/ethernet/netronome/nfp/nfp_shared_buf.c    | 1 +
 include/net/devlink.h                                  | 1 +
 include/uapi/linux/devlink.h                           | 2 ++
 net/core/devlink.c                                     | 3 +++
 5 files changed, 8 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c
index 12c61e0cc570..80066f437a65 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_buffers.c
@@ -713,6 +713,7 @@ int mlxsw_sp_sb_pool_get(struct mlxsw_core *mlxsw_core,
 	pool_info->pool_type = (enum devlink_sb_pool_type) dir;
 	pool_info->size = mlxsw_sp_cells_bytes(mlxsw_sp, pr->size);
 	pool_info->threshold_type = (enum devlink_sb_threshold_type) pr->mode;
+	pool_info->cell_size = mlxsw_sp->sb->cell_size;
 	return 0;
 }
 
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_shared_buf.c b/drivers/net/ethernet/netronome/nfp/nfp_shared_buf.c
index 814360ed3a20..ea2e3f829aba 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_shared_buf.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_shared_buf.c
@@ -48,6 +48,7 @@ int nfp_shared_buf_pool_get(struct nfp_pf *pf, unsigned int sb, u16 pool_index,
 	pool_info->pool_type = le32_to_cpu(get_data.pool_type);
 	pool_info->threshold_type = le32_to_cpu(get_data.threshold_type);
 	pool_info->size = le32_to_cpu(get_data.size) * unit_size;
+	pool_info->cell_size = unit_size;
 
 	return 0;
 }
diff --git a/include/net/devlink.h b/include/net/devlink.h
index 1c8523920f66..74d992a68a06 100644
--- a/include/net/devlink.h
+++ b/include/net/devlink.h
@@ -62,6 +62,7 @@ struct devlink_sb_pool_info {
 	enum devlink_sb_pool_type pool_type;
 	u32 size;
 	enum devlink_sb_threshold_type threshold_type;
+	u32 cell_size;
 };
 
 /**
diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h
index 7fffd879c328..054b2d1a4537 100644
--- a/include/uapi/linux/devlink.h
+++ b/include/uapi/linux/devlink.h
@@ -300,6 +300,8 @@ enum devlink_attr {
 	DEVLINK_ATTR_INFO_VERSION_NAME,		/* string */
 	DEVLINK_ATTR_INFO_VERSION_VALUE,	/* string */
 
+	DEVLINK_ATTR_SB_POOL_CELL_SIZE,		/* u32 */
+
 	/* add new attributes above here, update the policy in devlink.c */
 
 	__DEVLINK_ATTR_MAX,
diff --git a/net/core/devlink.c b/net/core/devlink.c
index eb839d74bcc0..52bf27491fb8 100644
--- a/net/core/devlink.c
+++ b/net/core/devlink.c
@@ -932,6 +932,9 @@ static int devlink_nl_sb_pool_fill(struct sk_buff *msg, struct devlink *devlink,
 	if (nla_put_u8(msg, DEVLINK_ATTR_SB_POOL_THRESHOLD_TYPE,
 		       pool_info.threshold_type))
 		goto nla_put_failure;
+	if (nla_put_u32(msg, DEVLINK_ATTR_SB_POOL_CELL_SIZE,
+			pool_info.cell_size))
+		goto nla_put_failure;
 
 	genlmsg_end(msg, hdr);
 	return 0;
-- 
2.19.2


^ permalink raw reply related

* Re: [RFC net-next 08/13] liquidio: Handle SWITCHDEV_PORT_ATTR_GET event
From: Felix Manlunas @ 2019-02-02  1:38 UTC (permalink / raw)
  To: f.fainelli@gmail.com
  Cc: netdev@vger.kernel.org, davem@davemloft.net, Felix Manlunas,
	Satananda Burla, Derek Chickles
In-Reply-To: <20190201220657.30170-9-f.fainelli@gmail.com>

On Fri,  1 Feb 2019 14:06:52 -0800, Florian Fainelli wrote:
> Following patches will change the way we communicate getting or setting
> a port's attribute and use a blocking notifier to perform those tasks.
> 
> Prepare bnxt to support receiving notifier events targeting

The code portion is fine (for 08/13), but the patch explanantion needs to
be revised.  "bnxt" should be replaced with "liquidio".

Thanks,
Felix

^ permalink raw reply

* RE: [PATCH 2/2] igb: Exclude device from suspend direct complete optimization
From: Brown, Aaron F @ 2019-02-02  0:31 UTC (permalink / raw)
  To: Kai-Heng Feng, Kirsher, Jeffrey T
  Cc: davem@davemloft.net, intel-wired-lan@lists.osuosl.org,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
In-Reply-To: <20181211075938.32026-2-kai.heng.feng@canonical.com>

> From: netdev-owner@vger.kernel.org [mailto:netdev-
> owner@vger.kernel.org] On Behalf Of Kai-Heng Feng
> Sent: Tuesday, December 11, 2018 12:00 AM
> To: Kirsher, Jeffrey T <jeffrey.t.kirsher@intel.com>
> Cc: davem@davemloft.net; intel-wired-lan@lists.osuosl.org;
> netdev@vger.kernel.org; linux-kernel@vger.kernel.org; Kai-Heng Feng
> <kai.heng.feng@canonical.com>
> Subject: [PATCH 2/2] igb: Exclude device from suspend direct complete
> optimization
> 
> igb sets different WoL settings in system suspend callback and runtime
> suspend callback.
> 
> The suspend direct complete optimization leaves igb in runtime suspneded
> state with wrong WoL setting during system suspend.
> 
> To fix this, we need to disable suspend direct complete optimization to
> let igb always use suspend callback to set correct WoL during system
> suspend.
> 
> Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
> ---
>  drivers/net/ethernet/intel/igb/igb_main.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
Tested-by: Aaron Brown <aaron.f.brown@intel.com>


^ permalink raw reply

* [PATCH bpf-next v4 0/3] tools/bpf: changes of libbpf debug interfaces
From: Yonghong Song @ 2019-02-02  0:14 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Magnus Karlsson, netdev
  Cc: Alexei Starovoitov, Daniel Borkmann, kernel-team, Yonghong Song

These are patches responding to my comments for
Magnus's patch (https://patchwork.ozlabs.org/patch/1032848/).
The goal is to make pr_* macros available to other C files
than libbpf.c, and to simplify API function libbpf_set_print().

Specifically, Patch #1 used global functions
to facilitate pr_* macros in the header files so they
are available in different C files.
Patch #2 removes the global function libbpf_print_level_available()
which is added in Patch 1.
Patch #3 simplified libbpf_set_print() which takes only one print
function with a debug level argument among others.

Changelogs:
 v3 -> v4:
   . rename libbpf internal header util.h to libbpf_util.h
   . rename libbpf internal function libbpf_debug_print() to libbpf_print()
 v2 -> v3:
   . bailed out earlier in libbpf_debug_print() if __libbpf_pr is NULL
   . added missing LIBBPF_DEBUG level check in libbpf.c __base_pr().
 v1 -> v2:
   . Renamed global function libbpf_dprint() to libbpf_debug_print()
     to be more expressive.
   . Removed libbpf_dprint_level_available() as it is used only
     once in btf.c and we can remove it by optimizing for common cases.

Yonghong Song (3):
  tools/bpf: move libbpf pr_* debug print functions to headers
  tools/bpf: print out btf log at LIBBPF_WARN level
  tools/bpf: simplify libbpf API function libbpf_set_print()

 tools/lib/bpf/btf.c                           | 110 +++++++++---------
 tools/lib/bpf/btf.h                           |   7 +-
 tools/lib/bpf/libbpf.c                        |  47 ++++----
 tools/lib/bpf/libbpf.h                        |  20 ++--
 tools/lib/bpf/libbpf_util.h                   |  30 +++++
 tools/lib/bpf/test_libbpf.cpp                 |   4 +-
 tools/perf/util/bpf-loader.c                  |  32 ++---
 tools/testing/selftests/bpf/test_btf.c        |   7 +-
 .../testing/selftests/bpf/test_libbpf_open.c  |  36 +++---
 tools/testing/selftests/bpf/test_progs.c      |  20 +++-
 10 files changed, 171 insertions(+), 142 deletions(-)
 create mode 100644 tools/lib/bpf/libbpf_util.h

-- 
2.17.1


^ permalink raw reply

* [PATCH bpf-next v4 1/3] tools/bpf: move libbpf pr_* debug print functions to headers
From: Yonghong Song @ 2019-02-02  0:14 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Magnus Karlsson, netdev
  Cc: Alexei Starovoitov, Daniel Borkmann, kernel-team, Yonghong Song
In-Reply-To: <20190202001413.3178000-1-yhs@fb.com>

A global function libbpf_print, which is invisible
outside the shared library, is defined to print based
on levels. The pr_warning, pr_info and pr_debug
macros are moved into the newly created header
common.h. So any .c file including common.h can
use these macros directly.

Currently btf__new and btf_ext__new API has an argument getting
__pr_debug function pointer into btf.c so the debugging information
can be printed there. This patch removed this parameter
from btf__new and btf_ext__new and directly using pr_debug in btf.c.

Another global function libbpf_print_level_available, also
invisible outside the shared library, can test
whether a particular level debug printing is
available or not. It is used in btf.c to
test whether DEBUG level debug printing is availabl or not,
based on which the log buffer will be allocated when loading
btf to the kernel.

Signed-off-by: Yonghong Song <yhs@fb.com>
---
 tools/lib/bpf/btf.c           | 97 +++++++++++++++++------------------
 tools/lib/bpf/btf.h           |  7 +--
 tools/lib/bpf/libbpf.c        | 46 ++++++++++++-----
 tools/lib/bpf/libbpf.h        |  6 +++
 tools/lib/bpf/libbpf_util.h   | 32 ++++++++++++
 tools/lib/bpf/test_libbpf.cpp |  2 +-
 6 files changed, 120 insertions(+), 70 deletions(-)
 create mode 100644 tools/lib/bpf/libbpf_util.h

diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c
index d682d3b8f7b9..93e792b82242 100644
--- a/tools/lib/bpf/btf.c
+++ b/tools/lib/bpf/btf.c
@@ -9,8 +9,9 @@
 #include <linux/btf.h>
 #include "btf.h"
 #include "bpf.h"
+#include "libbpf.h"
+#include "libbpf_util.h"
 
-#define elog(fmt, ...) { if (err_log) err_log(fmt, ##__VA_ARGS__); }
 #define max(a, b) ((a) > (b) ? (a) : (b))
 #define min(a, b) ((a) < (b) ? (a) : (b))
 
@@ -107,54 +108,54 @@ static int btf_add_type(struct btf *btf, struct btf_type *t)
 	return 0;
 }
 
-static int btf_parse_hdr(struct btf *btf, btf_print_fn_t err_log)
+static int btf_parse_hdr(struct btf *btf)
 {
 	const struct btf_header *hdr = btf->hdr;
 	__u32 meta_left;
 
 	if (btf->data_size < sizeof(struct btf_header)) {
-		elog("BTF header not found\n");
+		pr_debug("BTF header not found\n");
 		return -EINVAL;
 	}
 
 	if (hdr->magic != BTF_MAGIC) {
-		elog("Invalid BTF magic:%x\n", hdr->magic);
+		pr_debug("Invalid BTF magic:%x\n", hdr->magic);
 		return -EINVAL;
 	}
 
 	if (hdr->version != BTF_VERSION) {
-		elog("Unsupported BTF version:%u\n", hdr->version);
+		pr_debug("Unsupported BTF version:%u\n", hdr->version);
 		return -ENOTSUP;
 	}
 
 	if (hdr->flags) {
-		elog("Unsupported BTF flags:%x\n", hdr->flags);
+		pr_debug("Unsupported BTF flags:%x\n", hdr->flags);
 		return -ENOTSUP;
 	}
 
 	meta_left = btf->data_size - sizeof(*hdr);
 	if (!meta_left) {
-		elog("BTF has no data\n");
+		pr_debug("BTF has no data\n");
 		return -EINVAL;
 	}
 
 	if (meta_left < hdr->type_off) {
-		elog("Invalid BTF type section offset:%u\n", hdr->type_off);
+		pr_debug("Invalid BTF type section offset:%u\n", hdr->type_off);
 		return -EINVAL;
 	}
 
 	if (meta_left < hdr->str_off) {
-		elog("Invalid BTF string section offset:%u\n", hdr->str_off);
+		pr_debug("Invalid BTF string section offset:%u\n", hdr->str_off);
 		return -EINVAL;
 	}
 
 	if (hdr->type_off >= hdr->str_off) {
-		elog("BTF type section offset >= string section offset. No type?\n");
+		pr_debug("BTF type section offset >= string section offset. No type?\n");
 		return -EINVAL;
 	}
 
 	if (hdr->type_off & 0x02) {
-		elog("BTF type section is not aligned to 4 bytes\n");
+		pr_debug("BTF type section is not aligned to 4 bytes\n");
 		return -EINVAL;
 	}
 
@@ -163,7 +164,7 @@ static int btf_parse_hdr(struct btf *btf, btf_print_fn_t err_log)
 	return 0;
 }
 
-static int btf_parse_str_sec(struct btf *btf, btf_print_fn_t err_log)
+static int btf_parse_str_sec(struct btf *btf)
 {
 	const struct btf_header *hdr = btf->hdr;
 	const char *start = btf->nohdr_data + hdr->str_off;
@@ -171,7 +172,7 @@ static int btf_parse_str_sec(struct btf *btf, btf_print_fn_t err_log)
 
 	if (!hdr->str_len || hdr->str_len - 1 > BTF_MAX_NAME_OFFSET ||
 	    start[0] || end[-1]) {
-		elog("Invalid BTF string section\n");
+		pr_debug("Invalid BTF string section\n");
 		return -EINVAL;
 	}
 
@@ -180,7 +181,7 @@ static int btf_parse_str_sec(struct btf *btf, btf_print_fn_t err_log)
 	return 0;
 }
 
-static int btf_parse_type_sec(struct btf *btf, btf_print_fn_t err_log)
+static int btf_parse_type_sec(struct btf *btf)
 {
 	struct btf_header *hdr = btf->hdr;
 	void *nohdr_data = btf->nohdr_data;
@@ -219,7 +220,7 @@ static int btf_parse_type_sec(struct btf *btf, btf_print_fn_t err_log)
 		case BTF_KIND_RESTRICT:
 			break;
 		default:
-			elog("Unsupported BTF_KIND:%u\n",
+			pr_debug("Unsupported BTF_KIND:%u\n",
 			     BTF_INFO_KIND(t->info));
 			return -EINVAL;
 		}
@@ -363,7 +364,7 @@ void btf__free(struct btf *btf)
 	free(btf);
 }
 
-struct btf *btf__new(__u8 *data, __u32 size, btf_print_fn_t err_log)
+struct btf *btf__new(__u8 *data, __u32 size)
 {
 	__u32 log_buf_size = 0;
 	char *log_buf = NULL;
@@ -376,7 +377,7 @@ struct btf *btf__new(__u8 *data, __u32 size, btf_print_fn_t err_log)
 
 	btf->fd = -1;
 
-	if (err_log) {
+	if (libbpf_print_level_available(LIBBPF_DEBUG)) {
 		log_buf = malloc(BPF_LOG_BUF_SIZE);
 		if (!log_buf) {
 			err = -ENOMEM;
@@ -400,21 +401,21 @@ struct btf *btf__new(__u8 *data, __u32 size, btf_print_fn_t err_log)
 
 	if (btf->fd == -1) {
 		err = -errno;
-		elog("Error loading BTF: %s(%d)\n", strerror(errno), errno);
+		pr_debug("Error loading BTF: %s(%d)\n", strerror(errno), errno);
 		if (log_buf && *log_buf)
-			elog("%s\n", log_buf);
+			pr_debug("%s\n", log_buf);
 		goto done;
 	}
 
-	err = btf_parse_hdr(btf, err_log);
+	err = btf_parse_hdr(btf);
 	if (err)
 		goto done;
 
-	err = btf_parse_str_sec(btf, err_log);
+	err = btf_parse_str_sec(btf);
 	if (err)
 		goto done;
 
-	err = btf_parse_type_sec(btf, err_log);
+	err = btf_parse_type_sec(btf);
 
 done:
 	free(log_buf);
@@ -491,7 +492,7 @@ int btf__get_from_id(__u32 id, struct btf **btf)
 		goto exit_free;
 	}
 
-	*btf = btf__new((__u8 *)(long)btf_info.btf, btf_info.btf_size, NULL);
+	*btf = btf__new((__u8 *)(long)btf_info.btf, btf_info.btf_size);
 	if (IS_ERR(*btf)) {
 		err = PTR_ERR(*btf);
 		*btf = NULL;
@@ -514,8 +515,7 @@ struct btf_ext_sec_copy_param {
 
 static int btf_ext_copy_info(struct btf_ext *btf_ext,
 			     __u8 *data, __u32 data_size,
-			     struct btf_ext_sec_copy_param *ext_sec,
-			     btf_print_fn_t err_log)
+			     struct btf_ext_sec_copy_param *ext_sec)
 {
 	const struct btf_ext_header *hdr = (struct btf_ext_header *)data;
 	const struct btf_ext_info_sec *sinfo;
@@ -529,14 +529,14 @@ static int btf_ext_copy_info(struct btf_ext *btf_ext,
 	data_size -= hdr->hdr_len;
 
 	if (ext_sec->off & 0x03) {
-		elog(".BTF.ext %s section is not aligned to 4 bytes\n",
+		pr_debug(".BTF.ext %s section is not aligned to 4 bytes\n",
 		     ext_sec->desc);
 		return -EINVAL;
 	}
 
 	if (data_size < ext_sec->off ||
 	    ext_sec->len > data_size - ext_sec->off) {
-		elog("%s section (off:%u len:%u) is beyond the end of the ELF section .BTF.ext\n",
+		pr_debug("%s section (off:%u len:%u) is beyond the end of the ELF section .BTF.ext\n",
 		     ext_sec->desc, ext_sec->off, ext_sec->len);
 		return -EINVAL;
 	}
@@ -546,7 +546,7 @@ static int btf_ext_copy_info(struct btf_ext *btf_ext,
 
 	/* At least a record size */
 	if (info_left < sizeof(__u32)) {
-		elog(".BTF.ext %s record size not found\n", ext_sec->desc);
+		pr_debug(".BTF.ext %s record size not found\n", ext_sec->desc);
 		return -EINVAL;
 	}
 
@@ -554,7 +554,7 @@ static int btf_ext_copy_info(struct btf_ext *btf_ext,
 	record_size = *(__u32 *)info;
 	if (record_size < ext_sec->min_rec_size ||
 	    record_size & 0x03) {
-		elog("%s section in .BTF.ext has invalid record size %u\n",
+		pr_debug("%s section in .BTF.ext has invalid record size %u\n",
 		     ext_sec->desc, record_size);
 		return -EINVAL;
 	}
@@ -564,7 +564,7 @@ static int btf_ext_copy_info(struct btf_ext *btf_ext,
 
 	/* If no records, return failure now so .BTF.ext won't be used. */
 	if (!info_left) {
-		elog("%s section in .BTF.ext has no records", ext_sec->desc);
+		pr_debug("%s section in .BTF.ext has no records", ext_sec->desc);
 		return -EINVAL;
 	}
 
@@ -574,14 +574,14 @@ static int btf_ext_copy_info(struct btf_ext *btf_ext,
 		__u32 num_records;
 
 		if (info_left < sec_hdrlen) {
-			elog("%s section header is not found in .BTF.ext\n",
+			pr_debug("%s section header is not found in .BTF.ext\n",
 			     ext_sec->desc);
 			return -EINVAL;
 		}
 
 		num_records = sinfo->num_info;
 		if (num_records == 0) {
-			elog("%s section has incorrect num_records in .BTF.ext\n",
+			pr_debug("%s section has incorrect num_records in .BTF.ext\n",
 			     ext_sec->desc);
 			return -EINVAL;
 		}
@@ -589,7 +589,7 @@ static int btf_ext_copy_info(struct btf_ext *btf_ext,
 		total_record_size = sec_hdrlen +
 				    (__u64)num_records * record_size;
 		if (info_left < total_record_size) {
-			elog("%s section has incorrect num_records in .BTF.ext\n",
+			pr_debug("%s section has incorrect num_records in .BTF.ext\n",
 			     ext_sec->desc);
 			return -EINVAL;
 		}
@@ -610,8 +610,7 @@ static int btf_ext_copy_info(struct btf_ext *btf_ext,
 }
 
 static int btf_ext_copy_func_info(struct btf_ext *btf_ext,
-				  __u8 *data, __u32 data_size,
-				  btf_print_fn_t err_log)
+				  __u8 *data, __u32 data_size)
 {
 	const struct btf_ext_header *hdr = (struct btf_ext_header *)data;
 	struct btf_ext_sec_copy_param param = {
@@ -622,12 +621,11 @@ static int btf_ext_copy_func_info(struct btf_ext *btf_ext,
 		.desc = "func_info"
 	};
 
-	return btf_ext_copy_info(btf_ext, data, data_size, &param, err_log);
+	return btf_ext_copy_info(btf_ext, data, data_size, &param);
 }
 
 static int btf_ext_copy_line_info(struct btf_ext *btf_ext,
-				  __u8 *data, __u32 data_size,
-				  btf_print_fn_t err_log)
+				  __u8 *data, __u32 data_size)
 {
 	const struct btf_ext_header *hdr = (struct btf_ext_header *)data;
 	struct btf_ext_sec_copy_param param = {
@@ -638,37 +636,36 @@ static int btf_ext_copy_line_info(struct btf_ext *btf_ext,
 		.desc = "line_info",
 	};
 
-	return btf_ext_copy_info(btf_ext, data, data_size, &param, err_log);
+	return btf_ext_copy_info(btf_ext, data, data_size, &param);
 }
 
-static int btf_ext_parse_hdr(__u8 *data, __u32 data_size,
-			     btf_print_fn_t err_log)
+static int btf_ext_parse_hdr(__u8 *data, __u32 data_size)
 {
 	const struct btf_ext_header *hdr = (struct btf_ext_header *)data;
 
 	if (data_size < offsetof(struct btf_ext_header, func_info_off) ||
 	    data_size < hdr->hdr_len) {
-		elog("BTF.ext header not found");
+		pr_debug("BTF.ext header not found");
 		return -EINVAL;
 	}
 
 	if (hdr->magic != BTF_MAGIC) {
-		elog("Invalid BTF.ext magic:%x\n", hdr->magic);
+		pr_debug("Invalid BTF.ext magic:%x\n", hdr->magic);
 		return -EINVAL;
 	}
 
 	if (hdr->version != BTF_VERSION) {
-		elog("Unsupported BTF.ext version:%u\n", hdr->version);
+		pr_debug("Unsupported BTF.ext version:%u\n", hdr->version);
 		return -ENOTSUP;
 	}
 
 	if (hdr->flags) {
-		elog("Unsupported BTF.ext flags:%x\n", hdr->flags);
+		pr_debug("Unsupported BTF.ext flags:%x\n", hdr->flags);
 		return -ENOTSUP;
 	}
 
 	if (data_size == hdr->hdr_len) {
-		elog("BTF.ext has no data\n");
+		pr_debug("BTF.ext has no data\n");
 		return -EINVAL;
 	}
 
@@ -685,12 +682,12 @@ void btf_ext__free(struct btf_ext *btf_ext)
 	free(btf_ext);
 }
 
-struct btf_ext *btf_ext__new(__u8 *data, __u32 size, btf_print_fn_t err_log)
+struct btf_ext *btf_ext__new(__u8 *data, __u32 size)
 {
 	struct btf_ext *btf_ext;
 	int err;
 
-	err = btf_ext_parse_hdr(data, size, err_log);
+	err = btf_ext_parse_hdr(data, size);
 	if (err)
 		return ERR_PTR(err);
 
@@ -698,13 +695,13 @@ struct btf_ext *btf_ext__new(__u8 *data, __u32 size, btf_print_fn_t err_log)
 	if (!btf_ext)
 		return ERR_PTR(-ENOMEM);
 
-	err = btf_ext_copy_func_info(btf_ext, data, size, err_log);
+	err = btf_ext_copy_func_info(btf_ext, data, size);
 	if (err) {
 		btf_ext__free(btf_ext);
 		return ERR_PTR(err);
 	}
 
-	err = btf_ext_copy_line_info(btf_ext, data, size, err_log);
+	err = btf_ext_copy_line_info(btf_ext, data, size);
 	if (err) {
 		btf_ext__free(btf_ext);
 		return ERR_PTR(err);
diff --git a/tools/lib/bpf/btf.h b/tools/lib/bpf/btf.h
index b0610dcdae6b..b1e8e54cc21d 100644
--- a/tools/lib/bpf/btf.h
+++ b/tools/lib/bpf/btf.h
@@ -55,11 +55,8 @@ struct btf_ext_header {
 	__u32	line_info_len;
 };
 
-typedef int (*btf_print_fn_t)(const char *, ...)
-	__attribute__((format(printf, 1, 2)));
-
 LIBBPF_API void btf__free(struct btf *btf);
-LIBBPF_API struct btf *btf__new(__u8 *data, __u32 size, btf_print_fn_t err_log);
+LIBBPF_API struct btf *btf__new(__u8 *data, __u32 size);
 LIBBPF_API __s32 btf__find_by_name(const struct btf *btf,
 				   const char *type_name);
 LIBBPF_API const struct btf_type *btf__type_by_id(const struct btf *btf,
@@ -70,7 +67,7 @@ LIBBPF_API int btf__fd(const struct btf *btf);
 LIBBPF_API const char *btf__name_by_offset(const struct btf *btf, __u32 offset);
 LIBBPF_API int btf__get_from_id(__u32 id, struct btf **btf);
 
-struct btf_ext *btf_ext__new(__u8 *data, __u32 size, btf_print_fn_t err_log);
+struct btf_ext *btf_ext__new(__u8 *data, __u32 size);
 void btf_ext__free(struct btf_ext *btf_ext);
 int btf_ext__reloc_func_info(const struct btf *btf,
 			     const struct btf_ext *btf_ext,
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 03bc01ca2577..eeba77b695ad 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -42,6 +42,7 @@
 #include "bpf.h"
 #include "btf.h"
 #include "str_error.h"
+#include "libbpf_util.h"
 
 #ifndef EM_BPF
 #define EM_BPF 247
@@ -69,16 +70,6 @@ static __printf(1, 2) libbpf_print_fn_t __pr_warning = __base_pr;
 static __printf(1, 2) libbpf_print_fn_t __pr_info = __base_pr;
 static __printf(1, 2) libbpf_print_fn_t __pr_debug;
 
-#define __pr(func, fmt, ...)	\
-do {				\
-	if ((func))		\
-		(func)("libbpf: " fmt, ##__VA_ARGS__); \
-} while (0)
-
-#define pr_warning(fmt, ...)	__pr(__pr_warning, fmt, ##__VA_ARGS__)
-#define pr_info(fmt, ...)	__pr(__pr_info, fmt, ##__VA_ARGS__)
-#define pr_debug(fmt, ...)	__pr(__pr_debug, fmt, ##__VA_ARGS__)
-
 void libbpf_set_print(libbpf_print_fn_t warn,
 		      libbpf_print_fn_t info,
 		      libbpf_print_fn_t debug)
@@ -88,6 +79,35 @@ void libbpf_set_print(libbpf_print_fn_t warn,
 	__pr_debug = debug;
 }
 
+__printf(2, 3)
+void libbpf_print(enum libbpf_print_level level, const char *format, ...)
+{
+	va_list args;
+
+	va_start(args, format);
+	if (level == LIBBPF_WARN) {
+		if (__pr_warning)
+			__pr_warning(format, args);
+	} else if (level == LIBBPF_INFO) {
+		if (__pr_info)
+			__pr_info(format, args);
+	} else {
+		if (__pr_debug)
+			__pr_debug(format, args);
+	}
+	va_end(args);
+}
+
+bool libbpf_print_level_available(enum libbpf_print_level level)
+{
+	if (level == LIBBPF_WARN)
+		return !!__pr_warning;
+	else if (level == LIBBPF_INFO)
+		return !!__pr_info;
+	else
+		return !!__pr_debug;
+}
+
 #define STRERR_BUFSIZE  128
 
 #define CHECK_ERR(action, err, out) do {	\
@@ -839,8 +859,7 @@ static int bpf_object__elf_collect(struct bpf_object *obj, int flags)
 		else if (strcmp(name, "maps") == 0)
 			obj->efile.maps_shndx = idx;
 		else if (strcmp(name, BTF_ELF_SEC) == 0) {
-			obj->btf = btf__new(data->d_buf, data->d_size,
-					    __pr_debug);
+			obj->btf = btf__new(data->d_buf, data->d_size);
 			if (IS_ERR(obj->btf)) {
 				pr_warning("Error loading ELF section %s: %ld. Ignored and continue.\n",
 					   BTF_ELF_SEC, PTR_ERR(obj->btf));
@@ -915,8 +934,7 @@ static int bpf_object__elf_collect(struct bpf_object *obj, int flags)
 				 BTF_EXT_ELF_SEC, BTF_ELF_SEC);
 		} else {
 			obj->btf_ext = btf_ext__new(btf_ext_data->d_buf,
-						    btf_ext_data->d_size,
-						    __pr_debug);
+						    btf_ext_data->d_size);
 			if (IS_ERR(obj->btf_ext)) {
 				pr_warning("Error loading ELF section %s: %ld. Ignored and continue.\n",
 					   BTF_EXT_ELF_SEC,
diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h
index 43c77e98df6f..0fb32cc04633 100644
--- a/tools/lib/bpf/libbpf.h
+++ b/tools/lib/bpf/libbpf.h
@@ -47,6 +47,12 @@ enum libbpf_errno {
 
 LIBBPF_API int libbpf_strerror(int err, char *buf, size_t size);
 
+enum libbpf_print_level {
+        LIBBPF_WARN,
+        LIBBPF_INFO,
+        LIBBPF_DEBUG,
+};
+
 /*
  * __printf is defined in include/linux/compiler-gcc.h. However,
  * it would be better if libbpf.h didn't depend on Linux header files.
diff --git a/tools/lib/bpf/libbpf_util.h b/tools/lib/bpf/libbpf_util.h
new file mode 100644
index 000000000000..0fdc3b1d0e33
--- /dev/null
+++ b/tools/lib/bpf/libbpf_util.h
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */
+/* Copyright (c) 2019 Facebook */
+
+#ifndef __LIBBPF_LIBBPF_UTIL_H
+#define __LIBBPF_LIBBPF_UTIL_H
+
+#include <stdbool.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern void libbpf_print(enum libbpf_print_level level,
+			 const char *format, ...)
+	__attribute__((format(printf, 2, 3)));
+
+extern bool libbpf_print_level_available(enum libbpf_print_level level);
+
+#define __pr(level, fmt, ...)	\
+do {				\
+	libbpf_print(level, "libbpf: " fmt, ##__VA_ARGS__);	\
+} while (0)
+
+#define pr_warning(fmt, ...)	__pr(LIBBPF_WARN, fmt, ##__VA_ARGS__)
+#define pr_info(fmt, ...)	__pr(LIBBPF_INFO, fmt, ##__VA_ARGS__)
+#define pr_debug(fmt, ...)	__pr(LIBBPF_DEBUG, fmt, ##__VA_ARGS__)
+
+#ifdef __cplusplus
+} /* extern "C" */
+#endif
+
+#endif
diff --git a/tools/lib/bpf/test_libbpf.cpp b/tools/lib/bpf/test_libbpf.cpp
index abf3fc25c9fa..be67f5ea2c19 100644
--- a/tools/lib/bpf/test_libbpf.cpp
+++ b/tools/lib/bpf/test_libbpf.cpp
@@ -14,5 +14,5 @@ int main(int argc, char *argv[])
     bpf_prog_get_fd_by_id(0);
 
     /* btf.h */
-    btf__new(NULL, 0, NULL);
+    btf__new(NULL, 0);
 }
-- 
2.17.1


^ permalink raw reply related

* [PATCH bpf-next v4 3/3] tools/bpf: simplify libbpf API function libbpf_set_print()
From: Yonghong Song @ 2019-02-02  0:14 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Magnus Karlsson, netdev
  Cc: Alexei Starovoitov, Daniel Borkmann, kernel-team, Yonghong Song
In-Reply-To: <20190202001413.3178000-1-yhs@fb.com>

Currently, the libbpf API function libbpf_set_print()
takes three function pointer parameters for warning, info
and debug printout respectively.

This patch changes the API to have just one function pointer
parameter and the function pointer has one additional
parameter "debugging level". So if in the future, if
the debug level is increased, the function signature
won't change.

Signed-off-by: Yonghong Song <yhs@fb.com>
---
 tools/lib/bpf/libbpf.c                        | 33 +++++++----------
 tools/lib/bpf/libbpf.h                        | 14 +++-----
 tools/lib/bpf/test_libbpf.cpp                 |  2 +-
 tools/perf/util/bpf-loader.c                  | 32 +++++++----------
 tools/testing/selftests/bpf/test_btf.c        |  7 ++--
 .../testing/selftests/bpf/test_libbpf_open.c  | 36 +++++++++----------
 tools/testing/selftests/bpf/test_progs.c      | 20 +++++++++--
 7 files changed, 68 insertions(+), 76 deletions(-)

diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index 0354af03b038..ce209ab9a1a2 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -54,29 +54,26 @@
 
 #define __printf(a, b)	__attribute__((format(printf, a, b)))
 
-__printf(1, 2)
-static int __base_pr(const char *format, ...)
+__printf(2, 3)
+static int __base_pr(enum libbpf_print_level level, const char *format, ...)
 {
 	va_list args;
 	int err;
 
+	if (level == LIBBPF_DEBUG)
+		return 0;
+
 	va_start(args, format);
 	err = vfprintf(stderr, format, args);
 	va_end(args);
 	return err;
 }
 
-static __printf(1, 2) libbpf_print_fn_t __pr_warning = __base_pr;
-static __printf(1, 2) libbpf_print_fn_t __pr_info = __base_pr;
-static __printf(1, 2) libbpf_print_fn_t __pr_debug;
+static __printf(2, 3) libbpf_print_fn_t __libbpf_pr = __base_pr;
 
-void libbpf_set_print(libbpf_print_fn_t warn,
-		      libbpf_print_fn_t info,
-		      libbpf_print_fn_t debug)
+void libbpf_set_print(libbpf_print_fn_t fn)
 {
-	__pr_warning = warn;
-	__pr_info = info;
-	__pr_debug = debug;
+	__libbpf_pr = fn;
 }
 
 __printf(2, 3)
@@ -84,17 +81,11 @@ void libbpf_print(enum libbpf_print_level level, const char *format, ...)
 {
 	va_list args;
 
+	if (!__libbpf_pr)
+		return;
+
 	va_start(args, format);
-	if (level == LIBBPF_WARN) {
-		if (__pr_warning)
-			__pr_warning(format, args);
-	} else if (level == LIBBPF_INFO) {
-		if (__pr_info)
-			__pr_info(format, args);
-	} else {
-		if (__pr_debug)
-			__pr_debug(format, args);
-	}
+	__libbpf_pr(level, format, args);
 	va_end(args);
 }
 
diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h
index 0fb32cc04633..19dbc1bed960 100644
--- a/tools/lib/bpf/libbpf.h
+++ b/tools/lib/bpf/libbpf.h
@@ -53,17 +53,11 @@ enum libbpf_print_level {
         LIBBPF_DEBUG,
 };
 
-/*
- * __printf is defined in include/linux/compiler-gcc.h. However,
- * it would be better if libbpf.h didn't depend on Linux header files.
- * So instead of __printf, here we use gcc attribute directly.
- */
-typedef int (*libbpf_print_fn_t)(const char *, ...)
-	__attribute__((format(printf, 1, 2)));
+typedef int (*libbpf_print_fn_t)(enum libbpf_print_level level,
+				 const char *, ...)
+	__attribute__((format(printf, 2, 3)));
 
-LIBBPF_API void libbpf_set_print(libbpf_print_fn_t warn,
-				 libbpf_print_fn_t info,
-				 libbpf_print_fn_t debug);
+LIBBPF_API void libbpf_set_print(libbpf_print_fn_t fn);
 
 /* Hide internal to user */
 struct bpf_object;
diff --git a/tools/lib/bpf/test_libbpf.cpp b/tools/lib/bpf/test_libbpf.cpp
index be67f5ea2c19..fc134873bb6d 100644
--- a/tools/lib/bpf/test_libbpf.cpp
+++ b/tools/lib/bpf/test_libbpf.cpp
@@ -8,7 +8,7 @@
 int main(int argc, char *argv[])
 {
     /* libbpf.h */
-    libbpf_set_print(NULL, NULL, NULL);
+    libbpf_set_print(NULL);
 
     /* bpf.h */
     bpf_prog_get_fd_by_id(0);
diff --git a/tools/perf/util/bpf-loader.c b/tools/perf/util/bpf-loader.c
index 2f3eb6d293ee..38afdbe6a9e0 100644
--- a/tools/perf/util/bpf-loader.c
+++ b/tools/perf/util/bpf-loader.c
@@ -24,21 +24,17 @@
 #include "llvm-utils.h"
 #include "c++/clang-c.h"
 
-#define DEFINE_PRINT_FN(name, level) \
-static int libbpf_##name(const char *fmt, ...)	\
-{						\
-	va_list args;				\
-	int ret;				\
-						\
-	va_start(args, fmt);			\
-	ret = veprintf(level, verbose, pr_fmt(fmt), args);\
-	va_end(args);				\
-	return ret;				\
-}
+static int libbpf_perf_print(enum libbpf_print_level level __attribute__((unused)),
+			      const char *fmt, ...)
+{
+	va_list args;
+	int ret;
 
-DEFINE_PRINT_FN(warning, 1)
-DEFINE_PRINT_FN(info, 1)
-DEFINE_PRINT_FN(debug, 1)
+	va_start(args, fmt);
+	ret = veprintf(1, verbose, pr_fmt(fmt), args);
+	va_end(args);
+	return ret;
+}
 
 struct bpf_prog_priv {
 	bool is_tp;
@@ -59,9 +55,7 @@ bpf__prepare_load_buffer(void *obj_buf, size_t obj_buf_sz, const char *name)
 	struct bpf_object *obj;
 
 	if (!libbpf_initialized) {
-		libbpf_set_print(libbpf_warning,
-				 libbpf_info,
-				 libbpf_debug);
+		libbpf_set_print(libbpf_perf_print);
 		libbpf_initialized = true;
 	}
 
@@ -79,9 +73,7 @@ struct bpf_object *bpf__prepare_load(const char *filename, bool source)
 	struct bpf_object *obj;
 
 	if (!libbpf_initialized) {
-		libbpf_set_print(libbpf_warning,
-				 libbpf_info,
-				 libbpf_debug);
+		libbpf_set_print(libbpf_perf_print);
 		libbpf_initialized = true;
 	}
 
diff --git a/tools/testing/selftests/bpf/test_btf.c b/tools/testing/selftests/bpf/test_btf.c
index 179f1d8ec5bf..aebaeff5a5a0 100644
--- a/tools/testing/selftests/bpf/test_btf.c
+++ b/tools/testing/selftests/bpf/test_btf.c
@@ -54,8 +54,9 @@ static int count_result(int err)
 
 #define __printf(a, b)	__attribute__((format(printf, a, b)))
 
-__printf(1, 2)
-static int __base_pr(const char *format, ...)
+__printf(2, 3)
+static int __base_pr(enum libbpf_print_level level __attribute__((unused)),
+		     const char *format, ...)
 {
 	va_list args;
 	int err;
@@ -5650,7 +5651,7 @@ int main(int argc, char **argv)
 		return err;
 
 	if (args.always_log)
-		libbpf_set_print(__base_pr, __base_pr, __base_pr);
+		libbpf_set_print(__base_pr);
 
 	if (args.raw_test)
 		err |= test_raw();
diff --git a/tools/testing/selftests/bpf/test_libbpf_open.c b/tools/testing/selftests/bpf/test_libbpf_open.c
index 8fcd1c076add..b9ff3bf76544 100644
--- a/tools/testing/selftests/bpf/test_libbpf_open.c
+++ b/tools/testing/selftests/bpf/test_libbpf_open.c
@@ -34,23 +34,22 @@ static void usage(char *argv[])
 	printf("\n");
 }
 
-#define DEFINE_PRINT_FN(name, enabled) \
-static int libbpf_##name(const char *fmt, ...)  	\
-{							\
-        va_list args;					\
-        int ret;					\
-							\
-        va_start(args, fmt);				\
-	if (enabled) {					\
-		fprintf(stderr, "[" #name "] ");	\
-		ret = vfprintf(stderr, fmt, args);	\
-	}						\
-        va_end(args);					\
-        return ret;					\
+static bool debug = 0;
+static int libbpf_debug_print(enum libbpf_print_level level,
+			      const char *fmt, ...)
+{
+	va_list args;
+	int ret;
+
+	if (level == LIBBPF_DEBUG && !debug)
+		return 0;
+
+	va_start(args, fmt);
+	fprintf(stderr, "[%d] ", level);
+	ret = vfprintf(stderr, fmt, args);
+	va_end(args);
+	return ret;
 }
-DEFINE_PRINT_FN(warning, 1)
-DEFINE_PRINT_FN(info, 1)
-DEFINE_PRINT_FN(debug, 1)
 
 #define EXIT_FAIL_LIBBPF EXIT_FAILURE
 #define EXIT_FAIL_OPTION 2
@@ -120,15 +119,14 @@ int main(int argc, char **argv)
 	int longindex = 0;
 	int opt;
 
-	libbpf_set_print(libbpf_warning, libbpf_info, NULL);
+	libbpf_set_print(libbpf_debug_print);
 
 	/* Parse commands line args */
 	while ((opt = getopt_long(argc, argv, "hDq",
 				  long_options, &longindex)) != -1) {
 		switch (opt) {
 		case 'D':
-			libbpf_set_print(libbpf_warning, libbpf_info,
-					 libbpf_debug);
+			debug = 1;
 			break;
 		case 'q': /* Use in scripting mode */
 			verbose = 0;
diff --git a/tools/testing/selftests/bpf/test_progs.c b/tools/testing/selftests/bpf/test_progs.c
index a08d026ac396..55d05102e7bf 100644
--- a/tools/testing/selftests/bpf/test_progs.c
+++ b/tools/testing/selftests/bpf/test_progs.c
@@ -10,6 +10,7 @@
 #include <string.h>
 #include <assert.h>
 #include <stdlib.h>
+#include <stdarg.h>
 #include <time.h>
 
 #include <linux/types.h>
@@ -1783,6 +1784,21 @@ static void test_task_fd_query_tp(void)
 				   "sys_enter_read");
 }
 
+static int libbpf_debug_print(enum libbpf_print_level level,
+			      const char *format, ...)
+{
+	va_list args;
+	int ret;
+
+	if (level == LIBBPF_DEBUG)
+		return 0;
+
+	va_start(args, format);
+	ret = vfprintf(stderr, format, args);
+	va_end(args);
+	return ret;
+}
+
 static void test_reference_tracking()
 {
 	const char *file = "./test_sk_lookup_kern.o";
@@ -1809,9 +1825,9 @@ static void test_reference_tracking()
 
 		/* Expect verifier failure if test name has 'fail' */
 		if (strstr(title, "fail") != NULL) {
-			libbpf_set_print(NULL, NULL, NULL);
+			libbpf_set_print(NULL);
 			err = !bpf_program__load(prog, "GPL", 0);
-			libbpf_set_print(printf, printf, NULL);
+			libbpf_set_print(libbpf_debug_print);
 		} else {
 			err = bpf_program__load(prog, "GPL", 0);
 		}
-- 
2.17.1


^ permalink raw reply related

* [PATCH bpf-next v4 2/3] tools/bpf: print out btf log at LIBBPF_WARN level
From: Yonghong Song @ 2019-02-02  0:14 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Magnus Karlsson, netdev
  Cc: Alexei Starovoitov, Daniel Borkmann, kernel-team, Yonghong Song
In-Reply-To: <20190202001413.3178000-1-yhs@fb.com>

Currently, the btf log is allocated and printed out in case
of error at LIBBPF_DEBUG level.
Such logs from kernel are very important for debugging.
For example, bpf syscall BPF_PROG_LOAD command can get
verifier logs back to user space. In function load_program()
of libbpf.c, the log buffer is allocated unconditionally
and printed out at pr_warning() level.

Let us do the similar thing here for btf. Allocate buffer
unconditionally and print out error logs at pr_warning() level.
This can reduce one global function and
optimize for common situations where pr_warning()
is activated either by default or by user supplied
debug output function.

Signed-off-by: Yonghong Song <yhs@fb.com>
---
 tools/lib/bpf/btf.c         | 19 +++++++++----------
 tools/lib/bpf/libbpf.c      | 10 ----------
 tools/lib/bpf/libbpf_util.h |  2 --
 3 files changed, 9 insertions(+), 22 deletions(-)

diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c
index 93e792b82242..51a0db05bf80 100644
--- a/tools/lib/bpf/btf.c
+++ b/tools/lib/bpf/btf.c
@@ -377,16 +377,15 @@ struct btf *btf__new(__u8 *data, __u32 size)
 
 	btf->fd = -1;
 
-	if (libbpf_print_level_available(LIBBPF_DEBUG)) {
-		log_buf = malloc(BPF_LOG_BUF_SIZE);
-		if (!log_buf) {
-			err = -ENOMEM;
-			goto done;
-		}
-		*log_buf = 0;
-		log_buf_size = BPF_LOG_BUF_SIZE;
+	log_buf = malloc(BPF_LOG_BUF_SIZE);
+	if (!log_buf) {
+		err = -ENOMEM;
+		goto done;
 	}
 
+	*log_buf = 0;
+	log_buf_size = BPF_LOG_BUF_SIZE;
+
 	btf->data = malloc(size);
 	if (!btf->data) {
 		err = -ENOMEM;
@@ -401,9 +400,9 @@ struct btf *btf__new(__u8 *data, __u32 size)
 
 	if (btf->fd == -1) {
 		err = -errno;
-		pr_debug("Error loading BTF: %s(%d)\n", strerror(errno), errno);
+		pr_warning("Error loading BTF: %s(%d)\n", strerror(errno), errno);
 		if (log_buf && *log_buf)
-			pr_debug("%s\n", log_buf);
+			pr_warning("%s\n", log_buf);
 		goto done;
 	}
 
diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
index eeba77b695ad..0354af03b038 100644
--- a/tools/lib/bpf/libbpf.c
+++ b/tools/lib/bpf/libbpf.c
@@ -98,16 +98,6 @@ void libbpf_print(enum libbpf_print_level level, const char *format, ...)
 	va_end(args);
 }
 
-bool libbpf_print_level_available(enum libbpf_print_level level)
-{
-	if (level == LIBBPF_WARN)
-		return !!__pr_warning;
-	else if (level == LIBBPF_INFO)
-		return !!__pr_info;
-	else
-		return !!__pr_debug;
-}
-
 #define STRERR_BUFSIZE  128
 
 #define CHECK_ERR(action, err, out) do {	\
diff --git a/tools/lib/bpf/libbpf_util.h b/tools/lib/bpf/libbpf_util.h
index 0fdc3b1d0e33..81ecda0cb9c9 100644
--- a/tools/lib/bpf/libbpf_util.h
+++ b/tools/lib/bpf/libbpf_util.h
@@ -14,8 +14,6 @@ extern void libbpf_print(enum libbpf_print_level level,
 			 const char *format, ...)
 	__attribute__((format(printf, 2, 3)));
 
-extern bool libbpf_print_level_available(enum libbpf_print_level level);
-
 #define __pr(level, fmt, ...)	\
 do {				\
 	libbpf_print(level, "libbpf: " fmt, ##__VA_ARGS__);	\
-- 
2.17.1


^ permalink raw reply related

* [PATCH iproute2-next] devlink: add info subcommand
From: Jakub Kicinski @ 2019-02-02  0:03 UTC (permalink / raw)
  To: jiri, dsahern; +Cc: stephen, netdev, oss-drivers, Jakub Kicinski

Add support for reading the device serial number and versions
from the kernel.

RFCv2:
 - make info subcommand of dev.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
---
 devlink/devlink.c      | 207 +++++++++++++++++++++++++++++++++++++++++
 man/man8/devlink-dev.8 |  36 +++++++
 2 files changed, 243 insertions(+)

diff --git a/devlink/devlink.c b/devlink/devlink.c
index 3651e90c1159..3ab046ace8f8 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -199,6 +199,7 @@ static void ifname_map_free(struct ifname_map *ifname_map)
 #define DL_OPT_REGION_SNAPSHOT_ID	BIT(22)
 #define DL_OPT_REGION_ADDRESS		BIT(23)
 #define DL_OPT_REGION_LENGTH		BIT(24)
+#define DL_OPT_VERSIONS_TYPE		BIT(25)
 
 struct dl_opts {
 	uint32_t present; /* flags of present items */
@@ -230,6 +231,7 @@ struct dl_opts {
 	uint32_t region_snapshot_id;
 	uint64_t region_address;
 	uint64_t region_length;
+	int versions_attr;
 };
 
 struct dl {
@@ -383,6 +385,13 @@ static const enum mnl_attr_data_type devlink_policy[DEVLINK_ATTR_MAX + 1] = {
 	[DEVLINK_ATTR_REGION_CHUNK_DATA] = MNL_TYPE_BINARY,
 	[DEVLINK_ATTR_REGION_CHUNK_ADDR] = MNL_TYPE_U64,
 	[DEVLINK_ATTR_REGION_CHUNK_LEN] = MNL_TYPE_U64,
+	[DEVLINK_ATTR_INFO_DRIVER_NAME] = MNL_TYPE_STRING,
+	[DEVLINK_ATTR_INFO_SERIAL_NUMBER] = MNL_TYPE_STRING,
+	[DEVLINK_ATTR_INFO_VERSION_FIXED] = MNL_TYPE_NESTED,
+	[DEVLINK_ATTR_INFO_VERSION_RUNNING] = MNL_TYPE_NESTED,
+	[DEVLINK_ATTR_INFO_VERSION_STORED] = MNL_TYPE_NESTED,
+	[DEVLINK_ATTR_INFO_VERSION_NAME] = MNL_TYPE_STRING,
+	[DEVLINK_ATTR_INFO_VERSION_VALUE] = MNL_TYPE_STRING,
 };
 
 static int attr_cb(const struct nlattr *attr, void *data)
@@ -943,6 +952,21 @@ static int param_cmode_get(const char *cmodestr,
 	return 0;
 }
 
+static int versions_type_get(const char *typestr, int *p_attr)
+{
+	if (strcmp(typestr, "fixed") == 0) {
+		*p_attr = DEVLINK_ATTR_INFO_VERSION_FIXED;
+	} else if (strcmp(typestr, "stored") == 0) {
+		*p_attr = DEVLINK_ATTR_INFO_VERSION_STORED;
+	} else if (strcmp(typestr, "running") == 0) {
+		*p_attr = DEVLINK_ATTR_INFO_VERSION_RUNNING;
+	} else {
+		pr_err("Unknown versions type \"%s\"\n", typestr);
+		return -EINVAL;
+	}
+	return 0;
+}
+
 static int dl_argv_parse(struct dl *dl, uint32_t o_required,
 			 uint32_t o_optional)
 {
@@ -1178,6 +1202,19 @@ static int dl_argv_parse(struct dl *dl, uint32_t o_required,
 			if (err)
 				return err;
 			o_found |= DL_OPT_REGION_LENGTH;
+		} else if (dl_argv_match(dl, "versions") &&
+			   (o_all & DL_OPT_VERSIONS_TYPE)) {
+			const char *versionstr;
+
+			dl_arg_inc(dl);
+			err = dl_argv_str(dl, &versionstr);
+			if (err)
+				return err;
+			err = versions_type_get(versionstr,
+						&opts->versions_attr);
+			if (err)
+				return err;
+			o_found |= DL_OPT_VERSIONS_TYPE;
 		} else {
 			pr_err("Unknown option \"%s\"\n", dl_argv(dl));
 			return -EINVAL;
@@ -1443,6 +1480,9 @@ static void cmd_dev_help(void)
 	pr_err("       devlink dev param set DEV name PARAMETER value VALUE cmode { permanent | driverinit | runtime }\n");
 	pr_err("       devlink dev param show [DEV name PARAMETER]\n");
 	pr_err("       devlink dev reload DEV\n");
+	pr_err("       devlink dev info [ DEV [ { versions [ VTYPE ] } ] ]\n");
+	pr_err("\n");
+	pr_err("       VTYPE := { fixed | running | stored }\n");
 }
 
 static bool cmp_arr_last_handle(struct dl *dl, const char *bus_name,
@@ -1775,6 +1815,30 @@ static void pr_out_array_end(struct dl *dl)
 	}
 }
 
+static void pr_out_object_start(struct dl *dl, const char *name)
+{
+	if (dl->json_output) {
+		jsonw_name(dl->jw, name);
+		jsonw_start_object(dl->jw);
+	} else {
+		__pr_out_indent_inc();
+		__pr_out_newline();
+		pr_out("%s:", name);
+		__pr_out_indent_inc();
+		__pr_out_newline();
+	}
+}
+
+static void pr_out_object_end(struct dl *dl)
+{
+	if (dl->json_output) {
+		jsonw_end_object(dl->jw);
+	} else {
+		__pr_out_indent_dec();
+		__pr_out_indent_dec();
+	}
+}
+
 static void pr_out_entry_start(struct dl *dl)
 {
 	if (dl->json_output)
@@ -2415,6 +2479,146 @@ static int cmd_dev_reload(struct dl *dl)
 	return _mnlg_socket_sndrcv(dl->nlg, nlh, NULL, NULL);
 }
 
+static void pr_out_versions_single(struct dl *dl, const struct nlmsghdr *nlh,
+				   const char *name, int type)
+{
+	struct nlattr *version;
+
+	if (dl->opts.versions_attr && dl->opts.versions_attr != type)
+		return;
+
+	mnl_attr_for_each(version, nlh, sizeof(struct genlmsghdr)) {
+		struct nlattr *tb[DEVLINK_ATTR_MAX + 1] = {};
+		const char *ver_value;
+		const char *ver_name;
+		int err;
+
+		if (mnl_attr_get_type(version) != type)
+			continue;
+
+		err = mnl_attr_parse_nested(version, attr_cb, tb);
+		if (err != MNL_CB_OK)
+			continue;
+
+		if (!tb[DEVLINK_ATTR_INFO_VERSION_NAME] ||
+		    !tb[DEVLINK_ATTR_INFO_VERSION_VALUE])
+			continue;
+
+		if (name) {
+			pr_out_object_start(dl, name);
+			name = NULL;
+		}
+
+		ver_name = mnl_attr_get_str(tb[DEVLINK_ATTR_INFO_VERSION_NAME]);
+		ver_value = mnl_attr_get_str(tb[DEVLINK_ATTR_INFO_VERSION_VALUE]);
+
+		pr_out_str(dl, ver_name, ver_value);
+		if (!dl->json_output)
+			__pr_out_newline();
+	}
+
+	if (!name)
+		pr_out_object_end(dl);
+}
+
+static void pr_out_info(struct dl *dl, const struct nlmsghdr *nlh,
+			struct nlattr **tb, bool has_versions)
+{
+	__pr_out_handle_start(dl, tb, true, false);
+
+	__pr_out_indent_inc();
+	if (!dl->opts.versions_attr && tb[DEVLINK_ATTR_INFO_DRIVER_NAME]) {
+		struct nlattr *nla_drv = tb[DEVLINK_ATTR_INFO_DRIVER_NAME];
+
+		__pr_out_newline();
+		pr_out_str(dl, "driver", mnl_attr_get_str(nla_drv));
+	}
+
+	if (!dl->opts.versions_attr && tb[DEVLINK_ATTR_INFO_SERIAL_NUMBER]) {
+		struct nlattr *nla_sn = tb[DEVLINK_ATTR_INFO_SERIAL_NUMBER];
+
+		__pr_out_newline();
+		pr_out_str(dl, "serial_number", mnl_attr_get_str(nla_sn));
+	}
+	__pr_out_indent_dec();
+
+	if (has_versions) {
+		pr_out_object_start(dl, "versions");
+
+		pr_out_versions_single(dl, nlh, "fixed",
+				       DEVLINK_ATTR_INFO_VERSION_FIXED);
+		pr_out_versions_single(dl, nlh, "running",
+				       DEVLINK_ATTR_INFO_VERSION_RUNNING);
+		pr_out_versions_single(dl, nlh, "stored",
+				       DEVLINK_ATTR_INFO_VERSION_STORED);
+
+		pr_out_object_end(dl);
+	}
+
+	pr_out_handle_end(dl);
+}
+
+static int cmd_versions_show_cb(const struct nlmsghdr *nlh, void *data)
+{
+	struct genlmsghdr *genl = mnl_nlmsg_get_payload(nlh);
+	struct nlattr *tb[DEVLINK_ATTR_MAX + 1] = {};
+	bool has_versions, has_info;
+	struct dl *dl = data;
+
+	mnl_attr_parse(nlh, sizeof(*genl), attr_cb, tb);
+
+	if (!tb[DEVLINK_ATTR_BUS_NAME] || !tb[DEVLINK_ATTR_DEV_NAME])
+		return MNL_CB_ERROR;
+
+	has_versions = tb[DEVLINK_ATTR_INFO_VERSION_FIXED] ||
+		tb[DEVLINK_ATTR_INFO_VERSION_RUNNING] ||
+		tb[DEVLINK_ATTR_INFO_VERSION_STORED];
+	has_info = tb[DEVLINK_ATTR_INFO_DRIVER_NAME] ||
+		tb[DEVLINK_ATTR_INFO_SERIAL_NUMBER] ||
+		has_versions;
+
+	if (has_info)
+		pr_out_info(dl, nlh, tb, has_versions);
+
+	return MNL_CB_OK;
+}
+
+static void cmd_dev_info_help(void)
+{
+	pr_err("Usage: devlink dev info [ DEV [ { versions [ VTYPE ] } ] ]\n");
+	pr_err("\n");
+	pr_err("       VTYPE := { fixed | running | stored }\n");
+}
+
+static int cmd_dev_info(struct dl *dl)
+{
+	struct nlmsghdr *nlh;
+	uint16_t flags = NLM_F_REQUEST | NLM_F_ACK;
+	int err;
+
+	if (dl_argv_match(dl, "help")) {
+		cmd_dev_info_help();
+		return 0;
+	}
+
+	if (dl_argc(dl) == 0)
+		flags |= NLM_F_DUMP;
+
+	nlh = mnlg_msg_prepare(dl->nlg, DEVLINK_CMD_INFO_GET, flags);
+
+	if (dl_argc(dl) > 0) {
+		err = dl_argv_parse_put(nlh, dl, DL_OPT_HANDLE,
+					DL_OPT_VERSIONS_TYPE);
+		if (err)
+			return err;
+	}
+
+	pr_out_section_start(dl, "info");
+	err = _mnlg_socket_sndrcv(dl->nlg, nlh, cmd_versions_show_cb, dl);
+	pr_out_section_end(dl);
+	return err;
+}
+
 static int cmd_dev(struct dl *dl)
 {
 	if (dl_argv_match(dl, "help")) {
@@ -2433,6 +2637,9 @@ static int cmd_dev(struct dl *dl)
 	} else if (dl_argv_match(dl, "param")) {
 		dl_arg_inc(dl);
 		return cmd_dev_param(dl);
+	} else if (dl_argv_match(dl, "info")) {
+		dl_arg_inc(dl);
+		return cmd_dev_info(dl);
 	}
 	pr_err("Command \"%s\" not found\n", dl_argv(dl));
 	return -ENOENT;
diff --git a/man/man8/devlink-dev.8 b/man/man8/devlink-dev.8
index d985da172aa0..5b05298f88bf 100644
--- a/man/man8/devlink-dev.8
+++ b/man/man8/devlink-dev.8
@@ -63,6 +63,17 @@ devlink-dev \- devlink device configuration
 .BR "devlink dev reload"
 .IR DEV
 
+.ti -8
+.BR "devlink dev info"
+.RI "[ " DEV
+.RI "["
+.BR versions
+.RI "{ "
+.BR fixed " | " running " | " stored
+.RI "} "
+.RI "]"
+.RI "]"
+
 .SH "DESCRIPTION"
 .SS devlink dev show - display devlink device attributes
 
@@ -151,6 +162,31 @@ If this argument is omitted all parameters supported by devlink devices are list
 .I "DEV"
 - Specifies the devlink device to reload.
 
+.SS devlink dev info - display device information.
+Display device information provided by the driver. This command can be used
+to query versions of the hardware components or device components which
+can't be updated (
+.I fixed
+) as well as device firmware which can be updated. For firmware components
+.I running
+displays the versions of firmware currently loaded into the device, while
+.I stored
+reports the versions in device's flash.
+.I Running
+and
+.I stored
+versions may differ after flash has been updated, but before reboot.
+
+.PP
+.I "DEV"
+- specifies the devlink device to show.
+If this argument is omitted all devices are listed.
+
+.PP
+.BR versions " { " fixed " | " running " | " stored " } "
+- specifies the versions category to show.
+If this argument is omitted all categories are listed.
+
 .SH "EXAMPLES"
 .PP
 devlink dev show
-- 
2.19.2


^ permalink raw reply related

* Re: [PATCH bpf-next v3 1/3] tools/bpf: move libbpf pr_* debug print functions to headers
From: Yonghong Song @ 2019-02-02  0:00 UTC (permalink / raw)
  To: Alexei Starovoitov
  Cc: Arnaldo Carvalho de Melo, Magnus Karlsson, netdev@vger.kernel.org,
	Alexei Starovoitov, Daniel Borkmann, Kernel Team
In-Reply-To: <20190201225227.fxfvmldsxbe632vz@ast-mbp>



On 2/1/19 2:52 PM, Alexei Starovoitov wrote:
> On Fri, Feb 01, 2019 at 02:06:16PM -0800, Yonghong Song wrote:
>> A global function libbpf_debug_print, which is invisible
>> outside the shared library, is defined to print based
>> on levels. The pr_warning, pr_info and pr_debug
>> macros are moved into the newly created header
>> common.h. So any .c file including common.h can
>> use these macros directly.
> 
> s/common.h/util.h/ ?
> 
> I understand that util.h is libbpf's internal header, but still
> I'm worried that such file name is too generic and if users
> get their header paths wrong they may pick it by accident.
> May be call it libbpf_util.h instead?

Will change to libbpf_util.h.

>>
>> Currently btf__new and btf_ext__new API has an argument getting
>> __pr_debug function pointer into btf.c so the debugging information
>> can be printed there. This patch removed this parameter
>> from btf__new and btf_ext__new and directly using pr_debug in btf.c.
>>
>> Another global function libbpf_dprint_level_available, also
>> invisible outside the shared library, can test
>> whether a particular level debug printing is
>> available or not. It is used in btf.c to
>> test whether DEBUG level debug printing is availabl or not,
>> based on which the log buffer will be allocated when loading
>> btf to the kernel.
>>
>> Signed-off-by: Yonghong Song <yhs@fb.com>
> ...
>> diff --git a/tools/lib/bpf/util.h b/tools/lib/bpf/util.h
>> new file mode 100644
>> index 000000000000..3ae80f486875
>> --- /dev/null
>> +++ b/tools/lib/bpf/util.h
>> @@ -0,0 +1,32 @@
>> +/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */
>> +/* Copyright (c) 2019 Facebook */
>> +
>> +#ifndef __LIBBPF_COMMON_H
>> +#define __LIBBPF_COMMON_H
> 
> s/COMMON/new name/

Will change.

> 
>> +
>> +#include <stdbool.h>
>> +
>> +#ifdef __cplusplus
>> +extern "C" {
>> +#endif
>> +
>> +extern void libbpf_debug_print(enum libbpf_print_level level,
>> +			       const char *format, ...)
>> +	__attribute__((format(printf, 2, 3)));
> 
> May be shorten the name to libbpf_print ?
> Such name will match enum libbpf_print_level and libbpf_set_print.

Will change to libbpf_print.
Thanks!


^ permalink raw reply

* Re: [PATCH] bpfilter: remove extra header search paths for bpfilter_umh
From: Alexei Starovoitov @ 2019-02-01 23:59 UTC (permalink / raw)
  To: Masahiro Yamada
  Cc: Daniel Borkmann, netdev, Matteo Croce, David S. Miller,
	linux-kernel, Jakub Kicinski, Laura Abbott, YueHaibing
In-Reply-To: <1548904535-9853-1-git-send-email-yamada.masahiro@socionext.com>

On Thu, Jan 31, 2019 at 12:15:35PM +0900, Masahiro Yamada wrote:
> Currently, the header search paths -Itools/include and
> -Itools/include/uapi are not used. Let's drop the unused code.
> 
> We can remove -I. too by fixing up one C file.
> 
> Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> ---
> 
> Perhaps, are these extra header search paths for
> more upstreaming in the future?
> 
> If this patch is rejected, I will send an alternative one.
> 
> To clean up the Kbuild core,
> I want to drop as many unused header search paths as possible.
> 
> 
>  net/bpfilter/Makefile | 1 -
>  net/bpfilter/main.c   | 2 +-
>  2 files changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/net/bpfilter/Makefile b/net/bpfilter/Makefile
> index 0947ee7..5d6c776 100644
> --- a/net/bpfilter/Makefile
> +++ b/net/bpfilter/Makefile
> @@ -5,7 +5,6 @@
>  
>  hostprogs-y := bpfilter_umh
>  bpfilter_umh-objs := main.o
> -KBUILD_HOSTCFLAGS += -I. -Itools/include/ -Itools/include/uapi
>  HOSTCC := $(CC)
>  
>  ifeq ($(CONFIG_BPFILTER_UMH), y)
> diff --git a/net/bpfilter/main.c b/net/bpfilter/main.c
> index 1317f10..61ce845 100644
> --- a/net/bpfilter/main.c
> +++ b/net/bpfilter/main.c
> @@ -6,7 +6,7 @@
>  #include <sys/socket.h>
>  #include <fcntl.h>
>  #include <unistd.h>
> -#include "include/uapi/linux/bpf.h"
> +#include "../../include/uapi/linux/bpf.h"

argh. that's not pretty.
I would prefer to keep -I in a makefile


^ permalink raw reply

* Re: [PATCH bpf-next] selftests/bpf: remove generated verifier/tests.h on 'make clean'
From: Alexei Starovoitov @ 2019-02-01 23:53 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Stanislav Fomichev, netdev, davem, ast, daniel, quentin.monnet
In-Reply-To: <20190201154738.1caca071@cakuba.hsd1.ca.comcast.net>

On Fri, Feb 01, 2019 at 03:47:38PM -0800, Jakub Kicinski wrote:
> On Fri,  1 Feb 2019 15:46:38 -0800, Stanislav Fomichev wrote:
> > 'make clean' is supposed to remove generated files.
> > 
> > Signed-off-by: Stanislav Fomichev <sdf@google.com>
> 
> Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>

Applied, Thanks


^ permalink raw reply

* RE: [PATCH] igb: fix various indentation issues
From: Brown, Aaron F @ 2019-02-01 23:50 UTC (permalink / raw)
  To: Colin King, Kirsher, Jeffrey T, David S . Miller,
	intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org
  Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
In-Reply-To: <20190116185316.24814-1-colin.king@canonical.com>

> From: netdev-owner@vger.kernel.org [mailto:netdev-
> owner@vger.kernel.org] On Behalf Of Colin King
> Sent: Wednesday, January 16, 2019 10:53 AM
> To: Kirsher, Jeffrey T <jeffrey.t.kirsher@intel.com>; David S . Miller
> <davem@davemloft.net>; intel-wired-lan@lists.osuosl.org;
> netdev@vger.kernel.org
> Cc: kernel-janitors@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: [PATCH] igb: fix various indentation issues
> 
> From: Colin Ian King <colin.king@canonical.com>
> 
> There are some lines that have indentation issues, fix these
> 
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  drivers/net/ethernet/intel/igb/igb_ethtool.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
Tested-by: Aaron Brown <aaron.f.brown@intel.com>

^ permalink raw reply

* Re: [PATCH bpf-next] selftests/bpf: remove generated verifier/tests.h on 'make clean'
From: Jakub Kicinski @ 2019-02-01 23:47 UTC (permalink / raw)
  To: Stanislav Fomichev; +Cc: netdev, davem, ast, daniel, quentin.monnet
In-Reply-To: <20190201234638.54791-1-sdf@google.com>

On Fri,  1 Feb 2019 15:46:38 -0800, Stanislav Fomichev wrote:
> 'make clean' is supposed to remove generated files.
> 
> Signed-off-by: Stanislav Fomichev <sdf@google.com>

Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>

Ah, thanks!

^ permalink raw reply

* [PATCH bpf-next] selftests/bpf: remove generated verifier/tests.h on 'make clean'
From: Stanislav Fomichev @ 2019-02-01 23:46 UTC (permalink / raw)
  To: netdev
  Cc: davem, ast, daniel, jakub.kicinski, quentin.monnet,
	Stanislav Fomichev

'make clean' is supposed to remove generated files.

Signed-off-by: Stanislav Fomichev <sdf@google.com>
---
 tools/testing/selftests/bpf/Makefile | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile
index 8993e9c8f410..858572490644 100644
--- a/tools/testing/selftests/bpf/Makefile
+++ b/tools/testing/selftests/bpf/Makefile
@@ -216,7 +216,8 @@ ifeq ($(DWARF2BTF),y)
 	$(BTF_PAHOLE) -J $@
 endif
 
-$(OUTPUT)/test_verifier: $(OUTPUT)/verifier/tests.h
+VERIFIER_TESTS_H := $(OUTPUT)/verifier/tests.h
+$(OUTPUT)/test_verifier: $(VERIFIER_TESTS_H)
 $(OUTPUT)/test_verifier: CFLAGS += -I$(OUTPUT)
 
 VERIFIER_TEST_FILES := $(wildcard verifier/*.c)
@@ -227,6 +228,7 @@ $(OUTPUT)/verifier/tests.h: $(VERIFIER_TEST_FILES)
 		  ls *.c 2> /dev/null | \
 			sed -e 's@\(.*\)@#include \"\1\"@'; \
 		  echo '#endif' \
-		 ) > $(OUTPUT)/verifier/tests.h)
+		 ) > $(VERIFIER_TESTS_H))
 
-EXTRA_CLEAN := $(TEST_CUSTOM_PROGS) $(ALU32_BUILD_DIR)
+EXTRA_CLEAN := $(TEST_CUSTOM_PROGS) $(ALU32_BUILD_DIR) \
+	$(VERIFIER_TESTS_H)
-- 
2.20.1.611.gfbb209baf1-goog


^ permalink raw reply related

* Re: [PATCH net-next v4 0/8] devlink: add device (driver) information API
From: David Miller @ 2019-02-01 23:36 UTC (permalink / raw)
  To: jakub.kicinski
  Cc: netdev, oss-drivers, jiri, andrew, f.fainelli, mkubecek, eugenem,
	jonathan.lemon
In-Reply-To: <20190131185047.27685-1-jakub.kicinski@netronome.com>

From: Jakub Kicinski <jakub.kicinski@netronome.com>
Date: Thu, 31 Jan 2019 10:50:39 -0800

> fw_version field in ethtool -i does not suit modern needs with 31
> characters being quite limiting on more complex systems.  There is
> also no distinction between the running and flashed versions of
> the firmware.
> 
> Since the driver information pertains to the entire device, rather
> than a particular netdev, it seems wise to move it do devlink, at
> the same time fixing the aforementioned issues.
> 
> The new API allows exposing the device serial number and versions
> of the components of the card - both hardware, firmware (running
> and flashed).  Driver authors can choose descriptive identifiers
> for the version fields.  A few version identifiers which seemed
> relevant for most devices have been added to the global devlink
> header.
> 
> Example:
 ...
> Last patch also includes a compat code for ethtool.  If driver
> reports no fw_version via the traditional ethtool API, ethtool
> can call into devlink and try to cram as many versions as possible
> into the 31 characters.
 ...

Series applied.

^ permalink raw reply

* Re: [PATCH bpf-next v2 1/3] tools/bpf: move libbpf pr_* debug print functions to headers
From: Arnaldo Carvalho de Melo @ 2019-02-01 23:29 UTC (permalink / raw)
  To: Yonghong Song
  Cc: Arnaldo Carvalho de Melo, Magnus Karlsson, netdev@vger.kernel.org,
	Alexei Starovoitov, Daniel Borkmann, Kernel Team
In-Reply-To: <e5e29586-d372-0920-9787-fe687e66603b@fb.com>

Em Fri, Feb 01, 2019 at 11:20:44PM +0000, Yonghong Song escreveu:
> On 2/1/19 3:10 PM, Arnaldo Carvalho de Melo wrote:
> > Em Fri, Feb 01, 2019 at 09:47:31AM -0800, Yonghong Song escreveu:
> >> @@ -698,13 +695,13 @@ struct btf_ext *btf_ext__new(__u8 *data, __u32 size, btf_print_fn_t err_log)
> >>   	if (!btf_ext)
> >>   		return ERR_PTR(-ENOMEM);
> >>   
> >> -	err = btf_ext_copy_func_info(btf_ext, data, size, err_log);
> >> +	err = btf_ext_copy_func_info(btf_ext, data, size);
> >>   	if (err) {
> >>   		btf_ext__free(btf_ext);
> > 
> > One thing I noticed whas that the class + __ + method is not being
> > consistently followed, will this be dealt with in a followup patch, i.e.
> > to make this consistently use the format used in the
> > btf_ext__free(btf_ext) case?
> 
> Currently, the API functions have both +_+ and +__+ method names.
> The +_+ is for APIs having a close one-to-one mapping
> to system calls. The +__+ is for APIs a little bit high level.
> Did you find any particular method whose format is not quite right?

Nope, and thanks for the clarification, if I find something else I'll
get in touch,

- Arnaldo

^ permalink raw reply

* RE: [PATCH] e1000e: fix cyclic resets at link up with active tx
From: Brown, Aaron F @ 2019-02-01 23:28 UTC (permalink / raw)
  To: Konstantin Khlebnikov, netdev@vger.kernel.org,
	intel-wired-lan@lists.osuosl.org, Kirsher, Jeffrey T
  Cc: linux-kernel@vger.kernel.org, David S. Miller
In-Reply-To: <154747257030.250168.12931902291381446144.stgit@buzz>



> -----Original Message-----
> From: netdev-owner@vger.kernel.org [mailto:netdev-
> owner@vger.kernel.org] On Behalf Of Konstantin Khlebnikov
> Sent: Monday, January 14, 2019 5:30 AM
> To: netdev@vger.kernel.org; intel-wired-lan@lists.osuosl.org; Kirsher,
> Jeffrey T <jeffrey.t.kirsher@intel.com>
> Cc: linux-kernel@vger.kernel.org; David S. Miller <davem@davemloft.net>
> Subject: [PATCH] e1000e: fix cyclic resets at link up with active tx
> 
> I'm seeing series of e1000e resets (sometimes endless) at system boot
> if something generates tx traffic at this time. In my case this is
> netconsole who sends message "e1000e 0000:02:00.0: Some CPU C-states
> have been disabled in order to enable jumbo frames" from e1000e itself.
> As result e1000_watchdog_task sees used tx buffer while carrier is off
> and start this reset cycle again.
> 
> [   17.794359] e1000e: eth1 NIC Link is Up 1000 Mbps Full Duplex, Flow
> Control: None
> [   17.794714] IPv6: ADDRCONF(NETDEV_CHANGE): eth1: link becomes ready
> [   22.936455] e1000e 0000:02:00.0 eth1: changing MTU from 1500 to 9000
> [   23.033336] e1000e 0000:02:00.0: Some CPU C-states have been disabled in
> order to enable jumbo frames
> [   26.102364] e1000e: eth1 NIC Link is Up 1000 Mbps Full Duplex, Flow
> Control: None
> [   27.174495] 8021q: 802.1Q VLAN Support v1.8
> [   27.174513] 8021q: adding VLAN 0 to HW filter on device eth1
> [   30.671724] cgroup: cgroup: disabling cgroup2 socket matching due to
> net_prio or net_cls activation
> [   30.898564] netpoll: netconsole: local port 6666
> [   30.898566] netpoll: netconsole: local IPv6 address
> 2a02:6b8:0:80b:beae:c5ff:fe28:23f8
> [   30.898567] netpoll: netconsole: interface 'eth1'
> [   30.898568] netpoll: netconsole: remote port 6666
> [   30.898568] netpoll: netconsole: remote IPv6 address
> 2a02:6b8:b000:605c:e61d:2dff:fe03:3790
> [   30.898569] netpoll: netconsole: remote ethernet address b0:a8:6e:f4:ff:c0
> [   30.917747] console [netcon0] enabled
> [   30.917749] netconsole: network logging started
> [   31.453353] e1000e 0000:02:00.0: Some CPU C-states have been disabled in
> order to enable jumbo frames
> [   34.185730] e1000e 0000:02:00.0: Some CPU C-states have been disabled in
> order to enable jumbo frames
> [   34.321840] e1000e 0000:02:00.0: Some CPU C-states have been disabled in
> order to enable jumbo frames
> [   34.465822] e1000e 0000:02:00.0: Some CPU C-states have been disabled in
> order to enable jumbo frames
> [   34.597423] e1000e 0000:02:00.0: Some CPU C-states have been disabled in
> order to enable jumbo frames
> [   34.745417] e1000e 0000:02:00.0: Some CPU C-states have been disabled in
> order to enable jumbo frames
> [   34.877356] e1000e 0000:02:00.0: Some CPU C-states have been disabled in
> order to enable jumbo frames
> [   35.005441] e1000e 0000:02:00.0: Some CPU C-states have been disabled in
> order to enable jumbo frames
> [   35.157376] e1000e 0000:02:00.0: Some CPU C-states have been disabled in
> order to enable jumbo frames
> [   35.289362] e1000e 0000:02:00.0: Some CPU C-states have been disabled in
> order to enable jumbo frames
> [   35.417441] e1000e 0000:02:00.0: Some CPU C-states have been disabled in
> order to enable jumbo frames
> [   37.790342] e1000e: eth1 NIC Link is Up 1000 Mbps Full Duplex, Flow
> Control: None
> 
> This patch flushes tx buffers only once when carrier is off
> rather than at each watchdog iteration.
> 
> Signed-off-by: Konstantin Khlebnikov <khlebnikov@yandex-team.ru>
> ---
>  drivers/net/ethernet/intel/e1000e/netdev.c |   15 ++++++---------
>  1 file changed, 6 insertions(+), 9 deletions(-)

Tested-by: Aaron Brown <aaron.f.brown@intel.com>

^ permalink raw reply

* Re: pull-request: bpf 2019-01-31
From: David Miller @ 2019-02-01 23:28 UTC (permalink / raw)
  To: ast; +Cc: daniel, netdev, kernel-team
In-Reply-To: <20190131225040.3447108-1-ast@kernel.org>

From: Alexei Starovoitov <ast@kernel.org>
Date: Thu, 31 Jan 2019 14:50:40 -0800

> The following pull-request contains BPF updates for your *net* tree.
> 
> The main changes are:
> 
> 1) disable preemption in sender side of socket filters, from Alexei.
> 
> 2) fix two potential deadlocks in syscall bpf lookup and prog_register,
>    from Martin and Alexei.
> 
> 3) fix BTF to allow typedef on func_proto, from Yonghong.
> 
> 4) two bpftool fixes, from Jiri and Paolo.
> 
> Please consider pulling these changes from:
> 
>   git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git

Pulled, thanks Alexei.

^ permalink raw reply

* Re: [PATCH net-next 00/11] selftests: Various fixes
From: David Miller @ 2019-02-01 23:26 UTC (permalink / raw)
  To: petrm; +Cc: netdev, idosch
In-Reply-To: <cover.1548973731.git.petrm@mellanox.com>

From: Petr Machata <petrm@mellanox.com>
Date: Thu, 31 Jan 2019 22:35:08 +0000

> This patch set contains various fixes whose common denominator is
> improving quality of forwarding and mlxsw selftests.
> 
> Most of the fixes are improvements in determinism (such that timing and
> latency don't impact the test performance). These were prompted by
> regular runs of the test suite on a hardware emulator, the performance
> of which is necessarily lower than that of the real device.
> 
> Patches #1 (from Ido), #2 and #3 make changes to ping limits.
> 
> Patches #4 and #5 add more sleep in places where things need more time
> to finish.
> 
> Patches #6 and #7 fix two tests in the suite of mirror-to-gretap tests
> where underlay involves a VLAN device over an 802.1q bridge.
> 
> Patches #8, #9 and #10 fix bugs in mirror-to-gretap test where underlay
> involves a LAG device.
> 
> Patch #11 fixes a missed RET initialization in mirror-to-gretap flower
> test.

Series applied, thanks.

^ permalink raw reply

* Re: [PATCH v2] ipconfig: add carrier_timeout kernel parameter
From: David Miller @ 2019-02-01 23:25 UTC (permalink / raw)
  To: martin.kepplinger
  Cc: corbet, kuznet, yoshfuji, linux-doc, netdev, linux-kernel,
	manfred.schlaegl
In-Reply-To: <20190131101419.3988-1-martin.kepplinger@ginzinger.com>

From: Martin Kepplinger <martin.kepplinger@ginzinger.com>
Date: Thu, 31 Jan 2019 11:14:18 +0100

> commit 3fb72f1e6e61 ("ipconfig wait for carrier") added a
> "wait for carrier" policy, with a fixed worst case maximum wait
> of two minutes.
> 
> Now make the wait for carrier timeout configurable on the kernel
> commandline and use the 120s as the default.
> 
> The timeout messages introduced with
> commit 5e404cd65860 ("ipconfig: add informative timeout messages while
> waiting for carrier") are done in a fixed interval of 20 seconds, just
> like they were before (240/12).
> 
> Signed-off-by: Martin Kepplinger <martin.kepplinger@ginzinger.com>

Ok, this seems fine for me.

Applied to net-next, thanks.

^ permalink raw reply

* Re: [PATCH net-next] tulip: eeprom: use struct_size() in kmalloc()
From: David Miller @ 2019-02-01 23:13 UTC (permalink / raw)
  To: gustavo; +Cc: netdev, linux-parisc, linux-kernel
In-Reply-To: <20190131003355.GA27627@embeddedor>

From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
Date: Wed, 30 Jan 2019 18:33:55 -0600

> One of the more common cases of allocation size calculations is finding
> the size of a structure that has a zero-sized array at the end, along
> with memory for some number of elements for that array. For example:
> 
> struct foo {
>     int stuff;
>     struct boo entry[];
> };
> 
> instance = kmalloc(sizeof(struct foo) + count * sizeof(struct boo), GFP_KERNEL);
> 
> Instead of leaving these open-coded and prone to type mistakes, we can
> now use the new struct_size() helper:
> 
> instance = kmalloc(struct_size(instance, entry, count), GFP_KERNEL);
> 
> This code was detected with the help of Coccinelle.
> 
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>

Applied.

^ permalink raw reply

* Re: [PATCH net-next] net: tls: Set async_capable for tls zerocopy only if we see EINPROGRESS
From: David Miller @ 2019-02-01 23:05 UTC (permalink / raw)
  To: davejwatson; +Cc: netdev, vakul.garg, borisp, aviadye, john.fastabend, daniel
In-Reply-To: <20190130220819.wgwenjanlzftvb6i@davejwatson-mba.local>

From: Dave Watson <davejwatson@fb.com>
Date: Wed, 30 Jan 2019 22:08:21 +0000

> Currently we don't zerocopy if the crypto framework async bit is set.
> However some crypto algorithms (such as x86 AESNI) support async,
> but in the context of sendmsg, will never run asynchronously.  Instead,
> check for actual EINPROGRESS return code before assuming algorithm is
> async.
> 
> Signed-off-by: Dave Watson <davejwatson@fb.com>

Applied, thanks.

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox