netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vlad Yasevich <vyasevich@gmail.com>
To: Ahmed Amamou <ahmed@gandi.net>, netdev@vger.kernel.org
Cc: william@gandi.net, f.cachereul@alphalink.fr,
	Kamel Haddadou <kamel@gandi.net>
Subject: Re: [RFC PATCH 08/24] net: rbridge: Add Rbridge netlink message skeleton
Date: Wed, 24 Sep 2014 13:52:28 -0400	[thread overview]
Message-ID: <542304DC.4090105@gmail.com> (raw)
In-Reply-To: <1411573940-14079-9-git-send-email-ahmed@gandi.net>

On 09/24/2014 11:52 AM, Ahmed Amamou wrote:
> add data plane and control plane basic message skeleton
> add netlink socket registration and unregistration respectively within module init and deinit function
> 
> Signed-off-by: Ahmed Amamou <ahmed@gandi.net>
> Signed-off-by: Kamel Haddadou <kamel@gandi.net>
> ---
>  net/bridge/Makefile              |   2 +-
>  net/bridge/br.c                  |   6 ++
>  net/bridge/br_private.h          |   1 +
>  net/bridge/rbridge/rbr_netlink.c | 152 +++++++++++++++++++++++++++++++++++++++
>  net/bridge/rbridge/rbr_netlink.h |  62 ++++++++++++++++
>  5 files changed, 222 insertions(+), 1 deletion(-)
>  create mode 100644 net/bridge/rbridge/rbr_netlink.c
>  create mode 100644 net/bridge/rbridge/rbr_netlink.h
> 
> diff --git a/net/bridge/Makefile b/net/bridge/Makefile
> index 314783c..b11a22b 100644
> --- a/net/bridge/Makefile
> +++ b/net/bridge/Makefile
> @@ -18,4 +18,4 @@ bridge-$(CONFIG_BRIDGE_VLAN_FILTERING) += br_vlan.o
>  
>  obj-$(CONFIG_NETFILTER) += netfilter/
>  
> -bridge-$(CONFIG_TRILL) += rbridge/rbr.o
> +bridge-$(CONFIG_TRILL) += rbridge/rbr.o rbridge/rbr_netlink.o
> diff --git a/net/bridge/br.c b/net/bridge/br.c
> index 1a755a1..51af134 100644
> --- a/net/bridge/br.c
> +++ b/net/bridge/br.c
> @@ -178,6 +178,9 @@ static int __init br_init(void)
>  #if IS_ENABLED(CONFIG_ATM_LANE)
>  	br_fdb_test_addr_hook = br_fdb_test_addr;
>  #endif
> +#ifdef CONFIG_TRILL
> +	rbridge_register_genl();
> +#endif
>  
>  	return 0;
>  err_out4:
> @@ -210,6 +213,9 @@ static void __exit br_deinit(void)
>  	br_fdb_test_addr_hook = NULL;
>  #endif
>  
> +#ifdef CONFIG_TRILL
> +	rbridge_unregister_genl();
> +#endif
>  	br_fdb_fini();
>  }

The above #defines should be removed and inline noop stubs should
be added.

