Netdev List
 help / color / mirror / Atom feed
* Re: [PATCH net-next] net: proc_fs: trivial: print UIDs as unsigned int
From: David Miller @ 2013-08-15 21:38 UTC (permalink / raw)
  To: ffusco; +Cc: netdev
In-Reply-To: <bee30aaa49e84c82c8a7ca9939e7321e2c0a741d.1376566630.git.ffusco@redhat.com>

From: Francesco Fusco <ffusco@redhat.com>
Date: Thu, 15 Aug 2013 13:42:14 +0200

> UIDs are printed in the proc_fs as signed int, whereas
> they are unsigned int.
> 
> Signed-off-by: Francesco Fusco <ffusco@redhat.com>

Applied, thanks.

^ permalink raw reply

* Re: [PATCH net-next 0/5] qlcnic: Fixes for Mailbox command handling.
From: David Miller @ 2013-08-15 21:46 UTC (permalink / raw)
  To: sucheta.chakraborty; +Cc: netdev, Dept-HSGLinuxNICDev
In-Reply-To: <1376569649-565-1-git-send-email-sucheta.chakraborty@qlogic.com>

From: Sucheta Chakraborty <sucheta.chakraborty@qlogic.com>
Date: Thu, 15 Aug 2013 08:27:24 -0400

> All the bug fixes in this series are dependent on net-next patches which were
> submitted previously by commit (qlcnic: Interrupt based driver firmware mailbox
> mechanism, commit id - e5c4e6c696aea58fbea5758e8b2841d2b0309cf7).
> 
> Please apply this series to net-next.

Series applied, thanks.

^ permalink raw reply

* Re: [patch] tun: signedness bug in tun_get_user()
From: David Miller @ 2013-08-15 21:51 UTC (permalink / raw)
  To: nhorman; +Cc: dan.carpenter, jasowang, mst, edumazet, netdev, kernel-janitors
In-Reply-To: <20130815200834.GE20294@hmsreliant.think-freely.org>

From: Neil Horman <nhorman@tuxdriver.com>
Date: Thu, 15 Aug 2013 16:08:35 -0400

> On Thu, Aug 15, 2013 at 03:52:57PM +0300, Dan Carpenter wrote:
>> The recent fix d9bf5f1309 "tun: compare with 0 instead of total_len" is
>> not totally correct.  Because "len" and "sizeof()" are size_t type, that
>> means they are never less than zero.
>> 
>> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
 ...
> Acked-by: Neil Horman <nhorman@tuxdriver.com>

Applied, thanks everyone.

^ permalink raw reply

* Re: [PATCH v3 0/7] net: use platform_{get,set}_drvdata()
From: David Miller @ 2013-08-15 22:23 UTC (permalink / raw)
  To: clbchenlibo.chen
  Cc: netdev, lizefan, leoli, linuxppc-dev, pantelis.antoniou, vbordug,
	gregkh, jg1.han, sergei.shtylyov
In-Reply-To: <520CD11D.8010202@huawei.com>

From: Libo Chen <clbchenlibo.chen@huawei.com>
Date: Thu, 15 Aug 2013 21:01:17 +0800

> Use the wrapper functions for getting and setting the driver data using
> platform_device instead of using dev_{get,set}_drvdata() with &pdev->dev,
> so we can directly pass a struct platform_device.
> 
> changelog v3:
> 	remove modify about dev_set_drvdata()
> changelog v2:
> 	this version add modify record about dev_set_drvdata().

Series applied.

^ permalink raw reply

* [PATCH] netlink: Eliminate kmalloc in netlink dump operation.
From: Pravin B Shelar @ 2013-08-15 22:31 UTC (permalink / raw)
  To: netdev; +Cc: Pravin B Shelar

Following patch stores struct netlink_callback in netlink_sock
to avoid allocating and freeing it on every netlink dump msg.
Only one dump operation is allowed for a given socket at a time
therefore we can safely convert cb pointer to cb struct inside
netlink_sock.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
---
 net/netlink/af_netlink.c |   97 ++++++++++++++++++++--------------------------
 net/netlink/af_netlink.h |    3 +-
 2 files changed, 44 insertions(+), 56 deletions(-)

diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 6273772..a17dda1 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -595,7 +595,7 @@ static unsigned int netlink_poll(struct file *file, struct socket *sock,
 		 * for dumps is performed here. A dump is allowed to continue
 		 * if at least half the ring is unused.
 		 */
-		while (nlk->cb != NULL && netlink_dump_space(nlk)) {
+		while (nlk->cb_running && netlink_dump_space(nlk)) {
 			err = netlink_dump(sk);
 			if (err < 0) {
 				sk->sk_err = err;
@@ -802,18 +802,6 @@ static void netlink_ring_set_copied(struct sock *sk, struct sk_buff *skb)
 #define netlink_mmap_sendmsg(sk, msg, dst_portid, dst_group, siocb)	0
 #endif /* CONFIG_NETLINK_MMAP */
 
-static void netlink_destroy_callback(struct netlink_callback *cb)
-{
-	kfree_skb(cb->skb);
-	kfree(cb);
-}
-
-static void netlink_consume_callback(struct netlink_callback *cb)
-{
-	consume_skb(cb->skb);
-	kfree(cb);
-}
-
 static void netlink_skb_destructor(struct sk_buff *skb)
 {
 #ifdef CONFIG_NETLINK_MMAP
@@ -872,12 +860,12 @@ static void netlink_sock_destruct(struct sock *sk)
 {
 	struct netlink_sock *nlk = nlk_sk(sk);
 
-	if (nlk->cb) {
-		if (nlk->cb->done)
-			nlk->cb->done(nlk->cb);
+	if (nlk->cb_running) {
+		if (nlk->cb.done)
+			nlk->cb.done(&nlk->cb);
 
-		module_put(nlk->cb->module);
-		netlink_destroy_callback(nlk->cb);
+		module_put(nlk->cb.module);
+		kfree_skb(nlk->cb.skb);
 	}
 
 	skb_queue_purge(&sk->sk_receive_queue);
@@ -2350,7 +2338,8 @@ static int netlink_recvmsg(struct kiocb *kiocb, struct socket *sock,
 
 	skb_free_datagram(sk, skb);
 
-	if (nlk->cb && atomic_read(&sk->sk_rmem_alloc) <= sk->sk_rcvbuf / 2) {
+	if (nlk->cb_running &&
+	    atomic_read(&sk->sk_rmem_alloc) <= sk->sk_rcvbuf / 2) {
 		ret = netlink_dump(sk);
 		if (ret) {
 			sk->sk_err = ret;
@@ -2566,13 +2555,12 @@ static int netlink_dump(struct sock *sk)
 	int alloc_size;
 
 	mutex_lock(nlk->cb_mutex);
-
-	cb = nlk->cb;
-	if (cb == NULL) {
+	if (!nlk->cb_running) {
 		err = -EINVAL;
 		goto errout_skb;
 	}
 
+	cb = &nlk->cb;
 	alloc_size = max_t(int, cb->min_dump_alloc, NLMSG_GOODSIZE);
 
 	if (!netlink_rx_is_mmaped(sk) &&
@@ -2610,11 +2598,11 @@ static int netlink_dump(struct sock *sk)
 
 	if (cb->done)
 		cb->done(cb);
-	nlk->cb = NULL;
-	mutex_unlock(nlk->cb_mutex);
 
+	nlk->cb_running = false;
+	mutex_unlock(nlk->cb_mutex);
 	module_put(cb->module);
-	netlink_consume_callback(cb);
+	consume_skb(cb->skb);
 	return 0;
 
 errout_skb:
@@ -2632,59 +2620,51 @@ int __netlink_dump_start(struct sock *ssk, struct sk_buff *skb,
 	struct netlink_sock *nlk;
 	int ret;
 
-	cb = kzalloc(sizeof(*cb), GFP_KERNEL);
-	if (cb == NULL)
-		return -ENOBUFS;
-
 	/* Memory mapped dump requests need to be copied to avoid looping
 	 * on the pending state in netlink_mmap_sendmsg() while the CB hold
 	 * a reference to the skb.
 	 */
 	if (netlink_skb_is_mmaped(skb)) {
 		skb = skb_copy(skb, GFP_KERNEL);
-		if (skb == NULL) {
-			kfree(cb);
+		if (skb == NULL)
 			return -ENOBUFS;
-		}
 	} else
 		atomic_inc(&skb->users);
 
-	cb->dump = control->dump;
-	cb->done = control->done;
-	cb->nlh = nlh;
-	cb->data = control->data;
-	cb->module = control->module;
-	cb->min_dump_alloc = control->min_dump_alloc;
-	cb->skb = skb;
-
 	sk = netlink_lookup(sock_net(ssk), ssk->sk_protocol, NETLINK_CB(skb).portid);
 	if (sk == NULL) {
-		netlink_destroy_callback(cb);
-		return -ECONNREFUSED;
+		ret = -ECONNREFUSED;
+		goto error_free;
 	}
-	nlk = nlk_sk(sk);
 
+	nlk = nlk_sk(sk);
 	mutex_lock(nlk->cb_mutex);
 	/* A dump is in progress... */
-	if (nlk->cb) {
-		mutex_unlock(nlk->cb_mutex);
-		netlink_destroy_callback(cb);
+	if (nlk->cb_running) {
 		ret = -EBUSY;
-		goto out;
+		goto error_unlock;
 	}
 	/* add reference of module which cb->dump belongs to */
-	if (!try_module_get(cb->module)) {
-		mutex_unlock(nlk->cb_mutex);
-		netlink_destroy_callback(cb);
+	if (!try_module_get(control->module)) {
 		ret = -EPROTONOSUPPORT;
-		goto out;
+		goto error_unlock;
 	}
 
-	nlk->cb = cb;
+	cb = &nlk->cb;
+	memset(cb, 0, sizeof(*cb));
+	cb->dump = control->dump;
+	cb->done = control->done;
+	cb->nlh = nlh;
+	cb->data = control->data;
+	cb->module = control->module;
+	cb->min_dump_alloc = control->min_dump_alloc;
+	cb->skb = skb;
+
+	nlk->cb_running = true;
+
 	mutex_unlock(nlk->cb_mutex);
 
 	ret = netlink_dump(sk);
-out:
 	sock_put(sk);
 
 	if (ret)
@@ -2694,6 +2674,13 @@ out:
 	 * signal not to send ACK even if it was requested.
 	 */
 	return -EINTR;
+
+error_unlock:
+	sock_put(sk);
+	mutex_unlock(nlk->cb_mutex);
+error_free:
+	kfree_skb(skb);
+	return ret;
 }
 EXPORT_SYMBOL(__netlink_dump_start);
 
@@ -2916,14 +2903,14 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
 		struct sock *s = v;
 		struct netlink_sock *nlk = nlk_sk(s);
 
-		seq_printf(seq, "%pK %-3d %-6u %08x %-8d %-8d %pK %-8d %-8d %-8lu\n",
+		seq_printf(seq, "%pK %-3d %-6u %08x %-8d %-8d %d %-8d %-8d %-8lu\n",
 			   s,
 			   s->sk_protocol,
 			   nlk->portid,
 			   nlk->groups ? (u32)nlk->groups[0] : 0,
 			   sk_rmem_alloc_get(s),
 			   sk_wmem_alloc_get(s),
-			   nlk->cb,
+			   nlk->cb_running,
 			   atomic_read(&s->sk_refcnt),
 			   atomic_read(&s->sk_drops),
 			   sock_i_ino(s)
diff --git a/net/netlink/af_netlink.h b/net/netlink/af_netlink.h
index eaa88d1..acbd774 100644
--- a/net/netlink/af_netlink.h
+++ b/net/netlink/af_netlink.h
@@ -32,7 +32,8 @@ struct netlink_sock {
 	unsigned long		*groups;
 	unsigned long		state;
 	wait_queue_head_t	wait;
-	struct netlink_callback	*cb;
+	bool			cb_running;
+	struct netlink_callback	cb;
 	struct mutex		*cb_mutex;
 	struct mutex		cb_def_mutex;
 	void			(*netlink_rcv)(struct sk_buff *skb);
-- 
1.7.1

^ permalink raw reply related

* Re: [PATCH v3 0/7] net: use platform_{get,set}_drvdata()
From: David Miller @ 2013-08-15 22:39 UTC (permalink / raw)
  To: clbchenlibo.chen
  Cc: netdev, lizefan, leoli, linuxppc-dev, pantelis.antoniou, vbordug,
	gregkh, jg1.han, sergei.shtylyov
In-Reply-To: <20130815.152359.920302339053249583.davem@davemloft.net>

From: David Miller <davem@davemloft.net>
Date: Thu, 15 Aug 2013 15:23:59 -0700 (PDT)

> From: Libo Chen <clbchenlibo.chen@huawei.com>
> Date: Thu, 15 Aug 2013 21:01:17 +0800
> 
>> Use the wrapper functions for getting and setting the driver data using
>> platform_device instead of using dev_{get,set}_drvdata() with &pdev->dev,
>> so we can directly pass a struct platform_device.
>> 
>> changelog v3:
>> 	remove modify about dev_set_drvdata()
>> changelog v2:
>> 	this version add modify record about dev_set_drvdata().
> 
> Series applied.

Actually, I had to revert, these patches break the build.

drivers/net/ethernet/sun/sunhme.c: In function ‘happy_meal_pci_probe’:
drivers/net/ethernet/sun/sunhme.c:3114:2: error: implicit declaration of function ‘platform_set_drvdata’ [-Werror=implicit-function-declaration]
drivers/net/ethernet/sun/sunhme.c: In function ‘happy_meal_pci_remove’:
drivers/net/ethernet/sun/sunhme.c:3162:9: error: implicit declaration of function ‘platform_get_drvdata’ [-Werror=implicit-function-declaration]
drivers/net/ethernet/sun/sunhme.c:3162:26: warning: initialization makes pointer from integer without a cast [enabled by default]

^ permalink raw reply

* Re: [PATCH v3 2/2] macvtap: Allow tap features change when IFF_VNET_HDR is disabled.
From: David Miller @ 2013-08-15 22:39 UTC (permalink / raw)
  To: mst; +Cc: vyasevic, netdev
In-Reply-To: <20130815205245.GB12743@redhat.com>

From: "Michael S. Tsirkin" <mst@redhat.com>
Date: Thu, 15 Aug 2013 23:52:45 +0300

> OK in that case let's fix the rest of macvtap so I can stop getting
> confused?

Sure, but after you guys sort out these bug fixes.

^ permalink raw reply

* Re: [PATCH] macvtap: fix up direction in comment on offloading
From: David Miller @ 2013-08-15 22:39 UTC (permalink / raw)
  To: kongjianjun; +Cc: mst, linux-kernel, jasowang, edumazet, vyasevic, netdev
In-Reply-To: <CAFeW=paTeaNsvK7ai-PPs6+MVW3LbaPaW9et_eu3XuGPpMqnuw@mail.gmail.com>

From: Amos Kong <kongjianjun@gmail.com>
Date: Fri, 16 Aug 2013 04:41:26 +0800

> On Fri, Aug 16, 2013 at 1:46 AM, Michael S. Tsirkin <mst@redhat.com> wrote:
>> It speaks about receiving frames, so while
>> it says GSO, it really means GRO.
>>
>> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
>> ---
>>  drivers/net/macvtap.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
>> index a98fb0e..a98ed9f 100644
>> --- a/drivers/net/macvtap.c
>> +++ b/drivers/net/macvtap.c
>> @@ -1047,7 +1047,7 @@ static int set_offload(struct macvtap_queue *q, unsigned long arg)
>>          * accept TSO frames and turning it off means that user space
>>          * does not support TSO.
>>          * For macvtap, we have to invert it to mean the same thing.
>> -        * When user space turns off TSO, we turn off GSO/LRO so that
>> +        * When user space turns off TSO, we turn off GRO/LRO so that
> 
> Right fix.
> 
> Reviewed-by: Amos Kong <kongjianjun@gmail.com>

Applied, thanks.

^ permalink raw reply

* Re: [PATCH] net/mlx5_core: Support MANAGE_PAGES and QUERY_PAGES firmware command changes
From: David Miller @ 2013-08-15 22:43 UTC (permalink / raw)
  To: ogerlitz; +Cc: moshel, netdev, roland, eli
In-Reply-To: <520C9CD7.1090400@mellanox.com>

From: Or Gerlitz <ogerlitz@mellanox.com>
Date: Thu, 15 Aug 2013 12:18:15 +0300

> This commit fixes an issue (bug) which we find in testing done on the
> code/firmware used for the initial merge, xxit happens, indeed. All in
> all, we understand that moving forward, after the initial FW GA or the
> release of 3.11, we will have to maintain FW/driver compatibility.

Ok, since 3.11 is the first release of the driver, this is ok.

Thanks for explaining, applied.

^ permalink raw reply

* Re: [PATCH] netlink: Eliminate kmalloc in netlink dump operation.
From: David Miller @ 2013-08-15 22:51 UTC (permalink / raw)
  To: pshelar; +Cc: netdev
In-Reply-To: <1376605866-6808-1-git-send-email-pshelar@nicira.com>

From: Pravin B Shelar <pshelar@nicira.com>
Date: Thu, 15 Aug 2013 15:31:06 -0700

> Following patch stores struct netlink_callback in netlink_sock
> to avoid allocating and freeing it on every netlink dump msg.
> Only one dump operation is allowed for a given socket at a time
> therefore we can safely convert cb pointer to cb struct inside
> netlink_sock.
> 
> Signed-off-by: Pravin B Shelar <pshelar@nicira.com>

Your analysis looks good, applied, thanks.

^ permalink raw reply

* Re: [PATCH v3 0/7] net: use platform_{get,set}_drvdata()
From: Sergei Shtylyov @ 2013-08-15 22:51 UTC (permalink / raw)
  To: David Miller, clbchenlibo.chen
  Cc: netdev, lizefan, leoli, linuxppc-dev, pantelis.antoniou, vbordug,
	gregkh, jg1.han
In-Reply-To: <20130815.153903.859166500375208182.davem@davemloft.net>

Hello.

On 08/16/2013 02:39 AM, David Miller wrote:

>> From: Libo Chen <clbchenlibo.chen@huawei.com>
>> Date: Thu, 15 Aug 2013 21:01:17 +0800

>>> Use the wrapper functions for getting and setting the driver data using
>>> platform_device instead of using dev_{get,set}_drvdata() with &pdev->dev,
>>> so we can directly pass a struct platform_device.

>>> changelog v3:
>>> 	remove modify about dev_set_drvdata()
>>> changelog v2:
>>> 	this version add modify record about dev_set_drvdata().

>> Series applied.

> Actually, I had to revert, these patches break the build.

> drivers/net/ethernet/sun/sunhme.c: In function ‘happy_meal_pci_probe’:
> drivers/net/ethernet/sun/sunhme.c:3114:2: error: implicit declaration of function ‘platform_set_drvdata’ [-Werror=implicit-function-declaration]
> drivers/net/ethernet/sun/sunhme.c: In function ‘happy_meal_pci_remove’:
> drivers/net/ethernet/sun/sunhme.c:3162:9: error: implicit declaration of function ‘platform_get_drvdata’ [-Werror=implicit-function-declaration]
> drivers/net/ethernet/sun/sunhme.c:3162:26: warning: initialization makes pointer from integer without a cast [enabled by default]

    Hm, patch #5 was clearly defective as it tried to call 
platform_{get|set}_drvdata() on PCI devices -- I've read the patch but 
overlooked that. And the driver lacks #include <linux/platform_device.h>, so 
I'm not sure it always compiled flawlessly.

WBR, Sergei

^ permalink raw reply

* Re: [PATCH stable] ipv6: restrict neighbor entry creation to output flow
From: David Miller @ 2013-08-15 22:54 UTC (permalink / raw)
  To: hannes; +Cc: mleitner, netdev, jiri, dbanerje, yoshfuji
In-Reply-To: <20130814150054.GB2723@order.stressinduktion.org>

From: Hannes Frederic Sowa <hannes@stressinduktion.org>
Date: Wed, 14 Aug 2013 17:00:54 +0200

> On Wed, Aug 14, 2013 at 10:53:27AM -0300, Marcelo Ricardo Leitner wrote:
>> This patch is based on 3.2.y branch, the one used by reported. Please let me
>> know if it should be different. Thanks.
>> 
>> ---8<---
>> 
>> Commit 0d6a77079c475033cb622c07c5a880b392ef664e introduced a regression on
>> which routes to local delivery would not work anymore. Like this:
>> 
>>     $ ip -6 route add local 2001::/64 dev lo
>>     $ ping6 -c1 2001::9
>>     PING 2001::9(2001::9) 56 data bytes
>>     ping: sendmsg: Invalid argument
>> 
>> As this is a local delivery, that commit would not allow the creation of a
>> neighbor entry and thus the packet cannot be sent.
>> 
>> But as TPROXY scenario actually needs to avoid the neighbor entry creation only
>> for input flow, this patch now limits previous patch to input flow, keeping
>> output as before that patch.
>> 
>> Reported-by: Debabrata Banerjee <dbavatar@gmail.com>
>> Signed-off-by: Marcelo Ricardo Leitner <mleitner@redhat.com>
>> CC: Hannes Frederic Sowa <hannes@stressinduktion.org>
> 
> Looks good, thanks Marcelo!
> 
> Acked-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
> 
> David, this patch is for all stable kernels except the 3.10 series.
> It does not apply cleanly throughout the whole longterm kernels but the
> changes should not be too difficult to adapt. Do you take care of this
> or can we do something to ease this process?

I've queued it up for -stable, thanks.

^ permalink raw reply

* Re: [PATCH v3 0/7] net: use platform_{get,set}_drvdata()
From: Sergei Shtylyov @ 2013-08-15 23:04 UTC (permalink / raw)
  To: David Miller, clbchenlibo.chen
  Cc: netdev, lizefan, leoli, linuxppc-dev, pantelis.antoniou, vbordug,
	gregkh, jg1.han
In-Reply-To: <520D5B88.7080304@cogentembedded.com>

On 08/16/2013 02:51 AM, Sergei Shtylyov wrote:

>>> From: Libo Chen <clbchenlibo.chen@huawei.com>
>>> Date: Thu, 15 Aug 2013 21:01:17 +0800

>>>> Use the wrapper functions for getting and setting the driver data using
>>>> platform_device instead of using dev_{get,set}_drvdata() with &pdev->dev,
>>>> so we can directly pass a struct platform_device.

>>>> changelog v3:
>>>>     remove modify about dev_set_drvdata()
>>>> changelog v2:
>>>>     this version add modify record about dev_set_drvdata().

>>> Series applied.

>> Actually, I had to revert, these patches break the build.

>> drivers/net/ethernet/sun/sunhme.c: In function ‘happy_meal_pci_probe’:
>> drivers/net/ethernet/sun/sunhme.c:3114:2: error: implicit declaration of
>> function ‘platform_set_drvdata’ [-Werror=implicit-function-declaration]
>> drivers/net/ethernet/sun/sunhme.c: In function ‘happy_meal_pci_remove’:
>> drivers/net/ethernet/sun/sunhme.c:3162:9: error: implicit declaration of
>> function ‘platform_get_drvdata’ [-Werror=implicit-function-declaration]
>> drivers/net/ethernet/sun/sunhme.c:3162:26: warning: initialization makes
>> pointer from integer without a cast [enabled by default]

>     Hm, patch #5 was clearly defective as it tried to call
> platform_{get|set}_drvdata() on PCI devices -- I've read the patch but
> overlooked that. And the driver lacks #include <linux/platform_device.h>, so
> I'm not sure it always compiled flawlessly.

    Ah, the platform code is protected by #ifdef CONFIG_SBUS... probably some 
header #include's <linux/platform_device.h>?

WBR, Sergei

^ permalink raw reply

* [GIT] Networking
From: David Miller @ 2013-08-15 23:28 UTC (permalink / raw)
  To: torvalds; +Cc: akpm, netdev, linux-kernel


1) Fix SKB leak in 8139cp, from Dave Jones.

2) Fix use of *_PAGES interfaces with mlx5 firmware, from
   Moshe Lazar.

3) RCU conversion of macvtap introduced two races, fixes by
   Eric Dumazet.

4) Synchronize statistic flows in bnx2x driver to prevent
   corruption, from Dmitry Kravkov.

5) Undo optimization in IP tunneling, we were using the inner
   IP header in some cases to inherit the IP ID, but that
   isn't correct in some circumstances.  From Pravin B Shelar.

6) Use correct struct size when parsing netlink attributes in
   rtnl_bridge_getlink().  From Asbjoern Sloth Toennesen.

7) Length verifications in tun_get_user() are bogus, from
   Weiping Pan and Dan Carpenter.

8) Fix bad merge resolution during 3.11 networking development
   in openvswitch, albeit a harmless one which added some
   unreachable code.  From Jesse Gross.

9) Wrong size used in flexible array allocation in openvswitch,
   from Pravin B Shelar.

10) Clear out firmware capability flags the be2net driver isn't
    ready to handle yet, from Sarveshwar Bandi.

11) Revert DMA mapping error checking addition to cxgb3 driver,
    it's buggy.  From Alexey Kardashevskiy.

12) Fix regression in packet scheduler rate limiting when working
    with a link layer of ATM.  From Jesper Dangaard Brouer.

13) Fix several errors in TCP Cubic congestion control, in particular
    overflow errors in timestamp calculations.  From Eric Dumazet
    and Van Jacobson.

14) In ipv6 routing lookups, we need to backtrack if subtree traversal
    don't result in a match.  From Hannes Frederic Sowa.

15) ipgre_header() returns incorrect packet offset.  Fix from Timo Teräs.

16) Get "low latency" out of the new MIB counter names.  From Eliezer
    Tamir.

17) State check in ndo_dflt_fdb_del() is inverted, from Sridhar
    Samudrala.

18) Handle TCP Fast Open properly in netfilter conntrack, from Yuchung
    Cheng.

19) Wrong memcpy length in pcan_usb driver, from Stephane Grosjean.

20) Fix dealock in TIPC, from Wang Weidong and Ding Tianhong.

21) call_rcu() call to destroy SCTP transport is done too early and
    might result in an oops.  From Daniel Borkmann.

22) Fix races in genetlink family dumps, from Johannes Berg.

23) Flags passed into macvlan by the user need to be validated properly,
    from Michael S. Tsirkin.

24) Fix skge build on 32-bit, from Stephen Hemminger.

25) Handle malformed TCP headers properly in xt_TCPMSS, from Pablo
    Neira Ayuso.

26) Fix handling of stacked vlans in vlan_dev_real_dev(), from Nikolay
    Aleksandrov.

27) Eliminate MTU calculation overflows in esp{4,6}, from Daniel Borkmann.

28) neigh_parms need to be setup before calling the ->ndo_neigh_setup()
    method.  From Veaceslav Falico.

29) Kill out-of-bounds prefetch in fib_trie, from Eric Dumazet.

30) Don't dereference MLD query message if the length isn't value in
    the bridge multicast code, from Linus Lüssing.

31) Fix VXLAN IGMP join regression due to an inverted check, from Cong
    Wang.

Please pull, thanks a lot.

The following changes since commit 72a67a94bcba71a5fddd6b3596a20604d2b5dcd6:

  Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net (2013-08-03 15:00:23 -0700)

are available in the git repository at:


  git://git.kernel.org/pub/scm/linux/kernel/git/davem/net master

for you to fetch changes up to 0a324f3189ed9c78b1aaf48d88e93cb18643c655:

  net/mlx5_core: Support MANAGE_PAGES and QUERY_PAGES firmware command changes (2013-08-15 15:42:57 -0700)

----------------------------------------------------------------
Alexey Brodkin (1):
      ethernet/arc/arc_emac - fix NAPI "work > weight" warning

Alexey Kardashevskiy (1):
      Revert "cxgb3: Check and handle the dma mapping errors"

Ariel Elior (1):
      bnx2x: fix memory leak in VF

Asbjoern Sloth Toennesen (1):
      rtnetlink: rtnl_bridge_getlink: Call nlmsg_find_attr() with ifinfomsg header

Barak Witkowsky (1):
      bnx2x: fix PTE write access error

Bartlomiej Zolnierkiewicz (1):
      stmmac: fix init_dma_desc_rings() to handle errors

Byungho An (1):
      net: stmmac: Fixed the condition of extend_desc for jumbo frame

Chris Wright (1):
      mac80211: fix infinite loop in ieee80211_determine_chantype

Cong Wang (2):
      vxlan: fix a regression of igmp join
      vxlan: fix a soft lockup in vxlan module removal

Dan Carpenter (2):
      netfilter: nfnetlink_{log,queue}: fix information leaks in netlink message
      tun: signedness bug in tun_get_user()

Daniel Borkmann (4):
      net: esp{4,6}: fix potential MTU calculation overflows
      net: sctp: sctp_assoc_control_transport: fix MTU size in SCTP_PF state
      net: sctp: sctp_transport_destroy{, _rcu}: fix potential pointer corruption
      net: tg3: fix NULL pointer dereference in tg3_io_error_detected and tg3_io_slot_reset

Dave Jones (1):
      8139cp: Fix skb leak in rx_status_loop failure path.

David S. Miller (5):
      Merge branch 'for-davem' of git://git.kernel.org/.../linville/wireless
      Merge branch 'master' of git://git.kernel.org/.../pablo/nf
      Merge tag 'batman-adv-fix-for-davem' of git://git.open-mesh.org/linux-merge
      Merge branch 'bnx2x'
      Merge branch 'fixes' of git://git.kernel.org/.../jesse/openvswitch

Dmitry Kravkov (2):
      bnx2x: protect different statistics flows
      bnx2x: update fairness parameters following DCB negotiation

Eli Cohen (1):
      mlx5: remove health handler plugin

Eliezer Tamir (2):
      busy_poll: cleanup do-nothing placeholders
      net: rename busy poll MIB counter

Eric Dumazet (5):
      fib_trie: remove potential out of bound access
      tcp: cubic: fix overflow error in bictcp_update()
      tcp: cubic: fix bug in bictcp_acked()
      net: flow_dissector: add 802.1ad support
      macvtap: fix two races

Hannes Frederic Sowa (1):
      ipv6: don't stop backtracking in fib6_lookup_1 if subtree does not match

Himanshu Madhani (1):
      qlcnic: Fix set driver version command

Hyong-Youb Kim (1):
      myri10ge: Update MAINTAINERS

Jesper Dangaard Brouer (1):
      net_sched: restore "linklayer atm" handling

Jesse Gross (2):
      openvswitch: Fix bad merge resolution.
      openvswitch: Reset tunnel key between input and output.

Johannes Berg (6):
      nl80211: fix another nl80211_fam.attrbuf race
      mac80211: don't wait for TX status forever
      mac80211: ignore HT primary channel while connected
      cfg80211: fix P2P GO interface teardown
      mac80211: continue using disabled channels while connected
      genetlink: fix family dump race

John W. Linville (2):
      Merge branch 'for-john' of git://git.kernel.org/.../jberg/mac80211
      Merge branch 'master' of git://git.kernel.org/.../linville/wireless into for-davem

Julia Lawall (2):
      net/vmw_vsock/af_vsock.c: drop unneeded semicolon
      drivers/net/ethernet/via/via-velocity.c: update napi implementation

Linus Lüssing (2):
      bridge: don't try to update timers in case of broken MLD queries
      batman-adv: fix potential kernel paging errors for unicast transmissions

Manish Chopra (1):
      qlcnic: Fix diagnostic interrupt test for 83xx adapters

Michael S. Tsirkin (1):
      macvlan: validate flags

Moshe Lazer (1):
      net/mlx5_core: Support MANAGE_PAGES and QUERY_PAGES firmware command changes

Pablo Neira Ayuso (2):
      netfilter: xt_TCPMSS: fix handling of malformed TCP header and options
      netfilter: xt_TCPOPTSTRIP: fix possible off by one access

Pravin B Shelar (2):
      ip_tunnel: Do not use inner ip-header-id for tunnel ip-header-id.
      openvswitch: Use correct type while allocating flex array.

Sarveshwar Bandi (1):
      be2net: Clear any capability flags that driver is not interested in.

Solomon Peachy (1):
      cw1200: Fix spurious BUG_ON() trigger when starting AP mode.

Sridhar Samudrala (1):
      rtnetlink: Fix inverted check in ndo_dflt_fdb_del()

Stanislaw Gruszka (2):
      iwl4965: set power mode early
      iwl4965: reset firmware after rfkill off

Stephane Grosjean (1):
      can: pcan_usb: fix wrong memcpy() bytes length

Stephen Hemminger (1):
      skge: fix build on 32 bit

Sucheta Chakraborty (1):
      qlcnic: Fix beacon state return status handling

Timo Teräs (1):
      ip_gre: fix ipgre_header to return correct offset

