]> git.karo-electronics.de Git - linux-beck.git/commitdiff
ipvs: make "no destination available" message more informative
authorPatrick Schaaf <netdev@bof.de>
Fri, 11 Feb 2011 13:01:12 +0000 (14:01 +0100)
committerSimon Horman <horms@verge.net.au>
Wed, 16 Feb 2011 05:53:33 +0000 (14:53 +0900)
When IP_VS schedulers do not find a destination, they output a terse
"WLC: no destination available" message through kernel syslog, which I
can not only make sense of because syslog puts them in a logfile
together with keepalived checker results.

This patch makes the output a bit more informative, by telling you which
virtual service failed to find a destination.

Example output:

kernel: [1539214.552233] IPVS: wlc: TCP 192.168.8.30:22 - no destination available
kernel: [1539299.674418] IPVS: wlc: FWM 22 0x00000016 - no destination available

I have tested the code for IPv4 and FWM services, as you can see from
the example; I do not have an IPv6 setup to test the third code path
with.

To avoid code duplication, I put a new function ip_vs_scheduler_err()
into ip_vs_sched.c, and use that from the schedulers instead of calling
IP_VS_ERR_RL directly.

Signed-off-by: Patrick Schaaf <netdev@bof.de>
Signed-off-by: Simon Horman <horms@verge.net.au>
include/net/ip_vs.h
net/netfilter/ipvs/ip_vs_lblc.c
net/netfilter/ipvs/ip_vs_lblcr.c
net/netfilter/ipvs/ip_vs_lc.c
net/netfilter/ipvs/ip_vs_nq.c
net/netfilter/ipvs/ip_vs_rr.c
net/netfilter/ipvs/ip_vs_sched.c
net/netfilter/ipvs/ip_vs_sed.c
net/netfilter/ipvs/ip_vs_sh.c
net/netfilter/ipvs/ip_vs_wlc.c
net/netfilter/ipvs/ip_vs_wrr.c

index 5d75feadf4f494dda71453e82d4408cba00d7f97..93995494dfd4a86018dcaa55c48fc96170d49a60 100644 (file)
@@ -1019,6 +1019,8 @@ ip_vs_schedule(struct ip_vs_service *svc, struct sk_buff *skb,
 extern int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
                        struct ip_vs_proto_data *pd);
 
+extern void ip_vs_scheduler_err(struct ip_vs_service *svc, const char *msg);
+
 
 /*
  *      IPVS control data and functions (from ip_vs_ctl.c)
index 00b5ffab3768048dfd4915443f5c377f9e9b5838..4a9c8cd196902044a6bec8e38c4d7f1ab711ba13 100644 (file)
@@ -510,7 +510,7 @@ ip_vs_lblc_schedule(struct ip_vs_service *svc, const struct sk_buff *skb)
        /* No cache entry or it is invalid, time to schedule */
        dest = __ip_vs_lblc_schedule(svc);
        if (!dest) {
-               IP_VS_ERR_RL("LBLC: no destination available\n");
+               ip_vs_scheduler_err(svc, "no destination available");
                return NULL;
        }
 
index bfa25f1ea9e4b7333703a648951af891e206cf6a..bd329b1e958907065c58aa91150cb75e4f51bc65 100644 (file)
@@ -692,7 +692,7 @@ ip_vs_lblcr_schedule(struct ip_vs_service *svc, const struct sk_buff *skb)
                /* The cache entry is invalid, time to schedule */
                dest = __ip_vs_lblcr_schedule(svc);
                if (!dest) {
-                       IP_VS_ERR_RL("LBLCR: no destination available\n");
+                       ip_vs_scheduler_err(svc, "no destination available");
                        read_unlock(&svc->sched_lock);
                        return NULL;
                }
index 4f69db1fac56f514bbbdb17d4be00521683a19a3..60638007c6c7bf965c5d83411616adf6e7c180ea 100644 (file)
@@ -70,7 +70,7 @@ ip_vs_lc_schedule(struct ip_vs_service *svc, const struct sk_buff *skb)
        }
 
        if (!least)
-               IP_VS_ERR_RL("LC: no destination available\n");
+               ip_vs_scheduler_err(svc, "no destination available");
        else
                IP_VS_DBG_BUF(6, "LC: server %s:%u activeconns %d "
                              "inactconns %d\n",
index c413e18308230e910cef0a6e392e752826a57e5f..984d9c137d84ac65c140c6ee15c78a66d80c8775 100644 (file)
@@ -99,7 +99,7 @@ ip_vs_nq_schedule(struct ip_vs_service *svc, const struct sk_buff *skb)
        }
 
        if (!least) {
-               IP_VS_ERR_RL("NQ: no destination available\n");
+               ip_vs_scheduler_err(svc, "no destination available");
                return NULL;
        }
 
index e210f37d8ea29edca08996db3920d6ec363d234c..c49b388d1085238ce435fec81fa8f97da6a8ee93 100644 (file)
@@ -72,7 +72,7 @@ ip_vs_rr_schedule(struct ip_vs_service *svc, const struct sk_buff *skb)
                q = q->next;
        } while (q != p);
        write_unlock(&svc->sched_lock);
