netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Richard Cochran <richardcochran@gmail.com>
To: "Stefan Sørensen" <stefan.sorensen@spectralink.com>
Cc: davem@davemloft.net, netdev@vger.kernel.org
Subject: Re: [PATCH net-next 1/5] dp83640: Include hash in timestamp/packet matching
Date: Fri, 30 Oct 2015 21:32:01 +0100	[thread overview]
Message-ID: <20151030203201.GB27879@netboy> (raw)
In-Reply-To: <1446207244-2206-2-git-send-email-stefan.sorensen@spectralink.com>

On Fri, Oct 30, 2015 at 01:14:00PM +0100, Stefan Sørensen wrote:
> Only using the message type and sequence id for matching timestamps with
> packets is error prone, particularly if packets can be reordered. Fix by
> extending the check to include the hash of bytes 20-29 (source id in PTPv2)
> that is provided with the timestamps.

The example of reordered packets is bogus, since the sequence numbers
are not affected.  The one case that benefits from the hash check is
when the port is in the master role and multiple clients send
Delay_Req messages all with the same sequence number by chance.
 
> @@ -819,11 +820,18 @@ static int match(struct sk_buff *skb, unsigned int type, struct rxts *rxts)
>  		msgtype = data + offset + OFF_PTP_CONTROL;
>  	else
>  		msgtype = data + offset;
> +	if (rxts->msgtype != (*msgtype & 0xf))
> +		return 0;
>  
>  	seqid = (u16 *)(data + offset + OFF_PTP_SEQUENCE_ID);
> +	if (rxts->seqid != ntohs(*seqid))
> +		return 0;
> +
> +	hash = ether_crc(10, data + offset + 20) >> 20;

This could use a macro instead of magic 20.

Thanks,
Richard

> +	if (rxts->hash != hash)
> +		return 0;
>  
> -	return rxts->msgtype == (*msgtype & 0xf) &&
> -		rxts->seqid   == ntohs(*seqid);
> +	return 1;
>  }
>  
>  static void decode_rxts(struct dp83640_private *dp83640,
> -- 
> 2.5.0
> 

  reply	other threads:[~2015-10-30 20:32 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-30 12:13 [PATCH net-next 0/5] dp83640 driver fixes Stefan Sørensen
2015-10-30 12:14 ` [PATCH net-next 1/5] dp83640: Include hash in timestamp/packet matching Stefan Sørensen
2015-10-30 20:32   ` Richard Cochran [this message]
2015-10-30 12:14 ` [PATCH net-next 2/5] dp83640: Delay scheduled work Stefan Sørensen
2015-10-30 20:37   ` Richard Cochran
2015-11-02  7:23     ` Sørensen, Stefan
2015-11-02  9:59       ` Richard Cochran
2015-10-30 12:14 ` [PATCH net-next 3/5] dp83640: Prune rx timestamp list before reading from it Stefan Sørensen
2015-10-30 20:38   ` Richard Cochran
2015-10-30 12:14 ` [PATCH net-next 4/5] ptp: Change ptp_class to a proper bitmask Stefan Sørensen
2015-10-30 20:39   ` Richard Cochran
2015-10-30 12:14 ` [PATCH net-next 5/5] dp83640: Only wait for timestamps for packets with timestamping enabled Stefan Sørensen
2015-10-30 20:40   ` Richard Cochran
2015-11-02 20:13 ` [PATCH net-next 0/5] dp83640 driver fixes David Miller
2015-11-03  8:42   ` Richard Cochran

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=20151030203201.GB27879@netboy \
    --to=richardcochran@gmail.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    --cc=stefan.sorensen@spectralink.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).