netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Ahern <dsahern@gmail.com>
To: Mike Manning <mmanning@vyatta.att-mail.com>, netdev@vger.kernel.org
Cc: Dewi Morgan <morgand@vyatta.att-mail.com>
Subject: Re: [PATCH net-next v1 4/5] ipv6: do not drop vrf udp multicast packets
Date: Mon, 24 Sep 2018 17:21:46 -0600	[thread overview]
Message-ID: <f24cd29e-2cba-0a07-13a8-a8192dca4e2f@gmail.com> (raw)
In-Reply-To: <20180924161326.17167-5-mmanning@vyatta.att-mail.com>

On 9/24/18 10:13 AM, Mike Manning wrote:
> From: Dewi Morgan <morgand@vyatta.att-mail.com>
> 
> For bound udp sockets in a vrf, also check the sdif to get the index
> for ingress devices enslaved to an l3mdev. Verify the multicast address
> against the enslaved rather than the l3mdev device.
> 
> Signed-off-by: Dewi Morgan <morgand@vyatta.att-mail.com>
> Signed-off-by: Mike Manning <mmanning@vyatta.att-mail.com>
> ---
>  net/ipv6/ip6_input.c | 24 ++++++++++++++++++++----
>  net/ipv6/udp.c       |  8 +++++---
>  2 files changed, 25 insertions(+), 7 deletions(-)
> 

This should be 2 patches -- 1 that modifies the socket lookup to
consider and 1 that alters in the input path. They are completely
separate changes.


> diff --git a/net/ipv6/ip6_input.c b/net/ipv6/ip6_input.c
> index 108f5f88ec98..82ffb5cdd2ab 100644
> --- a/net/ipv6/ip6_input.c
> +++ b/net/ipv6/ip6_input.c
> @@ -324,11 +324,14 @@ void ipv6_list_rcv(struct list_head *head, struct packet_type *pt,
>  static int ip6_input_finish(struct net *net, struct sock *sk, struct sk_buff *skb)
>  {
>  	const struct inet6_protocol *ipprot;
> +	int sdif = inet6_sdif(skb);
> +	bool have_final = false;
>  	struct inet6_dev *idev;
> +	struct net_device *dev;

make sdif and dev declarations local to where they are needed.


>  	unsigned int nhoff;
> +	bool deliver;

deliver is not needed.

>  	int nexthdr;
>  	bool raw;
> -	bool have_final = false;

so no need to move this one.

>  
>  	/*
>  	 *	Parse extension headers
> @@ -371,9 +374,22 @@ static int ip6_input_finish(struct net *net, struct sock *sk, struct sk_buff *sk
>  			skb_postpull_rcsum(skb, skb_network_header(skb),
>  					   skb_network_header_len(skb));
>  			hdr = ipv6_hdr(skb);
> -			if (ipv6_addr_is_multicast(&hdr->daddr) &&
> -			    !ipv6_chk_mcast_addr(skb->dev, &hdr->daddr,
> -			    &hdr->saddr) &&
> +
> +			/* skb->dev passed may be master dev for vrfs. */
> +			if (sdif) {
> +				dev = dev_get_by_index_rcu(dev_net(skb->dev),

net is a passed in argument. Why not use it?

> +							   sdif);
> +				if (!dev) {
> +					kfree_skb(skb);
> +					return -ENODEV;

The rcu_read_lock() is held. I believe 'goto discard' is sufficient if
the enslaved device disappeared.

> +				}
> +			} else {
> +				dev = skb->dev;
> +			}
> +
> +			deliver = ipv6_chk_mcast_addr(dev, &hdr->daddr,
> +						      &hdr->saddr);
> +			if (ipv6_addr_is_multicast(&hdr->daddr) && !deliver &&
>  			    !ipv6_is_mld(skb, nexthdr, skb_network_header_len(skb)))
>  				goto discard;
>  		}

I think the original code only needs skb->dev changed to dev making this
a much smaller patch.

  reply	other threads:[~2018-09-25  5:26 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-24 16:13 [PATCH net-next v1 0/5] vrf: allow simultaneous service instances in default and other VRFs Mike Manning
2018-09-24 16:13 ` [PATCH net-next v1 1/5] net: allow binding socket in a VRF when there's an unbound socket Mike Manning
2018-09-24 22:44   ` David Ahern
2018-09-25 15:26     ` Mike Manning
2018-09-25 17:16       ` David Ahern
2018-10-01  8:48         ` Mike Manning
2018-09-24 16:13 ` [PATCH net-next v1 2/5] ipv6: allow link-local and multicast packets inside vrf Mike Manning
2018-09-24 23:39   ` David Ahern
2018-09-24 16:13 ` [PATCH net-next v1 3/5] ipv4: Allow sending multicast packets on specific i/f using VRF socket Mike Manning
2018-09-24 23:04   ` David Ahern
2018-09-24 16:13 ` [PATCH net-next v1 4/5] ipv6: do not drop vrf udp multicast packets Mike Manning
2018-09-24 23:21   ` David Ahern [this message]
2018-09-24 16:13 ` [PATCH net-next v1 5/5] ipv6: add vrf table handling code for ipv6 mcast Mike Manning
2018-09-24 20:13   ` David Ahern
2018-09-24 23:23   ` David Ahern

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=f24cd29e-2cba-0a07-13a8-a8192dca4e2f@gmail.com \
    --to=dsahern@gmail.com \
    --cc=mmanning@vyatta.att-mail.com \
    --cc=morgand@vyatta.att-mail.com \
    --cc=netdev@vger.kernel.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 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).