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: <4DFCB63F.7030301@candelatech.com>
Date:	Sat, 18 Jun 2011 07:29:19 -0700
From:	Ben Greear <greearb@...delatech.com>
To:	Eric Dumazet <eric.dumazet@...il.com>
CC:	netdev@...r.kernel.org
Subject: Re: [RFC 4/5] net:  Support sending frame with specified FCS.

On 06/17/2011 10:54 PM, Eric Dumazet wrote:
> Le vendredi 17 juin 2011 à 17:09 -0700, greearb@...delatech.com a
> écrit :
>> From: Ben Greear<greearb@...delatech.com>
>>
>> This allows user-space to send a packet with the
>> ethernet FCS appended to the end.  Supporting NICs
>> will know to disable their own FCS calculations and
>> send frame as is.
>>
>> This is useful for injecting bad frames on a network
>> for testing.

>> diff --git a/include/asm-generic/socket.h b/include/asm-generic/socket.h
>> index 9a6115e..22193a2 100644
>> --- a/include/asm-generic/socket.h
>> +++ b/include/asm-generic/socket.h
>> @@ -64,4 +64,11 @@
>>   #define SO_DOMAIN		39
>>
>>   #define SO_RXQ_OVFL             40
>> +
>> +/* Instruct lower device to not calculate the frame
>> + * checksum.  Useful for generating Ethernet frames
>> + * with custom checksums.
>> + */
>> +#define SO_NOFCS		41
>> +
>
> Please take a look at :
>
> arch/*/include/asm/socket.h for many arches.

Do I need to update each file, or just make sure the value in
asm-generic/socket.h is unique for all of them?

>> +	if (unlikely(sk->sk_flags&  SOCK_DONT_DO_LL_FCS))
>> +		skb->use_specified_ether_crc = 1;
>> +	else
>> +		skb->use_specified_ether_crc = 0;
>> +
>
> Manipulating a bit field is very expensive, and having an else branch is
> expensive as well, so please avoid setting crc to zero if its already
> guaranteed to be so.

Ok, I'll double-check that it is zero by default. and fix that.

> Also I cant see where you actually _set_ the fcs value : that might
> trigger a kmemcheck warning later when we read it.

It is the last 4 bytes of the payload passed in from user-space.

>>   	dev_queue_xmit(skb);
>>   	rcu_read_unlock();
>>   	return len;
>> @@ -1134,6 +1143,10 @@ static int packet_snd(struct socket *sock,
>>   	int vnet_hdr_len;
>>   	struct packet_sock *po = pkt_sk(sk);
>>   	unsigned short gso_type = 0;
>> +	int kludge = 0;
>> +
>> +	if (unlikely(sk->sk_flags&  SOCK_DONT_DO_LL_FCS))
>> +		kludge = 4; /* We're doing our own Ethernet FCS */
>
> kludge ? You mean fcs_len or something ? ;)

Err, yeah :)

Thanks,
Ben

-- 
Ben Greear <greearb@...delatech.com>
Candela Technologies Inc  http://www.candelatech.com
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