Veaceslav Falico (2):
      neighbour: populate neigh_parms on alloc before calling ndo_neigh_setup
      bonding: modify only neigh_parms owned by us

Wang Sheng-Hui (1):
      bridge: correct the comment for file br_sysfs_br.c

Weiping Pan (1):
      tun: compare with 0 instead of total_len

Yuchung Cheng (1):
      netfilter: nf_conntrack: fix tcp_in_window for Fast Open

Yuval Mintz (1):
      bnx2x: prevent crash in shutdown flow with CNIC

dingtianhong (1):
      tipc: avoid possible deadlock while enable and disable bearer

nikolay@redhat.com (2):
      vlan: make vlan_dev_real_dev work over stacked vlans
      net_sched: make dev_trans_start return vlan's real dev trans_start

stephen hemminger (2):
      skge: add dma_mapping check
      skge: dma_sync the whole receive buffer

 MAINTAINERS                                           |   4 +--
 drivers/net/bonding/bond_main.c                       |   8 ++++-
 drivers/net/can/usb/peak_usb/pcan_usb.c               |   2 +-
 drivers/net/ethernet/arc/emac_main.c                  |   2 +-
 drivers/net/ethernet/broadcom/bnx2x/bnx2x.h           |   5 +++
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_dcb.c       |   4 +++
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_hsi.h       |   5 +++
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c      |  43 ++++++++++++++++--------
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c     |   2 +-
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_stats.c     |  66 ++++++++++++++++++++++++++++++-------
 drivers/net/ethernet/broadcom/tg3.c                   |  13 +++++---
 drivers/net/ethernet/chelsio/cxgb3/sge.c              | 107 ++++++++++++++---------------------------------------------
 drivers/net/ethernet/emulex/benet/be_cmds.c           |   3 ++
 drivers/net/ethernet/emulex/benet/be_cmds.h           |   6 ++++
 drivers/net/ethernet/marvell/skge.c                   |  68 +++++++++++++++++++++++++++++---------
 drivers/net/ethernet/mellanox/mlx5/core/cmd.c         |   2 +-
 drivers/net/ethernet/mellanox/mlx5/core/eq.c          |   2 +-
 drivers/net/ethernet/mellanox/mlx5/core/fw.c          |   2 +-
 drivers/net/ethernet/mellanox/mlx5/core/health.c      |  29 +---------------
 drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c   |  58 +++++++++++++++-----------------
 drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c   |   5 +++
 drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c |   3 +-
 drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c      |   6 ++--
 drivers/net/ethernet/qlogic/qlcnic/qlcnic_sysfs.c     |   6 ++--
 drivers/net/ethernet/realtek/8139cp.c                 |   1 +
 drivers/net/ethernet/stmicro/stmmac/ring_mode.c       |  13 ++++++--
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c     | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++-----------
 drivers/net/ethernet/via/via-velocity.c               |   4 ++-
 drivers/net/macvlan.c                                 |   4 +++
 drivers/net/macvtap.c                                 |  12 +++++--
 drivers/net/tun.c                                     |   6 ++--
 drivers/net/vxlan.c                                   |   4 +--
 drivers/net/wireless/cw1200/sta.c                     |   7 ++--
 drivers/net/wireless/iwlegacy/4965-mac.c              |  16 ++++-----
 drivers/net/wireless/iwlegacy/common.c                |   1 +
 include/linux/mlx5/device.h                           |  22 ++++++-------
 include/linux/mlx5/driver.h                           |   7 ++--
 include/net/busy_poll.h                               |   7 +---
 include/net/ip_tunnels.h                              |  14 --------
 include/net/sch_generic.h                             |   9 ++++-
 include/uapi/linux/pkt_sched.h                        |  10 +++++-
 include/uapi/linux/snmp.h                             |   2 +-
 net/8021q/vlan_core.c                                 |   7 +++-
 net/batman-adv/bridge_loop_avoidance.c                |   2 ++
 net/batman-adv/gateway_client.c                       |  13 +++++++-
 net/batman-adv/gateway_client.h                       |   3 +-
 net/batman-adv/soft-interface.c                       |   9 ++++-
 net/batman-adv/unicast.c                              |  13 ++++++--
 net/bridge/br_multicast.c                             |   2 +-
 net/bridge/br_sysfs_br.c                              |   2 +-
 net/core/flow_dissector.c                             |   1 +
 net/core/neighbour.c                                  |  10 +++---
 net/core/rtnetlink.c                                  |   4 +--
 net/ipv4/esp4.c                                       |   2 +-
 net/ipv4/fib_trie.c                                   |   5 +--
 net/ipv4/ip_gre.c                                     |   2 +-
 net/ipv4/ip_tunnel_core.c                             |   4 +--
 net/ipv4/proc.c                                       |   2 +-
 net/ipv4/tcp_cubic.c                                  |  12 ++++---
 net/ipv6/esp6.c                                       |   2 +-
 net/ipv6/ip6_fib.c                                    |  16 ++++++---
 net/mac80211/mlme.c                                   |  54 ++++++++++++++++++++----------
 net/netfilter/nf_conntrack_proto_tcp.c                |  12 ++++---
 net/netfilter/nfnetlink_log.c                         |   6 +++-
 net/netfilter/nfnetlink_queue_core.c                  |   5 ++-
 net/netfilter/xt_TCPMSS.c                             |  28 +++++++++-------
 net/netfilter/xt_TCPOPTSTRIP.c                        |  10 +++---
 net/netlink/genetlink.c                               |   7 ++++
 net/openvswitch/actions.c                             |   1 +
 net/openvswitch/datapath.c                            |   3 --
 net/openvswitch/flow.c                                |   2 +-
 net/sched/sch_api.c                                   |  41 +++++++++++++++++++++++
 net/sched/sch_generic.c                               |   8 ++++-
 net/sched/sch_htb.c                                   |  13 ++++++++
 net/sctp/associola.c                                  |   4 +--
 net/sctp/transport.c                                  |   4 +--
 net/tipc/bearer.c                                     |   9 +++--
 net/vmw_vsock/af_vsock.c                              |   2 +-
 net/wireless/core.c                                   |   1 +
 net/wireless/nl80211.c                                |   6 ++--
 80 files changed, 651 insertions(+), 377 deletions(-)

^ permalink raw reply

* Re: Quick Blind TCP Connection Spoofing with SYN Cookies
From: Jiri Bohac @ 2013-08-15 23:57 UTC (permalink / raw)
  To: Jakob Lell; +Cc: netdev, davem
In-Reply-To: <520A3B4A.1050704@jakoblell.com>

On Tue, Aug 13, 2013 at 03:57:30PM +0200, Jakob Lell wrote:
> VIII. Possible mitigation options
> 
> The simplification of TCP Connection Spoofing described here is an
> inherent problem of TCP SYN Cookies and so there won't be a simple
> patch which just solves the issue and makes the Spoofing Attack as
> hard as it is without SYN Cookies. It is only possible to gradually
> increase the required effort for successfully spoofing a connection
> e.g. by only accepting the last two instead of four counter values
> (which will lead to a 60-120s 

If the counter is slowed down 4 times, accepting only two
values should result in similar behaviour as we have today.

Can anyone think of a reason this should not be done?


Additionally, I believe we should reduce the number of possible MSS
values. I think 3 values should be enough - not supporting jumbo
frames and wasting a few bytes on sub-optimal MSS around 1400
bytes should be acceptable when a system is under a DoS attack.

I have 3 patches doing just that:

1 - slow down the timer and improve the situation by a factor of 2
2 - since not everyone will be happy with exactly 3 MSS values,
    let's make this configurable via sysctl
3 - decrease the default number of MSS values to 3 and improve
    the situation by a factor of 8/3

These patches combined make the attack 5.3 times harder. By
using the sysctl to only set two possible MSSs, one can make
the attack 8 times harder - and only 4 times easier than
previously believed.

The patches are compile-tested only.

Thoughts?


-- 
Jiri Bohac <jbohac@suse.cz>
SUSE Labs, SUSE CZ

^ permalink raw reply

* [PATCH 1/3] [RFC] TCP syncookies: slow down timer to mitigate spoofing attacks
From: Jiri Bohac @ 2013-08-16  0:00 UTC (permalink / raw)
  To: Jiri Bohac; +Cc: Jakob Lell, netdev, davem
In-Reply-To: <20130815235743.GA25665@midget.suse.cz>

(compile-tested only)

Jakob Lell discovered that the sequence number that needs to be guessed to
successfully spoof a TCP connection with syncookies only has 27 bits of
entropy. Of the 32 bits, 2 bits are wasted by the four differrent timestamps
accepted and 3 are wasted by the 8 differrent RSS values. [1]

This patch slows down the timer used in syncookies from 1/60 Hz to 1/60/4 Hz
so that at any moment only two differrent timer values can be accepted.
As a result, 1 bit of sequence number entropy is gained.

This changes the maximum cookie age limit from 4 - 5 minutes to 4 - 8 minutes.

[1]: http://www.jakoblell.com/blog/2013/08/13/quick-blind-tcp-connection-spoofing-with-syn-cookies/

Signed-off-by: Jiri Bohac <jbohac@suse.cz>
---
 net/ipv4/syncookies.c | 30 ++++++++++++++++--------------
 net/ipv6/syncookies.c | 15 ++++++++-------
 2 files changed, 24 insertions(+), 21 deletions(-)

diff --git a/net/ipv4/syncookies.c b/net/ipv4/syncookies.c
index b05c96e..cf1b720 100644
--- a/net/ipv4/syncookies.c
+++ b/net/ipv4/syncookies.c
@@ -114,13 +114,13 @@ static __u32 secure_tcp_syn_cookie(__be32 saddr, __be32 daddr, __be16 sport,
  * If the syncookie is bad, the data returned will be out of
  * range.  This must be checked by the caller.
  *
- * The count value used to generate the cookie must be within
- * "maxdiff" if the current (passed-in) "count".  The return value
+ * The count value used to generate the cookie must be the same or
+ * one less than the current (passed-in) "count".  The return value
  * is (__u32)-1 if this test fails.
  */
 static __u32 check_tcp_syn_cookie(__u32 cookie, __be32 saddr, __be32 daddr,
 				  __be16 sport, __be16 dport, __u32 sseq,
-				  __u32 count, __u32 maxdiff)
+				  __u32 count)
 {
 	__u32 diff;
 
@@ -129,7 +129,7 @@ static __u32 check_tcp_syn_cookie(__u32 cookie, __be32 saddr, __be32 daddr,
 
 	/* Cookie is now reduced to (count * 2^24) ^ (hash % 2^24) */
 	diff = (count - (cookie >> COOKIEBITS)) & ((__u32) - 1 >> COOKIEBITS);
-	if (diff >= maxdiff)
+	if (diff >= 2)
 		return (__u32)-1;
 
 	return (cookie -
@@ -157,6 +157,16 @@ static __u16 const msstab[] = {
 };
 
 /*
+ * This value is the age (in seconds) of syncookies which will always be
+ * permitted. Cookies aged up to twice this value may be permitted as
+ * a result of rounding errors.
+ * Its ideal value should be dependent on TCP_TIMEOUT_INIT and
+ * sysctl_tcp_retries1. It's a rather complicated formula (exponential
+ * backoff) to compute at runtime so it's currently hardcoded here.
+ */
+#define COOKIE_LIFETIME 4	/* 4 to 8 seconds */
+
+/*
  * Generate a syncookie.  mssp points to the mss, which is returned
  * rounded down to the value encoded in the cookie.
  */
@@ -178,17 +188,10 @@ __u32 cookie_v4_init_sequence(struct sock *sk, struct sk_buff *skb, __u16 *mssp)
 
 	return secure_tcp_syn_cookie(iph->saddr, iph->daddr,
 				     th->source, th->dest, ntohl(th->seq),
-				     jiffies / (HZ * 60), mssind);
+				     jiffies / (HZ * 60 * COOKIE_LIFETIME), mssind);
 }
 
 /*
- * This (misnamed) value is the age of syncookie which is permitted.
- * Its ideal value should be dependent on TCP_TIMEOUT_INIT and
- * sysctl_tcp_retries1. It's a rather complicated formula (exponential
- * backoff) to compute at runtime so it's currently hardcoded here.
- */
-#define COUNTER_TRIES 4
-/*
  * Check if a ack sequence number is a valid syncookie.
  * Return the decoded mss if it is, or 0 if not.
  */
@@ -199,8 +202,7 @@ static inline int cookie_check(struct sk_buff *skb, __u32 cookie)
 	__u32 seq = ntohl(th->seq) - 1;
 	__u32 mssind = check_tcp_syn_cookie(cookie, iph->saddr, iph->daddr,
 					    th->source, th->dest, seq,
-					    jiffies / (HZ * 60),
-					    COUNTER_TRIES);
+					    jiffies / (HZ * 60 * COOKIE_LIFETIME));
 
 	return mssind < ARRAY_SIZE(msstab) ? msstab[mssind] : 0;
 }
