Netdev List
 help / color / mirror / Atom feed
* Re: [PATCH net-next 0/6] use pci_zalloc_consistent
From: David Miller @ 2018-06-05 13:00 UTC (permalink / raw)
  To: hch
  Cc: andy.shevchenko, yuehaibing, netdev, linux-kernel, jcliburn,
	chris.snook, benve, jdmason, chessman, jes, rahul.verma
In-Reply-To: <20180605124929.GA13305@lst.de>

From: Christoph Hellwig <hch@lst.de>
Date: Tue, 5 Jun 2018 14:49:29 +0200

> On Tue, Jun 05, 2018 at 03:39:16PM +0300, Andy Shevchenko wrote:
>> On Tue, Jun 5, 2018 at 3:28 PM, YueHaibing <yuehaibing@huawei.com> wrote:
>> >
>> 
>> Hmm... Is PCI case anyhow special or it's a simple wrapper on top of
>> dma.*alloc() ?
> 
> All drivers should move from pci_dma* to dma_* eventually.  Converting
> from one flavor of deprecated to another is completely pointless.

Agreed.

^ permalink raw reply

* Re: [PATCH] net-tcp: remove useless tw_timeout field
From: Eric Dumazet @ 2018-06-05 12:59 UTC (permalink / raw)
  To: Maciej Żenczykowski, Maciej Żenczykowski,
	David S . Miller, Eric Dumazet
  Cc: netdev
In-Reply-To: <20180605100723.164396-1-zenczykowski@gmail.com>



On 06/05/2018 03:07 AM, Maciej Żenczykowski wrote:
> From: Maciej Żenczykowski <maze@google.com>
> 
> Tested: 'git grep tw_timeout' comes up empty and it builds :-)
> 
> Signed-off-by: Maciej Żenczykowski <maze@google.com>
> Cc: Eric Dumazet <edumazet@google.com>

This field became no longer needed when tcp_tw_recycle was removed in linux-4.12

Signed-off-by: Eric Dumazet <edumazet@google.com>

Thanks Maciej

^ permalink raw reply

* Re: [PATCH net-next 0/2] net: phy: improve PM handling of PHY/MDIO
From: David Miller @ 2018-06-05 12:50 UTC (permalink / raw)
  To: hkallweit1; +Cc: andrew, f.fainelli, netdev
In-Reply-To: <b8f7b42e-791a-5997-d5eb-16f649738421@gmail.com>

From: Heiner Kallweit <hkallweit1@gmail.com>
Date: Sat, 2 Jun 2018 22:33:36 +0200

> Current implementation of MDIO bus PM ops doesn't actually implement
> bus-specific PM ops but just calls PM ops defined on a device level
> what doesn't seem to be fully in line with the core PM model.
> 
> When looking e.g. at __device_suspend() the PM core looks for PM ops
> of a device in a specific order:
> 1. device PM domain
> 2. device type
> 3. device class
> 4. device bus
> 
> I think it has good reason that there's no PM ops on device level.
> The situation can be improved by modeling PHY's as device type of
> a MDIO device. If for some other type of MDIO device PM ops are
> needed, it could be modeled as struct device_type as well.

Series applied, thanks.

^ permalink raw reply

* Re: [PATCH net-next 0/6] use pci_zalloc_consistent
From: Christoph Hellwig @ 2018-06-05 12:49 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: YueHaibing, Christoph Hellwig, David S. Miller, netdev,
	Linux Kernel Mailing List, jcliburn, chris.snook, benve,
	Jon Mason, chessman, jes, rahul.verma
In-Reply-To: <CAHp75VcWqO8hzbprP1FZJFmpu18iFXxHsu9uXw8RGngRf2jJhw@mail.gmail.com>

On Tue, Jun 05, 2018 at 03:39:16PM +0300, Andy Shevchenko wrote:
> On Tue, Jun 5, 2018 at 3:28 PM, YueHaibing <yuehaibing@huawei.com> wrote:
> >
> 
> Hmm... Is PCI case anyhow special or it's a simple wrapper on top of
> dma.*alloc() ?

All drivers should move from pci_dma* to dma_* eventually.  Converting
from one flavor of deprecated to another is completely pointless.

^ permalink raw reply

* Re: [PATCH net-next 0/6] use pci_zalloc_consistent
From: Andy Shevchenko @ 2018-06-05 12:46 UTC (permalink / raw)
  To: Christoph Hellwig
  Cc: YueHaibing, David S. Miller, netdev, Linux Kernel Mailing List,
	jcliburn, chris.snook, benve, Jon Mason, chessman, jes,
	rahul.verma
In-Reply-To: <20180605124929.GA13305@lst.de>

On Tue, Jun 5, 2018 at 3:49 PM, Christoph Hellwig <hch@lst.de> wrote:
> On Tue, Jun 05, 2018 at 03:39:16PM +0300, Andy Shevchenko wrote:
>> On Tue, Jun 5, 2018 at 3:28 PM, YueHaibing <yuehaibing@huawei.com> wrote:
>> >
>>
>> Hmm... Is PCI case anyhow special or it's a simple wrapper on top of
>> dma.*alloc() ?
>
> All drivers should move from pci_dma* to dma_* eventually.  Converting
> from one flavor of deprecated to another is completely pointless.

Exactly my impression. Thanks, Christoph for clarification.

YueHaibing, care to follow what Christoph said and change your series
accordingly?

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply

* Re: [PATCH bpf-next 10/11] i40e: implement AF_XDP zero-copy support for Tx
From: Jesper Dangaard Brouer @ 2018-06-05 12:43 UTC (permalink / raw)
  To: Björn Töpel
  Cc: magnus.karlsson, magnus.karlsson, alexander.h.duyck,
	alexander.duyck, ast, daniel, netdev, mykyta.iziumtsev,
	john.fastabend, willemdebruijn.kernel, mst, michael.lundkvist,
	jesse.brandeburg, anjali.singhai, qi.z.zhang, francois.ozog,
	ilias.apalodimas, brian.brooks, andy, michael.chan,
	intel-wired-lan, brouer
In-Reply-To: <20180604120601.18123-11-bjorn.topel@gmail.com>

On Mon,  4 Jun 2018 14:06:00 +0200
Björn Töpel <bjorn.topel@gmail.com> wrote:

> Here, ndo_xsk_async_xmit is implemented. As a shortcut, the existing
> XDP Tx rings are used for zero-copy. This will result in other devices
> doing XDP_REDIRECT to an AF_XDP enabled queue will have its packets
> dropped.

This behavior is problematic, because XDP Tx rings are smp_processor_id
based, and several RX queues can (via proc smp_affinity settings) be
assigned to the same CPU. Thus, other RX-queues (than the AF_XDP
enabled queue) can experience packet drops.  And other devices doing
redirect through i40e, which happen to run on a CPU which XDP Tx queue
is "hijacked" will see dropped packets.

