Skip to contentSkip to conversation

vrf: check forwarding on the original netdevice when generating ICMP dest unreachable

PATCH Superseded Stephen Suryaputra 2 participants 2 messages Feb 27, 2018 – Feb 28, 2018

Subsystems (3)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vrf: check forwarding on the original netdevice when generating ICMP dest unreachable

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.

---
 net/ipv4/route.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
net/ipv4/route.c +8 -1
index a4f44d8..2274503 100644
@@ -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)));
+	} 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);
Signature · 1 line
2.7.4
#1 lore raw
Quoted 21 lines · Stephen Suryaputra

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.

---
 net/ipv4/route.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
net/ipv4/route.c +1 -0
index a4f44d8..2274503 100644
@@ -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;

net/ipv4/route.c static int ip_error(struct sk_buff *skb) · line 949

Quoted 7 lines
net/ipv4/route.c +3 -1
@@ -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.

Quoted 8 lines
net/ipv4/route.c +4 -0
+	} 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);