/*
* 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
*/
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;
}
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;
}
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;
}
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;
}
* 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;
}
/* 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) {
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;
}
#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 \
/*
* 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
*/
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;
}
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;
}
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;
}
}
/*
* 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
*/
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;
}
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;
}
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;
}
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);
#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 <linux/netdevice.h>
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;
/* 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);
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;
}
/* 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;
}
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;
}
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;
}
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;
}