Any plans to allocate/create a dedicated TX ring per AF_XDP socket?

-- 
Best regards,
  Jesper Dangaard Brouer
  MSc.CS, Principal Kernel Engineer at Red Hat
  LinkedIn: http://www.linkedin.com/in/brouer

^ permalink raw reply

* Re: ANNOUNCE: Enhanced IP v1.4
From: Willy Tarreau @ 2018-06-05 12:41 UTC (permalink / raw)
  To: Bjørn Mork
  Cc: Eric Dumazet, Tom Herbert, Sam Patton,
	Linux Kernel Network Developers
In-Reply-To: <87y3ft9zwg.fsf@miraculix.mork.no>

On Tue, Jun 05, 2018 at 02:33:03PM +0200, Bjørn Mork wrote:
> > I do have IPv6 at home (a /48, waste of addressing space, I'd be fine
> > with less),
> 
> Any reason you would want less?  Any reason the ISP should give you
> less?

What I mean is that *if* the availability of /48 networks was an issue
for some ISPs, I'd be fine with less because I don't plan to deploy 64k
networks at home, though I already have ~9 around the firewall and don't
expect to go much further.

> > Maybe setting up a public list of ISPs where users don't have at least
> > a /60 by default could help, but I suspect that most of them will
> > consider that as long as their competitors are on the list there's no
> > emergency.
> 
> Exactly.  And the number of users using the list as the primary
> parameter for selecting an ISP would be close to 0.  The critical part
> is not the list, but making large enough groups of users consider IPv6
> an important parameter when selecting ISPs.

In fact the IoT trend could play a role here by letting users know that
they can remotely access their fridge and whatever stupid device they've
deployed. But the reality is the opposite : some gateway services are/will
be offered at a paid price to make these devices remotely accessible, and
the claimed security provided by this gateway will be presented as a real
benefit compared to the risks of anyone directly accessing your private
life over IPv6. So I'm not getting much hopes for the future in this area
either.

Willy

^ permalink raw reply

* Re: [PATCH net-next 0/6] use pci_zalloc_consistent
From: Andy Shevchenko @ 2018-06-05 12:39 UTC (permalink / raw)
  To: YueHaibing, Christoph Hellwig
  Cc: David S. Miller, netdev, Linux Kernel Mailing List, jcliburn,
	chris.snook, benve, Jon Mason, chessman, jes, rahul.verma
In-Reply-To: <20180605122851.23912-1-yuehaibing@huawei.com>

On Tue, Jun 5, 2018 at 3:28 PM, YueHaibing <yuehaibing@huawei.com> wrote:
>

Hmm... Is PCI case anyhow special or it's a simple wrapper on top of
dma.*alloc() ?

> YueHaibing (6):
>   net: hippi: use pci_zalloc_consistent
>   net: atheros: use pci_zalloc_consistent
>   net: neterion: use pci_zalloc_consistent
>   netxen_nic: use pci_zalloc_consistent
>   net: tlan: use pci_zalloc_consistent
>   enic: use pci_zalloc_consistent
>
>  drivers/net/ethernet/atheros/atl1e/atl1e_main.c    |  2 +-
>  drivers/net/ethernet/atheros/atlx/atl1.c           |  8 +++----
>  drivers/net/ethernet/atheros/atlx/atl2.c           |  5 ++--
>  drivers/net/ethernet/cisco/enic/vnic_dev.c         |  3 +--
>  drivers/net/ethernet/neterion/s2io.c               | 10 ++++----
>  .../net/ethernet/qlogic/netxen/netxen_nic_ctx.c    | 26 ++++++++------------
>  drivers/net/ethernet/ti/tlan.c                     |  7 +++---
>  drivers/net/hippi/rrunner.c                        | 28 +++++++++-------------
>  8 files changed, 35 insertions(+), 54 deletions(-)
>
> --
> 2.7.0
>
>



-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply

* Re: [bpf-next PATCH 0/5] net/xdp: remove net_device operation ndo_xdp_flush
From: Daniel Borkmann @ 2018-06-05 12:38 UTC (permalink / raw)
  To: Jesper Dangaard Brouer, netdev, Daniel Borkmann,
	Alexei Starovoitov
  Cc: liu.song.a23, songliubraving, John Fastabend
In-Reply-To: <152819969561.7083.15427306662397720502.stgit@firesoul>

On 06/05/2018 01:55 PM, Jesper Dangaard Brouer wrote:
> This patchset removes the net_device operation ndo_xdp_flush() call.
> This is a follow merge commit ea9916ea3ed9 ("Merge branch
> 'ndo_xdp_xmit-cleanup'").  As after commit c1ece6b245bd ("bpf/xdp:
> devmap can avoid calling ndo_xdp_flush") no callers of ndo_xdp_flush
> are left in bpf-next tree.

Looks good, applied to bpf-next, thanks Jesper!

^ permalink raw reply

* Re: ANNOUNCE: Enhanced IP v1.4
From: Bjørn Mork @ 2018-06-05 12:33 UTC (permalink / raw)
  To: Willy Tarreau
  Cc: Eric Dumazet, Tom Herbert, Sam Patton,
	Linux Kernel Network Developers
In-Reply-To: <20180604043426.GB11775@1wt.eu>

Willy Tarreau <w@1wt.eu> writes:

> I agree on these points, but I'd like to figure what can be done to put
> a bit more pressure on ISPs to *always* provide IPv6.

Most ISPs are in it for the money.  So what you can do is either to make
it more expensive to provide IPv4-only services or more profitable to
provide dual-stack services.  Making IPv4 more expensive is probably
hard.  Even ISPs having to buy address space still figure it is cheaper
than IPv6 with NAT64 or other CGN solutions.

So what you need to do is simply to convince enough of your friends to
pay the price of IPv6.

The fact is that adding IPv6 still has real costs and no real benefit
for an ISP.  There just aren't enough geeks voting with their wallet to
make a difference.  And even if "everything" supports IPv6, there will
always be an extra set of bugs and additional operational problems with
*any* optional feature you enable. IPv6 is no exception. Enthusiasts
within the ISPs is the only reason there is any ISP providing dual-stack
services at all.

> I do have IPv6 at home (a /48, waste of addressing space, I'd be fine
> with less),

Any reason you would want less?  Any reason the ISP should give you
less?

> Maybe setting up a public list of ISPs where users don't have at least
> a /60 by default could help, but I suspect that most of them will
> consider that as long as their competitors are on the list there's no
> emergency.

Exactly.  And the number of users using the list as the primary
parameter for selecting an ISP would be close to 0.  The critical part
is not the list, but making large enough groups of users consider IPv6
an important parameter when selecting ISPs.

Disclaimer: I work for an ISP providing dual-stack services on multiple
access technologies, in a market where no other major ISP does that.  We
have done it for 6 years now, and haven't see any tendency that end
users prefer us over competitors based on IPv6.  Media interest is none.
IPv6 is not even mentioned in articles claiming to compare services.


Bjørn

^ permalink raw reply

* Re: [PATCH net-next 1/2] ipv4: replace ip_hdr() with skb->data for optimization
From: Yafang Shao @ 2018-06-05 12:29 UTC (permalink / raw)
  To: Paolo Abeni; +Cc: Eric Dumazet, David Miller, netdev, LKML
In-Reply-To: <9ce783dc628699f02c45650c942f6735e93a18c4.camel@redhat.com>

On Tue, Jun 5, 2018 at 8:20 PM, Paolo Abeni <pabeni@redhat.com> wrote:
> On Tue, 2018-06-05 at 08:04 -0400, Yafang Shao wrote:
>> In ip receive path, when ip header hasn't been pulled yet, ip_hdr() and
>> skb->data are pointing to the same byte.
>>
>> In ip output path, when ip header is just pushed, ip_hdr() and skb->data
>> are pointing to the same byte.
>>
>> As ip_hdr() is more expensive than using skb->data, so replace ip_hdr()
>> with skb->data in these situations for optimization.
>
> IMHO this makes the code less readable and more error prone. Which kind
> of performance improvement do you measure here?
>

Correct the cc list.

Hi Paolo,

There's a "+" opertaion in ip_hdr(),  using skb->data and avoid this operation.

Thanks
Yafang

^ permalink raw reply

* [PATCH net-next 6/6] enic: use pci_zalloc_consistent
From: YueHaibing @ 2018-06-05 12:28 UTC (permalink / raw)
  To: davem
  Cc: netdev, linux-kernel, jcliburn, chris.snook, benve, jdmason,
	chessman, jes, rahul.verma, YueHaibing
In-Reply-To: <20180605122851.23912-1-yuehaibing@huawei.com>

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 drivers/net/ethernet/cisco/enic/vnic_dev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/cisco/enic/vnic_dev.c b/drivers/net/ethernet/cisco/enic/vnic_dev.c
index 76cdd4c..7693af9 100644
--- a/drivers/net/ethernet/cisco/enic/vnic_dev.c
+++ b/drivers/net/ethernet/cisco/enic/vnic_dev.c
@@ -1217,13 +1217,12 @@ int vnic_dev_classifier(struct vnic_dev *vdev, u8 cmd, u16 *entry,
 		tlv_size = sizeof(struct filter) +
 			   sizeof(struct filter_action) +
 			   2 * sizeof(struct filter_tlv);
-		tlv_va = pci_alloc_consistent(vdev->pdev, tlv_size, &tlv_pa);
+		tlv_va = pci_zalloc_consistent(vdev->pdev, tlv_size, &tlv_pa);
 		if (!tlv_va)
 			return -ENOMEM;
 		tlv = tlv_va;
 		a0 = tlv_pa;
 		a1 = tlv_size;
-		memset(tlv, 0, tlv_size);
 		tlv->type = CLSF_TLV_FILTER;
 		tlv->length = sizeof(struct filter);
 		*(struct filter *)&tlv->val = *data;
-- 
2.7.0

^ permalink raw reply related

* [PATCH net-next 5/6] net: tlan: use pci_zalloc_consistent
From: YueHaibing @ 2018-06-05 12:28 UTC (permalink / raw)
  To: davem
  Cc: netdev, linux-kernel, jcliburn, chris.snook, benve, jdmason,
	chessman, jes, rahul.verma, YueHaibing
In-Reply-To: <20180605122851.23912-1-yuehaibing@huawei.com>

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 drivers/net/ethernet/ti/tlan.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/ti/tlan.c b/drivers/net/ethernet/ti/tlan.c
index c769cd9..66f2e5d 100644
--- a/drivers/net/ethernet/ti/tlan.c
+++ b/drivers/net/ethernet/ti/tlan.c
@@ -843,9 +843,9 @@ static int tlan_init(struct net_device *dev)
 
 	dma_size = (TLAN_NUM_RX_LISTS + TLAN_NUM_TX_LISTS)
 		* (sizeof(struct tlan_list));
-	priv->dma_storage = pci_alloc_consistent(priv->pci_dev,
-						 dma_size,
-						 &priv->dma_storage_dma);
+	priv->dma_storage = pci_zalloc_consistent(priv->pci_dev,
+						  dma_size,
+						  &priv->dma_storage_dma);
 	priv->dma_size = dma_size;
 
 	if (priv->dma_storage == NULL) {
@@ -853,7 +853,6 @@ static int tlan_init(struct net_device *dev)
 		       dev->name);
 		return -ENOMEM;
 	}
-	memset(priv->dma_storage, 0, dma_size);
 	priv->rx_list = (struct tlan_list *)
 		ALIGN((unsigned long)priv->dma_storage, 8);
 	priv->rx_list_dma = ALIGN(priv->dma_storage_dma, 8);
-- 
2.7.0

^ permalink raw reply related

* [PATCH net-next 4/6] netxen_nic: use pci_zalloc_consistent
From: YueHaibing @ 2018-06-05 12:28 UTC (permalink / raw)
  To: davem
  Cc: netdev, linux-kernel, jcliburn, chris.snook, benve, jdmason,
	chessman, jes, rahul.verma, YueHaibing
In-Reply-To: <20180605122851.23912-1-yuehaibing@huawei.com>

use pci_zalloc_consistent to remove unnecessary memset.
Also remove a local intermediate pointer 'void *addr'.

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 .../net/ethernet/qlogic/netxen/netxen_nic_ctx.c    | 26 +++++++++-------------
 1 file changed, 10 insertions(+), 16 deletions(-)

diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c
index 7503aa2..096047e 100644
--- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c
+++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c
@@ -267,7 +267,6 @@ nx_fw_cmd_set_gbe_port(struct netxen_adapter *adapter,
 static int
 nx_fw_cmd_create_rx_ctx(struct netxen_adapter *adapter)
 {
-	void *addr;
 	nx_hostrq_rx_ctx_t *prq;
 	nx_cardrsp_rx_ctx_t *prsp;
 	nx_hostrq_rds_ring_t *prq_rds;
@@ -297,19 +296,17 @@ nx_fw_cmd_create_rx_ctx(struct netxen_adapter *adapter)
 	rsp_size =
 		SIZEOF_CARDRSP_RX(nx_cardrsp_rx_ctx_t, nrds_rings, nsds_rings);
 
-	addr = pci_alloc_consistent(adapter->pdev,
-				rq_size, &hostrq_phys_addr);
-	if (addr == NULL)
+	prq = pci_alloc_consistent(adapter->pdev,
+				   rq_size, &hostrq_phys_addr);
+	if (!prq)
 		return -ENOMEM;
-	prq = addr;
 
-	addr = pci_alloc_consistent(adapter->pdev,
-			rsp_size, &cardrsp_phys_addr);
-	if (addr == NULL) {
+	prsp = pci_alloc_consistent(adapter->pdev,
+				    rsp_size, &cardrsp_phys_addr);
+	if (!prsp) {
 		err = -ENOMEM;
 		goto out_free_rq;
 	}
-	prsp = addr;
 
 	prq->host_rsp_dma_addr = cpu_to_le64(cardrsp_phys_addr);
 
@@ -445,23 +442,20 @@ nx_fw_cmd_create_tx_ctx(struct netxen_adapter *adapter)
 	struct netxen_cmd_args cmd;
 
 	rq_size = SIZEOF_HOSTRQ_TX(nx_hostrq_tx_ctx_t);
-	rq_addr = pci_alloc_consistent(adapter->pdev,
-		rq_size, &rq_phys_addr);
+	rq_addr = pci_zalloc_consistent(adapter->pdev,
+					rq_size, &rq_phys_addr);
 	if (!rq_addr)
 		return -ENOMEM;
 
 	rsp_size = SIZEOF_CARDRSP_TX(nx_cardrsp_tx_ctx_t);
-	rsp_addr = pci_alloc_consistent(adapter->pdev,
-		rsp_size, &rsp_phys_addr);
+	rsp_addr = pci_zalloc_consistent(adapter->pdev,
+					 rsp_size, &rsp_phys_addr);
 	if (!rsp_addr) {
 		err = -ENOMEM;
 		goto out_free_rq;
 	}
 
-	memset(rq_addr, 0, rq_size);
 	prq = rq_addr;
-
-	memset(rsp_addr, 0, rsp_size);
 	prsp = rsp_addr;
 
 	prq->host_rsp_dma_addr = cpu_to_le64(rsp_phys_addr);
-- 
2.7.0

^ permalink raw reply related

* [PATCH net-next 3/6] net: neterion: use pci_zalloc_consistent
From: YueHaibing @ 2018-06-05 12:28 UTC (permalink / raw)
  To: davem
  Cc: netdev, linux-kernel, jcliburn, chris.snook, benve, jdmason,
	chessman, jes, rahul.verma, YueHaibing
In-Reply-To: <20180605122851.23912-1-yuehaibing@huawei.com>

use pci_zalloc_consistent to remove unnecessary memset.

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 drivers/net/ethernet/neterion/s2io.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/neterion/s2io.c b/drivers/net/ethernet/neterion/s2io.c
index b8983e7..4e8a2fd 100644
--- a/drivers/net/ethernet/neterion/s2io.c
+++ b/drivers/net/ethernet/neterion/s2io.c
@@ -733,8 +733,8 @@ static int init_shared_mem(struct s2io_nic *nic)
 
 			rx_blocks = &ring->rx_blocks[j];
 			size = SIZE_OF_BLOCK;	/* size is always page size */
-			tmp_v_addr = pci_alloc_consistent(nic->pdev, size,
-							  &tmp_p_addr);
+			tmp_v_addr = pci_zalloc_consistent(nic->pdev, size,
+							   &tmp_p_addr);
 			if (tmp_v_addr == NULL) {
 				/*
 				 * In case of failure, free_shared_mem()
@@ -746,7 +746,6 @@ static int init_shared_mem(struct s2io_nic *nic)
 				return -ENOMEM;
 			}
 			mem_allocated += size;
-			memset(tmp_v_addr, 0, size);
 
 			size = sizeof(struct rxd_info) *
 				rxd_count[nic->rxd_mode];
@@ -835,8 +834,8 @@ static int init_shared_mem(struct s2io_nic *nic)
 	/* Allocation and initialization of Statistics block */
 	size = sizeof(struct stat_block);
 	mac_control->stats_mem =
-		pci_alloc_consistent(nic->pdev, size,
-				     &mac_control->stats_mem_phy);
+		pci_zalloc_consistent(nic->pdev, size,
+				      &mac_control->stats_mem_phy);
 
 	if (!mac_control->stats_mem) {
 		/*
@@ -851,7 +850,6 @@ static int init_shared_mem(struct s2io_nic *nic)
 
 	tmp_v_addr = mac_control->stats_mem;
 	mac_control->stats_info = tmp_v_addr;
-	memset(tmp_v_addr, 0, size);
 	DBG_PRINT(INIT_DBG, "%s: Ring Mem PHY: 0x%llx\n",
 		dev_name(&nic->pdev->dev), (unsigned long long)tmp_p_addr);
 	mac_control->stats_info->sw_stat.mem_allocated += mem_allocated;
-- 
2.7.0

^ permalink raw reply related

* [PATCH net-next 2/6] net: atheros: use pci_zalloc_consistent
From: YueHaibing @ 2018-06-05 12:28 UTC (permalink / raw)
  To: davem
  Cc: netdev, linux-kernel, jcliburn, chris.snook, benve, jdmason,
	chessman, jes, rahul.verma, YueHaibing
In-Reply-To: <20180605122851.23912-1-yuehaibing@huawei.com>

use pci_zalloc_consistent to remove unnecessary memset

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 drivers/net/ethernet/atheros/atl1e/atl1e_main.c | 2 +-
 drivers/net/ethernet/atheros/atlx/atl1.c        | 8 +++-----
 drivers/net/ethernet/atheros/atlx/atl2.c        | 5 ++---
 3 files changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/atheros/atl1e/atl1e_main.c b/drivers/net/ethernet/atheros/atl1e/atl1e_main.c
index 9dc6da0..41da42f 100644
--- a/drivers/net/ethernet/atheros/atl1e/atl1e_main.c
+++ b/drivers/net/ethernet/atheros/atl1e/atl1e_main.c
@@ -829,7 +829,7 @@ static int atl1e_setup_ring_resources(struct atl1e_adapter *adapter)
 						       &adapter->ring_dma);
 	if (adapter->ring_vir_addr == NULL) {
 		netdev_err(adapter->netdev,
-			   "pci_alloc_consistent failed, size = D%d\n", size);
+			   "pci_zalloc_consistent failed, size = D%d\n", size);
 		return -ENOMEM;
 	}
 
diff --git a/drivers/net/ethernet/atheros/atlx/atl1.c b/drivers/net/ethernet/atheros/atlx/atl1.c
index b81fbf11..c72ef33 100644
--- a/drivers/net/ethernet/atheros/atlx/atl1.c
+++ b/drivers/net/ethernet/atheros/atlx/atl1.c
@@ -1069,16 +1069,14 @@ static s32 atl1_setup_ring_resources(struct atl1_adapter *adapter)
 		+ sizeof(struct stats_msg_block)
 		+ 40;
 
-	ring_header->desc = pci_alloc_consistent(pdev, ring_header->size,
-		&ring_header->dma);
+	ring_header->desc = pci_zalloc_consistent(pdev, ring_header->size,
+						  &ring_header->dma);
 	if (unlikely(!ring_header->desc)) {
 		if (netif_msg_drv(adapter))
-			dev_err(&pdev->dev, "pci_alloc_consistent failed\n");
+			dev_err(&pdev->dev, "pci_zalloc_consistent failed\n");
 		goto err_nomem;
 	}
 
-	memset(ring_header->desc, 0, ring_header->size);
-
 	/* init TPD ring */
 	tpd_ring->dma = ring_header->dma;
 	offset = (tpd_ring->dma & 0x7) ? (8 - (ring_header->dma & 0x7)) : 0;
diff --git a/drivers/net/ethernet/atheros/atlx/atl2.c b/drivers/net/ethernet/atheros/atlx/atl2.c
index db4bcc5..d430dc9 100644
--- a/drivers/net/ethernet/atheros/atlx/atl2.c
+++ b/drivers/net/ethernet/atheros/atlx/atl2.c
@@ -300,11 +300,10 @@ static s32 atl2_setup_ring_resources(struct atl2_adapter *adapter)
 		adapter->txs_ring_size * 4 + 7 +	/* dword align */
 		adapter->rxd_ring_size * 1536 + 127;	/* 128bytes align */
 
-	adapter->ring_vir_addr = pci_alloc_consistent(pdev, size,
-		&adapter->ring_dma);
+	adapter->ring_vir_addr = pci_zalloc_consistent(pdev, size,
+						       &adapter->ring_dma);
 	if (!adapter->ring_vir_addr)
 		return -ENOMEM;
-	memset(adapter->ring_vir_addr, 0, adapter->ring_size);
 
 	/* Init TXD Ring */
 	adapter->txd_dma = adapter->ring_dma ;
-- 
2.7.0

^ permalink raw reply related

* [PATCH net-next 1/6] net: hippi: use pci_zalloc_consistent
From: YueHaibing @ 2018-06-05 12:28 UTC (permalink / raw)
  To: davem
  Cc: netdev, linux-kernel, jcliburn, chris.snook, benve, jdmason,
	chessman, jes, rahul.verma, YueHaibing
In-Reply-To: <20180605122851.23912-1-yuehaibing@huawei.com>

use pci_zalloc_consistent to remove unnecessary memset.
Also remove a local intermediate pointer 'tmpptr'.

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 drivers/net/hippi/rrunner.c | 28 +++++++++++-----------------
 1 file changed, 11 insertions(+), 17 deletions(-)

diff --git a/drivers/net/hippi/rrunner.c b/drivers/net/hippi/rrunner.c
index f411164..9de7d2a 100644
--- a/drivers/net/hippi/rrunner.c
+++ b/drivers/net/hippi/rrunner.c
@@ -93,7 +93,6 @@ static int rr_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	static int version_disp;
 	u8 pci_latency;
 	struct rr_private *rrpriv;
-	void *tmpptr;
 	dma_addr_t ring_dma;
 	int ret = -ENOMEM;
 
@@ -155,29 +154,26 @@ static int rr_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 		goto out;
 	}
 
-	tmpptr = pci_alloc_consistent(pdev, TX_TOTAL_SIZE, &ring_dma);
-	rrpriv->tx_ring = tmpptr;
+	rrpriv->tx_ring = pci_alloc_consistent(pdev, TX_TOTAL_SIZE, &ring_dma);
 	rrpriv->tx_ring_dma = ring_dma;
 
-	if (!tmpptr) {
+	if (!rrpriv->tx_ring) {
 		ret = -ENOMEM;
 		goto out;
 	}
 
-	tmpptr = pci_alloc_consistent(pdev, RX_TOTAL_SIZE, &ring_dma);
-	rrpriv->rx_ring = tmpptr;
+	rrpriv->rx_ring = pci_alloc_consistent(pdev, RX_TOTAL_SIZE, &ring_dma);
 	rrpriv->rx_ring_dma = ring_dma;
 
-	if (!tmpptr) {
+	if (!rrpriv->rx_ring) {
 		ret = -ENOMEM;
 		goto out;
 	}
 
-	tmpptr = pci_alloc_consistent(pdev, EVT_RING_SIZE, &ring_dma);
-	rrpriv->evt_ring = tmpptr;
+	rrpriv->evt_ring = pci_alloc_consistent(pdev, EVT_RING_SIZE, &ring_dma);
 	rrpriv->evt_ring_dma = ring_dma;
 
-	if (!tmpptr) {
+	if (!trrpriv->evt_ring) {
 		ret = -ENOMEM;
 		goto out;
 	}
@@ -1192,24 +1188,22 @@ static int rr_open(struct net_device *dev)
 		goto error;
 	}
 
-	rrpriv->rx_ctrl = pci_alloc_consistent(pdev,
-					       256 * sizeof(struct ring_ctrl),
-					       &dma_addr);
+	rrpriv->rx_ctrl = pci_zalloc_consistent(pdev,
+						256 * sizeof(struct ring_ctrl),
+						&dma_addr);
 	if (!rrpriv->rx_ctrl) {
 		ecode = -ENOMEM;
 		goto error;
 	}
 	rrpriv->rx_ctrl_dma = dma_addr;
-	memset(rrpriv->rx_ctrl, 0, 256*sizeof(struct ring_ctrl));
 
-	rrpriv->info = pci_alloc_consistent(pdev, sizeof(struct rr_info),
-					    &dma_addr);
+	rrpriv->info = pci_zalloc_consistent(pdev, sizeof(struct rr_info),
+					     &dma_addr);
 	if (!rrpriv->info) {
 		ecode = -ENOMEM;
 		goto error;
 	}
 	rrpriv->info_dma = dma_addr;
-	memset(rrpriv->info, 0, sizeof(struct rr_info));
 	wmb();
 
 	spin_lock_irqsave(&rrpriv->lock, flags);
-- 
2.7.0

^ permalink raw reply related

* [PATCH net-next 0/6] use pci_zalloc_consistent
From: YueHaibing @ 2018-06-05 12:28 UTC (permalink / raw)
  To: davem
  Cc: netdev, linux-kernel, jcliburn, chris.snook, benve, jdmason,
	chessman, jes, rahul.verma, YueHaibing


YueHaibing (6):
  net: hippi: use pci_zalloc_consistent
  net: atheros: use pci_zalloc_consistent
  net: neterion: use pci_zalloc_consistent
  netxen_nic: use pci_zalloc_consistent
  net: tlan: use pci_zalloc_consistent
  enic: use pci_zalloc_consistent

 drivers/net/ethernet/atheros/atl1e/atl1e_main.c    |  2 +-
 drivers/net/ethernet/atheros/atlx/atl1.c           |  8 +++----
 drivers/net/ethernet/atheros/atlx/atl2.c           |  5 ++--
 drivers/net/ethernet/cisco/enic/vnic_dev.c         |  3 +--
 drivers/net/ethernet/neterion/s2io.c               | 10 ++++----
 .../net/ethernet/qlogic/netxen/netxen_nic_ctx.c    | 26 ++++++++------------
 drivers/net/ethernet/ti/tlan.c                     |  7 +++---
 drivers/net/hippi/rrunner.c                        | 28 +++++++++-------------
 8 files changed, 35 insertions(+), 54 deletions(-)

-- 
2.7.0

^ permalink raw reply

* Re: KASAN: slab-out-of-bounds Read in bpf_csum_update
From: Daniel Borkmann @ 2018-06-05 12:28 UTC (permalink / raw)
  To: Dmitry Vyukov, syzbot
  Cc: Alexei Starovoitov, David Miller, LKML, netdev, syzkaller-bugs
In-Reply-To: <CACT4Y+a7hZ0x16PnyJxrb7akBRNr-TDR8Cvn01G27HmAKVE_vg@mail.gmail.com>

On 06/04/2018 07:36 AM, Dmitry Vyukov wrote:
> On Mon, Jun 4, 2018 at 1:36 AM, syzbot
> <syzbot+efae31b384d5badbd620@syzkaller.appspotmail.com> wrote:
>> Hello,
>>
>> syzbot found the following crash on:
>>
>> HEAD commit:    0512e0134582 Merge tag 'xfs-4.17-fixes-3' of git://git.ker..
>> git tree:       upstream
>> console output: https://syzkaller.appspot.com/x/log.txt?x=17eb2d7b800000
>> kernel config:  https://syzkaller.appspot.com/x/.config?x=968b0b23c7854c0b
>> dashboard link: https://syzkaller.appspot.com/bug?extid=efae31b384d5badbd620
>> compiler:       gcc (GCC) 8.0.1 20180413 (experimental)
>> syzkaller repro:https://syzkaller.appspot.com/x/repro.syz?x=162c6def800000
>> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=14fe3db7800000
>>
>> IMPORTANT: if you fix the bug, please add the following tag to the commit:
>> Reported-by: syzbot+efae31b384d5badbd620@syzkaller.appspotmail.com
>>
>> random: sshd: uninitialized urandom read (32 bytes read)
>> random: sshd: uninitialized urandom read (32 bytes read)
>> random: sshd: uninitialized urandom read (32 bytes read)
>> random: sshd: uninitialized urandom read (32 bytes read)
>> ==================================================================
>> BUG: KASAN: slab-out-of-bounds in ____bpf_csum_update net/core/filter.c:1679
>> [inline]
>> BUG: KASAN: slab-out-of-bounds in bpf_csum_update+0xb4/0xc0
>> net/core/filter.c:1673
>> Read of size 1 at addr ffff8801d9235b50 by task syz-executor507/4513
>>
>> CPU: 0 PID: 4513 Comm: syz-executor507 Not tainted 4.17.0-rc7+ #78
>> 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+0x1b9/0x294 lib/dump_stack.c:113
>>  print_address_description+0x6c/0x20b mm/kasan/report.c:256
>>  kasan_report_error mm/kasan/report.c:354 [inline]
>>  kasan_report.cold.7+0x242/0x2fe mm/kasan/report.c:412
>>  __asan_report_load1_noabort+0x14/0x20 mm/kasan/report.c:430
>>  ____bpf_csum_update net/core/filter.c:1679 [inline]
>>  bpf_csum_update+0xb4/0xc0 net/core/filter.c:1673
> 
> /\/\/\/\/\
> 
> Are there any known bugs with unwind through bpf functions?

Looks like you don't have kallsyms export enabled, here's a syzkaller diff
to get jit images exposed, then it should work:

diff --git a/tools/create-image.sh b/tools/create-image.sh
index 9f82482..395a2a0 100755
--- a/tools/create-image.sh
+++ b/tools/create-image.sh
@@ -23,6 +23,7 @@ echo 'SELINUX=disabled' | sudo tee $DIR/etc/selinux/config
 echo "kernel.printk = 7 4 1 3" | sudo tee -a $DIR/etc/sysctl.conf
 echo 'debug.exception-trace = 0' | sudo tee -a $DIR/etc/sysctl.conf
 echo "net.core.bpf_jit_enable = 1" | sudo tee -a $DIR/etc/sysctl.conf
+echo "net.core.bpf_jit_kallsyms = 1" | sudo tee -a $DIR/etc/sysctl.conf
 echo "kernel.softlockup_all_cpu_backtrace = 1" | sudo tee -a $DIR/etc/sysctl.conf
 echo "kernel.kptr_restrict = 0" | sudo tee -a $DIR/etc/sysctl.conf
 echo "kernel.watchdog_thresh = 60" | sudo tee -a $DIR/etc/sysctl.conf

Cheers,
Daniel

^ permalink raw reply related

* Re: [PATCH net-next 1/2] ipv4: replace ip_hdr() with skb->data for optimization
From: Paolo Abeni @ 2018-06-05 12:20 UTC (permalink / raw)
  To: Yafang Shao, edumazet, davem; +Cc: netdev, inux-kernel
In-Reply-To: <1528200262-11834-1-git-send-email-laoar.shao@gmail.com>

On Tue, 2018-06-05 at 08:04 -0400, Yafang Shao wrote:
> In ip receive path, when ip header hasn't been pulled yet, ip_hdr() and
> skb->data are pointing to the same byte.
> 
> In ip output path, when ip header is just pushed, ip_hdr() and skb->data
> are pointing to the same byte.
> 
> As ip_hdr() is more expensive than using skb->data, so replace ip_hdr()
> with skb->data in these situations for optimization.

IMHO this makes the code less readable and more error prone. Which kind
of performance improvement do you measure here?

Thanks,

Paolo

^ permalink raw reply

* Re: [PATCH] netfilter: provide udp*_lib_lookup for nf_tproxy
From: Paolo Abeni @ 2018-06-05 12:13 UTC (permalink / raw)
  To: Arnd Bergmann, Pablo Neira Ayuso, David S. Miller,
	Alexey Kuznetsov, Hideaki YOSHIFUJI
  Cc: Máté Eckl, Willem de Bruijn, Eric Dumazet, David Ahern,
	Martin KaFai Lau, netdev, linux-kernel
In-Reply-To: <20180605114056.1239571-1-arnd@arndb.de>

On Tue, 2018-06-05 at 13:40 +0200, Arnd Bergmann wrote:
> It is now possible to enable the libified nf_tproxy modules without
> also enabling NETFILTER_XT_TARGET_TPROXY, which throws off the
> ifdef logic in the udp core code:
> 
> net/ipv6/netfilter/nf_tproxy_ipv6.o: In function `nf_tproxy_get_sock_v6':
> nf_tproxy_ipv6.c:(.text+0x1a8): undefined reference to `udp6_lib_lookup'
> net/ipv4/netfilter/nf_tproxy_ipv4.o: In function `nf_tproxy_get_sock_v4':
> nf_tproxy_ipv4.c:(.text+0x3d0): undefined reference to `udp4_lib_lookup'
> 
> We can actually simplify the conditions now to provide the two functions
> exactly when they are needed.
> 
> Fixes: 45ca4e0cf273 ("netfilter: Libify xt_TPROXY")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  net/ipv4/udp.c | 4 +---
>  net/ipv6/udp.c | 4 +---
>  2 files changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
> index 4f16e5d71875..3365362cac88 100644
> --- a/net/ipv4/udp.c
> +++ b/net/ipv4/udp.c
> @@ -544,9 +544,7 @@ EXPORT_SYMBOL_GPL(udp4_lib_lookup_skb);
>  /* Must be called under rcu_read_lock().
>   * Does increment socket refcount.
>   */
> -#if IS_ENABLED(CONFIG_NETFILTER_XT_MATCH_SOCKET) || \
> -    IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TPROXY) || \
> -    IS_ENABLED(CONFIG_NF_SOCKET_IPV4)
> +#if IS_ENABLED(CONFIG_NF_TPROXY_IPV4) || IS_ENABLED(CONFIG_NF_SOCKET_IPV4)
>  struct sock *udp4_lib_lookup(struct net *net, __be32 saddr, __be16 sport,
>  			     __be32 daddr, __be16 dport, int dif)
>  {
> diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
> index 967acff95bbe..164afd31aebf 100644
> --- a/net/ipv6/udp.c
> +++ b/net/ipv6/udp.c
> @@ -285,9 +285,7 @@ EXPORT_SYMBOL_GPL(udp6_lib_lookup_skb);
>  /* Must be called under rcu_read_lock().
>   * Does increment socket refcount.
>   */
> -#if IS_ENABLED(CONFIG_NETFILTER_XT_MATCH_SOCKET) || \
> -    IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TPROXY) || \
> -    IS_ENABLED(CONFIG_NF_SOCKET_IPV6)
> +#if IS_ENABLED(CONFIG_NF_TPROXY_IPV6) || IS_ENABLED(CONFIG_NF_SOCKET_IPV6)
>  struct sock *udp6_lib_lookup(struct net *net, const struct in6_addr *saddr, __be16 sport,
>  			     const struct in6_addr *daddr, __be16 dport, int dif)
>  {

LGTM,

Acked-by: Paolo Abeni <pabeni@redhat.com>

Thanks,

Paolo

^ permalink raw reply

* [PATCH net-next 2/2] ipv6: replace ip_hdr() with skb->data for optimization
From: Yafang Shao @ 2018-06-05 12:04 UTC (permalink / raw)
  To: edumazet, davem; +Cc: netdev, inux-kernel, Yafang Shao
In-Reply-To: <1528200262-11834-1-git-send-email-laoar.shao@gmail.com>

In ipv6 receive path, when ip header hasn't been pulled yet, ip_hdr()
and skb->data are pointing to the same byte.

In ipv6 output path, when ip header is just pushed, ip_hdr() and skb->data
are pointing to the same byte.

As ip_hdr() is more expensive than using skb->data, so replace ip_hdr()
with skb->data in these situations for optimization.

Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
---
 net/ipv6/ip6_input.c  | 4 ++--
 net/ipv6/ip6_output.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/ipv6/ip6_input.c b/net/ipv6/ip6_input.c
index f08d344..2ff4fe8 100644
--- a/net/ipv6/ip6_input.c
+++ b/net/ipv6/ip6_input.c
@@ -113,7 +113,7 @@ int ipv6_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt
 	if (unlikely(!pskb_may_pull(skb, sizeof(*hdr))))
 		goto err;
 
-	hdr = ipv6_hdr(skb);
+	hdr = (const struct ipv6hdr *)skb->data;
 
 	if (hdr->version != 6)
 		goto err;
@@ -189,7 +189,7 @@ int ipv6_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt
 			__IP6_INC_STATS(net, idev, IPSTATS_MIB_INHDRERRORS);
 			goto drop;
 		}
-		hdr = ipv6_hdr(skb);
+		hdr = (const struct ipv6hdr *)skb->data;
 	}
 
 	if (hdr->nexthdr == NEXTHDR_HOP) {
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 021e5ae..8bb3bc1 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -235,7 +235,7 @@ int ip6_xmit(const struct sock *sk, struct sk_buff *skb, struct flowi6 *fl6,
 
 	skb_push(skb, sizeof(struct ipv6hdr));
 	skb_reset_network_header(skb);
-	hdr = ipv6_hdr(skb);
+	hdr = (struct ipv6hdr *)skb->data;
 
 	/*
 	 *	Fill in the IPv6 header
@@ -1659,7 +1659,7 @@ struct sk_buff *__ip6_make_skb(struct sock *sk,
 
 	skb_push(skb, sizeof(struct ipv6hdr));
 	skb_reset_network_header(skb);
-	hdr = ipv6_hdr(skb);
+	hdr = (struct ipv6hdr *)skb->data;
 
 	ip6_flow_hdr(hdr, v6_cork->tclass,
 		     ip6_make_flowlabel(net, skb, fl6->flowlabel,
-- 
1.8.3.1

^ permalink raw reply related

* [PATCH net-next 1/2] ipv4: replace ip_hdr() with skb->data for optimization
From: Yafang Shao @ 2018-06-05 12:04 UTC (permalink / raw)
  To: edumazet, davem; +Cc: netdev, inux-kernel, Yafang Shao

In ip receive path, when ip header hasn't been pulled yet, ip_hdr() and
skb->data are pointing to the same byte.

In ip output path, when ip header is just pushed, ip_hdr() and skb->data
are pointing to the same byte.

As ip_hdr() is more expensive than using skb->data, so replace ip_hdr()
with skb->data in these situations for optimization.

Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
---
 net/ipv4/ip_input.c  | 8 ++++----
 net/ipv4/ip_output.c | 8 ++++----
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c
index 7582713..7a03e8c 100644
--- a/net/ipv4/ip_input.c
+++ b/net/ipv4/ip_input.c
@@ -309,7 +309,7 @@ static inline bool ip_rcv_options(struct sk_buff *skb)
 
 static int ip_rcv_finish(struct net *net, struct sock *sk, struct sk_buff *skb)
 {
-	const struct iphdr *iph = ip_hdr(skb);
+	const struct iphdr *iph = (const struct iphdr *)skb->data;
 	int (*edemux)(struct sk_buff *skb);
 	struct net_device *dev = skb->dev;
 	struct rtable *rt;
@@ -335,7 +335,7 @@ static int ip_rcv_finish(struct net *net, struct sock *sk, struct sk_buff *skb)
 			if (unlikely(err))
 				goto drop_error;
 			/* must reload iph, skb->head might have changed */
-			iph = ip_hdr(skb);
+			iph = (const struct iphdr *)skb->data;
 		}
 	}
 
@@ -433,7 +433,7 @@ int ip_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt,
 	if (!pskb_may_pull(skb, sizeof(struct iphdr)))
 		goto inhdr_error;
 
-	iph = ip_hdr(skb);
+	iph = (const struct iphdr *)skb->data;
 
 	/*
 	 *	RFC1122: 3.2.1.2 MUST silently discard any IP frame that fails the checksum.
@@ -459,7 +459,7 @@ int ip_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt,
 	if (!pskb_may_pull(skb, iph->ihl*4))
 		goto inhdr_error;
 
-	iph = ip_hdr(skb);
+	iph = (const struct iphdr *)skb->data;
 
 	if (unlikely(ip_fast_csum((u8 *)iph, iph->ihl)))
 		goto csum_error;
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index af5a830..f5014cd 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -96,7 +96,7 @@ void ip_send_check(struct iphdr *iph)
 
 int __ip_local_out(struct net *net, struct sock *sk, struct sk_buff *skb)
 {
-	struct iphdr *iph = ip_hdr(skb);
+	struct iphdr *iph = (struct iphdr *)skb->data;
 
 	iph->tot_len = htons(skb->len);
 	ip_send_check(iph);
@@ -151,7 +151,7 @@ int ip_build_and_send_pkt(struct sk_buff *skb, const struct sock *sk,
 	/* Build the IP header. */
 	skb_push(skb, sizeof(struct iphdr) + (opt ? opt->opt.optlen : 0));
 	skb_reset_network_header(skb);
-	iph = ip_hdr(skb);
+	iph = (struct iphdr *)skb->data;
 	iph->version  = 4;
 	iph->ihl      = 5;
 	iph->tos      = inet->tos;
@@ -477,7 +477,7 @@ int ip_queue_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl)
 	/* OK, we know where to send it, allocate and build IP header. */
 	skb_push(skb, sizeof(struct iphdr) + (inet_opt ? inet_opt->opt.optlen : 0));
 	skb_reset_network_header(skb);
-	iph = ip_hdr(skb);
+	iph = (struct iphdr *)skb->data;
 	*((__be16 *)iph) = htons((4 << 12) | (5 << 8) | (inet->tos & 0xff));
 	if (ip_dont_fragment(sk, &rt->dst) && !skb->ignore_df)
 		iph->frag_off = htons(IP_DF);
@@ -659,7 +659,7 @@ int ip_do_fragment(struct net *net, struct sock *sk, struct sk_buff *skb,
 				__skb_push(frag, hlen);
 				skb_reset_network_header(frag);
 				memcpy(skb_network_header(frag), iph, hlen);
-				iph = ip_hdr(frag);
+				iph = (struct iphdr *)skb->data;
 				iph->tot_len = htons(frag->len);
 				ip_copy_metadata(frag, skb);
 				if (offset == 0)
-- 
1.8.3.1

^ permalink raw reply related

* [bpf-next PATCH 5/5] net: remove net_device operation ndo_xdp_flush
From: Jesper Dangaard Brouer @ 2018-06-05 11:55 UTC (permalink / raw)
  To: netdev, Daniel Borkmann, Alexei Starovoitov,
	Jesper Dangaard Brouer
  Cc: liu.song.a23, songliubraving, John Fastabend
In-Reply-To: <152819969561.7083.15427306662397720502.stgit@firesoul>

All drivers are cleaned up and no references to ndo_xdp_flush
are left in drivers, it is time to remove the net_device_ops
operation ndo_xdp_flush.

Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
---
 include/linux/netdevice.h |    4 ----
 1 file changed, 4 deletions(-)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 7f17785a59d7..42c6ea35a6f2 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -1192,9 +1192,6 @@ struct dev_ifalias {
  *	that got dropped are freed/returned via xdp_return_frame().
  *	Returns negative number, means general error invoking ndo, meaning
  *	no frames were xmit'ed and core-caller will free all frames.
- * void (*ndo_xdp_flush)(struct net_device *dev);
- *	This function is used to inform the driver to flush a particular
- *	xdp tx queue. Must be called on same CPU as xdp_xmit.
  */
 struct net_device_ops {
 	int			(*ndo_init)(struct net_device *dev);
@@ -1382,7 +1379,6 @@ struct net_device_ops {
 	int			(*ndo_xdp_xmit)(struct net_device *dev, int n,
 						struct xdp_frame **xdp,
 						u32 flags);
-	void			(*ndo_xdp_flush)(struct net_device *dev);
 };
 
 /**

^ permalink raw reply related

* [bpf-next PATCH 4/5] tun: remove ndo_xdp_flush call tun_xdp_flush
From: Jesper Dangaard Brouer @ 2018-06-05 11:55 UTC (permalink / raw)
  To: netdev, Daniel Borkmann, Alexei Starovoitov,
	Jesper Dangaard Brouer
  Cc: liu.song.a23, songliubraving, John Fastabend
In-Reply-To: <152819969561.7083.15427306662397720502.stgit@firesoul>

Remove the ndo_xdp_flush call implementation tun_xdp_flush
as no callers of ndo_xdp_flush are left.

The tun drivers XDP_TX implementation also used tun_xdp_flush (and
tun_xdp_xmit).  This is easily solved by passing the XDP_XMIT_FLUSH
flag to tun_xdp_xmit in tun_xdp_tx.

Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
---
 drivers/net/tun.c |   23 +----------------------
 1 file changed, 1 insertion(+), 22 deletions(-)

diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index d82a05fb0594..ef09224496e8 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1347,26 +1347,7 @@ static int tun_xdp_tx(struct net_device *dev, struct xdp_buff *xdp)
 	if (unlikely(!frame))
 		return -EOVERFLOW;
 
-	return tun_xdp_xmit(dev, 1, &frame, 0);
-}
-
-static void tun_xdp_flush(struct net_device *dev)
-{
-	struct tun_struct *tun = netdev_priv(dev);
-	struct tun_file *tfile;
-	u32 numqueues;
-
-	rcu_read_lock();
-
-	numqueues = READ_ONCE(tun->numqueues);
-	if (!numqueues)
-		goto out;
-
-	tfile = rcu_dereference(tun->tfiles[smp_processor_id() %
-					    numqueues]);
-	__tun_xdp_flush_tfile(tfile);
-out:
-	rcu_read_unlock();
+	return tun_xdp_xmit(dev, 1, &frame, XDP_XMIT_FLUSH);
 }
 
 static const struct net_device_ops tap_netdev_ops = {
@@ -1387,7 +1368,6 @@ static const struct net_device_ops tap_netdev_ops = {
 	.ndo_get_stats64	= tun_net_get_stats64,
 	.ndo_bpf		= tun_xdp,
 	.ndo_xdp_xmit		= tun_xdp_xmit,
-	.ndo_xdp_flush		= tun_xdp_flush,
 };
 
 static void tun_flow_init(struct tun_struct *tun)
@@ -1706,7 +1686,6 @@ static struct sk_buff *tun_build_skb(struct tun_struct *tun,
 			alloc_frag->offset += buflen;
 			if (tun_xdp_tx(tun->dev, &xdp))
 				goto err_redirect;
-			tun_xdp_flush(tun->dev);
 			rcu_read_unlock();
 			preempt_enable();
 			return NULL;

^ 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