Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'dissect-ptp-l2-packet-header'

Eran Ben Elisha says:

====================
Dissect PTP L2 packet header

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.
====================

Link: https://lore.kernel.org/r/1610478433-7606-1-git-send-email-eranbe@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+25
+9
net/8021q/vlan_dev.c
··· 510 510 netdev_for_each_tx_queue(dev, vlan_dev_set_lockdep_one, NULL); 511 511 } 512 512 513 + static __be16 vlan_parse_protocol(const struct sk_buff *skb) 514 + { 515 + struct vlan_ethhdr *veth = (struct vlan_ethhdr *)(skb->data); 516 + 517 + return __vlan_get_protocol(skb, veth->h_vlan_proto, NULL); 518 + } 519 + 513 520 static const struct header_ops vlan_header_ops = { 514 521 .create = vlan_dev_hard_header, 515 522 .parse = eth_header_parse, 523 + .parse_protocol = vlan_parse_protocol, 516 524 }; 517 525 518 526 static int vlan_passthru_hard_header(struct sk_buff *skb, struct net_device *dev, ··· 540 532 static const struct header_ops vlan_passthru_header_ops = { 541 533 .create = vlan_passthru_hard_header, 542 534 .parse = eth_header_parse, 535 + .parse_protocol = vlan_parse_protocol, 543 536 }; 544 537 545 538 static struct device_type vlan_type = {
+16
net/core/flow_dissector.c
··· 23 23 #include <linux/if_ether.h> 24 24 #include <linux/mpls.h> 25 25 #include <linux/tcp.h> 26 + #include <linux/ptp_classify.h> 26 27 #include <net/flow_dissector.h> 27 28 #include <scsi/fc/fc_fcoe.h> 28 29 #include <uapi/linux/batadv_packet.h> ··· 1251 1250 fdret = __skb_flow_dissect_batadv(skb, key_control, data, 1252 1251 &proto, &nhoff, hlen, flags); 1253 1252 break; 1253 + 1254 + case htons(ETH_P_1588): { 1255 + struct ptp_header *hdr, _hdr; 1256 + 1257 + hdr = __skb_header_pointer(skb, nhoff, sizeof(_hdr), data, 1258 + hlen, &_hdr); 1259 + if (!hdr) { 1260 + fdret = FLOW_DISSECT_RET_OUT_BAD; 1261 + break; 1262 + } 1263 + 1264 + nhoff += ntohs(hdr->message_length); 1265 + fdret = FLOW_DISSECT_RET_OUT_GOOD; 1266 + break; 1267 + } 1254 1268 1255 1269 default: 1256 1270 fdret = FLOW_DISSECT_RET_OUT_BAD;