diff --git a/net/ipv6/syncookies.c b/net/ipv6/syncookies.c
index d5dda20..46e8b27 100644
--- a/net/ipv6/syncookies.c
+++ b/net/ipv6/syncookies.c
@@ -37,12 +37,14 @@ static __u16 const msstab[] = {
 };
 
 /*
- * This (misnamed) value is the age of syncookie which is permitted.
+ * This value is the age (in seconds) of syncookies which will always be
+ * permitted. Cookies aged up to twice this value may be permitted as
+ * a result of rounding errors.
  * Its ideal value should be dependent on TCP_TIMEOUT_INIT and
  * sysctl_tcp_retries1. It's a rather complicated formula (exponential
  * backoff) to compute at runtime so it's currently hardcoded here.
  */
-#define COUNTER_TRIES 4
+#define COOKIE_LIFETIME 4	/* 4 to 8 seconds */
 
 static inline struct sock *get_cookie_sock(struct sock *sk, struct sk_buff *skb,
 					   struct request_sock *req,
@@ -96,15 +98,14 @@ static __u32 secure_tcp_syn_cookie(const struct in6_addr *saddr,
 
 static __u32 check_tcp_syn_cookie(__u32 cookie, const struct in6_addr *saddr,
 				  const struct in6_addr *daddr, __be16 sport,
-				  __be16 dport, __u32 sseq, __u32 count,
-				  __u32 maxdiff)
+				  __be16 dport, __u32 sseq, __u32 count)
 {
 	__u32 diff;
 
 	cookie -= cookie_hash(saddr, daddr, sport, dport, 0, 0) + sseq;
 
 	diff = (count - (cookie >> COOKIEBITS)) & ((__u32) -1 >> COOKIEBITS);
-	if (diff >= maxdiff)
+	if (diff >= 2)
 		return (__u32)-1;
 
 	return (cookie -
@@ -131,7 +132,7 @@ __u32 cookie_v6_init_sequence(struct sock *sk, const struct sk_buff *skb, __u16
 
 	return secure_tcp_syn_cookie(&iph->saddr, &iph->daddr, th->source,
 				     th->dest, ntohl(th->seq),
-				     jiffies / (HZ * 60), mssind);
+				     jiffies / (HZ * 60 * COOKIE_LIFETIME), mssind);
 }
 
 static inline int cookie_check(const struct sk_buff *skb, __u32 cookie)
@@ -141,7 +142,7 @@ static inline int cookie_check(const struct sk_buff *skb, __u32 cookie)
 	__u32 seq = ntohl(th->seq) - 1;
 	__u32 mssind = check_tcp_syn_cookie(cookie, &iph->saddr, &iph->daddr,
 					    th->source, th->dest, seq,
-					    jiffies / (HZ * 60), COUNTER_TRIES);
+					    jiffies / (HZ * 60 * COOKIE_LIFETIME));
 
 	return mssind < ARRAY_SIZE(msstab) ? msstab[mssind] : 0;
 }
-- 
1.8.3.1

-- 
Jiri Bohac <jbohac@suse.cz>
SUSE Labs, SUSE CZ

^ permalink raw reply related

* [PATCH 2/3] [RFC] TCP syncookies: introduce sysctl to configure the MSS tables
From: Jiri Bohac @ 2013-08-16  0:03 UTC (permalink / raw)
  To: Jiri Bohac; +Cc: Jakob Lell, netdev, davem
In-Reply-To: <20130815235743.GA25665@midget.suse.cz>

(compile-tested only)

This patch introduces two new sysctls
	net.ipv4.tcp_syncookies_mss_table
	net.ipv6.tcp_syncookies_mss_table
to manipulate the TCP syncookie MSS tables

Signed-off-by: Jiri Bohac <jbohac@suse.cz>
---
 Documentation/networking/ip-sysctl.txt | 22 +++++++++++--
 include/net/tcp.h                      |  9 ++++++
 net/ipv4/syncookies.c                  | 13 +++++---
 net/ipv4/sysctl_net_ipv4.c             | 57 ++++++++++++++++++++++++++++++++++
 net/ipv6/syncookies.c                  | 13 +++++---
 net/ipv6/sysctl_net_ipv6.c             | 20 ++++++++++++
 6 files changed, 122 insertions(+), 12 deletions(-)

diff --git a/Documentation/networking/ip-sysctl.txt b/Documentation/networking/ip-sysctl.txt
index 1074290..f49a741 100644
--- a/Documentation/networking/ip-sysctl.txt
+++ b/Documentation/networking/ip-sysctl.txt
@@ -440,6 +440,20 @@ tcp_syncookies - BOOLEAN
 	SYN flood warnings in logs not being really flooded, your server
 	is seriously misconfigured.
 
+tcp_syncookies_mss_table - vector of INTEGERs
+	TCP connections initiated with TCP syncookies are limited to a
+	pre-defined set of MSS values. The more possible values, the better
+	the MSS can correspond with the MSS originally sent by the client.
+	However, more possible MSS values means less effort tu successfully 
+	spoof a TCP sonnection.
+
+	The sysctl is an array of possible MSS values, sorted from smallest to
+	largest. If a zero value is present, all following values will be
+	ignored.
+
+	This setting only applies to TCP over IPv4. IPv6 has its own sysctl.
+
+
 tcp_fastopen - INTEGER
 	Enable TCP Fast Open feature (draft-ietf-tcpm-fastopen) to send data
 	in the opening SYN packet. To use this feature, the client application
@@ -1042,8 +1056,12 @@ delon.nicolas@wanadoo.fr
 
 /proc/sys/net/ipv6/* Variables:
 
-IPv6 has no global variables such as tcp_*.  tcp_* settings under ipv4/ also
-apply to IPv6 [XXX?].
+tcp_syncookies_mss_table - vector of INTEGERs
+	see the TCP/IPv4 description 
+
+
+IPv6 has no other global variables such as tcp_*.  tcp_* settings under ipv4/ i
+also apply to IPv6 [XXX?].
 
 bindv6only - BOOLEAN
 	Default value for IPV6_V6ONLY socket option,
diff --git a/include/net/tcp.h b/include/net/tcp.h
index d198005..460ffe9 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -482,8 +482,15 @@ extern __u32 syncookie_secret[2][16-4+SHA_DIGEST_WORDS];
 extern struct sock *cookie_v4_check(struct sock *sk, struct sk_buff *skb, 
 				    struct ip_options *opt);
 #ifdef CONFIG_SYN_COOKIES
+#define TCP_SYNCOOKIES_MSS_COUNT_MAX 8
 extern __u32 cookie_v4_init_sequence(struct sock *sk, struct sk_buff *skb, 
 				     __u16 *mss);
+extern int sysctl_tcp4_syncookies_mss[TCP_SYNCOOKIES_MSS_COUNT_MAX];
+extern int sysctl_tcp4_syncookies_mss_count;
+int tcp_syncookies_mss_sysctl(struct ctl_table *ctl, int write,
+				 void __user *buffer, size_t *lenp,
+				 loff_t *ppos, int *count);
+
 #else
 static inline __u32 cookie_v4_init_sequence(struct sock *sk,
 					    struct sk_buff *skb,
@@ -502,6 +509,8 @@ extern struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb);
 #ifdef CONFIG_SYN_COOKIES
 extern __u32 cookie_v6_init_sequence(struct sock *sk, const struct sk_buff *skb,
 				     __u16 *mss);
+extern int sysctl_tcp6_syncookies_mss[TCP_SYNCOOKIES_MSS_COUNT_MAX];
+extern int sysctl_tcp6_syncookies_mss_count;
 #else
 static inline __u32 cookie_v6_init_sequence(struct sock *sk,
 					    struct sk_buff *skb,
diff --git a/net/ipv4/syncookies.c b/net/ipv4/syncookies.c
index cf1b720..af0692f 100644
--- a/net/ipv4/syncookies.c
+++ b/net/ipv4/syncookies.c
@@ -145,7 +145,7 @@ static __u32 check_tcp_syn_cookie(__u32 cookie, __be32 saddr, __be32 daddr,
  *
  * Table must be sorted.
  */
