+int
+LNetAddPeer(lnet_nid_t *nids, __u32 num_nids)
+{
+ lnet_nid_t pnid = 0;
+ bool mr;
+ int i, rc;
+
+ if (!nids || num_nids < 1)
+ return -EINVAL;
+
+ rc = LNetNIInit(LNET_PID_ANY);
+ if (rc < 0)
+ return rc;
+
+ mutex_lock(&the_lnet.ln_api_mutex);
+
+ mr = lnet_peer_discovery_disabled == 0;
+
+ rc = 0;
+ for (i = 0; i < num_nids; i++) {
+ if (nids[i] == LNET_NID_LO_0)
+ continue;
+
+ if (!pnid) {
+ pnid = nids[i];
+ rc = lnet_add_peer_ni(pnid, LNET_NID_ANY, mr, true);
+ } else if (lnet_peer_discovery_disabled) {
+ rc = lnet_add_peer_ni(nids[i], LNET_NID_ANY, mr, true);
+ } else {
+ rc = lnet_add_peer_ni(pnid, nids[i], mr, true);
+ }
+
+ if (rc && rc != -EEXIST)
+ goto unlock;
+ }
+
+unlock:
+ mutex_unlock(&the_lnet.ln_api_mutex);
+
+ LNetNIFini();
+
+ return rc == -EEXIST ? 0 : rc;
+}
+EXPORT_SYMBOL(LNetAddPeer);
+