Re: add patch to remove secondary ip addresses when curl-loader exit
Status: Alpha
Brought to you by:
coroberti
From: Robert I. <cor...@gm...> - 2013-04-03 20:31:19
|
thanks, Vincent. On Wed, Apr 3, 2013 at 10:33 PM, Vincent Li <vin...@gm...> wrote: > Hi, > > I am using curl-loader to test web services, I like the feature that > curl-loader creating secondary ip addresses, is it possible to remove > these ip addresses after each curl-loader run automatically because it > may create ip conflict in my environment when I run curl-loader from > another box using same secondary ip addresses. > > I am still rough with C and I have an incomplete patch idea to remove > secondary ip addresses when SIGINT received from keyboard, the idea is > to add a bool parameter to create_ip_addrs and pass it on to > add_secondary_ip_addrs and add_secondary_ip_to_device, when the bool > parameter is 0 (false), then remove secondary ip addresses, but I am > not sure where to call create_ip_addrs properly with the bool > parameter false with the batch contexts info, etc. could anyone shed > on light on how to do this? > > here is my half baked patch against curl-loader-0.56: > > diff --git a/ip_secondary.c b/ip_secondary.c > index ffd1e2d..7def472 100644 > --- a/ip_secondary.c > +++ b/ip_secondary.c > @@ -147,7 +147,7 @@ typedef struct > ********************************************************************************/ > int add_secondary_ip_to_device(const char*const device, > const char*const ip_slash_mask, > - char* scope) > + char* scope, bool add) > { > request req; > > @@ -168,7 +168,7 @@ int add_secondary_ip_to_device(const char*const device, > > req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifaddrmsg)); > req.n.nlmsg_flags = NLM_F_REQUEST; > - req.n.nlmsg_type = RTM_NEWADDR; > + req.n.nlmsg_type = add ? RTM_NEWADDR : RTM_DELADDR; > req.ifa.ifa_family = AF_UNSPEC; > > get_prefix(&lcl, (char*)ip_slash_mask, req.ifa.ifa_family); > @@ -891,7 +891,7 @@ int add_secondary_ip_addrs (const char*const interface, > int addr_number, > const char**const addresses, > int netmask, > - char* addr_scope) > + char* addr_scope, bool add) > { > char ip_slash_mask_buffer[64]; > int j = 0, rval_set_ip = -1; > @@ -907,7 +907,7 @@ int add_secondary_ip_addrs (const char*const interface, > > rval_set_ip = add_secondary_ip_to_device (interface, > ip_slash_mask_buffer, > - addr_scope); > + addr_scope, add); > > switch (rval_set_ip) > { > diff --git a/loader.c b/loader.c > index eb852b7..cfbfc27 100644 > --- a/loader.c > +++ b/loader.c > @@ -69,7 +69,7 @@ static size_t do_nothing_write_func (void *ptr, > size_t nmemb, > void *stream); > > -static int create_ip_addrs (batch_context* bctx, int bctx_num); > +static int create_ip_addrs (batch_context* bctx, int bctx_num, bool add); > > static void* batch_function (void *batch_data); > static int initial_handles_init (struct client_context*const cdata); > @@ -179,7 +179,7 @@ main (int argc, char *argv []) > Add ip-addresses to the loading network interfaces > and keep them in batch-contexts. > */ > - if (create_ip_addrs (bc_arr, batches_num) == -1) > + if (create_ip_addrs (bc_arr, batches_num, 1) == -1) > { > fprintf (stderr, "%s - error: create_ip_addrs () failed. \n", __func__); > return -1; > @@ -1717,7 +1717,7 @@ static void free_url (url_context* url, int clients_max) > * bctx_num - number of batch contexts in <bctx_array> > * Return Code/Output - None > *******************************************************************************/ > -static int create_ip_addrs (batch_context* bctx_array, int bctx_num) > +static int create_ip_addrs (batch_context* bctx_array, int bctx_num, bool add) > { > int batch_index, client_index; /* Batch and client indexes */ > char*** ip_addresses =0; > @@ -1777,7 +1777,7 @@ static int create_ip_addrs (batch_context* > bctx_array, int bctx_num) > bctx->client_num_max, > (const char** const) > ip_addresses[batch_index], > bctx->cidr_netmask, > - bctx->scope) == -1) > + bctx->scope, add) == -1) > { > fprintf (stderr, > "%s - error: add_secondary_ip_addrs() - failed for > batch = %d\n", > diff --git a/loader.h b/loader.h > index 47c2130..eac70aa 100644 > --- a/loader.h > +++ b/loader.h > @@ -44,6 +44,7 @@ struct client_context; > struct batch_context; > struct stat_point; > struct timer_node; > +typedef _Bool bool; > > /*--------- Common loading functions ----------------*/ > > @@ -120,7 +121,7 @@ int response_logfiles_set (struct client_context* > cctx, struct url_context* url) > ********************************************************************************/ > int add_secondary_ip_to_device (const char*const device, > const char*const ip_slash_mask, > - char* scope); > + char* scope, bool add); > > /******************************************************************************* > * Function name - add_secondary_ip_addrs > @@ -138,7 +139,7 @@ int add_secondary_ip_addrs (const char*const interface, > int addr_number, > const char**const addresses, > int netmask, > - char* scope); > + char* scope, bool add); > > /******************************************************************************* > * Function name - parse_config_file > > > Thanks in advance! > > ------------------------------------------------------------------------------ > Minimize network downtime and maximize team effectiveness. > Reduce network management and security costs.Learn how to hire > the most talented Cisco Certified professionals. Visit the > Employer Resources Portal > http://www.cisco.com/web/learning/employer_resources/index.html > _______________________________________________ > curl-loader-devel mailing list > cur...@li... > https://lists.sourceforge.net/lists/listinfo/curl-loader-devel -- Regards, Robert Iakobashvili, Ph.D. Home: http://www.ghotit.com .............................................. Ghotit Dyslexia Das Ist Real Writer & Reader ............................................... |