netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Julius Volz <juliusv@google.com>
To: netdev@vger.kernel.org, lvs-devel@vger.kernel.org
Cc: horms@verge.net.au, kaber@trash.net, vbusam@google.com,
	Julius Volz <juliusv@google.com>
Subject: [PATCHv3 07/24] IPVS: Add v6 support to ip_vs_service_get()
Date: Tue,  2 Sep 2008 15:55:38 +0200	[thread overview]
Message-ID: <1220363755-9854-8-git-send-email-juliusv@google.com> (raw)
In-Reply-To: <1220363755-9854-1-git-send-email-juliusv@google.com>

Add support for selecting services based on their address family to
ip_vs_service_get() and adjust the callers.

Signed-off-by: Julius Volz <juliusv@google.com>

 4 files changed, 28 insertions(+), 19 deletions(-)

diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
index 1adf8a0..30baed0 100644
--- a/include/net/ip_vs.h
+++ b/include/net/ip_vs.h
@@ -783,7 +783,8 @@ extern struct ip_vs_stats ip_vs_stats;
 extern const struct ctl_path net_vs_ctl_path[];
 
 extern struct ip_vs_service *
-ip_vs_service_get(__u32 fwmark, __u16 protocol, __be32 vaddr, __be16 vport);
+ip_vs_service_get(int af, __u32 fwmark, __u16 protocol,
+		  const union nf_inet_addr *vaddr, __be16 vport);
 
 static inline void ip_vs_service_put(struct ip_vs_service *svc)
 {
diff --git a/net/ipv4/ipvs/ip_vs_ctl.c b/net/ipv4/ipvs/ip_vs_ctl.c
index a2d69b2..1f3fc66 100644
--- a/net/ipv4/ipvs/ip_vs_ctl.c
+++ b/net/ipv4/ipvs/ip_vs_ctl.c
@@ -421,23 +421,24 @@ __ip_vs_svc_fwm_get(int af, __u32 fwmark)
 }
 
 struct ip_vs_service *
-ip_vs_service_get(__u32 fwmark, __u16 protocol, __be32 vaddr, __be16 vport)
+ip_vs_service_get(int af, __u32 fwmark, __u16 protocol,
+		  const union nf_inet_addr *vaddr, __be16 vport)
 {
 	struct ip_vs_service *svc;
-	union nf_inet_addr _vaddr = { .ip = vaddr };
+
 	read_lock(&__ip_vs_svc_lock);
 
 	/*
 	 *	Check the table hashed by fwmark first
 	 */
-	if (fwmark && (svc = __ip_vs_svc_fwm_get(AF_INET, fwmark)))
+	if (fwmark && (svc = __ip_vs_svc_fwm_get(af, fwmark)))
 		goto out;
 
 	/*
 	 *	Check the table hashed by <protocol,addr,port>
 	 *	for "full" addressed entries
 	 */
-	svc = __ip_vs_service_get(AF_INET, protocol, &_vaddr, vport);
+	svc = __ip_vs_service_get(af, protocol, vaddr, vport);
 
 	if (svc == NULL
 	    && protocol == IPPROTO_TCP
@@ -447,7 +448,7 @@ ip_vs_service_get(__u32 fwmark, __u16 protocol, __be32 vaddr, __be16 vport)
 		 * Check if ftp service entry exists, the packet
 		 * might belong to FTP data connections.
 		 */
-		svc = __ip_vs_service_get(AF_INET, protocol, &_vaddr, FTPPORT);
+		svc = __ip_vs_service_get(af, protocol, vaddr, FTPPORT);
 	}
 
 	if (svc == NULL
@@ -455,16 +456,16 @@ ip_vs_service_get(__u32 fwmark, __u16 protocol, __be32 vaddr, __be16 vport)
 		/*
 		 * Check if the catch-all port (port zero) exists
 		 */
-		svc = __ip_vs_service_get(AF_INET, protocol, &_vaddr, 0);
+		svc = __ip_vs_service_get(af, protocol, vaddr, 0);
 	}
 
   out:
 	read_unlock(&__ip_vs_svc_lock);
 
-	IP_VS_DBG(9, "lookup service: fwm %u %s %u.%u.%u.%u:%u %s\n",
-		  fwmark, ip_vs_proto_name(protocol),
-		  NIPQUAD(vaddr), ntohs(vport),
-		  svc?"hit":"not hit");
+	IP_VS_DBG_BUF(9, "lookup service: fwm %u %s %s:%u %s\n",
+		      fwmark, ip_vs_proto_name(protocol),
+		      IP_VS_DBG_ADDR(af, vaddr), ntohs(vport),
+		      svc ? "hit" : "not hit");
 
 	return svc;
 }
