Subject: Re: [PATCH 13/13] TProxy: use the interface primary IP address as a default value for --on-ip

From: Brian Haley <[email-masked]>
Date: Mon, 21 Sep 2009 14:00:39 -0400

Balazs Scheidler wrote: 
>  #if defined(CONFIG_IPV6) || defined(CONFIG_IPV6_MODULE)
> +
> +static inline const struct in6_addr *
> +tproxy_laddr6(struct sk_buff *skb, const struct in6_addr *user_laddr, const struct in6_addr *daddr)
> +{
> +	struct inet6_dev *indev;
> +	struct inet6_ifaddr *ifa;
> +	struct in6_addr *laddr;
> +	
> +        if (!ipv6_addr_any(user_laddr))
> +                return user_laddr;
> +	
> +        laddr = NULL;
> +        rcu_read_lock();
> +        indev = __in6_dev_get(skb->dev);
> +        if (indev && (ifa = indev->addr_list)) {
> +		laddr = &ifa->addr;
> +	}
> +        rcu_read_unlock();
> +        
> +        return laddr ? laddr : daddr;
> +}

You should call ipv6_dev_get_saddr() to get a source address based on the target
destination address.

-Brian