Netdev List
 help / color / mirror / Atom feed
* Re: [Patch net-next] bridge: add some missing __rcu marks
From: Cong Wang @ 2013-02-14  8:23 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: netdev, Vlad Yasevich, David S. Miller
In-Reply-To: <20130213223935.122d035b@nehalam.linuxnetplumber.net>

On Wed, 2013-02-13 at 22:39 -0800, Stephen Hemminger wrote:
> On Thu, 14 Feb 2013 14:12:30 +0800
> Cong Wang <amwang@redhat.com> wrote:
> >  #ifdef CONFIG_NET_POLL_CONTROLLER
> > -static inline struct netpoll_info *br_netpoll_info(struct net_bridge *br)
> > +static inline struct netpoll_info __rcu *br_netpoll_info(struct net_bridge *br)
> >  {
> >  	return br->dev->npinfo;
> >  }
> 
> 
> This doesn't seem right since there is no rcu_dereference() here.

But we don't dereference ->npinfo here, we only check if it is NULL.

^ permalink raw reply

* Re: how to handle bonding failover when using a bridge over the bond?
From: Cong Wang @ 2013-02-14  8:01 UTC (permalink / raw)
  To: netdev
In-Reply-To: <511ADEBB.1000701@genband.com>

On Wed, 13 Feb 2013 at 00:30 GMT, Chris Friesen <chris.friesen@genband.com> wrote:
> On 02/12/2013 06:02 PM, Jay Vosburgh wrote:
>> 	The bond doesn't track all of the MACs that go through it, but
>> the bridge presumably does, and could respond to the FAILOVER notifier
>> with something to notify the switch that the port assignments for the
>> various MACs have changed.
>
> That would probably make sense.  I've added the bridging folks, maybe 
> they'll have a suggestion how this sort of thing should be handled.
>

It is already handled. When BONDING_FAILOVER is triggered and the MAC has
been changed, NETDEV_CHANGEADDR is issued too, then bridge will capture
it and update its fdb:

        case NETDEV_CHANGEADDR:
                spin_lock_bh(&br->lock);
                br_fdb_changeaddr(p, dev->dev_addr);
                changed_addr = br_stp_recalculate_bridge_id(br);
                spin_unlock_bh(&br->lock);

                if (changed_addr)
                        call_netdevice_notifiers(NETDEV_CHANGEADDR, br->dev);

                break;
		

^ permalink raw reply

* !!! -{U Can Help }- !!! -{Letter Family Project Attach}
From: Mrs. Mary Gezi @ 2013-02-14  7:14 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 1 bytes --]

 

[-- Attachment #2: FAMILY PORJECT.doc --]
[-- Type: application/msword, Size: 35328 bytes --]

^ permalink raw reply

* Re: [Patch net-next] bridge: add some missing __rcu marks
From: Stephen Hemminger @ 2013-02-14  6:39 UTC (permalink / raw)
  To: Cong Wang; +Cc: netdev, Vlad Yasevich, David S. Miller
In-Reply-To: <1360822350-26882-1-git-send-email-amwang@redhat.com>

On Thu, 14 Feb 2013 14:12:30 +0800
Cong Wang <amwang@redhat.com> wrote:

> From: Cong Wang <amwang@redhat.com>
> 
> 
> Cc: Vlad Yasevich <vyasevic@redhat.com>
> Cc: Stephen Hemminger <stephen@networkplumber.org>
> Cc: David S. Miller <davem@davemloft.net>
> Signed-off-by: Cong Wang <amwang@redhat.com>
> 
> ---
> diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
> index 6d314c4..0f115ba 100644
> --- a/net/bridge/br_private.h
> +++ b/net/bridge/br_private.h
> @@ -328,7 +328,7 @@ extern void br_dev_delete(struct net_device *dev, struct list_head *list);
>  extern netdev_tx_t br_dev_xmit(struct sk_buff *skb,
>  			       struct net_device *dev);
>  #ifdef CONFIG_NET_POLL_CONTROLLER
> -static inline struct netpoll_info *br_netpoll_info(struct net_bridge *br)
> +static inline struct netpoll_info __rcu *br_netpoll_info(struct net_bridge *br)
>  {
>  	return br->dev->npinfo;
>  }


This doesn't seem right since there is no rcu_dereference() here.

^ permalink raw reply

* [Patch net-next] bridge: add some missing __rcu marks
From: Cong Wang @ 2013-02-14  6:12 UTC (permalink / raw)
  To: netdev; +Cc: Vlad Yasevich, Stephen Hemminger, David S. Miller, Cong Wang

From: Cong Wang <amwang@redhat.com>


Cc: Vlad Yasevich <vyasevic@redhat.com>
Cc: Stephen Hemminger <stephen@networkplumber.org>
Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Cong Wang <amwang@redhat.com>

---
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
index 6d314c4..0f115ba 100644
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -328,7 +328,7 @@ extern void br_dev_delete(struct net_device *dev, struct list_head *list);
 extern netdev_tx_t br_dev_xmit(struct sk_buff *skb,
 			       struct net_device *dev);
 #ifdef CONFIG_NET_POLL_CONTROLLER
-static inline struct netpoll_info *br_netpoll_info(struct net_bridge *br)
+static inline struct netpoll_info __rcu *br_netpoll_info(struct net_bridge *br)
 {
 	return br->dev->npinfo;
 }
@@ -345,7 +345,7 @@ static inline void br_netpoll_send_skb(const struct net_bridge_port *p,
 extern int br_netpoll_enable(struct net_bridge_port *p, gfp_t gfp);
 extern void br_netpoll_disable(struct net_bridge_port *p);
 #else
-static inline struct netpoll_info *br_netpoll_info(struct net_bridge *br)
+static inline struct netpoll_info __rcu *br_netpoll_info(struct net_bridge *br)
 {
 	return NULL;
 }
@@ -469,7 +469,7 @@ extern void br_multicast_free_pg(struct rcu_head *head);
 extern struct net_bridge_port_group *br_multicast_new_port_group(
 				struct net_bridge_port *port,
 				struct br_ip *group,
-				struct net_bridge_port_group *next,
+				struct net_bridge_port_group __rcu *next,
 				unsigned char state);
 extern void br_mdb_init(void);
 extern void br_mdb_uninit(void);

^ permalink raw reply related

* [Patch net-next] bridge: make ifla_br_policy and br_af_ops static
From: Cong Wang @ 2013-02-14  5:57 UTC (permalink / raw)
  To: netdev; +Cc: Vlad Yasevich, Stephen Hemminger, David S. Miller, Cong Wang

From: Cong Wang <amwang@redhat.com>

They are only used within this file.

Cc: Vlad Yasevich <vyasevic@redhat.com>
Cc: Stephen Hemminger <stephen@networkplumber.org>
Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Cong Wang <amwang@redhat.com>

---
diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
index d1dda47..27aa3ee 100644
--- a/net/bridge/br_netlink.c
+++ b/net/bridge/br_netlink.c
@@ -217,7 +217,7 @@ out:
 	return err;
 }
 
-const struct nla_policy ifla_br_policy[IFLA_MAX+1] = {
+static const struct nla_policy ifla_br_policy[IFLA_MAX+1] = {
 	[IFLA_BRIDGE_FLAGS]	= { .type = NLA_U16 },
 	[IFLA_BRIDGE_MODE]	= { .type = NLA_U16 },
 	[IFLA_BRIDGE_VLAN_INFO]	= { .type = NLA_BINARY,
@@ -463,7 +463,7 @@ static size_t br_get_link_af_size(const struct net_device *dev)
 	return pv->num_vlans * nla_total_size(sizeof(struct bridge_vlan_info));
 }
 
-struct rtnl_af_ops br_af_ops = {
+static struct rtnl_af_ops br_af_ops = {
 	.family			= AF_BRIDGE,
 	.get_link_af_size	= br_get_link_af_size,
 };

^ permalink raw reply related

* Re: [Patch net-next] bridge: use __u16 in if_bridge.h
From: David Miller @ 2013-02-14  5:54 UTC (permalink / raw)
  To: amwang; +Cc: netdev, vyasevic, stephen
In-Reply-To: <1360819951-19484-1-git-send-email-amwang@redhat.com>

From: Cong Wang <amwang@redhat.com>
Date: Thu, 14 Feb 2013 13:32:31 +0800

> From: Cong Wang <amwang@redhat.com>
> 
> We should use "__u16" instead of "u16" in the user-space visable
> header.
> 
> Cc: Vlad Yasevich <vyasevic@redhat.com>
> Cc: Stephen Hemminger <stephen@networkplumber.org>
> Cc: David S. Miller <davem@davemloft.net>
> Signed-off-by: Cong Wang <amwang@redhat.com>

Seems obvious enough, applied, thanks.

^ permalink raw reply

* [Patch net-next] bridge: use __u16 in if_bridge.h
From: Cong Wang @ 2013-02-14  5:32 UTC (permalink / raw)
  To: netdev; +Cc: Vlad Yasevich, Stephen Hemminger, David S. Miller, Cong Wang

From: Cong Wang <amwang@redhat.com>

We should use "__u16" instead of "u16" in the user-space visable
header.

Cc: Vlad Yasevich <vyasevic@redhat.com>
Cc: Stephen Hemminger <stephen@networkplumber.org>
Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Cong Wang <amwang@redhat.com>

---
diff --git a/include/uapi/linux/if_bridge.h b/include/uapi/linux/if_bridge.h
index f1bf8d3..2d70d79 100644
--- a/include/uapi/linux/if_bridge.h
+++ b/include/uapi/linux/if_bridge.h
@@ -124,8 +124,8 @@ enum {
 #define BRIDGE_VLAN_INFO_UNTAGGED	(1<<2)	/* VLAN egresses untagged */
 
 struct bridge_vlan_info {
-	u16 flags;
-	u16 vid;
+	__u16 flags;
+	__u16 vid;
 };
 
 /* Bridge multicast database attributes

^ permalink raw reply related

* [PATCH] bgmac: add read of interrupt mask after disabling interrupts
From: Nathan Hintz @ 2013-02-14  5:14 UTC (permalink / raw)
  To: davem; +Cc: netdev, hauke, zajec5, Nathan Hintz

The specs prescribe an immediate read of the interrupt mask after
disabling interrupts.  This patch updates the driver to match the
specs.

Signed-off-by: Nathan Hintz <nlhintz@hotmail.com>
---
 drivers/net/ethernet/broadcom/bgmac.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bgmac.c b/drivers/net/ethernet/broadcom/bgmac.c
index 52d9a54..d341090 100644
--- a/drivers/net/ethernet/broadcom/bgmac.c
+++ b/drivers/net/ethernet/broadcom/bgmac.c
@@ -974,6 +974,7 @@ static void bgmac_chip_intrs_on(struct bgmac *bgmac)
 static void bgmac_chip_intrs_off(struct bgmac *bgmac)
 {
 	bgmac_write(bgmac, BGMAC_INT_MASK, 0);
+	bgmac_read(bgmac, BGMAC_INT_MASK);
 }
 
 /* http://bcm-v4.sipsolutions.net/mac-gbit/gmac/gmac_enable */
-- 
1.7.7.6

^ permalink raw reply related

* Re: [PATCH net-next 2/3] ipv6: use newly introduced __ipv6_addr_needs_scope_id and ipv6_iface_scope_id
From: Hannes Frederic Sowa @ 2013-02-14  4:25 UTC (permalink / raw)
  To: YOSHIFUJI Hideaki; +Cc: Brian Haley, netdev
In-Reply-To: <511BC3B3.3070405@linux-ipv6.org>

On Thu, Feb 14, 2013 at 01:47:47AM +0900, YOSHIFUJI Hideaki wrote:
> If you have several address checks around, please use ipv6_addr_type()
> (or __ipv6_addr_type()).  Above "direct" checks should be used only for
> single-shot test.  But well, I have to agree that ipv6_addr_type and
> friends is becoming complex.  In mid-term, I would like to take look
> at it.  I might think of having addr_type for src/dst in skb->cb
> after all.

What do you think about the attached patch?  If you agree with the changes I
would test it tomorrow and rebase my other patches ontop. The changes are only
compile tested.

[PATCH net-next RFC] ipv6: introduce new type ipv6_addr_props to hold type and scope

---
 include/net/ipv6.h       | 16 +++++---
 net/ipv6/addrconf.c      | 27 +++++++-------
 net/ipv6/addrconf_core.c | 97 +++++++++++++++++++++++++++++++-----------------
 net/ipv6/datagram.c      | 12 +++---
 4 files changed, 95 insertions(+), 57 deletions(-)

diff --git a/include/net/ipv6.h b/include/net/ipv6.h
index 851d541..3a3ec1cc 100644
--- a/include/net/ipv6.h
+++ b/include/net/ipv6.h
@@ -298,20 +298,26 @@ static inline int ip6_frag_mem(struct net *net)
 #define IPV6_FRAG_LOW_THRESH	(3 * 1024*1024)	/* 3145728 */
 #define IPV6_FRAG_TIMEOUT	(60 * HZ)	/* 60 seconds */
 
-extern int __ipv6_addr_type(const struct in6_addr *addr);
+struct ipv6_addr_props {
+	u16 type;
+	s16 scope;
+};
+
+extern struct ipv6_addr_props __ipv6_addr_type(const struct in6_addr *addr);
 static inline int ipv6_addr_type(const struct in6_addr *addr)
 {
-	return __ipv6_addr_type(addr) & 0xffff;
+	return __ipv6_addr_type(addr).type;
 }
 
 static inline int ipv6_addr_scope(const struct in6_addr *addr)
 {
-	return __ipv6_addr_type(addr) & IPV6_ADDR_SCOPE_MASK;
+	return __ipv6_addr_type(addr).scope;
 }
 
-static inline int __ipv6_addr_src_scope(int type)
+static inline int __ipv6_addr_src_scope(struct ipv6_addr_props props)
 {
-	return (type == IPV6_ADDR_ANY) ? __IPV6_ADDR_SCOPE_INVALID : (type >> 16);
+	return (props.type == IPV6_ADDR_ANY) ?
+		__IPV6_ADDR_SCOPE_INVALID : props.scope;
 }
 
 static inline int ipv6_addr_src_scope(const struct in6_addr *addr)
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 86c235d..f9adec4 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -1106,7 +1106,7 @@ enum {
 
 struct ipv6_saddr_score {
 	int			rule;
-	int			addr_type;
+	struct ipv6_addr_props	addr_props;
 	struct inet6_ifaddr	*ifa;
 	DECLARE_BITMAP(scorebits, IPV6_SADDR_RULE_MAX);
 	int			scopedist;
@@ -1180,7 +1180,7 @@ static int ipv6_get_saddr_eval(struct net *net,
 		 * C > d + 14 - B >= 15 + 14 - B = 29 - B.
 		 * Assume B = 0 and we get C > 29.
 		 */
-		ret = __ipv6_addr_src_scope(score->addr_type);
+		ret = __ipv6_addr_src_scope(score->addr_props);
 		if (ret >= dst->scope)
 			ret = -ret;
 		else
@@ -1189,8 +1189,9 @@ static int ipv6_get_saddr_eval(struct net *net,
 		break;
 	case IPV6_SADDR_RULE_PREFERRED:
 		/* Rule 3: Avoid deprecated and optimistic addresses */
-		ret = ipv6_saddr_preferred(score->addr_type) ||
-		      !(score->ifa->flags & (IFA_F_DEPRECATED|IFA_F_OPTIMISTIC));
+		ret = ipv6_saddr_preferred(score->addr_props.type) ||
+			!(score->ifa->flags &
+			  (IFA_F_DEPRECATED|IFA_F_OPTIMISTIC));
 		break;
 #ifdef CONFIG_IPV6_MIP6
 	case IPV6_SADDR_RULE_HOA:
@@ -1209,7 +1210,7 @@ static int ipv6_get_saddr_eval(struct net *net,
 	case IPV6_SADDR_RULE_LABEL:
 		/* Rule 6: Prefer matching label */
 		ret = ipv6_addr_label(net,
-				      &score->ifa->addr, score->addr_type,
+				      &score->ifa->addr, score->addr_props.type,
 				      score->ifa->idev->dev->ifindex) == dst->label;
 		break;
 #ifdef CONFIG_IPV6_PRIVACY
@@ -1258,13 +1259,12 @@ int ipv6_dev_get_saddr(struct net *net, const struct net_device *dst_dev,
 				*score = &scores[0], *hiscore = &scores[1];
 	struct ipv6_saddr_dst dst;
 	struct net_device *dev;
-	int dst_type;
+	struct ipv6_addr_props dst_props = __ipv6_addr_type(daddr);
 
-	dst_type = __ipv6_addr_type(daddr);
 	dst.addr = daddr;
 	dst.ifindex = dst_dev ? dst_dev->ifindex : 0;
-	dst.scope = __ipv6_addr_src_scope(dst_type);
-	dst.label = ipv6_addr_label(net, daddr, dst_type, dst.ifindex);
+	dst.scope = __ipv6_addr_src_scope(dst_props);
+	dst.label = ipv6_addr_label(net, daddr, dst_props.type, dst.ifindex);
 	dst.prefs = prefs;
 
 	hiscore->rule = -1;
@@ -1287,7 +1287,7 @@ int ipv6_dev_get_saddr(struct net *net, const struct net_device *dst_dev,
 		 *    belonging to the same site as the outgoing
 		 *    interface.)
 		 */
-		if (((dst_type & IPV6_ADDR_MULTICAST) ||
+		if ((dst_props.type & IPV6_ADDR_MULTICAST ||
 		     dst.scope <= IPV6_ADDR_SCOPE_LINKLOCAL) &&
 		    dst.ifindex && dev->ifindex != dst.ifindex)
 			continue;
@@ -1314,10 +1314,11 @@ int ipv6_dev_get_saddr(struct net *net, const struct net_device *dst_dev,
 			    (!(score->ifa->flags & IFA_F_OPTIMISTIC)))
 				continue;
 
-			score->addr_type = __ipv6_addr_type(&score->ifa->addr);
+			score->addr_props = __ipv6_addr_type(&score->ifa->addr);
 
-			if (unlikely(score->addr_type == IPV6_ADDR_ANY ||
-				     score->addr_type & IPV6_ADDR_MULTICAST)) {
+			if (unlikely(score->addr_props.type == IPV6_ADDR_ANY ||
+				     score->addr_props.type &
+				     IPV6_ADDR_MULTICAST)) {
 				LIMIT_NETDEBUG(KERN_DEBUG
 					       "ADDRCONF: unspecified / multicast address "
 					       "assigned as unicast address on %s",
diff --git a/net/ipv6/addrconf_core.c b/net/ipv6/addrconf_core.c
index d051e5f..cb3eb1d 100644
--- a/net/ipv6/addrconf_core.c
+++ b/net/ipv6/addrconf_core.c
@@ -6,75 +6,104 @@
 #include <linux/export.h>
 #include <net/ipv6.h>
 
-#define IPV6_ADDR_SCOPE_TYPE(scope)	((scope) << 16)
-
-static inline unsigned int ipv6_addr_scope2type(unsigned int scope)
+static inline struct ipv6_addr_props ipv6_addr_scope2type(unsigned int scope)
 {
 	switch (scope) {
 	case IPV6_ADDR_SCOPE_NODELOCAL:
-		return (IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_NODELOCAL) |
-			IPV6_ADDR_LOOPBACK);
+		return (struct ipv6_addr_props){
+			.type = IPV6_ADDR_MULTICAST|IPV6_ADDR_LOOPBACK,
+			.scope = IPV6_ADDR_SCOPE_NODELOCAL
+		};
 	case IPV6_ADDR_SCOPE_LINKLOCAL:
-		return (IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_LINKLOCAL) |
-			IPV6_ADDR_LINKLOCAL);
+		return (struct ipv6_addr_props){
+			.type = IPV6_ADDR_MULTICAST|IPV6_ADDR_LINKLOCAL,
+			.scope = IPV6_ADDR_SCOPE_LINKLOCAL
+		};
 	case IPV6_ADDR_SCOPE_SITELOCAL:
-		return (IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_SITELOCAL) |
-			IPV6_ADDR_SITELOCAL);
+		return (struct ipv6_addr_props){
+			.type = IPV6_ADDR_MULTICAST|IPV6_ADDR_SITELOCAL,
+			.scope = IPV6_ADDR_SCOPE_SITELOCAL
+		};
 	}
-	return IPV6_ADDR_SCOPE_TYPE(scope);
+	return (struct ipv6_addr_props){
+		.type = IPV6_ADDR_MULTICAST,
+		.scope = scope
+	};
 }
 
-int __ipv6_addr_type(const struct in6_addr *addr)
+struct ipv6_addr_props __ipv6_addr_type(const struct in6_addr *addr)
 {
-	__be32 st;
-
-	st = addr->s6_addr32[0];
+	__be32 st = addr->s6_addr32[0];
 
 	/* Consider all addresses with the first three bits different of
 	   000 and 111 as unicasts.
 	 */
 	if ((st & htonl(0xE0000000)) != htonl(0x00000000) &&
 	    (st & htonl(0xE0000000)) != htonl(0xE0000000))
-		return (IPV6_ADDR_UNICAST |
-			IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_GLOBAL));
+		return (struct ipv6_addr_props){
+			.type = IPV6_ADDR_UNICAST,
+			.scope = IPV6_ADDR_SCOPE_GLOBAL
+		};
 
 	if ((st & htonl(0xFF000000)) == htonl(0xFF000000)) {
 		/* multicast */
 		/* addr-select 3.1 */
-		return (IPV6_ADDR_MULTICAST |
-			ipv6_addr_scope2type(IPV6_ADDR_MC_SCOPE(addr)));
+		return ipv6_addr_scope2type(IPV6_ADDR_MC_SCOPE(addr));
 	}
 
 	if ((st & htonl(0xFFC00000)) == htonl(0xFE800000))
-		return (IPV6_ADDR_LINKLOCAL | IPV6_ADDR_UNICAST |
-			IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_LINKLOCAL));		/* addr-select 3.1 */
+		/* addr-select 3.1 */
+		return (struct ipv6_addr_props){
+			.type = IPV6_ADDR_LINKLOCAL|IPV6_ADDR_UNICAST,
+			.scope = IPV6_ADDR_SCOPE_LINKLOCAL
+		};
 	if ((st & htonl(0xFFC00000)) == htonl(0xFEC00000))
-		return (IPV6_ADDR_SITELOCAL | IPV6_ADDR_UNICAST |
-			IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_SITELOCAL));		/* addr-select 3.1 */
+		/* addr-select 3.1 */
+		return (struct ipv6_addr_props){
+			.type = IPV6_ADDR_LINKLOCAL|IPV6_ADDR_UNICAST,
+			.scope = IPV6_ADDR_SCOPE_SITELOCAL,
+		};
 	if ((st & htonl(0xFE000000)) == htonl(0xFC000000))
-		return (IPV6_ADDR_UNICAST |
-			IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_GLOBAL));			/* RFC 4193 */
+		/* RFC 4193 */
+		return (struct ipv6_addr_props){
+			.type = IPV6_ADDR_UNICAST,
+			.scope = IPV6_ADDR_SCOPE_GLOBAL,
+		};
 
 	if ((addr->s6_addr32[0] | addr->s6_addr32[1]) == 0) {
 		if (addr->s6_addr32[2] == 0) {
 			if (addr->s6_addr32[3] == 0)
-				return IPV6_ADDR_ANY;
+				return (struct ipv6_addr_props){
+					.type = IPV6_ADDR_ANY
+				};
 
 			if (addr->s6_addr32[3] == htonl(0x00000001))
-				return (IPV6_ADDR_LOOPBACK | IPV6_ADDR_UNICAST |
-					IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_LINKLOCAL));	/* addr-select 3.4 */
+				/* addr-select 3.4 */
+				return (struct ipv6_addr_props){
+					.type = IPV6_ADDR_LOOPBACK|
+						IPV6_ADDR_UNICAST,
+					.scope = IPV6_ADDR_SCOPE_LINKLOCAL
+				};
 
-			return (IPV6_ADDR_COMPATv4 | IPV6_ADDR_UNICAST |
-				IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_GLOBAL));	/* addr-select 3.3 */
+			/* addr-select 3.3 */
+			return (struct ipv6_addr_props){
+				.type = IPV6_ADDR_COMPATv4|IPV6_ADDR_UNICAST,
+				.scope = IPV6_ADDR_SCOPE_GLOBAL
+			};
 		}
 
 		if (addr->s6_addr32[2] == htonl(0x0000ffff))
-			return (IPV6_ADDR_MAPPED |
-				IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_GLOBAL));	/* addr-select 3.3 */
+			/* addr-select 3.3 */
+			return (struct ipv6_addr_props){
+				.type = IPV6_ADDR_MAPPED,
+					.scope = IPV6_ADDR_SCOPE_GLOBAL
+					};
 	}
 
-	return (IPV6_ADDR_UNICAST |
-		IPV6_ADDR_SCOPE_TYPE(IPV6_ADDR_SCOPE_GLOBAL));	/* addr-select 3.4 */
+	/* addr-select 3.4 */
+	return (struct ipv6_addr_props){
+		.type = IPV6_ADDR_UNICAST,
+		.scope = IPV6_ADDR_SCOPE_GLOBAL
+	};
 }
 EXPORT_SYMBOL(__ipv6_addr_type);
-
diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
index f5a5478..e859899 100644
--- a/net/ipv6/datagram.c
+++ b/net/ipv6/datagram.c
@@ -614,7 +614,7 @@ int ip6_datagram_send_ctl(struct net *net, struct sock *sk,
 	int err = 0;
 
 	for (cmsg = CMSG_FIRSTHDR(msg); cmsg; cmsg = CMSG_NXTHDR(msg, cmsg)) {
-		int addr_type;
+		struct ipv6_addr_props addr_props;
 
 		if (!CMSG_OK(msg, cmsg)) {
 			err = -EINVAL;
@@ -644,7 +644,7 @@ int ip6_datagram_send_ctl(struct net *net, struct sock *sk,
 				fl6->flowi6_oif = src_info->ipi6_ifindex;
 			}
 
-			addr_type = __ipv6_addr_type(&src_info->ipi6_addr);
+			addr_props = __ipv6_addr_type(&src_info->ipi6_addr);
 
 			rcu_read_lock();
 			if (fl6->flowi6_oif) {
@@ -653,13 +653,15 @@ int ip6_datagram_send_ctl(struct net *net, struct sock *sk,
 					rcu_read_unlock();
 					return -ENODEV;
 				}
-			} else if (addr_type & IPV6_ADDR_LINKLOCAL) {
+			} else if (addr_props.type & IPV6_ADDR_LINKLOCAL) {
 				rcu_read_unlock();
 				return -EINVAL;
 			}
 
-			if (addr_type != IPV6_ADDR_ANY) {
-				int strict = __ipv6_addr_src_scope(addr_type) <= IPV6_ADDR_SCOPE_LINKLOCAL;
+			if (addr_props.type != IPV6_ADDR_ANY) {
+				int strict =
+					__ipv6_addr_src_scope(addr_props) <=
+					IPV6_ADDR_SCOPE_LINKLOCAL;
 				if (!(inet_sk(sk)->freebind || inet_sk(sk)->transparent) &&
 				    !ipv6_chk_addr(net, &src_info->ipi6_addr,
 						   strict ? dev : NULL, 0))
-- 
1.8.1.2

^ permalink raw reply related

* Re: [PATCH v3] net: sh_eth: Add support of device tree probe
From: Kuninori Morimoto @ 2013-02-14  3:41 UTC (permalink / raw)
  To: Nobuhiro Iwamatsu
  Cc: netdev, horms+renesas, magnus.damm, devicetree-discuss, kda
In-Reply-To: <1360811995-332-1-git-send-email-nobuhiro.iwamatsu.yj@renesas.com>


Hey

> This adds support of device tree probe for Renesas sh-ether driver.
> 
> Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
> 
> V3: - Removed sentnece of "needs-init" from document.
> V2: - Removed ether_setup().
>     - Fixed typo from "sh-etn" to "sh-eth".
> 	- Removed "needs-init" and sh-eth,endian from definition of DT.
> 	- Changed "sh-eth,edmac-endian" instead of "sh-eth,edmac-big-endain"
> 	  in definition of DT.

Did you read my feedback email ??

Best regards
---
Kuninori Morimoto

^ permalink raw reply

* Re: [PATCH 1/1] VSOCK: Introduce VM Sockets
From: Andy King @ 2013-02-14  3:20 UTC (permalink / raw)
  To: Gerd Hoffmann
  Cc: pv-drivers, netdev, linux-kernel, virtualization, gregkh, davem
In-Reply-To: <511B739C.8000204@redhat.com>

> I've seen you have a notify_ops in the vmci bits.  Do you have different
> notify ops depending on socket type or something?  Does it make sense to
> move the notify ops ptr into "struct vsock_sock" maybe?

The notify stuff only applies to STREAMs.  However, we have two different
notify impls, one for legacy ESX and one for newer, and we figure out at
runtime which protocol we're using with the hypervisor and set the
callbacks appropriately.  The difference between the two is that the
newer one is much smarter and knows not to signal (the peer) quite so much,
i.e., it has some basic but sensible flow-control, which improves
performance quite a bit.  Again, that might not make any sense at all
for virtio.  Do you need to signal when you enqueue to a ring?  And is
there coalescing?  Dunno...

> And can we make it optional please (i.e. allow the function pointers to
> be NULL)?

They were originally allowed to be NULL, but I changed it in the last
round of patches while moving them into the transport, since I disliked
the NULL checks so much.  I can put them back, but that's a bigger
change, and I'm not sure we want to push large patches to Dave right
now :)

> Which problem you are trying to tackle with the notifications?

It's to do with signaling the peer, or more appropriately, trying to
avoid signaling the peer when possible.  The naive impl. is to signal
every time we enqueue or dequeue data (into our VMCI queuepairs).
But signaling is slow, since it involves a world exit, so we prefer
not to.  Which means we need to keep track of rate of flow and figure
out when we should and should not, and that's what all the notification
stuff does.  It's...ugly...

> > For the VMCI transport, it indicates if the underlying queuepair is
> > still around (i.e., make sure we haven't torn it down while sleeping
> > in a blocking send or receive).  Perhaps it's not the best name?
> 
> How you'd hit that?  Peer closing the socket while sleeping?  Other
> thread closing the socket wile sleeping?  Both?
> 
> I think a state field in struct vsock_sock would be a better solution here.

Hrm, lemme think about this one.

> 
> >> What is *_allow?
> > 
> > It's very basic filtering.  We have specific addresses that we don't
> > allow, and we look for them in the allow() functions.  You can just
> > return true if you like.
> 
> Can we make those calls optional too please?

Sure.

> The notify_*_init could return a opaque pointer instead.  But then
> you'll need a notify_*_free too.  And you can't place it on the stack
> and thus have a allocation in the hot path, which I guess you are trying
> to avoid in the first place.

Avoiding allocation is good, but at the same time, I wonder if it's not
a big deal compared with the time spent copying out of the buffers, in
which case it won't matter.  So maybe we can do this.

Thanks!
- Andy

^ permalink raw reply

* [PATCH v3] net: sh_eth: Add support of device tree probe
From: Nobuhiro Iwamatsu @ 2013-02-14  3:19 UTC (permalink / raw)
  To: netdev
  Cc: horms+renesas, magnus.damm, devicetree-discuss, kda,
	Nobuhiro Iwamatsu

This adds support of device tree probe for Renesas sh-ether driver.

Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>

V3: - Removed sentnece of "needs-init" from document.
V2: - Removed ether_setup().
    - Fixed typo from "sh-etn" to "sh-eth".
	- Removed "needs-init" and sh-eth,endian from definition of DT.
	- Changed "sh-eth,edmac-endian" instead of "sh-eth,edmac-big-endain"
	  in definition of DT.
---
 Documentation/devicetree/bindings/net/sh_ether.txt |   39 +++++
 drivers/net/ethernet/renesas/sh_eth.c              |  156 +++++++++++++++++---
 2 files changed, 171 insertions(+), 24 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/sh_ether.txt

diff --git a/Documentation/devicetree/bindings/net/sh_ether.txt b/Documentation/devicetree/bindings/net/sh_ether.txt
new file mode 100644
index 0000000..f20d66a
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/sh_ether.txt
@@ -0,0 +1,39 @@
+* Renesas Electronics SuperH EMAC
+
+This file provides information, what the device node
+for the sh_eth interface contains.
+
+Required properties:
+- compatible:                   "renesas,sh-eth";
+- interrupt-parent:             The phandle for the interrupt controller that
+                                services interrupts for this device.
+- reg:                          Offset and length of the register set for the
+                                device.
+- interrupts:                   Interrupt mapping for the sh_eth interrupt
+                                sources (vector id).
+- phy-mode:                     String, operation mode of the PHY interface.
+- sh-eth,register-type:         String, register type of sh_eth.
+                                Please select "gigabit", "fast-sh4" or
+                                "fast-sh3-sh2".
+- sh-eth,phy-id:                PHY id.
+
+Optional properties:
+- local-mac-address:            6 bytes, mac address
+- sh-eth,no-ether-link:         Set link control by software. When device does
+                                not support ether-link, set.
+- sh-eth,ether-link-active-low: Set link check method.
+                                When detection of link is treated as active-low,
+                                set.
+- sh-eth,edmac-big-endian:      Set big endian for sh_eth dmac.
+                                It work as little endian when this is not set. 
+
+Example (armadillo800eva):
+	sh-eth@e9a00000 {
+		compatible = "renesas,sh-eth";
+		interrupt-parent = <&intca>;
+		reg = <0xe9a00000 0x800>, <0xe9a01800 0x800>;
+		interrupts = <0x500>;
+		phy-mode = "mii";
+		sh-eth,register-type = "gigabit";
+		sh-eth,phy-id = <0>;
+	};
diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
index 3d70586..15e50b87 100644
--- a/drivers/net/ethernet/renesas/sh_eth.c
+++ b/drivers/net/ethernet/renesas/sh_eth.c
@@ -1,7 +1,7 @@
 /*
  *  SuperH Ethernet device driver
  *
- *  Copyright (C) 2006-2012 Nobuhiro Iwamatsu
+ *  Copyright (C) 2006-2013 Nobuhiro Iwamatsu
  *  Copyright (C) 2008-2012 Renesas Solutions Corp.
  *
  *  This program is free software; you can redistribute it and/or modify it
@@ -31,6 +31,12 @@
 #include <linux/platform_device.h>
 #include <linux/mdio-bitbang.h>
 #include <linux/netdevice.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/of_platform.h>
+#include <linux/of_address.h>
+#include <linux/of_irq.h>
+#include <linux/of_net.h>
 #include <linux/phy.h>
 #include <linux/cache.h>
 #include <linux/io.h>
@@ -2347,26 +2353,109 @@ static const struct net_device_ops sh_eth_netdev_ops = {
 	.ndo_change_mtu		= eth_change_mtu,
 };
 
+#ifdef CONFIG_OF
+
+static int
+sh_eth_of_get_register_type(struct device_node *np)
+{
+	const char *of_str;
+	int ret = of_property_read_string(np, "sh-eth,register-type", &of_str);
+	if (ret)
+		return ret;
+
+	if (of_str && !strcmp(of_str, "gigabit"))
+		return SH_ETH_REG_GIGABIT;
+
+	else if (of_str && !strcmp(of_str, "fast-sh4"))
+		return SH_ETH_REG_FAST_SH4;
+	else if (of_str && !strcmp(of_str, "fast-sh3-sh2"))
+		return SH_ETH_REG_FAST_SH3_SH2;
+	else
+		return -EINVAL;
+}
+
+static struct sh_eth_plat_data *
+sh_eth_parse_dt(struct device *dev, struct net_device *ndev)
+{
+	int ret;
+	struct device_node *np = dev->of_node;
+	struct sh_eth_plat_data *pdata;
+
+	pdata = devm_kzalloc(dev, sizeof(struct sh_eth_plat_data),
+					GFP_KERNEL);
+	if (!pdata) {
+		dev_err(dev, "%s: failed to allocate config data\n", __func__);
+		return NULL;
+	}
+
+	pdata->phy_interface = of_get_phy_mode(np);
+
+	of_property_read_u32(np, "sh-eth,phy-id", &pdata->phy);
+
+	if (of_find_property(np, "sh-eth,edmac-big-endian", NULL))
+		pdata->edmac_endian = EDMAC_BIG_ENDIAN;
+	else
+		pdata->edmac_endian = EDMAC_LITTLE_ENDIAN;
+
+	if (of_find_property(np, "sh-eth,no-ether-link", NULL))
+		pdata->no_ether_link = 1;
+	else
+		pdata->no_ether_link = 0;
+
+	if (of_find_property(np, "sh-eth,ether-link-active-low", NULL))
+		pdata->ether_link_active_low = 1;
+	else
+		pdata->ether_link_active_low = 0;
+
+	ret = sh_eth_of_get_register_type(np);
+	if (ret < 0)
+		goto error;
+	pdata->register_type = ret;
+
+#ifdef CONFIG_OF_NET
+	if (!is_valid_ether_addr(ndev->dev_addr)) {
+		const char *macaddr = of_get_mac_address(np);
+		if (macaddr)
+			memcpy(pdata->mac_addr, macaddr, ETH_ALEN);
+	}
+#endif
+
+	return pdata;
+
+error:
+	devm_kfree(dev, pdata);
+	return NULL;
+}
+#else
+static struct sh_eth_plat_data *
+sh_eth_parse_dt(struct device *dev, struct net_device *ndev)
+{
+	return NULL;
+}
+#endif
+
 static int sh_eth_drv_probe(struct platform_device *pdev)
 {
-	int ret, devno = 0;
+	int ret = 0, devno = 0;
 	struct resource *res;
 	struct net_device *ndev = NULL;
 	struct sh_eth_private *mdp = NULL;
 	struct sh_eth_plat_data *pd;
+	struct device_node *np = pdev->dev.of_node;
+
+	ndev = alloc_etherdev(sizeof(struct sh_eth_private));
+	if (!ndev) {
+		ret = -ENOMEM;
+		goto out;
+	}
 
+	mdp = netdev_priv(ndev);
 	/* get base addr */
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (unlikely(res == NULL)) {
 		dev_err(&pdev->dev, "invalid resource\n");
 		ret = -EINVAL;
-		goto out;
-	}
-
-	ndev = alloc_etherdev(sizeof(struct sh_eth_private));
-	if (!ndev) {
-		ret = -ENOMEM;
-		goto out;
+		goto out_release;
 	}
 
 	/* The sh Ether-specific entries in the device structure. */
@@ -2383,27 +2472,41 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
 	}
 	ndev->irq = ret;
 
-	SET_NETDEV_DEV(ndev, &pdev->dev);
-
-	/* Fill in the fields of the device structure with ethernet values. */
-	ether_setup(ndev);
-
-	mdp = netdev_priv(ndev);
-	mdp->num_tx_ring = TX_RING_SIZE;
-	mdp->num_rx_ring = RX_RING_SIZE;
 	mdp->addr = ioremap(res->start, resource_size(res));
 	if (mdp->addr == NULL) {
 		ret = -ENOMEM;
 		dev_err(&pdev->dev, "ioremap failed.\n");
 		goto out_release;
 	}
+#ifdef CONFIG_OF
+	if (np && of_device_is_available(np)) {
+		pd = sh_eth_parse_dt(&pdev->dev, ndev);
+		if (pdev->dev.platform_data) {
+			struct sh_eth_plat_data *tmp =
+				pdev->dev.platform_data;
+			pd->set_mdio_gate = tmp->set_mdio_gate;
+			pd->needs_init = tmp->needs_init;
+		}
+	} else
+#endif
+		pd = (struct sh_eth_plat_data *)(pdev->dev.platform_data);
+	
+	if (!pd) {
+		dev_err(&pdev->dev, "no setup data defined\n");
+		ret = -EINVAL;
+		goto out_release;
+	}
+
+	SET_NETDEV_DEV(ndev, &pdev->dev);
+
+	mdp->num_tx_ring = TX_RING_SIZE;
+	mdp->num_rx_ring = RX_RING_SIZE;
 
 	spin_lock_init(&mdp->lock);
 	mdp->pdev = pdev;
 	pm_runtime_enable(&pdev->dev);
 	pm_runtime_resume(&pdev->dev);
 
-	pd = (struct sh_eth_plat_data *)(pdev->dev.platform_data);
 	/* get PHY ID */
 	mdp->phy_id = pd->phy;
 	mdp->phy_interface = pd->phy_interface;
@@ -2412,6 +2515,8 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
 	mdp->no_ether_link = pd->no_ether_link;
 	mdp->ether_link_active_low = pd->ether_link_active_low;
 	mdp->reg_offset = sh_eth_get_register_offset(pd->register_type);
+	/* read and set MAC address */
+	read_mac_address(ndev, pd->mac_addr);
 
 	/* set cpu data */
 #if defined(SH_ETH_HAS_BOTH_MODULES)
@@ -2429,20 +2534,16 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
 	/* debug message level */
 	mdp->msg_enable = SH_ETH_DEF_MSG_ENABLE;
 
-	/* read and set MAC address */
-	read_mac_address(ndev, pd->mac_addr);
-
 	/* ioremap the TSU registers */
 	if (mdp->cd->tsu) {
 		struct resource *rtsu;
 		rtsu = platform_get_resource(pdev, IORESOURCE_MEM, 1);
 		if (!rtsu) {
 			dev_err(&pdev->dev, "Not found TSU resource\n");
-			ret = -ENODEV;
 			goto out_release;
 		}
 		mdp->tsu_addr = ioremap(rtsu->start,
-					resource_size(rtsu));
+				resource_size(rtsu));
 		mdp->port = devno % 2;
 		ndev->features = NETIF_F_HW_VLAN_FILTER;
 	}
@@ -2522,17 +2623,24 @@ static int sh_eth_runtime_nop(struct device *dev)
 	return 0;
 }
 
-static struct dev_pm_ops sh_eth_dev_pm_ops = {
+static const struct dev_pm_ops sh_eth_dev_pm_ops = {
 	.runtime_suspend = sh_eth_runtime_nop,
 	.runtime_resume = sh_eth_runtime_nop,
 };
 
+static struct of_device_id sh_eth_match[] = {
+	{ .compatible = "renesas,sh-eth",},
+	{},
+};
+MODULE_DEVICE_TABLE(of, sh_eth_match);
+
 static struct platform_driver sh_eth_driver = {
 	.probe = sh_eth_drv_probe,
 	.remove = sh_eth_drv_remove,
 	.driver = {
 		   .name = CARDNAME,
 		   .pm = &sh_eth_dev_pm_ops,
+		   .of_match_table = sh_eth_match,
 	},
 };
 
-- 
1.7.10.4

^ permalink raw reply related

* Re: [PATCHi v2] net: sh_eth: Add support of device tree probe
From: Nobuhiro Iwamatsu @ 2013-02-14  3:18 UTC (permalink / raw)
  To: Magnus Damm; +Cc: netdev, devicetree-discuss, kda, horms+renesas
In-Reply-To: <CANqRtoQ_+eZFc-n0juBQP+BofR-bmVmEW_aVZdDP-vyr_aW5Kw@mail.gmail.com>

On Thu, Feb 14, 2013 at 10:47 AM, Magnus Damm <magnus.damm@gmail.com> wrote:
> Hi Iwamatsu-san,
>
> On Thu, Feb 14, 2013 at 9:51 AM, Nobuhiro Iwamatsu
> <nobuhiro.iwamatsu.yj@renesas.com> wrote:
>> This adds support of device tree probe for Renesas sh-ether driver.
>>
>> Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
>>
>> ---
>> V2: - Removed ether_setup().
>>     - Fixed typo from "sh-etn" to "sh-eth".
>>         - Removed "needs-init" and sh-eth,endian from definition of DT.
>>         - Changed "sh-eth,edmac-endian" instead of "sh-eth,edmac-big-endain"
>>           in definition of DT.
>>
>>  Documentation/devicetree/bindings/net/sh_ether.txt |   41 +++++
>>  drivers/net/ethernet/renesas/sh_eth.c              |  156 +++++++++++++++++---
>>  2 files changed, 173 insertions(+), 24 deletions(-)
>>  create mode 100644 Documentation/devicetree/bindings/net/sh_ether.txt
>>
>> diff --git a/Documentation/devicetree/bindings/net/sh_ether.txt b/Documentation/devicetree/bindings/net/sh_ether.txt
>> new file mode 100644
>> index 0000000..7415e54
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/net/sh_ether.txt
>> @@ -0,0 +1,41 @@
>> +* Renesas Electronics SuperH EMAC
>> +
>> +This file provides information, what the device node
>> +for the sh_eth interface contains.
>> +
>> +Required properties:
>> +- compatible:                   "renesas,sh-eth";
>> +- interrupt-parent:             The phandle for the interrupt controller that
>> +                                services interrupts for this device.
>> +- reg:                          Offset and length of the register set for the
>> +                                device.
>> +- interrupts:                   Interrupt mapping for the sh_eth interrupt
>> +                                sources (vector id).
>> +- phy-mode:                     String, operation mode of the PHY interface.
>> +- sh-eth,register-type:         String, register type of sh_eth.
>> +                                Please select "gigabit", "fast-sh4" or
>> +                                "fast-sh3-sh2".
>> +- sh-eth,phy-id:                PHY id.
>> +
>> +Optional properties:
>> +- local-mac-address:            6 bytes, mac address
>> +- sh-eth,no-ether-link:         Set link control by software. When device does
>> +                                not support ether-link, set.
>> +- sh-eth,ether-link-active-low: Set link check method.
>> +                                When detection of link is treated as active-low,
>> +                                set.
>> +- sh-eth,edmac-big-endian:      Set big endian for sh_eth dmac.
>> +                                It work as little endian when this is not set.
>> +- sh-etn,needs-init:            Initialization flag.
>> +                                When initialize device in probing device, set.
>
> I believe the above still says "sh-etn". Also, it is unclear why you
> want this flag at all since it is not used to describe the hardware.
>

yes, I forgot to delete this.
I will fix.

regards,
  Nobuhiro

-- 
Nobuhiro Iwamatsu

^ permalink raw reply

* Re: [PATCH 1/1] VSOCK: Introduce VM Sockets
From: Andy King @ 2013-02-14  3:07 UTC (permalink / raw)
  To: Gerd Hoffmann
  Cc: pv-drivers, netdev, linux-kernel, virtualization, gregkh, davem
In-Reply-To: <511B8AAF.2060202@redhat.com>

> > +	if (protocol)
> > +		return -EPROTONOSUPPORT;
> > +
> 
> IMO protocol == PF_VSOCK should not get rejected here.

Agreed, let me fix that too.

Thanks!
- Andy

^ permalink raw reply

* Re: From Capt: Mohamed Habbash
From: Capt:Mohamed Habbash @ 2013-02-14  1:51 UTC (permalink / raw)



Assalamu'alaikum, wr,wb.,
Attn:Dear,
I am, Capt: Mohamed Habbash, am seeking for an Agent in your country to transfer $10.3Million US Dollars for investment get back for more Detail, if interested.

^ permalink raw reply

* Re: [PATCHi v2] net: sh_eth: Add support of device tree probe
From: Magnus Damm @ 2013-02-14  1:47 UTC (permalink / raw)
  To: Nobuhiro Iwamatsu; +Cc: netdev, horms+renesas, devicetree-discuss, kda
In-Reply-To: <1360803091-26400-1-git-send-email-nobuhiro.iwamatsu.yj@renesas.com>

Hi Iwamatsu-san,

On Thu, Feb 14, 2013 at 9:51 AM, Nobuhiro Iwamatsu
<nobuhiro.iwamatsu.yj@renesas.com> wrote:
> This adds support of device tree probe for Renesas sh-ether driver.
>
> Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>
>
> ---
> V2: - Removed ether_setup().
>     - Fixed typo from "sh-etn" to "sh-eth".
>         - Removed "needs-init" and sh-eth,endian from definition of DT.
>         - Changed "sh-eth,edmac-endian" instead of "sh-eth,edmac-big-endain"
>           in definition of DT.
>
>  Documentation/devicetree/bindings/net/sh_ether.txt |   41 +++++
>  drivers/net/ethernet/renesas/sh_eth.c              |  156 +++++++++++++++++---
>  2 files changed, 173 insertions(+), 24 deletions(-)
>  create mode 100644 Documentation/devicetree/bindings/net/sh_ether.txt
>
> diff --git a/Documentation/devicetree/bindings/net/sh_ether.txt b/Documentation/devicetree/bindings/net/sh_ether.txt
> new file mode 100644
> index 0000000..7415e54
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/net/sh_ether.txt
> @@ -0,0 +1,41 @@
> +* Renesas Electronics SuperH EMAC
> +
> +This file provides information, what the device node
> +for the sh_eth interface contains.
> +
> +Required properties:
> +- compatible:                   "renesas,sh-eth";
> +- interrupt-parent:             The phandle for the interrupt controller that
> +                                services interrupts for this device.
> +- reg:                          Offset and length of the register set for the
> +                                device.
> +- interrupts:                   Interrupt mapping for the sh_eth interrupt
> +                                sources (vector id).
> +- phy-mode:                     String, operation mode of the PHY interface.
> +- sh-eth,register-type:         String, register type of sh_eth.
> +                                Please select "gigabit", "fast-sh4" or
> +                                "fast-sh3-sh2".
> +- sh-eth,phy-id:                PHY id.
> +
> +Optional properties:
> +- local-mac-address:            6 bytes, mac address
> +- sh-eth,no-ether-link:         Set link control by software. When device does
> +                                not support ether-link, set.
> +- sh-eth,ether-link-active-low: Set link check method.
> +                                When detection of link is treated as active-low,
> +                                set.
> +- sh-eth,edmac-big-endian:      Set big endian for sh_eth dmac.
> +                                It work as little endian when this is not set.
> +- sh-etn,needs-init:            Initialization flag.
> +                                When initialize device in probing device, set.

I believe the above still says "sh-etn". Also, it is unclear why you
want this flag at all since it is not used to describe the hardware.

Thanks,

/ magnus

^ permalink raw reply

* Re: [PATCHi v2] net: sh_eth: Add support of device tree probe
From: Kuninori Morimoto @ 2013-02-14  1:24 UTC (permalink / raw)
  To: Nobuhiro Iwamatsu
  Cc: netdev, horms+renesas, magnus.damm, devicetree-discuss, kda
In-Reply-To: <1360803091-26400-1-git-send-email-nobuhiro.iwamatsu.yj@renesas.com>


Hi Iwamatsu-san

Thank you for this patch.

Small comment from me

> +#ifdef CONFIG_OF
(snip)
> +sh_eth_parse_dt(struct device *dev, struct net_device *ndev)
> +{
> +	int ret;
> +	struct device_node *np = dev->of_node;
> +	struct sh_eth_plat_data *pdata;
...
> +#else
> +static struct sh_eth_plat_data *
> +sh_eth_parse_dt(struct device *dev, struct net_device *ndev)
> +{
> +	return NULL;
> +}
> +#endif

(snip)

>  static int sh_eth_drv_probe(struct platform_device *pdev)
>  {
...
> +#ifdef CONFIG_OF
> +	if (np && of_device_is_available(np)) {
> +		pd = sh_eth_parse_dt(&pdev->dev, ndev);
> +		if (pdev->dev.platform_data) {
> +			struct sh_eth_plat_data *tmp =
> +				pdev->dev.platform_data;
> +			pd->set_mdio_gate = tmp->set_mdio_gate;
> +			pd->needs_init = tmp->needs_init;
> +		}
> +	} else
> +#endif

sh_eth_parse_dt() was defined for both CONFIG_OF and !CONFIG_OF.
But it is called only from CONFIG_OF ?

Best regards
---
Kuninori Morimoto

^ permalink raw reply

* Re: [PATCH v11 net-next 00/12] VLAN filtering/VLAN aware bridge
From: David Miller @ 2013-02-14  1:10 UTC (permalink / raw)
  To: vyasevic; +Cc: netdev, shemminger, bridge
In-Reply-To: <1360792820-14116-1-git-send-email-vyasevic@redhat.com>

From: Vlad Yasevich <vyasevic@redhat.com>
Date: Wed, 13 Feb 2013 17:00:08 -0500

> Vlad Yasevich (12):
>   bridge: Add vlan filtering infrastructure
>   bridge: Validate that vlan is permitted on ingress
>   bridge: Verify that a vlan is allowed to egress on given port
>   bridge: Add netlink interface to configure vlans on bridge ports
>   bridge: Dump vlan information from a bridge port
>   bridge: Implement vlan ingress/egress policy with PVID.
>   bridge: Add the ability to configure pvid
>   bridge: Add vlan to unicast fdb entries
>   bridge: Add vlan id to multicast groups
>   bridge: Add vlan support to static neighbors
>   bridge: Add vlan support for local fdb entries
>   bridge: Separate egress policy bitmap

Series applied, thanks Vlad.

^ permalink raw reply

* [PATCHi v2] net: sh_eth: Add support of device tree probe
From: Nobuhiro Iwamatsu @ 2013-02-14  0:51 UTC (permalink / raw)
  To: netdev
  Cc: horms+renesas, magnus.damm, devicetree-discuss, kda,
	Nobuhiro Iwamatsu

This adds support of device tree probe for Renesas sh-ether driver.

Signed-off-by: Nobuhiro Iwamatsu <nobuhiro.iwamatsu.yj@renesas.com>

---
V2: - Removed ether_setup().
    - Fixed typo from "sh-etn" to "sh-eth".
	- Removed "needs-init" and sh-eth,endian from definition of DT.
	- Changed "sh-eth,edmac-endian" instead of "sh-eth,edmac-big-endain"
	  in definition of DT.

 Documentation/devicetree/bindings/net/sh_ether.txt |   41 +++++
 drivers/net/ethernet/renesas/sh_eth.c              |  156 +++++++++++++++++---
 2 files changed, 173 insertions(+), 24 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/net/sh_ether.txt

diff --git a/Documentation/devicetree/bindings/net/sh_ether.txt b/Documentation/devicetree/bindings/net/sh_ether.txt
new file mode 100644
index 0000000..7415e54
--- /dev/null
+++ b/Documentation/devicetree/bindings/net/sh_ether.txt
@@ -0,0 +1,41 @@
+* Renesas Electronics SuperH EMAC
+
+This file provides information, what the device node
+for the sh_eth interface contains.
+
+Required properties:
+- compatible:                   "renesas,sh-eth";
+- interrupt-parent:             The phandle for the interrupt controller that
+                                services interrupts for this device.
+- reg:                          Offset and length of the register set for the
+                                device.
+- interrupts:                   Interrupt mapping for the sh_eth interrupt
+                                sources (vector id).
+- phy-mode:                     String, operation mode of the PHY interface.
+- sh-eth,register-type:         String, register type of sh_eth.
+                                Please select "gigabit", "fast-sh4" or
+                                "fast-sh3-sh2".
+- sh-eth,phy-id:                PHY id.
+
+Optional properties:
+- local-mac-address:            6 bytes, mac address
+- sh-eth,no-ether-link:         Set link control by software. When device does
+                                not support ether-link, set.
+- sh-eth,ether-link-active-low: Set link check method.
+                                When detection of link is treated as active-low,
+                                set.
+- sh-eth,edmac-big-endian:      Set big endian for sh_eth dmac.
+                                It work as little endian when this is not set. 
+- sh-etn,needs-init:            Initialization flag.
+                                When initialize device in probing device, set.
+
+Example (armadillo800eva):
+	sh-eth@e9a00000 {
+		compatible = "renesas,sh-eth";
+		interrupt-parent = <&intca>;
+		reg = <0xe9a00000 0x800>, <0xe9a01800 0x800>;
+		interrupts = <0x500>;
+		phy-mode = "mii";
+		sh-eth,register-type = "gigabit";
+		sh-eth,phy-id = <0>;
+	};
diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c
index 3d70586..15e50b87 100644
--- a/drivers/net/ethernet/renesas/sh_eth.c
+++ b/drivers/net/ethernet/renesas/sh_eth.c
@@ -1,7 +1,7 @@
 /*
  *  SuperH Ethernet device driver
  *
- *  Copyright (C) 2006-2012 Nobuhiro Iwamatsu
+ *  Copyright (C) 2006-2013 Nobuhiro Iwamatsu
  *  Copyright (C) 2008-2012 Renesas Solutions Corp.
  *
  *  This program is free software; you can redistribute it and/or modify it
@@ -31,6 +31,12 @@
 #include <linux/platform_device.h>
 #include <linux/mdio-bitbang.h>
 #include <linux/netdevice.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/of_platform.h>
+#include <linux/of_address.h>
+#include <linux/of_irq.h>
+#include <linux/of_net.h>
 #include <linux/phy.h>
 #include <linux/cache.h>
 #include <linux/io.h>
@@ -2347,26 +2353,109 @@ static const struct net_device_ops sh_eth_netdev_ops = {
 	.ndo_change_mtu		= eth_change_mtu,
 };
 
+#ifdef CONFIG_OF
+
+static int
+sh_eth_of_get_register_type(struct device_node *np)
+{
+	const char *of_str;
+	int ret = of_property_read_string(np, "sh-eth,register-type", &of_str);
+	if (ret)
+		return ret;
+
+	if (of_str && !strcmp(of_str, "gigabit"))
+		return SH_ETH_REG_GIGABIT;
+
+	else if (of_str && !strcmp(of_str, "fast-sh4"))
+		return SH_ETH_REG_FAST_SH4;
+	else if (of_str && !strcmp(of_str, "fast-sh3-sh2"))
+		return SH_ETH_REG_FAST_SH3_SH2;
+	else
+		return -EINVAL;
+}
+
+static struct sh_eth_plat_data *
+sh_eth_parse_dt(struct device *dev, struct net_device *ndev)
+{
+	int ret;
+	struct device_node *np = dev->of_node;
+	struct sh_eth_plat_data *pdata;
+
+	pdata = devm_kzalloc(dev, sizeof(struct sh_eth_plat_data),
+					GFP_KERNEL);
+	if (!pdata) {
+		dev_err(dev, "%s: failed to allocate config data\n", __func__);
+		return NULL;
+	}
+
+	pdata->phy_interface = of_get_phy_mode(np);
+
+	of_property_read_u32(np, "sh-eth,phy-id", &pdata->phy);
+
+	if (of_find_property(np, "sh-eth,edmac-big-endian", NULL))
+		pdata->edmac_endian = EDMAC_BIG_ENDIAN;
+	else
+		pdata->edmac_endian = EDMAC_LITTLE_ENDIAN;
+
+	if (of_find_property(np, "sh-eth,no-ether-link", NULL))
+		pdata->no_ether_link = 1;
+	else
+		pdata->no_ether_link = 0;
+
+	if (of_find_property(np, "sh-eth,ether-link-active-low", NULL))
+		pdata->ether_link_active_low = 1;
+	else
+		pdata->ether_link_active_low = 0;
+
+	ret = sh_eth_of_get_register_type(np);
+	if (ret < 0)
+		goto error;
+	pdata->register_type = ret;
+
+#ifdef CONFIG_OF_NET
+	if (!is_valid_ether_addr(ndev->dev_addr)) {
+		const char *macaddr = of_get_mac_address(np);
+		if (macaddr)
+			memcpy(pdata->mac_addr, macaddr, ETH_ALEN);
+	}
+#endif
+
+	return pdata;
+
+error:
+	devm_kfree(dev, pdata);
+	return NULL;
+}
+#else
+static struct sh_eth_plat_data *
+sh_eth_parse_dt(struct device *dev, struct net_device *ndev)
+{
+	return NULL;
+}
+#endif
+
 static int sh_eth_drv_probe(struct platform_device *pdev)
 {
-	int ret, devno = 0;
+	int ret = 0, devno = 0;
 	struct resource *res;
 	struct net_device *ndev = NULL;
 	struct sh_eth_private *mdp = NULL;
 	struct sh_eth_plat_data *pd;
+	struct device_node *np = pdev->dev.of_node;
+
+	ndev = alloc_etherdev(sizeof(struct sh_eth_private));
+	if (!ndev) {
+		ret = -ENOMEM;
+		goto out;
+	}
 
+	mdp = netdev_priv(ndev);
 	/* get base addr */
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	if (unlikely(res == NULL)) {
 		dev_err(&pdev->dev, "invalid resource\n");
 		ret = -EINVAL;
-		goto out;
-	}
-
-	ndev = alloc_etherdev(sizeof(struct sh_eth_private));
-	if (!ndev) {
-		ret = -ENOMEM;
-		goto out;
+		goto out_release;
 	}
 
 	/* The sh Ether-specific entries in the device structure. */
@@ -2383,27 +2472,41 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
 	}
 	ndev->irq = ret;
 
-	SET_NETDEV_DEV(ndev, &pdev->dev);
-
-	/* Fill in the fields of the device structure with ethernet values. */
-	ether_setup(ndev);
-
-	mdp = netdev_priv(ndev);
-	mdp->num_tx_ring = TX_RING_SIZE;
-	mdp->num_rx_ring = RX_RING_SIZE;
 	mdp->addr = ioremap(res->start, resource_size(res));
 	if (mdp->addr == NULL) {
 		ret = -ENOMEM;
 		dev_err(&pdev->dev, "ioremap failed.\n");
 		goto out_release;
 	}
+#ifdef CONFIG_OF
+	if (np && of_device_is_available(np)) {
+		pd = sh_eth_parse_dt(&pdev->dev, ndev);
+		if (pdev->dev.platform_data) {
+			struct sh_eth_plat_data *tmp =
+				pdev->dev.platform_data;
+			pd->set_mdio_gate = tmp->set_mdio_gate;
+			pd->needs_init = tmp->needs_init;
+		}
+	} else
+#endif
+		pd = (struct sh_eth_plat_data *)(pdev->dev.platform_data);
+	
+	if (!pd) {
+		dev_err(&pdev->dev, "no setup data defined\n");
+		ret = -EINVAL;
+		goto out_release;
+	}
+
+	SET_NETDEV_DEV(ndev, &pdev->dev);
+
+	mdp->num_tx_ring = TX_RING_SIZE;
+	mdp->num_rx_ring = RX_RING_SIZE;
 
 	spin_lock_init(&mdp->lock);
 	mdp->pdev = pdev;
 	pm_runtime_enable(&pdev->dev);
 	pm_runtime_resume(&pdev->dev);
 
-	pd = (struct sh_eth_plat_data *)(pdev->dev.platform_data);
 	/* get PHY ID */
 	mdp->phy_id = pd->phy;
 	mdp->phy_interface = pd->phy_interface;
@@ -2412,6 +2515,8 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
 	mdp->no_ether_link = pd->no_ether_link;
 	mdp->ether_link_active_low = pd->ether_link_active_low;
 	mdp->reg_offset = sh_eth_get_register_offset(pd->register_type);
+	/* read and set MAC address */
+	read_mac_address(ndev, pd->mac_addr);
 
 	/* set cpu data */
 #if defined(SH_ETH_HAS_BOTH_MODULES)
@@ -2429,20 +2534,16 @@ static int sh_eth_drv_probe(struct platform_device *pdev)
 	/* debug message level */
 	mdp->msg_enable = SH_ETH_DEF_MSG_ENABLE;
 
-	/* read and set MAC address */
-	read_mac_address(ndev, pd->mac_addr);
-
 	/* ioremap the TSU registers */
 	if (mdp->cd->tsu) {
 		struct resource *rtsu;
 		rtsu = platform_get_resource(pdev, IORESOURCE_MEM, 1);
 		if (!rtsu) {
 			dev_err(&pdev->dev, "Not found TSU resource\n");
-			ret = -ENODEV;
 			goto out_release;
 		}
 		mdp->tsu_addr = ioremap(rtsu->start,
-					resource_size(rtsu));
+				resource_size(rtsu));
 		mdp->port = devno % 2;
 		ndev->features = NETIF_F_HW_VLAN_FILTER;
 	}
@@ -2522,17 +2623,24 @@ static int sh_eth_runtime_nop(struct device *dev)
 	return 0;
 }
 
-static struct dev_pm_ops sh_eth_dev_pm_ops = {
+static const struct dev_pm_ops sh_eth_dev_pm_ops = {
 	.runtime_suspend = sh_eth_runtime_nop,
 	.runtime_resume = sh_eth_runtime_nop,
 };
 
+static struct of_device_id sh_eth_match[] = {
+	{ .compatible = "renesas,sh-eth",},
+	{},
+};
+MODULE_DEVICE_TABLE(of, sh_eth_match);
+
 static struct platform_driver sh_eth_driver = {
 	.probe = sh_eth_drv_probe,
 	.remove = sh_eth_drv_remove,
 	.driver = {
 		   .name = CARDNAME,
 		   .pm = &sh_eth_dev_pm_ops,
+		   .of_match_table = sh_eth_match,
 	},
 };
 
-- 
1.7.10.4

^ permalink raw reply related

* Re: decnet: /proc/sys/net/decnet sysctl entries disappear
From: Larry Baker @ 2013-02-14  0:50 UTC (permalink / raw)
  To: Eric Biederman; +Cc: netdev, decnet list
In-Reply-To: <877gmca8qb.fsf@xmission.com>

Eric,

(Sorry for the re-send.  I had to make up a new e-mail address book entry for you without your middle initial to pass through the vger.kernel.org e-mail filters.  Apple Mail shows me the enclosing quotes, but apparently doesn't actually insert them in the SMTP text.)

FYI.  My original post to netdev for this problem is at http://www.spinics.net/lists/netdev/msg225990.html.  Since then, I have focused on reporting and patching only the problem with the disappearing sysctl entries.  My follow-up post with the problem description is at http://www.spinics.net/lists/netdev/msg226123.html.

On 13 Feb 2013, at 1:01 AM, Eric W. Biederman wrote:

> If you send me just the sysctl bits I will be happy to
> double check them and forward them to stable@vger.kernel.org.  Feel free
> to Cc netdev.  For at least the sysctl bits having them pass through me
> and getting my quick review and signed-off-by should help a little
> getting them backported.

Below is my stab at a proper patch for this problem for the 2.6.32.60 stable kernel.  This is the kernel series used by the latest CentOS/Red Hat 6.3.

scripts/checkpatch.pl warns about a couple lines over 80 characters (code motion and the banner), and gives one error:

ERROR: do not initialise statics to 0 or NULL
#53: FILE: net/decnet/dn_dev.c:173:
+static struct ctl_table_header *dn_conf_path = NULL;

I followed the same practice as the code in net/decnet/sysctl_net_decnet.c:

static struct ctl_table_header *dn_table_header = NULL;

I leave it to you to decide if that is a concern.

> For your other changes I can't tell if they are clean-ups or enhancments
> or just unneeded (like updating the banner string). As a cleanup it
> would probably make sense to just delete that silly banner string.

Lots of kernel modules have banner strings.  I find them informative.  I think the version should to be updated when (substantive?) changes are made.

> There are question I have when looking at your patches:
> Does dn_hiord_addr to -> dh_hiord make a difference?
> What is the purpose of all of the code motion?
> Will anyone besides you use the new debug option?  Or would we better to
> just forget that change.

Maybe only your code motion question still applies?  The code motion is required to create the sysctl entries in the correct order:

. Static executor node (host) entries in /proc/sys/net/decnet
. Static empty path entry /proc/sys/net/decnet/conf
. Static template network device entries in /proc/sys/net/decnet/conf/<type>
. Dynamic active DECnet device entries in /proc/sys/net/decnet/conf/<dev-name>

The entries in /proc/sys/net/decnet are created in sysctl_net_decnet.c; the entries in /proc/sys/net/decnet/conf are created in dn_dev.c.  The workaround only works when the empty path entry is created before the entries in /proc/sys/net/decnet.  Thus the code rearrangement.  Even when the workaround can be removed (3.4 and later), I think this is more rational behavior.

> Eric

Thanks again,

Larry Baker
US Geological Survey
650-329-5608
baker@usgs.gov

----------

This is the patch for stable kernel 2.6.32.60.  I tested this on a CentOS 6.3 x86_64 system, which uses a 2.6.32+ kernel.  I installed the 2.6.32.60 kernel, verified the problem in the original decnet module, patched the decnet source, and verified the patched module fixes the problem.

I don't know what is a good subject line.  It is supposed to say "what" and "why".  Should it tie in to the same patches Al made for net/core and net/ipv6?  (Add a reference to those patches in the message body?)  Should it mention the aberrant behavior being fixed?

I tried to pay attention to separating the lines for the changelog from the rest of the description.

Subject line:

Subject: [PATCH] decnet: Fix for sysctl rewrite (stable kernel 2.6.32.x)

Message body:

From: Larry Baker <baker@usgs.gov>

Fixes the problem of disappearing /proc/sys/net/decnet sysctl entries reported in http://www.spinics.net/lists/netdev/msg226123.html.  Applies the same workaround used in net/core/sysctl_net_core.c and net/ipv6/sysctl_net_ipv6.c.

The problem first appeared in kernel 2.6.27.  The later rewrite of sysctl in kernel 3.4 restored the previous behavior and eliminated the need for this workaround. 

Signed-off-by: Larry Baker <baker@usgs.gov>
---

The workaround is to register an empty sysctl path entry before registering any entries beneath it.  For example, the same workaround appears in sysctl_core_init() in net/core/sysctl_net_core.c and ipv6_static_sysctl_register() in net/ipv6/sysctl_net_ipv6.c.

The additional code motion is required to create the sysctl entries in the correct order:

. Static executor node (host) entries in /proc/sys/net/decnet
. Static empty path entry /proc/sys/net/decnet/conf
. Static template network device entries in /proc/sys/net/decnet/conf/<type>
. Dynamic active DECnet device entries in /proc/sys/net/decnet/conf/<dev-name>

The entries in /proc/sys/net/decnet are created in sysctl_net_decnet.c; the entries in /proc/sys/net/decnet/conf are created in dn_dev.c.  The workaround only works when the empty path entry is created before the entries in /proc/sys/net/decnet.  The code rearrangement accomplishes this.

--- original/net/decnet/af_decnet.c
+++ patched/net/decnet/af_decnet.c
@@ -2360,7 +2360,7 @@ MODULE_AUTHOR("Linux DECnet Project Team
MODULE_LICENSE("GPL");
MODULE_ALIAS_NETPROTO(PF_DECnet);

-static char banner[] __initdata = KERN_INFO "NET4: DECnet for Linux: V.2.5.68s (C) 1995-2003 Linux DECnet Project Team\n";
+static char banner[] __initdata = KERN_INFO "DECnet: DECnet for Linux: V.2.6.32 (C) 1995-2013 Linux DECnet Project Team\n";

static int __init decnet_init(void)
{
@@ -2372,6 +2372,8 @@ static int __init decnet_init(void)
	if (rc != 0)
		goto out;

+	dn_register_sysctl();
+
	dn_neigh_init();
	dn_dev_init();
	dn_route_init();
@@ -2382,7 +2384,6 @@ static int __init decnet_init(void)
	register_netdevice_notifier(&dn_dev_notifier);

	proc_net_fops_create(&init_net, "decnet", S_IRUGO, &dn_socket_seq_fops);
-	dn_register_sysctl();
out:
	return rc;

@@ -2401,8 +2402,6 @@ static void __exit decnet_exit(void)
	rtnl_unregister_all(PF_DECnet);
	dev_remove_pack(&dn_dix_packet_type);

-	dn_unregister_sysctl();
-
	unregister_netdevice_notifier(&dn_dev_notifier);

	dn_route_cleanup();
@@ -2410,6 +2409,8 @@ static void __exit decnet_exit(void)
	dn_neigh_cleanup();
	dn_fib_cleanup();

+	dn_unregister_sysctl();
+
	proc_net_remove(&init_net, "decnet");

	proto_unregister(&dn_proto);
--- original/net/decnet/dn_dev.c
+++ patched/net/decnet/dn_dev.c
@@ -170,6 +170,8 @@ static int dn_forwarding_sysctl(ctl_tabl
			void __user *oldval, size_t __user *oldlenp,
			void __user *newval, size_t newlen);

+static struct ctl_table_header *dn_conf_path = NULL;
+
static struct dn_dev_sysctl_table {
	struct ctl_table_header *sysctl_header;
	ctl_table dn_dev_vars[5];
@@ -1436,6 +1438,14 @@ MODULE_PARM_DESC(addr, "The DECnet addre

void __init dn_dev_init(void)
{
+	struct ctl_path dn_conf[] = {
+		{ .procname = "net", .ctl_name = CTL_NET, },
+		{ .procname = "decnet", .ctl_name = NET_DECNET, },
+		{ .procname = "conf", .ctl_name = NET_DECNET_CONF, },
+		{ },
+	};
+	static ctl_table empty[1];
+
	if (addr[0] > 63 || addr[0] < 0) {
		printk(KERN_ERR "DECnet: Area must be between 0 and 63");
		return;
@@ -1448,34 +1458,36 @@ void __init dn_dev_init(void)

	decnet_address = cpu_to_le16((addr[0] << 10) | addr[1]);

-	dn_dev_devices_on();
-
-	rtnl_register(PF_DECnet, RTM_NEWADDR, dn_nl_newaddr, NULL);
-	rtnl_register(PF_DECnet, RTM_DELADDR, dn_nl_deladdr, NULL);
-	rtnl_register(PF_DECnet, RTM_GETADDR, NULL, dn_nl_dump_ifaddr);
-
-	proc_net_fops_create(&init_net, "decnet_dev", S_IRUGO, &dn_dev_seq_fops);
-
#ifdef CONFIG_SYSCTL
+	dn_conf_path = register_sysctl_paths(dn_conf, empty);
	{
		int i;
		for(i = 0; i < DN_DEV_LIST_SIZE; i++)
			dn_dev_sysctl_register(NULL, &dn_dev_list[i]);
	}
#endif /* CONFIG_SYSCTL */
+
+	dn_dev_devices_on();
+
+	rtnl_register(PF_DECnet, RTM_NEWADDR, dn_nl_newaddr, NULL);
+	rtnl_register(PF_DECnet, RTM_DELADDR, dn_nl_deladdr, NULL);
+	rtnl_register(PF_DECnet, RTM_GETADDR, NULL, dn_nl_dump_ifaddr);
+
+	proc_net_fops_create(&init_net, "decnet_dev", S_IRUGO, &dn_dev_seq_fops);
}

void __exit dn_dev_cleanup(void)
{
+	proc_net_remove(&init_net, "decnet_dev");
+
+	dn_dev_devices_off();
+
#ifdef CONFIG_SYSCTL
	{
		int i;
		for(i = 0; i < DN_DEV_LIST_SIZE; i++)
			dn_dev_sysctl_unregister(&dn_dev_list[i]);
	}
+	unregister_sysctl_table(dn_conf_path);
#endif /* CONFIG_SYSCTL */
-
-	proc_net_remove(&init_net, "decnet_dev");
-
-	dn_dev_devices_off();
}

^ permalink raw reply

* Re: [PATCH] net: Convert skb->csum_(start|offset) integrity BUG_ON() to WARN_ON() & drop
From: David Miller @ 2013-02-14  0:37 UTC (permalink / raw)
  To: tgraf; +Cc: netdev
In-Reply-To: <20130213234843.GB21829@casper.infradead.org>

From: Thomas Graf <tgraf@suug.ch>
Date: Wed, 13 Feb 2013 23:48:43 +0000

> On 02/13/13 at 11:40pm, Thomas Graf wrote:
>> They have been hit with IPoIB which uses a 64K MTU. If a TCP
>> retransmission gets partially ACKed and collapsed multiple times
>> it is possible for the headroom to grow beyond 64K which will
>> overflow the 16bit skb->csum_start.
> 
> On the subject of fixing this, I considered:
> 
>  a) Reallocate the headroom in tcp_trim_head() if it would
>     overflow. I disregarded this idea because replacing the
>     old skb with the new skb on the write queue for such a
>     rare situation seems overkill.
> 
>  b) No longer collapse if the new skb would result in a
>     a headroom + data that exceeds 64K. This seems to be the
>     most trivial fix.
> 
>  c) Increase size of csum_start or store checksum_start_offset
>     differently.
> 
> Other ideas?

"b" is a good idea.

Let's not paper over this, this BUG_ON() is really a BUG_ON()
meaning "FIX ME NOW" :-)

^ permalink raw reply

* Re: [PATCH] net: Convert skb->csum_(start|offset) integrity BUG_ON() to WARN_ON() & drop
From: Thomas Graf @ 2013-02-13 23:48 UTC (permalink / raw)
  To: davem; +Cc: netdev
In-Reply-To: <20130213234021.GA21829@casper.infradead.org>

On 02/13/13 at 11:40pm, Thomas Graf wrote:
> They have been hit with IPoIB which uses a 64K MTU. If a TCP
> retransmission gets partially ACKed and collapsed multiple times
> it is possible for the headroom to grow beyond 64K which will
> overflow the 16bit skb->csum_start.

On the subject of fixing this, I considered:

 a) Reallocate the headroom in tcp_trim_head() if it would
    overflow. I disregarded this idea because replacing the
    old skb with the new skb on the write queue for such a
    rare situation seems overkill.

 b) No longer collapse if the new skb would result in a
    a headroom + data that exceeds 64K. This seems to be the
    most trivial fix.

 c) Increase size of csum_start or store checksum_start_offset
    differently.

Other ideas?

^ permalink raw reply

* [PATCH] net: Convert skb->csum_(start|offset) integrity BUG_ON() to WARN_ON() & drop
From: Thomas Graf @ 2013-02-13 23:40 UTC (permalink / raw)
  To: davem; +Cc: netdev

skb_checksum_help() verifies the integrity of skb->csum_start
and skb->csum_offset with BUG_ON()s.

They have been hit with IPoIB which uses a 64K MTU. If a TCP
retransmission gets partially ACKed and collapsed multiple times
it is possible for the headroom to grow beyond 64K which will
overflow the 16bit skb->csum_start.

This in turn will trigger the BUG_ON() in skb_checksum_help().
Convert these to WARN_ON() and drop the packet.

Signed-off-by: Thomas Graf <tgraf@suug.ch>
---
 net/core/dev.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index f64e439..629d22e 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -2047,11 +2047,14 @@ int skb_checksum_help(struct sk_buff *skb)
 	}
 
 	offset = skb_checksum_start_offset(skb);
-	BUG_ON(offset >= skb_headlen(skb));
+	if (WARN_ON(offset >= skb_headlen(skb)))
+		return -ERANGE;
+
 	csum = skb_checksum(skb, offset, skb->len - offset, 0);
 
 	offset += skb->csum_offset;
-	BUG_ON(offset + sizeof(__sum16) > skb_headlen(skb));
+	if (WARN_ON(offset + sizeof(__sum16) > skb_headlen(skb)))
+		return -ERANGE;
 
 	if (skb_cloned(skb) &&
 	    !skb_clone_writable(skb, offset + sizeof(__sum16))) {

^ permalink raw reply related

* Re: tcp_use_frto crashes on empty tcp_write_queue
From: Eric Dumazet @ 2013-02-13 23:24 UTC (permalink / raw)
  To: Zoltan Kiss; +Cc: netdev@vger.kernel.org, Frediano Ziglio
In-Reply-To: <511C1039.9020001@citrix.com>

On Wed, 2013-02-13 at 22:14 +0000, Zoltan Kiss wrote:
> Hi,
> 
> On 13/02/13 21:37, Eric Dumazet wrote:
> > This doesn't seem to be a standard kernel.
> 
> Indeed, this is a XenServer 6.0.2 kernel, which contains changes, 
> however the TCP parts are barely modified. The related code path were 
> not changed.
> I'm trying to determine if this bug could be fixed in an obvious way, so 
> let me rephrase my question: if the socket write queue is empty, 
> shouldn't we just stop going further instead of dropping a WARN? Or, if 
> there is a reason to do so, shouldn't we check at least that returned 
> pointer in tcp_use_frto()?

You could change the WARN_ON() to BUG_ON(), as there is a severe bug in
your tree (and possibly in current trees as well, but its hard to say,
given 2.6.32 is probably missing some tcp fixes)

Trying to hide the bug wont really help.

How write_queue can be empty and packets_out not null ?

^ 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