| @@ -22,12 +22,8 @@ · 21 unmodified lines |
| 22 | #include <net/netfilter/nf_conntrack_l4proto.h> | 22 | #include <net/netfilter/nf_conntrack_l4proto.h> |
| 23 | #include <net/netfilter/nf_conntrack_timeout.h> | 23 | #include <net/netfilter/nf_conntrack_timeout.h> |
| 24 | | 24 | |
| 25 | struct nf_ct_timeout * | 25 | const struct nf_ct_timeout_hooks *nf_ct_timeout_hook __read_mostly; |
| 26 | (*nf_ct_timeout_find_get_hook)(struct net *net, const char *name) __read_mostly; | 26 | EXPORT_SYMBOL_GPL(nf_ct_timeout_hook); |
| 27 | EXPORT_SYMBOL_GPL(nf_ct_timeout_find_get_hook); | | |
| 28 | | | |
| 29 | void (*nf_ct_timeout_put_hook)(struct nf_ct_timeout *timeout) __read_mostly; | | |
| 30 | EXPORT_SYMBOL_GPL(nf_ct_timeout_put_hook); | | |
| 31 | | 27 | |
| 32 | static int untimeout(struct nf_conn *ct, void *timeout) | 28 | static int untimeout(struct nf_conn *ct, void *timeout) |
| 33 | { | 29 | { |
| @@ -48,31 +44,30 @@ EXPORT_SYMBOL_GPL(nf_ct_untimeout); · 14 unmodified lines |
| 48 | | 44 | |
| 49 | static void __nf_ct_timeout_put(struct nf_ct_timeout *timeout) | 45 | static void __nf_ct_timeout_put(struct nf_ct_timeout *timeout) |
| 50 | { | 46 | { |
| 51 | typeof(nf_ct_timeout_put_hook) timeout_put; | 47 | const struct nf_ct_timeout_hooks *h = rcu_dereference(nf_ct_timeout_hook); |
| 52 | | 48 | |
| 53 | timeout_put = rcu_dereference(nf_ct_timeout_put_hook); | 49 | if (h) |
| 54 | if (timeout_put) | 50 | h->timeout_put(timeout); |
| 55 | timeout_put(timeout); | | |
| 56 | } | 51 | } |
| 57 | | 52 | |
| 58 | int nf_ct_set_timeout(struct net *net, struct nf_conn *ct, | 53 | int nf_ct_set_timeout(struct net *net, struct nf_conn *ct, |
| 59 | u8 l3num, u8 l4num, const char *timeout_name) | 54 | u8 l3num, u8 l4num, const char *timeout_name) |
| 60 | { | 55 | { |
| 61 | typeof(nf_ct_timeout_find_get_hook) timeout_find_get; | 56 | const struct nf_ct_timeout_hooks *h; |
| 62 | struct nf_ct_timeout *timeout; | 57 | struct nf_ct_timeout *timeout; |
| 63 | struct nf_conn_timeout *timeout_ext; | 58 | struct nf_conn_timeout *timeout_ext; |
| 64 | const char *errmsg = NULL; | 59 | const char *errmsg = NULL; |
| 65 | int ret = 0; | 60 | int ret = 0; |
| 66 | | 61 | |
| 67 | rcu_read_lock(); | 62 | rcu_read_lock(); |
| 68 | timeout_find_get = rcu_dereference(nf_ct_timeout_find_get_hook); | 63 | h = rcu_dereference(nf_ct_timeout_hook); |
| 69 | if (!timeout_find_get) { | 64 | if (!h) { |
| 70 | ret = -ENOENT; | 65 | ret = -ENOENT; |
| 71 | errmsg = "Timeout policy base is empty"; | 66 | errmsg = "Timeout policy base is empty"; |
| 72 | goto out; | 67 | goto out; |
| 73 | } | 68 | } |
| 74 | | 69 | |
| 75 | timeout = timeout_find_get(net, timeout_name); | 70 | timeout = h->timeout_find_get(net, timeout_name); |
| 76 | if (!timeout) { | 71 | if (!timeout) { |
| 77 | ret = -ENOENT; | 72 | ret = -ENOENT; |
| 78 | pr_info_ratelimited("No such timeout policy \"%s\"\n", | 73 | pr_info_ratelimited("No such timeout policy \"%s\"\n", |
| @@ -119,15 +114,15 @@ EXPORT_SYMBOL_GPL(nf_ct_set_timeout); · 40 unmodified lines |
| 119 | void nf_ct_destroy_timeout(struct nf_conn *ct) | 114 | void nf_ct_destroy_timeout(struct nf_conn *ct) |
| 120 | { | 115 | { |
| 121 | struct nf_conn_timeout *timeout_ext; | 116 | struct nf_conn_timeout *timeout_ext; |
| 122 | typeof(nf_ct_timeout_put_hook) timeout_put; | 117 | const struct nf_ct_timeout_hooks *h; |
| 123 | | 118 | |
| 124 | rcu_read_lock(); | 119 | rcu_read_lock(); |
| 125 | timeout_put = rcu_dereference(nf_ct_timeout_put_hook); | 120 | h = rcu_dereference(nf_ct_timeout_hook); |
| 126 | | 121 | |
| 127 | if (timeout_put) { | 122 | if (h) { |
| 128 | timeout_ext = nf_ct_timeout_find(ct); | 123 | timeout_ext = nf_ct_timeout_find(ct); |
| 129 | if (timeout_ext) { | 124 | if (timeout_ext) { |
| 130 | timeout_put(timeout_ext->timeout); | 125 | h->timeout_put(timeout_ext->timeout); |
| 131 | RCU_INIT_POINTER(timeout_ext->timeout, NULL); | 126 | RCU_INIT_POINTER(timeout_ext->timeout, NULL); |
| 132 | } | 127 | } |
| 133 | } | 128 | } |