- Timestamp:
- 06/08/09 18:29:43 (3 years ago)
- Children:
- 5987af1b79b0c1fbd4aa9d30a53ec6879853ece3
- Parents:
- 03dc5e370ef4fbf66e34cbe5bc5b878ed764149c
- git-committer:
- Neutron Soutmun <neo.neutron@…> (06/08/09 18:29:43)
- Files:
-
- 1 modified
-
src/rh-task-bandwidth.c (modified) (11 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/rh-task-bandwidth.c
rebf1b31 r2f0141c 18 18 #include "rh-task-memset.h" 19 19 #include "rh-utils.h" 20 21 22 20 23 21 #define BANDWIDTH_WRAPPER "/etc/rahunas/bandwidth.sh" … … 136 134 } 137 135 138 int bandwidth_start(void) 139 { 140 char *args[3]; 136 int bandwidth_start(struct vserver *vs) 137 { 138 char *args[5]; 139 struct interfaces *iface = vs->vserver_config->iface; 140 int ret; 141 141 142 142 DP("Bandwidth: start"); … … 144 144 args[0] = BANDWIDTH_WRAPPER; 145 145 args[1] = "start"; 146 args[2] = (char *) 0; 147 148 return bandwidth_exec(NULL, args); 149 } 150 151 int bandwidth_stop(void) 152 { 153 char *args[3]; 146 args[2] = iface->dev_internal; 147 args[3] = iface->dev_ifb; 148 args[4] = (char *) 0; 149 150 ret = bandwidth_exec(vs, args); 151 return ret; 152 } 153 154 int bandwidth_stop(struct vserver *vs) 155 { 156 char *args[5]; 157 struct interfaces *iface = vs->vserver_config->iface; 158 int ret; 154 159 155 160 DP("Bandwidth: stop"); … … 157 162 args[0] = BANDWIDTH_WRAPPER; 158 163 args[1] = "stop"; 159 args[2] = (char *) 0; 160 161 return bandwidth_exec(NULL, args); 164 args[2] = iface->dev_internal; 165 args[3] = iface->dev_ifb; 166 args[4] = (char *) 0; 167 168 ret = bandwidth_exec(vs, args); 169 return ret; 162 170 } 163 171 164 172 int bandwidth_add(struct vserver *vs, struct bandwidth_req *bw_req) 165 173 { 166 char *args[7]; 174 char *args[9]; 175 struct interfaces *iface = vs->vserver_config->iface; 167 176 168 177 DP("Bandwidth: request %s %s %s %s", bw_req->slot_id, … … 175 184 args[4] = bw_req->bandwidth_max_down; 176 185 args[5] = bw_req->bandwidth_max_up; 177 args[6] = (char *) 0; 186 args[6] = iface->dev_internal; 187 args[7] = iface->dev_ifb; 188 args[8] = (char *) 0; 178 189 179 190 return bandwidth_exec(vs, args); … … 182 193 int bandwidth_del(struct vserver *vs, struct bandwidth_req *bw_req) 183 194 { 184 char *args[4]; 195 char *args[6]; 196 struct interfaces *iface = vs->vserver_config->iface; 185 197 186 198 DP("Bandwidth: request %s", bw_req->slot_id); … … 189 201 args[1] = "del"; 190 202 args[2] = bw_req->slot_id; 191 args[3] = (char *) 0; 203 args[3] = iface->dev_internal; 204 args[4] = iface->dev_ifb; 205 args[5] = (char *) 0; 192 206 193 207 return bandwidth_exec(vs, args); … … 197 211 static int startservice (void) 198 212 { 199 return bandwidth_start();213 /* Do nothing */ 200 214 } 201 215 … … 203 217 static int stopservice (void) 204 218 { 205 return bandwidth_stop();219 /* Do nothing */ 206 220 } 207 221 … … 209 223 static void init (struct vserver *vs) 210 224 { 211 /* Do nothing */ 225 struct interfaces *iface = NULL; 226 if (!vs) 227 return; 228 229 if (vs->vserver_config->init_flag == VS_RELOAD) 230 return; 231 232 interfaces_list = append_interface (interfaces_list, 233 vs->vserver_config->dev_internal); 234 vs->vserver_config->iface = get_interface (interfaces_list, 235 vs->vserver_config->dev_internal); 236 iface = vs->vserver_config->iface; 237 if (!iface->init) 238 if (bandwidth_start(vs) >= 0) 239 iface->init = 1; 212 240 } 213 241 … … 215 243 static int cleanup (struct vserver *vs) 216 244 { 217 /* Do nothing */ 245 struct interfaces *iface = NULL; 246 if (!vs) 247 return; 248 249 if (vs->vserver_config->init_flag == VS_RELOAD) 250 return; 251 252 iface = vs->vserver_config->iface; 253 DP ("Bandwidth Cleanup: init=%d, hit=%d", iface->init, iface->hit); 254 if (iface->init && iface->hit <= 1) 255 if (bandwidth_stop(vs) >= 0) 256 iface->init = 0; 257 258 interfaces_list = remove_interface (interfaces_list, 259 vs->vserver_config->dev_internal); 218 260 } 219 261
