Netdev List
 help / color / mirror / Atom feed
* Re: [PATCH] bgmac: driver for GBit MAC core on BCMA bus
From: Joe Perches @ 2012-12-26 22:24 UTC (permalink / raw)
  To: Rafał Miłecki; +Cc: netdev, David S. Miller
In-Reply-To: <1356363222-16672-1-git-send-email-zajec5@gmail.com>

On Mon, 2012-12-24 at 16:33 +0100, Rafał Miłecki wrote:
> BCMA is a Broadcom specific bus with devices AKA cores. All recent BCMA
> based SoCs have gigabit ethernet provided by the GBit MAC core. This
> patch adds driver for such a cores registering itself as a netdev. It
> has been tested on a BCM4706 and BCM4718 chipsets.

Just a trivial note:

> diff --git a/drivers/net/ethernet/broadcom/bgmac.h b/drivers/net/ethernet/broadcom/bgmac.h
[]
> @@ -0,0 +1,443 @@
> +#ifndef _BGMAC_H
> +#define _BGMAC_H
> +
> +#define pr_fmt(fmt)		KBUILD_MODNAME ": " fmt
> +
> +#define bgmac_err(bgmac, fmt, ...) \
> +	pr_err("u%d: " fmt, (bgmac)->core->core_unit, ##__VA_ARGS__)
> +#define bgmac_warn(bgmac, fmt, ...) \
> +	pr_warn("u%d: " fmt, (bgmac)->core->core_unit, ##__VA_ARGS__)
> +#define bgmac_info(bgmac, fmt, ...) \
> +	pr_info("u%d: " fmt, (bgmac)->core->core_unit, ##__VA_ARGS__)
> +#define bgmac_dbg(bgmac, fmt, ...) \
> +	pr_debug("u%d: " fmt, (bgmac)->core->core_unit, ##__VA_ARGS__)

Maybe all the bgmac_<level> macros should be:

	dev_<level>(&bgmac->core->dev, "u%d: " fmt,
	            (bgmac)->core->core_unit, ##__VA_ARGS)

or maybe a new function like below if you use
a lot of these to decrease object size a little.

int bgmac_printk(const char *level, const struct bgmac *bgmac,
                 const char *fmt, ...)
{

	struct va_format vaf;
	va_list args;
	int r;

	va_start(args, fmt);

	vaf.fmt = fmt;
	vaf.va = &args;

	r = dev_printk(&bgmac->core->dev, "u%d: %pV",
	               bgmac->core->core_unit, &vaf);

	va_end(args);

	return r;
}

^ permalink raw reply

* Re: [PATCH] netprio_cgroup: define sk_cgrp_prioidx only if NETPRIO_CGROUP is enabled
From: David Miller @ 2012-12-26 22:16 UTC (permalink / raw)
  To: nhorman-2XuSBdqkA4R54TAoqtyWWQ
  Cc: lizefan-hv44wF8Li93QT0dZR+AlfA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	netdev-u79uwXL29TY76Z2rM5mHXA, cgroups-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <20121226180339.GB10793-0o1r3XBGOEbbgkc5XkKeNuvMHUBZFtU3YPYVAmT7z5s@public.gmane.org>

From: Neil Horman <nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>
Date: Wed, 26 Dec 2012 13:03:39 -0500

> On Wed, Dec 26, 2012 at 02:48:24PM +0800, Li Zefan wrote:
>> sock->sk_cgrp_prioidx won't be used at all if CONFIG_NETPRIO_CGROUP=n.
>> 
>> Signed-off-by: Li Zefan <lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
> Acked-by: Neil Horman <nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>

Applied, thanks.

^ permalink raw reply

* Re: [PATCH v2 0/2] cpts fixes for v3.8-rc2
From: David Miller @ 2012-12-26 22:15 UTC (permalink / raw)
  To: richardcochran
  Cc: netdev, linux-arm-kernel, linux-omap, cyril, mugunthanvnm,
	sshtylyov
In-Reply-To: <cover.1356331925.git.richardcochran@gmail.com>

From: Richard Cochran <richardcochran@gmail.com>
Date: Mon, 24 Dec 2012 08:19:08 +0100

> Changed in v2:
> Use clk_prepare_enable instead of clk_prepare + clk_enable.
> 
> The new cpts driver has two small issues, but it otherwise seems to be
> working in -rc1.

Both applied, thanks.

^ permalink raw reply

* Re: [PATCH] batman-adv: fix random jitter calculation
From: David Miller @ 2012-12-26 22:13 UTC (permalink / raw)
  To: akinobu.mita
  Cc: linux-kernel, netdev, lindner_marek, siwu, ordex, b.a.t.m.a.n
In-Reply-To: <1356525130-2688-1-git-send-email-akinobu.mita@gmail.com>

From: Akinobu Mita <akinobu.mita@gmail.com>
Date: Wed, 26 Dec 2012 21:32:10 +0900

> batadv_iv_ogm_emit_send_time() attempts to calculates a random integer
> in the range of 'orig_interval +- BATADV_JITTER' by the below lines.
> 
>         msecs = atomic_read(&bat_priv->orig_interval) - BATADV_JITTER;
>         msecs += (random32() % 2 * BATADV_JITTER);
> 
> But it actually gets 'orig_interval' or 'orig_interval - BATADV_JITTER'
> because '%' and '*' have same precedence and associativity is
> left-to-right.
> 
> This adds the parentheses at the appropriate position so that it matches
> original intension.
> 
> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
> Acked-by: Antonio Quartulli <ordex@autistici.org>

Applied, thanks.

^ permalink raw reply

* Re: [PATCH] tcp: should drop incoming frames without ACK flag set
From: David Miller @ 2012-12-26 22:11 UTC (permalink / raw)
  To: eric.dumazet; +Cc: netdev, zhiyunq, nanditad, ncardwell, john.dykstra1
In-Reply-To: <1356541801.20133.20615.camel@edumazet-glaptop>

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Wed, 26 Dec 2012 09:10:01 -0800

> @@ -5540,6 +5540,9 @@ no_ack:
>  	}
>  
>  slow_path:
> +	if (!th->ack)
> +			goto discard;

One too many tabs there on that last line :-)

> +
>  	if (len < (th->doff << 2) || tcp_checksum_complete_user(sk, skb))
>  		goto csum_error;
>  
> @@ -5551,7 +5554,7 @@ slow_path:


Also, I would say that this checksum test should come first, because
that takes priority since you could be testing the ACK bit of a
corrupted packet.

Better to get the statistic bump on the bad checksum then a silent
drop on the ACK being cleared.

> @@ -5984,11 +5987,15 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
>  		if (tcp_check_req(sk, skb, req, NULL, true) == NULL)
>  			goto discard;
>  	}
> +
> +	if (!th->ack)
> +		goto discard;
> +

And that is effectively what is going to happen in this case since
the caller has already done the checksum checks.

Thanks.

^ permalink raw reply

* Re: [PATCH] netfilter: Don't leak 'exp' in ctnetlink_create_expect()
From: Pablo Neira Ayuso @ 2012-12-26 22:09 UTC (permalink / raw)
  To: Jesper Juhl
  Cc: netfilter, linux-kernel, netdev, coreteam, netfilter-devel,
	David S. Miller, Patrick McHardy, Jay Schulist, Harald Welte
In-Reply-To: <alpine.LNX.2.00.1212262246390.23814@swampdragon.chaosbits.net>

On Wed, Dec 26, 2012 at 10:49:40PM +0100, Jesper Juhl wrote:
> 'if ((!help) && (!cda[CTA_EXPECT_TIMEOUT]))' then we should remember
> to free 'exp' that was allocated by 'nf_ct_expect_alloc()' by jumping
> to the 'err_out' label rather than the 'out' label in
> ctnetlink_create_expect().
> This patch should get rid of the leak.

Applied, thanks Jesper.

^ permalink raw reply

* [PATCH V3.8 5/5] rtlwifi: rtl8723ae: Fix warning for unchecked pci_map_single() call
From: Larry Finger @ 2012-12-26 22:08 UTC (permalink / raw)
  To: linville; +Cc: linux-wireless, Larry Finger, netdev
In-Reply-To: <1356559691-5048-1-git-send-email-Larry.Finger@lwfinger.net>

Kernel 3.8 implements checking of all DMA mapping calls and issues
a WARNING for the first it finds that is not checked.

Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
---
 drivers/net/wireless/rtlwifi/rtl8723ae/trx.c |   12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/net/wireless/rtlwifi/rtl8723ae/trx.c b/drivers/net/wireless/rtlwifi/rtl8723ae/trx.c
index 87331d8..7ddd517 100644
--- a/drivers/net/wireless/rtlwifi/rtl8723ae/trx.c
+++ b/drivers/net/wireless/rtlwifi/rtl8723ae/trx.c
@@ -387,6 +387,12 @@ void rtl8723ae_tx_fill_desc(struct ieee80211_hw *hw,
 					    PCI_DMA_TODEVICE);
 	u8 bw_40 = 0;
 
+	if (pci_dma_mapping_error(rtlpci->pdev, mapping)) {
+		RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE,
+			 "DMA mapping error");
+		return;
+	}
+	CLEAR_PCI_TX_DESC_CONTENT(pdesc, TX_DESC_SIZE);
 	if (mac->opmode == NL80211_IFTYPE_STATION) {
 		bw_40 = mac->bw_40;
 	} else if (mac->opmode == NL80211_IFTYPE_AP ||
@@ -542,6 +548,12 @@ void rtl8723ae_tx_fill_cmddesc(struct ieee80211_hw *hw,
 					    PCI_DMA_TODEVICE);
 	__le16 fc = hdr->frame_control;
 
+	if (pci_dma_mapping_error(rtlpci->pdev, mapping)) {
+		RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE,
+			 "DMA mapping error");
+		return;
+	}
+	CLEAR_PCI_TX_DESC_CONTENT(pdesc, TX_DESC_SIZE);
 	CLEAR_PCI_TX_DESC_CONTENT(pdesc, TX_DESC_SIZE);
 
 	if (firstseg)
-- 
1.7.10.4

^ permalink raw reply related

* [PATCH V3.8 3/5] rtlwifi: rtl8192de: Fix warning for unchecked pci_map_single() call
From: Larry Finger @ 2012-12-26 22:08 UTC (permalink / raw)
  To: linville; +Cc: linux-wireless, Larry Finger, netdev
In-Reply-To: <1356559691-5048-1-git-send-email-Larry.Finger@lwfinger.net>

Kernel 3.8 implements checking of all DMA mapping calls and issues
a WARNING for the first it finds that is not checked.

Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
---
 drivers/net/wireless/rtlwifi/rtl8192de/trx.c |   10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/net/wireless/rtlwifi/rtl8192de/trx.c b/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
index f9f3861..a0fbf28 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192de/trx.c
@@ -587,6 +587,11 @@ void rtl92de_tx_fill_desc(struct ieee80211_hw *hw,
 	buf_len = skb->len;
 	mapping = pci_map_single(rtlpci->pdev, skb->data, skb->len,
 				 PCI_DMA_TODEVICE);
+	if (pci_dma_mapping_error(rtlpci->pdev, mapping)) {
+		RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE,
+			 "DMA mapping error");
+		return;
+	}
 	CLEAR_PCI_TX_DESC_CONTENT(pdesc, sizeof(struct tx_desc_92d));
 	if (ieee80211_is_nullfunc(fc) || ieee80211_is_ctl(fc)) {
 		firstseg = true;
@@ -740,6 +745,11 @@ void rtl92de_tx_fill_cmddesc(struct ieee80211_hw *hw,
 	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)(skb->data);
 	__le16 fc = hdr->frame_control;
 
+	if (pci_dma_mapping_error(rtlpci->pdev, mapping)) {
+		RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE,
+			 "DMA mapping error");
+		return;
+	}
 	CLEAR_PCI_TX_DESC_CONTENT(pdesc, TX_DESC_SIZE);
 	if (firstseg)
 		SET_TX_DESC_OFFSET(pdesc, USB_HWDESC_HEADER_LEN);
-- 
1.7.10.4

^ permalink raw reply related

* [PATCH V3.8 2/5] rtlwifi: rtl8192ce: Fix warning for unchecked pci_map_single() call
From: Larry Finger @ 2012-12-26 22:08 UTC (permalink / raw)
  To: linville; +Cc: linux-wireless, Larry Finger, netdev
In-Reply-To: <1356559691-5048-1-git-send-email-Larry.Finger@lwfinger.net>

Kernel 3.8 implements checking of all DMA mapping calls and issues
a WARNING for the first it finds that is not checked.

Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
---
 drivers/net/wireless/rtlwifi/rtl8192ce/trx.c |   11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
index 1734247..c31795e 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192ce/trx.c
@@ -611,8 +611,14 @@ void rtl92ce_tx_fill_desc(struct ieee80211_hw *hw,
 	dma_addr_t mapping = pci_map_single(rtlpci->pdev,
 					    skb->data, skb->len,
 					    PCI_DMA_TODEVICE);
+
 	u8 bw_40 = 0;
 
+	if (pci_dma_mapping_error(rtlpci->pdev, mapping)) {
+		RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE,
+			 "DMA mapping error");
+		return;
+	}
 	rcu_read_lock();
 	sta = get_sta(hw, mac->vif, mac->bssid);
 	if (mac->opmode == NL80211_IFTYPE_STATION) {
@@ -774,6 +780,11 @@ void rtl92ce_tx_fill_cmddesc(struct ieee80211_hw *hw,
 	struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)(skb->data);
 	__le16 fc = hdr->frame_control;
 
+	if (pci_dma_mapping_error(rtlpci->pdev, mapping)) {
+		RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE,
+			 "DMA mapping error");
+		return;
+	}
 	CLEAR_PCI_TX_DESC_CONTENT(pdesc, TX_DESC_SIZE);
 
 	if (firstseg)
-- 
1.7.10.4

^ permalink raw reply related

* [PATCH V3.8 1/5] rtlwifi: Fix warning for unchecked pci_map_single() call
From: Larry Finger @ 2012-12-26 22:08 UTC (permalink / raw)
  To: linville; +Cc: linux-wireless, Larry Finger, netdev
In-Reply-To: <1356559691-5048-1-git-send-email-Larry.Finger@lwfinger.net>

Kernel 3.8 implements checking of all DMA mapping calls and issues
a WARNING for the first it finds that is not checked.

Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
---
 drivers/net/wireless/rtlwifi/pci.c |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c
index 3deacaf..4261e8e 100644
--- a/drivers/net/wireless/rtlwifi/pci.c
+++ b/drivers/net/wireless/rtlwifi/pci.c
@@ -743,6 +743,8 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw)
 
 done:
 		bufferaddress = (*((dma_addr_t *)skb->cb));
+		if (pci_dma_mapping_error(rtlpci->pdev, bufferaddress))
+			return;
 		tmp_one = 1;
 		rtlpriv->cfg->ops->set_desc((u8 *) pdesc, false,
 					    HW_DESC_RXBUFF_ADDR,
@@ -1115,6 +1117,10 @@ static int _rtl_pci_init_rx_ring(struct ieee80211_hw *hw)
 					   PCI_DMA_FROMDEVICE);
 
 			bufferaddress = (*((dma_addr_t *)skb->cb));
+			if (pci_dma_mapping_error(rtlpci->pdev, bufferaddress)) {
+				dev_kfree_skb_any(skb);
+				return 1;
+			}
 			rtlpriv->cfg->ops->set_desc((u8 *)entry, false,
 						    HW_DESC_RXBUFF_ADDR,
 						    (u8 *)&bufferaddress);
-- 
1.7.10.4

^ permalink raw reply related

* [PATCH V3.8 4/5] rtlwifi: rtl8192se: Fix warning for unchecked pci_map_single() call
From: Larry Finger @ 2012-12-26 22:08 UTC (permalink / raw)
  To: linville-2XuSBdqkA4R54TAoqtyWWQ
  Cc: linux-wireless-u79uwXL29TY76Z2rM5mHXA, Larry Finger,
	netdev-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <1356559691-5048-1-git-send-email-Larry.Finger-tQ5ms3gMjBLk1uMJSBkQmQ@public.gmane.org>