@@ -605,8 +606,9 @@ struct ip_vs_dest *ip_vs_find_dest(__be32 daddr, __be16 dport,
 {
 	struct ip_vs_dest *dest;
 	struct ip_vs_service *svc;
+	union nf_inet_addr _vaddr = { .ip = vaddr };
 
-	svc = ip_vs_service_get(0, protocol, vaddr, vport);
+	svc = ip_vs_service_get(AF_INET, 0, protocol, &_vaddr, vport);
 	if (!svc)
 		return NULL;
 	dest = ip_vs_lookup_dest(svc, daddr, dport);
diff --git a/net/ipv4/ipvs/ip_vs_proto_tcp.c b/net/ipv4/ipvs/ip_vs_proto_tcp.c
index 15860e1..fe93c9e 100644
--- a/net/ipv4/ipvs/ip_vs_proto_tcp.c
+++ b/net/ipv4/ipvs/ip_vs_proto_tcp.c
@@ -74,16 +74,19 @@ tcp_conn_schedule(struct sk_buff *skb,
 {
 	struct ip_vs_service *svc;
 	struct tcphdr _tcph, *th;
+	struct ip_vs_iphdr iph;
 
-	th = skb_header_pointer(skb, ip_hdrlen(skb), sizeof(_tcph), &_tcph);
+	ip_vs_fill_iphdr(AF_INET, skb_network_header(skb), &iph);
+
+	th = skb_header_pointer(skb, iph.len, sizeof(_tcph), &_tcph);
 	if (th == NULL) {
 		*verdict = NF_DROP;
 		return 0;
 	}
 
 	if (th->syn &&
-	    (svc = ip_vs_service_get(skb->mark, ip_hdr(skb)->protocol,
-				     ip_hdr(skb)->daddr, th->dest))) {
+	    (svc = ip_vs_service_get(AF_INET, skb->mark, iph.protocol,
+				     &iph.daddr, th->dest))) {
 		if (ip_vs_todrop()) {
 			/*
 			 * It seems that we are very loaded.
diff --git a/net/ipv4/ipvs/ip_vs_proto_udp.c b/net/ipv4/ipvs/ip_vs_proto_udp.c
index 8dfad5d..d208ed6 100644
--- a/net/ipv4/ipvs/ip_vs_proto_udp.c
+++ b/net/ipv4/ipvs/ip_vs_proto_udp.c
@@ -80,16 +80,19 @@ udp_conn_schedule(struct sk_buff *skb, struct ip_vs_protocol *pp,
 {
 	struct ip_vs_service *svc;
 	struct udphdr _udph, *uh;
+	struct ip_vs_iphdr iph;
 
-	uh = skb_header_pointer(skb, ip_hdrlen(skb),
-				sizeof(_udph), &_udph);
+	ip_vs_fill_iphdr(AF_INET, skb_network_header(skb), &iph);
+
+	uh = skb_header_pointer(skb, iph.len, sizeof(_udph), &_udph);
 	if (uh == NULL) {
 		*verdict = NF_DROP;
 		return 0;
 	}
 
-	if ((svc = ip_vs_service_get(skb->mark, ip_hdr(skb)->protocol,
-				     ip_hdr(skb)->daddr, uh->dest))) {
+	svc = ip_vs_service_get(AF_INET, skb->mark, iph.protocol,
+				&iph.daddr, uh->dest);
+	if (svc) {
 		if (ip_vs_todrop()) {
 			/*
 			 * It seems that we are very loaded.
-- 
1.5.4.5


  parent reply	other threads:[~2008-09-02 13:56 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-02 13:55 [PATCHv3 00/24] Add first IPv6 support to IPVS Julius Volz
2008-09-02 13:55 ` [PATCHv3 01/24] IPVS: Add CONFIG_IP_VS_IPV6 option for IPv6 support Julius Volz
2008-09-02 13:55 ` [PATCHv3 02/24] IPVS: Change IPVS data structures to support IPv6 addresses Julius Volz
2008-09-02 13:55 ` [PATCHv3 03/24] IPVS: Add general v4/v6 helper functions / data structures Julius Volz
2008-09-02 13:55 ` [PATCHv3 04/24] IPVS: Add debug macros for v4 and v6 address output Julius Volz
2008-09-02 13:55 ` [PATCHv3 05/24] IPVS: Add internal versions of sockopt interface structs Julius Volz
2008-09-02 13:55 ` [PATCHv3 06/24] IPVS: Convert __ip_vs_svc_get() and __ip_vs_fwm_get() Julius Volz
2008-09-02 13:55 ` Julius Volz [this message]
2008-09-02 13:55 ` [PATCHv3 08/24] IPVS: Add IPv6 support flag to schedulers Julius Volz
2008-09-02 13:55 ` [PATCHv3 09/24] IPVS: Add 'af' args to protocol handler functions Julius Volz
2008-09-02 13:55 ` [PATCHv3 10/24] IPVS: Add protocol debug functions for IPv6 Julius Volz
2008-09-05 12:43   ` [PATCH] ipvs: Mark tcp/udp v4 and v6 debug functions static Sven Wegener
2008-09-02 13:55 ` [PATCHv3 11/24] IPVS: Extend protocol DNAT/SNAT and state handlers Julius Volz
2008-09-02 13:55 ` [PATCHv3 12/24] IPVS: Extend functions for getting/creating connections Julius Volz
2008-09-05 11:46   ` [PATCH] ipvs: Use pointer to address from sync message Sven Wegener
2008-09-05 12:28     ` Julius Volz
2008-09-06  4:26       ` Simon Horman
2008-09-06  9:04         ` Julius Volz
2008-09-08  1:47           ` Simon Horman
2008-09-02 13:55 ` [PATCHv3 13/24] IPVS: Add IPv6 support to xmit() support functions Julius Volz
2008-09-02 13:55 ` [PATCHv3 14/24] IPVS: Add and bind IPv6 xmit functions Julius Volz
2008-09-02 13:55 ` [PATCHv3 15/24] IPVS: Extend scheduling functions for IPv6 support Julius Volz
2008-09-02 13:55 ` [PATCHv3 16/24] IPVS: Add/adjust Netfilter hook functions and helpers for v6 Julius Volz
2008-09-03  5:44   ` Simon Horman
2008-09-03  9:01     ` Julius Volz
2008-09-05  0:47       ` Simon Horman
2008-09-02 13:55 ` [PATCHv3 17/24] IPVS: Convert real server lookup functions Julius Volz
2008-09-02 13:55 ` [PATCHv3 18/24] IPVS: Convert procfs files for IPv6 entry output Julius Volz
2008-09-02 13:55 ` [PATCHv3 19/24] IVPS: Disable sync daemon for IPv6 connections Julius Volz
2008-09-02 13:55 ` [PATCHv3 20/24] IPVS: Turn off FTP application helper for IPv6 Julius Volz
2008-09-02 13:55 ` [PATCHv3 21/24] IPVS: Add function to determine if IPv6 address is local Julius Volz
2008-09-05 14:53   ` [PATCH] ipvs: Reject ipv6 link-local addresses for destinations Sven Wegener
2008-09-02 13:55 ` [PATCHv3 22/24] IPVS: Adjust various debug outputs to use new macros Julius Volz
2008-09-02 13:55 ` [PATCHv3 23/24] IPVS: Activate IPv6 Netfilter hooks Julius Volz
2008-09-02 13:55 ` [PATCHv3 24/24] IPVS: Allow adding IPv6 services from userspace Julius Volz
2008-09-05 11:47   ` [PATCH] ipvs: Return negative error values from ip_vs_edit_service() Sven Wegener
2008-09-03  0:40 ` [PATCHv3 00/24] Add first IPv6 support to IPVS Simon Horman
2008-09-03  9:03   ` Julius Volz
2008-09-05  1:25 ` Simon Horman
2008-09-05 11:05   ` Julius Volz

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=1220363755-9854-8-git-send-email-juliusv@google.com \
    --to=juliusv@google.com \
    --cc=horms@verge.net.au \
    --cc=kaber@trash.net \
    --cc=lvs-devel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=vbusam@google.com \
    /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;
as well as URLs for NNTP newsgroup(s).