summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2022-03-07 11:31:34 +0000
committerDavid S. Miller <davem@davemloft.net>2022-03-07 11:31:34 +0000
commitcd0b6277c3aafdf855a7cded10defd7705e6580e (patch)
tree78c6c8f0eee3afb62c390ac91c80267e80b2fb41 /net
parent669b258a793db9f1c3bff29ce2bbd61b810503ad (diff)
parent3914a9c07e8c3a30f178f1c92e2354b9cffdecb5 (diff)
downloadlinux-cd0b6277c3aafdf855a7cded10defd7705e6580e.tar.gz
linux-cd0b6277c3aafdf855a7cded10defd7705e6580e.tar.bz2
linux-cd0b6277c3aafdf855a7cded10defd7705e6580e.zip
Merge branch 'ptp-is_sync'
Kurt Kanzenbach says: ==================== ptp: Add generic is_sync() function as multiple PHY drivers such as micrel or TI dp83640 need to inspect whether a given skb represents a PTP Sync message, provide a generic function for it. This avoids code duplication and can be reused by future PHY IEEE 1588 implementations. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net')
-rw-r--r--net/core/ptp_classifier.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/net/core/ptp_classifier.c b/net/core/ptp_classifier.c
index dd4cf01d1e0a..598041b0499e 100644
--- a/net/core/ptp_classifier.c
+++ b/net/core/ptp_classifier.c
@@ -137,6 +137,18 @@ struct ptp_header *ptp_parse_header(struct sk_buff *skb, unsigned int type)
}
EXPORT_SYMBOL_GPL(ptp_parse_header);
+bool ptp_msg_is_sync(struct sk_buff *skb, unsigned int type)
+{
+ struct ptp_header *hdr;
+
+ hdr = ptp_parse_header(skb, type);
+ if (!hdr)
+ return false;
+
+ return ptp_get_msgtype(hdr, type) == PTP_MSGTYPE_SYNC;
+}
+EXPORT_SYMBOL_GPL(ptp_msg_is_sync);
+
void __init ptp_classifier_init(void)
{
static struct sock_filter ptp_filter[] __initdata = {