* equivalent interfaces to use
* This is an array because socklnd bonding can still be configured
*/
- char *ni_interfaces[LNET_NUM_INTERFACES];
+ char *ni_interfaces[LNET_INTERFACES_NUM];
struct net *ni_net_ns; /* original net namespace */
} lnet_ni_t;
};
struct lnet_ioctl_net_config {
- char ni_interfaces[LNET_NUM_INTERFACES][LNET_MAX_STR_LEN];
+ char ni_interfaces[LNET_INTERFACES_NUM][LNET_MAX_STR_LEN];
__u32 ni_status;
__u32 ni_cpts[LNET_MAX_SHOW_NUM_CPT];
char cfg_bulk[0];
struct lnet_ioctl_config_ni {
struct libcfs_ioctl_hdr lic_cfg_hdr;
lnet_nid_t lic_nid;
- char lic_ni_intf[LNET_NUM_INTERFACES][LNET_MAX_STR_LEN];
+ char lic_ni_intf[LNET_INTERFACES_NUM][LNET_MAX_STR_LEN];
char lic_legacy_ip2nets[LNET_MAX_STR_LEN];
__u32 lic_cpts[LNET_MAX_SHOW_NUM_CPT];
__u32 lic_ncpts;
* defined here because it is used in LNet data structures that are
* common to all LNDs.
*/
-#define LNET_NUM_INTERFACES 16
+#define LNET_INTERFACES_NUM 16
+
+/* The minimum number of interfaces per node supported by LNet. */
+#define LNET_INTERFACES_MIN 16
+/* The default - arbitrary - value of the lnet_max_interfaces tunable. */
+#define LNET_INTERFACES_MAX_DEFAULT 200
/**
* Objects maintained by the LNet are accessed through handles. Handle types
if (ni->ni_interfaces[0] != NULL) {
/* Use the IPoIB interface specified in 'networks=' */
- CLASSERT(LNET_NUM_INTERFACES > 1);
+ CLASSERT(LNET_INTERFACES_NUM > 1);
if (ni->ni_interfaces[1] != NULL) {
CERROR("Multiple interfaces not supported\n");
goto failed;
struct ksock_interface *iface;
for (i = 0; i < net->ksnn_ninterfaces; i++) {
- LASSERT(i < LNET_NUM_INTERFACES);
+ LASSERT(i < LNET_INTERFACES_NUM);
iface = &net->ksnn_interfaces[i];
if (iface->ksni_ipaddr == ip)
struct ksock_interface *iface;
for (i = 0; i < peer_ni->ksnp_n_passive_ips; i++) {
- LASSERT(i < LNET_NUM_INTERFACES);
+ LASSERT(i < LNET_INTERFACES_NUM);
ip = peer_ni->ksnp_passive_ips[i];
iface = ksocknal_ip2iface(peer_ni->ksnp_ni, ip);
read_lock(&ksocknal_data.ksnd_global_lock);
nip = net->ksnn_ninterfaces;
- LASSERT(nip <= LNET_NUM_INTERFACES);
+ LASSERT(nip <= LNET_INTERFACES_NUM);
/*
* Only offer interfaces for additional connections if I have
write_lock_bh(global_lock);
- LASSERT(n_peerips <= LNET_NUM_INTERFACES);
- LASSERT(net->ksnn_ninterfaces <= LNET_NUM_INTERFACES);
+ LASSERT(n_peerips <= LNET_INTERFACES_NUM);
+ LASSERT(net->ksnn_ninterfaces <= LNET_INTERFACES_NUM);
/* Only match interfaces for additional connections
* if I have > 1 interface */
return;
}
- LASSERT(npeer_ipaddrs <= LNET_NUM_INTERFACES);
+ LASSERT(npeer_ipaddrs <= LNET_INTERFACES_NUM);
for (i = 0; i < npeer_ipaddrs; i++) {
if (newroute != NULL) {
best_nroutes = 0;
best_netmatch = 0;
- LASSERT(net->ksnn_ninterfaces <= LNET_NUM_INTERFACES);
+ LASSERT(net->ksnn_ninterfaces <= LNET_INTERFACES_NUM);
/* Select interface to connect from */
for (j = 0; j < net->ksnn_ninterfaces; j++) {
atomic_set (&conn->ksnc_tx_nob, 0);
LIBCFS_ALLOC(hello, offsetof(struct ksock_hello_msg,
- kshm_ips[LNET_NUM_INTERFACES]));
+ kshm_ips[LNET_INTERFACES_NUM]));
if (hello == NULL) {
rc = -ENOMEM;
goto failed_1;
}
LIBCFS_FREE(hello, offsetof(struct ksock_hello_msg,
- kshm_ips[LNET_NUM_INTERFACES]));
+ kshm_ips[LNET_INTERFACES_NUM]));
/* setup the socket AFTER I've received hello (it disables
* SO_LINGER). I might call back to the acceptor who may want
failed_1:
if (hello != NULL)
LIBCFS_FREE(hello, offsetof(struct ksock_hello_msg,
- kshm_ips[LNET_NUM_INTERFACES]));
+ kshm_ips[LNET_INTERFACES_NUM]));
LIBCFS_FREE(conn, sizeof(*conn));
if (iface != NULL) {
/* silently ignore dups */
rc = 0;
- } else if (net->ksnn_ninterfaces == LNET_NUM_INTERFACES) {
+ } else if (net->ksnn_ninterfaces == LNET_INTERFACES_NUM) {
rc = -ENOSPC;
} else {
iface = &net->ksnn_interfaces[net->ksnn_ninterfaces++];
continue;
}
- if (j == LNET_NUM_INTERFACES) {
+ if (j == LNET_INTERFACES_NUM) {
CWARN("Ignoring interface %s (too many interfaces)\n",
names[i]);
continue;
net->ksnn_ninterfaces = 1;
} else {
- for (i = 0; i < LNET_NUM_INTERFACES; i++) {
+ for (i = 0; i < LNET_INTERFACES_NUM; i++) {
int up;
if (ni->ni_interfaces[i] == NULL)
int ksnn_npeers; /* # peers */
int ksnn_shutdown; /* shutting down? */
int ksnn_ninterfaces; /* IP interfaces */
- struct ksock_interface ksnn_interfaces[LNET_NUM_INTERFACES];
+ struct ksock_interface ksnn_interfaces[LNET_INTERFACES_NUM];
};
/** connd timeout */
time64_t ksnp_send_keepalive; /* time to send keepalive */
struct lnet_ni *ksnp_ni; /* which network */
int ksnp_n_passive_ips; /* # of... */
- __u32 ksnp_passive_ips[LNET_NUM_INTERFACES]; /* preferred local interfaces */
+ __u32 ksnp_passive_ips[LNET_INTERFACES_NUM]; /* preferred local interfaces */
};
struct ksock_connreq {
/* CAVEAT EMPTOR: this byte flips 'ipaddrs' */
struct ksock_net *net = (struct ksock_net *)ni->ni_data;
- LASSERT(hello->kshm_nips <= LNET_NUM_INTERFACES);
+ LASSERT(hello->kshm_nips <= LNET_INTERFACES_NUM);
/* rely on caller to hold a ref on socket so it wouldn't disappear */
LASSERT(conn->ksnc_proto != NULL);
hello->kshm_nips = le32_to_cpu (hdr->payload_length) /
sizeof (__u32);
- if (hello->kshm_nips > LNET_NUM_INTERFACES) {
+ if (hello->kshm_nips > LNET_INTERFACES_NUM) {
CERROR("Bad nips %d from ip %pI4h\n",
hello->kshm_nips, &conn->ksnc_ipaddr);
rc = -EPROTO;
__swab32s(&hello->kshm_nips);
}
- if (hello->kshm_nips > LNET_NUM_INTERFACES) {
+ if (hello->kshm_nips > LNET_INTERFACES_NUM) {
CERROR("Bad nips %d from ip %pI4h\n",
hello->kshm_nips, &conn->ksnc_ipaddr);
return -EPROTO;
#define DEBUG_SUBSYSTEM S_LNET
#include <linux/log2.h>
#include <linux/ktime.h>
+#include <linux/moduleparam.h>
#include <lnet/lib-lnet.h>
MODULE_PARM_DESC(lnet_numa_range,
"NUMA range to consider during Multi-Rail selection");
+static int lnet_interfaces_max = LNET_INTERFACES_MAX_DEFAULT;
+static int intf_max_set(const char *val, struct kernel_param *kp);
+module_param_call(lnet_interfaces_max, intf_max_set, param_get_int,
+ &lnet_interfaces_max, S_IRUGO|S_IWUSR);
+MODULE_PARM_DESC(lnet_interfaces_max,
+ "Maximum number of interfaces in a node.");
+
/*
* This sequence number keeps track of how many times DLC was used to
* update the local NIs. It is incremented when a NI is added or
static int lnet_ping(struct lnet_process_id id, signed long timeout,
struct lnet_process_id __user *ids, int n_ids);
+static int
+intf_max_set(const char *val, struct kernel_param *kp)
+{
+ int value, rc;
+
+ rc = kstrtoint(val, 0, &value);
+ if (rc) {
+ CERROR("Invalid module parameter value for 'lnet_interfaces_max'\n");
+ return rc;
+ }
+
+ if (value < LNET_INTERFACES_MIN) {
+ CWARN("max interfaces provided are too small, setting to %d\n",
+ LNET_INTERFACES_MIN);
+ value = LNET_INTERFACES_MIN;
+ }
+
+ *(int *)kp->arg = value;
+
+ return 0;
+}
+
static char *
lnet_get_routes(void)
{
struct lnet_handle_md mdh;
struct lnet_event event;
struct lnet_md md = { NULL };
- int which;
- int unlinked = 0;
- int replied = 0;
+ int which;
+ int unlinked = 0;
+ int replied = 0;
const signed long a_long_time = msecs_to_jiffies(60 * MSEC_PER_SEC);
- int infosz;
+ int infosz;
struct lnet_ping_info *info;
struct lnet_process_id tmpid;
- int i;
- int nob;
- int rc;
- int rc2;
- sigset_t blocked;
+ int i;
+ int nob;
+ int rc;
+ int rc2;
+ sigset_t blocked;
infosz = offsetof(struct lnet_ping_info, pi_ni[n_ids]);
/* n_ids limit is arbitrary */
- if (n_ids <= 0 || n_ids > 20 || id.nid == LNET_NID_ANY)
+ if (n_ids <= 0 || n_ids > lnet_interfaces_max || id.nid == LNET_NID_ANY)
return -EINVAL;
if (id.pid == LNET_PID_ANY)
/* check that the NI is unique to the interfaces with in the same NI.
* This is only a consideration if use_tcp_bonding is set */
static bool
-lnet_ni_unique_ni(char *iface_list[LNET_NUM_INTERFACES], char *iface)
+lnet_ni_unique_ni(char *iface_list[LNET_INTERFACES_NUM], char *iface)
{
int i;
- for (i = 0; i < LNET_NUM_INTERFACES; i++) {
+ for (i = 0; i < LNET_INTERFACES_NUM; i++) {
if (iface_list[i] != NULL &&
strncmp(iface_list[i], iface, strlen(iface)) == 0)
return false;
if (ni->ni_cpts != NULL)
cfs_expr_list_values_free(ni->ni_cpts, ni->ni_ncpts);
- for (i = 0; i < LNET_NUM_INTERFACES &&
+ for (i = 0; i < LNET_INTERFACES_NUM &&
ni->ni_interfaces[i] != NULL; i++) {
LIBCFS_FREE(ni->ni_interfaces[i],
strlen(ni->ni_interfaces[i]) + 1);
* can free the tokens at the end of the function.
* The newly allocated ni_interfaces[] can be
* freed when freeing the NI */
- while (niface < LNET_NUM_INTERFACES &&
+ while (niface < LNET_INTERFACES_NUM &&
ni->ni_interfaces[niface] != NULL)
niface++;
- if (niface >= LNET_NUM_INTERFACES) {
+ if (niface >= LNET_INTERFACES_NUM) {
LCONSOLE_ERROR_MSG(0x115, "Too many interfaces "
"for net %s\n",
libcfs_net2str(LNET_NIDNET(ni->ni_nid)));
if (interfaces == NULL)
goto out;
- for (j = 0; j < LNET_NUM_INTERFACES; j++) {
+ for (j = 0; j < LNET_INTERFACES_NUM; j++) {
if (strlen(ni_data->lic_ni_intf[j]) > 0) {
snprintf(str_buf,
sizeof(str_buf), "%d", j);