-       IP_VS_ERR_RL("RR: no destination available\n");
+       ip_vs_scheduler_err(svc, "no destination available");
        return NULL;
 
   out:
index 076ebe00435deef930f428fbb02414c550c14b98..08dbdd5bc18fc5dc9f23562ac86a66e20dafb897 100644 (file)
@@ -29,6 +29,7 @@
 
 #include <net/ip_vs.h>
 
+EXPORT_SYMBOL(ip_vs_scheduler_err);
 /*
  *  IPVS scheduler list
  */
@@ -146,6 +147,30 @@ void ip_vs_scheduler_put(struct ip_vs_scheduler *scheduler)
                module_put(scheduler->module);
 }
 
+/*
+ * Common error output helper for schedulers
+ */
+
+void ip_vs_scheduler_err(struct ip_vs_service *svc, const char *msg)
+{
+       if (svc->fwmark) {
+               IP_VS_ERR_RL("%s: FWM %u 0x%08X - %s\n",
+                            svc->scheduler->name, svc->fwmark,
+                            svc->fwmark, msg);
+#ifdef CONFIG_IP_VS_IPV6
+       } else if (svc->af == AF_INET6) {
+               IP_VS_ERR_RL("%s: %s [%pI6]:%d - %s\n",
+                            svc->scheduler->name,
+                            ip_vs_proto_name(svc->protocol),
+                            &svc->addr.in6, ntohs(svc->port), msg);
+#endif
+       } else {
+               IP_VS_ERR_RL("%s: %s %pI4:%d - %s\n",
+                            svc->scheduler->name,
+                            ip_vs_proto_name(svc->protocol),
+                            &svc->addr.ip, ntohs(svc->port), msg);
+       }
+}
 
 /*
  *  Register a scheduler in the scheduler list
index 1ab75a9dc400d5c9a45bf5a02ff6e95949292cff..89ead246ed3d250aa24bc2e195f4901f7b73b1d3 100644 (file)
@@ -87,7 +87,7 @@ ip_vs_sed_schedule(struct ip_vs_service *svc, const struct sk_buff *skb)
                        goto nextstage;
                }
        }
-       IP_VS_ERR_RL("SED: no destination available\n");
+       ip_vs_scheduler_err(svc, "no destination available");
        return NULL;
 
        /*
index e6cc174fbc06d4410a54c1e09021811e5773e81c..b5e2556c581ad4c7ddabad5807d6af2d50add98f 100644 (file)
@@ -223,7 +223,7 @@ ip_vs_sh_schedule(struct ip_vs_service *svc, const struct sk_buff *skb)
            || !(dest->flags & IP_VS_DEST_F_AVAILABLE)
            || atomic_read(&dest->weight) <= 0
            || is_overloaded(dest)) {
-               IP_VS_ERR_RL("SH: no destination available\n");
+               ip_vs_scheduler_err(svc, "no destination available");
                return NULL;
        }
 
index bbddfdb10db2b1afc026618456f2bc99a8698c48..fdf0f58962a4f627cfd68447e55484ddfea688f6 100644 (file)
@@ -75,7 +75,7 @@ ip_vs_wlc_schedule(struct ip_vs_service *svc, const struct sk_buff *skb)
                        goto nextstage;
                }
        }
-       IP_VS_ERR_RL("WLC: no destination available\n");
+       ip_vs_scheduler_err(svc, "no destination available");
        return NULL;
 
        /*
index 30db633f88f10c948e3e15c01ffb2b37bd0c4d13..1ef41f50723c04c13cfcff46ac1ca387aa6def7a 100644 (file)
@@ -147,8 +147,9 @@ ip_vs_wrr_schedule(struct ip_vs_service *svc, const struct sk_buff *skb)
 
                        if (mark->cl == mark->cl->next) {
                                /* no dest entry */
-                               IP_VS_ERR_RL("WRR: no destination available: "
-                                            "no destinations present\n");
+                               ip_vs_scheduler_err(svc,
+                                       "no destination available: "
+                                       "no destinations present");
                                dest = NULL;
                                goto out;
                        }
@@ -162,8 +163,8 @@ ip_vs_wrr_schedule(struct ip_vs_service *svc, const struct sk_buff *skb)
                                 */
                                if (mark->cw == 0) {
                                        mark->cl = &svc->destinations;
-                                       IP_VS_ERR_RL("WRR: no destination "
-                                                    "available\n");
+                                       ip_vs_scheduler_err(svc,
+                                               "no destination available");
                                        dest = NULL;
                                        goto out;
                                }
@@ -185,8 +186,9 @@ ip_vs_wrr_schedule(struct ip_vs_service *svc, const struct sk_buff *skb)
                        /* back to the start, and no dest is found.
                           It is only possible when all dests are OVERLOADED */
                        dest = NULL;
-                       IP_VS_ERR_RL("WRR: no destination available: "
-                                    "all destinations are overloaded\n");
+                       ip_vs_scheduler_err(svc,
+                               "no destination available: "
+                               "all destinations are overloaded");
                        goto out;
                }
        }