Netdev List
 help / color / mirror / Atom feed
* Re: [patch -next] amd-xgbe: fix ->rss_hash_type
From: David Miller @ 2014-11-12 20:04 UTC (permalink / raw)
  To: dan.carpenter; +Cc: thomas.lendacky, netdev, kernel-janitors
In-Reply-To: <20141112083135.GA12795@mwanda>

From: Dan Carpenter <dan.carpenter@oracle.com>
Date: Wed, 12 Nov 2014 11:31:35 +0300

> There was a missing break statement so we set everything to
> PKT_HASH_TYPE_L3 even when we intended to use PKT_HASH_TYPE_L4.
> 
> Fixes: 5b9dfe299e55 ('amd-xgbe: Provide support for receive side scaling')
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> This driver has a lot of Sparse endian warnings.
> http://lwn.net/Articles/205624/
> 
> diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-dev.c b/drivers/net/ethernet/amd/xgbe/xgbe-dev.c
> index 7daa2cd..55ba1dc 100644
> --- a/drivers/net/ethernet/amd/xgbe/xgbe-dev.c
> +++ b/drivers/net/ethernet/amd/xgbe/xgbe-dev.c
> @@ -1601,6 +1601,7 @@ static int xgbe_dev_read(struct xgbe_channel *channel)
>  		case RX_DESC3_L34T_IPV6_UDP:
>  			packet->rss_hash_type = PKT_HASH_TYPE_L4;
>  
> +			break;

Please don't add this spurious empty line before the break;, thanks.

^ permalink raw reply

* Re: [PATCH net-next] hyperv: Add processing of MTU reduced by the host
From: David Miller @ 2014-11-12 20:04 UTC (permalink / raw)
  To: haiyangz; +Cc: olaf, netdev, jasowang, driverdev-devel, linux-kernel
In-Reply-To: <ecc2fd8e646147fabb30d3120c889431@DFM-DB3MBX15-06.exchange.corp.microsoft.com>

From: Haiyang Zhang <haiyangz@microsoft.com>
Date: Wed, 12 Nov 2014 20:02:11 +0000

> The Hyper-V host doesn't support MTU below 1500. If we try setting MTU to a 
> value < 1500, the host will use 1500 automatically and return 1500 in the 
> RNDIS_OID_GEN_MAXIMUM_FRAME_SIZE query and guest will also use it. That's 
> why I set the lower limit to ETH_DATA_LEN.
> 
> Are you suggesting that we keep the 68 as the lower limit, and let the host 
> auto-reset it to 1500 when we trying to set an MTU < 1500?

Then you need to add a comment, because without any information or
context that change looks wrong.

^ permalink raw reply

* Re: [PATCH] ip_tunnel: Ops registration for secondary encap (fou, gue)
From: David Miller @ 2014-11-12 20:03 UTC (permalink / raw)
  To: therbert; +Cc: netdev, rdunlap
In-Reply-To: <1415822049-24978-1-git-send-email-therbert@google.com>

From: Tom Herbert <therbert@google.com>
Date: Wed, 12 Nov 2014 11:54:09 -0800

> Instead of calling fou and gue functions directly from ip_tunnel
> use ops for these that were previously registered. This patch adds the
> logic to add and remove encapsulation operations for ip_tunnel,
> and modified fou (and gue) to register with ip_tunnels.
> 
> This patch also addresses a circular dependency between ip_tunnel
> and fou that was causing link errors when CONFIG_NET_IP_TUNNEL=y
> and CONFIG_NET_FOU=m. References to fou an gue have been removed from
> ip_tunnel.c
> 
> Reported-by: Randy Dunlap <rdunlap@infradead.org>
> Signed-off-by: Tom Herbert <therbert@google.com>

Applied, please in the future be explicit about the target tree by
saying "[PATCH net-next]" or similar in your Subj.

I'm pretty sure this isn't the first time I've had to ask this of
you. :-/

Thanks Tom.

^ permalink raw reply

* RE: [PATCH net-next] hyperv: Add processing of MTU reduced by the host
From: Haiyang Zhang @ 2014-11-12 20:02 UTC (permalink / raw)
  To: David Miller
  Cc: netdev@vger.kernel.org, KY Srinivasan, olaf@aepfle.de,
	jasowang@redhat.com, linux-kernel@vger.kernel.org,
	driverdev-devel@linuxdriverproject.org
In-Reply-To: <20141112.144640.703336197189868183.davem@davemloft.net>



> -----Original Message-----
> From: David Miller [mailto:davem@davemloft.net]
> Sent: Wednesday, November 12, 2014 2:47 PM
> To: Haiyang Zhang
> Cc: netdev@vger.kernel.org; KY Srinivasan; olaf@aepfle.de;
> jasowang@redhat.com; linux-kernel@vger.kernel.org; driverdev-
> devel@linuxdriverproject.org
> Subject: Re: [PATCH net-next] hyperv: Add processing of MTU reduced by
> the host
> 
> From: Haiyang Zhang <haiyangz@microsoft.com>
> Date: Tue, 11 Nov 2014 15:27:52 -0800
> 
> > -	if (mtu < 68 || mtu > limit)
> > +	if (mtu < ETH_DATA_LEN || mtu > limit)
> >  		return -EINVAL;
> 
> This is not correct.
> 
> The test is against the minimally supported MTU, which should
> be 68 not ETH_DATA_LEN which is 1500.

The Hyper-V host doesn't support MTU below 1500. If we try setting MTU to a 
value < 1500, the host will use 1500 automatically and return 1500 in the 
RNDIS_OID_GEN_MAXIMUM_FRAME_SIZE query and guest will also use it. That's 
why I set the lower limit to ETH_DATA_LEN.

Are you suggesting that we keep the 68 as the lower limit, and let the host 
auto-reset it to 1500 when we trying to set an MTU < 1500?

Thanks,
- Haiyang

^ permalink raw reply

* Re: [PATCH net] cxgb4 : dcb open-lldp interop fixes
From: David Miller @ 2014-11-12 20:00 UTC (permalink / raw)
  To: anish; +Cc: netdev, hariprasad, leedom
In-Reply-To: <1415777451-14144-1-git-send-email-anish@chelsio.com>

From: Anish Bhatt <anish@chelsio.com>
Date: Tue, 11 Nov 2014 23:30:51 -0800

> * In LLD_MANAGED mode, traffic classes were being returned in reverse order to
>   lldp agent.
> * Priotype of strict is no longer the default returned.
> * Change behaviour of getdcbx() based on discussions on lldp-devel
> 
> These were missed as there was no working fetch interface for open-lldp when
> running in LLD_MANAGED mode till now.
> 
> Fixes: 76bcb31efc06 ("cxgb4 : Add DCBx support codebase and dcbnl_ops")
> 
> Signed-off-by: Anish Bhatt <anish@chelsio.com>

Applied, thanks.

^ permalink raw reply

* [PATCH] ip_tunnel: Ops registration for secondary encap (fou, gue)
From: Tom Herbert @ 2014-11-12 19:54 UTC (permalink / raw)
  To: davem, netdev; +Cc: rdunlap

Instead of calling fou and gue functions directly from ip_tunnel
use ops for these that were previously registered. This patch adds the
logic to add and remove encapsulation operations for ip_tunnel,
and modified fou (and gue) to register with ip_tunnels.

This patch also addresses a circular dependency between ip_tunnel
and fou that was causing link errors when CONFIG_NET_IP_TUNNEL=y
and CONFIG_NET_FOU=m. References to fou an gue have been removed from
ip_tunnel.c

Reported-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Tom Herbert <therbert@google.com>
---
 include/net/fou.h        | 25 ++------------
 include/net/ip_tunnels.h | 16 +++++++++
 net/ipv4/fou.c           | 85 ++++++++++++++++++++++++++++++++++++++++++++++++
 net/ipv4/ip_tunnel.c     | 78 ++++++++++++++++++++++++++++++--------------
 4 files changed, 157 insertions(+), 47 deletions(-)

diff --git a/include/net/fou.h b/include/net/fou.h
index 25b26ff..19b8a0c 100644
--- a/include/net/fou.h
+++ b/include/net/fou.h
@@ -8,31 +8,12 @@
 #include <net/ip_tunnels.h>
 #include <net/udp.h>
 
