From: Kamal Mostafa <kamal@canonical.com>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org,
kernel-team@lists.ubuntu.com
Cc: Julian Anastasov <ja@ssi.bg>, Simon Horman <horms@verge.net.au>,
Luis Henriques <luis.henriques@canonical.com>,
Kamal Mostafa <kamal@canonical.com>
Subject: [PATCH 3.8 01/81] ipvs: add backup_only flag to avoid loops
Date: Tue, 29 Oct 2013 11:03:22 -0700 [thread overview]
Message-ID: <1383069882-11437-2-git-send-email-kamal@canonical.com> (raw)
In-Reply-To: <1383069882-11437-1-git-send-email-kamal@canonical.com>
3.8.13.12 -stable review patch. If anyone has any objections, please let me know.
------------------
From: Julian Anastasov <ja@ssi.bg>
commit 0c12582fbcdea0cbb0dfd224e1c5f9a8428ffa18 upstream.
Dmitry Akindinov is reporting for a problem where SYNs are looping
between the master and backup server when the backup server is used as
real server in DR mode and has IPVS rules to function as director.
Even when the backup function is enabled we continue to forward
traffic and schedule new connections when the current master is using
the backup server as real server. While this is not a problem for NAT,
for DR and TUN method the backup server can not determine if a request
comes from client or from director.
To avoid such loops add new sysctl flag backup_only. It can be needed
for DR/TUN setups that do not need backup and director function at the
same time. When the backup function is enabled we stop any forwarding
and pass the traffic to the local stack (real server mode). The flag
disables the director function when the backup function is enabled.
For setups that enable backup function for some virtual services and
director function for other virtual services there should be another
more complex solution to support DR/TUN mode, may be to assign
per-virtual service syncid value, so that we can differentiate the
requests.
Reported-by: Dmitry Akindinov <dimak@stalker.com>
Tested-by: German Myzovsky <lawyer@sipnet.ru>
Signed-off-by: Julian Anastasov <ja@ssi.bg>
Signed-off-by: Simon Horman <horms@verge.net.au>
Cc: Luis Henriques <luis.henriques@canonical.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
---
Documentation/networking/ipvs-sysctl.txt | 7 +++++++
include/net/ip_vs.h | 12 ++++++++++++
net/netfilter/ipvs/ip_vs_core.c | 12 ++++++++----
net/netfilter/ipvs/ip_vs_ctl.c | 7 +++++++
4 files changed, 34 insertions(+), 4 deletions(-)
diff --git a/Documentation/networking/ipvs-sysctl.txt b/Documentation/networking/ipvs-sysctl.txt
index f2a2488..9573d0c 100644
--- a/Documentation/networking/ipvs-sysctl.txt
+++ b/Documentation/networking/ipvs-sysctl.txt
@@ -15,6 +15,13 @@ amemthresh - INTEGER
enabled and the variable is automatically set to 2, otherwise
the strategy is disabled and the variable is set to 1.
+backup_only - BOOLEAN
+ 0 - disabled (default)
+ not 0 - enabled
+
+ If set, disable the director function while the server is
+ in backup mode to avoid packet loops for DR/TUN methods.
+
conntrack - BOOLEAN
0 - disabled (default)
not 0 - enabled
diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
index 68c69d5..fce8e6b 100644
--- a/include/net/ip_vs.h
+++ b/include/net/ip_vs.h
@@ -976,6 +976,7 @@ struct netns_ipvs {
int sysctl_sync_retries;
int sysctl_nat_icmp_send;
int sysctl_pmtu_disc;
+ int sysctl_backup_only;
/* ip_vs_lblc */
int sysctl_lblc_expiration;
@@ -1067,6 +1068,12 @@ static inline int sysctl_pmtu_disc(struct netns_ipvs *ipvs)
return ipvs->sysctl_pmtu_disc;
}
+static inline int sysctl_backup_only(struct netns_ipvs *ipvs)
+{
+ return ipvs->sync_state & IP_VS_STATE_BACKUP &&
+ ipvs->sysctl_backup_only;
+}
+
#else
static inline int sysctl_sync_threshold(struct netns_ipvs *ipvs)
@@ -1114,6 +1121,11 @@ static inline int sysctl_pmtu_disc(struct netns_ipvs *ipvs)
return 1;
}
+static inline int sysctl_backup_only(struct netns_ipvs *ipvs)
+{
+ return 0;
+}
+
#endif
/*
diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
index a9e07fe..bbbb9a1 100644
--- a/net/netfilter/ipvs/ip_vs_core.c
+++ b/net/netfilter/ipvs/ip_vs_core.c
@@ -1604,7 +1604,8 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
}
/* ipvs enabled in this netns ? */
net = skb_net(skb);
- if (!net_ipvs(net)->enable)
+ ipvs = net_ipvs(net);
+ if (unlikely(sysctl_backup_only(ipvs) || !ipvs->enable))
return NF_ACCEPT;
ip_vs_fill_iph_skb(af, skb, &iph);
@@ -1690,7 +1691,6 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
}
IP_VS_DBG_PKT(11, af, pp, skb, 0, "Incoming packet");
- ipvs = net_ipvs(net);
/* Check the server status */
if (cp->dest && !(cp->dest->flags & IP_VS_DEST_F_AVAILABLE)) {
/* the destination server is not available */
@@ -1851,13 +1851,15 @@ ip_vs_forward_icmp(unsigned int hooknum, struct sk_buff *skb,
{
int r;
struct net *net;
+ struct netns_ipvs *ipvs;
if (ip_hdr(skb)->protocol != IPPROTO_ICMP)
return NF_ACCEPT;
/* ipvs enabled in this netns ? */
net = skb_net(skb);
- if (!net_ipvs(net)->enable)
+ ipvs = net_ipvs(net);
+ if (unlikely(sysctl_backup_only(ipvs) || !ipvs->enable))
return NF_ACCEPT;
return ip_vs_in_icmp(skb, &r, hooknum);
@@ -1871,6 +1873,7 @@ ip_vs_forward_icmp_v6(unsigned int hooknum, struct sk_buff *skb,
{
int r;
struct net *net;
+ struct netns_ipvs *ipvs;
struct ip_vs_iphdr iphdr;
ip_vs_fill_iph_skb(AF_INET6, skb, &iphdr);
@@ -1879,7 +1882,8 @@ ip_vs_forward_icmp_v6(unsigned int hooknum, struct sk_buff *skb,
/* ipvs enabled in this netns ? */
net = skb_net(skb);
- if (!net_ipvs(net)->enable)
+ ipvs = net_ipvs(net);
+ if (unlikely(sysctl_backup_only(ipvs) || !ipvs->enable))
return NF_ACCEPT;
return ip_vs_in_icmp_v6(skb, &r, hooknum, &iphdr);
diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
index 5f929a7..79c557d2 100644
--- a/net/netfilter/ipvs/ip_vs_ctl.c
+++ b/net/netfilter/ipvs/ip_vs_ctl.c
@@ -1808,6 +1808,12 @@ static struct ctl_table vs_vars[] = {
.mode = 0644,
.proc_handler = proc_dointvec,
},
+ {
+ .procname = "backup_only",
+ .maxlen = sizeof(int),
+ .mode = 0644,
+ .proc_handler = proc_dointvec,
+ },
#ifdef CONFIG_IP_VS_DEBUG
{
.procname = "debug_level",
@@ -3742,6 +3748,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
tbl[idx++].data = &ipvs->sysctl_nat_icmp_send;
ipvs->sysctl_pmtu_disc = 1;
tbl[idx++].data = &ipvs->sysctl_pmtu_disc;
+ tbl[idx++].data = &ipvs->sysctl_backup_only;
ipvs->sysctl_hdr = register_net_sysctl(net, "net/ipv4/vs", tbl);
--
1.8.1.2
next prev parent reply other threads:[~2013-10-29 18:05 UTC|newest]
Thread overview: 84+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-29 18:03 [3.8.y.z extended stable] Linux 3.8.13.12 stable review Kamal Mostafa
2013-10-29 18:03 ` Kamal Mostafa [this message]
2013-10-29 18:03 ` [PATCH 3.8 02/81] random: run random_int_secret_init() run after all late_initcalls Kamal Mostafa
2013-10-29 18:03 ` [PATCH 3.8 03/81] tile: use a more conservative __my_cpu_offset in CONFIG_PREEMPT Kamal Mostafa
2013-10-29 18:03 ` [PATCH 3.8 04/81] ALSA: snd-usb-usx2y: remove bogus frame checks Kamal Mostafa
2013-10-29 18:03 ` [PATCH 3.8 05/81] drm/i915/hsw: Disable L3 caching of atomic memory operations Kamal Mostafa
2013-10-29 18:03 ` [PATCH 3.8 06/81] drm/i915: Only apply DPMS to the encoder if enabled Kamal Mostafa
2013-10-29 18:03 ` [PATCH 3.8 07/81] ALSA: hda - hdmi: Fix channel map switch not taking effect Kamal Mostafa
2013-10-29 18:03 ` [PATCH 3.8 08/81] ALSA: hda - Add fixup for ASUS N56VZ Kamal Mostafa
2013-10-29 18:03 ` [PATCH 3.8 09/81] hwmon: (applesmc) Always read until end of data Kamal Mostafa
2013-10-29 18:03 ` [PATCH 3.8 10/81] drm/radeon: fix typo in CP DMA register headers Kamal Mostafa
2013-10-29 18:03 ` [PATCH 3.8 11/81] drm/radeon: fix hw contexts for SUMO2 asics Kamal Mostafa
2013-10-29 18:03 ` [PATCH 3.8 12/81] drm/radeon: forever loop on error in radeon_do_test_moves() Kamal Mostafa
2013-10-29 18:03 ` [PATCH 3.8 13/81] i2c: omap: Clear ARDY bit twice Kamal Mostafa
2013-10-29 18:03 ` [PATCH 3.8 14/81] KVM: PPC: Book3S HV: Fix typo in saving DSCR Kamal Mostafa
2013-10-29 18:03 ` [PATCH 3.8 15/81] random: allow architectures to optionally define random_get_entropy() Kamal Mostafa
2013-10-29 18:03 ` [PATCH 3.8 16/81] Btrfs: use right root when checking for hash collision Kamal Mostafa
2013-10-29 18:03 ` [PATCH 3.8 17/81] compiler-gcc4.h: Reorder macros based upon gcc ver Kamal Mostafa
2013-10-29 18:03 ` [PATCH 3.8 18/81] compiler-gcc.h: Add gcc-recommended GCC_VERSION macro Kamal Mostafa
2013-10-29 18:03 ` [PATCH 3.8 19/81] compiler/gcc4: Add quirk for 'asm goto' miscompilation bug Kamal Mostafa
2013-10-29 18:03 ` [PATCH 3.8 20/81] ALSA: hda - Fix microphone for Sony VAIO Pro 13 (Haswell model) Kamal Mostafa
2013-10-29 18:03 ` [PATCH 3.8 21/81] ext4: fix memory leak in xattr Kamal Mostafa
2013-10-29 18:03 ` [PATCH 3.8 22/81] vfs: allow O_PATH file descriptors for fstatfs() Kamal Mostafa
2013-10-29 18:03 ` [PATCH 3.8 23/81] parisc: fix interruption handler to respect pagefault_disable() Kamal Mostafa
2013-10-29 18:03 ` [PATCH 3.8 24/81] tuntap: correctly handle error in tun_set_iff() Kamal Mostafa
2013-10-29 18:03 ` [PATCH 3.8 25/81] xen-blkfront: use a different scatterlist for each request Kamal Mostafa
2013-10-29 18:03 ` [PATCH 3.8 26/81] can: flexcan: fix flexcan_chip_start() on imx6 Kamal Mostafa
2013-10-29 18:03 ` [PATCH 3.8 27/81] can: flexcan: flexcan_chip_start: fix regression, mark one MB for TX and abort pending TX Kamal Mostafa
2013-10-29 18:03 ` [PATCH 3.8 28/81] caif: Add missing braces to multiline if in cfctrl_linkup_request Kamal Mostafa
2013-10-29 18:03 ` [PATCH 3.8 29/81] tcp: Add missing braces to do_tcp_setsockopt Kamal Mostafa
2013-10-29 18:03 ` [PATCH 3.8 30/81] ipv6/exthdrs: accept tlv which includes only padding Kamal Mostafa
2013-10-29 18:03 ` [PATCH 3.8 31/81] net: fib: fib6_add: fix potential NULL pointer dereference Kamal Mostafa
2013-10-29 18:03 ` [PATCH 3.8 32/81] net: sctp: fix smatch warning in sctp_send_asconf_del_ip Kamal Mostafa
2013-10-29 18:03 ` [PATCH 3.8 33/81] net: flow_dissector: fix thoff for IPPROTO_AH Kamal Mostafa
2013-10-29 18:03 ` [PATCH 3.8 34/81] net_sched: htb: fix a typo in htb_change_class() Kamal Mostafa
2013-10-29 18:03 ` [PATCH 3.8 35/81] r8169: enforce RX_MULTI_EN for the 8168f Kamal Mostafa
2013-10-29 18:03 ` [PATCH 3.8 36/81] netpoll: fix NULL pointer dereference in netpoll_cleanup Kamal Mostafa
2013-10-29 18:03 ` [PATCH 3.8 37/81] net: sctp: fix ipv6 ipsec encryption bug in sctp_v6_xmit Kamal Mostafa
2013-10-29 18:03 ` [PATCH 3.8 38/81] xen-netback: count number required slots for an skb more carefully Kamal Mostafa
2013-10-29 18:04 ` [PATCH 3.8 39/81] resubmit bridge: fix message_age_timer calculation Kamal Mostafa
2013-10-29 18:04 ` [PATCH 3.8 40/81] bridge: Clamp forward_delay when enabling STP Kamal Mostafa
2013-10-29 18:04 ` [PATCH 3.8 41/81] bridge: use br_port_get_rtnl within rtnl lock Kamal Mostafa
2013-10-29 18:04 ` [PATCH 3.8 42/81] bridge: fix NULL pointer deref of br_port_get_rcu Kamal Mostafa
2013-10-29 18:04 ` [PATCH 3.8 43/81] ip6_tunnels: raddr and laddr are inverted in nl msg Kamal Mostafa
2013-10-29 18:04 ` [PATCH 3.8 44/81] net: sctp: rfc4443: do not report ICMP redirects to user space Kamal Mostafa
2013-10-29 18:04 ` [PATCH 3.8 45/81] net:dccp: " Kamal Mostafa
2013-10-29 18:04 ` [PATCH 3.8 46/81] ip: use ip_hdr() in __ip_make_skb() to retrieve IP header Kamal Mostafa
2013-10-29 18:04 ` [PATCH 3.8 47/81] ip: generate unique IP identificator if local fragmentation is allowed Kamal Mostafa
2013-10-29 18:04 ` [PATCH 3.8 48/81] ipv6: udp packets following an UFO enqueued packet need also be handled by UFO Kamal Mostafa
2013-10-29 18:04 ` [PATCH 3.8 49/81] via-rhine: fix VLAN priority field (PCP, IEEE 802.1p) Kamal Mostafa
2013-10-29 18:04 ` [PATCH 3.8 50/81] dm9601: fix IFF_ALLMULTI handling Kamal Mostafa
2013-10-29 18:04 ` [PATCH 3.8 51/81] bonding: Fix broken promiscuity reference counting issue Kamal Mostafa
2013-10-29 18:04 ` [PATCH 3.8 52/81] ipv6: gre: correct calculation of max_headroom Kamal Mostafa
2013-10-29 18:04 ` [PATCH 3.8 53/81] ipv4 igmp: use in_dev_put in timer handlers instead of __in_dev_put Kamal Mostafa
2013-10-29 18:04 ` [PATCH 3.8 54/81] ipv6 mcast: use in6_dev_put in timer handlers instead of __in6_dev_put Kamal Mostafa
2013-10-29 18:04 ` [PATCH 3.8 55/81] ll_temac: Reset dma descriptors indexes on ndo_open Kamal Mostafa
2013-10-29 18:04 ` [PATCH 3.8 56/81] sit: allow to use rtnl ops on fb tunnel Kamal Mostafa
2013-10-29 18:04 ` [PATCH 3.8 57/81] ip6tnl: " Kamal Mostafa
2013-10-29 18:04 ` [PATCH 3.8 58/81] esp_scsi: Fix tag state corruption when autosensing Kamal Mostafa
2013-10-29 18:04 ` [PATCH 3.8 59/81] sparc64: Fix ITLB handler of null page Kamal Mostafa
2013-10-29 18:04 ` [PATCH 3.8 60/81] sparc64: Remove RWSEM export leftovers Kamal Mostafa
2013-10-29 18:04 ` [PATCH 3.8 61/81] sparc64: Fix off by one in trampoline TLB mapping installation loop Kamal Mostafa
2013-10-29 18:04 ` [PATCH 3.8 62/81] sparc64: Fix not SRA'ed %o5 in 32-bit traced syscall Kamal Mostafa
2013-10-29 18:04 ` [PATCH 3.8 63/81] sparc32: Fix exit flag passed from traced sys_sigreturn Kamal Mostafa
2013-10-29 18:04 ` [PATCH 3.8 64/81] cifs: Fix inability to write files >2GB to SMB2/3 shares Kamal Mostafa
2013-10-29 18:04 ` [PATCH 3.8 65/81] xhci: quirk for extra long delay for S4 Kamal Mostafa
2013-10-29 18:04 ` [PATCH 3.8 66/81] xhci: Fix spurious wakeups after S5 on Haswell Kamal Mostafa
2013-10-29 18:04 ` [PATCH 3.8 67/81] USB: support new huawei devices in option.c Kamal Mostafa
2013-10-29 18:04 ` [PATCH 3.8 68/81] USB: serial: ti_usb_3410_5052: add Abbott strip port ID to combined table as well Kamal Mostafa
2013-10-29 18:04 ` [PATCH 3.8 69/81] USB: serial: option: add support for Inovia SEW858 device Kamal Mostafa
2013-10-29 18:04 ` [PATCH 3.8 70/81] ARM: 7851/1: check for number of arguments in syscall_get/set_arguments() Kamal Mostafa
2013-10-29 18:04 ` [PATCH 3.8 71/81] USB: quirks.c: add one device that cannot deal with suspension Kamal Mostafa
2013-10-29 18:04 ` [PATCH 3.8 72/81] ALSA: us122l: Fix pcm_usb_stream mmapping regression Kamal Mostafa
2013-10-29 18:04 ` [PATCH 3.8 73/81] dm snapshot: fix data corruption Kamal Mostafa
2013-10-29 18:04 ` [PATCH 3.8 74/81] USB: quirks: add touchscreen that is dazzeled by remote wakeup Kamal Mostafa
2013-10-29 18:04 ` [PATCH 3.8 75/81] serial: vt8500: Fix range-checking on vt8500_uart_ports Kamal Mostafa
2013-10-29 18:04 ` [PATCH 3.8 76/81] serial: vt8500: add missing braces Kamal Mostafa
2013-10-29 18:04 ` [PATCH 3.8 77/81] usb: serial: option: blacklist Olivetti Olicard200 Kamal Mostafa
2013-10-29 18:04 ` [PATCH 3.8 78/81] usb-storage: add quirk for mandatory READ_CAPACITY_16 Kamal Mostafa
2013-10-29 18:04 ` [PATCH 3.8 79/81] fs: buffer: move allocation failure loop into the allocator Kamal Mostafa
2013-10-31 14:01 ` Johannes Weiner
2013-10-31 16:40 ` Kamal Mostafa
2013-10-29 18:04 ` [PATCH 3.8 80/81] writeback: fix negative bdi max pause Kamal Mostafa
2013-10-29 18:04 ` [PATCH 3.8 81/81] mm: fix BUG in __split_huge_page_pmd Kamal Mostafa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1383069882-11437-2-git-send-email-kamal@canonical.com \
--to=kamal@canonical.com \
--cc=horms@verge.net.au \
--cc=ja@ssi.bg \
--cc=kernel-team@lists.ubuntu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luis.henriques@canonical.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®