Skip to contentSkip to conversation

NETDEBUG network triggerable messages in IPv6

PATCH In review Andi Kleen 4 participants 11 messages Apr 9, 2004 – Apr 16, 2004

Subsystems (7)
lore
Share & tools
lore

Andi Kleen

author
#0 lore raw

PATCH 1/1 NETDEBUG network triggerable messages in IPv6

This wraps all potentially network triggerable printks in IPv6 with NETDEBUG.

Default behaviour doesn't change because the main kernel still has NETDEBUG enabled (although it may be a good idea now to disable it by default in the stable series)

Please apply.

-Andi

net/ipv4/esp4.c renamed from net/ipv4/esp4.c-o +4 -4
diff -u linux-2.6.5-netmsg/net/ipv4/esp4.c-o linux-2.6.5-netmsg/net/ipv4/esp4.c
@@ -428,8 +428,8 @@
 	x = xfrm_state_lookup((xfrm_address_t *)&iph->daddr, esph->spi, IPPROTO_ESP, AF_INET);
 	if (!x)
 		return;
-	printk(KERN_DEBUG "pmtu discovery on SA ESP/%08x/%08x\n",
-	       ntohl(esph->spi), ntohl(iph->daddr));
+	NETDEBUG(printk(KERN_DEBUG "pmtu discovery on SA ESP/%08x/%08x\n",
+			ntohl(esph->spi), ntohl(iph->daddr)));
 	xfrm_state_put(x);
 }
 
@@ -492,10 +492,10 @@
 
 		if (aalg_desc->uinfo.auth.icv_fullbits/8 !=
 		    crypto_tfm_alg_digestsize(esp->auth.tfm)) {
-			printk(KERN_INFO "ESP: %s digestsize %u != %hu\n",
+			NETDEBUG(printk(KERN_INFO "ESP: %s digestsize %u != %hu\n",
 			       x->aalg->alg_name,
 			       crypto_tfm_alg_digestsize(esp->auth.tfm),
-			       aalg_desc->uinfo.auth.icv_fullbits/8);
+			       aalg_desc->uinfo.auth.icv_fullbits/8));
 			goto error;
 		}
 
net/ipv4/icmp.c renamed from net/ipv4/icmp.c-o +4 -4
diff -u linux-2.6.5-netmsg/net/ipv4/icmp.c-o linux-2.6.5-netmsg/net/ipv4/icmp.c
@@ -620,11 +620,11 @@
 			break;
 		case ICMP_FRAG_NEEDED:
 			if (ipv4_config.no_pmtu_disc) {
-				if (net_ratelimit())
+				NETDEBUG(if (net_ratelimit())
 					printk(KERN_INFO "ICMP: %u.%u.%u.%u: "
 							 "fragmentation needed "
 							 "and DF set.\n",
-					       NIPQUAD(iph->daddr));
+					       NIPQUAD(iph->daddr)));
 			} else {
 				info = ip_rt_frag_needed(iph,
 						     ntohs(icmph->un.frag.mtu));
@@ -633,10 +633,10 @@
 			}
 			break;
 		case ICMP_SR_FAILED:
-			if (net_ratelimit())
+			NETDEBUG(if (net_ratelimit())
 				printk(KERN_INFO "ICMP: %u.%u.%u.%u: Source "
 						 "Route Failed.\n",
-				       NIPQUAD(iph->daddr));
+				       NIPQUAD(iph->daddr)));
 			break;
 		default:
 			break;
net/ipv4/ipcomp.c renamed from net/ipv4/ipcomp.c-o +2 -2
diff -u linux-2.6.5-netmsg/net/ipv4/ipcomp.c-o linux-2.6.5-netmsg/net/ipv4/ipcomp.c
@@ -258,8 +258,8 @@
 	                      spi, IPPROTO_COMP, AF_INET);
 	if (!x)
 		return;
-	printk(KERN_DEBUG "pmtu discovery on SA IPCOMP/%08x/%u.%u.%u.%u\n",
-	       spi, NIPQUAD(iph->daddr));
+	NETDEBUG(printk(KERN_DEBUG "pmtu discovery on SA IPCOMP/%08x/%u.%u.%u.%u\n",
+	       spi, NIPQUAD(iph->daddr)));
 	xfrm_state_put(x);
 }
 
net/ipv6/ah6.c renamed from net/ipv6/ah6.c-o +10 -10
diff -u linux-2.6.5-netmsg/net/ipv6/ah6.c-o linux-2.6.5-netmsg/net/ipv6/ah6.c
@@ -92,8 +92,8 @@
 			*nh_offset = offset;
 			offset += ipv6_optlen(exthdr);
 			if (!zero_out_mutable_opts(exthdr)) {
-				if (net_ratelimit())
-					printk(KERN_WARNING "overrun hopopts\n"); 
+				NETDEBUG(if (net_ratelimit())
+					printk(KERN_WARNING "overrun hopopts\n")); 
 				return 0;
 			}
 			nexthdr = exthdr->nexthdr;
