diff options
author | Hans Schillstrom <hans.schillstrom@ericsson.com> | 2011-01-03 08:44:43 -0500 |
---|---|---|
committer | Simon Horman <horms@verge.net.au> | 2011-01-12 20:30:26 -0500 |
commit | fc723250c9cb046cc19833a2b1c4309bbf59ac36 (patch) | |
tree | fa8cd33ad9e020549dd8c6389f311d25e495ca7d /include/net/ip_vs.h | |
parent | 61b1ab4583e275af216c8454b9256de680499b19 (diff) |
IPVS: netns to services part 1
Services hash tables got netns ptr a hash arg,
While Real Servers (rs) has been moved to ipvs struct.
Two new inline functions added to get net ptr from skb.
Since ip_vs is called from different contexts there is two
places to dig for the net ptr skb->dev or skb->sk
this is handled in skb_net() and skb_sknet()
Global functions, ip_vs_service_get() ip_vs_lookup_real_service()
etc have got struct net *net as first param.
If possible get net ptr skb etc,
- if not &init_net is used at this early stage of patching.
ip_vs_ctl.c procfs not ready for netns yet.
*v3
Comments by Julian
- __ip_vs_service_find and __ip_vs_svc_fwm_find are fast path,
net_eq(svc->net, net) so the check is at the end now.
- net = skb_net(skb) in ip_vs_out moved after check for skb_dst.
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.h | 64 |
1 files changed, 59 insertions, 5 deletions
diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h index c1c2ece3ed94..d551e0d8fd9a 100644 --- a/include/net/ip_vs.h +++ b/include/net/ip_vs.h | |||
@@ -37,6 +37,59 @@ static inline struct netns_ipvs *net_ipvs(struct net* net) | |||
37 | { | 37 | { |
38 | return net->ipvs; | 38 | return net->ipvs; |
39 | } | 39 | } |
40 | /* | ||
41 | * Get net ptr from skb in traffic cases | ||
42 | * use skb_sknet when call is from userland (ioctl or netlink) | ||
43 | */ | ||
44 | static inline struct net *skb_net(struct sk_buff *skb) | ||
45 | { | ||
46 | #ifdef CONFIG_NET_NS | ||
47 | #ifdef CONFIG_IP_VS_DEBUG | ||
48 | /* | ||
49 | * This is used for debug only. | ||
50 | * Start with the most likely hit | ||
51 | * End with BUG | ||
52 | */ | ||
53 | if (likely(skb->dev && skb->dev->nd_net)) | ||
54 | return dev_net(skb->dev); | ||
55 | if (skb_dst(skb)->dev) | ||
56 | return dev_net(skb_dst(skb)->dev); | ||
57 | WARN(skb->sk, "Maybe skb_sknet should be used in %s() at line:%d\n", | ||
58 | __func__, __LINE__); | ||
59 | if (likely(skb->sk && skb->sk->sk_net)) | ||
60 | return sock_net(skb->sk); | ||
61 | pr_err("There is no net ptr to find in the skb in %s() line:%d\n", | ||
62 | __func__, __LINE__); | ||
63 | BUG(); | ||
64 | #else | ||
65 | return dev_net(skb->dev ? : skb_dst(skb)->dev); | ||
66 | #endif | ||
67 | #else | ||
68 | return &init_net; | ||
69 | #endif | ||
70 | } | ||
71 | |||
72 | static inline struct net *skb_sknet(struct sk_buff *skb) | ||
73 | { | ||
74 | #ifdef CONFIG_NET_NS | ||
75 | #ifdef CONFIG_IP_VS_DEBUG | ||
76 | /* Start with the most likely hit */ | ||
77 | if (likely(skb->sk && skb->sk->sk_net)) | ||
78 | return sock_net(skb->sk); | ||
79 | WARN(skb->dev, "Maybe skb_net should be used instead in %s() line:%d\n", | ||
80 | __func__, __LINE__); | ||
81 | if (likely(skb->dev && skb->dev->nd_net)) | ||
82 | return dev_net(skb->dev); | ||
83 | pr_err("There is no net ptr to find in the skb in %s() line:%d\n", | ||
84 | __func__, __LINE__); | ||
85 | BUG(); | ||
86 | #else | ||
87 | return sock_net(skb->sk); | ||
88 | #endif | ||
89 | #else | ||
90 | return &init_net; | ||
91 | #endif | ||
92 | } | ||
40 | 93 | ||
41 | /* Connections' size value needed by ip_vs_ctl.c */ | 94 | /* Connections' size value needed by ip_vs_ctl.c */ |
42 | extern int ip_vs_conn_tab_size; | 95 | extern int ip_vs_conn_tab_size; |
@@ -496,6 +549,7 @@ struct ip_vs_service { | |||
496 | unsigned flags; /* service status flags */ | 549 | unsigned flags; /* service status flags */ |
497 | unsigned timeout; /* persistent timeout in ticks */ | 550 | unsigned timeout; /* persistent timeout in ticks */ |
498 | __be32 netmask; /* grouping granularity */ | 551 | __be32 netmask; /* grouping granularity */ |
552 | struct net *net; | ||
499 | 553 | ||
500 | struct list_head destinations; /* real server d-linked list */ | 554 | struct list_head destinations; /* real server d-linked list */ |
501 | __u32 num_dests; /* number of servers */ | 555 | __u32 num_dests; /* number of servers */ |
@@ -896,7 +950,7 @@ extern int sysctl_ip_vs_sync_ver; | |||
896 | 950 | ||
897 | extern void ip_vs_sync_switch_mode(int mode); | 951 | extern void ip_vs_sync_switch_mode(int mode); |
898 | extern struct ip_vs_service * | 952 | extern struct ip_vs_service * |
899 | ip_vs_service_get(int af, __u32 fwmark, __u16 protocol, | 953 | ip_vs_service_get(struct net *net, int af, __u32 fwmark, __u16 protocol, |
900 | const union nf_inet_addr *vaddr, __be16 vport); | 954 | const union nf_inet_addr *vaddr, __be16 vport); |
901 | 955 | ||
902 | static inline void ip_vs_service_put(struct ip_vs_service *svc) | 956 | static inline void ip_vs_service_put(struct ip_vs_service *svc) |
@@ -905,7 +959,7 @@ static inline void ip_vs_service_put(struct ip_vs_service *svc) | |||
905 | } | 959 | } |
906 | 960 | ||
907 | extern struct ip_vs_dest * | 961 | extern struct ip_vs_dest * |
908 | ip_vs_lookup_real_service(int af, __u16 protocol, | 962 | ip_vs_lookup_real_service(struct net *net, int af, __u16 protocol, |
909 | const union nf_inet_addr *daddr, __be16 dport); | 963 | const union nf_inet_addr *daddr, __be16 dport); |
910 | 964 | ||
911 | extern int ip_vs_use_count_inc(void); | 965 | extern int ip_vs_use_count_inc(void); |
@@ -913,9 +967,9 @@ extern void ip_vs_use_count_dec(void); | |||
913 | extern int ip_vs_control_init(void); | 967 | extern int ip_vs_control_init(void); |
914 | extern void ip_vs_control_cleanup(void); | 968 | extern void ip_vs_control_cleanup(void); |
915 | extern struct ip_vs_dest * | 969 | extern struct ip_vs_dest * |
916 | ip_vs_find_dest(int af, const union nf_inet_addr *daddr, __be16 dport, | 970 | ip_vs_find_dest(struct net *net, int af, const union nf_inet_addr *daddr, |
917 | const union nf_inet_addr *vaddr, __be16 vport, __u16 protocol, | 971 | __be16 dport, const union nf_inet_addr *vaddr, __be16 vport, |
918 | __u32 fwmark); | 972 | __u16 protocol, __u32 fwmark); |
919 | extern struct ip_vs_dest *ip_vs_try_bind_dest(struct ip_vs_conn *cp); | 973 | extern struct ip_vs_dest *ip_vs_try_bind_dest(struct ip_vs_conn *cp); |
920 | 974 | ||
921 | 975 | ||