Herbert Xu | b421995 | 2007-09-27 12:48:05 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Stateless NAT actions |
| 3 | * |
| 4 | * Copyright (c) 2007 Herbert Xu <herbert@gondor.apana.org.au> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify it |
| 7 | * under the terms of the GNU General Public License as published by the Free |
| 8 | * Software Foundation; either version 2 of the License, or (at your option) |
| 9 | * any later version. |
| 10 | */ |
| 11 | |
| 12 | #include <linux/errno.h> |
| 13 | #include <linux/init.h> |
| 14 | #include <linux/kernel.h> |
| 15 | #include <linux/module.h> |
| 16 | #include <linux/netfilter.h> |
| 17 | #include <linux/rtnetlink.h> |
| 18 | #include <linux/skbuff.h> |
| 19 | #include <linux/slab.h> |
| 20 | #include <linux/spinlock.h> |
| 21 | #include <linux/string.h> |
| 22 | #include <linux/tc_act/tc_nat.h> |
| 23 | #include <net/act_api.h> |
| 24 | #include <net/icmp.h> |
| 25 | #include <net/ip.h> |
| 26 | #include <net/netlink.h> |
| 27 | #include <net/tc_act/tc_nat.h> |
| 28 | #include <net/tcp.h> |
| 29 | #include <net/udp.h> |
| 30 | |
| 31 | |
Alexey Dobriyan | c7d03a0 | 2016-11-17 04:58:21 +0300 | [diff] [blame] | 32 | static unsigned int nat_net_id; |
WANG Cong | a85a970 | 2016-07-25 16:09:41 -0700 | [diff] [blame] | 33 | static struct tc_action_ops act_nat_ops; |
WANG Cong | ddf97cc | 2016-02-22 15:57:53 -0800 | [diff] [blame] | 34 | |
Patrick McHardy | 53b2bf3 | 2008-01-23 20:36:30 -0800 | [diff] [blame] | 35 | static const struct nla_policy nat_policy[TCA_NAT_MAX + 1] = { |
| 36 | [TCA_NAT_PARMS] = { .len = sizeof(struct tc_nat) }, |
| 37 | }; |
| 38 | |
Benjamin LaHaise | c1b5273 | 2013-01-14 05:15:39 +0000 | [diff] [blame] | 39 | static int tcf_nat_init(struct net *net, struct nlattr *nla, struct nlattr *est, |
WANG Cong | a85a970 | 2016-07-25 16:09:41 -0700 | [diff] [blame] | 40 | struct tc_action **a, int ovr, int bind) |
Herbert Xu | b421995 | 2007-09-27 12:48:05 -0700 | [diff] [blame] | 41 | { |
WANG Cong | ddf97cc | 2016-02-22 15:57:53 -0800 | [diff] [blame] | 42 | struct tc_action_net *tn = net_generic(net, nat_net_id); |
Patrick McHardy | 7ba699c | 2008-01-22 22:11:50 -0800 | [diff] [blame] | 43 | struct nlattr *tb[TCA_NAT_MAX + 1]; |
Herbert Xu | b421995 | 2007-09-27 12:48:05 -0700 | [diff] [blame] | 44 | struct tc_nat *parm; |
Patrick McHardy | cee6372 | 2008-01-23 20:33:32 -0800 | [diff] [blame] | 45 | int ret = 0, err; |
Herbert Xu | b421995 | 2007-09-27 12:48:05 -0700 | [diff] [blame] | 46 | struct tcf_nat *p; |
Herbert Xu | b421995 | 2007-09-27 12:48:05 -0700 | [diff] [blame] | 47 | |
Patrick McHardy | cee6372 | 2008-01-23 20:33:32 -0800 | [diff] [blame] | 48 | if (nla == NULL) |
Herbert Xu | b421995 | 2007-09-27 12:48:05 -0700 | [diff] [blame] | 49 | return -EINVAL; |
| 50 | |
Johannes Berg | fceb643 | 2017-04-12 14:34:07 +0200 | [diff] [blame] | 51 | err = nla_parse_nested(tb, TCA_NAT_MAX, nla, nat_policy, NULL); |
Patrick McHardy | cee6372 | 2008-01-23 20:33:32 -0800 | [diff] [blame] | 52 | if (err < 0) |
| 53 | return err; |
| 54 | |
Patrick McHardy | 53b2bf3 | 2008-01-23 20:36:30 -0800 | [diff] [blame] | 55 | if (tb[TCA_NAT_PARMS] == NULL) |
Herbert Xu | b421995 | 2007-09-27 12:48:05 -0700 | [diff] [blame] | 56 | return -EINVAL; |
Patrick McHardy | 7ba699c | 2008-01-22 22:11:50 -0800 | [diff] [blame] | 57 | parm = nla_data(tb[TCA_NAT_PARMS]); |
Herbert Xu | b421995 | 2007-09-27 12:48:05 -0700 | [diff] [blame] | 58 | |
Chris Mi | 65a206c | 2017-08-30 02:31:59 -0400 | [diff] [blame] | 59 | if (!tcf_idr_check(tn, parm->index, a, bind)) { |
| 60 | ret = tcf_idr_create(tn, parm->index, est, a, |
| 61 | &act_nat_ops, bind, false); |
WANG Cong | 8606203 | 2014-02-11 17:07:31 -0800 | [diff] [blame] | 62 | if (ret) |
| 63 | return ret; |
Herbert Xu | b421995 | 2007-09-27 12:48:05 -0700 | [diff] [blame] | 64 | ret = ACT_P_CREATED; |
| 65 | } else { |
Jamal Hadi Salim | 1a29321 | 2013-12-23 08:02:11 -0500 | [diff] [blame] | 66 | if (bind) |
| 67 | return 0; |
Chris Mi | 65a206c | 2017-08-30 02:31:59 -0400 | [diff] [blame] | 68 | tcf_idr_release(*a, bind); |
Jamal Hadi Salim | 1a29321 | 2013-12-23 08:02:11 -0500 | [diff] [blame] | 69 | if (!ovr) |
Herbert Xu | b421995 | 2007-09-27 12:48:05 -0700 | [diff] [blame] | 70 | return -EEXIST; |
Herbert Xu | b421995 | 2007-09-27 12:48:05 -0700 | [diff] [blame] | 71 | } |
WANG Cong | a85a970 | 2016-07-25 16:09:41 -0700 | [diff] [blame] | 72 | p = to_tcf_nat(*a); |
Herbert Xu | b421995 | 2007-09-27 12:48:05 -0700 | [diff] [blame] | 73 | |
| 74 | spin_lock_bh(&p->tcf_lock); |
| 75 | p->old_addr = parm->old_addr; |
| 76 | p->new_addr = parm->new_addr; |
| 77 | p->mask = parm->mask; |
| 78 | p->flags = parm->flags; |
| 79 | |
| 80 | p->tcf_action = parm->action; |
| 81 | spin_unlock_bh(&p->tcf_lock); |
| 82 | |
| 83 | if (ret == ACT_P_CREATED) |
Chris Mi | 65a206c | 2017-08-30 02:31:59 -0400 | [diff] [blame] | 84 | tcf_idr_insert(tn, *a); |
Herbert Xu | b421995 | 2007-09-27 12:48:05 -0700 | [diff] [blame] | 85 | |
| 86 | return ret; |
| 87 | } |
| 88 | |
Eric Dumazet | dc7f9f6 | 2011-07-05 23:25:42 +0000 | [diff] [blame] | 89 | static int tcf_nat(struct sk_buff *skb, const struct tc_action *a, |
Herbert Xu | b421995 | 2007-09-27 12:48:05 -0700 | [diff] [blame] | 90 | struct tcf_result *res) |
| 91 | { |
WANG Cong | a85a970 | 2016-07-25 16:09:41 -0700 | [diff] [blame] | 92 | struct tcf_nat *p = to_tcf_nat(a); |
Herbert Xu | b421995 | 2007-09-27 12:48:05 -0700 | [diff] [blame] | 93 | struct iphdr *iph; |
| 94 | __be32 old_addr; |
| 95 | __be32 new_addr; |
| 96 | __be32 mask; |
| 97 | __be32 addr; |
| 98 | int egress; |
| 99 | int action; |
| 100 | int ihl; |
Changli Gao | 36d1269 | 2010-08-03 17:39:18 +0000 | [diff] [blame] | 101 | int noff; |
Herbert Xu | b421995 | 2007-09-27 12:48:05 -0700 | [diff] [blame] | 102 | |
| 103 | spin_lock(&p->tcf_lock); |
| 104 | |
Jamal Hadi Salim | 9c4a4e4 | 2016-06-06 06:32:53 -0400 | [diff] [blame] | 105 | tcf_lastuse_update(&p->tcf_tm); |
Herbert Xu | b421995 | 2007-09-27 12:48:05 -0700 | [diff] [blame] | 106 | old_addr = p->old_addr; |
| 107 | new_addr = p->new_addr; |
| 108 | mask = p->mask; |
| 109 | egress = p->flags & TCA_NAT_FLAG_EGRESS; |
| 110 | action = p->tcf_action; |
| 111 | |
Eric Dumazet | bfe0d02 | 2011-01-09 08:30:54 +0000 | [diff] [blame] | 112 | bstats_update(&p->tcf_bstats, skb); |
Herbert Xu | b421995 | 2007-09-27 12:48:05 -0700 | [diff] [blame] | 113 | |
| 114 | spin_unlock(&p->tcf_lock); |
| 115 | |
| 116 | if (unlikely(action == TC_ACT_SHOT)) |
| 117 | goto drop; |
| 118 | |
Changli Gao | 36d1269 | 2010-08-03 17:39:18 +0000 | [diff] [blame] | 119 | noff = skb_network_offset(skb); |
| 120 | if (!pskb_may_pull(skb, sizeof(*iph) + noff)) |
Herbert Xu | b421995 | 2007-09-27 12:48:05 -0700 | [diff] [blame] | 121 | goto drop; |
| 122 | |
| 123 | iph = ip_hdr(skb); |
| 124 | |
| 125 | if (egress) |
| 126 | addr = iph->saddr; |
| 127 | else |
| 128 | addr = iph->daddr; |
| 129 | |
| 130 | if (!((old_addr ^ addr) & mask)) { |
Daniel Borkmann | 3697649 | 2016-02-19 23:05:25 +0100 | [diff] [blame] | 131 | if (skb_try_make_writable(skb, sizeof(*iph) + noff)) |
Herbert Xu | b421995 | 2007-09-27 12:48:05 -0700 | [diff] [blame] | 132 | goto drop; |
| 133 | |
| 134 | new_addr &= mask; |
| 135 | new_addr |= addr & ~mask; |
| 136 | |
| 137 | /* Rewrite IP header */ |
| 138 | iph = ip_hdr(skb); |
| 139 | if (egress) |
| 140 | iph->saddr = new_addr; |
| 141 | else |
| 142 | iph->daddr = new_addr; |
| 143 | |
Patrick McHardy | be0ea7d | 2007-11-30 01:17:11 +1100 | [diff] [blame] | 144 | csum_replace4(&iph->check, addr, new_addr); |
Changli Gao | 33c29dd | 2010-05-29 14:26:59 +0000 | [diff] [blame] | 145 | } else if ((iph->frag_off & htons(IP_OFFSET)) || |
| 146 | iph->protocol != IPPROTO_ICMP) { |
| 147 | goto out; |
Herbert Xu | b421995 | 2007-09-27 12:48:05 -0700 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | ihl = iph->ihl * 4; |
| 151 | |
| 152 | /* It would be nice to share code with stateful NAT. */ |
| 153 | switch (iph->frag_off & htons(IP_OFFSET) ? 0 : iph->protocol) { |
| 154 | case IPPROTO_TCP: |
| 155 | { |
| 156 | struct tcphdr *tcph; |
| 157 | |
Changli Gao | 36d1269 | 2010-08-03 17:39:18 +0000 | [diff] [blame] | 158 | if (!pskb_may_pull(skb, ihl + sizeof(*tcph) + noff) || |
Daniel Borkmann | 3697649 | 2016-02-19 23:05:25 +0100 | [diff] [blame] | 159 | skb_try_make_writable(skb, ihl + sizeof(*tcph) + noff)) |
Herbert Xu | b421995 | 2007-09-27 12:48:05 -0700 | [diff] [blame] | 160 | goto drop; |
| 161 | |
| 162 | tcph = (void *)(skb_network_header(skb) + ihl); |
Tom Herbert | 4b048d6 | 2015-08-17 13:42:25 -0700 | [diff] [blame] | 163 | inet_proto_csum_replace4(&tcph->check, skb, addr, new_addr, |
| 164 | true); |
Herbert Xu | b421995 | 2007-09-27 12:48:05 -0700 | [diff] [blame] | 165 | break; |
| 166 | } |
| 167 | case IPPROTO_UDP: |
| 168 | { |
| 169 | struct udphdr *udph; |
| 170 | |
Changli Gao | 36d1269 | 2010-08-03 17:39:18 +0000 | [diff] [blame] | 171 | if (!pskb_may_pull(skb, ihl + sizeof(*udph) + noff) || |
Daniel Borkmann | 3697649 | 2016-02-19 23:05:25 +0100 | [diff] [blame] | 172 | skb_try_make_writable(skb, ihl + sizeof(*udph) + noff)) |
Herbert Xu | b421995 | 2007-09-27 12:48:05 -0700 | [diff] [blame] | 173 | goto drop; |
| 174 | |
| 175 | udph = (void *)(skb_network_header(skb) + ihl); |
| 176 | if (udph->check || skb->ip_summed == CHECKSUM_PARTIAL) { |
Patrick McHardy | be0ea7d | 2007-11-30 01:17:11 +1100 | [diff] [blame] | 177 | inet_proto_csum_replace4(&udph->check, skb, addr, |
Tom Herbert | 4b048d6 | 2015-08-17 13:42:25 -0700 | [diff] [blame] | 178 | new_addr, true); |
Herbert Xu | b421995 | 2007-09-27 12:48:05 -0700 | [diff] [blame] | 179 | if (!udph->check) |
| 180 | udph->check = CSUM_MANGLED_0; |
| 181 | } |
| 182 | break; |
| 183 | } |
| 184 | case IPPROTO_ICMP: |
| 185 | { |
| 186 | struct icmphdr *icmph; |
| 187 | |
Changli Gao | 36d1269 | 2010-08-03 17:39:18 +0000 | [diff] [blame] | 188 | if (!pskb_may_pull(skb, ihl + sizeof(*icmph) + noff)) |
Herbert Xu | b421995 | 2007-09-27 12:48:05 -0700 | [diff] [blame] | 189 | goto drop; |
| 190 | |
| 191 | icmph = (void *)(skb_network_header(skb) + ihl); |
| 192 | |
| 193 | if ((icmph->type != ICMP_DEST_UNREACH) && |
| 194 | (icmph->type != ICMP_TIME_EXCEEDED) && |
| 195 | (icmph->type != ICMP_PARAMETERPROB)) |
| 196 | break; |
| 197 | |
Changli Gao | 36d1269 | 2010-08-03 17:39:18 +0000 | [diff] [blame] | 198 | if (!pskb_may_pull(skb, ihl + sizeof(*icmph) + sizeof(*iph) + |
| 199 | noff)) |
Changli Gao | 70c2efa | 2010-07-09 15:33:25 +0000 | [diff] [blame] | 200 | goto drop; |
| 201 | |
Changli Gao | 072d79a | 2010-07-29 13:41:46 +0000 | [diff] [blame] | 202 | icmph = (void *)(skb_network_header(skb) + ihl); |
Herbert Xu | b421995 | 2007-09-27 12:48:05 -0700 | [diff] [blame] | 203 | iph = (void *)(icmph + 1); |
| 204 | if (egress) |
| 205 | addr = iph->daddr; |
| 206 | else |
| 207 | addr = iph->saddr; |
| 208 | |
| 209 | if ((old_addr ^ addr) & mask) |
| 210 | break; |
| 211 | |
Daniel Borkmann | 3697649 | 2016-02-19 23:05:25 +0100 | [diff] [blame] | 212 | if (skb_try_make_writable(skb, ihl + sizeof(*icmph) + |
| 213 | sizeof(*iph) + noff)) |
Herbert Xu | b421995 | 2007-09-27 12:48:05 -0700 | [diff] [blame] | 214 | goto drop; |
| 215 | |
| 216 | icmph = (void *)(skb_network_header(skb) + ihl); |
| 217 | iph = (void *)(icmph + 1); |
| 218 | |
| 219 | new_addr &= mask; |
| 220 | new_addr |= addr & ~mask; |
| 221 | |
| 222 | /* XXX Fix up the inner checksums. */ |
| 223 | if (egress) |
| 224 | iph->daddr = new_addr; |
| 225 | else |
| 226 | iph->saddr = new_addr; |
| 227 | |
Patrick McHardy | be0ea7d | 2007-11-30 01:17:11 +1100 | [diff] [blame] | 228 | inet_proto_csum_replace4(&icmph->checksum, skb, addr, new_addr, |
Tom Herbert | 4b048d6 | 2015-08-17 13:42:25 -0700 | [diff] [blame] | 229 | false); |
Herbert Xu | b421995 | 2007-09-27 12:48:05 -0700 | [diff] [blame] | 230 | break; |
| 231 | } |
| 232 | default: |
| 233 | break; |
| 234 | } |
| 235 | |
Changli Gao | 33c29dd | 2010-05-29 14:26:59 +0000 | [diff] [blame] | 236 | out: |
Herbert Xu | b421995 | 2007-09-27 12:48:05 -0700 | [diff] [blame] | 237 | return action; |
| 238 | |
| 239 | drop: |
| 240 | spin_lock(&p->tcf_lock); |
| 241 | p->tcf_qstats.drops++; |
| 242 | spin_unlock(&p->tcf_lock); |
| 243 | return TC_ACT_SHOT; |
| 244 | } |
| 245 | |
| 246 | static int tcf_nat_dump(struct sk_buff *skb, struct tc_action *a, |
| 247 | int bind, int ref) |
| 248 | { |
| 249 | unsigned char *b = skb_tail_pointer(skb); |
WANG Cong | a85a970 | 2016-07-25 16:09:41 -0700 | [diff] [blame] | 250 | struct tcf_nat *p = to_tcf_nat(a); |
Eric Dumazet | 1c40be1 | 2010-08-16 20:04:22 +0000 | [diff] [blame] | 251 | struct tc_nat opt = { |
| 252 | .old_addr = p->old_addr, |
| 253 | .new_addr = p->new_addr, |
| 254 | .mask = p->mask, |
| 255 | .flags = p->flags, |
| 256 | |
| 257 | .index = p->tcf_index, |
| 258 | .action = p->tcf_action, |
| 259 | .refcnt = p->tcf_refcnt - ref, |
| 260 | .bindcnt = p->tcf_bindcnt - bind, |
| 261 | }; |
Herbert Xu | b421995 | 2007-09-27 12:48:05 -0700 | [diff] [blame] | 262 | struct tcf_t t; |
Herbert Xu | b421995 | 2007-09-27 12:48:05 -0700 | [diff] [blame] | 263 | |
David S. Miller | 1b34ec4 | 2012-03-29 05:11:39 -0400 | [diff] [blame] | 264 | if (nla_put(skb, TCA_NAT_PARMS, sizeof(opt), &opt)) |
| 265 | goto nla_put_failure; |
Jamal Hadi Salim | 48d8ee1 | 2016-06-06 06:32:55 -0400 | [diff] [blame] | 266 | |
| 267 | tcf_tm_dump(&t, &p->tcf_tm); |
Nicolas Dichtel | 9854518 | 2016-04-26 10:06:18 +0200 | [diff] [blame] | 268 | if (nla_put_64bit(skb, TCA_NAT_TM, sizeof(t), &t, TCA_NAT_PAD)) |
David S. Miller | 1b34ec4 | 2012-03-29 05:11:39 -0400 | [diff] [blame] | 269 | goto nla_put_failure; |
Herbert Xu | b421995 | 2007-09-27 12:48:05 -0700 | [diff] [blame] | 270 | |
Herbert Xu | b421995 | 2007-09-27 12:48:05 -0700 | [diff] [blame] | 271 | return skb->len; |
| 272 | |
Patrick McHardy | 7ba699c | 2008-01-22 22:11:50 -0800 | [diff] [blame] | 273 | nla_put_failure: |
Herbert Xu | b421995 | 2007-09-27 12:48:05 -0700 | [diff] [blame] | 274 | nlmsg_trim(skb, b); |
Herbert Xu | b421995 | 2007-09-27 12:48:05 -0700 | [diff] [blame] | 275 | return -1; |
| 276 | } |
| 277 | |
WANG Cong | ddf97cc | 2016-02-22 15:57:53 -0800 | [diff] [blame] | 278 | static int tcf_nat_walker(struct net *net, struct sk_buff *skb, |
| 279 | struct netlink_callback *cb, int type, |
WANG Cong | a85a970 | 2016-07-25 16:09:41 -0700 | [diff] [blame] | 280 | const struct tc_action_ops *ops) |
WANG Cong | ddf97cc | 2016-02-22 15:57:53 -0800 | [diff] [blame] | 281 | { |
| 282 | struct tc_action_net *tn = net_generic(net, nat_net_id); |
| 283 | |
WANG Cong | a85a970 | 2016-07-25 16:09:41 -0700 | [diff] [blame] | 284 | return tcf_generic_walker(tn, skb, cb, type, ops); |
WANG Cong | ddf97cc | 2016-02-22 15:57:53 -0800 | [diff] [blame] | 285 | } |
| 286 | |
WANG Cong | a85a970 | 2016-07-25 16:09:41 -0700 | [diff] [blame] | 287 | static int tcf_nat_search(struct net *net, struct tc_action **a, u32 index) |
WANG Cong | ddf97cc | 2016-02-22 15:57:53 -0800 | [diff] [blame] | 288 | { |
| 289 | struct tc_action_net *tn = net_generic(net, nat_net_id); |
| 290 | |
Chris Mi | 65a206c | 2017-08-30 02:31:59 -0400 | [diff] [blame] | 291 | return tcf_idr_search(tn, a, index); |
WANG Cong | ddf97cc | 2016-02-22 15:57:53 -0800 | [diff] [blame] | 292 | } |
| 293 | |
Herbert Xu | b421995 | 2007-09-27 12:48:05 -0700 | [diff] [blame] | 294 | static struct tc_action_ops act_nat_ops = { |
| 295 | .kind = "nat", |
Herbert Xu | b421995 | 2007-09-27 12:48:05 -0700 | [diff] [blame] | 296 | .type = TCA_ACT_NAT, |
Herbert Xu | b421995 | 2007-09-27 12:48:05 -0700 | [diff] [blame] | 297 | .owner = THIS_MODULE, |
| 298 | .act = tcf_nat, |
| 299 | .dump = tcf_nat_dump, |
Herbert Xu | b421995 | 2007-09-27 12:48:05 -0700 | [diff] [blame] | 300 | .init = tcf_nat_init, |
WANG Cong | ddf97cc | 2016-02-22 15:57:53 -0800 | [diff] [blame] | 301 | .walk = tcf_nat_walker, |
| 302 | .lookup = tcf_nat_search, |
WANG Cong | a85a970 | 2016-07-25 16:09:41 -0700 | [diff] [blame] | 303 | .size = sizeof(struct tcf_nat), |
WANG Cong | ddf97cc | 2016-02-22 15:57:53 -0800 | [diff] [blame] | 304 | }; |
| 305 | |
| 306 | static __net_init int nat_init_net(struct net *net) |
| 307 | { |
| 308 | struct tc_action_net *tn = net_generic(net, nat_net_id); |
| 309 | |
Cong Wang | c7e460c | 2017-11-06 13:47:18 -0800 | [diff] [blame] | 310 | return tc_action_net_init(tn, &act_nat_ops); |
WANG Cong | ddf97cc | 2016-02-22 15:57:53 -0800 | [diff] [blame] | 311 | } |
| 312 | |
| 313 | static void __net_exit nat_exit_net(struct net *net) |
| 314 | { |
| 315 | struct tc_action_net *tn = net_generic(net, nat_net_id); |
| 316 | |
| 317 | tc_action_net_exit(tn); |
| 318 | } |
| 319 | |
| 320 | static struct pernet_operations nat_net_ops = { |
| 321 | .init = nat_init_net, |
| 322 | .exit = nat_exit_net, |
| 323 | .id = &nat_net_id, |
| 324 | .size = sizeof(struct tc_action_net), |
Herbert Xu | b421995 | 2007-09-27 12:48:05 -0700 | [diff] [blame] | 325 | }; |
| 326 | |
| 327 | MODULE_DESCRIPTION("Stateless NAT actions"); |
| 328 | MODULE_LICENSE("GPL"); |
| 329 | |
| 330 | static int __init nat_init_module(void) |
| 331 | { |
WANG Cong | ddf97cc | 2016-02-22 15:57:53 -0800 | [diff] [blame] | 332 | return tcf_register_action(&act_nat_ops, &nat_net_ops); |
Herbert Xu | b421995 | 2007-09-27 12:48:05 -0700 | [diff] [blame] | 333 | } |
| 334 | |
| 335 | static void __exit nat_cleanup_module(void) |
| 336 | { |
WANG Cong | ddf97cc | 2016-02-22 15:57:53 -0800 | [diff] [blame] | 337 | tcf_unregister_action(&act_nat_ops, &nat_net_ops); |
Herbert Xu | b421995 | 2007-09-27 12:48:05 -0700 | [diff] [blame] | 338 | } |
| 339 | |
| 340 | module_init(nat_init_module); |
| 341 | module_exit(nat_cleanup_module); |