extern unsigned int lnet_health_sensitivity;
extern unsigned int lnet_recovery_interval;
extern unsigned int lnet_peer_discovery_disabled;
+extern unsigned int lnet_drop_asym_route;
extern int portal_rotor;
int lnet_notify(struct lnet_ni *ni, lnet_nid_t peer, int alive,
MODULE_PARM_DESC(lnet_peer_discovery_disabled,
"Set to 1 to disable peer discovery on this node.");
+unsigned int lnet_drop_asym_route;
+static int drop_asym_route_set(const char *val, cfs_kernel_param_arg_t *kp);
+
+static struct kernel_param_ops param_ops_drop_asym_route = {
+ .set = drop_asym_route_set,
+ .get = param_get_int,
+};
+
+#define param_check_drop_asym_route(name, p) \
+ __param_check(name, p, int)
+#ifdef HAVE_KERNEL_PARAM_OPS
+module_param(lnet_drop_asym_route, drop_asym_route, 0644);
+#else
+module_param_call(lnet_drop_asym_route, drop_asym_route_set, param_get_int,
+ ¶m_ops_drop_asym_route, 0644);
+#endif
+MODULE_PARM_DESC(lnet_drop_asym_route,
+ "Set to 1 to drop asymmetrical route messages.");
+
unsigned lnet_transaction_timeout = 50;
static int transaction_to_set(const char *val, cfs_kernel_param_arg_t *kp);
#ifdef HAVE_KERNEL_PARAM_OPS
}
static int
+drop_asym_route_set(const char *val, cfs_kernel_param_arg_t *kp)
+{
+ int rc;
+ unsigned int *drop_asym_route = (unsigned int *)kp->arg;
+ unsigned long value;
+
+ rc = kstrtoul(val, 0, &value);
+ if (rc) {
+ CERROR("Invalid module parameter value for "
+ "'lnet_drop_asym_route'\n");
+ return rc;
+ }
+
+ /*
+ * The purpose of locking the api_mutex here is to ensure that
+ * the correct value ends up stored properly.
+ */
+ mutex_lock(&the_lnet.ln_api_mutex);
+
+ if (value == *drop_asym_route) {
+ mutex_unlock(&the_lnet.ln_api_mutex);
+ return 0;
+ }
+
+ *drop_asym_route = value;
+
+ mutex_unlock(&the_lnet.ln_api_mutex);
+
+ return 0;
+}
+
+static int
transaction_to_set(const char *val, cfs_kernel_param_arg_t *kp)
{
int rc;
goto drop;
}
+ if (lnet_drop_asym_route && for_me &&
+ LNET_NIDNET(src_nid) != LNET_NIDNET(from_nid)) {
+ struct lnet_net *net;
+ struct lnet_remotenet *rnet;
+ bool found = true;
+
+ /* we are dealing with a routed message,
+ * so see if route to reach src_nid goes through from_nid
+ */
+ lnet_net_lock(cpt);
+ net = lnet_get_net_locked(LNET_NIDNET(ni->ni_nid));
+ if (!net) {
+ lnet_net_unlock(cpt);
+ CERROR("net %s not found\n",
+ libcfs_net2str(LNET_NIDNET(ni->ni_nid)));
+ return -EPROTO;
+ }
+
+ rnet = lnet_find_rnet_locked(LNET_NIDNET(src_nid));
+ if (rnet) {
+ struct lnet_peer_ni *gw = NULL;
+ struct lnet_route *route;
+
+ list_for_each_entry(route, &rnet->lrn_routes, lr_list) {
+ found = false;
+ gw = route->lr_gateway;
+ if (gw->lpni_net != net)
+ continue;
+ if (gw->lpni_nid == from_nid) {
+ found = true;
+ break;
+ }
+ }
+ }
+ lnet_net_unlock(cpt);
+ if (!found) {
+ /* we would not use from_nid to route a message to
+ * src_nid
+ * => asymmetric routing detected but forbidden
+ */
+ CERROR("%s, src %s: Dropping asymmetrical route %s\n",
+ libcfs_nid2str(from_nid),
+ libcfs_nid2str(src_nid), lnet_msgtyp2str(type));
+ goto drop;
+ }
+ }
msg = lnet_msg_alloc();
if (msg == NULL) {
}
+int lustre_lnet_config_drop_asym_route(int drop, int seq_no,
+ struct cYAML **err_rc)
+{
+ int rc = LUSTRE_CFG_RC_NO_ERR;
+ char err_str[LNET_MAX_STR_LEN];
+ char val[LNET_MAX_STR_LEN];
+
+ snprintf(err_str, sizeof(err_str), "\"success\"");
+
+ snprintf(val, sizeof(val), "%u", (drop) ? 1 : 0);
+
+ rc = write_sysfs_file(modparam_path, "lnet_drop_asym_route", val,
+ 1, strlen(val) + 1);
+ if (rc)
+ snprintf(err_str, sizeof(err_str),
+ "\"cannot configure drop asym route: %s\"",
+ strerror(errno));
+
+ cYAML_build_error(rc, seq_no, ADD_CMD, "drop_asym_route",
+ err_str, err_rc);
+
+ return rc;
+
+}
+
int lustre_lnet_config_numa_range(int range, int seq_no, struct cYAML **err_rc)
{
return ioctl_set_value(range, IOC_LIBCFS_SET_NUMA_RANGE,
err_rc, l_errno);
}
+int lustre_lnet_show_drop_asym_route(int seq_no, struct cYAML **show_rc,
+ struct cYAML **err_rc)
+{
+ int rc = LUSTRE_CFG_RC_OUT_OF_MEM;
+ char val[LNET_MAX_STR_LEN];
+ int drop_asym_route = -1, l_errno = 0;
+ char err_str[LNET_MAX_STR_LEN];
+
+ snprintf(err_str, sizeof(err_str), "\"out of memory\"");
+
+ rc = read_sysfs_file(modparam_path, "lnet_drop_asym_route", val,
+ 1, sizeof(val));
+ if (rc) {
+ l_errno = -errno;
+ snprintf(err_str, sizeof(err_str),
+ "\"cannot get drop asym route setting: %d\"", rc);
+ } else {
+ drop_asym_route = atoi(val);
+ }
+
+ return build_global_yaml_entry(err_str, sizeof(err_str), seq_no,
+ "drop_asym_route", drop_asym_route,
+ show_rc, err_rc, l_errno);
+}
+
int lustre_lnet_show_numa_range(int seq_no, struct cYAML **show_rc,
struct cYAML **err_rc)
{
struct cYAML **err_rc)
{
struct cYAML *max_intf, *numa, *discovery, *retry, *tto, *seq_no,
- *sen, *recov;
+ *sen, *recov, *drop_asym_route;
int rc = 0;
seq_no = cYAML_get_object_item(tree, "seq_no");
: -1,
err_rc);
+ drop_asym_route = cYAML_get_object_item(tree, "drop_asym_route");
+ if (drop_asym_route)
+ rc = lustre_lnet_config_drop_asym_route(
+ drop_asym_route->cy_valueint,
+ seq_no ? seq_no->cy_valueint : -1,
+ err_rc);
+
retry = cYAML_get_object_item(tree, "retry_count");
if (retry)
rc = lustre_lnet_config_retry_count(retry->cy_valueint,
struct cYAML **show_rc,
struct cYAML **err_rc)
{
- struct cYAML *max_intf, *numa, *discovery, *seq_no;
+ struct cYAML *max_intf, *numa, *discovery, *seq_no, *drop_asym_route;
int rc = 0;
seq_no = cYAML_get_object_item(tree, "seq_no");
: -1,
err_rc);
+ /* asymmetrical route messages are accepted by default */
+ drop_asym_route = cYAML_get_object_item(tree, "drop_asym_route");
+ if (drop_asym_route)
+ rc = lustre_lnet_config_drop_asym_route(
+ 0, seq_no ? seq_no->cy_valueint : -1, err_rc);
+
return rc;
}
struct cYAML **err_rc)
{
struct cYAML *max_intf, *numa, *discovery, *retry, *tto, *seq_no,
- *sen, *recov;
+ *sen, *recov, *drop_asym_route;
int rc = 0;
seq_no = cYAML_get_object_item(tree, "seq_no");
: -1,
show_rc, err_rc);
+ drop_asym_route = cYAML_get_object_item(tree, "drop_asym_route");
+ if (drop_asym_route)
+ rc = lustre_lnet_show_drop_asym_route(
+ seq_no ? seq_no->cy_valueint : -1,
+ show_rc, err_rc);
+
retry = cYAML_get_object_item(tree, "retry_count");
if (retry)
rc = lustre_lnet_show_retry_count(seq_no ? seq_no->cy_valueint
struct cYAML **err_rc);
/*
+ * lustre_lnet_config_drop_asym_route
+ * Drop or accept asymmetrical route messages. Accept by default.
+ *
+ * drop - non-0 drops, 0 accepts
+ * seq_no - sequence number of the request
+ * err_rc - [OUT] struct cYAML tree describing the error. Freed by
+ * caller
+ */
+int lustre_lnet_config_drop_asym_route(int drop, int seq_no,
+ struct cYAML **err_rc);
+
+/*
+ * lustre_lnet_show_drop_asym_route
+ * show current drop asym route setting
+ *
+ * seq_no - sequence number of the request
+ * show_rc - [OUT] struct cYAML tree containing NUMA range info
+ * err_rc - [OUT] struct cYAML tree describing the error. Freed by
+ * caller
+ */
+int lustre_lnet_show_drop_asym_route(int seq_no, struct cYAML **show_rc,
+ struct cYAML **err_rc);
+
+/*
* lustre_lnet_config_buffers
* Send down an IOCTL to configure routing buffer sizes. A value of 0 means
* default that particular buffer to default size. A value of -1 means
static int jt_del_peer_nid(int argc, char **argv);
static int jt_set_max_intf(int argc, char **argv);
static int jt_set_discovery(int argc, char **argv);
+static int jt_set_drop_asym_route(int argc, char **argv);
static int jt_list_peer(int argc, char **argv);
/*static int jt_show_peer(int argc, char **argv);*/
static int lnetctl_list_commands(int argc, char **argv);
{"discovery", jt_set_discovery, 0, "enable/disable peer discovery\n"
"\t0 - disable peer discovery\n"
"\t1 - enable peer discovery (default)\n"},
+ {"drop_asym_route", jt_set_drop_asym_route, 0,
+ "drop/accept asymmetrical route messages\n"
+ "\t0 - accept asymmetrical route messages (default)\n"
+ "\t1 - drop asymmetrical route messages\n"},
{"retry_count", jt_set_retry_count, 0, "number of retries\n"
"\t0 - turn of retries\n"
"\t>0 - number of retries\n"},
return rc;
}
+static int jt_set_drop_asym_route(int argc, char **argv)
+{
+ long int value;
+ int rc;
+ struct cYAML *err_rc = NULL;
+
+ rc = check_cmd(set_cmds, "set", "drop_asym_route", 2, argc, argv);
+ if (rc)
+ return rc;
+
+ rc = parse_long(argv[1], &value);
+ if (rc != 0) {
+ cYAML_build_error(-1, -1, "parser", "set",
+ "cannot parse drop_asym_route value",
+ &err_rc);
+ cYAML_print_tree2file(stderr, err_rc);
+ cYAML_free_tree(err_rc);
+ return -1;
+ }
+
+ rc = lustre_lnet_config_drop_asym_route(value, -1, &err_rc);
+ if (rc != LUSTRE_CFG_RC_NO_ERR)
+ cYAML_print_tree2file(stderr, err_rc);
+
+ cYAML_free_tree(err_rc);
+
+ return rc;
+}
+
static int jt_set_tiny(int argc, char **argv)
{
long int value;
goto out;
}
+ rc = lustre_lnet_show_drop_asym_route(-1, &show_rc, &err_rc);
+ if (rc != LUSTRE_CFG_RC_NO_ERR) {
+ cYAML_print_tree2file(stderr, err_rc);
+ goto out;
+ }
+
rc = lustre_lnet_show_retry_count(-1, &show_rc, &err_rc);
if (rc != LUSTRE_CFG_RC_NO_ERR) {
cYAML_print_tree2file(stderr, err_rc);
err_rc = NULL;
}
+ rc = lustre_lnet_show_drop_asym_route(-1, &show_rc, &err_rc);
+ if (rc != LUSTRE_CFG_RC_NO_ERR) {
+ cYAML_print_tree2file(stderr, err_rc);
+ cYAML_free_tree(err_rc);
+ err_rc = NULL;
+ }
+
if (show_rc != NULL) {
cYAML_print_tree2file(f, show_rc);
cYAML_free_tree(show_rc);
are not remembered, and the next time routing is enabled the default buffer
count will be used\.
.
+.TP
+\fBlnetctl set\fR drop_asym_route \fI[0, 1]\fR
+0 value indicates to accept asymmetrical route messages\. 1 value indicates to
+drop them\. Asymmetrical route is when a message from a remote peer is coming
+through a router that would not be used by this node to reach the remote peer\.
+.
.SS "Import and Export YAML Configuration Files"
LNet configuration can be represented in YAML format\. A YAML configuration
file can be passed to the lnetctl utility via the \fBimport\fR command\. The