Patrick McHardy | 20a6934 | 2013-10-11 12:06:22 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2008-2009 Patrick McHardy <kaber@trash.net> |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License version 2 as |
| 6 | * published by the Free Software Foundation. |
| 7 | * |
| 8 | * Development of this code funded by Astaro AG (http://www.astaro.com/) |
| 9 | */ |
| 10 | |
| 11 | #include <linux/kernel.h> |
| 12 | #include <linux/init.h> |
| 13 | #include <linux/module.h> |
| 14 | #include <linux/list.h> |
| 15 | #include <linux/rbtree.h> |
| 16 | #include <linux/netlink.h> |
| 17 | #include <linux/netfilter.h> |
| 18 | #include <linux/netfilter/nf_tables.h> |
| 19 | #include <net/netfilter/nf_tables.h> |
| 20 | |
Pablo Neira Ayuso | 7632667 | 2014-05-28 15:27:18 +0200 | [diff] [blame] | 21 | static DEFINE_SPINLOCK(nft_rbtree_lock); |
| 22 | |
Patrick McHardy | 20a6934 | 2013-10-11 12:06:22 +0200 | [diff] [blame] | 23 | struct nft_rbtree { |
| 24 | struct rb_root root; |
| 25 | }; |
| 26 | |
| 27 | struct nft_rbtree_elem { |
| 28 | struct rb_node node; |
Patrick McHardy | fe2811e | 2015-03-25 13:07:50 +0000 | [diff] [blame] | 29 | struct nft_set_ext ext; |
Patrick McHardy | 20a6934 | 2013-10-11 12:06:22 +0200 | [diff] [blame] | 30 | }; |
| 31 | |
Pablo Neira Ayuso | ef1d20e | 2016-04-12 23:50:36 +0200 | [diff] [blame] | 32 | static bool nft_rbtree_interval_end(const struct nft_rbtree_elem *rbe) |
| 33 | { |
| 34 | return nft_set_ext_exists(&rbe->ext, NFT_SET_EXT_FLAGS) && |
| 35 | (*nft_set_ext_flags(&rbe->ext) & NFT_SET_ELEM_INTERVAL_END); |
| 36 | } |
Patrick McHardy | cc02e45 | 2015-03-25 14:08:50 +0000 | [diff] [blame] | 37 | |
Pablo Neira Ayuso | e701001 | 2016-04-12 23:50:37 +0200 | [diff] [blame] | 38 | static bool nft_rbtree_equal(const struct nft_set *set, const void *this, |
| 39 | const struct nft_rbtree_elem *interval) |
| 40 | { |
| 41 | return memcmp(this, nft_set_ext_key(&interval->ext), set->klen) == 0; |
| 42 | } |
| 43 | |
Pablo Neira Ayuso | 42a5576 | 2016-07-08 14:41:49 +0200 | [diff] [blame] | 44 | static bool nft_rbtree_lookup(const struct net *net, const struct nft_set *set, |
| 45 | const u32 *key, const struct nft_set_ext **ext) |
Patrick McHardy | 20a6934 | 2013-10-11 12:06:22 +0200 | [diff] [blame] | 46 | { |
| 47 | const struct nft_rbtree *priv = nft_set_priv(set); |
| 48 | const struct nft_rbtree_elem *rbe, *interval = NULL; |
Pablo Neira Ayuso | 42a5576 | 2016-07-08 14:41:49 +0200 | [diff] [blame] | 49 | u8 genmask = nft_genmask_cur(net); |
Patrick McHardy | 16c45ed | 2015-03-21 15:19:14 +0000 | [diff] [blame] | 50 | const struct rb_node *parent; |
Pablo Neira Ayuso | e701001 | 2016-04-12 23:50:37 +0200 | [diff] [blame] | 51 | const void *this; |
Patrick McHardy | 20a6934 | 2013-10-11 12:06:22 +0200 | [diff] [blame] | 52 | int d; |
| 53 | |
Pablo Neira Ayuso | 7632667 | 2014-05-28 15:27:18 +0200 | [diff] [blame] | 54 | spin_lock_bh(&nft_rbtree_lock); |
Patrick McHardy | 16c45ed | 2015-03-21 15:19:14 +0000 | [diff] [blame] | 55 | parent = priv->root.rb_node; |
Patrick McHardy | 20a6934 | 2013-10-11 12:06:22 +0200 | [diff] [blame] | 56 | while (parent != NULL) { |
| 57 | rbe = rb_entry(parent, struct nft_rbtree_elem, node); |
| 58 | |
Pablo Neira Ayuso | e701001 | 2016-04-12 23:50:37 +0200 | [diff] [blame] | 59 | this = nft_set_ext_key(&rbe->ext); |
| 60 | d = memcmp(this, key, set->klen); |
Patrick McHardy | 20a6934 | 2013-10-11 12:06:22 +0200 | [diff] [blame] | 61 | if (d < 0) { |
| 62 | parent = parent->rb_left; |
Pablo Neira Ayuso | e701001 | 2016-04-12 23:50:37 +0200 | [diff] [blame] | 63 | /* In case of adjacent ranges, we always see the high |
| 64 | * part of the range in first place, before the low one. |
| 65 | * So don't update interval if the keys are equal. |
| 66 | */ |
| 67 | if (interval && nft_rbtree_equal(set, this, interval)) |
| 68 | continue; |
Patrick McHardy | 20a6934 | 2013-10-11 12:06:22 +0200 | [diff] [blame] | 69 | interval = rbe; |
| 70 | } else if (d > 0) |
| 71 | parent = parent->rb_right; |
| 72 | else { |
Patrick McHardy | cc02e45 | 2015-03-25 14:08:50 +0000 | [diff] [blame] | 73 | if (!nft_set_elem_active(&rbe->ext, genmask)) { |
| 74 | parent = parent->rb_left; |
| 75 | continue; |
| 76 | } |
Pablo Neira Ayuso | ef1d20e | 2016-04-12 23:50:36 +0200 | [diff] [blame] | 77 | if (nft_rbtree_interval_end(rbe)) |
Patrick McHardy | 20a6934 | 2013-10-11 12:06:22 +0200 | [diff] [blame] | 78 | goto out; |
Pablo Neira Ayuso | 7632667 | 2014-05-28 15:27:18 +0200 | [diff] [blame] | 79 | spin_unlock_bh(&nft_rbtree_lock); |
Patrick McHardy | b2832dd | 2015-03-25 14:08:48 +0000 | [diff] [blame] | 80 | |
| 81 | *ext = &rbe->ext; |
Patrick McHardy | 20a6934 | 2013-10-11 12:06:22 +0200 | [diff] [blame] | 82 | return true; |
| 83 | } |
| 84 | } |
| 85 | |
Pablo Neira Ayuso | c1eda3c | 2016-08-01 13:13:08 +0200 | [diff] [blame] | 86 | if (set->flags & NFT_SET_INTERVAL && interval != NULL && |
| 87 | nft_set_elem_active(&interval->ext, genmask) && |
| 88 | !nft_rbtree_interval_end(interval)) { |
| 89 | spin_unlock_bh(&nft_rbtree_lock); |
| 90 | *ext = &interval->ext; |
| 91 | return true; |
Patrick McHardy | 20a6934 | 2013-10-11 12:06:22 +0200 | [diff] [blame] | 92 | } |
| 93 | out: |
Pablo Neira Ayuso | 7632667 | 2014-05-28 15:27:18 +0200 | [diff] [blame] | 94 | spin_unlock_bh(&nft_rbtree_lock); |
Patrick McHardy | 20a6934 | 2013-10-11 12:06:22 +0200 | [diff] [blame] | 95 | return false; |
| 96 | } |
| 97 | |
Pablo Neira Ayuso | 42a5576 | 2016-07-08 14:41:49 +0200 | [diff] [blame] | 98 | static int __nft_rbtree_insert(const struct net *net, const struct nft_set *set, |
Pablo Neira Ayuso | c016c7e | 2016-08-24 12:41:54 +0200 | [diff] [blame] | 99 | struct nft_rbtree_elem *new, |
| 100 | struct nft_set_ext **ext) |
Patrick McHardy | 20a6934 | 2013-10-11 12:06:22 +0200 | [diff] [blame] | 101 | { |
| 102 | struct nft_rbtree *priv = nft_set_priv(set); |
Pablo Neira Ayuso | 42a5576 | 2016-07-08 14:41:49 +0200 | [diff] [blame] | 103 | u8 genmask = nft_genmask_next(net); |
Patrick McHardy | 20a6934 | 2013-10-11 12:06:22 +0200 | [diff] [blame] | 104 | struct nft_rbtree_elem *rbe; |
| 105 | struct rb_node *parent, **p; |
| 106 | int d; |
| 107 | |
| 108 | parent = NULL; |
| 109 | p = &priv->root.rb_node; |
| 110 | while (*p != NULL) { |
| 111 | parent = *p; |
| 112 | rbe = rb_entry(parent, struct nft_rbtree_elem, node); |
Patrick McHardy | e562d86 | 2015-04-11 02:27:34 +0100 | [diff] [blame] | 113 | d = memcmp(nft_set_ext_key(&rbe->ext), |
| 114 | nft_set_ext_key(&new->ext), |
| 115 | set->klen); |
Patrick McHardy | 20a6934 | 2013-10-11 12:06:22 +0200 | [diff] [blame] | 116 | if (d < 0) |
| 117 | p = &parent->rb_left; |
| 118 | else if (d > 0) |
| 119 | p = &parent->rb_right; |
Patrick McHardy | cc02e45 | 2015-03-25 14:08:50 +0000 | [diff] [blame] | 120 | else { |
Pablo Neira Ayuso | 3eb235a | 2017-05-21 00:37:10 +0200 | [diff] [blame^] | 121 | if (nft_rbtree_interval_end(rbe) && |
| 122 | !nft_rbtree_interval_end(new)) { |
| 123 | p = &parent->rb_left; |
| 124 | } else if (!nft_rbtree_interval_end(rbe) && |
| 125 | nft_rbtree_interval_end(new)) { |
| 126 | p = &parent->rb_right; |
| 127 | } else if (nft_set_elem_active(&rbe->ext, genmask)) { |
| 128 | *ext = &rbe->ext; |
| 129 | return -EEXIST; |
| 130 | } else { |
| 131 | p = &parent->rb_left; |
Pablo Neira Ayuso | e701001 | 2016-04-12 23:50:37 +0200 | [diff] [blame] | 132 | } |
Patrick McHardy | cc02e45 | 2015-03-25 14:08:50 +0000 | [diff] [blame] | 133 | } |
Patrick McHardy | 20a6934 | 2013-10-11 12:06:22 +0200 | [diff] [blame] | 134 | } |
| 135 | rb_link_node(&new->node, parent, p); |
| 136 | rb_insert_color(&new->node, &priv->root); |
| 137 | return 0; |
| 138 | } |
| 139 | |
Pablo Neira Ayuso | 42a5576 | 2016-07-08 14:41:49 +0200 | [diff] [blame] | 140 | static int nft_rbtree_insert(const struct net *net, const struct nft_set *set, |
Pablo Neira Ayuso | c016c7e | 2016-08-24 12:41:54 +0200 | [diff] [blame] | 141 | const struct nft_set_elem *elem, |
| 142 | struct nft_set_ext **ext) |
Patrick McHardy | 20a6934 | 2013-10-11 12:06:22 +0200 | [diff] [blame] | 143 | { |
Patrick McHardy | fe2811e | 2015-03-25 13:07:50 +0000 | [diff] [blame] | 144 | struct nft_rbtree_elem *rbe = elem->priv; |
Patrick McHardy | 20a6934 | 2013-10-11 12:06:22 +0200 | [diff] [blame] | 145 | int err; |
| 146 | |
Pablo Neira Ayuso | 7632667 | 2014-05-28 15:27:18 +0200 | [diff] [blame] | 147 | spin_lock_bh(&nft_rbtree_lock); |
Pablo Neira Ayuso | c016c7e | 2016-08-24 12:41:54 +0200 | [diff] [blame] | 148 | err = __nft_rbtree_insert(net, set, rbe, ext); |
Pablo Neira Ayuso | 7632667 | 2014-05-28 15:27:18 +0200 | [diff] [blame] | 149 | spin_unlock_bh(&nft_rbtree_lock); |
Patrick McHardy | fe2811e | 2015-03-25 13:07:50 +0000 | [diff] [blame] | 150 | |
Patrick McHardy | 20a6934 | 2013-10-11 12:06:22 +0200 | [diff] [blame] | 151 | return err; |
| 152 | } |
| 153 | |
| 154 | static void nft_rbtree_remove(const struct nft_set *set, |
| 155 | const struct nft_set_elem *elem) |
| 156 | { |
| 157 | struct nft_rbtree *priv = nft_set_priv(set); |
Patrick McHardy | cc02e45 | 2015-03-25 14:08:50 +0000 | [diff] [blame] | 158 | struct nft_rbtree_elem *rbe = elem->priv; |
Patrick McHardy | 20a6934 | 2013-10-11 12:06:22 +0200 | [diff] [blame] | 159 | |
Pablo Neira Ayuso | 7632667 | 2014-05-28 15:27:18 +0200 | [diff] [blame] | 160 | spin_lock_bh(&nft_rbtree_lock); |
Patrick McHardy | 20a6934 | 2013-10-11 12:06:22 +0200 | [diff] [blame] | 161 | rb_erase(&rbe->node, &priv->root); |
Pablo Neira Ayuso | 7632667 | 2014-05-28 15:27:18 +0200 | [diff] [blame] | 162 | spin_unlock_bh(&nft_rbtree_lock); |
Patrick McHardy | 20a6934 | 2013-10-11 12:06:22 +0200 | [diff] [blame] | 163 | } |
| 164 | |
Pablo Neira Ayuso | 42a5576 | 2016-07-08 14:41:49 +0200 | [diff] [blame] | 165 | static void nft_rbtree_activate(const struct net *net, |
| 166 | const struct nft_set *set, |
Patrick McHardy | cc02e45 | 2015-03-25 14:08:50 +0000 | [diff] [blame] | 167 | const struct nft_set_elem *elem) |
| 168 | { |
| 169 | struct nft_rbtree_elem *rbe = elem->priv; |
| 170 | |
Pablo Neira Ayuso | 42a5576 | 2016-07-08 14:41:49 +0200 | [diff] [blame] | 171 | nft_set_elem_change_active(net, set, &rbe->ext); |
Patrick McHardy | cc02e45 | 2015-03-25 14:08:50 +0000 | [diff] [blame] | 172 | } |
| 173 | |
Pablo Neira Ayuso | 42a5576 | 2016-07-08 14:41:49 +0200 | [diff] [blame] | 174 | static void *nft_rbtree_deactivate(const struct net *net, |
| 175 | const struct nft_set *set, |
Patrick McHardy | cc02e45 | 2015-03-25 14:08:50 +0000 | [diff] [blame] | 176 | const struct nft_set_elem *elem) |
Patrick McHardy | 20a6934 | 2013-10-11 12:06:22 +0200 | [diff] [blame] | 177 | { |
| 178 | const struct nft_rbtree *priv = nft_set_priv(set); |
| 179 | const struct rb_node *parent = priv->root.rb_node; |
Pablo Neira Ayuso | e701001 | 2016-04-12 23:50:37 +0200 | [diff] [blame] | 180 | struct nft_rbtree_elem *rbe, *this = elem->priv; |
Pablo Neira Ayuso | 42a5576 | 2016-07-08 14:41:49 +0200 | [diff] [blame] | 181 | u8 genmask = nft_genmask_next(net); |
Patrick McHardy | 20a6934 | 2013-10-11 12:06:22 +0200 | [diff] [blame] | 182 | int d; |
| 183 | |
| 184 | while (parent != NULL) { |
| 185 | rbe = rb_entry(parent, struct nft_rbtree_elem, node); |
| 186 | |
Patrick McHardy | 7d74026 | 2015-04-11 02:27:39 +0100 | [diff] [blame] | 187 | d = memcmp(nft_set_ext_key(&rbe->ext), &elem->key.val, |
| 188 | set->klen); |
Patrick McHardy | 20a6934 | 2013-10-11 12:06:22 +0200 | [diff] [blame] | 189 | if (d < 0) |
| 190 | parent = parent->rb_left; |
| 191 | else if (d > 0) |
| 192 | parent = parent->rb_right; |
| 193 | else { |
Patrick McHardy | cc02e45 | 2015-03-25 14:08:50 +0000 | [diff] [blame] | 194 | if (!nft_set_elem_active(&rbe->ext, genmask)) { |
| 195 | parent = parent->rb_left; |
| 196 | continue; |
| 197 | } |
Pablo Neira Ayuso | e701001 | 2016-04-12 23:50:37 +0200 | [diff] [blame] | 198 | if (nft_rbtree_interval_end(rbe) && |
| 199 | !nft_rbtree_interval_end(this)) { |
| 200 | parent = parent->rb_left; |
| 201 | continue; |
| 202 | } else if (!nft_rbtree_interval_end(rbe) && |
| 203 | nft_rbtree_interval_end(this)) { |
| 204 | parent = parent->rb_right; |
| 205 | continue; |
| 206 | } |
Pablo Neira Ayuso | 42a5576 | 2016-07-08 14:41:49 +0200 | [diff] [blame] | 207 | nft_set_elem_change_active(net, set, &rbe->ext); |
Patrick McHardy | cc02e45 | 2015-03-25 14:08:50 +0000 | [diff] [blame] | 208 | return rbe; |
Patrick McHardy | 20a6934 | 2013-10-11 12:06:22 +0200 | [diff] [blame] | 209 | } |
| 210 | } |
Patrick McHardy | cc02e45 | 2015-03-25 14:08:50 +0000 | [diff] [blame] | 211 | return NULL; |
Patrick McHardy | 20a6934 | 2013-10-11 12:06:22 +0200 | [diff] [blame] | 212 | } |
| 213 | |
| 214 | static void nft_rbtree_walk(const struct nft_ctx *ctx, |
| 215 | const struct nft_set *set, |
| 216 | struct nft_set_iter *iter) |
| 217 | { |
| 218 | const struct nft_rbtree *priv = nft_set_priv(set); |
Patrick McHardy | fe2811e | 2015-03-25 13:07:50 +0000 | [diff] [blame] | 219 | struct nft_rbtree_elem *rbe; |
Patrick McHardy | 20a6934 | 2013-10-11 12:06:22 +0200 | [diff] [blame] | 220 | struct nft_set_elem elem; |
| 221 | struct rb_node *node; |
| 222 | |
Pablo Neira Ayuso | 7632667 | 2014-05-28 15:27:18 +0200 | [diff] [blame] | 223 | spin_lock_bh(&nft_rbtree_lock); |
Patrick McHardy | 20a6934 | 2013-10-11 12:06:22 +0200 | [diff] [blame] | 224 | for (node = rb_first(&priv->root); node != NULL; node = rb_next(node)) { |
Patrick McHardy | cc02e45 | 2015-03-25 14:08:50 +0000 | [diff] [blame] | 225 | rbe = rb_entry(node, struct nft_rbtree_elem, node); |
| 226 | |
Patrick McHardy | 20a6934 | 2013-10-11 12:06:22 +0200 | [diff] [blame] | 227 | if (iter->count < iter->skip) |
| 228 | goto cont; |
Pablo Neira Ayuso | 8588ac0 | 2016-06-11 12:20:27 +0800 | [diff] [blame] | 229 | if (!nft_set_elem_active(&rbe->ext, iter->genmask)) |
Patrick McHardy | cc02e45 | 2015-03-25 14:08:50 +0000 | [diff] [blame] | 230 | goto cont; |
Patrick McHardy | 20a6934 | 2013-10-11 12:06:22 +0200 | [diff] [blame] | 231 | |
Patrick McHardy | fe2811e | 2015-03-25 13:07:50 +0000 | [diff] [blame] | 232 | elem.priv = rbe; |
Patrick McHardy | 20a6934 | 2013-10-11 12:06:22 +0200 | [diff] [blame] | 233 | |
| 234 | iter->err = iter->fn(ctx, set, iter, &elem); |
Pablo Neira Ayuso | 7632667 | 2014-05-28 15:27:18 +0200 | [diff] [blame] | 235 | if (iter->err < 0) { |
| 236 | spin_unlock_bh(&nft_rbtree_lock); |
Patrick McHardy | 20a6934 | 2013-10-11 12:06:22 +0200 | [diff] [blame] | 237 | return; |
Pablo Neira Ayuso | 7632667 | 2014-05-28 15:27:18 +0200 | [diff] [blame] | 238 | } |
Patrick McHardy | 20a6934 | 2013-10-11 12:06:22 +0200 | [diff] [blame] | 239 | cont: |
| 240 | iter->count++; |
| 241 | } |
Pablo Neira Ayuso | 7632667 | 2014-05-28 15:27:18 +0200 | [diff] [blame] | 242 | spin_unlock_bh(&nft_rbtree_lock); |
Patrick McHardy | 20a6934 | 2013-10-11 12:06:22 +0200 | [diff] [blame] | 243 | } |
| 244 | |
| 245 | static unsigned int nft_rbtree_privsize(const struct nlattr * const nla[]) |
| 246 | { |
| 247 | return sizeof(struct nft_rbtree); |
| 248 | } |
| 249 | |
| 250 | static int nft_rbtree_init(const struct nft_set *set, |
Patrick McHardy | c50b960 | 2014-03-28 10:19:47 +0000 | [diff] [blame] | 251 | const struct nft_set_desc *desc, |
Patrick McHardy | 20a6934 | 2013-10-11 12:06:22 +0200 | [diff] [blame] | 252 | const struct nlattr * const nla[]) |
| 253 | { |
| 254 | struct nft_rbtree *priv = nft_set_priv(set); |
| 255 | |
| 256 | priv->root = RB_ROOT; |
| 257 | return 0; |
| 258 | } |
| 259 | |
| 260 | static void nft_rbtree_destroy(const struct nft_set *set) |
| 261 | { |
| 262 | struct nft_rbtree *priv = nft_set_priv(set); |
| 263 | struct nft_rbtree_elem *rbe; |
| 264 | struct rb_node *node; |
| 265 | |
| 266 | while ((node = priv->root.rb_node) != NULL) { |
| 267 | rb_erase(node, &priv->root); |
| 268 | rbe = rb_entry(node, struct nft_rbtree_elem, node); |
Liping Zhang | 61f9e29 | 2016-10-22 18:51:25 +0800 | [diff] [blame] | 269 | nft_set_elem_destroy(set, rbe, true); |
Patrick McHardy | 20a6934 | 2013-10-11 12:06:22 +0200 | [diff] [blame] | 270 | } |
| 271 | } |
| 272 | |
Patrick McHardy | c50b960 | 2014-03-28 10:19:47 +0000 | [diff] [blame] | 273 | static bool nft_rbtree_estimate(const struct nft_set_desc *desc, u32 features, |
| 274 | struct nft_set_estimate *est) |
| 275 | { |
| 276 | unsigned int nsize; |
| 277 | |
| 278 | nsize = sizeof(struct nft_rbtree_elem); |
Patrick McHardy | c50b960 | 2014-03-28 10:19:47 +0000 | [diff] [blame] | 279 | if (desc->size) |
| 280 | est->size = sizeof(struct nft_rbtree) + desc->size * nsize; |
| 281 | else |
| 282 | est->size = nsize; |
| 283 | |
| 284 | est->class = NFT_SET_CLASS_O_LOG_N; |
| 285 | |
| 286 | return true; |
| 287 | } |
| 288 | |
Patrick McHardy | 20a6934 | 2013-10-11 12:06:22 +0200 | [diff] [blame] | 289 | static struct nft_set_ops nft_rbtree_ops __read_mostly = { |
| 290 | .privsize = nft_rbtree_privsize, |
Patrick McHardy | fe2811e | 2015-03-25 13:07:50 +0000 | [diff] [blame] | 291 | .elemsize = offsetof(struct nft_rbtree_elem, ext), |
Patrick McHardy | c50b960 | 2014-03-28 10:19:47 +0000 | [diff] [blame] | 292 | .estimate = nft_rbtree_estimate, |
Patrick McHardy | 20a6934 | 2013-10-11 12:06:22 +0200 | [diff] [blame] | 293 | .init = nft_rbtree_init, |
| 294 | .destroy = nft_rbtree_destroy, |
| 295 | .insert = nft_rbtree_insert, |
| 296 | .remove = nft_rbtree_remove, |
Patrick McHardy | cc02e45 | 2015-03-25 14:08:50 +0000 | [diff] [blame] | 297 | .deactivate = nft_rbtree_deactivate, |
| 298 | .activate = nft_rbtree_activate, |
Patrick McHardy | 20a6934 | 2013-10-11 12:06:22 +0200 | [diff] [blame] | 299 | .lookup = nft_rbtree_lookup, |
| 300 | .walk = nft_rbtree_walk, |
| 301 | .features = NFT_SET_INTERVAL | NFT_SET_MAP, |
| 302 | .owner = THIS_MODULE, |
| 303 | }; |
| 304 | |
| 305 | static int __init nft_rbtree_module_init(void) |
| 306 | { |
| 307 | return nft_register_set(&nft_rbtree_ops); |
| 308 | } |
| 309 | |
| 310 | static void __exit nft_rbtree_module_exit(void) |
| 311 | { |
| 312 | nft_unregister_set(&nft_rbtree_ops); |
| 313 | } |
| 314 | |
| 315 | module_init(nft_rbtree_module_init); |
| 316 | module_exit(nft_rbtree_module_exit); |
| 317 | |
| 318 | MODULE_LICENSE("GPL"); |
| 319 | MODULE_AUTHOR("Patrick McHardy <kaber@trash.net>"); |
| 320 | MODULE_ALIAS_NFT_SET(); |