From: David Ahern <dsahern@gmail.com>
To: Stephen Suryaputra <ssuryaextr@gmail.com>, netdev@vger.kernel.org
Subject: Re: [PATCH net] vrf: check forwarding on the original netdevice when generating ICMP dest unreachable
Date: Tue, 27 Feb 2018 20:28:50 -0700 [thread overview]
Message-ID: <c433c7f7-987a-a89e-9c4c-e4210289a474@gmail.com> (raw)
In-Reply-To: <1519756613-11962-1-git-send-email-ssuryaextr@gmail.com>
On 2/27/18 11:36 AM, Stephen Suryaputra wrote:
> When ip_error() is called the device is the l3mdev master instead of the
> original device. So the forwarding check should be on the original one.
>
> Signed-off-by: Stephen Suryaputra <ssuryaextr@gmail.com>
> ---
> net/ipv4/route.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/net/ipv4/route.c b/net/ipv4/route.c
> index a4f44d8..2274503 100644
> --- a/net/ipv4/route.c
> +++ b/net/ipv4/route.c
> @@ -933,6 +933,7 @@ static int ip_error(struct sk_buff *skb)
> struct in_device *in_dev = __in_dev_get_rcu(skb->dev);
> struct rtable *rt = skb_rtable(skb);
> struct inet_peer *peer;
> + int in_dev_forward;
> unsigned long now;
> struct net *net;
> bool send;
> @@ -943,7 +944,13 @@ static int ip_error(struct sk_buff *skb)
> goto out;
>
> net = dev_net(rt->dst.dev);
> - if (!IN_DEV_FORWARD(in_dev)) {
> + if (netif_is_l3_master(skb->dev)) {
> + in_dev_forward = IN_DEV_FORWARD(
> + __in_dev_get_rcu(__dev_get_by_index(net, IPCB(skb)->iif)));
I think this should be something like:
struct net_device *dev = skb->dev;
struct in_device *in_dev;
if (netif_is_l3_master(skb->dev))
dev = __dev_get_by_index(net, IPCB(skb)->iif);
in_dev = __in_dev_get_rcu(dev);
The rest can stay; all you really need is to reset the device on which
the __in_dev_get_rcu is done.
> + } else {
> + in_dev_forward = IN_DEV_FORWARD(in_dev);
> + }
> + if (!in_dev_forward) {
> switch (rt->dst.error) {
> case EHOSTUNREACH:
> __IP_INC_STATS(net, IPSTATS_MIB_INADDRERRORS);
>
prev parent reply other threads:[~2018-02-28 3:28 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-27 18:36 [PATCH net] vrf: check forwarding on the original netdevice when generating ICMP dest unreachable Stephen Suryaputra
2018-02-28 3:28 ` David Ahern [this message]
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=c433c7f7-987a-a89e-9c4c-e4210289a474@gmail.com \
--to=dsahern@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=ssuryaextr@gmail.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).