]> git.hungrycats.org Git - linux/commitdiff
[IPV6]: Limit network triggerable printks.
authorAndi Kleen <ak@suse.de>
Fri, 16 Apr 2004 06:55:01 +0000 (23:55 -0700)
committerStephen Hemminger <shemminger@osdl.org>
Fri, 16 Apr 2004 06:55:01 +0000 (23:55 -0700)
13 files changed:
include/net/sock.h
net/ipv4/esp4.c
net/ipv4/icmp.c
net/ipv4/ipcomp.c
net/ipv6/ah6.c
net/ipv6/datagram.c
net/ipv6/esp6.c
net/ipv6/exthdrs.c
net/ipv6/icmp.c
net/ipv6/ip6_output.c
net/ipv6/raw.c
net/ipv6/tcp_ipv6.c
net/ipv6/udp.c

index 3fd86b12eb3e8080122482c26336e225e0e2b8c2..c9d69221a02e38bf8551b666bb1fb9e91eb254fd 100644 (file)
@@ -1058,8 +1058,10 @@ extern int sock_get_timestamp(struct sock *, struct timeval *);
 
 #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
 
 /*
index 3efefe7846aa2fb6e31e049df4c9dca3473fa8a5..d4696c1f01e38fc91fde17860a6886bfefec836a 100644 (file)
@@ -447,8 +447,8 @@ void esp4_err(struct sk_buff *skb, u32 info)
        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);
 }
 
@@ -511,10 +511,10 @@ int esp_init_state(struct xfrm_state *x, void *args)
 
                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;
                }
 
index 266174ae70ef308c3eb67553a5fd5da224717085..530cfcd6ccf4160cfda606a065510ef6530bbe95 100644 (file)
@@ -620,11 +620,11 @@ static void icmp_unreach(struct sk_buff *skb)
                        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 @@ static void icmp_unreach(struct sk_buff *skb)
                        }
                        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;
index 0676d6c6f8133d1db0d0d08607b5f9148007e306..2a5a7dfcf28af5e474d0e25228155efe0fb6815e 100644 (file)
@@ -258,8 +258,8 @@ static void ipcomp4_err(struct sk_buff *skb, u32 info)
                              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);
 }
 
index 042bc845f8ee4654d91576ce869d58845a70cc23..d04ecbb2dd7daae223b83f1e5ebf870c30679c65 100644 (file)
@@ -92,8 +92,8 @@ static int ipv6_clear_mutable_options(struct sk_buff *skb, u16 *nh_offset, int d
                        *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 @@ static int ipv6_clear_mutable_options(struct sk_buff *skb, u16 *nh_offset, int d
                        *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 @@ static int ipv6_clear_mutable_options(struct sk_buff *skb, u16 *nh_offset, int d
                                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 @@ int ah6_input(struct xfrm_state *x, struct xfrm_decap_state *decap, struct sk_bu
                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 @@ void ah6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
        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);
 }
index 8c39cf5f6e340dad10fc40939928bf9c6b5ae00a..fef31fb55f7ef06a3b7c6392812b731eea046ce6 100644 (file)
@@ -427,8 +427,8 @@ int datagram_send_ctl(struct msghdr *msg, struct flowi *fl,
                        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;
                };
index ca3685bafc0613b88599a51073a4bd916e8401f6..9c016d78589a31740433929ada68f40617d030a2 100644 (file)
@@ -278,9 +278,9 @@ int esp6_input(struct xfrm_state *x, struct xfrm_decap_state *decap, struct sk_b
 
                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;
                }
index b1b3f82d3b39f544863414b8094ab1b5bdd02416..24286b94051d2ea3bcaa0409e98f5321917dc5cf 100644 (file)
@@ -421,8 +421,8 @@ static int ipv6_hop_ra(struct sk_buff *skb, int optoff)
                ((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;
 }
@@ -434,8 +434,8 @@ static int ipv6_hop_jumbo(struct sk_buff *skb, int optoff)
        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]));
                IP6_INC_STATS_BH(Ip6InHdrErrors);
                goto drop;
        }
index 25bdac3cf0a8240c8ca3fd146ac87c12ee383b8d..cc153c21fbafe3ea136dfb25ba41f88cf00d0b42 100644 (file)
@@ -329,8 +329,8 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info,
         *      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 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info,
         *      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 @@ void icmpv6_send(struct sk_buff *skb, int type, int code, __u32 info,
        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 @@ static int icmpv6_rcv(struct sk_buff **pskb, unsigned int *nhoffp)
                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;
                }
        }
@@ -650,8 +650,8 @@ static int icmpv6_rcv(struct sk_buff **pskb, unsigned int *nhoffp)
                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)
index deda313945d922b9e55fd05bd62ad6216f24e35c..d6f0db4aaa069a781b3497a622388ec725e0dbb5 100644 (file)
@@ -170,8 +170,8 @@ int ip6_route_me_harder(struct sk_buff *skb)
 
        if (dst->error) {
                IP6_INC_STATS(Ip6OutNoRoutes);
-               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;
        }
index d126dd72d3ff603755177baffa5707bf9f305402..c407c7ed57cc4bdcbbdb42a20cec4a58d3e5b2cc 100644 (file)
@@ -328,7 +328,8 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
                        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;
                        }
                }
index 00d91e32024502e7f3c8a778b9283966ccfcf184..2949cd143b40126dfc053868daf620c980c967b3 100644 (file)
@@ -1425,7 +1425,7 @@ static int tcp_v6_checksum_init(struct sk_buff *skb)
                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,
index 4c048ed643e733ae5e1b1bed7cb79e699748bbc7..35940f20995559db971656cfe83c240637ce11e1 100644 (file)
@@ -634,8 +634,8 @@ static int udpv6_rcv(struct sk_buff **pskb, unsigned int *nhoffp)
                /* 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 @@ static int udpv6_rcv(struct sk_buff **pskb, unsigned int *nhoffp)
        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 @@ back_from_confirm:
                /* ... 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;
        }