@@ -112,8 +112,8 @@
 			*nh_offset = offset;
 			offset += ipv6_optlen(exthdr);
 			if (!zero_out_mutable_opts(exthdr))  {
-				if (net_ratelimit())
-					printk(KERN_WARNING "overrun destopt\n"); 
+				NETDEBUG(if (net_ratelimit())
+					printk(KERN_WARNING "overrun destopt\n")); 
 				return 0;
 			}
 			nexthdr = exthdr->nexthdr;
@@ -130,8 +130,8 @@
 				exthdr = (struct ipv6_opt_hdr*)(skb->nh.raw + offset);
 				nextnexthdr = exthdr->nexthdr;
 				if (!zero_out_mutable_opts(exthdr)) {
-					if (net_ratelimit())
-						printk(KERN_WARNING "overrun destopt\n");
+					NETDEBUG(if (net_ratelimit())
+						printk(KERN_WARNING "overrun destopt\n"));
 					return 0;
 				}
 			}
@@ -322,8 +322,8 @@
 		skb_push(skb, skb->data - skb->nh.raw);
 		ahp->icv(ahp, skb, ah->auth_data);
 		if (memcmp(ah->auth_data, auth_data, ahp->icv_trunc_len)) {
-			if (net_ratelimit())
-				printk(KERN_WARNING "ipsec ah authentication error\n");
+			NETDEBUG(if (net_ratelimit())
+				printk(KERN_WARNING "ipsec ah authentication error\n"));
 			x->stats.integrity_failed++;
 			goto free_out;
 		}
@@ -368,9 +368,9 @@
 	if (!x)
 		return;
 
-	printk(KERN_DEBUG "pmtu discovery on SA AH/%08x/"
+	NETDEBUG(printk(KERN_DEBUG "pmtu discovery on SA AH/%08x/"
 			"%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n",
-	       ntohl(ah->spi), NIP6(iph->daddr));
+	       ntohl(ah->spi), NIP6(iph->daddr)));
 
 	xfrm_state_put(x);
 }
net/ipv6/esp6.c renamed from net/ipv6/esp6.c-o +2 -2
diff -u linux-2.6.5-netmsg/net/ipv6/esp6.c-o linux-2.6.5-netmsg/net/ipv6/esp6.c
@@ -278,9 +278,9 @@
 
 		padlen = nexthdr[0];
 		if (padlen+2 >= elen) {
-			if (net_ratelimit()) {
+			NETDEBUG(if (net_ratelimit()) {
 				printk(KERN_WARNING "ipsec esp packet is garbage padlen=%d, elen=%d\n", padlen+2, elen);
-			}
+			});
 			ret = -EINVAL;
 			goto out;
 		}
net/ipv6/datagram.c renamed from net/ipv6/datagram.c-o +2 -2
diff -u linux-2.6.5-netmsg/net/ipv6/datagram.c-o linux-2.6.5-netmsg/net/ipv6/datagram.c
@@ -427,8 +427,8 @@
 			break;
 
 		default:
-			if (net_ratelimit())
-				printk(KERN_DEBUG "invalid cmsg type: %d\n", cmsg->cmsg_type);
+			NETDEBUG(if (net_ratelimit())
+				printk(KERN_DEBUG "invalid cmsg type: %d\n", cmsg->cmsg_type));
 			err = -EINVAL;
 			break;
 		};
net/ipv6/icmp.c renamed from net/ipv6/icmp.c-o +12 -12
diff -u linux-2.6.5-netmsg/net/ipv6/icmp.c-o linux-2.6.5-netmsg/net/ipv6/icmp.c
@@ -329,8 +329,8 @@
 	 *	for now we don't know that.
 	 */
 	if ((addr_type == IPV6_ADDR_ANY) || (addr_type & IPV6_ADDR_MULTICAST)) {
-		if (net_ratelimit())
-			printk(KERN_DEBUG "icmpv6_send: addr_any/mcast source\n");
+		NETDEBUG(if (net_ratelimit())
+			printk(KERN_DEBUG "icmpv6_send: addr_any/mcast source\n"));
 		return;
 	}
 
@@ -338,8 +338,8 @@
 	 *	Never answer to a ICMP packet.
 	 */
 	if (is_ineligible(skb)) {
-		if (net_ratelimit())
-			printk(KERN_DEBUG "icmpv6_send: no reply to icmp error\n"); 
+		NETDEBUG(if (net_ratelimit())
+			printk(KERN_DEBUG "icmpv6_send: no reply to icmp error\n")); 
 		return;
 	}
 
