From: Ben Pfaff Date: Sat, 10 Jan 2009 00:24:56 +0000 (-0800) Subject: datapath: Add log level annotations to printk messages. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5b01614b33a4f533b569cc14c0ee0fcfe2a0240f;p=openvswitch datapath: Add log level annotations to printk messages. General approach is: - KERN_EMERG: Conditions that prevent the modules from loading. - KERN_ERR: Conditions that indicate an OpenFlow kernel code bug. - KERN_WARNING: Conditions that might indicate a bug in OpenFlow kernel code or other kernel code. - KERN_NOTICE: Conditions that might indicate a bug in secchan or the OpenFlow controller, or minor conditions that are typically transient. --- diff --git a/datapath/chain.c b/datapath/chain.c index aec78e3a..229be65c 100644 --- a/datapath/chain.c +++ b/datapath/chain.c @@ -1,6 +1,6 @@ /* * Distributed under the terms of the GNU GPL version 2. - * Copyright (c) 2007, 2008 The Board of Trustees of The Leland + * Copyright (c) 2007, 2008, 2009 The Board of Trustees of The Leland * Stanford Junior University */ @@ -25,7 +25,8 @@ static int add_table(struct sw_chain *chain, struct sw_table *table) if (table == NULL) return -ENOMEM; if (chain->n_tables >= CHAIN_MAX_TABLES) { - printk("%s: too many tables in chain\n", chain->dp->netdev->name); + printk(KERN_EMERG "%s: too many tables in chain\n", + chain->dp->netdev->name); table->destroy(table); return -ENOBUFS; } diff --git a/datapath/datapath.c b/datapath/datapath.c index 2e00091b..e5ed9df1 100644 --- a/datapath/datapath.c +++ b/datapath/datapath.c @@ -224,8 +224,9 @@ alloc_openflow_skb(struct datapath *dp, size_t openflow_len, uint8_t type, if ((openflow_len + sizeof(struct ofp_header)) > UINT16_MAX) { if (net_ratelimit()) - printk("%s: alloc_openflow_skb: openflow message too large: %zu\n", - dp->netdev->name, openflow_len); + printk(KERN_ERR "%s: alloc_openflow_skb: openflow " + "message too large: %zu\n", + dp->netdev->name, openflow_len); return NULL; } @@ -234,9 +235,6 @@ alloc_openflow_skb(struct datapath *dp, size_t openflow_len, uint8_t type, genl_len += nla_total_size(openflow_len); /* DP_GENL_A_OPENFLOW */ skb = *pskb = genlmsg_new(genl_len, GFP_ATOMIC); if (!skb) { - if (net_ratelimit()) - printk("%s: alloc_openflow_skb: genlmsg_new failed\n", - dp->netdev->name); return NULL; } @@ -663,8 +661,8 @@ dp_xmit_skb(struct sk_buff *skb) int len = skb->len; if (packet_length(skb) > skb->dev->mtu && !skb_is_gso(skb)) { - printk("%s: dropped over-mtu packet: %d > %d\n", - dp->netdev->name, packet_length(skb), skb->dev->mtu); + printk(KERN_WARNING "%s: dropped over-mtu packet: %d > %d\n", + dp->netdev->name, packet_length(skb), skb->dev->mtu); kfree_skb(skb); return -E2BIG; } @@ -686,8 +684,9 @@ int dp_output_port(struct datapath *dp, struct sk_buff *skb, int out_port, * the skb. */ if (!skb->dev) { if (net_ratelimit()) - printk("%s: skb device not set forwarding to in_port\n", - dp->netdev->name); + printk(KERN_NOTICE "%s: skb device not set " + "forwarding to in_port\n", + dp->netdev->name); kfree_skb(skb); return -ESRCH; } @@ -727,8 +726,9 @@ int dp_output_port(struct datapath *dp, struct sk_buff *skb, int out_port, /* To send to the input port, must use OFPP_IN_PORT */ kfree_skb(skb); if (net_ratelimit()) - printk("%s: can't directly forward to input port\n", - dp->netdev->name); + printk(KERN_NOTICE "%s: can't directly " + "forward to input port\n", + dp->netdev->name); return -EINVAL; } if (p->config & OFPPC_NO_FWD && !ignore_no_fwd) { @@ -746,8 +746,8 @@ int dp_output_port(struct datapath *dp, struct sk_buff *skb, int out_port, bad_port: kfree_skb(skb); if (net_ratelimit()) - printk("%s: can't forward to bad port %d\n", dp->netdev->name, - out_port); + printk(KERN_NOTICE "%s: can't forward to bad port %d\n", + dp->netdev->name, out_port); return -ENOENT; } diff --git a/datapath/datapath.h b/datapath/datapath.h index ffd045e8..84eb5dc2 100644 --- a/datapath/datapath.h +++ b/datapath/datapath.h @@ -16,12 +16,6 @@ #define NL_FLOWS_PER_MESSAGE 100 -#ifdef NDEBUG -#define dprintk(x...) -#else -#define dprintk(x...) printk(x) -#endif - /* Capabilities supported by this implementation. */ #define OFP_SUPPORTED_CAPABILITIES ( OFPC_FLOW_STATS \ | OFPC_TABLE_STATS \ diff --git a/datapath/dp_act.c b/datapath/dp_act.c index 32a1e429..3b5086f6 100644 --- a/datapath/dp_act.c +++ b/datapath/dp_act.c @@ -1,6 +1,6 @@ /* * Distributed under the terms of the GNU GPL version 2. - * Copyright (c) 2007, 2008 The Board of Trustees of The Leland + * Copyright (c) 2007, 2008, 2009 The Board of Trustees of The Leland * Stanford Junior University */ @@ -398,17 +398,8 @@ execute_ofpat(struct sk_buff *skb, struct sw_flow_key *key, const struct ofp_action_header *ah, uint16_t type) { const struct openflow_action *act = &of_actions[type]; - struct datapath *dp = skb->dev->br_port->dp; - - if (act->execute) { - if (!make_writable(&skb)) { - if (net_ratelimit()) - printk("%s: make_writable failed\n", dp->netdev->name); - return skb; - } + if (act->execute && make_writable(&skb)) skb = act->execute(skb, key, ah); - } - return skb; } @@ -432,8 +423,9 @@ execute_vendor(struct sk_buff *skb, const struct sw_flow_key *key, default: /* This should not be possible due to prior validation. */ if (net_ratelimit()) - printk("%s: attempt to execute action with unknown vendor: %#x\n", - dp->netdev->name, ntohl(avh->vendor)); + printk(KERN_WARNING "%s: attempt to execute action " + "with unknown vendor: %#x\n", + dp->netdev->name, ntohl(avh->vendor)); break; } @@ -483,8 +475,9 @@ void execute_actions(struct datapath *dp, struct sk_buff *skb, if (!skb) { if (net_ratelimit()) - printk("%s: execute_actions lost skb\n", - dp->netdev->name); + printk(KERN_WARNING "%s: " + "execute_actions lost skb\n", + dp->netdev->name); return; } } diff --git a/datapath/forward.c b/datapath/forward.c index 1ba29103..d8662397 100644 --- a/datapath/forward.c +++ b/datapath/forward.c @@ -1,6 +1,6 @@ /* * Distributed under the terms of the GNU GPL version 2. - * Copyright (c) 2007, 2008 The Board of Trustees of The Leland + * Copyright (c) 2007, 2008, 2009 The Board of Trustees of The Leland * Stanford Junior University */ @@ -128,8 +128,8 @@ recv_packet_out(struct sw_chain *chain, const struct sender *sender, if (actions_len > (ntohs(opo->header.length) - sizeof *opo)) { if (net_ratelimit()) - printk("%s: message too short for number of actions\n", - chain->dp->netdev->name); + printk(KERN_NOTICE "%s: message too short for number " + "of actions\n", chain->dp->netdev->name); return -EINVAL; } @@ -349,8 +349,8 @@ recv_vendor(struct sw_chain *chain, const struct sender *sender, return nx_recv_msg(chain, sender, msg); default: if (net_ratelimit()) - printk("%s: unknown vendor: 0x%x\n", chain->dp->netdev->name, - ntohl(ovh->vendor)); + printk(KERN_NOTICE "%s: unknown vendor: 0x%x\n", + chain->dp->netdev->name, ntohl(ovh->vendor)); dp_send_error_msg(chain->dp, sender, OFPET_BAD_REQUEST, OFPBRC_BAD_VENDOR, msg, ntohs(ovh->header.length)); return -EINVAL; @@ -429,8 +429,9 @@ fwd_control_input(struct sw_chain *chain, const struct sender *sender, } if (ntohs(oh->length) != length) { if (net_ratelimit()) - printk("%s: received message length wrong: %d/%d\n", - chain->dp->netdev->name, ntohs(oh->length), length); + printk(KERN_NOTICE "%s: received message length " + "wrong: %d/%d\n", chain->dp->netdev->name, + ntohs(oh->length), length); return -EINVAL; } @@ -519,8 +520,9 @@ static struct sk_buff *retrieve_skb(uint32_t id) skb = p->skb; p->skb = NULL; } else { - printk("cookie mismatch: %x != %x\n", - id >> PKT_BUFFER_BITS, p->cookie); + if (net_ratelimit()) + printk(KERN_NOTICE "cookie mismatch: %x != %x\n", + id >> PKT_BUFFER_BITS, p->cookie); } spin_unlock_irqrestore(&buffer_lock, flags); diff --git a/datapath/nx_act_snat.c b/datapath/nx_act_snat.c index 5db6f9d4..5b26c625 100644 --- a/datapath/nx_act_snat.c +++ b/datapath/nx_act_snat.c @@ -1,7 +1,7 @@ #ifdef SUPPORT_SNAT /* * Distributed under the terms of the GNU GPL version 2. - * Copyright (c) 2008 Nicira Networks + * Copyright (c) 2008, 2009 Nicira Networks */ #include @@ -127,12 +127,8 @@ dnat_mac(struct net_bridge_port *p, struct sk_buff *skb) list_for_each_entry (m, &sc->mappings, node) { if (m->ip_addr == iph->daddr){ /* Found it! */ - if (!make_writable(&skb)) { - if (net_ratelimit()) - printk("%s: make_writable failed\n", - p->dp->netdev->name); + if (!make_writable(&skb)) return -EINVAL; - } m->used = jiffies; memcpy(eh->h_dest, m->hw_addr, ETH_ALEN); break; @@ -268,12 +264,8 @@ handle_icmp_snat(struct sk_buff *skb) /* Send an echo reply in response */ nskb = skb_copy(skb, GFP_ATOMIC); - if (!nskb) { - if (net_ratelimit()) - printk("%s: skb copy failed for icmp reply\n", - p->dp->netdev->name); + if (!nskb) return -1; - } /* Update Ethernet header. */ eh = eth_hdr(nskb); @@ -486,8 +478,9 @@ snat_del_port(struct datapath *dp, uint16_t port) if (!p) { if (net_ratelimit()) - printk("%s: attempt to remove snat on non-existent port: %d\n", - dp->netdev->name, port); + printk(KERN_NOTICE "%s: attempt to remove snat on " + "non-existent port: %d\n", + dp->netdev->name, port); return -EINVAL; } @@ -496,8 +489,8 @@ snat_del_port(struct datapath *dp, uint16_t port) /* SNAT not configured on this port */ spin_unlock_irqrestore(&p->lock, flags); if (net_ratelimit()) - printk("%s: attempt to remove snat on non-snat port: %d\n", - dp->netdev->name, port); + printk(KERN_NOTICE "%s: attempt to remove snat on " + "non-snat port: %d\n", dp->netdev->name, port); return -EINVAL; } @@ -522,8 +515,9 @@ snat_add_port(struct datapath *dp, uint16_t port, if (!p) { if (net_ratelimit()) - printk("%s: attempt to add snat on non-existent port: %d\n", - dp->netdev->name, port); + printk(KERN_NOTICE "%s: attempt to add snat on " + "non-existent port: %d\n", + dp->netdev->name, port); return -EINVAL; } diff --git a/datapath/table-hash.c b/datapath/table-hash.c index 588b5f56..a501c3ca 100644 --- a/datapath/table-hash.c +++ b/datapath/table-hash.c @@ -242,7 +242,8 @@ struct sw_table *table_hash_create(unsigned int polynomial, BUG_ON(n_buckets & (n_buckets - 1)); th->buckets = kmem_zalloc(n_buckets * sizeof *th->buckets); if (th->buckets == NULL) { - printk("failed to allocate %u buckets\n", n_buckets); + printk(KERN_EMERG "failed to allocate %u buckets\n", + n_buckets); kfree(th); return NULL; } @@ -422,8 +423,8 @@ kmem_alloc(size_t size) if (!ptr) { ptr = vmalloc(size); if (ptr) - printk("openflow: used vmalloc for %lu bytes\n", - (unsigned long)size); + printk(KERN_NOTICE "openflow: used vmalloc for %lu " + "bytes\n", (unsigned long)size); } return ptr; }