netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Simon Horman <horms@verge.net.au>
To: Julius Volz <juliusv@google.com>
Cc: netdev@vger.kernel.org, lvs-devel@vger.kernel.org,
	kaber@trash.net, vbusam@google.com
Subject: Re: [PATCHv2 RFC 21/25] IPVS: Add function to determine if IPv6 address is local
Date: Tue, 2 Sep 2008 17:57:19 +1000	[thread overview]
Message-ID: <20080902075718.GK13730@verge.net.au> (raw)
In-Reply-To: <1220273782-19901-22-git-send-email-juliusv@google.com>

On Mon, Sep 01, 2008 at 02:56:18PM +0200, Julius Volz wrote:
> From: Vince Busam <vbusam@google.com>
> 
> Add __ip_vs_addr_is_local_v6() to find out if an IPv6 address belongs to a
> local interface. Use this function to decide whether to set the
> IP_VS_CONN_F_LOCALNODE flag for IPv6 destinations.

Hi Vince,

could you please fix the following minor problems that were flagged
by checkpatch.pl ?

ERROR: open brace '{' following function declarations go on the next line
#78: FILE: net/ipv4/ipvs/ip_vs_ctl.c:100:
+static int __ip_vs_addr_is_local_v6(const struct in6_addr *addr) {

ERROR: do not use assignment in if condition
#87: FILE: net/ipv4/ipvs/ip_vs_ctl.c:109:
+	if ((rt = (struct rt6_info *)ip6_route_output(&init_net, NULL, &fl)))

> Signed-off-by: Vince Busam <vbusam@google.com>
> 
>  1 files changed, 46 insertions(+), 7 deletions(-)
> 
> diff --git a/net/ipv4/ipvs/ip_vs_ctl.c b/net/ipv4/ipvs/ip_vs_ctl.c
> index fe17504..3ce2873 100644
> --- a/net/ipv4/ipvs/ip_vs_ctl.c
> +++ b/net/ipv4/ipvs/ip_vs_ctl.c
> @@ -35,6 +35,10 @@
>  
>  #include <net/net_namespace.h>
>  #include <net/ip.h>
> +#ifdef CONFIG_IP_VS_IPV6
> +#include <net/ipv6.h>
> +#include <net/ip6_route.h>
> +#endif
>  #include <net/route.h>
>  #include <net/sock.h>
>  #include <net/genetlink.h>
> @@ -91,6 +95,23 @@ int ip_vs_get_debug_level(void)
>  }
>  #endif
>  
> +#ifdef CONFIG_IP_VS_IPV6
> +/* Taken from rt6_fill_node() in net/ipv6/route.c, is there a better way? */
> +static int __ip_vs_addr_is_local_v6(const struct in6_addr *addr) {
> +	struct rt6_info *rt;
> +	struct flowi fl = {
> +		.oif = 0,
> +		.nl_u = {
> +			.ip6_u = {
> +				.daddr = *addr,
> +				.saddr = { .s6_addr32 = {0, 0, 0, 0} }, } },
> +	};
> +	if ((rt = (struct rt6_info *)ip6_route_output(&init_net, NULL, &fl)))
> +		if (rt->rt6i_dev && (rt->rt6i_dev->flags & IFF_LOOPBACK))
> +			return 1;
> +	return 0;
> +}
> +#endif
>  /*
>   *	update_defense_level is called from keventd and from sysctl,
>   *	so it needs to protect itself from softirqs
> @@ -750,10 +771,18 @@ __ip_vs_update_dest(struct ip_vs_service *svc,
>  	conn_flags = udest->conn_flags | IP_VS_CONN_F_INACTIVE;
>  
>  	/* check if local node and update the flags */
> -	if (inet_addr_type(&init_net, udest->addr.ip) == RTN_LOCAL) {
> -		conn_flags = (conn_flags & ~IP_VS_CONN_F_FWD_MASK)
> -			| IP_VS_CONN_F_LOCALNODE;
> -	}
> +#ifdef CONFIG_IP_VS_IPV6
> +	if (svc->af == AF_INET6) {
> +		if (__ip_vs_addr_is_local_v6(&udest->addr.in6)) {
> +			conn_flags = (conn_flags & ~IP_VS_CONN_F_FWD_MASK)
> +				| IP_VS_CONN_F_LOCALNODE;
> +		}
> +	} else
> +#endif
> +		if (inet_addr_type(&init_net, udest->addr.ip) == RTN_LOCAL) {
> +			conn_flags = (conn_flags & ~IP_VS_CONN_F_FWD_MASK)
> +				| IP_VS_CONN_F_LOCALNODE;
> +		}
>  
>  	/* set the IP_VS_CONN_F_NOOUTPUT flag if not masquerading/NAT */
>  	if ((conn_flags & IP_VS_CONN_F_FWD_MASK) != 0) {
> @@ -802,9 +831,19 @@ ip_vs_new_dest(struct ip_vs_service *svc, struct ip_vs_dest_user_kern *udest,
>  
>  	EnterFunction(2);
>  
> -	atype = inet_addr_type(&init_net, udest->addr.ip);
> -	if (atype != RTN_LOCAL && atype != RTN_UNICAST)
> -		return -EINVAL;
> +#ifdef CONFIG_IP_VS_IPV6
> +	if (svc->af == AF_INET6) {
> +		atype = ipv6_addr_type(&udest->addr.in6);
> +		if (!(atype & IPV6_ADDR_UNICAST) &&
> +			!__ip_vs_addr_is_local_v6(&udest->addr.in6))
> +			return -EINVAL;
> +	} else
> +#endif
> +	{
> +		atype = inet_addr_type(&init_net, udest->addr.ip);
> +		if (atype != RTN_LOCAL && atype != RTN_UNICAST)
> +			return -EINVAL;
> +	}
>  
>  	dest = kzalloc(sizeof(struct ip_vs_dest), GFP_ATOMIC);
>  	if (dest == NULL) {
> -- 
> 1.5.4.5

  reply	other threads:[~2008-09-02  7:57 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-01 12:55 [PATCHv2 RFC 00/00] Add first IPv6 support to IPVS Julius Volz
2008-09-01 12:55 ` [PATCHv2 RFC 01/25] IPVS: Add CONFIG_IP_VS_IPV6 option for IPv6 support Julius Volz
2008-09-01 12:55 ` [PATCHv2 RFC 02/25] IPVS: Change IPVS data structures to support IPv6 addresses Julius Volz
2008-09-02  5:23   ` Simon Horman
2008-09-02  5:53     ` Simon Horman
2008-09-02  6:08   ` Simon Horman
2008-09-01 12:56 ` [PATCHv2 RFC 03/25] IPVS: Add general v4/v6 helper functions / data structures Julius Volz
2008-09-01 12:56 ` [PATCHv2 RFC 04/25] IPVS: Add debug macros for v4 and v6 address output Julius Volz
2008-09-01 12:56 ` [PATCHv2 RFC 05/25] IPVS: Add internal versions of sockopt interface structs Julius Volz
2008-09-02  6:06   ` Simon Horman
2008-09-01 12:56 ` [PATCHv2 RFC 06/25] IPVS: Convert __ip_vs_svc_get() and __ip_vs_fwm_get() Julius Volz
2008-09-01 12:56 ` [PATCHv2 RFC 07/25] IPVS: Add v6 support to ip_vs_service_get() Julius Volz
2008-09-01 12:56 ` [PATCHv2 RFC 08/25] IPVS: Add IPv6 support flag to schedulers Julius Volz
2008-09-01 12:56 ` [PATCHv2 RFC 09/25] IPVS: Add 'af' args to protocol handler functions Julius Volz
2008-09-02  6:26   ` Simon Horman
2008-09-01 12:56 ` [PATCHv2 RFC 10/25] IPVS: Add protocol debug functions for IPv6 Julius Volz
2008-09-01 12:56 ` [PATCHv2 RFC 11/25] IPVS: Extend protocol DNAT/SNAT and state handlers Julius Volz
2008-09-01 12:56 ` [PATCHv2 RFC 12/25] IPVS: Extend functions for getting/creating connections Julius Volz
2008-09-02  6:47   ` Simon Horman
2008-09-01 12:56 ` [PATCHv2 RFC 13/25] IPVS: Add IPv6 support to xmit() support functions Julius Volz
2008-09-02 22:28   ` Simon Horman
2008-09-03  8:43     ` Julius Volz
2008-09-03  8:48       ` Simon Horman
2008-09-01 12:56 ` [PATCHv2 RFC 14/25] IPVS: Add and bind IPv6 xmit functions Julius Volz
2008-09-02  7:32   ` Simon Horman
2008-09-01 12:56 ` [PATCHv2 RFC 15/25] IPVS: Extend scheduling functions for IPv6 support Julius Volz
2008-09-01 12:56 ` [PATCHv2 RFC 16/25] IPVS: Add/adjust Netfilter hook functions and helpers for v6 Julius Volz
2008-09-02  7:40   ` Simon Horman
2008-09-02 13:34     ` Julius Volz
2008-09-01 12:56 ` [PATCHv2 RFC 17/25] IPVS: Convert real server lookup functions Julius Volz
2008-09-02  7:46   ` Simon Horman
2008-09-01 12:56 ` [PATCHv2 RFC 18/25] IPVS: Convert procfs files for IPv6 entry output Julius Volz
2008-09-02  7:49   ` Simon Horman
2008-09-01 12:56 ` [PATCHv2 RFC 19/25] IVPS: Disable sync daemon for IPv6 connections Julius Volz
2008-09-01 12:56 ` [PATCHv2 RFC 20/25] IPVS: Turn off FTP application helper for IPv6 Julius Volz
2008-09-01 12:56 ` [PATCHv2 RFC 21/25] IPVS: Add function to determine if IPv6 address is local Julius Volz
2008-09-02  7:57   ` Simon Horman [this message]
2008-09-01 12:56 ` [PATCHv2 RFC 22/25] IPVS: Adjust various debug outputs to use new macros Julius Volz
2008-09-02  8:00   ` Simon Horman
2008-09-01 12:56 ` [PATCHv2 RFC 23/25] IPVS: Activate IPv6 Netfilter hooks Julius Volz
2008-09-01 12:56 ` [PATCHv2 RFC 24/25] IPVS: Allow adding IPv6 services from userspace Julius Volz
2008-09-01 12:56 ` [PATCHv2 RFC 25/25] IPVS: Add changelog notes to header comments Julius Volz
2008-09-02  2:25   ` Stephen Hemminger
2008-09-02  9:22     ` Julius Volz
2008-09-02  8:18 ` [PATCHv2 RFC 00/00] Add first IPv6 support to IPVS Simon Horman
2008-09-02  9:22   ` 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=20080902075718.GK13730@verge.net.au \
    --to=horms@verge.net.au \
    --cc=juliusv@google.com \
    --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).