@@ -385,8 +385,8 @@
 	len = skb->len - msg.offset;
 	len = min_t(unsigned int, len, IPV6_MIN_MTU - sizeof(struct ipv6hdr) -sizeof(struct icmp6hdr));
 	if (len < 0) {
-		if (net_ratelimit())
-			printk(KERN_DEBUG "icmp: len problem\n");
+		NETDEBUG(if (net_ratelimit())
+			printk(KERN_DEBUG "icmp: len problem\n"));
 		goto out_dst_release;
 	}
 
@@ -570,17 +570,17 @@
 		skb->ip_summed = CHECKSUM_UNNECESSARY;
 		if (csum_ipv6_magic(saddr, daddr, skb->len, IPPROTO_ICMPV6,
 				    skb->csum)) {
-			if (net_ratelimit())
-				printk(KERN_DEBUG "ICMPv6 hw checksum failed\n");
+			NETDEBUG(if (net_ratelimit())
+				printk(KERN_DEBUG "ICMPv6 hw checksum failed\n"));
 			skb->ip_summed = CHECKSUM_NONE;
 		}
 	}
 	if (skb->ip_summed == CHECKSUM_NONE) {
 		if (csum_ipv6_magic(saddr, daddr, skb->len, IPPROTO_ICMPV6,
 				    skb_checksum(skb, 0, skb->len, 0))) {
-			if (net_ratelimit())
+			NETDEBUG(if (net_ratelimit())
 				printk(KERN_DEBUG "ICMPv6 checksum failed [%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x > %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x]\n",
-				       NIP6(*saddr), NIP6(*daddr));
+				       NIP6(*saddr), NIP6(*daddr)));
 			goto discard_it;
 		}
 	}
@@ -649,8 +649,8 @@
 		break;
 
 	default:
-		if (net_ratelimit())
-			printk(KERN_DEBUG "icmpv6: msg of unknown type\n");
+		NETDEBUG(if (net_ratelimit())
+			printk(KERN_DEBUG "icmpv6: msg of unknown type\n"));
 
 		/* informational */
 		if (type & ICMPV6_INFOMSG_MASK)
net/ipv6/exthdrs.c renamed from net/ipv6/exthdrs.c-o +4 -4
diff -u linux-2.6.5-netmsg/net/ipv6/exthdrs.c-o linux-2.6.5-netmsg/net/ipv6/exthdrs.c
@@ -410,8 +410,8 @@
 		((struct inet6_skb_parm*)skb->cb)->ra = optoff;
 		return 1;
 	}
-	if (net_ratelimit())
-		printk(KERN_DEBUG "ipv6_hop_ra: wrong RA length %d\n", skb->nh.raw[optoff+1]);
+	NETDEBUG(if (net_ratelimit())
+		 printk(KERN_DEBUG "ipv6_hop_ra: wrong RA length %d\n", skb->nh.raw[optoff+1]));
 	kfree_skb(skb);
 	return 0;
 }
@@ -423,8 +423,8 @@
 	u32 pkt_len;
 
 	if (skb->nh.raw[optoff+1] != 4 || (optoff&3) != 2) {
-		if (net_ratelimit())
-			printk(KERN_DEBUG "ipv6_hop_jumbo: wrong jumbo opt length/alignment %d\n", skb->nh.raw[optoff+1]);
+		NETDEBUG(if (net_ratelimit())
+			 printk(KERN_DEBUG "ipv6_hop_jumbo: wrong jumbo opt length/alignment %d\n", skb->nh.raw[optoff+1]));
 		goto drop;
 	}
 
net/ipv6/udp.c renamed from net/ipv6/udp.c-o +2 -2
diff -u linux-2.6.5-netmsg/net/ipv6/udp.c-o linux-2.6.5-netmsg/net/ipv6/udp.c
@@ -634,8 +634,8 @@
 		/* RFC 2460 section 8.1 says that we SHOULD log
 		   this error. Well, it is reasonable.
 		 */
-		if (net_ratelimit())
-			printk(KERN_INFO "IPv6: udp checksum is 0\n");
+		NETDEBUG(if (net_ratelimit())
+			printk(KERN_INFO "IPv6: udp checksum is 0\n"));
 		goto discard;
 	}
 
net/ipv6/ip6_output.c renamed from net/ipv6/ip6_output.c-o +2 -2
diff -u linux-2.6.5-netmsg/net/ipv6/ip6_output.c-o linux-2.6.5-netmsg/net/ipv6/ip6_output.c
@@ -167,8 +167,8 @@
 	dst = ip6_route_output(skb->sk, &fl);
 
 	if (dst->error) {
-		if (net_ratelimit())
-			printk(KERN_DEBUG "ip6_route_me_harder: No more route.\n");
+		NETDEBUG(if (net_ratelimit())
+			printk(KERN_DEBUG "ip6_route_me_harder: No more route.\n"));
 		dst_release(dst);
 		return -EINVAL;
 	}
#1 lore raw

In article <[email protected]> (at Fri, 9 Apr 2004 17:48:47 +0200), Andi Kleen <[email protected]> says:

Quoted 1 line

This wraps all potentially network triggerable printks in IPv6 with NETDEBUG.

I really do NOT like this. Please, please do not do this.

Quoted 7 lines
net/ipv4/icmp.c renamed from net/ipv4/icmp.c-o +2 -2
 		case ICMP_SR_FAILED:
-			if (net_ratelimit())
+			NETDEBUG(if (net_ratelimit())
 				printk(KERN_INFO "ICMP: %u.%u.%u.%u: Source "
 						 "Route Failed.\n",
-				       NIPQUAD(iph->daddr));
+				       NIPQUAD(iph->daddr)));
Signature · 2 lines
Hideaki YOSHIFUJI @ USAGI Project <[email protected]>
GPG FP: 9022 65EB 1ECF 3AD1 0BDF  80D8 4807 F894 E062 0EEA
author
#2 lore raw
Quoted 5 lines · On Sat, 10 Apr 2004 01:00:51 +0900 (JST) YOSHIFUJI Hideaki / _$B5HF#1QL@…

In article <[email protected]> (at Fri, 9 Apr 2004 17:48:47 +0200), Andi Kleen <[email protected]> says:

Quoted 1 line

This wraps all potentially network triggerable printks in IPv6 with NETDEBUG.

I really do NOT like this. Please, please do not do this.

If you don't like it just keep NETDEBUG on. But for production systems being able to fill up logs from the network is not acceptable IMHO. Anyways default behaviour does not change right now, it just allows to easily disable all this cruft for people who want that.

-Andi

#3 lore raw

In article <[email protected]> (at Fri, 9 Apr 2004 18:21:25 +0200), Andi Kleen <[email protected]> says:

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

This wraps all potentially network triggerable printks in IPv6 with NETDEBUG.

I really do NOT like this. Please, please do not do this.

If you don't like it just keep NETDEBUG on. But for production systems being able to fill up logs from the network is not acceptable IMHO. Anyways default behaviour does not change right now, it just allows to easily disable all this cruft for people who want that.

I don't like the style; it is too ugly.
E.g. please do not put "if () ..." into the macro argument.

--yoshfuji

author
#4 lore raw
Quoted 6 lines · On Sat, 10 Apr 2004 02:18:40 +0900 (JST) YOSHIFUJI Hideaki / _$B5HF#1QL@…

In article <[email protected]> (at Fri, 9 Apr 2004 18:21:25 +0200), Andi Kleen <[email protected]> says:

Quoted 4 lines
Quoted 3 lines
Quoted 1 line

This wraps all potentially network triggerable printks in IPv6 with NETDEBUG.

I really do NOT like this. Please, please do not do this.

Quoted 7 lines
Quoted 4 lines

If you don't like it just keep NETDEBUG on. But for production systems being able to fill up logs from the network is not acceptable IMHO. Anyways default behaviour does not change right now, it just allows to easily disable all this cruft for people who want that.

I don't like the style; it is too ugly.
E.g. please do not put "if () ..." into the macro argument.

Ok, here is a new version that defines a new macro LIMIT_NETDEBUG that does the rate limit implicitely.

DaveM, please apply.
-Andi

include/net/sock.h renamed from include/net/sock.h-o +2 -0
diff -u linux-2.6.5-netmsg/include/net/sock.h-o linux-2.6.5-netmsg/include/net/sock.h
@@ -1035,8 +1035,10 @@
 
 #if 0
 #define NETDEBUG(x)	do { } while (0)
+#define LIMIT_NETDEBUG(x) do {} while(0)
 #else
 #define NETDEBUG(x)	do { x; } while (0)
+#define LIMIT_NETDEBUG(x) do { if (net_ratelimit()) { x; } } while(0)
 #endif
 
 /*
net/ipv4/esp4.c renamed from net/ipv4/esp4.c-o +4 -4
diff -u linux-2.6.5-netmsg/net/ipv4/esp4.c-o linux-2.6.5-netmsg/net/ipv4/esp4.c
@@ -428,8 +428,8 @@
 	x = xfrm_state_lookup((xfrm_address_t *)&iph->daddr, esph->spi, IPPROTO_ESP, AF_INET);
 	if (!x)
 		return;
-	printk(KERN_DEBUG "pmtu discovery on SA ESP/%08x/%08x\n",
-	       ntohl(esph->spi), ntohl(iph->daddr));
+	NETDEBUG(printk(KERN_DEBUG "pmtu discovery on SA ESP/%08x/%08x\n",
+			ntohl(esph->spi), ntohl(iph->daddr)));
 	xfrm_state_put(x);
 }
 
@@ -492,10 +492,10 @@
 
 		if (aalg_desc->uinfo.auth.icv_fullbits/8 !=
 		    crypto_tfm_alg_digestsize(esp->auth.tfm)) {
-			printk(KERN_INFO "ESP: %s digestsize %u != %hu\n",
+			NETDEBUG(printk(KERN_INFO "ESP: %s digestsize %u != %hu\n",
 			       x->aalg->alg_name,
 			       crypto_tfm_alg_digestsize(esp->auth.tfm),
-			       aalg_desc->uinfo.auth.icv_fullbits/8);
+			       aalg_desc->uinfo.auth.icv_fullbits/8));
 			goto error;
 		}
 
net/ipv4/icmp.c renamed from net/ipv4/icmp.c-o +4 -4
diff -u linux-2.6.5-netmsg/net/ipv4/icmp.c-o linux-2.6.5-netmsg/net/ipv4/icmp.c
@@ -620,11 +620,11 @@
 			break;
 		case ICMP_FRAG_NEEDED:
 			if (ipv4_config.no_pmtu_disc) {
-				if (net_ratelimit())
+				LIMIT_NETDEBUG(
 					printk(KERN_INFO "ICMP: %u.%u.%u.%u: "
 							 "fragmentation needed "
 							 "and DF set.\n",
-					       NIPQUAD(iph->daddr));
+					       NIPQUAD(iph->daddr)));
 			} else {
 				info = ip_rt_frag_needed(iph,
 						     ntohs(icmph->un.frag.mtu));
@@ -633,10 +633,10 @@
 			}
 			break;
 		case ICMP_SR_FAILED:
-			if (net_ratelimit())
+			LIMIT_NETDEBUG(
 				printk(KERN_INFO "ICMP: %u.%u.%u.%u: Source "
 						 "Route Failed.\n",
-				       NIPQUAD(iph->daddr));
+				       NIPQUAD(iph->daddr)));
 			break;
 		default:
 			break;
net/ipv4/ipcomp.c renamed from net/ipv4/ipcomp.c-o +2 -2
diff -u linux-2.6.5-netmsg/net/ipv4/ipcomp.c-o linux-2.6.5-netmsg/net/ipv4/ipcomp.c
@@ -258,8 +258,8 @@
 	                      spi, IPPROTO_COMP, AF_INET);
 	if (!x)
 		return;
-	printk(KERN_DEBUG "pmtu discovery on SA IPCOMP/%08x/%u.%u.%u.%u\n",
-	       spi, NIPQUAD(iph->daddr));
+	NETDEBUG(printk(KERN_DEBUG "pmtu discovery on SA IPCOMP/%08x/%u.%u.%u.%u\n",
+	       spi, NIPQUAD(iph->daddr)));
 	xfrm_state_put(x);
 }
 
net/ipv6/ah6.c renamed from net/ipv6/ah6.c-o +10 -10
diff -u linux-2.6.5-netmsg/net/ipv6/ah6.c-o linux-2.6.5-netmsg/net/ipv6/ah6.c
@@ -92,8 +92,8 @@
 			*nh_offset = offset;
 			offset += ipv6_optlen(exthdr);
 			if (!zero_out_mutable_opts(exthdr)) {
-				if (net_ratelimit())
-					printk(KERN_WARNING "overrun hopopts\n"); 
+				LIMIT_NETDEBUG(
+				printk(KERN_WARNING "overrun hopopts\n")); 
 				return 0;
 			}
 			nexthdr = exthdr->nexthdr;
@@ -112,8 +112,8 @@
 			*nh_offset = offset;
 			offset += ipv6_optlen(exthdr);
 			if (!zero_out_mutable_opts(exthdr))  {
-				if (net_ratelimit())
-					printk(KERN_WARNING "overrun destopt\n"); 
+				LIMIT_NETDEBUG(
+					printk(KERN_WARNING "overrun destopt\n")); 
 				return 0;
 			}
 			nexthdr = exthdr->nexthdr;
@@ -130,8 +130,8 @@
 				exthdr = (struct ipv6_opt_hdr*)(skb->nh.raw + offset);
 				nextnexthdr = exthdr->nexthdr;
 				if (!zero_out_mutable_opts(exthdr)) {
-					if (net_ratelimit())
-						printk(KERN_WARNING "overrun destopt\n");
+					LIMIT_NETDEBUG(
+						printk(KERN_WARNING "overrun destopt\n"));
 					return 0;
 				}
 			}
@@ -322,8 +322,8 @@
 		skb_push(skb, skb->data - skb->nh.raw);
 		ahp->icv(ahp, skb, ah->auth_data);
 		if (memcmp(ah->auth_data, auth_data, ahp->icv_trunc_len)) {
-			if (net_ratelimit())
-				printk(KERN_WARNING "ipsec ah authentication error\n");
+			LIMIT_NETDEBUG(
+				printk(KERN_WARNING "ipsec ah authentication error\n"));
 			x->stats.integrity_failed++;
 			goto free_out;
 		}
@@ -368,9 +368,9 @@
 	if (!x)
 		return;
 
-	printk(KERN_DEBUG "pmtu discovery on SA AH/%08x/"
+	NETDEBUG(printk(KERN_DEBUG "pmtu discovery on SA AH/%08x/"
 			"%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n",
-	       ntohl(ah->spi), NIP6(iph->daddr));
+	       ntohl(ah->spi), NIP6(iph->daddr)));
 
 	xfrm_state_put(x);
 }
net/ipv6/esp6.c renamed from net/ipv6/esp6.c-o +2 -2
diff -u linux-2.6.5-netmsg/net/ipv6/esp6.c-o linux-2.6.5-netmsg/net/ipv6/esp6.c
@@ -278,9 +278,9 @@
 
 		padlen = nexthdr[0];
 		if (padlen+2 >= elen) {
-			if (net_ratelimit()) {
+			LIMIT_NETDEBUG(
 				printk(KERN_WARNING "ipsec esp packet is garbage padlen=%d, elen=%d\n", padlen+2, elen);
-			}
+			});
 			ret = -EINVAL;
 			goto out;
 		}
net/ipv6/datagram.c renamed from net/ipv6/datagram.c-o +2 -2
diff -u linux-2.6.5-netmsg/net/ipv6/datagram.c-o linux-2.6.5-netmsg/net/ipv6/datagram.c
@@ -427,8 +427,8 @@
 			break;
 
 		default:
-			if (net_ratelimit())
-				printk(KERN_DEBUG "invalid cmsg type: %d\n", cmsg->cmsg_type);
+			LIMIT_NETDEBUG(
+				printk(KERN_DEBUG "invalid cmsg type: %d\n", cmsg->cmsg_type));
 			err = -EINVAL;
 			break;
 		};
net/ipv6/icmp.c renamed from net/ipv6/icmp.c-o +12 -12
diff -u linux-2.6.5-netmsg/net/ipv6/icmp.c-o linux-2.6.5-netmsg/net/ipv6/icmp.c
@@ -329,8 +329,8 @@
 	 *	for now we don't know that.
 	 */
 	if ((addr_type == IPV6_ADDR_ANY) || (addr_type & IPV6_ADDR_MULTICAST)) {
-		if (net_ratelimit())
-			printk(KERN_DEBUG "icmpv6_send: addr_any/mcast source\n");
+		LIMIT_NETDEBUG(
+			printk(KERN_DEBUG "icmpv6_send: addr_any/mcast source\n"));
 		return;
 	}
 
