Skip to content

Commit d9d6f07

Browse files
rary21kartben
authored andcommitted
net: gptp: Add TLV type, OUI check for signaling messages
Add validation to ensure gPTP signaling messages contain the correct TLV type, IEEE 802.1 Committee OUI and sub-type before processing it as interval requests. signed-off-by: Yusuke Omae <[email protected]>
1 parent 39e6f01 commit d9d6f07

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

subsys/net/l2/ethernet/gptp/gptp_messages.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ static bool ts_cb_registered[CONFIG_NET_GPTP_NUM_PORTS];
2323

2424
static const struct net_eth_addr gptp_multicast_eth_addr = {
2525
{ 0x01, 0x80, 0xc2, 0x00, 0x00, 0x0e } };
26+
static uint8_t ieee8021_oui[3] = { OUI_IEEE_802_1_COMMITTEE };
2627

2728
#define NET_GPTP_INFO(msg, pkt) \
2829
if (CONFIG_NET_GPTP_LOG_LEVEL >= LOG_LEVEL_DBG) { \
@@ -791,6 +792,14 @@ void gptp_handle_signaling(int port, struct net_pkt *pkt)
791792
return;
792793
}
793794

795+
/* Check if this is interval request. */
796+
if (ntohs(sig->tlv.type) != GPTP_TLV_ORGANIZATION_EXT ||
797+
memcmp(sig->tlv.org_id, ieee8021_oui, sizeof(ieee8021_oui)) != 0 ||
798+
sig->tlv.org_sub_type[0] != 0 || sig->tlv.org_sub_type[1] != 0 ||
799+
sig->tlv.org_sub_type[2] != 2) {
800+
return;
801+
}
802+
794803
/* pDelay interval. */
795804
gptp_update_pdelay_req_interval(port, sig->tlv.link_delay_itv);
796805

subsys/net/l2/ethernet/gptp/gptp_messages.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ extern "C" {
115115
#define GPTP_FUP_TLV_ORG_ID_BYTE_2 0xC2
116116
#define GPTP_FUP_TLV_ORG_SUB_TYPE 0x01
117117

118+
/* Organizationally Unique Identifiers */
119+
#define OUI_IEEE_802_1_COMMITTEE 0x00, 0x80, 0xC2
120+
118121
/**
119122
* @brief gPTP Clock Quality
120123
*

0 commit comments

Comments
 (0)