From: Hans Schillstrom <hans.schillstrom@ericsson.com>
To: <horms@verge.net.au>, <ja@ssi.bg>, <daniel.lezcano@free.fr>,
<wensong@linux-vs.org>, <lvs-devel@vger.kernel.org>,
<netdev@vger.kernel.org>, <netfilter-devel@vger.kernel.org>
Cc: <hans@schillstrom.com>, Hans Schillstrom <hans.schillstrom@ericsson.com>
Subject: [*v2 PATCH 05/22] IPVS: netns, prepare protocol
Date: Mon, 13 Dec 2010 14:38:13 +0100 [thread overview]
Message-ID: <1292247510-753-6-git-send-email-hans.schillstrom@ericsson.com> (raw)
In-Reply-To: <1292247510-753-1-git-send-email-hans.schillstrom@ericsson.com>
Add support for protocol data per name-space.
in struct ip_vs_protocol, appcnt will be removed when all protos
are modified for network name-space.
This patch causes warnings of unused functions, they will be used
when next patch will be applied.
Signed-off-by: Hans Schillstrom <hans.schillstrom@ericsson.com>
---
include/net/ip_vs.h | 20 +++++++++++-
include/net/netns/ip_vs.h | 3 ++
net/netfilter/ipvs/ip_vs_proto.c | 66 ++++++++++++++++++++++++++++++++++++++
3 files changed, 88 insertions(+), 1 deletions(-)
diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
index 7532eef..528c5e8 100644
--- a/include/net/ip_vs.h
+++ b/include/net/ip_vs.h
@@ -353,6 +353,7 @@ struct iphdr;
struct ip_vs_conn;
struct ip_vs_app;
struct sk_buff;
+struct ip_vs_proto_data;
struct ip_vs_protocol {
struct ip_vs_protocol *next;
@@ -367,6 +368,10 @@ struct ip_vs_protocol {
void (*exit)(struct ip_vs_protocol *pp);
+ void (*init_netns)(struct net *net, struct ip_vs_proto_data *pd);
+
+ void (*exit_netns)(struct net *net, struct ip_vs_proto_data *pd);
+
int (*conn_schedule)(int af, struct sk_buff *skb,
struct ip_vs_protocol *pp,
int *verdict, struct ip_vs_conn **cpp);
@@ -418,7 +423,20 @@ struct ip_vs_protocol {
int (*set_state_timeout)(struct ip_vs_protocol *pp, char *sname, int to);
};
-extern struct ip_vs_protocol * ip_vs_proto_get(unsigned short proto);
+/*
+ * protocol data per netns
+ */
+struct ip_vs_proto_data {
+ struct ip_vs_proto_data *next;
+ struct ip_vs_protocol *pp;
+ int *timeout_table; /* protocol timeout table */
+ atomic_t appcnt; /* counter of proto app incs. */
+ struct tcp_states_t *tcp_state_table;
+};
+
+extern struct ip_vs_protocol * ip_vs_proto_get(unsigned short proto);
+extern struct ip_vs_proto_data * ip_vs_proto_data_get(struct net *net,
+ unsigned short proto);
struct ip_vs_conn_param {
const union nf_inet_addr *caddr;
diff --git a/include/net/netns/ip_vs.h b/include/net/netns/ip_vs.h
index 4c8d751..b7d7815 100644
--- a/include/net/netns/ip_vs.h
+++ b/include/net/netns/ip_vs.h
@@ -29,6 +29,9 @@ struct netns_ipvs {
#define IP_VS_RTAB_MASK (IP_VS_RTAB_SIZE - 1)
struct list_head rs_table[IP_VS_RTAB_SIZE];
+ /* ip_vs_proto */
+ #define IP_VS_PROTO_TAB_SIZE 32 /* must be power of 2 */
+ struct ip_vs_proto_data *proto_data_table[IP_VS_PROTO_TAB_SIZE];
/* ip_vs_lblc */
int sysctl_lblc_expiration;
diff --git a/net/netfilter/ipvs/ip_vs_proto.c b/net/netfilter/ipvs/ip_vs_proto.c
index 27bf034..8caaf3e 100644
--- a/net/netfilter/ipvs/ip_vs_proto.c
+++ b/net/netfilter/ipvs/ip_vs_proto.c
@@ -60,6 +60,31 @@ static int __used __init register_ip_vs_protocol(struct ip_vs_protocol *pp)
return 0;
}
+/*
+ * register an ipvs protocols netns related data
+ */
+static int
+register_ip_vs_proto_netns(struct net *net, struct ip_vs_protocol *pp)
+{
+ struct netns_ipvs *ipvs = net_ipvs(net);
+ unsigned hash = IP_VS_PROTO_HASH(pp->protocol);
+ struct ip_vs_proto_data *pd =
+ kzalloc(sizeof(struct ip_vs_proto_data), GFP_ATOMIC);
+
+ if (!pd) {
+ pr_err("%s(): no memory.\n", __func__);
+ return -ENOMEM;
+ }
+ pd->pp = pp; /* For speed issues */
+ pd->next = ipvs->proto_data_table[hash];
+ ipvs->proto_data_table[hash] = pd;
+ atomic_set(&pd->appcnt, 0); /* Init app counter */
+
+ if (pp->init_netns != NULL)
+ pp->init_netns(net, pd);
+
+ return 0;
+}
/*
* unregister an ipvs protocol
@@ -82,6 +107,29 @@ static int unregister_ip_vs_protocol(struct ip_vs_protocol *pp)
return -ESRCH;
}
+/*
+ * unregister an ipvs protocols netns data
+ */
+static int
+unregister_ip_vs_proto_netns(struct net *net, struct ip_vs_proto_data *pd)
+{
+ struct netns_ipvs *ipvs = net_ipvs(net);
+ struct ip_vs_proto_data **pd_p;
+ unsigned hash = IP_VS_PROTO_HASH(pd->pp->protocol);
+
+ pd_p = &ipvs->proto_data_table[hash];
+ for (; *pd_p; pd_p = &(*pd_p)->next) {
+ if (*pd_p == pd) {
+ *pd_p = pd->next;
+ if (pd->pp->exit_netns != NULL)
+ pd->pp->exit_netns(net, pd);
+ kfree(pd);
+ return 0;
+ }
+ }
+
+ return -ESRCH;
+}
/*
* get ip_vs_protocol object by its proto.
@@ -100,6 +148,24 @@ struct ip_vs_protocol * ip_vs_proto_get(unsigned short proto)
}
EXPORT_SYMBOL(ip_vs_proto_get);
+/*
+ * get ip_vs_protocol object data by netns and proto
+ */
+struct ip_vs_proto_data *
+ip_vs_proto_data_get(struct net *net, unsigned short proto)
+{
+ struct netns_ipvs *ipvs = net_ipvs(net);
+ struct ip_vs_proto_data *pd;
+ unsigned hash = IP_VS_PROTO_HASH(proto);
+
+ for (pd = ipvs->proto_data_table[hash]; pd; pd = pd->next) {
+ if (pd->pp->protocol == proto)
+ return pd;
+ }
+
+ return NULL;
+}
+EXPORT_SYMBOL(ip_vs_proto_data_get);
/*
* Propagate event for state change to all protocols
--
1.7.2.3
next prev parent reply other threads:[~2010-12-13 13:38 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-12-13 13:38 [*v2 PATCH 00/22] IPVS, Network Name Space aware Hans Schillstrom
2010-12-13 13:38 ` [*v2 PATCH 01/22] IPVS: netns, add basic init per netns Hans Schillstrom
2010-12-13 14:08 ` Jan Engelhardt
2010-12-13 15:12 ` Hans Schillstrom
2010-12-13 13:38 ` [*v2 PATCH 02/22] IPVS: netns to services part 1 Hans Schillstrom
2010-12-13 13:38 ` [*v2 PATCH 03/22] IPVS: netns awarness to lblcr sheduler Hans Schillstrom
2010-12-13 13:38 ` [*v2 PATCH 04/22] IPVS: netns awarness to lblc sheduler Hans Schillstrom
2010-12-13 13:38 ` Hans Schillstrom [this message]
2010-12-13 13:38 ` [*v2 PATCH 06/22] IPVS: netns preparation for proto_tcp Hans Schillstrom
2010-12-13 22:18 ` Simon Horman
2010-12-14 6:42 ` Hans Schillstrom
2010-12-15 21:37 ` Julian Anastasov
2010-12-13 13:38 ` [*v2 PATCH 07/22] IPVS: netns preparation for proto_udp Hans Schillstrom
2010-12-13 13:38 ` [*v2 PATCH 08/22] IPVS: netns preparation for proto_sctp Hans Schillstrom
2010-12-13 22:23 ` Simon Horman
2010-12-14 6:27 ` Hans Schillstrom
2010-12-13 13:38 ` [*v2 PATCH 09/22] IPVS: netns preparation for proto_ah_esp Hans Schillstrom
2010-12-13 22:19 ` Simon Horman
2010-12-13 13:38 ` [*v2 PATCH 10/22] IPVS: netns, use ip_vs_proto_data as param Hans Schillstrom
2010-12-13 13:38 ` [*v2 PATCH 11/22] IPVS: netns, common protocol changes and use of appcnt Hans Schillstrom
2010-12-13 13:38 ` [*v2 PATCH 12/22] IPVS: netns awareness to ip_vs_app Hans Schillstrom
2010-12-13 13:38 ` [*v2 PATCH 13/22] IPVS: netns awareness to ip_vs_est Hans Schillstrom
2010-12-13 13:38 ` [*v2 PATCH 14/22] IPVS: netns awareness to ip_vs_sync Hans Schillstrom
2010-12-13 13:38 ` [*v2 PATCH 15/22] IPVS: netns, ip_vs_stats and its procfs Hans Schillstrom
2010-12-13 13:38 ` [*v2 PATCH 16/22] IPVS: netns, connection hash got net as param Hans Schillstrom
2010-12-13 13:38 ` [*v2 PATCH 17/22] IPVS: netns, ip_vs_ctl local vars moved to ipvs struct Hans Schillstrom
2010-12-13 13:38 ` [*v2 PATCH 18/22] IPVS: netns, defense work timer Hans Schillstrom
2010-12-13 13:38 ` [*v2 PATCH 19/22] IPVS: netns, trash handling Hans Schillstrom
2010-12-13 13:38 ` [*v2 PATCH 20/22] IPVS: netns, svc counters moved in ip_vs_ctl,c Hans Schillstrom
2010-12-13 13:38 ` [*v2 PATCH 21/22] IPVS: netns, misc init_net removal in core Hans Schillstrom
2010-12-13 13:38 ` [*v2 PATCH 22/22] IPVS: netns, final patch enabling network name space Hans Schillstrom
2010-12-14 23:43 ` [*v2 PATCH 00/22] IPVS, Network Name Space aware Julian Anastasov
2010-12-15 10:32 ` Hans Schillstrom
2010-12-15 21:11 ` Julian Anastasov
2010-12-15 10:52 ` Hans Schillstrom
2010-12-15 12:15 ` Graeme Fowler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1292247510-753-6-git-send-email-hans.schillstrom@ericsson.com \
--to=hans.schillstrom@ericsson.com \
--cc=daniel.lezcano@free.fr \
--cc=hans@schillstrom.com \
--cc=horms@verge.net.au \
--cc=ja@ssi.bg \
--cc=lvs-devel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=wensong@linux-vs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).