[dpdk-dev] [PATCH 3/3] examples/l3fwd: Handle SIGINT and SIGTERM in l3fwd

Wang, Zhihong zhihong.wang at intel.com
Fri Dec 25 10:17:06 CET 2015


> > +/* When we receive a INT signal, close all ports */ static void
> > +sigint_handler(__rte_unused int signum) {
> > +	unsigned portid, nb_ports;
> > +
> > +	printf("Preparing to exit...\n");
> > +	nb_ports = rte_eth_dev_count();
> > +	for (portid = 0; portid < nb_ports; portid++) {
> > +		if ((enabled_port_mask & (1 << portid)) == 0) {
> > +			continue;
> > +		}
> > +		printf("Stopping port %d...", portid);
> > +		rte_eth_dev_stop(portid);
> > +		rte_eth_dev_close(portid);
> 
> Hmm, so your interrupt thread invokes dev_stop, while IO lcores keep calling
> rx_burst/tx_burst?
> For graceful shutdown on SIGINT, I suppose you first have to stop your IO lcores
> first.
> Let say have a global var: 'stop' that every lcore has to check from time to time (or
> something similar).

Thanks for the advice! This works once the program enters the forwarding phase.
Have to go the other way if it's still in initialization phase which can take quite some time.

/Zhihong

> Konstantin
> 
> > +		printf(" Done\n");
> > +	}
> > +	printf("Bye...\n");
> > +	exit(0);
> > +}
> > +
> >  int
> >  main(int argc, char **argv)
> >  {
> > @@ -2572,6 +2594,9 @@ main(int argc, char **argv)
> >  	uint32_t n_tx_queue, nb_lcores;
> >  	uint8_t portid, nb_rx_queue, queue, socketid;
> >
> > +	signal(SIGINT, sigint_handler);
> > +	signal(SIGTERM, sigint_handler);
> > +
> >  	/* init EAL */
> >  	ret = rte_eal_init(argc, argv);
> >  	if (ret < 0)
> > --
> > 2.5.0



More information about the dev mailing list