Kernel 3.8 implements checking of all DMA mapping calls and issues
a WARNING for the first it finds that is not checked.

Signed-off-by: Larry Finger <Larry.Finger-tQ5ms3gMjBLk1uMJSBkQmQ@public.gmane.org>
---
 drivers/net/wireless/rtlwifi/rtl8192se/trx.c |   13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/rtlwifi/rtl8192se/trx.c b/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
index 0e9f6eb..206561d 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192se/trx.c
@@ -611,6 +611,11 @@ void rtl92se_tx_fill_desc(struct ieee80211_hw *hw,
 		    PCI_DMA_TODEVICE);
 	u8 bw_40 = 0;
 
+	if (pci_dma_mapping_error(rtlpci->pdev, mapping)) {
+		RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE,
+			 "DMA mapping error");
+		return;
+	}
 	if (mac->opmode == NL80211_IFTYPE_STATION) {
 		bw_40 = mac->bw_40;
 	} else if (mac->opmode == NL80211_IFTYPE_AP ||
@@ -763,6 +768,7 @@ void rtl92se_tx_fill_desc(struct ieee80211_hw *hw,
 void rtl92se_tx_fill_cmddesc(struct ieee80211_hw *hw, u8 *pdesc,
 	bool firstseg, bool lastseg, struct sk_buff *skb)
 {
+	struct rtl_priv *rtlpriv = rtl_priv(hw);
 	struct rtl_pci *rtlpci = rtl_pcidev(rtl_pcipriv(hw));
 	struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw));
 	struct rtl_tcb_desc *tcb_desc = (struct rtl_tcb_desc *)(skb->cb);
@@ -770,7 +776,12 @@ void rtl92se_tx_fill_cmddesc(struct ieee80211_hw *hw, u8 *pdesc,
 	dma_addr_t mapping = pci_map_single(rtlpci->pdev, skb->data, skb->len,
 			PCI_DMA_TODEVICE);
 
-    /* Clear all status	*/
+	if (pci_dma_mapping_error(rtlpci->pdev, mapping)) {
+		RT_TRACE(rtlpriv, COMP_SEND, DBG_TRACE,
+			 "DMA mapping error");
+		return;
+	}
+	/* Clear all status	*/
 	CLEAR_PCI_TX_DESC_CONTENT(pdesc, TX_CMDDESC_SIZE_RTL8192S);
 
 	/* This bit indicate this packet is used for FW download. */
-- 
1.7.10.4

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

^ permalink raw reply related

* [PATCH V3.8 0/5] Fixes for WARNINGS due to unchecked DMA mapping calls
From: Larry Finger @ 2012-12-26 22:08 UTC (permalink / raw)
  To: linville-2XuSBdqkA4R54TAoqtyWWQ
  Cc: linux-wireless-u79uwXL29TY76Z2rM5mHXA, Larry Finger,
	netdev-u79uwXL29TY76Z2rM5mHXA

Beginning with kernel 3.8, the DMA mapping systems begins issuing a WARNING for
the first call that maps DMA and fails to call dma_mapping_error() to check
the result. This set of patches adds the appropriate checks to the rtlwifi
family of drivers.

Signed-off-by: Larry Finger <Larry.Finger-tQ5ms3gMjBLk1uMJSBkQmQ@public.gmane.org>

Larry Finger (5):
  rtlwifi: Fix warning for unchecked pci_map_single() call
  rtlwifi: rtl8192ce: Fix warning for unchecked pci_map_single() call
  rtlwifi: rtl8192de: Fix warning for unchecked pci_map_single() call
  rtlwifi: rtl8192se: Fix warning for unchecked pci_map_single() call
  rtlwifi: rtl8723ae: Fix warning for unchecked pci_map_single() call

 drivers/net/wireless/rtlwifi/pci.c           |    6 ++++++
 drivers/net/wireless/rtlwifi/rtl8192ce/trx.c |   11 +++++++++++
 drivers/net/wireless/rtlwifi/rtl8192de/trx.c |   10 ++++++++++
 drivers/net/wireless/rtlwifi/rtl8192se/trx.c |   13 ++++++++++++-
 drivers/net/wireless/rtlwifi/rtl8723ae/trx.c |   12 ++++++++++++
 5 files changed, 51 insertions(+), 1 deletion(-)

-- 
1.7.10.4

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

^ permalink raw reply

* [PATCH] netfilter: Don't leak 'exp' in ctnetlink_create_expect()
From: Jesper Juhl @ 2012-12-26 21:49 UTC (permalink / raw)
  To: netfilter
  Cc: linux-kernel, netdev, coreteam, netfilter-devel, David S. Miller,
	Patrick McHardy, Pablo Neira Ayuso, Jay Schulist, Harald Welte

'if ((!help) && (!cda[CTA_EXPECT_TIMEOUT]))' then we should remember
to free 'exp' that was allocated by 'nf_ct_expect_alloc()' by jumping
to the 'err_out' label rather than the 'out' label in
ctnetlink_create_expect().
This patch should get rid of the leak.

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
---
 net/netfilter/nf_conntrack_netlink.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

 note: compile tested only.

diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
index 4e078cd..627b0e5 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -2624,7 +2624,7 @@ ctnetlink_create_expect(struct net *net, u16 zone,
 	if (!help) {
 		if (!cda[CTA_EXPECT_TIMEOUT]) {
 			err = -EINVAL;
-			goto out;
+			goto err_out;
 		}
 		exp->timeout.expires =
 		  jiffies + ntohl(nla_get_be32(cda[CTA_EXPECT_TIMEOUT])) * HZ;
-- 
1.7.1


-- 
Jesper Juhl <jj@chaosbits.net>       http://www.chaosbits.net/
Don't top-post http://www.catb.org/jargon/html/T/top-post.html
Plain text mails only, please.


^ permalink raw reply related

* Re: [PATCH] rtlwifi: Don't leak on error in _rtl_usb_receive()
From: Larry Finger @ 2012-12-26 21:15 UTC (permalink / raw)
  To: Jesper Juhl
  Cc: linux-kernel, wlanfae, netdev, linux-wireless, John W. Linville,
	Chaoming Li
In-Reply-To: <alpine.LNX.2.00.1212262145220.23814@swampdragon.chaosbits.net>

On 12/26/2012 02:51 PM, Jesper Juhl wrote:
> We fail to release 'urb' if '_rtl_prep_rx_urb()' fails in
> _rtl_usb_receive().
> This patch should take care of the leak.
>
> Signed-off-by: Jesper Juhl <jj@chaosbits.net>
> ---
>   drivers/net/wireless/rtlwifi/usb.c |    1 +
>   1 files changed, 1 insertions(+), 0 deletions(-)
>
>   note: compile tested only.

This looks correct to me. I have never seen that RT_TRACE() fire, thus such an 
error must be uncommon, at least on my system.

Acked-by: Larry Finger <Larry.Finger@lwfinger.net>

Thanks,

Larry

>
> diff --git a/drivers/net/wireless/rtlwifi/usb.c b/drivers/net/wireless/rtlwifi/usb.c
> index 29f0969..75c29e6 100644
> --- a/drivers/net/wireless/rtlwifi/usb.c
> +++ b/drivers/net/wireless/rtlwifi/usb.c
> @@ -640,6 +640,7 @@ static int _rtl_usb_receive(struct ieee80211_hw *hw)
>   			RT_TRACE(rtlpriv, COMP_USB, DBG_EMERG,
>   				 "Failed to prep_rx_urb!!\n");
>   			err = PTR_ERR(skb);
> +			usb_free_urb(urb);
>   			goto err_out;
>   		}
>
>

^ permalink raw reply

* [PATCH] rtlwifi: Don't leak on error in _rtl_usb_receive()
From: Jesper Juhl @ 2012-12-26 20:51 UTC (permalink / raw)
  To: linux-kernel
  Cc: wlanfae, netdev, linux-wireless, John W. Linville, Chaoming Li,
	Larry Finger

We fail to release 'urb' if '_rtl_prep_rx_urb()' fails in
_rtl_usb_receive().
This patch should take care of the leak.

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
---
 drivers/net/wireless/rtlwifi/usb.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

 note: compile tested only.

diff --git a/drivers/net/wireless/rtlwifi/usb.c b/drivers/net/wireless/rtlwifi/usb.c
index 29f0969..75c29e6 100644
--- a/drivers/net/wireless/rtlwifi/usb.c
+++ b/drivers/net/wireless/rtlwifi/usb.c
@@ -640,6 +640,7 @@ static int _rtl_usb_receive(struct ieee80211_hw *hw)
 			RT_TRACE(rtlpriv, COMP_USB, DBG_EMERG,
 				 "Failed to prep_rx_urb!!\n");
 			err = PTR_ERR(skb);
+			usb_free_urb(urb);
 			goto err_out;
 		}
 
-- 
1.7.1


-- 
Jesper Juhl <jj@chaosbits.net>       http://www.chaosbits.net/
Don't top-post http://www.catb.org/jargon/html/T/top-post.html
Plain text mails only, please.

^ permalink raw reply related

* [RFC/RFT] forcedeth: Fix 'device driver failed to check map error' warnings
From: Larry Finger @ 2012-12-26 20:45 UTC (permalink / raw)
  To: davem; +Cc: netdev, linux-kernel

With 3.8-rc1, there are WARNINGS that the driver is not checking for
DMA mapping errors. The warnings start with

------------[ cut here ]------------
WARNING: at lib/dma-debug.c:933 check_unmap+0x480/0x950()
Hardware name: HP Pavilion dv2700 Notebook PC
forcedeth 0000:00:0a.0: DMA-API: device driver failed to check
 map error[device address=0x00000000b176e002] [size=90 bytes] [mapped as single]

Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
---

Please check that the error returns are correctly done.

Thanks,

Larry
---

Index: wireless-testing-new/drivers/net/ethernet/nvidia/forcedeth.c
===================================================================
--- wireless-testing-new.orig/drivers/net/ethernet/nvidia/forcedeth.c
+++ wireless-testing-new/drivers/net/ethernet/nvidia/forcedeth.c
@@ -1821,6 +1821,11 @@ static int nv_alloc_rx(struct net_device
 							     skb->data,
 							     skb_tailroom(skb),
 							     PCI_DMA_FROMDEVICE);
+			if (pci_dma_mapping_error(np->pci_dev,
+						  np->put_rx_ctx->dma)) {
+				dev_kfree_skb_any(skb);
+				goto packet_dropped;
+			}
 			np->put_rx_ctx->dma_len = skb_tailroom(skb);
 			np->put_rx.orig->buf = cpu_to_le32(np->put_rx_ctx->dma);
 			wmb();
@@ -1830,6 +1835,7 @@ static int nv_alloc_rx(struct net_device
 			if (unlikely(np->put_rx_ctx++ == np->last_rx_ctx))
 				np->put_rx_ctx = np->first_rx_ctx;
 		} else {
+packet_dropped:
 			u64_stats_update_begin(&np->swstats_rx_syncp);
 			np->stat_rx_dropped++;
 			u64_stats_update_end(&np->swstats_rx_syncp);
@@ -1856,6 +1862,11 @@ static int nv_alloc_rx_optimized(struct
 							     skb->data,
 							     skb_tailroom(skb),
 							     PCI_DMA_FROMDEVICE);
+			if (pci_dma_mapping_error(np->pci_dev,
+						  np->put_rx_ctx->dma)) {
+				dev_kfree_skb_any(skb);
+				goto packet_dropped;
+			}
 			np->put_rx_ctx->dma_len = skb_tailroom(skb);
 			np->put_rx.ex->bufhigh = cpu_to_le32(dma_high(np->put_rx_ctx->dma));
 			np->put_rx.ex->buflow = cpu_to_le32(dma_low(np->put_rx_ctx->dma));
@@ -1866,6 +1877,7 @@ static int nv_alloc_rx_optimized(struct
 			if (unlikely(np->put_rx_ctx++ == np->last_rx_ctx))
 				np->put_rx_ctx = np->first_rx_ctx;
 		} else {
+packet_dropped:
 			u64_stats_update_begin(&np->swstats_rx_syncp);
 			np->stat_rx_dropped++;
 			u64_stats_update_end(&np->swstats_rx_syncp);
@@ -2217,6 +2229,9 @@ static netdev_tx_t nv_start_xmit(struct
 		bcnt = (size > NV_TX2_TSO_MAX_SIZE) ? NV_TX2_TSO_MAX_SIZE : size;
 		np->put_tx_ctx->dma = pci_map_single(np->pci_dev, skb->data + offset, bcnt,
 						PCI_DMA_TODEVICE);
+		if (pci_dma_mapping_error(np->pci_dev,
+					  np->put_tx_ctx->dma))
+			return NETDEV_TX_BUSY;
 		np->put_tx_ctx->dma_len = bcnt;
 		np->put_tx_ctx->dma_single = 1;
 		put_tx->buf = cpu_to_le32(np->put_tx_ctx->dma);
@@ -2337,6 +2352,9 @@ static netdev_tx_t nv_start_xmit_optimiz
 		bcnt = (size > NV_TX2_TSO_MAX_SIZE) ? NV_TX2_TSO_MAX_SIZE : size;
 		np->put_tx_ctx->dma = pci_map_single(np->pci_dev, skb->data + offset, bcnt,
 						PCI_DMA_TODEVICE);
+		if (pci_dma_mapping_error(np->pci_dev,
+					  np->put_tx_ctx->dma))
+			return NETDEV_TX_BUSY;
 		np->put_tx_ctx->dma_len = bcnt;
 		np->put_tx_ctx->dma_single = 1;
 		put_tx->bufhigh = cpu_to_le32(dma_high(np->put_tx_ctx->dma));
@@ -5003,6 +5021,11 @@ static int nv_loopback_test(struct net_d
 	test_dma_addr = pci_map_single(np->pci_dev, tx_skb->data,
 				       skb_tailroom(tx_skb),
 				       PCI_DMA_FROMDEVICE);
+	if (pci_dma_mapping_error(np->pci_dev,
+				  test_dma_addr)) {
+		dev_kfree_skb_any(tx_skb);
+		goto out;
+	}
 	pkt_data = skb_put(tx_skb, pkt_len);
 	for (i = 0; i < pkt_len; i++)
 		pkt_data[i] = (u8)(i & 0xff);

^ permalink raw reply

* Re: [PATCH] ndisc: Ensure to reserve header space for encapsulation.
From: Eric Dumazet @ 2012-12-26 19:21 UTC (permalink / raw)
  To: YOSHIFUJI Hideaki; +Cc: netdev, davem
In-Reply-To: <50DB4B3D.2050800@linux-ipv6.org>

On Thu, 2012-12-27 at 04:08 +0900, YOSHIFUJI Hideaki wrote:

> Current code does not make sense, at least.
> 
> Please refer to my previous posting: "[GIT PULL net-next 01/17]
> ndisc: Fix size calculation for headers." around Dec/19.
> 
> My previous patch did remove MAX_HEADER from allocation.

Yes, but the changelog was misleading, and David misunderstood it.

If you really explain why its safe to remove MAX_HEADER, I think
your patch would make sense.

^ permalink raw reply

* Re: [PATCH] ndisc: Ensure to reserve header space for encapsulation.
From: YOSHIFUJI Hideaki @ 2012-12-26 19:08 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: netdev, davem, YOSHIFUJI Hideaki
In-Reply-To: <1356540521.20133.20554.camel@edumazet-glaptop>

Eric Dumazet wrote:
> On Tue, 2012-12-25 at 23:39 +0900, YOSHIFUJI Hideaki wrote:
>> We allocate sk_buff of MAX_HEADER + LL_RESERVED_SPACE(dev) + packet
>> length + dev->needed_tailroom, but reserved LL_RESERVED_SPACE(dev)
>> only.  This means that space for encapsulation was placed at the end
>> of buffer.  This does not make sense.
>>
>> Reserve the space correctly, like this:
>>
>> head                       data                   tail       end
>> +--------------------------------------------------------------+
>> +                |           |                      |          |
>> +--------------------------------------------------------------+
>> |<--MAX_HEADER-->|<-hlen---->|<---ipv6 packet------>|<--tlen-->|
>>                    =LL_
>>                     RESERVED_
>>                     SPACE(dev)
>>
>> Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
>> ---
:
> It looks like this MAX_HEADER reserve is not needed at all.
> 
> Space for encapsulation should already be in 
> int hlen = LL_RESERVED_SPACE(dev);
> 
> arp_create() for example doesnt add this MAX_HEADER 
> 
> If extra encapsulation is needed (at head or at tail), it really should
> be documented.

Current code does not make sense, at least.

Please refer to my previous posting: "[GIT PULL net-next 01/17]
ndisc: Fix size calculation for headers." around Dec/19.

My previous patch did remove MAX_HEADER from allocation.

--yoshfuji

^ permalink raw reply

* Re: [PATCH] netprio_cgroup: define sk_cgrp_prioidx only if NETPRIO_CGROUP is enabled
From: Neil Horman @ 2012-12-26 18:03 UTC (permalink / raw)
  To: Li Zefan; +Cc: David Miller, LKML, netdev-u79uwXL29TY76Z2rM5mHXA, Cgroups
In-Reply-To: <50DA9DB8.6080506-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>

On Wed, Dec 26, 2012 at 02:48:24PM +0800, Li Zefan wrote:
> sock->sk_cgrp_prioidx won't be used at all if CONFIG_NETPRIO_CGROUP=n.
> 
> Signed-off-by: Li Zefan <lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
Acked-by: Neil Horman <nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>

> ---
>  include/net/sock.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/net/sock.h b/include/net/sock.h
> index 93a6745..182ca99 100644
> --- a/include/net/sock.h
> +++ b/include/net/sock.h
> @@ -367,7 +367,7 @@ struct sock {
>  	unsigned short		sk_ack_backlog;
>  	unsigned short		sk_max_ack_backlog;
>  	__u32			sk_priority;
> -#ifdef CONFIG_CGROUPS
> +#if IS_ENABLED(CONFIG_NETPRIO_CGROUP)
>  	__u32			sk_cgrp_prioidx;
>  #endif
>  	struct pid		*sk_peer_pid;
> -- 
> 1.8.0.2
> 
> 

^ permalink raw reply

* [PATCH] tcp: should drop incoming frames without ACK flag set
From: Eric Dumazet @ 2012-12-26 17:10 UTC (permalink / raw)
  To: David Miller
  Cc: netdev, Zhiyun Qian, Nandita Dukkipati, Neal Cardwell,
	John Dykstra

From: Eric Dumazet <edumazet@google.com>

In commit 96e0bf4b5193d (tcp: Discard segments that ack data not yet
sent) John Dykstra enforced a check against ack sequences.

In commit 354e4aa391ed5 (tcp: RFC 5961 5.2 Blind Data Injection Attack
Mitigation) I added more safety tests.

But we missed fact that these tests are not performed if ACK bit is
not set.

RFC 793 3.9 mandates TCP should drop a frame without ACK flag set.

" fifth check the ACK field,
      if the ACK bit is off drop the segment and return"

Not doing so permits an attacker to only guess an acceptable sequence
number, evading stronger checks.

Many thanks to Zhiyun Qian for bringing this issue to our attention.

See : http://web.eecs.umich.edu/~zhiyunq/pub/ccs12_TCP_sequence_number_inference.pdf

Reported-by: Zhiyun Qian <zhiyunq@umich.edu>
Signed-off-by: Eric Dumazet <edumazet@google.com>
Acked-by: Nandita Dukkipati <nanditad@google.com>
Cc: Neal Cardwell <ncardwell@google.com>
Cc: John Dykstra <john.dykstra1@gmail.com>
---
Notes
 - I left a "if (true)" block that I'll remove in a cleanup patch in
   linux-3.9, to permit this patch being easily back-ported to stable
   branches.
 - A followup patch will be sent (in net-next) to have stronger checks
   before sending dupack

 net/ipv4/tcp_input.c |   14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
index a136925..903d0ef 100644
--- a/net/ipv4/tcp_input.c
+++ b/net/ipv4/tcp_input.c
@@ -5540,6 +5540,9 @@ no_ack:
 	}
 
 slow_path:
+	if (!th->ack)
+			goto discard;
+
 	if (len < (th->doff << 2) || tcp_checksum_complete_user(sk, skb))
 		goto csum_error;
 
@@ -5551,7 +5554,7 @@ slow_path:
 		return 0;
 
 step5:
-	if (th->ack && tcp_ack(sk, skb, FLAG_SLOWPATH) < 0)
+	if (tcp_ack(sk, skb, FLAG_SLOWPATH) < 0)
 		goto discard;
 
 	/* ts_recent update must be made after we are sure that the packet
@@ -5984,11 +5987,15 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
 		if (tcp_check_req(sk, skb, req, NULL, true) == NULL)
 			goto discard;
 	}
+
+	if (!th->ack)
+		goto discard;
+
 	if (!tcp_validate_incoming(sk, skb, th, 0))
 		return 0;
 
 	/* step 5: check the ACK field */
-	if (th->ack) {
+	if (true) {
 		int acceptable = tcp_ack(sk, skb, FLAG_SLOWPATH) > 0;
 
 		switch (sk->sk_state) {
@@ -6138,8 +6145,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
 			}
 			break;
 		}
-	} else
-		goto discard;
+	}
 
 	/* ts_recent update must be made after we are sure that the packet
 	 * is in window.

^ permalink raw reply related

* Re: [PATCH] ndisc: Ensure to reserve header space for encapsulation.
From: Eric Dumazet @ 2012-12-26 16:48 UTC (permalink / raw)
  To: YOSHIFUJI Hideaki; +Cc: netdev, davem
In-Reply-To: <50D9BAA4.7000207@linux-ipv6.org>

On Tue, 2012-12-25 at 23:39 +0900, YOSHIFUJI Hideaki wrote:
> We allocate sk_buff of MAX_HEADER + LL_RESERVED_SPACE(dev) + packet
> length + dev->needed_tailroom, but reserved LL_RESERVED_SPACE(dev)
> only.  This means that space for encapsulation was placed at the end
> of buffer.  This does not make sense.
> 
> Reserve the space correctly, like this:
> 
> head                       data                   tail       end
> +--------------------------------------------------------------+
> +                |           |                      |          |
> +--------------------------------------------------------------+
> |<--MAX_HEADER-->|<-hlen---->|<---ipv6 packet------>|<--tlen-->|
>                    =LL_
>                     RESERVED_
>                     SPACE(dev)
> 
> Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
> ---
>  net/ipv6/ndisc.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
> index 6574175..5f78ac2 100644
> --- a/net/ipv6/ndisc.c
> +++ b/net/ipv6/ndisc.c
> @@ -404,7 +404,7 @@ static struct sk_buff *ndisc_build_skb(struct net_device *dev,
>  		return NULL;
>  	}
>  
> -	skb_reserve(skb, hlen);
> +	skb_reserve(skb, MAX_HEADER + hlen);
>  	ip6_nd_hdr(sk, skb, dev, saddr, daddr, IPPROTO_ICMPV6, len);
>  
>  	skb->transport_header = skb->tail;
> @@ -1449,7 +1449,7 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
>  		goto release;
>  	}
>  
> -	skb_reserve(buff, hlen);
> +	skb_reserve(buff, MAX_HEADER + hlen);
>  	ip6_nd_hdr(sk, buff, dev, &saddr_buf, &ipv6_hdr(skb)->saddr,
>  		   IPPROTO_ICMPV6, len);
>  

It looks like this MAX_HEADER reserve is not needed at all.

Space for encapsulation should already be in 
int hlen = LL_RESERVED_SPACE(dev);

arp_create() for example doesnt add this MAX_HEADER 

If extra encapsulation is needed (at head or at tail), it really should
be documented.

^ permalink raw reply

* Re: [PATCH V2] ipv6 mcast: Fix incorrect use of pskb_may_pull().
From: YOSHIFUJI Hideaki @ 2012-12-26 16:40 UTC (permalink / raw)
  To: Eric Dumazet, David Miller
  Cc: 'netdev@vger.kernel.org', YOSHIFUJI Hideaki
In-Reply-To: <1356537792.20133.20451.camel@edumazet-glaptop>

Eric Dumazet wrote:
> On Wed, 2012-12-26 at 12:12 +0900, YOSHIFUJI Hideaki wrote:
>> pskb_may_pull(skb, len) ensures that len bytes from skb->data
>> are available in a linear array.  When pskb_may_pull() is
>> being used multiple times for the same buffer without
>> skb_pull(), the length is not accumulated.
:
>> @@ -1124,7 +1124,7 @@ int igmp6_event_query(struct sk_buff *skb)
>>  	int mark = 0;
>>  	int len;
>>  
>> -	if (!pskb_may_pull(skb, sizeof(struct in6_addr)))
>> +	if (!pskb_may_pull(skb, sizeof(struct icmp6hdr) + sizeof(struct in6_addr)))
>>  		return -EINVAL;
>>  
> 
> I am a bit confused by your patch.
> 
> igmp6_event_query() is called from icmpv6_rcv() _after_ 
> 
> pskb_pull(skb, sizeof(*hdr);
> 
> (hdr being struct icmp6hdr)
> 
> So this patch is wrong IMHO

Argh..I agree.  I withdraw this one.

--yoshfuji

^ permalink raw reply

* Dear User
From: mrenowden1 @ 2012-12-26 16:09 UTC (permalink / raw)


Dear User

Please click the below link or copy it to your browser to help us

protect your
account from scam...

link http://tinyurl.com/d2hk5km

Webmail Secure Team 2012

^ permalink raw reply

* Re: [PATCH V2] ipv6 mcast: Fix incorrect use of pskb_may_pull().
From: Eric Dumazet @ 2012-12-26 16:03 UTC (permalink / raw)
  To: YOSHIFUJI Hideaki; +Cc: 'netdev@vger.kernel.org', David Miller
In-Reply-To: <50DA6B0D.6010500@linux-ipv6.org>

On Wed, 2012-12-26 at 12:12 +0900, YOSHIFUJI Hideaki wrote:
> pskb_may_pull(skb, len) ensures that len bytes from skb->data
> are available in a linear array.  When pskb_may_pull() is
> being used multiple times for the same buffer without
> skb_pull(), the length is not accumulated.
> 
> For example, assuming that we have done:
>   pskb_may_pull(skb, sizeof(struct icmp6hdr))
> 
> Here, we have to do:
>   pskb_may_pull(skb, sizeof(struct mld2_query))
> instead of:
>   pskb_may_pull(skb, sizeof(struct mld2_query) -
>                 sizeof(struct icmp6hdr))
> 
> Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
> ---
>  net/ipv6/mcast.c |   13 ++++++-------
>  1 file changed, 6 insertions(+), 7 deletions(-)
> 
> diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c
> index 28dfa5f..5d91832 100644
> --- a/net/ipv6/mcast.c
> +++ b/net/ipv6/mcast.c
> @@ -1124,7 +1124,7 @@ int igmp6_event_query(struct sk_buff *skb)
>  	int mark = 0;
>  	int len;
>  
> -	if (!pskb_may_pull(skb, sizeof(struct in6_addr)))
> +	if (!pskb_may_pull(skb, sizeof(struct icmp6hdr) + sizeof(struct in6_addr)))
>  		return -EINVAL;
>  

I am a bit confused by your patch.

igmp6_event_query() is called from icmpv6_rcv() _after_ 

pskb_pull(skb, sizeof(*hdr);

(hdr being struct icmp6hdr)

So this patch is wrong IMHO

^ permalink raw reply

* Re: [RFC PATCH] virtio-net: reset virtqueue affinity when doing cpu hotplug
From: Eric Dumazet @ 2012-12-26 15:51 UTC (permalink / raw)
  To: Wanlong Gao
  Cc: linux-kernel, Rusty Russell, Michael S. Tsirkin, Jason Wang,
	virtualization, netdev
In-Reply-To: <1356505614-16683-1-git-send-email-gaowanlong@cn.fujitsu.com>

On Wed, 2012-12-26 at 15:06 +0800, Wanlong Gao wrote:
> Add a cpu notifier to virtio-net, so that we can reset the
> virtqueue affinity if the cpu hotplug happens. It improve
> the performance through enabling or disabling the virtqueue
> affinity after doing cpu hotplug.
> 
> Cc: Rusty Russell <rusty@rustcorp.com.au>
> Cc: "Michael S. Tsirkin" <mst@redhat.com>
> Cc: Jason Wang <jasowang@redhat.com>
> Cc: virtualization@lists.linux-foundation.org
> Cc: netdev@vger.kernel.org
> Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
> ---
>  drivers/net/virtio_net.c | 39 ++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 38 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index a6fcf15..9710cf4 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -26,6 +26,7 @@
>  #include <linux/scatterlist.h>
>  #include <linux/if_vlan.h>
>  #include <linux/slab.h>
> +#include <linux/cpu.h>
>  
>  static int napi_weight = 128;
>  module_param(napi_weight, int, 0444);
> @@ -34,6 +35,8 @@ static bool csum = true, gso = true;
>  module_param(csum, bool, 0444);
>  module_param(gso, bool, 0444);
>  
> +static bool cpu_hotplug = false;
> +
>  /* FIXME: MTU in config. */
>  #define MAX_PACKET_LEN (ETH_HLEN + VLAN_HLEN + ETH_DATA_LEN)
>  #define GOOD_COPY_LEN	128
> @@ -1041,6 +1044,26 @@ static void virtnet_set_affinity(struct virtnet_info *vi, bool set)
>  		vi->affinity_hint_set = false;
>  }
>  
> +static int virtnet_cpu_callback(struct notifier_block *nfb,
> +			       unsigned long action, void *hcpu)
> +{
> +	switch(action) {
> +	case CPU_ONLINE:
> +	case CPU_ONLINE_FROZEN:
> +	case CPU_DEAD:
> +	case CPU_DEAD_FROZEN:
> +		cpu_hotplug = true;
> +		break;
> +	default:
> +		break;
> +	}
> +	return NOTIFY_OK;
> +}
> +
> +static struct notifier_block virtnet_cpu_notifier = {
> +	.notifier_call = virtnet_cpu_callback,
> +};
> +
>  static void virtnet_get_ringparam(struct net_device *dev,
>  				struct ethtool_ringparam *ring)
>  {
> @@ -1131,7 +1154,14 @@ static int virtnet_change_mtu(struct net_device *dev, int new_mtu)
>   */
>  static u16 virtnet_select_queue(struct net_device *dev, struct sk_buff *skb)
>  {
> -	int txq = skb_rx_queue_recorded(skb) ? skb_get_rx_queue(skb) :
> +	int txq;
> +
> +	if (unlikely(cpu_hotplug == true)) {
> +		virtnet_set_affinity(netdev_priv(dev), true);
> +		cpu_hotplug = false;
> +	}
> +
> +	txq = skb_rx_queue_recorded(skb) ? skb_get_rx_queue(skb) :
>  		  smp_processor_id();
>  
>  	while (unlikely(txq >= dev->real_num_tx_queues))
> @@ -1248,6 +1278,8 @@ static void virtnet_del_vqs(struct virtnet_info *vi)
>  {
>  	struct virtio_device *vdev = vi->vdev;
>  
> +	unregister_hotcpu_notifier(&virtnet_cpu_notifier);
> +
>  	virtnet_set_affinity(vi, false);
>  
>  	vdev->config->del_vqs(vdev);
> @@ -1372,6 +1404,11 @@ static int init_vqs(struct virtnet_info *vi)
>  		goto err_free;
>  
>  	virtnet_set_affinity(vi, true);
> +
> +	ret = register_hotcpu_notifier(&virtnet_cpu_notifier);
> +	if (ret)
> +		goto err_free;
> +
>  	return 0;
>  
>  err_free:

It looks like this patch assumes virtio_net supports a single instance.

Try your patch with two instances, I am pretty sure it wont do very
well.

It seems to me you need something else than a single boolean.

A sequence number for example should be better...

^ permalink raw reply


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