Add datapath device name to printk's.
authorJustin Pettit <jpettit@nicira.com>
Fri, 9 Jan 2009 23:41:42 +0000 (15:41 -0800)
committerJustin Pettit <jpettit@nicira.com>
Fri, 9 Jan 2009 23:41:56 +0000 (15:41 -0800)
To aid debugging, this prints the datapath device name to printk
messages.  Not doing this wasn't a big deal when only a single datapath
was running, but it's very confusing when there are multiple.

datapath/brc_sysfs_dp.c
datapath/brc_sysfs_if.c
datapath/chain.c
datapath/datapath.c
datapath/dp_act.c
datapath/forward.c
datapath/nx_act_snat.c

index cb323cbb9f5359a92f2e51c4f86590c681ad1003..b1b27ed1f09474841aa0cae7df1e4ad2390ae305 100644 (file)
@@ -40,9 +40,7 @@ static ssize_t store_bridge_parm(struct class_device *d,
                                 const char *buf, size_t len,
                                 void (*set)(struct datapath *, unsigned long))
 {
-#if 0
        struct datapath *dp = dp_dev_get_dp(to_net_dev(d));
-#endif
        char *endp;
        unsigned long val;
 
@@ -58,7 +56,8 @@ static ssize_t store_bridge_parm(struct class_device *d,
        (*set)(br, val);
        spin_unlock_bh(&br->lock);
 #else
-       printk("xxx writing dp parms not supported yet!\n");
+       printk("%s: xxx writing dp parms not supported yet!\n", 
+                       dp->netdev->name);
 #endif
        return len;
 }
@@ -83,7 +82,7 @@ static void set_forward_delay(struct datapath *dp, unsigned long val)
        if (br_is_root_bridge(br))
                br->bridge_forward_delay = delay;
 #else
-       printk("xxx attempt to set_forward_delay()\n");
+       printk("%s: xxx attempt to set_forward_delay()\n", dp->netdev->name);
 #endif
 }
 
@@ -113,7 +112,7 @@ static void set_hello_time(struct datapath *dp, unsigned long val)
        if (br_is_root_bridge(br))
                br->bridge_hello_time = t;
 #else
-       printk("xxx attempt to set_hello_time()\n");
+       printk("%s: xxx attempt to set_hello_time()\n", dp->netdev->name);
 #endif
 }
 
@@ -145,7 +144,7 @@ static void set_max_age(struct datapath *dp, unsigned long val)
        if (br_is_root_bridge(br))
                br->bridge_max_age = t;
 #else
-       printk("xxx attempt to set_max_age()\n");
+       printk("%s: xxx attempt to set_max_age()\n", dp->netdev->name);
 #endif
 }
 
@@ -172,7 +171,7 @@ static void set_ageing_time(struct datapath *dp, unsigned long val)
 #if 0
        br->ageing_time = clock_t_to_jiffies(val);
 #else
-       printk("xxx attempt to set_ageing_time()\n");
+       printk("%s: xxx attempt to set_ageing_time()\n", dp->netdev->name);
 #endif
 }
 
