File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -94,6 +94,7 @@ static void update_defense_level(struct netns_ipvs *ipvs)
94
94
{
95
95
struct sysinfo i ;
96
96
int availmem ;
97
+ int amemthresh ;
97
98
int nomem ;
98
99
int to_change = -1 ;
99
100
@@ -105,7 +106,8 @@ static void update_defense_level(struct netns_ipvs *ipvs)
105
106
/* si_swapinfo(&i); */
106
107
/* availmem = availmem - (i.totalswap - i.freeswap); */
107
108
108
- nomem = (availmem < ipvs -> sysctl_amemthresh );
109
+ amemthresh = max (READ_ONCE (ipvs -> sysctl_amemthresh ), 0 );
110
+ nomem = (availmem < amemthresh );
109
111
110
112
local_bh_disable ();
111
113
@@ -145,19 +147,17 @@ static void update_defense_level(struct netns_ipvs *ipvs)
145
147
break ;
146
148
case 1 :
147
149
if (nomem ) {
148
- ipvs -> drop_rate = ipvs -> drop_counter
149
- = ipvs -> sysctl_amemthresh /
150
- (ipvs -> sysctl_amemthresh - availmem );
150
+ ipvs -> drop_counter = amemthresh / (amemthresh - availmem );
151
+ ipvs -> drop_rate = ipvs -> drop_counter ;
151
152
ipvs -> sysctl_drop_packet = 2 ;
152
153
} else {
153
154
ipvs -> drop_rate = 0 ;
154
155
}
155
156
break ;
156
157
case 2 :
157
158
if (nomem ) {
158
- ipvs -> drop_rate = ipvs -> drop_counter
159
- = ipvs -> sysctl_amemthresh /
160
- (ipvs -> sysctl_amemthresh - availmem );
159
+ ipvs -> drop_counter = amemthresh / (amemthresh - availmem );
160
+ ipvs -> drop_rate = ipvs -> drop_counter ;
161
161
} else {
162
162
ipvs -> drop_rate = 0 ;
163
163
ipvs -> sysctl_drop_packet = 1 ;
You can’t perform that action at this time.
0 commit comments