- memset(net, 0, sizeof(*net));
- spin_lock_init(&net->ksnn_lock);
- net->ksnn_incarnation = ksocknal_new_incarnation();
- ni->ni_data = net;
- ni->ni_maxtxcredits = *ksocknal_tunables.ksnd_credits;
- ni->ni_peertxcredits = *ksocknal_tunables.ksnd_peercredits;
-
- if (ni->ni_interfaces[0] == NULL) {
- rc = ksocknal_enumerate_interfaces(net);
- if (rc <= 0)
- goto fail_1;
-
- net->ksnn_ninterfaces = 1;
- } else {
- for (i = 0; i < LNET_MAX_INTERFACES; i++) {
- int up;
-
- if (ni->ni_interfaces[i] == NULL)
- break;
-
- rc = libcfs_ipif_query(
- ni->ni_interfaces[i], &up,
- &net->ksnn_interfaces[i].ksni_ipaddr,
- &net->ksnn_interfaces[i].ksni_netmask);
-
- if (rc != 0) {
- CERROR("Can't get interface %s info: %d\n",
- ni->ni_interfaces[i], rc);
- goto fail_1;
- }
-
- if (!up) {
- CERROR("Interface %s is down\n",
- ni->ni_interfaces[i]);
- goto fail_1;
- }
- }
- net->ksnn_ninterfaces = i;
- }
-
- ni->ni_nid = LNET_MKNID(LNET_NIDNET(ni->ni_nid),
- net->ksnn_interfaces[0].ksni_ipaddr);
+ spin_lock_init(&net->ksnn_lock);
+ net->ksnn_incarnation = ktime_get_real_ns();
+ ni->ni_data = net;
+ net_tunables = &ni->ni_net->net_tunables;
+
+ if (net_tunables->lct_peer_timeout == -1)
+ net_tunables->lct_peer_timeout =
+ *ksocknal_tunables.ksnd_peertimeout;
+
+ if (net_tunables->lct_max_tx_credits == -1)
+ net_tunables->lct_max_tx_credits =
+ *ksocknal_tunables.ksnd_credits;
+
+ if (net_tunables->lct_peer_tx_credits == -1)
+ net_tunables->lct_peer_tx_credits =
+ *ksocknal_tunables.ksnd_peertxcredits;
+
+ if (net_tunables->lct_peer_tx_credits >
+ net_tunables->lct_max_tx_credits)
+ net_tunables->lct_peer_tx_credits =
+ net_tunables->lct_max_tx_credits;
+
+ if (net_tunables->lct_peer_rtr_credits == -1)
+ net_tunables->lct_peer_rtr_credits =
+ *ksocknal_tunables.ksnd_peerrtrcredits;
+
+ if (!ni->ni_interfaces[0]) {
+ rc = ksocknal_enumerate_interfaces(net, NULL);
+ if (rc < 0)
+ goto fail_1;
+ } else {
+ /* Before Multi-Rail ksocklnd would manage
+ * multiple interfaces with its own tcp bonding.
+ * If we encounter an old configuration using
+ * this tcp bonding approach then we need to
+ * handle more than one ni_interfaces.
+ *
+ * In Multi-Rail configuration only ONE ni_interface
+ * should exist. Each IP alias should be mapped to
+ * each 'struct net_ni'.
+ */
+ for (i = 0; i < LNET_INTERFACES_NUM; i++) {
+ int j;
+
+ if (!ni->ni_interfaces[i])
+ break;
+
+ for (j = 0; j < net->ksnn_ninterfaces; j++) {
+ struct ksock_interface *ksi;
+
+ ksi = &net->ksnn_interfaces[j];
+
+ if (strcmp(ni->ni_interfaces[i],
+ ksi->ksni_name) == 0) {
+ CERROR("found duplicate %s\n",
+ ksi->ksni_name);
+ rc = -EEXIST;
+ goto fail_1;
+ }
+ }
+
+ rc = ksocknal_enumerate_interfaces(net, ni->ni_interfaces[i]);
+ if (rc < 0)
+ goto fail_1;
+ }
+ }
+
+ net_dev = dev_get_by_name(&init_net,
+ net->ksnn_interfaces[0].ksni_name);
+ if (net_dev != NULL) {
+ node_id = dev_to_node(&net_dev->dev);
+ ni->ni_dev_cpt = cfs_cpt_of_node(lnet_cpt_table(), node_id);
+ dev_put(net_dev);
+ } else {
+ ni->ni_dev_cpt = CFS_CPT_ANY;
+ }
+
+ /* call it before add it to ksocknal_data.ksnd_nets */
+ rc = ksocknal_net_start_threads(net, ni->ni_cpts, ni->ni_ncpts);
+ if (rc != 0)
+ goto fail_1;
+
+ ni->ni_nid = LNET_MKNID(LNET_NIDNET(ni->ni_nid),
+ net->ksnn_interfaces[0].ksni_ipaddr);
+ list_add(&net->ksnn_list, &ksocknal_data.ksnd_nets);