+size_t fou_encap_hlen(struct ip_tunnel_encap *e);
+static size_t gue_encap_hlen(struct ip_tunnel_encap *e);
+
 int fou_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e,
 		     u8 *protocol, struct flowi4 *fl4);
 int gue_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e,
 		     u8 *protocol, struct flowi4 *fl4);
 
-static size_t fou_encap_hlen(struct ip_tunnel_encap *e)
-{
-	return sizeof(struct udphdr);
-}
-
-static size_t gue_encap_hlen(struct ip_tunnel_encap *e)
-{
-	size_t len;
-	bool need_priv = false;
-
-	len = sizeof(struct udphdr) + sizeof(struct guehdr);
-
-	if (e->flags & TUNNEL_ENCAP_FLAG_REMCSUM) {
-		len += GUE_PLEN_REMCSUM;
-		need_priv = true;
-	}
-
-	len += need_priv ? GUE_LEN_PRIV : 0;
-
-	return len;
-}
-
 #endif
diff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h
index 5bc6ede..25a59eb 100644
--- a/include/net/ip_tunnels.h
+++ b/include/net/ip_tunnels.h
@@ -117,6 +117,22 @@ struct ip_tunnel_net {
 	struct hlist_head tunnels[IP_TNL_HASH_SIZE];
 };
 
+struct ip_tunnel_encap_ops {
+	size_t (*encap_hlen)(struct ip_tunnel_encap *e);
+	int (*build_header)(struct sk_buff *skb, struct ip_tunnel_encap *e,
+			    u8 *protocol, struct flowi4 *fl4);
+};
+
+#define MAX_IPTUN_ENCAP_OPS 8
+
+extern const struct ip_tunnel_encap_ops __rcu *
+		iptun_encaps[MAX_IPTUN_ENCAP_OPS];
+
+int ip_tunnel_encap_add_ops(const struct ip_tunnel_encap_ops *op,
+			    unsigned int num);
+int ip_tunnel_encap_del_ops(const struct ip_tunnel_encap_ops *op,
+			    unsigned int num);
+
 #ifdef CONFIG_INET
 
 int ip_tunnel_init(struct net_device *dev);
diff --git a/net/ipv4/fou.c b/net/ipv4/fou.c
index 740ae09..fe09077 100644
--- a/net/ipv4/fou.c
+++ b/net/ipv4/fou.c
@@ -668,6 +668,30 @@ static const struct genl_ops fou_nl_ops[] = {
 	},
 };
 
