bridge: change console message interface
authorstephen hemminger <shemminger@vyatta.com>
Mon, 10 May 2010 09:31:09 +0000 (09:31 +0000)
committerDavid S. Miller <davem@davemloft.net>
Sun, 16 May 2010 06:10:02 +0000 (23:10 -0700)
Use one set of macro's for all bridge messages.

Note: can't use netdev_XXX macro's because bridge is purely
virtual and has no device parent.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/bridge/br.c
net/bridge/br_device.c
net/bridge/br_fdb.c
net/bridge/br_ioctl.c
net/bridge/br_multicast.c
net/bridge/br_netlink.c
net/bridge/br_private.h
net/bridge/br_stp.c
net/bridge/br_stp_if.c
net/bridge/br_stp_timer.c

index e1241c76239a96fb3e4d027ba071b640c2904ceb..76357b547752327d2ff4a7ce310effc5f4142b79 100644 (file)
@@ -38,7 +38,7 @@ static int __init br_init(void)
 
        err = stp_proto_register(&br_stp_proto);
        if (err < 0) {
-               printk(KERN_ERR "bridge: can't register sap for STP\n");
+               pr_err("bridge: can't register sap for STP\n");
                return err;
        }
 
index 22b97ba7dc527cabca898169837e5664e7707eac..eedf2c94820e26150d8823c2aa1652626c5f281d 100644 (file)
@@ -263,9 +263,8 @@ void br_netpoll_enable(struct net_bridge *br,
                        dev->npinfo = br->dev->npinfo;
        } else if (!(br->dev->priv_flags & IFF_DISABLE_NETPOLL)) {
                br->dev->priv_flags |= IFF_DISABLE_NETPOLL;
-               printk(KERN_INFO "%s:new device %s"
-                       " does not support netpoll (disabling)",
-                       br->dev->name, dev->name);
+               br_info(br,"new device %s does not support netpoll (disabling)",
+                       dev->name);
        }
 }
 
