Netdev List
 help / color / mirror / Atom feed
* [PATCH net-next] pktgen: Use pr_debug
From: Joe Perches @ 2012-05-17  3:50 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, linux-kernel

Convert printk(KERN_DEBUG to pr_debug which can
enable dynamic debugging.

Remove embedded prefixes from the conversions as
pr_fmt adds them.

Align arguments.

Signed-off-by: Joe Perches <joe@perches.com>
---
 net/core/pktgen.c |   41 ++++++++++++++++++-----------------------
 1 files changed, 18 insertions(+), 23 deletions(-)

diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 3391257..d22509b 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -891,8 +891,8 @@ static ssize_t pktgen_if_write(struct file *file,
 		if (copy_from_user(tb, user_buffer, copy))
 			return -EFAULT;
 		tb[copy] = 0;
-		printk(KERN_DEBUG "pktgen: %s,%lu  buffer -:%s:-\n", name,
-		       (unsigned long)count, tb);
+		pr_debug("%s,%lu  buffer -:%s:-\n",
+			 name, (unsigned long)count, tb);
 	}
 
 	if (!strcmp(name, "min_pkt_size")) {
@@ -1261,8 +1261,7 @@ static ssize_t pktgen_if_write(struct file *file,
 			pkt_dev->cur_daddr = pkt_dev->daddr_min;
 		}
 		if (debug)
-			printk(KERN_DEBUG "pktgen: dst_min set to: %s\n",
-			       pkt_dev->dst_min);
+			pr_debug("dst_min set to: %s\n", pkt_dev->dst_min);
 		i += len;
 		sprintf(pg_result, "OK: dst_min=%s", pkt_dev->dst_min);
 		return count;
@@ -1284,8 +1283,7 @@ static ssize_t pktgen_if_write(struct file *file,
 			pkt_dev->cur_daddr = pkt_dev->daddr_max;
 		}
 		if (debug)
-			printk(KERN_DEBUG "pktgen: dst_max set to: %s\n",
-			       pkt_dev->dst_max);
+			pr_debug("dst_max set to: %s\n", pkt_dev->dst_max);
 		i += len;
 		sprintf(pg_result, "OK: dst_max=%s", pkt_dev->dst_max);
 		return count;
@@ -1307,7 +1305,7 @@ static ssize_t pktgen_if_write(struct file *file,
 		pkt_dev->cur_in6_daddr = pkt_dev->in6_daddr;
 
 		if (debug)
-			printk(KERN_DEBUG "pktgen: dst6 set to: %s\n", buf);
+			pr_debug("dst6 set to: %s\n", buf);
 
 		i += len;
 		sprintf(pg_result, "OK: dst6=%s", buf);
@@ -1329,7 +1327,7 @@ static ssize_t pktgen_if_write(struct file *file,
 
 		pkt_dev->cur_in6_daddr = pkt_dev->min_in6_daddr;
 		if (debug)
-			printk(KERN_DEBUG "pktgen: dst6_min set to: %s\n", buf);
+			pr_debug("dst6_min set to: %s\n", buf);
 
 		i += len;
 		sprintf(pg_result, "OK: dst6_min=%s", buf);
@@ -1350,7 +1348,7 @@ static ssize_t pktgen_if_write(struct file *file,
 		snprintf(buf, sizeof(buf), "%pI6c", &pkt_dev->max_in6_daddr);
 
 		if (debug)
-			printk(KERN_DEBUG "pktgen: dst6_max set to: %s\n", buf);
+			pr_debug("dst6_max set to: %s\n", buf);
 
 		i += len;
 		sprintf(pg_result, "OK: dst6_max=%s", buf);
@@ -1373,7 +1371,7 @@ static ssize_t pktgen_if_write(struct file *file,
 		pkt_dev->cur_in6_saddr = pkt_dev->in6_saddr;
 
 		if (debug)
-			printk(KERN_DEBUG "pktgen: src6 set to: %s\n", buf);
+			pr_debug("src6 set to: %s\n", buf);
 
 		i += len;
 		sprintf(pg_result, "OK: src6=%s", buf);
@@ -1394,8 +1392,7 @@ static ssize_t pktgen_if_write(struct file *file,
 			pkt_dev->cur_saddr = pkt_dev->saddr_min;
 		}
 		if (debug)
-			printk(KERN_DEBUG "pktgen: src_min set to: %s\n",
-			       pkt_dev->src_min);
+			pr_debug("src_min set to: %s\n", pkt_dev->src_min);
 		i += len;
 		sprintf(pg_result, "OK: src_min=%s", pkt_dev->src_min);
 		return count;
@@ -1415,8 +1412,7 @@ static ssize_t pktgen_if_write(struct file *file,
 			pkt_dev->cur_saddr = pkt_dev->saddr_max;
 		}
 		if (debug)
-			printk(KERN_DEBUG "pktgen: src_max set to: %s\n",
-			       pkt_dev->src_max);
+			pr_debug("src_max set to: %s\n", pkt_dev->src_max);
 		i += len;
 		sprintf(pg_result, "OK: src_max=%s", pkt_dev->src_max);
 		return count;
@@ -1527,7 +1523,7 @@ static ssize_t pktgen_if_write(struct file *file,
 			pkt_dev->svlan_id = 0xffff;
 
 			if (debug)
-				printk(KERN_DEBUG "pktgen: VLAN/SVLAN auto turned off\n");
+				pr_debug("VLAN/SVLAN auto turned off\n");
 		}
 		return count;
 	}
@@ -1542,10 +1538,10 @@ static ssize_t pktgen_if_write(struct file *file,
 			pkt_dev->vlan_id = value;  /* turn on VLAN */
 
 			if (debug)
-				printk(KERN_DEBUG "pktgen: VLAN turned on\n");
+				pr_debug("VLAN turned on\n");
 
 			if (debug && pkt_dev->nr_labels)
-				printk(KERN_DEBUG "pktgen: MPLS auto turned off\n");
+				pr_debug("MPLS auto turned off\n");
 
 			pkt_dev->nr_labels = 0;    /* turn off MPLS */
 			sprintf(pg_result, "OK: vlan_id=%u", pkt_dev->vlan_id);
@@ -1554,7 +1550,7 @@ static ssize_t pktgen_if_write(struct file *file,
 			pkt_dev->svlan_id = 0xffff;
 
 			if (debug)
-				printk(KERN_DEBUG "pktgen: VLAN/SVLAN turned off\n");
+				pr_debug("VLAN/SVLAN turned off\n");
 		}
 		return count;
 	}
@@ -1599,10 +1595,10 @@ static ssize_t pktgen_if_write(struct file *file,
 			pkt_dev->svlan_id = value;  /* turn on SVLAN */
 
 			if (debug)
-				printk(KERN_DEBUG "pktgen: SVLAN turned on\n");
+				pr_debug("SVLAN turned on\n");
 
 			if (debug && pkt_dev->nr_labels)
-				printk(KERN_DEBUG "pktgen: MPLS auto turned off\n");
+				pr_debug("MPLS auto turned off\n");
 
 			pkt_dev->nr_labels = 0;    /* turn off MPLS */
 			sprintf(pg_result, "OK: svlan_id=%u", pkt_dev->svlan_id);
@@ -1611,7 +1607,7 @@ static ssize_t pktgen_if_write(struct file *file,
 			pkt_dev->svlan_id = 0xffff;
 
 			if (debug)
-				printk(KERN_DEBUG "pktgen: VLAN/SVLAN turned off\n");
+				pr_debug("VLAN/SVLAN turned off\n");
 		}
 		return count;
 	}
@@ -1779,8 +1775,7 @@ static ssize_t pktgen_thread_write(struct file *file,
 	i += len;
 
 	if (debug)
-		printk(KERN_DEBUG "pktgen: t=%s, count=%lu\n",
-		       name, (unsigned long)count);
+		pr_debug("t=%s, count=%lu\n", name, (unsigned long)count);
 
 	if (!t) {
 		pr_err("ERROR: No thread\n");

^ permalink raw reply related

* Re: [RFC 13/13] USB: Disable hub-initiated LPM for comms devices.
From: Sarah Sharp @ 2012-05-17  4:52 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: gigaset307x-common-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	libertas-dev-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
	netdev-u79uwXL29TY76Z2rM5mHXA, linux-usb-u79uwXL29TY76Z2rM5mHXA,
	linux-wireless-u79uwXL29TY76Z2rM5mHXA,
	users-poMEt7QlJxcwIE2E9O76wjtx2kNaKg5H,
	linux-bluetooth-u79uwXL29TY76Z2rM5mHXA,
	ath9k-devel-xDcbHBWguxHbcTqmT+pZeQ, Alan Stern
In-Reply-To: <20120516232019.GA960-U8xfFu+wG4EAvxtiuMwx3w@public.gmane.org>

On Wed, May 16, 2012 at 04:20:19PM -0700, Greg Kroah-Hartman wrote:
> On Wed, May 16, 2012 at 03:45:28PM -0700, Sarah Sharp wrote:
> > [Resending with a smaller Cc list]
> > 
> > Hub-initiated LPM is not good for USB communications devices.  Comms
> > devices should be able to tell when their link can go into a lower power
> > state, because they know when an incoming transmission is finished.
> > Ideally, these devices would slam their links into a lower power state,
> > using the device-initiated LPM, after finishing the last packet of their
> > data transfer.
> > 
> > If we enable the idle timeouts for the parent hubs to enable
> > hub-initiated LPM, we will get a lot of useless LPM packets on the bus
> > as the devices reject LPM transitions when they're in the middle of
> > receiving data.  Worse, some devices might blindly accept the
> > hub-initiated LPM and power down their radios while they're in the
> > middle of receiving a transmission.
> > 
> > The Intel Windows folks are disabling hub-initiated LPM for all USB
> > communications devices under a xHCI USB 3.0 host.  In order to keep
> > the Linux behavior as close as possible to Windows, we need to do the
> > same in Linux.
> 
> How is the USB core on Windows determining that LPM should be turned off
> for these devices?  Surely they aren't modifying each individual driver
> like this is, right?  Any way we also can do this in the core?

No, I don't think they're modifying individual drivers.  Maybe they
placed a shim/filter driver below other drivers?

Basically, I don't know the exact details of what the Windows folks are
doing.  The recommendation from the Intel Windows team was simply to
turn hub-initiated LPM off for "all communications devices".  Perhaps
the Windows USB core is looking for specific USB class codes?  Or maybe
it has some older API that lets the core know it's a communications
device?

I'm not really sure we can do it in the USB core with out basically
duplicating all the class/PID/VID matching in the communications driver.
I think just adding a flag might be the best way.  I'm open to
suggestions though.

> Or, turn it around the other way, and only enable it if we know it's
> safe to do so, in each driver, but I guess that would be even messier.

Yeah, I think it would be messier.

Sarah Sharp

^ permalink raw reply

* [PATCH net-next] net: ipv6: ndisc: Neaten ND_PRINTx macros
From: Joe Perches @ 2012-05-17  5:28 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, linux-kernel

Why use several macros when one will do?

Convert the multiple ND_PRINTKx macros to a single
ND_PRINTK macro.  Use the new net_<level>_ratelimited
mechanism too.

Add pr_fmt with "ICMPv6: " as prefix.
Remove embedded ICMPv6 prefixes from messages.

Signed-off-by: Joe Perches <joe@perches.com>
---
 net/ipv6/ndisc.c |  216 +++++++++++++++++++++++-------------------------------
 1 files changed, 91 insertions(+), 125 deletions(-)

diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index cbb863d..c7a27ac 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -27,27 +27,7 @@
  *	YOSHIFUJI Hideaki @USAGI	:	Verify ND options properly
  */
 
-/* Set to 3 to get tracing... */
-#define ND_DEBUG 1
-
-#define ND_PRINTK(fmt, args...) do { if (net_ratelimit()) { printk(fmt, ## args); } } while(0)
-#define ND_NOPRINTK(x...) do { ; } while(0)
-#define ND_PRINTK0 ND_PRINTK
-#define ND_PRINTK1 ND_NOPRINTK
-#define ND_PRINTK2 ND_NOPRINTK
-#define ND_PRINTK3 ND_NOPRINTK
-#if ND_DEBUG >= 1
-#undef ND_PRINTK1
-#define ND_PRINTK1 ND_PRINTK
-#endif
-#if ND_DEBUG >= 2
-#undef ND_PRINTK2
-#define ND_PRINTK2 ND_PRINTK
-#endif
-#if ND_DEBUG >= 3
-#undef ND_PRINTK3
-#define ND_PRINTK3 ND_PRINTK
-#endif
+#define pr_fmt(fmt) "ICMPv6: " fmt
 
 #include <linux/module.h>
 #include <linux/errno.h>
@@ -92,6 +72,15 @@
 #include <linux/netfilter.h>
 #include <linux/netfilter_ipv6.h>
 
+/* Set to 3 to get tracing... */
+#define ND_DEBUG 1
+
+#define ND_PRINTK(val, level, fmt, ...)				\
+do {								\
+	if (val <= ND_DEBUG)					\
+		net_##level##_ratelimited(fmt, ##__VA_ARGS__);	\
+} while (0)
+
 static u32 ndisc_hash(const void *pkey,
 		      const struct net_device *dev,
 		      __u32 *hash_rnd);
@@ -265,10 +254,9 @@ static struct ndisc_options *ndisc_parse_options(u8 *opt, int opt_len,
 		case ND_OPT_MTU:
 		case ND_OPT_REDIRECT_HDR:
 			if (ndopts->nd_opt_array[nd_opt->nd_opt_type]) {
-				ND_PRINTK2(KERN_WARNING
-					   "%s: duplicated ND6 option found: type=%d\n",
-					   __func__,
-					   nd_opt->nd_opt_type);
+				ND_PRINTK(2, warn,
+					  "%s: duplicated ND6 option found: type=%d\n",
+					  __func__, nd_opt->nd_opt_type);
 			} else {
 				ndopts->nd_opt_array[nd_opt->nd_opt_type] = nd_opt;
 			}
@@ -296,10 +284,11 @@ static struct ndisc_options *ndisc_parse_options(u8 *opt, int opt_len,
 				 * to accommodate future extension to the
 				 * protocol.
 				 */
-				ND_PRINTK2(KERN_NOTICE
-					   "%s: ignored unsupported option; type=%d, len=%d\n",
-					   __func__,
-					   nd_opt->nd_opt_type, nd_opt->nd_opt_len);
+				ND_PRINTK(2, notice,
+					  "%s: ignored unsupported option; type=%d, len=%d\n",
+					  __func__,
+					  nd_opt->nd_opt_type,
+					  nd_opt->nd_opt_len);
 			}
 		}
 		opt_len -= l;
@@ -455,9 +444,8 @@ struct sk_buff *ndisc_build_skb(struct net_device *dev,
 				   len + hlen + tlen),
 				  1, &err);
 	if (!skb) {
-		ND_PRINTK0(KERN_ERR
-			   "ICMPv6 ND: %s failed to allocate an skb, err=%d.\n",
-			   __func__, err);
+		ND_PRINTK(0, err, "ND: %s failed to allocate an skb, err=%d\n",
+			  __func__, err);
 		return NULL;
 	}
 
@@ -693,8 +681,9 @@ static void ndisc_solicit(struct neighbour *neigh, struct sk_buff *skb)
 
 	if ((probes -= neigh->parms->ucast_probes) < 0) {
 		if (!(neigh->nud_state & NUD_VALID)) {
-			ND_PRINTK1(KERN_DEBUG "%s: trying to ucast probe in NUD_INVALID: %pI6\n",
-				   __func__, target);
+			ND_PRINTK(1, dbg,
+				  "%s: trying to ucast probe in NUD_INVALID: %pI6\n",
+				  __func__, target);
 		}
 		ndisc_send_ns(dev, neigh, target, target, saddr);
 	} else if ((probes -= neigh->parms->app_probes) < 0) {
@@ -740,8 +729,7 @@ static void ndisc_recv_ns(struct sk_buff *skb)
 	int is_router = -1;
 
 	if (ipv6_addr_is_multicast(&msg->target)) {
-		ND_PRINTK2(KERN_WARNING
-			   "ICMPv6 NS: multicast target address");
+		ND_PRINTK(2, warn, "NS: multicast target address\n");
 		return;
 	}
 
@@ -754,22 +742,20 @@ static void ndisc_recv_ns(struct sk_buff *skb)
 	      daddr->s6_addr32[1] == htonl(0x00000000) &&
 	      daddr->s6_addr32[2] == htonl(0x00000001) &&
 	      daddr->s6_addr [12] == 0xff )) {
-		ND_PRINTK2(KERN_WARNING
-			   "ICMPv6 NS: bad DAD packet (wrong destination)\n");
+		ND_PRINTK(2, warn, "NS: bad DAD packet (wrong destination)\n");
 		return;
 	}
 
 	if (!ndisc_parse_options(msg->opt, ndoptlen, &ndopts)) {
-		ND_PRINTK2(KERN_WARNING
-			   "ICMPv6 NS: invalid ND options\n");
+		ND_PRINTK(2, warn, "NS: invalid ND options\n");
 		return;
 	}
 
 	if (ndopts.nd_opts_src_lladdr) {
 		lladdr = ndisc_opt_addr_data(ndopts.nd_opts_src_lladdr, dev);
 		if (!lladdr) {
-			ND_PRINTK2(KERN_WARNING
-				   "ICMPv6 NS: invalid link-layer address length\n");
+			ND_PRINTK(2, warn,
+				  "NS: invalid link-layer address length\n");
 			return;
 		}
 
@@ -779,8 +765,8 @@ static void ndisc_recv_ns(struct sk_buff *skb)
 		 *	in the message.
 		 */
 		if (dad) {
-			ND_PRINTK2(KERN_WARNING
-				   "ICMPv6 NS: bad DAD packet (link-layer address option)\n");
+			ND_PRINTK(2, warn,
+				  "NS: bad DAD packet (link-layer address option)\n");
 			return;
 		}
 	}
@@ -898,34 +884,30 @@ static void ndisc_recv_na(struct sk_buff *skb)
 	struct neighbour *neigh;
 
 	if (skb->len < sizeof(struct nd_msg)) {
-		ND_PRINTK2(KERN_WARNING
-			   "ICMPv6 NA: packet too short\n");
+		ND_PRINTK(2, warn, "NA: packet too short\n");
 		return;
 	}
 
 	if (ipv6_addr_is_multicast(&msg->target)) {
-		ND_PRINTK2(KERN_WARNING
-			   "ICMPv6 NA: target address is multicast.\n");
+		ND_PRINTK(2, warn, "NA: target address is multicast\n");
 		return;
 	}
 
 	if (ipv6_addr_is_multicast(daddr) &&
 	    msg->icmph.icmp6_solicited) {
-		ND_PRINTK2(KERN_WARNING
-			   "ICMPv6 NA: solicited NA is multicasted.\n");
+		ND_PRINTK(2, warn, "NA: solicited NA is multicasted\n");
 		return;
 	}
 
 	if (!ndisc_parse_options(msg->opt, ndoptlen, &ndopts)) {
-		ND_PRINTK2(KERN_WARNING
-			   "ICMPv6 NS: invalid ND option\n");
+		ND_PRINTK(2, warn, "NS: invalid ND option\n");
 		return;
 	}
 	if (ndopts.nd_opts_tgt_lladdr) {
 		lladdr = ndisc_opt_addr_data(ndopts.nd_opts_tgt_lladdr, dev);
 		if (!lladdr) {
-			ND_PRINTK2(KERN_WARNING
-				   "ICMPv6 NA: invalid link-layer address length\n");
+			ND_PRINTK(2, warn,
+				  "NA: invalid link-layer address length\n");
 			return;
 		}
 	}
@@ -946,9 +928,9 @@ static void ndisc_recv_na(struct sk_buff *skb)
 		   unsolicited advertisement.
 		 */
 		if (skb->pkt_type != PACKET_LOOPBACK)
-			ND_PRINTK1(KERN_WARNING
-			   "ICMPv6 NA: someone advertises our address %pI6 on %s!\n",
-			   &ifp->addr, ifp->idev->dev->name);
+			ND_PRINTK(1, warn,
+				  "NA: someone advertises our address %pI6 on %s!\n",
+				  &ifp->addr, ifp->idev->dev->name);
 		in6_ifa_put(ifp);
 		return;
 	}
@@ -1010,8 +992,7 @@ static void ndisc_recv_rs(struct sk_buff *skb)
 
 	idev = __in6_dev_get(skb->dev);
 	if (!idev) {
-		if (net_ratelimit())
-			ND_PRINTK1("ICMP6 RS: can't find in6 device\n");
+		ND_PRINTK(1, err, "RS: can't find in6 device\n");
 		return;
 	}
 
@@ -1028,8 +1009,7 @@ static void ndisc_recv_rs(struct sk_buff *skb)
 
 	/* Parse ND options */
 	if (!ndisc_parse_options(rs_msg->opt, ndoptlen, &ndopts)) {
-		if (net_ratelimit())
-			ND_PRINTK2("ICMP6 NS: invalid ND option, ignored\n");
+		ND_PRINTK(2, notice, "NS: invalid ND option, ignored\n");
 		goto out;
 	}
 
@@ -1127,20 +1107,17 @@ static void ndisc_router_discovery(struct sk_buff *skb)
 	optlen = (skb->tail - skb->transport_header) - sizeof(struct ra_msg);
 
 	if (!(ipv6_addr_type(&ipv6_hdr(skb)->saddr) & IPV6_ADDR_LINKLOCAL)) {
-		ND_PRINTK2(KERN_WARNING
-			   "ICMPv6 RA: source address is not link-local.\n");
+		ND_PRINTK(2, warn, "RA: source address is not link-local\n");
 		return;
 	}
 	if (optlen < 0) {
-		ND_PRINTK2(KERN_WARNING
-			   "ICMPv6 RA: packet too short\n");
+		ND_PRINTK(2, warn, "RA: packet too short\n");
 		return;
 	}
 
 #ifdef CONFIG_IPV6_NDISC_NODETYPE
 	if (skb->ndisc_nodetype == NDISC_NODETYPE_HOST) {
-		ND_PRINTK2(KERN_WARNING
-			   "ICMPv6 RA: from host or unauthorized router\n");
+		ND_PRINTK(2, warn, "RA: from host or unauthorized router\n");
 		return;
 	}
 #endif
@@ -1151,15 +1128,13 @@ static void ndisc_router_discovery(struct sk_buff *skb)
 
 	in6_dev = __in6_dev_get(skb->dev);
 	if (in6_dev == NULL) {
-		ND_PRINTK0(KERN_ERR
-			   "ICMPv6 RA: can't find inet6 device for %s.\n",
-			   skb->dev->name);
+		ND_PRINTK(0, err, "RA: can't find inet6 device for %s\n",
+			  skb->dev->name);
 		return;
 	}
 
 	if (!ndisc_parse_options(opt, optlen, &ndopts)) {
-		ND_PRINTK2(KERN_WARNING
-			   "ICMP6 RA: invalid ND options\n");
+		ND_PRINTK(2, warn, "RA: invalid ND options\n");
 		return;
 	}
 
@@ -1212,9 +1187,9 @@ static void ndisc_router_discovery(struct sk_buff *skb)
 	if (rt) {
 		neigh = dst_neigh_lookup(&rt->dst, &ipv6_hdr(skb)->saddr);
 		if (!neigh) {
-			ND_PRINTK0(KERN_ERR
-				   "ICMPv6 RA: %s got default router without neighbour.\n",
-				   __func__);
+			ND_PRINTK(0, err,
+				  "RA: %s got default router without neighbour\n",
+				  __func__);
 			dst_release(&rt->dst);
 			return;
 		}
@@ -1225,22 +1200,21 @@ static void ndisc_router_discovery(struct sk_buff *skb)
 	}
 
 	if (rt == NULL && lifetime) {
-		ND_PRINTK3(KERN_DEBUG
-			   "ICMPv6 RA: adding default router.\n");
+		ND_PRINTK(3, dbg, "RA: adding default router\n");
 
 		rt = rt6_add_dflt_router(&ipv6_hdr(skb)->saddr, skb->dev, pref);
 		if (rt == NULL) {
-			ND_PRINTK0(KERN_ERR
-				   "ICMPv6 RA: %s failed to add default route.\n",
-				   __func__);
+			ND_PRINTK(0, err,
+				  "RA: %s failed to add default route\n",
+				  __func__);
 			return;
 		}
 
 		neigh = dst_neigh_lookup(&rt->dst, &ipv6_hdr(skb)->saddr);
 		if (neigh == NULL) {
-			ND_PRINTK0(KERN_ERR
-				   "ICMPv6 RA: %s got default router without neighbour.\n",
-				   __func__);
+			ND_PRINTK(0, err,
+				  "RA: %s got default router without neighbour\n",
+				  __func__);
 			dst_release(&rt->dst);
 			return;
 		}
@@ -1308,8 +1282,8 @@ skip_linkparms:
 			lladdr = ndisc_opt_addr_data(ndopts.nd_opts_src_lladdr,
 						     skb->dev);
 			if (!lladdr) {
-				ND_PRINTK2(KERN_WARNING
-					   "ICMPv6 RA: invalid link-layer address length\n");
+				ND_PRINTK(2, warn,
+					  "RA: invalid link-layer address length\n");
 				goto out;
 			}
 		}
@@ -1373,9 +1347,7 @@ skip_routeinfo:
 		mtu = ntohl(n);
 
 		if (mtu < IPV6_MIN_MTU || mtu > skb->dev->mtu) {
-			ND_PRINTK2(KERN_WARNING
-				   "ICMPv6 RA: invalid mtu: %d\n",
-				   mtu);
+			ND_PRINTK(2, warn, "RA: invalid mtu: %d\n", mtu);
 		} else if (in6_dev->cnf.mtu6 != mtu) {
 			in6_dev->cnf.mtu6 = mtu;
 
@@ -1396,8 +1368,7 @@ skip_routeinfo:
 	}
 
 	if (ndopts.nd_opts_tgt_lladdr || ndopts.nd_opts_rh) {
-		ND_PRINTK2(KERN_WARNING
-			   "ICMPv6 RA: invalid RA options");
+		ND_PRINTK(2, warn, "RA: invalid RA options\n");
 	}
 out:
 	if (rt)
@@ -1422,15 +1393,15 @@ static void ndisc_redirect_rcv(struct sk_buff *skb)
 	switch (skb->ndisc_nodetype) {
 	case NDISC_NODETYPE_HOST:
 	case NDISC_NODETYPE_NODEFAULT:
-		ND_PRINTK2(KERN_WARNING
-			   "ICMPv6 Redirect: from host or unauthorized router\n");
+		ND_PRINTK(2, warn,
+			  "Redirect: from host or unauthorized router\n");
 		return;
 	}
 #endif
 
 	if (!(ipv6_addr_type(&ipv6_hdr(skb)->saddr) & IPV6_ADDR_LINKLOCAL)) {
-		ND_PRINTK2(KERN_WARNING
-			   "ICMPv6 Redirect: source address is not link-local.\n");
+		ND_PRINTK(2, warn,
+			  "Redirect: source address is not link-local\n");
 		return;
 	}
 
@@ -1438,8 +1409,7 @@ static void ndisc_redirect_rcv(struct sk_buff *skb)
 	optlen -= sizeof(struct icmp6hdr) + 2 * sizeof(struct in6_addr);
 
 	if (optlen < 0) {
-		ND_PRINTK2(KERN_WARNING
-			   "ICMPv6 Redirect: packet too short\n");
+		ND_PRINTK(2, warn, "Redirect: packet too short\n");
 		return;
 	}
 
@@ -1448,8 +1418,8 @@ static void ndisc_redirect_rcv(struct sk_buff *skb)
 	dest = target + 1;
 
 	if (ipv6_addr_is_multicast(dest)) {
-		ND_PRINTK2(KERN_WARNING
-			   "ICMPv6 Redirect: destination address is multicast.\n");
+		ND_PRINTK(2, warn,
+			  "Redirect: destination address is multicast\n");
 		return;
 	}
 
@@ -1457,8 +1427,8 @@ static void ndisc_redirect_rcv(struct sk_buff *skb)
 		on_link = 1;
 	} else if (ipv6_addr_type(target) !=
 		   (IPV6_ADDR_UNICAST|IPV6_ADDR_LINKLOCAL)) {
-		ND_PRINTK2(KERN_WARNING
-			   "ICMPv6 Redirect: target address is not link-local unicast.\n");
+		ND_PRINTK(2, warn,
+			  "Redirect: target address is not link-local unicast\n");
 		return;
 	}
 
@@ -1474,16 +1444,15 @@ static void ndisc_redirect_rcv(struct sk_buff *skb)
 	 */
 
 	if (!ndisc_parse_options((u8*)(dest + 1), optlen, &ndopts)) {
-		ND_PRINTK2(KERN_WARNING
-			   "ICMPv6 Redirect: invalid ND options\n");
+		ND_PRINTK(2, warn, "Redirect: invalid ND options\n");
 		return;
 	}
 	if (ndopts.nd_opts_tgt_lladdr) {
 		lladdr = ndisc_opt_addr_data(ndopts.nd_opts_tgt_lladdr,
 					     skb->dev);
 		if (!lladdr) {
-			ND_PRINTK2(KERN_WARNING
-				   "ICMPv6 Redirect: invalid link-layer address length\n");
+			ND_PRINTK(2, warn,
+				  "Redirect: invalid link-layer address length\n");
 			return;
 		}
 	}
@@ -1518,16 +1487,15 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
 	u8 ha_buf[MAX_ADDR_LEN], *ha = NULL;
 
 	if (ipv6_get_lladdr(dev, &saddr_buf, IFA_F_TENTATIVE)) {
-		ND_PRINTK2(KERN_WARNING
-			   "ICMPv6 Redirect: no link-local address on %s\n",
-			   dev->name);
+		ND_PRINTK(2, warn, "Redirect: no link-local address on %s\n",
+			  dev->name);
 		return;
 	}
 
 	if (!ipv6_addr_equal(&ipv6_hdr(skb)->daddr, target) &&
 	    ipv6_addr_type(target) != (IPV6_ADDR_UNICAST|IPV6_ADDR_LINKLOCAL)) {
-		ND_PRINTK2(KERN_WARNING
-			"ICMPv6 Redirect: target address is not link-local unicast.\n");
+		ND_PRINTK(2, warn,
+			  "Redirect: target address is not link-local unicast\n");
 		return;
 	}
 
@@ -1546,8 +1514,8 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
 	rt = (struct rt6_info *) dst;
 
 	if (rt->rt6i_flags & RTF_GATEWAY) {
-		ND_PRINTK2(KERN_WARNING
-			   "ICMPv6 Redirect: destination is not a neighbour.\n");
+		ND_PRINTK(2, warn,
+			  "Redirect: destination is not a neighbour\n");
 		goto release;
 	}
 	if (!rt->rt6i_peer)
@@ -1558,8 +1526,8 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
 	if (dev->addr_len) {
 		struct neighbour *neigh = dst_neigh_lookup(skb_dst(skb), target);
 		if (!neigh) {
-			ND_PRINTK2(KERN_WARNING
-				   "ICMPv6 Redirect: no neigh for target address\n");
+			ND_PRINTK(2, warn,
+				  "Redirect: no neigh for target address\n");
 			goto release;
 		}
 
@@ -1587,9 +1555,9 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
 				    len + hlen + tlen),
 				   1, &err);
 	if (buff == NULL) {
-		ND_PRINTK0(KERN_ERR
-			   "ICMPv6 Redirect: %s failed to allocate an skb, err=%d.\n",
-			   __func__, err);
+		ND_PRINTK(0, err,
+			  "Redirect: %s failed to allocate an skb, err=%d\n",
+			  __func__, err);
 		goto release;
 	}
 
@@ -1674,16 +1642,14 @@ int ndisc_rcv(struct sk_buff *skb)
 	__skb_push(skb, skb->data - skb_transport_header(skb));
 
 	if (ipv6_hdr(skb)->hop_limit != 255) {
-		ND_PRINTK2(KERN_WARNING
-			   "ICMPv6 NDISC: invalid hop-limit: %d\n",
-			   ipv6_hdr(skb)->hop_limit);
+		ND_PRINTK(2, warn, "NDISC: invalid hop-limit: %d\n",
+			  ipv6_hdr(skb)->hop_limit);
 		return 0;
 	}
 
 	if (msg->icmph.icmp6_code != 0) {
-		ND_PRINTK2(KERN_WARNING
-			   "ICMPv6 NDISC: invalid ICMPv6 code: %d\n",
-			   msg->icmph.icmp6_code);
+		ND_PRINTK(2, warn, "NDISC: invalid ICMPv6 code: %d\n",
+			  msg->icmph.icmp6_code);
 		return 0;
 	}
 
@@ -1804,9 +1770,9 @@ static int __net_init ndisc_net_init(struct net *net)
 	err = inet_ctl_sock_create(&sk, PF_INET6,
 				   SOCK_RAW, IPPROTO_ICMPV6, net);
 	if (err < 0) {
-		ND_PRINTK0(KERN_ERR
-			   "ICMPv6 NDISC: Failed to initialize the control socket (err %d).\n",
-			   err);
+		ND_PRINTK(0, err,
+			  "NDISC: Failed to initialize the control socket (err %d)\n",
+			  err);
 		return err;
 	}
 

^ permalink raw reply related

* Re: [PATCH v5 2/2] decrement static keys on real destroy time
From: Andrew Morton @ 2012-05-17  5:37 UTC (permalink / raw)
  To: Glauber Costa
  Cc: cgroups-u79uwXL29TY76Z2rM5mHXA, linux-mm-Bw31MaZKKs3YtjvyW6yDsg,
	devel-GEFAQzZX7r8dnm+yROfE0A,
	kamezawa.hiroyu-+CUm20s59erQFUHtdCDX3A,
	netdev-u79uwXL29TY76Z2rM5mHXA, Tejun Heo, Li Zefan,
	Johannes Weiner, Michal Hocko
In-Reply-To: <4FB46B4C.3000307-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>

On Thu, 17 May 2012 07:06:52 +0400 Glauber Costa <glommer-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org> wrote:

> ...
> >> +	else if (val != RESOURCE_MAX) {
> >> +		/*
> >> +		 * ->activated needs to be written after the static_key update.
> >> +		 *  This is what guarantees that the socket activation function
> >> +		 *  is the last one to run. See sock_update_memcg() for details,
> >> +		 *  and note that we don't mark any socket as belonging to this
> >> +		 *  memcg until that flag is up.
> >> +		 *
> >> +		 *  We need to do this, because static_keys will span multiple
> >> +		 *  sites, but we can't control their order. If we mark a socket
> >> +		 *  as accounted, but the accounting functions are not patched in
> >> +		 *  yet, we'll lose accounting.
> >> +		 *
> >> +		 *  We never race with the readers in sock_update_memcg(), because
> >> +		 *  when this value change, the code to process it is not patched in
> >> +		 *  yet.
> >> +		 */
> >> +		if (!cg_proto->activated) {
> >> +			static_key_slow_inc(&memcg_socket_limit_enabled);
> >> +			cg_proto->activated = true;
> >> +		}
> >
> > If two threads run this code concurrently, they can both see
> > cg_proto->activated==false and they will both run
> > static_key_slow_inc().
> >
> > Hopefully there's some locking somewhere which prevents this, but it is
> > unobvious.  We should comment this, probably at the cg_proto.activated
> > definition site.  Or we should fix the bug ;)
> >
> If that happens, locking in static_key_slow_inc will prevent any damage.
> My previous version had explicit code to prevent that, but we were 
> pointed out that this is already part of the static_key expectations, so 
> that was dropped.

This makes no sense.  If two threads run that code concurrently,
key->enabled gets incremented twice.  Nobody anywhere has a record that
this happened so it cannot be undone.  key->enabled is now in an
unknown state.

^ permalink raw reply

* Re: linux-next: manual merge of the net-next tree with the sparc-next tree
From: Sam Ravnborg @ 2012-05-17  5:54 UTC (permalink / raw)
  To: Stephen Rothwell; +Cc: David Miller, netdev, linux-next, linux-kernel
In-Reply-To: <20120517130406.1706f944820bbe8dc5e368f2@canb.auug.org.au>

> So I applied this merge fixup to the merge of the net-next tree today
> (and can carry it as necessary):

Perfect. And please carry this as we do not plan to solve this
conflict.

	Sam

^ permalink raw reply

* [PATCH net-next] net: core: Use pr_<level>
From: Joe Perches @ 2012-05-17  5:58 UTC (permalink / raw)
  To: David S. Miller; +Cc: Neil Horman, netdev, linux-kernel

Use the current logging style.

This enables use of dynamic debugging as well.

Convert printk(KERN_<LEVEL> to pr_<level>.
Add pr_fmt. Remove embedded prefixes, use
%s, __func__ instead.

Signed-off-by: Joe Perches <joe@perches.com>
---
 net/core/drop_monitor.c   |   10 ++++++----
 net/core/neighbour.c      |   13 +++++++------
 net/core/net_namespace.c  |    6 ++++--
 net/core/netprio_cgroup.c |    6 ++++--
 net/core/skbuff.c         |   20 ++++++++++----------
 net/core/sock.c           |   25 +++++++++++++------------
 6 files changed, 44 insertions(+), 36 deletions(-)

diff --git a/net/core/drop_monitor.c b/net/core/drop_monitor.c
index a7cad74..eca00a9 100644
--- a/net/core/drop_monitor.c
+++ b/net/core/drop_monitor.c
@@ -4,6 +4,8 @@
  * Copyright (C) 2009 Neil Horman <nhorman@tuxdriver.com>
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/string.h>
@@ -381,10 +383,10 @@ static int __init init_net_drop_monitor(void)
 	struct per_cpu_dm_data *data;
 	int cpu, rc;
 
-	printk(KERN_INFO "Initializing network drop monitor service\n");
+	pr_info("Initializing network drop monitor service\n");
 
 	if (sizeof(void *) > 8) {
-		printk(KERN_ERR "Unable to store program counters on this arch, Drop monitor failed\n");
+		pr_err("Unable to store program counters on this arch, Drop monitor failed\n");
 		return -ENOSPC;
 	}
 
@@ -392,13 +394,13 @@ static int __init init_net_drop_monitor(void)
 					   dropmon_ops,
 					   ARRAY_SIZE(dropmon_ops));
 	if (rc) {
-		printk(KERN_ERR "Could not create drop monitor netlink family\n");
+		pr_err("Could not create drop monitor netlink family\n");
 		return rc;
 	}
 
 	rc = register_netdevice_notifier(&dropmon_net_notifier);
 	if (rc < 0) {
-		printk(KERN_CRIT "Failed to register netdevice notifier\n");
+		pr_crit("Failed to register netdevice notifier\n");
 		goto out_unreg;
 	}
 
diff --git a/net/core/neighbour.c b/net/core/neighbour.c
index fadaa81..eb09f8b 100644
--- a/net/core/neighbour.c
+++ b/net/core/neighbour.c
@@ -15,6 +15,8 @@
  *	Harald Welte		Add neighbour cache statistics like rtstat
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/slab.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
@@ -712,14 +714,13 @@ void neigh_destroy(struct neighbour *neigh)
 	NEIGH_CACHE_STAT_INC(neigh->tbl, destroys);
 
 	if (!neigh->dead) {
-		printk(KERN_WARNING
-		       "Destroying alive neighbour %p\n", neigh);
+		pr_warn("Destroying alive neighbour %p\n", neigh);
 		dump_stack();
 		return;
 	}
 
 	if (neigh_del_timer(neigh))
-		printk(KERN_WARNING "Impossible event.\n");
+		pr_warn("Impossible event\n");
 
 	skb_queue_purge(&neigh->arp_queue);
 	neigh->arp_queue_len_bytes = 0;
@@ -1554,8 +1555,8 @@ void neigh_table_init(struct neigh_table *tbl)
 	write_unlock(&neigh_tbl_lock);
 
 	if (unlikely(tmp)) {
-		printk(KERN_ERR "NEIGH: Registering multiple tables for "
-		       "family %d\n", tbl->family);
+		pr_err("Registering multiple tables for family %d\n",
+		       tbl->family);
 		dump_stack();
 	}
 }
@@ -1571,7 +1572,7 @@ int neigh_table_clear(struct neigh_table *tbl)
 	pneigh_queue_purge(&tbl->proxy_queue);
 	neigh_ifdown(tbl, NULL);
 	if (atomic_read(&tbl->entries))
-		printk(KERN_CRIT "neighbour leakage\n");
+		pr_crit("neighbour leakage\n");
 	write_lock(&neigh_tbl_lock);
 	for (tp = &neigh_tables; *tp; tp = &(*tp)->next) {
 		if (*tp == tbl) {
diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
index 31a5ae5..dddbacb 100644
--- a/net/core/net_namespace.c
+++ b/net/core/net_namespace.c
@@ -1,3 +1,5 @@
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/workqueue.h>
 #include <linux/rtnetlink.h>
 #include <linux/cache.h>
@@ -212,8 +214,8 @@ static void net_free(struct net *net)
 {
 #ifdef NETNS_REFCNT_DEBUG
 	if (unlikely(atomic_read(&net->use_count) != 0)) {
-		printk(KERN_EMERG "network namespace not free! Usage: %d\n",
-			atomic_read(&net->use_count));
+		pr_emerg("network namespace not free! Usage: %d\n",
+			 atomic_read(&net->use_count));
 		return;
 	}
 #endif
diff --git a/net/core/netprio_cgroup.c b/net/core/netprio_cgroup.c
index ba6900f..09eda68 100644
--- a/net/core/netprio_cgroup.c
+++ b/net/core/netprio_cgroup.c
@@ -9,6 +9,8 @@
  * Authors:	Neil Horman <nhorman@tuxdriver.com>
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/types.h>
@@ -88,7 +90,7 @@ static void extend_netdev_table(struct net_device *dev, u32 new_len)
 	old_priomap  = rtnl_dereference(dev->priomap);
 
 	if (!new_priomap) {
-		printk(KERN_WARNING "Unable to alloc new priomap!\n");
+		pr_warn("Unable to alloc new priomap!\n");
 		return;
 	}
 
@@ -136,7 +138,7 @@ static struct cgroup_subsys_state *cgrp_create(struct cgroup *cgrp)
 
 	ret = get_prioidx(&cs->prioidx);
 	if (ret != 0) {
-		printk(KERN_WARNING "No space in priority index array\n");
+		pr_warn("No space in priority index array\n");
 		kfree(cs);
 		return ERR_PTR(ret);
 	}
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 2a18719..7a10f08 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -36,6 +36,8 @@
  *	The functions in this file will not compile correctly with gcc 2.4.x
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
@@ -118,11 +120,10 @@ static const struct pipe_buf_operations sock_pipe_buf_ops = {
  */
 static void skb_over_panic(struct sk_buff *skb, int sz, void *here)
 {
-	printk(KERN_EMERG "skb_over_panic: text:%p len:%d put:%d head:%p "
-			  "data:%p tail:%#lx end:%#lx dev:%s\n",
-	       here, skb->len, sz, skb->head, skb->data,
-	       (unsigned long)skb->tail, (unsigned long)skb->end,
-	       skb->dev ? skb->dev->name : "<NULL>");
+	pr_emerg("%s: text:%p len:%d put:%d head:%p data:%p tail:%#lx end:%#lx dev:%s\n",
+		 __func__, here, skb->len, sz, skb->head, skb->data,
+		 (unsigned long)skb->tail, (unsigned long)skb->end,
+		 skb->dev ? skb->dev->name : "<NULL>");
 	BUG();
 }
 
@@ -137,11 +138,10 @@ static void skb_over_panic(struct sk_buff *skb, int sz, void *here)
 
 static void skb_under_panic(struct sk_buff *skb, int sz, void *here)
 {
-	printk(KERN_EMERG "skb_under_panic: text:%p len:%d put:%d head:%p "
-			  "data:%p tail:%#lx end:%#lx dev:%s\n",
-	       here, skb->len, sz, skb->head, skb->data,
-	       (unsigned long)skb->tail, (unsigned long)skb->end,
-	       skb->dev ? skb->dev->name : "<NULL>");
+	pr_emerg("%s: text:%p len:%d put:%d head:%p data:%p tail:%#lx end:%#lx dev:%s\n",
+		 __func__, here, skb->len, sz, skb->head, skb->data,
+		 (unsigned long)skb->tail, (unsigned long)skb->end,
+		 skb->dev ? skb->dev->name : "<NULL>");
 	BUG();
 }
 
diff --git a/net/core/sock.c b/net/core/sock.c
index 9d144ee..5efcd63 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -89,6 +89,8 @@
  *		2 of the License, or (at your option) any later version.
  */
 
+#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
 #include <linux/capability.h>
 #include <linux/errno.h>
 #include <linux/types.h>
@@ -297,9 +299,8 @@ static int sock_set_timeout(long *timeo_p, char __user *optval, int optlen)
 		*timeo_p = 0;
 		if (warned < 10 && net_ratelimit()) {
 			warned++;
-			printk(KERN_INFO "sock_set_timeout: `%s' (pid %d) "
-			       "tries to set negative timeout\n",
-				current->comm, task_pid_nr(current));
+			pr_info("%s: `%s' (pid %d) tries to set negative timeout\n",
+				__func__, current->comm, task_pid_nr(current));
 		}
 		return 0;
 	}
@@ -317,8 +318,8 @@ static void sock_warn_obsolete_bsdism(const char *name)
 	static char warncomm[TASK_COMM_LEN];
 	if (strcmp(warncomm, current->comm) && warned < 5) {
 		strcpy(warncomm,  current->comm);
-		printk(KERN_WARNING "process `%s' is using obsolete "
-		       "%s SO_BSDCOMPAT\n", warncomm, name);
+		pr_warn("process `%s' is using obsolete %s SO_BSDCOMPAT\n",
+			warncomm, name);
 		warned++;
 	}
 }
@@ -1238,8 +1239,8 @@ static void __sk_free(struct sock *sk)
 	sock_disable_timestamp(sk, SK_FLAGS_TIMESTAMP);
 
 	if (atomic_read(&sk->sk_omem_alloc))
-		printk(KERN_DEBUG "%s: optmem leakage (%d bytes) detected.\n",
-		       __func__, atomic_read(&sk->sk_omem_alloc));
+		pr_debug("%s: optmem leakage (%d bytes) detected\n",
+			 __func__, atomic_read(&sk->sk_omem_alloc));
 
 	if (sk->sk_peer_cred)
 		put_cred(sk->sk_peer_cred);
@@ -2424,7 +2425,7 @@ static void assign_proto_idx(struct proto *prot)
 	prot->inuse_idx = find_first_zero_bit(proto_inuse_idx, PROTO_INUSE_NR);
 
 	if (unlikely(prot->inuse_idx == PROTO_INUSE_NR - 1)) {
-		printk(KERN_ERR "PROTO_INUSE_NR exhausted\n");
+		pr_err("PROTO_INUSE_NR exhausted\n");
 		return;
 	}
 
@@ -2454,8 +2455,8 @@ int proto_register(struct proto *prot, int alloc_slab)
 					NULL);
 
 		if (prot->slab == NULL) {
-			printk(KERN_CRIT "%s: Can't create sock SLAB cache!\n",
-			       prot->name);
+			pr_crit("%s: Can't create sock SLAB cache!\n",
+				prot->name);
 			goto out;
 		}
 
@@ -2469,8 +2470,8 @@ int proto_register(struct proto *prot, int alloc_slab)
 								 SLAB_HWCACHE_ALIGN, NULL);
 
 			if (prot->rsk_prot->slab == NULL) {
-				printk(KERN_CRIT "%s: Can't create request sock SLAB cache!\n",
-				       prot->name);
+				pr_crit("%s: Can't create request sock SLAB cache!\n",
+					prot->name);
 				goto out_free_request_sock_slab_name;
 			}
 		}