+size_t fou_encap_hlen(struct ip_tunnel_encap *e)
+{
+	return sizeof(struct udphdr);
+}
+EXPORT_SYMBOL(fou_encap_hlen);
+
+size_t gue_encap_hlen(struct ip_tunnel_encap *e)
+{
+	size_t len;
+	bool need_priv = false;
+
+	len = sizeof(struct udphdr) + sizeof(struct guehdr);
+
+	if (e->flags & TUNNEL_ENCAP_FLAG_REMCSUM) {
+		len += GUE_PLEN_REMCSUM;
+		need_priv = true;
+	}
+
+	len += need_priv ? GUE_LEN_PRIV : 0;
+
+	return len;
+}
+EXPORT_SYMBOL(gue_encap_hlen);
+
 static void fou_build_udp(struct sk_buff *skb, struct ip_tunnel_encap *e,
 			  struct flowi4 *fl4, u8 *protocol, __be16 sport)
 {
@@ -787,6 +811,57 @@ int gue_build_header(struct sk_buff *skb, struct ip_tunnel_encap *e,
 }
 EXPORT_SYMBOL(gue_build_header);
 
+#ifdef CONFIG_NET_FOU_IP_TUNNELS
+
+static const struct ip_tunnel_encap_ops __read_mostly fou_iptun_ops = {
+	.encap_hlen = fou_encap_hlen,
+	.build_header = fou_build_header,
+};
+
+static const struct ip_tunnel_encap_ops __read_mostly gue_iptun_ops = {
+	.encap_hlen = gue_encap_hlen,
+	.build_header = gue_build_header,
+};
+
+static int ip_tunnel_encap_add_fou_ops(void)
+{
+	int ret;
+
+	ret = ip_tunnel_encap_add_ops(&fou_iptun_ops, TUNNEL_ENCAP_FOU);
+	if (ret < 0) {
+		pr_err("can't add fou ops\n");
+		return ret;
+	}
+
+	ret = ip_tunnel_encap_add_ops(&gue_iptun_ops, TUNNEL_ENCAP_GUE);
+	if (ret < 0) {
+		pr_err("can't add gue ops\n");
+		ip_tunnel_encap_del_ops(&fou_iptun_ops, TUNNEL_ENCAP_FOU);
+		return ret;
+	}
+
+	return 0;
+}
+
+static void ip_tunnel_encap_del_fou_ops(void)
+{
+	ip_tunnel_encap_del_ops(&fou_iptun_ops, TUNNEL_ENCAP_FOU);
+	ip_tunnel_encap_del_ops(&gue_iptun_ops, TUNNEL_ENCAP_GUE);
+}
+
+#else
+
+static int ip_tunnel_encap_add_fou_ops(void)
+{
+	return 0;
+}
+
+static int ip_tunnel_encap_del_fou_ops(void)
+{
+}
+
+#endif
+
 static int __init fou_init(void)
 {
 	int ret;
@@ -794,6 +869,14 @@ static int __init fou_init(void)
 	ret = genl_register_family_with_ops(&fou_nl_family,
 					    fou_nl_ops);
 
+	if (ret < 0)
+		goto exit;
+
+	ret = ip_tunnel_encap_add_fou_ops();
+	if (ret < 0)
+		genl_unregister_family(&fou_nl_family);
+
+exit:
 	return ret;
 }
 
@@ -801,6 +884,8 @@ static void __exit fou_fini(void)
 {
 	struct fou *fou, *next;
 
+	ip_tunnel_encap_del_fou_ops();
+
 	genl_unregister_family(&fou_nl_family);
 
 	/* Close all the FOU sockets */
diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c
index c3587e1..63e745a 100644
--- a/net/ipv4/ip_tunnel.c
+++ b/net/ipv4/ip_tunnel.c
@@ -57,10 +57,6 @@
 #include <net/rtnetlink.h>
 #include <net/udp.h>
 
-#if IS_ENABLED(CONFIG_NET_FOU)
-#include <net/fou.h>
-#endif
-
 #if IS_ENABLED(CONFIG_IPV6)
 #include <net/ipv6.h>
 #include <net/ip6_fib.h>
@@ -494,19 +490,50 @@ EXPORT_SYMBOL_GPL(ip_tunnel_rcv);
 
 static int ip_encap_hlen(struct ip_tunnel_encap *e)
 {
-	switch (e->type) {
-	case TUNNEL_ENCAP_NONE:
+	const struct ip_tunnel_encap_ops *ops;
+	int hlen = -EINVAL;
+
+	if (e->type == TUNNEL_ENCAP_NONE)
 		return 0;
-#if IS_ENABLED(CONFIG_NET_FOU)
-	case TUNNEL_ENCAP_FOU:
-		return fou_encap_hlen(e);
-	case TUNNEL_ENCAP_GUE:
-		return gue_encap_hlen(e);
-#endif
-	default:
+
+	if (e->type >= MAX_IPTUN_ENCAP_OPS)
 		return -EINVAL;
-	}
+
+	rcu_read_lock();
+	ops = rcu_dereference(iptun_encaps[e->type]);
+	if (likely(ops && ops->encap_hlen))
+		hlen = ops->encap_hlen(e);
+	rcu_read_unlock();
+
+	return hlen;
+}
+
+const struct ip_tunnel_encap_ops __rcu *
+		iptun_encaps[MAX_IPTUN_ENCAP_OPS] __read_mostly;
+
+int ip_tunnel_encap_add_ops(const struct ip_tunnel_encap_ops *ops,
+			    unsigned int num)
+{
+	return !cmpxchg((const struct ip_tunnel_encap_ops **)
+			&iptun_encaps[num],
+			NULL, ops) ? 0 : -1;
 }
+EXPORT_SYMBOL(ip_tunnel_encap_add_ops);
+
+int ip_tunnel_encap_del_ops(const struct ip_tunnel_encap_ops *ops,
+			    unsigned int num)
+{
+	int ret;
+
+	ret = (cmpxchg((const struct ip_tunnel_encap_ops **)
+		       &iptun_encaps[num],
+		       ops, NULL) == ops) ? 0 : -1;
+
+	synchronize_net();
+
+	return ret;
+}
+EXPORT_SYMBOL(ip_tunnel_encap_del_ops);
 
 int ip_tunnel_encap_setup(struct ip_tunnel *t,
 			  struct ip_tunnel_encap *ipencap)
@@ -534,18 +561,19 @@ EXPORT_SYMBOL_GPL(ip_tunnel_encap_setup);
 int ip_tunnel_encap(struct sk_buff *skb, struct ip_tunnel *t,
 		    u8 *protocol, struct flowi4 *fl4)
 {
-	switch (t->encap.type) {
-	case TUNNEL_ENCAP_NONE:
+	const struct ip_tunnel_encap_ops *ops;
+	int ret = -EINVAL;
+
+	if (t->encap.type == TUNNEL_ENCAP_NONE)
 		return 0;
-#if IS_ENABLED(CONFIG_NET_FOU)
-	case TUNNEL_ENCAP_FOU:
-		return fou_build_header(skb, &t->encap, protocol, fl4);
-	case TUNNEL_ENCAP_GUE:
-		return gue_build_header(skb, &t->encap, protocol, fl4);
-#endif
-	default:
-		return -EINVAL;
-	}
+
+	rcu_read_lock();
+	ops = rcu_dereference(iptun_encaps[t->encap.type]);
+	if (likely(ops && ops->build_header))
+		ret = ops->build_header(skb, &t->encap, protocol, fl4);
+	rcu_read_unlock();
+
+	return ret;
 }
 EXPORT_SYMBOL(ip_tunnel_encap);
 
-- 
2.1.0.rc2.206.gedb03e5

^ permalink raw reply related

* Re: [PATCH net-next] udp: Neaten function pointer calls and add braces
From: David Miller @ 2014-11-12 19:52 UTC (permalink / raw)
  To: joe; +Cc: netdev, peter
In-Reply-To: <1415771960.16070.21.camel@perches.com>

From: Joe Perches <joe@perches.com>
Date: Tue, 11 Nov 2014 21:59:20 -0800

> Standardize function pointer uses.
> 
> Convert calling style from:
> 	(*foo)(args...);
> to:
> 	foo(args...);
> 
> Other miscellanea:
> 
> o Add braces around loops with single ifs on multiple lines
> o Realign arguments around these functions
> o Invert logic in if to return immediately.
> 
> Signed-off-by: Joe Perches <joe@perches.com>

Applied, thanks Joe.

^ permalink raw reply

* Re: [PATCH net-next 2/2] r8152: adjust rtl_start_rx
From: David Miller @ 2014-11-12 19:49 UTC (permalink / raw)
  To: hayeswang; +Cc: netdev, nic_swsd, linux-kernel, linux-usb
In-Reply-To: <0835B3720019904CB8F7AA43166CEEB2ECE46C@RTITMBSV03.realtek.com.tw>

From: Hayes Wang <hayeswang@realtek.com>
Date: Wed, 12 Nov 2014 06:29:46 +0000

> David Miller [mailto:davem@davemloft.net] 
>> Sent: Wednesday, November 12, 2014 1:44 PM
> [...]
>> What do other USB network drivers do in similar situations?
> 
> According to the usbnet.c, it would make sure to submit the
> number of min(10, RX_QLEN(dev)) rx buffers. If there are
> not enough rx buffers, it schedule a tasklet for next try.
> 
> The brief flow is as following.
> 1. Call open().
>    - schedule a tasklet.
> 2. Tasklet is called.
>    if (dev->rxq.qlen < RX_QLEN(dev)) {
> 	   - submit rx buffers util the number of
> 	     min(10, RX_QLEN(dev)). If the error
> 	     occurs, break the loop.
> 	   - If the dev->rxq.qlen < RX_QLEN(dev),
> 	     schedule the tasklet.
>    }

That sounds like a better recovery model, why don't you mimick it?

^ permalink raw reply

* Re: [PATCH net-next v3 0/3] Code adjustment
From: David Miller @ 2014-11-12 19:49 UTC (permalink / raw)
  To: hayeswang; +Cc: netdev, nic_swsd, linux-kernel, linux-usb
In-Reply-To: <1394712342-15778-91-Taiwan-albertk@realtek.com>

From: Hayes Wang <hayeswang@realtek.com>
Date: Wed, 12 Nov 2014 10:05:02 +0800

> v3:
>  Remove the test_bit for patch #2.
> 
> v2:
>  Correct the spelling error for the comment of patch #3.
> 
> v1:
> Adjust some codes to make them more reasonable.

Series applied, thanks.

^ permalink raw reply

* Re: [PATCH net-next] hyperv: Add processing of MTU reduced by the host
From: David Miller @ 2014-11-12 19:46 UTC (permalink / raw)
  To: haiyangz; +Cc: netdev, kys, olaf, jasowang, linux-kernel, driverdev-devel
In-Reply-To: <1415748472-27463-1-git-send-email-haiyangz@microsoft.com>

From: Haiyang Zhang <haiyangz@microsoft.com>
Date: Tue, 11 Nov 2014 15:27:52 -0800

> -	if (mtu < 68 || mtu > limit)
> +	if (mtu < ETH_DATA_LEN || mtu > limit)
>  		return -EINVAL;

This is not correct.

The test is against the minimally supported MTU, which should
be 68 not ETH_DATA_LEN which is 1500.

^ permalink raw reply

* Re: [PATCH net] netlink: Properly unbind in error conditions.
From: Richard Guy Briggs @ 2014-11-12 19:44 UTC (permalink / raw)
  To: Hiroaki SHIMODA; +Cc: davem, netdev
In-Reply-To: <20141113042410.013c5d044aa442a05832d6d9@gmail.com>

On 14/11/13, Hiroaki SHIMODA wrote:
> Even if netlink_kernel_cfg::unbind is implemented the unbind() method is
> not called, because cfg->unbind is omitted in __netlink_kernel_create().
> And fix wrong argument of test_bit() and off by one problem.
> 
> At this point, no unbind() method is implemented, so there is no real
> issue.
> 
> Fixes: 4f520900522f ("netlink: have netlink per-protocol bind function return an error code.")
> Signed-off-by: Hiroaki SHIMODA <shimoda.hiroaki@gmail.com>
> Cc: Richard Guy Briggs <rgb@redhat.com>
> ---
>  net/netlink/af_netlink.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
> index f1de72de273e..0007b8180397 100644
> --- a/net/netlink/af_netlink.c
> +++ b/net/netlink/af_netlink.c
> @@ -1440,7 +1440,7 @@ static void netlink_unbind(int group, long unsigned int groups,
>  		return;
>  
>  	for (undo = 0; undo < group; undo++)
> -		if (test_bit(group, &groups))
> +		if (test_bit(undo, &groups))

Nice find!  (Cut-and-waste from line 1480...)

>  			nlk->netlink_unbind(undo);
>  }
>  
> @@ -1492,7 +1492,7 @@ static int netlink_bind(struct socket *sock, struct sockaddr *addr,
>  			netlink_insert(sk, net, nladdr->nl_pid) :
>  			netlink_autobind(sock);
>  		if (err) {
> -			netlink_unbind(nlk->ngroups - 1, groups, nlk);
> +			netlink_unbind(nlk->ngroups, groups, nlk);

Yup, agreed.

>  			return err;
>  		}
>  	}
> @@ -2509,6 +2509,7 @@ __netlink_kernel_create(struct net *net, int unit, struct module *module,
>  		nl_table[unit].module = module;
>  		if (cfg) {
>  			nl_table[unit].bind = cfg->bind;
> +			nl_table[unit].unbind = cfg->unbind;

Yup, thanks.

>  			nl_table[unit].flags = cfg->flags;
>  			if (cfg->compare)
>  				nl_table[unit].compare = cfg->compare;

Acked-by: Richard Guy Briggs <rgb@redhat.com>

> -- 
> 2.0.4
> 

- RGB

--
Richard Guy Briggs <rbriggs@redhat.com>
Senior Software Engineer, Kernel Security, AMER ENG Base Operating Systems, Red Hat
Remote, Ottawa, Canada
Voice: +1.647.777.2635, Internal: (81) 32635, Alt: +1.613.693.0684x3545

^ permalink raw reply

* [PATCH net] netlink: Properly unbind in error conditions.
From: Hiroaki SHIMODA @ 2014-11-12 19:24 UTC (permalink / raw)
  To: davem; +Cc: netdev, rgb

Even if netlink_kernel_cfg::unbind is implemented the unbind() method is
not called, because cfg->unbind is omitted in __netlink_kernel_create().
And fix wrong argument of test_bit() and off by one problem.

At this point, no unbind() method is implemented, so there is no real
issue.

Fixes: 4f520900522f ("netlink: have netlink per-protocol bind function return an error code.")
Signed-off-by: Hiroaki SHIMODA <shimoda.hiroaki@gmail.com>
Cc: Richard Guy Briggs <rgb@redhat.com>
---
 net/netlink/af_netlink.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index f1de72de273e..0007b8180397 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -1440,7 +1440,7 @@ static void netlink_unbind(int group, long unsigned int groups,
 		return;
 
 	for (undo = 0; undo < group; undo++)
-		if (test_bit(group, &groups))
+		if (test_bit(undo, &groups))
 			nlk->netlink_unbind(undo);
 }
 
@@ -1492,7 +1492,7 @@ static int netlink_bind(struct socket *sock, struct sockaddr *addr,
 			netlink_insert(sk, net, nladdr->nl_pid) :
 			netlink_autobind(sock);
 		if (err) {
-			netlink_unbind(nlk->ngroups - 1, groups, nlk);
+			netlink_unbind(nlk->ngroups, groups, nlk);
 			return err;
 		}
 	}
@@ -2509,6 +2509,7 @@ __netlink_kernel_create(struct net *net, int unit, struct module *module,
 		nl_table[unit].module = module;
 		if (cfg) {
 			nl_table[unit].bind = cfg->bind;
+			nl_table[unit].unbind = cfg->unbind;
 			nl_table[unit].flags = cfg->flags;
 			if (cfg->compare)
 				nl_table[unit].compare = cfg->compare;
-- 
2.0.4

^ permalink raw reply related

* Re: [patch net-next 1/2] net: move vlan pop/push functions into common code
From: Pravin Shelar @ 2014-11-12 19:20 UTC (permalink / raw)
  To: Jiri Pirko
  Cc: netdev, David Miller, Jamal Hadi Salim, Tom Herbert, Eric Dumazet,
	Willem de Bruijn, Daniel Borkmann, mst, fw, Paul.Durrant,
	Thomas Graf
In-Reply-To: <20141112115933.GD1882@nanopsycho.orion>

On Wed, Nov 12, 2014 at 3:59 AM, Jiri Pirko <jiri@resnulli.us> wrote:
> Tue, Nov 11, 2014 at 06:24:15PM CET, pshelar@nicira.com wrote:
>>On Tue, Nov 11, 2014 at 2:13 AM, Jiri Pirko <jiri@resnulli.us> wrote:
>>> So it can be used from out of openvswitch code.
>>> Did couple of cosmetic changes on the way, namely variable naming and
>>> adding support for 8021AD proto.
>>>
>>> Signed-off-by: Jiri Pirko <jiri@resnulli.us>
>>> ---
>>>  include/linux/skbuff.h    |  2 ++
>>>  net/core/skbuff.c         | 86 +++++++++++++++++++++++++++++++++++++++++++++++
>>>  net/openvswitch/actions.c | 76 ++---------------------------------------
>>>  3 files changed, 90 insertions(+), 74 deletions(-)
>>>
>>> diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
>>> index 103fbe8..3b0445c 100644
>>> --- a/include/linux/skbuff.h
>>> +++ b/include/linux/skbuff.h
>>> @@ -2673,6 +2673,8 @@ void skb_scrub_packet(struct sk_buff *skb, bool xnet);
>>>  unsigned int skb_gso_transport_seglen(const struct sk_buff *skb);
>>>  struct sk_buff *skb_segment(struct sk_buff *skb, netdev_features_t features);
>>>  struct sk_buff *skb_vlan_untag(struct sk_buff *skb);
>>> +int skb_vlan_pop(struct sk_buff *skb);
>>> +int skb_vlan_push(struct sk_buff *skb, __be16 vlan_proto, u16 vlan_tci);
>>>
>>>  struct skb_checksum_ops {
>>>         __wsum (*update)(const void *mem, int len, __wsum wsum);
>>> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
>>> index 7001896..75e53d4 100644
>>> --- a/net/core/skbuff.c
>>> +++ b/net/core/skbuff.c
>>> @@ -4151,6 +4151,92 @@ err_free:
>>>  }
>>>  EXPORT_SYMBOL(skb_vlan_untag);
>>>
>>> +/* remove VLAN header from packet and update csum accordingly. */
>>> +static int __skb_vlan_pop(struct sk_buff *skb, u16 *vlan_tci)
>>> +{
>>> +       struct vlan_hdr *vhdr;
>>> +       int err;
>>> +
>>> +       if (!pskb_may_pull(skb, VLAN_ETH_HLEN))
>>> +               return -ENOMEM;
>>> +
>>> +       if (!skb_cloned(skb) || skb_clone_writable(skb, VLAN_ETH_HLEN))
>>> +               return 0;
>>> +
>>> +       err = pskb_expand_head(skb, 0, 0, GFP_ATOMIC);
>>> +       if (unlikely(err))
>>> +               return err;
>>> +
>>> +       if (skb->ip_summed == CHECKSUM_COMPLETE)
>>> +               skb->csum = csum_sub(skb->csum, csum_partial(skb->data
>>> +                                       + (2 * ETH_ALEN), VLAN_HLEN, 0));
>>> +
>>> +       vhdr = (struct vlan_hdr *)(skb->data + ETH_HLEN);
>>> +       *vlan_tci = ntohs(vhdr->h_vlan_TCI);
>>> +
>>> +       memmove(skb->data + VLAN_HLEN, skb->data, 2 * ETH_ALEN);
>>> +       __skb_pull(skb, VLAN_HLEN);
>>> +
>>> +       vlan_set_encap_proto(skb, vhdr);
>>> +       skb->mac_header += VLAN_HLEN;
>>> +       if (skb_network_offset(skb) < ETH_HLEN)
>>> +               skb_set_network_header(skb, ETH_HLEN);
>>> +       skb_reset_mac_len(skb);
>>> +
>>> +       return 0;
>>> +}
>>> +
>>> +int skb_vlan_pop(struct sk_buff *skb)
>>> +{
>>> +       u16 vlan_tci;
>>> +       __be16 vlan_proto;
>>> +       int err;
>>> +
>>> +       if (likely(vlan_tx_tag_present(skb))) {
>>> +               skb->vlan_tci = 0;
>>> +       } else {
>>> +               if (unlikely((skb->protocol != htons(ETH_P_8021Q) &&
>>> +                             skb->protocol != htons(ETH_P_8021AD)) ||
>>> +                            skb->len < VLAN_ETH_HLEN))
>>> +                       return 0;
>>> +
>>> +               err = __skb_vlan_pop(skb, &vlan_tci);
>>> +               if (err)
>>> +                       return err;
>>> +       }
>>> +       /* move next vlan tag to hw accel tag */
>>> +       if (likely((skb->protocol != htons(ETH_P_8021Q) &&
>>> +                   skb->protocol != htons(ETH_P_8021AD)) ||
>>> +                  skb->len < VLAN_ETH_HLEN))
>>> +               return 0;
>>> +
>>> +       vlan_proto = skb->protocol;
>>> +       err = __skb_vlan_pop(skb, &vlan_tci);
>>> +       if (unlikely(err))
>>> +               return err;
>>> +
>>> +       __vlan_hwaccel_put_tag(skb, vlan_proto, vlan_tci);
>>> +       return 0;
>>> +}
>>> +EXPORT_SYMBOL(skb_vlan_pop);
>>> +
>>> +int skb_vlan_push(struct sk_buff *skb, __be16 vlan_proto, u16 vlan_tci)
>>> +{
>>> +       if (vlan_tx_tag_present(skb)) {
>>> +               /* push down current VLAN tag */
>>> +               if (!__vlan_put_tag(skb, skb->vlan_proto,
>>> +                                   vlan_tx_tag_get(skb)))
>>> +                       return -ENOMEM;
>>> +
>>Since you are restructuring this code, can you also change
>>__vlan_put_tag() to not free skb on error. So that these two new
>>functions can have common error handling code.
>
> That is not directly related to this patchset. I believe that should be
> changed in separate patch later on.

If you are not going to change this then I am not sure how tcf_vlan()
(that is introduced in next patch) can have common error handling
code.

^ permalink raw reply

* Re: Device Tree Binding for Marvell DSA Switch on imx28 board over Mdio Interface
From: Florian Fainelli @ 2014-11-12 19:19 UTC (permalink / raw)
  To: Oliver Graute, netdev
In-Reply-To: <CA+KjHfYZdZ88ZFzFCPN-bGphh+mnSWy6i0WNzFYv=gOsafXA7g@mail.gmail.com>

On 11/12/2014 05:07 AM, Oliver Graute wrote:
> Hello,
> 
> how do I specify the DSA node and the MDIO node in the Device Tree
> Binding to integrate a Marvell 88e6071 switch with a imx28 board?

If you do not CC the people actively working on this, chances are that
they will just miss your email.

> 
> On my board the Marvell switch 88e6071 is connected via phy1 (on a
> imx28 PCB) to phy5 on the Marvell switch (on a Switch PCB). All phys
> are connected via the same MDIO Bus.
> 
> I enabled the Marvell DSA Support Driver, Gianfar Ethernet Driver and
> Freescale PQ MDIO Driver in the Kernel (I' am not sure if this is the
> right choice for imx28 fec ethernet controller is it?)
> 
> I already know that I need to adapt the DSA driver for this new
> switch. But currently I can't access the switch ports because my MDIO
> Bus is not configured correctly. It always ends with:
> 
> dmesg | grep -E "mii|dsa|mdio"
> [    2.528900] libphy: fec_enet_mii_bus: probed
> [    3.028061] !!!!Enter dsa Probe!!!!!
> [    3.037640] !!!!!Enter dsa_of_probe!!!!!
> [    3.041736] !!!!before of_parse_phandle dsa,mii-bus!!!!!
> [    3.047123] !!!! mdio->name=ethernet-phy !!!!!
> [    3.051658] !!!!before of_mdio_find_bus!!!!!
> [    3.055950] !!!!!enter of_mdio_find_bus!!!!!
> [    3.074074] !!!!!enter of_mdio_bus_match!!!!!
> [    3.078451] !!!!!enter of_mdio_bus_match!!!!!
> [    3.088915] !!!!Leave of_mdio_find_bus !!!!!
> [    3.093268] !!!! return  of_mdio_find_bus =22 !!!!!
> [    3.098166] dsa_of_probe returns=-22
> [    3.101858] dsa: probe of dsa.5 failed with error -22
> [   19.169423] fec 800f0000.ethernet eth0: Freescale FEC PHY driver
> [Micrel KSZ8041] (mii_bus:phy_addr=800f0000.etherne:00, irq=-1)
> [   20.038786] fec 800f4000.ethernet eth1: Freescale FEC PHY driver
> [Micrel KSZ8041] (mii_bus:phy_addr=800f0000.etherne:01, irq=-1)
> 
> because the method  of_mdio_find_bus returns with EINVAL
> 
> I suspect that the problem is the fact that the Kernel is not getting
> connected to the MDIO bus.
> what is wrong here?
> 
> dsa@0 {
>         compatible = "marvell,dsa";
>         #address-cells = <2>;
>         #size-cells = <0>;
>         interrupts = <10>;
>         dsa,ethernet = <&eth1>;
>          dsa,mii-bus = <&ethphy1>;

This should be phandle to the MDIO bus controller, not a node within
its, so in your case this should be dsa,mii-bus = <&mdio_bus>;

> 
>         switch@0 {
>             #address-cells = <1>;
>             #size-cells = <0>;
>             reg = <5 0>;   /* MDIO address 5, switch 0 in tree */
> 
>             port@0 {
>                 reg = <0>;
>                 label = "lan1";
>                 phy-handle = <&ethphy1>;
>             };
> 
>             port@1 {
>                 reg = <1>;
>                 label = "lan2";
>             };
> 
>             port@2 {
>                 reg = <2>;
>                 label = "lan3";
>             };
> 
>             port@3 {
>                 reg = <3>;
>                 label = "lan4";
>             };
> 
>             port@4 {
>                 reg = <4>;
>                 label = "lan5";
>             };
> 
>             port@5 {
>                 reg = <5>;
>                 label = "cpu";
>             };
> 
>         };
>     };
> 
> 
> eth1: eth1 {
>     status = "okay";
>     ethernet1-port@1 {
>         phy-handle = <&ethphy1>;

You probably want to use a fixed-link node here to provide a link status
that is always UP as seen from the CPU Ethernet MAC perspective, so
something like this:

fixed-link {
	speed = <1000>;
	full-duplex;
};

>     };
> };
> 
> 
> mdio_bus: mdio {
>         #address-cells = <1>;
>         #size-cells = <0>;
>         device_type = "mdio";
>         //compatible = "fsl,gianfar-mdio";
>         compatible = "fsl,mpc875-fec-mdio", "fsl,pq1-fec-mdio";
>         reg = <0xe00 0x188>;
>         status = "okay";
> 
>          ethphy0: ethernet-phy@0 {
>                  reg = <0>;
> 
>          };
> 
>          ethphy1: ethernet-phy@1 {
>                  reg = <1>;
>                 };
>                  //reg = <0xff>; */ /* No PHY attached */
>                  //speed = <1000>;
>                  //duple = <1>;
>        };
> 
> Best regards,
> 
> Oliver Graute
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply

* Re: [patch net-next v2 3/4] net: move vlan pop/push functions into common code
From: Pravin Shelar @ 2014-11-12 19:17 UTC (permalink / raw)
  To: Jiri Pirko
  Cc: netdev, David Miller, Jamal Hadi Salim, Tom Herbert, Eric Dumazet,
	Willem de Bruijn, Daniel Borkmann, mst, fw, Paul.Durrant,
	Thomas Graf
In-Reply-To: <1415803950-9838-3-git-send-email-jiri@resnulli.us>

On Wed, Nov 12, 2014 at 6:52 AM, Jiri Pirko <jiri@resnulli.us> wrote:
> So it can be used from out of openvswitch code.
> Did couple of cosmetic changes on the way, namely variable naming and
> adding support for 8021AD proto.
>
> Signed-off-by: Jiri Pirko <jiri@resnulli.us>
> ---
>
> v1->v2:
> - adjusted to fix recent ovs changes
> - included change to use make_writable suggested by Eric
>
>  include/linux/skbuff.h    |  2 ++
>  net/core/skbuff.c         | 78 +++++++++++++++++++++++++++++++++++++++++++++
>  net/openvswitch/actions.c | 81 +++++------------------------------------------
>  3 files changed, 88 insertions(+), 73 deletions(-)
>
> diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
> index e045516..78c299f 100644
> --- a/include/linux/skbuff.h
> +++ b/include/linux/skbuff.h
> @@ -2679,6 +2679,8 @@ unsigned int skb_gso_transport_seglen(const struct sk_buff *skb);
>  struct sk_buff *skb_segment(struct sk_buff *skb, netdev_features_t features);
>  struct sk_buff *skb_vlan_untag(struct sk_buff *skb);
>  int skb_ensure_writable(struct sk_buff *skb, int write_len);
> +int skb_vlan_pop(struct sk_buff *skb);
> +int skb_vlan_push(struct sk_buff *skb, __be16 vlan_proto, u16 vlan_tci);
>
>  struct skb_checksum_ops {
>         __wsum (*update)(const void *mem, int len, __wsum wsum);
> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> index d11bbe0..c7d3000 100644
> --- a/net/core/skbuff.c
> +++ b/net/core/skbuff.c
> @@ -4163,6 +4163,84 @@ int skb_ensure_writable(struct sk_buff *skb, int write_len)
>  }
>  EXPORT_SYMBOL(skb_ensure_writable);
>
> +/* remove VLAN header from packet and update csum accordingly. */
> +static int __skb_vlan_pop(struct sk_buff *skb, u16 *vlan_tci)
> +{
> +       struct vlan_hdr *vhdr;
> +       int err;
> +
> +       err = skb_ensure_writable(skb, VLAN_ETH_HLEN);
> +       if (unlikely(err))
> +               return err;
> +
> +       skb_postpull_rcsum(skb, skb->data + (2 * ETH_ALEN), VLAN_HLEN);
> +
> +       vhdr = (struct vlan_hdr *)(skb->data + ETH_HLEN);
> +       *vlan_tci = ntohs(vhdr->h_vlan_TCI);
> +
> +       memmove(skb->data + VLAN_HLEN, skb->data, 2 * ETH_ALEN);
> +       __skb_pull(skb, VLAN_HLEN);
> +
> +       vlan_set_encap_proto(skb, vhdr);
> +       skb->mac_header += VLAN_HLEN;
> +       if (skb_network_offset(skb) < ETH_HLEN)
> +               skb_set_network_header(skb, ETH_HLEN);
> +       skb_reset_mac_len(skb);
> +
> +       return 0;
> +}
> +
> +int skb_vlan_pop(struct sk_buff *skb)
> +{
> +       u16 vlan_tci;
> +       __be16 vlan_proto;
> +       int err;
> +
> +       if (likely(vlan_tx_tag_present(skb))) {
> +               skb->vlan_tci = 0;
> +       } else {
> +               if (unlikely((skb->protocol != htons(ETH_P_8021Q) &&
> +                             skb->protocol != htons(ETH_P_8021AD)) ||
> +                            skb->len < VLAN_ETH_HLEN))
> +                       return 0;
> +
> +               err = __skb_vlan_pop(skb, &vlan_tci);
> +               if (err)
> +                       return err;
> +       }
> +       /* move next vlan tag to hw accel tag */
> +       if (likely((skb->protocol != htons(ETH_P_8021Q) &&
> +                   skb->protocol != htons(ETH_P_8021AD)) ||
> +                  skb->len < VLAN_ETH_HLEN))
> +               return 0;
> +
> +       vlan_proto = skb->protocol;
> +       err = __skb_vlan_pop(skb, &vlan_tci);
> +       if (unlikely(err))
> +               return err;
> +
> +       __vlan_hwaccel_put_tag(skb, vlan_proto, vlan_tci);
> +       return 0;
> +}
> +EXPORT_SYMBOL(skb_vlan_pop);
> +
> +int skb_vlan_push(struct sk_buff *skb, __be16 vlan_proto, u16 vlan_tci)
> +{
> +       if (vlan_tx_tag_present(skb)) {
> +               /* push down current VLAN tag */
> +               if (!__vlan_put_tag(skb, skb->vlan_proto,
> +                                   vlan_tx_tag_get(skb)))
> +                       return -ENOMEM;
> +
> +               if (skb->ip_summed == CHECKSUM_COMPLETE)
> +                       skb->csum = csum_add(skb->csum, csum_partial(skb->data
> +                                       + (2 * ETH_ALEN), VLAN_HLEN, 0));
> +       }

Needs to update skb->mac_len.


> +       __vlan_hwaccel_put_tag(skb, vlan_proto, vlan_tci);
> +       return 0;
> +}
> +EXPORT_SYMBOL(skb_vlan_push);
> +
>  /**
>   * alloc_skb_with_frags - allocate skb with page frags
>   *
> diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
> index 04c9680..e1a5182 100644
> --- a/net/openvswitch/actions.c
> +++ b/net/openvswitch/actions.c
> @@ -206,91 +206,26 @@ static int set_mpls(struct sk_buff *skb, struct sw_flow_key *key,
>         return 0;
>  }
>
> -/* remove VLAN header from packet and update csum accordingly. */
> -static int __pop_vlan_tci(struct sk_buff *skb, __be16 *current_tci)
> -{
> -       struct vlan_hdr *vhdr;
> -       int err;
> -
> -       err = skb_ensure_writable(skb, VLAN_ETH_HLEN);
> -       if (unlikely(err))
> -               return err;
> -
> -       skb_postpull_rcsum(skb, skb->data + (2 * ETH_ALEN), VLAN_HLEN);
> -
> -       vhdr = (struct vlan_hdr *)(skb->data + ETH_HLEN);
> -       *current_tci = vhdr->h_vlan_TCI;
> -
> -       memmove(skb->data + VLAN_HLEN, skb->data, 2 * ETH_ALEN);
> -       __skb_pull(skb, VLAN_HLEN);
> -
> -       vlan_set_encap_proto(skb, vhdr);
> -       skb->mac_header += VLAN_HLEN;
> -
> -       if (skb_network_offset(skb) < ETH_HLEN)
> -               skb_set_network_header(skb, ETH_HLEN);
> -
> -       /* Update mac_len for subsequent MPLS actions */
> -       skb_reset_mac_len(skb);
> -       return 0;
> -}
> -
>  static int pop_vlan(struct sk_buff *skb, struct sw_flow_key *key)
>  {
> -       __be16 tci;
>         int err;
>
> -       if (likely(vlan_tx_tag_present(skb))) {
> -               skb->vlan_tci = 0;
> -       } else {
> -               if (unlikely(skb->protocol != htons(ETH_P_8021Q) ||
> -                            skb->len < VLAN_ETH_HLEN))
> -                       return 0;
> -
> -               err = __pop_vlan_tci(skb, &tci);
> -               if (err)
> -                       return err;
> -       }
> -       /* move next vlan tag to hw accel tag */
> -       if (likely(skb->protocol != htons(ETH_P_8021Q) ||
> -                  skb->len < VLAN_ETH_HLEN)) {
> +       err = skb_vlan_pop(skb);
> +       if (vlan_tx_tag_present(skb))
> +               invalidate_flow_key(key);
> +       else
>                 key->eth.tci = 0;
> -               return 0;
> -       }
> -
> -       invalidate_flow_key(key);
> -       err = __pop_vlan_tci(skb, &tci);
> -       if (unlikely(err))
> -               return err;
> -
> -       __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), ntohs(tci));
> -       return 0;
> +       return err;
>  }
>
>  static int push_vlan(struct sk_buff *skb, struct sw_flow_key *key,
>                      const struct ovs_action_push_vlan *vlan)
>  {
> -       if (unlikely(vlan_tx_tag_present(skb))) {
> -               u16 current_tag;
> -
> -               /* push down current VLAN tag */
> -               current_tag = vlan_tx_tag_get(skb);
> -
> -               if (!__vlan_put_tag(skb, skb->vlan_proto, current_tag))
> -                       return -ENOMEM;
> -               /* Update mac_len for subsequent MPLS actions */
> -               skb->mac_len += VLAN_HLEN;
> -
> -               if (skb->ip_summed == CHECKSUM_COMPLETE)
> -                       skb->csum = csum_add(skb->csum, csum_partial(skb->data
> -                                       + (2 * ETH_ALEN), VLAN_HLEN, 0));
> -
> +       if (vlan_tx_tag_present(skb))
>                 invalidate_flow_key(key);
> -       } else {
> +       else
>                 key->eth.tci = vlan->vlan_tci;
> -       }
> -       __vlan_hwaccel_put_tag(skb, vlan->vlan_tpid, ntohs(vlan->vlan_tci) & ~VLAN_TAG_PRESENT);
> -       return 0;
> +       return skb_vlan_push(skb, vlan->vlan_tpid, ntohs(vlan->vlan_tci) & ~VLAN_TAG_PRESENT);
>  }
>
>  static int set_eth_addr(struct sk_buff *skb, struct sw_flow_key *key,
> --
> 1.9.3
>

^ permalink raw reply

* Re: [patch net-next v2 2/4] net: move make_writable helper into common code
From: Pravin Shelar @ 2014-11-12 19:15 UTC (permalink / raw)
  To: Jiri Pirko
  Cc: netdev, David Miller, Jamal Hadi Salim, Tom Herbert, Eric Dumazet,
	Willem de Bruijn, Daniel Borkmann, mst, fw, Paul.Durrant,
	Thomas Graf
In-Reply-To: <1415803950-9838-2-git-send-email-jiri@resnulli.us>

On Wed, Nov 12, 2014 at 6:52 AM, Jiri Pirko <jiri@resnulli.us> wrote:
> note that skb_make_writable already exists in net/netfilter/core.c
> but does something slightly different.
>
> Suggested-by: Eric Dumazet <eric.dumazet@gmail.com>
> Signed-off-by: Jiri Pirko <jiri@resnulli.us>

Looks good.
Acked-by: Pravin B Shelar <pshelar@nicira.com>

> ---
>  include/linux/skbuff.h    |  1 +
>  net/core/skbuff.c         | 12 ++++++++++++
>  net/openvswitch/actions.c | 39 ++++++++++++++-------------------------
>  3 files changed, 27 insertions(+), 25 deletions(-)
>
> diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
> index 73c370e..e045516 100644
> --- a/include/linux/skbuff.h
> +++ b/include/linux/skbuff.h
> @@ -2678,6 +2678,7 @@ void skb_scrub_packet(struct sk_buff *skb, bool xnet);
>  unsigned int skb_gso_transport_seglen(const struct sk_buff *skb);
>  struct sk_buff *skb_segment(struct sk_buff *skb, netdev_features_t features);
>  struct sk_buff *skb_vlan_untag(struct sk_buff *skb);
> +int skb_ensure_writable(struct sk_buff *skb, int write_len);
>
>  struct skb_checksum_ops {
>         __wsum (*update)(const void *mem, int len, __wsum wsum);
> diff --git a/net/core/skbuff.c b/net/core/skbuff.c
> index 7001896..d11bbe0 100644
> --- a/net/core/skbuff.c
> +++ b/net/core/skbuff.c
> @@ -4151,6 +4151,18 @@ err_free:
>  }
>  EXPORT_SYMBOL(skb_vlan_untag);
>
> +int skb_ensure_writable(struct sk_buff *skb, int write_len)
> +{
> +       if (!pskb_may_pull(skb, write_len))
> +               return -ENOMEM;
> +
> +       if (!skb_cloned(skb) || skb_clone_writable(skb, write_len))
> +               return 0;
> +
> +       return pskb_expand_head(skb, 0, 0, GFP_ATOMIC);
> +}
> +EXPORT_SYMBOL(skb_ensure_writable);
> +
>  /**
>   * alloc_skb_with_frags - allocate skb with page frags
>   *
> diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
> index 749a301..04c9680 100644
> --- a/net/openvswitch/actions.c
> +++ b/net/openvswitch/actions.c
> @@ -119,17 +119,6 @@ static bool is_flow_key_valid(const struct sw_flow_key *key)
>         return !!key->eth.type;
>  }
>
> -static int make_writable(struct sk_buff *skb, int write_len)
> -{
> -       if (!pskb_may_pull(skb, write_len))
> -               return -ENOMEM;
> -
> -       if (!skb_cloned(skb) || skb_clone_writable(skb, write_len))
> -               return 0;
> -
> -       return pskb_expand_head(skb, 0, 0, GFP_ATOMIC);
> -}
> -
>  static int push_mpls(struct sk_buff *skb, struct sw_flow_key *key,
>                      const struct ovs_action_push_mpls *mpls)
>  {
> @@ -171,7 +160,7 @@ static int pop_mpls(struct sk_buff *skb, struct sw_flow_key *key,
>         struct ethhdr *hdr;
>         int err;
>
> -       err = make_writable(skb, skb->mac_len + MPLS_HLEN);
> +       err = skb_ensure_writable(skb, skb->mac_len + MPLS_HLEN);
>         if (unlikely(err))
>                 return err;
>
> @@ -201,7 +190,7 @@ static int set_mpls(struct sk_buff *skb, struct sw_flow_key *key,
>         __be32 *stack;
>         int err;
>
> -       err = make_writable(skb, skb->mac_len + MPLS_HLEN);
> +       err = skb_ensure_writable(skb, skb->mac_len + MPLS_HLEN);
>         if (unlikely(err))
>                 return err;
>
> @@ -223,7 +212,7 @@ static int __pop_vlan_tci(struct sk_buff *skb, __be16 *current_tci)
>         struct vlan_hdr *vhdr;
>         int err;
>
> -       err = make_writable(skb, VLAN_ETH_HLEN);
> +       err = skb_ensure_writable(skb, VLAN_ETH_HLEN);
>         if (unlikely(err))
>                 return err;
>
> @@ -308,7 +297,7 @@ static int set_eth_addr(struct sk_buff *skb, struct sw_flow_key *key,
>                         const struct ovs_key_ethernet *eth_key)
>  {
>         int err;
> -       err = make_writable(skb, ETH_HLEN);
> +       err = skb_ensure_writable(skb, ETH_HLEN);
>         if (unlikely(err))
>                 return err;
>
> @@ -410,8 +399,8 @@ static int set_ipv4(struct sk_buff *skb, struct sw_flow_key *key,
>         struct iphdr *nh;
>         int err;
>
> -       err = make_writable(skb, skb_network_offset(skb) +
> -                                sizeof(struct iphdr));
> +       err = skb_ensure_writable(skb, skb_network_offset(skb) +
> +                                 sizeof(struct iphdr));
>         if (unlikely(err))
>                 return err;
>
> @@ -448,8 +437,8 @@ static int set_ipv6(struct sk_buff *skb, struct sw_flow_key *key,
>         __be32 *saddr;
>         __be32 *daddr;
>
> -       err = make_writable(skb, skb_network_offset(skb) +
> -                           sizeof(struct ipv6hdr));
> +       err = skb_ensure_writable(skb, skb_network_offset(skb) +
> +                                 sizeof(struct ipv6hdr));
>         if (unlikely(err))
>                 return err;
>
> @@ -491,7 +480,7 @@ static int set_ipv6(struct sk_buff *skb, struct sw_flow_key *key,
>         return 0;
>  }
>
> -/* Must follow make_writable() since that can move the skb data. */
> +/* Must follow skb_ensure_writable() since that can move the skb data. */
>  static void set_tp_port(struct sk_buff *skb, __be16 *port,
>                          __be16 new_port, __sum16 *check)
>  {
> @@ -521,8 +510,8 @@ static int set_udp(struct sk_buff *skb, struct sw_flow_key *key,
>         struct udphdr *uh;
>         int err;
>
> -       err = make_writable(skb, skb_transport_offset(skb) +
> -                                sizeof(struct udphdr));
> +       err = skb_ensure_writable(skb, skb_transport_offset(skb) +
> +                                 sizeof(struct udphdr));
>         if (unlikely(err))
>                 return err;
>
> @@ -546,8 +535,8 @@ static int set_tcp(struct sk_buff *skb, struct sw_flow_key *key,
>         struct tcphdr *th;
>         int err;
>
> -       err = make_writable(skb, skb_transport_offset(skb) +
> -                                sizeof(struct tcphdr));
> +       err = skb_ensure_writable(skb, skb_transport_offset(skb) +
> +                                 sizeof(struct tcphdr));
>         if (unlikely(err))
>                 return err;
>
> @@ -572,7 +561,7 @@ static int set_sctp(struct sk_buff *skb, struct sw_flow_key *key,
>         int err;
>         unsigned int sctphoff = skb_transport_offset(skb);
>
> -       err = make_writable(skb, sctphoff + sizeof(struct sctphdr));
> +       err = skb_ensure_writable(skb, sctphoff + sizeof(struct sctphdr));
>         if (unlikely(err))
>                 return err;
>
> --
> 1.9.3
>

^ permalink raw reply

* Re: [patch net-next v2 1/4] openvswitch: actions: use skb_postpull_rcsum when possible
From: Pravin Shelar @ 2014-11-12 19:13 UTC (permalink / raw)
  To: Jiri Pirko
  Cc: netdev, David Miller, Jamal Hadi Salim, Tom Herbert, Eric Dumazet,
	Willem de Bruijn, Daniel Borkmann, mst, fw, Paul.Durrant,
	Thomas Graf
In-Reply-To: <1415803950-9838-1-git-send-email-jiri@resnulli.us>

On Wed, Nov 12, 2014 at 6:52 AM, Jiri Pirko <jiri@resnulli.us> wrote:
> Replace duplicated code by calling skb_postpull_rcsum
>
> Suggested-by: Eric Dumazet <eric.dumazet@gmail.com>
> Signed-off-by: Jiri Pirko <jiri@resnulli.us>

Looks good.
Acked-by: Pravin B Shelar <pshelar@nicira.com>

> ---
>  net/openvswitch/actions.c | 9 ++-------
>  1 file changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c
> index 394efa6..749a301 100644
> --- a/net/openvswitch/actions.c
> +++ b/net/openvswitch/actions.c
> @@ -175,10 +175,7 @@ static int pop_mpls(struct sk_buff *skb, struct sw_flow_key *key,
>         if (unlikely(err))
>                 return err;
>
> -       if (skb->ip_summed == CHECKSUM_COMPLETE)
> -               skb->csum = csum_sub(skb->csum,
> -                                    csum_partial(skb_mpls_header(skb),
> -                                                 MPLS_HLEN, 0));
> +       skb_postpull_rcsum(skb, skb_mpls_header(skb), MPLS_HLEN);
>
>         memmove(skb_mac_header(skb) + MPLS_HLEN, skb_mac_header(skb),
>                 skb->mac_len);
> @@ -230,9 +227,7 @@ static int __pop_vlan_tci(struct sk_buff *skb, __be16 *current_tci)
>         if (unlikely(err))
>                 return err;
>
> -       if (skb->ip_summed == CHECKSUM_COMPLETE)
> -               skb->csum = csum_sub(skb->csum, csum_partial(skb->data
> -                                       + (2 * ETH_ALEN), VLAN_HLEN, 0));
> +       skb_postpull_rcsum(skb, skb->data + (2 * ETH_ALEN), VLAN_HLEN);
>
>         vhdr = (struct vlan_hdr *)(skb->data + ETH_HLEN);
>         *current_tci = vhdr->h_vlan_TCI;
> --
> 1.9.3
>

^ permalink raw reply

* Re: [patch net-next 1/2] net: move vlan pop/push functions into common code
From: David Miller @ 2014-11-12 19:11 UTC (permalink / raw)
  To: jiri
  Cc: pshelar, netdev, jhs, therbert, edumazet, willemb, dborkman, mst,
	fw, Paul.Durrant, tgraf
In-Reply-To: <20141112115933.GD1882@nanopsycho.orion>

From: Jiri Pirko <jiri@resnulli.us>
Date: Wed, 12 Nov 2014 12:59:33 +0100

> That is not directly related to this patchset. I believe that should be
> changed in separate patch later on.

+1, but this has been a long standing issue and a large source of bugs.

^ permalink raw reply

* Re: [PATCH net-next 0/5] net: phy: bcm7xxx: workaround updates
From: David Miller @ 2014-11-12 19:08 UTC (permalink / raw)
  To: f.fainelli; +Cc: netdev
In-Reply-To: <1415746514-11189-1-git-send-email-f.fainelli@gmail.com>

From: Florian Fainelli <f.fainelli@gmail.com>
Date: Tue, 11 Nov 2014 14:55:09 -0800

> This patch series contains some updates to the Broadcom BCM7xxx internal
> PHY driver, including:
> 
> - removing an annonying print that would appear during interface up/down and
>   suspend/resume cycles
> - drop a workaround sequence for a non-production PHY revision
> - add new workarounds for the latest and greatest PHY devices found out ther

Applied, thanks Florian.

^ permalink raw reply

* Re: [PATCH] irda: Convert IRDA_DEBUG to pr_debug
From: David Miller @ 2014-11-12 18:57 UTC (permalink / raw)
  To: joe; +Cc: samuel, netdev
In-Reply-To: <1415745897.16070.15.camel@perches.com>

From: Joe Perches <joe@perches.com>
Date: Tue, 11 Nov 2014 14:44:57 -0800

> Use the normal kernel debugging mechanism which also
> enables dynamic_debug at the same time.
> 
> Other miscellanea:
> 
> o Remove sysctl for irda_debug
> o Remove function tracing like uses (use ftrace instead)
> o Coalesce formats
> o Realign arguments
> o Remove unnecessary OOM messages
> 
> Signed-off-by: Joe Perches <joe@perches.com>
> ---
> 
> donauboe does not have normal indentation, unchanged.

Applied to net-next, thanks Joe.

^ permalink raw reply

* Re: [PATCH 0/9] net: phy: micrel: refactoring and KSZ8081/KSZ8091 features
From: David Miller @ 2014-11-12 18:56 UTC (permalink / raw)
  To: johan; +Cc: f.fainelli, linux-kernel, netdev
In-Reply-To: <1415732415-10363-1-git-send-email-johan@kernel.org>

From: Johan Hovold <johan@kernel.org>
Date: Tue, 11 Nov 2014 20:00:06 +0100

> This series cleans up and refactors parts of the micrel PHY driver, and
> adds support for broadcast-address-disable and led-mode configuration
> for KSZ8081 and KSZ8091 PHYs.
> 
> Specifically, this enables dual KSZ8081 setups (which are limited to
> using address 0 and 3).
> 
> A follow up series will add device-type abstraction which will allow for
> further refactoring and shared initialisation code.

Series applied, thanks Johan.

^ permalink raw reply

* Re: [PATCH 0/3] net: phy: add module_phy_driver macro
From: David Miller @ 2014-11-12 18:53 UTC (permalink / raw)
  To: f.fainelli; +Cc: johan, linux-kernel, netdev
In-Reply-To: <54626015.3030907@gmail.com>

From: Florian Fainelli <f.fainelli@gmail.com>
Date: Tue, 11 Nov 2014 11:14:29 -0800

> On 11/11/2014 10:45 AM, Johan Hovold wrote:
>> Add module_phy_driver macro that can be used by PHY drivers that only
>> calls phy_driver_register or phy_drivers_register (and the corresponding
>> unregister functions) in their module init (and exit).
>> 
>> This allows us to eliminate a lot of boilerplate code.
>> 
>> Split in three patches (actual macro and two driver change classes) in
>> order to facilitate review.
> 
> Looks good to me:
> 
> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>

Series applied, thanks.

^ permalink raw reply

* Re: [PATCH net-next] sunvnet: fix NULL pointer dereference
From: David Miller @ 2014-11-12 18:51 UTC (permalink / raw)
  To: david.stevens; +Cc: netdev, sowmini.varadhan
In-Reply-To: <546383B7.2090106@oracle.com>

From: David L Stevens <david.stevens@oracle.com>
Date: Wed, 12 Nov 2014 10:58:47 -0500

> This patch fixes a NULL pointer dereference when __tx_port_find() doesn't
> find a matching port.
> 
> Signed-off-by: David L Stevens <david.stevens@oracle.com>

Applied, thanks.

^ permalink raw reply

* Re: [PATCH v1 net-next 1/2] bonding: Expand speed type bits of the AD Port Key
From: David Miller @ 2014-11-12 17:43 UTC (permalink / raw)
  To: jianhua.xie; +Cc: jay.vosburgh, netdev, vfalico, andy
In-Reply-To: <54632E25.3000205@freescale.com>


Please do not top-post.

^ permalink raw reply

* Re: "asix: Don't reset PHY on if_up for ASIX 88772" breaks net on arndale platform
From: David Miller @ 2014-11-12 17:43 UTC (permalink / raw)
  To: M.Stam
  Cc: ben, ckeepax, riku.voipio, linux-usb, netdev, linux-kernel,
	linux-samsung-soc
In-Reply-To: <C89EFD3CD56F64468D3D206D683A8D2203A003FE@ldam-msx2.fugro-nl.local>


Please do not top-post.

^ 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