mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	net: vrf: Add support for PREROUTING rules on vrf device
Add support for PREROUTING rules with skb->dev set to the vrf device. INPUT rules are already allowed. Provides symmetry with the output path which allows POSTROUTING rules. Signed-off-by: David Ahern <dsa@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
		
							parent
							
								
									8297f2d9ef
								
							
						
					
					
						commit
						73e20b761a
					
				
					 1 changed files with 21 additions and 0 deletions
				
			
		| 
						 | 
					@ -779,6 +779,25 @@ static int vrf_get_saddr(struct net_device *dev, struct flowi4 *fl4)
 | 
				
			||||||
	return rc;
 | 
						return rc;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static int vrf_rcv_finish(struct net *net, struct sock *sk, struct sk_buff *skb)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						return 0;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static struct sk_buff *vrf_rcv_nfhook(u8 pf, unsigned int hook,
 | 
				
			||||||
 | 
									      struct sk_buff *skb,
 | 
				
			||||||
 | 
									      struct net_device *dev)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						struct net *net = dev_net(dev);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						nf_reset(skb);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						if (NF_HOOK(pf, hook, net, NULL, skb, dev, NULL, vrf_rcv_finish) < 0)
 | 
				
			||||||
 | 
							skb = NULL;    /* kfree_skb(skb) handled by nf code */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return skb;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#if IS_ENABLED(CONFIG_IPV6)
 | 
					#if IS_ENABLED(CONFIG_IPV6)
 | 
				
			||||||
/* neighbor handling is done with actual device; do not want
 | 
					/* neighbor handling is done with actual device; do not want
 | 
				
			||||||
 * to flip skb->dev for those ndisc packets. This really fails
 | 
					 * to flip skb->dev for those ndisc packets. This really fails
 | 
				
			||||||
| 
						 | 
					@ -899,6 +918,7 @@ static struct sk_buff *vrf_ip6_rcv(struct net_device *vrf_dev,
 | 
				
			||||||
	if (need_strict)
 | 
						if (need_strict)
 | 
				
			||||||
		vrf_ip6_input_dst(skb, vrf_dev, orig_iif);
 | 
							vrf_ip6_input_dst(skb, vrf_dev, orig_iif);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						skb = vrf_rcv_nfhook(NFPROTO_IPV6, NF_INET_PRE_ROUTING, skb, vrf_dev);
 | 
				
			||||||
out:
 | 
					out:
 | 
				
			||||||
	return skb;
 | 
						return skb;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -929,6 +949,7 @@ static struct sk_buff *vrf_ip_rcv(struct net_device *vrf_dev,
 | 
				
			||||||
	dev_queue_xmit_nit(skb, vrf_dev);
 | 
						dev_queue_xmit_nit(skb, vrf_dev);
 | 
				
			||||||
	skb_pull(skb, skb->mac_len);
 | 
						skb_pull(skb, skb->mac_len);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						skb = vrf_rcv_nfhook(NFPROTO_IPV4, NF_INET_PRE_ROUTING, skb, vrf_dev);
 | 
				
			||||||
out:
 | 
					out:
 | 
				
			||||||
	return skb;
 | 
						return skb;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue