aboutsummaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/bluetooth/bnep/core.c4
-rw-r--r--net/compat.c19
-rw-r--r--net/ipv4/ip_output.c6
-rw-r--r--net/ipv4/netfilter/arp_tables.c6
-rw-r--r--net/ipv4/netfilter/ip_conntrack_core.c4
-rw-r--r--net/ipv4/netfilter/ip_conntrack_helper_h323.c4
-rw-r--r--net/ipv4/netfilter/ip_conntrack_netlink.c72
-rw-r--r--net/ipv4/netfilter/ip_tables.c15
-rw-r--r--net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c1
-rw-r--r--net/ipv6/ipv6_sockglue.c4
-rw-r--r--net/ipv6/netfilter/ip6_tables.c15
-rw-r--r--net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c1
-rw-r--r--net/netfilter/Kconfig6
-rw-r--r--net/netfilter/nf_conntrack_core.c35
-rw-r--r--net/netfilter/nf_conntrack_netlink.c84
-rw-r--r--net/netfilter/nf_conntrack_standalone.c2
-rw-r--r--net/netfilter/nfnetlink_queue.c19
-rw-r--r--net/netfilter/x_tables.c16
-rw-r--r--net/netfilter/xt_CLASSIFY.c12
-rw-r--r--net/netfilter/xt_CONNMARK.c12
-rw-r--r--net/netfilter/xt_MARK.c21
-rw-r--r--net/netfilter/xt_NFQUEUE.c19
-rw-r--r--net/netfilter/xt_NOTRACK.c12
-rw-r--r--net/netfilter/xt_comment.c12
-rw-r--r--net/netfilter/xt_connbytes.c12
-rw-r--r--net/netfilter/xt_connmark.c29
-rw-r--r--net/netfilter/xt_conntrack.c33
-rw-r--r--net/netfilter/xt_dccp.c12
-rw-r--r--net/netfilter/xt_helper.c29
-rw-r--r--net/netfilter/xt_length.c12
-rw-r--r--net/netfilter/xt_limit.c12
-rw-r--r--net/netfilter/xt_mac.c12
-rw-r--r--net/netfilter/xt_mark.c12
-rw-r--r--net/netfilter/xt_physdev.c12
-rw-r--r--net/netfilter/xt_pkttype.c12
-rw-r--r--net/netfilter/xt_policy.c18
-rw-r--r--net/netfilter/xt_realm.c5
-rw-r--r--net/netfilter/xt_sctp.c12
-rw-r--r--net/netfilter/xt_state.c41
-rw-r--r--net/netfilter/xt_string.c12
-rw-r--r--net/netfilter/xt_tcpmss.c12
-rw-r--r--net/netfilter/xt_tcpudp.c26
-rw-r--r--net/socket.c21
-rw-r--r--net/x25/af_x25.c173
-rw-r--r--net/x25/x25_facilities.c82
-rw-r--r--net/x25/x25_in.c3
-rw-r--r--net/x25/x25_subr.c6
47 files changed, 766 insertions, 233 deletions
diff --git a/net/bluetooth/bnep/core.c b/net/bluetooth/bnep/core.c
index cbb20c32a6c..d908d49dc9f 100644
--- a/net/bluetooth/bnep/core.c
+++ b/net/bluetooth/bnep/core.c
@@ -532,8 +532,8 @@ int bnep_add_connection(struct bnep_connadd_req *req, struct socket *sock)
dev = alloc_netdev(sizeof(struct bnep_session),
(*req->device) ? req->device : "bnep%d",
bnep_net_setup);
- if (!dev)
- return ENOMEM;
+ if (!dev)
+ return -ENOMEM;
down_write(&bnep_session_sem);
diff --git a/net/compat.c b/net/compat.c
index 13177a1a4b3..8fd37cd7b50 100644
--- a/net/compat.c
+++ b/net/compat.c
@@ -543,6 +543,25 @@ static int compat_sock_getsockopt(struct socket *sock, int level, int optname,
return sock_getsockopt(sock, level, optname, optval, optlen);
}
+int compat_sock_get_timestamp(struct sock *sk, struct timeval __user *userstamp)
+{
+ struct compat_timeval __user *ctv =
+ (struct compat_timeval __user*) userstamp;
+ int err = -ENOENT;
+
+ if (!sock_flag(sk, SOCK_TIMESTAMP))
+ sock_enable_timestamp(sk);
+ if (sk->sk_stamp.tv_sec == -1)
+ return err;
+ if (sk->sk_stamp.tv_sec == 0)
+ do_gettimeofday(&sk->sk_stamp);
+ if (put_user(sk->sk_stamp.tv_sec, &ctv->tv_sec) ||
+ put_user(sk->sk_stamp.tv_usec, &ctv->tv_usec))
+ err = -EFAULT;
+ return err;
+}
+EXPORT_SYMBOL(compat_sock_get_timestamp);
+
asmlinkage long compat_sys_getsockopt(int fd, int level, int optname,
char __user *optval, int __user *optlen)
{
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c
index 8ee4d016740..f75ff1d9655 100644
--- a/net/ipv4/ip_output.c
+++ b/net/ipv4/ip_output.c
@@ -1249,11 +1249,7 @@ int ip_push_pending_frames(struct sock *sk)
iph->tos = inet->tos;
iph->tot_len = htons(skb->len);
iph->frag_off = df;
- if (!df) {
- __ip_select_ident(iph, &rt->u.dst, 0);
- } else {
- iph->id = htons(inet->id++);
- }
+ ip_select_ident(iph, &rt->u.dst, sk);
iph->ttl = ttl;
iph->protocol = sk->sk_protocol;
iph->saddr = rt->rt_src;
diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
index f7efb3f27bf..ff0c594a419 100644
--- a/net/ipv4/netfilter/arp_tables.c
+++ b/net/ipv4/netfilter/arp_tables.c
@@ -1146,12 +1146,14 @@ void arpt_unregister_table(struct arpt_table *table)
static struct arpt_target arpt_standard_target = {
.name = ARPT_STANDARD_TARGET,
.targetsize = sizeof(int),
+ .family = NF_ARP,
};
static struct arpt_target arpt_error_target = {
.name = ARPT_ERROR_TARGET,
.target = arpt_error,
.targetsize = ARPT_FUNCTION_MAXNAMELEN,
+ .family = NF_ARP,
};
static struct nf_sockopt_ops arpt_sockopts = {
@@ -1171,8 +1173,8 @@ static int __init init(void)
xt_proto_init(NF_ARP);
/* Noone else will be downing sem now, so we won't sleep */
- xt_register_target(NF_ARP, &arpt_standard_target);
- xt_register_target(NF_ARP, &arpt_error_target);
+ xt_register_target(&arpt_standard_target);
+ xt_register_target(&arpt_error_target);
/* Register setsockopt */
ret = nf_register_sockopt(&arpt_sockopts);
diff --git a/net/ipv4/netfilter/ip_conntrack_core.c b/net/ipv4/netfilter/ip_conntrack_core.c
index 84c66dbfeda..9e34034729a 100644
--- a/net/ipv4/netfilter/ip_conntrack_core.c
+++ b/net/ipv4/netfilter/ip_conntrack_core.c
@@ -77,8 +77,8 @@ unsigned int ip_ct_log_invalid;
static LIST_HEAD(unconfirmed);
static int ip_conntrack_vmalloc;
-static unsigned int ip_conntrack_next_id = 1;
-static unsigned int ip_conntrack_expect_next_id = 1;
+static unsigned int ip_conntrack_next_id;
+static unsigned int ip_conntrack_expect_next_id;
#ifdef CONFIG_IP_NF_CONNTRACK_EVENTS
struct notifier_block *ip_conntrack_chain;
struct notifier_block *ip_conntrack_expect_chain;
diff --git a/net/ipv4/netfilter/ip_conntrack_helper_h323.c b/net/ipv4/netfilter/ip_conntrack_helper_h323.c
index 20da6730b86..daeb1395faa 100644
--- a/net/ipv4/netfilter/ip_conntrack_helper_h323.c
+++ b/net/ipv4/netfilter/ip_conntrack_helper_h323.c
@@ -639,8 +639,8 @@ void ip_conntrack_h245_expect(struct ip_conntrack *new,
}
/****************************************************************************/
-static int get_h225_addr(unsigned char *data, TransportAddress * addr,
- u_int32_t * ip, u_int16_t * port)
+int get_h225_addr(unsigned char *data, TransportAddress * addr,
+ u_int32_t * ip, u_int16_t * port)
{
unsigned char *p;
diff --git a/net/ipv4/netfilter/ip_conntrack_netlink.c b/net/ipv4/netfilter/ip_conntrack_netlink.c
index 5ce2e3fc2c7..9b6e19bae90 100644
--- a/net/ipv4/netfilter/ip_conntrack_netlink.c
+++ b/net/ipv4/netfilter/ip_conntrack_netlink.c
@@ -4,7 +4,7 @@
* (C) 2001 by Jay Schulist <jschlst@samba.org>
* (C) 2002-2005 by Harald Welte <laforge@gnumonks.org>
* (C) 2003 by Patrick Mchardy <kaber@trash.net>
- * (C) 2005 by Pablo Neira Ayuso <pablo@eurodev.net>
+ * (C) 2005-2006 by Pablo Neira Ayuso <pablo@eurodev.net>
*
* I've reworked this stuff to use attributes instead of conntrack
* structures. 5.44 am. I need more tea. --pablo 05/07/11.
@@ -53,20 +53,18 @@ static char __initdata version[] = "0.90";
static inline int
ctnetlink_dump_tuples_proto(struct sk_buff *skb,
- const struct ip_conntrack_tuple *tuple)
+ const struct ip_conntrack_tuple *tuple,
+ struct ip_conntrack_protocol *proto)
{
- struct ip_conntrack_protocol *proto;
int ret = 0;
+ struct nfattr *nest_parms = NFA_NEST(skb, CTA_TUPLE_PROTO);
NFA_PUT(skb, CTA_PROTO_NUM, sizeof(u_int8_t), &tuple->dst.protonum);
- /* If no protocol helper is found, this function will return the
- * generic protocol helper, so proto won't *ever* be NULL */
- proto = ip_conntrack_proto_find_get(tuple->dst.protonum);
if (likely(proto->tuple_to_nfattr))
ret = proto->tuple_to_nfattr(skb, tuple);
- ip_conntrack_proto_put(proto);
+ NFA_NEST_END(skb, nest_parms);
return ret;
@@ -75,28 +73,41 @@ nfattr_failure:
}
static inline int
-ctnetlink_dump_tuples(struct sk_buff *skb,
- const struct ip_conntrack_tuple *tuple)
+ctnetlink_dump_tuples_ip(struct sk_buff *skb,
+ const struct ip_conntrack_tuple *tuple)
{
- struct nfattr *nest_parms;
- int ret;
+ struct nfattr *nest_parms = NFA_NEST(skb, CTA_TUPLE_IP);
- nest_parms = NFA_NEST(skb, CTA_TUPLE_IP);
NFA_PUT(skb, CTA_IP_V4_SRC, sizeof(u_int32_t), &tuple->src.ip);
NFA_PUT(skb, CTA_IP_V4_DST, sizeof(u_int32_t), &tuple->dst.ip);
- NFA_NEST_END(skb, nest_parms);
- nest_parms = NFA_NEST(skb, CTA_TUPLE_PROTO);
- ret = ctnetlink_dump_tuples_proto(skb, tuple);
NFA_NEST_END(skb, nest_parms);
- return ret;
+ return 0;
nfattr_failure:
return -1;
}
static inline int
+ctnetlink_dump_tuples(struct sk_buff *skb,
+ const struct ip_conntrack_tuple *tuple)
+{
+ int ret;
+ struct ip_conntrack_protocol *proto;
+
+ ret = ctnetlink_dump_tuples_ip(skb, tuple);
+ if (unlikely(ret < 0))
+ return ret;
+
+ proto = ip_conntrack_proto_find_get(tuple->dst.protonum);
+ ret = ctnetlink_dump_tuples_proto(skb, tuple, proto);
+ ip_conntrack_proto_put(proto);
+
+ return ret;
+}
+
+static inline int
ctnetlink_dump_status(struct sk_buff *skb, const struct ip_conntrack *ct)
{
u_int32_t status = htonl((u_int32_t) ct->status);
@@ -1135,6 +1146,33 @@ nfattr_failure:
}
static inline int
+ctnetlink_exp_dump_mask(struct sk_buff *skb,
+ const struct ip_conntrack_tuple *tuple,
+ const struct ip_conntrack_tuple *mask)
+{
+ int ret;
+ struct ip_conntrack_protocol *proto;
+ struct nfattr *nest_parms = NFA_NEST(skb, CTA_EXPECT_MASK);
+
+ ret = ctnetlink_dump_tuples_ip(skb, mask);
+ if (unlikely(ret < 0))
+ goto nfattr_failure;
+
+ proto = ip_conntrack_proto_find_get(tuple->dst.protonum);
+ ret = ctnetlink_dump_tuples_proto(skb, mask, proto);
+ ip_conntrack_proto_put(proto);
+ if (unlikely(ret < 0))
+ goto nfattr_failure;
+
+ NFA_NEST_END(skb, nest_parms);
+
+ return 0;
+
+nfattr_failure:
+ return -1;
+}
+
+static inline int
ctnetlink_exp_dump_expect(struct sk_buff *skb,
const struct ip_conntrack_expect *exp)
{
@@ -1144,7 +1182,7 @@ ctnetlink_exp_dump_expect(struct sk_buff *skb,
if (ctnetlink_exp_dump_tuple(skb, &exp->tuple, CTA_EXPECT_TUPLE) < 0)
goto nfattr_failure;
- if (ctnetlink_exp_dump_tuple(skb, &exp->mask, CTA_EXPECT_MASK) < 0)
+ if (ctnetlink_exp_dump_mask(skb, &exp->tuple, &exp->mask) < 0)
goto nfattr_failure;
if (ctnetlink_exp_dump_tuple(skb,
&master->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
index 39705f9bc15..a7b194c4d79 100644
--- a/net/ipv4/netfilter/ip_tables.c
+++ b/net/ipv4/netfilter/ip_tables.c
@@ -1335,12 +1335,14 @@ icmp_checkentry(const char *tablename,
static struct ipt_target ipt_standard_target = {
.name = IPT_STANDARD_TARGET,
.targetsize = sizeof(int),
+ .family = AF_INET,
};
static struct ipt_target ipt_error_target = {
.name = IPT_ERROR_TARGET,
.target = ipt_error,
.targetsize = IPT_FUNCTION_MAXNAMELEN,
+ .family = AF_INET,
};
static struct nf_sockopt_ops ipt_sockopts = {
@@ -1358,6 +1360,7 @@ static struct ipt_match icmp_matchstruct = {
.match = icmp_match,
.matchsize = sizeof(struct ipt_icmp),
.proto = IPPROTO_ICMP,
+ .family = AF_INET,
.checkentry = icmp_checkentry,
};
@@ -1368,9 +1371,9 @@ static int __init init(void)
xt_proto_init(AF_INET);
/* Noone else will be downing sem now, so we won't sleep */
- xt_register_target(AF_INET, &ipt_standard_target);
- xt_register_target(AF_INET, &ipt_error_target);
- xt_register_match(AF_INET, &icmp_matchstruct);
+ xt_register_target(&ipt_standard_target);
+ xt_register_target(&ipt_error_target);
+ xt_register_match(&icmp_matchstruct);
/* Register setsockopt */
ret = nf_register_sockopt(&ipt_sockopts);
@@ -1387,9 +1390,9 @@ static void __exit fini(void)
{
nf_unregister_sockopt(&ipt_sockopts);
- xt_unregister_match(AF_INET, &icmp_matchstruct);
- xt_unregister_target(AF_INET, &ipt_error_target);
- xt_unregister_target(AF_INET, &ipt_standard_target);
+ xt_unregister_match(&icmp_matchstruct);
+ xt_unregister_target(&ipt_error_target);
+ xt_unregister_target(&ipt_standard_target);
xt_proto_fini(AF_INET);
}
diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
index cb9c661f3f3..c8abc9d859b 100644
--- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
+++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
@@ -568,6 +568,7 @@ static int init_or_cleanup(int init)
return ret;
}
+MODULE_ALIAS("nf_conntrack-" __stringify(AF_INET));
MODULE_LICENSE("GPL");
static int __init init(void)
diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
index 602feec4773..4c20eeb3d56 100644
--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -907,7 +907,7 @@ int ipv6_getsockopt(struct sock *sk, int level, int optname,
err = do_ipv6_getsockopt(sk, level, optname, optval, optlen);
#ifdef CONFIG_NETFILTER
/* we need to exclude all possible EINVALs except default case */
- if (err == -ENOPROTOOPT && optname != IPV6_ADDRFORM &&
+ if (err == -EINVAL && optname != IPV6_ADDRFORM &&
optname != MCAST_MSFILTER) {
int len;
@@ -944,7 +944,7 @@ int compat_ipv6_getsockopt(struct sock *sk, int level, int optname,
err = do_ipv6_getsockopt(sk, level, optname, optval, optlen);
#ifdef CONFIG_NETFILTER
/* we need to exclude all possible EINVALs except default case */
- if (err == -ENOPROTOOPT && optname != IPV6_ADDRFORM &&
+ if (err == -EINVAL && optname != IPV6_ADDRFORM &&
optname != MCAST_MSFILTER) {
int len;
diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
index 5a2063bda67..db3c9ae98e9 100644
--- a/net/ipv6/netfilter/ip6_tables.c
+++ b/net/ipv6/netfilter/ip6_tables.c
@@ -1377,12 +1377,14 @@ icmp6_checkentry(const char *tablename,
static struct ip6t_target ip6t_standard_target = {
.name = IP6T_STANDARD_TARGET,
.targetsize = sizeof(int),
+ .family = AF_INET6,
};
static struct ip6t_target ip6t_error_target = {
.name = IP6T_ERROR_TARGET,
.target = ip6t_error,
.targetsize = IP6T_FUNCTION_MAXNAMELEN,
+ .family = AF_INET6,
};
static struct nf_sockopt_ops ip6t_sockopts = {
@@ -1401,6 +1403,7 @@ static struct ip6t_match icmp6_matchstruct = {
.matchsize = sizeof(struct ip6t_icmp),
.checkentry = icmp6_checkentry,
.proto = IPPROTO_ICMPV6,
+ .family = AF_INET6,
};
static int __init init(void)
@@ -1410,9 +1413,9 @@ static int __init init(void)
xt_proto_init(AF_INET6);
/* Noone else will be downing sem now, so we won't sleep */
- xt_register_target(AF_INET6, &ip6t_standard_target);
- xt_register_target(AF_INET6, &ip6t_error_target);
- xt_register_match(AF_INET6, &icmp6_matchstruct);
+ xt_register_target(&ip6t_standard_target);
+ xt_register_target(&ip6t_error_target);
+ xt_register_match(&icmp6_matchstruct);
/* Register setsockopt */
ret = nf_register_sockopt(&ip6t_sockopts);
@@ -1429,9 +1432,9 @@ static int __init init(void)
static void __exit fini(void)
{
nf_unregister_sockopt(&ip6t_sockopts);
- xt_unregister_match(AF_INET6, &icmp6_matchstruct);
- xt_unregister_target(AF_INET6, &ip6t_error_target);
- xt_unregister_target(AF_INET6, &ip6t_standard_target);
+ xt_unregister_match(&icmp6_matchstruct);
+ xt_unregister_target(&ip6t_error_target);
+ xt_unregister_target(&ip6t_standard_target);
xt_proto_fini(AF_INET6);
}
diff --git a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
index ac35f952636..c16f62934bd 100644
--- a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
+++ b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
@@ -584,6 +584,7 @@ static int init_or_cleanup(int init)
return ret;
}
+MODULE_ALIAS("nf_conntrack-" __stringify(AF_INET6));
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Yasuyuki KOZAKAI @USAGI <yasuyuki.kozakai@toshiba.co.jp>");
diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
index 17402780914..332acb37b38 100644
--- a/net/netfilter/Kconfig
+++ b/net/netfilter/Kconfig
@@ -11,7 +11,7 @@ config NETFILTER_NETLINK_QUEUE
tristate "Netfilter NFQUEUE over NFNETLINK interface"
depends on NETFILTER_NETLINK
help
- If this option isenabled, the kernel will include support
+ If this option is enabled, the kernel will include support
for queueing packets via NFNETLINK.
config NETFILTER_NETLINK_LOG
@@ -66,7 +66,7 @@ config NF_CONNTRACK_EVENTS
help
If this option is enabled, the connection tracking code will
provide a notifier chain that can be used by other kernel code
- to get notified aboutchanges in the connection tracking state.
+ to get notified about changes in the connection tracking state.
If unsure, say `N'.
@@ -153,7 +153,7 @@ config NETFILTER_XT_TARGET_NFQUEUE
tristate '"NFQUEUE" target Support'
depends on NETFILTER_XTABLES
help
- This Target replaced the old obsolete QUEUE target.
+ This target replaced the old obsolete QUEUE target.
As opposed to QUEUE, it supports 65535 different queues,
not just one.
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index f6498234e26..0ae281d9bfc 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -23,6 +23,8 @@
* 26 Jan 2006: Harald Welte <laforge@netfilter.org>
* - restructure nf_conn (introduce nf_conn_help)
* - redesign 'features' how they were originally intended
+ * 26 Feb 2006: Pablo Neira Ayuso <pablo@eurodev.net>
+ * - add support for L3 protocol module load on demand.
*
* Derived from net/ipv4/netfilter/ip_conntrack_core.c
*/
@@ -85,8 +87,8 @@ unsigned int nf_ct_log_invalid;
static LIST_HEAD(unconfirmed);
static int nf_conntrack_vmalloc;
-static unsigned int nf_conntrack_next_id = 1;
-static unsigned int nf_conntrack_expect_next_id = 1;
+static unsigned int nf_conntrack_next_id;
+static unsigned int nf_conntrack_expect_next_id;
#ifdef CONFIG_NF_CONNTRACK_EVENTS
struct notifier_block *nf_conntrack_chain;
struct notifier_block *nf_conntrack_expect_chain;
@@ -241,6 +243,35 @@ void nf_ct_l3proto_put(struct nf_conntrack_l3proto *p)
module_put(p->me);
}
+int
+nf_ct_l3proto_try_module_get(unsigned short l3proto)
+{
+ int ret;
+ struct nf_conntrack_l3proto *p;
+
+retry: p = nf_ct_l3proto_find_get(l3proto);
+ if (p == &nf_conntrack_generic_l3proto) {
+ ret = request_module("nf_conntrack-%d", l3proto);
+ if (!ret)
+ goto retry;
+
+ return -EPROTOTYPE;
+ }
+
+ return 0;
+}
+
+void nf_ct_l3proto_module_put(unsigned short l3proto)
+{
+ struct nf_conntrack_l3proto *p;
+
+ preempt_disable();
+ p = __nf_ct_l3proto_find(l3proto);
+ preempt_enable();
+
+ module_put(p->me);
+}
+
static int nf_conntrack_hash_rnd_initted;
static unsigned int nf_conntrack_hash_rnd;
diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
index 5eadf009bb1..0e0e9d7b34c 100644
--- a/net/netfilter/nf_conntrack_netlink.c
+++ b/net/netfilter/nf_conntrack_netlink.c
@@ -4,7 +4,7 @@
* (C) 2001 by Jay Schulist <jschlst@samba.org>
* (C) 2002-2006 by Harald Welte <laforge@gnumonks.org>
* (C) 2003 by Patrick Mchardy <kaber@trash.net>
- * (C) 2005 by Pablo Neira Ayuso <pablo@eurodev.net>
+ * (C) 2005-2006 by Pablo Neira Ayuso <pablo@eurodev.net>
*
* I've reworked this stuff to use attributes instead of conntrack
* structures. 5.44 am. I need more tea. --pablo 05/07/11.
@@ -55,20 +55,18 @@ static char __initdata version[] = "0.93";
static inline int
ctnetlink_dump_tuples_proto(struct sk_buff *skb,
- const struct nf_conntrack_tuple *tuple)
+ const struct nf_conntrack_tuple *tuple,
+ struct nf_conntrack_protocol *proto)
{
- struct nf_conntrack_protocol *proto;
int ret = 0;
+ struct nfattr *nest_parms = NFA_NEST(skb, CTA_TUPLE_PROTO);
NFA_PUT(skb, CTA_PROTO_NUM, sizeof(u_int8_t), &tuple->dst.protonum);
- /* If no protocol helper is found, this function will return the
- * generic protocol helper, so proto won't *ever* be NULL */
- proto = nf_ct_proto_find_get(tuple->src.l3num, tuple->dst.protonum);
if (likely(proto->tuple_to_nfattr))
ret = proto->tuple_to_nfattr(skb, tuple);
- nf_ct_proto_put(proto);
+ NFA_NEST_END(skb, nest_parms);
return ret;
@@ -77,33 +75,44 @@ nfattr_failure:
}
static inline int
-ctnetlink_dump_tuples(struct sk_buff *skb,
- const struct nf_conntrack_tuple *tuple)
+ctnetlink_dump_tuples_ip(struct sk_buff *skb,
+ const struct nf_conntrack_tuple *tuple,
+ struct nf_conntrack_l3proto *l3proto)
{
- struct nfattr *nest_parms;
- struct nf_conntrack_l3proto *l3proto;
int ret = 0;
-
- l3proto = nf_ct_l3proto_find_get(tuple->src.l3num);
-
- nest_parms = NFA_NEST(skb, CTA_TUPLE_IP);
+ struct nfattr *nest_parms = NFA_NEST(skb, CTA_TUPLE_IP);
+
if (likely(l3proto->tuple_to_nfattr))
ret = l3proto->tuple_to_nfattr(skb, tuple);
+
NFA_NEST_END(skb, nest_parms);
+ return ret;
+
+nfattr_failure:
+ return -1;
+}
+
+static inline int
+ctnetlink_dump_tuples(struct sk_buff *skb,
+ const struct nf_conntrack_tuple *tuple)
+{
+ int ret;
+ struct nf_conntrack_l3proto *l3proto;
+ struct nf_conntrack_protocol *proto;
+
+ l3proto = nf_ct_l3proto_find_get(tuple->src.l3num);
+ ret = ctnetlink_dump_tuples_ip(skb, tuple, l3proto);
nf_ct_l3proto_put(l3proto);
if (unlikely(ret < 0))
return ret;
- nest_parms = NFA_NEST(skb, CTA_TUPLE_PROTO);
- ret = ctnetlink_dump_tuples_proto(skb, tuple);
- NFA_NEST_END(skb, nest_parms);
+ proto = nf_ct_proto_find_get(tuple->src.l3num, tuple->dst.protonum);
+ ret = ctnetlink_dump_tuples_proto(skb, tuple, proto);
+ nf_ct_proto_put(proto);
return ret;
-
-nfattr_failure:
- return -1;
}
static inline int
@@ -1153,6 +1162,37 @@ nfattr_failure:
}
static inline int
+ctnetlink_exp_dump_mask(struct sk_buff *skb,
+ const struct nf_conntrack_tuple *tuple,
+ const struct nf_conntrack_tuple *mask)
+{
+ int ret;
+ struct nf_conntrack_l3proto *l3proto;
+ struct nf_conntrack_protocol *proto;
+ struct nfattr *nest_parms = NFA_NEST(skb, CTA_EXPECT_MASK);
+
+ l3proto = nf_ct_l3proto_find_get(tuple->src.l3num);
+ ret = ctnetlink_dump_tuples_ip(skb, mask, l3proto);
+ nf_ct_l3proto_put(l3proto);
+
+ if (unlikely(ret < 0))
+ goto nfattr_failure;
+
+ proto = nf_ct_proto_find_get(tuple->src.l3num, tuple->dst.protonum);
+ ret = ctnetlink_dump_tuples_proto(skb, mask, proto);
+ nf_ct_proto_put(proto);
+ if (unlikely(ret < 0))
+ goto nfattr_failure;
+
+ NFA_NEST_END(skb, nest_parms);
+
+ return 0;
+
+nfattr_failure:
+ return -1;
+}
+
+static inline int
ctnetlink_exp_dump_expect(struct sk_buff *skb,
const struct nf_conntrack_expect *exp)
{
@@ -1162,7 +1202,7 @@ ctnetlink_exp_dump_expect(struct sk_buff *skb,
if (ctnetlink_exp_dump_tuple(skb, &exp->tuple, CTA_EXPECT_TUPLE) < 0)
goto nfattr_failure;
- if (ctnetlink_exp_dump_tuple(skb, &exp->mask, CTA_EXPECT_MASK) < 0)
+ if (ctnetlink_exp_dump_mask(skb, &exp->tuple, &exp->mask) < 0)
goto nfattr_failure;
if (ctnetlink_exp_dump_tuple(skb,
&master->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
index 290d5a0c559..75577e175b3 100644
--- a/net/netfilter/nf_conntrack_standalone.c
+++ b/net/netfilter/nf_conntrack_standalone.c
@@ -834,6 +834,8 @@ EXPORT_SYMBOL_GPL(__nf_ct_event_cache_init);
EXPORT_PER_CPU_SYMBOL_GPL(nf_conntrack_ecache);
EXPORT_SYMBOL_GPL(nf_ct_deliver_cached_events);
#endif
+EXPORT_SYMBOL(nf_ct_l3proto_try_module_get);
+EXPORT_SYMBOL(nf_ct_l3proto_module_put);
EXPORT_SYMBOL(nf_conntrack_l3proto_register);
EXPORT_SYMBOL(nf_conntrack_l3proto_unregister);
EXPORT_SYMBOL(nf_conntrack_protocol_register);
diff --git a/net/netfilter/nfnetlink_queue.c b/net/netfilter/nfnetlink_queue.c
index 2cf5fb8322c..b5701662182 100644
--- a/net/netfilter/nfnetlink_queue.c
+++ b/net/netfilter/nfnetlink_queue.c
@@ -354,16 +354,17 @@ nfqnl_build_packet_message(struct nfqnl_instance *queue,
QDEBUG("entered\n");
/* all macros expand to constant values at compile time */
- size = NLMSG_SPACE(sizeof(struct nfqnl_msg_packet_hdr))
- + NLMSG_SPACE(sizeof(u_int32_t)) /* ifindex */
- + NLMSG_SPACE(sizeof(u_int32_t)) /* ifindex */
+ size = NLMSG_SPACE(sizeof(struct nfgenmsg)) +
+ + NFA_SPACE(sizeof(struct nfqnl_msg_packet_hdr))
+ + NFA_SPACE(sizeof(u_int32_t)) /* ifindex */
+ + NFA_SPACE(sizeof(u_int32_t)) /* ifindex */
#ifdef CONFIG_BRIDGE_NETFILTER
- + NLMSG_SPACE(sizeof(u_int32_t)) /* ifindex */
- + NLMSG_SPACE(sizeof(u_int32_t)) /* ifindex */
+ + NFA_SPACE(sizeof(u_int32_t)) /* ifindex */
+ + NFA_SPACE(sizeof(u_int32_t)) /* ifindex */
#endif
- + NLMSG_SPACE(sizeof(u_int32_t)) /* mark */
- + NLMSG_SPACE(sizeof(struct nfqnl_msg_packet_hw))
- + NLMSG_SPACE(sizeof(struct nfqnl_msg_packet_timestamp));
+ + NFA_SPACE(sizeof(u_int32_t)) /* mark */
+ + NFA_SPACE(sizeof(struct nfqnl_msg_packet_hw))
+ + NFA_SPACE(sizeof(struct nfqnl_msg_packet_timestamp));
outdev = entinf->outdev;
@@ -388,7 +389,7 @@ nfqnl_build_packet_message(struct nfqnl_instance *queue,
else
data_len = queue->copy_range;
- size += NLMSG_SPACE(data_len);
+ size += NFA_SPACE(data_len);
break;
default:
diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
index 750b9282976..0a29a24d9a7 100644
--- a/net/netfilter/x_tables.c
+++ b/net/netfilter/x_tables.c
@@ -60,9 +60,9 @@ static const char *xt_prefix[NPROTO] = {
/* Registration hooks for targets. */
int
-xt_register_target(int af, struct xt_target *target)
+xt_register_target(struct xt_target *target)
{
- int ret;
+ int ret, af = target->family;
ret = down_interruptible(&xt[af].mutex);
if (ret != 0)
@@ -74,8 +74,10 @@ xt_register_target(int af, struct xt_target *target)
EXPORT_SYMBOL(xt_register_target);
void
-xt_unregister_target(int af, struct xt_target *target)
+xt_unregister_target(struct xt_target *target)
{
+ int af = target->family;
+
down(&xt[af].mutex);
LIST_DELETE(&xt[af].target, target);
up(&xt[af].mutex);
@@ -83,9 +85,9 @@ xt_unregister_target(int af, struct xt_target *target)
EXPORT_SYMBOL(xt_unregister_target);
int
-xt_register_match(int af, struct xt_match *match)
+xt_register_match(struct xt_match *match)
{
- int ret;
+ int ret, af = match->family;
ret = down_interruptible(&xt[af].mutex);
if (ret != 0)
@@ -99,8 +101,10 @@ xt_register_match(int af, struct xt_match *match)
EXPORT_SYMBOL(xt_register_match);
void
-xt_unregister_match(int af, struct xt_match *match)
+xt_unregister_match(struct xt_match *match)
{
+ int af = match->family;
+
down(&xt[af].mutex);
LIST_DELETE(&xt[af].match, match);
up(&xt[af].mutex);
diff --git a/net/netfilter/xt_CLASSIFY.c b/net/netfilter/xt_CLASSIFY.c
index 3224ed87d4c..3cd2ac90a25 100644
--- a/net/netfilter/xt_CLASSIFY.c
+++ b/net/netfilter/xt_CLASSIFY.c
@@ -47,6 +47,7 @@ static struct xt_target classify_reg = {
.table = "mangle",
.hooks = (1 << NF_IP_LOCAL_OUT) | (1 << NF_IP_FORWARD) |
(1 << NF_IP_POST_ROUTING),
+ .family = AF_INET,
.me = THIS_MODULE,
};
static struct xt_target classify6_reg = {
@@ -56,6 +57,7 @@ static struct xt_target classify6_reg = {
.table = "mangle",
.hooks = (1 << NF_IP_LOCAL_OUT) | (1 << NF_IP_FORWARD) |
(1 << NF_IP_POST_ROUTING),
+ .family = AF_INET6,
.me = THIS_MODULE,
};
@@ -64,21 +66,21 @@ static int __init init(void)
{
int ret;
- ret = xt_register_target(AF_INET, &classify_reg);
+ ret = xt_register_target(&classify_reg);
if (ret)
return ret;
- ret = xt_register_target(AF_INET6, &classify6_reg);
+ ret = xt_register_target(&classify6_reg);
if (ret)
- xt_unregister_target(AF_INET, &classify_reg);
+ xt_unregister_target(&classify_reg);
return ret;
}
static void __exit fini(void)
{
- xt_unregister_target(AF_INET, &classify_reg);
- xt_unregister_target(AF_INET6, &classify6_reg);
+ xt_unregister_target(&classify_reg);
+ xt_unregister_target(&classify6_reg);
}
module_init(init);
diff --git a/net/netfilter/xt_CONNMARK.c b/net/netfilter/xt_CONNMARK.c
index df2486a3efd..35448b8e688 100644
--- a/net/netfilter/xt_CONNMARK.c
+++ b/net/netfilter/xt_CONNMARK.c
@@ -102,6 +102,7 @@ static struct xt_target connmark_reg = {
.target = target,
.targetsize = sizeof(struct xt_connmark_target_info),
.checkentry = checkentry,
+ .family = AF_INET,
.me = THIS_MODULE
};
@@ -110,6 +111,7 @@ static struct xt_target connmark6_reg = {
.target = target,
.targetsize = sizeof(struct xt_connmark_target_info),
.checkentry = checkentry,
+ .family = AF_INET6,
.me = THIS_MODULE
};
@@ -119,21 +121,21 @@ static int __init init(void)
need_conntrack();
- ret = xt_register_target(AF_INET, &connmark_reg);
+ ret = xt_register_target(&connmark_reg);
if (ret)
return ret;
- ret = xt_register_target(AF_INET6, &connmark6_reg);
+ ret = xt_register_target(&connmark6_reg);
if (ret)
- xt_unregister_target(AF_INET, &connmark_reg);
+ xt_unregister_target(&connmark_reg);
return ret;
}
static void __exit fini(void)
{
- xt_unregister_target(AF_INET, &connmark_reg);
- xt_unregister_target(AF_INET6, &connmark6_reg);
+ xt_unregister_target(&connmark_reg);
+ xt_unregister_target(&connmark6_reg);
}
module_init(init);
diff --git a/net/netfilter/xt_MARK.c b/net/netfilter/xt_MARK.c
index dcb5266efae..73bdd5c80e1 100644
--- a/net/netfilter/xt_MARK.c
+++ b/net/netfilter/xt_MARK.c
@@ -119,6 +119,7 @@ static struct xt_target ipt_mark_reg_v0 = {
.table = "mangle",
.checkentry = checkentry_v0,
.me = THIS_MODULE,
+ .family = AF_INET,
.revision = 0,
};
@@ -129,6 +130,7 @@ static struct xt_target ipt_mark_reg_v1 = {
.table = "mangle",
.checkentry = checkentry_v1,
.me = THIS_MODULE,
+ .family = AF_INET,
.revision = 1,
};
@@ -139,6 +141,7 @@ static struct xt_target ip6t_mark_reg_v0 = {
.table = "mangle",
.checkentry = checkentry_v0,
.me = THIS_MODULE,
+ .family = AF_INET6,
.revision = 0,
};
@@ -146,18 +149,18 @@ static int __init init(void)
{
int err;
- err = xt_register_target(AF_INET, &ipt_mark_reg_v0);
+ err = xt_register_target(&ipt_mark_reg_v0);
if (err)
return err;
- err = xt_register_target(AF_INET, &ipt_mark_reg_v1);
+ err = xt_register_target(&ipt_mark_reg_v1);
if (err)
- xt_unregister_target(AF_INET, &ipt_mark_reg_v0);
+ xt_unregister_target(&ipt_mark_reg_v0);
- err = xt_register_target(AF_INET6, &ip6t_mark_reg_v0);
+ err = xt_register_target(&ip6t_mark_reg_v0);
if (err) {
- xt_unregister_target(AF_INET, &ipt_mark_reg_v0);
- xt_unregister_target(AF_INET, &ipt_mark_reg_v1);
+ xt_unregister_target(&ipt_mark_reg_v0);
+ xt_unregister_target(&ipt_mark_reg_v1);
}
return err;
@@ -165,9 +168,9 @@ static int __init init(void)
static void __exit fini(void)
{
- xt_unregister_target(AF_INET, &ipt_mark_reg_v0);
- xt_unregister_target(AF_INET, &ipt_mark_reg_v1);
- xt_unregister_target(AF_INET6, &ip6t_mark_reg_v0);
+ xt_unregister_target(&ipt_mark_reg_v0);
+ xt_unregister_target(&ipt_mark_reg_v1);
+ xt_unregister_target(&ip6t_mark_reg_v0);
}
module_init(init);
diff --git a/net/netfilter/xt_NFQUEUE.c b/net/netfilter/xt_NFQUEUE.c
index 39a963edf16..2873e1c60f6 100644
--- a/net/netfilter/xt_NFQUEUE.c
+++ b/net/netfilter/xt_NFQUEUE.c
@@ -41,6 +41,7 @@ static struct xt_target ipt_NFQ_reg = {
.name = "NFQUEUE",
.target = target,
.targetsize = sizeof(struct xt_NFQ_info),
+ .family = AF_INET,
.me = THIS_MODULE,
};
@@ -48,6 +49,7 @@ static struct xt_target ip6t_NFQ_reg = {
.name = "NFQUEUE",
.target = target,
.targetsize = sizeof(struct xt_NFQ_info),
+ .family = AF_INET6,
.me = THIS_MODULE,
};
@@ -55,36 +57,37 @@ static struct xt_target arpt_NFQ_reg = {
.name = "NFQUEUE",
.target = target,
.targetsize = sizeof(struct xt_NFQ_info),
+ .family = NF_ARP,
.me = THIS_MODULE,
};
static int __init init(void)
{
int ret;
- ret = xt_register_target(AF_INET, &ipt_NFQ_reg);
+ ret = xt_register_target(&ipt_NFQ_reg);
if (ret)
return ret;
- ret = xt_register_target(AF_INET6, &ip6t_NFQ_reg);
+ ret = xt_register_target(&ip6t_NFQ_reg);
if (ret)
goto out_ip;
- ret = xt_register_target(NF_ARP, &arpt_NFQ_reg);
+ ret = xt_register_target(&arpt_NFQ_reg);
if (ret)
goto out_ip6;
return ret;
out_ip6:
- xt_unregister_target(AF_INET6, &ip6t_NFQ_reg);
+ xt_unregister_target(&ip6t_NFQ_reg);
out_ip:
- xt_unregister_target(AF_INET, &ipt_NFQ_reg);
+ xt_unregister_target(&ipt_NFQ_reg);
return ret;
}
static void __exit fini(void)
{
- xt_unregister_target(NF_ARP, &arpt_NFQ_reg);
- xt_unregister_target(AF_INET6, &ip6t_NFQ_reg);
- xt_unregister_target(AF_INET, &ipt_NFQ_reg);
+ xt_unregister_target(&arpt_NFQ_reg);
+ xt_unregister_target(&ip6t_NFQ_reg);
+ xt_unregister_target(&ipt_NFQ_reg);
}
module_init(init);
diff --git a/net/netfilter/xt_NOTRACK.c b/net/netfilter/xt_NOTRACK.c
index b8634e3f616..cf2ebd76fd6 100644
--- a/net/netfilter/xt_NOTRACK.c
+++ b/net/netfilter/xt_NOTRACK.c
@@ -39,6 +39,7 @@ static struct xt_target notrack_reg = {
.target = target,
.targetsize = 0,
.table = "raw",
+ .family = AF_INET,
.me = THIS_MODULE,
};
@@ -47,6 +48,7 @@ static struct xt_target notrack6_reg = {
.target = target,
.targetsize = 0,
.table = "raw",
+ .family = AF_INET6,
.me = THIS_MODULE,
};
@@ -54,21 +56,21 @@ static int __init init(void)
{
int ret;
- ret = xt_register_target(AF_INET, &notrack_reg);
+ ret = xt_register_target(&notrack_reg);
if (ret)
return ret;
- ret = xt_register_target(AF_INET6, &notrack6_reg);
+ ret = xt_register_target(&notrack6_reg);
if (ret)
- xt_unregister_target(AF_INET, &notrack_reg);
+ xt_unregister_target(&notrack_reg);
return ret;
}
static void __exit fini(void)
{
- xt_unregister_target(AF_INET6, &notrack6_reg);
- xt_unregister_target(AF_INET, &notrack_reg);
+ xt_unregister_target(&notrack6_reg);
+ xt_unregister_target(&notrack_reg);
}
module_init(init);
diff --git a/net/netfilter/xt_comment.c b/net/netfilter/xt_comment.c
index 03d9d741231..2637724b498 100644
--- a/net/netfilter/xt_comment.c
+++ b/net/netfilter/xt_comment.c
@@ -33,6 +33,7 @@ static struct xt_match comment_match = {
.name = "comment",
.match = match,
.matchsize = sizeof(struct xt_comment_info),
+ .family = AF_INET,
.me = THIS_MODULE
};
@@ -40,6 +41,7 @@ static struct xt_match comment6_match = {
.name = "comment",
.match = match,
.matchsize = sizeof(struct xt_comment_info),
+ .family = AF_INET6,
.me = THIS_MODULE
};
@@ -47,21 +49,21 @@ static int __init init(void)
{
int ret;
- ret = xt_register_match(AF_INET, &comment_match);
+ ret = xt_register_match(&comment_match);
if (ret)
return ret;
- ret = xt_register_match(AF_INET6, &comment6_match);
+ ret = xt_register_match(&comment6_match);
if (ret)
- xt_unregister_match(AF_INET, &comment_match);
+ xt_unregister_match(&comment_match);
return ret;
}
static void __exit fini(void)
{
- xt_unregister_match(AF_INET, &comment_match);
- xt_unregister_match(AF_INET6, &comment6_match);
+ xt_unregister_match(&comment_match);
+ xt_unregister_match(&comment6_match);
}
module_init(init);
diff --git a/net/netfilter/xt_connbytes.c b/net/netfilter/xt_connbytes.c
index f34ecb9485c..4985f5ec58c 100644
--- a/net/netfilter/xt_connbytes.c
+++ b/net/netfilter/xt_connbytes.c
@@ -148,6 +148,7 @@ static struct xt_match connbytes_match = {
.match = match,
.checkentry = check,
.matchsize = sizeof(struct xt_connbytes_info),
+ .family = AF_INET,
.me = THIS_MODULE
};
static struct xt_match connbytes6_match = {
@@ -155,26 +156,27 @@ static struct xt_match connbytes6_match = {
.match = match,
.checkentry = check,
.matchsize = sizeof(struct xt_connbytes_info),
+ .family = AF_INET6,
.me = THIS_MODULE
};
static int __init init(void)
{
int ret;
- ret = xt_register_match(AF_INET, &connbytes_match);
+ ret = xt_register_match(&connbytes_match);
if (ret)
return ret;
- ret = xt_register_match(AF_INET6, &connbytes6_match);
+ ret = xt_register_match(&connbytes6_match);
if (ret)
- xt_unregister_match(AF_INET, &connbytes_match);
+ xt_unregister_match(&connbytes_match);
return ret;
}
static void __exit fini(void)
{
- xt_unregister_match(AF_INET, &connbytes_match);
- xt_unregister_match(AF_INET6, &connbytes6_match);
+ xt_unregister_match(&connbytes_match);
+ xt_unregister_match(&connbytes6_match);
}
module_init(init);
diff --git a/net/netfilter/xt_connmark.c b/net/netfilter/xt_connmark.c
index 51822471e91..7b16f1ee16b 100644
--- a/net/netfilter/xt_connmark.c
+++ b/net/netfilter/xt_connmark.c
@@ -64,14 +64,31 @@ checkentry(const char *tablename,
printk(KERN_WARNING "connmark: only support 32bit mark\n");
return 0;
}
+#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
+ if (nf_ct_l3proto_try_module_get(match->family) < 0) {
+ printk(KERN_WARNING "can't load nf_conntrack support for "
+ "proto=%d\n", match->family);
+ return 0;
+ }
+#endif
return 1;
}
+static void
+destroy(const struct xt_match *match, void *matchinfo, unsigned int matchsize)
+{
+#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
+ nf_ct_l3proto_module_put(match->family);
+#endif
+}
+
static struct xt_match connmark_match = {
.name = "connmark",
.match = match,
.matchsize = sizeof(struct xt_connmark_info),
.checkentry = checkentry,
+ .destroy = destroy,
+ .family = AF_INET,
.me = THIS_MODULE
};
@@ -80,6 +97,8 @@ static struct xt_match connmark6_match = {
.match = match,
.matchsize = sizeof(struct xt_connmark_info),
.checkentry = checkentry,
+ .destroy = destroy,
+ .family = AF_INET6,
.me = THIS_MODULE
};
@@ -89,20 +108,20 @@ static int __init init(void)
need_conntrack();
- ret = xt_register_match(AF_INET, &connmark_match);
+ ret = xt_register_match(&connmark_match);
if (ret)
return ret;
- ret = xt_register_match(AF_INET6, &connmark6_match);
+ ret = xt_register_match(&connmark6_match);
if (ret)
- xt_unregister_match(AF_INET, &connmark_match);
+ xt_unregister_match(&connmark_match);
return ret;
}
static void __exit fini(void)
{
- xt_unregister_match(AF_INET6, &connmark6_match);
- xt_unregister_match(AF_INET, &connmark_match);
+ xt_unregister_match(&connmark6_match);
+ xt_unregister_match(&connmark_match);
}
module_init(init);
diff --git a/net/netfilter/xt_conntrack.c b/net/netfilter/xt_conntrack.c
index 39fc29496e0..65a84809fd3 100644
--- a/net/netfilter/xt_conntrack.c
+++ b/net/netfilter/xt_conntrack.c
@@ -203,10 +203,39 @@ match(const struct sk_buff *skb,
#endif /* CONFIG_NF_IP_CONNTRACK */
+static int
+checkentry(const char *tablename,
+ const void *ip,
+ const struct xt_match *match,
+ void *matchinfo,
+ unsigned int matchsize,
+ unsigned int hook_mask)
+{
+#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
+ if (nf_ct_l3proto_try_module_get(match->family) < 0) {
+ printk(KERN_WARNING "can't load nf_conntrack support for "
+ "proto=%d\n", match->family);
+ return 0;
+ }
+#endif
+ return 1;
+}
+
+static void
+destroy(const struct xt_match *match, void *matchinfo, unsigned int matchsize)
+{
+#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
+ nf_ct_l3proto_module_put(match->family);
+#endif
+}
+
static struct xt_match conntrack_match = {
.name = "conntrack",
.match = match,
+ .checkentry = checkentry,
+ .destroy = destroy,
.matchsize = sizeof(struct xt_conntrack_info),
+ .family = AF_INET,
.me = THIS_MODULE,
};
@@ -214,14 +243,14 @@ static int __init init(void)
{
int ret;
need_conntrack();
- ret = xt_register_match(AF_INET, &conntrack_match);
+ ret = xt_register_match(&conntrack_match);
return ret;
}
static void __exit fini(void)
{
- xt_unregister_match(AF_INET, &conntrack_match);
+ xt_unregister_match(&conntrack_match);
}
module_init(init);
diff --git a/net/netfilter/xt_dccp.c b/net/netfilter/xt_dccp.c
index db6b70cdc77..2f331decd15 100644
--- a/net/netfilter/xt_dccp.c
+++ b/net/netfilter/xt_dccp.c
@@ -149,6 +149,7 @@ static struct xt_match dccp_match =
.matchsize = sizeof(struct xt_dccp_info),
.proto = IPPROTO_DCCP,
.checkentry = checkentry,
+ .family = AF_INET,
.me = THIS_MODULE,
};
static struct xt_match dccp6_match =
@@ -158,6 +159,7 @@ static struct xt_match dccp6_match =
.matchsize = sizeof(struct xt_dccp_info),
.proto = IPPROTO_DCCP,
.checkentry = checkentry,
+ .family = AF_INET6,
.me = THIS_MODULE,
};
@@ -172,17 +174,17 @@ static int __init init(void)
dccp_optbuf = kmalloc(256 * 4, GFP_KERNEL);
if (!dccp_optbuf)
return -ENOMEM;
- ret = xt_register_match(AF_INET, &dccp_match);
+ ret = xt_register_match(&dccp_match);
if (ret)
goto out_kfree;
- ret = xt_register_match(AF_INET6, &dccp6_match);
+ ret = xt_register_match(&dccp6_match);
if (ret)
goto out_unreg;
return ret;
out_unreg:
- xt_unregister_match(AF_INET, &dccp_match);
+ xt_unregister_match(&dccp_match);
out_kfree:
kfree(dccp_optbuf);
@@ -191,8 +193,8 @@ out_kfree:
static void __exit fini(void)
{
- xt_unregister_match(AF_INET6, &dccp6_match);
- xt_unregister_match(AF_INET, &dccp_match);
+ xt_unregister_match(&dccp6_match);
+ xt_unregister_match(&dccp_match);
kfree(dccp_optbuf);
}
diff --git a/net/netfilter/xt_helper.c b/net/netfilter/xt_helper.c
index ef8e54d40c9..101f0005e98 100644
--- a/net/netfilter/xt_helper.c
+++ b/net/netfilter/xt_helper.c
@@ -144,15 +144,32 @@ static int check(const char *tablename,
{
struct xt_helper_info *info = matchinfo;
+#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
+ if (nf_ct_l3proto_try_module_get(match->family) < 0) {
+ printk(KERN_WARNING "can't load nf_conntrack support for "
+ "proto=%d\n", match->family);
+ return 0;
+ }
+#endif
info->name[29] = '\0';
return 1;
}
+static void
+destroy(const struct xt_match *match, void *matchinfo, unsigned int matchsize)
+{
+#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
+ nf_ct_l3proto_module_put(match->family);
+#endif
+}
+
static struct xt_match helper_match = {
.name = "helper",
.match = match,
.matchsize = sizeof(struct xt_helper_info),
.checkentry = check,
+ .destroy = destroy,
+ .family = AF_INET,
.me = THIS_MODULE,
};
static struct xt_match helper6_match = {
@@ -160,6 +177,8 @@ static struct xt_match helper6_match = {
.match = match,
.matchsize = sizeof(struct xt_helper_info),
.checkentry = check,
+ .destroy = destroy,
+ .family = AF_INET6,
.me = THIS_MODULE,
};
@@ -168,21 +187,21 @@ static int __init init(void)
int ret;
need_conntrack();
- ret = xt_register_match(AF_INET, &helper_match);
+ ret = xt_register_match(&helper_match);
if (ret < 0)
return ret;
- ret = xt_register_match(AF_INET6, &helper6_match);
+ ret = xt_register_match(&helper6_match);
if (ret < 0)
- xt_unregister_match(AF_INET, &helper_match);
+ xt_unregister_match(&helper_match);
return ret;
}
static void __exit fini(void)
{
- xt_unregister_match(AF_INET, &helper_match);
- xt_unregister_match(AF_INET6, &helper6_match);
+ xt_unregister_match(&helper_match);
+ xt_unregister_match(&helper6_match);
}
module_init(init);
diff --git a/net/netfilter/xt_length.c b/net/netfilter/xt_length.c
index b9e60f041a6..38560caef75 100644
--- a/net/netfilter/xt_length.c
+++ b/net/netfilter/xt_length.c
@@ -56,6 +56,7 @@ static struct xt_match length_match = {
.name = "length",
.match = match,
.matchsize = sizeof(struct xt_length_info),
+ .family = AF_INET,
.me = THIS_MODULE,
};
@@ -63,26 +64,27 @@ static struct xt_match length6_match = {
.name = "length",
.match = match6,
.matchsize = sizeof(struct xt_length_info),
+ .family = AF_INET6,
.me = THIS_MODULE,
};
static int __init init(void)
{
int ret;
- ret = xt_register_match(AF_INET, &length_match);
+ ret = xt_register_match(&length_match);
if (ret)
return ret;
- ret = xt_register_match(AF_INET6, &length6_match);
+ ret = xt_register_match(&length6_match);
if (ret)
- xt_unregister_match(AF_INET, &length_match);
+ xt_unregister_match(&length_match);
return ret;
}
static void __exit fini(void)
{
- xt_unregister_match(AF_INET, &length_match);
- xt_unregister_match(AF_INET6, &length6_match);
+ xt_unregister_match(&length_match);
+ xt_unregister_match(&length6_match);
}
module_init(init);
diff --git a/net/netfilter/xt_limit.c b/net/netfilter/xt_limit.c
index 3049e6f8889..e91c1a444e7 100644
--- a/net/netfilter/xt_limit.c
+++ b/net/netfilter/xt_limit.c
@@ -141,6 +141,7 @@ static struct xt_match ipt_limit_reg = {
.match = ipt_limit_match,
.matchsize = sizeof(struct xt_rateinfo),
.checkentry = ipt_limit_checkentry,
+ .family = AF_INET,
.me = THIS_MODULE,
};
static struct xt_match limit6_reg = {
@@ -148,6 +149,7 @@ static struct xt_match limit6_reg = {
.match = ipt_limit_match,
.matchsize = sizeof(struct xt_rateinfo),
.checkentry = ipt_limit_checkentry,
+ .family = AF_INET6,
.me = THIS_MODULE,
};
@@ -155,21 +157,21 @@ static int __init init(void)
{
int ret;
- ret = xt_register_match(AF_INET, &ipt_limit_reg);
+ ret = xt_register_match(&ipt_limit_reg);
if (ret)
return ret;
- ret = xt_register_match(AF_INET6, &limit6_reg);
+ ret = xt_register_match(&limit6_reg);
if (ret)
- xt_unregister_match(AF_INET, &ipt_limit_reg);
+ xt_unregister_match(&ipt_limit_reg);
return ret;
}
static void __exit fini(void)
{
- xt_unregister_match(AF_INET, &ipt_limit_reg);
- xt_unregister_match(AF_INET6, &limit6_reg);
+ xt_unregister_match(&ipt_limit_reg);
+ xt_unregister_match(&limit6_reg);
}
module_init(init);
diff --git a/net/netfilter/xt_mac.c b/net/netfilter/xt_mac.c
index b4559a46dce..f4defa28a6e 100644
--- a/net/netfilter/xt_mac.c
+++ b/net/netfilter/xt_mac.c
@@ -49,6 +49,7 @@ static struct xt_match mac_match = {
.matchsize = sizeof(struct xt_mac_info),
.hooks = (1 << NF_IP_PRE_ROUTING) | (1 << NF_IP_LOCAL_IN) |
(1 << NF_IP_FORWARD),
+ .family = AF_INET,
.me = THIS_MODULE,
};
static struct xt_match mac6_match = {
@@ -57,27 +58,28 @@ static struct xt_match mac6_match = {
.matchsize = sizeof(struct xt_mac_info),
.hooks = (1 << NF_IP_PRE_ROUTING) | (1 << NF_IP_LOCAL_IN) |
(1 << NF_IP_FORWARD),
+ .family = AF_INET6,
.me = THIS_MODULE,
};
static int __init init(void)
{
int ret;
- ret = xt_register_match(AF_INET, &mac_match);
+ ret = xt_register_match(&mac_match);
if (ret)
return ret;
- ret = xt_register_match(AF_INET6, &mac6_match);
+ ret = xt_register_match(&mac6_match);
if (ret)
- xt_unregister_match(AF_INET, &mac_match);
+ xt_unregister_match(&mac_match);
return ret;
}
static void __exit fini(void)
{
- xt_unregister_match(AF_INET, &mac_match);
- xt_unregister_match(AF_INET6, &mac6_match);
+ xt_unregister_match(&mac_match);
+ xt_unregister_match(&mac6_match);
}
module_init(init);
diff --git a/net/netfilter/xt_mark.c b/net/netfilter/xt_mark.c
index c1a8f0f587f..ce0badfeef9 100644
--- a/net/netfilter/xt_mark.c
+++ b/net/netfilter/xt_mark.c
@@ -56,6 +56,7 @@ static struct xt_match mark_match = {
.match = match,
.matchsize = sizeof(struct xt_mark_info),
.checkentry = checkentry,
+ .family = AF_INET,
.me = THIS_MODULE,
};
@@ -64,27 +65,28 @@ static struct xt_match mark6_match = {
.match = match,
.matchsize = sizeof(struct xt_mark_info),
.checkentry = checkentry,
+ .family = AF_INET6,
.me = THIS_MODULE,
};
static int __init init(void)
{
int ret;
- ret = xt_register_match(AF_INET, &mark_match);
+ ret = xt_register_match(&mark_match);
if (ret)
return ret;
- ret = xt_register_match(AF_INET6, &mark6_match);
+ ret = xt_register_match(&mark6_match);
if (ret)
- xt_unregister_match(AF_INET, &mark_match);
+ xt_unregister_match(&mark_match);
return ret;
}
static void __exit fini(void)
{
- xt_unregister_match(AF_INET, &mark_match);
- xt_unregister_match(AF_INET6, &mark6_match);
+ xt_unregister_match(&mark_match);
+ xt_unregister_match(&mark6_match);
}
module_init(init);
diff --git a/net/netfilter/xt_physdev.c b/net/netfilter/xt_physdev.c
index f788e8e7625..089f4f7e863 100644
--- a/net/netfilter/xt_physdev.c
+++ b/net/netfilter/xt_physdev.c
@@ -121,6 +121,7 @@ static struct xt_match physdev_match = {
.match = match,
.matchsize = sizeof(struct xt_physdev_info),
.checkentry = checkentry,
+ .family = AF_INET,
.me = THIS_MODULE,
};
@@ -129,6 +130,7 @@ static struct xt_match physdev6_match = {
.match = match,
.matchsize = sizeof(struct xt_physdev_info),
.checkentry = checkentry,
+ .family = AF_INET6,
.me = THIS_MODULE,
};
@@ -136,21 +138,21 @@ static int __init init(void)
{
int ret;
- ret = xt_register_match(AF_INET, &physdev_match);
+ ret = xt_register_match(&physdev_match);
if (ret < 0)
return ret;
- ret = xt_register_match(AF_INET6, &physdev6_match);
+ ret = xt_register_match(&physdev6_match);
if (ret < 0)
- xt_unregister_match(AF_INET, &physdev_match);
+ xt_unregister_match(&physdev_match);
return ret;
}
static void __exit fini(void)
{
- xt_unregister_match(AF_INET, &physdev_match);
- xt_unregister_match(AF_INET6, &physdev6_match);
+ xt_unregister_match(&physdev_match);
+ xt_unregister_match(&physdev6_match);
}
module_init(init);
diff --git a/net/netfilter/xt_pkttype.c b/net/netfilter/xt_pkttype.c
index f38638dfd13..8b8bca988ac 100644
--- a/net/netfilter/xt_pkttype.c
+++ b/net/netfilter/xt_pkttype.c
@@ -37,6 +37,7 @@ static struct xt_match pkttype_match = {
.name = "pkttype",
.match = match,
.matchsize = sizeof(struct xt_pkttype_info),
+ .family = AF_INET,
.me = THIS_MODULE,
};
@@ -44,27 +45,28 @@ static struct xt_match pkttype6_match = {
.name = "pkttype",
.match = match,
.matchsize = sizeof(struct xt_pkttype_info),
+ .family = AF_INET6,
.me = THIS_MODULE,
};
static int __init init(void)
{
int ret;
- ret = xt_register_match(AF_INET, &pkttype_match);
+ ret = xt_register_match(&pkttype_match);
if (ret)
return ret;
- ret = xt_register_match(AF_INET6, &pkttype6_match);
+ ret = xt_register_match(&pkttype6_match);
if (ret)
- xt_unregister_match(AF_INET, &pkttype_match);
+ xt_unregister_match(&pkttype_match);
return ret;
}
static void __exit fini(void)
{
- xt_unregister_match(AF_INET, &pkttype_match);
- xt_unregister_match(AF_INET6, &pkttype6_match);
+ xt_unregister_match(&pkttype_match);
+ xt_unregister_match(&pkttype6_match);
}
module_init(init);
diff --git a/net/netfilter/xt_policy.c b/net/netfilter/xt_policy.c
index 1ec22082f04..1099cb005fc 100644
--- a/net/netfilter/xt_policy.c
+++ b/net/netfilter/xt_policy.c
@@ -27,9 +27,9 @@ xt_addr_cmp(const union xt_policy_addr *a1, const union xt_policy_addr *m,
{
switch (family) {
case AF_INET:
- return (a1->a4.s_addr ^ a2->a4.s_addr) & m->a4.s_addr;
+ return !((a1->a4.s_addr ^ a2->a4.s_addr) & m->a4.s_addr);
case AF_INET6:
- return ipv6_masked_addr_cmp(&a1->a6, &m->a6, &a2->a6);
+ return !ipv6_masked_addr_cmp(&a1->a6, &m->a6, &a2->a6);
}
return 0;
}
@@ -44,7 +44,7 @@ match_xfrm_state(struct xfrm_state *x, const struct xt_policy_elem *e,
#define MATCH(x,y) (!e->match.x || ((e->x == (y)) ^ e->invert.x))
return MATCH_ADDR(saddr, smask, (union xt_policy_addr *)&x->props.saddr) &&
- MATCH_ADDR(daddr, dmask, (union xt_policy_addr *)&x->id.daddr.a4) &&
+ MATCH_ADDR(daddr, dmask, (union xt_policy_addr *)&x->id.daddr) &&
MATCH(proto, x->id.proto) &&
MATCH(mode, x->props.mode) &&
MATCH(spi, x->id.spi) &&
@@ -172,6 +172,7 @@ static struct xt_match policy_match = {
.match = match,
.matchsize = sizeof(struct xt_policy_info),
.checkentry = checkentry,
+ .family = AF_INET,
.me = THIS_MODULE,
};
@@ -181,6 +182,7 @@ static struct xt_match policy6_match = {
.match = match,
.matchsize = sizeof(struct xt_policy_info),
.checkentry = checkentry,
+ .family = AF_INET6,
.me = THIS_MODULE,
};
@@ -188,19 +190,19 @@ static int __init init(void)
{
int ret;
- ret = xt_register_match(AF_INET, &policy_match);
+ ret = xt_register_match(&policy_match);
if (ret)
return ret;
- ret = xt_register_match(AF_INET6, &policy6_match);
+ ret = xt_register_match(&policy6_match);
if (ret)
- xt_unregister_match(AF_INET, &policy_match);
+ xt_unregister_match(&policy_match);
return ret;
}
static void __exit fini(void)
{
- xt_unregister_match(AF_INET6, &policy6_match);
- xt_unregister_match(AF_INET, &policy_match);
+ xt_unregister_match(&policy6_match);
+ xt_unregister_match(&policy_match);
}
module_init(init);
diff --git a/net/netfilter/xt_realm.c b/net/netfilter/xt_realm.c
index 57815a07db6..5e31a4a835b 100644
--- a/net/netfilter/xt_realm.c
+++ b/net/netfilter/xt_realm.c
@@ -45,17 +45,18 @@ static struct xt_match realm_match = {
.matchsize = sizeof(struct xt_realm_info),
.hooks = (1 << NF_IP_POST_ROUTING) | (1 << NF_IP_FORWARD) |
(1 << NF_IP_LOCAL_OUT) | (1 << NF_IP_LOCAL_IN),
+ .family = AF_INET,
.me = THIS_MODULE
};
static int __init init(void)
{
- return xt_register_match(AF_INET, &realm_match);
+ return xt_register_match(&realm_match);
}
static void __exit fini(void)
{
- xt_unregister_match(AF_INET, &realm_match);
+ xt_unregister_match(&realm_match);
}
module_init(init);
diff --git a/net/netfilter/xt_sctp.c b/net/netfilter/xt_sctp.c
index f5d698ba03c..c6eb24a2fe1 100644
--- a/net/netfilter/xt_sctp.c
+++ b/net/netfilter/xt_sctp.c
@@ -186,6 +186,7 @@ static struct xt_match sctp_match = {
.matchsize = sizeof(struct xt_sctp_info),
.proto = IPPROTO_SCTP,
.checkentry = checkentry,
+ .family = AF_INET,
.me = THIS_MODULE
};
@@ -195,27 +196,28 @@ static struct xt_match sctp6_match = {
.matchsize = sizeof(struct xt_sctp_info),
.proto = IPPROTO_SCTP,
.checkentry = checkentry,
+ .family = AF_INET6,
.me = THIS_MODULE
};
static int __init init(void)
{
int ret;
- ret = xt_register_match(AF_INET, &sctp_match);
+ ret = xt_register_match(&sctp_match);
if (ret)
return ret;
- ret = xt_register_match(AF_INET6, &sctp6_match);
+ ret = xt_register_match(&sctp6_match);
if (ret)
- xt_unregister_match(AF_INET, &sctp_match);
+ xt_unregister_match(&sctp_match);
return ret;
}
static void __exit fini(void)
{
- xt_unregister_match(AF_INET6, &sctp6_match);
- xt_unregister_match(AF_INET, &sctp_match);
+ xt_unregister_match(&sctp6_match);
+ xt_unregister_match(&sctp_match);
}
module_init(init);
diff --git a/net/netfilter/xt_state.c b/net/netfilter/xt_state.c
index b8ec00cd51f..e6c0be9d94d 100644
--- a/net/netfilter/xt_state.c
+++ b/net/netfilter/xt_state.c
@@ -44,17 +44,48 @@ match(const struct sk_buff *skb,
return (sinfo->statemask & statebit);
}
+static int check(const char *tablename,
+ const void *inf,
+ const struct xt_match *match,
+ void *matchinfo,
+ unsigned int matchsize,
+ unsigned int hook_mask)
+{
+#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
+ if (nf_ct_l3proto_try_module_get(match->family) < 0) {
+ printk(KERN_WARNING "can't load nf_conntrack support for "
+ "proto=%d\n", match->family);
+ return 0;
+ }
+#endif
+ return 1;
+}
+
+static void
+destroy(const struct xt_match *match, void *matchinfo, unsigned int matchsize)
+{
+#if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
+ nf_ct_l3proto_module_put(match->family);
+#endif
+}
+
static struct xt_match state_match = {
.name = "state",
.match = match,
+ .checkentry = check,
+ .destroy = destroy,
.matchsize = sizeof(struct xt_state_info),
+ .family = AF_INET,
.me = THIS_MODULE,
};
static struct xt_match state6_match = {
.name = "state",
.match = match,
+ .checkentry = check,
+ .destroy = destroy,
.matchsize = sizeof(struct xt_state_info),
+ .family = AF_INET6,
.me = THIS_MODULE,
};
@@ -64,21 +95,21 @@ static int __init init(void)
need_conntrack();
- ret = xt_register_match(AF_INET, &state_match);
+ ret = xt_register_match(&state_match);
if (ret < 0)
return ret;
- ret = xt_register_match(AF_INET6, &state6_match);
+ ret = xt_register_match(&state6_match);
if (ret < 0)
- xt_unregister_match(AF_INET,&state_match);
+ xt_unregister_match(&state_match);
return ret;
}
static void __exit fini(void)
{
- xt_unregister_match(AF_INET, &state_match);
- xt_unregister_match(AF_INET6, &state6_match);
+ xt_unregister_match(&state_match);
+ xt_unregister_match(&state6_match);
}
module_init(init);
diff --git a/net/netfilter/xt_string.c b/net/netfilter/xt_string.c
index fccbad6a7f4..703d80fccac 100644
--- a/net/netfilter/xt_string.c
+++ b/net/netfilter/xt_string.c
@@ -78,6 +78,7 @@ static struct xt_match string_match = {
.matchsize = sizeof(struct xt_string_info),
.checkentry = checkentry,
.destroy = destroy,
+ .family = AF_INET,
.me = THIS_MODULE
};
static struct xt_match string6_match = {
@@ -86,6 +87,7 @@ static struct xt_match string6_match = {
.matchsize = sizeof(struct xt_string_info),
.checkentry = checkentry,
.destroy = destroy,
+ .family = AF_INET6,
.me = THIS_MODULE
};
@@ -93,20 +95,20 @@ static int __init init(void)
{
int ret;
- ret = xt_register_match(AF_INET, &string_match);
+ ret = xt_register_match(&string_match);
if (ret)
return ret;
- ret = xt_register_match(AF_INET6, &string6_match);
+ ret = xt_register_match(&string6_match);
if (ret)
- xt_unregister_match(AF_INET, &string_match);
+ xt_unregister_match(&string_match);
return ret;
}
static void __exit fini(void)
{
- xt_unregister_match(AF_INET, &string_match);
- xt_unregister_match(AF_INET6, &string6_match);
+ xt_unregister_match(&string_match);
+ xt_unregister_match(&string6_match);
}
module_init(init);
diff --git a/net/netfilter/xt_tcpmss.c b/net/netfilter/xt_tcpmss.c
index 4925fc98f4a..70a8858ae3f 100644
--- a/net/netfilter/xt_tcpmss.c
+++ b/net/netfilter/xt_tcpmss.c
@@ -98,6 +98,7 @@ static struct xt_match tcpmss_match = {
.match = match,
.matchsize = sizeof(struct xt_tcpmss_match_info),
.proto = IPPROTO_TCP,
+ .family = AF_INET,
.me = THIS_MODULE,
};
@@ -106,6 +107,7 @@ static struct xt_match tcpmss6_match = {
.match = match,
.matchsize = sizeof(struct xt_tcpmss_match_info),
.proto = IPPROTO_TCP,
+ .family = AF_INET6,
.me = THIS_MODULE,
};
@@ -113,21 +115,21 @@ static struct xt_match tcpmss6_match = {
static int __init init(void)
{
int ret;
- ret = xt_register_match(AF_INET, &tcpmss_match);
+ ret = xt_register_match(&tcpmss_match);
if (ret)
return ret;
- ret = xt_register_match(AF_INET6, &tcpmss6_match);
+ ret = xt_register_match(&tcpmss6_match);
if (ret)
- xt_unregister_match(AF_INET, &tcpmss_match);
+ xt_unregister_match(&tcpmss_match);
return ret;
}
static void __exit fini(void)
{
- xt_unregister_match(AF_INET6, &tcpmss6_match);
- xt_unregister_match(AF_INET, &tcpmss_match);
+ xt_unregister_match(&tcpmss6_match);
+ xt_unregister_match(&tcpmss_match);
}
module_init(init);
diff --git a/net/netfilter/xt_tcpudp.c b/net/netfilter/xt_tcpudp.c
index b5cd0dd4e41..14a990eb666 100644
--- a/net/netfilter/xt_tcpudp.c
+++ b/net/netfilter/xt_tcpudp.c
@@ -204,6 +204,7 @@ static struct xt_match tcp_matchstruct = {
.match = tcp_match,
.matchsize = sizeof(struct xt_tcp),
.proto = IPPROTO_TCP,
+ .family = AF_INET,
.checkentry = tcp_checkentry,
.me = THIS_MODULE,
};
@@ -213,6 +214,7 @@ static struct xt_match tcp6_matchstruct = {
.match = tcp_match,
.matchsize = sizeof(struct xt_tcp),
.proto = IPPROTO_TCP,
+ .family = AF_INET6,
.checkentry = tcp_checkentry,
.me = THIS_MODULE,
};
@@ -222,6 +224,7 @@ static struct xt_match udp_matchstruct = {
.match = udp_match,
.matchsize = sizeof(struct xt_udp),
.proto = IPPROTO_UDP,
+ .family = AF_INET,
.checkentry = udp_checkentry,
.me = THIS_MODULE,
};
@@ -230,6 +233,7 @@ static struct xt_match udp6_matchstruct = {
.match = udp_match,
.matchsize = sizeof(struct xt_udp),
.proto = IPPROTO_UDP,
+ .family = AF_INET6,
.checkentry = udp_checkentry,
.me = THIS_MODULE,
};
@@ -237,39 +241,39 @@ static struct xt_match udp6_matchstruct = {
static int __init init(void)
{
int ret;
- ret = xt_register_match(AF_INET, &tcp_matchstruct);
+ ret = xt_register_match(&tcp_matchstruct);
if (ret)
return ret;
- ret = xt_register_match(AF_INET6, &tcp6_matchstruct);
+ ret = xt_register_match(&tcp6_matchstruct);
if (ret)
goto out_unreg_tcp;
- ret = xt_register_match(AF_INET, &udp_matchstruct);
+ ret = xt_register_match(&udp_matchstruct);
if (ret)
goto out_unreg_tcp6;
- ret = xt_register_match(AF_INET6, &udp6_matchstruct);
+ ret = xt_register_match(&udp6_matchstruct);
if (ret)
goto out_unreg_udp;
return ret;
out_unreg_udp:
- xt_unregister_match(AF_INET, &tcp_matchstruct);
+ xt_unregister_match(&tcp_matchstruct);
out_unreg_tcp6:
- xt_unregister_match(AF_INET6, &tcp6_matchstruct);
+ xt_unregister_match(&tcp6_matchstruct);
out_unreg_tcp:
- xt_unregister_match(AF_INET, &tcp_matchstruct);
+ xt_unregister_match(&tcp_matchstruct);
return ret;
}
static void __exit fini(void)
{
- xt_unregister_match(AF_INET6, &udp6_matchstruct);
- xt_unregister_match(AF_INET, &udp_matchstruct);
- xt_unregister_match(AF_INET6, &tcp6_matchstruct);
- xt_unregister_match(AF_INET, &tcp_matchstruct);
+ xt_unregister_match(&udp6_matchstruct);
+ xt_unregister_match(&udp_matchstruct);
+ xt_unregister_match(&tcp6_matchstruct);
+ xt_unregister_match(&tcp_matchstruct);
}
module_init(init);
diff --git a/net/socket.c b/net/socket.c
index e3c21d5ec28..e2d5bae994d 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -107,6 +107,10 @@ static unsigned int sock_poll(struct file *file,
struct poll_table_struct *wait);
static long sock_ioctl(struct file *file,
unsigned int cmd, unsigned long arg);
+#ifdef CONFIG_COMPAT
+static long compat_sock_ioctl(struct file *file,
+ unsigned int cmd, unsigned long arg);
+#endif
static int sock_fasync(int fd, struct file *filp, int on);
static ssize_t sock_readv(struct file *file, const struct iovec *vector,
unsigned long count, loff_t *ppos);
@@ -128,6 +132,9 @@ static struct file_operations socket_file_ops = {
.aio_write = sock_aio_write,
.poll = sock_poll,
.unlocked_ioctl = sock_ioctl,
+#ifdef CONFIG_COMPAT
+ .compat_ioctl = compat_sock_ioctl,
+#endif
.mmap = sock_mmap,
.open = sock_no_open, /* special open code to disallow open via /proc */
.release = sock_close,
@@ -2136,6 +2143,20 @@ void socket_seq_show(struct seq_file *seq)
}
#endif /* CONFIG_PROC_FS */
+#ifdef CONFIG_COMPAT
+static long compat_sock_ioctl(struct file *file, unsigned cmd,
+ unsigned long arg)
+{
+ struct socket *sock = file->private_data;
+ int ret = -ENOIOCTLCMD;
+
+ if (sock->ops->compat_ioctl)
+ ret = sock->ops->compat_ioctl(sock, cmd, arg);
+
+ return ret;
+}
+#endif
+
/* ABI emulation layers need these two */
EXPORT_SYMBOL(move_addr_to_kernel);
EXPORT_SYMBOL(move_addr_to_user);
diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c
index 72b6ff3299b..282ce4e40d7 100644
--- a/net/x25/af_x25.c
+++ b/net/x25/af_x25.c
@@ -54,7 +54,10 @@
#include <linux/termios.h> /* For TIOCINQ/OUTQ */
#include <linux/notifier.h>
#include <linux/init.h>
+#include <linux/compat.h>
+
#include <net/x25.h>
+#include <net/compat.h>
int sysctl_x25_restart_request_timeout = X25_DEFAULT_T20;
int sysctl_x25_call_request_timeout = X25_DEFAULT_T21;
@@ -69,6 +72,14 @@ static const struct proto_ops x25_proto_ops;
static struct x25_address null_x25_address = {" "};
+#ifdef CONFIG_COMPAT
+struct compat_x25_subscrip_struct {
+ char device[200-sizeof(compat_ulong_t)];
+ compat_ulong_t global_facil_mask;
+ compat_uint_t extended;
+};
+#endif
+
int x25_addr_ntoa(unsigned char *p, struct x25_address *called_addr,
struct x25_address *calling_addr)
{
@@ -514,6 +525,13 @@ static int x25_create(struct socket *sock, int protocol)
x25->facilities.pacsize_out = X25_DEFAULT_PACKET_SIZE;
x25->facilities.throughput = X25_DEFAULT_THROUGHPUT;
x25->facilities.reverse = X25_DEFAULT_REVERSE;
+ x25->dte_facilities.calling_len = 0;
+ x25->dte_facilities.called_len = 0;
+ memset(x25->dte_facilities.called_ae, '\0',
+ sizeof(x25->dte_facilities.called_ae));
+ memset(x25->dte_facilities.calling_ae, '\0',
+ sizeof(x25->dte_facilities.calling_ae));
+
rc = 0;
out:
return rc;
@@ -550,6 +568,7 @@ static struct sock *x25_make_new(struct sock *osk)
x25->t2 = ox25->t2;
x25->facilities = ox25->facilities;
x25->qbitincl = ox25->qbitincl;
+ x25->dte_facilities = ox25->dte_facilities;
x25->cudmatchlength = ox25->cudmatchlength;
x25->accptapprv = ox25->accptapprv;
@@ -733,7 +752,7 @@ out:
return rc;
}
-static int x25_wait_for_data(struct sock *sk, int timeout)
+static int x25_wait_for_data(struct sock *sk, long timeout)
{
DECLARE_WAITQUEUE(wait, current);
int rc = 0;
@@ -829,6 +848,7 @@ int x25_rx_call_request(struct sk_buff *skb, struct x25_neigh *nb,
struct x25_sock *makex25;
struct x25_address source_addr, dest_addr;
struct x25_facilities facilities;
+ struct x25_dte_facilities dte_facilities;
int len, rc;
/*
@@ -865,7 +885,8 @@ int x25_rx_call_request(struct sk_buff *skb, struct x25_neigh *nb,
/*
* Try to reach a compromise on the requested facilities.
*/
- if ((len = x25_negotiate_facilities(skb, sk, &facilities)) == -1)
+ len = x25_negotiate_facilities(skb, sk, &facilities, &dte_facilities);
+ if (len == -1)
goto out_sock_put;
/*
@@ -896,9 +917,12 @@ int x25_rx_call_request(struct sk_buff *skb, struct x25_neigh *nb,
makex25->source_addr = source_addr;
makex25->neighbour = nb;
makex25->facilities = facilities;
+ makex25->dte_facilities= dte_facilities;
makex25->vc_facil_mask = x25_sk(sk)->vc_facil_mask;
/* ensure no reverse facil on accept */
makex25->vc_facil_mask &= ~X25_MASK_REVERSE;
+ /* ensure no calling address extension on accept */
+ makex25->vc_facil_mask &= ~X25_MASK_CALLING_AE;
makex25->cudmatchlength = x25_sk(sk)->cudmatchlength;
/* Normally all calls are accepted immediatly */
@@ -1305,6 +1329,36 @@ static int x25_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg)
break;
}
+ case SIOCX25GDTEFACILITIES: {
+ rc = copy_to_user(argp, &x25->dte_facilities,
+ sizeof(x25->dte_facilities));
+ if (rc)
+ rc = -EFAULT;
+ break;
+ }
+
+ case SIOCX25SDTEFACILITIES: {
+ struct x25_dte_facilities dtefacs;
+ rc = -EFAULT;
+ if (copy_from_user(&dtefacs, argp, sizeof(dtefacs)))
+ break;
+ rc = -EINVAL;
+ if (sk->sk_state != TCP_LISTEN &&
+ sk->sk_state != TCP_CLOSE)
+ break;
+ if (dtefacs.calling_len > X25_MAX_AE_LEN)
+ break;
+ if (dtefacs.calling_ae == NULL)
+ break;
+ if (dtefacs.called_len > X25_MAX_AE_LEN)
+ break;
+ if (dtefacs.called_ae == NULL)
+ break;
+ x25->dte_facilities = dtefacs;
+ rc = 0;
+ break;
+ }
+
case SIOCX25GCALLUSERDATA: {
struct x25_calluserdata cud = x25->calluserdata;
rc = copy_to_user(argp, &cud,
@@ -1387,6 +1441,118 @@ static struct net_proto_family x25_family_ops = {
.owner = THIS_MODULE,
};
+#ifdef CONFIG_COMPAT
+static int compat_x25_subscr_ioctl(unsigned int cmd,
+ struct compat_x25_subscrip_struct __user *x25_subscr32)
+{
+ struct compat_x25_subscrip_struct x25_subscr;
+ struct x25_neigh *nb;
+ struct net_device *dev;
+ int rc = -EINVAL;
+
+ rc = -EFAULT;
+ if (copy_from_user(&x25_subscr, x25_subscr32, sizeof(*x25_subscr32)))
+ goto out;
+
+ rc = -EINVAL;
+ dev = x25_dev_get(x25_subscr.device);
+ if (dev == NULL)
+ goto out;
+
+ nb = x25_get_neigh(dev);
+ if (nb == NULL)
+ goto out_dev_put;
+
+ dev_put(dev);
+
+ if (cmd == SIOCX25GSUBSCRIP) {
+ x25_subscr.extended = nb->extended;
+ x25_subscr.global_facil_mask = nb->global_facil_mask;
+ rc = copy_to_user(x25_subscr32, &x25_subscr,
+ sizeof(*x25_subscr32)) ? -EFAULT : 0;
+ } else {
+ rc = -EINVAL;
+ if (x25_subscr.extended == 0 || x25_subscr.extended == 1) {
+ rc = 0;
+ nb->extended = x25_subscr.extended;
+ nb->global_facil_mask = x25_subscr.global_facil_mask;
+ }
+ }
+ x25_neigh_put(nb);
+out:
+ return rc;
+out_dev_put:
+ dev_put(dev);
+ goto out;
+}
+
+static int compat_x25_ioctl(struct socket *sock, unsigned int cmd,
+ unsigned long arg)
+{
+ void __user *argp = compat_ptr(arg);
+ struct sock *sk = sock->sk;
+
+ int rc = -ENOIOCTLCMD;
+
+ switch(cmd) {
+ case TIOCOUTQ:
+ case TIOCINQ:
+ rc = x25_ioctl(sock, cmd, (unsigned long)argp);
+ break;
+ case SIOCGSTAMP:
+ rc = -EINVAL;
+ if (sk)
+ rc = compat_sock_get_timestamp(sk,
+ (struct timeval __user*)argp);
+ break;
+ case SIOCGIFADDR:
+ case SIOCSIFADDR:
+ case SIOCGIFDSTADDR:
+ case SIOCSIFDSTADDR:
+ case SIOCGIFBRDADDR:
+ case SIOCSIFBRDADDR:
+ case SIOCGIFNETMASK:
+ case SIOCSIFNETMASK:
+ case SIOCGIFMETRIC:
+ case SIOCSIFMETRIC:
+ rc = -EINVAL;
+ break;
+ case SIOCADDRT:
+ case SIOCDELRT:
+ rc = -EPERM;
+ if (!capable(CAP_NET_ADMIN))
+ break;
+ rc = x25_route_ioctl(cmd, argp);
+ break;
+ case SIOCX25GSUBSCRIP:
+ rc = compat_x25_subscr_ioctl(cmd, argp);
+ break;
+ case SIOCX25SSUBSCRIP:
+ rc = -EPERM;
+ if (!capable(CAP_NET_ADMIN))
+ break;
+ rc = compat_x25_subscr_ioctl(cmd, argp);
+ break;
+ case SIOCX25GFACILITIES:
+ case SIOCX25SFACILITIES:
+ case SIOCX25GDTEFACILITIES:
+ case SIOCX25SDTEFACILITIES:
+ case SIOCX25GCALLUSERDATA:
+ case SIOCX25SCALLUSERDATA:
+ case SIOCX25GCAUSEDIAG:
+ case SIOCX25SCUDMATCHLEN:
+ case SIOCX25CALLACCPTAPPRV:
+ case SIOCX25SENDCALLACCPT:
+ rc = x25_ioctl(sock, cmd, (unsigned long)argp);
+ break;
+ default:
+ rc = -ENOIOCTLCMD;
+ break;
+ }
+ return rc;
+}
+#endif
+
static const struct proto_ops SOCKOPS_WRAPPED(x25_proto_ops) = {
.family = AF_X25,
.owner = THIS_MODULE,
@@ -1398,6 +1564,9 @@ static const struct proto_ops SOCKOPS_WRAPPED(x25_proto_ops) = {
.getname = x25_getname,
.poll = datagram_poll,
.ioctl = x25_ioctl,
+#ifdef CONFIG_COMPAT
+ .compat_ioctl = compat_x25_ioctl,
+#endif
.listen = x25_listen,
.shutdown = sock_no_shutdown,
.setsockopt = x25_setsockopt,
diff --git a/net/x25/x25_facilities.c b/net/x25/x25_facilities.c
index 54278b962f4..9f42b9c9de3 100644
--- a/net/x25/x25_facilities.c
+++ b/net/x25/x25_facilities.c
@@ -28,18 +28,28 @@
#include <net/x25.h>
/*
- * Parse a set of facilities into the facilities structure. Unrecognised
+ * Parse a set of facilities into the facilities structures. Unrecognised
* facilities are written to the debug log file.
*/
-int x25_parse_facilities(struct sk_buff *skb,
- struct x25_facilities *facilities,
- unsigned long *vc_fac_mask)
+int x25_parse_facilities(struct sk_buff *skb, struct x25_facilities *facilities,
+ struct x25_dte_facilities *dte_facs, unsigned long *vc_fac_mask)
{
unsigned char *p = skb->data;
unsigned int len = *p++;
*vc_fac_mask = 0;
+ /*
+ * The kernel knows which facilities were set on an incoming call but
+ * currently this information is not available to userspace. Here we
+ * give userspace who read incoming call facilities 0 length to indicate
+ * it wasn't set.
+ */
+ dte_facs->calling_len = 0;
+ dte_facs->called_len = 0;
+ memset(dte_facs->called_ae, '\0', sizeof(dte_facs->called_ae));
+ memset(dte_facs->calling_ae, '\0', sizeof(dte_facs->calling_ae));
+
while (len > 0) {
switch (*p & X25_FAC_CLASS_MASK) {
case X25_FAC_CLASS_A:
@@ -74,6 +84,8 @@ int x25_parse_facilities(struct sk_buff *skb,
facilities->throughput = p[1];
*vc_fac_mask |= X25_MASK_THROUGHPUT;
break;
+ case X25_MARKER:
+ break;
default:
printk(KERN_DEBUG "X.25: unknown facility "
"%02X, value %02X\n",
@@ -112,11 +124,30 @@ int x25_parse_facilities(struct sk_buff *skb,
len -= 4;
break;
case X25_FAC_CLASS_D:
- printk(KERN_DEBUG "X.25: unknown facility %02X, "
- "length %d, values %02X, %02X, %02X, %02X\n",
- p[0], p[1], p[2], p[3], p[4], p[5]);
+ switch (*p) {
+ case X25_FAC_CALLING_AE:
+ if (p[1] > X25_MAX_DTE_FACIL_LEN)
+ break;
+ dte_facs->calling_len = p[2];
+ memcpy(dte_facs->calling_ae, &p[3], p[1] - 1);
+ *vc_fac_mask |= X25_MASK_CALLING_AE;
+ break;
+ case X25_FAC_CALLED_AE:
+ if (p[1] > X25_MAX_DTE_FACIL_LEN)
+ break;
+ dte_facs->called_len = p[2];
+ memcpy(dte_facs->called_ae, &p[3], p[1] - 1);
+ *vc_fac_mask |= X25_MASK_CALLED_AE;
+ break;
+ default:
+ printk(KERN_DEBUG "X.25: unknown facility %02X,"
+ "length %d, values %02X, %02X, "
+ "%02X, %02X\n",
+ p[0], p[1], p[2], p[3], p[4], p[5]);
+ break;
+ }
len -= p[1] + 2;
- p += p[1] + 2;
+ p += p[1] + 2;
break;
}
}
@@ -128,8 +159,8 @@ int x25_parse_facilities(struct sk_buff *skb,
* Create a set of facilities.
*/
int x25_create_facilities(unsigned char *buffer,
- struct x25_facilities *facilities,
- unsigned long facil_mask)
+ struct x25_facilities *facilities,
+ struct x25_dte_facilities *dte_facs, unsigned long facil_mask)
{
unsigned char *p = buffer + 1;
int len;
@@ -168,6 +199,33 @@ int x25_create_facilities(unsigned char *buffer,
*p++ = facilities->winsize_out ? : facilities->winsize_in;
}
+ if (facil_mask & (X25_MASK_CALLING_AE|X25_MASK_CALLED_AE)) {
+ *p++ = X25_MARKER;
+ *p++ = X25_DTE_SERVICES;
+ }
+
+ if (dte_facs->calling_len && (facil_mask & X25_MASK_CALLING_AE)) {
+ unsigned bytecount = (dte_facs->calling_len % 2) ?
+ dte_facs->calling_len / 2 + 1 :
+ dte_facs->calling_len / 2;
+ *p++ = X25_FAC_CALLING_AE;
+ *p++ = 1 + bytecount;
+ *p++ = dte_facs->calling_len;
+ memcpy(p, dte_facs->calling_ae, bytecount);
+ p += bytecount;
+ }
+
+ if (dte_facs->called_len && (facil_mask & X25_MASK_CALLED_AE)) {
+ unsigned bytecount = (dte_facs->called_len % 2) ?
+ dte_facs->called_len / 2 + 1 :
+ dte_facs->called_len / 2;
+ *p++ = X25_FAC_CALLED_AE;
+ *p++ = 1 + bytecount;
+ *p++ = dte_facs->called_len;
+ memcpy(p, dte_facs->called_ae, bytecount);
+ p+=bytecount;
+ }
+
len = p - buffer;
buffer[0] = len - 1;
@@ -180,7 +238,7 @@ int x25_create_facilities(unsigned char *buffer,
* The only real problem is with reverse charging.
*/
int x25_negotiate_facilities(struct sk_buff *skb, struct sock *sk,
- struct x25_facilities *new)
+ struct x25_facilities *new, struct x25_dte_facilities *dte)
{
struct x25_sock *x25 = x25_sk(sk);
struct x25_facilities *ours = &x25->facilities;
@@ -190,7 +248,7 @@ int x25_negotiate_facilities(struct sk_buff *skb, struct sock *sk,
memset(&theirs, 0, sizeof(theirs));
memcpy(new, ours, sizeof(*new));
- len = x25_parse_facilities(skb, &theirs, &x25->vc_facil_mask);
+ len = x25_parse_facilities(skb, &theirs, dte, &x25->vc_facil_mask);
/*
* They want reverse charging, we won't accept it.
diff --git a/net/x25/x25_in.c b/net/x25/x25_in.c
index 26146874b83..eed50e10f09 100644
--- a/net/x25/x25_in.c
+++ b/net/x25/x25_in.c
@@ -106,7 +106,8 @@ static int x25_state1_machine(struct sock *sk, struct sk_buff *skb, int frametyp
skb_pull(skb, x25_addr_ntoa(skb->data, &source_addr, &dest_addr));
skb_pull(skb,
x25_parse_facilities(skb, &x25->facilities,
- &x25->vc_facil_mask));
+ &x25->dte_facilities,
+ &x25->vc_facil_mask));
/*
* Copy any Call User Data.
*/
diff --git a/net/x25/x25_subr.c b/net/x25/x25_subr.c
index 8be9b8fbc24..8d6220aa5d0 100644
--- a/net/x25/x25_subr.c
+++ b/net/x25/x25_subr.c
@@ -190,8 +190,9 @@ void x25_write_internal(struct sock *sk, int frametype)
dptr = skb_put(skb, len);
memcpy(dptr, addresses, len);
len = x25_create_facilities(facilities,
- &x25->facilities,
- x25->neighbour->global_facil_mask);
+ &x25->facilities,
+ &x25->dte_facilities,
+ x25->neighbour->global_facil_mask);
dptr = skb_put(skb, len);
memcpy(dptr, facilities, len);
dptr = skb_put(skb, x25->calluserdata.cudlength);
@@ -206,6 +207,7 @@ void x25_write_internal(struct sock *sk, int frametype)
*dptr++ = 0x00; /* Address lengths */
len = x25_create_facilities(facilities,
&x25->facilities,
+ &x25->dte_facilities,
x25->vc_facil_mask);
dptr = skb_put(skb, len);
memcpy(dptr, facilities, len);