^ permalink raw reply related

* Re: [PATCH v3 4/7] ARM: davinci: net: davinci_emac: add OF support
From: Heiko Schocher @ 2012-05-17  6:32 UTC (permalink / raw)
  To: Nori, Sekhar
  Cc: davinci-linux-open-source@linux.davincidsp.com,
	linux-arm-kernel@lists.infradead.org,
	devicetree-discuss@lists.ozlabs.org, netdev@vger.kernel.org,
	Grant Likely, Wolfgang Denk, Anatoly Sivov
In-Reply-To: <DF0F476B391FA8409C78302C7BA518B63EA14401@DBDE01.ent.ti.com>

Hello Nori,

thanks for the review!

Nori, Sekhar wrote:
> Hi Heiko,
> 
> On Mon, Mar 05, 2012 at 16:40:01, Heiko Schocher wrote:
>> add of support for the davinci_emac driver.
>>
>> Signed-off-by: Heiko Schocher <hs@denx.de>
>> Cc: davinci-linux-open-source@linux.davincidsp.com
>> Cc: linux-arm-kernel@lists.infradead.org
>> Cc: devicetree-discuss@lists.ozlabs.org
>> Cc: netdev@vger.kernel.org
>> Cc: Grant Likely <grant.likely@secretlab.ca>
>> Cc: Sekhar Nori <nsekhar@ti.com>
>> Cc: Wolfgang Denk <wd@denx.de>
>> Cc: Anatoly Sivov <mm05@mail.ru>
>>
>> ---
>> - changes for v2:
>>   - add comment from Anatoly Sivov
>>     - fix typo in davinci_emac.txt
>>   - add comment from Grant Likely:
>>     - add prefix "ti,davinci-" to davinci specific property names
>>     - remove version property
>>     - use compatible name "ti,davinci-dm6460-emac"
>>     - use devm_kzalloc()
>>     - use of_match_ptr()
>>     - document all new properties
>>     - remove of_address_to_resource() and do not overwrite
>>       resource table
>>     - whitespace fixes
>>     - remove hw_ram_addr as it is not used in current
>>       board code
>> - no changes for v3
>>
>>  .../bindings/arm/davinci/davinci_emac.txt          |   43 +++++++++
>>  drivers/net/ethernet/ti/davinci_emac.c             |   94 +++++++++++++++++++-
>>  2 files changed, 136 insertions(+), 1 deletions(-)
>>  create mode 100644 Documentation/devicetree/bindings/arm/davinci/davinci_emac.txt
>>
>> diff --git a/Documentation/devicetree/bindings/arm/davinci/davinci_emac.txt b/Documentation/devicetree/bindings/arm/davinci/davinci_emac.txt
>> new file mode 100644
>> index 0000000..a7b0911
>> --- /dev/null
>> +++ b/Documentation/devicetree/bindings/arm/davinci/davinci_emac.txt
> 
> Since DaVinci EMAC driver may be used on platforms other than DaVinci (c6x,
> OMAP), can we place the bindings documentation in bindings/net/?

