Skip to content

Commit cca04b2

Browse files
richardcochrandavem330
authored andcommitted
net: ptp: fix time stamp matching logic for VLAN packets.
Commit ae5c6c6 "ptp: Classify ptp over ip over vlan packets" changed the code in two drivers that matches time stamps with PTP frames, with the goal of allowing VLAN tagged PTP packets to receive hardware time stamps. However, that commit failed to account for the VLAN header when parsing IPv4 packets. This patch fixes those two drivers to correctly match VLAN tagged IPv4/UDP PTP messages with their time stamps. This patch should also be applied to v3.17. Signed-off-by: Richard Cochran <richardcochran@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent ee7bc3c commit cca04b2

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

‎drivers/net/ethernet/ti/cpts.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ static int cpts_match(struct sk_buff *skb, unsigned int ptp_class,
264264

265265
switch (ptp_class & PTP_CLASS_PMASK) {
266266
case PTP_CLASS_IPV4:
267-
offset += ETH_HLEN + IPV4_HLEN(data) + UDP_HLEN;
267+
offset += ETH_HLEN + IPV4_HLEN(data + offset) + UDP_HLEN;
268268
break;
269269
case PTP_CLASS_IPV6:
270270
offset += ETH_HLEN + IP6_HLEN + UDP_HLEN;

‎drivers/net/phy/dp83640.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ static int match(struct sk_buff *skb, unsigned int type, struct rxts *rxts)
791791

792792
switch (type & PTP_CLASS_PMASK) {
793793
case PTP_CLASS_IPV4:
794-
offset += ETH_HLEN + IPV4_HLEN(data) + UDP_HLEN;
794+
offset += ETH_HLEN + IPV4_HLEN(data + offset) + UDP_HLEN;
795795
break;
796796
case PTP_CLASS_IPV6:
797797
offset += ETH_HLEN + IP6_HLEN + UDP_HLEN;
@@ -934,7 +934,7 @@ static int is_sync(struct sk_buff *skb, int type)
934934

935935
switch (type & PTP_CLASS_PMASK) {
936936
case PTP_CLASS_IPV4:
937-
offset += ETH_HLEN + IPV4_HLEN(data) + UDP_HLEN;
937+
offset += ETH_HLEN + IPV4_HLEN(data + offset) + UDP_HLEN;
938938
break;
939939
case PTP_CLASS_IPV6:
940940
offset += ETH_HLEN + IP6_HLEN + UDP_HLEN;

0 commit comments

Comments
 (0)