lnd_cfg->lnd_timeout) == NULL)
return LUSTRE_CFG_RC_OUT_OF_MEM;
+ if (cYAML_create_number(lndparams, "tos",
+ lnd_cfg->lnd_tos) == NULL)
+ return LUSTRE_CFG_RC_OUT_OF_MEM;
+
return LUSTRE_CFG_RC_NO_ERR;
}
lnd_cfg->lnd_timeout) == NULL)
return LUSTRE_CFG_RC_OUT_OF_MEM;
+ if (cYAML_create_number(lndparams, "tos",
+ lnd_cfg->lnd_tos) == NULL)
+ return LUSTRE_CFG_RC_OUT_OF_MEM;
+
return LUSTRE_CFG_RC_NO_ERR;
}
struct cYAML *fmr_pool_size = NULL, *fmr_cache = NULL;
struct cYAML *fmr_flush_trigger = NULL, *lndparams = NULL;
struct cYAML *conns_per_peer = NULL, *ntx = NULL;
+ struct cYAML *tos = NULL;
lndparams = cYAML_get_object_item(tree, "lnd tunables");
if (!lndparams)
lnd_cfg->lnd_conns_per_peer =
(conns_per_peer) ? conns_per_peer->cy_valueint : 1;
+ tos = cYAML_get_object_item(lndparams, "tos");
+ lnd_cfg->lnd_tos =
+ (tos) ? tos->cy_valueint : -1;
}
#ifdef HAVE_KFILND
yaml_extract_sock_tun(struct cYAML *tree,
struct lnet_ioctl_config_socklnd_tunables *lnd_cfg)
{
- struct cYAML *conns_per_peer = NULL, *lndparams = NULL;
+ struct cYAML *conns_per_peer = NULL;
+ struct cYAML *tos = NULL;
+ struct cYAML *lndparams = NULL;
lndparams = cYAML_get_object_item(tree, "lnd tunables");
if (!lndparams)
conns_per_peer = cYAML_get_object_item(lndparams, "conns_per_peer");
lnd_cfg->lnd_conns_per_peer =
(conns_per_peer) ? conns_per_peer->cy_valueint : 1;
+
+ tos = cYAML_get_object_item(lndparams, "tos");
+ lnd_cfg->lnd_tos =
+ (tos) ? tos->cy_valueint : -1;
}
void
"\t--conns-per-peer: number of connections per peer\n"
"\t--skip-mr-route-setup: do not add linux route for the ni\n"
"\t--auth-key: Network authorization key (kfilnd only)\n"
- "\t--traffic-class: Traffic class (kfilnd only)\n"},
+ "\t--traffic-class: Traffic class (kfilnd only)\n"
+ "\t--tos: IP's Type of Service\n"},
{"del", jt_del_ni, 0, "delete a network\n"
"\t--net: net name (e.g. tcp0)\n"
"\t--nid: shutdown NI based on the address of the specified LNet NID\n"
skip_general_settings:
if (tunables->lt_tun.lnd_tun_u.lnd_sock.lnd_conns_per_peer > 0 ||
+ tunables->lt_tun.lnd_tun_u.lnd_sock.lnd_tos >= 0 ||
#ifdef HAVE_KFILND
tunables->lt_tun.lnd_tun_u.lnd_kfi.lnd_auth_key > 0 ||
tunables->lt_tun.lnd_tun_u.lnd_kfi.lnd_traffic_class_str[0] ||
#endif
- tunables->lt_tun.lnd_tun_u.lnd_o2ib.lnd_conns_per_peer > 0) {
+ tunables->lt_tun.lnd_tun_u.lnd_o2ib.lnd_conns_per_peer > 0 ||
+ tunables->lt_tun.lnd_tun_u.lnd_o2ib.lnd_tos >= 0) {
yaml_scalar_event_initialize(&event, NULL,
(yaml_char_t *)YAML_STR_TAG,
(yaml_char_t *)"lnd tunables",
goto error;
}
+ if (tunables->lt_tun.lnd_tun_u.lnd_sock.lnd_tos >= 0 ||
+ tunables->lt_tun.lnd_tun_u.lnd_o2ib.lnd_tos >= 0) {
+ int tos = 0;
+
+ yaml_scalar_event_initialize(&event, NULL,
+ (yaml_char_t *)YAML_STR_TAG,
+ (yaml_char_t *)"tos",
+ strlen("tos"), 1, 0,
+ YAML_PLAIN_SCALAR_STYLE);
+ rc = yaml_emitter_emit(output, &event);
+ if (rc == 0)
+ goto error;
+
+ if (LNET_NETTYP(nw_descr->nw_id) == SOCKLND)
+ tos = tunables->lt_tun.lnd_tun_u.lnd_sock.lnd_tos;
+ else if (LNET_NETTYP(nw_descr->nw_id) == O2IBLND)
+ tos = tunables->lt_tun.lnd_tun_u.lnd_o2ib.lnd_tos;
+ snprintf(num, sizeof(num), "%u", tos);
+
+ yaml_scalar_event_initialize(&event, NULL,
+ (yaml_char_t *)YAML_INT_TAG,
+ (yaml_char_t *)num,
+ strlen(num), 1, 0,
+ YAML_PLAIN_SCALAR_STYLE);
+ rc = yaml_emitter_emit(output, &event);
+ if (rc == 0)
+ goto error;
+ }
+
yaml_mapping_end_event_initialize(&event);
rc = yaml_emitter_emit(output, &event);
}
char *ip2net = NULL;
long int pto = -1, pc = -1, pbc = -1, cre = -1, cpp = -1, auth_key = -1;
char *traffic_class = NULL;
+ long int tos = -1;
struct cYAML *err_rc = NULL;
int rc, opt, cpt_rc = -1;
struct lnet_dlc_network_descr nw_descr;
{ .name = "cpt", .has_arg = required_argument, .val = 's' },
{ .name = "peer-timeout", .has_arg = required_argument, .val = 't' },
{ .name = "traffic-class", .has_arg = required_argument, .val = 'T' },
+ { .name = "tos", .has_arg = required_argument, .val = 'S' },
{ .name = NULL } };
bool nid_request = false;
char *net_id = NULL;
goto failed;
}
break;
+ case 'S':
+ rc = parse_long(optarg, &tos);
+ if (rc || tos < -1 || tos > 0xff) {
+ cYAML_build_error(-1, -1, "ni", "add",
+ "Invalid ToS argument",
+ &err_rc);
+ rc = LUSTRE_CFG_RC_BAD_PARAM;
+ goto failed;
+ }
+ break;
case '?':
print_help(net_cmds, "net", "add");
default:
}
#endif
+ if (LNET_NETTYP(nw_descr.nw_id) == SOCKLND) {
+ tunables.lt_tun.lnd_tun_u.lnd_sock.lnd_tos = tos;
+ found = true;
+ } else if (LNET_NETTYP(nw_descr.nw_id) == O2IBLND) {
+ tunables.lt_tun.lnd_tun_u.lnd_o2ib.lnd_tos = tos;
+ found = true;
+ }
+
if (LNET_NETTYP(nw_descr.nw_id) == SOCKLND && (cpp > -1)) {
tunables.lt_tun.lnd_tun_u.lnd_sock.lnd_conns_per_peer = cpp;
found = true;
}
run_test 231 "Check DLC handling of peer_timeout parameter"
+test_232() {
+ [[ ${NETTYPE} =~ ^(tcp|o2ib) ]] ||
+ skip "Need tcp or o2ib NETTYPE"
+
+ local i
+ local modparam=-1
+ local net=${NETTYPE}232
+
+ reinit_dlc || return $?
+ if [[ ${NETTYPE} == tcp* ]];then
+ modparam=$(cat "/sys/module/ksocklnd/parameters/tos")
+ elif [[ ${NETTYPE} == o2ib* ]]; then
+ modparam=$(cat "/sys/module/ko2iblnd/parameters/tos")
+ fi
+
+ do_lnetctl net add --net $net --if ${INTERFACES[0]} ||
+ error "Failed to add net (no ToS)"
+ do_lnetctl net show --net $net -v 1 | grep -q "tos: $modparam" ||
+ error "Failed ToS value should inherit from module parameter $modparam"
+ do_lnetctl net del --net $net --if ${INTERFACES[0]} ||
+ error "Failed to delete net $net"
+
+ for i in -1 104 106; do
+ do_lnetctl net add --net $net --if ${INTERFACES[0]} --tos $i ||
+ error "Failed to add net (ToS: $i)"
+ do_lnetctl net show --net $net -v 1 | grep -q "tos: $i" ||
+ error "Failed to set ToS value to 104"
+ do_lnetctl net del --net $net --if ${INTERFACES[0]} ||
+ error "Failed to delete net $net"
+ done
+
+ ! do_lnetctl net add --net $net --if ${INTERFACES[0]} --tos 300 ||
+ error "lnetctl should reject invalid ToS value (>255)"
+}
+run_test 232 "Test setting ToS value"
+
### Test that linux route is added for each ni
test_250() {
local skip_param