Commit af9debd4 authored by Julian Anastasov's avatar Julian Anastasov Committed by David S. Miller

[IPVS]: Add and reorder bh locks after moving to keventd.

An addition to the last ipvs changes that move
update_defense_level/si_meminfo to keventd:

- ip_vs_random_dropentry now runs in process context and should use _bh
  locks to protect from softirqs

- update_defense_level still needs _bh locks after si_meminfo is called,
  for the same purpose
Signed-off-by: default avatarJulian Anastasov <ja@ssi.bg>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f5b8adb4
...@@ -758,7 +758,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp) ...@@ -758,7 +758,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
return 1; return 1;
} }
/* Called from keventd and must protect itself from softirqs */
void ip_vs_random_dropentry(void) void ip_vs_random_dropentry(void)
{ {
int idx; int idx;
...@@ -773,7 +773,7 @@ void ip_vs_random_dropentry(void) ...@@ -773,7 +773,7 @@ void ip_vs_random_dropentry(void)
/* /*
* Lock is actually needed in this loop. * Lock is actually needed in this loop.
*/ */
ct_write_lock(hash); ct_write_lock_bh(hash);
list_for_each_entry(cp, &ip_vs_conn_tab[hash], c_list) { list_for_each_entry(cp, &ip_vs_conn_tab[hash], c_list) {
if (!cp->cport && !(cp->flags & IP_VS_CONN_F_NO_CPORT)) if (!cp->cport && !(cp->flags & IP_VS_CONN_F_NO_CPORT))
...@@ -806,7 +806,7 @@ void ip_vs_random_dropentry(void) ...@@ -806,7 +806,7 @@ void ip_vs_random_dropentry(void)
ip_vs_conn_expire_now(cp->control); ip_vs_conn_expire_now(cp->control);
} }
} }
ct_write_unlock(hash); ct_write_unlock_bh(hash);
} }
} }
......
...@@ -90,7 +90,8 @@ int ip_vs_get_debug_level(void) ...@@ -90,7 +90,8 @@ int ip_vs_get_debug_level(void)
#endif #endif
/* /*
* update_defense_level is called from keventd and from sysctl. * update_defense_level is called from keventd and from sysctl,
* so it needs to protect itself from softirqs
*/ */
static void update_defense_level(void) static void update_defense_level(void)
{ {
...@@ -110,6 +111,8 @@ static void update_defense_level(void) ...@@ -110,6 +111,8 @@ static void update_defense_level(void)
nomem = (availmem < sysctl_ip_vs_amemthresh); nomem = (availmem < sysctl_ip_vs_amemthresh);
local_bh_disable();
/* drop_entry */ /* drop_entry */
spin_lock(&__ip_vs_dropentry_lock); spin_lock(&__ip_vs_dropentry_lock);
switch (sysctl_ip_vs_drop_entry) { switch (sysctl_ip_vs_drop_entry) {
...@@ -206,6 +209,8 @@ static void update_defense_level(void) ...@@ -206,6 +209,8 @@ static void update_defense_level(void)
if (to_change >= 0) if (to_change >= 0)
ip_vs_protocol_timeout_change(sysctl_ip_vs_secure_tcp>1); ip_vs_protocol_timeout_change(sysctl_ip_vs_secure_tcp>1);
write_unlock(&__ip_vs_securetcp_lock); write_unlock(&__ip_vs_securetcp_lock);
local_bh_enable();
} }
...@@ -1360,9 +1365,7 @@ proc_do_defense_mode(ctl_table *table, int write, struct file * filp, ...@@ -1360,9 +1365,7 @@ proc_do_defense_mode(ctl_table *table, int write, struct file * filp,
/* Restore the correct value */ /* Restore the correct value */
*valp = val; *valp = val;
} else { } else {
local_bh_disable();
update_defense_level(); update_defense_level();
local_bh_enable();
} }
} }
return rc; return rc;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment