Skip to content

Commit 52793db

Browse files
Julian Anastasovummakynes
authored andcommitted
ipvs: try also real server with port 0 in backup server
We should not forget to try for real server with port 0 in the backup server when processing the sync message. We should do it in all cases because the backup server can use different forwarding method. Signed-off-by: Julian Anastasov <[email protected]> Signed-off-by: Simon Horman <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent fe3c8cc commit 52793db

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

include/net/ip_vs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1207,7 +1207,7 @@ extern void ip_vs_control_cleanup(void);
12071207
extern struct ip_vs_dest *
12081208
ip_vs_find_dest(struct net *net, int af, const union nf_inet_addr *daddr,
12091209
__be16 dport, const union nf_inet_addr *vaddr, __be16 vport,
1210-
__u16 protocol, __u32 fwmark);
1210+
__u16 protocol, __u32 fwmark, __u32 flags);
12111211
extern struct ip_vs_dest *ip_vs_try_bind_dest(struct ip_vs_conn *cp);
12121212

12131213

net/netfilter/ipvs/ip_vs_conn.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ struct ip_vs_dest *ip_vs_try_bind_dest(struct ip_vs_conn *cp)
616616
if ((cp) && (!cp->dest)) {
617617
dest = ip_vs_find_dest(ip_vs_conn_net(cp), cp->af, &cp->daddr,
618618
cp->dport, &cp->vaddr, cp->vport,
619-
cp->protocol, cp->fwmark);
619+
cp->protocol, cp->fwmark, cp->flags);
620620
ip_vs_bind_dest(cp, dest);
621621
return dest;
622622
} else

net/netfilter/ipvs/ip_vs_ctl.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -619,15 +619,21 @@ struct ip_vs_dest *ip_vs_find_dest(struct net *net, int af,
619619
const union nf_inet_addr *daddr,
620620
__be16 dport,
621621
const union nf_inet_addr *vaddr,
622-
__be16 vport, __u16 protocol, __u32 fwmark)
622+
__be16 vport, __u16 protocol, __u32 fwmark,
623+
__u32 flags)
623624
{
624625
struct ip_vs_dest *dest;
625626
struct ip_vs_service *svc;
627+
__be16 port = dport;
626628

627629
svc = ip_vs_service_get(net, af, fwmark, protocol, vaddr, vport);
628630
if (!svc)
629631
return NULL;
630-
dest = ip_vs_lookup_dest(svc, daddr, dport);
632+
if (fwmark && (flags & IP_VS_CONN_F_FWD_MASK) != IP_VS_CONN_F_MASQ)
633+
port = 0;
634+
dest = ip_vs_lookup_dest(svc, daddr, port);
635+
if (!dest)
636+
dest = ip_vs_lookup_dest(svc, daddr, port ^ dport);
631637
if (dest)
632638
atomic_inc(&dest->refcnt);
633639
ip_vs_service_put(svc);

net/netfilter/ipvs/ip_vs_sync.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
740740
* but still handled.
741741
*/
742742
dest = ip_vs_find_dest(net, type, daddr, dport, param->vaddr,
743-
param->vport, protocol, fwmark);
743+
param->vport, protocol, fwmark, flags);
744744

745745
/* Set the approprite ativity flag */
746746
if (protocol == IPPROTO_TCP) {

0 commit comments

Comments
 (0)