@@ -200,8 +199,8 @@ static ssize_t store_stp_state(struct class_device *d,
                               const char *buf,
                               size_t len)
 {
-#if 0
        struct datapath *dp = dp_dev_get_dp(to_net_dev(d));
+#if 0
        char *endp;
        unsigned long val;
 
@@ -216,7 +215,7 @@ static ssize_t store_stp_state(struct class_device *d,
        br_stp_set_enabled(br, val);
        rtnl_unlock();
 #else
-       printk("xxx attempt to set_stp_state()\n");
+       printk("%s: xxx attempt to set_stp_state()\n", dp->netdev->name);
 #endif
 
        return len;
@@ -241,7 +240,7 @@ static void set_priority(struct datapath *dp, unsigned long val)
 #if 0
        br_stp_set_bridge_priority(br, (u16) val);
 #else
-       printk("xxx attempt to set_priority()\n");
+       printk("%s: xxx attempt to set_priority()\n", dp->netdev->name);
 #endif
 }
 
@@ -387,8 +386,8 @@ static ssize_t show_group_addr(struct class_device *d,
 static ssize_t store_group_addr(struct class_device *d,
                                const char *buf, size_t len)
 {
-#if 0
        struct datapath *dp = dp_dev_get_dp(to_net_dev(d));
+#if 0
        unsigned new_addr[6];
        int i;
 
@@ -418,7 +417,7 @@ static ssize_t store_group_addr(struct class_device *d,
                br->group_addr[i] = new_addr[i];
        spin_unlock_bh(&br->lock);
 #else
-       printk("xxx attempt to store_group_addr()\n");
+       printk("%s: xxx attempt to store_group_addr()\n", dp->netdev->name);
 #endif
        return len;
 }
index cc0bd50497cc83fbea30aa96a74de7d70e6ebb18..cf1412ffb3d03e23c480ae979811fb69c305fb28 100644 (file)
@@ -224,9 +224,9 @@ static ssize_t brport_store(struct kobject * kobj,
                            struct attribute * attr,
                            const char * buf, size_t count)
 {
+       struct net_bridge_port * p = to_brport(kobj);
 #if 0
        struct brport_attribute * brport_attr = to_brport_attr(attr);
-       struct net_bridge_port * p = to_brport(kobj);
        char *endp;
        unsigned long val;
 #endif
@@ -249,7 +249,8 @@ static ssize_t brport_store(struct kobject * kobj,
                rtnl_unlock();
        }
 #else
-       printk("xxx writing port parms not supported yet!\n");
+       printk("%s: xxx writing port parms not supported yet!\n", 
+                       p->dp->netdev->name);
 #endif
        return ret;
 }
index 8c2dddadc848e2102f7b5694fb57ff2b94a60e2c..aec78e3ae6cf45d39fa4a846a93932e22d695090 100644 (file)
@@ -5,6 +5,7 @@
  */
 
 #include "chain.h"
+#include "datapath.h"
 #include "flow.h"
 #include "table.h"
 #include <linux/module.h>
@@ -24,7 +25,7 @@ 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("too many tables in chain\n");
+               printk("%s: too many tables in chain\n", chain->dp->netdev->name);
                table->destroy(table);
                return -ENOBUFS;
        }
index a6c54c906f0dad002dc33059af51cc86205415c3..2e00091b0924faf17bd643eeb4e0194152f02e51 100644 (file)
@@ -224,8 +224,8 @@ 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("alloc_openflow_skb: openflow message too large: %zu\n", 
-                                       openflow_len);
+                       printk("%s: alloc_openflow_skb: openflow message too large: %zu\n", 
+                                       dp->netdev->name, openflow_len);
                return NULL;
        }
 
@@ -235,7 +235,8 @@ alloc_openflow_skb(struct datapath *dp, size_t openflow_len, uint8_t type,
        skb = *pskb = genlmsg_new(genl_len, GFP_ATOMIC);
        if (!skb) {
                if (net_ratelimit())
-                       printk("alloc_openflow_skb: genlmsg_new failed\n");
+                       printk("%s: alloc_openflow_skb: genlmsg_new failed\n", 
+                                       dp->netdev->name);
                return NULL;
        }
 
@@ -658,10 +659,12 @@ void dp_set_origin(struct datapath *dp, uint16_t in_port,
 int 
 dp_xmit_skb(struct sk_buff *skb)
 {
+       struct datapath *dp = skb->dev->br_port->dp;
        int len = skb->len;
+
        if (packet_length(skb) > skb->dev->mtu && !skb_is_gso(skb)) {
-               printk("dropped over-mtu packet: %d > %d\n",
-                          packet_length(skb), skb->dev->mtu);
+               printk("%s: dropped over-mtu packet: %d > %d\n",
+                          dp->netdev->name, packet_length(skb), skb->dev->mtu);
                kfree_skb(skb);
                return -E2BIG;
        }
@@ -683,7 +686,8 @@ int dp_output_port(struct datapath *dp, struct sk_buff *skb, int out_port,
                 * the skb. */
                if (!skb->dev) {
                        if (net_ratelimit())
-                               printk("skb device not set forwarding to in_port\n");
+                               printk("%s: skb device not set forwarding to in_port\n",
+                                               dp->netdev->name);
                        kfree_skb(skb);
                        return -ESRCH;
                }
@@ -723,7 +727,8 @@ 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("can't directly forward to input port\n");
+                               printk("%s: can't directly forward to input port\n", 
+                                               dp->netdev->name);
                        return -EINVAL;
                }
                if (p->config & OFPPC_NO_FWD && !ignore_no_fwd) {
@@ -741,7 +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("can't forward to bad port %d\n", out_port);
+               printk("%s: can't forward to bad port %d\n", dp->netdev->name, 
+                               out_port);
        return -ENOENT;
 }
 
index c41a32993590e0fe991aae4b7aa210d43f6dd734..32a1e42900c9ebdd9f22d89a1e860d077a996210 100644 (file)
@@ -398,11 +398,12 @@ 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("make_writable failed\n");
+                               printk("%s: make_writable failed\n", dp->netdev->name);
                        return skb;
                }
                skb = act->execute(skb, key, ah);
@@ -418,6 +419,7 @@ execute_vendor(struct sk_buff *skb, const struct sw_flow_key *key,
 {
        struct ofp_action_vendor_header *avh 
                        = (struct ofp_action_vendor_header *)ah;
+       struct datapath *dp = skb->dev->br_port->dp;
 
        /* NB: If changes need to be made to the packet, a call should be
         * made to make_writable or its equivalent first. */
@@ -430,8 +432,8 @@ 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("attempt to execute action with unknown vendor: %#x\n", 
-                                       ntohl(avh->vendor));
+                       printk("%s: attempt to execute action with unknown vendor: %#x\n", 
+                                       dp->netdev->name, ntohl(avh->vendor));
                break;
        }
 
@@ -481,7 +483,8 @@ void execute_actions(struct datapath *dp, struct sk_buff *skb,
 
                        if (!skb) {
                                if (net_ratelimit())
-                                       printk("execute_actions lost skb\n");
+                                       printk("%s: execute_actions lost skb\n", 
+                                                       dp->netdev->name);
                                return;
                        }
                }
index 8b9b15a6a0ab8b64d9c54e498b0bafcd2eae67d5..1ba291032ed90a9ab320703ba015c84ba7beb085 100644 (file)
@@ -128,7 +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("message too short for number of actions\n");
+                       printk("%s: message too short for number of actions\n", 
+                                       chain->dp->netdev->name);
                return -EINVAL;
        }
 
@@ -348,7 +349,8 @@ recv_vendor(struct sw_chain *chain, const struct sender *sender,
                return nx_recv_msg(chain, sender, msg);
        default:
                if (net_ratelimit())
-                       printk("unknown vendor: 0x%x\n", ntohl(ovh->vendor));
+                       printk("%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;
@@ -427,8 +429,8 @@ fwd_control_input(struct sw_chain *chain, const struct sender *sender,
        }
        if (ntohs(oh->length) != length) {
                if (net_ratelimit())
-                       printk("received message length wrong: %d/%d\n", 
-                               ntohs(oh->length), length);
+                       printk("%s: received message length wrong: %d/%d\n", 
+                               chain->dp->netdev->name, ntohs(oh->length), length);
                return -EINVAL;
        }
 
index d3750f1b29282565802c1abe4674bc7995656584..5db6f9d4cd79fa9e74940d887068ccb94dfb68d2 100644 (file)
@@ -129,7 +129,8 @@ dnat_mac(struct net_bridge_port *p, struct sk_buff *skb)
                        /* Found it! */
                        if (!make_writable(&skb)) {
                                if (net_ratelimit())
-                                       printk("make_writable failed\n");
+                                       printk("%s: make_writable failed\n", 
+                                                       p->dp->netdev->name);
                                return -EINVAL;
                        }
                        m->used = jiffies;
@@ -269,7 +270,8 @@ handle_icmp_snat(struct sk_buff *skb)
        nskb = skb_copy(skb, GFP_ATOMIC);
        if (!nskb) {
                if (net_ratelimit())
-                       printk("skb copy failed for icmp reply\n");
+                       printk("%s: skb copy failed for icmp reply\n", 
+                                       p->dp->netdev->name);
                return -1;
        }
 
@@ -484,7 +486,8 @@ snat_del_port(struct datapath *dp, uint16_t port)
 
        if (!p) {
                if (net_ratelimit()) 
-                       printk("Attempt to remove snat on non-existent port: %d\n", port);
+                       printk("%s: attempt to remove snat on non-existent port: %d\n", 
+                                       dp->netdev->name, port);
                return -EINVAL;
        }
 
@@ -493,7 +496,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("Attempt to remove snat on non-snat port: %d\n", port);
+                       printk("%s: attempt to remove snat on non-snat port: %d\n", 
+                                       dp->netdev->name, port);
                return -EINVAL;
        }
 
@@ -518,7 +522,8 @@ snat_add_port(struct datapath *dp, uint16_t port,
 
        if (!p) {
                if (net_ratelimit()) 
-                       printk("Attempt to add snat on non-existent port: %d\n", port);
+                       printk("%s: attempt to add snat on non-existent port: %d\n", 
+                                       dp->netdev->name, port);
                return -EINVAL;
        }