@@ -164,6 +164,7 @@ int LNetGet(lnet_nid_t self,
int LNetCtl(unsigned int cmd, void *arg);
void LNetDebugPeer(struct lnet_process_id id);
int LNetGetPeerDiscoveryStatus(void);
+int LNetAddPeer(lnet_nid_t *nids, u32 num_nids);
/** @} lnet_misc */
@@ -854,7 +854,7 @@ struct lnet_peer_net *lnet_peer_get_net_locked(struct lnet_peer *peer,
void lnet_peer_clr_pref_rtrs(struct lnet_peer_ni *lpni);
int lnet_peer_add_pref_rtr(struct lnet_peer_ni *lpni, lnet_nid_t nid);
int lnet_peer_ni_set_non_mr_pref_nid(struct lnet_peer_ni *lpni, lnet_nid_t nid);
-int lnet_add_peer_ni(lnet_nid_t key_nid, lnet_nid_t nid, bool mr);
+int lnet_add_peer_ni(lnet_nid_t key_nid, lnet_nid_t nid, bool mr, bool temp);
int lnet_del_peer_ni(lnet_nid_t key_nid, lnet_nid_t nid);
int lnet_get_peer_info(struct lnet_ioctl_peer_cfg *cfg, void __user *bulk);
int lnet_get_peer_ni_info(u32 peer_index, u64 *nid,
@@ -4015,7 +4015,7 @@ u32 lnet_get_dlc_seq_locked(void)
mutex_lock(&the_lnet.ln_api_mutex);
rc = lnet_add_peer_ni(cfg->prcfg_prim_nid,
cfg->prcfg_cfg_nid,
- cfg->prcfg_mr);
+ cfg->prcfg_mr, false);
mutex_unlock(&the_lnet.ln_api_mutex);
return rc;
}
@@ -1320,6 +1320,51 @@ struct lnet_peer_ni *
return rc;
}
+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);
+
lnet_nid_t
LNetPrimaryNID(lnet_nid_t nid)
{
@@ -1538,6 +1583,11 @@ struct lnet_peer_net *
else if ((lp->lp_state ^ flags) & LNET_PEER_MULTI_RAIL)
rc = -EPERM;
goto out;
+ } else if (!(flags & LNET_PEER_CONFIGURED)) {
+ if (lp->lp_primary_nid == nid) {
+ rc = -EEXIST;
+ goto out;
+ }
}
/* Delete and recreate as a configured peer. */
lnet_peer_del(lp);
@@ -1777,17 +1827,19 @@ struct lnet_peer_net *
* being created/modified/deleted by a different thread.
*/
int
-lnet_add_peer_ni(lnet_nid_t prim_nid, lnet_nid_t nid, bool mr)
+lnet_add_peer_ni(lnet_nid_t prim_nid, lnet_nid_t nid, bool mr, bool temp)
{
struct lnet_peer *lp = NULL;
struct lnet_peer_ni *lpni;
- unsigned int flags;
+ unsigned int flags = 0;
/* The prim_nid must always be specified */
if (prim_nid == LNET_NID_ANY)
return -EINVAL;
- flags = LNET_PEER_CONFIGURED;
+ if (!temp)
+ flags = LNET_PEER_CONFIGURED;
+
if (mr)
flags |= LNET_PEER_MULTI_RAIL;
@@ -1806,7 +1858,7 @@ struct lnet_peer_net *
lp = lpni->lpni_peer_net->lpn_peer;
/* Peer must have been configured. */
- if (!(lp->lp_state & LNET_PEER_CONFIGURED)) {
+ if (!temp && !(lp->lp_state & LNET_PEER_CONFIGURED)) {
CDEBUG(D_NET, "peer %s was not configured\n",
libcfs_nid2str(prim_nid));
return -ENOENT;