xt_TPROXY.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  1. /*
  2. * Transparent proxy support for Linux/iptables
  3. *
  4. * Copyright (c) 2006-2010 BalaBit IT Ltd.
  5. * Author: Balazs Scheidler, Krisztian Kovacs
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. *
  11. */
  12. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  13. #include <linux/module.h>
  14. #include <linux/skbuff.h>
  15. #include <linux/ip.h>
  16. #include <net/checksum.h>
  17. #include <net/udp.h>
  18. #include <net/tcp.h>
  19. #include <net/inet_sock.h>
  20. #include <net/inet_hashtables.h>
  21. #include <linux/inetdevice.h>
  22. #include <linux/netfilter/x_tables.h>
  23. #include <linux/netfilter_ipv4/ip_tables.h>
  24. #include <net/netfilter/ipv4/nf_defrag_ipv4.h>
  25. #if IS_ENABLED(CONFIG_IP6_NF_IPTABLES)
  26. #define XT_TPROXY_HAVE_IPV6 1
  27. #include <net/if_inet6.h>
  28. #include <net/addrconf.h>
  29. #include <net/inet6_hashtables.h>
  30. #include <linux/netfilter_ipv6/ip6_tables.h>
  31. #include <net/netfilter/ipv6/nf_defrag_ipv6.h>
  32. #endif
  33. #include <linux/netfilter/xt_TPROXY.h>
  34. enum nf_tproxy_lookup_t {
  35. NFT_LOOKUP_LISTENER,
  36. NFT_LOOKUP_ESTABLISHED,
  37. };
  38. static bool tproxy_sk_is_transparent(struct sock *sk)
  39. {
  40. switch (sk->sk_state) {
  41. case TCP_TIME_WAIT:
  42. if (inet_twsk(sk)->tw_transparent)
  43. return true;
  44. break;
  45. case TCP_NEW_SYN_RECV:
  46. if (inet_rsk(inet_reqsk(sk))->no_srccheck)
  47. return true;
  48. break;
  49. default:
  50. if (inet_sk(sk)->transparent)
  51. return true;
  52. }
  53. sock_gen_put(sk);
  54. return false;
  55. }
  56. static inline __be32
  57. tproxy_laddr4(struct sk_buff *skb, __be32 user_laddr, __be32 daddr)
  58. {
  59. struct in_device *indev;
  60. __be32 laddr;
  61. if (user_laddr)
  62. return user_laddr;
  63. laddr = 0;
  64. rcu_read_lock();
  65. indev = __in_dev_get_rcu(skb->dev);
  66. for_primary_ifa(indev) {
  67. laddr = ifa->ifa_local;
  68. break;
  69. } endfor_ifa(indev);
  70. rcu_read_unlock();
  71. return laddr ? laddr : daddr;
  72. }
  73. /*
  74. * This is used when the user wants to intercept a connection matching
  75. * an explicit iptables rule. In this case the sockets are assumed
  76. * matching in preference order:
  77. *
  78. * - match: if there's a fully established connection matching the
  79. * _packet_ tuple, it is returned, assuming the redirection
  80. * already took place and we process a packet belonging to an
  81. * established connection
  82. *
  83. * - match: if there's a listening socket matching the redirection
  84. * (e.g. on-port & on-ip of the connection), it is returned,
  85. * regardless if it was bound to 0.0.0.0 or an explicit
  86. * address. The reasoning is that if there's an explicit rule, it
  87. * does not really matter if the listener is bound to an interface
  88. * or to 0. The user already stated that he wants redirection
  89. * (since he added the rule).
  90. *
  91. * Please note that there's an overlap between what a TPROXY target
  92. * and a socket match will match. Normally if you have both rules the
  93. * "socket" match will be the first one, effectively all packets
  94. * belonging to established connections going through that one.
  95. */
  96. static inline struct sock *
  97. nf_tproxy_get_sock_v4(struct net *net, struct sk_buff *skb, void *hp,
  98. const u8 protocol,
  99. const __be32 saddr, const __be32 daddr,
  100. const __be16 sport, const __be16 dport,
  101. const struct net_device *in,
  102. const enum nf_tproxy_lookup_t lookup_type)
  103. {
  104. struct sock *sk;
  105. struct tcphdr *tcph;
  106. switch (protocol) {
  107. case IPPROTO_TCP:
  108. switch (lookup_type) {
  109. case NFT_LOOKUP_LISTENER:
  110. tcph = hp;
  111. sk = inet_lookup_listener(net, &tcp_hashinfo, skb,
  112. ip_hdrlen(skb) +
  113. __tcp_hdrlen(tcph),
  114. saddr, sport,
  115. daddr, dport,
  116. in->ifindex);
  117. if (sk && !atomic_inc_not_zero(&sk->sk_refcnt))
  118. sk = NULL;
  119. /* NOTE: we return listeners even if bound to
  120. * 0.0.0.0, those are filtered out in
  121. * xt_socket, since xt_TPROXY needs 0 bound
  122. * listeners too
  123. */
  124. break;
  125. case NFT_LOOKUP_ESTABLISHED:
  126. sk = inet_lookup_established(net, &tcp_hashinfo,
  127. saddr, sport, daddr, dport,
  128. in->ifindex);
  129. break;
  130. default:
  131. BUG();
  132. }
  133. break;
  134. case IPPROTO_UDP:
  135. sk = udp4_lib_lookup(net, saddr, sport, daddr, dport,
  136. in->ifindex);
  137. if (sk) {
  138. int connected = (sk->sk_state == TCP_ESTABLISHED);
  139. int wildcard = (inet_sk(sk)->inet_rcv_saddr == 0);
  140. /* NOTE: we return listeners even if bound to
  141. * 0.0.0.0, those are filtered out in
  142. * xt_socket, since xt_TPROXY needs 0 bound
  143. * listeners too
  144. */
  145. if ((lookup_type == NFT_LOOKUP_ESTABLISHED && (!connected || wildcard)) ||
  146. (lookup_type == NFT_LOOKUP_LISTENER && connected)) {
  147. sock_put(sk);
  148. sk = NULL;
  149. }
  150. }
  151. break;
  152. default:
  153. WARN_ON(1);
  154. sk = NULL;
  155. }
  156. pr_debug("tproxy socket lookup: proto %u %08x:%u -> %08x:%u, lookup type: %d, sock %p\n",
  157. protocol, ntohl(saddr), ntohs(sport), ntohl(daddr), ntohs(dport), lookup_type, sk);
  158. return sk;
  159. }
  160. #ifdef XT_TPROXY_HAVE_IPV6
  161. static inline struct sock *
  162. nf_tproxy_get_sock_v6(struct net *net, struct sk_buff *skb, int thoff, void *hp,
  163. const u8 protocol,
  164. const struct in6_addr *saddr, const struct in6_addr *daddr,
  165. const __be16 sport, const __be16 dport,
  166. const struct net_device *in,
  167. const enum nf_tproxy_lookup_t lookup_type)
  168. {
  169. struct sock *sk;
  170. struct tcphdr *tcph;
  171. switch (protocol) {
  172. case IPPROTO_TCP:
  173. switch (lookup_type) {
  174. case NFT_LOOKUP_LISTENER:
  175. tcph = hp;
  176. sk = inet6_lookup_listener(net, &tcp_hashinfo, skb,
  177. thoff + __tcp_hdrlen(tcph),
  178. saddr, sport,
  179. daddr, ntohs(dport),
  180. in->ifindex);
  181. if (sk && !atomic_inc_not_zero(&sk->sk_refcnt))
  182. sk = NULL;
  183. /* NOTE: we return listeners even if bound to
  184. * 0.0.0.0, those are filtered out in
  185. * xt_socket, since xt_TPROXY needs 0 bound
  186. * listeners too
  187. */
  188. break;
  189. case NFT_LOOKUP_ESTABLISHED:
  190. sk = __inet6_lookup_established(net, &tcp_hashinfo,
  191. saddr, sport, daddr, ntohs(dport),
  192. in->ifindex);
  193. break;
  194. default:
  195. BUG();
  196. }
  197. break;
  198. case IPPROTO_UDP:
  199. sk = udp6_lib_lookup(net, saddr, sport, daddr, dport,
  200. in->ifindex);
  201. if (sk) {
  202. int connected = (sk->sk_state == TCP_ESTABLISHED);
  203. int wildcard = ipv6_addr_any(&sk->sk_v6_rcv_saddr);
  204. /* NOTE: we return listeners even if bound to
  205. * 0.0.0.0, those are filtered out in
  206. * xt_socket, since xt_TPROXY needs 0 bound
  207. * listeners too
  208. */
  209. if ((lookup_type == NFT_LOOKUP_ESTABLISHED && (!connected || wildcard)) ||
  210. (lookup_type == NFT_LOOKUP_LISTENER && connected)) {
  211. sock_put(sk);
  212. sk = NULL;
  213. }
  214. }
  215. break;
  216. default:
  217. WARN_ON(1);
  218. sk = NULL;
  219. }
  220. pr_debug("tproxy socket lookup: proto %u %pI6:%u -> %pI6:%u, lookup type: %d, sock %p\n",
  221. protocol, saddr, ntohs(sport), daddr, ntohs(dport), lookup_type, sk);
  222. return sk;
  223. }
  224. #endif
  225. /**
  226. * tproxy_handle_time_wait4 - handle IPv4 TCP TIME_WAIT reopen redirections
  227. * @skb: The skb being processed.
  228. * @laddr: IPv4 address to redirect to or zero.
  229. * @lport: TCP port to redirect to or zero.
  230. * @sk: The TIME_WAIT TCP socket found by the lookup.
  231. *
  232. * We have to handle SYN packets arriving to TIME_WAIT sockets
  233. * differently: instead of reopening the connection we should rather
  234. * redirect the new connection to the proxy if there's a listener
  235. * socket present.
  236. *
  237. * tproxy_handle_time_wait4() consumes the socket reference passed in.
  238. *
  239. * Returns the listener socket if there's one, the TIME_WAIT socket if
  240. * no such listener is found, or NULL if the TCP header is incomplete.
  241. */
  242. static struct sock *
  243. tproxy_handle_time_wait4(struct net *net, struct sk_buff *skb,
  244. __be32 laddr, __be16 lport, struct sock *sk)
  245. {
  246. const struct iphdr *iph = ip_hdr(skb);
  247. struct tcphdr _hdr, *hp;
  248. hp = skb_header_pointer(skb, ip_hdrlen(skb), sizeof(_hdr), &_hdr);
  249. if (hp == NULL) {
  250. inet_twsk_put(inet_twsk(sk));
  251. return NULL;
  252. }
  253. if (hp->syn && !hp->rst && !hp->ack && !hp->fin) {
  254. /* SYN to a TIME_WAIT socket, we'd rather redirect it
  255. * to a listener socket if there's one */
  256. struct sock *sk2;
  257. sk2 = nf_tproxy_get_sock_v4(net, skb, hp, iph->protocol,
  258. iph->saddr, laddr ? laddr : iph->daddr,
  259. hp->source, lport ? lport : hp->dest,
  260. skb->dev, NFT_LOOKUP_LISTENER);
  261. if (sk2) {
  262. inet_twsk_deschedule_put(inet_twsk(sk));
  263. sk = sk2;
  264. }
  265. }
  266. return sk;
  267. }
  268. /* assign a socket to the skb -- consumes sk */
  269. static void
  270. nf_tproxy_assign_sock(struct sk_buff *skb, struct sock *sk)
  271. {
  272. skb_orphan(skb);
  273. skb->sk = sk;
  274. skb->destructor = sock_edemux;
  275. }
  276. static unsigned int
  277. tproxy_tg4(struct net *net, struct sk_buff *skb, __be32 laddr, __be16 lport,
  278. u_int32_t mark_mask, u_int32_t mark_value)
  279. {
  280. const struct iphdr *iph = ip_hdr(skb);
  281. struct udphdr _hdr, *hp;
  282. struct sock *sk;
  283. hp = skb_header_pointer(skb, ip_hdrlen(skb), sizeof(_hdr), &_hdr);
  284. if (hp == NULL)
  285. return NF_DROP;
  286. /* check if there's an ongoing connection on the packet
  287. * addresses, this happens if the redirect already happened
  288. * and the current packet belongs to an already established
  289. * connection */
  290. sk = nf_tproxy_get_sock_v4(net, skb, hp, iph->protocol,
  291. iph->saddr, iph->daddr,
  292. hp->source, hp->dest,
  293. skb->dev, NFT_LOOKUP_ESTABLISHED);
  294. laddr = tproxy_laddr4(skb, laddr, iph->daddr);
  295. if (!lport)
  296. lport = hp->dest;
  297. /* UDP has no TCP_TIME_WAIT state, so we never enter here */
  298. if (sk && sk->sk_state == TCP_TIME_WAIT)
  299. /* reopening a TIME_WAIT connection needs special handling */
  300. sk = tproxy_handle_time_wait4(net, skb, laddr, lport, sk);
  301. else if (!sk)
  302. /* no, there's no established connection, check if
  303. * there's a listener on the redirected addr/port */
  304. sk = nf_tproxy_get_sock_v4(net, skb, hp, iph->protocol,
  305. iph->saddr, laddr,
  306. hp->source, lport,
  307. skb->dev, NFT_LOOKUP_LISTENER);
  308. /* NOTE: assign_sock consumes our sk reference */
  309. if (sk && tproxy_sk_is_transparent(sk)) {
  310. /* This should be in a separate target, but we don't do multiple
  311. targets on the same rule yet */
  312. skb->mark = (skb->mark & ~mark_mask) ^ mark_value;
  313. pr_debug("redirecting: proto %hhu %pI4:%hu -> %pI4:%hu, mark: %x\n",
  314. iph->protocol, &iph->daddr, ntohs(hp->dest),
  315. &laddr, ntohs(lport), skb->mark);
  316. nf_tproxy_assign_sock(skb, sk);
  317. return NF_ACCEPT;
  318. }
  319. pr_debug("no socket, dropping: proto %hhu %pI4:%hu -> %pI4:%hu, mark: %x\n",
  320. iph->protocol, &iph->saddr, ntohs(hp->source),
  321. &iph->daddr, ntohs(hp->dest), skb->mark);
  322. return NF_DROP;
  323. }
  324. static unsigned int
  325. tproxy_tg4_v0(struct sk_buff *skb, const struct xt_action_param *par)
  326. {
  327. const struct xt_tproxy_target_info *tgi = par->targinfo;
  328. return tproxy_tg4(par->net, skb, tgi->laddr, tgi->lport, tgi->mark_mask, tgi->mark_value);
  329. }
  330. static unsigned int
  331. tproxy_tg4_v1(struct sk_buff *skb, const struct xt_action_param *par)
  332. {
  333. const struct xt_tproxy_target_info_v1 *tgi = par->targinfo;
  334. return tproxy_tg4(par->net, skb, tgi->laddr.ip, tgi->lport, tgi->mark_mask, tgi->mark_value);
  335. }
  336. #ifdef XT_TPROXY_HAVE_IPV6
  337. static inline const struct in6_addr *
  338. tproxy_laddr6(struct sk_buff *skb, const struct in6_addr *user_laddr,
  339. const struct in6_addr *daddr)
  340. {
  341. struct inet6_dev *indev;
  342. struct inet6_ifaddr *ifa;
  343. struct in6_addr *laddr;
  344. if (!ipv6_addr_any(user_laddr))
  345. return user_laddr;
  346. laddr = NULL;
  347. rcu_read_lock();
  348. indev = __in6_dev_get(skb->dev);
  349. if (indev)
  350. list_for_each_entry(ifa, &indev->addr_list, if_list) {
  351. if (ifa->flags & (IFA_F_TENTATIVE | IFA_F_DEPRECATED))
  352. continue;
  353. laddr = &ifa->addr;
  354. break;
  355. }
  356. rcu_read_unlock();
  357. return laddr ? laddr : daddr;
  358. }
  359. /**
  360. * tproxy_handle_time_wait6 - handle IPv6 TCP TIME_WAIT reopen redirections
  361. * @skb: The skb being processed.
  362. * @tproto: Transport protocol.
  363. * @thoff: Transport protocol header offset.
  364. * @par: Iptables target parameters.
  365. * @sk: The TIME_WAIT TCP socket found by the lookup.
  366. *
  367. * We have to handle SYN packets arriving to TIME_WAIT sockets
  368. * differently: instead of reopening the connection we should rather
  369. * redirect the new connection to the proxy if there's a listener
  370. * socket present.
  371. *
  372. * tproxy_handle_time_wait6() consumes the socket reference passed in.
  373. *
  374. * Returns the listener socket if there's one, the TIME_WAIT socket if
  375. * no such listener is found, or NULL if the TCP header is incomplete.
  376. */
  377. static struct sock *
  378. tproxy_handle_time_wait6(struct sk_buff *skb, int tproto, int thoff,
  379. const struct xt_action_param *par,
  380. struct sock *sk)
  381. {
  382. const struct ipv6hdr *iph = ipv6_hdr(skb);
  383. struct tcphdr _hdr, *hp;
  384. const struct xt_tproxy_target_info_v1 *tgi = par->targinfo;
  385. hp = skb_header_pointer(skb, thoff, sizeof(_hdr), &_hdr);
  386. if (hp == NULL) {
  387. inet_twsk_put(inet_twsk(sk));
  388. return NULL;
  389. }
  390. if (hp->syn && !hp->rst && !hp->ack && !hp->fin) {
  391. /* SYN to a TIME_WAIT socket, we'd rather redirect it
  392. * to a listener socket if there's one */
  393. struct sock *sk2;
  394. sk2 = nf_tproxy_get_sock_v6(par->net, skb, thoff, hp, tproto,
  395. &iph->saddr,
  396. tproxy_laddr6(skb, &tgi->laddr.in6, &iph->daddr),
  397. hp->source,
  398. tgi->lport ? tgi->lport : hp->dest,
  399. skb->dev, NFT_LOOKUP_LISTENER);
  400. if (sk2) {
  401. inet_twsk_deschedule_put(inet_twsk(sk));
  402. sk = sk2;
  403. }
  404. }
  405. return sk;
  406. }
  407. static unsigned int
  408. tproxy_tg6_v1(struct sk_buff *skb, const struct xt_action_param *par)
  409. {
  410. const struct ipv6hdr *iph = ipv6_hdr(skb);
  411. const struct xt_tproxy_target_info_v1 *tgi = par->targinfo;
  412. struct udphdr _hdr, *hp;
  413. struct sock *sk;
  414. const struct in6_addr *laddr;
  415. __be16 lport;
  416. int thoff = 0;
  417. int tproto;
  418. tproto = ipv6_find_hdr(skb, &thoff, -1, NULL, NULL);
  419. if (tproto < 0) {
  420. pr_debug("unable to find transport header in IPv6 packet, dropping\n");
  421. return NF_DROP;
  422. }
  423. hp = skb_header_pointer(skb, thoff, sizeof(_hdr), &_hdr);
  424. if (hp == NULL) {
  425. pr_debug("unable to grab transport header contents in IPv6 packet, dropping\n");
  426. return NF_DROP;
  427. }
  428. /* check if there's an ongoing connection on the packet
  429. * addresses, this happens if the redirect already happened
  430. * and the current packet belongs to an already established
  431. * connection */
  432. sk = nf_tproxy_get_sock_v6(par->net, skb, thoff, hp, tproto,
  433. &iph->saddr, &iph->daddr,
  434. hp->source, hp->dest,
  435. par->in, NFT_LOOKUP_ESTABLISHED);
  436. laddr = tproxy_laddr6(skb, &tgi->laddr.in6, &iph->daddr);
  437. lport = tgi->lport ? tgi->lport : hp->dest;
  438. /* UDP has no TCP_TIME_WAIT state, so we never enter here */
  439. if (sk && sk->sk_state == TCP_TIME_WAIT)
  440. /* reopening a TIME_WAIT connection needs special handling */
  441. sk = tproxy_handle_time_wait6(skb, tproto, thoff, par, sk);
  442. else if (!sk)
  443. /* no there's no established connection, check if
  444. * there's a listener on the redirected addr/port */
  445. sk = nf_tproxy_get_sock_v6(par->net, skb, thoff, hp,
  446. tproto, &iph->saddr, laddr,
  447. hp->source, lport,
  448. par->in, NFT_LOOKUP_LISTENER);
  449. /* NOTE: assign_sock consumes our sk reference */
  450. if (sk && tproxy_sk_is_transparent(sk)) {
  451. /* This should be in a separate target, but we don't do multiple
  452. targets on the same rule yet */
  453. skb->mark = (skb->mark & ~tgi->mark_mask) ^ tgi->mark_value;
  454. pr_debug("redirecting: proto %hhu %pI6:%hu -> %pI6:%hu, mark: %x\n",
  455. tproto, &iph->saddr, ntohs(hp->source),
  456. laddr, ntohs(lport), skb->mark);
  457. nf_tproxy_assign_sock(skb, sk);
  458. return NF_ACCEPT;
  459. }
  460. pr_debug("no socket, dropping: proto %hhu %pI6:%hu -> %pI6:%hu, mark: %x\n",
  461. tproto, &iph->saddr, ntohs(hp->source),
  462. &iph->daddr, ntohs(hp->dest), skb->mark);
  463. return NF_DROP;
  464. }
  465. static int tproxy_tg6_check(const struct xt_tgchk_param *par)
  466. {
  467. const struct ip6t_ip6 *i = par->entryinfo;
  468. if ((i->proto == IPPROTO_TCP || i->proto == IPPROTO_UDP) &&
  469. !(i->invflags & IP6T_INV_PROTO))
  470. return 0;
  471. pr_info("Can be used only in combination with "
  472. "either -p tcp or -p udp\n");
  473. return -EINVAL;
  474. }
  475. #endif
  476. static int tproxy_tg4_check(const struct xt_tgchk_param *par)
  477. {
  478. const struct ipt_ip *i = par->entryinfo;
  479. if ((i->proto == IPPROTO_TCP || i->proto == IPPROTO_UDP)
  480. && !(i->invflags & IPT_INV_PROTO))
  481. return 0;
  482. pr_info("Can be used only in combination with "
  483. "either -p tcp or -p udp\n");
  484. return -EINVAL;
  485. }
  486. static struct xt_target tproxy_tg_reg[] __read_mostly = {
  487. {
  488. .name = "TPROXY",
  489. .family = NFPROTO_IPV4,
  490. .table = "mangle",
  491. .target = tproxy_tg4_v0,
  492. .revision = 0,
  493. .targetsize = sizeof(struct xt_tproxy_target_info),
  494. .checkentry = tproxy_tg4_check,
  495. .hooks = 1 << NF_INET_PRE_ROUTING,
  496. .me = THIS_MODULE,
  497. },
  498. {
  499. .name = "TPROXY",
  500. .family = NFPROTO_IPV4,
  501. .table = "mangle",
  502. .target = tproxy_tg4_v1,
  503. .revision = 1,
  504. .targetsize = sizeof(struct xt_tproxy_target_info_v1),
  505. .checkentry = tproxy_tg4_check,
  506. .hooks = 1 << NF_INET_PRE_ROUTING,
  507. .me = THIS_MODULE,
  508. },
  509. #ifdef XT_TPROXY_HAVE_IPV6
  510. {
  511. .name = "TPROXY",
  512. .family = NFPROTO_IPV6,
  513. .table = "mangle",
  514. .target = tproxy_tg6_v1,
  515. .revision = 1,
  516. .targetsize = sizeof(struct xt_tproxy_target_info_v1),
  517. .checkentry = tproxy_tg6_check,
  518. .hooks = 1 << NF_INET_PRE_ROUTING,
  519. .me = THIS_MODULE,
  520. },
  521. #endif
  522. };
  523. static int __init tproxy_tg_init(void)
  524. {
  525. nf_defrag_ipv4_enable();
  526. #ifdef XT_TPROXY_HAVE_IPV6
  527. nf_defrag_ipv6_enable();
  528. #endif
  529. return xt_register_targets(tproxy_tg_reg, ARRAY_SIZE(tproxy_tg_reg));
  530. }
  531. static void __exit tproxy_tg_exit(void)
  532. {
  533. xt_unregister_targets(tproxy_tg_reg, ARRAY_SIZE(tproxy_tg_reg));
  534. }
  535. module_init(tproxy_tg_init);
  536. module_exit(tproxy_tg_exit);
  537. MODULE_LICENSE("GPL");
  538. MODULE_AUTHOR("Balazs Scheidler, Krisztian Kovacs");
  539. MODULE_DESCRIPTION("Netfilter transparent proxy (TPROXY) target module.");
  540. MODULE_ALIAS("ipt_TPROXY");
  541. MODULE_ALIAS("ip6t_TPROXY");