Show
Ignore:
Timestamp:
06/08/09 18:29:43 (3 years ago)
Author:
Neutron Soutmun <neo.neutron@…>
Children:
5987af1b79b0c1fbd4aa9d30a53ec6879853ece3
Parents:
03dc5e370ef4fbf66e34cbe5bc5b878ed764149c
git-committer:
Neutron Soutmun <neo.neutron@…> (06/08/09 18:29:43)
Message:

Implement IFB to replace the IMQ

  • IFB (Intermediate Functional Block) is more clearly work in the SMP.
  • Implement IFB on config, bandwidth task and support scripts.
  • IMQ is now deprecated. (not support).
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • src/rh-task-bandwidth.c

    rebf1b31 r2f0141c  
    1818#include "rh-task-memset.h" 
    1919#include "rh-utils.h" 
    20  
    21  
    2220 
    2321#define BANDWIDTH_WRAPPER "/etc/rahunas/bandwidth.sh" 
     
    136134} 
    137135 
    138 int bandwidth_start(void) 
    139 { 
    140   char *args[3]; 
     136int bandwidth_start(struct vserver *vs) 
     137{ 
     138  char *args[5]; 
     139  struct interfaces *iface = vs->vserver_config->iface; 
     140  int  ret; 
    141141 
    142142  DP("Bandwidth: start"); 
     
    144144  args[0] = BANDWIDTH_WRAPPER; 
    145145  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 
     154int bandwidth_stop(struct vserver *vs) 
     155{ 
     156  char *args[5]; 
     157  struct interfaces *iface = vs->vserver_config->iface; 
     158  int  ret; 
    154159 
    155160  DP("Bandwidth: stop"); 
     
    157162  args[0] = BANDWIDTH_WRAPPER; 
    158163  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;  
    162170} 
    163171 
    164172int bandwidth_add(struct vserver *vs, struct bandwidth_req *bw_req) 
    165173{ 
    166   char *args[7]; 
     174  char *args[9]; 
     175  struct interfaces *iface = vs->vserver_config->iface; 
    167176 
    168177  DP("Bandwidth: request %s %s %s %s", bw_req->slot_id,  
     
    175184  args[4] = bw_req->bandwidth_max_down; 
    176185  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; 
    178189 
    179190  return bandwidth_exec(vs, args); 
     
    182193int bandwidth_del(struct vserver *vs, struct bandwidth_req *bw_req) 
    183194{ 
    184   char *args[4]; 
     195  char *args[6]; 
     196  struct interfaces *iface = vs->vserver_config->iface; 
    185197 
    186198  DP("Bandwidth: request %s", bw_req->slot_id); 
     
    189201  args[1] = "del"; 
    190202  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; 
    192206 
    193207  return bandwidth_exec(vs, args); 
     
    197211static int startservice (void) 
    198212{ 
    199   return bandwidth_start(); 
     213  /* Do nothing */ 
    200214} 
    201215 
     
    203217static int stopservice (void) 
    204218{ 
    205   return bandwidth_stop(); 
     219  /* Do nothing */ 
    206220} 
    207221 
     
    209223static void init (struct vserver *vs) 
    210224{ 
    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; 
    212240} 
    213241 
     
    215243static int cleanup (struct vserver *vs) 
    216244{ 
    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); 
    218260} 
    219261