@@ -97,6 +97,10 @@ typedef enum {
9797 AGENT_MSG_TYPE_ACK
9898} agent_udp_message_type_t ;
9999
100+ // Arbitrary 64 bit numbers
101+ #define MAGIC_ORIGINATOR 0x9a9e2fbce63a11e5
102+ #define MAGIC_TARGET 0x60735c68f368aace
103+
100104/*
101105 * Ping and ACK messages
102106 */
@@ -110,6 +114,11 @@ typedef struct {
110114 uint32_t src_ipv4_addr ;
111115 uint32_t src_udp_port ;
112116
117+ /* A magic number that helps determine that the sender was Open
118+ MPI */
119+ uint64_t magic_number ;
120+ uint32_t major_version , minor_version ;
121+
113122 /* If this is a PING, the message should be this size.
114123 If this is an ACK, we are ACKing a ping of this size. */
115124 uint32_t size ;
@@ -369,6 +378,21 @@ static void agent_thread_handle_ping(agent_udp_port_listener_t *listener,
369378 return ;
370379 }
371380
381+ if (msg -> magic_number != MAGIC_ORIGINATOR ) {
382+ opal_output_verbose (20 , USNIC_OUT ,
383+ "usNIC connectivity got bad ping (magic number: %" PRIu64 ", discarded)" ,
384+ msg -> magic_number );
385+ return ;
386+ }
387+ if (msg -> major_version != OPAL_MAJOR_VERSION ||
388+ msg -> minor_version != OPAL_MINOR_VERSION ) {
389+ opal_output_verbose (20 , USNIC_OUT ,
390+ "usNIC connectivity got bad ping (originator version: %d.%d, expected %d.%d, discarded)" ,
391+ msg -> major_version , msg -> minor_version ,
392+ OPAL_MAJOR_VERSION , OPAL_MINOR_VERSION );
393+ return ;
394+ }
395+
372396 /* Ok, this is a good ping. Send the ACK back. The PING sender
373397 will verify that the ACK came back from the IP address that it
374398 expected. */
@@ -383,6 +407,7 @@ static void agent_thread_handle_ping(agent_udp_port_listener_t *listener,
383407 in the msg (the sender will use the msg fields and the
384408 recvfrom() src_addr to check for a match). */
385409 msg -> message_type = AGENT_MSG_TYPE_ACK ;
410+ msg -> magic_number = MAGIC_TARGET ;
386411
387412 agent_sendto (listener -> fd , (char * ) listener -> buffer , sizeof (* msg ), from );
388413}
@@ -406,6 +431,12 @@ static void agent_thread_handle_ack(agent_udp_port_listener_t *listener,
406431 (int ) numbytes , str , (int ) sizeof (* msg ));
407432 return ;
408433 }
434+ if (msg -> magic_number != MAGIC_TARGET ) {
435+ opal_output_verbose (20 , USNIC_OUT ,
436+ "usNIC connectivity got bad ACK (magic number: %" PRIu64 ", discarded)" ,
437+ msg -> magic_number );
438+ return ;
439+ }
409440
410441 /* Find the pending ping request (on this interface) for this ACK.
411442 If we don't find a match, we'll drop it. */
@@ -866,6 +897,9 @@ static void agent_thread_cmd_ping(agent_ipc_listener_t *ipc_listener)
866897 msg -> message_type = AGENT_MSG_TYPE_PING ;
867898 msg -> src_ipv4_addr = ap -> src_ipv4_addr ;
868899 msg -> src_udp_port = ap -> src_udp_port ;
900+ msg -> magic_number = MAGIC_ORIGINATOR ;
901+ msg -> major_version = OPAL_MAJOR_VERSION ;
902+ msg -> minor_version = OPAL_MINOR_VERSION ;
869903 msg -> size = ap -> sizes [i ];
870904 }
871905
0 commit comments