lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6c660465-2a32-c490-45e1-15e4513ce92a@mellanox.com>
Date:   Wed, 3 Jan 2018 10:44:44 +0800
From:   Chris Mi <chrism@...lanox.com>
To:     Marcelo Ricardo Leitner <marcelo.leitner@...il.com>
Cc:     netdev@...r.kernel.org, gerlitz.or@...il.com,
        stephen@...workplumber.org, dsahern@...il.com
Subject: Re: [patch iproute2 v4 2/3] tc: Add -bs option to batch mode


> On Tue, Jan 02, 2018 at 11:28:03PM +0900, Chris Mi wrote:
>> @@ -240,23 +244,49 @@ static int batch(const char *name)
>>   	}
>>   
>>   	cmdlineno = 0;
>> -	while (getcmdline(&line, &len, stdin) != -1) {
>> +	if (getcmdline(&line, &len, stdin) == -1)
>> +		goto Exit;
>> +	do {
>>   		char *largv[100];
>>   		int largc;
>>   
>> +		if (getcmdline(&line2, &len, stdin) == -1)
>> +			lastline = true;
>> +
>>   		largc = makeargs(line, largv, 100);
>>   		if (largc == 0)
>>   			continue;	/* blank line */
> If it reads a new line, it won't process anything else after it
> because line won't get updated.
Indeed. Thanks for catching it. After fixing it, I find that it only 
works if the blank line is
in the beginning or middle. If the blank line is in the end, we may lose 
at most batchsize - 1 rules.
It is not easy to fix it. I think this issue is trivial. It is not worth 
to make the code complex to fix it.
So I describe this limitation in the man page.

-Chris
>
>    Marcelo
>
>>   
>> -		if (do_cmd(largc, largv)) {
>> -			fprintf(stderr, "Command failed %s:%d\n", name, cmdlineno);
>> +		line = line2;
>> +		line2 = NULL;
>> +		len = 0;
>> +
>> +		/*
>> +		 * In batch mode, if we haven't accumulated enough commands
>> +		 * and this is not the last command, don't send the message
>> +		 * immediately.
>> +		 */
>> +		if (batch_size > 1 && msg_iov_index + 1 != batch_size
>> +		    && !lastline)
>> +			send = false;
>> +		else
>> +			send = true;
>> +
>> +		ret = do_cmd(largc, largv, batch_size, msg_iov_index++, send);
>> +		if (ret < 0) {
>> +			fprintf(stderr, "Command failed %s:%d\n", name,
>> +				cmdlineno);
>>   			ret = 1;
>>   			if (!force)
>>   				break;
>>   		}
>> -	}
>> -	if (line)
>> -		free(line);
>> +		msg_iov_index %= batch_size;
>> +	} while (!lastline);
>> +
>> +	free_filter_reqs();
>> +	free_action_reqs();
>> +Exit:
>> +	free(line);
>>   
>>   	rtnl_close(&rth);
>>   	return ret;

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