Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 990078af authored by Michael Smith's avatar Michael Smith Committed by David S. Miller
Browse files

Disable rp_filter for IPsec packets



The reverse path filter interferes with IPsec subnet-to-subnet tunnels,
especially when the link to the IPsec peer is on an interface other than
the one hosting the default route.

With dynamic routing, where the peer might be reachable through eth0
today and eth1 tomorrow, it's difficult to keep rp_filter enabled unless
fake routes to the remote subnets are configured on the interface
currently used to reach the peer.

IPsec provides a much stronger anti-spoofing policy than rp_filter, so
this patch disables the rp_filter for packets with a security path.

Signed-off-by: default avatarMichael Smith <msmith@cbnco.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5c04c819
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -957,6 +957,15 @@ struct sec_path {
	struct xfrm_state	*xvec[XFRM_MAX_DEPTH];
};

static inline int secpath_exists(struct sk_buff *skb)
{
#ifdef CONFIG_XFRM
	return skb->sp != NULL;
#else
	return 0;
#endif
}

static inline struct sec_path *
secpath_get(struct sec_path *sp)
{
+5 −1
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@
#include <net/arp.h>
#include <net/ip_fib.h>
#include <net/rtnetlink.h>
#include <net/xfrm.h>

#ifndef CONFIG_IP_MULTIPLE_TABLES

@@ -211,7 +212,10 @@ int fib_validate_source(struct sk_buff *skb, __be32 src, __be32 dst, u8 tos,
	in_dev = __in_dev_get_rcu(dev);
	if (in_dev) {
		no_addr = in_dev->ifa_list == NULL;
		rpf = IN_DEV_RPFILTER(in_dev);

		/* Ignore rp_filter for packets protected by IPsec. */
		rpf = secpath_exists(skb) ? 0 : IN_DEV_RPFILTER(in_dev);

		accept_local = IN_DEV_ACCEPT_LOCAL(in_dev);
		fl4.flowi4_mark = IN_DEV_SRC_VMARK(in_dev) ? skb->mark : 0;
	}