ip_vs.h 33 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181
  1. /*
  2. * IP Virtual Server
  3. * data structure and functionality definitions
  4. */
  5. #ifndef _NET_IP_VS_H
  6. #define _NET_IP_VS_H
  7. #include <linux/ip_vs.h> /* definitions shared with userland */
  8. /* old ipvsadm versions still include this file directly */
  9. #ifdef __KERNEL__
  10. #include <asm/types.h> /* for __uXX types */
  11. #include <linux/sysctl.h> /* for ctl_path */
  12. #include <linux/list.h> /* for struct list_head */
  13. #include <linux/spinlock.h> /* for struct rwlock_t */
  14. #include <asm/atomic.h> /* for struct atomic_t */
  15. #include <linux/compiler.h>
  16. #include <linux/timer.h>
  17. #include <net/checksum.h>
  18. #include <linux/netfilter.h> /* for union nf_inet_addr */
  19. #include <linux/ip.h>
  20. #include <linux/ipv6.h> /* for struct ipv6hdr */
  21. #include <net/ipv6.h> /* for ipv6_addr_copy */
  22. #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
  23. #include <net/netfilter/nf_conntrack.h>
  24. #endif
  25. #include <net/net_namespace.h> /* Netw namespace */
  26. /*
  27. * Generic access of ipvs struct
  28. */
  29. static inline struct netns_ipvs *net_ipvs(struct net* net)
  30. {
  31. return net->ipvs;
  32. }
  33. /*
  34. * Get net ptr from skb in traffic cases
  35. * use skb_sknet when call is from userland (ioctl or netlink)
  36. */
  37. static inline struct net *skb_net(struct sk_buff *skb)
  38. {
  39. #ifdef CONFIG_NET_NS
  40. #ifdef CONFIG_IP_VS_DEBUG
  41. /*
  42. * This is used for debug only.
  43. * Start with the most likely hit
  44. * End with BUG
  45. */
  46. if (likely(skb->dev && skb->dev->nd_net))
  47. return dev_net(skb->dev);
  48. if (skb_dst(skb)->dev)
  49. return dev_net(skb_dst(skb)->dev);
  50. WARN(skb->sk, "Maybe skb_sknet should be used in %s() at line:%d\n",
  51. __func__, __LINE__);
  52. if (likely(skb->sk && skb->sk->sk_net))
  53. return sock_net(skb->sk);
  54. pr_err("There is no net ptr to find in the skb in %s() line:%d\n",
  55. __func__, __LINE__);
  56. BUG();
  57. #else
  58. return dev_net(skb->dev ? : skb_dst(skb)->dev);
  59. #endif
  60. #else
  61. return &init_net;
  62. #endif
  63. }
  64. static inline struct net *skb_sknet(struct sk_buff *skb)
  65. {
  66. #ifdef CONFIG_NET_NS
  67. #ifdef CONFIG_IP_VS_DEBUG
  68. /* Start with the most likely hit */
  69. if (likely(skb->sk && skb->sk->sk_net))
  70. return sock_net(skb->sk);
  71. WARN(skb->dev, "Maybe skb_net should be used instead in %s() line:%d\n",
  72. __func__, __LINE__);
  73. if (likely(skb->dev && skb->dev->nd_net))
  74. return dev_net(skb->dev);
  75. pr_err("There is no net ptr to find in the skb in %s() line:%d\n",
  76. __func__, __LINE__);
  77. BUG();
  78. #else
  79. return sock_net(skb->sk);
  80. #endif
  81. #else
  82. return &init_net;
  83. #endif
  84. }
  85. /* Connections' size value needed by ip_vs_ctl.c */
  86. extern int ip_vs_conn_tab_size;
  87. struct ip_vs_iphdr {
  88. int len;
  89. __u8 protocol;
  90. union nf_inet_addr saddr;
  91. union nf_inet_addr daddr;
  92. };
  93. static inline void
  94. ip_vs_fill_iphdr(int af, const void *nh, struct ip_vs_iphdr *iphdr)
  95. {
  96. #ifdef CONFIG_IP_VS_IPV6
  97. if (af == AF_INET6) {
  98. const struct ipv6hdr *iph = nh;
  99. iphdr->len = sizeof(struct ipv6hdr);
  100. iphdr->protocol = iph->nexthdr;
  101. ipv6_addr_copy(&iphdr->saddr.in6, &iph->saddr);
  102. ipv6_addr_copy(&iphdr->daddr.in6, &iph->daddr);
  103. } else
  104. #endif
  105. {
  106. const struct iphdr *iph = nh;
  107. iphdr->len = iph->ihl * 4;
  108. iphdr->protocol = iph->protocol;
  109. iphdr->saddr.ip = iph->saddr;
  110. iphdr->daddr.ip = iph->daddr;
  111. }
  112. }
  113. static inline void ip_vs_addr_copy(int af, union nf_inet_addr *dst,
  114. const union nf_inet_addr *src)
  115. {
  116. #ifdef CONFIG_IP_VS_IPV6
  117. if (af == AF_INET6)
  118. ipv6_addr_copy(&dst->in6, &src->in6);
  119. else
  120. #endif
  121. dst->ip = src->ip;
  122. }
  123. static inline int ip_vs_addr_equal(int af, const union nf_inet_addr *a,
  124. const union nf_inet_addr *b)
  125. {
  126. #ifdef CONFIG_IP_VS_IPV6
  127. if (af == AF_INET6)
  128. return ipv6_addr_equal(&a->in6, &b->in6);
  129. #endif
  130. return a->ip == b->ip;
  131. }
  132. #ifdef CONFIG_IP_VS_DEBUG
  133. #include <linux/net.h>
  134. extern int ip_vs_get_debug_level(void);
  135. static inline const char *ip_vs_dbg_addr(int af, char *buf, size_t buf_len,
  136. const union nf_inet_addr *addr,
  137. int *idx)
  138. {
  139. int len;
  140. #ifdef CONFIG_IP_VS_IPV6
  141. if (af == AF_INET6)
  142. len = snprintf(&buf[*idx], buf_len - *idx, "[%pI6]",
  143. &addr->in6) + 1;
  144. else
  145. #endif
  146. len = snprintf(&buf[*idx], buf_len - *idx, "%pI4",
  147. &addr->ip) + 1;
  148. *idx += len;
  149. BUG_ON(*idx > buf_len + 1);
  150. return &buf[*idx - len];
  151. }
  152. #define IP_VS_DBG_BUF(level, msg, ...) \
  153. do { \
  154. char ip_vs_dbg_buf[160]; \
  155. int ip_vs_dbg_idx = 0; \
  156. if (level <= ip_vs_get_debug_level()) \
  157. printk(KERN_DEBUG pr_fmt(msg), ##__VA_ARGS__); \
  158. } while (0)
  159. #define IP_VS_ERR_BUF(msg...) \
  160. do { \
  161. char ip_vs_dbg_buf[160]; \
  162. int ip_vs_dbg_idx = 0; \
  163. pr_err(msg); \
  164. } while (0)
  165. /* Only use from within IP_VS_DBG_BUF() or IP_VS_ERR_BUF macros */
  166. #define IP_VS_DBG_ADDR(af, addr) \
  167. ip_vs_dbg_addr(af, ip_vs_dbg_buf, \
  168. sizeof(ip_vs_dbg_buf), addr, \
  169. &ip_vs_dbg_idx)
  170. #define IP_VS_DBG(level, msg, ...) \
  171. do { \
  172. if (level <= ip_vs_get_debug_level()) \
  173. printk(KERN_DEBUG pr_fmt(msg), ##__VA_ARGS__); \
  174. } while (0)
  175. #define IP_VS_DBG_RL(msg, ...) \
  176. do { \
  177. if (net_ratelimit()) \
  178. printk(KERN_DEBUG pr_fmt(msg), ##__VA_ARGS__); \
  179. } while (0)
  180. #define IP_VS_DBG_PKT(level, af, pp, skb, ofs, msg) \
  181. do { \
  182. if (level <= ip_vs_get_debug_level()) \
  183. pp->debug_packet(af, pp, skb, ofs, msg); \
  184. } while (0)
  185. #define IP_VS_DBG_RL_PKT(level, af, pp, skb, ofs, msg) \
  186. do { \
  187. if (level <= ip_vs_get_debug_level() && \
  188. net_ratelimit()) \
  189. pp->debug_packet(af, pp, skb, ofs, msg); \
  190. } while (0)
  191. #else /* NO DEBUGGING at ALL */
  192. #define IP_VS_DBG_BUF(level, msg...) do {} while (0)
  193. #define IP_VS_ERR_BUF(msg...) do {} while (0)
  194. #define IP_VS_DBG(level, msg...) do {} while (0)
  195. #define IP_VS_DBG_RL(msg...) do {} while (0)
  196. #define IP_VS_DBG_PKT(level, af, pp, skb, ofs, msg) do {} while (0)
  197. #define IP_VS_DBG_RL_PKT(level, af, pp, skb, ofs, msg) do {} while (0)
  198. #endif
  199. #define IP_VS_BUG() BUG()
  200. #define IP_VS_ERR_RL(msg, ...) \
  201. do { \
  202. if (net_ratelimit()) \
  203. pr_err(msg, ##__VA_ARGS__); \
  204. } while (0)
  205. #ifdef CONFIG_IP_VS_DEBUG
  206. #define EnterFunction(level) \
  207. do { \
  208. if (level <= ip_vs_get_debug_level()) \
  209. printk(KERN_DEBUG \
  210. pr_fmt("Enter: %s, %s line %i\n"), \
  211. __func__, __FILE__, __LINE__); \
  212. } while (0)
  213. #define LeaveFunction(level) \
  214. do { \
  215. if (level <= ip_vs_get_debug_level()) \
  216. printk(KERN_DEBUG \
  217. pr_fmt("Leave: %s, %s line %i\n"), \
  218. __func__, __FILE__, __LINE__); \
  219. } while (0)
  220. #else
  221. #define EnterFunction(level) do {} while (0)
  222. #define LeaveFunction(level) do {} while (0)
  223. #endif
  224. #define IP_VS_WAIT_WHILE(expr) while (expr) { cpu_relax(); }
  225. /*
  226. * The port number of FTP service (in network order).
  227. */
  228. #define FTPPORT cpu_to_be16(21)
  229. #define FTPDATA cpu_to_be16(20)
  230. /*
  231. * TCP State Values
  232. */
  233. enum {
  234. IP_VS_TCP_S_NONE = 0,
  235. IP_VS_TCP_S_ESTABLISHED,
  236. IP_VS_TCP_S_SYN_SENT,
  237. IP_VS_TCP_S_SYN_RECV,
  238. IP_VS_TCP_S_FIN_WAIT,
  239. IP_VS_TCP_S_TIME_WAIT,
  240. IP_VS_TCP_S_CLOSE,
  241. IP_VS_TCP_S_CLOSE_WAIT,
  242. IP_VS_TCP_S_LAST_ACK,
  243. IP_VS_TCP_S_LISTEN,
  244. IP_VS_TCP_S_SYNACK,
  245. IP_VS_TCP_S_LAST
  246. };
  247. /*
  248. * UDP State Values
  249. */
  250. enum {
  251. IP_VS_UDP_S_NORMAL,
  252. IP_VS_UDP_S_LAST,
  253. };
  254. /*
  255. * ICMP State Values
  256. */
  257. enum {
  258. IP_VS_ICMP_S_NORMAL,
  259. IP_VS_ICMP_S_LAST,
  260. };
  261. /*
  262. * SCTP State Values
  263. */
  264. enum ip_vs_sctp_states {
  265. IP_VS_SCTP_S_NONE,
  266. IP_VS_SCTP_S_INIT_CLI,
  267. IP_VS_SCTP_S_INIT_SER,
  268. IP_VS_SCTP_S_INIT_ACK_CLI,
  269. IP_VS_SCTP_S_INIT_ACK_SER,
  270. IP_VS_SCTP_S_ECHO_CLI,
  271. IP_VS_SCTP_S_ECHO_SER,
  272. IP_VS_SCTP_S_ESTABLISHED,
  273. IP_VS_SCTP_S_SHUT_CLI,
  274. IP_VS_SCTP_S_SHUT_SER,
  275. IP_VS_SCTP_S_SHUT_ACK_CLI,
  276. IP_VS_SCTP_S_SHUT_ACK_SER,
  277. IP_VS_SCTP_S_CLOSED,
  278. IP_VS_SCTP_S_LAST
  279. };
  280. /*
  281. * Delta sequence info structure
  282. * Each ip_vs_conn has 2 (output AND input seq. changes).
  283. * Only used in the VS/NAT.
  284. */
  285. struct ip_vs_seq {
  286. __u32 init_seq; /* Add delta from this seq */
  287. __u32 delta; /* Delta in sequence numbers */
  288. __u32 previous_delta; /* Delta in sequence numbers
  289. before last resized pkt */
  290. };
  291. /*
  292. * IPVS statistics objects
  293. */
  294. struct ip_vs_estimator {
  295. struct list_head list;
  296. u64 last_inbytes;
  297. u64 last_outbytes;
  298. u32 last_conns;
  299. u32 last_inpkts;
  300. u32 last_outpkts;
  301. u32 cps;
  302. u32 inpps;
  303. u32 outpps;
  304. u32 inbps;
  305. u32 outbps;
  306. };
  307. struct ip_vs_stats {
  308. struct ip_vs_stats_user ustats; /* statistics */
  309. struct ip_vs_estimator est; /* estimator */
  310. spinlock_t lock; /* spin lock */
  311. };
  312. struct dst_entry;
  313. struct iphdr;
  314. struct ip_vs_conn;
  315. struct ip_vs_app;
  316. struct sk_buff;
  317. struct ip_vs_proto_data;
  318. struct ip_vs_protocol {
  319. struct ip_vs_protocol *next;
  320. char *name;
  321. u16 protocol;
  322. u16 num_states;
  323. int dont_defrag;
  324. void (*init)(struct ip_vs_protocol *pp);
  325. void (*exit)(struct ip_vs_protocol *pp);
  326. void (*init_netns)(struct net *net, struct ip_vs_proto_data *pd);
  327. void (*exit_netns)(struct net *net, struct ip_vs_proto_data *pd);
  328. int (*conn_schedule)(int af, struct sk_buff *skb,
  329. struct ip_vs_proto_data *pd,
  330. int *verdict, struct ip_vs_conn **cpp);
  331. struct ip_vs_conn *
  332. (*conn_in_get)(int af,
  333. const struct sk_buff *skb,
  334. const struct ip_vs_iphdr *iph,
  335. unsigned int proto_off,
  336. int inverse);
  337. struct ip_vs_conn *
  338. (*conn_out_get)(int af,
  339. const struct sk_buff *skb,
  340. const struct ip_vs_iphdr *iph,
  341. unsigned int proto_off,
  342. int inverse);
  343. int (*snat_handler)(struct sk_buff *skb,
  344. struct ip_vs_protocol *pp, struct ip_vs_conn *cp);
  345. int (*dnat_handler)(struct sk_buff *skb,
  346. struct ip_vs_protocol *pp, struct ip_vs_conn *cp);
  347. int (*csum_check)(int af, struct sk_buff *skb,
  348. struct ip_vs_protocol *pp);
  349. const char *(*state_name)(int state);
  350. int (*state_transition)(struct ip_vs_conn *cp, int direction,
  351. const struct sk_buff *skb,
  352. struct ip_vs_proto_data *pd);
  353. int (*register_app)(struct ip_vs_app *inc);
  354. void (*unregister_app)(struct ip_vs_app *inc);
  355. int (*app_conn_bind)(struct ip_vs_conn *cp);
  356. void (*debug_packet)(int af, struct ip_vs_protocol *pp,
  357. const struct sk_buff *skb,
  358. int offset,
  359. const char *msg);
  360. void (*timeout_change)(struct ip_vs_proto_data *pd, int flags);
  361. };
  362. /*
  363. * protocol data per netns
  364. */
  365. struct ip_vs_proto_data {
  366. struct ip_vs_proto_data *next;
  367. struct ip_vs_protocol *pp;
  368. int *timeout_table; /* protocol timeout table */
  369. atomic_t appcnt; /* counter of proto app incs. */
  370. struct tcp_states_t *tcp_state_table;
  371. };
  372. extern struct ip_vs_protocol *ip_vs_proto_get(unsigned short proto);
  373. extern struct ip_vs_proto_data *ip_vs_proto_data_get(struct net *net,
  374. unsigned short proto);
  375. struct ip_vs_conn_param {
  376. const union nf_inet_addr *caddr;
  377. const union nf_inet_addr *vaddr;
  378. __be16 cport;
  379. __be16 vport;
  380. __u16 protocol;
  381. u16 af;
  382. const struct ip_vs_pe *pe;
  383. char *pe_data;
  384. __u8 pe_data_len;
  385. };
  386. /*
  387. * IP_VS structure allocated for each dynamically scheduled connection
  388. */
  389. struct ip_vs_conn {
  390. struct list_head c_list; /* hashed list heads */
  391. /* Protocol, addresses and port numbers */
  392. u16 af; /* address family */
  393. union nf_inet_addr caddr; /* client address */
  394. union nf_inet_addr vaddr; /* virtual address */
  395. union nf_inet_addr daddr; /* destination address */
  396. volatile __u32 flags; /* status flags */
  397. __u32 fwmark; /* Fire wall mark from skb */
  398. __be16 cport;
  399. __be16 vport;
  400. __be16 dport;
  401. __u16 protocol; /* Which protocol (TCP/UDP) */
  402. /* counter and timer */
  403. atomic_t refcnt; /* reference count */
  404. struct timer_list timer; /* Expiration timer */
  405. volatile unsigned long timeout; /* timeout */
  406. /* Flags and state transition */
  407. spinlock_t lock; /* lock for state transition */
  408. volatile __u16 state; /* state info */
  409. volatile __u16 old_state; /* old state, to be used for
  410. * state transition triggerd
  411. * synchronization
  412. */
  413. /* Control members */
  414. struct ip_vs_conn *control; /* Master control connection */
  415. atomic_t n_control; /* Number of controlled ones */
  416. struct ip_vs_dest *dest; /* real server */
  417. atomic_t in_pkts; /* incoming packet counter */
  418. /* packet transmitter for different forwarding methods. If it
  419. mangles the packet, it must return NF_DROP or better NF_STOLEN,
  420. otherwise this must be changed to a sk_buff **.
  421. NF_ACCEPT can be returned when destination is local.
  422. */
  423. int (*packet_xmit)(struct sk_buff *skb, struct ip_vs_conn *cp,
  424. struct ip_vs_protocol *pp);
  425. /* Note: we can group the following members into a structure,
  426. in order to save more space, and the following members are
  427. only used in VS/NAT anyway */
  428. struct ip_vs_app *app; /* bound ip_vs_app object */
  429. void *app_data; /* Application private data */
  430. struct ip_vs_seq in_seq; /* incoming seq. struct */
  431. struct ip_vs_seq out_seq; /* outgoing seq. struct */
  432. const struct ip_vs_pe *pe;
  433. char *pe_data;
  434. __u8 pe_data_len;
  435. };
  436. /*
  437. * Extended internal versions of struct ip_vs_service_user and
  438. * ip_vs_dest_user for IPv6 support.
  439. *
  440. * We need these to conveniently pass around service and destination
  441. * options, but unfortunately, we also need to keep the old definitions to
  442. * maintain userspace backwards compatibility for the setsockopt interface.
  443. */
  444. struct ip_vs_service_user_kern {
  445. /* virtual service addresses */
  446. u16 af;
  447. u16 protocol;
  448. union nf_inet_addr addr; /* virtual ip address */
  449. u16 port;
  450. u32 fwmark; /* firwall mark of service */
  451. /* virtual service options */
  452. char *sched_name;
  453. char *pe_name;
  454. unsigned flags; /* virtual service flags */
  455. unsigned timeout; /* persistent timeout in sec */
  456. u32 netmask; /* persistent netmask */
  457. };
  458. struct ip_vs_dest_user_kern {
  459. /* destination server address */
  460. union nf_inet_addr addr;
  461. u16 port;
  462. /* real server options */
  463. unsigned conn_flags; /* connection flags */
  464. int weight; /* destination weight */
  465. /* thresholds for active connections */
  466. u32 u_threshold; /* upper threshold */
  467. u32 l_threshold; /* lower threshold */
  468. };
  469. /*
  470. * The information about the virtual service offered to the net
  471. * and the forwarding entries
  472. */
  473. struct ip_vs_service {
  474. struct list_head s_list; /* for normal service table */
  475. struct list_head f_list; /* for fwmark-based service table */
  476. atomic_t refcnt; /* reference counter */
  477. atomic_t usecnt; /* use counter */
  478. u16 af; /* address family */
  479. __u16 protocol; /* which protocol (TCP/UDP) */
  480. union nf_inet_addr addr; /* IP address for virtual service */
  481. __be16 port; /* port number for the service */
  482. __u32 fwmark; /* firewall mark of the service */
  483. unsigned flags; /* service status flags */
  484. unsigned timeout; /* persistent timeout in ticks */
  485. __be32 netmask; /* grouping granularity */
  486. struct net *net;
  487. struct list_head destinations; /* real server d-linked list */
  488. __u32 num_dests; /* number of servers */
  489. struct ip_vs_stats stats; /* statistics for the service */
  490. struct ip_vs_app *inc; /* bind conns to this app inc */
  491. /* for scheduling */
  492. struct ip_vs_scheduler *scheduler; /* bound scheduler object */
  493. rwlock_t sched_lock; /* lock sched_data */
  494. void *sched_data; /* scheduler application data */
  495. /* alternate persistence engine */
  496. struct ip_vs_pe *pe;
  497. };
  498. /*
  499. * The real server destination forwarding entry
  500. * with ip address, port number, and so on.
  501. */
  502. struct ip_vs_dest {
  503. struct list_head n_list; /* for the dests in the service */
  504. struct list_head d_list; /* for table with all the dests */
  505. u16 af; /* address family */
  506. union nf_inet_addr addr; /* IP address of the server */
  507. __be16 port; /* port number of the server */
  508. volatile unsigned flags; /* dest status flags */
  509. atomic_t conn_flags; /* flags to copy to conn */
  510. atomic_t weight; /* server weight */
  511. atomic_t refcnt; /* reference counter */
  512. struct ip_vs_stats stats; /* statistics */
  513. /* connection counters and thresholds */
  514. atomic_t activeconns; /* active connections */
  515. atomic_t inactconns; /* inactive connections */
  516. atomic_t persistconns; /* persistent connections */
  517. __u32 u_threshold; /* upper threshold */
  518. __u32 l_threshold; /* lower threshold */
  519. /* for destination cache */
  520. spinlock_t dst_lock; /* lock of dst_cache */
  521. struct dst_entry *dst_cache; /* destination cache entry */
  522. u32 dst_rtos; /* RT_TOS(tos) for dst */
  523. u32 dst_cookie;
  524. #ifdef CONFIG_IP_VS_IPV6
  525. struct in6_addr dst_saddr;
  526. #endif
  527. /* for virtual service */
  528. struct ip_vs_service *svc; /* service it belongs to */
  529. __u16 protocol; /* which protocol (TCP/UDP) */
  530. union nf_inet_addr vaddr; /* virtual IP address */
  531. __be16 vport; /* virtual port number */
  532. __u32 vfwmark; /* firewall mark of service */
  533. };
  534. /*
  535. * The scheduler object
  536. */
  537. struct ip_vs_scheduler {
  538. struct list_head n_list; /* d-linked list head */
  539. char *name; /* scheduler name */
  540. atomic_t refcnt; /* reference counter */
  541. struct module *module; /* THIS_MODULE/NULL */
  542. /* scheduler initializing service */
  543. int (*init_service)(struct ip_vs_service *svc);
  544. /* scheduling service finish */
  545. int (*done_service)(struct ip_vs_service *svc);
  546. /* scheduler updating service */
  547. int (*update_service)(struct ip_vs_service *svc);
  548. /* selecting a server from the given service */
  549. struct ip_vs_dest* (*schedule)(struct ip_vs_service *svc,
  550. const struct sk_buff *skb);
  551. };
  552. /* The persistence engine object */
  553. struct ip_vs_pe {
  554. struct list_head n_list; /* d-linked list head */
  555. char *name; /* scheduler name */
  556. atomic_t refcnt; /* reference counter */
  557. struct module *module; /* THIS_MODULE/NULL */
  558. /* get the connection template, if any */
  559. int (*fill_param)(struct ip_vs_conn_param *p, struct sk_buff *skb);
  560. bool (*ct_match)(const struct ip_vs_conn_param *p,
  561. struct ip_vs_conn *ct);
  562. u32 (*hashkey_raw)(const struct ip_vs_conn_param *p, u32 initval,
  563. bool inverse);
  564. int (*show_pe_data)(const struct ip_vs_conn *cp, char *buf);
  565. };
  566. /*
  567. * The application module object (a.k.a. app incarnation)
  568. */
  569. struct ip_vs_app {
  570. struct list_head a_list; /* member in app list */
  571. int type; /* IP_VS_APP_TYPE_xxx */
  572. char *name; /* application module name */
  573. __u16 protocol;
  574. struct module *module; /* THIS_MODULE/NULL */
  575. struct list_head incs_list; /* list of incarnations */
  576. /* members for application incarnations */
  577. struct list_head p_list; /* member in proto app list */
  578. struct ip_vs_app *app; /* its real application */
  579. __be16 port; /* port number in net order */
  580. atomic_t usecnt; /* usage counter */
  581. /*
  582. * output hook: Process packet in inout direction, diff set for TCP.
  583. * Return: 0=Error, 1=Payload Not Mangled/Mangled but checksum is ok,
  584. * 2=Mangled but checksum was not updated
  585. */
  586. int (*pkt_out)(struct ip_vs_app *, struct ip_vs_conn *,
  587. struct sk_buff *, int *diff);
  588. /*
  589. * input hook: Process packet in outin direction, diff set for TCP.
  590. * Return: 0=Error, 1=Payload Not Mangled/Mangled but checksum is ok,
  591. * 2=Mangled but checksum was not updated
  592. */
  593. int (*pkt_in)(struct ip_vs_app *, struct ip_vs_conn *,
  594. struct sk_buff *, int *diff);
  595. /* ip_vs_app initializer */
  596. int (*init_conn)(struct ip_vs_app *, struct ip_vs_conn *);
  597. /* ip_vs_app finish */
  598. int (*done_conn)(struct ip_vs_app *, struct ip_vs_conn *);
  599. /* not used now */
  600. int (*bind_conn)(struct ip_vs_app *, struct ip_vs_conn *,
  601. struct ip_vs_protocol *);
  602. void (*unbind_conn)(struct ip_vs_app *, struct ip_vs_conn *);
  603. int * timeout_table;
  604. int * timeouts;
  605. int timeouts_size;
  606. int (*conn_schedule)(struct sk_buff *skb, struct ip_vs_app *app,
  607. int *verdict, struct ip_vs_conn **cpp);
  608. struct ip_vs_conn *
  609. (*conn_in_get)(const struct sk_buff *skb, struct ip_vs_app *app,
  610. const struct iphdr *iph, unsigned int proto_off,
  611. int inverse);
  612. struct ip_vs_conn *
  613. (*conn_out_get)(const struct sk_buff *skb, struct ip_vs_app *app,
  614. const struct iphdr *iph, unsigned int proto_off,
  615. int inverse);
  616. int (*state_transition)(struct ip_vs_conn *cp, int direction,
  617. const struct sk_buff *skb,
  618. struct ip_vs_app *app);
  619. void (*timeout_change)(struct ip_vs_app *app, int flags);
  620. };
  621. /*
  622. * IPVS core functions
  623. * (from ip_vs_core.c)
  624. */
  625. extern const char *ip_vs_proto_name(unsigned proto);
  626. extern void ip_vs_init_hash_table(struct list_head *table, int rows);
  627. #define IP_VS_INIT_HASH_TABLE(t) ip_vs_init_hash_table((t), ARRAY_SIZE((t)))
  628. #define IP_VS_APP_TYPE_FTP 1
  629. /*
  630. * ip_vs_conn handling functions
  631. * (from ip_vs_conn.c)
  632. */
  633. enum {
  634. IP_VS_DIR_INPUT = 0,
  635. IP_VS_DIR_OUTPUT,
  636. IP_VS_DIR_INPUT_ONLY,
  637. IP_VS_DIR_LAST,
  638. };
  639. static inline void ip_vs_conn_fill_param(int af, int protocol,
  640. const union nf_inet_addr *caddr,
  641. __be16 cport,
  642. const union nf_inet_addr *vaddr,
  643. __be16 vport,
  644. struct ip_vs_conn_param *p)
  645. {
  646. p->af = af;
  647. p->protocol = protocol;
  648. p->caddr = caddr;
  649. p->cport = cport;
  650. p->vaddr = vaddr;
  651. p->vport = vport;
  652. p->pe = NULL;
  653. p->pe_data = NULL;
  654. }
  655. struct ip_vs_conn *ip_vs_conn_in_get(const struct ip_vs_conn_param *p);
  656. struct ip_vs_conn *ip_vs_ct_in_get(const struct ip_vs_conn_param *p);
  657. struct ip_vs_conn * ip_vs_conn_in_get_proto(int af, const struct sk_buff *skb,
  658. const struct ip_vs_iphdr *iph,
  659. unsigned int proto_off,
  660. int inverse);
  661. struct ip_vs_conn *ip_vs_conn_out_get(const struct ip_vs_conn_param *p);
  662. struct ip_vs_conn * ip_vs_conn_out_get_proto(int af, const struct sk_buff *skb,
  663. const struct ip_vs_iphdr *iph,
  664. unsigned int proto_off,
  665. int inverse);
  666. /* put back the conn without restarting its timer */
  667. static inline void __ip_vs_conn_put(struct ip_vs_conn *cp)
  668. {
  669. atomic_dec(&cp->refcnt);
  670. }
  671. extern void ip_vs_conn_put(struct ip_vs_conn *cp);
  672. extern void ip_vs_conn_fill_cport(struct ip_vs_conn *cp, __be16 cport);
  673. struct ip_vs_conn *ip_vs_conn_new(const struct ip_vs_conn_param *p,
  674. const union nf_inet_addr *daddr,
  675. __be16 dport, unsigned flags,
  676. struct ip_vs_dest *dest, __u32 fwmark);
  677. extern void ip_vs_conn_expire_now(struct ip_vs_conn *cp);
  678. extern const char * ip_vs_state_name(__u16 proto, int state);
  679. extern void ip_vs_tcp_conn_listen(struct net *net, struct ip_vs_conn *cp);
  680. extern int ip_vs_check_template(struct ip_vs_conn *ct);
  681. extern void ip_vs_random_dropentry(void);
  682. extern int ip_vs_conn_init(void);
  683. extern void ip_vs_conn_cleanup(void);
  684. static inline void ip_vs_control_del(struct ip_vs_conn *cp)
  685. {
  686. struct ip_vs_conn *ctl_cp = cp->control;
  687. if (!ctl_cp) {
  688. IP_VS_ERR_BUF("request control DEL for uncontrolled: "
  689. "%s:%d to %s:%d\n",
  690. IP_VS_DBG_ADDR(cp->af, &cp->caddr),
  691. ntohs(cp->cport),
  692. IP_VS_DBG_ADDR(cp->af, &cp->vaddr),
  693. ntohs(cp->vport));
  694. return;
  695. }
  696. IP_VS_DBG_BUF(7, "DELeting control for: "
  697. "cp.dst=%s:%d ctl_cp.dst=%s:%d\n",
  698. IP_VS_DBG_ADDR(cp->af, &cp->caddr),
  699. ntohs(cp->cport),
  700. IP_VS_DBG_ADDR(cp->af, &ctl_cp->caddr),
  701. ntohs(ctl_cp->cport));
  702. cp->control = NULL;
  703. if (atomic_read(&ctl_cp->n_control) == 0) {
  704. IP_VS_ERR_BUF("BUG control DEL with n=0 : "
  705. "%s:%d to %s:%d\n",
  706. IP_VS_DBG_ADDR(cp->af, &cp->caddr),
  707. ntohs(cp->cport),
  708. IP_VS_DBG_ADDR(cp->af, &cp->vaddr),
  709. ntohs(cp->vport));
  710. return;
  711. }
  712. atomic_dec(&ctl_cp->n_control);
  713. }
  714. static inline void
  715. ip_vs_control_add(struct ip_vs_conn *cp, struct ip_vs_conn *ctl_cp)
  716. {
  717. if (cp->control) {
  718. IP_VS_ERR_BUF("request control ADD for already controlled: "
  719. "%s:%d to %s:%d\n",
  720. IP_VS_DBG_ADDR(cp->af, &cp->caddr),
  721. ntohs(cp->cport),
  722. IP_VS_DBG_ADDR(cp->af, &cp->vaddr),
  723. ntohs(cp->vport));
  724. ip_vs_control_del(cp);
  725. }
  726. IP_VS_DBG_BUF(7, "ADDing control for: "
  727. "cp.dst=%s:%d ctl_cp.dst=%s:%d\n",
  728. IP_VS_DBG_ADDR(cp->af, &cp->caddr),
  729. ntohs(cp->cport),
  730. IP_VS_DBG_ADDR(cp->af, &ctl_cp->caddr),
  731. ntohs(ctl_cp->cport));
  732. cp->control = ctl_cp;
  733. atomic_inc(&ctl_cp->n_control);
  734. }
  735. /*
  736. * IPVS application functions
  737. * (from ip_vs_app.c)
  738. */
  739. #define IP_VS_APP_MAX_PORTS 8
  740. extern int register_ip_vs_app(struct ip_vs_app *app);
  741. extern void unregister_ip_vs_app(struct ip_vs_app *app);
  742. extern int ip_vs_bind_app(struct ip_vs_conn *cp, struct ip_vs_protocol *pp);
  743. extern void ip_vs_unbind_app(struct ip_vs_conn *cp);
  744. extern int
  745. register_ip_vs_app_inc(struct ip_vs_app *app, __u16 proto, __u16 port);
  746. extern int ip_vs_app_inc_get(struct ip_vs_app *inc);
  747. extern void ip_vs_app_inc_put(struct ip_vs_app *inc);
  748. extern int ip_vs_app_pkt_out(struct ip_vs_conn *, struct sk_buff *skb);
  749. extern int ip_vs_app_pkt_in(struct ip_vs_conn *, struct sk_buff *skb);
  750. extern int ip_vs_app_init(void);
  751. extern void ip_vs_app_cleanup(void);
  752. void ip_vs_bind_pe(struct ip_vs_service *svc, struct ip_vs_pe *pe);
  753. void ip_vs_unbind_pe(struct ip_vs_service *svc);
  754. int register_ip_vs_pe(struct ip_vs_pe *pe);
  755. int unregister_ip_vs_pe(struct ip_vs_pe *pe);
  756. struct ip_vs_pe *ip_vs_pe_getbyname(const char *name);
  757. struct ip_vs_pe *__ip_vs_pe_getbyname(const char *pe_name);
  758. static inline void ip_vs_pe_get(const struct ip_vs_pe *pe)
  759. {
  760. if (pe && pe->module)
  761. __module_get(pe->module);
  762. }
  763. static inline void ip_vs_pe_put(const struct ip_vs_pe *pe)
  764. {
  765. if (pe && pe->module)
  766. module_put(pe->module);
  767. }
  768. /*
  769. * IPVS protocol functions (from ip_vs_proto.c)
  770. */
  771. extern int ip_vs_protocol_init(void);
  772. extern void ip_vs_protocol_cleanup(void);
  773. extern void ip_vs_protocol_timeout_change(struct netns_ipvs *ipvs, int flags);
  774. extern int *ip_vs_create_timeout_table(int *table, int size);
  775. extern int
  776. ip_vs_set_state_timeout(int *table, int num, const char *const *names,
  777. const char *name, int to);
  778. extern void
  779. ip_vs_tcpudp_debug_packet(int af, struct ip_vs_protocol *pp,
  780. const struct sk_buff *skb,
  781. int offset, const char *msg);
  782. extern struct ip_vs_protocol ip_vs_protocol_tcp;
  783. extern struct ip_vs_protocol ip_vs_protocol_udp;
  784. extern struct ip_vs_protocol ip_vs_protocol_icmp;
  785. extern struct ip_vs_protocol ip_vs_protocol_esp;
  786. extern struct ip_vs_protocol ip_vs_protocol_ah;
  787. extern struct ip_vs_protocol ip_vs_protocol_sctp;
  788. /*
  789. * Registering/unregistering scheduler functions
  790. * (from ip_vs_sched.c)
  791. */
  792. extern int register_ip_vs_scheduler(struct ip_vs_scheduler *scheduler);
  793. extern int unregister_ip_vs_scheduler(struct ip_vs_scheduler *scheduler);
  794. extern int ip_vs_bind_scheduler(struct ip_vs_service *svc,
  795. struct ip_vs_scheduler *scheduler);
  796. extern int ip_vs_unbind_scheduler(struct ip_vs_service *svc);
  797. extern struct ip_vs_scheduler *ip_vs_scheduler_get(const char *sched_name);
  798. extern void ip_vs_scheduler_put(struct ip_vs_scheduler *scheduler);
  799. extern struct ip_vs_conn *
  800. ip_vs_schedule(struct ip_vs_service *svc, struct sk_buff *skb,
  801. struct ip_vs_proto_data *pd, int *ignored);
  802. extern int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
  803. struct ip_vs_proto_data *pd);
  804. /*
  805. * IPVS control data and functions (from ip_vs_ctl.c)
  806. */
  807. extern int sysctl_ip_vs_cache_bypass;
  808. extern int sysctl_ip_vs_expire_nodest_conn;
  809. extern int sysctl_ip_vs_expire_quiescent_template;
  810. extern int sysctl_ip_vs_sync_threshold[2];
  811. extern int sysctl_ip_vs_nat_icmp_send;
  812. extern int sysctl_ip_vs_conntrack;
  813. extern int sysctl_ip_vs_snat_reroute;
  814. extern struct ip_vs_stats ip_vs_stats;
  815. extern const struct ctl_path net_vs_ctl_path[];
  816. extern int sysctl_ip_vs_sync_ver;
  817. extern void ip_vs_sync_switch_mode(int mode);
  818. extern struct ip_vs_service *
  819. ip_vs_service_get(struct net *net, int af, __u32 fwmark, __u16 protocol,
  820. const union nf_inet_addr *vaddr, __be16 vport);
  821. static inline void ip_vs_service_put(struct ip_vs_service *svc)
  822. {
  823. atomic_dec(&svc->usecnt);
  824. }
  825. extern struct ip_vs_dest *
  826. ip_vs_lookup_real_service(struct net *net, int af, __u16 protocol,
  827. const union nf_inet_addr *daddr, __be16 dport);
  828. extern int ip_vs_use_count_inc(void);
  829. extern void ip_vs_use_count_dec(void);
  830. extern int ip_vs_control_init(void);
  831. extern void ip_vs_control_cleanup(void);
  832. extern struct ip_vs_dest *
  833. ip_vs_find_dest(struct net *net, int af, const union nf_inet_addr *daddr,
  834. __be16 dport, const union nf_inet_addr *vaddr, __be16 vport,
  835. __u16 protocol, __u32 fwmark);
  836. extern struct ip_vs_dest *ip_vs_try_bind_dest(struct ip_vs_conn *cp);
  837. /*
  838. * IPVS sync daemon data and function prototypes
  839. * (from ip_vs_sync.c)
  840. */
  841. extern volatile int ip_vs_sync_state;
  842. extern volatile int ip_vs_master_syncid;
  843. extern volatile int ip_vs_backup_syncid;
  844. extern char ip_vs_master_mcast_ifn[IP_VS_IFNAME_MAXLEN];
  845. extern char ip_vs_backup_mcast_ifn[IP_VS_IFNAME_MAXLEN];
  846. extern int start_sync_thread(int state, char *mcast_ifn, __u8 syncid);
  847. extern int stop_sync_thread(int state);
  848. extern void ip_vs_sync_conn(struct ip_vs_conn *cp);
  849. extern int ip_vs_sync_init(void);
  850. extern void ip_vs_sync_cleanup(void);
  851. /*
  852. * IPVS rate estimator prototypes (from ip_vs_est.c)
  853. */
  854. extern int ip_vs_estimator_init(void);
  855. extern void ip_vs_estimator_cleanup(void);
  856. extern void ip_vs_new_estimator(struct ip_vs_stats *stats);
  857. extern void ip_vs_kill_estimator(struct ip_vs_stats *stats);
  858. extern void ip_vs_zero_estimator(struct ip_vs_stats *stats);
  859. /*
  860. * Various IPVS packet transmitters (from ip_vs_xmit.c)
  861. */
  862. extern int ip_vs_null_xmit
  863. (struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp);
  864. extern int ip_vs_bypass_xmit
  865. (struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp);
  866. extern int ip_vs_nat_xmit
  867. (struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp);
  868. extern int ip_vs_tunnel_xmit
  869. (struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp);
  870. extern int ip_vs_dr_xmit
  871. (struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp);
  872. extern int ip_vs_icmp_xmit
  873. (struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp, int offset);
  874. extern void ip_vs_dst_reset(struct ip_vs_dest *dest);
  875. #ifdef CONFIG_IP_VS_IPV6
  876. extern int ip_vs_bypass_xmit_v6
  877. (struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp);
  878. extern int ip_vs_nat_xmit_v6
  879. (struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp);
  880. extern int ip_vs_tunnel_xmit_v6
  881. (struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp);
  882. extern int ip_vs_dr_xmit_v6
  883. (struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp);
  884. extern int ip_vs_icmp_xmit_v6
  885. (struct sk_buff *skb, struct ip_vs_conn *cp, struct ip_vs_protocol *pp,
  886. int offset);
  887. #endif
  888. /*
  889. * This is a simple mechanism to ignore packets when
  890. * we are loaded. Just set ip_vs_drop_rate to 'n' and
  891. * we start to drop 1/rate of the packets
  892. */
  893. extern int ip_vs_drop_rate;
  894. extern int ip_vs_drop_counter;
  895. static __inline__ int ip_vs_todrop(void)
  896. {
  897. if (!ip_vs_drop_rate) return 0;
  898. if (--ip_vs_drop_counter > 0) return 0;
  899. ip_vs_drop_counter = ip_vs_drop_rate;
  900. return 1;
  901. }
  902. /*
  903. * ip_vs_fwd_tag returns the forwarding tag of the connection
  904. */
  905. #define IP_VS_FWD_METHOD(cp) (cp->flags & IP_VS_CONN_F_FWD_MASK)
  906. static inline char ip_vs_fwd_tag(struct ip_vs_conn *cp)
  907. {
  908. char fwd;
  909. switch (IP_VS_FWD_METHOD(cp)) {
  910. case IP_VS_CONN_F_MASQ:
  911. fwd = 'M'; break;
  912. case IP_VS_CONN_F_LOCALNODE:
  913. fwd = 'L'; break;
  914. case IP_VS_CONN_F_TUNNEL:
  915. fwd = 'T'; break;
  916. case IP_VS_CONN_F_DROUTE:
  917. fwd = 'R'; break;
  918. case IP_VS_CONN_F_BYPASS:
  919. fwd = 'B'; break;
  920. default:
  921. fwd = '?'; break;
  922. }
  923. return fwd;
  924. }
  925. extern void ip_vs_nat_icmp(struct sk_buff *skb, struct ip_vs_protocol *pp,
  926. struct ip_vs_conn *cp, int dir);
  927. #ifdef CONFIG_IP_VS_IPV6
  928. extern void ip_vs_nat_icmp_v6(struct sk_buff *skb, struct ip_vs_protocol *pp,
  929. struct ip_vs_conn *cp, int dir);
  930. #endif
  931. extern __sum16 ip_vs_checksum_complete(struct sk_buff *skb, int offset);
  932. static inline __wsum ip_vs_check_diff4(__be32 old, __be32 new, __wsum oldsum)
  933. {
  934. __be32 diff[2] = { ~old, new };
  935. return csum_partial(diff, sizeof(diff), oldsum);
  936. }
  937. #ifdef CONFIG_IP_VS_IPV6
  938. static inline __wsum ip_vs_check_diff16(const __be32 *old, const __be32 *new,
  939. __wsum oldsum)
  940. {
  941. __be32 diff[8] = { ~old[3], ~old[2], ~old[1], ~old[0],
  942. new[3], new[2], new[1], new[0] };
  943. return csum_partial(diff, sizeof(diff), oldsum);
  944. }
  945. #endif
  946. static inline __wsum ip_vs_check_diff2(__be16 old, __be16 new, __wsum oldsum)
  947. {
  948. __be16 diff[2] = { ~old, new };
  949. return csum_partial(diff, sizeof(diff), oldsum);
  950. }
  951. /*
  952. * Forget current conntrack (unconfirmed) and attach notrack entry
  953. */
  954. static inline void ip_vs_notrack(struct sk_buff *skb)
  955. {
  956. #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE)
  957. enum ip_conntrack_info ctinfo;
  958. struct nf_conn *ct = ct = nf_ct_get(skb, &ctinfo);
  959. if (!ct || !nf_ct_is_untracked(ct)) {
  960. nf_reset(skb);
  961. skb->nfct = &nf_ct_untracked_get()->ct_general;
  962. skb->nfctinfo = IP_CT_NEW;
  963. nf_conntrack_get(skb->nfct);
  964. }
  965. #endif
  966. }
  967. #ifdef CONFIG_IP_VS_NFCT
  968. /*
  969. * Netfilter connection tracking
  970. * (from ip_vs_nfct.c)
  971. */
  972. static inline int ip_vs_conntrack_enabled(void)
  973. {
  974. return sysctl_ip_vs_conntrack;
  975. }
  976. extern void ip_vs_update_conntrack(struct sk_buff *skb, struct ip_vs_conn *cp,
  977. int outin);
  978. extern int ip_vs_confirm_conntrack(struct sk_buff *skb, struct ip_vs_conn *cp);
  979. extern void ip_vs_nfct_expect_related(struct sk_buff *skb, struct nf_conn *ct,
  980. struct ip_vs_conn *cp, u_int8_t proto,
  981. const __be16 port, int from_rs);
  982. extern void ip_vs_conn_drop_conntrack(struct ip_vs_conn *cp);
  983. #else
  984. static inline int ip_vs_conntrack_enabled(void)
  985. {
  986. return 0;
  987. }
  988. static inline void ip_vs_update_conntrack(struct sk_buff *skb,
  989. struct ip_vs_conn *cp, int outin)
  990. {
  991. }
  992. static inline int ip_vs_confirm_conntrack(struct sk_buff *skb,
  993. struct ip_vs_conn *cp)
  994. {
  995. return NF_ACCEPT;
  996. }
  997. static inline void ip_vs_conn_drop_conntrack(struct ip_vs_conn *cp)
  998. {
  999. }
  1000. /* CONFIG_IP_VS_NFCT */
  1001. #endif
  1002. #endif /* __KERNEL__ */
  1003. #endif /* _NET_IP_VS_H */