diff --git a/src/urma/lib/urma/core/include/urma_cmd.h b/src/urma/lib/urma/core/include/urma_cmd.h index 5dda3e6fd18600c253c5e098d50e6ad9b557b445..0f3db31eefc7c6460a7c7be682cabfef07ebf40c 100644 --- a/src/urma/lib/urma/core/include/urma_cmd.h +++ b/src/urma/lib/urma/core/include/urma_cmd.h @@ -42,6 +42,7 @@ typedef enum urma_core_cmd { URMA_CORE_SET_DEV_SHARING_MODE, URMA_CORE_EXPOSE_DEV_NS, URMA_CORE_UNEXPOSE_DEV_NS, + URMA_CORE_SET_DEV_EID_NS, URMA_CORE_GET_TOPO_INFO, } urma_core_cmd_t; diff --git a/src/urma/tools/urma_admin/admin_cmd_eid.c b/src/urma/tools/urma_admin/admin_cmd_eid.c index 088c8ab4b9ed1bc3ae89ee496ff2c70ebc8a9aac..42861f374fae7a0ecb0ddd8aef22437e8d07807b 100644 --- a/src/urma/tools/urma_admin/admin_cmd_eid.c +++ b/src/urma/tools/urma_admin/admin_cmd_eid.c @@ -61,8 +61,38 @@ static int cmd_eid_set_mode(admin_config_t *cfg) static int cmd_eid_set_ns(admin_config_t *cfg) { - printf("TODO set eid ns %s %u\n", cfg->dev_name, cfg->idx); - return 0; + int ret; + if ((ret = pop_arg_ns(cfg)) != 0) { + return ret; + } + + int ns_fd = admin_get_ns_fd(cfg->ns); + if (ns_fd < 0) { + (void)printf("Failed to get ns fd, ns %s.\n", cfg->ns); + return ns_fd; + } + + struct nl_msg *msg = admin_nl_alloc_msg(URMA_CORE_SET_DEV_EID_NS, 0); + if (msg == NULL) { + ret = -ENOMEM; + goto close_ns_fd; + } + + admin_core_cmd_update_eid_t arg = {0}; + (void)memcpy(arg.in.dev_name, cfg->dev_name, URMA_ADMIN_MAX_DEV_NAME); + arg.in.eid_index = cfg->idx; + arg.in.ns_fd = ns_fd; + + admin_nl_put_string(msg, UBCORE_ATTR_DEV_NAME, cfg->dev_name); + admin_nl_put_u32(msg, UBCORE_ATTR_NS_FD, ns_fd); + admin_nl_put_u32(msg, UBCORE_HDR_ARGS_LEN, sizeof(admin_core_cmd_update_eid_t)); + admin_nl_put_u64(msg, UBCORE_HDR_ARGS_ADDR, (uint64_t)&arg); + ret = admin_nl_send_recv_msg_default(msg); + admin_nl_free_msg(msg); + +close_ns_fd: + (void)close(ns_fd); + return ret; } static int cmd_eid_set(admin_config_t *cfg)