From da80033c2f0c6037794721bd9ad36237e6d2ccca Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Tue, 26 Aug 2014 01:09:08 +0200 Subject: [PATCH 1/5] nf: nfnl_*_str2copy_mode() should return int ... to be able to return a negative error code for unknown modes. [thaller@redhat.com: This is potentially an ABI break, but since the size of the enum is implementation defined, it seems anyway unstable to have them as function arguments/return values.] http://lists.infradead.org/pipermail/libnl/2014-August/001616.html Signed-off-by: Thomas Graf Signed-off-by: Thomas Haller --- include/netlink/netfilter/log.h | 2 +- include/netlink/netfilter/queue.h | 2 +- lib/netfilter/log_obj.c | 2 +- lib/netfilter/queue_obj.c | 2 +- src/nf-log.c | 2 +- src/nf-queue.c | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/netlink/netfilter/log.h b/include/netlink/netfilter/log.h index 2002fa8..e48eddf 100644 --- a/include/netlink/netfilter/log.h +++ b/include/netlink/netfilter/log.h @@ -58,7 +58,7 @@ extern enum nfnl_log_copy_mode nfnl_log_get_copy_mode(const struct nfnl_log *); extern char * nfnl_log_copy_mode2str(enum nfnl_log_copy_mode, char *, size_t); -extern enum nfnl_log_copy_mode nfnl_log_str2copy_mode(const char *); +extern int nfnl_log_str2copy_mode(const char *); extern void nfnl_log_set_copy_range(struct nfnl_log *, uint32_t); extern int nfnl_log_test_copy_range(const struct nfnl_log *); diff --git a/include/netlink/netfilter/queue.h b/include/netlink/netfilter/queue.h index 664610d..224d469 100644 --- a/include/netlink/netfilter/queue.h +++ b/include/netlink/netfilter/queue.h @@ -54,7 +54,7 @@ extern enum nfnl_queue_copy_mode nfnl_queue_get_copy_mode(const struct nfnl_queu extern char * nfnl_queue_copy_mode2str(enum nfnl_queue_copy_mode, char *, size_t); -extern enum nfnl_queue_copy_mode nfnl_queue_str2copy_mode(const char *); +extern int nfnl_queue_str2copy_mode(const char *); extern void nfnl_queue_set_copy_range(struct nfnl_queue *, uint32_t); diff --git a/lib/netfilter/log_obj.c b/lib/netfilter/log_obj.c index 5e1bf9e..3fdb347 100644 --- a/lib/netfilter/log_obj.c +++ b/lib/netfilter/log_obj.c @@ -69,7 +69,7 @@ char *nfnl_log_copy_mode2str(enum nfnl_log_copy_mode copy_mode, char *buf, ARRAY_SIZE(copy_modes)); } -enum nfnl_log_copy_mode nfnl_log_str2copy_mode(const char *name) +int nfnl_log_str2copy_mode(const char *name) { return __str2type(name, copy_modes, ARRAY_SIZE(copy_modes)); } diff --git a/lib/netfilter/queue_obj.c b/lib/netfilter/queue_obj.c index b51f5ec..36ed3c5 100644 --- a/lib/netfilter/queue_obj.c +++ b/lib/netfilter/queue_obj.c @@ -65,7 +65,7 @@ char *nfnl_queue_copy_mode2str(enum nfnl_queue_copy_mode copy_mode, char *buf, ARRAY_SIZE(copy_modes)); } -enum nfnl_queue_copy_mode nfnl_queue_str2copy_mode(const char *name) +int nfnl_queue_str2copy_mode(const char *name) { return __str2type(name, copy_modes, ARRAY_SIZE(copy_modes)); } diff --git a/src/nf-log.c b/src/nf-log.c index 913ba16..c0cffe0 100644 --- a/src/nf-log.c +++ b/src/nf-log.c @@ -54,7 +54,7 @@ int main(int argc, char *argv[]) struct nl_sock *rt_sock; struct nl_cache *link_cache; struct nfnl_log *log; - enum nfnl_log_copy_mode copy_mode; + int copy_mode; uint32_t copy_range; int err; int family; diff --git a/src/nf-queue.c b/src/nf-queue.c index 922d9c8..7151381 100644 --- a/src/nf-queue.c +++ b/src/nf-queue.c @@ -62,7 +62,7 @@ int main(int argc, char *argv[]) struct nl_sock *rt_sock; struct nl_cache *link_cache; struct nfnl_queue *queue; - enum nfnl_queue_copy_mode copy_mode; + int copy_mode; uint32_t copy_range; int err = 1; int family; From a45fca9a586d6b4452725b1c405c1ee93dfe68ad Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Tue, 26 Aug 2014 01:09:09 +0200 Subject: [PATCH 2/5] xfrm: Remove unused function __assign_addr() Signed-off-by: Thomas Graf Signed-off-by: Thomas Haller --- lib/xfrm/sp.c | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/lib/xfrm/sp.c b/lib/xfrm/sp.c index cf16297..e6ab195 100644 --- a/lib/xfrm/sp.c +++ b/lib/xfrm/sp.c @@ -1296,21 +1296,6 @@ int xfrmnl_sp_set_mark (struct xfrmnl_sp* sp, unsigned int value, unsigned int m return 0; } -static inline int __assign_addr(struct xfrmnl_sp* sp, struct nl_addr **pos, - struct nl_addr *new, int flag) -{ - if (*pos) - nl_addr_put(*pos); - - nl_addr_get(new); - *pos = new; - - sp->ce_mask |= flag; - - return 0; -} - - /** @} */ static struct nl_object_ops xfrm_sp_obj_ops = { From 485cefd66562ddf8852aa20895062633f42ef1d0 Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Tue, 26 Aug 2014 01:09:10 +0200 Subject: [PATCH 3/5] nf: Remove unused function htonll() Signed-off-by: Thomas Graf Signed-off-by: Thomas Haller --- lib/netfilter/ct.c | 8 -------- 1 file changed, 8 deletions(-) diff --git a/lib/netfilter/ct.c b/lib/netfilter/ct.c index 36a83db..903c584 100644 --- a/lib/netfilter/ct.c +++ b/lib/netfilter/ct.c @@ -35,19 +35,11 @@ static uint64_t ntohll(uint64_t x) { return x; } -static uint64_t htonll(uint64_t x) -{ - return x; -} #elif __BYTE_ORDER == __LITTLE_ENDIAN static uint64_t ntohll(uint64_t x) { return bswap_64(x); } -static uint64_t htonll(uint64_t x) -{ - return bswap_64(x); -} #endif static struct nla_policy ct_policy[CTA_MAX+1] = { From c231aa4159b837b18c1b5ca8fb4bf17b8d467003 Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Tue, 26 Aug 2014 01:09:11 +0200 Subject: [PATCH 4/5] xfrm: Remove unused variable sp_id and sa_id Cc: Sruthi Yellamraju Signed-off-by: Thomas Graf Signed-off-by: Thomas Haller --- lib/xfrm/sa.c | 2 -- lib/xfrm/sp.c | 2 -- 2 files changed, 4 deletions(-) diff --git a/lib/xfrm/sa.c b/lib/xfrm/sa.c index 07633e5..9b5ea9d 100644 --- a/lib/xfrm/sa.c +++ b/lib/xfrm/sa.c @@ -655,7 +655,6 @@ int xfrmnl_sa_parse(struct nlmsghdr *n, struct xfrmnl_sa **result) struct nlattr *tb[XFRMA_MAX + 1]; struct xfrm_usersa_info* sa_info; struct xfrm_user_expire* ue; - struct xfrm_usersa_id* sa_id; int len, err; struct nl_addr* addr; @@ -675,7 +674,6 @@ int xfrmnl_sa_parse(struct nlmsghdr *n, struct xfrmnl_sa **result) } else if (n->nlmsg_type == XFRM_MSG_DELSA) { - sa_id = nlmsg_data(n); sa_info = (struct xfrm_usersa_info*)(nlmsg_data(n) + sizeof (struct xfrm_usersa_id) + NLA_HDRLEN); } else diff --git a/lib/xfrm/sp.c b/lib/xfrm/sp.c index e6ab195..76cdc61 100644 --- a/lib/xfrm/sp.c +++ b/lib/xfrm/sp.c @@ -518,7 +518,6 @@ int xfrmnl_sp_parse(struct nlmsghdr *n, struct xfrmnl_sp **result) struct xfrmnl_sp *sp; struct nlattr *tb[XFRMA_MAX + 1]; struct xfrm_userpolicy_info *sp_info; - struct xfrm_userpolicy_id *sp_id; int len, err; struct nl_addr* addr; @@ -531,7 +530,6 @@ int xfrmnl_sp_parse(struct nlmsghdr *n, struct xfrmnl_sp **result) sp->ce_msgtype = n->nlmsg_type; if (n->nlmsg_type == XFRM_MSG_DELPOLICY) { - sp_id = nlmsg_data(n); sp_info = (struct xfrm_userpolicy_info*)(nlmsg_data(n) + sizeof (struct xfrm_userpolicy_id) + NLA_HDRLEN); } else From 340d5d69c41bd35ee8b84d40b30f511bd24d5aab Mon Sep 17 00:00:00 2001 From: Thomas Graf Date: Tue, 26 Aug 2014 01:09:12 +0200 Subject: [PATCH 5/5] src: Silence all warnings Signed-off-by: Thomas Graf Signed-off-by: Thomas Haller --- src/nf-log.c | 3 +-- src/nf-queue.c | 3 +-- src/nl-monitor.c | 3 +-- src/nl-neightbl-list.c | 4 ++-- src/nl-route-get.c | 7 ++----- src/nl-rule-list.c | 4 ++-- 6 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/nf-log.c b/src/nf-log.c index c0cffe0..1e2c1e4 100644 --- a/src/nf-log.c +++ b/src/nf-log.c @@ -52,7 +52,6 @@ int main(int argc, char *argv[]) { struct nl_sock *nf_sock; struct nl_sock *rt_sock; - struct nl_cache *link_cache; struct nfnl_log *log; int copy_mode; uint32_t copy_range; @@ -116,7 +115,7 @@ int main(int argc, char *argv[]) rt_sock = nl_cli_alloc_socket(); nl_cli_connect(rt_sock, NETLINK_ROUTE); - link_cache = nl_cli_link_alloc_cache(rt_sock); + nl_cli_link_alloc_cache(rt_sock); while (1) { fd_set rfds; diff --git a/src/nf-queue.c b/src/nf-queue.c index 7151381..b043c80 100644 --- a/src/nf-queue.c +++ b/src/nf-queue.c @@ -60,7 +60,6 @@ static int event_input(struct nl_msg *msg, void *arg) int main(int argc, char *argv[]) { struct nl_sock *rt_sock; - struct nl_cache *link_cache; struct nfnl_queue *queue; int copy_mode; uint32_t copy_range; @@ -116,7 +115,7 @@ int main(int argc, char *argv[]) rt_sock = nl_cli_alloc_socket(); nl_cli_connect(rt_sock, NETLINK_ROUTE); - link_cache = nl_cli_link_alloc_cache(rt_sock); + nl_cli_link_alloc_cache(rt_sock); nl_socket_set_buffer_size(nf_sock, 1024*127, 1024*127); diff --git a/src/nl-monitor.c b/src/nl-monitor.c index fdf6497..16ecac0 100644 --- a/src/nl-monitor.c +++ b/src/nl-monitor.c @@ -35,7 +35,6 @@ static int event_input(struct nl_msg *msg, void *arg) int main(int argc, char *argv[]) { struct nl_sock *sock; - struct nl_cache *link_cache; int err = 1; int i, idx; @@ -92,7 +91,7 @@ int main(int argc, char *argv[]) fprintf(stderr, "Warning: Unknown group: %s\n", argv[idx]); } - link_cache = nl_cli_link_alloc_cache(sock); + nl_cli_link_alloc_cache(sock); while (1) { fd_set rfds; diff --git a/src/nl-neightbl-list.c b/src/nl-neightbl-list.c index 5010b92..4c4230f 100644 --- a/src/nl-neightbl-list.c +++ b/src/nl-neightbl-list.c @@ -28,7 +28,7 @@ static void print_usage(void) int main(int argc, char *argv[]) { struct nl_sock *sock; - struct nl_cache *link_cache, *neightbl_cache; + struct nl_cache *neightbl_cache; struct nl_dump_params params = { .dp_type = NL_DUMP_LINE, .dp_fd = stdout, @@ -36,7 +36,7 @@ int main(int argc, char *argv[]) sock = nl_cli_alloc_socket(); nl_cli_connect(sock, NETLINK_ROUTE); - link_cache = nl_cli_link_alloc_cache(sock); + nl_cli_link_alloc_cache(sock); neightbl_cache = nl_cli_alloc_cache(sock, "neighbour table", rtnl_neightbl_alloc_cache); diff --git a/src/nl-route-get.c b/src/nl-route-get.c index 9d9a448..1ee47e4 100644 --- a/src/nl-route-get.c +++ b/src/nl-route-get.c @@ -43,7 +43,6 @@ static int cb(struct nl_msg *msg, void *arg) int main(int argc, char *argv[]) { struct nl_sock *sock; - struct nl_cache *link_cache, *route_cache; struct nl_addr *dst; int err = 1; @@ -52,8 +51,8 @@ int main(int argc, char *argv[]) sock = nl_cli_alloc_socket(); nl_cli_connect(sock, NETLINK_ROUTE); - link_cache = nl_cli_link_alloc_cache(sock); - route_cache = nl_cli_route_alloc_cache(sock, 0); + nl_cli_link_alloc_cache(sock); + nl_cli_route_alloc_cache(sock, 0); dst = nl_cli_addr_parse(argv[1], AF_INET); @@ -83,7 +82,5 @@ int main(int argc, char *argv[]) nl_cli_fatal(err, "%s", nl_geterror(err)); } - //nl_cache_dump(route_cache, ¶ms); - return 0; } diff --git a/src/nl-rule-list.c b/src/nl-rule-list.c index 8b474fa..7c450e2 100644 --- a/src/nl-rule-list.c +++ b/src/nl-rule-list.c @@ -34,7 +34,7 @@ int main(int argc, char *argv[]) { struct nl_sock *sock; struct rtnl_rule *rule; - struct nl_cache *link_cache, *rule_cache; + struct nl_cache *rule_cache; struct nl_dump_params params = { .dp_fd = stdout, .dp_type = NL_DUMP_LINE, @@ -42,7 +42,7 @@ int main(int argc, char *argv[]) sock = nl_cli_alloc_socket(); nl_cli_connect(sock, NETLINK_ROUTE); - link_cache = nl_cli_link_alloc_cache(sock); + nl_cli_link_alloc_cache(sock); rule_cache = nl_cli_rule_alloc_cache(sock); rule = nl_cli_rule_alloc();