.. | .. |
---|
14 | 14 | #include <linux/spinlock.h> /* for struct rwlock_t */ |
---|
15 | 15 | #include <linux/atomic.h> /* for struct atomic_t */ |
---|
16 | 16 | #include <linux/refcount.h> /* for struct refcount_t */ |
---|
| 17 | +#include <linux/workqueue.h> |
---|
17 | 18 | |
---|
18 | 19 | #include <linux/compiler.h> |
---|
19 | 20 | #include <linux/timer.h> |
---|
.. | .. |
---|
24 | 25 | #include <linux/ip.h> |
---|
25 | 26 | #include <linux/ipv6.h> /* for struct ipv6hdr */ |
---|
26 | 27 | #include <net/ipv6.h> |
---|
27 | | -#if IS_ENABLED(CONFIG_IP_VS_IPV6) |
---|
28 | | -#include <linux/netfilter_ipv6/ip6_tables.h> |
---|
29 | | -#endif |
---|
30 | 28 | #if IS_ENABLED(CONFIG_NF_CONNTRACK) |
---|
31 | 29 | #include <net/netfilter/nf_conntrack.h> |
---|
32 | 30 | #endif |
---|
.. | .. |
---|
453 | 451 | int (*dnat_handler)(struct sk_buff *skb, struct ip_vs_protocol *pp, |
---|
454 | 452 | struct ip_vs_conn *cp, struct ip_vs_iphdr *iph); |
---|
455 | 453 | |
---|
456 | | - int (*csum_check)(int af, struct sk_buff *skb, |
---|
457 | | - struct ip_vs_protocol *pp); |
---|
458 | | - |
---|
459 | 454 | const char *(*state_name)(int state); |
---|
460 | 455 | |
---|
461 | 456 | void (*state_transition)(struct ip_vs_conn *cp, int direction, |
---|
.. | .. |
---|
554 | 549 | */ |
---|
555 | 550 | struct ip_vs_app *app; /* bound ip_vs_app object */ |
---|
556 | 551 | 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 | + ); |
---|
559 | 556 | |
---|
560 | 557 | const struct ip_vs_pe *pe; |
---|
561 | 558 | char *pe_data; |
---|
.. | .. |
---|
603 | 600 | |
---|
604 | 601 | /* Address family of addr */ |
---|
605 | 602 | u16 af; |
---|
| 603 | + |
---|
| 604 | + u16 tun_type; /* tunnel type */ |
---|
| 605 | + __be16 tun_port; /* tunnel port */ |
---|
| 606 | + u16 tun_flags; /* tunnel flags */ |
---|
606 | 607 | }; |
---|
607 | 608 | |
---|
608 | 609 | |
---|
.. | .. |
---|
663 | 664 | atomic_t conn_flags; /* flags to copy to conn */ |
---|
664 | 665 | atomic_t weight; /* server weight */ |
---|
665 | 666 | 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 */ |
---|
666 | 670 | |
---|
667 | 671 | refcount_t refcnt; /* reference counter */ |
---|
668 | 672 | struct ip_vs_stats stats; /* statistics */ |
---|
.. | .. |
---|
870 | 874 | struct ip_vs_stats tot_stats; /* Statistics & est. */ |
---|
871 | 875 | |
---|
872 | 876 | int num_services; /* no of virtual services */ |
---|
| 877 | + int num_services6; /* IPv6 virtual services */ |
---|
873 | 878 | |
---|
874 | 879 | /* Trash for destinations */ |
---|
875 | 880 | struct list_head dest_trash; |
---|
.. | .. |
---|
881 | 886 | atomic_t conn_out_counter; |
---|
882 | 887 | |
---|
883 | 888 | #ifdef CONFIG_SYSCTL |
---|
| 889 | + /* delayed work for expiring no dest connections */ |
---|
| 890 | + struct delayed_work expire_nodest_conn_work; |
---|
884 | 891 | /* 1/rate drop and drop-entry variables */ |
---|
885 | 892 | struct delayed_work defense_work; /* Work handler */ |
---|
886 | 893 | int drop_rate; |
---|
.. | .. |
---|
956 | 963 | * are not supported when synchronization is enabled. |
---|
957 | 964 | */ |
---|
958 | 965 | unsigned int mixed_address_family_dests; |
---|
| 966 | + unsigned int hooks_afmask; /* &1=AF_INET, &2=AF_INET6 */ |
---|
959 | 967 | }; |
---|
960 | 968 | |
---|
961 | 969 | #define DEFAULT_SYNC_THRESHOLD 3 |
---|
.. | .. |
---|
1045 | 1053 | return ipvs->sysctl_conn_reuse_mode; |
---|
1046 | 1054 | } |
---|
1047 | 1055 | |
---|
| 1056 | +static inline int sysctl_expire_nodest_conn(struct netns_ipvs *ipvs) |
---|
| 1057 | +{ |
---|
| 1058 | + return ipvs->sysctl_expire_nodest_conn; |
---|
| 1059 | +} |
---|
| 1060 | + |
---|
1048 | 1061 | static inline int sysctl_schedule_icmp(struct netns_ipvs *ipvs) |
---|
1049 | 1062 | { |
---|
1050 | 1063 | return ipvs->sysctl_schedule_icmp; |
---|
.. | .. |
---|
1130 | 1143 | static inline int sysctl_conn_reuse_mode(struct netns_ipvs *ipvs) |
---|
1131 | 1144 | { |
---|
1132 | 1145 | return 1; |
---|
| 1146 | +} |
---|
| 1147 | + |
---|
| 1148 | +static inline int sysctl_expire_nodest_conn(struct netns_ipvs *ipvs) |
---|
| 1149 | +{ |
---|
| 1150 | + return 0; |
---|
1133 | 1151 | } |
---|
1134 | 1152 | |
---|
1135 | 1153 | static inline int sysctl_schedule_icmp(struct netns_ipvs *ipvs) |
---|
.. | .. |
---|
1321 | 1339 | void ip_vs_control_net_cleanup(struct netns_ipvs *ipvs); |
---|
1322 | 1340 | void ip_vs_estimator_net_cleanup(struct netns_ipvs *ipvs); |
---|
1323 | 1341 | 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); |
---|
1325 | 1343 | |
---|
1326 | 1344 | /* IPVS application functions |
---|
1327 | 1345 | * (from ip_vs_app.c) |
---|
.. | .. |
---|
1405 | 1423 | struct ip_vs_dest * |
---|
1406 | 1424 | ip_vs_find_real_service(struct netns_ipvs *ipvs, int af, __u16 protocol, |
---|
1407 | 1425 | 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); |
---|
1408 | 1429 | |
---|
1409 | 1430 | int ip_vs_use_count_inc(void); |
---|
1410 | 1431 | void ip_vs_use_count_dec(void); |
---|
.. | .. |
---|
1497 | 1518 | #else |
---|
1498 | 1519 | static inline int ip_vs_todrop(struct netns_ipvs *ipvs) { return 0; } |
---|
1499 | 1520 | #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) |
---|
1500 | 1540 | |
---|
1501 | 1541 | /* ip_vs_fwd_tag returns the forwarding tag of the connection */ |
---|
1502 | 1542 | #define IP_VS_FWD_METHOD(cp) (cp->flags & IP_VS_CONN_F_FWD_MASK) |
---|
.. | .. |
---|
1658 | 1698 | #endif |
---|
1659 | 1699 | } |
---|
1660 | 1700 | |
---|
| 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 | + |
---|
1661 | 1704 | static inline int |
---|
1662 | 1705 | ip_vs_dest_conn_overhead(struct ip_vs_dest *dest) |
---|
1663 | 1706 | { |
---|