@@ -1299,39 +1299,65 @@ mca_oob_t* mca_oob_tcp_component_init(int* priority)
12991299 int i ;
13001300 bool found_local = false;
13011301 bool found_nonlocal = false;
1302+ char * * interfaces = NULL ;
1303+ mca_oob_tcp_device_t * dev ;
1304+ bool including = true;
1305+ char name [32 ];
13021306
13031307 * priority = 1 ;
13041308
13051309 /* are there any interfaces? */
1306- if (opal_ifcount () <= 0 )
1310+ if (opal_ifcount () <= 0 ) {
13071311 return NULL ;
1312+ }
1313+
1314+ /* did someone mistakenly specify both includes AND excludes? */
1315+ if (NULL != mca_oob_tcp_component .tcp_include &&
1316+ NULL != mca_oob_tcp_component .tcp_exclude ) {
1317+ orte_show_help ("help-oob-tcp.txt" , "include-exclude" , true,
1318+ mca_oob_tcp_component .tcp_include ,
1319+ mca_oob_tcp_component .tcp_exclude );
1320+ return NULL ;
1321+ }
13081322
1309- /* Which interfaces should we use? Start by building a list of
1310- all devices that meet the requirements of the if_include and
1311- if_exclude list. This might include local and non-local
1312- interfaces mixed together. After that sorting is done, if there
1313- is a mix of devices, we go through the devices that survived
1314- the initial sort and remove all the local devices (since we
1315- have non-local devices to use). */
1323+ /* if interface include was given, construct a list
1324+ * of those interfaces which match the specifications - remember,
1325+ * the includes could be given as named interfaces, IP addrs, or
1326+ * subnet+mask
1327+ */
1328+ if (NULL != mca_oob_tcp_component .tcp_include ) {
1329+ interfaces = opal_argv_split (mca_oob_tcp_component .tcp_include , ',' );
1330+ including = true;
1331+ } else if (NULL != mca_oob_tcp_component .tcp_exclude ) {
1332+ interfaces = opal_argv_split (mca_oob_tcp_component .tcp_exclude , ',' );
1333+ including = false;
1334+ }
1335+
1336+ /* look at all available interfaces */
13161337 for (i = opal_ifbegin () ; i > 0 ; i = opal_ifnext (i )) {
1317- char name [32 ];
1318- mca_oob_tcp_device_t * dev ;
13191338
1339+ /* get the name for diagnostic purposes */
13201340 opal_ifindextoname (i , name , sizeof (name ));
13211341
1322- if (mca_oob_tcp_component .tcp_include != NULL &&
1323- strstr (mca_oob_tcp_component .tcp_include ,name ) == NULL ) {
1324- OPAL_OUTPUT_VERBOSE ((1 , mca_oob_tcp_output_handle ,
1325- "%s oob:tcp:init rejecting interface %s" ,
1326- ORTE_NAME_PRINT (ORTE_PROC_MY_NAME ), name ));
1327- continue ;
1328- }
1329- if (mca_oob_tcp_component .tcp_exclude != NULL &&
1330- strstr (mca_oob_tcp_component .tcp_exclude ,name ) != NULL ) {
1331- OPAL_OUTPUT_VERBOSE ((1 , mca_oob_tcp_output_handle ,
1332- "%s oob:tcp:init rejecting interface %s" ,
1333- ORTE_NAME_PRINT (ORTE_PROC_MY_NAME ), name ));
1334- continue ;
1342+ /* handle include/exclude directives */
1343+ if (NULL != interfaces ) {
1344+ /* if we are including, then ignore this if not present */
1345+ if (including ) {
1346+ if (!opal_ifmatches (i , interfaces )) {
1347+ OPAL_OUTPUT_VERBOSE ((1 , mca_oob_tcp_output_handle ,
1348+ "%s oob:tcp:init rejecting interface %s" ,
1349+ ORTE_NAME_PRINT (ORTE_PROC_MY_NAME ), name ));
1350+ continue ;
1351+ }
1352+ } else {
1353+ /* we are excluding, so ignore if present */
1354+ if (opal_ifmatches (i , interfaces )) {
1355+ OPAL_OUTPUT_VERBOSE ((1 , mca_oob_tcp_output_handle ,
1356+ "%s oob:tcp:init rejecting interface %s" ,
1357+ ORTE_NAME_PRINT (ORTE_PROC_MY_NAME ), name ));
1358+ continue ;
1359+ }
1360+ }
13351361 }
13361362
13371363 dev = OBJ_NEW (mca_oob_tcp_device_t );
@@ -1353,6 +1379,13 @@ mca_oob_t* mca_oob_tcp_component_init(int* priority)
13531379 opal_list_append (& mca_oob_tcp_component .tcp_available_devices ,
13541380 & dev -> super );
13551381 }
1382+
1383+ /* cleanup */
1384+ if (NULL != interfaces ) {
1385+ opal_argv_free (interfaces );
1386+ }
1387+
1388+ /* remove all the local devices if we have non-local devices to use. */
13561389 if (found_local && found_nonlocal ) {
13571390 opal_list_item_t * item , * next ;
13581391 for (item = opal_list_get_first (& mca_oob_tcp_component .tcp_available_devices ) ;
@@ -1377,18 +1410,18 @@ mca_oob_t* mca_oob_tcp_component_init(int* priority)
13771410 opal_hash_table_init (& mca_oob_tcp_component .tcp_peer_names , 128 );
13781411
13791412 opal_free_list_init (& mca_oob_tcp_component .tcp_peer_free ,
1380- sizeof (mca_oob_tcp_peer_t ),
1381- OBJ_CLASS (mca_oob_tcp_peer_t ),
1382- 8 , /* initial number */
1383- mca_oob_tcp_component .tcp_peer_limit , /* maximum number */
1384- 8 ); /* increment to grow by */
1413+ sizeof (mca_oob_tcp_peer_t ),
1414+ OBJ_CLASS (mca_oob_tcp_peer_t ),
1415+ 8 , /* initial number */
1416+ mca_oob_tcp_component .tcp_peer_limit , /* maximum number */
1417+ 8 ); /* increment to grow by */
13851418
13861419 opal_free_list_init (& mca_oob_tcp_component .tcp_msgs ,
1387- sizeof (mca_oob_tcp_msg_t ),
1388- OBJ_CLASS (mca_oob_tcp_msg_t ),
1389- 8 , /* initial number */
1390- -1 , /* maximum number */
1391- 8 ); /* increment to grow by */
1420+ sizeof (mca_oob_tcp_msg_t ),
1421+ OBJ_CLASS (mca_oob_tcp_msg_t ),
1422+ 8 , /* initial number */
1423+ -1 , /* maximum number */
1424+ 8 ); /* increment to grow by */
13921425
13931426
13941427 /* intialize event library */
0 commit comments