IPVS: netns, connection hash got net as param.
Connection hash table is now name space aware. i.e. net ptr >> 8 is xor:ed to the hash, and this is the first param to be compared. The net struct is 0xa40 in size ( a little bit smaller for 32 bit arch:s) and cache-line aligned, so a ptr >> 5 might be a more clever solution ? All lookups where net is compared uses net_eq() which returns 1 when netns is disabled, and the compiler seems to do something clever in that case. ip_vs_conn_fill_param() have *net as first param now. Three new inlines added to keep conn struct smaller when names space is disabled. - ip_vs_conn_net() - ip_vs_conn_net_set() - ip_vs_conn_net_eq() *v3 moved net compare to the end in "fast path" Signed-off-by: Hans Schillstrom <hans.schillstrom@ericsson.com> Acked-by: Julian Anastasov <ja@ssi.bg> Signed-off-by: Simon Horman <horms@verge.net.au>
This commit is contained in:

committed by
Simon Horman

parent
b17fc9963f
commit
6e67e586e7
@@ -477,6 +477,7 @@ extern struct ip_vs_proto_data *ip_vs_proto_data_get(struct net *net,
|
||||
unsigned short proto);
|
||||
|
||||
struct ip_vs_conn_param {
|
||||
struct net *net;
|
||||
const union nf_inet_addr *caddr;
|
||||
const union nf_inet_addr *vaddr;
|
||||
__be16 cport;
|
||||
@@ -494,17 +495,19 @@ struct ip_vs_conn_param {
|
||||
*/
|
||||
struct ip_vs_conn {
|
||||
struct list_head c_list; /* hashed list heads */
|
||||
|
||||
#ifdef CONFIG_NET_NS
|
||||
struct net *net; /* Name space */
|
||||
#endif
|
||||
/* Protocol, addresses and port numbers */
|
||||
u16 af; /* address family */
|
||||
union nf_inet_addr caddr; /* client address */
|
||||
union nf_inet_addr vaddr; /* virtual address */
|
||||
union nf_inet_addr daddr; /* destination address */
|
||||
volatile __u32 flags; /* status flags */
|
||||
__u32 fwmark; /* Fire wall mark from skb */
|
||||
__be16 cport;
|
||||
__be16 vport;
|
||||
__be16 dport;
|
||||
u16 af; /* address family */
|
||||
__be16 cport;
|
||||
__be16 vport;
|
||||
__be16 dport;
|
||||
__u32 fwmark; /* Fire wall mark from skb */
|
||||
union nf_inet_addr caddr; /* client address */
|
||||
union nf_inet_addr vaddr; /* virtual address */
|
||||
union nf_inet_addr daddr; /* destination address */
|
||||
volatile __u32 flags; /* status flags */
|
||||
__u16 protocol; /* Which protocol (TCP/UDP) */
|
||||
|
||||
/* counter and timer */
|
||||
@@ -547,6 +550,33 @@ struct ip_vs_conn {
|
||||
__u8 pe_data_len;
|
||||
};
|
||||
|
||||
/*
|
||||
* To save some memory in conn table when name space is disabled.
|
||||
*/
|
||||
static inline struct net *ip_vs_conn_net(const struct ip_vs_conn *cp)
|
||||
{
|
||||
#ifdef CONFIG_NET_NS
|
||||
return cp->net;
|
||||
#else
|
||||
return &init_net;
|
||||
#endif
|
||||
}
|
||||
static inline void ip_vs_conn_net_set(struct ip_vs_conn *cp, struct net *net)
|
||||
{
|
||||
#ifdef CONFIG_NET_NS
|
||||
cp->net = net;
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline int ip_vs_conn_net_eq(const struct ip_vs_conn *cp,
|
||||
struct net *net)
|
||||
{
|
||||
#ifdef CONFIG_NET_NS
|
||||
return cp->net == net;
|
||||
#else
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Extended internal versions of struct ip_vs_service_user and
|
||||
@@ -796,13 +826,14 @@ enum {
|
||||
IP_VS_DIR_LAST,
|
||||
};
|
||||
|
||||
static inline void ip_vs_conn_fill_param(int af, int protocol,
|
||||
static inline void ip_vs_conn_fill_param(struct net *net, int af, int protocol,
|
||||
const union nf_inet_addr *caddr,
|
||||
__be16 cport,
|
||||
const union nf_inet_addr *vaddr,
|
||||
__be16 vport,
|
||||
struct ip_vs_conn_param *p)
|
||||
{
|
||||
p->net = net;
|
||||
p->af = af;
|
||||
p->protocol = protocol;
|
||||
p->caddr = caddr;
|
||||
|
Reference in New Issue
Block a user