aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/ip_vs.h
diff options
context:
space:
mode:
authorHans Schillstrom <hans.schillstrom@ericsson.com>2011-01-03 08:44:57 -0500
committerSimon Horman <horms@verge.net.au>2011-01-12 20:30:28 -0500
commit6e67e586e7289c144d5a189d6e0fa7141d025746 (patch)
tree33a064ac5fa2e2ac4270c6361d5566bc99c671e6 /include/net/ip_vs.h
parentb17fc9963f837ef1acfe36e193108fb16ed58647 (diff)
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>
Diffstat (limited to 'include/net/ip_vs.h')
-rw-r--r--include/net/ip_vs.h53
1 files changed, 42 insertions, 11 deletions
diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
index 605d5db81a39..f82c0ffdee74 100644
--- a/include/net/ip_vs.h
+++ b/include/net/ip_vs.h
@@ -477,6 +477,7 @@ extern struct ip_vs_proto_data *ip_vs_proto_data_get(struct net *net,
477 unsigned short proto); 477 unsigned short proto);
478 478
479struct ip_vs_conn_param { 479struct ip_vs_conn_param {
480 struct net *net;
480 const union nf_inet_addr *caddr; 481 const union nf_inet_addr *caddr;
481 const union nf_inet_addr *vaddr; 482 const union nf_inet_addr *vaddr;
482 __be16 cport; 483 __be16 cport;
@@ -494,17 +495,19 @@ struct ip_vs_conn_param {
494 */ 495 */
495struct ip_vs_conn { 496struct ip_vs_conn {
496 struct list_head c_list; /* hashed list heads */ 497 struct list_head c_list; /* hashed list heads */
497 498#ifdef CONFIG_NET_NS
499 struct net *net; /* Name space */
500#endif
498 /* Protocol, addresses and port numbers */ 501 /* Protocol, addresses and port numbers */
499 u16 af; /* address family */ 502 u16 af; /* address family */
500 union nf_inet_addr caddr; /* client address */ 503 __be16 cport;
501 union nf_inet_addr vaddr; /* virtual address */ 504 __be16 vport;
502 union nf_inet_addr daddr; /* destination address */ 505 __be16 dport;
503 volatile __u32 flags; /* status flags */ 506 __u32 fwmark; /* Fire wall mark from skb */
504 __u32 fwmark; /* Fire wall mark from skb */ 507 union nf_inet_addr caddr; /* client address */
505 __be16 cport; 508 union nf_inet_addr vaddr; /* virtual address */
506 __be16 vport; 509 union nf_inet_addr daddr; /* destination address */
507 __be16 dport; 510 volatile __u32 flags; /* status flags */
508 __u16 protocol; /* Which protocol (TCP/UDP) */ 511 __u16 protocol; /* Which protocol (TCP/UDP) */
509 512
510 /* counter and timer */ 513 /* counter and timer */
@@ -547,6 +550,33 @@ struct ip_vs_conn {
547 __u8 pe_data_len; 550 __u8 pe_data_len;
548}; 551};
549 552
553/*
554 * To save some memory in conn table when name space is disabled.
555 */
556static inline struct net *ip_vs_conn_net(const struct ip_vs_conn *cp)
557{
558#ifdef CONFIG_NET_NS
559 return cp->net;
560#else
561 return &init_net;
562#endif
563}
564static inline void ip_vs_conn_net_set(struct ip_vs_conn *cp, struct net *net)
565{
566#ifdef CONFIG_NET_NS
567 cp->net = net;
568#endif
569}
570
571static inline int ip_vs_conn_net_eq(const struct ip_vs_conn *cp,
572 struct net *net)
573{
574#ifdef CONFIG_NET_NS
575 return cp->net == net;
576#else
577 return 1;
578#endif
579}
550 580
551/* 581/*
552 * Extended internal versions of struct ip_vs_service_user and 582 * Extended internal versions of struct ip_vs_service_user and
@@ -796,13 +826,14 @@ enum {
796 IP_VS_DIR_LAST, 826 IP_VS_DIR_LAST,
797}; 827};
798 828
799static inline void ip_vs_conn_fill_param(int af, int protocol, 829static inline void ip_vs_conn_fill_param(struct net *net, int af, int protocol,
800 const union nf_inet_addr *caddr, 830 const union nf_inet_addr *caddr,
801 __be16 cport, 831 __be16 cport,
802 const union nf_inet_addr *vaddr, 832 const union nf_inet_addr *vaddr,
803 __be16 vport, 833 __be16 vport,
804 struct ip_vs_conn_param *p) 834 struct ip_vs_conn_param *p)
805{ 835{
836 p->net = net;
806 p->af = af; 837 p->af = af;
807 p->protocol = protocol; 838 p->protocol = protocol;
808 p->caddr = caddr; 839 p->caddr = caddr;