Done.

>> @@ -0,0 +1,43 @@
>> +* Texas Instruments Davinci EMAC
>> +
>> +This file provides information, what the device node
>> +for the davinci_emac interface contain.
> 
> s/contain/contains

fixed.

>> +
>> +Required properties:
>> +- compatible: "ti,davinci-dm6460-emac";
> 
> There is no device called dm6460. If you intend to only support
> "version 2" of the EMAC IP at this time, you can use dm6467
> (http://www.ti.com/product/tms320dm6467)

renamed to "ti,davinci-dm6467-emac"

>> +- reg: Offset and length of the register set for the device
>> +- ti,davinci-ctrl-reg-offset: offset to control register
>> +- ti,davinci-ctrl-mod-reg-offset: offset to control module register
>> +- ti,davinci-ctrl-ram-offset: offset to control module ram
>> +- ti,davinci-ctrl-ram-size: size of control module ram
>> +- ti,davinci-rmii-en: use RMII
>> +- ti,davinci-no-bd-ram: has the emac controller BD RAM
>> +- phy-handle: Contains a phandle to an Ethernet PHY.
>> +              if not, davinci_emac driver defaults to 100/FULL
>> +- interrupts: interrupt mapping for the davinci emac interrupts sources:
>> +              4 sources: <Receive Threshold Interrupt
>> +			  Receive Interrupt
>> +			  Transmit Interrupt
>> +			  Miscellaneous Interrupt>
>> +- pinmux-handle: Contains a handle to configure the pinmux settings.

removed.

>> +
>> +Optional properties:
>> +- local-mac-address : 6 bytes, mac address
>> +
>> +Example (enbw_cmc board):
>> +	eth0: emac@1e20000 {
>> +		compatible = "ti,davinci-dm6460-emac";
>> +		reg = <0x220000 0x4000>;
>> +		ti,davinci-ctrl-reg-offset = <0x3000>;
>> +		ti,davinci-ctrl-mod-reg-offset = <0x2000>;
>> +		ti,davinci-ctrl-ram-offset = <0>;
>> +		ti,davinci-ctrl-ram-size = <0x2000>;
>> +		local-mac-address = [ 00 00 00 00 00 00 ];
>> +		interrupts = <33
>> +				34
>> +				35
>> +				36
>> +				>;
>> +		interrupt-parent = <&intc>;
>> +		pinmux-handle = <&emac_pins>;

removed.

>> +	};
>> diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c
>> index 4fa0bcb..56e1c35 100644
>> --- a/drivers/net/ethernet/ti/davinci_emac.c
>> +++ b/drivers/net/ethernet/ti/davinci_emac.c
>> @@ -58,6 +58,12 @@
>>  #include <linux/io.h>
>>  #include <linux/uaccess.h>
>>  #include <linux/davinci_emac.h>
>> +#include <linux/of.h>
>> +#include <linux/of_address.h>
>> +#include <linux/of_irq.h>
>> +#include <linux/of_net.h>
>> +
>> +#include <mach/mux.h>
>>  
>>  #include <asm/irq.h>
>>  #include <asm/page.h>
>> @@ -339,6 +345,9 @@ struct emac_priv {
>>  	u32 rx_addr_type;
>>  	atomic_t cur_tx;
>>  	const char *phy_id;
>> +#ifdef CONFIG_OF
>> +	struct device_node *phy_node;
>> +#endif
>>  	struct phy_device *phydev;
>>  	spinlock_t lock;
>>  	/*platform specific members*/
>> @@ -1760,6 +1769,82 @@ static const struct net_device_ops emac_netdev_ops = {
>>  #endif
>>  };
>>  
>> +#ifdef CONFIG_OF
>> +static struct emac_platform_data
>> +	*davinci_emac_of_get_pdata(struct platform_device *pdev,
>> +	struct emac_priv *priv)
>> +{
>> +	struct device_node *np;
>> +	struct device_node *pinmux_np;
>> +	struct emac_platform_data *pdata = NULL;
>> +	const u8 *mac_addr;
>> +	u32 data;
>> +	int ret;
>> +	int version;
>> +
>> +	np = pdev->dev.of_node;
>> +	if (!np)
>> +		goto nodata;
>> +	else
>> +		version = EMAC_VERSION_2;
> 
> You could set pdata->version directly here. 

done.

>> +
>> +	pdata = pdev->dev.platform_data;
>> +	if (!pdata) {
>> +		pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
>> +		if (!pdata)
>> +			goto nodata;
>> +	}
>> +	pdata->version = version;
>> +
>> +	mac_addr = of_get_mac_address(np);
>> +	if (mac_addr)
>> +		memcpy(pdata->mac_addr, mac_addr, ETH_ALEN);
>> +
>> +	ret = of_property_read_u32(np, "ti,davinci-ctrl-reg-offset", &data);
>> +	if (!ret)
>> +		pdata->ctrl_reg_offset = data;
>> +
>> +	ret = of_property_read_u32(np, "ti,davinci-ctrl-mod-reg-offset",
>> +		&data);
>> +	if (!ret)
>> +		pdata->ctrl_mod_reg_offset = data;
>> +
>> +	ret = of_property_read_u32(np, "ti,davinci-ctrl-ram-offset", &data);
>> +	if (!ret)
>> +		pdata->ctrl_ram_offset = data;
>> +
>> +	ret = of_property_read_u32(np, "ti,davinci-ctrl-ram-size", &data);
>> +	if (!ret)
>> +		pdata->ctrl_ram_size = data;
>> +
>> +	ret = of_property_read_u32(np, "ti,davinci-rmii-en", &data);
>> +	if (!ret)
>> +		pdata->rmii_en = data;
>> +
>> +	ret = of_property_read_u32(np, "ti,davinci-no-bd-ram", &data);
>> +	if (!ret)
>> +		pdata->no_bd_ram = data;
>> +
>> +	priv->phy_node = of_parse_phandle(np, "phy-handle", 0);
>> +	if (!priv->phy_node)
>> +		pdata->phy_id = "";
>> +
>> +	pinmux_np = of_parse_phandle(np, "pinmux-handle", 0);
>> +	if (pinmux_np)
>> +		davinci_cfg_reg_of(pinmux_np);
> 
> This is a DaVinci specific pinmux function and this
> driver can be used in non-DaVinci platforms like C6x
> and OMAP. So, it will not be correct to call a DaVinci
> specific function here.

Ah, right!

> Can you drop the pinmux from this patch for now? On DaVinci,

Done ... Hmm.. so I think, I should drop this for all patches
from my patchset, right?

> for pinmux, we need to migrate to drivers/pinctrl/ as well.

Ah, I see ... take a look at it, maybe I find time to do here
something ... or do you know about work in progress here?

> Doing this will also make this patch independent of the rest
> of this series can even be merged separately. Can you please
> make these changes and resend just this patch?

Yep, I do some test with the changes you requested and resend
this patch ... do you prefer some tree, which I should use as
base?

>> +
>> +	pdev->dev.platform_data = pdata;
>> +nodata:
>> +	return  pdata;
>> +}
>> +#else
>> +static struct emac_platform_data
>> +	*davinci_emac_of_get_pdata(struct platform_device *pdev,
>> +	struct emac_priv *priv)
>> +{
>> +	return  pdev->dev.platform_data;
>> +}
>> +#endif
>>  /**
>>   * davinci_emac_probe: EMAC device probe
>>   * @pdev: The DaVinci EMAC device that we are removing
>> @@ -1803,7 +1888,7 @@ static int __devinit davinci_emac_probe(struct platform_device *pdev)
>>  
>>  	spin_lock_init(&priv->lock);
>>  
>> -	pdata = pdev->dev.platform_data;
>> +	pdata = davinci_emac_of_get_pdata(pdev, priv);
>>  	if (!pdata) {
>>  		dev_err(&pdev->dev, "no platform data\n");
>>  		rc = -ENODEV;
>> @@ -2013,6 +2098,12 @@ static const struct dev_pm_ops davinci_emac_pm_ops = {
>>  	.resume		= davinci_emac_resume,
>>  };
>>  
>> +static const struct of_device_id davinci_emac_of_match[] = {
>> +	{.compatible = "ti,davinci-dm6460-emac", },
> 
> This needs to be ti,davinci-dm6467-emac as well.

Yep, fixed.

bye,
Heiko
-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.de

^ permalink raw reply

* [patch] isdn: remove duplicate NULL check
From: Dan Carpenter @ 2012-05-17  6:51 UTC (permalink / raw)
  To: Karsten Keil
  Cc: David Howells, Phil Carmody, netdev, kernel-janitors,
	David S. Miller

We test both "!skb_out" and "skb_out" here which is duplicative and
causes a static checker warning.  I considered that the intent might
have been to test "skb_in" but that's a valid pointer here.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/isdn/i4l/isdn_bsdcomp.c b/drivers/isdn/i4l/isdn_bsdcomp.c
index c59e8d2..8837ac5 100644
--- a/drivers/isdn/i4l/isdn_bsdcomp.c
+++ b/drivers/isdn/i4l/isdn_bsdcomp.c
@@ -612,7 +612,7 @@ static int bsd_compress(void *state, struct sk_buff *skb_in, struct sk_buff *skb
 		db->n_bits++;
 
 	/* If output length is too large then this is an incompressible frame. */
-	if (!skb_out || (skb_out && skb_out->len >= skb_in->len)) {
+	if (!skb_out || skb_out->len >= skb_in->len) {
 		++db->incomp_count;
 		db->incomp_bytes += isize;
 		return 0;

^ permalink raw reply related

* all networking trees merged
From: David Miller @ 2012-05-17  7:18 UTC (permalink / raw)
  To: netdev


Earlier this evening I merged:

	Linus's tree --> net --> net-next

Just FYI...

^ permalink raw reply

* Re: [PATCH v3 4/7] ARM: davinci: net: davinci_emac: add OF support
From: Sekhar Nori @ 2012-05-17  7:21 UTC (permalink / raw)
  To: hs
  Cc: davinci-linux-open-source@linux.davincidsp.com,
	linux-arm-kernel@lists.infradead.org,
	devicetree-discuss@lists.ozlabs.org, netdev@vger.kernel.org,
	Grant Likely, Wolfgang Denk, Anatoly Sivov
In-Reply-To: <4FB49B7B.60506@denx.de>

On 5/17/2012 12:02 PM, Heiko Schocher wrote:
> Nori, Sekhar wrote:
>> On Mon, Mar 05, 2012 at 16:40:01, Heiko Schocher wrote:

>>> +#ifdef CONFIG_OF
>>> +static struct emac_platform_data
>>> +	*davinci_emac_of_get_pdata(struct platform_device *pdev,
>>> +	struct emac_priv *priv)
>>> +{
>>> +	struct device_node *np;
>>> +	struct device_node *pinmux_np;
>>> +	struct emac_platform_data *pdata = NULL;
>>> +	const u8 *mac_addr;
>>> +	u32 data;
>>> +	int ret;
>>> +	int version;
>>> +
>>> +	np = pdev->dev.of_node;
>>> +	if (!np)
>>> +		goto nodata;
>>> +	else
>>> +		version = EMAC_VERSION_2;
>>
>> You could set pdata->version directly here. 
> 
> done.

Just noticed that pdata is not setup at this time. I guess you will be
moving around some code to do this.

>>> +
>>> +	pinmux_np = of_parse_phandle(np, "pinmux-handle", 0);
>>> +	if (pinmux_np)
>>> +		davinci_cfg_reg_of(pinmux_np);
>>
>> This is a DaVinci specific pinmux function and this
>> driver can be used in non-DaVinci platforms like C6x
>> and OMAP. So, it will not be correct to call a DaVinci
>> specific function here.
> 
> Ah, right!
> 
>> Can you drop the pinmux from this patch for now? On DaVinci,
> 
> Done ... Hmm.. so I think, I should drop this for all patches
> from my patchset, right?

Yes.

> 
>> for pinmux, we need to migrate to drivers/pinctrl/ as well.
> 
> Ah, I see ... take a look at it, maybe I find time to do here
> something ... or do you know about work in progress here?

There is no work in progress within TI. So, if you are interested in
taking a stab it it, it will be great.

> 
>> Doing this will also make this patch independent of the rest
>> of this series can even be merged separately. Can you please
>> make these changes and resend just this patch?
> 
> Yep, I do some test with the changes you requested and resend
> this patch ... do you prefer some tree, which I should use as
> base?

This one should ideally merge through the network subsystem so may be
base it on the net-next tree?

http://git.kernel.org/?p=linux/kernel/git/davem/net-next.git;a=summary

Thanks,
Sekhar

^ permalink raw reply

* Re: [Bridge] [PATCH] net/bridge/netfilter: Fix the randconfig warning
From: Bart De Schuymer @ 2012-05-17  7:21 UTC (permalink / raw)
  To: Devendra Naga
  Cc: Pablo Neira Ayuso, Patrick McHardy, Stephen Hemminger,
	David S. Miller, netfilter-devel, netfilter, coreteam, bridge,
	netdev
In-Reply-To: <1337023817-26132-1-git-send-email-devendra.aaru@gmail.com>

Op 14/05/2012 21:30, Devendra Naga schreef:
> when ran with make randconfig got
>
> warning: (BRIDGE_NF_EBTABLES) selects NETFILTER_XTABLES which has unmet direct dependencies (NET&&  INET&&  NETFILTER)
>
> added NET&&  INET&&  NETFILTER dependency to the BRIDGE_NF_EBTABLES

I really don't see why ebtables should depend on INET. To me the issue 
lies in the fact that xtables depends on INET.

Bart

-- 
Bart De Schuymer
www.artinalgorithms.be

^ permalink raw reply

* Re: [PATCH net-next v2 0/2] 6lowpan: code updates
From: Alexander Smirnov @ 2012-05-17  7:31 UTC (permalink / raw)
  To: David Miller; +Cc: netdev
In-Reply-To: <20120516.152801.915753046212672140.davem@davemloft.net>

Got it!

Damn, my fault, sorry for that.

Alex

2012/5/16 David Miller <davem@davemloft.net>:
> From: Alexander Smirnov <alex.bluesman.smirnov@gmail.com>
> Date: Wed, 16 May 2012 11:27:26 +0400
>
>>   6lowpan: rework data fetching from skb
>
> This is not what we told you to do.
>
> We told you that IF you were going to emit a warning message
> for the pskb_may_pull() failure condition, you should use
> WARN_ON_ONCE() so that it doesn't potentially flood the
> logs.
>
> But you must always, in every case, handle the error in some
> reasonable way, not just when WARN_ON_ONCE() does that initial
> one-and-only trigger.

^ permalink raw reply

* Re: [PATCH] ipv6: fix incorrect ipsec transport mode fragment
From: Gao feng @ 2012-05-17  7:42 UTC (permalink / raw)
  To: David Miller; +Cc: steffen.klassert, netdev, lw
In-Reply-To: <20120514.184132.1506982467448756718.davem@davemloft.net>

于 2012年05月15日 06:41, David Miller 写道:
> From: Steffen Klassert <steffen.klassert@secunet.com>
> Date: Mon, 14 May 2012 15:05:28 +0200
> 
>> There might be other opinions, but I don't like to see this IPsec mode
>> dependent stuff hacked into the generic ipv6 output path.
> 
> Completely agreed.

Hi David

how do you think about adding function pointer to struct xfrm_mode?
when prefering xfrm_mode,there must be some ipsec codes in the generic ipv6 output
path,just like below.it looks ugly.

int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to,
        int offset, int len, int odd, struct sk_buff *skb),
        void *from, int length, int transhdrlen,
        int hlimit, int tclass, struct ipv6_txoptions *opt, struct flowi6 *fl6,
        struct rt6_info *rt, unsigned int flags, int dontfrag)
{
#ifdef CONFIG_XFRM
        struct xfrm_state *x = rt->dst.xfrm;
        if (x && x->outer_mode && x->outer_mode->append_data) {
                x->outer_mode->append_data(...);
        } else
#endif
                __ip6_append_data(...);
}

I want to use one bit of rt6_info->rt6i_flags to identify the actions we should
do in ip6_append_data. BUT it seems not what the rt6i_flags should do.this may
make rt6i_flags in chaos.

What's your comment?

> --
> 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] net: l2tp: Standardize logging styles
From: James Chapman @ 2012-05-17  7:46 UTC (permalink / raw)
  To: Joe Perches; +Cc: David S. Miller, netdev, linux-kernel
In-Reply-To: <1337198156.10019.8.camel@joe2Laptop>

This is a good improvement. Thanks!

Signed-off-by: James Chapman <jchapman@katalix.com>

On 16/05/12 20:55, Joe Perches wrote:
> Use more current logging styles.
> 
> Add pr_fmt to prefix output appropriately.
> Convert printks to pr_<level>.
> Convert PRINTK macros to new l2tp_<level> macros.
> Neaten some <foo>_refcount debugging macros.
> Use print_hex_dump_bytes instead of hand-coded loops.
> Coalesce formats and align arguments.
> 
> Some KERN_DEBUG output is not now emitted unless
> dynamic_debugging is enabled.
> 
> Signed-off-by: Joe Perches <joe@perches.com>
> ---
>  net/l2tp/l2tp_core.c    |  216 ++++++++++++++++++++++-------------------------
>  net/l2tp/l2tp_core.h    |   35 ++++++--
>  net/l2tp/l2tp_debugfs.c |    6 +-
>  net/l2tp/l2tp_eth.c     |   15 +--
>  net/l2tp/l2tp_ip.c      |   15 +--
>  net/l2tp/l2tp_ip6.c     |   15 +--
>  net/l2tp/l2tp_netlink.c |    4 +-
>  net/l2tp/l2tp_ppp.c     |  128 ++++++++++++++--------------
>  8 files changed, 213 insertions(+), 221 deletions(-)
> 
> diff --git a/net/l2tp/l2tp_core.c b/net/l2tp/l2tp_core.c
> index 0d6aedc..32b2155 100644
> --- a/net/l2tp/l2tp_core.c
> +++ b/net/l2tp/l2tp_core.c
> @@ -18,6 +18,8 @@
>   * published by the Free Software Foundation.
>   */
>  
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
>  #include <linux/module.h>
>  #include <linux/string.h>
>  #include <linux/list.h>
> @@ -86,12 +88,6 @@
>  /* Default trace flags */
>  #define L2TP_DEFAULT_DEBUG_FLAGS	0
>  
> -#define PRINTK(_mask, _type, _lvl, _fmt, args...)			\
> -	do {								\
> -		if ((_mask) & (_type))					\
> -			printk(_lvl "L2TP: " _fmt, ##args);		\
> -	} while (0)
> -
>  /* Private data stored for received packets in the skb.
>   */
>  struct l2tp_skb_cb {
> @@ -141,14 +137,20 @@ static inline void l2tp_tunnel_dec_refcount_1(struct l2tp_tunnel *tunnel)
>  		l2tp_tunnel_free(tunnel);
>  }
>  #ifdef L2TP_REFCNT_DEBUG
> -#define l2tp_tunnel_inc_refcount(_t) do { \
> -		printk(KERN_DEBUG "l2tp_tunnel_inc_refcount: %s:%d %s: cnt=%d\n", __func__, __LINE__, (_t)->name, atomic_read(&_t->ref_count)); \
> -		l2tp_tunnel_inc_refcount_1(_t);				\
> -	} while (0)
> -#define l2tp_tunnel_dec_refcount(_t) do { \
> -		printk(KERN_DEBUG "l2tp_tunnel_dec_refcount: %s:%d %s: cnt=%d\n", __func__, __LINE__, (_t)->name, atomic_read(&_t->ref_count)); \
> -		l2tp_tunnel_dec_refcount_1(_t);				\
> -	} while (0)
> +#define l2tp_tunnel_inc_refcount(_t)					\
> +do {									\
> +	pr_debug("l2tp_tunnel_inc_refcount: %s:%d %s: cnt=%d\n",	\
> +		 __func__, __LINE__, (_t)->name,			\
> +		 atomic_read(&_t->ref_count));				\
> +	l2tp_tunnel_inc_refcount_1(_t);					\
> +} while (0)
> +#define l2tp_tunnel_dec_refcount(_t)
> +do {									\
> +	pr_debug("l2tp_tunnel_dec_refcount: %s:%d %s: cnt=%d\n",	\
> +		 __func__, __LINE__, (_t)->name,			\
> +		 atomic_read(&_t->ref_count));				\
> +	l2tp_tunnel_dec_refcount_1(_t);					\
> +} while (0)
>  #else
>  #define l2tp_tunnel_inc_refcount(t) l2tp_tunnel_inc_refcount_1(t)
>  #define l2tp_tunnel_dec_refcount(t) l2tp_tunnel_dec_refcount_1(t)
> @@ -337,10 +339,10 @@ static void l2tp_recv_queue_skb(struct l2tp_session *session, struct sk_buff *sk
>  	skb_queue_walk_safe(&session->reorder_q, skbp, tmp) {
>  		if (L2TP_SKB_CB(skbp)->ns > ns) {
>  			__skb_queue_before(&session->reorder_q, skbp, skb);
> -			PRINTK(session->debug, L2TP_MSG_SEQ, KERN_DEBUG,
> -			       "%s: pkt %hu, inserted before %hu, reorder_q len=%d\n",
> -			       session->name, ns, L2TP_SKB_CB(skbp)->ns,
> -			       skb_queue_len(&session->reorder_q));
> +			l2tp_dbg(session, L2TP_MSG_SEQ,
> +				 "%s: pkt %hu, inserted before %hu, reorder_q len=%d\n",
> +				 session->name, ns, L2TP_SKB_CB(skbp)->ns,
> +				 skb_queue_len(&session->reorder_q));
>  			u64_stats_update_begin(&sstats->syncp);
>  			sstats->rx_oos_packets++;
>  			u64_stats_update_end(&sstats->syncp);
> @@ -386,8 +388,8 @@ static void l2tp_recv_dequeue_skb(struct l2tp_session *session, struct sk_buff *
>  		else
>  			session->nr &= 0xffffff;
>  
> -		PRINTK(session->debug, L2TP_MSG_SEQ, KERN_DEBUG,
> -		       "%s: updated nr to %hu\n", session->name, session->nr);
> +		l2tp_dbg(session, L2TP_MSG_SEQ, "%s: updated nr to %hu\n",
> +			 session->name, session->nr);
>  	}
>  
>  	/* call private receive handler */
> @@ -422,12 +424,11 @@ start:
>  			sstats->rx_seq_discards++;
>  			sstats->rx_errors++;
>  			u64_stats_update_end(&sstats->syncp);
> -			PRINTK(session->debug, L2TP_MSG_SEQ, KERN_DEBUG,
> -			       "%s: oos pkt %u len %d discarded (too old), "
> -			       "waiting for %u, reorder_q_len=%d\n",
> -			       session->name, L2TP_SKB_CB(skb)->ns,
> -			       L2TP_SKB_CB(skb)->length, session->nr,
> -			       skb_queue_len(&session->reorder_q));
> +			l2tp_dbg(session, L2TP_MSG_SEQ,
> +				 "%s: oos pkt %u len %d discarded (too old), waiting for %u, reorder_q_len=%d\n",
> +				 session->name, L2TP_SKB_CB(skb)->ns,
> +				 L2TP_SKB_CB(skb)->length, session->nr,
> +				 skb_queue_len(&session->reorder_q));
>  			session->reorder_skip = 1;
>  			__skb_unlink(skb, &session->reorder_q);
>  			kfree_skb(skb);
> @@ -438,20 +439,19 @@ start:
>  
>  		if (L2TP_SKB_CB(skb)->has_seq) {
>  			if (session->reorder_skip) {
> -				PRINTK(session->debug, L2TP_MSG_SEQ, KERN_DEBUG,
> -				       "%s: advancing nr to next pkt: %u -> %u",
> -				       session->name, session->nr,
> -				       L2TP_SKB_CB(skb)->ns);
> +				l2tp_dbg(session, L2TP_MSG_SEQ,
> +					 "%s: advancing nr to next pkt: %u -> %u",
> +					 session->name, session->nr,
> +					 L2TP_SKB_CB(skb)->ns);
>  				session->reorder_skip = 0;
>  				session->nr = L2TP_SKB_CB(skb)->ns;
>  			}
>  			if (L2TP_SKB_CB(skb)->ns != session->nr) {
> -				PRINTK(session->debug, L2TP_MSG_SEQ, KERN_DEBUG,
> -				       "%s: holding oos pkt %u len %d, "
> -				       "waiting for %u, reorder_q_len=%d\n",
> -				       session->name, L2TP_SKB_CB(skb)->ns,
> -				       L2TP_SKB_CB(skb)->length, session->nr,
> -				       skb_queue_len(&session->reorder_q));
> +				l2tp_dbg(session, L2TP_MSG_SEQ,
> +					 "%s: holding oos pkt %u len %d, waiting for %u, reorder_q_len=%d\n",
> +					 session->name, L2TP_SKB_CB(skb)->ns,
> +					 L2TP_SKB_CB(skb)->length, session->nr,
> +					 skb_queue_len(&session->reorder_q));
>  				goto out;
>  			}
>  		}
> @@ -595,9 +595,10 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb,
>  	/* Parse and check optional cookie */
>  	if (session->peer_cookie_len > 0) {
>  		if (memcmp(ptr, &session->peer_cookie[0], session->peer_cookie_len)) {
> -			PRINTK(tunnel->debug, L2TP_MSG_DATA, KERN_INFO,
> -			       "%s: cookie mismatch (%u/%u). Discarding.\n",
> -			       tunnel->name, tunnel->tunnel_id, session->session_id);
> +			l2tp_info(tunnel, L2TP_MSG_DATA,
> +				  "%s: cookie mismatch (%u/%u). Discarding.\n",
> +				  tunnel->name, tunnel->tunnel_id,
> +				  session->session_id);
>  			u64_stats_update_begin(&sstats->syncp);
>  			sstats->rx_cookie_discards++;
>  			u64_stats_update_end(&sstats->syncp);
> @@ -626,9 +627,9 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb,
>  			L2TP_SKB_CB(skb)->ns = ns;
>  			L2TP_SKB_CB(skb)->has_seq = 1;
>  
> -			PRINTK(session->debug, L2TP_MSG_SEQ, KERN_DEBUG,
> -			       "%s: recv data ns=%u, nr=%u, session nr=%u\n",
> -			       session->name, ns, nr, session->nr);
> +			l2tp_dbg(session, L2TP_MSG_SEQ,
> +				 "%s: recv data ns=%u, nr=%u, session nr=%u\n",
> +				 session->name, ns, nr, session->nr);
>  		}
>  	} else if (session->l2specific_type == L2TP_L2SPECTYPE_DEFAULT) {
>  		u32 l2h = ntohl(*(__be32 *) ptr);
> @@ -640,9 +641,9 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb,
>  			L2TP_SKB_CB(skb)->ns = ns;
>  			L2TP_SKB_CB(skb)->has_seq = 1;
>  
> -			PRINTK(session->debug, L2TP_MSG_SEQ, KERN_DEBUG,
> -			       "%s: recv data ns=%u, session nr=%u\n",
> -			       session->name, ns, session->nr);
> +			l2tp_dbg(session, L2TP_MSG_SEQ,
> +				 "%s: recv data ns=%u, session nr=%u\n",
> +				 session->name, ns, session->nr);
>  		}
>  	}
>  
> @@ -655,9 +656,9 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb,
>  		 * configure it so.
>  		 */
>  		if ((!session->lns_mode) && (!session->send_seq)) {
> -			PRINTK(session->debug, L2TP_MSG_SEQ, KERN_INFO,
> -			       "%s: requested to enable seq numbers by LNS\n",
> -			       session->name);
> +			l2tp_info(session, L2TP_MSG_SEQ,
> +				  "%s: requested to enable seq numbers by LNS\n",
> +				  session->name);
>  			session->send_seq = -1;
>  			l2tp_session_set_header_len(session, tunnel->version);
>  		}
> @@ -666,9 +667,9 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb,
>  		 * If user has configured mandatory sequence numbers, discard.
>  		 */
>  		if (session->recv_seq) {
> -			PRINTK(session->debug, L2TP_MSG_SEQ, KERN_WARNING,
> -			       "%s: recv data has no seq numbers when required. "
> -			       "Discarding\n", session->name);
> +			l2tp_warn(session, L2TP_MSG_SEQ,
> +				  "%s: recv data has no seq numbers when required. Discarding.\n",
> +				  session->name);
>  			u64_stats_update_begin(&sstats->syncp);
>  			sstats->rx_seq_discards++;
>  			u64_stats_update_end(&sstats->syncp);
> @@ -681,15 +682,15 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb,
>  		 * LAC is broken. Discard the frame.
>  		 */
>  		if ((!session->lns_mode) && (session->send_seq)) {
> -			PRINTK(session->debug, L2TP_MSG_SEQ, KERN_INFO,
> -			       "%s: requested to disable seq numbers by LNS\n",
> -			       session->name);
> +			l2tp_info(session, L2TP_MSG_SEQ,
> +				  "%s: requested to disable seq numbers by LNS\n",
> +				  session->name);
>  			session->send_seq = 0;
>  			l2tp_session_set_header_len(session, tunnel->version);
>  		} else if (session->send_seq) {
> -			PRINTK(session->debug, L2TP_MSG_SEQ, KERN_WARNING,
> -			       "%s: recv data has no seq numbers when required. "
> -			       "Discarding\n", session->name);
> +			l2tp_warn(session, L2TP_MSG_SEQ,
> +				  "%s: recv data has no seq numbers when required. Discarding.\n",
> +				  session->name);
>  			u64_stats_update_begin(&sstats->syncp);
>  			sstats->rx_seq_discards++;
>  			u64_stats_update_end(&sstats->syncp);
> @@ -749,12 +750,11 @@ void l2tp_recv_common(struct l2tp_session *session, struct sk_buff *skb,
>  				u64_stats_update_begin(&sstats->syncp);
>  				sstats->rx_seq_discards++;
>  				u64_stats_update_end(&sstats->syncp);
> -				PRINTK(session->debug, L2TP_MSG_SEQ, KERN_DEBUG,
> -				       "%s: oos pkt %u len %d discarded, "
> -				       "waiting for %u, reorder_q_len=%d\n",
> -				       session->name, L2TP_SKB_CB(skb)->ns,
> -				       L2TP_SKB_CB(skb)->length, session->nr,
> -				       skb_queue_len(&session->reorder_q));
> +				l2tp_dbg(session, L2TP_MSG_SEQ,
> +					 "%s: oos pkt %u len %d discarded, waiting for %u, reorder_q_len=%d\n",
> +					 session->name, L2TP_SKB_CB(skb)->ns,
> +					 L2TP_SKB_CB(skb)->length, session->nr,
> +					 skb_queue_len(&session->reorder_q));
>  				goto discard;
>  			}
>  			skb_queue_tail(&session->reorder_q, skb);
> @@ -800,7 +800,6 @@ static int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb,
>  	unsigned char *ptr, *optr;
>  	u16 hdrflags;
>  	u32 tunnel_id, session_id;
> -	int offset;
>  	u16 version;
>  	int length;
>  	struct l2tp_stats *tstats;
> @@ -813,8 +812,9 @@ static int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb,
>  
>  	/* Short packet? */
>  	if (!pskb_may_pull(skb, L2TP_HDR_SIZE_SEQ)) {
> -		PRINTK(tunnel->debug, L2TP_MSG_DATA, KERN_INFO,
> -		       "%s: recv short packet (len=%d)\n", tunnel->name, skb->len);
> +		l2tp_info(tunnel, L2TP_MSG_DATA,
> +			  "%s: recv short packet (len=%d)\n",
> +			  tunnel->name, skb->len);
>  		goto error;
>  	}
>  
> @@ -824,14 +824,8 @@ static int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb,
>  		if (!pskb_may_pull(skb, length))
>  			goto error;
>  
> -		printk(KERN_DEBUG "%s: recv: ", tunnel->name);
> -
> -		offset = 0;
> -		do {
> -			printk(" %02X", skb->data[offset]);
> -		} while (++offset < length);
> -
> -		printk("\n");
> +		pr_debug("%s: recv\n", tunnel->name);
> +		print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, skb->data, length);
>  	}
>  
>  	/* Point to L2TP header */
> @@ -843,9 +837,9 @@ static int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb,
>  	/* Check protocol version */
>  	version = hdrflags & L2TP_HDR_VER_MASK;
>  	if (version != tunnel->version) {
> -		PRINTK(tunnel->debug, L2TP_MSG_DATA, KERN_INFO,
> -		       "%s: recv protocol version mismatch: got %d expected %d\n",
> -		       tunnel->name, version, tunnel->version);
> +		l2tp_info(tunnel, L2TP_MSG_DATA,
> +			  "%s: recv protocol version mismatch: got %d expected %d\n",
> +			  tunnel->name, version, tunnel->version);
>  		goto error;
>  	}
>  
> @@ -854,8 +848,9 @@ static int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb,
>  
>  	/* If type is control packet, it is handled by userspace. */
>  	if (hdrflags & L2TP_HDRFLAG_T) {
> -		PRINTK(tunnel->debug, L2TP_MSG_DATA, KERN_DEBUG,
> -		       "%s: recv control packet, len=%d\n", tunnel->name, length);
> +		l2tp_dbg(tunnel, L2TP_MSG_DATA,
> +			 "%s: recv control packet, len=%d\n",
> +			 tunnel->name, length);
>  		goto error;
>  	}
>  
> @@ -883,9 +878,9 @@ static int l2tp_udp_recv_core(struct l2tp_tunnel *tunnel, struct sk_buff *skb,
>  	session = l2tp_session_find(tunnel->l2tp_net, tunnel, session_id);
>  	if (!session || !session->recv_skb) {
>  		/* Not found? Pass to userspace to deal with */
> -		PRINTK(tunnel->debug, L2TP_MSG_DATA, KERN_INFO,
> -		       "%s: no session found (%u/%u). Passing up.\n",
> -		       tunnel->name, tunnel_id, session_id);
> +		l2tp_info(tunnel, L2TP_MSG_DATA,
> +			  "%s: no session found (%u/%u). Passing up.\n",
> +			  tunnel->name, tunnel_id, session_id);
>  		goto error;
>  	}
>  
> @@ -925,8 +920,8 @@ int l2tp_udp_encap_recv(struct sock *sk, struct sk_buff *skb)
>  	if (tunnel == NULL)
>  		goto pass_up;
>  
> -	PRINTK(tunnel->debug, L2TP_MSG_DATA, KERN_DEBUG,
> -	       "%s: received %d bytes\n", tunnel->name, skb->len);
> +	l2tp_dbg(tunnel, L2TP_MSG_DATA, "%s: received %d bytes\n",
> +		 tunnel->name, skb->len);
>  
>  	if (l2tp_udp_recv_core(tunnel, skb, tunnel->recv_payload_hook))
>  		goto pass_up_put;
> @@ -968,8 +963,8 @@ static int l2tp_build_l2tpv2_header(struct l2tp_session *session, void *buf)
>  		*bufp++ = 0;
>  		session->ns++;
>  		session->ns &= 0xffff;
> -		PRINTK(session->debug, L2TP_MSG_SEQ, KERN_DEBUG,
> -		       "%s: updated ns to %u\n", session->name, session->ns);
> +		l2tp_dbg(session, L2TP_MSG_SEQ, "%s: updated ns to %u\n",
> +			 session->name, session->ns);
>  	}
>  
>  	return bufp - optr;
> @@ -1005,8 +1000,9 @@ static int l2tp_build_l2tpv3_header(struct l2tp_session *session, void *buf)
>  				l2h = 0x40000000 | session->ns;
>  				session->ns++;
>  				session->ns &= 0xffffff;
> -				PRINTK(session->debug, L2TP_MSG_SEQ, KERN_DEBUG,
> -				       "%s: updated ns to %u\n", session->name, session->ns);
> +				l2tp_dbg(session, L2TP_MSG_SEQ,
> +					 "%s: updated ns to %u\n",
> +					 session->name, session->ns);
>  			}
>  
>  			*((__be32 *) bufp) = htonl(l2h);
> @@ -1029,27 +1025,19 @@ static int l2tp_xmit_core(struct l2tp_session *session, struct sk_buff *skb,
>  
>  	/* Debug */
>  	if (session->send_seq)
> -		PRINTK(session->debug, L2TP_MSG_DATA, KERN_DEBUG,
> -		       "%s: send %Zd bytes, ns=%u\n", session->name,
> -		       data_len, session->ns - 1);
> +		l2tp_dbg(session, L2TP_MSG_DATA, "%s: send %Zd bytes, ns=%u\n",
> +			 session->name, data_len, session->ns - 1);
>  	else
> -		PRINTK(session->debug, L2TP_MSG_DATA, KERN_DEBUG,
> -		       "%s: send %Zd bytes\n", session->name, data_len);
> +		l2tp_dbg(session, L2TP_MSG_DATA, "%s: send %Zd bytes\n",
> +			 session->name, data_len);
>  
>  	if (session->debug & L2TP_MSG_DATA) {
> -		int i;
>  		int uhlen = (tunnel->encap == L2TP_ENCAPTYPE_UDP) ? sizeof(struct udphdr) : 0;
>  		unsigned char *datap = skb->data + uhlen;
>  
> -		printk(KERN_DEBUG "%s: xmit:", session->name);
> -		for (i = 0; i < (len - uhlen); i++) {
> -			printk(" %02X", *datap++);
> -			if (i == 31) {
> -				printk(" ...");
> -				break;
> -			}
> -		}
> -		printk("\n");
> +		pr_debug("%s: xmit\n", session->name);
> +		print_hex_dump_bytes("", DUMP_PREFIX_OFFSET,
> +				     datap, min_t(size_t, 32, len - uhlen));
>  	}
>  
>  	/* Queue the packet to IP for output */
> @@ -1248,8 +1236,7 @@ static void l2tp_tunnel_destruct(struct sock *sk)
>  	if (tunnel == NULL)
>  		goto end;
>  
> -	PRINTK(tunnel->debug, L2TP_MSG_CONTROL, KERN_INFO,
> -	       "%s: closing...\n", tunnel->name);
> +	l2tp_info(tunnel, L2TP_MSG_CONTROL, "%s: closing...\n", tunnel->name);
>  
>  	/* Close all sessions */
>  	l2tp_tunnel_closeall(tunnel);
> @@ -1291,8 +1278,8 @@ static void l2tp_tunnel_closeall(struct l2tp_tunnel *tunnel)
>  
>  	BUG_ON(tunnel == NULL);
>  
> -	PRINTK(tunnel->debug, L2TP_MSG_CONTROL, KERN_INFO,
> -	       "%s: closing all sessions...\n", tunnel->name);
> +	l2tp_info(tunnel, L2TP_MSG_CONTROL, "%s: closing all sessions...\n",
> +		  tunnel->name);
>  
>  	write_lock_bh(&tunnel->hlist_lock);
>  	for (hash = 0; hash < L2TP_HASH_SIZE; hash++) {
> @@ -1300,8 +1287,8 @@ again:
>  		hlist_for_each_safe(walk, tmp, &tunnel->session_hlist[hash]) {
>  			session = hlist_entry(walk, struct l2tp_session, hlist);
>  
> -			PRINTK(session->debug, L2TP_MSG_CONTROL, KERN_INFO,
> -			       "%s: closing session\n", session->name);
> +			l2tp_info(session, L2TP_MSG_CONTROL,
> +				  "%s: closing session\n", session->name);
>  
>  			hlist_del_init(&session->hlist);
>  
> @@ -1354,8 +1341,7 @@ static void l2tp_tunnel_free(struct l2tp_tunnel *tunnel)
>  	BUG_ON(atomic_read(&tunnel->ref_count) != 0);
>  	BUG_ON(tunnel->sock != NULL);
>  
> -	PRINTK(tunnel->debug, L2TP_MSG_CONTROL, KERN_INFO,
> -	       "%s: free...\n", tunnel->name);
> +	l2tp_info(tunnel, L2TP_MSG_CONTROL, "%s: free...\n", tunnel->name);
>  
>  	/* Remove from tunnel list */
>  	spin_lock_bh(&pn->l2tp_tunnel_list_lock);
> @@ -1536,7 +1522,7 @@ int l2tp_tunnel_create(struct net *net, int fd, int version, u32 tunnel_id, u32
>  		err = -EBADF;
>  		sock = sockfd_lookup(fd, &err);
>  		if (!sock) {
> -			printk(KERN_ERR "tunl %hu: sockfd_lookup(fd=%d) returned %d\n",
> +			pr_err("tunl %hu: sockfd_lookup(fd=%d) returned %d\n",
>  			       tunnel_id, fd, err);
>  			goto err;
>  		}
> @@ -1552,7 +1538,7 @@ int l2tp_tunnel_create(struct net *net, int fd, int version, u32 tunnel_id, u32
>  	case L2TP_ENCAPTYPE_UDP:
>  		err = -EPROTONOSUPPORT;
>  		if (sk->sk_protocol != IPPROTO_UDP) {
> -			printk(KERN_ERR "tunl %hu: fd %d wrong protocol, got %d, expected %d\n",
> +			pr_err("tunl %hu: fd %d wrong protocol, got %d, expected %d\n",
>  			       tunnel_id, fd, sk->sk_protocol, IPPROTO_UDP);
>  			goto err;
>  		}
> @@ -1560,7 +1546,7 @@ int l2tp_tunnel_create(struct net *net, int fd, int version, u32 tunnel_id, u32
>  	case L2TP_ENCAPTYPE_IP:
>  		err = -EPROTONOSUPPORT;
>  		if (sk->sk_protocol != IPPROTO_L2TP) {
> -			printk(KERN_ERR "tunl %hu: fd %d wrong protocol, got %d, expected %d\n",
> +			pr_err("tunl %hu: fd %d wrong protocol, got %d, expected %d\n",
>  			       tunnel_id, fd, sk->sk_protocol, IPPROTO_L2TP);
>  			goto err;
>  		}
> @@ -1868,7 +1854,7 @@ static int __init l2tp_init(void)
>  	if (rc)
>  		goto out;
>  
> -	printk(KERN_INFO "L2TP core driver, %s\n", L2TP_DRV_VERSION);
> +	pr_info("L2TP core driver, %s\n", L2TP_DRV_VERSION);
>  
>  out:
>  	return rc;
> diff --git a/net/l2tp/l2tp_core.h b/net/l2tp/l2tp_core.h
> index 9002634..a38ec6c 100644
> --- a/net/l2tp/l2tp_core.h
> +++ b/net/l2tp/l2tp_core.h
> @@ -261,17 +261,36 @@ static inline void l2tp_session_dec_refcount_1(struct l2tp_session *session)
>  }
>  
>  #ifdef L2TP_REFCNT_DEBUG
> -#define l2tp_session_inc_refcount(_s) do { \
> -		printk(KERN_DEBUG "l2tp_session_inc_refcount: %s:%d %s: cnt=%d\n", __func__, __LINE__, (_s)->name, atomic_read(&_s->ref_count)); \
> -		l2tp_session_inc_refcount_1(_s);				\
> -	} while (0)
> -#define l2tp_session_dec_refcount(_s) do { \
> -		printk(KERN_DEBUG "l2tp_session_dec_refcount: %s:%d %s: cnt=%d\n", __func__, __LINE__, (_s)->name, atomic_read(&_s->ref_count)); \
> -		l2tp_session_dec_refcount_1(_s);				\
> -	} while (0)
> +#define l2tp_session_inc_refcount(_s)					\
> +do {									\
> +	pr_debug("l2tp_session_inc_refcount: %s:%d %s: cnt=%d\n",	\
> +		 __func__, __LINE__, (_s)->name,			\
> +		 atomic_read(&_s->ref_count));				\
> +	l2tp_session_inc_refcount_1(_s);				\
> +} while (0)
> +#define l2tp_session_dec_refcount(_s)					\
> +do {									\
> +	pr_debug("l2tp_session_dec_refcount: %s:%d %s: cnt=%d\n",	\
> +		 __func__, __LINE__, (_s)->name,			\
> +		 atomic_read(&_s->ref_count));				\
> +	l2tp_session_dec_refcount_1(_s);				\
> +} while (0)
>  #else
>  #define l2tp_session_inc_refcount(s) l2tp_session_inc_refcount_1(s)
>  #define l2tp_session_dec_refcount(s) l2tp_session_dec_refcount_1(s)
>  #endif
>  
> +#define l2tp_printk(ptr, type, func, fmt, ...)				\
> +do {									\
> +	if (((ptr)->debug) & (type))					\
> +		func(fmt, ##__VA_ARGS__);				\
> +} while (0)
> +
> +#define l2tp_warn(ptr, type, fmt, ...)					\
> +	l2tp_printk(ptr, type, pr_warn, fmt, ##__VA_ARGS__)
> +#define l2tp_info(ptr, type, fmt, ...)					\
> +	l2tp_printk(ptr, type, pr_info, fmt, ##__VA_ARGS__)
> +#define l2tp_dbg(ptr, type, fmt, ...)					\
> +	l2tp_printk(ptr, type, pr_debug, fmt, ##__VA_ARGS__)
> +
>  #endif /* _L2TP_CORE_H_ */
> diff --git a/net/l2tp/l2tp_debugfs.c b/net/l2tp/l2tp_debugfs.c
> index c0d57ba..c3813bc 100644
> --- a/net/l2tp/l2tp_debugfs.c
> +++ b/net/l2tp/l2tp_debugfs.c
> @@ -9,6 +9,8 @@
>   *	2 of the License, or (at your option) any later version.
>   */
>  
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
>  #include <linux/module.h>
>  #include <linux/skbuff.h>
>  #include <linux/socket.h>
> @@ -325,11 +327,11 @@ static int __init l2tp_debugfs_init(void)
>  	if (tunnels == NULL)
>  		rc = -EIO;
>  
> -	printk(KERN_INFO "L2TP debugfs support\n");
> +	pr_info("L2TP debugfs support\n");
>  
>  out:
>  	if (rc)
> -		printk(KERN_WARNING "l2tp debugfs: unable to init\n");
> +		pr_warn("unable to init\n");
>  
>  	return rc;
>  }
> diff --git a/net/l2tp/l2tp_eth.c b/net/l2tp/l2tp_eth.c
> index 63fe5f3..443591d 100644
> --- a/net/l2tp/l2tp_eth.c
> +++ b/net/l2tp/l2tp_eth.c
> @@ -9,6 +9,8 @@
>   *	2 of the License, or (at your option) any later version.
>   */
>  
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
>  #include <linux/module.h>
>  #include <linux/skbuff.h>
>  #include <linux/socket.h>
> @@ -115,21 +117,14 @@ static void l2tp_eth_dev_recv(struct l2tp_session *session, struct sk_buff *skb,
>  
>  	if (session->debug & L2TP_MSG_DATA) {
>  		unsigned int length;
> -		int offset;
>  		u8 *ptr = skb->data;
>  
>  		length = min(32u, skb->len);
>  		if (!pskb_may_pull(skb, length))
>  			goto error;
>  
> -		printk(KERN_DEBUG "%s: eth recv: ", session->name);
> -
> -		offset = 0;
> -		do {
> -			printk(" %02X", ptr[offset]);
> -		} while (++offset < length);
> -
> -		printk("\n");
> +		pr_debug("%s: eth recv\n", session->name);
> +		print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, ptr, length);
>  	}
>  
>  	if (!pskb_may_pull(skb, sizeof(ETH_HLEN)))
> @@ -308,7 +303,7 @@ static int __init l2tp_eth_init(void)
>  	if (err)
>  		goto out_unreg;
>  
> -	printk(KERN_INFO "L2TP ethernet pseudowire support (L2TPv3)\n");
> +	pr_info("L2TP ethernet pseudowire support (L2TPv3)\n");
>  
>  	return 0;
>  
> diff --git a/net/l2tp/l2tp_ip.c b/net/l2tp/l2tp_ip.c
> index c89a32f..889f5d1 100644
> --- a/net/l2tp/l2tp_ip.c
> +++ b/net/l2tp/l2tp_ip.c
> @@ -9,6 +9,8 @@
>   *	2 of the License, or (at your option) any later version.
>   */
>  
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
>  #include <linux/icmp.h>
>  #include <linux/module.h>
>  #include <linux/skbuff.h>
> @@ -120,7 +122,6 @@ static int l2tp_ip_recv(struct sk_buff *skb)
>  	struct l2tp_session *session;
>  	struct l2tp_tunnel *tunnel = NULL;
>  	int length;
> -	int offset;
>  
>  	/* Point to L2TP header */
>  	optr = ptr = skb->data;
> @@ -155,14 +156,8 @@ static int l2tp_ip_recv(struct sk_buff *skb)
>  		if (!pskb_may_pull(skb, length))
>  			goto discard;
>  
> -		printk(KERN_DEBUG "%s: ip recv: ", tunnel->name);
> -
> -		offset = 0;
> -		do {
> -			printk(" %02X", ptr[offset]);
> -		} while (++offset < length);
> -
> -		printk("\n");
> +		pr_debug("%s: ip recv\n", tunnel->name);
> +		print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, ptr, length);
>  	}
>  
>  	l2tp_recv_common(session, skb, ptr, optr, 0, skb->len, tunnel->recv_payload_hook);
> @@ -593,7 +588,7 @@ static int __init l2tp_ip_init(void)
>  {
>  	int err;
>  
> -	printk(KERN_INFO "L2TP IP encapsulation support (L2TPv3)\n");
> +	pr_info("L2TP IP encapsulation support (L2TPv3)\n");
>  
>  	err = proto_register(&l2tp_ip_prot, 1);
>  	if (err != 0)
> diff --git a/net/l2tp/l2tp_ip6.c b/net/l2tp/l2tp_ip6.c
> index 88f0abe..0291d8d 100644
> --- a/net/l2tp/l2tp_ip6.c
> +++ b/net/l2tp/l2tp_ip6.c
> @@ -9,6 +9,8 @@
>   *	2 of the License, or (at your option) any later version.
>   */
>  
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
>  #include <linux/icmp.h>
>  #include <linux/module.h>
>  #include <linux/skbuff.h>
> @@ -133,7 +135,6 @@ static int l2tp_ip6_recv(struct sk_buff *skb)
>  	struct l2tp_session *session;
>  	struct l2tp_tunnel *tunnel = NULL;
>  	int length;
> -	int offset;
>  
>  	/* Point to L2TP header */
>  	optr = ptr = skb->data;
> @@ -168,14 +169,8 @@ static int l2tp_ip6_recv(struct sk_buff *skb)
>  		if (!pskb_may_pull(skb, length))
>  			goto discard;
>  
> -		printk(KERN_DEBUG "%s: ip recv: ", tunnel->name);
> -
> -		offset = 0;
> -		do {
> -			printk(" %02X", ptr[offset]);
> -		} while (++offset < length);
> -
> -		printk("\n");
> +		pr_debug("%s: ip recv\n", tunnel->name);
> +		print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, ptr, length);
>  	}
>  
>  	l2tp_recv_common(session, skb, ptr, optr, 0, skb->len,
> @@ -752,7 +747,7 @@ static int __init l2tp_ip6_init(void)
>  {
>  	int err;
>  
> -	printk(KERN_INFO "L2TP IP encapsulation support for IPv6 (L2TPv3)\n");
> +	pr_info("L2TP IP encapsulation support for IPv6 (L2TPv3)\n");
>  
>  	err = proto_register(&l2tp_ip6_prot, 1);
>  	if (err != 0)
> diff --git a/net/l2tp/l2tp_netlink.c b/net/l2tp/l2tp_netlink.c
> index 24edad0..8577264 100644
> --- a/net/l2tp/l2tp_netlink.c
> +++ b/net/l2tp/l2tp_netlink.c
> @@ -14,6 +14,8 @@
>   * published by the Free Software Foundation.
>   */
>  
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
>  #include <net/sock.h>
>  #include <net/genetlink.h>
>  #include <net/udp.h>
> @@ -902,7 +904,7 @@ static int l2tp_nl_init(void)
>  {
>  	int err;
>  
> -	printk(KERN_INFO "L2TP netlink interface\n");
> +	pr_info("L2TP netlink interface\n");
>  	err = genl_register_family_with_ops(&l2tp_nl_family, l2tp_nl_ops,
>  					    ARRAY_SIZE(l2tp_nl_ops));
>  
> diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c
> index 9f2c421..8ef6b94 100644
> --- a/net/l2tp/l2tp_ppp.c
> +++ b/net/l2tp/l2tp_ppp.c
> @@ -57,6 +57,8 @@
>   * http://openl2tp.sourceforge.net.
>   */
>  
> +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
> +
>  #include <linux/module.h>
>  #include <linux/string.h>
>  #include <linux/list.h>
> @@ -106,12 +108,6 @@
>  /* Space for UDP, L2TP and PPP headers */
>  #define PPPOL2TP_HEADER_OVERHEAD	40
>  
> -#define PRINTK(_mask, _type, _lvl, _fmt, args...)			\
> -	do {								\
> -		if ((_mask) & (_type))					\
> -			printk(_lvl "PPPOL2TP: " _fmt, ##args);		\
> -	} while (0)
> -
>  /* Number of bytes to build transmit L2TP headers.
>   * Unfortunately the size is different depending on whether sequence numbers
>   * are enabled.
> @@ -236,9 +232,9 @@ static void pppol2tp_recv(struct l2tp_session *session, struct sk_buff *skb, int
>  
>  	if (sk->sk_state & PPPOX_BOUND) {
>  		struct pppox_sock *po;
> -		PRINTK(session->debug, PPPOL2TP_MSG_DATA, KERN_DEBUG,
> -		       "%s: recv %d byte data frame, passing to ppp\n",
> -		       session->name, data_len);
> +		l2tp_dbg(session, PPPOL2TP_MSG_DATA,
> +			 "%s: recv %d byte data frame, passing to ppp\n",
> +			 session->name, data_len);
>  
>  		/* We need to forget all info related to the L2TP packet
>  		 * gathered in the skb as we are going to reuse the same
> @@ -259,8 +255,8 @@ static void pppol2tp_recv(struct l2tp_session *session, struct sk_buff *skb, int
>  		po = pppox_sk(sk);
>  		ppp_input(&po->chan, skb);
>  	} else {
> -		PRINTK(session->debug, PPPOL2TP_MSG_DATA, KERN_INFO,
> -		       "%s: socket not bound\n", session->name);
> +		l2tp_info(session, PPPOL2TP_MSG_DATA, "%s: socket not bound\n",
> +			  session->name);
>  
>  		/* Not bound. Nothing we can do, so discard. */
>  		session->stats.rx_errors++;
> @@ -270,8 +266,7 @@ static void pppol2tp_recv(struct l2tp_session *session, struct sk_buff *skb, int
>  	return;
>  
>  no_sock:
> -	PRINTK(session->debug, PPPOL2TP_MSG_DATA, KERN_INFO,
> -	       "%s: no socket\n", session->name);
> +	l2tp_info(session, PPPOL2TP_MSG_DATA, "%s: no socket\n", session->name);
>  	kfree_skb(skb);
>  }
>  
> @@ -827,8 +822,8 @@ out_no_ppp:
>  	/* This is how we get the session context from the socket. */
>  	sk->sk_user_data = session;
>  	sk->sk_state = PPPOX_CONNECTED;
> -	PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
> -	       "%s: created\n", session->name);
> +	l2tp_info(session, PPPOL2TP_MSG_CONTROL, "%s: created\n",
> +		  session->name);
>  
>  end:
>  	release_sock(sk);
> @@ -881,8 +876,8 @@ static int pppol2tp_session_create(struct net *net, u32 tunnel_id, u32 session_i
>  	ps = l2tp_session_priv(session);
>  	ps->tunnel_sock = tunnel->sock;
>  
> -	PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
> -	       "%s: created\n", session->name);
> +	l2tp_info(session, PPPOL2TP_MSG_CONTROL, "%s: created\n",
> +		  session->name);
>  
>  	error = 0;
>  
> @@ -1058,9 +1053,9 @@ static int pppol2tp_session_ioctl(struct l2tp_session *session,
>  	struct l2tp_tunnel *tunnel = session->tunnel;
>  	struct pppol2tp_ioc_stats stats;
>  
> -	PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_DEBUG,
> -	       "%s: pppol2tp_session_ioctl(cmd=%#x, arg=%#lx)\n",
> -	       session->name, cmd, arg);
> +	l2tp_dbg(session, PPPOL2TP_MSG_CONTROL,
> +		 "%s: pppol2tp_session_ioctl(cmd=%#x, arg=%#lx)\n",
> +		 session->name, cmd, arg);
>  
>  	sk = ps->sock;
>  	sock_hold(sk);
> @@ -1078,8 +1073,8 @@ static int pppol2tp_session_ioctl(struct l2tp_session *session,
>  		if (copy_to_user((void __user *) arg, &ifr, sizeof(struct ifreq)))
>  			break;
>  
> -		PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
> -		       "%s: get mtu=%d\n", session->name, session->mtu);
> +		l2tp_info(session, PPPOL2TP_MSG_CONTROL, "%s: get mtu=%d\n",
> +			  session->name, session->mtu);
>  		err = 0;
>  		break;
>  
> @@ -1094,8 +1089,8 @@ static int pppol2tp_session_ioctl(struct l2tp_session *session,
>  
>  		session->mtu = ifr.ifr_mtu;
>  
> -		PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
> -		       "%s: set mtu=%d\n", session->name, session->mtu);
> +		l2tp_info(session, PPPOL2TP_MSG_CONTROL, "%s: set mtu=%d\n",
> +			  session->name, session->mtu);
>  		err = 0;
>  		break;
>  
> @@ -1108,8 +1103,8 @@ static int pppol2tp_session_ioctl(struct l2tp_session *session,
>  		if (put_user(session->mru, (int __user *) arg))
>  			break;
>  
> -		PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
> -		       "%s: get mru=%d\n", session->name, session->mru);
> +		l2tp_info(session, PPPOL2TP_MSG_CONTROL, "%s: get mru=%d\n",
> +			  session->name, session->mru);
>  		err = 0;
>  		break;
>  
> @@ -1123,8 +1118,8 @@ static int pppol2tp_session_ioctl(struct l2tp_session *session,
>  			break;
>  
>  		session->mru = val;
> -		PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
> -		       "%s: set mru=%d\n", session->name, session->mru);
> +		l2tp_info(session, PPPOL2TP_MSG_CONTROL, "%s: set mru=%d\n",
> +			  session->name, session->mru);
>  		err = 0;
>  		break;
>  
> @@ -1133,8 +1128,8 @@ static int pppol2tp_session_ioctl(struct l2tp_session *session,
>  		if (put_user(ps->flags, (int __user *) arg))
>  			break;
>  
> -		PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
> -		       "%s: get flags=%d\n", session->name, ps->flags);
> +		l2tp_info(session, PPPOL2TP_MSG_CONTROL, "%s: get flags=%d\n",
> +			  session->name, ps->flags);
>  		err = 0;
>  		break;
>  
> @@ -1143,8 +1138,8 @@ static int pppol2tp_session_ioctl(struct l2tp_session *session,
>  		if (get_user(val, (int __user *) arg))
>  			break;
>  		ps->flags = val;
> -		PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
> -		       "%s: set flags=%d\n", session->name, ps->flags);
> +		l2tp_info(session, PPPOL2TP_MSG_CONTROL, "%s: set flags=%d\n",
> +			  session->name, ps->flags);
>  		err = 0;
>  		break;
>  
> @@ -1160,8 +1155,8 @@ static int pppol2tp_session_ioctl(struct l2tp_session *session,
>  		if (copy_to_user((void __user *) arg, &stats,
>  				 sizeof(stats)))
>  			break;
> -		PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
> -		       "%s: get L2TP stats\n", session->name);
> +		l2tp_info(session, PPPOL2TP_MSG_CONTROL, "%s: get L2TP stats\n",
> +			  session->name);
>  		err = 0;
>  		break;
>  
> @@ -1188,9 +1183,9 @@ static int pppol2tp_tunnel_ioctl(struct l2tp_tunnel *tunnel,
>  	struct sock *sk;
>  	struct pppol2tp_ioc_stats stats;
>  
> -	PRINTK(tunnel->debug, PPPOL2TP_MSG_CONTROL, KERN_DEBUG,
> -	       "%s: pppol2tp_tunnel_ioctl(cmd=%#x, arg=%#lx)\n",
> -	       tunnel->name, cmd, arg);
> +	l2tp_dbg(tunnel, PPPOL2TP_MSG_CONTROL,
> +		 "%s: pppol2tp_tunnel_ioctl(cmd=%#x, arg=%#lx)\n",
> +		 tunnel->name, cmd, arg);
>  
>  	sk = tunnel->sock;
>  	sock_hold(sk);
> @@ -1224,8 +1219,8 @@ static int pppol2tp_tunnel_ioctl(struct l2tp_tunnel *tunnel,
>  			err = -EFAULT;
>  			break;
>  		}
> -		PRINTK(tunnel->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
> -		       "%s: get L2TP stats\n", tunnel->name);
> +		l2tp_info(tunnel, PPPOL2TP_MSG_CONTROL, "%s: get L2TP stats\n",
> +			  tunnel->name);
>  		err = 0;
>  		break;
>  
> @@ -1314,8 +1309,8 @@ static int pppol2tp_tunnel_setsockopt(struct sock *sk,
>  	switch (optname) {
>  	case PPPOL2TP_SO_DEBUG:
>  		tunnel->debug = val;
> -		PRINTK(tunnel->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
> -		       "%s: set debug=%x\n", tunnel->name, tunnel->debug);
> +		l2tp_info(tunnel, PPPOL2TP_MSG_CONTROL, "%s: set debug=%x\n",
> +			  tunnel->name, tunnel->debug);
>  		break;
>  
>  	default:
> @@ -1342,8 +1337,9 @@ static int pppol2tp_session_setsockopt(struct sock *sk,
>  			break;
>  		}
>  		session->recv_seq = val ? -1 : 0;
> -		PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
> -		       "%s: set recv_seq=%d\n", session->name, session->recv_seq);
> +		l2tp_info(session, PPPOL2TP_MSG_CONTROL,
> +			  "%s: set recv_seq=%d\n",
> +			  session->name, session->recv_seq);
>  		break;
>  
>  	case PPPOL2TP_SO_SENDSEQ:
> @@ -1358,8 +1354,9 @@ static int pppol2tp_session_setsockopt(struct sock *sk,
>  			po->chan.hdrlen = val ? PPPOL2TP_L2TP_HDR_SIZE_SEQ :
>  				PPPOL2TP_L2TP_HDR_SIZE_NOSEQ;
>  		}
> -		PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
> -		       "%s: set send_seq=%d\n", session->name, session->send_seq);
> +		l2tp_info(session, PPPOL2TP_MSG_CONTROL,
> +			  "%s: set send_seq=%d\n",
> +			  session->name, session->send_seq);
>  		break;
>  
>  	case PPPOL2TP_SO_LNSMODE:
> @@ -1368,20 +1365,22 @@ static int pppol2tp_session_setsockopt(struct sock *sk,
>  			break;
>  		}
>  		session->lns_mode = val ? -1 : 0;
> -		PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
> -		       "%s: set lns_mode=%d\n", session->name, session->lns_mode);
> +		l2tp_info(session, PPPOL2TP_MSG_CONTROL,
> +			  "%s: set lns_mode=%d\n",
> +			  session->name, session->lns_mode);
>  		break;
>  
>  	case PPPOL2TP_SO_DEBUG:
>  		session->debug = val;
> -		PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
> -		       "%s: set debug=%x\n", session->name, session->debug);
> +		l2tp_info(session, PPPOL2TP_MSG_CONTROL, "%s: set debug=%x\n",
> +			  session->name, session->debug);
>  		break;
>  
>  	case PPPOL2TP_SO_REORDERTO:
>  		session->reorder_timeout = msecs_to_jiffies(val);
> -		PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
> -		       "%s: set reorder_timeout=%d\n", session->name, session->reorder_timeout);
> +		l2tp_info(session, PPPOL2TP_MSG_CONTROL,
> +			  "%s: set reorder_timeout=%d\n",
> +			  session->name, session->reorder_timeout);
>  		break;
>  
>  	default:
> @@ -1460,8 +1459,8 @@ static int pppol2tp_tunnel_getsockopt(struct sock *sk,
>  	switch (optname) {
>  	case PPPOL2TP_SO_DEBUG:
>  		*val = tunnel->debug;
> -		PRINTK(tunnel->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
> -		       "%s: get debug=%x\n", tunnel->name, tunnel->debug);
> +		l2tp_info(tunnel, PPPOL2TP_MSG_CONTROL, "%s: get debug=%x\n",
> +			  tunnel->name, tunnel->debug);
>  		break;
>  
>  	default:
> @@ -1483,32 +1482,32 @@ static int pppol2tp_session_getsockopt(struct sock *sk,
>  	switch (optname) {
>  	case PPPOL2TP_SO_RECVSEQ:
>  		*val = session->recv_seq;
> -		PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
> -		       "%s: get recv_seq=%d\n", session->name, *val);
> +		l2tp_info(session, PPPOL2TP_MSG_CONTROL,
> +			  "%s: get recv_seq=%d\n", session->name, *val);
>  		break;
>  
>  	case PPPOL2TP_SO_SENDSEQ:
>  		*val = session->send_seq;
> -		PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
> -		       "%s: get send_seq=%d\n", session->name, *val);
> +		l2tp_info(session, PPPOL2TP_MSG_CONTROL,
> +			  "%s: get send_seq=%d\n", session->name, *val);
>  		break;
>  
>  	case PPPOL2TP_SO_LNSMODE:
>  		*val = session->lns_mode;
> -		PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
> -		       "%s: get lns_mode=%d\n", session->name, *val);
> +		l2tp_info(session, PPPOL2TP_MSG_CONTROL,
> +			  "%s: get lns_mode=%d\n", session->name, *val);
>  		break;
>  
>  	case PPPOL2TP_SO_DEBUG:
>  		*val = session->debug;
> -		PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
> -		       "%s: get debug=%d\n", session->name, *val);
> +		l2tp_info(session, PPPOL2TP_MSG_CONTROL, "%s: get debug=%d\n",
> +			  session->name, *val);
>  		break;
>  
>  	case PPPOL2TP_SO_REORDERTO:
>  		*val = (int) jiffies_to_msecs(session->reorder_timeout);
> -		PRINTK(session->debug, PPPOL2TP_MSG_CONTROL, KERN_INFO,
> -		       "%s: get reorder_timeout=%d\n", session->name, *val);
> +		l2tp_info(session, PPPOL2TP_MSG_CONTROL,
> +			  "%s: get reorder_timeout=%d\n", session->name, *val);
>  		break;
>  
>  	default:
> @@ -1871,8 +1870,7 @@ static int __init pppol2tp_init(void)
>  		goto out_unregister_pppox;
>  #endif
>  
> -	printk(KERN_INFO "PPPoL2TP kernel driver, %s\n",
> -	       PPPOL2TP_DRV_VERSION);
> +	pr_info("PPPoL2TP kernel driver, %s\n", PPPOL2TP_DRV_VERSION);
>  
>  out:
>  	return err;
> 
> 



-- 
James Chapman
Katalix Systems Ltd
http://www.katalix.com
Catalysts for your Embedded Linux software development

^ permalink raw reply

* Re: [PATCH 1/1] smsc95xx: add FLAG_POINTTOPOINT flag for driver_info
From: Xiao Jiang @ 2012-05-17  8:06 UTC (permalink / raw)
  To: Sergei Shtylyov
  Cc: steve.glendinning, gregkh, netdev, linux-usb, linux-kernel
In-Reply-To: <4FB3A74E.4060303@mvista.com>

Sergei Shtylyov wrote:
> Hello.
>
> On 16-05-2012 12:01, jgq516@gmail.com wrote:
>
>> From: Xiao Jiang<jgq516@gmail.com>
>
>> commit c26134 introduced FLAG_POINTTOPOINT flag for USB ethernet devices
>
>    Please also specify that commit's summary in parens.
Thanks, will add the summary if this patch does make sense.

Regards,
Xiao
>
>> which possibly use "usb%d" names, add this flag to make sure pandaboard
>> can mount nfs with smsc95xx NIC.
>
>> Signed-off-by: Xiao Jiang<jgq516@gmail.com>
>
> WBR, Sergei

^ permalink raw reply

* Re[2]:  [PATCH] netfilter: xt_HMARK: fix endian bugs and warnings
From: Hans Schillstrom @ 2012-05-17  8:07 UTC (permalink / raw)
  To: Pablo Neira Ayuso
  Cc: Hans Schillstrom, kaber, jengelh, netfilter-devel, netdev,
	dan.carpenter

>
>On Wed, May 16, 2012 at 05:00:42PM +0200, Hans Schillstrom wrote:
>> A mix of u32 and __be32 causes endian warning.
>> The hash value produced is now the same for big and little endian machines.
>> i.e. a mix of Big and Little endian in a cluster is now possible.
>> 
>> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
>> Signed-off-by: Hans Schillstrom <hans.schillstrom@ericsson.com>
>> ---
>>  include/linux/netfilter/xt_HMARK.h |    5 ++-
>>  net/netfilter/xt_HMARK.c           |   68 ++++++++++++++++++++---------------
>>  2 files changed, 42 insertions(+), 31 deletions(-)
>> 
>> diff --git a/include/linux/netfilter/xt_HMARK.h b/include/linux/netfilter/xt_HMARK.h
>> index abb1650..8b6307a 100644
>> --- a/include/linux/netfilter/xt_HMARK.h
>> +++ b/include/linux/netfilter/xt_HMARK.h
>> @@ -24,10 +24,11 @@ enum {
>>  
>>  union hmark_ports {
>>  	struct {
>> -		__u16	src;
>> -		__u16	dst;
>> +		__be16	src;
>> +		__be16	dst;
>>  	} p16;
>>  	__u32	v32;
>> +	__be32	b32;
>>  };
>>  
>>  struct xt_hmark_info {
>> diff --git a/net/netfilter/xt_HMARK.c b/net/netfilter/xt_HMARK.c
>> index 32fbd73..7bb7b5e 100644
>> --- a/net/netfilter/xt_HMARK.c
>> +++ b/net/netfilter/xt_HMARK.c
>> @@ -32,13 +32,13 @@ MODULE_ALIAS("ipt_HMARK");
>>  MODULE_ALIAS("ip6t_HMARK");
>>  
>>  struct hmark_tuple {
>> -	u32			src;
>> -	u32			dst;
>> +	__be32			src;
>> +	__be32			dst;
>>  	union hmark_ports	uports;
>>  	uint8_t			proto;
>>  };
>>  
>> -static inline u32 hmark_addr6_mask(const __u32 *addr32, const __u32 *mask)
>> +static inline __be32 hmark_addr6_mask(const __be32 *addr32, const __be32 *mask)
>>  {
>>  	return (addr32[0] & mask[0]) ^
>>  	       (addr32[1] & mask[1]) ^
>> @@ -46,8 +46,8 @@ static inline u32 hmark_addr6_mask(const __u32 *addr32, const __u32 *mask)
>>  	       (addr32[3] & mask[3]);
>>  }
>>  
>> -static inline u32
>> -hmark_addr_mask(int l3num, const __u32 *addr32, const __u32 *mask)
>> +static inline __be32
>> +hmark_addr_mask(int l3num, const __be32 *addr32, const __be32 *mask)
>>  {
>>  	switch (l3num) {
>>  	case AF_INET:
>> @@ -58,6 +58,25 @@ hmark_addr_mask(int l3num, const __u32 *addr32, const __u32 *mask)
>>  	return 0;
>>  }
>>  
>> +static inline void hmark_port_order(union hmark_ports *uports,
>
>comestical change, better call this hmark_swap_ports

>
>> +				    const struct xt_hmark_info *info)
>> +{
>> +	union hmark_ports hp;
>> +
>> +	hp.b32 = (uports->b32 & info->port_mask.b32) | info->port_set.b32;
>> +	hp.v32 = ntohl(hp.b32);
>> +	/* Make it endian safe into jhash() */
>> +#if defined(__LITTLE_ENDIAN)
>> +	if ((__force u16) uports->p16.dst >
>> +	    (__force u16) uports->p16.src)
>> +#else
>> +	if ((__force u16) uports->p16.src >
>> +	    (__force u16) uports->p16.dst)
>> +#endif
>
>This ifdef is ugly. 

Indeed,  but it saves some cpu cycles 

>I prefer if you use ntohs the ports and store the values in some local variable, 
>then compare and swap if required.
>
>Just like you do with the IPv4 address.

Ok, to make it endian safe a shift is required.
Like this:

        hp.b32 = (uports->b32 & info->port_mask.b32) | info->port_set.b32;
        src = ntohs(hp.b16.src);
        dst = ntohs(hp.b16.dst);

        if (dst > src)
                uports->v32 = (dst << 16) | src;
        else
                uports->v32 = (src << 16) | dst;

>
>> +		swap(hp.p16.src, hp.p16.dst);
>> +	uports->v32 = hp.v32;
>> +}
>> +

I'll re-spin the patch




^ permalink raw reply

* RE: [PATCH 3/7] netfilter: xt_HMARK: modulus is expensive for hash calculation
From: David Laight @ 2012-05-17  8:16 UTC (permalink / raw)
  To: pablo, netfilter-devel; +Cc: davem, netdev
In-Reply-To: <1337209604-3412-4-git-send-email-pablo@netfilter.org>

 
> From: Pablo Neira Ayuso <pablo@netfilter.org>
> 
> Use:
> 
> ((u64)(HASH_VAL * HASH_SIZE)) >> 32
> 
> as suggested by David S. Miller.

That (u64) cast is very unlikely to have any effect.
If you want a 64 bit result from the product of two
32 bit values, you have to cast one of the 32 bit values
prior to the multiply - as in the patch below.

	David

> 
> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
> ---
>  net/netfilter/xt_HMARK.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/netfilter/xt_HMARK.c b/net/netfilter/xt_HMARK.c
> index 5817d03..0a96a43 100644
> --- a/net/netfilter/xt_HMARK.c
> +++ b/net/netfilter/xt_HMARK.c
> @@ -109,7 +109,7 @@ hmark_hash(struct hmark_tuple *t, const 
> struct xt_hmark_info *info)
>  	hash = jhash_3words(t->src, t->dst, t->uports.v32, 
> info->hashrnd);
>  	hash = hash ^ (t->proto & info->proto_mask);
>  
> -	return (hash % info->hmodulus) + info->hoffset;
> +	return (((u64)hash * info->hmodulus) >> 32) + info->hoffset;
>  }
>  
>  static void
> -- 
> 1.7.10
> 
> --
> 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 1/1] smsc95xx: add FLAG_POINTTOPOINT flag for driver_info
From: Ming Lei @ 2012-05-17  8:20 UTC (permalink / raw)
  To: Xiao Jiang; +Cc: steve.glendinning, gregkh, netdev, linux-usb, linux-kernel
In-Reply-To: <4FB4613B.3020603@gmail.com>

On Thu, May 17, 2012 at 10:23 AM, Xiao Jiang <jgq516@gmail.com> wrote:
> Ming Lei wrote:
>>
>> On Wed, May 16, 2012 at 4:01 PM,  <jgq516@gmail.com> wrote:
>>
>>>
>>> From: Xiao Jiang <jgq516@gmail.com>
>>>
>>> commit c26134 introduced FLAG_POINTTOPOINT flag for USB ethernet devices
>>> which possibly use "usb%d" names, add this flag to make sure pandaboard
>>> can mount nfs with smsc95xx NIC.
>>>
>>
>>
>> Without the flag, I also can mount nfs successfully on my Pandaboard...

I always mount nfs in console, and not tried to mount nfs as root fs.

>>
>>
>
> I have pulled latest tree
> (git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
> commit 0e93b4b304ae052ba1bc73f6d34a68556fe93429), and enable related options
> (USB_NET_SMSC95XX,
> USB_EHCI_HCD and USB_EHCI_HCD_OMAP) with omap2plus_config, However the
> kernel still can't mount
> nfs, pls see below infos.
>
> [    3.114105] smsc95xx v1.0.4
> [    4.533752] smsc95xx 1-1.1:1.0: *eth0*: register 'smsc95xx' at
> usb-ehci-omap.0-1.1, smsc95xx USB 2.0 Ethernet, fe:b9:1b:07:8e:d1
> [  108.854217] VFS: Unable to mount root fs via NFS, trying floppy.
> [  108.861114] VFS: Cannot open root device "nfs" or unknown-block(2,0):
> error -6
> [  108.868713] Please append a correct "root=" boot option; here are the
> available partitions:
> [  108.877655] b300         7761920 mmcblk0  driver: mmcblk
> [  108.883239]   b301           40131 mmcblk0p1
> 00000000-0000-0000-0000-000000000mmcblk0p1
> [  108.891662]   b302         7719232 mmcblk0p2
> 00000000-0000-0000-0000-000000000mmcblk0p2
> [  108.900146] Kernel panic - not syncing: VFS: Unable to mount root fs on
> unknown-block(2,0)
>
> BTW: I tested it with OMAP4430 ES2.2 pandaboard, the issue can be solved
> with apply the patch.
>
> Is there something which I missed? thanks.

What is your kernel parameter? Maybe you use 'usb%d' in kernel parameter for
mounting nfs as root fs. If so, could you try 'eth%d' in kernel cmd?

In fact, smsc95xx is a real LAN interface, and 'eth%d' should be prefered name
as described in changelog of commit
c261344d3ce3edac781f9d3c7eabe2e96d8e8fe8(usbnet:use eth%d name for
known ethernet devices)


Thanks,
-- 
Ming Lei

^ permalink raw reply

* Re: [PATCH net-next] net: l2tp: Standardize logging styles
From: David Miller @ 2012-05-17  8:34 UTC (permalink / raw)
  To: jchapman; +Cc: joe, netdev, linux-kernel
In-Reply-To: <4FB4ACD1.10509@katalix.com>

From: James Chapman <jchapman@katalix.com>
Date: Thu, 17 May 2012 08:46:25 +0100

> This is a good improvement. Thanks!
> 
> Signed-off-by: James Chapman <jchapman@katalix.com>

James, please don't quote an entire patch when ACK'ing a patch like.
Do you realize that this makes the whole patch have to be processed by
every recipient subscribed to these mailing lists as well as sites
that monitor discussions on patches such as patchwork?

Even if you want to comment on some portions of the patch, you should
only quote the very specific hunks you wish to comment upon.

It is absolutely never appropriate to quote an entire patch in an
email response, really.

Anyways I'll apply this patch, thanks everyone.

^ permalink raw reply

* RE: [PATCH 3/7] netfilter: xt_HMARK: modulus is expensive for hash calculation
From: Eric Dumazet @ 2012-05-17  8:39 UTC (permalink / raw)
  To: David Laight; +Cc: pablo, netfilter-devel, davem, netdev
In-Reply-To: <AE90C24D6B3A694183C094C60CF0A2F6026B6F10@saturn3.aculab.com>

On Thu, 2012-05-17 at 09:16 +0100, David Laight wrote:
> > From: Pablo Neira Ayuso <pablo@netfilter.org>
> > 
> > Use:
> > 
> > ((u64)(HASH_VAL * HASH_SIZE)) >> 32
> > 
> > as suggested by David S. Miller.
> 
> That (u64) cast is very unlikely to have any effect.
> If you want a 64 bit result from the product of two
> 32 bit values, you have to cast one of the 32 bit values
> prior to the multiply - as in the patch below.

Hey, Changelog is a bit wrong (for several reasons) but code is correct.

return (((u64)hash * info->hmodulus) >> 32) + info->hoffset;

^ permalink raw reply

* Re: [PATCH 1/1] smsc95xx: add FLAG_POINTTOPOINT flag for driver_info
From: Xiao Jiang @ 2012-05-17  8:40 UTC (permalink / raw)
  To: Ben Hutchings; +Cc: steve.glendinning, gregkh, netdev, linux-usb, linux-kernel
In-Reply-To: <1337168320.4107.42.camel@deadeye>

Ben Hutchings wrote:
> On Wed, 2012-05-16 at 16:01 +0800, jgq516@gmail.com wrote:
>   
>> From: Xiao Jiang <jgq516@gmail.com>
>>
>> commit c26134 introduced FLAG_POINTTOPOINT flag for USB ethernet devices
>> which possibly use "usb%d" names, add this flag to make sure pandaboard
>> can mount nfs with smsc95xx NIC.
>>     
>
> These are normal Ethernet interfaces, whereas FLAG_POINTTOPOINT is for
> devices that use non-standard short physical links.
>
>   
This flag is used by some usb NICs, I amn't familiar with those cards 
perhaps those are
non-standard short physical links as you said.
But smsc95xx seems need this flag to use "usb%d" name, at least my 
pandaboard can't
mount nfs with eth0 name, is there other ways to avoid nfs issue with 
keep smsc95xx's
name unchange? thanks.

-bash-3.2$ grep FLAG_POINTTOPOINT * -r
drivers/net/usb/zaurus.c:    .flags =    FLAG_POINTTOPOINT | FLAG_FRAMING_Z,
drivers/net/usb/zaurus.c:    .flags =    FLAG_POINTTOPOINT | FLAG_FRAMING_Z,
drivers/net/usb/zaurus.c:    .flags =    FLAG_POINTTOPOINT | FLAG_FRAMING_Z,
drivers/net/usb/zaurus.c:    .flags =    FLAG_POINTTOPOINT | FLAG_FRAMING_Z,
drivers/net/usb/cdc_ncm.c:    .flags = FLAG_POINTTOPOINT | 
FLAG_NO_SETINT | FLAG_MULTI_PACKET,
drivers/net/usb/gl620a.c:    .flags =    FLAG_POINTTOPOINT | 
FLAG_FRAMING_GL | FLAG_NO_SETINT,
drivers/net/usb/plusb.c:    .flags =    FLAG_POINTTOPOINT | FLAG_NO_SETINT,
drivers/net/usb/usbnet.c:            ((dev->driver_info->flags & 
FLAG_POINTTOPOINT) == 0 ||
drivers/net/usb/cdc_subset.c:    .flags       = FLAG_POINTTOPOINT,
drivers/net/usb/cdc_subset.c:    .flags       = FLAG_POINTTOPOINT,
drivers/net/usb/cdc_subset.c:    .flags       = FLAG_POINTTOPOINT,
drivers/net/usb/cdc_subset.c:    .flags = FLAG_POINTTOPOINT,
drivers/net/usb/cdc_subset.c:    .flags = FLAG_POINTTOPOINT,
drivers/net/usb/cdc_subset.c:    .flags = FLAG_POINTTOPOINT,
drivers/net/usb/cdc_subset.c:    .flags = FLAG_POINTTOPOINT,
drivers/net/usb/cdc_subset.c:    .flags = FLAG_POINTTOPOINT,
drivers/net/usb/cdc_eem.c:    .flags =    FLAG_ETHER | FLAG_POINTTOPOINT,
drivers/net/usb/rndis_host.c:    .flags =    FLAG_ETHER | 
FLAG_POINTTOPOINT | FLAG_FRAMING_RN | FLAG_NO_SETINT,
drivers/net/usb/rndis_host.c:    .flags =    FLAG_ETHER | 
FLAG_POINTTOPOINT | FLAG_FRAMING_RN | FLAG_NO_SETINT,
drivers/net/usb/cdc_ether.c:    .flags =    FLAG_ETHER | FLAG_POINTTOPOINT,
drivers/net/usb/net1080.c:    .flags =    FLAG_POINTTOPOINT | 
FLAG_FRAMING_NC,
include/linux/usb/usbnet.h:#define FLAG_POINTTOPOINT 0x1000    /* 
possibly use "usb%d" names */

Regards,
Xiao
> Ben.
>
>   
>> Signed-off-by: Xiao Jiang <jgq516@gmail.com>
>> ---
>>  drivers/net/usb/smsc95xx.c |    3 ++-
>>  1 files changed, 2 insertions(+), 1 deletions(-)
>>
>> diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
>> index 94ae669..e158288 100644
>> --- a/drivers/net/usb/smsc95xx.c
>> +++ b/drivers/net/usb/smsc95xx.c
>> @@ -1192,7 +1192,8 @@ static const struct driver_info smsc95xx_info = {
>>  	.rx_fixup	= smsc95xx_rx_fixup,
>>  	.tx_fixup	= smsc95xx_tx_fixup,
>>  	.status		= smsc95xx_status,
>> -	.flags		= FLAG_ETHER | FLAG_SEND_ZLP | FLAG_LINK_INTR,
>> +	.flags		= FLAG_ETHER | FLAG_POINTTOPOINT | FLAG_SEND_ZLP |
>> +			  FLAG_LINK_INTR,
>>  };
>>  
>>  static const struct usb_device_id products[] = {
>>     
>
>   

^ permalink raw reply

* [PATCH net-next] net: include/net/sock.h cleanup
From: Eric Dumazet @ 2012-05-17  8:48 UTC (permalink / raw)
  To: David Miller; +Cc: netdev

From: Eric Dumazet <edumazet@google.com>

bool/const conversions where possible

__inline__ -> inline

space cleanups

Signed-off-by: Eric Dumazet <edumazet@google.com>
---
 include/net/sock.h |  151 +++++++++++++++++++++----------------------
 net/dccp/proto.c   |    4 -
 net/ipv4/tcp.c     |   12 +--
 net/llc/af_llc.c   |    4 -
 4 files changed, 84 insertions(+), 87 deletions(-)

diff --git a/include/net/sock.h b/include/net/sock.h
index 0e7c4f4..e993c81 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -97,7 +97,7 @@ void mem_cgroup_sockets_destroy(struct cgroup *cgrp)
 #else
 /* Validate arguments and do nothing */
 static inline __printf(2, 3)
-void SOCK_DEBUG(struct sock *sk, const char *msg, ...)
+void SOCK_DEBUG(const struct sock *sk, const char *msg, ...)
 {
 }
 #endif
@@ -372,8 +372,8 @@ struct sock {
 	void			(*sk_data_ready)(struct sock *sk, int bytes);
 	void			(*sk_write_space)(struct sock *sk);
 	void			(*sk_error_report)(struct sock *sk);
-  	int			(*sk_backlog_rcv)(struct sock *sk,
-						  struct sk_buff *skb);  
+	int			(*sk_backlog_rcv)(struct sock *sk,
+						  struct sk_buff *skb);
 	void                    (*sk_destruct)(struct sock *sk);
 };
 
@@ -454,40 +454,40 @@ static inline struct sock *sk_nulls_next(const struct sock *sk)
 		NULL;
 }
 
-static inline int sk_unhashed(const struct sock *sk)
+static inline bool sk_unhashed(const struct sock *sk)
 {
 	return hlist_unhashed(&sk->sk_node);
 }
 
-static inline int sk_hashed(const struct sock *sk)
+static inline bool sk_hashed(const struct sock *sk)
 {
 	return !sk_unhashed(sk);
 }
 
-static __inline__ void sk_node_init(struct hlist_node *node)
+static inline void sk_node_init(struct hlist_node *node)
 {
 	node->pprev = NULL;
 }
 
-static __inline__ void sk_nulls_node_init(struct hlist_nulls_node *node)
+static inline void sk_nulls_node_init(struct hlist_nulls_node *node)
 {
 	node->pprev = NULL;
 }
 
-static __inline__ void __sk_del_node(struct sock *sk)
+static inline void __sk_del_node(struct sock *sk)
 {
 	__hlist_del(&sk->sk_node);
 }
 
 /* NB: equivalent to hlist_del_init_rcu */
-static __inline__ int __sk_del_node_init(struct sock *sk)
+static inline bool __sk_del_node_init(struct sock *sk)
 {
 	if (sk_hashed(sk)) {
 		__sk_del_node(sk);
 		sk_node_init(&sk->sk_node);
-		return 1;
+		return true;
 	}
-	return 0;
+	return false;
 }
 
 /* Grab socket reference count. This operation is valid only
@@ -509,9 +509,9 @@ static inline void __sock_put(struct sock *sk)
 	atomic_dec(&sk->sk_refcnt);
 }
 
-static __inline__ int sk_del_node_init(struct sock *sk)
+static inline bool sk_del_node_init(struct sock *sk)
 {
-	int rc = __sk_del_node_init(sk);
+	bool rc = __sk_del_node_init(sk);
 
 	if (rc) {
 		/* paranoid for a while -acme */
@@ -522,18 +522,18 @@ static __inline__ int sk_del_node_init(struct sock *sk)
 }
 #define sk_del_node_init_rcu(sk)	sk_del_node_init(sk)
 
-static __inline__ int __sk_nulls_del_node_init_rcu(struct sock *sk)
+static inline bool __sk_nulls_del_node_init_rcu(struct sock *sk)
 {
 	if (sk_hashed(sk)) {
 		hlist_nulls_del_init_rcu(&sk->sk_nulls_node);
-		return 1;
+		return true;
 	}
-	return 0;
+	return false;
 }
 
-static __inline__ int sk_nulls_del_node_init_rcu(struct sock *sk)
+static inline bool sk_nulls_del_node_init_rcu(struct sock *sk)
 {
-	int rc = __sk_nulls_del_node_init_rcu(sk);
+	bool rc = __sk_nulls_del_node_init_rcu(sk);
 
 	if (rc) {
 		/* paranoid for a while -acme */
@@ -543,40 +543,40 @@ static __inline__ int sk_nulls_del_node_init_rcu(struct sock *sk)
 	return rc;
 }
 
-static __inline__ void __sk_add_node(struct sock *sk, struct hlist_head *list)
+static inline void __sk_add_node(struct sock *sk, struct hlist_head *list)
 {
 	hlist_add_head(&sk->sk_node, list);
 }
 
-static __inline__ void sk_add_node(struct sock *sk, struct hlist_head *list)
+static inline void sk_add_node(struct sock *sk, struct hlist_head *list)
 {
 	sock_hold(sk);
 	__sk_add_node(sk, list);
 }
 
-static __inline__ void sk_add_node_rcu(struct sock *sk, struct hlist_head *list)
+static inline void sk_add_node_rcu(struct sock *sk, struct hlist_head *list)
 {
 	sock_hold(sk);
 	hlist_add_head_rcu(&sk->sk_node, list);
 }
 
-static __inline__ void __sk_nulls_add_node_rcu(struct sock *sk, struct hlist_nulls_head *list)
+static inline void __sk_nulls_add_node_rcu(struct sock *sk, struct hlist_nulls_head *list)
 {
 	hlist_nulls_add_head_rcu(&sk->sk_nulls_node, list);
 }
 
-static __inline__ void sk_nulls_add_node_rcu(struct sock *sk, struct hlist_nulls_head *list)
+static inline void sk_nulls_add_node_rcu(struct sock *sk, struct hlist_nulls_head *list)
 {
 	sock_hold(sk);
 	__sk_nulls_add_node_rcu(sk, list);
 }
 
-static __inline__ void __sk_del_bind_node(struct sock *sk)
+static inline void __sk_del_bind_node(struct sock *sk)
 {
 	__hlist_del(&sk->sk_bind_node);
 }
 
-static __inline__ void sk_add_bind_node(struct sock *sk,
+static inline void sk_add_bind_node(struct sock *sk,
 					struct hlist_head *list)
 {
 	hlist_add_head(&sk->sk_bind_node, list);
@@ -665,7 +665,7 @@ static inline void sk_acceptq_added(struct sock *sk)
 	sk->sk_ack_backlog++;
 }
 
-static inline int sk_acceptq_is_full(struct sock *sk)
+static inline bool sk_acceptq_is_full(const struct sock *sk)
 {
 	return sk->sk_ack_backlog > sk->sk_max_ack_backlog;
 }
@@ -673,19 +673,19 @@ static inline int sk_acceptq_is_full(struct sock *sk)
 /*
  * Compute minimal free write space needed to queue new packets.
  */
-static inline int sk_stream_min_wspace(struct sock *sk)
+static inline int sk_stream_min_wspace(const struct sock *sk)
 {
 	return sk->sk_wmem_queued >> 1;
 }
 
-static inline int sk_stream_wspace(struct sock *sk)
+static inline int sk_stream_wspace(const struct sock *sk)
 {
 	return sk->sk_sndbuf - sk->sk_wmem_queued;
 }
 
 extern void sk_stream_write_space(struct sock *sk);
 
-static inline int sk_stream_memory_free(struct sock *sk)
+static inline bool sk_stream_memory_free(const struct sock *sk)
 {
 	return sk->sk_wmem_queued < sk->sk_sndbuf;
 }
@@ -809,26 +809,26 @@ struct module;
  * transport -> network interface is defined by struct inet_proto
  */
 struct proto {
-	void			(*close)(struct sock *sk, 
+	void			(*close)(struct sock *sk,
 					long timeout);
 	int			(*connect)(struct sock *sk,
-				        struct sockaddr *uaddr, 
+					struct sockaddr *uaddr,
 					int addr_len);
 	int			(*disconnect)(struct sock *sk, int flags);
 
-	struct sock *		(*accept) (struct sock *sk, int flags, int *err);
+	struct sock *		(*accept)(struct sock *sk, int flags, int *err);
 
 	int			(*ioctl)(struct sock *sk, int cmd,
 					 unsigned long arg);
 	int			(*init)(struct sock *sk);
 	void			(*destroy)(struct sock *sk);
 	void			(*shutdown)(struct sock *sk, int how);
-	int			(*setsockopt)(struct sock *sk, int level, 
+	int			(*setsockopt)(struct sock *sk, int level,
 					int optname, char __user *optval,
 					unsigned int optlen);
-	int			(*getsockopt)(struct sock *sk, int level, 
-					int optname, char __user *optval, 
-					int __user *option);  	 
+	int			(*getsockopt)(struct sock *sk, int level,
+					int optname, char __user *optval,
+					int __user *option);
 #ifdef CONFIG_COMPAT
 	int			(*compat_setsockopt)(struct sock *sk,
 					int level,
@@ -845,14 +845,14 @@ struct proto {
 					   struct msghdr *msg, size_t len);
 	int			(*recvmsg)(struct kiocb *iocb, struct sock *sk,
 					   struct msghdr *msg,
-					size_t len, int noblock, int flags, 
-					int *addr_len);
+					   size_t len, int noblock, int flags,
+					   int *addr_len);
 	int			(*sendpage)(struct sock *sk, struct page *page,
 					int offset, size_t size, int flags);
-	int			(*bind)(struct sock *sk, 
+	int			(*bind)(struct sock *sk,
 					struct sockaddr *uaddr, int addr_len);
 
-	int			(*backlog_rcv) (struct sock *sk, 
+	int			(*backlog_rcv) (struct sock *sk,
 						struct sk_buff *skb);
 
 	/* Keeping track of sk's, looking them up, and port selection methods. */
@@ -1173,7 +1173,7 @@ proto_memory_pressure(struct proto *prot)
 extern void sock_prot_inuse_add(struct net *net, struct proto *prot, int inc);
 extern int sock_prot_inuse_get(struct net *net, struct proto *proto);
 #else
-static void inline sock_prot_inuse_add(struct net *net, struct proto *prot,
+static inline void sock_prot_inuse_add(struct net *net, struct proto *prot,
 		int inc)
 {
 }
@@ -1260,24 +1260,24 @@ static inline int sk_mem_pages(int amt)
 	return (amt + SK_MEM_QUANTUM - 1) >> SK_MEM_QUANTUM_SHIFT;
 }
 
-static inline int sk_has_account(struct sock *sk)
+static inline bool sk_has_account(struct sock *sk)
 {
 	/* return true if protocol supports memory accounting */
 	return !!sk->sk_prot->memory_allocated;
 }
 
-static inline int sk_wmem_schedule(struct sock *sk, int size)
+static inline bool sk_wmem_schedule(struct sock *sk, int size)
 {
 	if (!sk_has_account(sk))
-		return 1;
+		return true;
 	return size <= sk->sk_forward_alloc ||
 		__sk_mem_schedule(sk, size, SK_MEM_SEND);
 }
 
-static inline int sk_rmem_schedule(struct sock *sk, int size)
+static inline bool sk_rmem_schedule(struct sock *sk, int size)
 {
 	if (!sk_has_account(sk))
-		return 1;
+		return true;
 	return size <= sk->sk_forward_alloc ||
 		__sk_mem_schedule(sk, size, SK_MEM_RECV);
 }
@@ -1342,7 +1342,7 @@ static inline void sk_wmem_free_skb(struct sock *sk, struct sk_buff *skb)
  * Mark both the sk_lock and the sk_lock.slock as a
  * per-address-family lock class.
  */
-#define sock_lock_init_class_and_name(sk, sname, skey, name, key) 	\
+#define sock_lock_init_class_and_name(sk, sname, skey, name, key)	\
 do {									\
 	sk->sk_lock.owned = 0;						\
 	init_waitqueue_head(&sk->sk_lock.wq);				\
@@ -1350,7 +1350,7 @@ do {									\
 	debug_check_no_locks_freed((void *)&(sk)->sk_lock,		\
 			sizeof((sk)->sk_lock));				\
 	lockdep_set_class_and_name(&(sk)->sk_lock.slock,		\
-		       	(skey), (sname));				\
+				(skey), (sname));				\
 	lockdep_init_map(&(sk)->sk_lock.dep_map, (name), (key), 0);	\
 } while (0)
 
@@ -1410,13 +1410,13 @@ extern int			sock_setsockopt(struct socket *sock, int level,
 						unsigned int optlen);
 
 extern int			sock_getsockopt(struct socket *sock, int level,
-						int op, char __user *optval, 
+						int op, char __user *optval,
 						int __user *optlen);
-extern struct sk_buff 		*sock_alloc_send_skb(struct sock *sk,
+extern struct sk_buff		*sock_alloc_send_skb(struct sock *sk,
 						     unsigned long size,
 						     int noblock,
 						     int *errcode);
-extern struct sk_buff 		*sock_alloc_send_pskb(struct sock *sk,
+extern struct sk_buff		*sock_alloc_send_pskb(struct sock *sk,
 						      unsigned long header_len,
 						      unsigned long data_len,
 						      int noblock,
@@ -1438,7 +1438,7 @@ static inline void sock_update_classid(struct sock *sk)
  * Functions to fill in entries in struct proto_ops when a protocol
  * does not implement a particular function.
  */
-extern int                      sock_no_bind(struct socket *, 
+extern int                      sock_no_bind(struct socket *,
 					     struct sockaddr *, int);
 extern int                      sock_no_connect(struct socket *,
 						struct sockaddr *, int, int);
@@ -1467,7 +1467,7 @@ extern int			sock_no_mmap(struct file *file,
 					     struct vm_area_struct *vma);
 extern ssize_t			sock_no_sendpage(struct socket *sock,
 						struct page *page,
-						int offset, size_t size, 
+						int offset, size_t size,
 						int flags);
 
 /*
@@ -1490,7 +1490,7 @@ extern void sk_common_release(struct sock *sk);
 /*
  *	Default socket callbacks and setup code
  */
- 
+
 /* Initialise core socket variables */
 extern void sock_init_data(struct socket *sock, struct sock *sk);
 
@@ -1690,7 +1690,7 @@ extern struct dst_entry *__sk_dst_check(struct sock *sk, u32 cookie);
 
 extern struct dst_entry *sk_dst_check(struct sock *sk, u32 cookie);
 
-static inline int sk_can_gso(const struct sock *sk)
+static inline bool sk_can_gso(const struct sock *sk)
 {
 	return net_gso_ok(sk->sk_route_caps, sk->sk_gso_type);
 }
@@ -1807,7 +1807,7 @@ static inline int sk_rmem_alloc_get(const struct sock *sk)
  *
  * Returns true if socket has write or read allocations
  */
-static inline int sk_has_allocations(const struct sock *sk)
+static inline bool sk_has_allocations(const struct sock *sk)
 {
 	return sk_wmem_alloc_get(sk) || sk_rmem_alloc_get(sk);
 }
@@ -1846,9 +1846,7 @@ static inline int sk_has_allocations(const struct sock *sk)
  */
 static inline bool wq_has_sleeper(struct socket_wq *wq)
 {
-
-	/*
-	 * We need to be sure we are in sync with the
+	/* We need to be sure we are in sync with the
 	 * add_wait_queue modifications to the wait queue.
 	 *
 	 * This memory barrier is paired in the sock_poll_wait.
@@ -1870,22 +1868,21 @@ static inline void sock_poll_wait(struct file *filp,
 {
 	if (!poll_does_not_wait(p) && wait_address) {
 		poll_wait(filp, wait_address, p);
-		/*
-		 * We need to be sure we are in sync with the
+		/* We need to be sure we are in sync with the
 		 * socket flags modification.
 		 *
 		 * This memory barrier is paired in the wq_has_sleeper.
-		*/
+		 */
 		smp_mb();
 	}
 }
 
 /*
- * 	Queue a received datagram if it will fit. Stream and sequenced
+ *	Queue a received datagram if it will fit. Stream and sequenced
  *	protocols can't normally use this as they need to fit buffers in
  *	and play with them.
  *
- * 	Inlined as it's very short and called for pretty much every
+ *	Inlined as it's very short and called for pretty much every
  *	packet ever received.
  */
 
@@ -1911,10 +1908,10 @@ static inline void skb_set_owner_r(struct sk_buff *skb, struct sock *sk)
 	sk_mem_charge(sk, skb->truesize);
 }
 
-extern void sk_reset_timer(struct sock *sk, struct timer_list* timer,
+extern void sk_reset_timer(struct sock *sk, struct timer_list *timer,
 			   unsigned long expires);
 
-extern void sk_stop_timer(struct sock *sk, struct timer_list* timer);
+extern void sk_stop_timer(struct sock *sk, struct timer_list *timer);
 
 extern int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb);
 
@@ -1923,7 +1920,7 @@ extern int sock_queue_err_skb(struct sock *sk, struct sk_buff *skb);
 /*
  *	Recover an error report and clear atomically
  */
- 
+
 static inline int sock_error(struct sock *sk)
 {
 	int err;
@@ -1939,7 +1936,7 @@ static inline unsigned long sock_wspace(struct sock *sk)
 
 	if (!(sk->sk_shutdown & SEND_SHUTDOWN)) {
 		amt = sk->sk_sndbuf - atomic_read(&sk->sk_wmem_alloc);
-		if (amt < 0) 
+		if (amt < 0)
 			amt = 0;
 	}
 	return amt;
@@ -1983,7 +1980,7 @@ static inline struct page *sk_stream_alloc_page(struct sock *sk)
 /*
  *	Default write policy as shown to user space via poll/select/SIGIO
  */
-static inline int sock_writeable(const struct sock *sk) 
+static inline bool sock_writeable(const struct sock *sk)
 {
 	return atomic_read(&sk->sk_wmem_alloc) < (sk->sk_sndbuf >> 1);
 }
@@ -1993,12 +1990,12 @@ static inline gfp_t gfp_any(void)
 	return in_softirq() ? GFP_ATOMIC : GFP_KERNEL;
 }
 
-static inline long sock_rcvtimeo(const struct sock *sk, int noblock)
+static inline long sock_rcvtimeo(const struct sock *sk, bool noblock)
 {
 	return noblock ? 0 : sk->sk_rcvtimeo;
 }
 
-static inline long sock_sndtimeo(const struct sock *sk, int noblock)
+static inline long sock_sndtimeo(const struct sock *sk, bool noblock)
 {
 	return noblock ? 0 : sk->sk_sndtimeo;
 }
@@ -2021,7 +2018,7 @@ extern void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk,
 extern void __sock_recv_wifi_status(struct msghdr *msg, struct sock *sk,
 	struct sk_buff *skb);
 
-static __inline__ void
+static inline void
 sock_recv_timestamp(struct msghdr *msg, struct sock *sk, struct sk_buff *skb)
 {
 	ktime_t kt = skb->tstamp;
@@ -2062,7 +2059,7 @@ static inline void sock_recv_ts_and_drops(struct msghdr *msg, struct sock *sk,
 			   (1UL << SOCK_RCVTSTAMP)			| \
 			   (1UL << SOCK_TIMESTAMPING_RX_SOFTWARE)	| \
 			   (1UL << SOCK_TIMESTAMPING_SOFTWARE)		| \
-			   (1UL << SOCK_TIMESTAMPING_RAW_HARDWARE) 	| \
+			   (1UL << SOCK_TIMESTAMPING_RAW_HARDWARE)	| \
 			   (1UL << SOCK_TIMESTAMPING_SYS_HARDWARE))
 
 	if (sk->sk_flags & FLAGS_TS_OR_DROPS)
@@ -2091,7 +2088,7 @@ extern int sock_tx_timestamp(struct sock *sk, __u8 *tx_flags);
  * locked so that the sk_buff queue operation is ok.
 */
 #ifdef CONFIG_NET_DMA
-static inline void sk_eat_skb(struct sock *sk, struct sk_buff *skb, int copied_early)
+static inline void sk_eat_skb(struct sock *sk, struct sk_buff *skb, bool copied_early)
 {
 	__skb_unlink(skb, &sk->sk_receive_queue);
 	if (!copied_early)
@@ -2100,7 +2097,7 @@ static inline void sk_eat_skb(struct sock *sk, struct sk_buff *skb, int copied_e
 		__skb_queue_tail(&sk->sk_async_wait_queue, skb);
 }
 #else
-static inline void sk_eat_skb(struct sock *sk, struct sk_buff *skb, int copied_early)
+static inline void sk_eat_skb(struct sock *sk, struct sk_buff *skb, bool copied_early)
 {
 	__skb_unlink(skb, &sk->sk_receive_queue);
 	__kfree_skb(skb);
@@ -2147,8 +2144,8 @@ extern void sock_enable_timestamp(struct sock *sk, int flag);
 extern int sock_get_timestamp(struct sock *, struct timeval __user *);
 extern int sock_get_timestampns(struct sock *, struct timespec __user *);
 
-/* 
- *	Enable debug/info messages 
+/*
+ *	Enable debug/info messages
  */
 extern int net_msg_warn;
 #define NETDEBUG(fmt, args...) \
diff --git a/net/dccp/proto.c b/net/dccp/proto.c
index 7065c0a..6c7c78b 100644
--- a/net/dccp/proto.c
+++ b/net/dccp/proto.c
@@ -848,7 +848,7 @@ int dccp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
 		default:
 			dccp_pr_debug("packet_type=%s\n",
 				      dccp_packet_name(dh->dccph_type));
-			sk_eat_skb(sk, skb, 0);
+			sk_eat_skb(sk, skb, false);
 		}
 verify_sock_status:
 		if (sock_flag(sk, SOCK_DONE)) {
@@ -905,7 +905,7 @@ verify_sock_status:
 			len = skb->len;
 	found_fin_ok:
 		if (!(flags & MSG_PEEK))
-			sk_eat_skb(sk, skb, 0);
+			sk_eat_skb(sk, skb, false);
 		break;
 	} while (1);
 out:
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index feb2e25..e8a80d0 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -1473,11 +1473,11 @@ int tcp_read_sock(struct sock *sk, read_descriptor_t *desc,
 				break;
 		}
 		if (tcp_hdr(skb)->fin) {
-			sk_eat_skb(sk, skb, 0);
+			sk_eat_skb(sk, skb, false);
 			++seq;
 			break;
 		}
-		sk_eat_skb(sk, skb, 0);
+		sk_eat_skb(sk, skb, false);
 		if (!desc->count)
 			break;
 		tp->copied_seq = seq;
@@ -1513,7 +1513,7 @@ int tcp_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
 	int target;		/* Read at least this many bytes */
 	long timeo;
 	struct task_struct *user_recv = NULL;
-	int copied_early = 0;
+	bool copied_early = false;
 	struct sk_buff *skb;
 	u32 urg_hole = 0;
 
@@ -1801,7 +1801,7 @@ do_prequeue:
 				dma_async_memcpy_issue_pending(tp->ucopy.dma_chan);
 
 				if ((offset + used) == skb->len)
-					copied_early = 1;
+					copied_early = true;
 
 			} else
 #endif
@@ -1835,7 +1835,7 @@ skip_copy:
 			goto found_fin_ok;
 		if (!(flags & MSG_PEEK)) {
 			sk_eat_skb(sk, skb, copied_early);
-			copied_early = 0;
+			copied_early = false;
 		}
 		continue;
 
@@ -1844,7 +1844,7 @@ skip_copy:
 		++*seq;
 		if (!(flags & MSG_PEEK)) {
 			sk_eat_skb(sk, skb, copied_early);
-			copied_early = 0;
+			copied_early = false;
 		}
 		break;
 	} while (len > 0);
diff --git a/net/llc/af_llc.c b/net/llc/af_llc.c
index e944075..fe5453c 100644
--- a/net/llc/af_llc.c
+++ b/net/llc/af_llc.c
@@ -838,7 +838,7 @@ static int llc_ui_recvmsg(struct kiocb *iocb, struct socket *sock,
 
 		if (!(flags & MSG_PEEK)) {
 			spin_lock_irqsave(&sk->sk_receive_queue.lock, cpu_flags);
-			sk_eat_skb(sk, skb, 0);
+			sk_eat_skb(sk, skb, false);
 			spin_unlock_irqrestore(&sk->sk_receive_queue.lock, cpu_flags);
 			*seq = 0;
 		}
@@ -861,7 +861,7 @@ copy_uaddr:
 
 	if (!(flags & MSG_PEEK)) {
 			spin_lock_irqsave(&sk->sk_receive_queue.lock, cpu_flags);
-			sk_eat_skb(sk, skb, 0);
+			sk_eat_skb(sk, skb, false);
 			spin_unlock_irqrestore(&sk->sk_receive_queue.lock, cpu_flags);
 			*seq = 0;
 	}

^ permalink raw reply related

* Re: [patch] isdn: remove duplicate NULL check
From: David Miller @ 2012-05-17  8:48 UTC (permalink / raw)
  To: dan.carpenter; +Cc: isdn, dhowells, ext-phil.2.carmody, netdev, kernel-janitors
In-Reply-To: <20120517065102.GC14660@elgon.mountain>

From: Dan Carpenter <dan.carpenter@oracle.com>
Date: Thu, 17 May 2012 09:51:02 +0300

> We test both "!skb_out" and "skb_out" here which is duplicative and
> causes a static checker warning.  I considered that the intent might
> have been to test "skb_in" but that's a valid pointer here.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Applied, thanks.

^ permalink raw reply

* Re: [PATCH] ipv6: fix incorrect ipsec transport mode fragment
From: David Miller @ 2012-05-17  8:48 UTC (permalink / raw)
  To: gaofeng; +Cc: steffen.klassert, netdev, lw
In-Reply-To: <4FB4ABC8.5000506@cn.fujitsu.com>

From: Gao feng <gaofeng@cn.fujitsu.com>
Date: Thu, 17 May 2012 15:42:00 +0800

> What's your comment?

I don't have any, you will need to work this out yourself.

^ permalink raw reply

* Re: [PATCH net-next] net: include/net/sock.h cleanup
From: David Miller @ 2012-05-17  8:50 UTC (permalink / raw)
  To: eric.dumazet; +Cc: netdev
In-Reply-To: <1337244495.29313.2.camel@edumazet-laptop>

From: Eric Dumazet <eric.dumazet@gmail.com>
Date: Thu, 17 May 2012 10:48:15 +0200

> From: Eric Dumazet <edumazet@google.com>
> 
> bool/const conversions where possible
> 
> __inline__ -> inline
> 
> space cleanups
> 
> Signed-off-by: Eric Dumazet <edumazet@google.com>

Applied.

^ 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