Jan Engelhardt | 64eb12f | 2008-01-14 23:40:53 -0800 | [diff] [blame] | 1 | /* |
| 2 | * xt_conntrack - Netfilter module to match connection tracking |
| 3 | * information. (Superset of Rusty's minimalistic state match.) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * |
Jan Engelhardt | 64eb12f | 2008-01-14 23:40:53 -0800 | [diff] [blame] | 5 | * (C) 2001 Marc Boucher (marc@mbsi.ca). |
| 6 | * Copyright © CC Computer Consultants GmbH, 2007 - 2008 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | * |
Jan Engelhardt | 64eb12f | 2008-01-14 23:40:53 -0800 | [diff] [blame] | 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License version 2 as |
| 10 | * published by the Free Software Foundation. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | */ |
Jan Engelhardt | 8bee4ba | 2010-03-17 16:04:40 +0100 | [diff] [blame] | 12 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | #include <linux/module.h> |
| 14 | #include <linux/skbuff.h> |
Jan Engelhardt | 64eb12f | 2008-01-14 23:40:53 -0800 | [diff] [blame] | 15 | #include <net/ipv6.h> |
Harald Welte | 2e4e6a1 | 2006-01-12 13:30:04 -0800 | [diff] [blame] | 16 | #include <linux/netfilter/x_tables.h> |
| 17 | #include <linux/netfilter/xt_conntrack.h> |
Patrick McHardy | 587aa64 | 2007-03-14 16:37:25 -0700 | [diff] [blame] | 18 | #include <net/netfilter/nf_conntrack.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | |
| 20 | MODULE_LICENSE("GPL"); |
| 21 | MODULE_AUTHOR("Marc Boucher <marc@mbsi.ca>"); |
Jan Engelhardt | 9e05ec4 | 2009-06-12 18:56:14 +0200 | [diff] [blame] | 22 | MODULE_AUTHOR("Jan Engelhardt <jengelh@medozas.de>"); |
Jan Engelhardt | 2ae15b6 | 2008-01-14 23:42:28 -0800 | [diff] [blame] | 23 | MODULE_DESCRIPTION("Xtables: connection tracking state match"); |
Harald Welte | 2e4e6a1 | 2006-01-12 13:30:04 -0800 | [diff] [blame] | 24 | MODULE_ALIAS("ipt_conntrack"); |
Jan Engelhardt | 64eb12f | 2008-01-14 23:40:53 -0800 | [diff] [blame] | 25 | MODULE_ALIAS("ip6t_conntrack"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | |
Jan Engelhardt | 1d93a9c | 2007-07-07 22:15:35 -0700 | [diff] [blame] | 27 | static bool |
Jan Engelhardt | 64eb12f | 2008-01-14 23:40:53 -0800 | [diff] [blame] | 28 | conntrack_addrcmp(const union nf_inet_addr *kaddr, |
| 29 | const union nf_inet_addr *uaddr, |
| 30 | const union nf_inet_addr *umask, unsigned int l3proto) |
| 31 | { |
Jan Engelhardt | ee999d8 | 2008-10-08 11:35:01 +0200 | [diff] [blame] | 32 | if (l3proto == NFPROTO_IPV4) |
Jan Engelhardt | 6556874 | 2008-02-27 12:20:41 -0800 | [diff] [blame] | 33 | return ((kaddr->ip ^ uaddr->ip) & umask->ip) == 0; |
Jan Engelhardt | ee999d8 | 2008-10-08 11:35:01 +0200 | [diff] [blame] | 34 | else if (l3proto == NFPROTO_IPV6) |
Jan Engelhardt | 64eb12f | 2008-01-14 23:40:53 -0800 | [diff] [blame] | 35 | return ipv6_masked_addr_cmp(&kaddr->in6, &umask->in6, |
| 36 | &uaddr->in6) == 0; |
| 37 | else |
| 38 | return false; |
| 39 | } |
| 40 | |
| 41 | static inline bool |
| 42 | conntrack_mt_origsrc(const struct nf_conn *ct, |
Jan Engelhardt | d6d3f08 | 2009-06-29 14:31:46 +0200 | [diff] [blame] | 43 | const struct xt_conntrack_mtinfo2 *info, |
Jan Engelhardt | 76108ce | 2008-10-08 11:35:00 +0200 | [diff] [blame] | 44 | u_int8_t family) |
Jan Engelhardt | 64eb12f | 2008-01-14 23:40:53 -0800 | [diff] [blame] | 45 | { |
| 46 | return conntrack_addrcmp(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.src.u3, |
| 47 | &info->origsrc_addr, &info->origsrc_mask, family); |
| 48 | } |
| 49 | |
| 50 | static inline bool |
| 51 | conntrack_mt_origdst(const struct nf_conn *ct, |
Jan Engelhardt | d6d3f08 | 2009-06-29 14:31:46 +0200 | [diff] [blame] | 52 | const struct xt_conntrack_mtinfo2 *info, |
Jan Engelhardt | 76108ce | 2008-10-08 11:35:00 +0200 | [diff] [blame] | 53 | u_int8_t family) |
Jan Engelhardt | 64eb12f | 2008-01-14 23:40:53 -0800 | [diff] [blame] | 54 | { |
| 55 | return conntrack_addrcmp(&ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple.dst.u3, |
| 56 | &info->origdst_addr, &info->origdst_mask, family); |
| 57 | } |
| 58 | |
| 59 | static inline bool |
| 60 | conntrack_mt_replsrc(const struct nf_conn *ct, |
Jan Engelhardt | d6d3f08 | 2009-06-29 14:31:46 +0200 | [diff] [blame] | 61 | const struct xt_conntrack_mtinfo2 *info, |
Jan Engelhardt | 76108ce | 2008-10-08 11:35:00 +0200 | [diff] [blame] | 62 | u_int8_t family) |
Jan Engelhardt | 64eb12f | 2008-01-14 23:40:53 -0800 | [diff] [blame] | 63 | { |
| 64 | return conntrack_addrcmp(&ct->tuplehash[IP_CT_DIR_REPLY].tuple.src.u3, |
| 65 | &info->replsrc_addr, &info->replsrc_mask, family); |
| 66 | } |
| 67 | |
| 68 | static inline bool |
| 69 | conntrack_mt_repldst(const struct nf_conn *ct, |
Jan Engelhardt | d6d3f08 | 2009-06-29 14:31:46 +0200 | [diff] [blame] | 70 | const struct xt_conntrack_mtinfo2 *info, |
Jan Engelhardt | 76108ce | 2008-10-08 11:35:00 +0200 | [diff] [blame] | 71 | u_int8_t family) |
Jan Engelhardt | 64eb12f | 2008-01-14 23:40:53 -0800 | [diff] [blame] | 72 | { |
| 73 | return conntrack_addrcmp(&ct->tuplehash[IP_CT_DIR_REPLY].tuple.dst.u3, |
| 74 | &info->repldst_addr, &info->repldst_mask, family); |
| 75 | } |
| 76 | |
Jan Engelhardt | b416499 | 2008-01-31 03:58:24 -0800 | [diff] [blame] | 77 | static inline bool |
Jan Engelhardt | d6d3f08 | 2009-06-29 14:31:46 +0200 | [diff] [blame] | 78 | ct_proto_port_check(const struct xt_conntrack_mtinfo2 *info, |
Jan Engelhardt | b416499 | 2008-01-31 03:58:24 -0800 | [diff] [blame] | 79 | const struct nf_conn *ct) |
| 80 | { |
| 81 | const struct nf_conntrack_tuple *tuple; |
| 82 | |
| 83 | tuple = &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple; |
| 84 | if ((info->match_flags & XT_CONNTRACK_PROTO) && |
Patrick McHardy | 5e8fbe2 | 2008-04-14 11:15:52 +0200 | [diff] [blame] | 85 | (nf_ct_protonum(ct) == info->l4proto) ^ |
Jan Engelhardt | b416499 | 2008-01-31 03:58:24 -0800 | [diff] [blame] | 86 | !(info->invert_flags & XT_CONNTRACK_PROTO)) |
| 87 | return false; |
| 88 | |
| 89 | /* Shortcut to match all recognized protocols by using ->src.all. */ |
| 90 | if ((info->match_flags & XT_CONNTRACK_ORIGSRC_PORT) && |
| 91 | (tuple->src.u.all == info->origsrc_port) ^ |
| 92 | !(info->invert_flags & XT_CONNTRACK_ORIGSRC_PORT)) |
| 93 | return false; |
| 94 | |
| 95 | if ((info->match_flags & XT_CONNTRACK_ORIGDST_PORT) && |
| 96 | (tuple->dst.u.all == info->origdst_port) ^ |
| 97 | !(info->invert_flags & XT_CONNTRACK_ORIGDST_PORT)) |
| 98 | return false; |
| 99 | |
| 100 | tuple = &ct->tuplehash[IP_CT_DIR_REPLY].tuple; |
| 101 | |
| 102 | if ((info->match_flags & XT_CONNTRACK_REPLSRC_PORT) && |
| 103 | (tuple->src.u.all == info->replsrc_port) ^ |
| 104 | !(info->invert_flags & XT_CONNTRACK_REPLSRC_PORT)) |
| 105 | return false; |
| 106 | |
| 107 | if ((info->match_flags & XT_CONNTRACK_REPLDST_PORT) && |
| 108 | (tuple->dst.u.all == info->repldst_port) ^ |
| 109 | !(info->invert_flags & XT_CONNTRACK_REPLDST_PORT)) |
| 110 | return false; |
| 111 | |
| 112 | return true; |
| 113 | } |
| 114 | |
Patrick McHardy | b017900 | 2010-12-15 09:46:26 +0100 | [diff] [blame] | 115 | static inline bool |
| 116 | port_match(u16 min, u16 max, u16 port, bool invert) |
| 117 | { |
| 118 | return (port >= min && port <= max) ^ invert; |
| 119 | } |
| 120 | |
| 121 | static inline bool |
| 122 | ct_proto_port_check_v3(const struct xt_conntrack_mtinfo3 *info, |
| 123 | const struct nf_conn *ct) |
| 124 | { |
| 125 | const struct nf_conntrack_tuple *tuple; |
| 126 | |
| 127 | tuple = &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple; |
| 128 | if ((info->match_flags & XT_CONNTRACK_PROTO) && |
| 129 | (nf_ct_protonum(ct) == info->l4proto) ^ |
| 130 | !(info->invert_flags & XT_CONNTRACK_PROTO)) |
| 131 | return false; |
| 132 | |
| 133 | /* Shortcut to match all recognized protocols by using ->src.all. */ |
| 134 | if ((info->match_flags & XT_CONNTRACK_ORIGSRC_PORT) && |
| 135 | !port_match(info->origsrc_port, info->origsrc_port_high, |
| 136 | ntohs(tuple->src.u.all), |
| 137 | info->invert_flags & XT_CONNTRACK_ORIGSRC_PORT)) |
| 138 | return false; |
| 139 | |
| 140 | if ((info->match_flags & XT_CONNTRACK_ORIGDST_PORT) && |
| 141 | !port_match(info->origdst_port, info->origdst_port_high, |
| 142 | ntohs(tuple->dst.u.all), |
| 143 | info->invert_flags & XT_CONNTRACK_ORIGDST_PORT)) |
| 144 | return false; |
| 145 | |
| 146 | tuple = &ct->tuplehash[IP_CT_DIR_REPLY].tuple; |
| 147 | |
| 148 | if ((info->match_flags & XT_CONNTRACK_REPLSRC_PORT) && |
| 149 | !port_match(info->replsrc_port, info->replsrc_port_high, |
| 150 | ntohs(tuple->src.u.all), |
| 151 | info->invert_flags & XT_CONNTRACK_REPLSRC_PORT)) |
| 152 | return false; |
| 153 | |
| 154 | if ((info->match_flags & XT_CONNTRACK_REPLDST_PORT) && |
| 155 | !port_match(info->repldst_port, info->repldst_port_high, |
| 156 | ntohs(tuple->dst.u.all), |
| 157 | info->invert_flags & XT_CONNTRACK_REPLDST_PORT)) |
| 158 | return false; |
| 159 | |
| 160 | return true; |
| 161 | } |
| 162 | |
Jan Engelhardt | 64eb12f | 2008-01-14 23:40:53 -0800 | [diff] [blame] | 163 | static bool |
Jan Engelhardt | 62fc805 | 2009-07-07 20:42:08 +0200 | [diff] [blame] | 164 | conntrack_mt(const struct sk_buff *skb, struct xt_action_param *par, |
Florian Westphal | 3a04292 | 2009-11-23 10:43:57 +0100 | [diff] [blame] | 165 | u16 state_mask, u16 status_mask) |
Jan Engelhardt | 64eb12f | 2008-01-14 23:40:53 -0800 | [diff] [blame] | 166 | { |
Jan Engelhardt | d6d3f08 | 2009-06-29 14:31:46 +0200 | [diff] [blame] | 167 | const struct xt_conntrack_mtinfo2 *info = par->matchinfo; |
Jan Engelhardt | 64eb12f | 2008-01-14 23:40:53 -0800 | [diff] [blame] | 168 | enum ip_conntrack_info ctinfo; |
| 169 | const struct nf_conn *ct; |
| 170 | unsigned int statebit; |
| 171 | |
| 172 | ct = nf_ct_get(skb, &ctinfo); |
| 173 | |
Eric Dumazet | 5bfddbd | 2010-06-08 16:09:52 +0200 | [diff] [blame] | 174 | if (ct) { |
| 175 | if (nf_ct_is_untracked(ct)) |
| 176 | statebit = XT_CONNTRACK_STATE_UNTRACKED; |
| 177 | else |
| 178 | statebit = XT_CONNTRACK_STATE_BIT(ctinfo); |
| 179 | } else |
Jan Engelhardt | 64eb12f | 2008-01-14 23:40:53 -0800 | [diff] [blame] | 180 | statebit = XT_CONNTRACK_STATE_INVALID; |
| 181 | |
| 182 | if (info->match_flags & XT_CONNTRACK_STATE) { |
| 183 | if (ct != NULL) { |
| 184 | if (test_bit(IPS_SRC_NAT_BIT, &ct->status)) |
| 185 | statebit |= XT_CONNTRACK_STATE_SNAT; |
| 186 | if (test_bit(IPS_DST_NAT_BIT, &ct->status)) |
| 187 | statebit |= XT_CONNTRACK_STATE_DNAT; |
| 188 | } |
Florian Westphal | 3a04292 | 2009-11-23 10:43:57 +0100 | [diff] [blame] | 189 | if (!!(state_mask & statebit) ^ |
Jan Engelhardt | 64eb12f | 2008-01-14 23:40:53 -0800 | [diff] [blame] | 190 | !(info->invert_flags & XT_CONNTRACK_STATE)) |
| 191 | return false; |
| 192 | } |
| 193 | |
| 194 | if (ct == NULL) |
| 195 | return info->match_flags & XT_CONNTRACK_STATE; |
Jan Engelhardt | b416499 | 2008-01-31 03:58:24 -0800 | [diff] [blame] | 196 | if ((info->match_flags & XT_CONNTRACK_DIRECTION) && |
| 197 | (CTINFO2DIR(ctinfo) == IP_CT_DIR_ORIGINAL) ^ |
Florian Westphal | 96120d8 | 2011-04-04 17:06:21 +0200 | [diff] [blame] | 198 | !(info->invert_flags & XT_CONNTRACK_DIRECTION)) |
Jan Engelhardt | 64eb12f | 2008-01-14 23:40:53 -0800 | [diff] [blame] | 199 | return false; |
| 200 | |
| 201 | if (info->match_flags & XT_CONNTRACK_ORIGSRC) |
Jan Engelhardt | 92f3b2b | 2008-10-08 11:35:20 +0200 | [diff] [blame] | 202 | if (conntrack_mt_origsrc(ct, info, par->family) ^ |
Jan Engelhardt | 64eb12f | 2008-01-14 23:40:53 -0800 | [diff] [blame] | 203 | !(info->invert_flags & XT_CONNTRACK_ORIGSRC)) |
| 204 | return false; |
| 205 | |
| 206 | if (info->match_flags & XT_CONNTRACK_ORIGDST) |
Jan Engelhardt | 92f3b2b | 2008-10-08 11:35:20 +0200 | [diff] [blame] | 207 | if (conntrack_mt_origdst(ct, info, par->family) ^ |
Jan Engelhardt | 64eb12f | 2008-01-14 23:40:53 -0800 | [diff] [blame] | 208 | !(info->invert_flags & XT_CONNTRACK_ORIGDST)) |
| 209 | return false; |
| 210 | |
| 211 | if (info->match_flags & XT_CONNTRACK_REPLSRC) |
Jan Engelhardt | 92f3b2b | 2008-10-08 11:35:20 +0200 | [diff] [blame] | 212 | if (conntrack_mt_replsrc(ct, info, par->family) ^ |
Jan Engelhardt | 64eb12f | 2008-01-14 23:40:53 -0800 | [diff] [blame] | 213 | !(info->invert_flags & XT_CONNTRACK_REPLSRC)) |
| 214 | return false; |
| 215 | |
| 216 | if (info->match_flags & XT_CONNTRACK_REPLDST) |
Jan Engelhardt | 92f3b2b | 2008-10-08 11:35:20 +0200 | [diff] [blame] | 217 | if (conntrack_mt_repldst(ct, info, par->family) ^ |
Jan Engelhardt | 64eb12f | 2008-01-14 23:40:53 -0800 | [diff] [blame] | 218 | !(info->invert_flags & XT_CONNTRACK_REPLDST)) |
| 219 | return false; |
| 220 | |
Patrick McHardy | b017900 | 2010-12-15 09:46:26 +0100 | [diff] [blame] | 221 | if (par->match->revision != 3) { |
| 222 | if (!ct_proto_port_check(info, ct)) |
| 223 | return false; |
| 224 | } else { |
| 225 | if (!ct_proto_port_check_v3(par->matchinfo, ct)) |
| 226 | return false; |
| 227 | } |
Jan Engelhardt | b416499 | 2008-01-31 03:58:24 -0800 | [diff] [blame] | 228 | |
Jan Engelhardt | 64eb12f | 2008-01-14 23:40:53 -0800 | [diff] [blame] | 229 | if ((info->match_flags & XT_CONNTRACK_STATUS) && |
Florian Westphal | 3a04292 | 2009-11-23 10:43:57 +0100 | [diff] [blame] | 230 | (!!(status_mask & ct->status) ^ |
Jan Engelhardt | 64eb12f | 2008-01-14 23:40:53 -0800 | [diff] [blame] | 231 | !(info->invert_flags & XT_CONNTRACK_STATUS))) |
| 232 | return false; |
| 233 | |
| 234 | if (info->match_flags & XT_CONNTRACK_EXPIRES) { |
| 235 | unsigned long expires = 0; |
| 236 | |
| 237 | if (timer_pending(&ct->timeout)) |
| 238 | expires = (ct->timeout.expires - jiffies) / HZ; |
| 239 | if ((expires >= info->expires_min && |
| 240 | expires <= info->expires_max) ^ |
| 241 | !(info->invert_flags & XT_CONNTRACK_EXPIRES)) |
| 242 | return false; |
| 243 | } |
| 244 | return true; |
| 245 | } |
| 246 | |
Jan Engelhardt | d6d3f08 | 2009-06-29 14:31:46 +0200 | [diff] [blame] | 247 | static bool |
Jan Engelhardt | 62fc805 | 2009-07-07 20:42:08 +0200 | [diff] [blame] | 248 | conntrack_mt_v1(const struct sk_buff *skb, struct xt_action_param *par) |
Jan Engelhardt | d6d3f08 | 2009-06-29 14:31:46 +0200 | [diff] [blame] | 249 | { |
Florian Westphal | 3a04292 | 2009-11-23 10:43:57 +0100 | [diff] [blame] | 250 | const struct xt_conntrack_mtinfo1 *info = par->matchinfo; |
Jan Engelhardt | d6d3f08 | 2009-06-29 14:31:46 +0200 | [diff] [blame] | 251 | |
Florian Westphal | 3a04292 | 2009-11-23 10:43:57 +0100 | [diff] [blame] | 252 | return conntrack_mt(skb, par, info->state_mask, info->status_mask); |
| 253 | } |
| 254 | |
| 255 | static bool |
Jan Engelhardt | 62fc805 | 2009-07-07 20:42:08 +0200 | [diff] [blame] | 256 | conntrack_mt_v2(const struct sk_buff *skb, struct xt_action_param *par) |
Florian Westphal | 3a04292 | 2009-11-23 10:43:57 +0100 | [diff] [blame] | 257 | { |
| 258 | const struct xt_conntrack_mtinfo2 *info = par->matchinfo; |
| 259 | |
| 260 | return conntrack_mt(skb, par, info->state_mask, info->status_mask); |
Jan Engelhardt | d6d3f08 | 2009-06-29 14:31:46 +0200 | [diff] [blame] | 261 | } |
| 262 | |
Patrick McHardy | b017900 | 2010-12-15 09:46:26 +0100 | [diff] [blame] | 263 | static bool |
| 264 | conntrack_mt_v3(const struct sk_buff *skb, struct xt_action_param *par) |
| 265 | { |
| 266 | const struct xt_conntrack_mtinfo3 *info = par->matchinfo; |
| 267 | |
| 268 | return conntrack_mt(skb, par, info->state_mask, info->status_mask); |
| 269 | } |
| 270 | |
Jan Engelhardt | b0f3845 | 2010-03-19 17:16:42 +0100 | [diff] [blame] | 271 | static int conntrack_mt_check(const struct xt_mtchk_param *par) |
Pablo Neira Ayuso | b9f78f9 | 2006-03-22 13:56:08 -0800 | [diff] [blame] | 272 | { |
Jan Engelhardt | 4a5a5c7 | 2010-03-19 17:32:59 +0100 | [diff] [blame] | 273 | int ret; |
| 274 | |
Jan Engelhardt | a2361c8 | 2011-02-14 17:28:55 +0100 | [diff] [blame] | 275 | if (strcmp(par->table, "raw") == 0) { |
| 276 | pr_info("state is undetermined at the time of raw table\n"); |
| 277 | return -EINVAL; |
| 278 | } |
| 279 | |
Jan Engelhardt | 4a5a5c7 | 2010-03-19 17:32:59 +0100 | [diff] [blame] | 280 | ret = nf_ct_l3proto_try_module_get(par->family); |
Jan Engelhardt | f95c74e | 2010-03-21 04:05:56 +0100 | [diff] [blame] | 281 | if (ret < 0) |
Jan Engelhardt | 8bee4ba | 2010-03-17 16:04:40 +0100 | [diff] [blame] | 282 | pr_info("cannot load conntrack support for proto=%u\n", |
| 283 | par->family); |
Jan Engelhardt | f95c74e | 2010-03-21 04:05:56 +0100 | [diff] [blame] | 284 | return ret; |
Pablo Neira Ayuso | b9f78f9 | 2006-03-22 13:56:08 -0800 | [diff] [blame] | 285 | } |
| 286 | |
Jan Engelhardt | 6be3d85 | 2008-10-08 11:35:19 +0200 | [diff] [blame] | 287 | static void conntrack_mt_destroy(const struct xt_mtdtor_param *par) |
Pablo Neira Ayuso | b9f78f9 | 2006-03-22 13:56:08 -0800 | [diff] [blame] | 288 | { |
Jan Engelhardt | 92f3b2b | 2008-10-08 11:35:20 +0200 | [diff] [blame] | 289 | nf_ct_l3proto_module_put(par->family); |
Pablo Neira Ayuso | b9f78f9 | 2006-03-22 13:56:08 -0800 | [diff] [blame] | 290 | } |
| 291 | |
Jan Engelhardt | 64eb12f | 2008-01-14 23:40:53 -0800 | [diff] [blame] | 292 | static struct xt_match conntrack_mt_reg[] __read_mostly = { |
| 293 | { |
| 294 | .name = "conntrack", |
Jan Engelhardt | 64eb12f | 2008-01-14 23:40:53 -0800 | [diff] [blame] | 295 | .revision = 1, |
Jan Engelhardt | 92f3b2b | 2008-10-08 11:35:20 +0200 | [diff] [blame] | 296 | .family = NFPROTO_UNSPEC, |
Jan Engelhardt | 64eb12f | 2008-01-14 23:40:53 -0800 | [diff] [blame] | 297 | .matchsize = sizeof(struct xt_conntrack_mtinfo1), |
Jan Engelhardt | d6d3f08 | 2009-06-29 14:31:46 +0200 | [diff] [blame] | 298 | .match = conntrack_mt_v1, |
Florian Westphal | 3a04292 | 2009-11-23 10:43:57 +0100 | [diff] [blame] | 299 | .checkentry = conntrack_mt_check, |
| 300 | .destroy = conntrack_mt_destroy, |
Jan Engelhardt | d6d3f08 | 2009-06-29 14:31:46 +0200 | [diff] [blame] | 301 | .me = THIS_MODULE, |
| 302 | }, |
| 303 | { |
| 304 | .name = "conntrack", |
| 305 | .revision = 2, |
| 306 | .family = NFPROTO_UNSPEC, |
| 307 | .matchsize = sizeof(struct xt_conntrack_mtinfo2), |
Florian Westphal | 3a04292 | 2009-11-23 10:43:57 +0100 | [diff] [blame] | 308 | .match = conntrack_mt_v2, |
Jan Engelhardt | 64eb12f | 2008-01-14 23:40:53 -0800 | [diff] [blame] | 309 | .checkentry = conntrack_mt_check, |
| 310 | .destroy = conntrack_mt_destroy, |
| 311 | .me = THIS_MODULE, |
| 312 | }, |
Patrick McHardy | b017900 | 2010-12-15 09:46:26 +0100 | [diff] [blame] | 313 | { |
| 314 | .name = "conntrack", |
| 315 | .revision = 3, |
| 316 | .family = NFPROTO_UNSPEC, |
| 317 | .matchsize = sizeof(struct xt_conntrack_mtinfo3), |
| 318 | .match = conntrack_mt_v3, |
| 319 | .checkentry = conntrack_mt_check, |
| 320 | .destroy = conntrack_mt_destroy, |
| 321 | .me = THIS_MODULE, |
| 322 | }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 323 | }; |
| 324 | |
Jan Engelhardt | d3c5ee6 | 2007-12-04 23:24:03 -0800 | [diff] [blame] | 325 | static int __init conntrack_mt_init(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 326 | { |
Jan Engelhardt | 64eb12f | 2008-01-14 23:40:53 -0800 | [diff] [blame] | 327 | return xt_register_matches(conntrack_mt_reg, |
| 328 | ARRAY_SIZE(conntrack_mt_reg)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 329 | } |
| 330 | |
Jan Engelhardt | d3c5ee6 | 2007-12-04 23:24:03 -0800 | [diff] [blame] | 331 | static void __exit conntrack_mt_exit(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 332 | { |
Jan Engelhardt | 64eb12f | 2008-01-14 23:40:53 -0800 | [diff] [blame] | 333 | xt_unregister_matches(conntrack_mt_reg, ARRAY_SIZE(conntrack_mt_reg)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 334 | } |
| 335 | |
Jan Engelhardt | d3c5ee6 | 2007-12-04 23:24:03 -0800 | [diff] [blame] | 336 | module_init(conntrack_mt_init); |
| 337 | module_exit(conntrack_mt_exit); |