aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorJulius Volz <juliusv@google.com>2008-09-02 09:55:46 -0400
committerSimon Horman <horms@verge.net.au>2008-09-04 21:17:09 -0400
commitcd17f9ed099ed27e9b0d298253e5c05e335ac656 (patch)
tree782bdc31e8b66c6d3ec437ed51d66c25927f1ea5 /net
parentb3cdd2a73867d309dca288b8e820c09e3b7f1da1 (diff)
IPVS: Extend scheduling functions for IPv6 support
Convert ip_vs_schedule() and ip_vs_sched_persist() to support scheduling of IPv6 connections. Signed-off-by: Julius Volz <juliusv@google.com> Signed-off-by: Simon Horman <horms@verge.net.au>
Diffstat (limited to 'net')
-rw-r--r--net/ipv4/ipvs/ip_vs_core.c56
1 files changed, 31 insertions, 25 deletions
diff --git a/net/ipv4/ipvs/ip_vs_core.c b/net/ipv4/ipvs/ip_vs_core.c
index d6f5bf9049ad..8bfd7c2f0ebe 100644
--- a/net/ipv4/ipvs/ip_vs_core.c
+++ b/net/ipv4/ipvs/ip_vs_core.c
@@ -176,19 +176,25 @@ ip_vs_sched_persist(struct ip_vs_service *svc,
176 struct ip_vs_iphdr iph; 176 struct ip_vs_iphdr iph;
177 struct ip_vs_dest *dest; 177 struct ip_vs_dest *dest;
178 struct ip_vs_conn *ct; 178 struct ip_vs_conn *ct;
179 __be16 dport; /* destination port to forward */ 179 __be16 dport; /* destination port to forward */
180 union nf_inet_addr snet; /* source network of the client, 180 union nf_inet_addr snet; /* source network of the client,
181 after masking */ 181 after masking */
182 ip_vs_fill_iphdr(AF_INET, skb_network_header(skb), &iph); 182
183 ip_vs_fill_iphdr(svc->af, skb_network_header(skb), &iph);
183 184
184 /* Mask saddr with the netmask to adjust template granularity */ 185 /* Mask saddr with the netmask to adjust template granularity */
185 snet.ip = iph.saddr.ip & svc->netmask; 186#ifdef CONFIG_IP_VS_IPV6
187 if (svc->af == AF_INET6)
188 ipv6_addr_prefix(&snet.in6, &iph.saddr.in6, svc->netmask);
189 else
190#endif
191 snet.ip = iph.saddr.ip & svc->netmask;
186 192
187 IP_VS_DBG(6, "p-schedule: src %u.%u.%u.%u:%u dest %u.%u.%u.%u:%u " 193 IP_VS_DBG_BUF(6, "p-schedule: src %s:%u dest %s:%u "
188 "mnet %u.%u.%u.%u\n", 194 "mnet %s\n",
189 NIPQUAD(iph.saddr.ip), ntohs(ports[0]), 195 IP_VS_DBG_ADDR(svc->af, &iph.saddr), ntohs(ports[0]),
190 NIPQUAD(iph.daddr.ip), ntohs(ports[1]), 196 IP_VS_DBG_ADDR(svc->af, &iph.daddr), ntohs(ports[1]),
191 NIPQUAD(snet)); 197 IP_VS_DBG_ADDR(svc->af, &snet));
192 198
193 /* 199 /*
194 * As far as we know, FTP is a very complicated network protocol, and 200 * As far as we know, FTP is a very complicated network protocol, and
@@ -206,10 +212,10 @@ ip_vs_sched_persist(struct ip_vs_service *svc,
206 if (ports[1] == svc->port) { 212 if (ports[1] == svc->port) {
207 /* Check if a template already exists */ 213 /* Check if a template already exists */
208 if (svc->port != FTPPORT) 214 if (svc->port != FTPPORT)
209 ct = ip_vs_ct_in_get(AF_INET, iph.protocol, &snet, 0, 215 ct = ip_vs_ct_in_get(svc->af, iph.protocol, &snet, 0,
210 &iph.daddr, ports[1]); 216 &iph.daddr, ports[1]);
211 else 217 else
212 ct = ip_vs_ct_in_get(AF_INET, iph.protocol, &snet, 0, 218 ct = ip_vs_ct_in_get(svc->af, iph.protocol, &snet, 0,
213 &iph.daddr, 0); 219 &iph.daddr, 0);
214 220
215 if (!ct || !ip_vs_check_template(ct)) { 221 if (!ct || !ip_vs_check_template(ct)) {
@@ -230,7 +236,7 @@ ip_vs_sched_persist(struct ip_vs_service *svc,
230 * for ftp service. 236 * for ftp service.
231 */ 237 */
232 if (svc->port != FTPPORT) 238 if (svc->port != FTPPORT)
233 ct = ip_vs_conn_new(AF_INET, iph.protocol, 239 ct = ip_vs_conn_new(svc->af, iph.protocol,
234 &snet, 0, 240 &snet, 0,
235 &iph.daddr, 241 &iph.daddr,
236 ports[1], 242 ports[1],
@@ -238,7 +244,7 @@ ip_vs_sched_persist(struct ip_vs_service *svc,
238 IP_VS_CONN_F_TEMPLATE, 244 IP_VS_CONN_F_TEMPLATE,
239 dest); 245 dest);
240 else 246 else
241 ct = ip_vs_conn_new(AF_INET, iph.protocol, 247 ct = ip_vs_conn_new(svc->af, iph.protocol,
242 &snet, 0, 248 &snet, 0,
243 &iph.daddr, 0, 249 &iph.daddr, 0,
244 &dest->addr, 0, 250 &dest->addr, 0,
@@ -265,10 +271,10 @@ ip_vs_sched_persist(struct ip_vs_service *svc,
265 .all = { 0, 0, 0, htonl(svc->fwmark) } 271 .all = { 0, 0, 0, htonl(svc->fwmark) }
266 }; 272 };
267 273
268 ct = ip_vs_ct_in_get(AF_INET, IPPROTO_IP, &snet, 0, 274 ct = ip_vs_ct_in_get(svc->af, IPPROTO_IP, &snet, 0,
269 &fwmark, 0); 275 &fwmark, 0);
270 } else 276 } else
271 ct = ip_vs_ct_in_get(AF_INET, iph.protocol, &snet, 0, 277 ct = ip_vs_ct_in_get(svc->af, iph.protocol, &snet, 0,
272 &iph.daddr, 0); 278 &iph.daddr, 0);
273 279
274 if (!ct || !ip_vs_check_template(ct)) { 280 if (!ct || !ip_vs_check_template(ct)) {
@@ -293,14 +299,14 @@ ip_vs_sched_persist(struct ip_vs_service *svc,
293 .all = { 0, 0, 0, htonl(svc->fwmark) } 299 .all = { 0, 0, 0, htonl(svc->fwmark) }
294 }; 300 };
295 301
296 ct = ip_vs_conn_new(AF_INET, IPPROTO_IP, 302 ct = ip_vs_conn_new(svc->af, IPPROTO_IP,
297 &snet, 0, 303 &snet, 0,
298 &fwmark, 0, 304 &fwmark, 0,
299 &dest->addr, 0, 305 &dest->addr, 0,
300 IP_VS_CONN_F_TEMPLATE, 306 IP_VS_CONN_F_TEMPLATE,
301 dest); 307 dest);
302 } else 308 } else
303 ct = ip_vs_conn_new(AF_INET, iph.protocol, 309 ct = ip_vs_conn_new(svc->af, iph.protocol,
304 &snet, 0, 310 &snet, 0,
305 &iph.daddr, 0, 311 &iph.daddr, 0,
306 &dest->addr, 0, 312 &dest->addr, 0,
@@ -320,7 +326,7 @@ ip_vs_sched_persist(struct ip_vs_service *svc,
320 /* 326 /*
321 * Create a new connection according to the template 327 * Create a new connection according to the template
322 */ 328 */
323 cp = ip_vs_conn_new(AF_INET, iph.protocol, 329 cp = ip_vs_conn_new(svc->af, iph.protocol,
324 &iph.saddr, ports[0], 330 &iph.saddr, ports[0],
325 &iph.daddr, ports[1], 331 &iph.daddr, ports[1],
326 &dest->addr, dport, 332 &dest->addr, dport,
@@ -387,7 +393,7 @@ ip_vs_schedule(struct ip_vs_service *svc, const struct sk_buff *skb)
387 /* 393 /*
388 * Create a connection entry. 394 * Create a connection entry.
389 */ 395 */
390 cp = ip_vs_conn_new(AF_INET, iph.protocol, 396 cp = ip_vs_conn_new(svc->af, iph.protocol,
391 &iph.saddr, pptr[0], 397 &iph.saddr, pptr[0],
392 &iph.daddr, pptr[1], 398 &iph.daddr, pptr[1],
393 &dest->addr, dest->port ? dest->port : pptr[1], 399 &dest->addr, dest->port ? dest->port : pptr[1],
@@ -396,13 +402,13 @@ ip_vs_schedule(struct ip_vs_service *svc, const struct sk_buff *skb)
396 if (cp == NULL) 402 if (cp == NULL)
397 return NULL; 403 return NULL;
398 404
399 IP_VS_DBG(6, "Schedule fwd:%c c:%u.%u.%u.%u:%u v:%u.%u.%u.%u:%u " 405 IP_VS_DBG_BUF(6, "Schedule fwd:%c c:%s:%u v:%s:%u "
400 "d:%u.%u.%u.%u:%u conn->flags:%X conn->refcnt:%d\n", 406 "d:%s:%u conn->flags:%X conn->refcnt:%d\n",
401 ip_vs_fwd_tag(cp), 407 ip_vs_fwd_tag(cp),
402 NIPQUAD(cp->caddr.ip), ntohs(cp->cport), 408 IP_VS_DBG_ADDR(svc->af, &cp->caddr), ntohs(cp->cport),
403 NIPQUAD(cp->vaddr.ip), ntohs(cp->vport), 409 IP_VS_DBG_ADDR(svc->af, &cp->vaddr), ntohs(cp->vport),
404 NIPQUAD(cp->daddr.ip), ntohs(cp->dport), 410 IP_VS_DBG_ADDR(svc->af, &cp->daddr), ntohs(cp->dport),
405 cp->flags, atomic_read(&cp->refcnt)); 411 cp->flags, atomic_read(&cp->refcnt));
406 412
407 ip_vs_conn_stats(cp, svc); 413 ip_vs_conn_stats(cp, svc);
408 return cp; 414 return cp;