From: Ben Greear <greearb@candelatech.com>
To: Eric Dumazet <eric.dumazet@gmail.com>
Cc: netdev@vger.kernel.org
Subject: Re: [RFC 4/5] net: Support sending frame with specified FCS.
Date: Sat, 18 Jun 2011 07:29:19 -0700 [thread overview]
Message-ID: <4DFCB63F.7030301@candelatech.com> (raw)
In-Reply-To: <1308376473.3539.37.camel@edumazet-laptop>
On 06/17/2011 10:54 PM, Eric Dumazet wrote:
> Le vendredi 17 juin 2011 à 17:09 -0700, greearb@candelatech.com a
> écrit :
>> From: Ben Greear<greearb@candelatech.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@candelatech.com>
Candela Technologies Inc http://www.candelatech.com
next prev parent reply other threads:[~2011-06-18 14:29 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-18 0:09 [RFC 0/5] Ethernet low-level frame debugging support greearb
2011-06-18 0:09 ` [RFC 1/5] net: Support ethtool ops for rx of errored frames greearb
2011-06-18 0:09 ` [RFC 2/5] net: Add pkt-type PACKET_INVALID greearb
2011-06-18 0:09 ` [RFC 3/5] e100: Support receiving errored frames greearb
2011-06-18 0:09 ` [RFC 4/5] net: Support sending frame with specified FCS greearb
2011-06-18 5:54 ` Eric Dumazet
2011-06-18 14:29 ` Ben Greear [this message]
2011-06-18 14:44 ` Eric Dumazet
2011-06-18 0:09 ` [RFC 5/5] e1000e: Support sending frame with custom FCS greearb
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4DFCB63F.7030301@candelatech.com \
--to=greearb@candelatech.com \
--cc=eric.dumazet@gmail.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.