Message ID | 1610389068-2133-3-git-send-email-eranbe@nvidia.com (mailing list archive) |
---|---|
State | Superseded |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | Dissect PTP L2 packet header | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Link |
netdev/fixes_present | success | Link |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Clearly marked for net-next |
netdev/subject_prefix | success | Link |
netdev/cc_maintainers | warning | 3 maintainers not CCed: ast@kernel.org andriin@fb.com lariel@mellanox.com |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 2 this patch: 2 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | success | total: 0 errors, 0 warnings, 0 checks, 28 lines checked |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 2 this patch: 2 |
netdev/header_inline | success | Link |
netdev/stable | success | Stable not CCed |
On Mon, Jan 11, 2021 at 08:17:48PM +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> > --- > net/core/flow_dissector.c | 16 ++++++++++++++++ > 1 file changed, 16 insertions(+) > > diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c > index 6f1adba6695f..fcaa223c7cdc 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 || (hlen - nhoff) < sizeof(_hdr)) { I'm not really familiar with the flow dissector, but why check (hlen - nhoff) here? None of the other cases do that. Doesn't skb_copy_bits() in __skb_header_pointer() already handle that? Thanks, Richard > + 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; > -- > 2.17.1 >
On 1/12/2021 3:49 PM, Richard Cochran wrote: > On Mon, Jan 11, 2021 at 08:17:48PM +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> >> --- >> net/core/flow_dissector.c | 16 ++++++++++++++++ >> 1 file changed, 16 insertions(+) >> >> diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c >> index 6f1adba6695f..fcaa223c7cdc 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 || (hlen - nhoff) < sizeof(_hdr)) { > > I'm not really familiar with the flow dissector, but why check (hlen - nhoff) here? > None of the other cases do that. Doesn't skb_copy_bits() in > __skb_header_pointer() already handle that? You are right. I saw similar len validation at ETH_P_FCOE case. But now I see it does not go through __skb_header_pointer() flow. Thanks. > > Thanks, > Richard > > >> + 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; >> -- >> 2.17.1 >>
diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c index 6f1adba6695f..fcaa223c7cdc 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 || (hlen - nhoff) < sizeof(_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;