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]
Date:   Sun, 2 Aug 2020 15:54:15 -0700
From:   Richard Cochran <richardcochran@...il.com>
To:     Kurt Kanzenbach <kurt@...utronix.de>
Cc:     Andrew Lunn <andrew@...n.ch>,
        Vivien Didelot <vivien.didelot@...il.com>,
        Florian Fainelli <f.fainelli@...il.com>,
        "David S. Miller" <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>,
        Jiri Pirko <jiri@...lanox.com>,
        Ido Schimmel <idosch@...lanox.com>,
        Heiner Kallweit <hkallweit1@...il.com>,
        Russell King <linux@...linux.org.uk>,
        Grygorii Strashko <grygorii.strashko@...com>,
        Ivan Khoronzhuk <ivan.khoronzhuk@...aro.org>,
        Samuel Zou <zou_wei@...wei.com>, netdev@...r.kernel.org,
        Petr Machata <petrm@...lanox.com>
Subject: Re: [PATCH v3 7/9] net: phy: dp83640: Use generic helper function

On Thu, Jul 30, 2020 at 10:00:46AM +0200, Kurt Kanzenbach wrote:
> In order to reduce code duplication between ptp drivers, generic helper
> functions were introduced. Use them.
> 
> Signed-off-by: Kurt Kanzenbach <kurt@...utronix.de>
> ---
>  drivers/net/phy/dp83640.c | 69 +++++++++------------------------------
>  1 file changed, 16 insertions(+), 53 deletions(-)
> 
> diff --git a/drivers/net/phy/dp83640.c b/drivers/net/phy/dp83640.c
> index 50fb7d16b75a..1cd987e3d0f2 100644
> --- a/drivers/net/phy/dp83640.c
> +++ b/drivers/net/phy/dp83640.c
> @@ -803,46 +803,28 @@ static int decode_evnt(struct dp83640_private *dp83640,
>  
>  static int match(struct sk_buff *skb, unsigned int type, struct rxts *rxts)
>  {
> -	unsigned int offset = 0;
> -	u8 *msgtype, *data = skb_mac_header(skb);
> -	__be16 *seqid;
> +	struct ptp_header *hdr;
> +	u8 msgtype;
> +	u16 seqid;
>  	u16 hash;
>  
>  	/* check sequenceID, messageType, 12 bit hash of offset 20-29 */
>  
> -	if (type & PTP_CLASS_VLAN)
> -		offset += VLAN_HLEN;
> -
> -	switch (type & PTP_CLASS_PMASK) {
> -	case PTP_CLASS_IPV4:
> -		offset += ETH_HLEN + IPV4_HLEN(data + offset) + UDP_HLEN;
> -		break;
> -	case PTP_CLASS_IPV6:
> -		offset += ETH_HLEN + IP6_HLEN + UDP_HLEN;
> -		break;
> -	case PTP_CLASS_L2:
> -		offset += ETH_HLEN;
> -		break;
> -	default:
> +	hdr = ptp_parse_header(skb, type);
> +	if (!hdr)
>  		return 0;
> -	}
>  
> -	if (skb->len + ETH_HLEN < offset + OFF_PTP_SEQUENCE_ID + sizeof(*seqid))
> -		return 0;
> +	msgtype = ptp_get_msgtype(hdr, type);
>  
> -	if (unlikely(type & PTP_CLASS_V1))
> -		msgtype = data + offset + OFF_PTP_CONTROL;
> -	else
> -		msgtype = data + offset;
> -	if (rxts->msgtype != (*msgtype & 0xf))
> +	if (rxts->msgtype != (msgtype & 0xf))
>  		return 0;
>  
> -	seqid = (__be16 *)(data + offset + OFF_PTP_SEQUENCE_ID);
> -	if (rxts->seqid != ntohs(*seqid))
> +	seqid = be16_to_cpu(hdr->sequence_id);
> +	if (rxts->seqid != seqid)
>  		return 0;
>  
>  	hash = ether_crc(DP83640_PACKET_HASH_LEN,
> -			 data + offset + DP83640_PACKET_HASH_OFFSET) >> 20;
> +			 (unsigned char *)&hdr->source_port_identity) >> 20;

Looks like DP83640_PACKET_HASH_OFFSET can be removed now.

Tested-by: Richard Cochran <richardcochran@...il.com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