diff mbox series

[RFC,net-next,05/22] nexthop: Add nexthop notification data structures

Message ID 20200908091037.2709823-6-idosch@idosch.org
State RFC
Delegated to: David Miller
Headers show
Series nexthop: Add support for nexthop objects offload | expand

Commit Message

Ido Schimmel Sept. 8, 2020, 9:10 a.m. UTC
From: Ido Schimmel <idosch@nvidia.com>

Add data structures that will be used for nexthop replace and delete
notifications in the previously introduced nexthop notification chain.

New data structures are added instead of passing the existing nexthop
code structures directly for several reasons.

First, the existing structures encode a lot of bookkeeping information
which is irrelevant for listeners of the notification chain.

Second, the existing structures can be changed without worrying about
introducing regressions in listeners since they are not accessed
directly by them.

Third, listeners of the notification chain do not need to each parse the
relatively complex nexthop code structures. They are passing the
required information in a simplified way.

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
---
 include/net/nexthop.h | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

Comments

David Ahern Sept. 8, 2020, 2:43 p.m. UTC | #1
On 9/8/20 3:10 AM, Ido Schimmel wrote:
> From: Ido Schimmel <idosch@nvidia.com>
> 
> Add data structures that will be used for nexthop replace and delete
> notifications in the previously introduced nexthop notification chain.
> 
> New data structures are added instead of passing the existing nexthop
> code structures directly for several reasons.
> 
> First, the existing structures encode a lot of bookkeeping information
> which is irrelevant for listeners of the notification chain.
> 
> Second, the existing structures can be changed without worrying about
> introducing regressions in listeners since they are not accessed
> directly by them.
> 
> Third, listeners of the notification chain do not need to each parse the
> relatively complex nexthop code structures. They are passing the
> required information in a simplified way.

agreed. My preference is for only nexthop.{c,h} to understand and parse
the nexthop structs.


> 
> Signed-off-by: Ido Schimmel <idosch@nvidia.com>
> ---
>  include/net/nexthop.h | 35 +++++++++++++++++++++++++++++++++++
>  1 file changed, 35 insertions(+)
> 
> diff --git a/include/net/nexthop.h b/include/net/nexthop.h
> index 2e44efe5709b..0bde1aa867c0 100644
> --- a/include/net/nexthop.h
> +++ b/include/net/nexthop.h
> @@ -109,6 +109,41 @@ enum nexthop_event_type {
>  	NEXTHOP_EVENT_DEL
>  };
>  
> +struct nh_notifier_single_info {
> +	struct net_device *dev;
> +	u8 gw_family;
> +	union {
> +		__be32 ipv4;
> +		struct in6_addr ipv6;
> +	};
> +	u8 is_reject:1,
> +	   is_fdb:1,
> +	   is_encap:1;

use has_encap since it refers to a configuration of a nexthop versus a
nexthop type.

I take it this is a placeholder until lwt offload is supported?

besides the naming nit,

Reviewed-by: David Ahern <dsahern@gmail.com>
Ido Schimmel Sept. 11, 2020, 2:50 p.m. UTC | #2
On Tue, Sep 08, 2020 at 08:43:10AM -0600, David Ahern wrote:
> On 9/8/20 3:10 AM, Ido Schimmel wrote:
> > From: Ido Schimmel <idosch@nvidia.com>
> > 
> > Add data structures that will be used for nexthop replace and delete
> > notifications in the previously introduced nexthop notification chain.
> > 
> > New data structures are added instead of passing the existing nexthop
> > code structures directly for several reasons.
> > 
> > First, the existing structures encode a lot of bookkeeping information
> > which is irrelevant for listeners of the notification chain.
> > 
> > Second, the existing structures can be changed without worrying about
> > introducing regressions in listeners since they are not accessed
> > directly by them.
> > 
> > Third, listeners of the notification chain do not need to each parse the
> > relatively complex nexthop code structures. They are passing the
> > required information in a simplified way.
> 
> agreed. My preference is for only nexthop.{c,h} to understand and parse
> the nexthop structs.
> 
> 
> > 
> > Signed-off-by: Ido Schimmel <idosch@nvidia.com>
> > ---
> >  include/net/nexthop.h | 35 +++++++++++++++++++++++++++++++++++
> >  1 file changed, 35 insertions(+)
> > 
> > diff --git a/include/net/nexthop.h b/include/net/nexthop.h
> > index 2e44efe5709b..0bde1aa867c0 100644
> > --- a/include/net/nexthop.h
> > +++ b/include/net/nexthop.h
> > @@ -109,6 +109,41 @@ enum nexthop_event_type {
> >  	NEXTHOP_EVENT_DEL
> >  };
> >  
> > +struct nh_notifier_single_info {
> > +	struct net_device *dev;
> > +	u8 gw_family;
> > +	union {
> > +		__be32 ipv4;
> > +		struct in6_addr ipv6;
> > +	};
> > +	u8 is_reject:1,
> > +	   is_fdb:1,
> > +	   is_encap:1;
> 
> use has_encap since it refers to a configuration of a nexthop versus a
> nexthop type.

Will change.

> 
> I take it this is a placeholder until lwt offload is supported?

Yes, I will mention this in the commit message. I didn't bother parsing
all the encap configuration into the struct since no listener is going
to look at it. Only added this bit so that listeners could reject
nexthops that perform encapsulation.

> 
> besides the naming nit,
> 
> Reviewed-by: David Ahern <dsahern@gmail.com>

Thanks for the prompt review, David!
diff mbox series

Patch

diff --git a/include/net/nexthop.h b/include/net/nexthop.h
index 2e44efe5709b..0bde1aa867c0 100644
--- a/include/net/nexthop.h
+++ b/include/net/nexthop.h
@@ -109,6 +109,41 @@  enum nexthop_event_type {
 	NEXTHOP_EVENT_DEL
 };
 
+struct nh_notifier_single_info {
+	struct net_device *dev;
+	u8 gw_family;
+	union {
+		__be32 ipv4;
+		struct in6_addr ipv6;
+	};
+	u8 is_reject:1,
+	   is_fdb:1,
+	   is_encap:1;
+};
+
+struct nh_notifier_grp_entry_info {
+	u8 weight;
+	u32 id;
+	struct nh_notifier_single_info nh;
+};
+
+struct nh_notifier_grp_info {
+	u16 num_nh;
+	bool is_fdb;
+	struct nh_notifier_grp_entry_info nh_entries[];
+};
+
+struct nh_notifier_info {
+	struct net *net;
+	struct netlink_ext_ack *extack;
+	u32 id;
+	bool is_grp;
+	union {
+		struct nh_notifier_single_info *nh;
+		struct nh_notifier_grp_info *nh_grp;
+	};
+};
+
 int register_nexthop_notifier(struct net *net, struct notifier_block *nb);
 int unregister_nexthop_notifier(struct net *net, struct notifier_block *nb);