hc
2024-05-10 ee930fffee469d076998274a2ca55e13dc1efb67
kernel/include/net/ip_vs.h
....@@ -14,6 +14,7 @@
1414 #include <linux/spinlock.h> /* for struct rwlock_t */
1515 #include <linux/atomic.h> /* for struct atomic_t */
1616 #include <linux/refcount.h> /* for struct refcount_t */
17
+#include <linux/workqueue.h>
1718
1819 #include <linux/compiler.h>
1920 #include <linux/timer.h>
....@@ -24,9 +25,6 @@
2425 #include <linux/ip.h>
2526 #include <linux/ipv6.h> /* for struct ipv6hdr */
2627 #include <net/ipv6.h>
27
-#if IS_ENABLED(CONFIG_IP_VS_IPV6)
28
-#include <linux/netfilter_ipv6/ip6_tables.h>
29
-#endif
3028 #if IS_ENABLED(CONFIG_NF_CONNTRACK)
3129 #include <net/netfilter/nf_conntrack.h>
3230 #endif
....@@ -453,9 +451,6 @@
453451 int (*dnat_handler)(struct sk_buff *skb, struct ip_vs_protocol *pp,
454452 struct ip_vs_conn *cp, struct ip_vs_iphdr *iph);
455453
456
- int (*csum_check)(int af, struct sk_buff *skb,
457
- struct ip_vs_protocol *pp);
458
-
459454 const char *(*state_name)(int state);
460455
461456 void (*state_transition)(struct ip_vs_conn *cp, int direction,
....@@ -554,8 +549,10 @@
554549 */
555550 struct ip_vs_app *app; /* bound ip_vs_app object */
556551 void *app_data; /* Application private data */
557
- struct ip_vs_seq in_seq; /* incoming seq. struct */
558
- struct ip_vs_seq out_seq; /* outgoing seq. struct */
552
+ struct_group(sync_conn_opt,
553
+ struct ip_vs_seq in_seq; /* incoming seq. struct */
554
+ struct ip_vs_seq out_seq; /* outgoing seq. struct */
555
+ );
559556
560557 const struct ip_vs_pe *pe;
561558 char *pe_data;
....@@ -603,6 +600,10 @@
603600
604601 /* Address family of addr */
605602 u16 af;
603
+
604
+ u16 tun_type; /* tunnel type */
605
+ __be16 tun_port; /* tunnel port */
606
+ u16 tun_flags; /* tunnel flags */
606607 };
607608
608609
....@@ -663,6 +664,9 @@
663664 atomic_t conn_flags; /* flags to copy to conn */
664665 atomic_t weight; /* server weight */
665666 atomic_t last_weight; /* server latest weight */
667
+ __u16 tun_type; /* tunnel type */
668
+ __be16 tun_port; /* tunnel port */
669
+ __u16 tun_flags; /* tunnel flags */
666670
667671 refcount_t refcnt; /* reference counter */
668672 struct ip_vs_stats stats; /* statistics */
....@@ -870,6 +874,7 @@
870874 struct ip_vs_stats tot_stats; /* Statistics & est. */
871875
872876 int num_services; /* no of virtual services */
877
+ int num_services6; /* IPv6 virtual services */
873878
874879 /* Trash for destinations */
875880 struct list_head dest_trash;
....@@ -881,6 +886,8 @@
881886 atomic_t conn_out_counter;
882887
883888 #ifdef CONFIG_SYSCTL
889
+ /* delayed work for expiring no dest connections */
890
+ struct delayed_work expire_nodest_conn_work;
884891 /* 1/rate drop and drop-entry variables */
885892 struct delayed_work defense_work; /* Work handler */
886893 int drop_rate;
....@@ -956,6 +963,7 @@
956963 * are not supported when synchronization is enabled.
957964 */
958965 unsigned int mixed_address_family_dests;
966
+ unsigned int hooks_afmask; /* &1=AF_INET, &2=AF_INET6 */
959967 };
960968
961969 #define DEFAULT_SYNC_THRESHOLD 3
....@@ -1045,6 +1053,11 @@
10451053 return ipvs->sysctl_conn_reuse_mode;
10461054 }
10471055
1056
+static inline int sysctl_expire_nodest_conn(struct netns_ipvs *ipvs)
1057
+{
1058
+ return ipvs->sysctl_expire_nodest_conn;
1059
+}
1060
+
10481061 static inline int sysctl_schedule_icmp(struct netns_ipvs *ipvs)
10491062 {
10501063 return ipvs->sysctl_schedule_icmp;
....@@ -1130,6 +1143,11 @@
11301143 static inline int sysctl_conn_reuse_mode(struct netns_ipvs *ipvs)
11311144 {
11321145 return 1;
1146
+}
1147
+
1148
+static inline int sysctl_expire_nodest_conn(struct netns_ipvs *ipvs)
1149
+{
1150
+ return 0;
11331151 }
11341152
11351153 static inline int sysctl_schedule_icmp(struct netns_ipvs *ipvs)
....@@ -1321,7 +1339,7 @@
13211339 void ip_vs_control_net_cleanup(struct netns_ipvs *ipvs);
13221340 void ip_vs_estimator_net_cleanup(struct netns_ipvs *ipvs);
13231341 void ip_vs_sync_net_cleanup(struct netns_ipvs *ipvs);
1324
-void ip_vs_service_net_cleanup(struct netns_ipvs *ipvs);
1342
+void ip_vs_service_nets_cleanup(struct list_head *net_list);
13251343
13261344 /* IPVS application functions
13271345 * (from ip_vs_app.c)
....@@ -1405,6 +1423,9 @@
14051423 struct ip_vs_dest *
14061424 ip_vs_find_real_service(struct netns_ipvs *ipvs, int af, __u16 protocol,
14071425 const union nf_inet_addr *daddr, __be16 dport);
1426
+struct ip_vs_dest *ip_vs_find_tunnel(struct netns_ipvs *ipvs, int af,
1427
+ const union nf_inet_addr *daddr,
1428
+ __be16 tun_port);
14081429
14091430 int ip_vs_use_count_inc(void);
14101431 void ip_vs_use_count_dec(void);
....@@ -1497,6 +1518,25 @@
14971518 #else
14981519 static inline int ip_vs_todrop(struct netns_ipvs *ipvs) { return 0; }
14991520 #endif
1521
+
1522
+#ifdef CONFIG_SYSCTL
1523
+/* Enqueue delayed work for expiring no dest connections
1524
+ * Only run when sysctl_expire_nodest=1
1525
+ */
1526
+static inline void ip_vs_enqueue_expire_nodest_conns(struct netns_ipvs *ipvs)
1527
+{
1528
+ if (sysctl_expire_nodest_conn(ipvs))
1529
+ queue_delayed_work(system_long_wq,
1530
+ &ipvs->expire_nodest_conn_work, 1);
1531
+}
1532
+
1533
+void ip_vs_expire_nodest_conn_flush(struct netns_ipvs *ipvs);
1534
+#else
1535
+static inline void ip_vs_enqueue_expire_nodest_conns(struct netns_ipvs *ipvs) {}
1536
+#endif
1537
+
1538
+#define IP_VS_DFWD_METHOD(dest) (atomic_read(&(dest)->conn_flags) & \
1539
+ IP_VS_CONN_F_FWD_MASK)
15001540
15011541 /* ip_vs_fwd_tag returns the forwarding tag of the connection */
15021542 #define IP_VS_FWD_METHOD(cp) (cp->flags & IP_VS_CONN_F_FWD_MASK)
....@@ -1658,6 +1698,9 @@
16581698 #endif
16591699 }
16601700
1701
+int ip_vs_register_hooks(struct netns_ipvs *ipvs, unsigned int af);
1702
+void ip_vs_unregister_hooks(struct netns_ipvs *ipvs, unsigned int af);
1703
+
16611704 static inline int
16621705 ip_vs_dest_conn_overhead(struct ip_vs_dest *dest)
16631706 {