Netdev List
 help / color / mirror / Atom feed
* Re: [PATCH] libbpf: Don't error out if getsockopt() fails for XDP_OPTIONS
From: Daniel Borkmann @ 2019-09-16  8:08 UTC (permalink / raw)
  To: Yonghong Song, Toke Høiland-Jørgensen,
	Alexei Starovoitov, netdev@vger.kernel.org, bpf@vger.kernel.org,
	maximmi@mellanox.com
In-Reply-To: <60651b4b-c185-1e17-1664-88957537e3f1@fb.com>

On 9/13/19 8:53 PM, Yonghong Song wrote:
> On 9/10/19 12:06 AM, Toke Høiland-Jørgensen wrote:
>> Yonghong Song <yhs@fb.com> writes:
>>> On 9/9/19 10:46 AM, Toke Høiland-Jørgensen wrote:
>>>> The xsk_socket__create() function fails and returns an error if it cannot
>>>> get the XDP_OPTIONS through getsockopt(). However, support for XDP_OPTIONS
>>>> was not added until kernel 5.3, so this means that creating XSK sockets
>>>> always fails on older kernels.
>>>>
>>>> Since the option is just used to set the zero-copy flag in the xsk struct,
>>>> there really is no need to error out if the getsockopt() call fails.
>>>>
>>>> Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
>>>> ---
>>>>     tools/lib/bpf/xsk.c | 8 ++------
>>>>     1 file changed, 2 insertions(+), 6 deletions(-)
>>>>
>>>> diff --git a/tools/lib/bpf/xsk.c b/tools/lib/bpf/xsk.c
>>>> index 680e63066cf3..598e487d9ce8 100644
>>>> --- a/tools/lib/bpf/xsk.c
>>>> +++ b/tools/lib/bpf/xsk.c
>>>> @@ -603,12 +603,8 @@ int xsk_socket__create(struct xsk_socket **xsk_ptr, const char *ifname,
>>>>     
>>>>     	optlen = sizeof(opts);
>>>>     	err = getsockopt(xsk->fd, SOL_XDP, XDP_OPTIONS, &opts, &optlen);
>>>> -	if (err) {
>>>> -		err = -errno;
>>>> -		goto out_mmap_tx;
>>>> -	}
>>>> -
>>>> -	xsk->zc = opts.flags & XDP_OPTIONS_ZEROCOPY;
>>>> +	if (!err)
>>>> +		xsk->zc = opts.flags & XDP_OPTIONS_ZEROCOPY;
>>>>     
>>>>     	if (!(xsk->config.libbpf_flags & XSK_LIBBPF_FLAGS__INHIBIT_PROG_LOAD)) {
>>>>     		err = xsk_setup_xdp_prog(xsk);
>>>
>>> Since 'zc' is not used by anybody, maybe all codes 'zc' related can be
>>> removed? It can be added back back once there is an interface to use
>>> 'zc'?
>>
>> Fine with me; up to the maintainers what they prefer, I guess? :)

Given this is not exposed to applications at this point and we don't do anything
useful with it, lets just remove the zc cruft until there is a proper interface
added to libbpf. Toke, please respin with the suggested removal, thanks!

^ permalink raw reply

* Re: [PATCH net-next v2 0/3] mlxsw: spectrum_buffers: Add the ability to query the CPU port's shared buffer
From: Shalom Toledo @ 2019-09-16  8:14 UTC (permalink / raw)
  To: Ido Schimmel, netdev@vger.kernel.org, davem@davemloft.net
  Cc: Jiri Pirko, mlxsw, Ido Schimmel
In-Reply-To: <20190916061750.26207-1-idosch@idosch.org>

Hi David,

I have v3 with all the fixes Jiri commented. Can I send it? Or should I wait
until net-next will be open again?

Thanks,
Shalom.

On 16/09/2019 9:17, Ido Schimmel wrote:
> From: Ido Schimmel <idosch@mellanox.com>
> 
> Shalom says:
> 
> While debugging packet loss towards the CPU, it is useful to be able to
> query the CPU port's shared buffer quotas and occupancy.
> 
> Patch #1 prevents changing the CPU port's threshold and binding.
> 
> Patch #2 registers the CPU port with devlink.
> 
> Patch #3 adds the ability to query the CPU port's shared buffer quotas and
> occupancy.
> 
> v2:
> 
> Patch #1:
> * s/0/MLXSW_PORT_CPU_PORT/
> * Assign "mlxsw_sp->ports[MLXSW_PORT_CPU_PORT" at the end of
>   mlxsw_sp_cpu_port_create() to avoid NULL assignment on error path
> * Add common functions for mlxsw_core_port_init/fini()
> 
> Patch #2:
> * Move "changing CPU port's threshold and binding" check to a separate
>   patch
> 
> Shalom Toledo (3):
>   mlxsw: spectrum_buffers: Prevent changing CPU port's configuration
>   mlxsw: spectrum: Register CPU port with devlink
>   mlxsw: spectrum_buffers: Add the ability to query the CPU port's
>     shared buffer
> 
>  drivers/net/ethernet/mellanox/mlxsw/core.c    | 65 ++++++++++++++++---
>  drivers/net/ethernet/mellanox/mlxsw/core.h    |  5 ++
>  .../net/ethernet/mellanox/mlxsw/spectrum.c    | 46 +++++++++++++
>  .../mellanox/mlxsw/spectrum_buffers.c         | 51 ++++++++++++---
>  4 files changed, 150 insertions(+), 17 deletions(-)
> 


^ permalink raw reply

* Re: [PATCH bpf-next v2 0/3] AF_XDP fixes for i40e, ixgbe and xdpsock
From: Daniel Borkmann @ 2019-09-16  8:18 UTC (permalink / raw)
  To: Ciara Loftus, netdev, ast, bjorn.topel, magnus.karlsson,
	jonathan.lemon
  Cc: bruce.richardson, bpf, intel-wired-lan, kevin.laatz
In-Reply-To: <20190913103948.32053-1-ciara.loftus@intel.com>

On 9/13/19 12:39 PM, Ciara Loftus wrote:
> This patch set contains some fixes for AF_XDP zero copy in the i40e and
> ixgbe drivers as well as a fix for the 'xdpsock' sample application when
> running in unaligned mode.
> 
> Patches 1 and 2 fix a regression for the i40e and ixgbe drivers which
> caused the umem headroom to be added to the xdp handle twice, resulting in
> an incorrect value being received by the user for the case where the umem
> headroom is non-zero.
> 
> Patch 3 fixes an issue with the xdpsock sample application whereby the
> start of the tx packet data (offset) was not being set correctly when the
> application was being run in unaligned mode.
> 
> This patch set has been applied against commit a2c11b034142 ("kcm: use
> BPF_PROG_RUN")
> 
> ---
> v2:
> - Rearranged local variable order in i40e_run_xdp_zc and ixgbe_run_xdp_zc
> to comply with coding standards.
> 
> Ciara Loftus (3):
>    i40e: fix xdp handle calculations
>    ixgbe: fix xdp handle calculations
>    samples/bpf: fix xdpsock l2fwd tx for unaligned mode
> 
>   drivers/net/ethernet/intel/i40e/i40e_xsk.c   | 4 ++--
>   drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c | 4 ++--
>   samples/bpf/xdpsock_user.c                   | 2 +-
>   3 files changed, 5 insertions(+), 5 deletions(-)
> 

Applied, thanks!

^ permalink raw reply

* Re: [PATCH] brcmsmac: remove a useless test
From: Arend Van Spriel @ 2019-09-16  8:32 UTC (permalink / raw)
  To: Christophe JAILLET, franky.lin, hante.meuleman, chi-hsien.lin,
	wright.feng, kvalo, davem
  Cc: linux-wireless, brcm80211-dev-list.pdl, brcm80211-dev-list,
	netdev, linux-kernel, kernel-janitors
In-Reply-To: <20190915193210.27357-1-christophe.jaillet@wanadoo.fr>

On 9/15/2019 9:32 PM, Christophe JAILLET wrote:
> 'pih' is known to be non-NULL at this point, so the test can be removed.

Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>   drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)

^ permalink raw reply

* Re: [PATCH v2 0/2] mmc: core: Fix Marvell WiFi reset by adding SDIO API to replug card
From: Ulf Hansson @ 2019-09-16  9:25 UTC (permalink / raw)
  To: Doug Anderson
  Cc: Kalle Valo, Adrian Hunter, Ganapathi Bhat, linux-wireless,
	Andreas Fenkart, Brian Norris, Amitkumar Karwar,
	open list:ARM/Rockchip SoC..., Wolfram Sang, Nishant Sarmukadam,
	netdev, Avri Altman, linux-mmc@vger.kernel.org, David S. Miller,
	Xinming Hu, Linux Kernel Mailing List, Thomas Gleixner,
	Kate Stewart
In-Reply-To: <CAD=FV=VTLoqGbxFFMT8h72cfHCLupyvZpD75JB0N86+kFA+vzw@mail.gmail.com>

On Wed, 11 Sep 2019 at 23:26, Doug Anderson <dianders@chromium.org> wrote:
>
> Hi,
>
> On Thu, Jul 25, 2019 at 6:28 AM Ulf Hansson <ulf.hansson@linaro.org> wrote:
> >
> > On Mon, 22 Jul 2019 at 21:41, Douglas Anderson <dianders@chromium.org> wrote:
> > >
> > > As talked about in the thread at:
> > >
> > > http://lkml.kernel.org/r/CAD=FV=X7P2F1k_zwHc0mbtfk55-rucTz_GoDH=PL6zWqKYcpuw@mail.gmail.com
> > >
> > > ...when the Marvell WiFi card tries to reset itself it kills
> > > Bluetooth.  It was observed that we could re-init the card properly by
> > > unbinding / rebinding the host controller.  It was also observed that
> > > in the downstream Chrome OS codebase the solution used was
> > > mmc_remove_host() / mmc_add_host(), which is similar to the solution
> > > in this series.
> > >
> > > So far I've only done testing of this series using the reset test
> > > source that can be simulated via sysfs.  Specifically I ran this test:
> > >
> > > for i in $(seq 1000); do
> > >   echo "LOOP $i --------"
> > >   echo 1 > /sys/kernel/debug/mwifiex/mlan0/reset
> > >
> > >   while true; do
> > >     if ! ping -w15 -c1 "${GW}" >/dev/null 2>&1; then
> > >       fail=$(( fail + 1 ))
> > >       echo "Fail WiFi ${fail}"
> > >       if [[ ${fail} == 3 ]]; then
> > >         exit 1
> > >       fi
> > >     else
> > >       fail=0
> > >       break
> > >     fi
> > >   done
> > >
> > >   hciconfig hci0 down
> > >   sleep 1
> > >   if ! hciconfig hci0 up; then
> > >     echo "Fail BT"
> > >     exit 1
> > >   fi
> > > done
> > >
> > > I ran this several times and got several hundred iterations each
> > > before a failure.  When I saw failures:
> > >
> > > * Once I saw a "Fail BT"; manually resetting the card again fixed it.
> > >   I didn't give it time to see if it would have detected this
> > >   automatically.
> > > * Once I saw the ping fail because (for some reason) my device only
> > >   got an IPv6 address from my router and the IPv4 ping failed.  I
> > >   changed my script to use 'ping6' to see if that would help.
> > > * Once I saw the ping fail because the higher level network stack
> > >   ("shill" in my case) seemed to crash.  A few minutes later the
> > >   system recovered itself automatically.  https://crbug.com/984593 if
> > >   you want more details.
> > > * Sometimes while I was testing I saw "Fail WiFi 1" indicating a
> > >   transitory failure.  Usually this was an association failure, but in
> > >   one case I saw the device do "Firmware wakeup failed" after I
> > >   triggered the reset.  This caused the driver to trigger a re-reset
> > >   of itself which eventually recovered things.  This was good because
> > >   it was an actual test of the normal reset flow (not the one
> > >   triggered via sysfs).
> > >
> > > Changes in v2:
> > > - s/routnine/routine (Brian Norris, Matthias Kaehlcke).
> > > - s/contining/containing (Matthias Kaehlcke).
> > > - Add Matthias Reviewed-by tag.
> > > - Removed clear_bit() calls and old comment (Brian Norris).
> > > - Explicit CC of Andreas Fenkart.
> > > - Explicit CC of Brian Norris.
> > > - Add "Fixes" pointing at the commit Brian talked about.
> > > - Add Brian's Reviewed-by tag.
> > >
> > > Douglas Anderson (2):
> > >   mmc: core: Add sdio_trigger_replug() API
> > >   mwifiex: Make use of the new sdio_trigger_replug() API to reset
> > >
> > >  drivers/mmc/core/core.c                     | 28 +++++++++++++++++++--
> > >  drivers/mmc/core/sdio_io.c                  | 20 +++++++++++++++
> > >  drivers/net/wireless/marvell/mwifiex/sdio.c | 16 +-----------
> > >  include/linux/mmc/host.h                    | 15 ++++++++++-
> > >  include/linux/mmc/sdio_func.h               |  2 ++
> > >  5 files changed, 63 insertions(+), 18 deletions(-)
> > >
> >
> > Doug, thanks for sending this!
> >
> > As you know, I have been working on additional changes for SDIO
> > suspend/resume (still WIP and not ready for sharing) and this series
> > is related.
> >
> > The thing is, that even during system suspend/resume, synchronizations
> > are needed between the different layers (mmc host, mmc core and
> > sdio-funcs), which is common to the problem you want to solve.
> >
> > That said, I need to scratch my head a bit more before I can provide
> > you some feedback on $subject series. Moreover, it's vacation period
> > at my side so things are moving a bit slower. Please be patient.
>
> I had kinda forgotten about this series after we landed it locally in
> Chrome OS, but I realized that it never got resolved upstream.  Any
> chance your head has been sufficiently scratched and you're now happy
> with $subject series?  ;-)

