Netdev List
 help / color / mirror / Atom feed
From: Jiri Pirko <jiri@resnulli.us>
To: Yunsheng Lin <linyunsheng@huawei.com>
Cc: netdev@vger.kernel.org, davem@davemloft.net, yotamg@mellanox.com,
	idosch@mellanox.com, mlxsw@mellanox.com,
	nikolay@cumulusnetworks.com, andrew@lunn.ch
Subject: Re: [patch net-next v2 06/12] net: mroute: Check if rule is a default rule
Date: Mon, 25 Sep 2017 11:45:08 +0200	[thread overview]
Message-ID: <20170925094508.GC1899@nanopsycho> (raw)
In-Reply-To: <93dcea9d-94eb-39cf-4102-e5c59fb2dfa5@huawei.com>

Mon, Sep 25, 2017 at 03:28:21AM CEST, linyunsheng@huawei.com wrote:
>Hi, Jiri
>
>On 2017/9/25 1:22, Jiri Pirko wrote:
>> From: Yotam Gigi <yotamg@mellanox.com>
>> 
>> 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: Yotam Gigi <yotamg@mellanox.com>
>> Reviewed-by: Ido Schimmel <idosch@mellanox.com>
>> Signed-off-by: Jiri Pirko <jiri@mellanox.com>
>> ---
>>  include/linux/mroute.h |  7 +++++++
>>  net/ipv4/ipmr.c        | 10 ++++++++++
>>  2 files changed, 17 insertions(+)
>> 
>> diff --git a/include/linux/mroute.h b/include/linux/mroute.h
>> index 5566580..b072a84 100644
>> --- a/include/linux/mroute.h
>> +++ b/include/linux/mroute.h
>> @@ -5,6 +5,7 @@
>>  #include <linux/pim.h>
>>  #include <linux/rhashtable.h>
>>  #include <net/sock.h>
>> +#include <net/fib_rules.h>
>>  #include <net/fib_notifier.h>
>>  #include <uapi/linux/mroute.h>
>>  
>> @@ -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_compat_ioctl(struct sock *sk, unsigned int cmd, void __user *arg);
>>  int ip_mr_init(void);
>> +bool ipmr_rule_default(const struct fib_rule *rule);
>>  #else
>>  static inline int ip_mroute_setsockopt(struct sock *sock, int optname,
>>  				       char __user *optval, unsigned int optlen)
>> @@ -46,6 +48,11 @@ static inline int ip_mroute_opt(int opt)
>>  {
>>  	return 0;
>>  }
>> +
>> +static inline bool ipmr_rule_default(const struct fib_rule *rule)
>> +{
>> +	return true;
>> +}
>>  #endif
>>  
>>  struct vif_device {
>> diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
>> index 2a795d2..a714f55 100644
>> --- a/net/ipv4/ipmr.c
>> +++ b/net/ipv4/ipmr.c
>> @@ -320,6 +320,16 @@ static unsigned int ipmr_rules_seq_read(struct net *net)
>>  }
>>  #endif
>>  
>> +bool ipmr_rule_default(const struct fib_rule *rule)
>> +{
>> +#if IS_ENABLED(CONFIG_FIB_RULES)
>> +	return fib_rule_matchall(rule) && rule->table == RT_TABLE_DEFAULT;
>> +#else
>> +	return true;
>> +#endif
>
>In patch 02, You have the following, can you do the same for the above?
>+#ifdef CONFIG_IP_MROUTE
>+void ipmr_cache_free(struct mfc_cache *mfc_cache);
>+#else
>+static inline void ipmr_cache_free(struct mfc_cache *mfc_cache)
>+{
>+}
>+#endif

I don't believe this is necessary. The solution you described is often
used in headers. But here, I'm ok with the current code.


>
>> +}
>> +EXPORT_SYMBOL(ipmr_rule_default);
>> +
>>  static inline int ipmr_hash_cmp(struct rhashtable_compare_arg *arg,
>>  				const void *ptr)
>>  {
>> 
>

  parent reply	other threads:[~2017-09-25  9:45 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-24 17:22 [patch net-next v2 00/12] mlxsw: Add support for offloading IPv4 multicast routes Jiri Pirko
2017-09-24 17:22 ` [patch net-next v2 01/12] fib: notifier: Add VIF add and delete event types Jiri Pirko
2017-09-25  9:20   ` Nikolay Aleksandrov
2017-09-24 17:22 ` [patch net-next v2 02/12] ipmr: Add reference count to MFC entries Jiri Pirko
2017-09-25  9:27   ` Nikolay Aleksandrov
2017-09-24 17:22 ` [patch net-next v2 03/12] ipmr: Add FIB notification access functions Jiri Pirko
2017-09-25  1:19   ` Yunsheng Lin
2017-09-25  5:38     ` Yotam Gigi
2017-09-25  6:32       ` Yunsheng Lin
2017-09-25  9:35   ` Nikolay Aleksandrov
2017-09-25  9:40     ` Nikolay Aleksandrov
2017-09-25  9:47       ` Jiri Pirko
2017-09-25  9:59         ` Nikolay Aleksandrov
2017-09-24 17:22 ` [patch net-next v2 04/12] ipmr: Send FIB notifications on MFC and VIF entries Jiri Pirko
2017-09-24 17:22 ` [patch net-next v2 05/12] net: ipmr: Add MFC offload indication Jiri Pirko
2017-09-25  9:36   ` Nikolay Aleksandrov
2017-09-25 11:21     ` Yotam Gigi
2017-09-24 17:22 ` [patch net-next v2 06/12] net: mroute: Check if rule is a default rule Jiri Pirko
2017-09-25  1:28   ` Yunsheng Lin
2017-09-25  5:39     ` Yotam Gigi
2017-09-25  9:45     ` Jiri Pirko [this message]
2017-09-25 10:02       ` Nikolay Aleksandrov
2017-09-25 13:37         ` Yotam Gigi
2017-09-25  9:38   ` Nikolay Aleksandrov
2017-09-24 17:22 ` [patch net-next v2 07/12] mlxsw: spectrum: Add the multicast routing offloading logic Jiri Pirko
2017-09-25  1:48   ` Yunsheng Lin
2017-09-25  5:55     ` Yotam Gigi
2017-09-25 10:40   ` Nikolay Aleksandrov
2017-09-25 10:53     ` Yotam Gigi
2017-09-24 17:22 ` [patch net-next v2 08/12] mlxsw: spectrum: Add the multicast routing hardware logic Jiri Pirko
2017-09-24 17:22 ` [patch net-next v2 09/12] mlxsw: spectrum: router: Squash the default route table to main Jiri Pirko
2017-09-24 17:22 ` [patch net-next v2 10/12] mlxsw: spectrum_router: Add multicast routes notification handling functionality Jiri Pirko
2017-09-24 17:22 ` [patch net-next v2 11/12] mlxsw: spectrum: Notify multicast router on RIF MTU changes Jiri Pirko
2017-09-24 17:22 ` [patch net-next v2 12/12] mlxsw: spectrum: router: Don't ignore IPMR notifications Jiri Pirko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170925094508.GC1899@nanopsycho \
    --to=jiri@resnulli.us \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=idosch@mellanox.com \
    --cc=linyunsheng@huawei.com \
    --cc=mlxsw@mellanox.com \
    --cc=netdev@vger.kernel.org \
    --cc=nikolay@cumulusnetworks.com \
    --cc=yotamg@mellanox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox