]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
net: flow_dissector: Parse PTP L2 packet header
authorEran Ben Elisha <eranbe@nvidia.com>
Tue, 12 Jan 2021 19:07:13 +0000 (21:07 +0200)
committerJakub Kicinski <kuba@kernel.org>
Fri, 15 Jan 2021 02:24:54 +0000 (18:24 -0800)
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>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/core/flow_dissector.c

index 6f1adba6695fc8f1fd6bba0a5c858054aa87d901..2d70ded389aeb571240de6d9bf4bf6343a527513 100644 (file)
@@ -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 @@ proto_again:
                                                  &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;