It's still on my TODO list. Apologize for the delay, but I still need
more time to look into it, possibly later this week.

In any case, let's make sure we get this problem resolved for v5.5.

Kind regards
Uffe

^ permalink raw reply

* Re: [PATCH bpf] bpf: respect CAP_IPC_LOCK in RLIMIT_MEMLOCK check
From: Daniel Borkmann @ 2019-09-16  9:26 UTC (permalink / raw)
  To: Christian Barcenas, Alexei Starovoitov, netdev
  Cc: Martin KaFai Lau, Song Liu, Yonghong Song, bpf
In-Reply-To: <20190911181816.89874-1-christian@cbarcenas.com>

On 9/11/19 8:18 PM, Christian Barcenas wrote:
> A process can lock memory addresses into physical RAM explicitly
> (via mlock, mlockall, shmctl, etc.) or implicitly (via VFIO,
> perf ring-buffers, bpf maps, etc.), subject to RLIMIT_MEMLOCK limits.
> 
> CAP_IPC_LOCK allows a process to exceed these limits, and throughout
> the kernel this capability is checked before allowing/denying an attempt
> to lock memory regions into RAM.
> 
> Because bpf locks its programs and maps into RAM, it should respect
> CAP_IPC_LOCK. Previously, bpf would return EPERM when RLIMIT_MEMLOCK was
> exceeded by a privileged process, which is contrary to documented
> RLIMIT_MEMLOCK+CAP_IPC_LOCK behavior.

Do you have a link/pointer where this is /clearly/ documented?

Uapi header is not overly clear ...

include/uapi/linux/capability.h says:

   /* Allow locking of shared memory segments */
   /* Allow mlock and mlockall (which doesn't really have anything to do
      with IPC) */

   #define CAP_IPC_LOCK         14

   [...]

   /* Override resource limits. Set resource limits. */
   /* Override quota limits. */
   /* Override reserved space on ext2 filesystem */
   /* Modify data journaling mode on ext3 filesystem (uses journaling
      resources) */
   /* NOTE: ext2 honors fsuid when checking for resource overrides, so
      you can override using fsuid too */
   /* Override size restrictions on IPC message queues */
   /* Allow more than 64hz interrupts from the real-time clock */
   /* Override max number of consoles on console allocation */
   /* Override max number of keymaps */

   #define CAP_SYS_RESOURCE     24

... but my best guess is you are referring to `man 2 mlock`:

    Limits and permissions

        In Linux 2.6.8 and earlier, a process must be privileged (CAP_IPC_LOCK)
        in order to lock memory and the RLIMIT_MEMLOCK soft resource limit defines
        a limit on how much memory the process may lock.

        Since  Linux  2.6.9, no limits are placed on the amount of memory that a
        privileged process can lock and the RLIMIT_MEMLOCK soft resource limit
        instead defines a limit on how much memory an unprivileged process may lock.

Thanks,
Daniel

^ permalink raw reply

* Re: [PATCH v2 net-next 2/7] net: dsa: Pass ndo_setup_tc slave callback to drivers
From: Ilias Apalodimas @ 2019-09-16  9:31 UTC (permalink / raw)
  To: Vladimir Oltean
  Cc: f.fainelli, vivien.didelot, andrew, davem, vinicius.gomes,
	vedang.patel, richardcochran, weifeng.voon, jiri, m-karicheri2,
	Jose.Abreu, jhs, xiyou.wangcong, kurt.kanzenbach,
	joergen.andreasen, netdev
In-Reply-To: <20190914011802.1602-3-olteanv@gmail.com>

Hi Vladimir,

Yes fixes my request on the initial RFC. Sorry for the delayed response.

