diff options
author | Daniel Borkmann <dborkman@redhat.com> | 2014-03-28 13:58:22 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-03-31 00:45:09 -0400 |
commit | 164d8c6665213c931645578310256da7b1259331 (patch) | |
tree | 336d19cb5fd510a3aaf6b1eb908f256c0cb9ee09 /include/linux/ptp_classify.h | |
parent | e62d2df084e2849edffb206559725fa81bb569a8 (diff) |
net: ptp: do not reimplement PTP/BPF classifier
There are currently pch_gbe, cpts, and ixp4xx_eth drivers that open-code
and reimplement a BPF classifier for the PTP protocol. Since all of them
effectively do the very same thing and load the very same PTP/BPF filter,
we can just consolidate that code by introducing ptp_classify_raw() in
the time-stamping core framework which can be used in drivers.
As drivers get initialized after bootstrapping the core networking
subsystem, they can make use of ptp_insns wrapped through
ptp_classify_raw(), which allows to simplify and remove PTP classifier
setup code in drivers.
Joint work with Alexei Starovoitov.
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Signed-off-by: Alexei Starovoitov <ast@plumgrid.com>
Cc: Richard Cochran <richard.cochran@omicron.at>
Cc: Jiri Benc <jbenc@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux/ptp_classify.h')
-rw-r--r-- | include/linux/ptp_classify.h | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/include/linux/ptp_classify.h b/include/linux/ptp_classify.h index 3decfa4d3732..6d3b0a2ef9ce 100644 --- a/include/linux/ptp_classify.h +++ b/include/linux/ptp_classify.h | |||
@@ -80,14 +80,6 @@ | |||
80 | #define OP_RETA (BPF_RET | BPF_A) | 80 | #define OP_RETA (BPF_RET | BPF_A) |
81 | #define OP_RETK (BPF_RET | BPF_K) | 81 | #define OP_RETK (BPF_RET | BPF_K) |
82 | 82 | ||
83 | static inline int ptp_filter_init(struct sock_filter *f, int len) | ||
84 | { | ||
85 | if (OP_LDH == f[0].code) | ||
86 | return sk_chk_filter(f, len); | ||
87 | else | ||
88 | return 0; | ||
89 | } | ||
90 | |||
91 | #define PTP_FILTER \ | 83 | #define PTP_FILTER \ |
92 | {OP_LDH, 0, 0, OFF_ETYPE }, /* */ \ | 84 | {OP_LDH, 0, 0, OFF_ETYPE }, /* */ \ |
93 | {OP_JEQ, 0, 12, ETH_P_IP }, /* f goto L20 */ \ | 85 | {OP_JEQ, 0, 12, ETH_P_IP }, /* f goto L20 */ \ |
@@ -133,4 +125,6 @@ static inline int ptp_filter_init(struct sock_filter *f, int len) | |||
133 | {OP_RETA, 0, 0, 0 }, /* */ \ | 125 | {OP_RETA, 0, 0, 0 }, /* */ \ |
134 | /*L6x*/ {OP_RETK, 0, 0, PTP_CLASS_NONE }, | 126 | /*L6x*/ {OP_RETK, 0, 0, PTP_CLASS_NONE }, |
135 | 127 | ||
128 | unsigned int ptp_classify_raw(const struct sk_buff *skb); | ||
129 | |||
136 | #endif | 130 | #endif |