From a2602f47c8e0a3130d382c5098f5acb02447589e Mon Sep 17 00:00:00 2001 From: w00808059 Date: Wed, 31 Dec 2025 10:36:42 +0800 Subject: [PATCH] urma: add set eid ns. --- src/urma/lib/urma/core/include/urma_cmd.h | 1 + src/urma/tools/urma_admin/admin_cmd_eid.c | 34 +++++++++++++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/urma/lib/urma/core/include/urma_cmd.h b/src/urma/lib/urma/core/include/urma_cmd.h index 5dda3e6..0f3db31 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 088c8ab..42861f3 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) -- Gitee