On Sat, Sep 14, 2019 at 04:17:57AM +0300, Vladimir Oltean wrote:
> DSA currently handles shared block filters (for the classifier-action
> qdisc) in the core due to what I believe are simply pragmatic reasons -
> hiding the complexity from drivers and offerring a simple API for port
> mirroring.
> 
> Extend the dsa_slave_setup_tc function by passing all other qdisc
> offloads to the driver layer, where the driver may choose what it
> implements and how. DSA is simply a pass-through in this case.
> 
> Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
> Acked-by: Kurt Kanzenbach <kurt@linutronix.de>
> ---
> Changes since v1:
> - Added Kurt Kanzenbach's Acked-by.
> 
> Changes since RFC:
> - Removed the unused declaration of struct tc_taprio_qopt_offload.
> 
>  include/net/dsa.h |  2 ++
>  net/dsa/slave.c   | 12 ++++++++----
>  2 files changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/include/net/dsa.h b/include/net/dsa.h
> index 96acb14ec1a8..541fb514e31d 100644
> --- a/include/net/dsa.h
> +++ b/include/net/dsa.h
> @@ -515,6 +515,8 @@ struct dsa_switch_ops {
>  				   bool ingress);
>  	void	(*port_mirror_del)(struct dsa_switch *ds, int port,
>  				   struct dsa_mall_mirror_tc_entry *mirror);
> +	int	(*port_setup_tc)(struct dsa_switch *ds, int port,
> +				 enum tc_setup_type type, void *type_data);
>  
>  	/*
>  	 * Cross-chip operations
> diff --git a/net/dsa/slave.c b/net/dsa/slave.c
> index 9a88035517a6..75d58229a4bd 100644
> --- a/net/dsa/slave.c
> +++ b/net/dsa/slave.c
> @@ -1035,12 +1035,16 @@ static int dsa_slave_setup_tc_block(struct net_device *dev,
>  static int dsa_slave_setup_tc(struct net_device *dev, enum tc_setup_type type,
>  			      void *type_data)
>  {
> -	switch (type) {
> -	case TC_SETUP_BLOCK:
> +	struct dsa_port *dp = dsa_slave_to_port(dev);
> +	struct dsa_switch *ds = dp->ds;
> +
> +	if (type == TC_SETUP_BLOCK)
>  		return dsa_slave_setup_tc_block(dev, type_data);
> -	default:
> +
> +	if (!ds->ops->port_setup_tc)
>  		return -EOPNOTSUPP;
> -	}
> +
> +	return ds->ops->port_setup_tc(ds, dp->index, type, type_data);
>  }
>  
>  static void dsa_slave_get_stats64(struct net_device *dev,
> -- 
> 2.17.1
> 

Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>

^ permalink raw reply

* [patch iproute2-next v2] devlink: add reload failed indication
From: Jiri Pirko @ 2019-09-16  9:44 UTC (permalink / raw)
  To: netdev; +Cc: dsahern, stephen, idosch, jakub.kicinski, tariqt, mlxsw

From: Jiri Pirko <jiri@mellanox.com>

Add indication about previous failed devlink reload.

Example outputs:

$ devlink dev
netdevsim/netdevsim10: reload_failed true
$ devlink dev -j -p
{
    "dev": {
        "netdevsim/netdevsim10": {
            "reload_failed": true
        }
    }
}

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
v1->v2:
- added patch description including example
---
 devlink/devlink.c | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/devlink/devlink.c b/devlink/devlink.c
index 15877a04f5d6..da62c144d5d5 100644
--- a/devlink/devlink.c
+++ b/devlink/devlink.c
@@ -450,6 +450,7 @@ static const enum mnl_attr_data_type devlink_policy[DEVLINK_ATTR_MAX + 1] = {
 	[DEVLINK_ATTR_TRAP_GENERIC] = MNL_TYPE_FLAG,
 	[DEVLINK_ATTR_TRAP_METADATA] = MNL_TYPE_NESTED,
 	[DEVLINK_ATTR_TRAP_GROUP_NAME] = MNL_TYPE_STRING,
+	[DEVLINK_ATTR_RELOAD_FAILED] = MNL_TYPE_U8,
 };
 
 static const enum mnl_attr_data_type
@@ -1949,11 +1950,6 @@ static void pr_out_region_chunk(struct dl *dl, uint8_t *data, uint32_t len,
 	pr_out_region_chunk_end(dl);
 }
 
-static void pr_out_dev(struct dl *dl, struct nlattr **tb)
-{
-	pr_out_handle(dl, tb);
-}
-
 static void pr_out_section_start(struct dl *dl, const char *name)
 {
 	if (dl->json_output) {
@@ -2649,11 +2645,23 @@ static int cmd_dev_show_cb(const struct nlmsghdr *nlh, void *data)
 	struct dl *dl = data;
 	struct nlattr *tb[DEVLINK_ATTR_MAX + 1] = {};
 	struct genlmsghdr *genl = mnl_nlmsg_get_payload(nlh);
+	uint8_t reload_failed = 0;
 
 	mnl_attr_parse(nlh, sizeof(*genl), attr_cb, tb);
 	if (!tb[DEVLINK_ATTR_BUS_NAME] || !tb[DEVLINK_ATTR_DEV_NAME])
 		return MNL_CB_ERROR;
-	pr_out_dev(dl, tb);
+
+	if (tb[DEVLINK_ATTR_RELOAD_FAILED])
+		reload_failed = mnl_attr_get_u8(tb[DEVLINK_ATTR_RELOAD_FAILED]);
+
+	if (reload_failed) {
+		__pr_out_handle_start(dl, tb, true, false);
+		pr_out_bool(dl, "reload_failed", true);
+		pr_out_handle_end(dl);
+	} else {
+		pr_out_handle(dl, tb);
+	}
+
 	return MNL_CB_OK;
 }
 
@@ -3991,7 +3999,7 @@ static int cmd_mon_show_cb(const struct nlmsghdr *nlh, void *data)
 		if (!tb[DEVLINK_ATTR_BUS_NAME] || !tb[DEVLINK_ATTR_DEV_NAME])
 			return MNL_CB_ERROR;
 		pr_out_mon_header(genl->cmd);
-		pr_out_dev(dl, tb);
+		pr_out_handle(dl, tb);
 		break;
 	case DEVLINK_CMD_PORT_GET: /* fall through */
 	case DEVLINK_CMD_PORT_SET: /* fall through */
-- 
2.21.0


^ permalink raw reply related

* Re: [PATCH v2 net-next 2/7] net: dsa: Pass ndo_setup_tc slave callback to drivers
From: Vladimir Oltean @ 2019-09-16  9:53 UTC (permalink / raw)
  To: Ilias Apalodimas
  Cc: Florian Fainelli, Vivien Didelot, Andrew Lunn, David S. Miller,
	Vinicius Costa Gomes, Patel, Vedang, Richard Cochran,
	Voon, Weifeng, jiri, m-karicheri2, Jose Abreu, Jamal Hadi Salim,
	Cong Wang, Kurt Kanzenbach, Joergen Andreasen, netdev
In-Reply-To: <20190916093108.GA28448@apalos.home>

Hi Ilias,

