diff options
| -rw-r--r-- | include/linux/netfilter/nfnetlink_acct.h | 8 | ||||
| -rw-r--r-- | include/net/netfilter/nf_nat.h | 2 | ||||
| -rw-r--r-- | include/uapi/linux/netfilter/nfnetlink.h | 2 | ||||
| -rw-r--r-- | include/uapi/linux/netfilter/nfnetlink_acct.h | 9 | ||||
| -rw-r--r-- | net/ipv4/netfilter/iptable_nat.c | 14 | ||||
| -rw-r--r-- | net/ipv4/netfilter/nft_chain_nat_ipv4.c | 12 | ||||
| -rw-r--r-- | net/ipv6/netfilter/ip6table_nat.c | 14 | ||||
| -rw-r--r-- | net/ipv6/netfilter/nft_chain_nat_ipv6.c | 12 | ||||
| -rw-r--r-- | net/netfilter/ipvs/ip_vs_core.c | 2 | ||||
| -rw-r--r-- | net/netfilter/nf_nat_core.c | 24 | ||||
| -rw-r--r-- | net/netfilter/nfnetlink_acct.c | 85 | ||||
| -rw-r--r-- | net/netfilter/xt_nfacct.c | 5 |
12 files changed, 138 insertions, 51 deletions
diff --git a/include/linux/netfilter/nfnetlink_acct.h b/include/linux/netfilter/nfnetlink_acct.h index b2e85e59f760..6ec975748742 100644 --- a/include/linux/netfilter/nfnetlink_acct.h +++ b/include/linux/netfilter/nfnetlink_acct.h | |||
| @@ -3,11 +3,17 @@ | |||
| 3 | 3 | ||
| 4 | #include <uapi/linux/netfilter/nfnetlink_acct.h> | 4 | #include <uapi/linux/netfilter/nfnetlink_acct.h> |
| 5 | 5 | ||
| 6 | enum { | ||
| 7 | NFACCT_NO_QUOTA = -1, | ||
| 8 | NFACCT_UNDERQUOTA, | ||
| 9 | NFACCT_OVERQUOTA, | ||
| 10 | }; | ||
| 6 | 11 | ||
| 7 | struct nf_acct; | 12 | struct nf_acct; |
| 8 | 13 | ||
| 9 | struct nf_acct *nfnl_acct_find_get(const char *filter_name); | 14 | struct nf_acct *nfnl_acct_find_get(const char *filter_name); |
| 10 | void nfnl_acct_put(struct nf_acct *acct); | 15 | void nfnl_acct_put(struct nf_acct *acct); |
| 11 | void nfnl_acct_update(const struct sk_buff *skb, struct nf_acct *nfacct); | 16 | void nfnl_acct_update(const struct sk_buff *skb, struct nf_acct *nfacct); |
| 12 | 17 | extern int nfnl_acct_overquota(const struct sk_buff *skb, | |
| 18 | struct nf_acct *nfacct); | ||
| 13 | #endif /* _NFNL_ACCT_H */ | 19 | #endif /* _NFNL_ACCT_H */ |
diff --git a/include/net/netfilter/nf_nat.h b/include/net/netfilter/nf_nat.h index 07eaaf604092..a71dd333ac68 100644 --- a/include/net/netfilter/nf_nat.h +++ b/include/net/netfilter/nf_nat.h | |||
| @@ -48,6 +48,8 @@ unsigned int nf_nat_setup_info(struct nf_conn *ct, | |||
| 48 | extern unsigned int nf_nat_alloc_null_binding(struct nf_conn *ct, | 48 | extern unsigned int nf_nat_alloc_null_binding(struct nf_conn *ct, |
| 49 | unsigned int hooknum); | 49 | unsigned int hooknum); |
| 50 | 50 | ||
| 51 | struct nf_conn_nat *nf_ct_nat_ext_add(struct nf_conn *ct); | ||
| 52 | |||
| 51 | /* Is this tuple already taken? (not by us)*/ | 53 | /* Is this tuple already taken? (not by us)*/ |
| 52 | int nf_nat_used_tuple(const struct nf_conntrack_tuple *tuple, | 54 | int nf_nat_used_tuple(const struct nf_conntrack_tuple *tuple, |
| 53 | const struct nf_conn *ignored_conntrack); | 55 | const struct nf_conn *ignored_conntrack); |
diff --git a/include/uapi/linux/netfilter/nfnetlink.h b/include/uapi/linux/netfilter/nfnetlink.h index 596ddd45253c..354a7e5e50f2 100644 --- a/include/uapi/linux/netfilter/nfnetlink.h +++ b/include/uapi/linux/netfilter/nfnetlink.h | |||
| @@ -20,6 +20,8 @@ enum nfnetlink_groups { | |||
| 20 | #define NFNLGRP_CONNTRACK_EXP_DESTROY NFNLGRP_CONNTRACK_EXP_DESTROY | 20 | #define NFNLGRP_CONNTRACK_EXP_DESTROY NFNLGRP_CONNTRACK_EXP_DESTROY |
| 21 | NFNLGRP_NFTABLES, | 21 | NFNLGRP_NFTABLES, |
| 22 | #define NFNLGRP_NFTABLES NFNLGRP_NFTABLES | 22 | #define NFNLGRP_NFTABLES NFNLGRP_NFTABLES |
| 23 | NFNLGRP_ACCT_QUOTA, | ||
| 24 | #define NFNLGRP_ACCT_QUOTA NFNLGRP_ACCT_QUOTA | ||
| 23 | __NFNLGRP_MAX, | 25 | __NFNLGRP_MAX, |
| 24 | }; | 26 | }; |
| 25 | #define NFNLGRP_MAX (__NFNLGRP_MAX - 1) | 27 | #define NFNLGRP_MAX (__NFNLGRP_MAX - 1) |
diff --git a/include/uapi/linux/netfilter/nfnetlink_acct.h b/include/uapi/linux/netfilter/nfnetlink_acct.h index c7b6269e760b..51404ec19022 100644 --- a/include/uapi/linux/netfilter/nfnetlink_acct.h +++ b/include/uapi/linux/netfilter/nfnetlink_acct.h | |||
| @@ -10,15 +10,24 @@ enum nfnl_acct_msg_types { | |||
| 10 | NFNL_MSG_ACCT_GET, | 10 | NFNL_MSG_ACCT_GET, |
| 11 | NFNL_MSG_ACCT_GET_CTRZERO, | 11 | NFNL_MSG_ACCT_GET_CTRZERO, |
| 12 | NFNL_MSG_ACCT_DEL, | 12 | NFNL_MSG_ACCT_DEL, |
| 13 | NFNL_MSG_ACCT_OVERQUOTA, | ||
| 13 | NFNL_MSG_ACCT_MAX | 14 | NFNL_MSG_ACCT_MAX |
| 14 | }; | 15 | }; |
| 15 | 16 | ||
| 17 | enum nfnl_acct_flags { | ||
| 18 | NFACCT_F_QUOTA_PKTS = (1 << 0), | ||
| 19 | NFACCT_F_QUOTA_BYTES = (1 << 1), | ||
| 20 | NFACCT_F_OVERQUOTA = (1 << 2), /* can't be set from userspace */ | ||
| 21 | }; | ||
| 22 | |||
| 16 | enum nfnl_acct_type { | 23 | enum nfnl_acct_type { |
| 17 | NFACCT_UNSPEC, | 24 | NFACCT_UNSPEC, |
| 18 | NFACCT_NAME, | 25 | NFACCT_NAME, |
| 19 | NFACCT_PKTS, | 26 | NFACCT_PKTS, |
| 20 | NFACCT_BYTES, | 27 | NFACCT_BYTES, |
| 21 | NFACCT_USE, | 28 | NFACCT_USE, |
| 29 | NFACCT_FLAGS, | ||
| 30 | NFACCT_QUOTA, | ||
| 22 | __NFACCT_MAX | 31 | __NFACCT_MAX |
| 23 | }; | 32 | }; |
| 24 | #define NFACCT_MAX (__NFACCT_MAX - 1) | 33 | #define NFACCT_MAX (__NFACCT_MAX - 1) |
diff --git a/net/ipv4/netfilter/iptable_nat.c b/net/ipv4/netfilter/iptable_nat.c index ee2886126e3d..f1787c04a4dd 100644 --- a/net/ipv4/netfilter/iptable_nat.c +++ b/net/ipv4/netfilter/iptable_nat.c | |||
| @@ -91,17 +91,9 @@ nf_nat_ipv4_fn(const struct nf_hook_ops *ops, | |||
| 91 | if (nf_ct_is_untracked(ct)) | 91 | if (nf_ct_is_untracked(ct)) |
| 92 | return NF_ACCEPT; | 92 | return NF_ACCEPT; |
| 93 | 93 | ||
| 94 | nat = nfct_nat(ct); | 94 | nat = nf_ct_nat_ext_add(ct); |
| 95 | if (!nat) { | 95 | if (nat == NULL) |
| 96 | /* NAT module was loaded late. */ | 96 | return NF_ACCEPT; |
| 97 | if (nf_ct_is_confirmed(ct)) | ||
| 98 | return NF_ACCEPT; | ||
| 99 | nat = nf_ct_ext_add(ct, NF_CT_EXT_NAT, GFP_ATOMIC); | ||
| 100 | if (nat == NULL) { | ||
| 101 | pr_debug("failed to add NAT extension\n"); | ||
| 102 | return NF_ACCEPT; | ||
| 103 | } | ||
| 104 | } | ||
| 105 | 97 | ||
| 106 | switch (ctinfo) { | 98 | switch (ctinfo) { |
| 107 | case IP_CT_RELATED: | 99 | case IP_CT_RELATED: |
diff --git a/net/ipv4/netfilter/nft_chain_nat_ipv4.c b/net/ipv4/netfilter/nft_chain_nat_ipv4.c index b5b256d45e67..3964157d826c 100644 --- a/net/ipv4/netfilter/nft_chain_nat_ipv4.c +++ b/net/ipv4/netfilter/nft_chain_nat_ipv4.c | |||
| @@ -48,15 +48,9 @@ static unsigned int nf_nat_fn(const struct nf_hook_ops *ops, | |||
| 48 | 48 | ||
| 49 | NF_CT_ASSERT(!(ip_hdr(skb)->frag_off & htons(IP_MF | IP_OFFSET))); | 49 | NF_CT_ASSERT(!(ip_hdr(skb)->frag_off & htons(IP_MF | IP_OFFSET))); |
| 50 | 50 | ||
| 51 | nat = nfct_nat(ct); | 51 | nat = nf_ct_nat_ext_add(ct); |
| 52 | if (nat == NULL) { | 52 | if (nat == NULL) |
| 53 | /* Conntrack module was loaded late, can't add extension. */ | 53 | return NF_ACCEPT; |
| 54 | if (nf_ct_is_confirmed(ct)) | ||
| 55 | return NF_ACCEPT; | ||
| 56 | nat = nf_ct_ext_add(ct, NF_CT_EXT_NAT, GFP_ATOMIC); | ||
| 57 | if (nat == NULL) | ||
| 58 | return NF_ACCEPT; | ||
| 59 | } | ||
| 60 | 54 | ||
| 61 | switch (ctinfo) { | 55 | switch (ctinfo) { |
| 62 | case IP_CT_RELATED: | 56 | case IP_CT_RELATED: |
diff --git a/net/ipv6/netfilter/ip6table_nat.c b/net/ipv6/netfilter/ip6table_nat.c index 84c7f33d0cf8..387d8b8fc18d 100644 --- a/net/ipv6/netfilter/ip6table_nat.c +++ b/net/ipv6/netfilter/ip6table_nat.c | |||
| @@ -90,17 +90,9 @@ nf_nat_ipv6_fn(const struct nf_hook_ops *ops, | |||
| 90 | if (nf_ct_is_untracked(ct)) | 90 | if (nf_ct_is_untracked(ct)) |
| 91 | return NF_ACCEPT; | 91 | return NF_ACCEPT; |
| 92 | 92 | ||
| 93 | nat = nfct_nat(ct); | 93 | nat = nf_ct_nat_ext_add(ct); |
| 94 | if (!nat) { | 94 | if (nat == NULL) |
| 95 | /* NAT module was loaded late. */ | 95 | return NF_ACCEPT; |
| 96 | if (nf_ct_is_confirmed(ct)) | ||
| 97 | return NF_ACCEPT; | ||
| 98 | nat = nf_ct_ext_add(ct, NF_CT_EXT_NAT, GFP_ATOMIC); | ||
| 99 | if (nat == NULL) { | ||
| 100 | pr_debug("failed to add NAT extension\n"); | ||
| 101 | return NF_ACCEPT; | ||
| 102 | } | ||
| 103 | } | ||
| 104 | 96 | ||
| 105 | switch (ctinfo) { | 97 | switch (ctinfo) { |
| 106 | case IP_CT_RELATED: | 98 | case IP_CT_RELATED: |
diff --git a/net/ipv6/netfilter/nft_chain_nat_ipv6.c b/net/ipv6/netfilter/nft_chain_nat_ipv6.c index 9c3297a768fd..d189fcb437fe 100644 --- a/net/ipv6/netfilter/nft_chain_nat_ipv6.c +++ b/net/ipv6/netfilter/nft_chain_nat_ipv6.c | |||
| @@ -47,15 +47,9 @@ static unsigned int nf_nat_ipv6_fn(const struct nf_hook_ops *ops, | |||
| 47 | if (ct == NULL || nf_ct_is_untracked(ct)) | 47 | if (ct == NULL || nf_ct_is_untracked(ct)) |
| 48 | return NF_ACCEPT; | 48 | return NF_ACCEPT; |
| 49 | 49 | ||
| 50 | nat = nfct_nat(ct); | 50 | nat = nf_ct_nat_ext_add(ct); |
| 51 | if (nat == NULL) { | 51 | if (nat == NULL) |
| 52 | /* Conntrack module was loaded late, can't add extension. */ | 52 | return NF_ACCEPT; |
| 53 | if (nf_ct_is_confirmed(ct)) | ||
| 54 | return NF_ACCEPT; | ||
| 55 | nat = nf_ct_ext_add(ct, NF_CT_EXT_NAT, GFP_ATOMIC); | ||
| 56 | if (nat == NULL) | ||
| 57 | |||
