From 2d6fc268c4d5b6d9942c1039a431548e7673df5d Mon Sep 17 00:00:00 2001 From: James Simmons Date: Wed, 25 Jan 2023 20:38:17 -0800 Subject: [PATCH] LU-13903 utils: move userland only nidstr.h handling The function cfs_expand_nidlist() no longer exist for kernel internals. We can move the function prototype from the UAPI header to string.h which is a libcfs user land header. The structure netstrfns that is defined in a UAPI header has been adding user land only handling. Additional its use struct list_head which will confuse reviewers since kernel developers see this as a kernel only thing. Lustre-change: https://review.whamcloud.com/39115 Lustre-commit: 062809b1313ac7000e3476c96cbbe5d017f10875 Test-Parameters: trivial Change-Id: Ifc3c87f6d3237a94d282d009455ff389278e73ea Signed-off-by: James Simmons Reviewed-by: Arshad Hussain Reviewed-by: Chris Horn Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/49777 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Yang Sheng Reviewed-by: Andreas Dilger --- libcfs/include/libcfs/util/string.h | 19 +++++++++++++++++++ lnet/include/lnet/lib-types.h | 15 +++++++++++++++ lnet/include/uapi/linux/lnet/nidstr.h | 19 ------------------- lnet/lnet/nidstrings.c | 1 + 4 files changed, 35 insertions(+), 19 deletions(-) diff --git a/libcfs/include/libcfs/util/string.h b/libcfs/include/libcfs/util/string.h index f73fd79..50c9a66 100644 --- a/libcfs/include/libcfs/util/string.h +++ b/libcfs/include/libcfs/util/string.h @@ -43,6 +43,7 @@ #include #include +#include #include static inline @@ -75,6 +76,22 @@ static inline int scnprintf(char *buf, size_t bufsz, const char *format, ...) return ret; } +struct netstrfns { + __u32 nf_type; + char *nf_name; + char *nf_modname; + void (*nf_addr2str)(__u32 addr, char *str, size_t size); + int (*nf_str2addr)(const char *str, int nob, __u32 *addr); + int (*nf_parse_addrlist)(char *str, int len, + struct list_head *list); + int (*nf_print_addrlist)(char *buffer, int count, + struct list_head *list); + int (*nf_match_addr)(__u32 addr, struct list_head *list); + int (*nf_min_max)(struct list_head *nidlist, __u32 *min_nid, + __u32 *max_nid); + int (*nf_expand_addrrange)(struct list_head *addrranges, + __u32 *addrs, int max_addrs); +}; /** * Structure to represent NULL-less strings. @@ -117,6 +134,8 @@ int cfs_ip_addr_parse(char *str, int len, struct list_head *list); int cfs_ip_addr_range_gen(__u32 *ip_list, int count, struct list_head *ip_addr_expr); int cfs_ip_addr_match(__u32 addr, struct list_head *list); +int cfs_expand_nidlist(struct list_head *nidlist, lnet_nid_t *lnet_nidlist, + int max_nids); int cfs_abs_path(const char *request_path, char **resolved_path); #endif diff --git a/lnet/include/lnet/lib-types.h b/lnet/include/lnet/lib-types.h index 9b1e7e3..1d3a2e4 100644 --- a/lnet/include/lnet/lib-types.h +++ b/lnet/include/lnet/lib-types.h @@ -242,6 +242,21 @@ struct lnet_test_peer { #define LNET_COOKIE_TYPE_BITS 2 #define LNET_COOKIE_MASK ((1ULL << LNET_COOKIE_TYPE_BITS) - 1ULL) +struct netstrfns { + u32 nf_type; + char *nf_name; + char *nf_modname; + void (*nf_addr2str)(u32 addr, char *str, size_t size); + int (*nf_str2addr)(const char *str, int nob, u32 *addr); + int (*nf_parse_addrlist)(char *str, int len, + struct list_head *list); + int (*nf_print_addrlist)(char *buffer, int count, + struct list_head *list); + int (*nf_match_addr)(u32 addr, struct list_head *list); + int (*nf_min_max)(struct list_head *nidlist, u32 *min_nid, + u32 *max_nid); +}; + struct lnet_ni; /* forward ref */ struct socket; diff --git a/lnet/include/uapi/linux/lnet/nidstr.h b/lnet/include/uapi/linux/lnet/nidstr.h index e445766..55b03d7 100644 --- a/lnet/include/uapi/linux/lnet/nidstr.h +++ b/lnet/include/uapi/linux/lnet/nidstr.h @@ -93,28 +93,9 @@ void cfs_free_nidlist(struct list_head *list); int cfs_parse_nidlist(char *str, int len, struct list_head *list); int cfs_print_nidlist(char *buffer, int count, struct list_head *list); int cfs_match_nid(lnet_nid_t nid, struct list_head *list); -int cfs_expand_nidlist(struct list_head *nidlist, lnet_nid_t *lnet_nidlist, - int max_nids); int cfs_ip_addr_parse(char *str, int len, struct list_head *list); int cfs_ip_addr_match(__u32 addr, struct list_head *list); int cfs_nidrange_find_min_max(struct list_head *nidlist, char *min_nid, char *max_nid, __kernel_size_t nidstr_length); -struct netstrfns { - __u32 nf_type; - char *nf_name; - char *nf_modname; - void (*nf_addr2str)(__u32 addr, char *str, __kernel_size_t size); - int (*nf_str2addr)(const char *str, int nob, __u32 *addr); - int (*nf_parse_addrlist)(char *str, int len, - struct list_head *list); - int (*nf_print_addrlist)(char *buffer, int count, - struct list_head *list); - int (*nf_match_addr)(__u32 addr, struct list_head *list); - int (*nf_min_max)(struct list_head *nidlist, __u32 *min_nid, - __u32 *max_nid); - int (*nf_expand_addrrange)(struct list_head *addrranges, - __u32 *addrs, int max_addrs); -}; - #endif /* _LNET_NIDSTRINGS_H */ diff --git a/lnet/lnet/nidstrings.c b/lnet/lnet/nidstrings.c index 3ad2884..aa3b034 100644 --- a/lnet/lnet/nidstrings.c +++ b/lnet/lnet/nidstrings.c @@ -38,6 +38,7 @@ #include #include +#include /* max value for numeric network address */ #define MAX_NUMERIC_VALUE 0xffffffff -- 1.8.3.1