index 9101a4e5620129fa4d29df1a7e2cbde264cf88f2..26637439965bef745542f7baa4242d5249a33d9d 100644 (file)
@@ -353,8 +353,7 @@ static int fdb_insert(struct net_bridge *br, struct net_bridge_port *source,
                 */
                if (fdb->is_local)
                        return 0;
-
-               printk(KERN_WARNING "%s adding interface with same address "
+               br_warn(br, "adding interface %s with same address "
                       "as a received packet\n",
                       source->dev->name);
                fdb_delete(fdb);
@@ -397,9 +396,9 @@ void br_fdb_update(struct net_bridge *br, struct net_bridge_port *source,
                /* attempt to update an entry for a local interface */
                if (unlikely(fdb->is_local)) {
                        if (net_ratelimit())
-                               printk(KERN_WARNING "%s: received packet with "
-                                      "own address as source address\n",
-                                      source->dev->name);
+                               br_warn(br, "received packet on %s with "
+                                       "own address as source address\n",
+                                       source->dev->name);
                } else {
                        /* fastpath: update of existing entry */
                        fdb->dst = source;
index 995afc4b04dc58bf46d0ca4b5b7d650247b37282..cb43312b846ee8f33be636e7ca69df3dd2eeb455 100644 (file)
@@ -412,6 +412,6 @@ int br_dev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 
        }
 
-       pr_debug("Bridge does not support ioctl 0x%x\n", cmd);
+       br_debug(br, "Bridge does not support ioctl 0x%x\n", cmd);
        return -EOPNOTSUPP;
 }
index c8419e2403165f40f3c71fa3e88bd56a72cbaa6e..9d21d98ae5fa98cc5d187bc6ae9b6ceb85f294cc 100644 (file)
@@ -585,10 +585,9 @@ static struct net_bridge_mdb_entry *br_multicast_get_group(
 
        if (unlikely(count > br->hash_elasticity && count)) {
                if (net_ratelimit())
-                       printk(KERN_INFO "%s: Multicast hash table "
-                              "chain limit reached: %s\n",
-                              br->dev->name, port ? port->dev->name :
-                                                    br->dev->name);
+                       br_info(br, "Multicast hash table "
+                               "chain limit reached: %s\n",
+                               port ? port->dev->name : br->dev->name);
 
                elasticity = br->hash_elasticity;
        }
@@ -596,11 +595,9 @@ static struct net_bridge_mdb_entry *br_multicast_get_group(
        if (mdb->size >= max) {
                max *= 2;
                if (unlikely(max >= br->hash_max)) {
-                       printk(KERN_WARNING "%s: Multicast hash table maximum "
-                              "reached, disabling snooping: %s, %d\n",
-                              br->dev->name, port ? port->dev->name :
-                                                    br->dev->name,
-                              max);
+                       br_warn(br, "Multicast hash table maximum "
+                               "reached, disabling snooping: %s, %d\n",
+                               port ? port->dev->name : br->dev->name, max);
                        err = -E2BIG;
 disable:
                        br->multicast_disabled = 1;
@@ -611,22 +608,19 @@ disable:
        if (max > mdb->max || elasticity) {
                if (mdb->old) {
                        if (net_ratelimit())
-                               printk(KERN_INFO "%s: Multicast hash table "
-                                      "on fire: %s\n",
-                                      br->dev->name, port ? port->dev->name :
-                                                            br->dev->name);
+                               br_info(br, "Multicast hash table "
+                                       "on fire: %s\n",
+                                       port ? port->dev->name : br->dev->name);
                        err = -EEXIST;
                        goto err;
                }
 
                err = br_mdb_rehash(&br->mdb, max, elasticity);
                if (err) {
-                       printk(KERN_WARNING "%s: Cannot rehash multicast "
-                              "hash table, disabling snooping: "
-                              "%s, %d, %d\n",
-                              br->dev->name, port ? port->dev->name :
-                                                    br->dev->name,
-                              mdb->size, err);
+                       br_warn(br, "Cannot rehash multicast "
+                               "hash table, disabling snooping: %s, %d, %d\n",
+                               port ? port->dev->name : br->dev->name,
+                               mdb->size, err);
                        goto disable;
                }
 
index aa56ac2c88293ad7717c62c256eaea185a638cd1..fe0a79018ab238e0b1adf826b87cf3a97184723b 100644 (file)
@@ -42,8 +42,8 @@ static int br_fill_ifinfo(struct sk_buff *skb, const struct net_bridge_port *por
        struct nlmsghdr *nlh;
        u8 operstate = netif_running(dev) ? dev->operstate : IF_OPER_DOWN;
 
-       pr_debug("br_fill_info event %d port %s master %s\n",
-                event, dev->name, br->dev->name);
+       br_debug(br, "br_fill_info event %d port %s master %s\n",
+                    event, dev->name, br->dev->name);
 
        nlh = nlmsg_put(skb, pid, seq, event, sizeof(*hdr), flags);
        if (nlh == NULL)
@@ -87,7 +87,9 @@ void br_ifinfo_notify(int event, struct net_bridge_port *port)
        struct sk_buff *skb;
        int err = -ENOBUFS;
 
-       pr_debug("bridge notify event=%d\n", event);
+       br_debug(port->br, "port %u(%s) event %d\n",
+                (unsigned)port->port_no, port->dev->name, event);
+
        skb = nlmsg_new(br_nlmsg_size(), GFP_ATOMIC);
        if (skb == NULL)
                goto errout;
index 8a072661a7444604ddad820438635cae6930d0ba..79a13d1c25735016a3f388bc316889984b003852 100644 (file)
@@ -240,6 +240,21 @@ struct br_input_skb_cb {
 # define BR_INPUT_SKB_CB_MROUTERS_ONLY(__skb)  (0)
 #endif
 
+#define br_printk(level, br, format, args...)  \
+       printk(level "%s: " format, (br)->dev->name, ##args)
+
+#define br_err(__br, format, args...)                  \
+       br_printk(KERN_ERR, __br, format, ##args)
+#define br_warn(__br, format, args...)                 \
+       br_printk(KERN_WARNING, __br, format, ##args)
+#define br_notice(__br, format, args...)               \
+       br_printk(KERN_NOTICE, __br, format, ##args)
+#define br_info(__br, format, args...)                 \
+       br_printk(KERN_INFO, __br, format, ##args)
+
+#define br_debug(br, format, args...)                  \
+       pr_debug("%s: " format,  (br)->dev->name, ##args)
+
 extern struct notifier_block br_device_notifier;
 extern const u8 br_group_address[ETH_ALEN];
 
index edcf14b560f6febf68a814418999cbe63ee6dcfd..57186d84d2bd6497366d7d4d7cca7a694e0b5818 100644 (file)
@@ -31,10 +31,9 @@ static const char *const br_port_state_names[] = {
 
 void br_log_state(const struct net_bridge_port *p)
 {
-       pr_info("%s: port %d(%s) entering %s state\n",
-               p->br->dev->name, p->port_no, p->dev->name,
+       br_info(p->br, "port %u(%s) entering %s state\n",
+               (unsigned) p->port_no, p->dev->name,
                br_port_state_names[p->state]);
-
 }
 
 /* called under bridge lock */
@@ -300,7 +299,7 @@ void br_topology_change_detection(struct net_bridge *br)
        if (br->stp_enabled != BR_KERNEL_STP)
                return;
 
-       pr_info("%s: topology change detected, %s\n", br->dev->name,
+       br_info(br, "topology change detected, %s\n",
                isroot ? "propagating" : "sending tcn bpdu");
 
        if (isroot) {
@@ -469,8 +468,8 @@ void br_received_config_bpdu(struct net_bridge_port *p, struct br_config_bpdu *b
 void br_received_tcn_bpdu(struct net_bridge_port *p)
 {
        if (br_is_designated_port(p)) {
-               pr_info("%s: received tcn bpdu on port %i(%s)\n",
-                      p->br->dev->name, p->port_no, p->dev->name);
+               br_info(p->br, "port %u(%s) received tcn bpdu\n",
+                       (unsigned) p->port_no, p->dev->name);
 
                br_topology_change_detection(p->br);
                br_topology_change_acknowledge(p);
index d527119e9f54fd0d226a60c8f20e669ab506c55c..1d8826914cbf20a7fecec51bffeee3551a61e7e4 100644 (file)
@@ -85,17 +85,16 @@ void br_stp_enable_port(struct net_bridge_port *p)
 {
        br_init_port(p);
        br_port_state_selection(p->br);
+       br_log_state(p);
 }
 
 /* called under bridge lock */
 void br_stp_disable_port(struct net_bridge_port *p)
 {
-       struct net_bridge *br;
+       struct net_bridge *br = p->br;
        int wasroot;
 
-       br = p->br;
-       printk(KERN_INFO "%s: port %i(%s) entering %s state\n",
-              br->dev->name, p->port_no, p->dev->name, "disabled");
+       br_log_state(p);
 
        wasroot = br_is_root_bridge(br);
        br_become_designated_port(p);
@@ -127,11 +126,10 @@ static void br_stp_start(struct net_bridge *br)
        r = call_usermodehelper(BR_STP_PROG, argv, envp, UMH_WAIT_PROC);
        if (r == 0) {
                br->stp_enabled = BR_USER_STP;
-               printk(KERN_INFO "%s: userspace STP started\n", br->dev->name);
+               br_debug(br, "userspace STP started\n");
        } else {
                br->stp_enabled = BR_KERNEL_STP;
-               printk(KERN_INFO "%s: starting userspace STP failed, "
-                               "starting kernel STP\n", br->dev->name);
+               br_debug(br, "using kernel STP\n");
 
                /* To start timers on any ports left in blocking */
                spin_lock_bh(&br->lock);
@@ -148,9 +146,7 @@ static void br_stp_stop(struct net_bridge *br)
 
        if (br->stp_enabled == BR_USER_STP) {
                r = call_usermodehelper(BR_STP_PROG, argv, envp, 1);
-               printk(KERN_INFO "%s: userspace STP stopped, return code %d\n",
-                       br->dev->name, r);
-
+               br_info(br, "userspace STP stopped, return code %d\n", r);
 
                /* To start timers on any ports left in blocking */
                spin_lock_bh(&br->lock);
index 772a140bfdf0f8edc2f9692bf7d001d5dbf97954..7b22456023c5615642b3c1a786bc135065aeb990 100644 (file)
@@ -35,7 +35,7 @@ static void br_hello_timer_expired(unsigned long arg)
 {
        struct net_bridge *br = (struct net_bridge *)arg;
 
-       pr_debug("%s: hello timer expired\n", br->dev->name);
+       br_debug(br, "hello timer expired\n");
        spin_lock(&br->lock);
        if (br->dev->flags & IFF_UP) {
                br_config_bpdu_generation(br);
@@ -55,13 +55,9 @@ static void br_message_age_timer_expired(unsigned long arg)
        if (p->state == BR_STATE_DISABLED)
                return;
 
-
-       pr_info("%s: neighbor %.2x%.2x.%.2x:%.2x:%.2x:%.2x:%.2x:%.2x lost on port %d(%s)\n",
-               br->dev->name,
-               id->prio[0], id->prio[1],
-               id->addr[0], id->addr[1], id->addr[2],
-               id->addr[3], id->addr[4], id->addr[5],
-               p->port_no, p->dev->name);
+       br_info(br, "port %u(%s) neighbor %.2x%.2x.%pM lost\n",
+               (unsigned) p->port_no, p->dev->name,
+               id->prio[0], id->prio[1], &id->addr);
 
        /*
         * According to the spec, the message age timer cannot be
@@ -87,8 +83,8 @@ static void br_forward_delay_timer_expired(unsigned long arg)
        struct net_bridge_port *p = (struct net_bridge_port *) arg;
        struct net_bridge *br = p->br;
 
-       pr_debug("%s: %d(%s) forward delay timer\n",
-                br->dev->name, p->port_no, p->dev->name);
+       br_debug(br, "port %u(%s) forward delay timer\n",
+                (unsigned) p->port_no, p->dev->name);
        spin_lock(&br->lock);
        if (p->state == BR_STATE_LISTENING) {
                p->state = BR_STATE_LEARNING;
@@ -107,7 +103,7 @@ static void br_tcn_timer_expired(unsigned long arg)
 {
        struct net_bridge *br = (struct net_bridge *) arg;
 
-       pr_debug("%s: tcn timer expired\n", br->dev->name);
+       br_debug(br, "tcn timer expired\n");
        spin_lock(&br->lock);
        if (br->dev->flags & IFF_UP) {
                br_transmit_tcn(br);
@@ -121,7 +117,7 @@ static void br_topology_change_timer_expired(unsigned long arg)
 {
        struct net_bridge *br = (struct net_bridge *) arg;
 
-       pr_debug("%s: topo change timer expired\n", br->dev->name);
+       br_debug(br, "topo change timer expired\n");
        spin_lock(&br->lock);
        br->topology_change_detected = 0;
        br->topology_change = 0;
@@ -132,8 +128,8 @@ static void br_hold_timer_expired(unsigned long arg)
 {
        struct net_bridge_port *p = (struct net_bridge_port *) arg;
 
-       pr_debug("%s: %d(%s) hold timer expired\n",
-                p->br->dev->name,  p->port_no, p->dev->name);
+       br_debug(p->br, "port %u(%s) hold timer expired\n",
+                (unsigned) p->port_no, p->dev->name);
 
        spin_lock(&p->br->lock);
        if (p->config_pending)