Commit ce144f24 authored by Hans Schillstrom's avatar Hans Schillstrom Committed by Simon Horman

IPVS: Split ports[2] into src_port and dst_port

Avoid sending invalid pointer due to skb_linearize() call.
This patch prepares for next patch where skb_linearize is a part.

In ip_vs_sched_persist() params the ports ptr will be replaced by
src and dst port.
Signed-off-by: default avatarHans Schillstrom <hans.schillstrom@ericsson.com>
Acked-by: default avatarJulian Anastasov <ja@ssi.bg>
Signed-off-by: default avatarSimon Horman <horms@verge.net.au>
parent 0e051e68
...@@ -200,7 +200,7 @@ ip_vs_conn_fill_param_persist(const struct ip_vs_service *svc, ...@@ -200,7 +200,7 @@ ip_vs_conn_fill_param_persist(const struct ip_vs_service *svc,
static struct ip_vs_conn * static struct ip_vs_conn *
ip_vs_sched_persist(struct ip_vs_service *svc, ip_vs_sched_persist(struct ip_vs_service *svc,
struct sk_buff *skb, struct sk_buff *skb,
__be16 ports[2]) __be16 src_port, __be16 dst_port)
{ {
struct ip_vs_conn *cp = NULL; struct ip_vs_conn *cp = NULL;
struct ip_vs_iphdr iph; struct ip_vs_iphdr iph;
...@@ -224,8 +224,8 @@ ip_vs_sched_persist(struct ip_vs_service *svc, ...@@ -224,8 +224,8 @@ ip_vs_sched_persist(struct ip_vs_service *svc,
IP_VS_DBG_BUF(6, "p-schedule: src %s:%u dest %s:%u " IP_VS_DBG_BUF(6, "p-schedule: src %s:%u dest %s:%u "
"mnet %s\n", "mnet %s\n",
IP_VS_DBG_ADDR(svc->af, &iph.saddr), ntohs(ports[0]), IP_VS_DBG_ADDR(svc->af, &iph.saddr), ntohs(src_port),
IP_VS_DBG_ADDR(svc->af, &iph.daddr), ntohs(ports[1]), IP_VS_DBG_ADDR(svc->af, &iph.daddr), ntohs(dst_port),
IP_VS_DBG_ADDR(svc->af, &snet)); IP_VS_DBG_ADDR(svc->af, &snet));
/* /*
...@@ -247,14 +247,14 @@ ip_vs_sched_persist(struct ip_vs_service *svc, ...@@ -247,14 +247,14 @@ ip_vs_sched_persist(struct ip_vs_service *svc,
const union nf_inet_addr fwmark = { .ip = htonl(svc->fwmark) }; const union nf_inet_addr fwmark = { .ip = htonl(svc->fwmark) };
__be16 vport = 0; __be16 vport = 0;
if (ports[1] == svc->port) { if (dst_port == svc->port) {
/* non-FTP template: /* non-FTP template:
* <protocol, caddr, 0, vaddr, vport, daddr, dport> * <protocol, caddr, 0, vaddr, vport, daddr, dport>
* FTP template: * FTP template:
* <protocol, caddr, 0, vaddr, 0, daddr, 0> * <protocol, caddr, 0, vaddr, 0, daddr, 0>
*/ */
if (svc->port != FTPPORT) if (svc->port != FTPPORT)
vport = ports[1]; vport = dst_port;
} else { } else {
/* Note: persistent fwmark-based services and /* Note: persistent fwmark-based services and
* persistent port zero service are handled here. * persistent port zero service are handled here.
...@@ -285,7 +285,7 @@ ip_vs_sched_persist(struct ip_vs_service *svc, ...@@ -285,7 +285,7 @@ ip_vs_sched_persist(struct ip_vs_service *svc,
return NULL; return NULL;
} }
if (ports[1] == svc->port && svc->port != FTPPORT) if (dst_port == svc->port && svc->port != FTPPORT)
dport = dest->port; dport = dest->port;
/* Create a template /* Create a template
...@@ -306,7 +306,7 @@ ip_vs_sched_persist(struct ip_vs_service *svc, ...@@ -306,7 +306,7 @@ ip_vs_sched_persist(struct ip_vs_service *svc,
kfree(param.pe_data); kfree(param.pe_data);
} }
dport = ports[1]; dport = dst_port;
if (dport == svc->port && dest->port) if (dport == svc->port && dest->port)
dport = dest->port; dport = dest->port;
...@@ -317,8 +317,9 @@ ip_vs_sched_persist(struct ip_vs_service *svc, ...@@ -317,8 +317,9 @@ ip_vs_sched_persist(struct ip_vs_service *svc,
/* /*
* Create a new connection according to the template * Create a new connection according to the template
*/ */
ip_vs_conn_fill_param(svc->af, iph.protocol, &iph.saddr, ports[0], ip_vs_conn_fill_param(svc->af, iph.protocol, &iph.saddr, src_port,
&iph.daddr, ports[1], &param); &iph.daddr, dst_port, &param);
cp = ip_vs_conn_new(&param, &dest->addr, dport, flags, dest, skb->mark); cp = ip_vs_conn_new(&param, &dest->addr, dport, flags, dest, skb->mark);
if (cp == NULL) { if (cp == NULL) {
ip_vs_conn_put(ct); ip_vs_conn_put(ct);
...@@ -388,7 +389,7 @@ ip_vs_schedule(struct ip_vs_service *svc, struct sk_buff *skb, ...@@ -388,7 +389,7 @@ ip_vs_schedule(struct ip_vs_service *svc, struct sk_buff *skb,
*/ */
if (svc->flags & IP_VS_SVC_F_PERSISTENT) { if (svc->flags & IP_VS_SVC_F_PERSISTENT) {
*ignored = 0; *ignored = 0;
return ip_vs_sched_persist(svc, skb, pptr); return ip_vs_sched_persist(svc, skb, pptr[0], pptr[1]);
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment