Re: [PATCH bluetooth-next] 6lowpan: fix debugfs interface entry name

2015-12-19 Thread Marcel Holtmann
Hi Alex,

> This patches moves the debugfs interface related register after
> netdevice register. The function lowpan_dev_debugfs_init will use
> "dev->name" which can be before register_netdevice a format string.
> The function register_netdevice will evaluate the format string if
> necessary and replace "dev->name" to the real interface name.
> 
> Reported-by: Lukasz Duda 
> Signed-off-by: Alexander Aring 
> ---
> net/6lowpan/core.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] bluetooth:Fix variable assignment for internal function returns in the function l2cap_bredr_sig_cmd

2015-12-19 Thread Marcel Holtmann
Hi Nick,

> This makes all internal functions that can return a error code to
> properly signal this to the caller of the function l2cap_bredr_sig_cmd
> by making their return value equal to the variable err before returning
> to the caller of the function l2cap_bredr_sig_cmd with this value
> as to allow us to correctly signal when a failure has occurred when
> this particular function is called.
> 
> Signed-off-by: Nicholas Krause 
> ---
> net/bluetooth/l2cap_core.c | 8 
> 1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
> index 7c65ee2..488eebe 100644
> --- a/net/bluetooth/l2cap_core.c
> +++ b/net/bluetooth/l2cap_core.c
> @@ -5319,7 +5319,7 @@ static inline int l2cap_bredr_sig_cmd(struct l2cap_conn 
> *conn,
> 
>   switch (cmd->code) {
>   case L2CAP_COMMAND_REJ:
> - l2cap_command_rej(conn, cmd, cmd_len, data);
> + err = l2cap_command_rej(conn, cmd, cmd_len, data);
>   break;

this patch is wrong. Please try to understand on how L2CAP works and look up 
what the caller of l2cap_bredr_sig_cmd does with the return code. Responses can 
not cause another command reject.

Regards

Marcel

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 01/14] Bluetooth: use list_for_each_entry*

2015-12-19 Thread Marcel Holtmann
Hi Geliang,

> Use list_for_each_entry*() instead of list_for_each*() to simplify
> the code.
> 
> Signed-off-by: Geliang Tang 
> ---
> net/bluetooth/af_bluetooth.c | 12 ++--
> net/bluetooth/cmtp/capi.c|  8 ++--
> net/bluetooth/hci_core.c |  8 +++-
> net/bluetooth/rfcomm/core.c  | 46 ++--
> 4 files changed, 25 insertions(+), 49 deletions(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] can: sja1000: add documentation for Technologic Systems version

2015-12-19 Thread Rob Herring
On Fri, Dec 18, 2015 at 03:17:24PM -0500, Damien Riegel wrote:
> This commit adds documentation for the Technologic Systems version of
> SJA1000. The difference with the NXP version is in the way the registers
> are accessed.
> 
> Signed-off-by: Damien Riegel 
> ---
>  Documentation/devicetree/bindings/net/can/sja1000.txt | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/Documentation/devicetree/bindings/net/can/sja1000.txt 
> b/Documentation/devicetree/bindings/net/can/sja1000.txt
> index b4a6d53..7a158d5 100644
> --- a/Documentation/devicetree/bindings/net/can/sja1000.txt
> +++ b/Documentation/devicetree/bindings/net/can/sja1000.txt
> @@ -2,7 +2,7 @@ Memory mapped SJA1000 CAN controller from NXP (formerly 
> Philips)
>  
>  Required properties:
>  
> -- compatible : should be "nxp,sja1000".
> +- compatible : should be one of "nxp,sja1000", "technologic,sja1000".
>  
>  - reg : should specify the chip select, address offset and size required
>   to map the registers of the SJA1000. The size is usually 0x80.
> @@ -14,6 +14,7 @@ Optional properties:
>  
>  - reg-io-width : Specify the size (in bytes) of the IO accesses that
>   should be performed on the device.  Valid value is 1, 2 or 4.
> + Must be set to 2 for technologic version.
>   Default to 1 (8 bits).

Really, this should default to 2 for technologic version and not be 
required.

Rob
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[no subject]

2015-12-19 Thread Vitaly Davidovich
subscribe netdev 

Sent from my iPhone
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] sh_eth: fix 16-bit descriptor field access endianness too

2015-12-19 Thread Sergei Shtylyov
Commit 1299653affa4 ("sh_eth: fix descriptor access endianness") only
addressed the 32-bit buffer address field byte-swapping  but the driver
still accesses 16-bit frame/buffer length descriptor fields without the
necessary byte-swapping -- which should affect the big-endian kernels.
In order to be able to use {cpu|edmac}_to_{edmac|cpu}(), we need to declare
the RX/TX descriptor word 1 as a 32-bit field and use shifts/masking to
access the 16-bit subfields (which gets rid of the ugly #ifdef'ery too)...

Signed-off-by: Sergei Shtylyov 

---
The patch is against DaveM's 'net.git' repo.

 drivers/net/ethernet/renesas/sh_eth.c |   25 ++---
 drivers/net/ethernet/renesas/sh_eth.h |   33 -
 2 files changed, 30 insertions(+), 28 deletions(-)

Index: net/drivers/net/ethernet/renesas/sh_eth.c
===
--- net.orig/drivers/net/ethernet/renesas/sh_eth.c
+++ net/drivers/net/ethernet/renesas/sh_eth.c
@@ -1167,6 +1167,7 @@ static void sh_eth_ring_format(struct ne
int tx_ringsize = sizeof(*txdesc) * mdp->num_tx_ring;
int skbuff_size = mdp->rx_buf_sz + SH_ETH_RX_ALIGN + 32 - 1;
dma_addr_t dma_addr;
+   u32 buf_len;
 
mdp->cur_rx = 0;
mdp->cur_tx = 0;
@@ -1187,9 +1188,9 @@ static void sh_eth_ring_format(struct ne
/* RX descriptor */
rxdesc = &mdp->rx_ring[i];
/* The size of the buffer is a multiple of 32 bytes. */
-   rxdesc->buffer_length = ALIGN(mdp->rx_buf_sz, 32);
-   dma_addr = dma_map_single(&ndev->dev, skb->data,
- rxdesc->buffer_length,
+   buf_len = ALIGN(mdp->rx_buf_sz, 32);
+   rxdesc->len = cpu_to_edmac(mdp, buf_len << 16);
+   dma_addr = dma_map_single(&ndev->dev, skb->data, buf_len,
  DMA_FROM_DEVICE);
if (dma_mapping_error(&ndev->dev, dma_addr)) {
kfree_skb(skb);
@@ -1220,7 +1221,7 @@ static void sh_eth_ring_format(struct ne
mdp->tx_skbuff[i] = NULL;
txdesc = &mdp->tx_ring[i];
txdesc->status = cpu_to_edmac(mdp, TD_TFP);
-   txdesc->buffer_length = 0;
+   txdesc->len = cpu_to_edmac(mdp, 0);
if (i == 0) {
/* Tx descriptor address set */
sh_eth_write(ndev, mdp->tx_desc_dma, TDLAR);
@@ -1429,7 +1430,8 @@ static int sh_eth_txfree(struct net_devi
if (mdp->tx_skbuff[entry]) {
dma_unmap_single(&ndev->dev,
 edmac_to_cpu(mdp, txdesc->addr),
-txdesc->buffer_length, DMA_TO_DEVICE);
+edmac_to_cpu(mdp, txdesc->len) >> 16,
+DMA_TO_DEVICE);
dev_kfree_skb_irq(mdp->tx_skbuff[entry]);
mdp->tx_skbuff[entry] = NULL;
free_num++;
@@ -1439,7 +1441,7 @@ static int sh_eth_txfree(struct net_devi
txdesc->status |= cpu_to_edmac(mdp, TD_TDLE);
 
ndev->stats.tx_packets++;
-   ndev->stats.tx_bytes += txdesc->buffer_length;
+   ndev->stats.tx_bytes += edmac_to_cpu(mdp, txdesc->len) >> 16;
}
return free_num;
 }
@@ -1458,6 +1460,7 @@ static int sh_eth_rx(struct net_device *
u32 desc_status;
int skbuff_size = mdp->rx_buf_sz + SH_ETH_RX_ALIGN + 32 - 1;
dma_addr_t dma_addr;
+   u32 buf_len;
 
boguscnt = min(boguscnt, *quota);
limit = boguscnt;
@@ -1466,7 +1469,7 @@ static int sh_eth_rx(struct net_device *
/* RACT bit must be checked before all the following reads */
dma_rmb();
desc_status = edmac_to_cpu(mdp, rxdesc->status);
-   pkt_len = rxdesc->frame_length;
+   pkt_len = edmac_to_cpu(mdp, rxdesc->len) & RD_RFL;
 
if (--boguscnt < 0)
break;
@@ -1532,7 +1535,8 @@ static int sh_eth_rx(struct net_device *
entry = mdp->dirty_rx % mdp->num_rx_ring;
rxdesc = &mdp->rx_ring[entry];
/* The size of the buffer is 32 byte boundary. */
-   rxdesc->buffer_length = ALIGN(mdp->rx_buf_sz, 32);
+   buf_len = ALIGN(mdp->rx_buf_sz, 32);
+   rxdesc->len = cpu_to_edmac(mdp, buf_len << 16);
 
if (mdp->rx_skbuff[entry] == NULL) {
skb = netdev_alloc_skb(ndev, skbuff_size);
@@ -1540,8 +1544,7 @@ static int sh_eth_rx(struct net_device *
break;  /* Better luck next round. */
sh_eth_set_receive_align(skb);
dma_addr = dma_map_single(&ndev->dev, skb->data,
-  

Re: [PATCH] veth: don’t modify ip_summed; doing so treats packets with bad checksums as good.

2015-12-19 Thread Cong Wang
On Fri, Dec 18, 2015 at 11:34 AM, Vijay Pandurangan  wrote:
> Packets that arrive from real hardware devices have ip_summed ==
> CHECKSUM_UNNECESSARY if the hardware verified the checksums, or
> CHECKSUM_NONE if the packet is bad or it was unable to verify it. The
> current version of veth will replace CHECKSUM_NONE with
> CHECKSUM_UNNECESSARY, which causes corrupt packets routed from hardware to
> a veth device to be delivered to the application. This caused applications
> at Twitter to receive corrupt data when network hardware was corrupting
> packets.
>
> We believe this was added as an optimization to skip computing and
> verifying checksums for communication between containers. However, locally
> generated packets have ip_summed == CHECKSUM_PARTIAL, so the code as
> written does nothing for them. As far as we can tell, after removing this
> code, these packets are transmitted from one stack to another unmodified
> (tcpdump shows invalid checksums on both sides, as expected), and they are
> delivered correctly to applications. We didn’t test every possible network
> configuration, but we tried a few common ones such as bridging containers,
> using NAT between the host and a container, and routing from hardware
> devices to containers. We have effectively deployed this in production at
> Twitter (by disabling RX checksum offloading on veth devices).
>
> This code dates back to the first version of the driver, commit
>  ("[NET]: Virtual ethernet device driver"), so I
> suspect this bug occurred mostly because the driver API has evolved
> significantly since then. Commit <0b7967503dc97864f283a> ("net/veth: Fix
> packet checksumming") (in December 2010) fixed this for packets that get
> created locally and sent to hardware devices, by not changing
> CHECKSUM_PARTIAL. However, the same issue still occurs for packets coming
> in from hardware devices.
>
> Co-authored-by: Evan Jones 
> Signed-off-by: Evan Jones 
> Cc: Nicolas Dichtel 
> Cc: Phil Sutter 
> Cc: Toshiaki Makita 
> Cc: netdev@vger.kernel.org
> Cc: linux-ker...@vger.kernel.org
> Signed-off-by: Vijay Pandurangan 


Acked-by: Cong Wang 
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] veth: don't modify ip-summed; doing so treats packets with bad checksums as good.

2015-12-19 Thread Cong Wang
On Sat, Dec 19, 2015 at 1:01 PM, Cong Wang  wrote:
> On Fri, Dec 18, 2015 at 11:42 AM, Vijay Pandurangan  wrote:
>> Evan and I have demonstrated this bug on Kubernetes as well, so it's
>> not just a problem in Mesos. (See
>> https://github.com/kubernetes/kubernetes/issues/18898)
>>
>
> Interesting... then this problem is much more serious than I thought.
>
> Looks like in RX path the bridge sets the checksum to CHECKSUM_NONE
> too:
>
> static inline void skb_forward_csum(struct sk_buff *skb)
> {
> /* Unfortunately we don't support this one.  Any brave souls? */
> if (skb->ip_summed == CHECKSUM_COMPLETE)
> skb->ip_summed = CHECKSUM_NONE;
> }
>
> I guess this is probably why Docker/Kubernetes could be affected too.

Hmm, no, actually this is due to netem does the software checksum
and sets it to CHECKSUM_NONE:

if (q->corrupt && q->corrupt >= get_crandom(&q->corrupt_cor)) {
if (!(skb = skb_unshare(skb, GFP_ATOMIC)) ||
(skb->ip_summed == CHECKSUM_PARTIAL &&
 skb_checksum_help(skb)))
return qdisc_drop(skb, sch);

skb->data[prandom_u32() % skb_headlen(skb)] ^=
1<<(prandom_u32() % 8);
}


But anyway, your patch still looks correct to me.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] veth: don't modify ip-summed; doing so treats packets with bad checksums as good.

2015-12-19 Thread Cong Wang
On Fri, Dec 18, 2015 at 11:42 AM, Vijay Pandurangan  wrote:
> Evan and I have demonstrated this bug on Kubernetes as well, so it's
> not just a problem in Mesos. (See
> https://github.com/kubernetes/kubernetes/issues/18898)
>

Interesting... then this problem is much more serious than I thought.

Looks like in RX path the bridge sets the checksum to CHECKSUM_NONE
too:

static inline void skb_forward_csum(struct sk_buff *skb)
{
/* Unfortunately we don't support this one.  Any brave souls? */
if (skb->ip_summed == CHECKSUM_COMPLETE)
skb->ip_summed = CHECKSUM_NONE;
}

I guess this is probably why Docker/Kubernetes could be affected too.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] RDS: don't pretend to use cpu notifiers

2015-12-19 Thread Santosh Shilimkar
From: Sebastian Andrzej Siewior 

It looks like an attempt to use CPU notifier here which was never
completed. Nobody tried to wire it up completely since 2k9. So I unwind
this code and get rid of everything not required. Oh look! 19 lines were
removed while code still does the same thing.

Acked-by: Santosh Shilimkar 
Tested-by: Santosh Shilimkar 
Signed-off-by: Sebastian Andrzej Siewior 
---

v2:
Test and Ack tag added.

 net/rds/page.c | 31 ++-
 1 file changed, 6 insertions(+), 25 deletions(-)

diff --git a/net/rds/page.c b/net/rds/page.c
index 9005a2c..5a14e6d 100644
--- a/net/rds/page.c
+++ b/net/rds/page.c
@@ -179,37 +179,18 @@ out:
 }
 EXPORT_SYMBOL_GPL(rds_page_remainder_alloc);
 
-static int rds_page_remainder_cpu_notify(struct notifier_block *self,
-unsigned long action, void *hcpu)
+void rds_page_exit(void)
 {
-   struct rds_page_remainder *rem;
-   long cpu = (long)hcpu;
+   unsigned int cpu;
 
-   rem = &per_cpu(rds_page_remainders, cpu);
+   for_each_possible_cpu(cpu) {
+   struct rds_page_remainder *rem;
 
-   rdsdebug("cpu %ld action 0x%lx\n", cpu, action);
+   rem = &per_cpu(rds_page_remainders, cpu);
+   rdsdebug("cpu %u\n", cpu);
 
-   switch (action) {
-   case CPU_DEAD:
if (rem->r_page)
__free_page(rem->r_page);
rem->r_page = NULL;
-   break;
}
-
-   return 0;
-}
-
-static struct notifier_block rds_page_remainder_nb = {
-   .notifier_call = rds_page_remainder_cpu_notify,
-};
-
-void rds_page_exit(void)
-{
-   int i;
-
-   for_each_possible_cpu(i)
-   rds_page_remainder_cpu_notify(&rds_page_remainder_nb,
- (unsigned long)CPU_DEAD,
- (void *)(long)i);
 }
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: net, ipv6: out of bounds access in secret_stable

2015-12-19 Thread Cong Wang
On Fri, Dec 18, 2015 at 5:13 PM, Sasha Levin  wrote:
> Hi Hannes,
>
> I've hit the following out of bounds access while fuzzing on the latest -next 
> kernel.
>
> This code was added in 3d1bec9932 ("ipv6: introduce secret_stable to 
> ipv6_devconf").
>
> [  459.553655] BUG: KASAN: stack-out-of-bounds in strlen+0x58/0x90 at addr 
> 8802ab0efb0e
> [  459.554953] Read of size 1 by task trinity-c91/22576
> [  459.555805] page:ea000aac3bc0 count:0 mapcount:0 mapping:  
> (null) index:0x0
> [  459.556899] flags: 0x26f8000()
> [  459.557521] page dumped because: kasan: bad access detected
> [  459.558320] CPU: 7 PID: 22576 Comm: trinity-c91 Not tainted 
> 4.4.0-rc5-next-20151218-sasha-00021-gaba8d84-dirty #2750
> [  459.559809]   549d0aa3 8802ab0ef860 
> a1042384
> [  459.561036]  41b58ab3 ac667cdb a10422d9 
> 8802ab0ef848
> [  459.562245]  9f6a417e 549d0aa3 8802ab0efb0e 
> 8802ab0efb0e
> [  459.563429] Call Trace:
> [  459.563831] dump_stack (lib/dump_stack.c:52)
> [  459.564623] ? _atomic_dec_and_lock (lib/dump_stack.c:27)
> [  459.565628] ? __dump_page (mm/debug.c:126)
> [  459.566538] kasan_report_error (include/linux/kasan.h:28 
> mm/kasan/report.c:170 mm/kasan/report.c:237)
> [  459.570997] __asan_report_load1_noabort (mm/kasan/report.c:277)
> [  459.572119] ? check_preemption_disabled (lib/smp_processor_id.c:39)
> [  459.573731] ? strlen (lib/string.c:481 (discriminator 1))
> [  459.574646] strlen (lib/string.c:481 (discriminator 1))
> [  459.575485] proc_dostring (kernel/sysctl.c:1825 kernel/sysctl.c:1906)
> [  459.576445] ? alloc_debug_processing (mm/slub.c:1054)
> [  459.577523] addrconf_sysctl_stable_secret (net/ipv6/addrconf.c:5395)

Looks like we don't initialize the array on stack for write case.
At least other callers always initialize the data for both read
and write.

Please try the attached patch.

Thanks!
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 17f8e7e..8d4fa7c 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -5369,13 +5369,11 @@ static int addrconf_sysctl_stable_secret(struct 
ctl_table *ctl, int write,
goto out;
}
 
-   if (!write) {
-   err = snprintf(str, sizeof(str), "%pI6",
-  &secret->secret);
-   if (err >= sizeof(str)) {
-   err = -EIO;
-   goto out;
-   }
+   err = snprintf(str, sizeof(str), "%pI6",
+  &secret->secret);
+   if (err >= sizeof(str)) {
+   err = -EIO;
+   goto out;
}
 
err = proc_dostring(&lctl, write, buffer, lenp, ppos);


Merry Christmas

2015-12-19 Thread xpp74
外贸客户开发轻松入门;
软件针对外贸行业的客户开发系统,具有惊人的客户搜索速度和非常好的推广效果。
可以利用你们的产品的“关键词”搜索出你们行业的所有的经销商,进口商,OEM商等所有的联系方式,直击终端客户。
完全避开B2B的价格战,展会的成本高,主动出击迅速找到真正对你们产品感兴趣的客户。
加Q--Q:2036-019519免费为您演示软件功能以及效果。

Re: [PATCH v2] natsemi: add checks for dma mapping errors

2015-12-19 Thread David Miller
From: Alexey Khoroshilov 
Date: Sat, 19 Dec 2015 15:13:49 +0300

> refill_rx() and start_tx() do not check if mapping dma memory succeed.
> The patch adds the checks and failure handling.
> 
> Found by Linux Driver Verification project (linuxtesting.org).
> 
> Signed-off-by: Alexey Khoroshilov 

Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] natsemi: add checks for dma mapping errors

2015-12-19 Thread David Miller
From: Alexey Khoroshilov 
Date: Sat, 19 Dec 2015 15:06:45 +0300

> On 19.12.2015 05:36, David Miller wrote:
>> From: Alexey Khoroshilov 
>> Date: Sat, 19 Dec 2015 00:55:37 +0300
>>
>>> @@ -2093,6 +2099,10 @@ static netdev_tx_t start_tx(struct sk_buff
> *skb, struct net_device *dev)
>>> np->tx_skbuff[entry] = skb;
>>> np->tx_dma[entry] = pci_map_single(np->pci_dev,
>>> skb->data,skb->len, PCI_DMA_TODEVICE);
>>> +   if (pci_dma_mapping_error(np->pci_dev, np->tx_dma[entry])) {
>>> +   np->tx_skbuff[entry] = NULL;
>>> +   return NETDEV_TX_BUSY;
>>> +   }
>>>
>>> np->tx_ring[entry].addr = cpu_to_le32(np->tx_dma[entry]);
>>>
>>
>> Returning NETDEV_TX_BUSY and freeing the SKB will crash the system.
> 
> I do not quite understand what do you mean by 'freeing the SKB'.
> At least the patch left skb untouched.

Sorry, I misread your patch, I thought I saw a kfree there but
obviously there isn't.

>> NETDEV_TX_BUSY is only for buggy drivers that do not manage their
>> TX ring busy condition correctly, and thus need retries.
> 
> Ok, I will replace NETDEV_TX_BUSY by dropping the packet.

Thanks.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] [iproute2] tc/q_htb.c: rename b4 buffer to b3 to make its name more consistent

2015-12-19 Thread Dmitrii Shcherbakov
b3 buffer has been deleted previously so b2 is followed by b4 which is not 
consistent

Signed-off-by: Dmitrii Shcherbakov 
Acked-by: Jesper Dangaard Brouer 
Acked-by: Phil Sutter 
---
 tc/q_htb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tc/q_htb.c b/tc/q_htb.c
index e76d20a..7d54090 100644
--- a/tc/q_htb.c
+++ b/tc/q_htb.c
@@ -273,7 +273,7 @@ static int htb_print_opt(struct qdisc_util *qu, FILE *f, 
struct rtattr *opt)
__u64 rate64, ceil64;
SPRINT_BUF(b1);
SPRINT_BUF(b2);
-   SPRINT_BUF(b4);
+   SPRINT_BUF(b3);
 
if (opt == NULL)
return 0;
@@ -310,7 +310,7 @@ static int htb_print_opt(struct qdisc_util *qu, FILE *f, 
struct rtattr *opt)
cbuffer = tc_calc_xmitsize(ceil64, hopt->cbuffer);
linklayer = (hopt->rate.linklayer & TC_LINKLAYER_MASK);
if (linklayer > TC_LINKLAYER_ETHERNET || show_details)
-   fprintf(f, "linklayer %s ", sprint_linklayer(linklayer, 
b4));
+   fprintf(f, "linklayer %s ", sprint_linklayer(linklayer, 
b3));
if (show_details) {
fprintf(f, "burst %s/%u mpu %s ",
sprint_size(buffer, b1),
-- 
2.5.0
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] [iproute2] tc/q_htb.c: remove printing of a deprecated overhead value previously encoded as a part of mpu field

2015-12-19 Thread Dmitrii Shcherbakov
Remove printing according to the previously used encoding of mpu and overhead 
values within the tc_ratespec's mpu field. This encoding is no longer being 
used as a separate 'overhead' field in the ratespec structure has been 
introduced.

Signed-off-by: Dmitrii Shcherbakov 
Acked-by: Jesper Dangaard Brouer 
Acked-by: Phil Sutter 
---
 tc/q_htb.c | 11 ---
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/tc/q_htb.c b/tc/q_htb.c
index 7075a4c..e76d20a 100644
--- a/tc/q_htb.c
+++ b/tc/q_htb.c
@@ -273,7 +273,6 @@ static int htb_print_opt(struct qdisc_util *qu, FILE *f, 
struct rtattr *opt)
__u64 rate64, ceil64;
SPRINT_BUF(b1);
SPRINT_BUF(b2);
-   SPRINT_BUF(b3);
SPRINT_BUF(b4);
 
if (opt == NULL)
@@ -313,16 +312,14 @@ static int htb_print_opt(struct qdisc_util *qu, FILE *f, 
struct rtattr *opt)
if (linklayer > TC_LINKLAYER_ETHERNET || show_details)
fprintf(f, "linklayer %s ", sprint_linklayer(linklayer, 
b4));
if (show_details) {
-   fprintf(f, "burst %s/%u mpu %s overhead %s ",
+   fprintf(f, "burst %s/%u mpu %s ",
sprint_size(buffer, b1),
1rate.mpu&0xFF, b2),
-   sprint_size((hopt->rate.mpu>>8)&0xFF, b3));
-   fprintf(f, "cburst %s/%u mpu %s overhead %s ",
+   sprint_size(hopt->rate.mpu, b2));
+   fprintf(f, "cburst %s/%u mpu %s ",
sprint_size(cbuffer, b1),
1ceil.mpu&0xFF, b2),
-   sprint_size((hopt->ceil.mpu>>8)&0xFF, b3));
+   sprint_size(hopt->ceil.mpu, b2));
fprintf(f, "level %d ", (int)hopt->level);
} else {
fprintf(f, "burst %s ", sprint_size(buffer, b1));
-- 
2.5.0
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] rsi: consolidate kmalloc/memset 0 calls to kzalloc

2015-12-19 Thread Nicholas Mc Guire
This is an API consolidation only. The use of kmalloc + memset to 0
is equivalent to kzalloc.

Signed-off-by: Nicholas Mc Guire 
---

Found by coccinelle script (relaxed version of
scripts/coccinelle/api/alloc/kzalloc-simple.cocci)

Patch was compile tested with: x86_64_defconfig +
CONFIG_RSI_91X=m

Patch is against linux-next (localversion-next is -next-20151218)

 drivers/net/wireless/rsi/rsi_91x_mgmt.c |3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/wireless/rsi/rsi_91x_mgmt.c 
b/drivers/net/wireless/rsi/rsi_91x_mgmt.c
index 8d110fd..697caab 100644
--- a/drivers/net/wireless/rsi/rsi_91x_mgmt.c
+++ b/drivers/net/wireless/rsi/rsi_91x_mgmt.c
@@ -1023,7 +1023,7 @@ static int rsi_send_auto_rate_request(struct rsi_common 
*common)
return -ENOMEM;
}
 
-   selected_rates = kmalloc(2 * RSI_TBL_SZ, GFP_KERNEL);
+   selected_rates = kzalloc(2 * RSI_TBL_SZ, GFP_KERNEL);
if (!selected_rates) {
rsi_dbg(ERR_ZONE, "%s: Failed in allocation of mem\n",
__func__);
@@ -1032,7 +1032,6 @@ static int rsi_send_auto_rate_request(struct rsi_common 
*common)
}
 
memset(skb->data, 0, sizeof(struct rsi_auto_rate));
-   memset(selected_rates, 0, 2 * RSI_TBL_SZ);
 
auto_rate = (struct rsi_auto_rate *)skb->data;
 
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] rsi: bool tests do not need comparison

2015-12-19 Thread Nicholas Mc Guire
This is an API consolidation only. Bool initializations should 
use true and false thus bool tests don't need an explicit comparison.

Signed-off-by: Nicholas Mc Guire 
---

Found by coccinelle: scripts/coccinelle/misc/boolinit.cocci

Patch was compile tested with: x86_64_defconfig +
CONFIG_RSI_91X=m

Patch is against linux-next (localversion-next is -next-20151218)

 drivers/net/wireless/rsi/rsi_91x_mgmt.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/rsi/rsi_91x_mgmt.c 
b/drivers/net/wireless/rsi/rsi_91x_mgmt.c
index 8d110fd..90161aa 100644
--- a/drivers/net/wireless/rsi/rsi_91x_mgmt.c
+++ b/drivers/net/wireless/rsi/rsi_91x_mgmt.c
@@ -1227,7 +1227,7 @@ int rsi_send_block_unblock_frame(struct rsi_common 
*common, bool block_event)
mgmt_frame->desc_word[0] = cpu_to_le16(RSI_WIFI_MGMT_Q << 12);
mgmt_frame->desc_word[1] = cpu_to_le16(BLOCK_HW_QUEUE);
 
-   if (block_event == true) {
+   if (block_event) {
rsi_dbg(INFO_ZONE, "blocking the data qs\n");
mgmt_frame->desc_word[4] = cpu_to_le16(0xf);
} else {
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[RFC PATCH] can: sja1000: of: add per-compatible init hook

2015-12-19 Thread Damien Riegel
This commit adds the capability to allocate and init private data
embedded in the sja1000_priv structure on a per-compatible basis. The
device node is passed as a parameter of the init callback to allow
parsing of custom device tree properties.

Signed-off-by: Damien Riegel 
---
Hi Marc,


I am sending this patch as RFC as I have only compile-tested it, but I
would like your feedback on it.

The idea of this patch is to ease integration of the Technologic Systems
version of this IP in the most generic way, providing a facility that
could be used by others.


Thanks,
Damien

 drivers/net/can/sja1000/sja1000_platform.c | 44 +-
 1 file changed, 37 insertions(+), 7 deletions(-)

diff --git a/drivers/net/can/sja1000/sja1000_platform.c 
b/drivers/net/can/sja1000/sja1000_platform.c
index 0552ed4..33581b0 100644
--- a/drivers/net/can/sja1000/sja1000_platform.c
+++ b/drivers/net/can/sja1000/sja1000_platform.c
@@ -40,6 +40,11 @@ MODULE_DESCRIPTION("Socket-CAN driver for SJA1000 on the 
platform bus");
 MODULE_ALIAS("platform:" DRV_NAME);
 MODULE_LICENSE("GPL v2");
 
+struct sja1000_of_data {
+   size_t  priv_sz;
+   int (*init)(struct sja1000_priv *priv, struct device_node *of);
+};
+
 static u8 sp_read_reg8(const struct sja1000_priv *priv, int reg)
 {
return ioread8(priv->reg_base + reg);
@@ -154,6 +159,26 @@ static void sp_populate_of(struct sja1000_priv *priv, 
struct device_node *of)
priv->cdr |= CDR_CBP; /* default */
 }
 
+static const struct of_device_id sp_of_table[] = {
+   {.compatible = "nxp,sja1000"},
+   {},
+};
+MODULE_DEVICE_TABLE(of, sp_of_table);
+
+static const struct sja1000_of_data *sp_get_of_data(struct device_node *of)
+{
+   const struct of_device_id *id;
+
+   if (!of)
+   return NULL;
+
+   id = of_match_node(sp_of_table, of);
+   if (!id)
+   return NULL;
+
+   return id->data;
+}
+
 static int sp_probe(struct platform_device *pdev)
 {
int err, irq = 0;
@@ -163,6 +188,8 @@ static int sp_probe(struct platform_device *pdev)
struct resource *res_mem, *res_irq = NULL;
struct sja1000_platform_data *pdata;
struct device_node *of = pdev->dev.of_node;
+   const struct sja1000_of_data *of_data = sp_get_of_data(of);
+   size_t priv_sz = 0;
 
pdata = dev_get_platdata(&pdev->dev);
if (!pdata && !of) {
@@ -191,7 +218,10 @@ static int sp_probe(struct platform_device *pdev)
if (!irq && !res_irq)
return -ENODEV;
 
-   dev = alloc_sja1000dev(0);
+   if (of_data)
+   priv_sz = of_data->priv_sz;
+
+   dev = alloc_sja1000dev(priv_sz);
if (!dev)
return -ENOMEM;
priv = netdev_priv(dev);
@@ -213,6 +243,12 @@ static int sp_probe(struct platform_device *pdev)
else
sp_populate(priv, pdata, res_mem->flags);
 
+   if (of_data && of_data->init) {
+   err = of_data->init(priv, of);
+   if (err)
+   goto exit_free;
+   }
+
platform_set_drvdata(pdev, dev);
SET_NETDEV_DEV(dev, &pdev->dev);
 
@@ -242,12 +278,6 @@ static int sp_remove(struct platform_device *pdev)
return 0;
 }
 
-static const struct of_device_id sp_of_table[] = {
-   {.compatible = "nxp,sja1000"},
-   {},
-};
-MODULE_DEVICE_TABLE(of, sp_of_table);
-
 static struct platform_driver sp_driver = {
.probe = sp_probe,
.remove = sp_remove,
-- 
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Migrate all elements from net_device_stats

2015-12-19 Thread Corcodel Marian
Hi
This is not patch .On net_device structure only 2 elements from old
structure net_device_stats exists rx_dropped and tx_dropped why please
put alls elements from net_device_stats for bee ready for atomic
operations.
/include/linux/netdevice.h
-- 
Corcodel Marian 

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 03/14 v2] ipv4, ipv6: use list_for_each_entry*

2015-12-19 Thread Julia Lawall


On Sat, 19 Dec 2015, Geliang Tang wrote:

> Use list_for_each_entry*() instead of list_for_each*() to simplify
> the code.

Is the code really simpler?  At least in the case of net/ipv6/addrconf.c,
I have the impression that there can be an access from a pointer that is
not really pointing to the thing indicated by its type.  The code seems to
work, but this doesn't seem like a good property for it to have.  In these
cases, you need access to both the list and to the entry.  The original
code seemed like a reasonable way to express that.

julia

> Signed-off-by: Geliang Tang 
> ---
> Changes in v2:
>  - bugfix for inet6_register_protosw in v1.
> ---
>  net/ipv4/af_inet.c| 11 ---
>  net/ipv4/tcp_output.c |  6 ++
>  net/ipv6/addrconf.c   |  8 +++-
>  net/ipv6/af_inet6.c   | 19 +--
>  4 files changed, 14 insertions(+), 30 deletions(-)
>
> diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
> index 11c4ca1..eedf814 100644
> --- a/net/ipv4/af_inet.c
> +++ b/net/ipv4/af_inet.c
> @@ -1028,10 +1028,8 @@ static struct inet_protosw inetsw_array[] =
>
>  void inet_register_protosw(struct inet_protosw *p)
>  {
> - struct list_head *lh;
> - struct inet_protosw *answer;
> + struct inet_protosw *answer, *last_perm;
>   int protocol = p->protocol;
> - struct list_head *last_perm;
>
>   spin_lock_bh(&inetsw_lock);
>
> @@ -1040,14 +1038,13 @@ void inet_register_protosw(struct inet_protosw *p)
>
>   /* If we are trying to override a permanent protocol, bail. */
>   last_perm = &inetsw[p->type];
> - list_for_each(lh, &inetsw[p->type]) {
> - answer = list_entry(lh, struct inet_protosw, list);
> + list_for_each_entry(answer, &inetsw[p->type], list) {
>   /* Check only the non-wild match. */
>   if ((INET_PROTOSW_PERMANENT & answer->flags) == 0)
>   break;
>   if (protocol == answer->protocol)
>   goto out_permanent;
> - last_perm = lh;
> + last_perm = answer;
>   }
>
>   /* Add the new entry after the last permanent entry if any, so that
> @@ -1056,7 +1053,7 @@ void inet_register_protosw(struct inet_protosw *p)
>* non-permanent entry.  This means that when we remove this entry, the
>* system automatically returns to the old behavior.
>*/
> - list_add_rcu(&p->list, last_perm);
> + list_add_rcu(&p->list, &last_perm->list);
>  out:
>   spin_unlock_bh(&inetsw_lock);
>
> diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
> index a800cee..8810694 100644
> --- a/net/ipv4/tcp_output.c
> +++ b/net/ipv4/tcp_output.c
> @@ -751,16 +751,14 @@ static void tcp_tasklet_func(unsigned long data)
>   struct tsq_tasklet *tsq = (struct tsq_tasklet *)data;
>   LIST_HEAD(list);
>   unsigned long flags;
> - struct list_head *q, *n;
> - struct tcp_sock *tp;
> + struct tcp_sock *tp, *n;
>   struct sock *sk;
>
>   local_irq_save(flags);
>   list_splice_init(&tsq->head, &list);
>   local_irq_restore(flags);
>
> - list_for_each_safe(q, n, &list) {
> - tp = list_entry(q, struct tcp_sock, tsq_node);
> + list_for_each_entry_safe(tp, n, &list, tsq_node) {
>   list_del(&tp->tsq_node);
>
>   sk = (struct sock *)tp;
> diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
> index 7082fb7..e293647 100644
> --- a/net/ipv6/addrconf.c
> +++ b/net/ipv6/addrconf.c
> @@ -865,21 +865,19 @@ void inet6_ifa_finish_destroy(struct inet6_ifaddr *ifp)
>  static void
>  ipv6_link_dev_addr(struct inet6_dev *idev, struct inet6_ifaddr *ifp)
>  {
> - struct list_head *p;
> + struct inet6_ifaddr *ifa;
>   int ifp_scope = ipv6_addr_src_scope(&ifp->addr);
>
>   /*
>* Each device address list is sorted in order of scope -
>* global before linklocal.
>*/
> - list_for_each(p, &idev->addr_list) {
> - struct inet6_ifaddr *ifa
> - = list_entry(p, struct inet6_ifaddr, if_list);
> + list_for_each_entry(ifa, &idev->addr_list, if_list) {
>   if (ifp_scope >= ipv6_addr_src_scope(&ifa->addr))
>   break;
>   }
>
> - list_add_tail(&ifp->if_list, p);
> + list_add_tail(&ifp->if_list, &ifa->if_list);
>  }
>
>  static u32 inet6_addr_hash(const struct in6_addr *addr)
> diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
> index 8ec0df7..437a500 100644
> --- a/net/ipv6/af_inet6.c
> +++ b/net/ipv6/af_inet6.c
> @@ -568,9 +568,7 @@ static const struct net_proto_family inet6_family_ops = {
>
>  int inet6_register_protosw(struct inet_protosw *p)
>  {
> - struct list_head *lh;
> - struct inet_protosw *answer;
> - struct list_head *last_perm;
> + struct inet_protosw *answer, *last_perm;
>   int protocol = p->protocol;
>   int ret;
>
> @@ -581,23 +579,16 @@ int inet6_register_protosw(struct inet_protosw *p)
>   goto out_illegal;
>
>

[PATCH 03/14 v2] ipv4, ipv6: use list_for_each_entry*

2015-12-19 Thread Geliang Tang
Use list_for_each_entry*() instead of list_for_each*() to simplify
the code.

Signed-off-by: Geliang Tang 
---
Changes in v2:
 - bugfix for inet6_register_protosw in v1.
---
 net/ipv4/af_inet.c| 11 ---
 net/ipv4/tcp_output.c |  6 ++
 net/ipv6/addrconf.c   |  8 +++-
 net/ipv6/af_inet6.c   | 19 +--
 4 files changed, 14 insertions(+), 30 deletions(-)

diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index 11c4ca1..eedf814 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -1028,10 +1028,8 @@ static struct inet_protosw inetsw_array[] =
 
 void inet_register_protosw(struct inet_protosw *p)
 {
-   struct list_head *lh;
-   struct inet_protosw *answer;
+   struct inet_protosw *answer, *last_perm;
int protocol = p->protocol;
-   struct list_head *last_perm;
 
spin_lock_bh(&inetsw_lock);
 
@@ -1040,14 +1038,13 @@ void inet_register_protosw(struct inet_protosw *p)
 
/* If we are trying to override a permanent protocol, bail. */
last_perm = &inetsw[p->type];
-   list_for_each(lh, &inetsw[p->type]) {
-   answer = list_entry(lh, struct inet_protosw, list);
+   list_for_each_entry(answer, &inetsw[p->type], list) {
/* Check only the non-wild match. */
if ((INET_PROTOSW_PERMANENT & answer->flags) == 0)
break;
if (protocol == answer->protocol)
goto out_permanent;
-   last_perm = lh;
+   last_perm = answer;
}
 
/* Add the new entry after the last permanent entry if any, so that
@@ -1056,7 +1053,7 @@ void inet_register_protosw(struct inet_protosw *p)
 * non-permanent entry.  This means that when we remove this entry, the
 * system automatically returns to the old behavior.
 */
-   list_add_rcu(&p->list, last_perm);
+   list_add_rcu(&p->list, &last_perm->list);
 out:
spin_unlock_bh(&inetsw_lock);
 
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index a800cee..8810694 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -751,16 +751,14 @@ static void tcp_tasklet_func(unsigned long data)
struct tsq_tasklet *tsq = (struct tsq_tasklet *)data;
LIST_HEAD(list);
unsigned long flags;
-   struct list_head *q, *n;
-   struct tcp_sock *tp;
+   struct tcp_sock *tp, *n;
struct sock *sk;
 
local_irq_save(flags);
list_splice_init(&tsq->head, &list);
local_irq_restore(flags);
 
-   list_for_each_safe(q, n, &list) {
-   tp = list_entry(q, struct tcp_sock, tsq_node);
+   list_for_each_entry_safe(tp, n, &list, tsq_node) {
list_del(&tp->tsq_node);
 
sk = (struct sock *)tp;
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 7082fb7..e293647 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -865,21 +865,19 @@ void inet6_ifa_finish_destroy(struct inet6_ifaddr *ifp)
 static void
 ipv6_link_dev_addr(struct inet6_dev *idev, struct inet6_ifaddr *ifp)
 {
-   struct list_head *p;
+   struct inet6_ifaddr *ifa;
int ifp_scope = ipv6_addr_src_scope(&ifp->addr);
 
/*
 * Each device address list is sorted in order of scope -
 * global before linklocal.
 */
-   list_for_each(p, &idev->addr_list) {
-   struct inet6_ifaddr *ifa
-   = list_entry(p, struct inet6_ifaddr, if_list);
+   list_for_each_entry(ifa, &idev->addr_list, if_list) {
if (ifp_scope >= ipv6_addr_src_scope(&ifa->addr))
break;
}
 
-   list_add_tail(&ifp->if_list, p);
+   list_add_tail(&ifp->if_list, &ifa->if_list);
 }
 
 static u32 inet6_addr_hash(const struct in6_addr *addr)
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index 8ec0df7..437a500 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -568,9 +568,7 @@ static const struct net_proto_family inet6_family_ops = {
 
 int inet6_register_protosw(struct inet_protosw *p)
 {
-   struct list_head *lh;
-   struct inet_protosw *answer;
-   struct list_head *last_perm;
+   struct inet_protosw *answer, *last_perm;
int protocol = p->protocol;
int ret;
 
@@ -581,23 +579,16 @@ int inet6_register_protosw(struct inet_protosw *p)
goto out_illegal;
 
/* If we are trying to override a permanent protocol, bail. */
-   answer = NULL;
ret = -EPERM;
last_perm = &inetsw6[p->type];
-   list_for_each(lh, &inetsw6[p->type]) {
-   answer = list_entry(lh, struct inet_protosw, list);
-
+   list_for_each_entry(answer, &inetsw6[p->type], list) {
/* Check only the non-wild match. */
if (INET_PROTOSW_PERMANENT & answer->flags) {
if (protocol == answer->protocol)
-   break;
-

[PATCH v2] natsemi: add checks for dma mapping errors

2015-12-19 Thread Alexey Khoroshilov
refill_rx() and start_tx() do not check if mapping dma memory succeed.
The patch adds the checks and failure handling.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov 
---
 drivers/net/ethernet/natsemi/natsemi.c | 12 
 1 file changed, 12 insertions(+)

diff --git a/drivers/net/ethernet/natsemi/natsemi.c 
b/drivers/net/ethernet/natsemi/natsemi.c
index b83f7c0fcf99..122c2ee3dfe2 100644
--- a/drivers/net/ethernet/natsemi/natsemi.c
+++ b/drivers/net/ethernet/natsemi/natsemi.c
@@ -1937,6 +1937,12 @@ static void refill_rx(struct net_device *dev)
break; /* Better luck next round. */
np->rx_dma[entry] = pci_map_single(np->pci_dev,
skb->data, buflen, PCI_DMA_FROMDEVICE);
+   if (pci_dma_mapping_error(np->pci_dev,
+ np->rx_dma[entry])) {
+   dev_kfree_skb_any(skb);
+   np->rx_skbuff[entry] = NULL;
+   break; /* Better luck next round. */
+   }
np->rx_ring[entry].addr = 
cpu_to_le32(np->rx_dma[entry]);
}
np->rx_ring[entry].cmd_status = cpu_to_le32(np->rx_buf_sz);
@@ -2093,6 +2099,12 @@ static netdev_tx_t start_tx(struct sk_buff *skb, struct 
net_device *dev)
np->tx_skbuff[entry] = skb;
np->tx_dma[entry] = pci_map_single(np->pci_dev,
skb->data,skb->len, PCI_DMA_TODEVICE);
+   if (pci_dma_mapping_error(np->pci_dev, np->tx_dma[entry])) {
+   np->tx_skbuff[entry] = NULL;
+   dev_kfree_skb_irq(skb);
+   dev->stats.tx_dropped++;
+   return NETDEV_TX_OK;
+   }
 
np->tx_ring[entry].addr = cpu_to_le32(np->tx_dma[entry]);
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] natsemi: add checks for dma mapping errors

2015-12-19 Thread Alexey Khoroshilov
On 19.12.2015 05:36, David Miller wrote:
> From: Alexey Khoroshilov 
> Date: Sat, 19 Dec 2015 00:55:37 +0300
>
>> @@ -2093,6 +2099,10 @@ static netdev_tx_t start_tx(struct sk_buff
*skb, struct net_device *dev)
>>  np->tx_skbuff[entry] = skb;
>>  np->tx_dma[entry] = pci_map_single(np->pci_dev,
>>  skb->data,skb->len, PCI_DMA_TODEVICE);
>> +if (pci_dma_mapping_error(np->pci_dev, np->tx_dma[entry])) {
>> +np->tx_skbuff[entry] = NULL;
>> +return NETDEV_TX_BUSY;
>> +}
>>
>>  np->tx_ring[entry].addr = cpu_to_le32(np->tx_dma[entry]);
>>
>
> Returning NETDEV_TX_BUSY and freeing the SKB will crash the system.

I do not quite understand what do you mean by 'freeing the SKB'.
At least the patch left skb untouched.

But I saw such pattern, for example, in
drivers/net/ethernet/freescale/fec_main.c:

addr = dma_map_single(&fep->pdev->dev, data, size, DMA_TO_DEVICE);
if (dma_mapping_error(&fep->pdev->dev, addr)) {
dev_kfree_skb_any(skb);
if (net_ratelimit())
netdev_err(ndev, "Tx DMA memory map failed\n");
return NETDEV_TX_BUSY;
}

>
> NETDEV_TX_BUSY is only for buggy drivers that do not manage their
> TX ring busy condition correctly, and thus need retries.

Ok, I will replace NETDEV_TX_BUSY by dropping the packet.

--
Alexey

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html