diff --git a/Makefile.am b/Makefile.am index 778d57ef..d64a6efd 100644 --- a/Makefile.am +++ b/Makefile.am @@ -271,7 +271,6 @@ noinst_HEADERS = \ include/linux-private/linux/tc_ematch/tc_em_meta.h \ include/linux-private/linux/veth.h \ include/linux-private/linux/xfrm.h \ - include/netlink-private/netlink.h \ include/nl-aux-core/nl-core.h \ include/nl-aux-route/nl-route.h \ include/nl-default.h \ diff --git a/include/base/nl-base-utils.h b/include/base/nl-base-utils.h index e02b5f4b..4e7ad7a4 100644 --- a/include/base/nl-base-utils.h +++ b/include/base/nl-base-utils.h @@ -8,6 +8,9 @@ #include #include +#include +#include +#include #include #include #include @@ -17,6 +20,12 @@ #include #include +#ifndef DISABLE_PTHREADS +#include +#endif + +/*****************************************************************************/ + #if __BYTE_ORDER == __BIG_ENDIAN #define ntohll(x) (x) #elif __BYTE_ORDER == __LITTLE_ENDIAN @@ -178,9 +187,14 @@ #define _NL_N_ELEMENTS(arr) (sizeof(arr) / sizeof((arr)[0])) +#define ARRAY_SIZE(arr) _NL_N_ELEMENTS(arr) + /*****************************************************************************/ -extern const char *nl_strerror_l(int err); +/* This is also defined in stddef.h */ +#ifndef offsetof +#define offsetof(TYPE, MEMBER) ((size_t) & ((TYPE *)0)->MEMBER) +#endif /*****************************************************************************/ @@ -713,4 +727,98 @@ static inline char *_nl_inet_ntop_dup(int addr_family, const void *addr) #define _nl_auto_free _nl_auto(_nl_auto_free_fcn) _NL_AUTO_DEFINE_FCN_VOID0(void *, _nl_auto_free_fcn, free); +/*****************************************************************************/ + +#define NSEC_PER_SEC 1000000000L + +struct trans_tbl { + uint64_t i; + const char *a; +}; + +#define __ADD(id, name) \ + { \ + .i = id, .a = #name \ + } + +#define BUG() \ + do { \ + fprintf(stderr, "BUG at file position %s:%d:%s\n", __FILE__, \ + __LINE__, __func__); \ + assert(0); \ + } while (0) + +#define BUG_ON(condition) \ + do { \ + if (condition) \ + BUG(); \ + } while (0) + +#define APPBUG(msg) \ + do { \ + fprintf(stderr, "APPLICATION BUG: %s:%d:%s: %s\n", __FILE__, \ + __LINE__, __func__, msg); \ + assert(0); \ + } while (0) + +/*****************************************************************************/ + +#ifndef DISABLE_PTHREADS +#define NL_LOCK(NAME) pthread_mutex_t(NAME) = PTHREAD_MUTEX_INITIALIZER +#define NL_RW_LOCK(NAME) pthread_rwlock_t(NAME) = PTHREAD_RWLOCK_INITIALIZER + +static inline void nl_lock(pthread_mutex_t *lock) +{ + pthread_mutex_lock(lock); +} + +static inline void nl_unlock(pthread_mutex_t *lock) +{ + pthread_mutex_unlock(lock); +} + +static inline void nl_read_lock(pthread_rwlock_t *lock) +{ + pthread_rwlock_rdlock(lock); +} + +static inline void nl_read_unlock(pthread_rwlock_t *lock) +{ + pthread_rwlock_unlock(lock); +} + +static inline void nl_write_lock(pthread_rwlock_t *lock) +{ + pthread_rwlock_wrlock(lock); +} + +static inline void nl_write_unlock(pthread_rwlock_t *lock) +{ + pthread_rwlock_unlock(lock); +} + +#else +#define NL_LOCK(NAME) int __unused_lock_##NAME __attribute__((unused)) +#define NL_RW_LOCK(NAME) int __unused_lock_##NAME __attribute__((unused)) + +#define nl_lock(LOCK) \ + do { \ + } while (0) +#define nl_unlock(LOCK) \ + do { \ + } while (0) +#define nl_read_lock(LOCK) \ + do { \ + } while (0) +#define nl_read_unlock(LOCK) \ + do { \ + } while (0) +#define nl_write_lock(LOCK) \ + do { \ + } while (0) +#define nl_write_unlock(LOCK) \ + do { \ + } while (0) +#endif + #endif /* __NETLINK_BASE_NL_BASE_UTILS_H__ */ diff --git a/include/netlink-private/netlink.h b/include/netlink-private/netlink.h deleted file mode 100644 index 7c636054..00000000 --- a/include/netlink-private/netlink.h +++ /dev/null @@ -1,220 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-only */ -/* - * Copyright (c) 2003-2013 Thomas Graf - */ - -#ifndef NETLINK_LOCAL_H_ -#define NETLINK_LOCAL_H_ - -#include "nl-default.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#ifndef SOL_NETLINK -#define SOL_NETLINK 270 -#endif - -#include - -/* local header copies */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef DISABLE_PTHREADS -#include -#endif - -#include "base/nl-base-utils.h" - -#include -#include -#include -#include - -#include "nl-shared-core/cache-api.h" -#include "nl-aux-core/nl-core.h" - -#define NSEC_PER_SEC 1000000000L - -struct trans_tbl { - uint64_t i; - const char *a; -}; - -#define __ADD(id, name) { .i = id, .a = #name } - -struct trans_list { - int i; - char *a; - struct nl_list_head list; -}; - -#ifdef NL_DEBUG -#define NL_DBG(LVL,FMT,ARG...) \ - do { \ - if (LVL <= nl_debug) { \ - int _errsv = errno; \ - fprintf(stderr, \ - "DBG<" #LVL ">%20s:%-4u %s: " FMT, \ - __FILE__, __LINE__, \ - __func__, ##ARG); \ - errno = _errsv; \ - } \ - } while (0) -#else /* NL_DEBUG */ -#define NL_DBG(LVL,FMT,ARG...) do { } while(0) -#endif /* NL_DEBUG */ - -#define BUG() \ - do { \ - fprintf(stderr, "BUG at file position %s:%d:%s\n", \ - __FILE__, __LINE__, __func__); \ - assert(0); \ - } while (0) - -#define BUG_ON(condition) \ - do { \ - if (condition) \ - BUG(); \ - } while (0) - - -#define APPBUG(msg) \ - do { \ - fprintf(stderr, "APPLICATION BUG: %s:%d:%s: %s\n", \ - __FILE__, __LINE__, __func__, msg); \ - assert(0); \ - } while(0) - -extern int __nl_read_num_str_file(const char *path, - int (*cb)(long, const char *)); - -extern int __trans_list_add(int, const char *, struct nl_list_head *); -extern void __trans_list_clear(struct nl_list_head *); - -extern char *__type2str(int, char *, size_t, const struct trans_tbl *, size_t); -extern int __str2type(const char *, const struct trans_tbl *, size_t); - -extern char *__list_type2str(int, char *, size_t, struct nl_list_head *); -extern int __list_str2type(const char *, struct nl_list_head *); - -extern char *__flags2str(int, char *, size_t, const struct trans_tbl *, size_t); -extern int __str2flags(const char *, const struct trans_tbl *, size_t); - -extern void dump_from_ops(struct nl_object *, struct nl_dump_params *); -extern struct rtnl_link *link_lookup(struct nl_cache *cache, int ifindex); - -#define ARRAY_SIZE(X) (sizeof(X) / sizeof((X)[0])) - -/* This is also defined in stddef.h */ -#ifndef offsetof -#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) -#endif - -extern int nl_cache_parse(struct nl_cache_ops *, struct sockaddr_nl *, - struct nlmsghdr *, struct nl_parser_param *); - - -#define GENL_FAMILY(id, name) \ - { \ - { id, NL_ACT_UNSPEC, name }, \ - END_OF_MSGTYPES_LIST, \ - } - -static inline int build_sysconf_path(char **strp, const char *filename) -{ - char *sysconfdir; - - sysconfdir = getenv("NLSYSCONFDIR"); - - if (!sysconfdir) - sysconfdir = SYSCONFDIR; - - return asprintf(strp, "%s/%s", sysconfdir, filename); -} - -#ifndef DISABLE_PTHREADS -#define NL_LOCK(NAME) pthread_mutex_t (NAME) = PTHREAD_MUTEX_INITIALIZER -#define NL_RW_LOCK(NAME) pthread_rwlock_t (NAME) = PTHREAD_RWLOCK_INITIALIZER - -static inline void nl_lock(pthread_mutex_t *lock) -{ - pthread_mutex_lock(lock); -} - -static inline void nl_unlock(pthread_mutex_t *lock) -{ - pthread_mutex_unlock(lock); -} - -static inline void nl_read_lock(pthread_rwlock_t *lock) -{ - pthread_rwlock_rdlock(lock); -} - -static inline void nl_read_unlock(pthread_rwlock_t *lock) -{ - pthread_rwlock_unlock(lock); -} - -static inline void nl_write_lock(pthread_rwlock_t *lock) -{ - pthread_rwlock_wrlock(lock); -} - -static inline void nl_write_unlock(pthread_rwlock_t *lock) -{ - pthread_rwlock_unlock(lock); -} - -#else -#define NL_LOCK(NAME) int __unused_lock_ ##NAME __attribute__((unused)) -#define NL_RW_LOCK(NAME) int __unused_lock_ ##NAME __attribute__((unused)) - -#define nl_lock(LOCK) do { } while(0) -#define nl_unlock(LOCK) do { } while(0) -#define nl_read_lock(LOCK) do { } while(0) -#define nl_read_unlock(LOCK) do { } while(0) -#define nl_write_lock(LOCK) do { } while(0) -#define nl_write_unlock(LOCK) do { } while(0) -#endif - -static inline int rtnl_tc_calc_txtime64(int bufsize, uint64_t rate) -{ - return ((double) bufsize / (double) rate) * 1000000.0; -} - -static inline int rtnl_tc_calc_bufsize64(int txtime, uint64_t rate) -{ - return ((double) txtime * (double) rate) / 1000000.0; -} - -#endif diff --git a/include/nl-aux-core/nl-core.h b/include/nl-aux-core/nl-core.h index 1a02aaa9..c336e34d 100644 --- a/include/nl-aux-core/nl-core.h +++ b/include/nl-aux-core/nl-core.h @@ -5,6 +5,22 @@ #include "base/nl-base-utils.h" +#ifdef NL_DEBUG +#define NL_DBG(LVL, FMT, ARG...) \ + do { \ + if (LVL <= nl_debug) { \ + int _errsv = errno; \ + fprintf(stderr, "DBG<" #LVL ">%20s:%-4u %s: " FMT, \ + __FILE__, __LINE__, __func__, ##ARG); \ + errno = _errsv; \ + } \ + } while (0) +#else /* NL_DEBUG */ +#define NL_DBG(LVL, FMT, ARG...) \ + do { \ + } while (0) +#endif /* NL_DEBUG */ + struct nl_addr; void nl_addr_put(struct nl_addr *); #define _nl_auto_nl_addr _nl_auto(_nl_auto_nl_addr_fcn) diff --git a/include/nl-shared-core/cache-api.h b/include/nl-shared-core/cache-api.h index 38662b71..6491651f 100644 --- a/include/nl-shared-core/cache-api.h +++ b/include/nl-shared-core/cache-api.h @@ -258,6 +258,29 @@ struct nl_cache_ops /** @} */ +struct nl_cache { + struct nl_list_head c_items; + int c_nitems; + int c_iarg1; + int c_iarg2; + int c_refcnt; + unsigned int c_flags; + struct nl_hash_table *hashtable; + struct nl_cache_ops *c_ops; +}; + +static inline const char *nl_cache_name(struct nl_cache *cache) +{ + return cache->c_ops ? cache->c_ops->co_name : "unknown"; +} + +struct nl_cache_assoc { + struct nl_cache *ca_cache; + change_func_t ca_change; + change_func_v2_t ca_change_v2; + void *ca_change_data; +}; + #ifdef __cplusplus } #endif diff --git a/include/nl-shared-core/nl-core.h b/include/nl-shared-core/nl-core.h index d4866b26..d7bec85c 100644 --- a/include/nl-shared-core/nl-core.h +++ b/include/nl-shared-core/nl-core.h @@ -32,29 +32,6 @@ static inline int wait_for_ack(struct nl_sock *sk) return nl_wait_for_ack(sk); } -struct nl_cache { - struct nl_list_head c_items; - int c_nitems; - int c_iarg1; - int c_iarg2; - int c_refcnt; - unsigned int c_flags; - struct nl_hash_table *hashtable; - struct nl_cache_ops *c_ops; -}; - -static inline const char *nl_cache_name(struct nl_cache *cache) -{ - return cache->c_ops ? cache->c_ops->co_name : "unknown"; -} - -struct nl_cache_assoc { - struct nl_cache *ca_cache; - change_func_t ca_change; - change_func_v2_t ca_change_v2; - void *ca_change_data; -}; - #define LOOSE_COMPARISON 1 #define ID_COMPARISON 2 @@ -87,4 +64,23 @@ struct nl_msg { int nm_refcnt; }; +/*****************************************************************************/ + +extern const char *nl_strerror_l(int err); + +extern int __nl_read_num_str_file(const char *path, + int (*cb)(long, const char *)); + +extern int __trans_list_add(int, const char *, struct nl_list_head *); +extern void __trans_list_clear(struct nl_list_head *); + +extern char *__type2str(int, char *, size_t, const struct trans_tbl *, size_t); +extern int __str2type(const char *, const struct trans_tbl *, size_t); + +extern char *__list_type2str(int, char *, size_t, struct nl_list_head *); +extern int __list_str2type(const char *, struct nl_list_head *); + +extern char *__flags2str(int, char *, size_t, const struct trans_tbl *, size_t); +extern int __str2flags(const char *, const struct trans_tbl *, size_t); + #endif /* __NL_SHARED_CORE_NL_CORE_H__ */ diff --git a/lib/addr.c b/lib/addr.c index 3a15d0ef..673c2df0 100644 --- a/lib/addr.c +++ b/lib/addr.c @@ -28,8 +28,7 @@ #include #include #include - -#include +#include #include "mpls.h" #include "nl-shared-core/nl-core.h" diff --git a/lib/attr.c b/lib/attr.c index f0a12560..58499211 100644 --- a/lib/attr.c +++ b/lib/attr.c @@ -13,9 +13,8 @@ #include #include -#include - #include "nl-shared-core/nl-core.h" +#include "nl-aux-core/nl-core.h" /** * @ingroup msg diff --git a/lib/cache.c b/lib/cache.c index 1f3011eb..89642980 100644 --- a/lib/cache.c +++ b/lib/cache.c @@ -51,10 +51,11 @@ #include #include -#include - +#include "nl-core.h" #include "nl-shared-core/nl-core.h" #include "nl-shared-core/object-api.h" +#include "nl-shared-core/cache-api.h" +#include "nl-aux-core/nl-core.h" /** * @name Access Functions diff --git a/lib/cache_mngr.c b/lib/cache_mngr.c index 73db014d..81bdad19 100644 --- a/lib/cache_mngr.c +++ b/lib/cache_mngr.c @@ -32,9 +32,10 @@ #include #include -#include - +#include "nl-core.h" #include "nl-shared-core/nl-core.h" +#include "nl-shared-core/cache-api.h" +#include "nl-aux-core/nl-core.h" /** @cond SKIP */ struct nl_cache_mngr diff --git a/lib/cache_mngt.c b/lib/cache_mngt.c index c362dcaf..758cb7bc 100644 --- a/lib/cache_mngt.c +++ b/lib/cache_mngt.c @@ -25,10 +25,10 @@ #include #include -#include - #include "nl-shared-core/nl-core.h" #include "nl-shared-core/object-api.h" +#include "nl-shared-core/cache-api.h" +#include "nl-aux-core/nl-core.h" static struct nl_cache_ops *cache_ops; static NL_RW_LOCK(cache_ops_lock); diff --git a/lib/data.c b/lib/data.c index 6f9f25ae..34fca860 100644 --- a/lib/data.c +++ b/lib/data.c @@ -26,10 +26,10 @@ #include #include +#include +#include #include -#include - #include "nl-shared-core/nl-core.h" /** diff --git a/lib/error.c b/lib/error.c index d1a448ae..9b6d8067 100644 --- a/lib/error.c +++ b/lib/error.c @@ -7,8 +7,6 @@ #include -#include - static const char *errmsg[NLE_MAX+1] = { [NLE_SUCCESS] = "Success", [NLE_FAILURE] = "Unspecific failure", diff --git a/lib/fib_lookup/lookup.c b/lib/fib_lookup/lookup.c index 1aaeee3e..12f12936 100644 --- a/lib/fib_lookup/lookup.c +++ b/lib/fib_lookup/lookup.c @@ -21,9 +21,9 @@ #include #include -#include - #include "nl-shared-core/object-api.h" +#include "nl-shared-core/cache-api.h" +#include "nl-shared-core/nl-core.h" /** @cond SKIP */ struct flnl_result diff --git a/lib/fib_lookup/request.c b/lib/fib_lookup/request.c index ee4baef8..67a7b7cc 100644 --- a/lib/fib_lookup/request.c +++ b/lib/fib_lookup/request.c @@ -18,8 +18,6 @@ #include #include -#include - #include "nl-shared-core/nl-core.h" #include "nl-shared-core/object-api.h" diff --git a/lib/genl/ctrl.c b/lib/genl/ctrl.c index 689da732..dd5f1097 100644 --- a/lib/genl/ctrl.c +++ b/lib/genl/ctrl.c @@ -522,6 +522,12 @@ static struct genl_ops genl_ops = { extern struct nl_object_ops genl_family_ops; +#define GENL_FAMILY(id, name) \ + { \ + { id, NL_ACT_UNSPEC, name }, \ + END_OF_MSGTYPES_LIST, \ + } + static struct nl_cache_ops genl_ctrl_ops = { .co_name = "genl/family", .co_hdrsize = GENL_HDRSIZE(0), diff --git a/lib/genl/family.c b/lib/genl/family.c index cb0ec6dc..53c9cbd7 100644 --- a/lib/genl/family.c +++ b/lib/genl/family.c @@ -21,6 +21,7 @@ #include "nl-genl.h" #include "nl-shared-core/object-api.h" +#include "nl-shared-core/nl-core.h" /** @cond SKIP */ struct genl_family_op diff --git a/lib/genl/genl.c b/lib/genl/genl.c index 769c1e32..2e52aae1 100644 --- a/lib/genl/genl.c +++ b/lib/genl/genl.c @@ -16,6 +16,7 @@ #include #include "nl-genl.h" +#include "nl-aux-core/nl-core.h" /** * @name Generic Netlink Socket diff --git a/lib/genl/nl-genl.h b/lib/genl/nl-genl.h index 194466d3..0d702b09 100644 --- a/lib/genl/nl-genl.h +++ b/lib/genl/nl-genl.h @@ -8,9 +8,8 @@ #include -#include - #include "nl-shared-core/object-api.h" +#include "nl-shared-core/cache-api.h" #define GENL_HDRSIZE(hdrlen) (GENL_HDRLEN + (hdrlen)) diff --git a/lib/handlers.c b/lib/handlers.c index d921b3f3..5d1789cc 100644 --- a/lib/handlers.c +++ b/lib/handlers.c @@ -26,9 +26,8 @@ #include #include -#include - #include "nl-core.h" +#include "nl-shared-core/nl-core.h" static void print_header_content(FILE *ofd, struct nlmsghdr *n) { diff --git a/lib/hashtable.c b/lib/hashtable.c index f6d49be8..17df838c 100644 --- a/lib/hashtable.c +++ b/lib/hashtable.c @@ -11,7 +11,7 @@ #include #include -#include +#include "nl-aux-core/nl-core.h" /** * @ingroup core_types diff --git a/lib/idiag/idiag.c b/lib/idiag/idiag.c index 69a650e5..baca1c27 100644 --- a/lib/idiag/idiag.c +++ b/lib/idiag/idiag.c @@ -17,7 +17,7 @@ #include #include -#include +#include "nl-shared-core/nl-core.h" /** * @name Socket Creation diff --git a/lib/idiag/idiag_meminfo_obj.c b/lib/idiag/idiag_meminfo_obj.c index 795f3bef..ebb9767d 100644 --- a/lib/idiag/idiag_meminfo_obj.c +++ b/lib/idiag/idiag_meminfo_obj.c @@ -7,8 +7,6 @@ #include -#include - #include "nl-idiag.h" /** diff --git a/lib/idiag/idiag_msg_obj.c b/lib/idiag/idiag_msg_obj.c index f05e87fb..338aa928 100644 --- a/lib/idiag/idiag_msg_obj.c +++ b/lib/idiag/idiag_msg_obj.c @@ -13,10 +13,10 @@ #include #include -#include - #include "nl-idiag.h" #include "nl-shared-core/nl-core.h" +#include "nl-aux-core/nl-core.h" +#include "nl-shared-core/cache-api.h" /** @cond SKIP */ struct idiagnl_msg { diff --git a/lib/idiag/idiag_req_obj.c b/lib/idiag/idiag_req_obj.c index 6d0c0c20..282ca350 100644 --- a/lib/idiag/idiag_req_obj.c +++ b/lib/idiag/idiag_req_obj.c @@ -9,8 +9,9 @@ #include #include - -#include +#include +#include +#include #include "nl-shared-core/object-api.h" diff --git a/lib/idiag/idiag_vegasinfo_obj.c b/lib/idiag/idiag_vegasinfo_obj.c index 0104eb5d..f9e9408e 100644 --- a/lib/idiag/idiag_vegasinfo_obj.c +++ b/lib/idiag/idiag_vegasinfo_obj.c @@ -7,8 +7,6 @@ #include -#include - #include "nl-idiag.h" /** diff --git a/lib/msg.c b/lib/msg.c index 677a2267..78a31646 100644 --- a/lib/msg.c +++ b/lib/msg.c @@ -22,6 +22,8 @@ #include "nl-default.h" +#include + #include #include @@ -29,9 +31,10 @@ #include #include -#include - +#include "nl-core.h" #include "nl-shared-core/nl-core.h" +#include "nl-shared-core/cache-api.h" +#include "nl-aux-core/nl-core.h" static size_t default_msg_size; diff --git a/lib/netfilter/ct.c b/lib/netfilter/ct.c index 3b54b3d7..8473d69a 100644 --- a/lib/netfilter/ct.c +++ b/lib/netfilter/ct.c @@ -24,10 +24,9 @@ #include #include -#include - #include "nl-netfilter.h" #include "nl-shared-core/nl-core.h" +#include "nl-shared-core/cache-api.h" static struct nl_cache_ops nfnl_ct_ops; diff --git a/lib/netfilter/ct_obj.c b/lib/netfilter/ct_obj.c index 59ade2cd..f4537039 100644 --- a/lib/netfilter/ct_obj.c +++ b/lib/netfilter/ct_obj.c @@ -16,8 +16,6 @@ #include #include -#include - #include "nl-shared-core/object-api.h" #include "nl-netfilter.h" #include "nl-shared-core/nl-core.h" diff --git a/lib/netfilter/exp.c b/lib/netfilter/exp.c index b69ae5b9..43335f78 100644 --- a/lib/netfilter/exp.c +++ b/lib/netfilter/exp.c @@ -25,10 +25,9 @@ #include #include -#include - #include "nl-netfilter.h" #include "nl-shared-core/nl-core.h" +#include "nl-shared-core/cache-api.h" static struct nl_cache_ops nfnl_exp_ops; diff --git a/lib/netfilter/exp_obj.c b/lib/netfilter/exp_obj.c index c24eacb4..7c1750c4 100644 --- a/lib/netfilter/exp_obj.c +++ b/lib/netfilter/exp_obj.c @@ -18,8 +18,6 @@ #include #include -#include - #include "nl-shared-core/object-api.h" #include "nl-netfilter.h" #include "nl-shared-core/nl-core.h" diff --git a/lib/netfilter/log.c b/lib/netfilter/log.c index c67de169..5556df80 100644 --- a/lib/netfilter/log.c +++ b/lib/netfilter/log.c @@ -21,9 +21,8 @@ #include #include -#include - #include "nl-shared-core/nl-core.h" +#include "nl-shared-core/cache-api.h" /** * @name Log Commands diff --git a/lib/netfilter/log_msg.c b/lib/netfilter/log_msg.c index 558a0811..3e3ac604 100644 --- a/lib/netfilter/log_msg.c +++ b/lib/netfilter/log_msg.c @@ -23,9 +23,8 @@ #include #include -#include - #include "nl-netfilter.h" +#include "nl-shared-core/cache-api.h" static struct nla_policy log_msg_policy[NFULA_MAX+1] = { [NFULA_PACKET_HDR] = { diff --git a/lib/netfilter/log_msg_obj.c b/lib/netfilter/log_msg_obj.c index a7b2c2e3..b3c140a3 100644 --- a/lib/netfilter/log_msg_obj.c +++ b/lib/netfilter/log_msg_obj.c @@ -11,8 +11,7 @@ #include #include #include - -#include +#include #include "nl-shared-core/object-api.h" #include "nl-netfilter.h" diff --git a/lib/netfilter/log_obj.c b/lib/netfilter/log_obj.c index cc140692..f14ca121 100644 --- a/lib/netfilter/log_obj.c +++ b/lib/netfilter/log_obj.c @@ -11,9 +11,9 @@ #include #include -#include - #include "nl-shared-core/object-api.h" +#include "nl-shared-core/cache-api.h" +#include "nl-shared-core/nl-core.h" /** @cond SKIP */ struct nfnl_log { diff --git a/lib/netfilter/netfilter.c b/lib/netfilter/netfilter.c index 908c7003..f008d9d0 100644 --- a/lib/netfilter/netfilter.c +++ b/lib/netfilter/netfilter.c @@ -9,7 +9,7 @@ #include -#include +#include "nl-shared-core/nl-core.h" static const struct trans_tbl nfnl_verdicts[] = { __ADD(NF_DROP, NF_DROP), diff --git a/lib/netfilter/nfnl.c b/lib/netfilter/nfnl.c index 63113294..c70827b8 100644 --- a/lib/netfilter/nfnl.c +++ b/lib/netfilter/nfnl.c @@ -61,8 +61,10 @@ #include #include +#include +#include -#include +#include "nl-aux-core/nl-core.h" /** * @name Socket Creating diff --git a/lib/netfilter/queue.c b/lib/netfilter/queue.c index 1ef7f3a9..6e926a4a 100644 --- a/lib/netfilter/queue.c +++ b/lib/netfilter/queue.c @@ -20,9 +20,8 @@ #include #include -#include - #include "nl-shared-core/nl-core.h" +#include "nl-shared-core/cache-api.h" struct nl_sock *nfnl_queue_socket_alloc(void) { diff --git a/lib/netfilter/queue_msg.c b/lib/netfilter/queue_msg.c index 03d42fb8..5f5d3fac 100644 --- a/lib/netfilter/queue_msg.c +++ b/lib/netfilter/queue_msg.c @@ -21,10 +21,9 @@ #include #include -#include - #include "nl-netfilter.h" #include "nl-shared-core/nl-core.h" +#include "nl-shared-core/cache-api.h" static struct nl_cache_ops nfnl_queue_msg_ops; diff --git a/lib/netfilter/queue_msg_obj.c b/lib/netfilter/queue_msg_obj.c index ea4e3c0d..98d1c518 100644 --- a/lib/netfilter/queue_msg_obj.c +++ b/lib/netfilter/queue_msg_obj.c @@ -10,10 +10,10 @@ #include #include #include - -#include +#include #include "nl-netfilter.h" +#include "nl-shared-core/nl-core.h" /** @cond SKIP */ #define QUEUE_MSG_ATTR_GROUP (1UL << 0) diff --git a/lib/netfilter/queue_obj.c b/lib/netfilter/queue_obj.c index 58526925..50e67689 100644 --- a/lib/netfilter/queue_obj.c +++ b/lib/netfilter/queue_obj.c @@ -15,9 +15,8 @@ #include #include -#include - #include "nl-shared-core/object-api.h" +#include "nl-shared-core/nl-core.h" /** @cond SKIP */ struct nfnl_queue { diff --git a/lib/nl-core.h b/lib/nl-core.h index 182e213b..42d76299 100644 --- a/lib/nl-core.h +++ b/lib/nl-core.h @@ -6,8 +6,6 @@ #ifndef __LIB_NL_CORE_H__ #define __LIB_NL_CORE_H__ -#include - struct nl_cb { nl_recvmsg_msg_cb_t cb_set[NL_CB_TYPE_MAX+1]; @@ -54,4 +52,9 @@ uint32_t _nl_socket_set_local_port_no_release(struct nl_sock *sk, int generate_o void _nl_socket_used_ports_release_all(const uint32_t *used_ports); void _nl_socket_used_ports_set(uint32_t *used_ports, uint32_t port); +extern int nl_cache_parse(struct nl_cache_ops *, struct sockaddr_nl *, + struct nlmsghdr *, struct nl_parser_param *); + +extern void dump_from_ops(struct nl_object *, struct nl_dump_params *); + #endif /* __LIB_NL_CORE_H__ */ diff --git a/lib/nl.c b/lib/nl.c index 2fdaab58..7afa9614 100644 --- a/lib/nl.c +++ b/lib/nl.c @@ -29,10 +29,10 @@ #include #include -#include - #include "nl-core.h" #include "nl-shared-core/nl-core.h" +#include "nl-aux-core/nl-core.h" +#include "nl-shared-core/cache-api.h" /** * @defgroup core_types Data Types diff --git a/lib/object.c b/lib/object.c index e7607523..cdb99eef 100644 --- a/lib/object.c +++ b/lib/object.c @@ -28,10 +28,11 @@ #include #include -#include - +#include "nl-core.h" #include "nl-shared-core/nl-core.h" #include "nl-shared-core/object-api.h" +#include "nl-shared-core/cache-api.h" +#include "nl-aux-core/nl-core.h" static inline struct nl_object_ops *obj_ops(struct nl_object *obj) { diff --git a/lib/route/act.c b/lib/route/act.c index 8e096099..b8aa55df 100644 --- a/lib/route/act.c +++ b/lib/route/act.c @@ -16,11 +16,10 @@ #include #include -#include - #include "nl-route.h" #include "tc-api.h" #include "nl-shared-core/object-api.h" +#include "nl-shared-core/cache-api.h" static struct nl_object_ops act_obj_ops; static struct nl_cache_ops rtnl_act_ops; diff --git a/lib/route/act/gact.c b/lib/route/act/gact.c index 6ce25a73..2e04c5a3 100644 --- a/lib/route/act/gact.c +++ b/lib/route/act/gact.c @@ -17,8 +17,6 @@ #include #include -#include - #include "tc-api.h" struct rtnl_gact { diff --git a/lib/route/act/mirred.c b/lib/route/act/mirred.c index a857fbe3..72ead6b0 100644 --- a/lib/route/act/mirred.c +++ b/lib/route/act/mirred.c @@ -17,8 +17,6 @@ #include #include -#include - #include "tc-api.h" struct rtnl_mirred { diff --git a/lib/route/act/nat.c b/lib/route/act/nat.c index 137bcff1..ffc9d2be 100644 --- a/lib/route/act/nat.c +++ b/lib/route/act/nat.c @@ -18,8 +18,6 @@ #include #include -#include - #include "tc-api.h" static struct nla_policy nat_policy[TCA_NAT_MAX + 1] = { diff --git a/lib/route/act/skbedit.c b/lib/route/act/skbedit.c index 588f053e..32a3506f 100644 --- a/lib/route/act/skbedit.c +++ b/lib/route/act/skbedit.c @@ -17,8 +17,6 @@ #include #include -#include - #include "nl-route.h" #include "tc-api.h" diff --git a/lib/route/act/vlan.c b/lib/route/act/vlan.c index f86a35db..71f16e52 100644 --- a/lib/route/act/vlan.c +++ b/lib/route/act/vlan.c @@ -19,8 +19,6 @@ #include #include -#include - #include "tc-api.h" struct rtnl_vlan diff --git a/lib/route/addr.c b/lib/route/addr.c index 190e5fa9..cb2c7818 100644 --- a/lib/route/addr.c +++ b/lib/route/addr.c @@ -109,10 +109,9 @@ #include #include -#include - #include "nl-route.h" #include "nl-shared-core/nl-core.h" +#include "nl-shared-core/cache-api.h" /** @cond SKIP */ struct rtnl_addr_cacheinfo { diff --git a/lib/route/class.c b/lib/route/class.c index 34f02769..29ba8094 100644 --- a/lib/route/class.c +++ b/lib/route/class.c @@ -17,8 +17,6 @@ #include #include -#include - #include "nl-route.h" #include "tc-api.h" diff --git a/lib/route/classid.c b/lib/route/classid.c index 2740b040..f5a75f07 100644 --- a/lib/route/classid.c +++ b/lib/route/classid.c @@ -11,11 +11,15 @@ #include "nl-default.h" +#include +#include + #include #include #include -#include +#include "nl-route.h" +#include "nl-aux-core/nl-core.h" struct classid_map { diff --git a/lib/route/cls.c b/lib/route/cls.c index f44a55d7..8f970b12 100644 --- a/lib/route/cls.c +++ b/lib/route/cls.c @@ -11,13 +11,13 @@ #include "nl-default.h" +#include + #include #include #include #include -#include - #include "nl-route.h" #include "tc-api.h" diff --git a/lib/route/cls/basic.c b/lib/route/cls/basic.c index b1e39261..ed83ca1c 100644 --- a/lib/route/cls/basic.c +++ b/lib/route/cls/basic.c @@ -24,8 +24,6 @@ #include #include -#include - #include "tc-api.h" struct rtnl_basic diff --git a/lib/route/cls/cgroup.c b/lib/route/cls/cgroup.c index cd894831..3534281a 100644 --- a/lib/route/cls/cgroup.c +++ b/lib/route/cls/cgroup.c @@ -19,8 +19,6 @@ #include #include -#include - #include "tc-api.h" /** @cond SKIP */ diff --git a/lib/route/cls/ematch.c b/lib/route/cls/ematch.c index 25276238..5a5a2104 100644 --- a/lib/route/cls/ematch.c +++ b/lib/route/cls/ematch.c @@ -19,9 +19,8 @@ #include #include -#include - #include "nl-route.h" +#include "nl-aux-core/nl-core.h" #include "ematch_syntax.h" #include "ematch_grammar.h" diff --git a/lib/route/cls/ematch/cmp.c b/lib/route/cls/ematch/cmp.c index d0eb38c3..9feb2e58 100644 --- a/lib/route/cls/ematch/cmp.c +++ b/lib/route/cls/ematch/cmp.c @@ -18,8 +18,6 @@ #include #include -#include - void rtnl_ematch_cmp_set(struct rtnl_ematch *e, struct tcf_em_cmp *cfg) { memcpy(rtnl_ematch_data(e), cfg, sizeof(*cfg)); diff --git a/lib/route/cls/ematch/container.c b/lib/route/cls/ematch/container.c index 71aba58d..ea2d1666 100644 --- a/lib/route/cls/ematch/container.c +++ b/lib/route/cls/ematch/container.c @@ -8,8 +8,6 @@ #include #include -#include - #include "nl-route.h" static int container_parse(struct rtnl_ematch *e, void *data, size_t len __attribute__((unused))) diff --git a/lib/route/cls/ematch/meta.c b/lib/route/cls/ematch/meta.c index 2cfc3e81..ea4d5dcb 100644 --- a/lib/route/cls/ematch/meta.c +++ b/lib/route/cls/ematch/meta.c @@ -18,7 +18,7 @@ #include #include -#include +#include "nl-shared-core/nl-core.h" struct rtnl_meta_value { diff --git a/lib/route/cls/ematch/nbyte.c b/lib/route/cls/ematch/nbyte.c index d7c6b061..d0ab84ba 100644 --- a/lib/route/cls/ematch/nbyte.c +++ b/lib/route/cls/ematch/nbyte.c @@ -18,8 +18,6 @@ #include #include -#include - struct nbyte_data { struct tcf_em_nbyte cfg; diff --git a/lib/route/cls/ematch/text.c b/lib/route/cls/ematch/text.c index a1fcc1b2..d7a233f8 100644 --- a/lib/route/cls/ematch/text.c +++ b/lib/route/cls/ematch/text.c @@ -18,8 +18,6 @@ #include #include -#include - struct text_data { struct tcf_em_text cfg; diff --git a/lib/route/cls/ematch_grammar.l b/lib/route/cls/ematch_grammar.l index 6b2b8b0d..1035079c 100644 --- a/lib/route/cls/ematch_grammar.l +++ b/lib/route/cls/ematch_grammar.l @@ -4,11 +4,14 @@ */ %{ - #include + #include + #include #include #include - #include + + #include "nl-route.h" + #include "ematch_syntax.h" int ematch_get_column(yyscan_t); diff --git a/lib/route/cls/ematch_syntax.y b/lib/route/cls/ematch_syntax.y index 7328d631..0031aeea 100644 --- a/lib/route/cls/ematch_syntax.y +++ b/lib/route/cls/ematch_syntax.y @@ -4,7 +4,9 @@ */ %{ -#include +#include +#include + #include #include #include @@ -13,15 +15,13 @@ #include #include #include -#include -#include + +#include "nl-route.h" #define META_ALLOC rtnl_meta_value_alloc_id #define META_ID(name) TCF_META_ID_##name #define META_INT TCF_META_TYPE_INT #define META_VAR TCF_META_TYPE_VAR - -#include "nl-route.h" %} %code requires { diff --git a/lib/route/cls/flower.c b/lib/route/cls/flower.c index ceec90a6..e0a98e97 100644 --- a/lib/route/cls/flower.c +++ b/lib/route/cls/flower.c @@ -5,6 +5,8 @@ #include "nl-default.h" +#include + #include #include #include @@ -12,8 +14,6 @@ #include #include -#include - #include "tc-api.h" /** @cond SKIP */ diff --git a/lib/route/cls/fw.c b/lib/route/cls/fw.c index 2b91ab92..01be33fd 100644 --- a/lib/route/cls/fw.c +++ b/lib/route/cls/fw.c @@ -18,8 +18,6 @@ #include #include -#include - #include "tc-api.h" /** @cond SKIP */ diff --git a/lib/route/cls/mall.c b/lib/route/cls/mall.c index 69d700c1..04ec58a2 100644 --- a/lib/route/cls/mall.c +++ b/lib/route/cls/mall.c @@ -19,8 +19,6 @@ #include #include -#include - #include "tc-api.h" struct rtnl_mall { diff --git a/lib/route/cls/police.c b/lib/route/cls/police.c index d184c165..ef6924fe 100644 --- a/lib/route/cls/police.c +++ b/lib/route/cls/police.c @@ -10,7 +10,7 @@ #include #include -#include +#include "nl-shared-core/nl-core.h" /** * @name Policer Type diff --git a/lib/route/cls/u32.c b/lib/route/cls/u32.c index 50934f02..ab8b9774 100644 --- a/lib/route/cls/u32.c +++ b/lib/route/cls/u32.c @@ -21,8 +21,6 @@ #include #include -#include - #include "tc-api.h" #include "nl-aux-route/nl-route.h" diff --git a/lib/route/link.c b/lib/route/link.c index 9e27b526..b8239dd9 100644 --- a/lib/route/link.c +++ b/lib/route/link.c @@ -14,6 +14,8 @@ #include "nl-default.h" +#include + #include #include #include @@ -23,10 +25,9 @@ #include #include -#include - #include "nl-aux-route/nl-route.h" #include "nl-shared-core/nl-core.h" +#include "nl-shared-core/cache-api.h" #include "nl-route.h" #include "link-sriov.h" #include "link/link-api.h" diff --git a/lib/route/link/api.c b/lib/route/link/api.c index 3dc0182d..abc9e6a7 100644 --- a/lib/route/link/api.c +++ b/lib/route/link/api.c @@ -39,8 +39,6 @@ #include #include -#include - #include "nl-route.h" #include "link-api.h" diff --git a/lib/route/link/bonding.c b/lib/route/link/bonding.c index c470f067..640a62ca 100644 --- a/lib/route/link/bonding.c +++ b/lib/route/link/bonding.c @@ -19,8 +19,6 @@ #include #include -#include - #include "nl-route.h" #include "link-api.h" diff --git a/lib/route/link/bridge.c b/lib/route/link/bridge.c index da0b2214..a17d7cc6 100644 --- a/lib/route/link/bridge.c +++ b/lib/route/link/bridge.c @@ -20,8 +20,6 @@ #include #include -#include - #include "nl-route.h" #include "link-api.h" #include "nl-shared-core/nl-core.h" diff --git a/lib/route/link/bridge_info.c b/lib/route/link/bridge_info.c index 2823a704..61b885f0 100644 --- a/lib/route/link/bridge_info.c +++ b/lib/route/link/bridge_info.c @@ -15,8 +15,6 @@ #include -#include - #include "nl-route.h" #include "link-api.h" diff --git a/lib/route/link/can.c b/lib/route/link/can.c index c2bdb5c7..290d42c7 100644 --- a/lib/route/link/can.c +++ b/lib/route/link/can.c @@ -27,8 +27,6 @@ #include #include -#include - #include "nl-route.h" #include "link-api.h" diff --git a/lib/route/link/dummy.c b/lib/route/link/dummy.c index 514a0cf6..83d6ba79 100644 --- a/lib/route/link/dummy.c +++ b/lib/route/link/dummy.c @@ -17,8 +17,6 @@ #include -#include - #include "link-api.h" static struct rtnl_link_info_ops dummy_info_ops = { diff --git a/lib/route/link/geneve.c b/lib/route/link/geneve.c index 1e23ea24..61dd1f1f 100644 --- a/lib/route/link/geneve.c +++ b/lib/route/link/geneve.c @@ -23,8 +23,6 @@ #include #include -#include - #include "nl-route.h" #include "link-api.h" diff --git a/lib/route/link/ifb.c b/lib/route/link/ifb.c index 9c0f5c89..d5fc6855 100644 --- a/lib/route/link/ifb.c +++ b/lib/route/link/ifb.c @@ -17,8 +17,6 @@ #include -#include - #include "link-api.h" static struct rtnl_link_info_ops ifb_info_ops = { diff --git a/lib/route/link/inet.c b/lib/route/link/inet.c index a5ed46fd..7ed705e2 100644 --- a/lib/route/link/inet.c +++ b/lib/route/link/inet.c @@ -53,13 +53,13 @@ #include "nl-default.h" +#include + #include #include #include #include -#include - #include "link-api.h" /** @cond SKIP */ diff --git a/lib/route/link/inet6.c b/lib/route/link/inet6.c index 7a89f687..b03e47d0 100644 --- a/lib/route/link/inet6.c +++ b/lib/route/link/inet6.c @@ -5,13 +5,14 @@ #include "nl-default.h" +#include +#include + #include #include #include #include -#include - #include "nl-route.h" #include "link-api.h" #include "nl-priv-static-route/nl-priv-static-route.h" diff --git a/lib/route/link/ip6gre.c b/lib/route/link/ip6gre.c index d518785c..51d4609c 100644 --- a/lib/route/link/ip6gre.c +++ b/lib/route/link/ip6gre.c @@ -24,8 +24,6 @@ #include #include -#include - #include "nl-route.h" #include "link-api.h" diff --git a/lib/route/link/ip6tnl.c b/lib/route/link/ip6tnl.c index 0c5a4f60..bba79ea0 100644 --- a/lib/route/link/ip6tnl.c +++ b/lib/route/link/ip6tnl.c @@ -29,8 +29,6 @@ #include #include -#include - #include "nl-route.h" #include "link-api.h" diff --git a/lib/route/link/ip6vti.c b/lib/route/link/ip6vti.c index 617f8a4d..b6c7a1b2 100644 --- a/lib/route/link/ip6vti.c +++ b/lib/route/link/ip6vti.c @@ -24,8 +24,6 @@ #include #include -#include - #include "nl-route.h" #include "link-api.h" diff --git a/lib/route/link/ipgre.c b/lib/route/link/ipgre.c index 79eb8ff1..bd3cc40f 100644 --- a/lib/route/link/ipgre.c +++ b/lib/route/link/ipgre.c @@ -27,8 +27,6 @@ #include #include -#include - #include "nl-route.h" #include "link-api.h" diff --git a/lib/route/link/ipip.c b/lib/route/link/ipip.c index 8783667a..74db8901 100644 --- a/lib/route/link/ipip.c +++ b/lib/route/link/ipip.c @@ -27,8 +27,6 @@ #include #include -#include - #include "nl-route.h" #include "link-api.h" diff --git a/lib/route/link/ipvlan.c b/lib/route/link/ipvlan.c index 5f85b442..807942bb 100644 --- a/lib/route/link/ipvlan.c +++ b/lib/route/link/ipvlan.c @@ -27,8 +27,6 @@ #include #include -#include - #include "nl-route.h" #include "link-api.h" diff --git a/lib/route/link/ipvti.c b/lib/route/link/ipvti.c index cb8586ce..fd578959 100644 --- a/lib/route/link/ipvti.c +++ b/lib/route/link/ipvti.c @@ -27,8 +27,6 @@ #include #include -#include - #include "nl-route.h" #include "link-api.h" diff --git a/lib/route/link/link-api.h b/lib/route/link/link-api.h index e87537a2..b25d6c53 100644 --- a/lib/route/link/link-api.h +++ b/lib/route/link/link-api.h @@ -7,6 +7,7 @@ #define NETLINK_LINK_API_H_ #include +#include #include "nl-shared-core/nl-core.h" @@ -193,4 +194,6 @@ extern int rtnl_link_info_data_compare(struct rtnl_link *a, } #endif +extern struct rtnl_link *link_lookup(struct nl_cache *cache, int ifindex); + #endif diff --git a/lib/route/link/macsec.c b/lib/route/link/macsec.c index 8118da50..1fb8762b 100644 --- a/lib/route/link/macsec.c +++ b/lib/route/link/macsec.c @@ -27,8 +27,6 @@ #include #include -#include - #include "nl-route.h" #include "link-api.h" #include "nl-shared-core/nl-core.h" diff --git a/lib/route/link/macvlan.c b/lib/route/link/macvlan.c index d6580f40..be9a2e2b 100644 --- a/lib/route/link/macvlan.c +++ b/lib/route/link/macvlan.c @@ -20,6 +20,7 @@ #include "nl-default.h" #include +#include #include #include @@ -29,8 +30,6 @@ #include #include -#include - #include "nl-route.h" #include "link-api.h" diff --git a/lib/route/link/ppp.c b/lib/route/link/ppp.c index 11cd1ee4..34ca5f66 100644 --- a/lib/route/link/ppp.c +++ b/lib/route/link/ppp.c @@ -19,8 +19,6 @@ #include #include -#include - #include "nl-route.h" #include "link-api.h" diff --git a/lib/route/link/sit.c b/lib/route/link/sit.c index 031a7274..69dd3163 100644 --- a/lib/route/link/sit.c +++ b/lib/route/link/sit.c @@ -27,8 +27,6 @@ #include #include -#include - #include "nl-route.h" #include "link-api.h" diff --git a/lib/route/link/sriov.c b/lib/route/link/sriov.c index 4c4c85ac..d47d1ddf 100644 --- a/lib/route/link/sriov.c +++ b/lib/route/link/sriov.c @@ -28,8 +28,6 @@ #include #include -#include - #include "nl-route.h" #include "link-sriov.h" #include "link-api.h" diff --git a/lib/route/link/team.c b/lib/route/link/team.c index d3a04e6b..0f1161be 100644 --- a/lib/route/link/team.c +++ b/lib/route/link/team.c @@ -19,8 +19,6 @@ #include #include -#include - #include "link-api.h" /** diff --git a/lib/route/link/veth.c b/lib/route/link/veth.c index 871c9b6a..be4b795c 100644 --- a/lib/route/link/veth.c +++ b/lib/route/link/veth.c @@ -28,8 +28,6 @@ #include #include -#include - #include "nl-route.h" #include "link-api.h" diff --git a/lib/route/link/vlan.c b/lib/route/link/vlan.c index 2ad4b8e1..60e4358f 100644 --- a/lib/route/link/vlan.c +++ b/lib/route/link/vlan.c @@ -27,8 +27,6 @@ #include #include -#include - #include "nl-route.h" #include "link-api.h" diff --git a/lib/route/link/vrf.c b/lib/route/link/vrf.c index 4583efeb..810ba90c 100644 --- a/lib/route/link/vrf.c +++ b/lib/route/link/vrf.c @@ -30,8 +30,6 @@ #include #include -#include - #include "nl-route.h" #include "link-api.h" diff --git a/lib/route/link/vxlan.c b/lib/route/link/vxlan.c index 332d4d4e..4606dd5f 100644 --- a/lib/route/link/vxlan.c +++ b/lib/route/link/vxlan.c @@ -27,8 +27,6 @@ #include #include -#include - #include "nl-route.h" #include "link-api.h" diff --git a/lib/route/link/xfrmi.c b/lib/route/link/xfrmi.c index 37e7f705..09ceb809 100644 --- a/lib/route/link/xfrmi.c +++ b/lib/route/link/xfrmi.c @@ -27,8 +27,6 @@ #include #include -#include - #include "nl-route.h" #include "link-api.h" diff --git a/lib/route/mdb.c b/lib/route/mdb.c index bdfd513c..925303eb 100644 --- a/lib/route/mdb.c +++ b/lib/route/mdb.c @@ -13,10 +13,10 @@ #include #include -#include - +#include "nl-route.h" #include "nl-aux-route/nl-route.h" #include "nl-shared-core/object-api.h" +#include "nl-shared-core/cache-api.h" /** @cond SKIP */ #define MDB_ATTR_IFINDEX 0x000001 diff --git a/lib/route/neigh.c b/lib/route/neigh.c index cc818698..f746a251 100644 --- a/lib/route/neigh.c +++ b/lib/route/neigh.c @@ -153,10 +153,9 @@ #include #include -#include - #include "nl-route.h" #include "nl-shared-core/nl-core.h" +#include "nl-shared-core/cache-api.h" /** @cond SKIP */ struct rtnl_ncacheinfo { diff --git a/lib/route/neightbl.c b/lib/route/neightbl.c index 344c8e6b..59eefd14 100644 --- a/lib/route/neightbl.c +++ b/lib/route/neightbl.c @@ -18,10 +18,9 @@ #include #include -#include - #include "nl-route.h" #include "nl-shared-core/nl-core.h" +#include "nl-shared-core/cache-api.h" struct rtnl_neightbl_parms { /** diff --git a/lib/route/netconf.c b/lib/route/netconf.c index be69236f..614d3576 100644 --- a/lib/route/netconf.c +++ b/lib/route/netconf.c @@ -21,9 +21,9 @@ #include #include -#include - +#include "nl-route.h" #include "nl-shared-core/nl-core.h" +#include "nl-shared-core/cache-api.h" #include "nl-shared-core/object-api.h" /** @cond SKIP */ diff --git a/lib/route/nexthop.c b/lib/route/nexthop.c index 37fc0600..0cbc3cf9 100644 --- a/lib/route/nexthop.c +++ b/lib/route/nexthop.c @@ -16,10 +16,9 @@ #include #include -#include - #include "nexthop-encap.h" #include "nl-route.h" +#include "nl-shared-core/nl-core.h" /** @cond SKIP */ #define NH_ATTR_FLAGS 0x000001 diff --git a/lib/route/nexthop_encap.c b/lib/route/nexthop_encap.c index 20c645b2..226b901a 100644 --- a/lib/route/nexthop_encap.c +++ b/lib/route/nexthop_encap.c @@ -4,8 +4,6 @@ #include -#include - #include "nl-route.h" #include "nexthop-encap.h" diff --git a/lib/route/nh.c b/lib/route/nh.c index 101180c7..83eae9aa 100644 --- a/lib/route/nh.c +++ b/lib/route/nh.c @@ -11,11 +11,10 @@ #include #include -#include - #include "nl-aux-route/nl-route.h" #include "nl-route.h" #include "nl-shared-core/nl-core.h" +#include "nl-shared-core/cache-api.h" /** @cond SKIP */ struct rtnl_nh { diff --git a/lib/route/nh_encap_mpls.c b/lib/route/nh_encap_mpls.c index 6cf6dc55..a7802917 100644 --- a/lib/route/nh_encap_mpls.c +++ b/lib/route/nh_encap_mpls.c @@ -7,8 +7,6 @@ #include -#include - #include "nl-route.h" #include "nexthop-encap.h" diff --git a/lib/route/nl-route.h b/lib/route/nl-route.h index 1c0c742d..573d77c8 100644 --- a/lib/route/nl-route.h +++ b/lib/route/nl-route.h @@ -7,8 +7,11 @@ #ifndef __LIB_ROUTE_NL_ROUTE_H__ #define __LIB_ROUTE_NL_ROUTE_H__ +#include + #include "nl-shared-core/object-api.h" #include "nl-priv-dynamic-route/nl-priv-dynamic-route.h" +#include "nl-aux-core/nl-core.h" /*****************************************************************************/ @@ -159,4 +162,30 @@ static inline void rtnl_rcopy_ratespec(struct tc_ratespec *dst, (uint32_t)src->rs_rate64; } +/*****************************************************************************/ + +static inline int build_sysconf_path(char **strp, const char *filename) +{ + char *sysconfdir; + + sysconfdir = getenv("NLSYSCONFDIR"); + + if (!sysconfdir) + sysconfdir = SYSCONFDIR; + + return asprintf(strp, "%s/%s", sysconfdir, filename); +} + +/*****************************************************************************/ + +static inline int rtnl_tc_calc_txtime64(int bufsize, uint64_t rate) +{ + return ((double)bufsize / (double)rate) * 1000000.0; +} + +static inline int rtnl_tc_calc_bufsize64(int txtime, uint64_t rate) +{ + return ((double)txtime * (double)rate) / 1000000.0; +} + #endif /* __LIB_ROUTE_NL_ROUTE_H__ */ diff --git a/lib/route/pktloc.c b/lib/route/pktloc.c index a82dac90..7f320d9b 100644 --- a/lib/route/pktloc.c +++ b/lib/route/pktloc.c @@ -27,11 +27,13 @@ #include "nl-default.h" +#include + #include #include #include -#include +#include "nl-route.h" #include "pktloc_syntax.h" #include "pktloc_grammar.h" diff --git a/lib/route/pktloc_grammar.l b/lib/route/pktloc_grammar.l index c5757aec..2db229d1 100644 --- a/lib/route/pktloc_grammar.l +++ b/lib/route/pktloc_grammar.l @@ -1,9 +1,10 @@ %{ - #include + #include + #include #include #include - #include + #include "pktloc_syntax.h" int pktloc_get_column(yyscan_t); diff --git a/lib/route/pktloc_syntax.y b/lib/route/pktloc_syntax.y index dac149dc..661463a4 100644 --- a/lib/route/pktloc_syntax.y +++ b/lib/route/pktloc_syntax.y @@ -1,8 +1,9 @@ %{ -#include #include #include #include + +#include "nl-route.h" %} %locations diff --git a/lib/route/qdisc.c b/lib/route/qdisc.c index 8a5db4ff..67ea358d 100644 --- a/lib/route/qdisc.c +++ b/lib/route/qdisc.c @@ -18,8 +18,6 @@ #include #include -#include - #include "tc-api.h" static struct nl_cache_ops rtnl_qdisc_ops; diff --git a/lib/route/qdisc/blackhole.c b/lib/route/qdisc/blackhole.c index 523ace91..8d8f4bab 100644 --- a/lib/route/qdisc/blackhole.c +++ b/lib/route/qdisc/blackhole.c @@ -13,8 +13,6 @@ #include -#include - #include "tc-api.h" static struct rtnl_tc_ops blackhole_ops = { diff --git a/lib/route/qdisc/cbq.c b/lib/route/qdisc/cbq.c index 6a88a8bc..b9a66960 100644 --- a/lib/route/qdisc/cbq.c +++ b/lib/route/qdisc/cbq.c @@ -13,8 +13,6 @@ #include #include -#include - #include "tc-api.h" struct rtnl_cbq { diff --git a/lib/route/qdisc/dsmark.c b/lib/route/qdisc/dsmark.c index 994a1e5c..f5718f9c 100644 --- a/lib/route/qdisc/dsmark.c +++ b/lib/route/qdisc/dsmark.c @@ -18,8 +18,6 @@ #include #include -#include - #include "tc-api.h" /** @cond SKIP */ diff --git a/lib/route/qdisc/fifo.c b/lib/route/qdisc/fifo.c index 2044e1a4..99768037 100644 --- a/lib/route/qdisc/fifo.c +++ b/lib/route/qdisc/fifo.c @@ -30,8 +30,6 @@ #include #include -#include - #include "tc-api.h" /** @cond SKIP */ diff --git a/lib/route/qdisc/fq_codel.c b/lib/route/qdisc/fq_codel.c index d2915a3e..a44ab222 100644 --- a/lib/route/qdisc/fq_codel.c +++ b/lib/route/qdisc/fq_codel.c @@ -18,8 +18,6 @@ #include #include -#include - #include "tc-api.h" /** @cond SKIP */ diff --git a/lib/route/qdisc/hfsc.c b/lib/route/qdisc/hfsc.c index d6d45832..49c24c7d 100644 --- a/lib/route/qdisc/hfsc.c +++ b/lib/route/qdisc/hfsc.c @@ -20,8 +20,6 @@ #include #include -#include - #include "tc-api.h" /** @cond SKIP */ diff --git a/lib/route/qdisc/htb.c b/lib/route/qdisc/htb.c index ac8a204a..28061b90 100644 --- a/lib/route/qdisc/htb.c +++ b/lib/route/qdisc/htb.c @@ -22,8 +22,6 @@ #include #include -#include - #include "tc-api.h" /** @cond SKIP */ diff --git a/lib/route/qdisc/ingress.c b/lib/route/qdisc/ingress.c index 979ce672..5363c262 100644 --- a/lib/route/qdisc/ingress.c +++ b/lib/route/qdisc/ingress.c @@ -16,8 +16,6 @@ #include #include -#include - #include "tc-api.h" struct dumb { diff --git a/lib/route/qdisc/mqprio.c b/lib/route/qdisc/mqprio.c index d518f8cb..5e9d08f8 100644 --- a/lib/route/qdisc/mqprio.c +++ b/lib/route/qdisc/mqprio.c @@ -10,8 +10,6 @@ #include #include -#include - #include "tc-api.h" /** @cond SKIP */ diff --git a/lib/route/qdisc/netem.c b/lib/route/qdisc/netem.c index 8f07452f..3839ac89 100644 --- a/lib/route/qdisc/netem.c +++ b/lib/route/qdisc/netem.c @@ -19,8 +19,6 @@ #include #include -#include - #include "tc-api.h" #include "nl-shared-core/nl-core.h" diff --git a/lib/route/qdisc/plug.c b/lib/route/qdisc/plug.c index 1ab4bbef..f0108020 100644 --- a/lib/route/qdisc/plug.c +++ b/lib/route/qdisc/plug.c @@ -60,8 +60,6 @@ #include #include -#include - #include "tc-api.h" struct rtnl_plug { diff --git a/lib/route/qdisc/prio.c b/lib/route/qdisc/prio.c index c2121c97..e7338453 100644 --- a/lib/route/qdisc/prio.c +++ b/lib/route/qdisc/prio.c @@ -27,8 +27,6 @@ #include #include -#include - #include "tc-api.h" /** @cond SKIP */ diff --git a/lib/route/qdisc/red.c b/lib/route/qdisc/red.c index 29d05bd3..e793b780 100644 --- a/lib/route/qdisc/red.c +++ b/lib/route/qdisc/red.c @@ -17,8 +17,6 @@ #include #include -#include - #include "tc-api.h" /** @cond SKIP */ diff --git a/lib/route/qdisc/sfq.c b/lib/route/qdisc/sfq.c index d266676d..43798893 100644 --- a/lib/route/qdisc/sfq.c +++ b/lib/route/qdisc/sfq.c @@ -24,8 +24,6 @@ #include #include -#include - #include "tc-api.h" /** @cond SKIP */ diff --git a/lib/route/qdisc/tbf.c b/lib/route/qdisc/tbf.c index e4db33b2..67996eb5 100644 --- a/lib/route/qdisc/tbf.c +++ b/lib/route/qdisc/tbf.c @@ -19,8 +19,6 @@ #include #include -#include - #include "tc-api.h" /** @cond SKIP */ diff --git a/lib/route/route.c b/lib/route/route.c index 50b863f4..e74c675c 100644 --- a/lib/route/route.c +++ b/lib/route/route.c @@ -20,9 +20,9 @@ #include #include -#include - +#include "nl-route.h" #include "nl-shared-core/nl-core.h" +#include "nl-shared-core/cache-api.h" #include "nl-aux-route/nl-route.h" static struct nl_cache_ops rtnl_route_ops; diff --git a/lib/route/route_obj.c b/lib/route/route_obj.c index 3909e412..cd0d495f 100644 --- a/lib/route/route_obj.c +++ b/lib/route/route_obj.c @@ -38,8 +38,6 @@ #include #include -#include - #include "nl-route.h" #include "nl-aux-route/nl-route.h" #include "nl-shared-core/nl-core.h" diff --git a/lib/route/route_utils.c b/lib/route/route_utils.c index 5dfa9dd2..413ea295 100644 --- a/lib/route/route_utils.c +++ b/lib/route/route_utils.c @@ -38,7 +38,7 @@ #include #include -#include +#include "nl-shared-core/nl-core.h" /** * @name Routing Table Identifier Translations diff --git a/lib/route/rtnl.c b/lib/route/rtnl.c index 5b2c7e97..01351b63 100644 --- a/lib/route/rtnl.c +++ b/lib/route/rtnl.c @@ -14,7 +14,7 @@ #include #include -#include +#include "nl-shared-core/nl-core.h" /** * @name Sending diff --git a/lib/route/rule.c b/lib/route/rule.c index fdbb22fa..8f0a42c3 100644 --- a/lib/route/rule.c +++ b/lib/route/rule.c @@ -21,10 +21,9 @@ #include #include -#include - #include "nl-route.h" #include "nl-shared-core/nl-core.h" +#include "nl-shared-core/cache-api.h" /** @cond SKIP */ struct rtnl_rule { diff --git a/lib/route/tc-api.h b/lib/route/tc-api.h index c8bb48f7..b797c073 100644 --- a/lib/route/tc-api.h +++ b/lib/route/tc-api.h @@ -13,6 +13,7 @@ #include "nl-route.h" #include "nl-hidden-route/nl-hidden-route.h" #include "nl-shared-core/nl-core.h" +#include "nl-shared-core/cache-api.h" /*****************************************************************************/ diff --git a/lib/route/tc.c b/lib/route/tc.c index 6b0c3727..97487cdf 100644 --- a/lib/route/tc.c +++ b/lib/route/tc.c @@ -11,14 +11,16 @@ #include "nl-default.h" +#include +#include +#include + #include #include #include #include #include -#include - #include "tc-api.h" /** @cond SKIP */ diff --git a/lib/socket.c b/lib/socket.c index fc299913..918ee93f 100644 --- a/lib/socket.c +++ b/lib/socket.c @@ -23,7 +23,8 @@ #include "nl-default.h" -#include "sys/socket.h" +#include +#include #include #include @@ -31,10 +32,13 @@ #include #include -#include - #include "nl-core.h" #include "nl-shared-core/nl-core.h" +#include "nl-aux-core/nl-core.h" + +#ifndef SOL_NETLINK +#define SOL_NETLINK 270 +#endif static int default_cb = NL_CB_DEFAULT; diff --git a/lib/utils.c b/lib/utils.c index 73e2e055..17be6470 100644 --- a/lib/utils.c +++ b/lib/utils.c @@ -24,13 +24,15 @@ #include #include +#include #include #include -#include - +#include "nl-core.h" #include "nl-shared-core/object-api.h" +#include "nl-shared-core/nl-core.h" +#include "nl-aux-core/nl-core.h" /** * Global variable indicating the desired level of debugging output. @@ -121,6 +123,12 @@ int __nl_read_num_str_file(const char *path, int (*cb)(long, const char *)) return 0; } +struct trans_list { + int i; + char *a; + struct nl_list_head list; +}; + const char *nl_strerror_l(int err) { const char *buf; diff --git a/lib/xfrm/ae.c b/lib/xfrm/ae.c index 84c523fa..49198c8d 100644 --- a/lib/xfrm/ae.c +++ b/lib/xfrm/ae.c @@ -129,10 +129,10 @@ #include -#include - #include "nl-xfrm.h" #include "nl-shared-core/object-api.h" +#include "nl-shared-core/nl-core.h" +#include "nl-shared-core/cache-api.h" /** @cond SKIP */ diff --git a/lib/xfrm/lifetime.c b/lib/xfrm/lifetime.c index f955baba..17c98835 100644 --- a/lib/xfrm/lifetime.c +++ b/lib/xfrm/lifetime.c @@ -51,8 +51,6 @@ #include -#include - #include "nl-xfrm.h" static void ltime_cfg_destroy(struct xfrmnl_ltime_cfg* ltime) diff --git a/lib/xfrm/sa.c b/lib/xfrm/sa.c index 4c7f6450..355e9893 100644 --- a/lib/xfrm/sa.c +++ b/lib/xfrm/sa.c @@ -50,10 +50,10 @@ #include #include -#include - #include "nl-xfrm.h" #include "nl-shared-core/object-api.h" +#include "nl-shared-core/nl-core.h" +#include "nl-shared-core/cache-api.h" /** @cond SKIP */ diff --git a/lib/xfrm/selector.c b/lib/xfrm/selector.c index 18ec498b..4f14b7b0 100644 --- a/lib/xfrm/selector.c +++ b/lib/xfrm/selector.c @@ -51,8 +51,6 @@ #include -#include - /* Selector, used as selector both on policy rules (SPD) and SAs. */ struct xfrmnl_sel { uint32_t refcnt; diff --git a/lib/xfrm/sp.c b/lib/xfrm/sp.c index 8267144d..9d9d6986 100644 --- a/lib/xfrm/sp.c +++ b/lib/xfrm/sp.c @@ -49,10 +49,10 @@ #include #include -#include - #include "nl-xfrm.h" #include "nl-shared-core/object-api.h" +#include "nl-shared-core/nl-core.h" +#include "nl-shared-core/cache-api.h" struct xfrmnl_userpolicy_type { uint8_t type; diff --git a/lib/xfrm/template.c b/lib/xfrm/template.c index 1cb47398..205f0174 100644 --- a/lib/xfrm/template.c +++ b/lib/xfrm/template.c @@ -51,9 +51,8 @@ #include -#include - #include "nl-xfrm.h" +#include "nl-shared-core/nl-core.h" void xfrmnl_user_tmpl_free(struct xfrmnl_user_tmpl* utmpl) { diff --git a/src/nl-list-caches.c b/src/nl-list-caches.c index 814cb2c7..a39a52c2 100644 --- a/src/nl-list-caches.c +++ b/src/nl-list-caches.c @@ -7,9 +7,8 @@ #include -#include - #include "nl-shared-core/object-api.h" +#include "nl-shared-core/cache-api.h" static void print_usage(void) { diff --git a/tests/test-create-ip6tnl.c b/tests/test-create-ip6tnl.c index ca2efb9e..b0c02819 100644 --- a/tests/test-create-ip6tnl.c +++ b/tests/test-create-ip6tnl.c @@ -4,8 +4,6 @@ #include -#include - int main(int argc, char *argv[]) { struct nl_cache *link_cache; diff --git a/tests/test-create-ipgre.c b/tests/test-create-ipgre.c index 23a43292..31d0eec2 100644 --- a/tests/test-create-ipgre.c +++ b/tests/test-create-ipgre.c @@ -4,8 +4,6 @@ #include -#include - int main(int argc, char *argv[]) { struct nl_cache *link_cache; diff --git a/tests/test-create-ipgretap.c b/tests/test-create-ipgretap.c index 40f15c5e..8dceaf10 100644 --- a/tests/test-create-ipgretap.c +++ b/tests/test-create-ipgretap.c @@ -4,8 +4,6 @@ #include -#include - int main(int argc, char *argv[]) { struct nl_cache *link_cache; diff --git a/tests/test-create-ipip.c b/tests/test-create-ipip.c index 2f8e0095..2ea3bf0c 100644 --- a/tests/test-create-ipip.c +++ b/tests/test-create-ipip.c @@ -4,8 +4,6 @@ #include -#include - int main(int argc, char *argv[]) { struct nl_cache *link_cache; diff --git a/tests/test-create-ipvti.c b/tests/test-create-ipvti.c index ce676ecc..33eb646e 100644 --- a/tests/test-create-ipvti.c +++ b/tests/test-create-ipvti.c @@ -4,8 +4,6 @@ #include -#include - int main(int argc, char *argv[]) { struct nl_cache *link_cache; diff --git a/tests/test-create-sit.c b/tests/test-create-sit.c index 8adf83fc..5c7aaeb8 100644 --- a/tests/test-create-sit.c +++ b/tests/test-create-sit.c @@ -4,8 +4,6 @@ #include -#include - int main(int argc, char *argv[]) { struct nl_cache *link_cache; diff --git a/tests/test-create-xfrmi.c b/tests/test-create-xfrmi.c index 8845b6e0..8fd7c3ab 100644 --- a/tests/test-create-xfrmi.c +++ b/tests/test-create-xfrmi.c @@ -4,8 +4,6 @@ #include -#include - int main(int argc, char *argv[]) { struct nl_cache *link_cache; diff --git a/tests/test-genl.c b/tests/test-genl.c index 5db23f00..6d15a2f7 100644 --- a/tests/test-genl.c +++ b/tests/test-genl.c @@ -66,8 +66,6 @@ static struct genl_cmd cmds[] = { }, }; -#define ARRAY_SIZE(X) (sizeof(X) / sizeof((X)[0])) - static struct genl_ops ops = { .o_name = TASKSTATS_GENL_NAME, .o_cmds = cmds, diff --git a/tools/clang-format.sh b/tools/clang-format.sh index 049459ce..0f565068 100755 --- a/tools/clang-format.sh +++ b/tools/clang-format.sh @@ -14,7 +14,6 @@ EXCLUDE_PATHS_TOPLEVEL=( # The following files are currently not formatted with clang. # Exclude them too. EXCLUDE_PATHS_TOPLEVEL+=( - "include/netlink-private/netlink.h" "include/netlink/addr.h" "include/netlink/attr.h" "include/netlink/cache-api.h"