On Mon, 16 Sep 2019 at 12:31, Ilias Apalodimas
<ilias.apalodimas@linaro.org> wrote:
>
> Hi Vladimir,
>
> Yes fixes my request on the initial RFC. Sorry for the delayed response.
>
> On Sat, Sep 14, 2019 at 04:17:57AM +0300, Vladimir Oltean wrote:
> > DSA currently handles shared block filters (for the classifier-action
> > qdisc) in the core due to what I believe are simply pragmatic reasons -
> > hiding the complexity from drivers and offerring a simple API for port
> > mirroring.
> >
> > Extend the dsa_slave_setup_tc function by passing all other qdisc
> > offloads to the driver layer, where the driver may choose what it
> > implements and how. DSA is simply a pass-through in this case.
> >
> > Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
> > Acked-by: Kurt Kanzenbach <kurt@linutronix.de>
> > ---
> > Changes since v1:
> > - Added Kurt Kanzenbach's Acked-by.
> >
> > Changes since RFC:
> > - Removed the unused declaration of struct tc_taprio_qopt_offload.
> >
> >  include/net/dsa.h |  2 ++
> >  net/dsa/slave.c   | 12 ++++++++----
> >  2 files changed, 10 insertions(+), 4 deletions(-)
> >
> > diff --git a/include/net/dsa.h b/include/net/dsa.h
> > index 96acb14ec1a8..541fb514e31d 100644
> > --- a/include/net/dsa.h
> > +++ b/include/net/dsa.h
> > @@ -515,6 +515,8 @@ struct dsa_switch_ops {
> >                                  bool ingress);
> >       void    (*port_mirror_del)(struct dsa_switch *ds, int port,
> >                                  struct dsa_mall_mirror_tc_entry *mirror);
> > +     int     (*port_setup_tc)(struct dsa_switch *ds, int port,
> > +                              enum tc_setup_type type, void *type_data);
> >
> >       /*
> >        * Cross-chip operations
> > diff --git a/net/dsa/slave.c b/net/dsa/slave.c
> > index 9a88035517a6..75d58229a4bd 100644
> > --- a/net/dsa/slave.c
> > +++ b/net/dsa/slave.c
> > @@ -1035,12 +1035,16 @@ static int dsa_slave_setup_tc_block(struct net_device *dev,
> >  static int dsa_slave_setup_tc(struct net_device *dev, enum tc_setup_type type,
> >                             void *type_data)
> >  {
> > -     switch (type) {
> > -     case TC_SETUP_BLOCK:
> > +     struct dsa_port *dp = dsa_slave_to_port(dev);
> > +     struct dsa_switch *ds = dp->ds;
> > +
> > +     if (type == TC_SETUP_BLOCK)
> >               return dsa_slave_setup_tc_block(dev, type_data);
> > -     default:
> > +
> > +     if (!ds->ops->port_setup_tc)
> >               return -EOPNOTSUPP;
> > -     }
> > +
> > +     return ds->ops->port_setup_tc(ds, dp->index, type, type_data);
> >  }
> >
> >  static void dsa_slave_get_stats64(struct net_device *dev,
> > --
> > 2.17.1
> >
>
> Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>

Thanks. Could you add this Acked-by to the v4 email, just so we keep
the discussion on the latest submitted version?

-Vladimir

^ permalink raw reply

* Re: [PATCH v4 net-next 2/6] net: dsa: Pass ndo_setup_tc slave callback to drivers
From: Ilias Apalodimas @ 2019-09-16  9:56 UTC (permalink / raw)
  To: Vladimir Oltean
  Cc: f.fainelli, vivien.didelot, andrew, davem, vinicius.gomes,
	vedang.patel, richardcochran, weifeng.voon, jiri, m-karicheri2,
	jose.abreu, jhs, xiyou.wangcong, kurt.kanzenbach,
	joergen.andreasen, netdev
In-Reply-To: <20190915020003.27926-3-olteanv@gmail.com>

On Sun, Sep 15, 2019 at 04:59:59AM +0300, Vladimir Oltean wrote:
> DSA currently handles shared block filters (for the classifier-action
> qdisc) in the core due to what I believe are simply pragmatic reasons -
> hiding the complexity from drivers and offerring a simple API for port
> mirroring.
> 
> Extend the dsa_slave_setup_tc function by passing all other qdisc
> offloads to the driver layer, where the driver may choose what it
> implements and how. DSA is simply a pass-through in this case.
> 
> Signed-off-by: Vladimir Oltean <olteanv@gmail.com>
> Acked-by: Kurt Kanzenbach <kurt@linutronix.de>
> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
> ---
> Changes since v2:
> - Added Florian Fainelli's Reviewed-by.
> 
> Changes since v1:
> - Added Kurt Kanzenbach's Acked-by.
> 
> Changes since RFC:
> - Removed the unused declaration of struct tc_taprio_qopt_offload.
> 
>  include/net/dsa.h |  2 ++
>  net/dsa/slave.c   | 12 ++++++++----
>  2 files changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/include/net/dsa.h b/include/net/dsa.h
> index 96acb14ec1a8..541fb514e31d 100644
> --- a/include/net/dsa.h
> +++ b/include/net/dsa.h
> @@ -515,6 +515,8 @@ struct dsa_switch_ops {
>  				   bool ingress);
>  	void	(*port_mirror_del)(struct dsa_switch *ds, int port,
>  				   struct dsa_mall_mirror_tc_entry *mirror);
> +	int	(*port_setup_tc)(struct dsa_switch *ds, int port,
> +				 enum tc_setup_type type, void *type_data);
>  
>  	/*
>  	 * Cross-chip operations
> diff --git a/net/dsa/slave.c b/net/dsa/slave.c
> index 9a88035517a6..75d58229a4bd 100644
> --- a/net/dsa/slave.c
> +++ b/net/dsa/slave.c
> @@ -1035,12 +1035,16 @@ static int dsa_slave_setup_tc_block(struct net_device *dev,
>  static int dsa_slave_setup_tc(struct net_device *dev, enum tc_setup_type type,
>  			      void *type_data)
>  {
> -	switch (type) {
> -	case TC_SETUP_BLOCK:
> +	struct dsa_port *dp = dsa_slave_to_port(dev);
> +	struct dsa_switch *ds = dp->ds;
> +
> +	if (type == TC_SETUP_BLOCK)
>  		return dsa_slave_setup_tc_block(dev, type_data);
> -	default:
> +
> +	if (!ds->ops->port_setup_tc)
>  		return -EOPNOTSUPP;
> -	}
> +
> +	return ds->ops->port_setup_tc(ds, dp->index, type, type_data);
>  }
>  
>  static void dsa_slave_get_stats64(struct net_device *dev,
> -- 
> 2.17.1
> 

Acked-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>

^ permalink raw reply

* bpf-next is CLOSED
From: Daniel Borkmann @ 2019-09-16  9:59 UTC (permalink / raw)
  To: bpf; +Cc: netdev, alexei.starovoitov, davem

Only bug fixes from this point forward given the merge window is open.

Thanks everyone,
Daniel

^ permalink raw reply

* Re: macb: inconsistent Rx descriptor chain after OOM
From: Claudiu.Beznea @ 2019-09-16 10:00 UTC (permalink / raw)
  To: schwab, Nicolas.Ferre; +Cc: netdev
In-Reply-To: <mvm4l1chemx.fsf@suse.de>

Hi Andreas,

I will have a look on it. It would be good if you could give me some
details about the steps to reproduce it.

Thank you,
Claudiu Beznea

On 16.09.2019 10:41, Andreas Schwab wrote:
> When there is an OOM situation, the macb driver cannot recover from it:
> 
> [245622.872993] macb 10090000.ethernet eth0: Unable to allocate sk_buff
> [245622.891438] macb 10090000.ethernet eth0: inconsistent Rx descriptor chain
> 
> After that, the interface is dead.  Since this system is using NFS root,
> it then stalled as a whole.
> 
> Andreas.
> 

^ permalink raw reply

* Re: [patch iproute2-next v4 0/2] devlink: couple forgotten flash patches
From: Jiri Pirko @ 2019-09-16 10:09 UTC (permalink / raw)
  To: David Ahern; +Cc: netdev, stephen, jakub.kicinski, saeedm, mlxsw, f.fainelli
In-Reply-To: <7f32dc69-7cc1-4488-a1b6-94db64748630@gmail.com>

Sun, Sep 15, 2019 at 07:58:33PM CEST, dsahern@gmail.com wrote:
>On 9/14/19 12:00 AM, Jiri Pirko wrote:
>> Fri, Sep 13, 2019 at 07:25:07PM CEST, dsahern@gmail.com wrote:
>>> On 9/12/19 12:29 PM, Jiri Pirko wrote:
>>>> From: Jiri Pirko <jiri@mellanox.com>
>>>>
>>>> I was under impression they are already merged, but apparently they are
>>>> not. I just rebased them on top of current iproute2 net-next tree.
>>>>
>>>
>>> they were not forgotten; they were dropped asking for changes.
>>>
>>> thread is here:
>>> https://lore.kernel.org/netdev/20190604134450.2839-3-jiri@resnulli.us/
>> 
>> Well not really. The path was discussed in the thread. However, that is
>> unrelated to the changes these patches do. The flashing itself is
>> already there and present. These patches only add status.
>> 
>> Did I missed something?
>> 
>
>you are thinking like a kernel developer and not a user.
>
>The second patch has a man page change that should state that firmware
>files are expected to be in /lib/firmware and that path is added by the
>kernel so the path passed on the command line needs to drop that part.

The manpage change is just addition to the "EXAMPLES" section.
The fact that the file is expected to be in /lib/firmware is in the
devlink flash description right above:


   devlink dev flash - write device's non-volatile memory.
       DEV - specifies the devlink device to write to.

       file PATH - Path to the file which will be written into device's flash. The path needs to be relative to one of the directories
       searched by the kernel firmware loaded, such as /lib/firmware. <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

       component NAME - If device stores multiple firmware images in non-volatile memory, this parameter may be used to indicate which
       firmware image should be written.  The value of NAME should match the component names from devlink dev info and may be driver-
       dependent.

EXAMPLES
       devlink dev show
           Shows the state of all devlink devices on the system.

       devlink dev show pci/0000:01:00.0
           Shows the state of specified devlink device.

       devlink dev eswitch show pci/0000:01:00.0
           Shows the eswitch mode of specified devlink device.

       devlink dev eswitch set pci/0000:01:00.0 mode switchdev
           Sets the eswitch mode of specified devlink device to switchdev.

       devlink dev param show pci/0000:01:00.0 name max_macs
           Shows the parameter max_macs attributes.

       devlink dev param set pci/0000:01:00.0 name internal_error_reset value true cmode runtime
           Sets the parameter internal_error_reset of specified devlink device to true.

       devlink dev reload pci/0000:01:00.0
           Performs hot reload of specified devlink device.

       devlink dev flash pci/0000:01:00.0 file firmware.bin
           Flashes the specified devlink device with provided firmware file name. If the driver supports it, user gets updates about the
           flash status. For example:
           Preparing to flash
           Flashing 100%
           Flashing done


I don't understand what is that you need :(

^ permalink raw reply

* Re: macb: inconsistent Rx descriptor chain after OOM
From: Andreas Schwab @ 2019-09-16 10:14 UTC (permalink / raw)
  To: Claudiu.Beznea; +Cc: Nicolas.Ferre, netdev
In-Reply-To: <51458d2e-69a5-2a30-2167-7f47a43d9a2f@microchip.com>

On Sep 16 2019, <Claudiu.Beznea@microchip.com> wrote:

> I will have a look on it. It would be good if you could give me some
> details about the steps to reproduce it.

You need to trigger OOM.

Andreas.

-- 
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."

^ permalink raw reply

* [PATCH net] net/sched: cls_api: Fix nooffloaddevcnt counter in indr block call success
From: wenxu @ 2019-09-16 10:15 UTC (permalink / raw)
  To: davem; +Cc: netdev

From: wenxu <wenxu@ucloud.cn>

When a block bind with a dev which support indr block call(vxlan/gretap
device). It can bind success but with nooffloaddevcnt++. It will fail
when replace the hw filter in tc_setup_cb_call with skip_sw mode for
checkout the nooffloaddevcnt and skip_sw.

if (block->nooffloaddevcnt && err_stop)
	return -EOPNOTSUPP;

So with this patch, if the indr block call success, it will not modify
the nooffloaddevcnt counter.

Fixes: 7f76fa36754b ("net: sched: register callbacks for indirect tc block binds")
Signed-off-by: wenxu <wenxu@ucloud.cn>
---
 net/sched/cls_api.c | 27 +++++++++++++++------------
 1 file changed, 15 insertions(+), 12 deletions(-)

diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index efd3cfb..8a1e3a5 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -766,10 +766,10 @@ void tc_indr_block_cb_unregister(struct net_device *dev,
 }
 EXPORT_SYMBOL_GPL(tc_indr_block_cb_unregister);
 
-static void tc_indr_block_call(struct tcf_block *block, struct net_device *dev,
-			       struct tcf_block_ext_info *ei,
-			       enum flow_block_command command,
-			       struct netlink_ext_ack *extack)
+static int tc_indr_block_call(struct tcf_block *block, struct net_device *dev,
+			      struct tcf_block_ext_info *ei,
+			      enum flow_block_command command,
+			      struct netlink_ext_ack *extack)
 {
 	struct tc_indr_block_cb *indr_block_cb;
 	struct tc_indr_block_dev *indr_dev;
@@ -785,7 +785,7 @@ static void tc_indr_block_call(struct tcf_block *block, struct net_device *dev,
 
 	indr_dev = tc_indr_block_dev_lookup(dev);
 	if (!indr_dev)
-		return;
+		return -ENOENT;
 
 	indr_dev->block = command == FLOW_BLOCK_BIND ? block : NULL;
 
@@ -793,7 +793,10 @@ static void tc_indr_block_call(struct tcf_block *block, struct net_device *dev,
 		indr_block_cb->cb(dev, indr_block_cb->cb_priv, TC_SETUP_BLOCK,
 				  &bo);
 
-	tcf_block_setup(block, &bo);
+	if (list_empty(&bo.cb_list))
+		return -EOPNOTSUPP;
+
+	return tcf_block_setup(block, &bo);
 }
 
 static bool tcf_block_offload_in_use(struct tcf_block *block)
@@ -849,14 +852,14 @@ static int tcf_block_offload_bind(struct tcf_block *block, struct Qdisc *q,
 	if (err)
 		return err;
 
-	tc_indr_block_call(block, dev, ei, FLOW_BLOCK_BIND, extack);
 	return 0;
 
 no_offload_dev_inc:
 	if (tcf_block_offload_in_use(block))
 		return -EOPNOTSUPP;
-	block->nooffloaddevcnt++;
-	tc_indr_block_call(block, dev, ei, FLOW_BLOCK_BIND, extack);
+	err = tc_indr_block_call(block, dev, ei, FLOW_BLOCK_BIND, extack);
+	if (err)
+		block->nooffloaddevcnt++;
 	return 0;
 }
 
@@ -866,8 +869,6 @@ static void tcf_block_offload_unbind(struct tcf_block *block, struct Qdisc *q,
 	struct net_device *dev = q->dev_queue->dev;
 	int err;
 
-	tc_indr_block_call(block, dev, ei, FLOW_BLOCK_UNBIND, NULL);
-
 	if (!dev->netdev_ops->ndo_setup_tc)
 		goto no_offload_dev_dec;
 	err = tcf_block_offload_cmd(block, dev, ei, FLOW_BLOCK_UNBIND, NULL);
@@ -876,7 +877,9 @@ static void tcf_block_offload_unbind(struct tcf_block *block, struct Qdisc *q,
 	return;
 
 no_offload_dev_dec:
-	WARN_ON(block->nooffloaddevcnt-- == 0);
+	err = tc_indr_block_call(block, dev, ei, FLOW_BLOCK_UNBIND, NULL);
+	if (err)
+		WARN_ON(block->nooffloaddevcnt-- == 0);
 }
 
 static int
-- 
1.8.3.1


^ permalink raw reply related

* Re: macb: inconsistent Rx descriptor chain after OOM
From: Claudiu.Beznea @ 2019-09-16 10:16 UTC (permalink / raw)
  To: schwab; +Cc: Nicolas.Ferre, netdev
In-Reply-To: <mvmmuf4fszw.fsf@suse.de>



On 16.09.2019 13:14, Andreas Schwab wrote:
> External E-Mail
> 
> 
> On Sep 16 2019, <Claudiu.Beznea@microchip.com> wrote:
> 
>> I will have a look on it. It would be good if you could give me some
>> details about the steps to reproduce it.
> 
> You need to trigger OOM.

Ok, thank you!

> 
> Andreas.
> 

^ permalink raw reply

* INFO: task hung in cancel_delayed_work_sync
From: syzbot @ 2019-09-16 10:19 UTC (permalink / raw)
  To: ast, aviadye, borisp, bpf, daniel, davejwatson, davem, ilyal,
	jakub.kicinski, john.fastabend, kafai, linux-crypto, linux-kernel,
	netdev, songliubraving, steffen.klassert, syzkaller-bugs, yhs

Hello,

syzbot found the following crash on:

HEAD commit:    f4b752a6 mlx4: fix spelling mistake "veify" -> "verify"
git tree:       net
console output: https://syzkaller.appspot.com/x/log.txt?x=1183c7fa600000
kernel config:  https://syzkaller.appspot.com/x/.config?x=b89bb446a3faaba4
dashboard link: https://syzkaller.appspot.com/bug?extid=f39ab8494f6015e62360
compiler:       gcc (GCC) 9.0.0 20181231 (experimental)
syz repro:      https://syzkaller.appspot.com/x/repro.syz?x=14426d85600000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=110c1af1600000

The bug was bisected to:

commit 3c4d7559159bfe1e3b94df3a657b2cda3a34e218
Author: Dave Watson <davejwatson@fb.com>
Date:   Wed Jun 14 18:37:39 2017 +0000

     tls: kernel TLS support

bisection log:  https://syzkaller.appspot.com/x/bisect.txt?x=144a4ffa600000
final crash:    https://syzkaller.appspot.com/x/report.txt?x=164a4ffa600000
console output: https://syzkaller.appspot.com/x/log.txt?x=124a4ffa600000

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+f39ab8494f6015e62360@syzkaller.appspotmail.com
Fixes: 3c4d7559159b ("tls: kernel TLS support")

INFO: task syz-executor279:9995 blocked for more than 143 seconds.
       Not tainted 5.3.0-rc7+ #0
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
syz-executor279 D24264  9995   9994 0x00000000
Call Trace:
  context_switch kernel/sched/core.c:3254 [inline]
  __schedule+0x755/0x1580 kernel/sched/core.c:3880
  schedule+0xd9/0x260 kernel/sched/core.c:3947
  schedule_timeout+0x717/0xc50 kernel/time/timer.c:1783
  do_wait_for_common kernel/sched/completion.c:83 [inline]
  __wait_for_common kernel/sched/completion.c:104 [inline]
  wait_for_common kernel/sched/completion.c:115 [inline]
  wait_for_completion+0x29c/0x440 kernel/sched/completion.c:136
  __flush_work+0x508/0xa50 kernel/workqueue.c:3040
  __cancel_work_timer+0x3d9/0x540 kernel/workqueue.c:3127
  cancel_delayed_work_sync+0x1b/0x20 kernel/workqueue.c:3259
  tls_sw_cancel_work_tx+0x68/0x80 net/tls/tls_sw.c:2063
  tls_sk_proto_close+0x4ac/0x990 net/tls/tls_main.c:299
  inet_release+0xed/0x200 net/ipv4/af_inet.c:427
  inet6_release+0x53/0x80 net/ipv6/af_inet6.c:470
  __sock_release+0xce/0x280 net/socket.c:590
  sock_close+0x1e/0x30 net/socket.c:1268
  __fput+0x2ff/0x890 fs/file_table.c:280
  ____fput+0x16/0x20 fs/file_table.c:313
  task_work_run+0x145/0x1c0 kernel/task_work.c:113
  tracehook_notify_resume include/linux/tracehook.h:188 [inline]
  exit_to_usermode_loop+0x316/0x380 arch/x86/entry/common.c:163
  prepare_exit_to_usermode arch/x86/entry/common.c:194 [inline]
  syscall_return_slowpath arch/x86/entry/common.c:274 [inline]
  do_syscall_64+0x5a9/0x6a0 arch/x86/entry/common.c:299
  entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x401f40
Code: ff ff ff 25 62 63 20 00 68 08 00 00 00 e9 60 ff ff ff ff 25 5a 63 20  
00 68 09 00 00 00 e9 50 ff ff ff ff 25 52 63 20 00 68 0a <00> 00 00 e9 40  
ff ff ff ff 25 4a 63 20 00 68 0b 00 00 00 e9 30 ff
RSP: 002b:00007fffd8200d58 EFLAGS: 00000246 ORIG_RAX: 0000000000000003
RAX: 0000000000000000 RBX: 0000000000000005 RCX: 0000000000401f40
RDX: ffffffffffffffc1 RSI: 1201000000003618 RDI: 0000000000000004
RBP: 00007fffd8200d70 R08: 0000000000000000 R09: 1201000000003618
R10: 0000000000000000 R11: 0000000000000246 R12: 0000000000000000
R13: 0000000000403170 R14: 0000000000000000 R15: 0000000000000000
INFO: lockdep is turned off.
NMI backtrace for cpu 1
CPU: 1 PID: 1057 Comm: khungtaskd Not tainted 5.3.0-rc7+ #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS  
Google 01/01/2011
Call Trace:
  __dump_stack lib/dump_stack.c:77 [inline]
  dump_stack+0x172/0x1f0 lib/dump_stack.c:113
  nmi_cpu_backtrace.cold+0x70/0xb2 lib/nmi_backtrace.c:101
  nmi_trigger_cpumask_backtrace+0x23b/0x28b lib/nmi_backtrace.c:62
  arch_trigger_cpumask_backtrace+0x14/0x20 arch/x86/kernel/apic/hw_nmi.c:38
  trigger_all_cpu_backtrace include/linux/nmi.h:146 [inline]
  check_hung_uninterruptible_tasks kernel/hung_task.c:205 [inline]
  watchdog+0x9d0/0xef0 kernel/hung_task.c:289
  kthread+0x361/0x430 kernel/kthread.c:255
  ret_from_fork+0x24/0x30 arch/x86/entry/entry_64.S:352
Sending NMI from CPU 1 to CPUs 0:
NMI backtrace for cpu 0 skipped: idling at native_safe_halt+0xe/0x10  
arch/x86/include/asm/irqflags.h:60


---
This bug is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzkaller@googlegroups.com.

syzbot will keep track of this bug report. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
For information about bisection process see: https://goo.gl/tpsmEJ#bisection
syzbot can test patches for this bug, for details see:
https://goo.gl/tpsmEJ#testing-patches

^ permalink raw reply

* Re: [PATCH net] net/sched: cls_api: Fix nooffloaddevcnt counter in indr block call success
From: Jiri Pirko @ 2019-09-16 10:28 UTC (permalink / raw)
  To: wenxu; +Cc: davem, netdev
In-Reply-To: <1568628934-32085-1-git-send-email-wenxu@ucloud.cn>

Please use get_maintainers script to get list of ccs.

Mon, Sep 16, 2019 at 12:15:34PM CEST, wenxu@ucloud.cn wrote:
>From: wenxu <wenxu@ucloud.cn>
>
>When a block bind with a dev which support indr block call(vxlan/gretap
>device). It can bind success but with nooffloaddevcnt++. It will fail
>when replace the hw filter in tc_setup_cb_call with skip_sw mode for
>checkout the nooffloaddevcnt and skip_sw.

I read this paragraph 5 times, I still don't understand :( Could you
please re-phrase?


>
>if (block->nooffloaddevcnt && err_stop)
>	return -EOPNOTSUPP;
>
>So with this patch, if the indr block call success, it will not modify
>the nooffloaddevcnt counter.
>
>Fixes: 7f76fa36754b ("net: sched: register callbacks for indirect tc block binds")
>Signed-off-by: wenxu <wenxu@ucloud.cn>
>---
> net/sched/cls_api.c | 27 +++++++++++++++------------
> 1 file changed, 15 insertions(+), 12 deletions(-)
>
>diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
>index efd3cfb..8a1e3a5 100644
>--- a/net/sched/cls_api.c
>+++ b/net/sched/cls_api.c
>@@ -766,10 +766,10 @@ void tc_indr_block_cb_unregister(struct net_device *dev,
> }
> EXPORT_SYMBOL_GPL(tc_indr_block_cb_unregister);
> 
>-static void tc_indr_block_call(struct tcf_block *block, struct net_device *dev,
>-			       struct tcf_block_ext_info *ei,
>-			       enum flow_block_command command,
>-			       struct netlink_ext_ack *extack)
>+static int tc_indr_block_call(struct tcf_block *block, struct net_device *dev,
>+			      struct tcf_block_ext_info *ei,
>+			      enum flow_block_command command,
>+			      struct netlink_ext_ack *extack)
> {
> 	struct tc_indr_block_cb *indr_block_cb;
> 	struct tc_indr_block_dev *indr_dev;
>@@ -785,7 +785,7 @@ static void tc_indr_block_call(struct tcf_block *block, struct net_device *dev,
> 
> 	indr_dev = tc_indr_block_dev_lookup(dev);
> 	if (!indr_dev)
>-		return;
>+		return -ENOENT;
> 
> 	indr_dev->block = command == FLOW_BLOCK_BIND ? block : NULL;
> 
>@@ -793,7 +793,10 @@ static void tc_indr_block_call(struct tcf_block *block, struct net_device *dev,
> 		indr_block_cb->cb(dev, indr_block_cb->cb_priv, TC_SETUP_BLOCK,
> 				  &bo);
> 
>-	tcf_block_setup(block, &bo);
>+	if (list_empty(&bo.cb_list))
>+		return -EOPNOTSUPP;

How is this part related to the rest of the patch?

>+
>+	return tcf_block_setup(block, &bo);
> }
> 
> static bool tcf_block_offload_in_use(struct tcf_block *block)
>@@ -849,14 +852,14 @@ static int tcf_block_offload_bind(struct tcf_block *block, struct Qdisc *q,
> 	if (err)
> 		return err;
> 
>-	tc_indr_block_call(block, dev, ei, FLOW_BLOCK_BIND, extack);
> 	return 0;
> 
> no_offload_dev_inc:
> 	if (tcf_block_offload_in_use(block))
> 		return -EOPNOTSUPP;
>-	block->nooffloaddevcnt++;
>-	tc_indr_block_call(block, dev, ei, FLOW_BLOCK_BIND, extack);
>+	err = tc_indr_block_call(block, dev, ei, FLOW_BLOCK_BIND, extack);
>+	if (err)
>+		block->nooffloaddevcnt++;
> 	return 0;
> }
> 
>@@ -866,8 +869,6 @@ static void tcf_block_offload_unbind(struct tcf_block *block, struct Qdisc *q,
> 	struct net_device *dev = q->dev_queue->dev;
> 	int err;
> 
>-	tc_indr_block_call(block, dev, ei, FLOW_BLOCK_UNBIND, NULL);
>-
> 	if (!dev->netdev_ops->ndo_setup_tc)
> 		goto no_offload_dev_dec;
> 	err = tcf_block_offload_cmd(block, dev, ei, FLOW_BLOCK_UNBIND, NULL);
>@@ -876,7 +877,9 @@ static void tcf_block_offload_unbind(struct tcf_block *block, struct Qdisc *q,
> 	return;
> 
> no_offload_dev_dec:
>-	WARN_ON(block->nooffloaddevcnt-- == 0);
>+	err = tc_indr_block_call(block, dev, ei, FLOW_BLOCK_UNBIND, NULL);
>+	if (err)
>+		WARN_ON(block->nooffloaddevcnt-- == 0);
> }
> 
> static int
>-- 
>1.8.3.1
>

^ permalink raw reply

* Re: ss: Checking selected network ports
From: Markus Elfring @ 2019-09-16 10:32 UTC (permalink / raw)
  To: David Miller, David Ahern, Stephen Hemminger, netdev
  Cc: Josh Hunt, linux-kernel, kernel-janitors
In-Reply-To: <20190601.164838.1496580524715275443.davem@davemloft.net>

> If you use netlink operations directly, you can have the kernel filter
> on various criteria and only get the socket entries you are interested in.

I suggest to take another look at software design options.


> This whole discussion has zero to do with what text format 'ss' outputs.

Is there a need to improve the software documentation any further?

Which programming interface should be used to check the receive queue
for a single port (without retrieving more network data before)?

Regards,
Markus

^ permalink raw reply

* [PATCH v3 bpf-next 04/14] samples: bpf: use own EXTRA_CFLAGS for clang commands
From: Ivan Khoronzhuk @ 2019-09-16 10:54 UTC (permalink / raw)
  To: ast, daniel, yhs, davem, jakub.kicinski, hawk, john.fastabend
  Cc: linux-kernel, netdev, bpf, clang-built-linux, sergei.shtylyov,
	Ivan Khoronzhuk
In-Reply-To: <20190916105433.11404-1-ivan.khoronzhuk@linaro.org>

It can overlap with CFLAGS used for libraries built with gcc if
not now then in next patches. Correct it here for simplicity.

Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
---
 samples/bpf/Makefile | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
index b59e77e2250e..8ecc5d0c2d5b 100644
--- a/samples/bpf/Makefile
+++ b/samples/bpf/Makefile
@@ -218,10 +218,10 @@ BTF_LLVM_PROBE := $(shell echo "int main() { return 0; }" | \
 			  /bin/rm -f ./llvm_btf_verify.o)
 
 ifneq ($(BTF_LLVM_PROBE),)
-	EXTRA_CFLAGS += -g
+	CLANG_EXTRA_CFLAGS += -g
 else
 ifneq ($(and $(BTF_LLC_PROBE),$(BTF_PAHOLE_PROBE),$(BTF_OBJCOPY_PROBE)),)
-	EXTRA_CFLAGS += -g
+	CLANG_EXTRA_CFLAGS += -g
 	LLC_FLAGS += -mattr=dwarfris
 	DWARF2BTF = y
 endif
@@ -280,8 +280,8 @@ $(obj)/hbm_edt_kern.o: $(src)/hbm.h $(src)/hbm_kern.h
 # useless for BPF samples.
 $(obj)/%.o: $(src)/%.c
 	@echo "  CLANG-bpf " $@
-	$(Q)$(CLANG) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(EXTRA_CFLAGS) -I$(obj) \
-		-I$(srctree)/tools/testing/selftests/bpf/ \
+	$(Q)$(CLANG) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(CLANG_EXTRA_CFLAGS) \
+		-I$(obj) -I$(srctree)/tools/testing/selftests/bpf/ \
 		-D__KERNEL__ -D__BPF_TRACING__ -Wno-unused-value -Wno-pointer-sign \
 		-D__TARGET_ARCH_$(SRCARCH) -Wno-compare-distinct-pointer-types \
 		-Wno-gnu-variable-sized-type-not-at-end \
-- 
2.17.1


^ permalink raw reply related

* [PATCH v3 bpf-next 08/14] samples: bpf: makefile: base target programs rules on Makefile.target
From: Ivan Khoronzhuk @ 2019-09-16 10:54 UTC (permalink / raw)
  To: ast, daniel, yhs, davem, jakub.kicinski, hawk, john.fastabend
  Cc: linux-kernel, netdev, bpf, clang-built-linux, sergei.shtylyov,
	Ivan Khoronzhuk
In-Reply-To: <20190916105433.11404-1-ivan.khoronzhuk@linaro.org>

The main reason for that - HOSTCC and CC have different aims.
HOSTCC is used to build programs running on host, that can
cross-comple target programs with CC. It was tested for arm and arm64
cross compilation, based on linaro toolchain, but should work for
others.

So, in order to split cross compilation (CC) with host build (HOSTCC),
lets base samples on Makefile.target. It allows to cross-compile
samples/bpf programs with CC while auxialry tools running on host
built with HOSTCC.

Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
---
 samples/bpf/Makefile | 135 ++++++++++++++++++++++---------------------
 1 file changed, 69 insertions(+), 66 deletions(-)

diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
index 9d923546e087..1579cc16a1c2 100644
--- a/samples/bpf/Makefile
+++ b/samples/bpf/Makefile
@@ -4,55 +4,53 @@ BPF_SAMPLES_PATH ?= $(abspath $(srctree)/$(src))
 TOOLS_PATH := $(BPF_SAMPLES_PATH)/../../tools
 
 # List of programs to build
-hostprogs-y := test_lru_dist
-hostprogs-y += sock_example
-hostprogs-y += fds_example
-hostprogs-y += sockex1
-hostprogs-y += sockex2
-hostprogs-y += sockex3
-hostprogs-y += tracex1
-hostprogs-y += tracex2
-hostprogs-y += tracex3
-hostprogs-y += tracex4
-hostprogs-y += tracex5
-hostprogs-y += tracex6
-hostprogs-y += tracex7
-hostprogs-y += test_probe_write_user
-hostprogs-y += trace_output
-hostprogs-y += lathist
-hostprogs-y += offwaketime
-hostprogs-y += spintest
-hostprogs-y += map_perf_test
-hostprogs-y += test_overhead
-hostprogs-y += test_cgrp2_array_pin
-hostprogs-y += test_cgrp2_attach
-hostprogs-y += test_cgrp2_sock
-hostprogs-y += test_cgrp2_sock2
-hostprogs-y += xdp1
-hostprogs-y += xdp2
-hostprogs-y += xdp_router_ipv4
-hostprogs-y += test_current_task_under_cgroup
-hostprogs-y += trace_event
-hostprogs-y += sampleip
-hostprogs-y += tc_l2_redirect
-hostprogs-y += lwt_len_hist
-hostprogs-y += xdp_tx_iptunnel
-hostprogs-y += test_map_in_map
-hostprogs-y += per_socket_stats_example
-hostprogs-y += xdp_redirect
-hostprogs-y += xdp_redirect_map
-hostprogs-y += xdp_redirect_cpu
-hostprogs-y += xdp_monitor
-hostprogs-y += xdp_rxq_info
-hostprogs-y += syscall_tp
-hostprogs-y += cpustat
-hostprogs-y += xdp_adjust_tail
-hostprogs-y += xdpsock
-hostprogs-y += xdp_fwd
-hostprogs-y += task_fd_query
-hostprogs-y += xdp_sample_pkts
-hostprogs-y += ibumad
-hostprogs-y += hbm
+tprogs-y := test_lru_dist
+tprogs-y += sock_example
+tprogs-y += fds_example
+tprogs-y += sockex1
+tprogs-y += sockex2
+tprogs-y += sockex3
+tprogs-y += tracex1
+tprogs-y += tracex2
+tprogs-y += tracex3
+tprogs-y += tracex4
+tprogs-y += tracex5
+tprogs-y += tracex6
+tprogs-y += tracex7
+tprogs-y += test_probe_write_user
+tprogs-y += trace_output
+tprogs-y += lathist
+tprogs-y += offwaketime
+tprogs-y += spintest
+tprogs-y += map_perf_test
+tprogs-y += test_overhead
+tprogs-y += test_cgrp2_array_pin
+tprogs-y += test_cgrp2_attach
+tprogs-y += test_cgrp2_sock
+tprogs-y += test_cgrp2_sock2
+tprogs-y += xdp1
+tprogs-y += xdp2
+tprogs-y += xdp_router_ipv4
+tprogs-y += test_current_task_under_cgroup
+tprogs-y += trace_event
+tprogs-y += sampleip
+tprogs-y += tc_l2_redirect
+tprogs-y += lwt_len_hist
+tprogs-y += xdp_tx_iptunnel
+tprogs-y += test_map_in_map
+tprogs-y += xdp_redirect_map
+tprogs-y += xdp_redirect_cpu
+tprogs-y += xdp_monitor
+tprogs-y += xdp_rxq_info
+tprogs-y += syscall_tp
+tprogs-y += cpustat
+tprogs-y += xdp_adjust_tail
+tprogs-y += xdpsock
+tprogs-y += xdp_fwd
+tprogs-y += task_fd_query
+tprogs-y += xdp_sample_pkts
+tprogs-y += ibumad
+tprogs-y += hbm
 
 # Libbpf dependencies
 LIBBPF = $(TOOLS_PATH)/lib/bpf/libbpf.a
@@ -111,7 +109,7 @@ ibumad-objs := bpf_load.o ibumad_user.o $(TRACE_HELPERS)
 hbm-objs := bpf_load.o hbm.o $(CGROUP_HELPERS)
 
 # Tell kbuild to always build the programs
-always := $(hostprogs-y)
+always := $(tprogs-y)
 always += sockex1_kern.o
 always += sockex2_kern.o
 always += sockex3_kern.o
@@ -170,21 +168,6 @@ always += ibumad_kern.o
 always += hbm_out_kern.o
 always += hbm_edt_kern.o
 
-KBUILD_HOSTCFLAGS += -I$(objtree)/usr/include
-KBUILD_HOSTCFLAGS += -I$(srctree)/tools/lib/bpf/
-KBUILD_HOSTCFLAGS += -I$(srctree)/tools/testing/selftests/bpf/
-KBUILD_HOSTCFLAGS += -I$(srctree)/tools/lib/ -I$(srctree)/tools/include
-KBUILD_HOSTCFLAGS += -I$(srctree)/tools/perf
-
-HOSTCFLAGS_bpf_load.o += -Wno-unused-variable
-
-KBUILD_HOSTLDLIBS		+= $(LIBBPF) -lelf
-HOSTLDLIBS_tracex4		+= -lrt
-HOSTLDLIBS_trace_output	+= -lrt
-HOSTLDLIBS_map_perf_test	+= -lrt
-HOSTLDLIBS_test_overhead	+= -lrt
-HOSTLDLIBS_xdpsock		+= -pthread
-
 ifeq ($(ARCH), arm)
 # Strip all except -D__LINUX_ARM_ARCH__ option needed to handle linux
 # headers when arm instruction set identification is requested.
@@ -192,9 +175,27 @@ ARM_ARCH_SELECTOR = $(shell echo "$(KBUILD_CFLAGS) " | \
 		    sed 's/[[:blank:]]/\n/g' | sed '/^-D__LINUX_ARM_ARCH__/!d')
 
 CLANG_EXTRA_CFLAGS := $(ARM_ARCH_SELECTOR)
-KBUILD_HOSTCFLAGS := $(ARM_ARCH_SELECTOR)
+TPROGS_CFLAGS += $(ARM_ARCH_SELECTOR)
 endif
 
+TPROGS_LDLIBS := $(KBUILD_HOSTLDLIBS)
+TPROGS_CFLAGS += $(KBUILD_HOSTCFLAGS) $(HOST_EXTRACFLAGS)
+TPROGS_CFLAGS += -I$(objtree)/usr/include
+TPROGS_CFLAGS += -I$(srctree)/tools/lib/bpf/
+TPROGS_CFLAGS += -I$(srctree)/tools/testing/selftests/bpf/
+TPROGS_CFLAGS += -I$(srctree)/tools/lib/
+TPROGS_CFLAGS += -I$(srctree)/tools/include
+TPROGS_CFLAGS += -I$(srctree)/tools/perf
+
+TPROGCFLAGS_bpf_load.o += -Wno-unused-variable
+
+TPROGS_LDLIBS			+= $(LIBBPF) -lelf
+TPROGLDLIBS_tracex4		+= -lrt
+TPROGLDLIBS_trace_output	+= -lrt
+TPROGLDLIBS_map_perf_test	+= -lrt
+TPROGLDLIBS_test_overhead	+= -lrt
+TPROGLDLIBS_xdpsock		+= -pthread
+
 # Allows pointing LLC/CLANG to a LLVM backend with bpf support, redefine on cmdline:
 #  make samples/bpf/ LLC=~/git/llvm/build/bin/llc CLANG=~/git/llvm/build/bin/clang
 LLC ?= llc
@@ -285,6 +286,8 @@ $(obj)/hbm_out_kern.o: $(src)/hbm.h $(src)/hbm_kern.h
 $(obj)/hbm.o: $(src)/hbm.h
 $(obj)/hbm_edt_kern.o: $(src)/hbm.h $(src)/hbm_kern.h
 
+-include $(BPF_SAMPLES_PATH)/Makefile.target
+
 # asm/sysreg.h - inline assembly used by it is incompatible with llvm.
 # But, there is no easy way to fix it, so just exclude it since it is
 # useless for BPF samples.
-- 
2.17.1


^ permalink raw reply related

* [PATCH v3 bpf-next 10/14] samples: bpf: makefile: use target CC environment for HDR_PROBE
From: Ivan Khoronzhuk @ 2019-09-16 10:54 UTC (permalink / raw)
  To: ast, daniel, yhs, davem, jakub.kicinski, hawk, john.fastabend
  Cc: linux-kernel, netdev, bpf, clang-built-linux, sergei.shtylyov,
	Ivan Khoronzhuk
In-Reply-To: <20190916105433.11404-1-ivan.khoronzhuk@linaro.org>

No need in hacking HOSTCC to be cross-compiler any more, so drop
this trick and use target CC for HDR_PROBE.

Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
---
 samples/bpf/Makefile | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
index b5c87a8b8b51..18ec22e7b444 100644
--- a/samples/bpf/Makefile
+++ b/samples/bpf/Makefile
@@ -214,15 +214,14 @@ BTF_PAHOLE ?= pahole
 
 # Detect that we're cross compiling and use the cross compiler
 ifdef CROSS_COMPILE
-HOSTCC = $(CROSS_COMPILE)gcc
 CLANG_ARCH_ARGS = --target=$(notdir $(CROSS_COMPILE:%-=%))
 endif
 
 # Don't evaluate probes and warnings if we need to run make recursively
 ifneq ($(src),)
 HDR_PROBE := $(shell printf "\#include <linux/types.h>\n struct list_head { int a; }; int main() { return 0; }" | \
-	$(HOSTCC) $(KBUILD_HOSTCFLAGS) -x c - -o /dev/null 2>/dev/null && \
-	echo okay)
+	$(CC) $(TPROGS_CFLAGS) $(TPROGS_LDFLAGS) -x c - \
+	-o /dev/null 2>/dev/null && echo okay)
 
 ifeq ($(HDR_PROBE),)
 $(warning WARNING: Detected possible issues with include path.)
-- 
2.17.1


^ permalink raw reply related

* [PATCH v3 bpf-next 09/14] samples: bpf: makefile: use own flags but not host when cross compile
From: Ivan Khoronzhuk @ 2019-09-16 10:54 UTC (permalink / raw)
  To: ast, daniel, yhs, davem, jakub.kicinski, hawk, john.fastabend
  Cc: linux-kernel, netdev, bpf, clang-built-linux, sergei.shtylyov,
	Ivan Khoronzhuk
In-Reply-To: <20190916105433.11404-1-ivan.khoronzhuk@linaro.org>

While compile natively, the hosts cflags and ldflags are equal to ones
used from HOSTCFLAGS and HOSTLDFLAGS. When cross compiling it should
have own, used for target arch. While verification, for arm, arm64 and
x86_64 the following flags were used alsways:

-Wall
-O2
-fomit-frame-pointer
-Wmissing-prototypes
-Wstrict-prototypes

So, add them as they were verified and used before adding
Makefile.target, but anyway limit it only for cross compile options as
for host can be some configurations when another options can be used,
So, for host arch samples left all as is, it allows to avoid potential
option mistmatches for existent environments.

Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
---
 samples/bpf/Makefile | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
index 1579cc16a1c2..b5c87a8b8b51 100644
--- a/samples/bpf/Makefile
+++ b/samples/bpf/Makefile
@@ -178,8 +178,17 @@ CLANG_EXTRA_CFLAGS := $(ARM_ARCH_SELECTOR)
 TPROGS_CFLAGS += $(ARM_ARCH_SELECTOR)
 endif
 
+ifdef CROSS_COMPILE
+TPROGS_CFLAGS += -Wall
+TPROGS_CFLAGS += -O2
+TPROGS_CFLAGS += -fomit-frame-pointer
+TPROGS_CFLAGS += -Wmissing-prototypes
+TPROGS_CFLAGS += -Wstrict-prototypes
+else
 TPROGS_LDLIBS := $(KBUILD_HOSTLDLIBS)
 TPROGS_CFLAGS += $(KBUILD_HOSTCFLAGS) $(HOST_EXTRACFLAGS)
+endif
+
 TPROGS_CFLAGS += -I$(objtree)/usr/include
 TPROGS_CFLAGS += -I$(srctree)/tools/lib/bpf/
 TPROGS_CFLAGS += -I$(srctree)/tools/testing/selftests/bpf/
-- 
2.17.1


^ permalink raw reply related

* [PATCH v3 bpf-next 14/14] samples: bpf: README: add preparation steps and sysroot info
From: Ivan Khoronzhuk @ 2019-09-16 10:54 UTC (permalink / raw)
  To: ast, daniel, yhs, davem, jakub.kicinski, hawk, john.fastabend
  Cc: linux-kernel, netdev, bpf, clang-built-linux, sergei.shtylyov,
	Ivan Khoronzhuk
In-Reply-To: <20190916105433.11404-1-ivan.khoronzhuk@linaro.org>

Add couple preparation steps: clean and configuration. Also add newly
added sysroot support info to cross-compile section.
---
 samples/bpf/README.rst | 41 ++++++++++++++++++++++++++++++++++++-----
 1 file changed, 36 insertions(+), 5 deletions(-)

diff --git a/samples/bpf/README.rst b/samples/bpf/README.rst
index 5f27e4faca50..d5845d73ab7d 100644
--- a/samples/bpf/README.rst
+++ b/samples/bpf/README.rst
@@ -14,6 +14,20 @@ Compiling requires having installed:
 Note that LLVM's tool 'llc' must support target 'bpf', list version
 and supported targets with command: ``llc --version``
 
+Clean and configuration
+-----------------------
+
+It can be needed to clean tools, samples or kernel before trying new arch or
+after some changes (on demand)::
+
+ make -C tools clean
+ make -C samples/bpf clean
+ make clean
+
+Configure kernel, defconfig for instance::
+
+ make defconfig
+
 Kernel headers
 --------------
 
@@ -68,9 +82,26 @@ It is also possible to point make to the newly compiled 'llc' or
 Cross compiling samples
 -----------------------
 In order to cross-compile, say for arm64 targets, export CROSS_COMPILE and ARCH
-environment variables before calling make. This will direct make to build
-samples for the cross target.
+environment variables before calling make. But do this before clean,
+cofiguration and header install steps described above. This will direct make to
+build samples for the cross target::
+
+ export ARCH=arm64
+ export CROSS_COMPILE="aarch64-linux-gnu-"
+
+Headers can be also installed on RFC of target board if need to keep them in
+sync (not necessarily and it creates a local "usr/include" directory also)::
+
+ make INSTALL_HDR_PATH=~/some_sysroot/usr headers_install
+
+Pointing LLC and CLANG is not necessarily if it's installed on HOST and have
+in its targets appropriate arm64 arch (usually it has several arches).
+Build samples::
+
+ make samples/bpf/
+
+Or build samples with SYSROOT if some header or library is absent in toolchain,
+say libelf, providing address to file system containing headers and libs,
+can be RFS of target board::
 
-export ARCH=arm64
-export CROSS_COMPILE="aarch64-linux-gnu-"
-make samples/bpf/ LLC=~/git/llvm/build/bin/llc CLANG=~/git/llvm/build/bin/clang
+ make samples/bpf/ SYSROOT=~/some_sysroot
-- 
2.17.1


^ permalink raw reply related

* [PATCH v3 bpf-next 12/14] samples: bpf: makefile: provide C/CXX/LD flags to libbpf
From: Ivan Khoronzhuk @ 2019-09-16 10:54 UTC (permalink / raw)
  To: ast, daniel, yhs, davem, jakub.kicinski, hawk, john.fastabend
  Cc: linux-kernel, netdev, bpf, clang-built-linux, sergei.shtylyov,
	Ivan Khoronzhuk
In-Reply-To: <20190916105433.11404-1-ivan.khoronzhuk@linaro.org>

In order to build libs using C/CXX/LD flags of target arch,
provide them to libbpf make.

Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
---
 samples/bpf/Makefile | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile
index 18ec22e7b444..133123d4c7d7 100644
--- a/samples/bpf/Makefile
+++ b/samples/bpf/Makefile
@@ -182,8 +182,6 @@ ifdef CROSS_COMPILE
 TPROGS_CFLAGS += -Wall
 TPROGS_CFLAGS += -O2
 TPROGS_CFLAGS += -fomit-frame-pointer
-TPROGS_CFLAGS += -Wmissing-prototypes
-TPROGS_CFLAGS += -Wstrict-prototypes
 else
 TPROGS_LDLIBS := $(KBUILD_HOSTLDLIBS)
 TPROGS_CFLAGS += $(KBUILD_HOSTCFLAGS) $(HOST_EXTRACFLAGS)
@@ -196,6 +194,14 @@ TPROGS_CFLAGS += -I$(srctree)/tools/lib/
 TPROGS_CFLAGS += -I$(srctree)/tools/include
 TPROGS_CFLAGS += -I$(srctree)/tools/perf
 
+EXTRA_CXXFLAGS := $(TPROGS_CFLAGS)
+
+# options not valid for C++
+ifdef CROSS_COMPILE
+$(TPROGS_CFLAGS) += -Wmissing-prototypes
+$(TPROGS_CFLAGS) += -Wstrict-prototypes
+endif
+
 TPROGCFLAGS_bpf_load.o += -Wno-unused-variable
 
 TPROGS_LDLIBS			+= $(LIBBPF) -lelf
@@ -257,7 +263,9 @@ clean:
 
 $(LIBBPF): FORCE
 # Fix up variables inherited from Kbuild that tools/ build system won't like
-	$(MAKE) -C $(dir $@) RM='rm -rf' LDFLAGS= srctree=$(BPF_SAMPLES_PATH)/../../ O=
+	$(MAKE) -C $(dir $@) RM='rm -rf' EXTRA_CFLAGS="$(TPROGS_CFLAGS)" \
+		EXTRA_CXXFLAGS="$(EXTRA_CXXFLAGS)" LDFLAGS=$(TPROGS_LDFLAGS) \
+		srctree=$(BPF_SAMPLES_PATH)/../../ O=
 
 $(obj)/syscall_nrs.h:	$(obj)/syscall_nrs.s FORCE
 	$(call filechk,offsets,__SYSCALL_NRS_H__)
-- 
2.17.1


^ permalink raw reply related


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