Commit 478e4c2f authored by Yotam Gigi's avatar Yotam Gigi Committed by David S. Miller

net: mroute: Check if rule is a default rule

When the ipmr starts, it adds one default FIB rule that matches all packets
and sends them to the DEFAULT (multicast) FIB table. A more complex rule
can be added by user to specify that for a specific interface, a packet
should be look up at either an arbitrary table or according to the l3mdev
of the interface.

For drivers willing to offload the ipmr logic into a hardware but don't
want to offload all the FIB rules functionality, provide a function that
can indicate whether the FIB rule is the default multicast rule, thus only
one routing table is needed.

This way, a driver can register to the FIB notification chain, get
notifications about FIB rules added and trigger some kind of an internal
abort mechanism when a non default rule is added by the user.
Signed-off-by: default avatarYotam Gigi <yotamg@mellanox.com>
Reviewed-by: default avatarIdo Schimmel <idosch@mellanox.com>
Signed-off-by: default avatarJiri Pirko <jiri@mellanox.com>
Reviewed-by: default avatarNikolay Aleksandrov <nikolay@cumulusnetworks.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c7c0bbea
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include <linux/pim.h> #include <linux/pim.h>
#include <linux/rhashtable.h> #include <linux/rhashtable.h>
#include <net/sock.h> #include <net/sock.h>
#include <net/fib_rules.h>
#include <net/fib_notifier.h> #include <net/fib_notifier.h>
#include <uapi/linux/mroute.h> #include <uapi/linux/mroute.h>
...@@ -19,6 +20,7 @@ int ip_mroute_getsockopt(struct sock *, int, char __user *, int __user *); ...@@ -19,6 +20,7 @@ int ip_mroute_getsockopt(struct sock *, int, char __user *, int __user *);
int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg); int ipmr_ioctl(struct sock *sk, int cmd, void __user *arg);
int ipmr_compat_ioctl(struct sock *sk, unsigned int cmd, void __user *arg); int ipmr_compat_ioctl(struct sock *sk, unsigned int cmd, void __user *arg);
int ip_mr_init(void); int ip_mr_init(void);
bool ipmr_rule_default(const struct fib_rule *rule);
#else #else
static inline int ip_mroute_setsockopt(struct sock *sock, int optname, static inline int ip_mroute_setsockopt(struct sock *sock, int optname,
char __user *optval, unsigned int optlen) char __user *optval, unsigned int optlen)
...@@ -46,6 +48,11 @@ static inline int ip_mroute_opt(int opt) ...@@ -46,6 +48,11 @@ static inline int ip_mroute_opt(int opt)
{ {
return 0; return 0;
} }
static inline bool ipmr_rule_default(const struct fib_rule *rule)
{
return true;
}
#endif #endif
struct vif_device { struct vif_device {
......
...@@ -274,6 +274,12 @@ static unsigned int ipmr_rules_seq_read(struct net *net) ...@@ -274,6 +274,12 @@ static unsigned int ipmr_rules_seq_read(struct net *net)
{ {
return fib_rules_seq_read(net, RTNL_FAMILY_IPMR); return fib_rules_seq_read(net, RTNL_FAMILY_IPMR);
} }
bool ipmr_rule_default(const struct fib_rule *rule)
{
return fib_rule_matchall(rule) && rule->table == RT_TABLE_DEFAULT;
}
EXPORT_SYMBOL(ipmr_rule_default);
#else #else
#define ipmr_for_each_table(mrt, net) \ #define ipmr_for_each_table(mrt, net) \
for (mrt = net->ipv4.mrt; mrt; mrt = NULL) for (mrt = net->ipv4.mrt; mrt; mrt = NULL)
...@@ -318,6 +324,12 @@ static unsigned int ipmr_rules_seq_read(struct net *net) ...@@ -318,6 +324,12 @@ static unsigned int ipmr_rules_seq_read(struct net *net)
{ {
return 0; return 0;
} }
bool ipmr_rule_default(const struct fib_rule *rule)
{
return true;
}
EXPORT_SYMBOL(ipmr_rule_default);
#endif #endif
static inline int ipmr_hash_cmp(struct rhashtable_compare_arg *arg, static inline int ipmr_hash_cmp(struct rhashtable_compare_arg *arg,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment