Dissect PTP L2 packet header
Subsystems (2)
v4 cover Dissect PTP L2 packet header
Hi Jakub, Dave,
This series adds support for dissecting PTP L2 packet header (EtherType 0x88F7).
For packet header dissecting, skb->protocol is needed. Add protocol parsing operation to vlan ops, to guarantee skb->protocol is set, as EtherType 0x88F7 occasionally follows a vlan header.
Changelog:
v4:
- Drop a redundant length check when fetching ptp header from skb. v2, v3:
- Add more people to the CC list.
Eran Ben Elisha (2):
net: vlan: Add parse protocol header ops
net: flow_dissector: Parse PTP L2 packet header
net/8021q/vlan_dev.c | 9 +++++++++ net/core/flow_dissector.c | 16 ++++++++++++++++ 2 files changed, 25 insertions(+)
Signature · 1 line
2.17.1
PATCH v4 1/2 net: vlan: Add parse protocol header ops
Add parse protocol header ops for vlan device. Before this patch, vlan tagged packet transmitted by af_packet had skb->protocol unset. Some kernel methods (like __skb_flow_dissect()) rely on this missing information for its packet processing.
--- net/8021q/vlan_dev.c | 9 +++++++++ 1 file changed, 9 insertions(+)
net/8021q/vlan_dev.c +9 -0
@@ -510,9 +510,17 @@ static void vlan_dev_set_lockdep_class(struct net_device *dev)netdev_for_each_tx_queue (dev, vlan_dev_set_lockdep_one,NULL ); } +static __be16 vlan_parse_protocol (const struct sk_buff *skb) +{ +struct vlan_ethhdr *veth = (struct vlan_ethhdr *)(skb->data); + +return __vlan_get_protocol (skb, veth->h_vlan_proto,NULL ); +} +static const struct header_ops vlan_header_ops = { .create = vlan_dev_hard_header, .parse = eth_header_parse, + .parse_protocol = vlan_parse_protocol, }; static int vlan_passthru_hard_header(struct sk_buff *skb, struct net_device *dev,
@@ -532,6 +540,7 @@ static int vlan_passthru_hard_header(struct sk_buff *skb, struct net_device *devstatic const struct header_ops vlan_passthru_header_ops = { .create = vlan_passthru_hard_header, .parse = eth_header_parse, + .parse_protocol = vlan_parse_protocol, };static struct device_type vlan_type = {
Signature · 1 line
2.17.1
PATCH v4 2/2 net: flow_dissector: Parse PTP L2 packet header
In reply to Eran Ben ElishaAdd 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.
--- net/core/flow_dissector.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+)
net/core/flow_dissector.c +16 -0
@@ -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 ;
Signature · 1 line
2.17.1
Re: [PATCH net-next v4 2/2] net: flow_dissector: Parse PTP L2 packet header
Quoted 6 lines · Eran Ben Elisha
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 <[email protected]>Reviewed-by Tariq Toukan <[email protected]>
This series was applied to netdev/net-next.git (refs/heads/master):
Hello:
This series was applied to netdev/net-next.git (refs/heads/master):
Quoted 10 lines · On Tue, 12 Jan 2021 21:07:11 +0200 you wrote:
Hi Jakub, Dave,
This series adds support for dissecting PTP L2 packet header (EtherType
0x88F7).For packet header dissecting,
skb->protocolis needed. Add protocol parsing operation to vlan ops, to guaranteeskb->protocolis set, as EtherType0x88F7occasionally follows a vlan header.[...]
Here is the summary with links:
- [net-next,v4,1/2] net: vlan: Add parse protocol header ops
https://git.kernel.org/netdev/net-next/c/71854255820d - [net-next,v4,2/2] net: flow_dissector: Parse PTP L2 packet header https://git.kernel.org/netdev/net-next/c/4f1cc51f3488
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html