Skip to contentSkip to conversation

vrf: check the original netdevice for generating redirect

PATCH In review Stephen Suryaputra 3 participants 3 messages Jun 1, 2018 – Jun 3, 2018

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vrf: check the original netdevice for generating redirect

Use the right device to determine if redirect should be sent especially when using vrf. Same as well as when sending the redirect.

---
 net/ipv6/ip6_output.c | 3 ++-
 net/ipv6/ndisc.c      | 6 ++++++
 2 files changed, 8 insertions(+), 1 deletion(-)
net/ipv6/ip6_output.c +2 -1
index 7b6d168..af49f6c 100644
@@ -507,7 +507,8 @@ int ip6_forward(struct sk_buff *skb)
 	   send redirects to source routed frames.
 	   We don't send redirects to frames decapsulated from IPsec.
 	 */
-	if (skb->dev == dst->dev && opt->srcrt == 0 && !skb_sec_path(skb)) {
+	if (IP6CB(skb)->iif == dst->dev->ifindex &&
+	    opt->srcrt == 0 && !skb_sec_path(skb)) {
 		struct in6_addr *target = NULL;
 		struct inet_peer *peer;
 		struct rt6_info *rt;
net/ipv6/ndisc.c +6 -0
index 9de4dfb1..525051a 100644
@@ -1576,6 +1576,12 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
 	   ops_data_buf[NDISC_OPS_REDIRECT_DATA_SPACE], *ops_data = NULL;
 	bool ret;
 
+	if (netif_is_l3_master(skb->dev)) {
+		dev = __dev_get_by_index(dev_net(skb->dev), IPCB(skb)->iif);
+		if (!dev)
+			return;
+	}
+
 	if (ipv6_get_lladdr(dev, &saddr_buf, IFA_F_TENTATIVE)) {
 		ND_PRINTK(2, warn, "Redirect: no link-local address on %s\n",
 			  dev->name);
Signature · 1 line
2.7.4
Acked-by on v1 1/1
#2 lore raw
In reply to Stephen Suryaputra
Quoted 8 lines · Stephen Suryaputra

Use the right device to determine if redirect should be sent especially when using vrf. Same as well as when sending the redirect.

---
 net/ipv6/ip6_output.c | 3 ++-
 net/ipv6/ndisc.c      | 6 ++++++
 2 files changed, 8 insertions(+), 1 deletion(-)

skb->dev in this path is set to the vrf device if applicable, so yes the change is needed. Thanks for the fix.