All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vlad Yasevich <vladislav.yasevich@hp.com>
To: "YOSHIFUJI Hideaki / 吉藤英明" <yoshfuji@linux-ipv6.org>
Cc: netdev@vger.kernel.org
Subject: Re: [**RFC**] [IPV6]: Support RFC3542 IPV6_PKTINFO socket option.
Date: Mon, 16 Jul 2007 11:31:28 -0400	[thread overview]
Message-ID: <469B8F50.7000906@hp.com> (raw)
In-Reply-To: <20070716.234413.103263857.yoshfuji@linux-ipv6.org>

YOSHIFUJI Hideaki / 吉藤英明 wrote:
> Hello.
> 
> This patch is just a tentative implementation of RFC3542 IPV6_PKTINFO
> sticky option, and is NOT intended to be applied so far.
> 
> We need to check if this is okay in RFC POV, anyway.

ok.  comments from just the RFC pov.

> diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
> index fe0f490..cc6e480 100644
> --- a/net/ipv6/datagram.c
> +++ b/net/ipv6/datagram.c
> @@ -496,7 +496,55 @@ int datagram_recv_ctl(struct sock *sk, struct msghdr *msg, struct sk_buff *skb)
>  	return 0;
>  }
>  
> -int datagram_send_ctl(struct msghdr *msg, struct flowi *fl,
> +int ip6_datagram_set_pktinfo(struct in6_pktinfo *src_info,
> +			     struct in6_addr *saddr,
> +			     struct flowi *fl)
> +{
> +	struct net_device *dev = NULL;
> +	int addr_type;
> +
> +	if (src_info->ipi6_ifindex) {
> +		if (fl->oif && src_info->ipi6_ifindex != fl->oif)
> +			return -EINVAL;
> +		fl->oif = src_info->ipi6_ifindex;
> +	}
> +
> +	addr_type = ipv6_addr_type(&src_info->ipi6_addr);
> +
> +	if (addr_type == IPV6_ADDR_ANY)
> +		return 0;

The above code will not fully clear the previously set option since
we are not guaranteed that fl->oif is 0.

   An   application can clear any sticky IPV6_PKTINFO option by doing a
   "regular" setsockopt with ipi6_addr being in6addr_any and
   ipi6_ifindex being zero.



> +
> +	if (saddr) {
> +		if (!ipv6_addr_any(saddr))
> +			return -EINVAL;
> +		if (!ipv6_addr_equal(&src_info->ipi6_addr, saddr))
> +			return -EINVAL;
> +	}
   
Not following the following text:
   If the ipi6_addr member is not the
   unspecified address, but the socket has already bound a source
   address, then the ipi6_addr value overrides the already-bound source
   address for this output operation only.


> +
> +	if (addr_type & IPV6_ADDR_LINKLOCAL) {
> +		if (!src_info->ipi6_ifindex)
> +			return -EINVAL;
> +		else {
> +			dev = dev_get_by_index(src_info->ipi6_ifindex);
> +			if (!dev)
> +				return -ENODEV;
> +		}
> +	}
> +	if (!ipv6_chk_addr(&src_info->ipi6_addr, dev, 0)) {
> +		if (dev)
> +			dev_put(dev);
> +		return -EINVAL;
> +	}
> +	if (dev)
> +		dev_put(dev);
> +
> +	ipv6_addr_copy(&fl->fl6_src, &src_info->ipi6_addr);

Additional checks needed for:

   IPV6_PKTINFO can also be used as a sticky option for specifying the
   socket's default source address.  However, the ipi6_addr member must
   be the unspecified address for TCP sockets, because it is not
   possible to dynamically change the source address of a TCP
   connection.  When the IPV6_PKTINFO option is specified for a TCP
   socket with a non-unspecified address, the call will fail.  This
   restriction should be applied even before the socket binds a specific
   address.


Also, see Section 6.7 for the correct interface selection rules that should
be applied as well.  Not sure if these are implemented anywhere.

Thanks
-vlad

  reply	other threads:[~2007-07-16 15:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-16 14:44 [**RFC**] [IPV6]: Support RFC3542 IPV6_PKTINFO socket option YOSHIFUJI Hideaki / 吉藤英明
2007-07-16 15:31 ` Vlad Yasevich [this message]
2007-07-16 16:55   ` YOSHIFUJI Hideaki / 吉藤英明
2007-07-16 17:47     ` Vlad Yasevich

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=469B8F50.7000906@hp.com \
    --to=vladislav.yasevich@hp.com \
    --cc=netdev@vger.kernel.org \
    --cc=yoshfuji@linux-ipv6.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.