diff options
author | Zhongqiu Duan <dzq.aishenghu0@gmail.com> | 2025-03-19 14:20:53 +0000 |
---|---|---|
committer | Florian Westphal <fw@strlen.de> | 2025-03-19 16:02:28 +0100 |
commit | c59d42a90b0d279955d5051c2306733bc01522f8 (patch) | |
tree | 4875c04f9bad97a4c3e88bf329b6c0d75935556d | |
parent | a7dfa49d34c76a420778a6fce2b5e7d85f0c8b1a (diff) |
src: remove unused str2XXX helpers
After commit 80077787f8f2 ("src: remove json support"), these internal
functions are no longer used:
nftnl_str2hooknum
nftnl_str2ntoh
nftnl_str2cmp
str2ctkey
str2ctdir
str2exthdr_op
str2exthdr_type
str2meta_key
nftnl_str2nat
nftnl_str2range
str2rt_key
nftnl_str2hooknum
Signed-off-by: Zhongqiu Duan <dzq.aishenghu0@gmail.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
-rw-r--r-- | src/chain.c | 11 | ||||
-rw-r--r-- | src/expr/byteorder.c | 12 | ||||
-rw-r--r-- | src/expr/cmp.c | 20 | ||||
-rw-r--r-- | src/expr/ct.c | 27 | ||||
-rw-r--r-- | src/expr/exthdr.c | 27 | ||||
-rw-r--r-- | src/expr/meta.c | 13 | ||||
-rw-r--r-- | src/expr/nat.c | 12 | ||||
-rw-r--r-- | src/expr/range.c | 12 | ||||
-rw-r--r-- | src/expr/rt.c | 13 | ||||
-rw-r--r-- | src/flowtable.c | 11 |
10 files changed, 0 insertions, 158 deletions
diff --git a/src/chain.c b/src/chain.c index 7287dcd..895108c 100644 --- a/src/chain.c +++ b/src/chain.c @@ -739,17 +739,6 @@ int nftnl_chain_nlmsg_parse(const struct nlmsghdr *nlh, struct nftnl_chain *c) return ret; } -static inline int nftnl_str2hooknum(int family, const char *hook) -{ - int hooknum; - - for (hooknum = 0; hooknum < NF_INET_NUMHOOKS; hooknum++) { - if (strcmp(hook, nftnl_hooknum2str(family, hooknum)) == 0) - return hooknum; - } - return -1; -} - static int nftnl_chain_snprintf_default(char *buf, size_t remain, const struct nftnl_chain *c) { diff --git a/src/expr/byteorder.c b/src/expr/byteorder.c index 903c775..4171d06 100644 --- a/src/expr/byteorder.c +++ b/src/expr/byteorder.c @@ -179,18 +179,6 @@ static const char *bo2str(uint32_t type) return expr_byteorder_str[type]; } -static inline int nftnl_str2ntoh(const char *op) -{ - if (strcmp(op, "ntoh") == 0) - return NFT_BYTEORDER_NTOH; - else if (strcmp(op, "hton") == 0) - return NFT_BYTEORDER_HTON; - else { - errno = EINVAL; - return -1; - } -} - static int nftnl_expr_byteorder_snprintf(char *buf, size_t remain, uint32_t flags, const struct nftnl_expr *e) diff --git a/src/expr/cmp.c b/src/expr/cmp.c index f55a8c0..2908f56 100644 --- a/src/expr/cmp.c +++ b/src/expr/cmp.c @@ -148,26 +148,6 @@ static const char *cmp2str(uint32_t op) return expr_cmp_str[op]; } -static inline int nftnl_str2cmp(const char *op) -{ - if (strcmp(op, "eq") == 0) - return NFT_CMP_EQ; - else if (strcmp(op, "neq") == 0) - return NFT_CMP_NEQ; - else if (strcmp(op, "lt") == 0) - return NFT_CMP_LT; - else if (strcmp(op, "lte") == 0) - return NFT_CMP_LTE; - else if (strcmp(op, "gt") == 0) - return NFT_CMP_GT; - else if (strcmp(op, "gte") == 0) - return NFT_CMP_GTE; - else { - errno = EINVAL; - return -1; - } -} - static int nftnl_expr_cmp_snprintf(char *buf, size_t remain, uint32_t flags, const struct nftnl_expr *e) diff --git a/src/expr/ct.c b/src/expr/ct.c index 71dbaf9..8f8c2a6 100644 --- a/src/expr/ct.c +++ b/src/expr/ct.c @@ -177,18 +177,6 @@ static const char *ctkey2str(uint32_t ctkey) return ctkey2str_array[ctkey]; } -static inline int str2ctkey(const char *ctkey) -{ - int i; - - for (i = 0; i < NFT_CT_MAX; i++) { - if (strcmp(ctkey2str_array[i], ctkey) == 0) - return i; - } - - return -1; -} - static const char *ctdir2str(uint8_t ctdir) { switch (ctdir) { @@ -201,21 +189,6 @@ static const char *ctdir2str(uint8_t ctdir) } } -static inline int str2ctdir(const char *str, uint8_t *ctdir) -{ - if (strcmp(str, "original") == 0) { - *ctdir = IP_CT_DIR_ORIGINAL; - return 0; - } - - if (strcmp(str, "reply") == 0) { - *ctdir = IP_CT_DIR_REPLY; - return 0; - } - - return -1; -} - static int nftnl_expr_ct_snprintf(char *buf, size_t remain, uint32_t flags, const struct nftnl_expr *e) diff --git a/src/expr/exthdr.c b/src/expr/exthdr.c index 339527d..ddebe43 100644 --- a/src/expr/exthdr.c +++ b/src/expr/exthdr.c @@ -202,33 +202,6 @@ static const char *op2str(uint8_t op) } } -static inline int str2exthdr_op(const char* str) -{ - if (!strcmp(str, "tcpopt")) - return NFT_EXTHDR_OP_TCPOPT; - if (!strcmp(str, "ipv4")) - return NFT_EXTHDR_OP_IPV4; - - /* if str == "ipv6" or anything else */ - return NFT_EXTHDR_OP_IPV6; -} - -static inline int str2exthdr_type(const char *str) -{ - if (strcmp(str, "hopopts") == 0) - return IPPROTO_HOPOPTS; - else if (strcmp(str, "routing") == 0) - return IPPROTO_ROUTING; - else if (strcmp(str, "fragment") == 0) - return IPPROTO_FRAGMENT; - else if (strcmp(str, "dstopts") == 0) - return IPPROTO_DSTOPTS; - else if (strcmp(str, "mh") == 0) - return IPPROTO_MH; - - return -1; -} - static int nftnl_expr_exthdr_snprintf(char *buf, size_t len, uint32_t flags, const struct nftnl_expr *e) diff --git a/src/expr/meta.c b/src/expr/meta.c index 56d3dda..d1ff6c4 100644 --- a/src/expr/meta.c +++ b/src/expr/meta.c @@ -173,19 +173,6 @@ static const char *meta_key2str(uint8_t key) return "unknown"; } -static inline int str2meta_key(const char *str) -{ - int i; - - for (i = 0; i < NFT_META_MAX; i++) { - if (strcmp(str, meta_key2str_array[i]) == 0) - return i; - } - - errno = EINVAL; - return -1; -} - static int nftnl_expr_meta_snprintf(char *buf, size_t len, uint32_t flags, const struct nftnl_expr *e) diff --git a/src/expr/nat.c b/src/expr/nat.c index 3ce1aaf..f7e24cb 100644 --- a/src/expr/nat.c +++ b/src/expr/nat.c @@ -202,18 +202,6 @@ static inline const char *nat2str(uint16_t nat) } } -static inline int nftnl_str2nat(const char *nat) -{ - if (strcmp(nat, "snat") == 0) - return NFT_NAT_SNAT; - else if (strcmp(nat, "dnat") == 0) - return NFT_NAT_DNAT; - else { - errno = EINVAL; - return -1; - } -} - static int nftnl_expr_nat_snprintf(char *buf, size_t remain, uint32_t flags, const struct nftnl_expr *e) diff --git a/src/expr/range.c b/src/expr/range.c index b05724f..50a8ed0 100644 --- a/src/expr/range.c +++ b/src/expr/range.c @@ -162,18 +162,6 @@ static const char *range2str(uint32_t op) return expr_range_str[op]; } -static inline int nftnl_str2range(const char *op) -{ - if (strcmp(op, "eq") == 0) - return NFT_RANGE_EQ; - else if (strcmp(op, "neq") == 0) - return NFT_RANGE_NEQ; - else { - errno = EINVAL; - return -1; - } -} - static int nftnl_expr_range_snprintf(char *buf, size_t remain, uint32_t flags, const struct nftnl_expr *e) { diff --git a/src/expr/rt.c b/src/expr/rt.c index 633031e..4f2e96b 100644 --- a/src/expr/rt.c +++ b/src/expr/rt.c @@ -122,19 +122,6 @@ static const char *rt_key2str(uint8_t key) return "unknown"; } -static inline int str2rt_key(const char *str) -{ - int i; - - for (i = 0; i < NFT_RT_MAX; i++) { - if (strcmp(str, rt_key2str_array[i]) == 0) - return i; - } - - errno = EINVAL; - return -1; -} - static int nftnl_expr_rt_snprintf(char *buf, size_t len, uint32_t flags, const struct nftnl_expr *e) diff --git a/src/flowtable.c b/src/flowtable.c index 2a8d374..fbbe0a8 100644 --- a/src/flowtable.c +++ b/src/flowtable.c @@ -488,17 +488,6 @@ static const char *nftnl_hooknum2str(int family, int hooknum) return "unknown"; } -static inline int nftnl_str2hooknum(int family, const char *hook) -{ - int hooknum; - - for (hooknum = 0; hooknum < NF_INET_NUMHOOKS; hooknum++) { - if (strcmp(hook, nftnl_hooknum2str(family, hooknum)) == 0) - return hooknum; - } - return -1; -} - EXPORT_SYMBOL(nftnl_flowtable_parse); int nftnl_flowtable_parse(struct nftnl_flowtable *c, enum nftnl_parse_type type, const char *data, struct nftnl_parse_err *err) |