@@ -338,8 +338,8 @@
 	 *	Never answer to a ICMP packet.
 	 */
 	if (is_ineligible(skb)) {
-		if (net_ratelimit())
-			printk(KERN_DEBUG "icmpv6_send: no reply to icmp error\n"); 
+		LIMIT_NETDEBUG(
+			printk(KERN_DEBUG "icmpv6_send: no reply to icmp error\n")); 
 		return;
 	}
 
@@ -385,8 +385,8 @@
 	len = skb->len - msg.offset;
 	len = min_t(unsigned int, len, IPV6_MIN_MTU - sizeof(struct ipv6hdr) -sizeof(struct icmp6hdr));
 	if (len < 0) {
-		if (net_ratelimit())
-			printk(KERN_DEBUG "icmp: len problem\n");
+		LIMIT_NETDEBUG(
+			printk(KERN_DEBUG "icmp: len problem\n"));
 		goto out_dst_release;
 	}
 
@@ -570,17 +570,17 @@
 		skb->ip_summed = CHECKSUM_UNNECESSARY;
 		if (csum_ipv6_magic(saddr, daddr, skb->len, IPPROTO_ICMPV6,
 				    skb->csum)) {
-			if (net_ratelimit())
-				printk(KERN_DEBUG "ICMPv6 hw checksum failed\n");
+			LIMIT_NETDEBUG(
+				printk(KERN_DEBUG "ICMPv6 hw checksum failed\n"));
 			skb->ip_summed = CHECKSUM_NONE;
 		}
 	}
 	if (skb->ip_summed == CHECKSUM_NONE) {
 		if (csum_ipv6_magic(saddr, daddr, skb->len, IPPROTO_ICMPV6,
 				    skb_checksum(skb, 0, skb->len, 0))) {
-			if (net_ratelimit())
+			LIMIT_NETDEBUG(
 				printk(KERN_DEBUG "ICMPv6 checksum failed [%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x > %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x]\n",
-				       NIP6(*saddr), NIP6(*daddr));
+				       NIP6(*saddr), NIP6(*daddr)));
 			goto discard_it;
 		}
 	}