>  
> diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
> index 844c87b..6952db8 100644
> --- a/net/bridge/br_private.h
> +++ b/net/bridge/br_private.h
> @@ -21,6 +21,7 @@
>  #include <linux/if_vlan.h>
>  #ifdef CONFIG_TRILL
>  #include "rbridge/rbr_private.h"
> +#include "rbridge/rbr_netlink.h"
>  #endif
>  
>  #define BR_HASH_BITS 8
> diff --git a/net/bridge/rbridge/rbr_netlink.c b/net/bridge/rbridge/rbr_netlink.c
> new file mode 100644
> index 0000000..eb7c902
> --- /dev/null
> +++ b/net/bridge/rbridge/rbr_netlink.c
> @@ -0,0 +1,152 @@
> +/*
> + *	Generic parts
> + *	Linux ethernet Rbridge
> + *
> + *	Authors:
> + *	Ahmed AMAMOU	<ahmed@gandi.net>
> + *	Kamel Haddadou	<kamel@gandi.net>
> + *
> + *	This program is free software; you can redistribute it and/or
> + *	modify it under the terms of the GNU General Public License
> + *	as published by the Free Software Foundation; either version
> + *	2 of the License, or (at your option) any later version.
> + */
> +
> +#include <net/genetlink.h>
> +#include <net/netlink.h>
> +#include <linux/if_trill.h>
> +#include <linux/socket.h>
> +#include <linux/socket.h>
> +#include "br_private.h"
> +#include "rbr_private.h"
> +#include "rbr_netlink.h"
> +
> +static struct nla_policy attrs_policy[TRILL_ATTR_MAX + 1] = {
> +	[TRILL_ATTR_U16] = {.type = NLA_U16},
> +	[TRILL_ATTR_BIN] = {.type = NLA_UNSPEC},
> +};
> +
> +static struct genl_family trill_genl_family = {
> +	.id = GENL_ID_GENERATE,
> +	.hdrsize = sizeof(struct trill_nl_header),
> +	.name = TRILL_NL_FAMILY,
> +	.version = TRILL_NL_VERSION,
> +	.maxattr = TRILL_ATTR_MAX
> +};
> +
> +static struct genl_multicast_group trill_mcgrps[] = {
> +	[TRILL_MCGRP_OFFSET] = {.name = TRILL_MCAST_NAME,},
> +};
> +
> +static int trill_cmd_set_nicks_info(struct sk_buff *skb, struct genl_info *info)
> +{
> +	return 0;
> +}
> +
> +static int trill_cmd_get_nicks_info(struct sk_buff *skb, struct genl_info *info)
> +{
> +	return 0;
> +}
> +
> +static int trill_cmd_add_nicks_info(struct sk_buff *skb, struct genl_info *info)
> +{
> +	return 0;
> +}
> +
> +static int trill_cmd_set_treeroot_id(struct sk_buff *skb,
> +				     struct genl_info *info)
> +{
> +	return 0;
> +}
> +
> +static int trill_cmd_get_rbridge(struct sk_buff *skb, struct genl_info *info)
> +{
> +	return 0;
> +}
> +
> +static int trill_cmd_set_rbridge(struct sk_buff *skb, struct genl_info *info)
> +{
> +	return 0;
> +}
> +
> +static int trill_cmd_port_flush(struct sk_buff *skb, struct genl_info *info)
> +{
> +	return 0;
> +}
> +
> +static int trill_cmd_nick_flush(struct sk_buff *skb, struct genl_info *info)
> +{
> +	return 0;
> +}
> +
> +static struct genl_ops trill_genl_ops[] = {
> +	{
> +	 .cmd = TRILL_CMD_SET_NICKS_INFO,
> +	 .flags = GENL_ADMIN_PERM,	/* Requires CAP_NET_ADMIN privilege. */
> +	 .policy = attrs_policy,
> +	 .doit = trill_cmd_set_nicks_info,
> +	 },
> +	{
> +	 .cmd = TRILL_CMD_GET_NICKS_INFO,
> +	 .flags = GENL_ADMIN_PERM,	/* Requires CAP_NET_ADMIN privilege. */
> +	 .policy = attrs_policy,
> +	 .doit = trill_cmd_get_nicks_info,
> +	 },
> +	{
> +	 .cmd = TRILL_CMD_ADD_NICKS_INFO,
> +	 .flags = GENL_ADMIN_PERM,	/* Requires CAP_NET_ADMIN privilege. */
> +	 .policy = attrs_policy,
> +	 .doit = trill_cmd_add_nicks_info,
> +	 },
> +	{
> +	 .cmd = TRILL_CMD_SET_TREEROOT_ID,
> +	 .flags = GENL_ADMIN_PERM,	/* Requires CAP_NET_ADMIN privilege. */
> +	 .policy = attrs_policy,
> +	 .doit = trill_cmd_set_treeroot_id,
> +	 },
> +	{
> +	 .cmd = TRILL_CMD_GET_RBRIDGE,
> +	 .flags = GENL_ADMIN_PERM,	/* Requires CAP_NET_ADMIN privilege. */
> +	 .policy = attrs_policy,
> +	 .doit = trill_cmd_get_rbridge,
> +	 },
> +	{
> +	 .cmd = TRILL_CMD_SET_RBRIDGE,
> +	 .flags = GENL_ADMIN_PERM,	/* Requires CAP_NET_ADMIN privilege. */
> +	 .policy = attrs_policy,
> +	 .doit = trill_cmd_set_rbridge,
> +	 },
> +	{
> +	 .cmd = TRILL_CMD_PORT_FLUSH,
> +	 .flags = GENL_ADMIN_PERM,	/* Requires CAP_NET_ADMIN privilege. */
> +	 .doit = trill_cmd_port_flush,
> +	 },
> +	{
> +	 .cmd = TRILL_CMD_NICK_FLUSH,
> +	 .flags = GENL_ADMIN_PERM,	/* Requires CAP_NET_ADMIN privilege. */
> +	 .policy = attrs_policy,
> +	 .doit = trill_cmd_nick_flush,
> +	 },
> +};
> +
> +void __exit rbridge_unregister_genl(void)
> +{
> +	genl_unregister_family(&trill_genl_family);
> +}
> +
> +int __init rbridge_register_genl(void)
> +{
> +	int err;
> +
> +	err =
> +	    genl_register_family_with_ops_groups(&trill_genl_family,
> +						 trill_genl_ops, trill_mcgrps);
> +	if (err)
> +		goto fail_genl_register_family;
> +
> +	return 0;
> +
> + fail_genl_register_family:
> +
> +	return err;
> +}
> diff --git a/net/bridge/rbridge/rbr_netlink.h b/net/bridge/rbridge/rbr_netlink.h
> new file mode 100644
> index 0000000..0556323
> --- /dev/null
> +++ b/net/bridge/rbridge/rbr_netlink.h
> @@ -0,0 +1,62 @@
> +/*
> + *	Generic parts
> + *	Linux ethernet Rbridge
> + *
> + *	Authors:
> + *	Ahmed AMAMOU	<ahmed@gandi.net>
> + *	Kamel Haddadou	<kamel@gandi.net>
> + *
> + *	This program is free software; you can redistribute it and/or
> + *	modify it under the terms of the GNU General Public License
> + *	as published by the Free Software Foundation; either version
> + *	2 of the License, or (at your option) any later version.
> + */
> +
> +#ifndef RBR_NETLINK_H_
> +#define RBR_NETLINK_H_
> +
> +/* TRILL Generic Netlink attributes definition*/
> +#define TRILL_NL_VERSION	0x1
> +#define TRILL_NL_FAMILY		"TRILL_NL"
> +#define TRILL_MCAST_NAME	"TR_NL_MCAST"
> +#define TRILL_MCGRP_OFFSET     0
> +
> +struct trill_nl_header {
> +	int ifindex;		/* port id */
> +	int total_length;	/* message total length for mutipart messages check */
> +	int msg_number;		/* message number for multipart messages check */
> +};
> +
> +enum {
> +	TRILL_ATTR_UNSPEC,
> +	TRILL_ATTR_U16,
> +	TRILL_ATTR_BIN,
> +	__TRILL_ATTR_MAX,
> +};
> +#define TRILL_ATTR_MAX (__TRILL_ATTR_MAX-1)
> +
> +/* GET and set are from user space perspective  example TRILL_CMD_GET_BRIDGE
> + * means that the kernel will send this bridge name to userspace
> + */
> +enum {
> +	TRILL_CMD_UNSPEC,
> +	TRILL_CMD_SET_NICKS_INFO,
> +	TRILL_CMD_GET_NICKS_INFO,
> +	TRILL_CMD_ADD_NICKS_INFO,
> +	TRILL_CMD_DEL_NICK,
> +	TRILL_CMD_SET_TREEROOT_ID,
> +	TRILL_CMD_GET_RBRIDGE,
> +	TRILL_CMD_SET_RBRIDGE,
> +	TRILL_CMD_PORT_FLUSH,
> +	TRILL_CMD_NICK_FLUSH,
> +	__TRILL_CMD_MAX,
> +};
> +#define TRILL_CMD_MAX (__TRILL_CMD_MAX - 1)
> +
> +int __init rbridge_register_genl(void);
> +void __exit rbridge_unregister_genl(void);
> +
> +/* used to indicate that message is provided by kernel to user space */
> +#define KERNL_RESPONSE_INTERFACE -1
> +
> +#endif				/* RBR_NETLINK_H_ */
> 