-static __u16 const msstab[] = {
+int sysctl_tcp4_syncookies_mss[TCP_SYNCOOKIES_MSS_COUNT_MAX] = {
 	64,
 	512,
 	536,
@@ -154,7 +154,9 @@ static __u16 const msstab[] = {
 	1460,
 	4312,
 	8960,
+	/* update sysctl_tcp4_syncookies_mss_count accordingly */
 };
+int sysctl_tcp4_syncookies_mss_count = 8;
 
 /*
  * This value is the age (in seconds) of syncookies which will always be
@@ -179,10 +181,10 @@ __u32 cookie_v4_init_sequence(struct sock *sk, struct sk_buff *skb, __u16 *mssp)
 
 	tcp_synq_overflow(sk);
 
-	for (mssind = ARRAY_SIZE(msstab) - 1; mssind ; mssind--)
-		if (mss >= msstab[mssind])
+	for (mssind = sysctl_tcp4_syncookies_mss_count - 1; mssind ; mssind--)
+		if (mss >= sysctl_tcp4_syncookies_mss[mssind])
 			break;
-	*mssp = msstab[mssind];
+	*mssp = sysctl_tcp4_syncookies_mss[mssind];
 
 	NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_SYNCOOKIESSENT);
 
@@ -204,7 +206,8 @@ static inline int cookie_check(struct sk_buff *skb, __u32 cookie)
 					    th->source, th->dest, seq,
 					    jiffies / (HZ * 60 * COOKIE_LIFETIME));
 
-	return mssind < ARRAY_SIZE(msstab) ? msstab[mssind] : 0;
+	return mssind < sysctl_tcp4_syncookies_mss_count ?
+		sysctl_tcp4_syncookies_mss[mssind] : 0;
 }
 
 static inline struct sock *get_cookie_sock(struct sock *sk, struct sk_buff *skb,
diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
index 610e324..b2e9266 100644
--- a/net/ipv4/sysctl_net_ipv4.c
+++ b/net/ipv4/sysctl_net_ipv4.c
@@ -235,6 +235,57 @@ static int ipv4_tcp_mem(struct ctl_table *ctl, int write,
 	return 0;
 }
 
+#ifdef CONFIG_SYN_COOKIES
+int tcp_syncookies_mss_sysctl(struct ctl_table *ctl, int write,
+				 void __user *buffer, size_t *lenp,
+				 loff_t *ppos, int *count)
+{
+	int *table = ctl->data;
+	int old_table[TCP_SYNCOOKIES_MSS_COUNT_MAX];
+	int old_count, err, i, prev = 0;
+
+	if (write) {
+		memcpy(old_table, table, sizeof(old_table));
+		old_count = *count;
+		memset(ctl->data, 0, sizeof(old_table));
+	}
+
+	err = proc_dointvec(ctl, write, buffer, lenp, ppos);
+	if (!write)
+		return err;
+	if (err)
+		goto restore;
+
+	for (i = 0; i < TCP_SYNCOOKIES_MSS_COUNT_MAX; ++i) {
+		if (!table[i])
+			break;
+		if (table[i] < 64 ||
+		    table[i] > 65536 ||
+		    prev >= table[i]) {
+			err = -EINVAL;
+			goto restore;
+		}
+		prev = table[i];
+	}
+	*count = i;
+
+	return err;
+restore:
+	*count = old_count;
+	memcpy(table, old_table, sizeof(old_table));
+	return err;
+}
+EXPORT_SYMBOL(tcp_syncookies_mss_sysctl);
+
+static int tcp4_syncookies_mss_sysctl(struct ctl_table *ctl, int write,
+				 void __user *buffer, size_t *lenp,
+				 loff_t *ppos)
+{
+	return tcp_syncookies_mss_sysctl(ctl, write, buffer, lenp, ppos,
+					   &sysctl_tcp4_syncookies_mss_count);
+}
+#endif
+
 static int proc_tcp_fastopen_key(struct ctl_table *ctl, int write,
 				 void __user *buffer, size_t *lenp,
 				 loff_t *ppos)
@@ -424,6 +474,13 @@ static struct ctl_table ipv4_table[] = {
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec
 	},
+	{
+		.procname	= "tcp_syncookies_mss_table",
+		.data		= &sysctl_tcp4_syncookies_mss,
+		.maxlen		= sizeof(sysctl_tcp4_syncookies_mss),
+		.mode		= 0644,
+		.proc_handler	= tcp4_syncookies_mss_sysctl,
+	},
 #endif
 	{
 		.procname	= "tcp_fastopen",
diff --git a/net/ipv6/syncookies.c b/net/ipv6/syncookies.c
index 46e8b27..4268448 100644
--- a/net/ipv6/syncookies.c
+++ b/net/ipv6/syncookies.c
@@ -25,7 +25,7 @@
 #define COOKIEMASK (((__u32)1 << COOKIEBITS) - 1)
 
 /* Table must be sorted. */
-static __u16 const msstab[] = {
+int sysctl_tcp6_syncookies_mss[TCP_SYNCOOKIES_MSS_COUNT_MAX] = {
 	64,
 	512,
 	536,
@@ -34,7 +34,9 @@ static __u16 const msstab[] = {
 	1500 - 60,
 	4460 - 60,
 	9000 - 60,
+	/* update sysctl_tcp6_syncookies_mss_count accordingly */
 };
+int sysctl_tcp6_syncookies_mss_count = 8;
 
 /*
  * This value is the age (in seconds) of syncookies which will always be
@@ -122,11 +124,11 @@ __u32 cookie_v6_init_sequence(struct sock *sk, const struct sk_buff *skb, __u16
 
 	tcp_synq_overflow(sk);
 
-	for (mssind = ARRAY_SIZE(msstab) - 1; mssind ; mssind--)
-		if (mss >= msstab[mssind])
+	for (mssind = sysctl_tcp6_syncookies_mss_count; mssind ; mssind--)
+		if (mss >= sysctl_tcp6_syncookies_mss[mssind])
 			break;
 
-	*mssp = msstab[mssind];
+	*mssp = sysctl_tcp6_syncookies_mss[mssind];
 
 	NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_SYNCOOKIESSENT);
 
@@ -144,7 +146,8 @@ static inline int cookie_check(const struct sk_buff *skb, __u32 cookie)
 					    th->source, th->dest, seq,
 					    jiffies / (HZ * 60 * COOKIE_LIFETIME));
 
-	return mssind < ARRAY_SIZE(msstab) ? msstab[mssind] : 0;
+	return mssind < sysctl_tcp6_syncookies_mss_count ?
+		sysctl_tcp6_syncookies_mss[mssind] : 0;
 }
 
 struct sock *cookie_v6_check(struct sock *sk, struct sk_buff *skb)
diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
index 107b2f1..4492535 100644
--- a/net/ipv6/sysctl_net_ipv6.c
+++ b/net/ipv6/sysctl_net_ipv6.c
@@ -15,6 +15,17 @@
 #include <net/ipv6.h>
 #include <net/addrconf.h>
 #include <net/inet_frag.h>
+#include <net/tcp.h>
+
+#ifdef CONFIG_SYN_COOKIES
+static int tcp6_syncookies_mss_sysctl(struct ctl_table *ctl, int write,
+				 void __user *buffer, size_t *lenp,
+				 loff_t *ppos)
+{
+	return tcp_syncookies_mss_sysctl(ctl, write, buffer, lenp, ppos,
+					   &sysctl_tcp6_syncookies_mss_count);
+}
+#endif
 
 static struct ctl_table ipv6_table_template[] = {
 	{
@@ -35,6 +46,15 @@ static struct ctl_table ipv6_rotable[] = {
 		.mode		= 0644,
 		.proc_handler	= proc_dointvec
 	},
+#ifdef CONFIG_SYN_COOKIES
+	{
+		.procname	= "tcp_syncookies_mss_table",
+		.data		= &sysctl_tcp6_syncookies_mss,
+		.maxlen		= sizeof(sysctl_tcp6_syncookies_mss),
+		.mode		= 0644,
+		.proc_handler	= tcp6_syncookies_mss_sysctl,
+	},
+#endif
 	{ }
 };
 

-- 
Jiri Bohac <jbohac@suse.cz>
SUSE Labs, SUSE CZ

^ permalink raw reply related

* [PATCH 3/3] [RFC] TCP syncookies: only allow 3 MSS values by default to mitigate spoofing attacks
From: Jiri Bohac @ 2013-08-16  0:05 UTC (permalink / raw)
  To: Jiri Bohac; +Cc: Jakob Lell, netdev, davem
In-Reply-To: <20130815235743.GA25665@midget.suse.cz>

Jakob Lell discovered that the sequence number that needs to be guessed to
successfully spoof a TCP connection with syncookies only has 27 bits of
entropy. Of the 32 bits, 3 are wasted by the 8 differrent RSS values. [1]

This patch decreases the number of possible MSS values from 8 to 3,
making the spoofing attack 8/3 times more difficult.

Rationale for the new values
- most packets are (1500 - headers); (1450 - headers) is not a huge waste and
  prevents fallback to much lower values
- clients will rarely send MSS below 536, so that's a safe fallback
- we need to keep the minimum (64)

[1]: http://www.jakoblell.com/blog/2013/08/13/quick-blind-tcp-connection-spoofing-with-syn-cookies/

Signed-off-by: Jiri Bohac <jbohac@suse.cz>
---
 net/ipv4/syncookies.c | 9 ++-------
 net/ipv6/syncookies.c | 9 ++-------
 2 files changed, 4 insertions(+), 14 deletions(-)

diff --git a/net/ipv4/syncookies.c b/net/ipv4/syncookies.c
index af0692f..0504bbe 100644
--- a/net/ipv4/syncookies.c
+++ b/net/ipv4/syncookies.c
@@ -148,15 +148,10 @@ static __u32 check_tcp_syn_cookie(__u32 cookie, __be32 saddr, __be32 daddr,
 int sysctl_tcp4_syncookies_mss[TCP_SYNCOOKIES_MSS_COUNT_MAX] = {
 	64,
 	512,
-	536,
-	1024,
-	1440,
-	1460,
-	4312,
-	8960,
+	1450 - 40,
 	/* update sysctl_tcp4_syncookies_mss_count accordingly */
 };
-int sysctl_tcp4_syncookies_mss_count = 8;
+int sysctl_tcp4_syncookies_mss_count = 3;
 
 /*
  * This value is the age (in seconds) of syncookies which will always be
diff --git a/net/ipv6/syncookies.c b/net/ipv6/syncookies.c
index 4268448..ccdb880 100644
--- a/net/ipv6/syncookies.c
+++ b/net/ipv6/syncookies.c
@@ -28,15 +28,10 @@
 int sysctl_tcp6_syncookies_mss[TCP_SYNCOOKIES_MSS_COUNT_MAX] = {
 	64,
 	512,
-	536,
-	1280 - 60,
-	1480 - 60,
-	1500 - 60,
-	4460 - 60,
-	9000 - 60,
+	1450 - 60,
 	/* update sysctl_tcp6_syncookies_mss_count accordingly */
 };
-int sysctl_tcp6_syncookies_mss_count = 8;
+int sysctl_tcp6_syncookies_mss_count = 3;
 
 /*
  * This value is the age (in seconds) of syncookies which will always be

-- 
Jiri Bohac <jbohac@suse.cz>
SUSE Labs, SUSE CZ

^ permalink raw reply related

* Re: Hello..
From: Mr Bill J. Moore @ 2013-08-16  0:04 UTC (permalink / raw)
  To: Recipients

Greetings!

I have been waiting for you to contact me for your Confirm-able Bank Draft of $800, 000,00 United States Dollars, but I did not hear from you.

Then I went and deposited the Draft with FedEx COURIER SERVICE, West Africa, I traveled out of the country for a 3 Months Course and I will not come back till end of December.

The only money you will send to the FedEx COURIER SERVICE to deliver your Draft direct to your postal Address in your country is($175.00 USD) only bring Security Keeping Fee of the Courier C mpany so far.

Contact Person: Mr. James Moore
Dispatch Director. Mr. James Moore
Email Address: dispatch_james01@qq.com
Telephone: :+(234) 705 528 7142

DO CONFIRM YOUR INFORMATION BELOW

FullName
Home Address
Occupation
Country

Let me repeat again, try and contact then us soon as you receive this mail to avoid any further delay and remember to pay them their Security Keeping fee  of $175.00 US Dollars for their immediate action.I know this e-mail may come to
you as a surprise.

Yours Faithfully,

Mr Bill J. Moore

^ permalink raw reply

* Re: [PATCH 1/3] [RFC] TCP syncookies: slow down timer to mitigate spoofing attacks
From: Neal Cardwell @ 2013-08-16  0:34 UTC (permalink / raw)
  To: Jiri Bohac; +Cc: Jakob Lell, Netdev, David Miller
In-Reply-To: <20130816000043.GA11950@midget.suse.cz>

On Thu, Aug 15, 2013 at 8:00 PM, Jiri Bohac <jbohac@suse.cz> wrote:
> (compile-tested only)
>
> Jakob Lell discovered that the sequence number that needs to be guessed to
> successfully spoof a TCP connection with syncookies only has 27 bits of
> entropy. Of the 32 bits, 2 bits are wasted by the four differrent timestamps
> accepted and 3 are wasted by the 8 differrent RSS values. [1]
>
> This patch slows down the timer used in syncookies from 1/60 Hz to 1/60/4 Hz
> so that at any moment only two differrent timer values can be accepted.
> As a result, 1 bit of sequence number entropy is gained.
>
> This changes the maximum cookie age limit from 4 - 5 minutes to 4 - 8 minutes.
>
> [1]: http://www.jakoblell.com/blog/2013/08/13/quick-blind-tcp-connection-spoofing-with-syn-cookies/
>
> Signed-off-by: Jiri Bohac <jbohac@suse.cz>
...

>  /*
> - * This (misnamed) value is the age of syncookie which is permitted.
> + * This value is the age (in seconds) of syncookies which will always be

I believe (hope?) you mean minutes here, rather than seconds. :-) Same
typo occurs in 2 spots each for IPv4 and IPv6.

neal

^ permalink raw reply

* Re: [PATCH 1/3 v4] ipv6: do not disable temp_address when reaching max_address
From: Ding Tianhong @ 2013-08-16  0:48 UTC (permalink / raw)
  To: David S. Miller, Alexey Kuznetsov, James Morris,
	Hideaki YOSHIFUJI, Patrick McHardy, Jon Maloy, Eric Dumazet,
	Netdev, kargig, ppandit
In-Reply-To: <20130815190754.GB30746@order.stressinduktion.org>

On 2013/8/16 3:07, Hannes Frederic Sowa wrote:
> On Thu, Aug 15, 2013 at 07:36:03PM +0200, Hannes Frederic Sowa wrote:
>> Now we have to check why these addresses don't go out of tentative state.
> 
> Just looked at it. flood_router26 just emits pretty high values for
> RetransTime:
> 
> 21:05:52.050159 IP6 (hlim 255, next-header ICMPv6 (58) payload length: 192) fe80::c:2a47:1360:1101 > ff02::1: [icmp6 sum ok] ICMP6, router advertisement, length 192
>         hop limit 255, Flags [none], pref high, router lifetime 65535s, reachable time 16384000ms, retrans time 1966080ms
>           mtu option (5), length 8 (1):  1500
>             0x0000:  0000 0000 05dc
> 
> We are completly in spec here. Just DAD needs a lot of time to finish.
> 
> Greetings,
> 
>   Hannes
> 
> 
Great job, more and more close to the truth, let's find a better way to finish it. 

> .
> 

^ permalink raw reply

* Re: [PATCH] vhost: Drop linux/socket.h
From: Asias He @ 2013-08-16  1:27 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, virtualization, kvm, mst
In-Reply-To: <20130815.140740.1781732332793977170.davem@davemloft.net>

On Thu, Aug 15, 2013 at 02:07:40PM -0700, David Miller wrote:
> From: Asias He <asias@redhat.com>
> Date: Thu, 15 Aug 2013 11:20:16 +0800
> 
> > memcpy_fromiovec is moved to lib/iovec.c. No need to include
> > linux/socket.h for it.
> > 
> > Signed-off-by: Asias He <asias@redhat.com>
> 
> You can't do this.
> 
> Because this file doesn't include the header file that
> provides the declaration, which is linux/uio.h

vhost.c includes drivers/vhost/vhost.h. In drivers/vhost/vhost.h, we
have linux/uio.h included.

> linux/socket.h includes linux/uio.h, so honestly leaving
> things the way they are is a 1000 times better than your
> patch.

Vhost is a separate module and a generic infrastructure which is not
bound to network anymore. I guess it's better to include the real one
instead of the socket one.

-- 
Asias

^ permalink raw reply

* Re: [PATCH net-next] bonding: lacp_port_id setting for 802.3ad
From: Krisztian Ivancso @ 2013-08-16  2:07 UTC (permalink / raw)
  To: Ding Tianhong, Jay Vosburgh; +Cc: netdev
In-Reply-To: <520AE16B.3040705@huawei.com>

On 08/14/2013 03:46 AM, Ding Tianhong wrote:
> On 2013/8/14 7:34, Krisztian Ivancso wrote:
>> On 08/13/2013 08:25 PM, Jay Vosburgh wrote:
>>> Krisztian Ivancso <github-ivan@ivancso.net> wrote:
>>>
>>>> On 08/13/2013 11:39 AM, Ding Tianhong wrote:
>>>>> On 2013/8/13 17:20, Krisztian Ivancso wrote:
>>>>>> On 08/13/2013 03:07 AM, Ding Tianhong wrote:
>>>>>>> On 2013/8/12 19:19, Krisztian Ivancso wrote:
>>>>>>>> >From 472fffa5a8f170daed9e4cc677af8e2560b86be2 Mon Sep 17 00:00:00 2001
>>>>>>>> From: Krisztian Ivancso <github-ivan@ivancso.net>
>>>>>>>> Date: Sun, 11 Aug 2013 20:30:44 +0200
>>>>>>>> Subject: [PATCH net-next] bonding: lacp_port_id setting for 802.3ad ports
>>>>>
>>>>> ok, for example: the bonding has four slave, slave1 and slave2 aggregation to 1 group,
>>>>> and slave3 and slave4 aggregtion to 2 group, how you distinguish the 1 and 2 group by initialize id.
>>>>
>>>> this is not possible, because all slave have to be a member of the same
>>>> aggregation group.
>>>
>>> 	Just on the above point, bonding can group slaves into multiple
>>> aggregators, but only one aggregator will be active at any given time.
>>>
>>> 	To answer the question, the four slaves would each be given
>>> unique port IDs that do not conflict.
>>>
>>>> i think we misunderstood each other.
>>>>
>>>> here is a new example:
>>>> - switch1 is a switch with a configured lag with two members ports
>>>>  (member1 and member2)
>>>> - two linux (linux1 and linux2) box with a configured bonding device
>>>>  (bond0) with the same MAC set in both box and one
>>>>  slave on each
>>>> - lacp_port_id is set to 10 in linux1 and 20 in linux2
>>>>
>>>> you can attach the slave from both linux boxes to the same
>>>> lag on switch1. (slave from linux1 to port member1 and
>>>> slave from linux2 to port member2 on switch1)
>>>>
>>>> port id must be unique within a system.
>>>> bonding implementation set a unique system id for every bonding device
>>>> which is derived from MAC of one of the slave interfaces.
>>>>
>>>> if we use the current bonding implementation second linux box can't be
>>>> a member on switch1 because port id is 1 in both linux bonding device.
>>>>
>>>> if we can set different starting port id for bonding in different boxes
>>>> the second box can be a member also.
>>>
>>> 	I understand what you're trying to do here (permit multiple
>>> instances of bonding on different systems to connect to a single
>>> aggregator on a switch), and I don't really have a problem with it in
>>> general.
>>>
>>> 	I do have some comments:
>>>
>>> 	First, altering the lacp_port_id (via sysfs) should only be
>>> permitted when there are no slaves in the bond, otherwise the
>>> /proc/net/bonding/bond0 output for the first port id will not match the
>>> actual first port id value assigned to the slaves.  As a practical
>>> matter, altering lacp_port_id while slaves are present in the bond has
>>> no effect until all slaves are released and the first new slave is
>>> added, so this is not reducing functionality.

fixed in bonding_store_lacp_port_id():
(        struct slave *first_slave = bond_first_slave(bond);
        if (first_slave) {
                pr_err("%s: Can't set port id because device have slave(s).\n",
                       bond->dev->name);
                return -EPERM;
        }
)

>>>
>>> 	Second, the lacp_port_id is global across all bonds created
>>> within the loaded module, and so multiple bonds will all use the same
>>> starting value.  Setting the lacp_port_id via sysfs has no effect, as it
>>> alters a per-bond value, bond->params.lacp_port_id, that is never
>>> actually used to set the port ID of a first slave in bond_enslave.
>>>
>>> 	The global default value should only be used to initialize the
>>> per-bond value when a bond is created, and that per-bond value should be
>>> used when setting the port id in bond_enslave().  The per-bond value is
>>> already displayed in /proc/net/bonding/bond0, and is the value modified
>>> by the sysfs functions

global default value is used to initialize bonding_defaults.lacp_port_id now.
(params->lacp_port_id = lacp_port_id;)

first slave is initialized by per-bond port id in bond_enslave().
(SLAVE_AD_INFO(new_slave).id = bond->params.lacp_port_id;)

>>>
>>> 	Third, consider adding the port ID to the 803.2ad section in
>>> bond_info_show_slave.

slave port id is shown in bond_info_show_slave():
(seq_printf(seq, "Slave port id: %d\n", SLAVE_AD_INFO(slave).id);)

>>
>> Thanks for these great comments. I'll soon fix sysfs related bug and
>> rework patch.
>>
>>>
>>> 	Lastly, I think this should be tested against systems other than
>>> Cisco to insure that it really interoperates with, for example,
>>> Juniper's methodology for spanning an aggregator across physical
>>> chassis.  I'm not sure why it wouldn't, but once new functionality
>>> becomes part of the kernel, changing it in non-backwards compatible ways
>>> is difficult.
>>
> 
> agreed
> 
> Ding Tianhong
port id overflow check in bond_enslave():
(                        prev_slave = bond_prev_slave(bond, new_slave);
                        if (SLAVE_AD_INFO(prev_slave).id == 65535) {
                                pr_err("%s: Error: Couldn't add new slave (%s) because maximum port id (65535) is reached.\n",
                                       bond_dev->name, slave_dev->name);
                                res = -EPERM;
                                goto err_detach;
                        }
)
i'm not sure "goto err_detach" is the proper jump but it seems to be good.

i hope next week i can test this solution with devices other than cisco.
(older juniper and low-end hp 3com)

btw i welcome any test with any network devices related to this feature.




>From 974763f179cf741a8b9b0459be2e9c84d23e8989 Mon Sep 17 00:00:00 2001
From: Krisztian Ivancso <github-ivan@ivancso.net>
Date: Fri, 16 Aug 2013 02:25:45 +0200
Subject: [PATCH net-next] bonding: lacp_port_id setting for 802.3ad

---
 drivers/net/bonding/bond_main.c   | 24 +++++++++++++++++++++--
 drivers/net/bonding/bond_procfs.c |  2 ++
 drivers/net/bonding/bond_sysfs.c  | 40 +++++++++++++++++++++++++++++++++++++++
 drivers/net/bonding/bonding.h     |  1 +
 4 files changed, 65 insertions(+), 2 deletions(-)

diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 4264a76..3580866 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -110,6 +110,7 @@ static char *fail_over_mac;
 static int all_slaves_active;
 static struct bond_params bonding_defaults;
 static int resend_igmp = BOND_DEFAULT_RESEND_IGMP;
+static int lacp_port_id = 1;

 module_param(max_bonds, int, 0);
 MODULE_PARM_DESC(max_bonds, "Max number of bonded devices");
@@ -150,7 +151,7 @@ module_param(lacp_rate, charp, 0);
 MODULE_PARM_DESC(lacp_rate, "LACPDU tx rate to request from 802.3ad partner; "
 			    "0 for slow, 1 for fast");
 module_param(ad_select, charp, 0);
-MODULE_PARM_DESC(ad_select, "803.ad aggregation selection logic; "
+MODULE_PARM_DESC(ad_select, "802.3ad aggregation selection logic; "
 			    "0 for stable (default), 1 for bandwidth, "
 			    "2 for count");
 module_param(min_links, int, 0);
@@ -181,6 +182,8 @@ MODULE_PARM_DESC(all_slaves_active, "Keep all frames received on an interface"
 module_param(resend_igmp, int, 0);
 MODULE_PARM_DESC(resend_igmp, "Number of IGMP membership reports to send on "
 			      "link failure");
+module_param(lacp_port_id, int, 0);
+MODULE_PARM_DESC(lacp_port_id, "802.3ad port id to send to switch in LACPDU");

 /*----------------------------- Global variables ----------------------------*/

@@ -1699,7 +1702,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
 		bond_set_slave_inactive_flags(new_slave);
 		/* if this is the first slave */
 		if (bond_first_slave(bond) == new_slave) {
-			SLAVE_AD_INFO(new_slave).id = 1;
+			SLAVE_AD_INFO(new_slave).id = bond->params.lacp_port_id;
 			/* Initialize AD with the number of times that the AD timer is called in 1 second
 			 * can be called only after the mac address of the bond is set
 			 */
@@ -1708,6 +1711,12 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
 			struct slave *prev_slave;

 			prev_slave = bond_prev_slave(bond, new_slave);
+			if (SLAVE_AD_INFO(prev_slave).id == 65535) {
+				pr_err("%s: Error: Couldn't add new slave (%s) because maximum port id (65535) is reached.\n",
+				       bond_dev->name, slave_dev->name);
+				res = -EPERM;
+				goto err_detach;
+			}
 			SLAVE_AD_INFO(new_slave).id =
 				SLAVE_AD_INFO(prev_slave).id + 1;
 		}
@@ -4377,6 +4386,16 @@ static int bond_check_params(struct bond_params *params)
 		resend_igmp = BOND_DEFAULT_RESEND_IGMP;
 	}

+	if (bond_mode == BOND_MODE_8023AD) {
+		/* we set upper limit to 65000 because new slaves will increase port
+                   id so we don't want id to overflow */
+		if (lacp_port_id < 1 || lacp_port_id > 65000) {
+			pr_warning("Warning: lacp_port_id (%d) should be between "
+				   "1 and 65000, resetting to 1\n", lacp_port_id);
+			lacp_port_id = 1;
+		}
+	}
+
 	/* reset values for TLB/ALB */
 	if ((bond_mode == BOND_MODE_TLB) ||
 	    (bond_mode == BOND_MODE_ALB)) {
@@ -4565,6 +4584,7 @@ static int bond_check_params(struct bond_params *params)
 	params->all_slaves_active = all_slaves_active;
 	params->resend_igmp = resend_igmp;
 	params->min_links = min_links;
+	params->lacp_port_id = lacp_port_id;

 	if (primary) {
 		strncpy(params->primary, primary, IFNAMSIZ);
diff --git a/drivers/net/bonding/bond_procfs.c b/drivers/net/bonding/bond_procfs.c
index 20a6ee2..96977d5 100644
--- a/drivers/net/bonding/bond_procfs.c
+++ b/drivers/net/bonding/bond_procfs.c
@@ -129,6 +129,7 @@ static void bond_info_show_master(struct seq_file *seq)
 		seq_printf(seq, "Min links: %d\n", bond->params.min_links);
 		seq_printf(seq, "Aggregator selection policy (ad_select): %s\n",
 			   ad_select_tbl[bond->params.ad_select].modename);
+		seq_printf(seq, "802.3ad starting port id: %d\n", bond->params.lacp_port_id);

 		if (__bond_3ad_get_active_agg_info(bond, &ad_info)) {
 			seq_printf(seq, "bond %s has no active aggregator\n",
@@ -193,6 +194,7 @@ static void bond_info_show_slave(struct seq_file *seq,
 				   agg->aggregator_identifier);
 		else
 			seq_puts(seq, "Aggregator ID: N/A\n");
+		seq_printf(seq, "Slave port id: %d\n", SLAVE_AD_INFO(slave).id);
 	}
 	seq_printf(seq, "Slave queue ID: %d\n", slave->queue_id);
 }
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index 0f539de..35b4bdd 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -920,6 +920,45 @@ static ssize_t bonding_store_min_links(struct device *d,
 static DEVICE_ATTR(min_links, S_IRUGO | S_IWUSR,
 		   bonding_show_min_links, bonding_store_min_links);

+static ssize_t bonding_show_lacp_port_id(struct device *d,
+				      struct device_attribute *attr,
+				      char *buf)
+{
+	struct bonding *bond = to_bond(d);
+
+	return sprintf(buf, "%d\n", bond->params.lacp_port_id);
+}
+
+static ssize_t bonding_store_lacp_port_id(struct device *d,
+				       struct device_attribute *attr,
+				       const char *buf, size_t count)
+{
+	struct bonding *bond = to_bond(d);
+	int ret;
+	unsigned int new_value;
+
+	struct slave *first_slave = bond_first_slave(bond);
+	if (first_slave) {
+		pr_err("%s: Can't set port id because device have slave(s).\n",
+		       bond->dev->name);
+		return -EPERM;
+	}
+
+	ret = kstrtouint(buf, 0, &new_value);
+	if ((ret < 0) || (new_value < 1) || (new_value > 65000)) {
+		pr_err("%s: Ignoring invalid 802.3ad port id value %s.\n",
+		       bond->dev->name, buf);
+		return -EINVAL;
+	}
+
+	pr_info("%s: Setting 802.3ad port id value to %u\n",
+		bond->dev->name, new_value);
+	bond->params.lacp_port_id = new_value;
+	return count;
+}
+static DEVICE_ATTR(lacp_port_id, S_IRUGO | S_IWUSR,
+		   bonding_show_lacp_port_id, bonding_store_lacp_port_id);
+
 static ssize_t bonding_show_ad_select(struct device *d,
 				      struct device_attribute *attr,
 				      char *buf)
@@ -1705,6 +1744,7 @@ static struct attribute *per_bond_attrs[] = {
 	&dev_attr_all_slaves_active.attr,
 	&dev_attr_resend_igmp.attr,
 	&dev_attr_min_links.attr,
+	&dev_attr_lacp_port_id.attr,
 	NULL,
 };

diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index 4bf52d5..8a078d6 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -176,6 +176,7 @@ struct bond_params {
 	int tx_queues;
 	int all_slaves_active;
 	int resend_igmp;
+	int lacp_port_id;
 };

 struct bond_parm_tbl {
-- 
1.8.3.1

^ permalink raw reply related

* Re: [PATCH v3 0/7] net: use platform_{get,set}_drvdata()
From: Libo Chen @ 2013-08-16  2:15 UTC (permalink / raw)
  To: David Miller
  Cc: netdev, lizefan, leoli, linuxppc-dev, pantelis.antoniou, vbordug,
	gregkh, jg1.han, sergei.shtylyov
In-Reply-To: <20130815.153903.859166500375208182.davem@davemloft.net>

On 2013/8/16 6:39, David Miller wrote:
> From: David Miller <davem@davemloft.net>
> Date: Thu, 15 Aug 2013 15:23:59 -0700 (PDT)
> 
>> From: Libo Chen <clbchenlibo.chen@huawei.com>
>> Date: Thu, 15 Aug 2013 21:01:17 +0800
>>
>>> Use the wrapper functions for getting and setting the driver data using
>>> platform_device instead of using dev_{get,set}_drvdata() with &pdev->dev,
>>> so we can directly pass a struct platform_device.
>>>
>>> changelog v3:
>>> 	remove modify about dev_set_drvdata()
>>> changelog v2:
>>> 	this version add modify record about dev_set_drvdata().
>>
>> Series applied.
> 
> Actually, I had to revert, these patches break the build.
> 
> drivers/net/ethernet/sun/sunhme.c: In function ‘happy_meal_pci_probe’:
> drivers/net/ethernet/sun/sunhme.c:3114:2: error: implicit declaration of function ‘platform_set_drvdata’ [-Werror=implicit-function-declaration]
> drivers/net/ethernet/sun/sunhme.c: In function ‘happy_meal_pci_remove’:
> drivers/net/ethernet/sun/sunhme.c:3162:9: error: implicit declaration of function ‘platform_get_drvdata’ [-Werror=implicit-function-declaration]
> drivers/net/ethernet/sun/sunhme.c:3162:26: warning: initialization makes pointer from integer without a cast [enabled by default]
> 


oh, it is my fault, I will update!

^ permalink raw reply

* [PATCH v3 RESEND 5/7] net: sunhme: use platform_{get,set}_drvdata()
From: Libo Chen @ 2013-08-16  2:33 UTC (permalink / raw)
  To: David Miller
  Cc: jg1.han, Bill Pemberton, netdev, LKML, Sergei Shtylyov, Li Zefan

Use the wrapper functions for getting and setting the driver data using
platform_device instead of using dev_{get,set}_drvdata() with &of_dev->dev,
so we can directly pass a struct platform_device.

changelog:
	remove modify about happy_meal_pci_probe && happy_meal_pci_remove

Signed-off-by: Libo Chen <libo.chen@huawei.com>
---
 drivers/net/ethernet/sun/sunhme.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/net/ethernet/sun/sunhme.c b/drivers/net/ethernet/sun/sunhme.c
index 171f5b0..b90d311 100644
--- a/drivers/net/ethernet/sun/sunhme.c
+++ b/drivers/net/ethernet/sun/sunhme.c
@@ -3231,7 +3231,7 @@ static int hme_sbus_probe(struct platform_device *op)

 static int hme_sbus_remove(struct platform_device *op)
 {
-	struct happy_meal *hp = dev_get_drvdata(&op->dev);
+	struct happy_meal *hp = platform_get_drvdata(op);
 	struct net_device *net_dev = hp->dev;

 	unregister_netdev(net_dev);
-- 
1.7.1

^ permalink raw reply related


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