@@ -649,8 +649,8 @@
 		break;
 
 	default:
-		if (net_ratelimit())
-			printk(KERN_DEBUG "icmpv6: msg of unknown type\n");
+		LIMIT_NETDEBUG(
+			printk(KERN_DEBUG "icmpv6: msg of unknown type\n"));
 
 		/* informational */
 		if (type & ICMPV6_INFOMSG_MASK)
net/ipv6/exthdrs.c renamed from net/ipv6/exthdrs.c-o +4 -4
diff -u linux-2.6.5-netmsg/net/ipv6/exthdrs.c-o linux-2.6.5-netmsg/net/ipv6/exthdrs.c
@@ -410,8 +410,8 @@
 		((struct inet6_skb_parm*)skb->cb)->ra = optoff;
 		return 1;
 	}
-	if (net_ratelimit())
-		printk(KERN_DEBUG "ipv6_hop_ra: wrong RA length %d\n", skb->nh.raw[optoff+1]);
+	LIMIT_NETDEBUG(
+		 printk(KERN_DEBUG "ipv6_hop_ra: wrong RA length %d\n", skb->nh.raw[optoff+1]));
 	kfree_skb(skb);
 	return 0;
 }
@@ -423,8 +423,8 @@
 	u32 pkt_len;
 
 	if (skb->nh.raw[optoff+1] != 4 || (optoff&3) != 2) {
-		if (net_ratelimit())
-			printk(KERN_DEBUG "ipv6_hop_jumbo: wrong jumbo opt length/alignment %d\n", skb->nh.raw[optoff+1]);
+		LIMIT_NETDEBUG(
+			 printk(KERN_DEBUG "ipv6_hop_jumbo: wrong jumbo opt length/alignment %d\n", skb->nh.raw[optoff+1]));
 		goto drop;
 	}
 
net/ipv6/udp.c renamed from net/ipv6/udp.c-o +4 -4
diff -u linux-2.6.5-netmsg/net/ipv6/udp.c-o linux-2.6.5-netmsg/net/ipv6/udp.c
@@ -634,8 +634,8 @@
 		/* RFC 2460 section 8.1 says that we SHOULD log
 		   this error. Well, it is reasonable.
 		 */
-		if (net_ratelimit())
-			printk(KERN_INFO "IPv6: udp checksum is 0\n");
+		LIMIT_NETDEBUG(
+			printk(KERN_INFO "IPv6: udp checksum is 0\n"));
 		goto discard;
 	}
 
@@ -650,7 +650,7 @@
 	if (skb->ip_summed==CHECKSUM_HW) {
 		skb->ip_summed = CHECKSUM_UNNECESSARY;
 		if (csum_ipv6_magic(saddr, daddr, ulen, IPPROTO_UDP, skb->csum)) {
-			NETDEBUG(if (net_ratelimit()) printk(KERN_DEBUG "udp v6 hw csum failure.\n"));
+			LIMIT_NETDEBUG(printk(KERN_DEBUG "udp v6 hw csum failure.\n"));
 			skb->ip_summed = CHECKSUM_NONE;
 		}
 	}
@@ -970,7 +970,7 @@
 		/* ... which is an evident application bug. --ANK */
 		release_sock(sk);
 
-		NETDEBUG(if (net_ratelimit()) printk(KERN_DEBUG "udp cork app bug 2\n"));
+		LIMIT_NETDEBUG(printk(KERN_DEBUG "udp cork app bug 2\n"));
 		err = -EINVAL;
 		goto out;
 	}
net/ipv6/ip6_output.c renamed from net/ipv6/ip6_output.c-o +2 -2
diff -u linux-2.6.5-netmsg/net/ipv6/ip6_output.c-o linux-2.6.5-netmsg/net/ipv6/ip6_output.c
@@ -167,8 +167,8 @@
 	dst = ip6_route_output(skb->sk, &fl);
 
 	if (dst->error) {
-		if (net_ratelimit())
-			printk(KERN_DEBUG "ip6_route_me_harder: No more route.\n");
+		LIMIT_NETDEBUG(
+			printk(KERN_DEBUG "ip6_route_me_harder: No more route.\n"));
 		dst_release(dst);
 		return -EINVAL;
 	}
