aboutsummaryrefslogtreecommitdiffstats
path: root/include/net/ip_vs.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/net/ip_vs.h')
-rw-r--r--include/net/ip_vs.h64
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 */
44static 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
72static 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 */
42extern int ip_vs_conn_tab_size; 95extern 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
897extern void ip_vs_sync_switch_mode(int mode); 951extern void ip_vs_sync_switch_mode(int mode);
898extern struct ip_vs_service * 952extern struct ip_vs_service *
899ip_vs_service_get(int af, __u32 fwmark, __u16 protocol, 953ip_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
902static inline void ip_vs_service_put(struct ip_vs_service *svc) 956static 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
907extern struct ip_vs_dest * 961extern struct ip_vs_dest *
908ip_vs_lookup_real_service(int af, __u16 protocol, 962ip_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
911extern int ip_vs_use_count_inc(void); 965extern int ip_vs_use_count_inc(void);
@@ -913,9 +967,9 @@ extern void ip_vs_use_count_dec(void);
913extern int ip_vs_control_init(void); 967extern int ip_vs_control_init(void);
914extern void ip_vs_control_cleanup(void); 968extern void ip_vs_control_cleanup(void);
915extern struct ip_vs_dest * 969extern struct ip_vs_dest *
916ip_vs_find_dest(int af, const union nf_inet_addr *daddr, __be16 dport, 970ip_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);
919extern struct ip_vs_dest *ip_vs_try_bind_dest(struct ip_vs_conn *cp); 973extern struct ip_vs_dest *ip_vs_try_bind_dest(struct ip_vs_conn *cp);
920 974
921 975