diff mbox series

[net-next,v4,2/2] net: flow_dissector: Parse PTP L2 packet header

Message ID 1610478433-7606-3-git-send-email-eranbe@nvidia.com
State New
Headers show
Series Dissect PTP L2 packet header | expand

Commit Message

Eran Ben Elisha Jan. 12, 2021, 7:07 p.m. UTC
Add support for parsing PTP L2 packet header. Such packet consists
of an L2 header (with ethertype of ETH_P_1588), PTP header, body
and an optional suffix.

Signed-off-by: Eran Ben Elisha <eranbe@nvidia.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
---
 net/core/flow_dissector.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Comments

Richard Cochran Jan. 15, 2021, 5:19 p.m. UTC | #1
On Tue, Jan 12, 2021 at 09:07:13PM +0200, Eran Ben Elisha wrote:
> Add support for parsing PTP L2 packet header. Such packet consists

> of an L2 header (with ethertype of ETH_P_1588), PTP header, body

> and an optional suffix.

> 

> Signed-off-by: Eran Ben Elisha <eranbe@nvidia.com>

> Reviewed-by: Tariq Toukan <tariqt@nvidia.com>


Acked-by: Richard Cochran <richardcochran@gmail.com>
diff mbox series

Patch

diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c
index 6f1adba6695f..2d70ded389ae 100644
--- a/net/core/flow_dissector.c
+++ b/net/core/flow_dissector.c
@@ -23,6 +23,7 @@ 
 #include <linux/if_ether.h>
 #include <linux/mpls.h>
 #include <linux/tcp.h>
+#include <linux/ptp_classify.h>
 #include <net/flow_dissector.h>
 #include <scsi/fc/fc_fcoe.h>
 #include <uapi/linux/batadv_packet.h>
@@ -1251,6 +1252,21 @@  bool __skb_flow_dissect(const struct net *net,
 						  &proto, &nhoff, hlen, flags);
 		break;
 
+	case htons(ETH_P_1588): {
+		struct ptp_header *hdr, _hdr;
+
+		hdr = __skb_header_pointer(skb, nhoff, sizeof(_hdr), data,
+					   hlen, &_hdr);
+		if (!hdr) {
+			fdret = FLOW_DISSECT_RET_OUT_BAD;
+			break;
+		}
+
+		nhoff += ntohs(hdr->message_length);
+		fdret = FLOW_DISSECT_RET_OUT_GOOD;
+		break;
+	}
+
 	default:
 		fdret = FLOW_DISSECT_RET_OUT_BAD;
 		break;