diff options
| author | David S. Miller <davem@davemloft.net> | 2010-10-21 11:21:34 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2010-10-21 11:21:34 -0400 |
| commit | 9941fb62762253774cc6177d0b9172ece5133fe1 (patch) | |
| tree | 641fc2b376e2f84c7023aa0cd8b9d76f954cc3a1 /include | |
| parent | a5190b4eea1f1c53ee26b3d1176441cafa8e7f79 (diff) | |
| parent | 3b1a1ce6f418cb7ab35eb55c8a6575987a524e30 (diff) | |
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/kaber/nf-next-2.6
Diffstat (limited to 'include')
| -rw-r--r-- | include/linux/in6.h | 4 | ||||
| -rw-r--r-- | include/linux/ip_vs.h | 15 | ||||
| -rw-r--r-- | include/linux/ipv6.h | 4 | ||||
| -rw-r--r-- | include/linux/netfilter/nf_conntrack_common.h | 6 | ||||
| -rw-r--r-- | include/linux/netfilter/nf_conntrack_sip.h | 1 | ||||
| -rw-r--r-- | include/linux/netfilter/nfnetlink_conntrack.h | 1 | ||||
| -rw-r--r-- | include/linux/netfilter/x_tables.h | 5 | ||||
| -rw-r--r-- | include/linux/netfilter/xt_TPROXY.h | 13 | ||||
| -rw-r--r-- | include/linux/netfilter_arp/arp_tables.h | 68 | ||||
| -rw-r--r-- | include/linux/netfilter_bridge/Kbuild | 2 | ||||
| -rw-r--r-- | include/linux/netfilter_ipv4/ip_tables.h | 107 | ||||
| -rw-r--r-- | include/linux/netfilter_ipv6/ip6_tables.h | 110 | ||||
| -rw-r--r-- | include/net/inet_hashtables.h | 2 | ||||
| -rw-r--r-- | include/net/ip_vs.h | 180 | ||||
| -rw-r--r-- | include/net/netfilter/ipv6/nf_defrag_ipv6.h | 6 | ||||
| -rw-r--r-- | include/net/netfilter/nf_conntrack_expect.h | 12 | ||||
| -rw-r--r-- | include/net/netfilter/nf_nat_protocol.h | 3 | ||||
| -rw-r--r-- | include/net/netfilter/nf_tproxy_core.h | 192 | ||||
| -rw-r--r-- | include/net/netfilter/xt_log.h | 54 | ||||
| -rw-r--r-- | include/net/udp.h | 3 |
20 files changed, 573 insertions, 215 deletions
diff --git a/include/linux/in6.h b/include/linux/in6.h index c4bf46f764bf..097a34b55560 100644 --- a/include/linux/in6.h +++ b/include/linux/in6.h | |||
| @@ -268,6 +268,10 @@ struct in6_flowlabel_req { | |||
| 268 | /* RFC5082: Generalized Ttl Security Mechanism */ | 268 | /* RFC5082: Generalized Ttl Security Mechanism */ |
| 269 | #define IPV6_MINHOPCOUNT 73 | 269 | #define IPV6_MINHOPCOUNT 73 |
| 270 | 270 | ||
| 271 | #define IPV6_ORIGDSTADDR 74 | ||
| 272 | #define IPV6_RECVORIGDSTADDR IPV6_ORIGDSTADDR | ||
| 273 | #define IPV6_TRANSPARENT 75 | ||
| 274 | |||
| 271 | /* | 275 | /* |
| 272 | * Multicast Routing: | 276 | * Multicast Routing: |
| 273 | * see include/linux/mroute6.h. | 277 | * see include/linux/mroute6.h. |
diff --git a/include/linux/ip_vs.h b/include/linux/ip_vs.h index 9708de265bb1..5f43a3b2e3ad 100644 --- a/include/linux/ip_vs.h +++ b/include/linux/ip_vs.h | |||
| @@ -70,6 +70,7 @@ | |||
| 70 | 70 | ||
| 71 | /* | 71 | /* |
| 72 | * IPVS Connection Flags | 72 | * IPVS Connection Flags |
| 73 | * Only flags 0..15 are sent to backup server | ||
| 73 | */ | 74 | */ |
| 74 | #define IP_VS_CONN_F_FWD_MASK 0x0007 /* mask for the fwd methods */ | 75 | #define IP_VS_CONN_F_FWD_MASK 0x0007 /* mask for the fwd methods */ |
| 75 | #define IP_VS_CONN_F_MASQ 0x0000 /* masquerading/NAT */ | 76 | #define IP_VS_CONN_F_MASQ 0x0000 /* masquerading/NAT */ |
| @@ -88,9 +89,20 @@ | |||
| 88 | #define IP_VS_CONN_F_TEMPLATE 0x1000 /* template, not connection */ | 89 | #define IP_VS_CONN_F_TEMPLATE 0x1000 /* template, not connection */ |
| 89 | #define IP_VS_CONN_F_ONE_PACKET 0x2000 /* forward only one packet */ | 90 | #define IP_VS_CONN_F_ONE_PACKET 0x2000 /* forward only one packet */ |
| 90 | 91 | ||
| 92 | /* Flags that are not sent to backup server start from bit 16 */ | ||
| 93 | #define IP_VS_CONN_F_NFCT (1 << 16) /* use netfilter conntrack */ | ||
| 94 | |||
| 95 | /* Connection flags from destination that can be changed by user space */ | ||
| 96 | #define IP_VS_CONN_F_DEST_MASK (IP_VS_CONN_F_FWD_MASK | \ | ||
| 97 | IP_VS_CONN_F_ONE_PACKET | \ | ||
| 98 | IP_VS_CONN_F_NFCT | \ | ||
| 99 | 0) | ||
| 100 | |||
| 91 | #define IP_VS_SCHEDNAME_MAXLEN 16 | 101 | #define IP_VS_SCHEDNAME_MAXLEN 16 |
| 102 | #define IP_VS_PENAME_MAXLEN 16 | ||
| 92 | #define IP_VS_IFNAME_MAXLEN 16 | 103 | #define IP_VS_IFNAME_MAXLEN 16 |
| 93 | 104 | ||
| 105 | #define IP_VS_PEDATA_MAXLEN 255 | ||
| 94 | 106 | ||
| 95 | /* | 107 | /* |
| 96 | * The struct ip_vs_service_user and struct ip_vs_dest_user are | 108 | * The struct ip_vs_service_user and struct ip_vs_dest_user are |
| @@ -324,6 +336,9 @@ enum { | |||
| 324 | IPVS_SVC_ATTR_NETMASK, /* persistent netmask */ | 336 | IPVS_SVC_ATTR_NETMASK, /* persistent netmask */ |
| 325 | 337 | ||
| 326 | IPVS_SVC_ATTR_STATS, /* nested attribute for service stats */ | 338 | IPVS_SVC_ATTR_STATS, /* nested attribute for service stats */ |
| 339 | |||
| 340 | IPVS_SVC_ATTR_PE_NAME, /* name of ct retriever */ | ||
| 341 | |||
| 327 | __IPVS_SVC_ATTR_MAX, | 342 | __IPVS_SVC_ATTR_MAX, |
| 328 | }; | 343 | }; |
| 329 | 344 | ||
diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h index e62683ba88e6..8e429d0e0405 100644 --- a/include/linux/ipv6.h +++ b/include/linux/ipv6.h | |||
| @@ -341,7 +341,9 @@ struct ipv6_pinfo { | |||
| 341 | odstopts:1, | 341 | odstopts:1, |
| 342 | rxflow:1, | 342 | rxflow:1, |
| 343 | rxtclass:1, | 343 | rxtclass:1, |
| 344 | rxpmtu:1; | 344 | rxpmtu:1, |
| 345 | rxorigdstaddr:1; | ||
| 346 | /* 2 bits hole */ | ||
| 345 | } bits; | 347 | } bits; |
| 346 | __u16 all; | 348 | __u16 all; |
| 347 | } rxopt; | 349 | } rxopt; |
diff --git a/include/linux/netfilter/nf_conntrack_common.h b/include/linux/netfilter/nf_conntrack_common.h index 1afd18c855ec..50cdc2559a5a 100644 --- a/include/linux/netfilter/nf_conntrack_common.h +++ b/include/linux/netfilter/nf_conntrack_common.h | |||
| @@ -98,8 +98,14 @@ enum ip_conntrack_events { | |||
| 98 | 98 | ||
| 99 | enum ip_conntrack_expect_events { | 99 | enum ip_conntrack_expect_events { |
| 100 | IPEXP_NEW, /* new expectation */ | 100 | IPEXP_NEW, /* new expectation */ |
| 101 | IPEXP_DESTROY, /* destroyed expectation */ | ||
| 101 | }; | 102 | }; |
| 102 | 103 | ||
| 104 | /* expectation flags */ | ||
| 105 | #define NF_CT_EXPECT_PERMANENT 0x1 | ||
| 106 | #define NF_CT_EXPECT_INACTIVE 0x2 | ||
| 107 | #define NF_CT_EXPECT_USERSPACE 0x4 | ||
| 108 | |||
| 103 | #ifdef __KERNEL__ | 109 | #ifdef __KERNEL__ |
| 104 | struct ip_conntrack_stat { | 110 | struct ip_conntrack_stat { |
| 105 | unsigned int searched; | 111 | unsigned int searched; |
diff --git a/include/linux/netfilter/nf_conntrack_sip.h b/include/linux/netfilter/nf_conntrack_sip.h index ff8cfbcf3b81..0ce91d56a5f2 100644 --- a/include/linux/netfilter/nf_conntrack_sip.h +++ b/include/linux/netfilter/nf_conntrack_sip.h | |||
| @@ -89,6 +89,7 @@ enum sip_header_types { | |||
| 89 | SIP_HDR_VIA_TCP, | 89 | SIP_HDR_VIA_TCP, |
| 90 | SIP_HDR_EXPIRES, | 90 | SIP_HDR_EXPIRES, |
| 91 | SIP_HDR_CONTENT_LENGTH, | 91 | SIP_HDR_CONTENT_LENGTH, |
| 92 | SIP_HDR_CALL_ID, | ||
| 92 | }; | 93 | }; |
| 93 | 94 | ||
| 94 | enum sdp_header_types { | 95 | enum sdp_header_types { |
diff --git a/include/linux/netfilter/nfnetlink_conntrack.h b/include/linux/netfilter/nfnetlink_conntrack.h index 9ed534c991b9..455f0ce4f430 100644 --- a/include/linux/netfilter/nfnetlink_conntrack.h +++ b/include/linux/netfilter/nfnetlink_conntrack.h | |||
| @@ -161,6 +161,7 @@ enum ctattr_expect { | |||
| 161 | CTA_EXPECT_ID, | 161 | CTA_EXPECT_ID, |
| 162 | CTA_EXPECT_HELP_NAME, | 162 | CTA_EXPECT_HELP_NAME, |
| 163 | CTA_EXPECT_ZONE, | 163 | CTA_EXPECT_ZONE, |
| 164 | CTA_EXPECT_FLAGS, | ||
| 164 | __CTA_EXPECT_MAX | 165 | __CTA_EXPECT_MAX |
| 165 | }; | 166 | }; |
| 166 | #define CTA_EXPECT_MAX (__CTA_EXPECT_MAX - 1) | 167 | #define CTA_EXPECT_MAX (__CTA_EXPECT_MAX - 1) |
diff --git a/include/linux/netfilter/x_tables.h b/include/linux/netfilter/x_tables.h index 24e5d01d27d0..742bec051440 100644 --- a/include/linux/netfilter/x_tables.h +++ b/include/linux/netfilter/x_tables.h | |||
| @@ -66,6 +66,11 @@ struct xt_standard_target { | |||
| 66 | int verdict; | 66 | int verdict; |
| 67 | }; | 67 | }; |
| 68 | 68 | ||
| 69 | struct xt_error_target { | ||
| 70 | struct xt_entry_target target; | ||
| 71 | char errorname[XT_FUNCTION_MAXNAMELEN]; | ||
| 72 | }; | ||
| 73 | |||
| 69 | /* The argument to IPT_SO_GET_REVISION_*. Returns highest revision | 74 | /* The argument to IPT_SO_GET_REVISION_*. Returns highest revision |
| 70 | * kernel supports, if >= revision. */ | 75 | * kernel supports, if >= revision. */ |
| 71 | struct xt_get_revision { | 76 | struct xt_get_revision { |
diff --git a/include/linux/netfilter/xt_TPROXY.h b/include/linux/netfilter/xt_TPROXY.h index 152e8f97132b..3f3d69361289 100644 --- a/include/linux/netfilter/xt_TPROXY.h +++ b/include/linux/netfilter/xt_TPROXY.h | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | #ifndef _XT_TPROXY_H_target | 1 | #ifndef _XT_TPROXY_H |
| 2 | #define _XT_TPROXY_H_target | 2 | #define _XT_TPROXY_H |
| 3 | 3 | ||
| 4 | /* TPROXY target is capable of marking the packet to perform | 4 | /* TPROXY target is capable of marking the packet to perform |
| 5 | * redirection. We can get rid of that whenever we get support for | 5 | * redirection. We can get rid of that whenever we get support for |
| @@ -11,4 +11,11 @@ struct xt_tproxy_target_info { | |||
| 11 | __be16 lport; | 11 | __be16 lport; |
| 12 | }; | 12 | }; |
| 13 | 13 | ||
| 14 | #endif /* _XT_TPROXY_H_target */ | 14 | struct xt_tproxy_target_info_v1 { |
| 15 | u_int32_t mark_mask; | ||
| 16 | u_int32_t mark_value; | ||
| 17 | union nf_inet_addr laddr; | ||
| 18 | __be16 lport; | ||
| 19 | }; | ||
| 20 | |||
| 21 | #endif /* _XT_TPROXY_H */ | ||
diff --git a/include/linux/netfilter_arp/arp_tables.h b/include/linux/netfilter_arp/arp_tables.h index e9948c0560f6..adbf4bff87ed 100644 --- a/include/linux/netfilter_arp/arp_tables.h +++ b/include/linux/netfilter_arp/arp_tables.h | |||
| @@ -21,8 +21,21 @@ | |||
| 21 | 21 | ||
| 22 | #include <linux/netfilter/x_tables.h> | 22 | #include <linux/netfilter/x_tables.h> |
| 23 | 23 | ||
| 24 | #ifndef __KERNEL__ | ||
| 24 | #define ARPT_FUNCTION_MAXNAMELEN XT_FUNCTION_MAXNAMELEN | 25 | #define ARPT_FUNCTION_MAXNAMELEN XT_FUNCTION_MAXNAMELEN |
| 25 | #define ARPT_TABLE_MAXNAMELEN XT_TABLE_MAXNAMELEN | 26 | #define ARPT_TABLE_MAXNAMELEN XT_TABLE_MAXNAMELEN |
| 27 | #define arpt_entry_target xt_entry_target | ||
| 28 | #define arpt_standard_target xt_standard_target | ||
| 29 | #define arpt_error_target xt_error_target | ||
| 30 | #define ARPT_CONTINUE XT_CONTINUE | ||
| 31 | #define ARPT_RETURN XT_RETURN | ||
| 32 | #define arpt_counters_info xt_counters_info | ||
| 33 | #define arpt_counters xt_counters | ||
| 34 | #define ARPT_STANDARD_TARGET XT_STANDARD_TARGET | ||
| 35 | #define ARPT_ERROR_TARGET XT_ERROR_TARGET | ||
| 36 | #define ARPT_ENTRY_ITERATE(entries, size, fn, args...) \ | ||
| 37 | XT_ENTRY_ITERATE(struct arpt_entry, entries, size, fn, ## args) | ||
| 38 | #endif | ||
| 26 | 39 | ||
| 27 | #define ARPT_DEV_ADDR_LEN_MAX 16 | 40 | #define ARPT_DEV_ADDR_LEN_MAX 16 |
| 28 | 41 | ||
| @@ -63,9 +76,6 @@ struct arpt_arp { | |||
| 63 | u_int16_t invflags; | 76 | u_int16_t invflags; |
| 64 | }; | 77 | }; |
| 65 | 78 | ||
| 66 | #define arpt_entry_target xt_entry_target | ||
| 67 | #define arpt_standard_target xt_standard_target | ||
| 68 | |||
| 69 | /* Values for "flag" field in struct arpt_ip (general arp structure). | 79 | /* Values for "flag" field in struct arpt_ip (general arp structure). |
| 70 | * No flags defined yet. | 80 | * No flags defined yet. |
| 71 | */ | 81 | */ |
| @@ -125,16 +135,10 @@ struct arpt_entry | |||
| 125 | #define ARPT_SO_GET_REVISION_TARGET (ARPT_BASE_CTL + 3) | 135 | #define ARPT_SO_GET_REVISION_TARGET (ARPT_BASE_CTL + 3) |
| 126 | #define ARPT_SO_GET_MAX (ARPT_SO_GET_REVISION_TARGET) | 136 | #define ARPT_SO_GET_MAX (ARPT_SO_GET_REVISION_TARGET) |
| 127 | 137 | ||
| 128 | /* CONTINUE verdict for targets */ | ||
| 129 | #define ARPT_CONTINUE XT_CONTINUE | ||
| 130 | |||
| 131 | /* For standard target */ | ||
| 132 | #define ARPT_RETURN XT_RETURN | ||
| 133 | |||
| 134 | /* The argument to ARPT_SO_GET_INFO */ | 138 | /* The argument to ARPT_SO_GET_INFO */ |
| 135 | struct arpt_getinfo { | 139 | struct arpt_getinfo { |
| 136 | /* Which table: caller fills this in. */ | 140 | /* Which table: caller fills this in. */ |
| 137 | char name[ARPT_TABLE_MAXNAMELEN]; | 141 | char name[XT_TABLE_MAXNAMELEN]; |
| 138 | 142 | ||
| 139 | /* Kernel fills these in. */ | 143 | /* Kernel fills these in. */ |
| 140 | /* Which hook entry points are valid: bitmask */ | 144 | /* Which hook entry points are valid: bitmask */ |
| @@ -156,7 +160,7 @@ struct arpt_getinfo { | |||
| 156 | /* The argument to ARPT_SO_SET_REPLACE. */ | 160 | /* The argument to ARPT_SO_SET_REPLACE. */ |
| 157 | struct arpt_replace { | 161 | struct arpt_replace { |
| 158 | /* Which table. */ | 162 | /* Which table. */ |
| 159 | char name[ARPT_TABLE_MAXNAMELEN]; | 163 | char name[XT_TABLE_MAXNAMELEN]; |
| 160 | 164 | ||
| 161 | /* Which hook entry points are valid: bitmask. You can't | 165 | /* Which hook entry points are valid: bitmask. You can't |
| 162 | change this. */ | 166 | change this. */ |
| @@ -184,14 +188,10 @@ struct arpt_replace { | |||
| 184 | struct arpt_entry entries[0]; | 188 | struct arpt_entry entries[0]; |
| 185 | }; | 189 | }; |
| 186 | 190 | ||
| 187 | /* The argument to ARPT_SO_ADD_COUNTERS. */ | ||
| 188 | #define arpt_counters_info xt_counters_info | ||
| 189 | #define arpt_counters xt_counters | ||
| 190 | |||
| 191 | /* The argument to ARPT_SO_GET_ENTRIES. */ | 191 | /* The argument to ARPT_SO_GET_ENTRIES. */ |
| 192 | struct arpt_get_entries { | 192 | struct arpt_get_entries { |
| 193 | /* Which table: user fills this in. */ | 193 | /* Which table: user fills this in. */ |
| 194 | char name[ARPT_TABLE_MAXNAMELEN]; | 194 | char name[XT_TABLE_MAXNAMELEN]; |
| 195 | 195 | ||
| 196 | /* User fills this in: total entry size. */ | 196 | /* User fills this in: total entry size. */ |
| 197 | unsigned int size; | 197 | unsigned int size; |
| @@ -200,23 +200,12 @@ struct arpt_get_entries { | |||
| 200 | struct arpt_entry entrytable[0]; | 200 | struct arpt_entry entrytable[0]; |
| 201 | }; | 201 | }; |
| 202 | 202 | ||
| 203 | /* Standard return verdict, or do jump. */ | ||
| 204 | #define ARPT_STANDARD_TARGET XT_STANDARD_TARGET | ||
| 205 | /* Error verdict. */ | ||
| 206 | #define ARPT_ERROR_TARGET XT_ERROR_TARGET | ||
| 207 | |||
| 208 | /* Helper functions */ | 203 | /* Helper functions */ |
| 209 | static __inline__ struct arpt_entry_target *arpt_get_target(struct arpt_entry *e) | 204 | static __inline__ struct xt_entry_target *arpt_get_target(struct arpt_entry *e) |
| 210 | { | 205 | { |
| 211 | return (void *)e + e->target_offset; | 206 | return (void *)e + e->target_offset; |
| 212 | } | 207 | } |
| 213 | 208 | ||
| 214 | #ifndef __KERNEL__ | ||
| 215 | /* fn returns 0 to continue iteration */ | ||
| 216 | #define ARPT_ENTRY_ITERATE(entries, size, fn, args...) \ | ||
| 217 | XT_ENTRY_ITERATE(struct arpt_entry, entries, size, fn, ## args) | ||
| 218 | #endif | ||
| 219 | |||
| 220 | /* | 209 | /* |
| 221 | * Main firewall chains definitions and global var's definitions. | 210 | * Main firewall chains definitions and global var's definitions. |
| 222 | */ | 211 | */ |
| @@ -225,17 +214,12 @@ static __inline__ struct arpt_entry_target *arpt_get_target(struct arpt_entry *e | |||
| 225 | /* Standard entry. */ | 214 | /* Standard entry. */ |
| 226 | struct arpt_standard { | 215 | struct arpt_standard { |
| 227 | struct arpt_entry entry; | 216 | struct arpt_entry entry; |
| 228 | struct arpt_standard_target target; | 217 | struct xt_standard_target target; |
| 229 | }; | ||
| 230 | |||
| 231 | struct arpt_error_target { | ||
| 232 | struct arpt_entry_target target; | ||
| 233 | char errorname[ARPT_FUNCTION_MAXNAMELEN]; | ||
| 234 | }; | 218 | }; |
| 235 | 219 | ||
| 236 | struct arpt_error { | 220 | struct arpt_error { |
| 237 | struct arpt_entry entry; | 221 | struct arpt_entry entry; |
| 238 | struct arpt_error_target target; | 222 | struct xt_error_target target; |
| 239 | }; | 223 | }; |
| 240 | 224 | ||
| 241 | #define ARPT_ENTRY_INIT(__size) \ | 225 | #define ARPT_ENTRY_INIT(__size) \ |
| @@ -247,16 +231,16 @@ struct arpt_error { | |||
| 247 | #define ARPT_STANDARD_INIT(__verdict) \ | 231 | #define ARPT_STANDARD_INIT(__verdict) \ |
| 248 | { \ | 232 | { \ |
| 249 | .entry = ARPT_ENTRY_INIT(sizeof(struct arpt_standard)), \ | 233 | .entry = ARPT_ENTRY_INIT(sizeof(struct arpt_standard)), \ |
| 250 | .target = XT_TARGET_INIT(ARPT_STANDARD_TARGET, \ | 234 | .target = XT_TARGET_INIT(XT_STANDARD_TARGET, \ |
| 251 | sizeof(struct arpt_standard_target)), \ | 235 | sizeof(struct xt_standard_target)), \ |
| 252 | .target.verdict = -(__verdict) - 1, \ | 236 | .target.verdict = -(__verdict) - 1, \ |
| 253 | } | 237 | } |
| 254 | 238 | ||
| 255 | #define ARPT_ERROR_INIT \ | 239 | #define ARPT_ERROR_INIT \ |
| 256 | { \ | 240 | { \ |
| 257 | .entry = ARPT_ENTRY_INIT(sizeof(struct arpt_error)), \ | 241 | .entry = ARPT_ENTRY_INIT(sizeof(struct arpt_error)), \ |
| 258 | .target = XT_TARGET_INIT(ARPT_ERROR_TARGET, \ | 242 | .target = XT_TARGET_INIT(XT_ERROR_TARGET, \ |
| 259 | sizeof(struct arpt_error_target)), \ | 243 | sizeof(struct xt_error_target)), \ |
| 260 | .target.errorname = "ERROR", \ | 244 | .target.errorname = "ERROR", \ |
| 261 | } | 245 | } |
| 262 | 246 | ||
| @@ -271,8 +255,6 @@ extern unsigned int arpt_do_table(struct sk_buff *skb, | |||
| 271 | const struct net_device *out, | 255 | const struct net_device *out, |
| 272 | struct xt_table *table); | 256 | struct xt_table *table); |
| 273 | 257 | ||
| 274 | #define ARPT_ALIGN(s) XT_ALIGN(s) | ||
| 275 | |||
| 276 | #ifdef CONFIG_COMPAT | 258 | #ifdef CONFIG_COMPAT |
| 277 | #include <net/compat.h> | 259 | #include <net/compat.h> |
| 278 | 260 | ||
| @@ -285,14 +267,12 @@ struct compat_arpt_entry { | |||
| 285 | unsigned char elems[0]; | 267 | unsigned char elems[0]; |
| 286 | }; | 268 | }; |
| 287 | 269 | ||
| 288 | static inline struct arpt_entry_target * | 270 | static inline struct xt_entry_target * |
| 289 | compat_arpt_get_target(struct compat_arpt_entry *e) | 271 | compat_arpt_get_target(struct compat_arpt_entry *e) |
| 290 | { | 272 | { |
| 291 | return (void *)e + e->target_offset; | 273 | return (void *)e + e->target_offset; |
| 292 | } | 274 | } |
| 293 | 275 | ||
| 294 | #define COMPAT_ARPT_ALIGN(s) COMPAT_XT_ALIGN(s) | ||
| 295 | |||
| 296 | #endif /* CONFIG_COMPAT */ | 276 | #endif /* CONFIG_COMPAT */ |
| 297 | #endif /*__KERNEL__*/ | 277 | #endif /*__KERNEL__*/ |
| 298 | #endif /* _ARPTABLES_H */ | 278 | #endif /* _ARPTABLES_H */ |
diff --git a/include/linux/netfilter_bridge/Kbuild b/include/linux/netfilter_bridge/Kbuild index d4d78672873e..e48f1a3f5a4a 100644 --- a/include/linux/netfilter_bridge/Kbuild +++ b/include/linux/netfilter_bridge/Kbuild | |||
| @@ -3,11 +3,13 @@ header-y += ebt_among.h | |||
| 3 | header-y += ebt_arp.h | 3 | header-y += ebt_arp.h |
| 4 | header-y += ebt_arpreply.h | 4 | header-y += ebt_arpreply.h |
| 5 | header-y += ebt_ip.h | 5 | header-y += ebt_ip.h |
| 6 | header-y += ebt_ip6.h | ||
| 6 | header-y += ebt_limit.h | 7 | header-y += ebt_limit.h |
| 7 | header-y += ebt_log.h | 8 | header-y += ebt_log.h |
| 8 | header-y += ebt_mark_m.h | 9 | header-y += ebt_mark_m.h |
| 9 | header-y += ebt_mark_t.h | 10 | header-y += ebt_mark_t.h |
| 10 | header-y += ebt_nat.h | 11 | header-y += ebt_nat.h |
| 12 | header-y += ebt_nflog.h | ||
| 11 | header-y += ebt_pkttype.h | 13 | header-y += ebt_pkttype.h |
| 12 | header-y += ebt_redirect.h | 14 | header-y += ebt_redirect.h |
| 13 | header-y += ebt_stp.h | 15 | header-y += ebt_stp.h |
diff --git a/include/linux/netfilter_ipv4/ip_tables.h b/include/linux/netfilter_ipv4/ip_tables.h index 704a7b6e8169..64a5d95c58e8 100644 --- a/include/linux/netfilter_ipv4/ip_tables.h +++ b/include/linux/netfilter_ipv4/ip_tables.h | |||
| @@ -27,12 +27,49 @@ | |||
| 27 | 27 | ||
| 28 | #include <linux/netfilter/x_tables.h> | 28 | #include <linux/netfilter/x_tables.h> |
| 29 | 29 | ||
| 30 | #ifndef __KERNEL__ | ||
| 30 | #define IPT_FUNCTION_MAXNAMELEN XT_FUNCTION_MAXNAMELEN | 31 | #define IPT_FUNCTION_MAXNAMELEN XT_FUNCTION_MAXNAMELEN |
| 31 | #define IPT_TABLE_MAXNAMELEN XT_TABLE_MAXNAMELEN | 32 | #define IPT_TABLE_MAXNAMELEN XT_TABLE_MAXNAMELEN |
| 32 | #define ipt_match xt_match | 33 | #define ipt_match xt_match |
| 33 | #define ipt_target xt_target | 34 | #define ipt_target xt_target |
| 34 | #define ipt_table xt_table | 35 | #define ipt_table xt_table |
| 35 | #define ipt_get_revision xt_get_revision | 36 | #define ipt_get_revision xt_get_revision |
| 37 | #define ipt_entry_match xt_entry_match | ||
| 38 | #define ipt_entry_target xt_entry_target | ||
| 39 | #define ipt_standard_target xt_standard_target | ||
| 40 | #define ipt_error_target xt_error_target | ||
| 41 | #define ipt_counters xt_counters | ||
| 42 | #define IPT_CONTINUE XT_CONTINUE | ||
| 43 | #define IPT_RETURN XT_RETURN | ||
| 44 | |||
| 45 | /* This group is older than old (iptables < v1.4.0-rc1~89) */ | ||
| 46 | #include <linux/netfilter/xt_tcpudp.h> | ||
| 47 | #define ipt_udp xt_udp | ||
| 48 | #define ipt_tcp xt_tcp | ||
| 49 | #define IPT_TCP_INV_SRCPT XT_TCP_INV_SRCPT | ||
| 50 | #define IPT_TCP_INV_DSTPT XT_TCP_INV_DSTPT | ||
| 51 | #define IPT_TCP_INV_FLAGS XT_TCP_INV_FLAGS | ||
| 52 | #define IPT_TCP_INV_OPTION XT_TCP_INV_OPTION | ||
| 53 | #define IPT_TCP_INV_MASK XT_TCP_INV_MASK | ||
| 54 | #define IPT_UDP_INV_SRCPT XT_UDP_INV_SRCPT | ||
| 55 | #define IPT_UDP_INV_DSTPT XT_UDP_INV_DSTPT | ||
| 56 | #define IPT_UDP_INV_MASK XT_UDP_INV_MASK | ||
| 57 | |||
| 58 | /* The argument to IPT_SO_ADD_COUNTERS. */ | ||
| 59 | #define ipt_counters_info xt_counters_info | ||
| 60 | /* Standard return verdict, or do jump. */ | ||
| 61 | #define IPT_STANDARD_TARGET XT_STANDARD_TARGET | ||
| 62 | /* Error verdict. */ | ||
| 63 | #define IPT_ERROR_TARGET XT_ERROR_TARGET | ||
| 64 | |||
| 65 | /* fn returns 0 to continue iteration */ | ||
| 66 | #define IPT_MATCH_ITERATE(e, fn, args...) \ | ||
| 67 | XT_MATCH_ITERATE(struct ipt_entry, e, fn, ## args) | ||
| 68 | |||
| 69 | /* fn returns 0 to continue iteration */ | ||
| 70 | #define IPT_ENTRY_ITERATE(entries, size, fn, args...) \ | ||
| 71 | XT_ENTRY_ITERATE(struct ipt_entry, entries, size, fn, ## args) | ||
| 72 | #endif | ||
| 36 | 73 | ||
| 37 | /* Yes, Virginia, you have to zero the padding. */ | 74 | /* Yes, Virginia, you have to zero the padding. */ |
| 38 | struct ipt_ip { | 75 | struct ipt_ip { |
| @@ -52,12 +89,6 @@ struct ipt_ip { | |||
| 52 | u_int8_t invflags; | 89 | u_int8_t invflags; |
| 53 | }; | 90 | }; |
| 54 | 91 | ||
| 55 | #define ipt_entry_match xt_entry_match | ||
| 56 | #define ipt_entry_target xt_entry_target | ||
| 57 | #define ipt_standard_target xt_standard_target | ||
| 58 | |||
| 59 | #define ipt_counters xt_counters | ||
| 60 | |||
| 61 | /* Values for "flag" field in struct ipt_ip (general ip structure). */ | 92 | /* Values for "flag" field in struct ipt_ip (general ip structure). */ |
| 62 | #define IPT_F_FRAG 0x01 /* Set if rule is a fragment rule */ | 93 | #define IPT_F_FRAG 0x01 /* Set if rule is a fragment rule */ |
| 63 | #define IPT_F_GOTO 0x02 /* Set if jump is a goto */ | 94 | #define IPT_F_GOTO 0x02 /* Set if jump is a goto */ |
| @@ -116,23 +147,6 @@ struct ipt_entry { | |||
| 116 | #define IPT_SO_GET_REVISION_TARGET (IPT_BASE_CTL + 3) | 147 | #define IPT_SO_GET_REVISION_TARGET (IPT_BASE_CTL + 3) |
| 117 | #define IPT_SO_GET_MAX IPT_SO_GET_REVISION_TARGET | 148 | #define IPT_SO_GET_MAX IPT_SO_GET_REVISION_TARGET |
| 118 | 149 | ||
| 119 | #define IPT_CONTINUE XT_CONTINUE | ||
| 120 | #define IPT_RETURN XT_RETURN | ||
| 121 | |||
| 122 | #include <linux/netfilter/xt_tcpudp.h> | ||
| 123 | #define ipt_udp xt_udp | ||
| 124 | #define ipt_tcp xt_tcp | ||
| 125 | |||
| 126 | #define IPT_TCP_INV_SRCPT XT_TCP_INV_SRCPT | ||
| 127 | #define IPT_TCP_INV_DSTPT XT_TCP_INV_DSTPT | ||
| 128 | #define IPT_TCP_INV_FLAGS XT_TCP_INV_FLAGS | ||
| 129 | #define IPT_TCP_INV_OPTION XT_TCP_INV_OPTION | ||
| 130 | #define IPT_TCP_INV_MASK XT_TCP_INV_MASK | ||
| 131 | |||
| 132 | #define IPT_UDP_INV_SRCPT XT_UDP_INV_SRCPT | ||
| 133 | #define IPT_UDP_INV_DSTPT XT_UDP_INV_DSTPT | ||
| 134 | #define IPT_UDP_INV_MASK XT_UDP_INV_MASK | ||
| 135 | |||
| 136 | /* ICMP matching stuff */ | 150 | /* ICMP matching stuff */ |
| 137 | struct ipt_icmp { | 151 | struct ipt_icmp { |
| 138 | u_int8_t type; /* type to match */ | 152 | u_int8_t type; /* type to match */ |
| @@ -146,7 +160,7 @@ struct ipt_icmp { | |||
| 146 | /* The argument to IPT_SO_GET_INFO */ | 160 | /* The argument to IPT_SO_GET_INFO */ |
| 147 | struct ipt_getinfo { | 161 | struct ipt_getinfo { |
| 148 | /* Which table: caller fills this in. */ | 162 | /* Which table: caller fills this in. */ |
| 149 | char name[IPT_TABLE_MAXNAMELEN]; | 163 | char name[XT_TABLE_MAXNAMELEN]; |
| 150 | 164 | ||
| 151 | /* Kernel fills these in. */ | 165 | /* Kernel fills these in. */ |
| 152 | /* Which hook entry points are valid: bitmask */ | 166 | /* Which hook entry points are valid: bitmask */ |
| @@ -168,7 +182,7 @@ struct ipt_getinfo { | |||
| 168 | /* The argument to IPT_SO_SET_REPLACE. */ | 182 | /* The argument to IPT_SO_SET_REPLACE. */ |
| 169 | struct ipt_replace { | 183 | struct ipt_replace { |
| 170 | /* Which table. */ | 184 | /* Which table. */ |
| 171 | char name[IPT_TABLE_MAXNAMELEN]; | 185 | char name[XT_TABLE_MAXNAMELEN]; |
| 172 | 186 | ||
| 173 | /* Which hook entry points are valid: bitmask. You can't | 187 | /* Which hook entry points are valid: bitmask. You can't |
| 174 | change this. */ | 188 | change this. */ |
| @@ -196,13 +210,10 @@ struct ipt_replace { | |||
| 196 | struct ipt_entry entries[0]; | 210 | struct ipt_entry entries[0]; |
| 197 | }; | 211 | }; |
| 198 | 212 | ||
| 199 | /* The argument to IPT_SO_ADD_COUNTERS. */ | ||
| 200 | #define ipt_counters_info xt_counters_info | ||
| 201 | |||
| 202 | /* The argument to IPT_SO_GET_ENTRIES. */ | 213 | /* The argument to IPT_SO_GET_ENTRIES. */ |
| 203 | struct ipt_get_entries { | 214 | struct ipt_get_entries { |
| 204 | /* Which table: user fills this in. */ | 215 | /* Which table: user fills this in. */ |
| 205 | char name[IPT_TABLE_MAXNAMELEN]; | 216 | char name[XT_TABLE_MAXNAMELEN]; |
| 206 | 217 | ||
| 207 | /* User fills this in: total entry size. */ | 218 | /* User fills this in: total entry size. */ |
| 208 | unsigned int size; | 219 | unsigned int size; |
| @@ -211,28 +222,13 @@ struct ipt_get_entries { | |||
| 211 | struct ipt_entry entrytable[0]; | 222 | struct ipt_entry entrytable[0]; |
| 212 | }; | 223 | }; |
| 213 | 224 | ||
| 214 | /* Standard return verdict, or do jump. */ | ||
| 215 | #define IPT_STANDARD_TARGET XT_STANDARD_TARGET | ||
| 216 | /* Error verdict. */ | ||
| 217 | #define IPT_ERROR_TARGET XT_ERROR_TARGET | ||
| 218 | |||
| 219 | /* Helper functions */ | 225 | /* Helper functions */ |
| 220 | static __inline__ struct ipt_entry_target * | 226 | static __inline__ struct xt_entry_target * |
| 221 | ipt_get_target(struct ipt_entry *e) | 227 | ipt_get_target(struct ipt_entry *e) |
| 222 | { | 228 | { |
| 223 | return (void *)e + e->target_offset; | 229 | return (void *)e + e->target_offset; |
| 224 | } | 230 | } |
| 225 | 231 | ||
| 226 | #ifndef __KERNEL__ | ||
| 227 | /* fn returns 0 to continue iteration */ | ||
| 228 | #define IPT_MATCH_ITERATE(e, fn, args...) \ | ||
| 229 | XT_MATCH_ITERATE(struct ipt_entry, e, fn, ## args) | ||
| 230 | |||
| 231 | /* fn returns 0 to continue iteration */ | ||
| 232 | #define IPT_ENTRY_ITERATE(entries, size, fn, args...) \ | ||
| 233 | XT_ENTRY_ITERATE(struct ipt_entry, entries, size, fn, ## args) | ||
| 234 | #endif | ||
| 235 | |||
| 236 | /* | 232 | /* |
| 237 | * Main firewall chains definitions and global var's definitions. | 233 | * Main firewall chains definitions and global var's definitions. |
| 238 | */ | 234 | */ |
| @@ -249,17 +245,12 @@ extern void ipt_unregister_table(struct net *net, struct xt_table *table); | |||
| 249 | /* Standard entry. */ | 245 | /* Standard entry. */ |
| 250 | struct ipt_standard { | 246 | struct ipt_standard { |
| 251 | struct ipt_entry entry; | 247 | struct ipt_entry entry; |
| 252 | struct ipt_standard_target target; | 248 | struct xt_standard_target target; |
| 253 | }; | ||
| 254 | |||
| 255 | struct ipt_error_target { | ||
| 256 | struct ipt_entry_target target; | ||
| 257 | char errorname[IPT_FUNCTION_MAXNAMELEN]; | ||
| 258 | }; | 249 | }; |
| 259 | 250 | ||
| 260 | struct ipt_error { | 251 | struct ipt_error { |
| 261 | struct ipt_entry entry; | 252 | struct ipt_entry entry; |
| 262 | struct ipt_error_target target; | 253 | struct xt_error_target target; |
| 263 | }; | 254 | }; |
| 264 | 255 | ||
| 265 | #define IPT_ENTRY_INIT(__size) \ | 256 | #define IPT_ENTRY_INIT(__size) \ |
| @@ -271,7 +262,7 @@ struct ipt_error { | |||
| 271 | #define IPT_STANDARD_INIT(__verdict) \ | 262 | #define IPT_STANDARD_INIT(__verdict) \ |
| 272 | { \ | 263 | { \ |
| 273 | .entry = IPT_ENTRY_INIT(sizeof(struct ipt_standard)), \ | 264 | .entry = IPT_ENTRY_INIT(sizeof(struct ipt_standard)), \ |
| 274 | .target = XT_TARGET_INIT(IPT_STANDARD_TARGET, \ | 265 | .target = XT_TARGET_INIT(XT_STANDARD_TARGET, \ |
| 275 | sizeof(struct xt_standard_target)), \ | 266 | sizeof(struct xt_standard_target)), \ |
| 276 | .target.verdict = -(__verdict) - 1, \ | 267 | .target.verdict = -(__verdict) - 1, \ |
| 277 | } | 268 | } |
| @@ -279,8 +270,8 @@ struct ipt_error { | |||
| 279 | #define IPT_ERROR_INIT \ | 270 | #define IPT_ERROR_INIT \ |
| 280 | { \ | 271 | { \ |
| 281 | .entry = IPT_ENTRY_INIT(sizeof(struct ipt_error)), \ | 272 | .entry = IPT_ENTRY_INIT(sizeof(struct ipt_error)), \ |
| 282 | .target = XT_TARGET_INIT(IPT_ERROR_TARGET, \ | 273 | .target = XT_TARGET_INIT(XT_ERROR_TARGET, \ |
| 283 | sizeof(struct ipt_error_target)), \ | 274 | sizeof(struct xt_error_target)), \ |
| 284 | .target.errorname = "ERROR", \ | 275 | .target.errorname = "ERROR", \ |
| 285 | } | 276 | } |
| 286 | 277 | ||
| @@ -291,8 +282,6 @@ extern unsigned int ipt_do_table(struct sk_buff *skb, | |||
| 291 | const struct net_device *out, | 282 | const struct net_device *out, |
| 292 | struct xt_table *table); | 283 | struct xt_table *table); |
| 293 | 284 | ||
| 294 | #define IPT_ALIGN(s) XT_ALIGN(s) | ||
| 295 | |||
| 296 | #ifdef CONFIG_COMPAT | 285 | #ifdef CONFIG_COMPAT |
| 297 | #include <net/compat.h> | 286 | #include <net/compat.h> |
| 298 | 287 | ||
| @@ -307,14 +296,12 @@ struct compat_ipt_entry { | |||
| 307 | }; | 296 | }; |
| 308 | 297 | ||
| 309 | /* Helper functions */ | 298 | /* Helper functions */ |
| 310 | static inline struct ipt_entry_target * | 299 | static inline struct xt_entry_target * |
| 311 | compat_ipt_get_target(struct compat_ipt_entry *e) | 300 | compat_ipt_get_target(struct compat_ipt_entry *e) |
| 312 | { | 301 | { |
| 313 | return (void *)e + e->target_offset; | 302 | return (void *)e + e->target_offset; |
| 314 | } | 303 | } |
| 315 | 304 | ||
| 316 | #define COMPAT_IPT_ALIGN(s) COMPAT_XT_ALIGN(s) | ||
| 317 | |||
| 318 | #endif /* CONFIG_COMPAT */ | 305 | #endif /* CONFIG_COMPAT */ |
| 319 | #endif /*__KERNEL__*/ | 306 | #endif /*__KERNEL__*/ |
| 320 | #endif /* _IPTABLES_H */ | 307 | #endif /* _IPTABLES_H */ |
diff --git a/include/linux/netfilter_ipv6/ip6_tables.h b/include/linux/netfilter_ipv6/ip6_tables.h index 18442ff19c07..c9784f7a9c1f 100644 --- a/include/linux/netfilter_ipv6/ip6_tables.h +++ b/include/linux/netfilter_ipv6/ip6_tables.h | |||
| @@ -27,13 +27,42 @@ | |||
| 27 | 27 | ||
| 28 | #include <linux/netfilter/x_tables.h> | 28 | #include <linux/netfilter/x_tables.h> |
| 29 | 29 | ||
| 30 | #ifndef __KERNEL__ | ||
| 30 | #define IP6T_FUNCTION_MAXNAMELEN XT_FUNCTION_MAXNAMELEN | 31 | #define IP6T_FUNCTION_MAXNAMELEN XT_FUNCTION_MAXNAMELEN |
| 31 | #define IP6T_TABLE_MAXNAMELEN XT_TABLE_MAXNAMELEN | 32 | #define IP6T_TABLE_MAXNAMELEN XT_TABLE_MAXNAMELEN |
| 32 | |||
| 33 | #define ip6t_match xt_match | 33 | #define ip6t_match xt_match |
| 34 | #define ip6t_target xt_target | 34 | #define ip6t_target xt_target |
| 35 | #define ip6t_table xt_table | 35 | #define ip6t_table xt_table |
| 36 | #define ip6t_get_revision xt_get_revision | 36 | #define ip6t_get_revision xt_get_revision |
| 37 | #define ip6t_entry_match xt_entry_match | ||
| 38 | #define ip6t_entry_target xt_entry_target | ||
| 39 | #define ip6t_standard_target xt_standard_target | ||
| 40 | #define ip6t_error_target xt_error_target | ||
| 41 | #define ip6t_counters xt_counters | ||
| 42 | #define IP6T_CONTINUE XT_CONTINUE | ||
| 43 | #define IP6T_RETURN XT_RETURN | ||
| 44 | |||
| 45 | /* Pre-iptables-1.4.0 */ | ||
| 46 | #include <linux/netfilter/xt_tcpudp.h> | ||
| 47 | #define ip6t_tcp xt_tcp | ||
| 48 | #define ip6t_udp xt_udp | ||
| 49 | #define IP6T_TCP_INV_SRCPT XT_TCP_INV_SRCPT | ||
| 50 | #define IP6T_TCP_INV_DSTPT XT_TCP_INV_DSTPT | ||
| 51 | #define IP6T_TCP_INV_FLAGS XT_TCP_INV_FLAGS | ||
| 52 | #define IP6T_TCP_INV_OPTION XT_TCP_INV_OPTION | ||
| 53 | #define IP6T_TCP_INV_MASK XT_TCP_INV_MASK | ||
| 54 | #define IP6T_UDP_INV_SRCPT XT_UDP_INV_SRCPT | ||
| 55 | #define IP6T_UDP_INV_DSTPT XT_UDP_INV_DSTPT | ||
| 56 | #define IP6T_UDP_INV_MASK XT_UDP_INV_MASK | ||
| 57 | |||
| 58 | #define ip6t_counters_info xt_counters_info | ||
| 59 | #define IP6T_STANDARD_TARGET XT_STANDARD_TARGET | ||
| 60 | #define IP6T_ERROR_TARGET XT_ERROR_TARGET | ||
| 61 | #define IP6T_MATCH_ITERATE(e, fn, args...) \ | ||
| 62 | XT_MATCH_ITERATE(struct ip6t_entry, e, fn, ## args) | ||
| 63 | #define IP6T_ENTRY_ITERATE(entries, size, fn, args...) \ | ||
| 64 | XT_ENTRY_ITERATE(struct ip6t_entry, entries, size, fn, ## args) | ||
| 65 | #endif | ||
| 37 | 66 | ||
| 38 | /* Yes, Virginia, you have to zero the padding. */ | 67 | /* Yes, Virginia, you have to zero the padding. */ |
| 39 | struct ip6t_ip6 { | 68 | struct ip6t_ip6 { |
| @@ -62,12 +91,6 @@ struct ip6t_ip6 { | |||
| 62 | u_int8_t invflags; | 91 | u_int8_t invflags; |
| 63 | }; | 92 | }; |
| 64 | 93 | ||
| 65 | #define ip6t_entry_match xt_entry_match | ||
| 66 | #define ip6t_entry_target xt_entry_target | ||
| 67 | #define ip6t_standard_target xt_standard_target | ||
| 68 | |||
| 69 | #define ip6t_counters xt_counters | ||
| 70 | |||
| 71 | /* Values for "flag" field in struct ip6t_ip6 (general ip6 structure). */ | 94 | /* Values for "flag" field in struct ip6t_ip6 (general ip6 structure). */ |
| 72 | #define IP6T_F_PROTO 0x01 /* Set if rule cares about upper | 95 | #define IP6T_F_PROTO 0x01 /* Set if rule cares about upper |
| 73 | protocols */ | 96 | protocols */ |
| @@ -112,17 +135,12 @@ struct ip6t_entry { | |||
| 112 | /* Standard entry */ | 135 | /* Standard entry */ |
| 113 | struct ip6t_standard { | 136 | struct ip6t_standard { |
| 114 | struct ip6t_entry entry; | 137 | struct ip6t_entry entry; |
| 115 | struct ip6t_standard_target target; | 138 | struct xt_standard_target target; |
| 116 | }; | ||
| 117 | |||
| 118 | struct ip6t_error_target { | ||
| 119 | struct ip6t_entry_target target; | ||
| 120 | char errorname[IP6T_FUNCTION_MAXNAMELEN]; | ||
| 121 | }; | 139 | }; |
| 122 | 140 | ||
| 123 | struct ip6t_error { | 141 | struct ip6t_error { |
| 124 | struct ip6t_entry entry; | 142 | struct ip6t_entry entry; |
| 125 | struct ip6t_error_target target; | 143 | struct xt_error_target target; |
| 126 | }; | 144 | }; |
| 127 | 145 | ||
| 128 | #define IP6T_ENTRY_INIT(__size) \ | 146 | #define IP6T_ENTRY_INIT(__size) \ |
| @@ -134,16 +152,16 @@ struct ip6t_error { | |||
| 134 | #define IP6T_STANDARD_INIT(__verdict) \ | 152 | #define IP6T_STANDARD_INIT(__verdict) \ |
| 135 | { \ | 153 | { \ |
| 136 | .entry = IP6T_ENTRY_INIT(sizeof(struct ip6t_standard)), \ | 154 | .entry = IP6T_ENTRY_INIT(sizeof(struct ip6t_standard)), \ |
| 137 | .target = XT_TARGET_INIT(IP6T_STANDARD_TARGET, \ | 155 | .target = XT_TARGET_INIT(XT_STANDARD_TARGET, \ |
| 138 | sizeof(struct ip6t_standard_target)), \ | 156 | sizeof(struct xt_standard_target)), \ |
| 139 | .target.verdict = -(__verdict) - 1, \ | 157 | .target.verdict = -(__verdict) - 1, \ |
| 140 | } | 158 | } |
| 141 | 159 | ||
| 142 | #define IP6T_ERROR_INIT \ | 160 | #define IP6T_ERROR_INIT \ |
| 143 | { \ | 161 | { \ |
| 144 | .entry = IP6T_ENTRY_INIT(sizeof(struct ip6t_error)), \ | 162 | .entry = IP6T_ENTRY_INIT(sizeof(struct ip6t_error)), \ |
| 145 | .target = XT_TARGET_INIT(IP6T_ERROR_TARGET, \ | 163 | .target = XT_TARGET_INIT(XT_ERROR_TARGET, \ |
| 146 | sizeof(struct ip6t_error_target)), \ | 164 | sizeof(struct xt_error_target)), \ |
| 147 | .target.errorname = "ERROR", \ | 165 | .target.errorname = "ERROR", \ |
| 148 | } | 166 | } |
| 149 | 167 | ||
| @@ -166,30 +184,6 @@ struct ip6t_error { | |||
| 166 | #define IP6T_SO_GET_REVISION_TARGET (IP6T_BASE_CTL + 5) | 184 | #define IP6T_SO_GET_REVISION_TARGET (IP6T_BASE_CTL + 5) |
| 167 | #define IP6T_SO_GET_MAX IP6T_SO_GET_REVISION_TARGET | 185 | #define IP6T_SO_GET_MAX IP6T_SO_GET_REVISION_TARGET |
| 168 | 186 | ||
| 169 | /* CONTINUE verdict for targets */ | ||
| 170 | #define IP6T_CONTINUE XT_CONTINUE | ||
| 171 | |||
| 172 | /* For standard target */ | ||
| 173 | #define IP6T_RETURN XT_RETURN | ||
| 174 | |||
| 175 | /* TCP/UDP matching stuff */ | ||
| 176 | #include <linux/netfilter/xt_tcpudp.h> | ||
| 177 | |||
| 178 | #define ip6t_tcp xt_tcp | ||
| 179 | #define ip6t_udp xt_udp | ||
| 180 | |||
| 181 | /* Values for "inv" field in struct ipt_tcp. */ | ||
| 182 | #define IP6T_TCP_INV_SRCPT XT_TCP_INV_SRCPT | ||
| 183 | #define IP6T_TCP_INV_DSTPT XT_TCP_INV_DSTPT | ||
| 184 | #define IP6T_TCP_INV_FLAGS XT_TCP_INV_FLAGS | ||
| 185 | #define IP6T_TCP_INV_OPTION XT_TCP_INV_OPTION | ||
| 186 | #define IP6T_TCP_INV_MASK XT_TCP_INV_MASK | ||
| 187 | |||
| 188 | /* Values for "invflags" field in struct ipt_udp. */ | ||
| 189 | #define IP6T_UDP_INV_SRCPT XT_UDP_INV_SRCPT | ||
| 190 | #define IP6T_UDP_INV_DSTPT XT_UDP_INV_DSTPT | ||
| 191 | #define IP6T_UDP_INV_MASK XT_UDP_INV_MASK | ||
| 192 | |||
| 193 | /* ICMP matching stuff */ | 187 | /* ICMP matching stuff */ |
| 194 | struct ip6t_icmp { | 188 | struct ip6t_icmp { |
| 195 | u_int8_t type; /* type to match */ | 189 | u_int8_t type; /* type to match */ |
| @@ -203,7 +197,7 @@ struct ip6t_icmp { | |||
| 203 | /* The argument to IP6T_SO_GET_INFO */ | 197 | /* The argument to IP6T_SO_GET_INFO */ |
| 204 | struct ip6t_getinfo { | 198 | struct ip6t_getinfo { |
| 205 | /* Which table: caller fills this in. */ | 199 | /* Which table: caller fills this in. */ |
| 206 | char name[IP6T_TABLE_MAXNAMELEN]; | 200 | char name[XT_TABLE_MAXNAMELEN]; |
| 207 | 201 | ||
| 208 | /* Kernel fills these in. */ | 202 | /* Kernel fills these in. */ |
| 209 | /* Which hook entry points are valid: bitmask */ | 203 | /* Which hook entry points are valid: bitmask */ |
| @@ -225,7 +219,7 @@ struct ip6t_getinfo { | |||
| 225 | /* The argument to IP6T_SO_SET_REPLACE. */ | 219 | /* The argument to IP6T_SO_SET_REPLACE. */ |
| 226 | struct ip6t_replace { | 220 | struct ip6t_replace { |
| 227 | /* Which table. */ | 221 | /* Which table. */ |
| 228 | char name[IP6T_TABLE_MAXNAMELEN]; | 222 | char name[XT_TABLE_MAXNAMELEN]; |
| 229 | 223 | ||
| 230 | /* Which hook entry points are valid: bitmask. You can't | 224 | /* Which hook entry points are valid: bitmask. You can't |
| 231 | change this. */ | 225 | change this. */ |
| @@ -253,13 +247,10 @@ struct ip6t_replace { | |||
| 253 | struct ip6t_entry entries[0]; | 247 | struct ip6t_entry entries[0]; |
| 254 | }; | 248 | }; |
| 255 | 249 | ||
| 256 | /* The argument to IP6T_SO_ADD_COUNTERS. */ | ||
| 257 | #define ip6t_counters_info xt_counters_info | ||
| 258 | |||
| 259 | /* The argument to IP6T_SO_GET_ENTRIES. */ | 250 | /* The argument to IP6T_SO_GET_ENTRIES. */ |
| 260 | struct ip6t_get_entries { | 251 | struct ip6t_get_entries { |
| 261 | /* Which table: user fills this in. */ | 252 | /* Which table: user fills this in. */ |
| 262 | char name[IP6T_TABLE_MAXNAMELEN]; | 253 | char name[XT_TABLE_MAXNAMELEN]; |
| 263 | 254 | ||
| 264 | /* User fills this in: total entry size. */ | 255 | /* User fills this in: total entry size. */ |
| 265 | unsigned int size; | 256 | unsigned int size; |
| @@ -268,28 +259,13 @@ struct ip6t_get_entries { | |||
| 268 | struct ip6t_entry entrytable[0]; | 259 | struct ip6t_entry entrytable[0]; |
| 269 | }; | 260 | }; |
| 270 | 261 | ||
| 271 | /* Standard return verdict, or do jump. */ | ||
| 272 | #define IP6T_STANDARD_TARGET XT_STANDARD_TARGET | ||
| 273 | /* Error verdict. */ | ||
| 274 | #define IP6T_ERROR_TARGET XT_ERROR_TARGET | ||
| 275 | |||
| 276 | /* Helper functions */ | 262 | /* Helper functions */ |
| 277 | static __inline__ struct ip6t_entry_target * | 263 | static __inline__ struct xt_entry_target * |
| 278 | ip6t_get_target(struct ip6t_entry *e) | 264 | ip6t_get_target(struct ip6t_entry *e) |
| 279 | { | 265 | { |
| 280 | return (void *)e + e->target_offset; | 266 | return (void *)e + e->target_offset; |
| 281 | } | 267 | } |
| 282 | 268 | ||
| 283 | #ifndef __KERNEL__ | ||
| 284 | /* fn returns 0 to continue iteration */ | ||
| 285 | #define IP6T_MATCH_ITERATE(e, fn, args...) \ | ||
| 286 | XT_MATCH_ITERATE(struct ip6t_entry, e, fn, ## args) | ||
| 287 | |||
| 288 | /* fn returns 0 to continue iteration */ | ||
| 289 | #define IP6T_ENTRY_ITERATE(entries, size, fn, args...) \ | ||
| 290 | XT_ENTRY_ITERATE(struct ip6t_entry, entries, size, fn, ## args) | ||
| 291 | #endif | ||
| 292 | |||
| 293 | /* | 269 | /* |
| 294 | * Main firewall chains definitions and global var's definitions. | 270 | * Main firewall chains definitions and global var's definitions. |
| 295 | */ | 271 | */ |
| @@ -316,8 +292,6 @@ extern int ip6t_ext_hdr(u8 nexthdr); | |||
| 316 | extern int ipv6_find_hdr(const struct sk_buff *skb, unsigned int *offset, | 292 | extern int ipv6_find_hdr(const struct sk_buff *skb, unsigned int *offset, |
| 317 | int target, unsigned short *fragoff); | 293 | int target, unsigned short *fragoff); |
| 318 | 294 | ||
| 319 | #define IP6T_ALIGN(s) XT_ALIGN(s) | ||
| 320 | |||
| 321 | #ifdef CONFIG_COMPAT | 295 | #ifdef CONFIG_COMPAT |
| 322 | #include <net/compat.h> | 296 | #include <net/compat.h> |
| 323 | 297 | ||
| @@ -331,14 +305,12 @@ struct compat_ip6t_entry { | |||
| 331 | unsigned char elems[0]; | 305 | unsigned char elems[0]; |
| 332 | }; | 306 | }; |
| 333 | 307 | ||
| 334 | static inline struct ip6t_entry_target * | 308 | static inline struct xt_entry_target * |
| 335 | compat_ip6t_get_target(struct compat_ip6t_entry *e) | 309 | compat_ip6t_get_target(struct compat_ip6t_entry *e) |
| 336 | { | 310 | { |
| 337 | return (void *)e + e->target_offset; | 311 | return (void *)e + e->target_offset; |
| 338 | } | 312 | } |
| 339 | 313 | ||
| 340 | #define COMPAT_IP6T_ALIGN(s) COMPAT_XT_ALIGN(s) | ||
| 341 | |||
| 342 | #endif /* CONFIG_COMPAT */ | 314 | #endif /* CONFIG_COMPAT */ |
| 343 | #endif /*__KERNEL__*/ | 315 | #endif /*__KERNEL__*/ |
| 344 | #endif /* _IP6_TABLES_H */ | 316 | #endif /* _IP6_TABLES_H */ |
diff --git a/include/net/inet_hashtables.h b/include/net/inet_hashtables.h index 74358d1b3f43..e9c2ed8af864 100644 --- a/include/net/inet_hashtables.h +++ b/include/net/inet_hashtables.h | |||
| @@ -245,7 +245,7 @@ static inline int inet_sk_listen_hashfn(const struct sock *sk) | |||
| 245 | } | 245 | } |
| 246 | 246 | ||
| 247 | /* Caller must disable local BH processing. */ | 247 | /* Caller must disable local BH processing. */ |
| 248 | extern void __inet_inherit_port(struct sock *sk, struct sock *child); | 248 | extern int __inet_inherit_port(struct sock *sk, struct sock *child); |
| 249 | 249 | ||
| 250 | extern void inet_put_port(struct sock *sk); | 250 | extern void inet_put_port(struct sock *sk); |
| 251 | 251 | ||
diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h index f976885f686f..b7bbd6c28cfa 100644 --- a/include/net/ip_vs.h +++ b/include/net/ip_vs.h | |||
| @@ -25,7 +25,9 @@ | |||
| 25 | #include <linux/ip.h> | 25 | #include <linux/ip.h> |
| 26 | #include <linux/ipv6.h> /* for struct ipv6hdr */ | 26 | #include <linux/ipv6.h> /* for struct ipv6hdr */ |
| 27 | #include <net/ipv6.h> /* for ipv6_addr_copy */ | 27 | #include <net/ipv6.h> /* for ipv6_addr_copy */ |
| 28 | 28 | #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) | |
| 29 | #include <net/netfilter/nf_conntrack.h> | ||
| 30 | #endif | ||
| 29 | 31 | ||
| 30 | /* Connections' size value needed by ip_vs_ctl.c */ | 32 | /* Connections' size value needed by ip_vs_ctl.c */ |
| 31 | extern int ip_vs_conn_tab_size; | 33 | extern int ip_vs_conn_tab_size; |
| @@ -134,24 +136,24 @@ static inline const char *ip_vs_dbg_addr(int af, char *buf, size_t buf_len, | |||
| 134 | if (net_ratelimit()) \ | 136 | if (net_ratelimit()) \ |
| 135 | printk(KERN_DEBUG pr_fmt(msg), ##__VA_ARGS__); \ | 137 | printk(KERN_DEBUG pr_fmt(msg), ##__VA_ARGS__); \ |
| 136 | } while (0) | 138 | } while (0) |
| 137 | #define IP_VS_DBG_PKT(level, pp, skb, ofs, msg) \ | 139 | #define IP_VS_DBG_PKT(level, af, pp, skb, ofs, msg) \ |
| 138 | do { \ | 140 | do { \ |
| 139 | if (level <= ip_vs_get_debug_level()) \ | 141 | if (level <= ip_vs_get_debug_level()) \ |
| 140 | pp->debug_packet(pp, skb, ofs, msg); \ | 142 | pp->debug_packet(af, pp, skb, ofs, msg); \ |
| 141 | } while (0) | 143 | } while (0) |
| 142 | #define IP_VS_DBG_RL_PKT(level, pp, skb, ofs, msg) \ | 144 | #define IP_VS_DBG_RL_PKT(level, af, pp, skb, ofs, msg) \ |
| 143 | do { \ | 145 | do { \ |
| 144 | if (level <= ip_vs_get_debug_level() && \ | 146 | if (level <= ip_vs_get_debug_level() && \ |
| 145 | net_ratelimit()) \ | 147 | net_ratelimit()) \ |
| 146 | pp->debug_packet(pp, skb, ofs, msg); \ | 148 | pp->debug_packet(af, pp, skb, ofs, msg); \ |
| 147 | } while (0) | 149 | } while (0) |
| 148 | #else /* NO DEBUGGING at ALL */ | 150 | #else /* NO DEBUGGING at ALL */ |
| 149 | #define IP_VS_DBG_BUF(level, msg...) do {} while (0) | 151 | #define IP_VS_DBG_BUF(level, msg...) do {} while (0) |
| 150 | #define IP_VS_ERR_BUF(msg...) do {} while (0) | 152 | #define IP_VS_ERR_BUF(msg...) do {} while (0) |
| 151 | #define IP_VS_DBG(level, msg...) do {} while (0) | 153 | #define IP_VS_DBG(level, msg...) do {} while (0) |
| 152 | #define IP_VS_DBG_RL(msg...) do {} while (0) | 154 | #define IP_VS_DBG_RL(msg...) do {} while (0) |
| 153 | #define IP_VS_DBG_PKT(level, pp, skb, ofs, msg) do {} while (0) | 155 | #define IP_VS_DBG_PKT(level, af, pp, skb, ofs, msg) do {} while (0) |
| 154 | #define IP_VS_DBG_RL_PKT(level, pp, skb, ofs, msg) do {} while (0) | 156 | #define IP_VS_DBG_RL_PKT(level, af, pp, skb, ofs, msg) do {} while (0) |
| 155 | #endif | 157 | #endif |
| 156 | 158 | ||
| 157 | #define IP_VS_BUG() BUG() | 159 | #define IP_VS_BUG() BUG() |
| @@ -343,7 +345,7 @@ struct ip_vs_protocol { | |||
| 343 | 345 | ||
| 344 | int (*app_conn_bind)(struct ip_vs_conn *cp); | 346 | int (*app_conn_bind)(struct ip_vs_conn *cp); |
| 345 | 347 | ||
| 346 | void (*debug_packet)(struct ip_vs_protocol *pp, | 348 | void (*debug_packet)(int af, struct ip_vs_protocol *pp, |
| 347 | const struct sk_buff *skb, | 349 | const struct sk_buff *skb, |
| 348 | int offset, | 350 | int offset, |
| 349 | const char *msg); | 351 | const char *msg); |
| @@ -355,6 +357,19 @@ struct ip_vs_protocol { | |||
| 355 | 357 | ||
| 356 | extern struct ip_vs_protocol * ip_vs_proto_get(unsigned short proto); | 358 | extern struct ip_vs_protocol * ip_vs_proto_get(unsigned short proto); |
| 357 | 359 | ||
| 360 | struct ip_vs_conn_param { | ||
| 361 | const union nf_inet_addr *caddr; | ||
| 362 | const union nf_inet_addr *vaddr; | ||
| 363 | __be16 cport; | ||
| 364 | __be16 vport; | ||
| 365 | __u16 protocol; | ||
| 366 | u16 af; | ||
| 367 | |||
| 368 | const struct ip_vs_pe *pe; | ||
| 369 | char *pe_data; | ||
| 370 | __u8 pe_data_len; | ||
| 371 | }; | ||
| 372 | |||
| 358 | /* | 373 | /* |
| 359 | * IP_VS structure allocated for each dynamically scheduled connection | 374 | * IP_VS structure allocated for each dynamically scheduled connection |
| 360 | */ | 375 | */ |
| @@ -366,6 +381,7 @@ struct ip_vs_conn { | |||
| 366 | union nf_inet_addr caddr; /* client address */ | 381 | union nf_inet_addr caddr; /* client address */ |
| 367 | union nf_inet_addr vaddr; /* virtual address */ | 382 | union nf_inet_addr vaddr; /* virtual address */ |
| 368 | union nf_inet_addr daddr; /* destination address */ | 383 | union nf_inet_addr daddr; /* destination address */ |
| 384 | volatile __u32 flags; /* status flags */ | ||
| 369 | __be16 cport; | 385 | __be16 cport; |
| 370 | __be16 vport; | 386 | __be16 vport; |
| 371 | __be16 dport; | 387 | __be16 dport; |
| @@ -378,7 +394,6 @@ struct ip_vs_conn { | |||
| 378 | 394 | ||
| 379 | /* Flags and state transition */ | 395 | /* Flags and state transition */ |
| 380 | spinlock_t lock; /* lock for state transition */ | 396 | spinlock_t lock; /* lock for state transition */ |
| 381 | volatile __u16 flags; /* status flags */ | ||
| 382 | volatile __u16 state; /* state info */ | 397 | volatile __u16 state; /* state info */ |
| 383 | volatile __u16 old_state; /* old state, to be used for | 398 | volatile __u16 old_state; /* old state, to be used for |
| 384 | * state transition triggerd | 399 | * state transition triggerd |
| @@ -394,6 +409,7 @@ struct ip_vs_conn { | |||
| 394 | /* packet transmitter for different forwarding methods. If it | 409 | /* packet transmitter for different forwarding methods. If it |
| 395 | mangles the packet, it must return NF_DROP or better NF_STOLEN, | 410 | mangles the packet, it must return NF_DROP or better NF_STOLEN, |
| 396 | otherwise this must be changed to a sk_buff **. | 411 | otherwise this must be changed to a sk_buff **. |
| 412 | NF_ACCEPT can be returned when destination is local. | ||
| 397 | */ | 413 | */ |
| 398 | int (*packet_xmit)(struct sk_buff *skb, struct ip_vs_conn *cp, | 414 | int (*packet_xmit)(struct sk_buff *skb, struct ip_vs_conn *cp, |
| 399 | struct ip_vs_protocol *pp); | 415 | struct ip_vs_protocol *pp); |
| @@ -405,6 +421,9 @@ struct ip_vs_conn { | |||
| 405 | void *app_data; /* Application private data */ | 421 | void *app_data; /* Application private data */ |
| 406 | struct ip_vs_seq in_seq; /* incoming seq. struct */ | 422 | struct ip_vs_seq in_seq; /* incoming seq. struct */ |
| 407 | struct ip_vs_seq out_seq; /* outgoing seq. struct */ | 423 | struct ip_vs_seq out_seq; /* outgoing seq. struct */ |
| 424 | |||
| 425 | char *pe_data; | ||
| 426 | __u8 pe_data_len; | ||
| 408 | }; | 427 | }; |
| 409 | 428 | ||
| 410 | 429 | ||
| @@ -426,6 +445,7 @@ struct ip_vs_service_user_kern { | |||
| 426 | 445 | ||
| 427 | /* virtual service options */ | 446 | /* virtual service options */ |
| 428 | char *sched_name; | 447 | char *sched_name; |
| 448 | char *pe_name; | ||
| 429 | unsigned flags; /* virtual service flags */ | 449 | unsigned flags; /* virtual service flags */ |
| 430 | unsigned timeout; /* persistent timeout in sec */ | 450 | unsigned timeout; /* persistent timeout in sec */ |
| 431 | u32 netmask; /* persistent netmask */ | 451 | u32 netmask; /* persistent netmask */ |
| @@ -475,6 +495,9 @@ struct ip_vs_service { | |||
| 475 | struct ip_vs_scheduler *scheduler; /* bound scheduler object */ | 495 | struct ip_vs_scheduler *scheduler; /* bound scheduler object */ |
| 476 | rwlock_t sched_lock; /* lock sched_data */ | 496 | rwlock_t sched_lock; /* lock sched_data */ |
| 477 | void *sched_data; /* scheduler application data */ | 497 | void *sched_data; /* scheduler application data */ |
| 498 | |||
| 499 | /* alternate persistence engine */ | ||
| 500 | struct ip_vs_pe *pe; | ||
| 478 | }; | 501 | }; |
| 479 | 502 | ||
| 480 | 503 | ||
| @@ -507,6 +530,10 @@ struct ip_vs_dest { | |||
| 507 | spinlock_t dst_lock; /* lock of dst_cache */ | 530 | spinlock_t dst_lock; /* lock of dst_cache */ |
| 508 | struct dst_entry *dst_cache; /* destination cache entry */ | 531 | struct dst_entry *dst_cache; /* destination cache entry */ |
| 509 | u32 dst_rtos; /* RT_TOS(tos) for dst */ | 532 | u32 dst_rtos; /* RT_TOS(tos) for dst */ |
| 533 | u32 dst_cookie; | ||
| 534 | #ifdef CONFIG_IP_VS_IPV6 | ||
| 535 | struct in6_addr dst_saddr; | ||
| 536 | #endif | ||
| 510 | 537 | ||
| 511 | /* for virtual service */ | 538 | /* for virtual service */ |
| 512 | struct ip_vs_service *svc; /* service it belongs to */ | 539 | struct ip_vs_service *svc; /* service it belongs to */ |
| @@ -538,6 +565,21 @@ struct ip_vs_scheduler { | |||
| 538 | const struct sk_buff *skb); | 565 | const struct sk_buff *skb); |
| 539 | }; | 566 | }; |
| 540 | 567 | ||
| 568 | /* The persistence engine object */ | ||
| 569 | struct ip_vs_pe { | ||
| 570 | struct list_head n_list; /* d-linked list head */ | ||
| 571 | char *name; /* scheduler name */ | ||
| 572 | atomic_t refcnt; /* reference counter */ | ||
| 573 | struct module *module; /* THIS_MODULE/NULL */ | ||
| 574 | |||
| 575 | /* get the connection template, if any */ | ||
| 576 | int (*fill_param)(struct ip_vs_conn_param *p, struct sk_buff *skb); | ||
| 577 | bool (*ct_match)(const struct ip_vs_conn_param *p, | ||
| 578 | struct ip_vs_conn *ct); | ||
| 579 | u32 (*hashkey_raw)(const struct ip_vs_conn_param *p, u32 initval, | ||
| 580 | bool inverse); | ||
| 581 | int (*show_pe_data)(const struct ip_vs_conn *cp, char *buf); | ||
| 582 | }; | ||
| 541 | 583 | ||
| 542 | /* | 584 | /* |
| 543 | * The application module object (a.k.a. app incarnation) | 585 | * The application module object (a.k.a. app incarnation) |
| @@ -556,11 +598,19 @@ struct ip_vs_app { | |||
| 556 | __be16 port; /* port number in net order */ | 598 | __be16 port; /* port number in net order */ |
| 557 | atomic_t usecnt; /* usage counter */ | 599 | atomic_t usecnt; /* usage counter */ |
| 558 | 600 | ||
| 559 | /* output hook: return false if can't linearize. diff set for TCP. */ | 601 | /* |
| 602 | * output hook: Process packet in inout direction, diff set for TCP. | ||
| 603 | * Return: 0=Error, 1=Payload Not Mangled/Mangled but checksum is ok, | ||
| 604 | * 2=Mangled but checksum was not updated | ||
| 605 | */ | ||
| 560 | int (*pkt_out)(struct ip_vs_app *, struct ip_vs_conn *, | 606 | int (*pkt_out)(struct ip_vs_app *, struct ip_vs_conn *, |
| 561 | struct sk_buff *, int *diff); | 607 | struct sk_buff *, int *diff); |
| 562 | 608 | ||
| 563 | /* input hook: return false if can't linearize. diff set for TCP. */ | 609 | /* |
| 610 | * input hook: Process packet in outin direction, diff set for TCP. | ||
| 611 | * Return: 0=Error, 1=Payload Not Mangled/Mangled but checksum is ok, | ||
| 612 | * 2=Mangled but checksum was not updated | ||
| 613 | */ | ||
| 564 | int (*pkt_in)(struct ip_vs_app *, struct ip_vs_conn *, | 614 | int (*pkt_in)(struct ip_vs_app *, struct ip_vs_conn *, |
| 565 | struct sk_buff *, int *diff); | 615 | struct sk_buff *, int *diff); |
| 566 | 616 | ||
| @@ -624,13 +674,25 @@ enum { | |||
| 624 | IP_VS_DIR_LAST, | 674 | IP_VS_DIR_LAST, |
| 625 | }; | 675 | }; |
| 626 | 676 | ||
| 627 | extern struct ip_vs_conn *ip_vs_conn_in_get | 677 | static inline void ip_vs_conn_fill_param(int af, int protocol, |
| 628 | (int af, int protocol, const union nf_inet_addr *s_addr, __be16 s_port, | 678 | const union nf_inet_addr *caddr, |
| 629 | const union nf_inet_addr *d_addr, __be16 d_port); | 679 | __be16 cport, |
| 680 | const union nf_inet_addr *vaddr, | ||
| 681 | __be16 vport, | ||
| 682 | struct ip_vs_conn_param *p) | ||
| 683 | { | ||
| 684 | p->af = af; | ||
| 685 | p->protocol = protocol; | ||
| 686 | p->caddr = caddr; | ||
| 687 | p->cport = cport; | ||
| 688 | p->vaddr = vaddr; | ||
| 689 | p->vport = vport; | ||
| 690 | p->pe = NULL; | ||
| 691 | p->pe_data = NULL; | ||
| 692 | } | ||
| 630 | 693 | ||
| 631 | extern struct ip_vs_conn *ip_vs_ct_in_get | 694 | struct ip_vs_conn *ip_vs_conn_in_get(const struct ip_vs_conn_param *p); |
| 632 | (int af, int protocol, const union nf_inet_addr *s_addr, __be16 s_port, | 695 | struct ip_vs_conn *ip_vs_ct_in_get(const struct ip_vs_conn_param *p); |
| 633 | const union nf_inet_addr *d_addr, __be16 d_port); | ||
| 634 | 696 | ||
| 635 | struct ip_vs_conn * ip_vs_conn_in_get_proto(int af, const struct sk_buff *skb, | 697 | struct ip_vs_conn * ip_vs_conn_in_get_proto(int af, const struct sk_buff *skb, |
| 636 | struct ip_vs_protocol *pp, | 698 | struct ip_vs_protocol *pp, |
| @@ -638,9 +700,7 @@ struct ip_vs_conn * ip_vs_conn_in_get_proto(int af, const struct sk_buff *skb, | |||
| 638 | unsigned int proto_off, | 700 | unsigned int proto_off, |
| 639 | int inverse); | 701 | int inverse); |
| 640 | 702 | ||
| 641 | extern struct ip_vs_conn *ip_vs_conn_out_get | 703 | struct ip_vs_conn *ip_vs_conn_out_get(const struct ip_vs_conn_param *p); |
| 642 | (int af, int protocol, const union nf_inet_addr *s_addr, __be16 s_port, | ||
| 643 | const union nf_inet_addr *d_addr, __be16 d_port); | ||
| 644 | 704 | ||
| 645 | struct ip_vs_conn * ip_vs_conn_out_get_proto(int af, const struct sk_buff *skb, | 705 | struct ip_vs_conn * ip_vs_conn_out_get_proto(int af, const struct sk_buff *skb, |
| 646 | struct ip_vs_protocol *pp, | 706 | struct ip_vs_protocol *pp, |
| @@ -656,11 +716,10 @@ static inline void __ip_vs_conn_put(struct ip_vs_conn *cp) | |||
| 656 | extern void ip_vs_conn_put(struct ip_vs_conn *cp); | 716 | extern void ip_vs_conn_put(struct ip_vs_conn *cp); |
| 657 | extern void ip_vs_conn_fill_cport(struct ip_vs_conn *cp, __be16 cport); | 717 | extern void ip_vs_conn_fill_cport(struct ip_vs_conn *cp, __be16 cport); |
| 658 | 718 | ||
| 659 | extern struct ip_vs_conn * | 719 | struct ip_vs_conn *ip_vs_conn_new(const struct ip_vs_conn_param *p, |
| 660 | ip_vs_conn_new(int af, int proto, const union nf_inet_addr *caddr, __be16 cport, | 720 | const union nf_inet_addr *daddr, |
| 661 | const union nf_inet_addr *vaddr, __be16 vport, | 721 | __be16 dport, unsigned flags, |
| 662 | const union nf_inet_addr *daddr, __be16 dport, unsigned flags, | 722 | struct ip_vs_dest *dest); |
| 663 | struct ip_vs_dest *dest); | ||
| 664 | extern void ip_vs_conn_expire_now(struct ip_vs_conn *cp); | 723 | extern void ip_vs_conn_expire_now(struct ip_vs_conn *cp); |
| 665 | 724 | ||
| 666 | extern const char * ip_vs_state_name(__u16 proto, int state); | 725 | extern const char * ip_vs_state_name(__u16 proto, int state); |
| @@ -751,6 +810,12 @@ extern int ip_vs_app_pkt_in(struct ip_vs_conn *, struct sk_buff *skb); | |||
| 751 | extern int ip_vs_app_init(void); | 810 | extern int ip_vs_app_init(void); |
| 752 | extern void ip_vs_app_cleanup(void); | 811 | extern void ip_vs_app_cleanup(void); |
| 753 | 812 | ||
| 813 | void ip_vs_bind_pe(struct ip_vs_service *svc, struct ip_vs_pe *pe); | ||
| 814 | void ip_vs_unbind_pe(struct ip_vs_service *svc); | ||
| 815 | int register_ip_vs_pe(struct ip_vs_pe *pe); | ||
| 816 | int unregister_ip_vs_pe(struct ip_vs_pe *pe); | ||
| 817 | extern struct ip_vs_pe *ip_vs_pe_get(const char *name); | ||
| 818 | extern void ip_vs_pe_put(struct ip_vs_pe *pe); | ||
| 754 | 819 | ||
| 755 | /* | 820 | /* |
| 756 | * IPVS protocol functions (from ip_vs_proto.c) | 821 | * IPVS protocol functions (from ip_vs_proto.c) |
| @@ -763,7 +828,8 @@ extern int | |||
| 763 | ip_vs_set_state_timeout(int *table, int num, const char *const *names, | 828 | ip_vs_set_state_timeout(int *table, int num, const char *const *names, |
| 764 | const char *name, int to); | 829 | const char *name, int to); |
| 765 | extern void | 830 | extern void |
| 766 | ip_vs_tcpudp_debug_packet(struct ip_vs_protocol *pp, const struct sk_buff *skb, | 831 | ip_vs_tcpudp_debug_packet(int af, struct ip_vs_protocol *pp, |
| 832 | const struct sk_buff *skb, | ||
| 767 | int offset, const char *msg); | 833 | int offset, const char *msg); |
| 768 | 834 | ||
| 769 | extern struct ip_vs_protocol ip_vs_protocol_tcp; | 835 | extern struct ip_vs_protocol ip_vs_protocol_tcp; |
| @@ -785,7 +851,8 @@ extern int ip_vs_unbind_scheduler(struct ip_vs_service *svc); | |||
| 785 | extern struct ip_vs_scheduler *ip_vs_scheduler_get(const char *sched_name); | 851 | extern struct ip_vs_scheduler *ip_vs_scheduler_get(const char *sched_name); |
| 786 | extern void ip_vs_scheduler_put(struct ip_vs_scheduler *scheduler); | 852 | extern void ip_vs_scheduler_put(struct ip_vs_scheduler *scheduler); |
| 787 | extern struct ip_vs_conn * | 853 | extern struct ip_vs_conn * |
| 788 | ip_vs_schedule(struct ip_vs_service *svc, const struct sk_buff *skb); | 854 | ip_vs_schedule(struct ip_vs_service *svc, struct sk_buff *skb, |
| 855 | struct ip_vs_protocol *pp, int *ignored); | ||
| 789 | extern int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb, | 856 | extern int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb, |
| 790 | struct ip_vs_protocol *pp); | 857 | struct ip_vs_protocol *pp); |
| 791 | 858 | ||
| @@ -798,6 +865,8 @@ extern int sysctl_ip_vs_expire_nodest_conn; | |||
| 798 | extern int sysctl_ip_vs_expire_quiescent_template; | 865 | extern int sysctl_ip_vs_expire_quiescent_template; |
| 799 | extern int sysctl_ip_vs_sync_threshold[2]; | 866 | extern int sysctl_ip_vs_sync_threshold[2]; |
| 800 | extern int sysctl_ip_vs_nat_icmp_send; | 867 | extern int sysctl_ip_vs_nat_icmp_send; |
| 868 | extern int sysctl_ip_vs_conntrack; | ||
| 869 | extern int sysctl_ip_vs_snat_reroute; | ||
| 801 | extern struct ip_vs_stats ip_vs_stats; | 870 | extern struct ip_vs_stats ip_vs_stats; |
| 802 | extern const struct ctl_path net_vs_ctl_path[]; | 871 | extern const struct ctl_path net_vs_ctl_path[]; |
| 803 | 872 | ||
| @@ -955,8 +1024,65 @@ static inline __wsum ip_vs_check_diff2(__be16 old, __be16 new, __wsum oldsum) | |||
| 955 | return csum_partial(diff, sizeof(diff), oldsum); | 1024 | return csum_partial(diff, sizeof(diff), oldsum); |
| 956 | } | 1025 | } |
| 957 | 1026 | ||
| 1027 | /* | ||
| 1028 | * Forget current conntrack (unconfirmed) and attach notrack entry | ||
| 1029 | */ | ||
| 1030 | static inline void ip_vs_notrack(struct sk_buff *skb) | ||
| 1031 | { | ||
| 1032 | #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) | ||
| 1033 | enum ip_conntrack_info ctinfo; | ||
| 1034 | struct nf_conn *ct = ct = nf_ct_get(skb, &ctinfo); | ||
| 1035 | |||
| 1036 | if (!ct || !nf_ct_is_untracked(ct)) { | ||
| 1037 | nf_reset(skb); | ||
| 1038 | skb->nfct = &nf_ct_untracked_get()->ct_general; | ||
| 1039 | skb->nfctinfo = IP_CT_NEW; | ||
| 1040 | nf_conntrack_get(skb->nfct); | ||
| 1041 | } | ||
| 1042 | #endif | ||
| 1043 | } | ||
| 1044 | |||
| 1045 | #ifdef CONFIG_IP_VS_NFCT | ||
| 1046 | /* | ||
| 1047 | * Netfilter connection tracking | ||
| 1048 | * (from ip_vs_nfct.c) | ||
| 1049 | */ | ||
| 1050 | static inline int ip_vs_conntrack_enabled(void) | ||
| 1051 | { | ||
| 1052 | return sysctl_ip_vs_conntrack; | ||
| 1053 | } | ||
| 1054 | |||
| 958 | extern void ip_vs_update_conntrack(struct sk_buff *skb, struct ip_vs_conn *cp, | 1055 | extern void ip_vs_update_conntrack(struct sk_buff *skb, struct ip_vs_conn *cp, |
| 959 | int outin); | 1056 | int outin); |
| 1057 | extern int ip_vs_confirm_conntrack(struct sk_buff *skb, struct ip_vs_conn *cp); | ||
| 1058 | extern void ip_vs_nfct_expect_related(struct sk_buff *skb, struct nf_conn *ct, | ||
| 1059 | struct ip_vs_conn *cp, u_int8_t proto, | ||
| 1060 | const __be16 port, int from_rs); | ||
| 1061 | extern void ip_vs_conn_drop_conntrack(struct ip_vs_conn *cp); | ||
| 1062 | |||
| 1063 | #else | ||
| 1064 | |||
| 1065 | static inline int ip_vs_conntrack_enabled(void) | ||
| 1066 | { | ||
| 1067 | return 0; | ||
| 1068 | } | ||
| 1069 | |||
| 1070 | static inline void ip_vs_update_conntrack(struct sk_buff *skb, | ||
| 1071 | struct ip_vs_conn *cp, int outin) | ||
| 1072 | { | ||
| 1073 | } | ||
| 1074 | |||
| 1075 | static inline int ip_vs_confirm_conntrack(struct sk_buff *skb, | ||
| 1076 | struct ip_vs_conn *cp) | ||
| 1077 | { | ||
| 1078 | return NF_ACCEPT; | ||
| 1079 | } | ||
| 1080 | |||
| 1081 | static inline void ip_vs_conn_drop_conntrack(struct ip_vs_conn *cp) | ||
| 1082 | { | ||
| 1083 | } | ||
| 1084 | /* CONFIG_IP_VS_NFCT */ | ||
| 1085 | #endif | ||
| 960 | 1086 | ||
| 961 | #endif /* __KERNEL__ */ | 1087 | #endif /* __KERNEL__ */ |
| 962 | 1088 | ||
diff --git a/include/net/netfilter/ipv6/nf_defrag_ipv6.h b/include/net/netfilter/ipv6/nf_defrag_ipv6.h new file mode 100644 index 000000000000..94dd54d76b48 --- /dev/null +++ b/include/net/netfilter/ipv6/nf_defrag_ipv6.h | |||
| @@ -0,0 +1,6 @@ | |||
| 1 | #ifndef _NF_DEFRAG_IPV6_H | ||
| 2 | #define _NF_DEFRAG_IPV6_H | ||
| 3 | |||
| 4 | extern void nf_defrag_ipv6_enable(void); | ||
| 5 | |||
| 6 | #endif /* _NF_DEFRAG_IPV6_H */ | ||
diff --git a/include/net/netfilter/nf_conntrack_expect.h b/include/net/netfilter/nf_conntrack_expect.h index 11e815084fcf..0f8a8c587532 100644 --- a/include/net/netfilter/nf_conntrack_expect.h +++ b/include/net/netfilter/nf_conntrack_expect.h | |||
| @@ -67,9 +67,6 @@ struct nf_conntrack_expect_policy { | |||
| 67 | 67 | ||
| 68 | #define NF_CT_EXPECT_CLASS_DEFAULT 0 | 68 | #define NF_CT_EXPECT_CLASS_DEFAULT 0 |
| 69 | 69 | ||
| 70 | #define NF_CT_EXPECT_PERMANENT 0x1 | ||
| 71 | #define NF_CT_EXPECT_INACTIVE 0x2 | ||
| 72 | |||
| 73 | int nf_conntrack_expect_init(struct net *net); | 70 | int nf_conntrack_expect_init(struct net *net); |
| 74 | void nf_conntrack_expect_fini(struct net *net); | 71 | void nf_conntrack_expect_fini(struct net *net); |
| 75 | 72 | ||
| @@ -85,9 +82,16 @@ struct nf_conntrack_expect * | |||
| 85 | nf_ct_find_expectation(struct net *net, u16 zone, | 82 | nf_ct_find_expectation(struct net *net, u16 zone, |
| 86 | const struct nf_conntrack_tuple *tuple); | 83 | const struct nf_conntrack_tuple *tuple); |
| 87 | 84 | ||
| 88 | void nf_ct_unlink_expect(struct nf_conntrack_expect *exp); | 85 | void nf_ct_unlink_expect_report(struct nf_conntrack_expect *exp, |
| 86 | u32 pid, int report); | ||
| 87 | static inline void nf_ct_unlink_expect(struct nf_conntrack_expect *exp) | ||
| 88 | { | ||
| 89 | nf_ct_unlink_expect_report(exp, 0, 0); | ||
| 90 | } | ||
| 91 | |||
| 89 | void nf_ct_remove_expectations(struct nf_conn *ct); | 92 | void nf_ct_remove_expectations(struct nf_conn *ct); |
| 90 | void nf_ct_unexpect_related(struct nf_conntrack_expect *exp); | 93 | void nf_ct_unexpect_related(struct nf_conntrack_expect *exp); |
| 94 | void nf_ct_remove_userspace_expectations(void); | ||
| 91 | 95 | ||
| 92 | /* Allocate space for an expectation: this is mandatory before calling | 96 | /* Allocate space for an expectation: this is mandatory before calling |
| 93 | nf_ct_expect_related. You will have to call put afterwards. */ | 97 | nf_ct_expect_related. You will have to call put afterwards. */ |
diff --git a/include/net/netfilter/nf_nat_protocol.h b/include/net/netfilter/nf_nat_protocol.h index df17bac46bf5..93cc90d28e66 100644 --- a/include/net/netfilter/nf_nat_protocol.h +++ b/include/net/netfilter/nf_nat_protocol.h | |||
| @@ -45,9 +45,6 @@ struct nf_nat_protocol { | |||
| 45 | extern int nf_nat_protocol_register(const struct nf_nat_protocol *proto); | 45 | extern int nf_nat_protocol_register(const struct nf_nat_protocol *proto); |
| 46 | extern void nf_nat_protocol_unregister(const struct nf_nat_protocol *proto); | 46 | extern void nf_nat_protocol_unregister(const struct nf_nat_protocol *proto); |
| 47 | 47 | ||
| 48 | extern const struct nf_nat_protocol *nf_nat_proto_find_get(u_int8_t protocol); | ||
| 49 | extern void nf_nat_proto_put(const struct nf_nat_protocol *proto); | ||
| 50 | |||
| 51 | /* Built-in protocols. */ | 48 | /* Built-in protocols. */ |
| 52 | extern const struct nf_nat_protocol nf_nat_protocol_tcp; | 49 | extern const struct nf_nat_protocol nf_nat_protocol_tcp; |
| 53 | extern const struct nf_nat_protocol nf_nat_protocol_udp; | 50 | extern const struct nf_nat_protocol nf_nat_protocol_udp; |
diff --git a/include/net/netfilter/nf_tproxy_core.h b/include/net/netfilter/nf_tproxy_core.h index 208b46f4d6d2..cd85b3bc8327 100644 --- a/include/net/netfilter/nf_tproxy_core.h +++ b/include/net/netfilter/nf_tproxy_core.h | |||
| @@ -5,15 +5,201 @@ | |||
| 5 | #include <linux/in.h> | 5 | #include <linux/in.h> |
| 6 | #include <linux/skbuff.h> | 6 | #include <linux/skbuff.h> |
| 7 | #include <net/sock.h> | 7 | #include <net/sock.h> |
| 8 | #include <net/inet_sock.h> | 8 | #include <net/inet_hashtables.h> |
| 9 | #include <net/inet6_hashtables.h> | ||
| 9 | #include <net/tcp.h> | 10 | #include <net/tcp.h> |
| 10 | 11 | ||
| 12 | #define NFT_LOOKUP_ANY 0 | ||
| 13 | #define NFT_LOOKUP_LISTENER 1 | ||
| 14 | #define NFT_LOOKUP_ESTABLISHED 2 | ||
| 15 | |||
| 11 | /* look up and get a reference to a matching socket */ | 16 | /* look up and get a reference to a matching socket */ |
| 12 | extern struct sock * | 17 | |
| 18 | |||
| 19 | /* This function is used by the 'TPROXY' target and the 'socket' | ||
| 20 | * match. The following lookups are supported: | ||
| 21 | * | ||
| 22 | * Explicit TProxy target rule | ||
| 23 | * =========================== | ||
| 24 | * | ||
| 25 | * This is used when the user wants to intercept a connection matching | ||
| 26 | * an explicit iptables rule. In this case the sockets are assumed | ||
| 27 | * matching in preference order: | ||
| 28 | * | ||
| 29 | * - match: if there's a fully established connection matching the | ||
| 30 | * _packet_ tuple, it is returned, assuming the redirection | ||
| 31 | * already took place and we process a packet belonging to an | ||
| 32 | * established connection | ||
| 33 | * | ||
| 34 | * - match: if there's a listening socket matching the redirection | ||
| 35 | * (e.g. on-port & on-ip of the connection), it is returned, | ||
| 36 | * regardless if it was bound to 0.0.0.0 or an explicit | ||
| 37 | * address. The reasoning is that if there's an explicit rule, it | ||
| 38 | * does not really matter if the listener is bound to an interface | ||
| 39 | * or to 0. The user already stated that he wants redirection | ||
| 40 | * (since he added the rule). | ||
| 41 | * | ||
| 42 | * "socket" match based redirection (no specific rule) | ||
| 43 | * =================================================== | ||
| 44 | * | ||
| 45 | * There are connections with dynamic endpoints (e.g. FTP data | ||
| 46 | * connection) that the user is unable to add explicit rules | ||
| 47 | * for. These are taken care of by a generic "socket" rule. It is | ||
| 48 | * assumed that the proxy application is trusted to open such | ||
| 49 | * connections without explicit iptables rule (except of course the | ||
| 50 | * generic 'socket' rule). In this case the following sockets are | ||
| 51 | * matched in preference order: | ||
| 52 | * | ||
| 53 | * - match: if there's a fully established connection matching the | ||
| 54 | * _packet_ tuple | ||
| 55 | * | ||
| 56 | * - match: if there's a non-zero bound listener (possibly with a | ||
| 57 | * non-local address) We don't accept zero-bound listeners, since | ||
| 58 | * then local services could intercept traffic going through the | ||
| 59 | * box. | ||
| 60 | * | ||
| 61 | * Please note that there's an overlap between what a TPROXY target | ||
| 62 | * and a socket match will match. Normally if you have both rules the | ||
| 63 | * "socket" match will be the first one, effectively all packets | ||
| 64 | * belonging to established connections going through that one. | ||
| 65 | */ | ||
| 66 | static inline struct sock * | ||
| 13 | nf_tproxy_get_sock_v4(struct net *net, const u8 protocol, | 67 | nf_tproxy_get_sock_v4(struct net *net, const u8 protocol, |
| 14 | const __be32 saddr, const __be32 daddr, | 68 | const __be32 saddr, const __be32 daddr, |
| 15 | const __be16 sport, const __be16 dport, | 69 | const __be16 sport, const __be16 dport, |
| 16 | const struct net_device *in, bool listening); | 70 | const struct net_device *in, int lookup_type) |
| 71 | { | ||
| 72 | struct sock *sk; | ||
| 73 | |||
| 74 | /* look up socket */ | ||
| 75 | switch (protocol) { | ||
| 76 | case IPPROTO_TCP: | ||
| 77 | switch (lookup_type) { | ||
| 78 | case NFT_LOOKUP_ANY: | ||
| 79 | sk = __inet_lookup(net, &tcp_hashinfo, | ||
| 80 | saddr, sport, daddr, dport, | ||
| 81 | in->ifindex); | ||
| 82 | break; | ||
| 83 | case NFT_LOOKUP_LISTENER: | ||
| 84 | sk = inet_lookup_listener(net, &tcp_hashinfo, | ||
| 85 | daddr, dport, | ||
| 86 | in->ifindex); | ||
| 87 | |||
| 88 | /* NOTE: we return listeners even if bound to | ||
| 89 | * 0.0.0.0, those are filtered out in | ||
| 90 | * xt_socket, since xt_TPROXY needs 0 bound | ||
| 91 | * listeners too */ | ||
| 92 | |||
| 93 | break; | ||
| 94 | case NFT_LOOKUP_ESTABLISHED: | ||
| 95 | sk = inet_lookup_established(net, &tcp_hashinfo, | ||
| 96 | saddr, sport, daddr, dport, | ||
| 97 | in->ifindex); | ||
| 98 | break; | ||
| 99 | default: | ||
| 100 | WARN_ON(1); | ||
| 101 | sk = NULL; | ||
| 102 | break; | ||
| 103 | } | ||
| 104 | break; | ||
| 105 | case IPPROTO_UDP: | ||
| 106 | sk = udp4_lib_lookup(net, saddr, sport, daddr, dport, | ||
| 107 | in->ifindex); | ||
| 108 | if (sk && lookup_type != NFT_LOOKUP_ANY) { | ||
| 109 | int connected = (sk->sk_state == TCP_ESTABLISHED); | ||
| 110 | int wildcard = (inet_sk(sk)->inet_rcv_saddr == 0); | ||
| 111 | |||
| 112 | /* NOTE: we return listeners even if bound to | ||
| 113 | * 0.0.0.0, those are filtered out in | ||
| 114 | * xt_socket, since xt_TPROXY needs 0 bound | ||
| 115 | * listeners too */ | ||
| 116 | if ((lookup_type == NFT_LOOKUP_ESTABLISHED && (!connected || wildcard)) || | ||
| 117 | (lookup_type == NFT_LOOKUP_LISTENER && connected)) { | ||
| 118 | sock_put(sk); | ||
| 119 | sk = NULL; | ||
| 120 | } | ||
| 121 | } | ||
| 122 | break; | ||
| 123 | default: | ||
| 124 | WARN_ON(1); | ||
| 125 | sk = NULL; | ||
| 126 | } | ||
| 127 | |||
| 128 | pr_debug("tproxy socket lookup: proto %u %08x:%u -> %08x:%u, lookup type: %d, sock %p\n", | ||
| 129 | protocol, ntohl(saddr), ntohs(sport), ntohl(daddr), ntohs(dport), lookup_type, sk); | ||
| 130 | |||
| 131 | return sk; | ||
| 132 | } | ||
| 133 | |||
| 134 | #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE) | ||
| 135 | static inline struct sock * | ||
| 136 | nf_tproxy_get_sock_v6(struct net *net, const u8 protocol, | ||
| 137 | const struct in6_addr *saddr, const struct in6_addr *daddr, | ||
| 138 | const __be16 sport, const __be16 dport, | ||
| 139 | const struct net_device *in, int lookup_type) | ||
| 140 | { | ||
| 141 | struct sock *sk; | ||
| 142 | |||
| 143 | /* look up socket */ | ||
| 144 | switch (protocol) { | ||
| 145 | case IPPROTO_TCP: | ||
| 146 | switch (lookup_type) { | ||
| 147 | case NFT_LOOKUP_ANY: | ||
| 148 | sk = inet6_lookup(net, &tcp_hashinfo, | ||
| 149 | saddr, sport, daddr, dport, | ||
| 150 | in->ifindex); | ||
| 151 | break; | ||
| 152 | case NFT_LOOKUP_LISTENER: | ||
| 153 | sk = inet6_lookup_listener(net, &tcp_hashinfo, | ||
| 154 | daddr, ntohs(dport), | ||
| 155 | in->ifindex); | ||
| 156 | |||
| 157 | /* NOTE: we return listeners even if bound to | ||
| 158 | * 0.0.0.0, those are filtered out in | ||
| 159 | * xt_socket, since xt_TPROXY needs 0 bound | ||
| 160 | * listeners too */ | ||
| 161 | |||
| 162 | break; | ||
| 163 | case NFT_LOOKUP_ESTABLISHED: | ||
| 164 | sk = __inet6_lookup_established(net, &tcp_hashinfo, | ||
| 165 | saddr, sport, daddr, ntohs(dport), | ||
| 166 | in->ifindex); | ||
| 167 | break; | ||
| 168 | default: | ||
| 169 | WARN_ON(1); | ||
| 170 | sk = NULL; | ||
| 171 | break; | ||
| 172 | } | ||
| 173 | break; | ||
| 174 | case IPPROTO_UDP: | ||
| 175 | sk = udp6_lib_lookup(net, saddr, sport, daddr, dport, | ||
| 176 | in->ifindex); | ||
| 177 | if (sk && lookup_type != NFT_LOOKUP_ANY) { | ||
| 178 | int connected = (sk->sk_state == TCP_ESTABLISHED); | ||
| 179 | int wildcard = ipv6_addr_any(&inet6_sk(sk)->rcv_saddr); | ||
| 180 | |||
| 181 | /* NOTE: we return listeners even if bound to | ||
| 182 | * 0.0.0.0, those are filtered out in | ||
| 183 | * xt_socket, since xt_TPROXY needs 0 bound | ||
| 184 | * listeners too */ | ||
| 185 | if ((lookup_type == NFT_LOOKUP_ESTABLISHED && (!connected || wildcard)) || | ||
| 186 | (lookup_type == NFT_LOOKUP_LISTENER && connected)) { | ||
| 187 | sock_put(sk); | ||
| 188 | sk = NULL; | ||
| 189 | } | ||
| 190 | } | ||
| 191 | break; | ||
| 192 | default: | ||
| 193 | WARN_ON(1); | ||
| 194 | sk = NULL; | ||
| 195 | } | ||
| 196 | |||
| 197 | pr_debug("tproxy socket lookup: proto %u %pI6:%u -> %pI6:%u, lookup type: %d, sock %p\n", | ||
| 198 | protocol, saddr, ntohs(sport), daddr, ntohs(dport), lookup_type, sk); | ||
| 199 | |||
| 200 | return sk; | ||
| 201 | } | ||
| 202 | #endif | ||
| 17 | 203 | ||
| 18 | static inline void | 204 | static inline void |
| 19 | nf_tproxy_put_sock(struct sock *sk) | 205 | nf_tproxy_put_sock(struct sock *sk) |
diff --git a/include/net/netfilter/xt_log.h b/include/net/netfilter/xt_log.h new file mode 100644 index 000000000000..0dfb34a5b53c --- /dev/null +++ b/include/net/netfilter/xt_log.h | |||
| @@ -0,0 +1,54 @@ | |||
| 1 | #define S_SIZE (1024 - (sizeof(unsigned int) + 1)) | ||
| 2 | |||
| 3 | struct sbuff { | ||
| 4 | unsigned int count; | ||
| 5 | char buf[S_SIZE + 1]; | ||
| 6 | }; | ||
| 7 | static struct sbuff emergency, *emergency_ptr = &emergency; | ||
| 8 | |||
| 9 | static int sb_add(struct sbuff *m, const char *f, ...) | ||
| 10 | { | ||
| 11 | va_list args; | ||
| 12 | int len; | ||
| 13 | |||
| 14 | if (likely(m->count < S_SIZE)) { | ||
| 15 | va_start(args, f); | ||
| 16 | len = vsnprintf(m->buf + m->count, S_SIZE - m->count, f, args); | ||
| 17 | va_end(args); | ||
| 18 | if (likely(m->count + len < S_SIZE)) { | ||
| 19 | m->count += len; | ||
| 20 | return 0; | ||
| 21 | } | ||
| 22 | } | ||
| 23 | m->count = S_SIZE; | ||
| 24 | printk_once(KERN_ERR KBUILD_MODNAME " please increase S_SIZE\n"); | ||
| 25 | return -1; | ||
| 26 | } | ||
| 27 | |||
| 28 | static struct sbuff *sb_open(void) | ||
| 29 | { | ||
| 30 | struct sbuff *m = kmalloc(sizeof(*m), GFP_ATOMIC); | ||
| 31 | |||
| 32 | if (unlikely(!m)) { | ||
| 33 | local_bh_disable(); | ||
| 34 | do { | ||
| 35 | m = xchg(&emergency_ptr, NULL); | ||
| 36 | } while (!m); | ||
| 37 | } | ||
| 38 | m->count = 0; | ||
| 39 | return m; | ||
| 40 | } | ||
| 41 | |||
| 42 | static void sb_close(struct sbuff *m) | ||
| 43 | { | ||
| 44 | m->buf[m->count] = 0; | ||
| 45 | printk("%s\n", m->buf); | ||
| 46 | |||
| 47 | if (likely(m != &emergency)) | ||
| 48 | kfree(m); | ||
| 49 | else { | ||
| 50 | xchg(&emergency_ptr, m); | ||
| 51 | local_bh_enable(); | ||
| 52 | } | ||
| 53 | } | ||
| 54 | |||
diff --git a/include/net/udp.h b/include/net/udp.h index a184d3496b13..200b82848c9a 100644 --- a/include/net/udp.h +++ b/include/net/udp.h | |||
| @@ -183,6 +183,9 @@ extern int udp_lib_setsockopt(struct sock *sk, int level, int optname, | |||
| 183 | extern struct sock *udp4_lib_lookup(struct net *net, __be32 saddr, __be16 sport, | 183 | extern struct sock *udp4_lib_lookup(struct net *net, __be32 saddr, __be16 sport, |
| 184 | __be32 daddr, __be16 dport, | 184 | __be32 daddr, __be16 dport, |
| 185 | int dif); | 185 | int dif); |
| 186 | extern struct sock *udp6_lib_lookup(struct net *net, const struct in6_addr *saddr, __be16 sport, | ||
| 187 | const struct in6_addr *daddr, __be16 dport, | ||
| 188 | int dif); | ||
| 186 | 189 | ||
| 187 | /* | 190 | /* |
| 188 | * SNMP statistics for UDP and UDP-Lite | 191 | * SNMP statistics for UDP and UDP-Lite |
