[prev in list] [next in list] [prev in thread] [next in thread] 

List:       keepalived-devel
Subject:    [Keepalived-devel] [PATCH] Fix VS_ISEQ macro.
From:       Vincent Bernat <bernat () luffy ! cx>
Date:       2009-06-25 12:57:06
Message-ID: 20090625135329.19BD9C01E () b1 ! fti ! net
[Download RAW message or body]

VS_ISEQ macro considered that virtual servers from different virtual
server groups could be equal because no comparison was done with
vs->vsgname. This macro is only used when reloading configuration and
therefore, the configuration was cleaned too much.

Here is an example of configuration that would delete and recreate the
second group on reload:

virtual_server_group VS_GROUP_1 {
   172.24.11.26 80
}
virtual_server group VS_GROUP_1 {
   delay_loop 10
   lb_algo rr
   lb_kind NAT
   protocol TCP
   real_server 172.24.11.12 80 {
      weight 1
      TCP_CHECK {
        connect_port 80
        connect_timeout 5
      }
   }
}

virtual_server_group VS_GROUP_2 {
   172.24.11.26 81
}
virtual_server group VS_GROUP_2 {
   delay_loop 10
   lb_algo rr
   lb_kind NAT
   protocol TCP
   real_server 172.24.11.12 80 {
      weight 1
      TCP_CHECK {
        connect_port 80
        connect_timeout 5
      }
   }
}

On reload, VS_GROUP_2 is deleted and created again.

Another fix would have been to fix vs_exist() instead since this
function was trying to compare vsgname too but when VS_ISEQ was saying
that the virtual servers were equal (like VS_GROUP_1 and VS_GROUP_2)
and when vsgname were not matching, vs_exist() just return 0 instead
of trying next virtual server. Using break instead of return 0 would
have fixed this too. However, VS_ISEQ is also used in get_rs_list().
---
 keepalived/check/ipwrapper.c    |    6 ------
 keepalived/include/check_data.h |    5 ++++-
 2 files changed, 4 insertions(+), 7 deletions(-)


["0001-Fix-VS_ISEQ-macro.patch" (text/x-patch)]

diff --git a/keepalived/check/ipwrapper.c b/keepalived/check/ipwrapper.c
index d7ed3dd..7a89bc1 100644
--- a/keepalived/check/ipwrapper.c
+++ b/keepalived/check/ipwrapper.c
@@ -563,13 +563,7 @@ vs_exist(virtual_server * old_vs)
 		vs = ELEMENT_DATA(e);
 		if (VS_ISEQ(old_vs, vs)) {
 			/* Check if group exist */
-			if ((vs->vsgname && !old_vs->vsgname) ||
-			    (!vs->vsgname && old_vs->vsgname))
-				return 0;
-
 			if (vs->vsgname) {
-				if (strcmp(vs->vsgname, old_vs->vsgname) != 0)
-					return 0;
 				vsg = ipvs_get_group_by_name(old_vs->vsgname,
 							    check_data->vs_group);
 				if (!vsg)
diff --git a/keepalived/include/check_data.h b/keepalived/include/check_data.h
index 79ac0d9..403b286 100644
--- a/keepalived/include/check_data.h
+++ b/keepalived/include/check_data.h
@@ -156,7 +156,10 @@ typedef struct _check_conf_data {
 			 (X)->nat_mask                == (Y)->nat_mask &&		\
 			 (X)->granularity_persistence == (Y)->granularity_persistence &&\
 			 !strcmp((X)->sched, (Y)->sched) &&				\
-			 !strcmp((X)->timeout_persistence, (Y)->timeout_persistence))
+			 !strcmp((X)->timeout_persistence, (Y)->timeout_persistence) && \
+			 (((X)->vsgname && (Y)->vsgname &&				\
+			   !strcmp((X)->vsgname, (Y)->vsgname)) || 			\
+			  (!(X)->vsgname && !(Y)->vsgname)))
 
 #define VSGE_ISEQ(X,Y)	((X)->addr_ip   == (Y)->addr_ip &&	\
 			 (X)->range     == (Y)->range &&	\


------------------------------------------------------------------------------


_______________________________________________
Keepalived-devel mailing list
Keepalived-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/keepalived-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic