]> CyberLeo.Net >> Repos - FreeBSD/stable/8.git/blob - sys/netinet/ipfw/ip_fw_nat.c
Merge from head/ 220800,220837,220914:
[FreeBSD/stable/8.git] / sys / netinet / ipfw / ip_fw_nat.c
1 /*-
2  * Copyright (c) 2008 Paolo Pisati
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  */
26
27 #include <sys/cdefs.h>
28 __FBSDID("$FreeBSD$");
29
30 #include <sys/param.h>
31 #include <sys/systm.h>
32 #include <sys/eventhandler.h>
33 #include <sys/malloc.h>
34 #include <sys/kernel.h>
35 #include <sys/lock.h>
36 #include <sys/module.h>
37 #include <sys/rwlock.h>
38
39 #define        IPFW_INTERNAL   /* Access to protected data structures in ip_fw.h. */
40
41 #include <netinet/libalias/alias.h>
42 #include <netinet/libalias/alias_local.h>
43
44 #include <net/if.h>
45 #include <netinet/in.h>
46 #include <netinet/ip.h>
47 #include <netinet/ip_var.h>
48 #include <netinet/ip_fw.h>
49 #include <netinet/ipfw/ip_fw_private.h>
50 #include <netinet/tcp.h>
51 #include <netinet/udp.h>
52
53 #include <machine/in_cksum.h>   /* XXX for in_cksum */
54
55 static VNET_DEFINE(eventhandler_tag, ifaddr_event_tag);
56 #define V_ifaddr_event_tag      VNET(ifaddr_event_tag)
57
58 static void
59 ifaddr_change(void *arg __unused, struct ifnet *ifp)
60 {
61         struct cfg_nat *ptr;
62         struct ifaddr *ifa;
63         struct ip_fw_chain *chain;
64
65         chain = &V_layer3_chain;
66         IPFW_WLOCK(chain);
67         /* Check every nat entry... */
68         LIST_FOREACH(ptr, &chain->nat, _next) {
69                 /* ...using nic 'ifp->if_xname' as dynamic alias address. */
70                 if (strncmp(ptr->if_name, ifp->if_xname, IF_NAMESIZE) != 0)
71                         continue;
72                 if_addr_rlock(ifp);
73                 TAILQ_FOREACH(ifa, &ifp->if_addrhead, ifa_link) {
74                         if (ifa->ifa_addr == NULL)
75                                 continue;
76                         if (ifa->ifa_addr->sa_family != AF_INET)
77                                 continue;
78                         ptr->ip = ((struct sockaddr_in *)
79                             (ifa->ifa_addr))->sin_addr;
80                         LibAliasSetAddress(ptr->lib, ptr->ip);
81                 }
82                 if_addr_runlock(ifp);
83         }
84         IPFW_WUNLOCK(chain);
85 }
86
87 /*
88  * delete the pointers for nat entry ix, or all of them if ix < 0
89  */
90 static void
91 flush_nat_ptrs(struct ip_fw_chain *chain, const int ix)
92 {
93         int i;
94         ipfw_insn_nat *cmd;
95
96         IPFW_WLOCK_ASSERT(chain);
97         for (i = 0; i < chain->n_rules; i++) {
98                 cmd = (ipfw_insn_nat *)ACTION_PTR(chain->map[i]);
99                 /* XXX skip log and the like ? */
100                 if (cmd->o.opcode == O_NAT && cmd->nat != NULL &&
101                             (ix < 0 || cmd->nat->id == ix))
102                         cmd->nat = NULL;
103         }
104 }
105
106 static void
107 del_redir_spool_cfg(struct cfg_nat *n, struct redir_chain *head)
108 {
109         struct cfg_redir *r, *tmp_r;
110         struct cfg_spool *s, *tmp_s;
111         int i, num;
112
113         LIST_FOREACH_SAFE(r, head, _next, tmp_r) {
114                 num = 1; /* Number of alias_link to delete. */
115                 switch (r->mode) {
116                 case REDIR_PORT:
117                         num = r->pport_cnt;
118                         /* FALLTHROUGH */
119                 case REDIR_ADDR:
120                 case REDIR_PROTO:
121                         /* Delete all libalias redirect entry. */
122                         for (i = 0; i < num; i++)
123                                 LibAliasRedirectDelete(n->lib, r->alink[i]);
124                         /* Del spool cfg if any. */
125                         LIST_FOREACH_SAFE(s, &r->spool_chain, _next, tmp_s) {
126                                 LIST_REMOVE(s, _next);
127                                 free(s, M_IPFW);
128                         }
129                         free(r->alink, M_IPFW);
130                         LIST_REMOVE(r, _next);
131                         free(r, M_IPFW);
132                         break;
133                 default:
134                         printf("unknown redirect mode: %u\n", r->mode);
135                         /* XXX - panic?!?!? */
136                         break;
137                 }
138         }
139 }
140
141 static void
142 add_redir_spool_cfg(char *buf, struct cfg_nat *ptr)
143 {
144         struct cfg_redir *r, *ser_r;
145         struct cfg_spool *s, *ser_s;
146         int cnt, off, i;
147
148         for (cnt = 0, off = 0; cnt < ptr->redir_cnt; cnt++) {
149                 ser_r = (struct cfg_redir *)&buf[off];
150                 r = malloc(SOF_REDIR, M_IPFW, M_WAITOK | M_ZERO);
151                 memcpy(r, ser_r, SOF_REDIR);
152                 LIST_INIT(&r->spool_chain);
153                 off += SOF_REDIR;
154                 r->alink = malloc(sizeof(struct alias_link *) * r->pport_cnt,
155                     M_IPFW, M_WAITOK | M_ZERO);
156                 switch (r->mode) {
157                 case REDIR_ADDR:
158                         r->alink[0] = LibAliasRedirectAddr(ptr->lib, r->laddr,
159                             r->paddr);
160                         break;
161                 case REDIR_PORT:
162                         for (i = 0 ; i < r->pport_cnt; i++) {
163                                 /* If remotePort is all ports, set it to 0. */
164                                 u_short remotePortCopy = r->rport + i;
165                                 if (r->rport_cnt == 1 && r->rport == 0)
166                                         remotePortCopy = 0;
167                                 r->alink[i] = LibAliasRedirectPort(ptr->lib,
168                                     r->laddr, htons(r->lport + i), r->raddr,
169                                     htons(remotePortCopy), r->paddr,
170                                     htons(r->pport + i), r->proto);
171                                 if (r->alink[i] == NULL) {
172                                         r->alink[0] = NULL;
173                                         break;
174                                 }
175                         }
176                         break;
177                 case REDIR_PROTO:
178                         r->alink[0] = LibAliasRedirectProto(ptr->lib ,r->laddr,
179                             r->raddr, r->paddr, r->proto);
180                         break;
181                 default:
182                         printf("unknown redirect mode: %u\n", r->mode);
183                         break;
184                 }
185                 /* XXX perhaps return an error instead of panic ? */
186                 if (r->alink[0] == NULL)
187                         panic("LibAliasRedirect* returned NULL");
188                 /* LSNAT handling. */
189                 for (i = 0; i < r->spool_cnt; i++) {
190                         ser_s = (struct cfg_spool *)&buf[off];
191                         s = malloc(SOF_REDIR, M_IPFW, M_WAITOK | M_ZERO);
192                         memcpy(s, ser_s, SOF_SPOOL);
193                         LibAliasAddServer(ptr->lib, r->alink[0],
194                             s->addr, htons(s->port));
195                         off += SOF_SPOOL;
196                         /* Hook spool entry. */
197                         LIST_INSERT_HEAD(&r->spool_chain, s, _next);
198                 }
199                 /* And finally hook this redir entry. */
200                 LIST_INSERT_HEAD(&ptr->redir_chain, r, _next);
201         }
202 }
203
204 static int
205 ipfw_nat(struct ip_fw_args *args, struct cfg_nat *t, struct mbuf *m)
206 {
207         struct mbuf *mcl;
208         struct ip *ip;
209         /* XXX - libalias duct tape */
210         int ldt, retval;
211         char *c;
212
213         ldt = 0;
214         retval = 0;
215         mcl = m_megapullup(m, m->m_pkthdr.len);
216         if (mcl == NULL) {
217                 args->m = NULL;
218                 return (IP_FW_DENY);
219         }
220         ip = mtod(mcl, struct ip *);
221
222         /*
223          * XXX - Libalias checksum offload 'duct tape':
224          *
225          * locally generated packets have only pseudo-header checksum
226          * calculated and libalias will break it[1], so mark them for
227          * later fix.  Moreover there are cases when libalias modifies
228          * tcp packet data[2], mark them for later fix too.
229          *
230          * [1] libalias was never meant to run in kernel, so it does
231          * not have any knowledge about checksum offloading, and
232          * expects a packet with a full internet checksum.
233          * Unfortunately, packets generated locally will have just the
234          * pseudo header calculated, and when libalias tries to adjust
235          * the checksum it will actually compute a wrong value.
236          *
237          * [2] when libalias modifies tcp's data content, full TCP
238          * checksum has to be recomputed: the problem is that
239          * libalias does not have any idea about checksum offloading.
240          * To work around this, we do not do checksumming in LibAlias,
241          * but only mark the packets in th_x2 field. If we receive a
242          * marked packet, we calculate correct checksum for it
243          * aware of offloading.  Why such a terrible hack instead of
244          * recalculating checksum for each packet?
245          * Because the previous checksum was not checked!
246          * Recalculating checksums for EVERY packet will hide ALL
247          * transmission errors. Yes, marked packets still suffer from
248          * this problem. But, sigh, natd(8) has this problem, too.
249          *
250          * TODO: -make libalias mbuf aware (so
251          * it can handle delayed checksum and tso)
252          */
253
254         if (mcl->m_pkthdr.rcvif == NULL &&
255             mcl->m_pkthdr.csum_flags & CSUM_DELAY_DATA)
256                 ldt = 1;
257
258         c = mtod(mcl, char *);
259         if (args->oif == NULL)
260                 retval = LibAliasIn(t->lib, c,
261                         mcl->m_len + M_TRAILINGSPACE(mcl));
262         else
263                 retval = LibAliasOut(t->lib, c,
264                         mcl->m_len + M_TRAILINGSPACE(mcl));
265
266         /*
267          * We drop packet when:
268          * 1. libalias returns PKT_ALIAS_ERROR;
269          * 2. For incoming packets:
270          *      a) for unresolved fragments;
271          *      b) libalias returns PKT_ALIAS_IGNORED and
272          *              PKT_ALIAS_DENY_INCOMING flag is set.
273          */
274         if (retval == PKT_ALIAS_ERROR ||
275             (args->oif == NULL && (retval == PKT_ALIAS_UNRESOLVED_FRAGMENT ||
276             (retval == PKT_ALIAS_IGNORED &&
277             (t->lib->packetAliasMode & PKT_ALIAS_DENY_INCOMING) != 0)))) {
278                 /* XXX - should i add some logging? */
279                 m_free(mcl);
280                 args->m = NULL;
281                 return (IP_FW_DENY);
282         }
283
284         if (retval == PKT_ALIAS_RESPOND)
285                 m->m_flags |= M_SKIP_FIREWALL;
286         mcl->m_pkthdr.len = mcl->m_len = ntohs(ip->ip_len);
287
288         /*
289          * XXX - libalias checksum offload
290          * 'duct tape' (see above)
291          */
292
293         if ((ip->ip_off & htons(IP_OFFMASK)) == 0 &&
294             ip->ip_p == IPPROTO_TCP) {
295                 struct tcphdr   *th;
296
297                 th = (struct tcphdr *)(ip + 1);
298                 if (th->th_x2)
299                         ldt = 1;
300         }
301
302         if (ldt) {
303                 struct tcphdr   *th;
304                 struct udphdr   *uh;
305                 u_short cksum;
306
307                 ip->ip_len = ntohs(ip->ip_len);
308                 cksum = in_pseudo(ip->ip_src.s_addr, ip->ip_dst.s_addr,
309                     htons(ip->ip_p + ip->ip_len - (ip->ip_hl << 2)));
310
311                 switch (ip->ip_p) {
312                 case IPPROTO_TCP:
313                         th = (struct tcphdr *)(ip + 1);
314                         /*
315                          * Maybe it was set in
316                          * libalias...
317                          */
318                         th->th_x2 = 0;
319                         th->th_sum = cksum;
320                         mcl->m_pkthdr.csum_data =
321                             offsetof(struct tcphdr, th_sum);
322                         break;
323                 case IPPROTO_UDP:
324                         uh = (struct udphdr *)(ip + 1);
325                         uh->uh_sum = cksum;
326                         mcl->m_pkthdr.csum_data =
327                             offsetof(struct udphdr, uh_sum);
328                         break;
329                 }
330                 /* No hw checksum offloading: do it ourselves */
331                 if ((mcl->m_pkthdr.csum_flags & CSUM_DELAY_DATA) == 0) {
332                         in_delayed_cksum(mcl);
333                         mcl->m_pkthdr.csum_flags &= ~CSUM_DELAY_DATA;
334                 }
335                 ip->ip_len = htons(ip->ip_len);
336         }
337         args->m = mcl;
338         return (IP_FW_NAT);
339 }
340
341 static struct cfg_nat *
342 lookup_nat(struct nat_list *l, int nat_id)
343 {
344         struct cfg_nat *res;
345
346         LIST_FOREACH(res, l, _next) {
347                 if (res->id == nat_id)
348                         break;
349         }
350         return res;
351 }
352
353 static int
354 ipfw_nat_cfg(struct sockopt *sopt)
355 {
356         struct cfg_nat *cfg, *ptr;
357         char *buf;
358         struct ip_fw_chain *chain = &V_layer3_chain;
359         size_t len;
360         int gencnt, error = 0;
361
362         len = sopt->sopt_valsize;
363         buf = malloc(len, M_TEMP, M_WAITOK | M_ZERO);
364         if ((error = sooptcopyin(sopt, buf, len, sizeof(struct cfg_nat))) != 0)
365                 goto out;
366
367         cfg = (struct cfg_nat *)buf;
368         if (cfg->id < 0) {
369                 error = EINVAL;
370                 goto out;
371         }
372
373         /*
374          * Find/create nat rule.
375          */
376         IPFW_WLOCK(chain);
377         gencnt = chain->gencnt;
378         ptr = lookup_nat(&chain->nat, cfg->id);
379         if (ptr == NULL) {
380                 IPFW_WUNLOCK(chain);
381                 /* New rule: allocate and init new instance. */
382                 ptr = malloc(sizeof(struct cfg_nat), M_IPFW, M_WAITOK | M_ZERO);
383                 ptr->lib = LibAliasInit(NULL);
384                 LIST_INIT(&ptr->redir_chain);
385         } else {
386                 /* Entry already present: temporarily unhook it. */
387                 LIST_REMOVE(ptr, _next);
388                 flush_nat_ptrs(chain, cfg->id);
389                 IPFW_WUNLOCK(chain);
390         }
391
392         /*
393          * Basic nat configuration.
394          */
395         ptr->id = cfg->id;
396         /*
397          * XXX - what if this rule doesn't nat any ip and just
398          * redirect?
399          * do we set aliasaddress to 0.0.0.0?
400          */
401         ptr->ip = cfg->ip;
402         ptr->redir_cnt = cfg->redir_cnt;
403         ptr->mode = cfg->mode;
404         LibAliasSetMode(ptr->lib, cfg->mode, cfg->mode);
405         LibAliasSetAddress(ptr->lib, ptr->ip);
406         memcpy(ptr->if_name, cfg->if_name, IF_NAMESIZE);
407
408         /*
409          * Redir and LSNAT configuration.
410          */
411         /* Delete old cfgs. */
412         del_redir_spool_cfg(ptr, &ptr->redir_chain);
413         /* Add new entries. */
414         add_redir_spool_cfg(&buf[(sizeof(struct cfg_nat))], ptr);
415
416         IPFW_WLOCK(chain);
417         /* Extra check to avoid race with another ipfw_nat_cfg() */
418         if (gencnt != chain->gencnt &&
419             ((cfg = lookup_nat(&chain->nat, ptr->id)) != NULL))
420                 LIST_REMOVE(cfg, _next);
421         LIST_INSERT_HEAD(&chain->nat, ptr, _next);
422         chain->gencnt++;
423         IPFW_WUNLOCK(chain);
424
425 out:
426         free(buf, M_TEMP);
427         return (error);
428 }
429
430 static int
431 ipfw_nat_del(struct sockopt *sopt)
432 {
433         struct cfg_nat *ptr;
434         struct ip_fw_chain *chain = &V_layer3_chain;
435         int i;
436
437         sooptcopyin(sopt, &i, sizeof i, sizeof i);
438         /* XXX validate i */
439         IPFW_WLOCK(chain);
440         ptr = lookup_nat(&chain->nat, i);
441         if (ptr == NULL) {
442                 IPFW_WUNLOCK(chain);
443                 return (EINVAL);
444         }
445         LIST_REMOVE(ptr, _next);
446         flush_nat_ptrs(chain, i);
447         IPFW_WUNLOCK(chain);
448         del_redir_spool_cfg(ptr, &ptr->redir_chain);
449         LibAliasUninit(ptr->lib);
450         free(ptr, M_IPFW);
451         return (0);
452 }
453
454 static int
455 ipfw_nat_get_cfg(struct sockopt *sopt)
456 {
457         struct ip_fw_chain *chain = &V_layer3_chain;
458         struct cfg_nat *n;
459         struct cfg_redir *r;
460         struct cfg_spool *s;
461         char *data;
462         int gencnt, nat_cnt, len, error;
463
464         nat_cnt = 0;
465         len = sizeof(nat_cnt);
466
467         IPFW_RLOCK(chain);
468 retry:
469         gencnt = chain->gencnt;
470         /* Estimate memory amount */
471         LIST_FOREACH(n, &chain->nat, _next) {
472                 nat_cnt++;
473                 len += sizeof(struct cfg_nat);
474                 LIST_FOREACH(r, &n->redir_chain, _next) {
475                         len += sizeof(struct cfg_redir);
476                         LIST_FOREACH(s, &r->spool_chain, _next)
477                                 len += sizeof(struct cfg_spool);
478                 }
479         }
480         IPFW_RUNLOCK(chain);
481
482         data = malloc(len, M_TEMP, M_WAITOK | M_ZERO);
483         bcopy(&nat_cnt, data, sizeof(nat_cnt));
484
485         nat_cnt = 0;
486         len = sizeof(nat_cnt);
487
488         IPFW_RLOCK(chain);
489         if (gencnt != chain->gencnt) {
490                 free(data, M_TEMP);
491                 goto retry;
492         }
493         /* Serialize all the data. */
494         LIST_FOREACH(n, &chain->nat, _next) {
495                 bcopy(n, &data[len], sizeof(struct cfg_nat));
496                 len += sizeof(struct cfg_nat);
497                 LIST_FOREACH(r, &n->redir_chain, _next) {
498                         bcopy(r, &data[len], sizeof(struct cfg_redir));
499                         len += sizeof(struct cfg_redir);
500                         LIST_FOREACH(s, &r->spool_chain, _next) {
501                                 bcopy(s, &data[len], sizeof(struct cfg_spool));
502                                 len += sizeof(struct cfg_spool);
503                         }
504                 }
505         }
506         IPFW_RUNLOCK(chain);
507
508         error = sooptcopyout(sopt, data, len);
509         free(data, M_TEMP);
510
511         return (error);
512 }
513
514 static int
515 ipfw_nat_get_log(struct sockopt *sopt)
516 {
517         uint8_t *data;
518         struct cfg_nat *ptr;
519         int i, size;
520         struct ip_fw_chain *chain;
521
522         chain = &V_layer3_chain;
523
524         IPFW_RLOCK(chain);
525         /* one pass to count, one to copy the data */
526         i = 0;
527         LIST_FOREACH(ptr, &chain->nat, _next) {
528                 if (ptr->lib->logDesc == NULL)
529                         continue;
530                 i++;
531         }
532         size = i * (LIBALIAS_BUF_SIZE + sizeof(int));
533         data = malloc(size, M_IPFW, M_NOWAIT | M_ZERO);
534         if (data == NULL) {
535                 IPFW_RUNLOCK(chain);
536                 return (ENOSPC);
537         }
538         i = 0;
539         LIST_FOREACH(ptr, &chain->nat, _next) {
540                 if (ptr->lib->logDesc == NULL)
541                         continue;
542                 bcopy(&ptr->id, &data[i], sizeof(int));
543                 i += sizeof(int);
544                 bcopy(ptr->lib->logDesc, &data[i], LIBALIAS_BUF_SIZE);
545                 i += LIBALIAS_BUF_SIZE;
546         }
547         IPFW_RUNLOCK(chain);
548         sooptcopyout(sopt, data, size);
549         free(data, M_IPFW);
550         return(0);
551 }
552
553 static void
554 ipfw_nat_init(void)
555 {
556
557         IPFW_WLOCK(&V_layer3_chain);
558         /* init ipfw hooks */
559         ipfw_nat_ptr = ipfw_nat;
560         lookup_nat_ptr = lookup_nat;
561         ipfw_nat_cfg_ptr = ipfw_nat_cfg;
562         ipfw_nat_del_ptr = ipfw_nat_del;
563         ipfw_nat_get_cfg_ptr = ipfw_nat_get_cfg;
564         ipfw_nat_get_log_ptr = ipfw_nat_get_log;
565         IPFW_WUNLOCK(&V_layer3_chain);
566         V_ifaddr_event_tag = EVENTHANDLER_REGISTER(
567             ifaddr_event, ifaddr_change,
568             NULL, EVENTHANDLER_PRI_ANY);
569 }
570
571 static void
572 ipfw_nat_destroy(void)
573 {
574         struct cfg_nat *ptr, *ptr_temp;
575         struct ip_fw_chain *chain;
576
577         chain = &V_layer3_chain;
578         IPFW_WLOCK(chain);
579         LIST_FOREACH_SAFE(ptr, &chain->nat, _next, ptr_temp) {
580                 LIST_REMOVE(ptr, _next);
581                 del_redir_spool_cfg(ptr, &ptr->redir_chain);
582                 LibAliasUninit(ptr->lib);
583                 free(ptr, M_IPFW);
584         }
585         EVENTHANDLER_DEREGISTER(ifaddr_event, V_ifaddr_event_tag);
586         flush_nat_ptrs(chain, -1 /* flush all */);
587         /* deregister ipfw_nat */
588         ipfw_nat_ptr = NULL;
589         lookup_nat_ptr = NULL;
590         ipfw_nat_cfg_ptr = NULL;
591         ipfw_nat_del_ptr = NULL;
592         ipfw_nat_get_cfg_ptr = NULL;
593         ipfw_nat_get_log_ptr = NULL;
594         IPFW_WUNLOCK(chain);
595 }
596
597 static int
598 ipfw_nat_modevent(module_t mod, int type, void *unused)
599 {
600         int err = 0;
601
602         switch (type) {
603         case MOD_LOAD:
604                 ipfw_nat_init();
605                 break;
606
607         case MOD_UNLOAD:
608                 ipfw_nat_destroy();
609                 break;
610
611         default:
612                 return EOPNOTSUPP;
613                 break;
614         }
615         return err;
616 }
617
618 static moduledata_t ipfw_nat_mod = {
619         "ipfw_nat",
620         ipfw_nat_modevent,
621         0
622 };
623
624 DECLARE_MODULE(ipfw_nat, ipfw_nat_mod, SI_SUB_PROTO_IFATTACHDOMAIN, SI_ORDER_ANY);
625 MODULE_DEPEND(ipfw_nat, libalias, 1, 1, 1);
626 MODULE_DEPEND(ipfw_nat, ipfw, 2, 2, 2);
627 MODULE_VERSION(ipfw_nat, 1);
628 /* end of file */