From 036c22f98b75ac8e58d0c5e3e999ac485b603a38 Mon Sep 17 00:00:00 2001 From: Packit Service Date: Dec 09 2020 19:44:47 +0000 Subject: Prepare for a new update Reverting patches so we can apply the latest update and changes can be seen in the spec file and sources. --- diff --git a/.gitignore b/.gitignore deleted file mode 100644 index a83525b..0000000 --- a/.gitignore +++ /dev/null @@ -1,18 +0,0 @@ -.deps/ -.libs/ -Makefile -Makefile.in -*.o -*.la -*.lo - -/aclocal.m4 -/autom4te.cache/ -/build-aux/ -/config.* -/configure -/libtool - -/doxygen.cfg -/*.pc -/stamp-h1 diff --git a/configure.ac b/configure.ac index 9389b70..d9b0118 100644 --- a/configure.ac +++ b/configure.ac @@ -8,7 +8,6 @@ AC_CONFIG_HEADERS([config.h]) AM_INIT_AUTOMAKE([-Wall foreign tar-pax no-dist-gzip dist-bzip2 1.6 subdir-objects]) -m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) dnl kernel style compile messages m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) @@ -22,7 +21,7 @@ AC_DISABLE_STATIC LT_INIT CHECK_GCC_FVISIBILITY case "$host" in -*-*-linux* | *-*-uclinux*) ;; +*-*-linux*) ;; *) AC_MSG_ERROR([Linux only, dude!]);; esac diff --git a/doxygen.cfg.in b/doxygen.cfg.in index 190b7cd..cac9b05 100644 --- a/doxygen.cfg.in +++ b/doxygen.cfg.in @@ -72,7 +72,7 @@ RECURSIVE = YES EXCLUDE = EXCLUDE_SYMLINKS = NO EXCLUDE_PATTERNS = */.git/* .*.d -EXCLUDE_SYMBOLS = +EXCLUDE_SYMBOLS = EXPORT_SYMBOL EXAMPLE_PATH = EXAMPLE_PATTERNS = EXAMPLE_RECURSIVE = NO diff --git a/examples/nfct-helper-add.c b/examples/nfct-helper-add.c index 79e0963..6c47626 100644 --- a/examples/nfct-helper-add.c +++ b/examples/nfct-helper-add.c @@ -31,9 +31,7 @@ int main(int argc, char *argv[]) nfct_helper_attr_set_u32(nfct_helper, NFCTH_ATTR_QUEUE_NUM, atoi(argv[2])); nfct_helper_attr_set_u16(nfct_helper, NFCTH_ATTR_PROTO_L3NUM, AF_INET); nfct_helper_attr_set_u8(nfct_helper, NFCTH_ATTR_PROTO_L4NUM, IPPROTO_TCP); - nfct_helper_attr_set_u32(nfct_helper, NFCTH_ATTR_PRIV_DATA_LEN, 0); - /* Will be freed by nfct_helper_free. */ p = nfct_helper_policy_alloc(); if (p == NULL) { perror("OOM"); @@ -51,6 +49,7 @@ int main(int argc, char *argv[]) nfct_helper_nlmsg_build_payload(nlh, nfct_helper); nfct_helper_free(nfct_helper); + nfct_helper_policy_free(p); nl = mnl_socket_open(NETLINK_NETFILTER); if (nl == NULL) { diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h index c755646..f1b546e 100644 --- a/include/linux/netfilter/nfnetlink.h +++ b/include/linux/netfilter/nfnetlink.h @@ -18,10 +18,6 @@ enum nfnetlink_groups { #define NFNLGRP_CONNTRACK_EXP_UPDATE NFNLGRP_CONNTRACK_EXP_UPDATE NFNLGRP_CONNTRACK_EXP_DESTROY, #define NFNLGRP_CONNTRACK_EXP_DESTROY NFNLGRP_CONNTRACK_EXP_DESTROY - NFNLGRP_NFTABLES, -#define NFNLGRP_NFTABLES NFNLGRP_NFTABLES - NFNLGRP_ACCT_QUOTA, -#define NFNLGRP_ACCT_QUOTA NFNLGRP_ACCT_QUOTA __NFNLGRP_MAX, }; #define NFNLGRP_MAX (__NFNLGRP_MAX - 1) @@ -55,12 +51,46 @@ struct nfgenmsg { #define NFNL_SUBSYS_ACCT 7 #define NFNL_SUBSYS_CTNETLINK_TIMEOUT 8 #define NFNL_SUBSYS_CTHELPER 9 -#define NFNL_SUBSYS_NFTABLES 10 -#define NFNL_SUBSYS_NFT_COMPAT 11 -#define NFNL_SUBSYS_COUNT 12 +#define NFNL_SUBSYS_COUNT 10 -/* Reserved control nfnetlink messages */ -#define NFNL_MSG_BATCH_BEGIN NLMSG_MIN_TYPE -#define NFNL_MSG_BATCH_END NLMSG_MIN_TYPE+1 +#ifdef __KERNEL__ -#endif /* _NFNETLINK_H */ +#include +#include +#include + +struct nfnl_callback { + int (*call)(struct sock *nl, struct sk_buff *skb, + const struct nlmsghdr *nlh, + const struct nlattr * const cda[]); + int (*call_rcu)(struct sock *nl, struct sk_buff *skb, + const struct nlmsghdr *nlh, + const struct nlattr * const cda[]); + const struct nla_policy *policy; /* netlink attribute policy */ + const u_int16_t attr_count; /* number of nlattr's */ +}; + +struct nfnetlink_subsystem { + const char *name; + __u8 subsys_id; /* nfnetlink subsystem ID */ + __u8 cb_count; /* number of callbacks */ + const struct nfnl_callback *cb; /* callback for individual types */ +}; + +extern int nfnetlink_subsys_register(const struct nfnetlink_subsystem *n); +extern int nfnetlink_subsys_unregister(const struct nfnetlink_subsystem *n); + +extern int nfnetlink_has_listeners(struct net *net, unsigned int group); +extern int nfnetlink_send(struct sk_buff *skb, struct net *net, u32 pid, unsigned group, + int echo, gfp_t flags); +extern int nfnetlink_set_err(struct net *net, u32 pid, u32 group, int error); +extern int nfnetlink_unicast(struct sk_buff *skb, struct net *net, u_int32_t pid, int flags); + +extern void nfnl_lock(void); +extern void nfnl_unlock(void); + +#define MODULE_ALIAS_NFNL_SUBSYS(subsys) \ + MODULE_ALIAS("nfnetlink-subsys-" __stringify(subsys)) + +#endif /* __KERNEL__ */ +#endif /* _NFNETLINK_H */ diff --git a/src/internal.h b/src/internal.h index 5d78171..3a88d1a 100644 --- a/src/internal.h +++ b/src/internal.h @@ -3,9 +3,10 @@ #include "config.h" #ifdef HAVE_VISIBILITY_HIDDEN -# define __EXPORTED __attribute__((visibility("default"))) +# define __visible __attribute__((visibility("default"))) +# define EXPORT_SYMBOL(x) typeof(x) (x) __visible #else -# define __EXPORTED +# define EXPORT_SYMBOL #endif #endif diff --git a/src/libnetfilter_cthelper.c b/src/libnetfilter_cthelper.c index 7ed1f64..2978870 100644 --- a/src/libnetfilter_cthelper.c +++ b/src/libnetfilter_cthelper.c @@ -99,25 +99,27 @@ struct nfct_helper { * In case of success, this function returns a valid pointer, otherwise NULL * s returned and errno is appropriately set. */ -struct nfct_helper __EXPORTED *nfct_helper_alloc(void) +struct nfct_helper *nfct_helper_alloc(void) { return calloc(1, sizeof(struct nfct_helper)); } +EXPORT_SYMBOL(nfct_helper_alloc); /** * nfct_helper_free - release one helper object * \param nfct_helper pointer to the helper object */ -void __EXPORTED nfct_helper_free(struct nfct_helper *h) +void nfct_helper_free(struct nfct_helper *h) { int i; + free(h); for (i=0; iexpect_policy[i]) free(h->expect_policy[i]); } - free(h); } +EXPORT_SYMBOL(nfct_helper_free); /** * nfct_helper_policy_alloc - allocate a new helper policy object @@ -125,19 +127,21 @@ void __EXPORTED nfct_helper_free(struct nfct_helper *h) * In case of success, this function returns a valid pointer, otherwise NULL * s returned and errno is appropriately set. */ -struct nfct_helper_policy __EXPORTED *nfct_helper_policy_alloc(void) +struct nfct_helper_policy *nfct_helper_policy_alloc(void) { return calloc(1, sizeof(struct nfct_helper_policy)); } +EXPORT_SYMBOL(nfct_helper_policy_alloc); /** * nfct_helper_free - release one helper policy object * \param nfct_helper pointer to the helper object */ -void __EXPORTED nfct_helper_policy_free(struct nfct_helper_policy *p) +void nfct_helper_policy_free(struct nfct_helper_policy *p) { free(p); } +EXPORT_SYMBOL(nfct_helper_policy_free); /** * nfct_helper_policy_attr_set - set one attribute of the helper object @@ -145,7 +149,7 @@ void __EXPORTED nfct_helper_policy_free(struct nfct_helper_policy *p) * \param type attribute type you want to set * \param data pointer to data that will be used to set this attribute */ -void __EXPORTED +void nfct_helper_policy_attr_set(struct nfct_helper_policy *p, enum nfct_helper_policy_attr_type type, const void *data) @@ -166,6 +170,7 @@ nfct_helper_policy_attr_set(struct nfct_helper_policy *p, break; } } +EXPORT_SYMBOL(nfct_helper_policy_attr_set); /** * nfct_helper_attr_set_str - set one attribute the helper object @@ -173,21 +178,23 @@ nfct_helper_policy_attr_set(struct nfct_helper_policy *p, * \param type attribute type you want to set * \param name string that will be used to set this attribute */ -void __EXPORTED +void nfct_helper_policy_attr_set_str(struct nfct_helper_policy *p, enum nfct_helper_policy_attr_type type, const char *name) { nfct_helper_policy_attr_set(p, type, name); } +EXPORT_SYMBOL(nfct_helper_policy_attr_set_str); -void __EXPORTED +void nfct_helper_policy_attr_set_u32(struct nfct_helper_policy *p, enum nfct_helper_policy_attr_type type, uint32_t value) { nfct_helper_policy_attr_set(p, type, &value); } +EXPORT_SYMBOL(nfct_helper_policy_attr_set_u32); /** * nfct_helper_attr_set - set one attribute of the helper object @@ -195,7 +202,7 @@ nfct_helper_policy_attr_set_u32(struct nfct_helper_policy *p, * \param type attribute type you want to set * \param data pointer to data that will be used to set this attribute */ -void __EXPORTED +void nfct_helper_attr_set(struct nfct_helper *h, enum nfct_helper_attr_type type, const void *data) { @@ -243,6 +250,7 @@ nfct_helper_attr_set(struct nfct_helper *h, break; } } +EXPORT_SYMBOL(nfct_helper_attr_set); /** * nfct_helper_attr_set_str - set one attribute the helper object @@ -250,40 +258,44 @@ nfct_helper_attr_set(struct nfct_helper *h, * \param type attribute type you want to set * \param name string that will be used to set this attribute */ -void __EXPORTED +void nfct_helper_attr_set_str(struct nfct_helper *nfct_helper, enum nfct_helper_attr_type type, const char *name) { nfct_helper_attr_set(nfct_helper, type, name); } +EXPORT_SYMBOL(nfct_helper_attr_set_str); -void __EXPORTED +void nfct_helper_attr_set_u8(struct nfct_helper *nfct_helper, enum nfct_helper_attr_type type, uint8_t value) { nfct_helper_attr_set(nfct_helper, type, &value); } +EXPORT_SYMBOL(nfct_helper_attr_set_u8); -void __EXPORTED +void nfct_helper_attr_set_u16(struct nfct_helper *nfct_helper, enum nfct_helper_attr_type type, uint16_t value) { nfct_helper_attr_set(nfct_helper, type, &value); } +EXPORT_SYMBOL(nfct_helper_attr_set_u16); -void __EXPORTED +void nfct_helper_attr_set_u32(struct nfct_helper *nfct_helper, enum nfct_helper_attr_type type, uint32_t value) { nfct_helper_attr_set(nfct_helper, type, &value); } +EXPORT_SYMBOL(nfct_helper_attr_set_u32); /** * nfct_helper_attr_unset - unset one attribute the helper object * \param nfct_helper pointer to the helper object * \param type attribute type you want to set */ -void __EXPORTED +void nfct_helper_attr_unset(struct nfct_helper *nfct_helper, enum nfct_helper_attr_type type) { switch(type) { @@ -295,6 +307,7 @@ nfct_helper_attr_unset(struct nfct_helper *nfct_helper, enum nfct_helper_attr_ty break; } } +EXPORT_SYMBOL(nfct_helper_attr_unset); /** * nfct_helper_attr_get - get one attribute the helper object @@ -304,9 +317,8 @@ nfct_helper_attr_unset(struct nfct_helper *nfct_helper, enum nfct_helper_attr_ty * This function returns a valid pointer to the attribute data. If a * unsupported attribute is used, this returns NULL. */ -const void __EXPORTED * -nfct_helper_attr_get(struct nfct_helper *helper, - enum nfct_helper_attr_type type) +const void *nfct_helper_attr_get(struct nfct_helper *helper, + enum nfct_helper_attr_type type) { const void *ret = NULL; @@ -346,6 +358,7 @@ nfct_helper_attr_get(struct nfct_helper *helper, } return ret; } +EXPORT_SYMBOL(nfct_helper_attr_get); /** * nfct_helper_attr_get_str - get one attribute the helper object @@ -355,12 +368,13 @@ nfct_helper_attr_get(struct nfct_helper *helper, * This function returns a valid pointer to the beginning of the string. * If the attribute is unsupported, this returns NULL. */ -const char __EXPORTED * +const char * nfct_helper_attr_get_str(struct nfct_helper *nfct_helper, enum nfct_helper_attr_type type) { return (const char *)nfct_helper_attr_get(nfct_helper, type); } +EXPORT_SYMBOL(nfct_helper_attr_get_str); /** * nfct_helper_attr_get_u8 - get one attribute the helper object @@ -370,12 +384,12 @@ nfct_helper_attr_get_str(struct nfct_helper *nfct_helper, * This function returns a unsigned 8-bits integer. If the attribute is * unsupported, this returns NULL. */ -uint8_t __EXPORTED -nfct_helper_attr_get_u8(struct nfct_helper *nfct_helper, - enum nfct_helper_attr_type type) +uint8_t nfct_helper_attr_get_u8(struct nfct_helper *nfct_helper, + enum nfct_helper_attr_type type) { return *((uint8_t *)nfct_helper_attr_get(nfct_helper, type)); } +EXPORT_SYMBOL(nfct_helper_attr_get_u8); /** * nfct_helper_attr_get_u16 - get one attribute the helper object @@ -385,12 +399,12 @@ nfct_helper_attr_get_u8(struct nfct_helper *nfct_helper, * This function returns a unsigned 16-bits integer. If the attribute is * unsupported, this returns NULL. */ -uint16_t __EXPORTED -nfct_helper_attr_get_u16(struct nfct_helper *nfct_helper, - enum nfct_helper_attr_type type) +uint16_t nfct_helper_attr_get_u16(struct nfct_helper *nfct_helper, + enum nfct_helper_attr_type type) { return *((uint16_t *)nfct_helper_attr_get(nfct_helper, type)); } +EXPORT_SYMBOL(nfct_helper_attr_get_u16); /** * nfct_helper_attr_get_u32 - get one attribute the helper object @@ -400,12 +414,12 @@ nfct_helper_attr_get_u16(struct nfct_helper *nfct_helper, * This function returns a unsigned 32-bits integer. If the attribute is * unsupported, this returns NULL. */ -uint32_t __EXPORTED -nfct_helper_attr_get_u32(struct nfct_helper *nfct_helper, - enum nfct_helper_attr_type type) +uint32_t nfct_helper_attr_get_u32(struct nfct_helper *nfct_helper, + enum nfct_helper_attr_type type) { return *((uint32_t *)nfct_helper_attr_get(nfct_helper, type)); } +EXPORT_SYMBOL(nfct_helper_attr_get_u32); /** * nfct_helper_snprintf - print helper object into one buffer @@ -417,10 +431,9 @@ nfct_helper_attr_get_u32(struct nfct_helper *nfct_helper, * This function returns -1 in case that some mandatory attributes are * missing. On sucess, it returns 0. */ -int __EXPORTED -nfct_helper_snprintf(char *buf, size_t size, - struct nfct_helper *helper, - unsigned int type, unsigned int flags) +int nfct_helper_snprintf(char *buf, size_t size, + struct nfct_helper *helper, + unsigned int type, unsigned int flags) { int ret; @@ -441,6 +454,7 @@ nfct_helper_snprintf(char *buf, size_t size, return ret; } +EXPORT_SYMBOL(nfct_helper_snprintf); /** * @} @@ -476,7 +490,7 @@ nfct_helper_snprintf(char *buf, size_t size, * - Command NFNL_MSG_ACCT_DEL, to delete one specific nfct_helper object (if * unused, otherwise you hit EBUSY). */ -struct nlmsghdr __EXPORTED * +struct nlmsghdr * nfct_helper_nlmsg_build_hdr(char *buf, uint8_t cmd, uint16_t flags, uint32_t seq) { @@ -495,14 +509,15 @@ nfct_helper_nlmsg_build_hdr(char *buf, uint8_t cmd, return nlh; } +EXPORT_SYMBOL(nfct_helper_nlmsg_build_hdr); static void -nfct_helper_nlmsg_build_policy(struct nlmsghdr *nlh, uint16_t type, +nfct_helper_nlmsg_build_policy(struct nlmsghdr *nlh, struct nfct_helper_policy *p) { struct nlattr *nest; - nest = mnl_attr_nest_start(nlh, type); + nest = mnl_attr_nest_start(nlh, NFCTH_POLICY_SET); mnl_attr_put_strz(nlh, NFCTH_POLICY_NAME, p->name); mnl_attr_put_u32(nlh, NFCTH_POLICY_EXPECT_MAX, htonl(p->expect_max)); mnl_attr_put_u32(nlh, NFCTH_POLICY_EXPECT_TIMEOUT, @@ -515,7 +530,7 @@ nfct_helper_nlmsg_build_policy(struct nlmsghdr *nlh, uint16_t type, * \param nlh: netlink message that you want to use to add the payload. * \param nfct_helper: pointer to a helper object */ -void __EXPORTED +void nfct_helper_nlmsg_build_payload(struct nlmsghdr *nlh, struct nfct_helper *h) { struct nlattr *nest; @@ -549,22 +564,22 @@ nfct_helper_nlmsg_build_payload(struct nlmsghdr *nlh, struct nfct_helper *h) int policy_set_num = 0; if (h->bitset & (1 << NFCTH_ATTR_POLICY1)) { - nfct_helper_nlmsg_build_policy(nlh, NFCTH_POLICY_SET1, + nfct_helper_nlmsg_build_policy(nlh, h->expect_policy[0]); policy_set_num++; } if (h->bitset & (1 << NFCTH_ATTR_POLICY2)) { - nfct_helper_nlmsg_build_policy(nlh, NFCTH_POLICY_SET2, + nfct_helper_nlmsg_build_policy(nlh, h->expect_policy[1]); policy_set_num++; } if (h->bitset & (1 << NFCTH_ATTR_POLICY3)) { - nfct_helper_nlmsg_build_policy(nlh, NFCTH_POLICY_SET3, + nfct_helper_nlmsg_build_policy(nlh, h->expect_policy[2]); policy_set_num++; } if (h->bitset & (1 << NFCTH_ATTR_POLICY4)) { - nfct_helper_nlmsg_build_policy(nlh, NFCTH_POLICY_SET4, + nfct_helper_nlmsg_build_policy(nlh, h->expect_policy[3]); policy_set_num++; } @@ -578,6 +593,7 @@ nfct_helper_nlmsg_build_payload(struct nlmsghdr *nlh, struct nfct_helper *h) if (h->bitset & (1 << NFCTH_ATTR_STATUS)) mnl_attr_put_u32(nlh, NFCTH_STATUS, ntohl(h->status)); } +EXPORT_SYMBOL(nfct_helper_nlmsg_build_payload); static int nfct_helper_nlmsg_parse_tuple_cb(const struct nlattr *attr, void *data) @@ -717,13 +733,14 @@ nfct_helper_nlmsg_parse_policy_set(const struct nlattr *attr, struct nfct_helper *helper) { struct nlattr *tb[NFCTH_POLICY_SET_MAX+1] = {}; - int i, policy_num = 0; + int i; mnl_attr_parse_nested(attr, nfct_helper_nlmsg_parse_policy_set_cb, tb); - if (tb[NFCTH_POLICY_SET_NUM]) - policy_num = ntohl(mnl_attr_get_u32(tb[NFCTH_POLICY_SET_NUM])); - - for (i=0; ipolicy_num = + ntohl(mnl_attr_get_u32(tb[NFCTH_POLICY_SET_NUM])); + } + for (i=0; ipolicy_num; i++) { if (tb[NFCTH_POLICY_SET+i]) { nfct_helper_nlmsg_parse_policy(tb[NFCTH_POLICY_SET+i], helper); @@ -778,7 +795,7 @@ nfct_helper_nlmsg_parse_attr_cb(const struct nlattr *attr, void *data) * This function returns -1 in case that some mandatory attributes are * missing. On sucess, it returns 0. */ -int __EXPORTED +int nfct_helper_nlmsg_parse_payload(const struct nlmsghdr *nlh, struct nfct_helper *h) { @@ -815,6 +832,7 @@ nfct_helper_nlmsg_parse_payload(const struct nlmsghdr *nlh, } return 0; } +EXPORT_SYMBOL(nfct_helper_nlmsg_parse_payload); /** * @}