Patrick McHardy | 59eecdf | 2007-07-14 20:48:44 -0700 | [diff] [blame] | 1 | /* (C) 1999-2001 Paul `Rusty' Russell |
| 2 | * (C) 2002-2004 Netfilter Core Team <coreteam@netfilter.org> |
| 3 | * (C) 2007 Patrick McHardy <kaber@trash.net> |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License version 2 as |
| 7 | * published by the Free Software Foundation. |
| 8 | */ |
| 9 | |
| 10 | #include <linux/types.h> |
| 11 | #include <linux/timer.h> |
| 12 | #include <linux/module.h> |
Patrick McHardy | 59eecdf | 2007-07-14 20:48:44 -0700 | [diff] [blame] | 13 | #include <linux/udp.h> |
| 14 | #include <linux/seq_file.h> |
| 15 | #include <linux/skbuff.h> |
| 16 | #include <linux/ipv6.h> |
| 17 | #include <net/ip6_checksum.h> |
| 18 | #include <net/checksum.h> |
| 19 | |
| 20 | #include <linux/netfilter.h> |
| 21 | #include <linux/netfilter_ipv4.h> |
| 22 | #include <linux/netfilter_ipv6.h> |
| 23 | #include <net/netfilter/nf_conntrack_l4proto.h> |
| 24 | #include <net/netfilter/nf_conntrack_ecache.h> |
Patrick McHardy | f01ffbd | 2007-12-17 22:38:49 -0800 | [diff] [blame] | 25 | #include <net/netfilter/nf_log.h> |
Patrick McHardy | 59eecdf | 2007-07-14 20:48:44 -0700 | [diff] [blame] | 26 | |
Pablo Neira Ayuso | 5a41db9 | 2012-02-28 02:23:28 +0100 | [diff] [blame] | 27 | enum udplite_conntrack { |
| 28 | UDPLITE_CT_UNREPLIED, |
| 29 | UDPLITE_CT_REPLIED, |
| 30 | UDPLITE_CT_MAX |
| 31 | }; |
| 32 | |
| 33 | static unsigned int udplite_timeouts[UDPLITE_CT_MAX] = { |
| 34 | [UDPLITE_CT_UNREPLIED] = 30*HZ, |
| 35 | [UDPLITE_CT_REPLIED] = 180*HZ, |
| 36 | }; |
Patrick McHardy | 59eecdf | 2007-07-14 20:48:44 -0700 | [diff] [blame] | 37 | |
Jan Engelhardt | 09f263c | 2008-04-14 11:15:53 +0200 | [diff] [blame] | 38 | static bool udplite_pkt_to_tuple(const struct sk_buff *skb, |
| 39 | unsigned int dataoff, |
| 40 | struct nf_conntrack_tuple *tuple) |
Patrick McHardy | 59eecdf | 2007-07-14 20:48:44 -0700 | [diff] [blame] | 41 | { |
Jan Engelhardt | da3f13c | 2008-01-31 04:52:29 -0800 | [diff] [blame] | 42 | const struct udphdr *hp; |
| 43 | struct udphdr _hdr; |
Patrick McHardy | 59eecdf | 2007-07-14 20:48:44 -0700 | [diff] [blame] | 44 | |
| 45 | hp = skb_header_pointer(skb, dataoff, sizeof(_hdr), &_hdr); |
| 46 | if (hp == NULL) |
Jan Engelhardt | 09f263c | 2008-04-14 11:15:53 +0200 | [diff] [blame] | 47 | return false; |
Patrick McHardy | 59eecdf | 2007-07-14 20:48:44 -0700 | [diff] [blame] | 48 | |
| 49 | tuple->src.u.udp.port = hp->source; |
| 50 | tuple->dst.u.udp.port = hp->dest; |
Jan Engelhardt | 09f263c | 2008-04-14 11:15:53 +0200 | [diff] [blame] | 51 | return true; |
Patrick McHardy | 59eecdf | 2007-07-14 20:48:44 -0700 | [diff] [blame] | 52 | } |
| 53 | |
Jan Engelhardt | 09f263c | 2008-04-14 11:15:53 +0200 | [diff] [blame] | 54 | static bool udplite_invert_tuple(struct nf_conntrack_tuple *tuple, |
| 55 | const struct nf_conntrack_tuple *orig) |
Patrick McHardy | 59eecdf | 2007-07-14 20:48:44 -0700 | [diff] [blame] | 56 | { |
| 57 | tuple->src.u.udp.port = orig->dst.u.udp.port; |
| 58 | tuple->dst.u.udp.port = orig->src.u.udp.port; |
Jan Engelhardt | 09f263c | 2008-04-14 11:15:53 +0200 | [diff] [blame] | 59 | return true; |
Patrick McHardy | 59eecdf | 2007-07-14 20:48:44 -0700 | [diff] [blame] | 60 | } |
| 61 | |
| 62 | /* Print out the per-protocol part of the tuple. */ |
| 63 | static int udplite_print_tuple(struct seq_file *s, |
| 64 | const struct nf_conntrack_tuple *tuple) |
| 65 | { |
| 66 | return seq_printf(s, "sport=%hu dport=%hu ", |
| 67 | ntohs(tuple->src.u.udp.port), |
| 68 | ntohs(tuple->dst.u.udp.port)); |
| 69 | } |
| 70 | |
Pablo Neira Ayuso | 2c8503f | 2012-02-28 18:23:31 +0100 | [diff] [blame] | 71 | static unsigned int *udplite_get_timeouts(struct net *net) |
| 72 | { |
| 73 | return udplite_timeouts; |
| 74 | } |
| 75 | |
Patrick McHardy | 59eecdf | 2007-07-14 20:48:44 -0700 | [diff] [blame] | 76 | /* Returns verdict for packet, and may modify conntracktype */ |
Patrick McHardy | c88130b | 2008-01-31 04:42:11 -0800 | [diff] [blame] | 77 | static int udplite_packet(struct nf_conn *ct, |
Patrick McHardy | 59eecdf | 2007-07-14 20:48:44 -0700 | [diff] [blame] | 78 | const struct sk_buff *skb, |
| 79 | unsigned int dataoff, |
| 80 | enum ip_conntrack_info ctinfo, |
Jan Engelhardt | 76108ce | 2008-10-08 11:35:00 +0200 | [diff] [blame] | 81 | u_int8_t pf, |
Pablo Neira Ayuso | 2c8503f | 2012-02-28 18:23:31 +0100 | [diff] [blame] | 82 | unsigned int hooknum, |
| 83 | unsigned int *timeouts) |
Patrick McHardy | 59eecdf | 2007-07-14 20:48:44 -0700 | [diff] [blame] | 84 | { |
| 85 | /* If we've seen traffic both ways, this is some kind of UDP |
| 86 | stream. Extend timeout. */ |
Patrick McHardy | c88130b | 2008-01-31 04:42:11 -0800 | [diff] [blame] | 87 | if (test_bit(IPS_SEEN_REPLY_BIT, &ct->status)) { |
| 88 | nf_ct_refresh_acct(ct, ctinfo, skb, |
Pablo Neira Ayuso | 2c8503f | 2012-02-28 18:23:31 +0100 | [diff] [blame] | 89 | timeouts[UDPLITE_CT_REPLIED]); |
Patrick McHardy | 59eecdf | 2007-07-14 20:48:44 -0700 | [diff] [blame] | 90 | /* Also, more likely to be important, and not a probe */ |
Patrick McHardy | c88130b | 2008-01-31 04:42:11 -0800 | [diff] [blame] | 91 | if (!test_and_set_bit(IPS_ASSURED_BIT, &ct->status)) |
Patrick McHardy | 858b3133 | 2010-02-03 13:48:53 +0100 | [diff] [blame] | 92 | nf_conntrack_event_cache(IPCT_ASSURED, ct); |
Pablo Neira Ayuso | 5a41db9 | 2012-02-28 02:23:28 +0100 | [diff] [blame] | 93 | } else { |
| 94 | nf_ct_refresh_acct(ct, ctinfo, skb, |
Pablo Neira Ayuso | 2c8503f | 2012-02-28 18:23:31 +0100 | [diff] [blame] | 95 | timeouts[UDPLITE_CT_UNREPLIED]); |
Pablo Neira Ayuso | 5a41db9 | 2012-02-28 02:23:28 +0100 | [diff] [blame] | 96 | } |
Patrick McHardy | 59eecdf | 2007-07-14 20:48:44 -0700 | [diff] [blame] | 97 | return NF_ACCEPT; |
| 98 | } |
| 99 | |
| 100 | /* Called when a new connection for this protocol found. */ |
Jan Engelhardt | 09f263c | 2008-04-14 11:15:53 +0200 | [diff] [blame] | 101 | static bool udplite_new(struct nf_conn *ct, const struct sk_buff *skb, |
Pablo Neira Ayuso | 2c8503f | 2012-02-28 18:23:31 +0100 | [diff] [blame] | 102 | unsigned int dataoff, unsigned int *timeouts) |
Patrick McHardy | 59eecdf | 2007-07-14 20:48:44 -0700 | [diff] [blame] | 103 | { |
Jan Engelhardt | 09f263c | 2008-04-14 11:15:53 +0200 | [diff] [blame] | 104 | return true; |
Patrick McHardy | 59eecdf | 2007-07-14 20:48:44 -0700 | [diff] [blame] | 105 | } |
| 106 | |
Patrick McHardy | 8fea97e | 2010-02-15 17:45:08 +0100 | [diff] [blame] | 107 | static int udplite_error(struct net *net, struct nf_conn *tmpl, |
Alexey Dobriyan | 74c51a1 | 2008-10-08 11:35:05 +0200 | [diff] [blame] | 108 | struct sk_buff *skb, |
| 109 | unsigned int dataoff, |
Patrick McHardy | 59eecdf | 2007-07-14 20:48:44 -0700 | [diff] [blame] | 110 | enum ip_conntrack_info *ctinfo, |
Jan Engelhardt | 76108ce | 2008-10-08 11:35:00 +0200 | [diff] [blame] | 111 | u_int8_t pf, |
Patrick McHardy | 59eecdf | 2007-07-14 20:48:44 -0700 | [diff] [blame] | 112 | unsigned int hooknum) |
| 113 | { |
| 114 | unsigned int udplen = skb->len - dataoff; |
Jan Engelhardt | da3f13c | 2008-01-31 04:52:29 -0800 | [diff] [blame] | 115 | const struct udphdr *hdr; |
| 116 | struct udphdr _hdr; |
Patrick McHardy | 59eecdf | 2007-07-14 20:48:44 -0700 | [diff] [blame] | 117 | unsigned int cscov; |
| 118 | |
| 119 | /* Header is too small? */ |
| 120 | hdr = skb_header_pointer(skb, dataoff, sizeof(_hdr), &_hdr); |
| 121 | if (hdr == NULL) { |
Alexey Dobriyan | c2a2c7e | 2008-10-08 11:35:08 +0200 | [diff] [blame] | 122 | if (LOG_INVALID(net, IPPROTO_UDPLITE)) |
Patrick McHardy | 59eecdf | 2007-07-14 20:48:44 -0700 | [diff] [blame] | 123 | nf_log_packet(pf, 0, skb, NULL, NULL, NULL, |
| 124 | "nf_ct_udplite: short packet "); |
| 125 | return -NF_ACCEPT; |
| 126 | } |
| 127 | |
| 128 | cscov = ntohs(hdr->len); |
| 129 | if (cscov == 0) |
| 130 | cscov = udplen; |
| 131 | else if (cscov < sizeof(*hdr) || cscov > udplen) { |
Alexey Dobriyan | c2a2c7e | 2008-10-08 11:35:08 +0200 | [diff] [blame] | 132 | if (LOG_INVALID(net, IPPROTO_UDPLITE)) |
Patrick McHardy | 59eecdf | 2007-07-14 20:48:44 -0700 | [diff] [blame] | 133 | nf_log_packet(pf, 0, skb, NULL, NULL, NULL, |
| 134 | "nf_ct_udplite: invalid checksum coverage "); |
| 135 | return -NF_ACCEPT; |
| 136 | } |
| 137 | |
| 138 | /* UDPLITE mandates checksums */ |
| 139 | if (!hdr->check) { |
Alexey Dobriyan | c2a2c7e | 2008-10-08 11:35:08 +0200 | [diff] [blame] | 140 | if (LOG_INVALID(net, IPPROTO_UDPLITE)) |
Patrick McHardy | 59eecdf | 2007-07-14 20:48:44 -0700 | [diff] [blame] | 141 | nf_log_packet(pf, 0, skb, NULL, NULL, NULL, |
| 142 | "nf_ct_udplite: checksum missing "); |
| 143 | return -NF_ACCEPT; |
| 144 | } |
| 145 | |
| 146 | /* Checksum invalid? Ignore. */ |
Alexey Dobriyan | c04d055 | 2008-10-08 11:35:08 +0200 | [diff] [blame] | 147 | if (net->ct.sysctl_checksum && hooknum == NF_INET_PRE_ROUTING && |
Patrick McHardy | d63a650 | 2008-03-20 15:15:53 +0100 | [diff] [blame] | 148 | nf_checksum_partial(skb, hooknum, dataoff, cscov, IPPROTO_UDP, |
| 149 | pf)) { |
Alexey Dobriyan | c2a2c7e | 2008-10-08 11:35:08 +0200 | [diff] [blame] | 150 | if (LOG_INVALID(net, IPPROTO_UDPLITE)) |
Patrick McHardy | d63a650 | 2008-03-20 15:15:53 +0100 | [diff] [blame] | 151 | nf_log_packet(pf, 0, skb, NULL, NULL, NULL, |
| 152 | "nf_ct_udplite: bad UDPLite checksum "); |
| 153 | return -NF_ACCEPT; |
Patrick McHardy | 59eecdf | 2007-07-14 20:48:44 -0700 | [diff] [blame] | 154 | } |
| 155 | |
| 156 | return NF_ACCEPT; |
| 157 | } |
| 158 | |
Pablo Neira Ayuso | 5097846 | 2012-02-28 19:13:48 +0100 | [diff] [blame] | 159 | #if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) |
| 160 | |
| 161 | #include <linux/netfilter/nfnetlink.h> |
| 162 | #include <linux/netfilter/nfnetlink_cttimeout.h> |
| 163 | |
| 164 | static int udplite_timeout_nlattr_to_obj(struct nlattr *tb[], void *data) |
| 165 | { |
| 166 | unsigned int *timeouts = data; |
| 167 | |
| 168 | /* set default timeouts for UDPlite. */ |
| 169 | timeouts[UDPLITE_CT_UNREPLIED] = udplite_timeouts[UDPLITE_CT_UNREPLIED]; |
| 170 | timeouts[UDPLITE_CT_REPLIED] = udplite_timeouts[UDPLITE_CT_REPLIED]; |
| 171 | |
| 172 | if (tb[CTA_TIMEOUT_UDPLITE_UNREPLIED]) { |
| 173 | timeouts[UDPLITE_CT_UNREPLIED] = |
| 174 | ntohl(nla_get_be32(tb[CTA_TIMEOUT_UDPLITE_UNREPLIED])) * HZ; |
| 175 | } |
| 176 | if (tb[CTA_TIMEOUT_UDPLITE_REPLIED]) { |
| 177 | timeouts[UDPLITE_CT_REPLIED] = |
| 178 | ntohl(nla_get_be32(tb[CTA_TIMEOUT_UDPLITE_REPLIED])) * HZ; |
| 179 | } |
| 180 | return 0; |
| 181 | } |
| 182 | |
| 183 | static int |
| 184 | udplite_timeout_obj_to_nlattr(struct sk_buff *skb, const void *data) |
| 185 | { |
| 186 | const unsigned int *timeouts = data; |
| 187 | |
| 188 | NLA_PUT_BE32(skb, CTA_TIMEOUT_UDPLITE_UNREPLIED, |
| 189 | htonl(timeouts[UDPLITE_CT_UNREPLIED] / HZ)); |
| 190 | NLA_PUT_BE32(skb, CTA_TIMEOUT_UDPLITE_REPLIED, |
| 191 | htonl(timeouts[UDPLITE_CT_REPLIED] / HZ)); |
| 192 | return 0; |
| 193 | |
| 194 | nla_put_failure: |
| 195 | return -ENOSPC; |
| 196 | } |
| 197 | |
| 198 | static const struct nla_policy |
| 199 | udplite_timeout_nla_policy[CTA_TIMEOUT_UDPLITE_MAX+1] = { |
| 200 | [CTA_TIMEOUT_UDPLITE_UNREPLIED] = { .type = NLA_U32 }, |
| 201 | [CTA_TIMEOUT_UDPLITE_REPLIED] = { .type = NLA_U32 }, |
| 202 | }; |
| 203 | #endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ |
| 204 | |
Patrick McHardy | 59eecdf | 2007-07-14 20:48:44 -0700 | [diff] [blame] | 205 | #ifdef CONFIG_SYSCTL |
| 206 | static unsigned int udplite_sysctl_table_users; |
| 207 | static struct ctl_table_header *udplite_sysctl_header; |
| 208 | static struct ctl_table udplite_sysctl_table[] = { |
| 209 | { |
Patrick McHardy | 59eecdf | 2007-07-14 20:48:44 -0700 | [diff] [blame] | 210 | .procname = "nf_conntrack_udplite_timeout", |
Pablo Neira Ayuso | 5a41db9 | 2012-02-28 02:23:28 +0100 | [diff] [blame] | 211 | .data = &udplite_timeouts[UDPLITE_CT_UNREPLIED], |
Patrick McHardy | 59eecdf | 2007-07-14 20:48:44 -0700 | [diff] [blame] | 212 | .maxlen = sizeof(unsigned int), |
| 213 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 214 | .proc_handler = proc_dointvec_jiffies, |
Patrick McHardy | 59eecdf | 2007-07-14 20:48:44 -0700 | [diff] [blame] | 215 | }, |
| 216 | { |
Patrick McHardy | 59eecdf | 2007-07-14 20:48:44 -0700 | [diff] [blame] | 217 | .procname = "nf_conntrack_udplite_timeout_stream", |
Pablo Neira Ayuso | 5a41db9 | 2012-02-28 02:23:28 +0100 | [diff] [blame] | 218 | .data = &udplite_timeouts[UDPLITE_CT_REPLIED], |
Patrick McHardy | 59eecdf | 2007-07-14 20:48:44 -0700 | [diff] [blame] | 219 | .maxlen = sizeof(unsigned int), |
| 220 | .mode = 0644, |
Alexey Dobriyan | 6d9f239 | 2008-11-03 18:21:05 -0800 | [diff] [blame] | 221 | .proc_handler = proc_dointvec_jiffies, |
Patrick McHardy | 59eecdf | 2007-07-14 20:48:44 -0700 | [diff] [blame] | 222 | }, |
Eric W. Biederman | f8572d8 | 2009-11-05 13:32:03 -0800 | [diff] [blame] | 223 | { } |
Patrick McHardy | 59eecdf | 2007-07-14 20:48:44 -0700 | [diff] [blame] | 224 | }; |
| 225 | #endif /* CONFIG_SYSCTL */ |
| 226 | |
| 227 | static struct nf_conntrack_l4proto nf_conntrack_l4proto_udplite4 __read_mostly = |
| 228 | { |
| 229 | .l3proto = PF_INET, |
| 230 | .l4proto = IPPROTO_UDPLITE, |
| 231 | .name = "udplite", |
| 232 | .pkt_to_tuple = udplite_pkt_to_tuple, |
| 233 | .invert_tuple = udplite_invert_tuple, |
| 234 | .print_tuple = udplite_print_tuple, |
Patrick McHardy | 59eecdf | 2007-07-14 20:48:44 -0700 | [diff] [blame] | 235 | .packet = udplite_packet, |
Pablo Neira Ayuso | 2c8503f | 2012-02-28 18:23:31 +0100 | [diff] [blame] | 236 | .get_timeouts = udplite_get_timeouts, |
Patrick McHardy | 59eecdf | 2007-07-14 20:48:44 -0700 | [diff] [blame] | 237 | .new = udplite_new, |
| 238 | .error = udplite_error, |
Igor Maravić | c0cd115 | 2011-12-12 02:58:24 +0000 | [diff] [blame] | 239 | #if IS_ENABLED(CONFIG_NF_CT_NETLINK) |
Patrick McHardy | fdf7083 | 2007-09-28 14:37:41 -0700 | [diff] [blame] | 240 | .tuple_to_nlattr = nf_ct_port_tuple_to_nlattr, |
Holger Eitzenberger | a400c30 | 2009-03-25 21:53:39 +0100 | [diff] [blame] | 241 | .nlattr_tuple_size = nf_ct_port_nlattr_tuple_size, |
Patrick McHardy | fdf7083 | 2007-09-28 14:37:41 -0700 | [diff] [blame] | 242 | .nlattr_to_tuple = nf_ct_port_nlattr_to_tuple, |
Patrick McHardy | f73e924 | 2007-09-28 14:39:55 -0700 | [diff] [blame] | 243 | .nla_policy = nf_ct_port_nla_policy, |
Patrick McHardy | 59eecdf | 2007-07-14 20:48:44 -0700 | [diff] [blame] | 244 | #endif |
Pablo Neira Ayuso | 5097846 | 2012-02-28 19:13:48 +0100 | [diff] [blame] | 245 | #if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) |
| 246 | .ctnl_timeout = { |
| 247 | .nlattr_to_obj = udplite_timeout_nlattr_to_obj, |
| 248 | .obj_to_nlattr = udplite_timeout_obj_to_nlattr, |
| 249 | .nlattr_max = CTA_TIMEOUT_UDPLITE_MAX, |
| 250 | .obj_size = sizeof(unsigned int) * |
| 251 | CTA_TIMEOUT_UDPLITE_MAX, |
| 252 | .nla_policy = udplite_timeout_nla_policy, |
| 253 | }, |
| 254 | #endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ |
Patrick McHardy | 59eecdf | 2007-07-14 20:48:44 -0700 | [diff] [blame] | 255 | #ifdef CONFIG_SYSCTL |
| 256 | .ctl_table_users = &udplite_sysctl_table_users, |
| 257 | .ctl_table_header = &udplite_sysctl_header, |
| 258 | .ctl_table = udplite_sysctl_table, |
| 259 | #endif |
| 260 | }; |
| 261 | |
| 262 | static struct nf_conntrack_l4proto nf_conntrack_l4proto_udplite6 __read_mostly = |
| 263 | { |
| 264 | .l3proto = PF_INET6, |
| 265 | .l4proto = IPPROTO_UDPLITE, |
| 266 | .name = "udplite", |
| 267 | .pkt_to_tuple = udplite_pkt_to_tuple, |
| 268 | .invert_tuple = udplite_invert_tuple, |
| 269 | .print_tuple = udplite_print_tuple, |
Patrick McHardy | 59eecdf | 2007-07-14 20:48:44 -0700 | [diff] [blame] | 270 | .packet = udplite_packet, |
Pablo Neira Ayuso | 2c8503f | 2012-02-28 18:23:31 +0100 | [diff] [blame] | 271 | .get_timeouts = udplite_get_timeouts, |
Patrick McHardy | 59eecdf | 2007-07-14 20:48:44 -0700 | [diff] [blame] | 272 | .new = udplite_new, |
| 273 | .error = udplite_error, |
Igor Maravić | c0cd115 | 2011-12-12 02:58:24 +0000 | [diff] [blame] | 274 | #if IS_ENABLED(CONFIG_NF_CT_NETLINK) |
Patrick McHardy | fdf7083 | 2007-09-28 14:37:41 -0700 | [diff] [blame] | 275 | .tuple_to_nlattr = nf_ct_port_tuple_to_nlattr, |
Patrick McHardy | 5ff4829 | 2009-04-24 15:37:44 +0200 | [diff] [blame] | 276 | .nlattr_tuple_size = nf_ct_port_nlattr_tuple_size, |
Patrick McHardy | fdf7083 | 2007-09-28 14:37:41 -0700 | [diff] [blame] | 277 | .nlattr_to_tuple = nf_ct_port_nlattr_to_tuple, |
Patrick McHardy | f73e924 | 2007-09-28 14:39:55 -0700 | [diff] [blame] | 278 | .nla_policy = nf_ct_port_nla_policy, |
Patrick McHardy | 59eecdf | 2007-07-14 20:48:44 -0700 | [diff] [blame] | 279 | #endif |
Pablo Neira Ayuso | 5097846 | 2012-02-28 19:13:48 +0100 | [diff] [blame] | 280 | #if IS_ENABLED(CONFIG_NF_CT_NETLINK_TIMEOUT) |
| 281 | .ctnl_timeout = { |
| 282 | .nlattr_to_obj = udplite_timeout_nlattr_to_obj, |
| 283 | .obj_to_nlattr = udplite_timeout_obj_to_nlattr, |
| 284 | .nlattr_max = CTA_TIMEOUT_UDPLITE_MAX, |
| 285 | .obj_size = sizeof(unsigned int) * |
| 286 | CTA_TIMEOUT_UDPLITE_MAX, |
| 287 | .nla_policy = udplite_timeout_nla_policy, |
| 288 | }, |
| 289 | #endif /* CONFIG_NF_CT_NETLINK_TIMEOUT */ |
Patrick McHardy | 59eecdf | 2007-07-14 20:48:44 -0700 | [diff] [blame] | 290 | #ifdef CONFIG_SYSCTL |
| 291 | .ctl_table_users = &udplite_sysctl_table_users, |
| 292 | .ctl_table_header = &udplite_sysctl_header, |
| 293 | .ctl_table = udplite_sysctl_table, |
| 294 | #endif |
| 295 | }; |
| 296 | |
| 297 | static int __init nf_conntrack_proto_udplite_init(void) |
| 298 | { |
| 299 | int err; |
| 300 | |
| 301 | err = nf_conntrack_l4proto_register(&nf_conntrack_l4proto_udplite4); |
| 302 | if (err < 0) |
| 303 | goto err1; |
| 304 | err = nf_conntrack_l4proto_register(&nf_conntrack_l4proto_udplite6); |
| 305 | if (err < 0) |
| 306 | goto err2; |
| 307 | return 0; |
| 308 | err2: |
| 309 | nf_conntrack_l4proto_unregister(&nf_conntrack_l4proto_udplite4); |
| 310 | err1: |
| 311 | return err; |
| 312 | } |
| 313 | |
| 314 | static void __exit nf_conntrack_proto_udplite_exit(void) |
| 315 | { |
| 316 | nf_conntrack_l4proto_unregister(&nf_conntrack_l4proto_udplite6); |
| 317 | nf_conntrack_l4proto_unregister(&nf_conntrack_l4proto_udplite4); |
| 318 | } |
| 319 | |
| 320 | module_init(nf_conntrack_proto_udplite_init); |
| 321 | module_exit(nf_conntrack_proto_udplite_exit); |
| 322 | |
| 323 | MODULE_LICENSE("GPL"); |