Bridge is typically configured through rtnetlink and there is an
effort to make this configuration easier.  Switching to genl means
there will be yet another tool to configure some part of the bridge.

-vlad

  reply	other threads:[~2014-09-24 17:52 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-24 15:51 [RFC PATCH 00/24] TRILL implementation Ahmed Amamou
2014-09-24 15:51 ` [RFC PATCH 01/24] net: rbridge: add trill frame description Ahmed Amamou
2014-09-24 16:38   ` Stephen Hemminger
2014-09-24 16:48     ` William Dauchy
2014-09-24 17:26       ` Cong Wang
2014-09-24 17:34         ` William Dauchy
2014-09-24 17:01   ` Cong Wang
2014-09-24 15:51 ` [RFC PATCH 02/24] net: rbridge: Add layer 2 IS-IS Ethertype Ahmed Amamou
2014-09-24 15:51 ` [RFC PATCH 03/24] net: rbridge: Add RBridge structure Ahmed Amamou
2014-09-24 16:40   ` Stephen Hemminger
2014-09-24 16:55     ` William Dauchy
2014-09-24 17:18   ` Cong Wang
2014-09-24 15:52 ` [RFC PATCH 04/24] net: rbridge: Add CONFIG_TRILL Ahmed Amamou
2014-09-24 15:52 ` [RFC PATCH 05/24] net: rbridge: Adapt Bridge structure Ahmed Amamou
2014-09-24 20:56   ` Francois Romieu
2014-09-24 15:52 ` [RFC PATCH 06/24] net: rbridge: Enable/disable TRILL capability Ahmed Amamou
2014-09-24 17:46   ` Vlad Yasevich
2014-09-24 15:52 ` [RFC PATCH 07/24] net: rbridge: Add sysfs for trill_state Ahmed Amamou
2014-09-24 15:52 ` [RFC PATCH 08/24] net: rbridge: Add Rbridge netlink message skeleton Ahmed Amamou
2014-09-24 17:52   ` Vlad Yasevich [this message]
2014-09-24 15:52 ` [RFC PATCH 09/24] net: rbridge: Get Rbridge nickname from daemon Ahmed Amamou
2014-09-24 15:52 ` [RFC PATCH 10/24] net: rbridge: Add elected dtroot Ahmed Amamou
2014-09-25 11:30   ` Sergei Shtylyov
2014-09-24 15:52 ` [RFC PATCH 11/24] net: rbridge: Add rbr_node management function Ahmed Amamou
2014-09-25 11:24   ` Sergei Shtylyov
2014-09-24 15:52 ` [RFC PATCH 12/24] net: rbridge: Clean up rbr_node on rbridge stop Ahmed Amamou
2014-09-24 15:52 ` [RFC PATCH 13/24] net: rbridge: Add set_node function Ahmed Amamou
2014-09-25 11:34   ` Sergei Shtylyov
2014-09-24 15:52 ` [RFC PATCH 14/24] net: rbridge: Add get_node function Ahmed Amamou
2014-09-24 15:52 ` [RFC PATCH 15/24] net: rbridge: Add basic trill frame handling function Ahmed Amamou
2014-09-24 19:23   ` Francois Romieu
2014-09-24 15:52 ` [RFC PATCH 16/24] net: rbridge: Update forwarding database Ahmed Amamou
2014-09-24 15:52 ` [RFC PATCH 17/24] net: rbridge: Add test on trill flag before flood Ahmed Amamou
2014-09-24 15:52 ` [RFC PATCH 18/24] net: rbridge: Add encapsulation process Ahmed Amamou
2014-09-24 15:52 ` [RFC PATCH 19/24] net: rbridge: Add receive function Ahmed Amamou
2014-09-24 15:52 ` [RFC PATCH 20/24] net: rbridge: Add multicast recv handling Ahmed Amamou
2014-09-24 15:52 ` [RFC PATCH 21/24] net: rbridge: Add decapsulation function Ahmed Amamou
2014-09-24 15:52 ` [RFC PATCH 22/24] net: rbridge: Add rbr_fwd Ahmed Amamou
2014-09-25 11:43   ` Sergei Shtylyov
2014-09-24 15:52 ` [RFC PATCH 23/24] net: rbridge: Add rbr_multidest_fwd Ahmed Amamou
2014-09-24 15:52 ` [RFC PATCH 24/24] net: rbridge: replace net_port rx_handler Ahmed Amamou
2014-09-24 16:44 ` [RFC PATCH 00/24] TRILL implementation Stephen Hemminger
2014-09-24 16:54   ` William Dauchy
2014-09-24 17:24     ` Cong Wang
2014-09-24 17:33       ` William Dauchy
2014-09-24 20:57     ` Francois Romieu

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=542304DC.4090105@gmail.com \
    --to=vyasevich@gmail.com \
    --cc=ahmed@gandi.net \
    --cc=f.cachereul@alphalink.fr \
    --cc=kamel@gandi.net \
    --cc=netdev@vger.kernel.org \
    --cc=william@gandi.net \
    /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;
as well as URLs for NNTP newsgroup(s).