net/ipv6/raw.c renamed from net/ipv6/raw.c-o +2 -1
diff -u linux-2.6.5-netmsg/net/ipv6/raw.c-o linux-2.6.5-netmsg/net/ipv6/raw.c
@@ -328,7 +328,8 @@
 			if (csum_ipv6_magic(&skb->nh.ipv6h->saddr,
 					    &skb->nh.ipv6h->daddr,
 					    skb->len, inet->num, skb->csum)) {
-				NETDEBUG(if (net_ratelimit()) printk(KERN_DEBUG "raw v6 hw csum failure.\n"));
+				LIMIT_NETDEBUG(
+			        printk(KERN_DEBUG "raw v6 hw csum failure.\n"));
 				skb->ip_summed = CHECKSUM_NONE;
 			}
 		}
net/ipv6/tcp_ipv6.c renamed from net/ipv6/tcp_ipv6.c-o +1 -1
diff -u linux-2.6.5-netmsg/net/ipv6/tcp_ipv6.c-o linux-2.6.5-netmsg/net/ipv6/tcp_ipv6.c
@@ -1425,7 +1425,7 @@
 		if (!tcp_v6_check(skb->h.th,skb->len,&skb->nh.ipv6h->saddr,
 				  &skb->nh.ipv6h->daddr,skb->csum))
 			return 0;
-		NETDEBUG(if (net_ratelimit()) printk(KERN_DEBUG "hw tcp v6 csum failed\n"));
+		LIMIT_NETDEBUG(printk(KERN_DEBUG "hw tcp v6 csum failed\n"));
 	}
 	if (skb->len <= 76) {
 		if (tcp_v6_check(skb->h.th,skb->len,&skb->nh.ipv6h->saddr,
#5 lore raw

In article <[email protected]> (at Fri, 9 Apr 2004 19:31:23 +0200), Andi Kleen <[email protected]> says:

net/ipv6/ah6.c line 116

Quoted 9 lines
Quoted 2 lines

I don't like the style; it is too ugly.
E.g. please do not put "if () ..." into the macro argument.

Ok, here is a new version that defines a new macro LIMIT_NETDEBUG that does the rate limit implicitely.

net/ipv6/ah6.c renamed from net/ipv6/ah6.c-o +2 -2
-				if (net_ratelimit())
-					printk(KERN_WARNING "overrun destopt\n"); 
+				LIMIT_NETDEBUG(
+					printk(KERN_WARNING "overrun destopt\n")); 

Grr...

I'd prefer:

if (net_ratelimit())
NETDEBUG_PRINTK("overrun destopt\n"..)
or

NETDEBUG_PRINTK_LIMIT("overrun destopt\n"..)

(or something like this) much more.

--yoshfuji

author
#6 lore raw
Quoted 5 lines · On Sat, 10 Apr 2004 02:47:05 +0900 (JST) YOSHIFUJI Hideaki / _$B5HF#1QL@…

I'd prefer:

if (net_ratelimit())
NETDEBUG_PRINTK("overrun destopt\n"..)

This won't optimize away the function call.

Quoted 5 lines

or

NETDEBUG_PRINTK_LIMIT("overrun destopt\n"..)

(or something like this) much more.

... and this will make the lines even longer.

-Andi

#7 lore raw

In article <[email protected]> (at Fri, 9 Apr 2004 19:50:52 +0200), Andi Kleen <[email protected]> says:

Quoted 5 lines
Quoted 3 lines

NETDEBUG_PRINTK_LIMIT("overrun destopt\n"..)

(or something like this) much more.

... and this will make the lines even longer.

If you mind that, you can use shorter name
like IP6DEBUG / IP6DEBUG_LIMIT() etc.

--yoshfuji

author
#8 lore raw
Quoted 10 lines · On Sat, 10 Apr 2004 03:09:04 +0900 (JST) YOSHIFUJI Hideaki / _$B5HF#1QL@…

In article <[email protected]> (at Fri, 9 Apr 2004 19:50:52 +0200), Andi Kleen <[email protected]> says:

Quoted 5 lines
Quoted 3 lines

NETDEBUG_PRINTK_LIMIT("overrun destopt\n"..)

(or something like this) much more.

... and this will make the lines even longer.

If you mind that, you can use shorter name
like IP6DEBUG / IP6DEBUG_LIMIT() etc.

Yes, I opted for NETDEBUG_LIMIT.

-Andi

#10 lore raw
In reply to Andi Kleen
Quoted 3 lines · Andi Kleen

If you don't like it just keep NETDEBUG on. But for production systems being able to fill up logs from the network is not acceptable IMHO. Anyways default behaviour does not change right now, it just allows to easily disable all this cruft for
people who want that.

I'd like to support Andi's patch - or any flavor thereof, that results in being able to prevent nw triggered logging filling up logs. It is very much needed by us, too. I would like to see it be the default in mainline, really.

thanks,
Nivedita