Przeglądaj źródła

ip6mr: Add API for default_rule fib

Add the ability to discern whether a given FIB rule notification relates
to the default rule inserted when registering ip6mr or a different one.

Would later be used by drivers wishing to offload ipv6 multicast routes
but unable to offload rules other than the default one.

Signed-off-by: Yuval Mintz <yuvalm@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Yuval Mintz 7 lat temu
rodzic
commit
d3c07e5b99
2 zmienionych plików z 17 dodań i 0 usunięć
  1. 10 0
      include/linux/mroute6.h
  2. 7 0
      net/ipv6/ip6mr.c

+ 10 - 0
include/linux/mroute6.h

@@ -8,6 +8,7 @@
 #include <net/net_namespace.h>
 #include <net/net_namespace.h>
 #include <uapi/linux/mroute6.h>
 #include <uapi/linux/mroute6.h>
 #include <linux/mroute_base.h>
 #include <linux/mroute_base.h>
+#include <net/fib_rules.h>
 
 
 #ifdef CONFIG_IPV6_MROUTE
 #ifdef CONFIG_IPV6_MROUTE
 static inline int ip6_mroute_opt(int opt)
 static inline int ip6_mroute_opt(int opt)
@@ -63,6 +64,15 @@ static inline void ip6_mr_cleanup(void)
 }
 }
 #endif
 #endif
 
 
+#ifdef CONFIG_IPV6_MROUTE_MULTIPLE_TABLES
+bool ip6mr_rule_default(const struct fib_rule *rule);
+#else
+static inline bool ip6mr_rule_default(const struct fib_rule *rule)
+{
+	return true;
+}
+#endif
+
 #define VIFF_STATIC 0x8000
 #define VIFF_STATIC 0x8000
 
 
 struct mfc6_cache_cmp_arg {
 struct mfc6_cache_cmp_arg {

+ 7 - 0
net/ipv6/ip6mr.c

@@ -268,6 +268,13 @@ static unsigned int ip6mr_rules_seq_read(struct net *net)
 {
 {
 	return fib_rules_seq_read(net, RTNL_FAMILY_IP6MR);
 	return fib_rules_seq_read(net, RTNL_FAMILY_IP6MR);
 }
 }
+
+bool ip6mr_rule_default(const struct fib_rule *rule)
+{
+	return fib_rule_matchall(rule) && rule->action == FR_ACT_TO_TBL &&
+	       rule->table == RT6_TABLE_DFLT && !rule->l3mdev;
+}
+EXPORT_SYMBOL(ip6mr_rule_default);
 #else
 #else
 #define ip6mr_for_each_table(mrt, net) \
 #define ip6mr_for_each_table(mrt, net) \
 	for (mrt = net->ipv6.mrt6; mrt; mrt = NULL)
 	for (mrt = net->ipv6.mrt6; mrt; mrt = NULL)