From: Stephen Suryaputra <hidden> Date: 2018-02-28 14:47:08
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.
Changes from v1:
- Only need to reset the device on which __in_dev_get_rcu() is done (per
David Ahern).
Signed-off-by: Stephen Suryaputra <redacted>
---
net/ipv4/route.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
@@ -930,19 +930,26 @@ void ip_rt_send_redirect(struct sk_buff *skb)staticintip_error(structsk_buff*skb){-structin_device*in_dev=__in_dev_get_rcu(skb->dev);structrtable*rt=skb_rtable(skb);+structnet_device*dev=skb->dev;+structin_device*in_dev;structinet_peer*peer;unsignedlongnow;structnet*net;boolsend;intcode;+net=dev_net(rt->dst.dev);++if(netif_is_l3_master(skb->dev))+dev=__dev_get_by_index(net,IPCB(skb)->iif);++in_dev=__in_dev_get_rcu(dev);+/* IP on this device is disabled. */if(!in_dev)gotoout;-net=dev_net(rt->dst.dev);if(!IN_DEV_FORWARD(in_dev)){switch(rt->dst.error){caseEHOSTUNREACH:
From: David Ahern <hidden> Date: 2018-02-28 15:49:27
On 2/28/18 7:46 AM, Stephen Suryaputra wrote:
quoted hunk
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.
Changes from v1:
- Only need to reset the device on which __in_dev_get_rcu() is done (per
David Ahern).
Signed-off-by: Stephen Suryaputra <redacted>
---
net/ipv4/route.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
Do need to handle the device disappearing.
if (!dev)
goto out;
+
+ in_dev = __in_dev_get_rcu(dev);
+
/* IP on this device is disabled. */
if (!in_dev)
goto out;
- net = dev_net(rt->dst.dev);
if (!IN_DEV_FORWARD(in_dev)) {
switch (rt->dst.error) {
case EHOSTUNREACH:
From: Stephen Suryaputra <hidden> Date: 2018-02-28 16:55:16
The concern only applies when the skb->dev is an l3mdev master, right?
After I sent v2, I'm worried that rt shouldn't be derefrenced if
in_dev is NULL. Even though I think it should be ok, it's better to
keep the original execution order. So, how about this before I put
another patch? The net for the iif is derived from skb->dev.
@@ -930,14 +930,23 @@ void ip_rt_send_redirect(struct sk_buff *skb)staticintip_error(structsk_buff*skb){-structin_device*in_dev=__in_dev_get_rcu(skb->dev);structrtable*rt=skb_rtable(skb);+structnet_device*dev=skb->dev;+structin_device*in_dev;structinet_peer*peer;unsignedlongnow;structnet*net;boolsend;intcode;+if(netif_is_l3_master(skb->dev)){+dev=__dev_get_by_index(dev_net(skb->dev),IPCB(skb)->iif);+if(!dev)+gotoout;+}++in_dev=__in_dev_get_rcu(dev);+/* IP on this device is disabled. */if(!in_dev)gotoout;
On Wed, Feb 28, 2018 at 10:49 AM, David Ahern [off-list ref] wrote:
On 2/28/18 7:46 AM, Stephen Suryaputra wrote:
quoted
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.
Changes from v1:
- Only need to reset the device on which __in_dev_get_rcu() is done (per
David Ahern).
Signed-off-by: Stephen Suryaputra <redacted>
---
net/ipv4/route.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
Do need to handle the device disappearing.
if (!dev)
goto out;
quoted
+
+ in_dev = __in_dev_get_rcu(dev);
+
/* IP on this device is disabled. */
if (!in_dev)
goto out;
- net = dev_net(rt->dst.dev);
if (!IN_DEV_FORWARD(in_dev)) {
switch (rt->dst.error) {
case EHOSTUNREACH:
From: David Ahern <hidden> Date: 2018-02-28 17:39:51
On 2/28/18 9:55 AM, Stephen Suryaputra wrote:
quoted hunk
The concern only applies when the skb->dev is an l3mdev master, right?
After I sent v2, I'm worried that rt shouldn't be derefrenced if
in_dev is NULL. Even though I think it should be ok, it's better to
keep the original execution order. So, how about this before I put
another patch? The net for the iif is derived from skb->dev.
@@ -930,14 +930,23 @@ void ip_rt_send_redirect(struct sk_buff *skb)staticintip_error(structsk_buff*skb){-structin_device*in_dev=__in_dev_get_rcu(skb->dev);structrtable*rt=skb_rtable(skb);+structnet_device*dev=skb->dev;+structin_device*in_dev;structinet_peer*peer;unsignedlongnow;structnet*net;boolsend;intcode;+if(netif_is_l3_master(skb->dev)){+dev=__dev_get_by_index(dev_net(skb->dev),IPCB(skb)->iif);+if(!dev)+gotoout;+}++in_dev=__in_dev_get_rcu(dev);+/* IP on this device is disabled. */if(!in_dev)gotoout;
Using dev_net from skb is fine, preferable really since the real ingress
device and the VRF device have to be in the same network namespace.