* [PATCH net-next v1 1/2] tipc: move netlink policies to netlink.h
@ 2016-01-05 9:56 Richard Alpe
2016-01-05 9:56 ` [PATCH net-next v1 2/2] tipc: add peer removal functionality Richard Alpe
2016-01-05 21:47 ` [PATCH net-next v1 1/2] tipc: move netlink policies to netlink.h David Miller
0 siblings, 2 replies; 5+ messages in thread
From: Richard Alpe @ 2016-01-05 9:56 UTC (permalink / raw)
To: netdev; +Cc: tipc-discussion, Richard Alpe
Make the c files less cluttered and enable netlink attributes to be
shared between files. This will prove useful in a future patch where a
node message will contain a nested network.
Signed-off-by: Richard Alpe <richard.alpe@ericsson.com>
Acked-by: Jon Maloy <jon.maloy@ericsson.com>
---
net/tipc/bearer.c | 19 +-----------
net/tipc/link.c | 8 -----
net/tipc/name_table.c | 7 +----
net/tipc/net.c | 6 +---
net/tipc/netlink.c | 13 +-------
net/tipc/netlink.h | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++
net/tipc/node.c | 23 +-------------
net/tipc/socket.c | 9 +-----
net/tipc/udp_media.c | 9 +-----
9 files changed, 92 insertions(+), 87 deletions(-)
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c
index 802ffad..d654cfe 100644
--- a/net/tipc/bearer.c
+++ b/net/tipc/bearer.c
@@ -40,6 +40,7 @@
#include "link.h"
#include "discover.h"
#include "bcast.h"
+#include "netlink.h"
#define MAX_ADDR_STR 60
@@ -53,24 +54,6 @@ static struct tipc_media * const media_info_array[] = {
#endif
NULL
};
-
-static const struct nla_policy
-tipc_nl_bearer_policy[TIPC_NLA_BEARER_MAX + 1] = {
- [TIPC_NLA_BEARER_UNSPEC] = { .type = NLA_UNSPEC },
- [TIPC_NLA_BEARER_NAME] = {
- .type = NLA_STRING,
- .len = TIPC_MAX_BEARER_NAME
- },
- [TIPC_NLA_BEARER_PROP] = { .type = NLA_NESTED },
- [TIPC_NLA_BEARER_DOMAIN] = { .type = NLA_U32 }
-};
-
-static const struct nla_policy tipc_nl_media_policy[TIPC_NLA_MEDIA_MAX + 1] = {
- [TIPC_NLA_MEDIA_UNSPEC] = { .type = NLA_UNSPEC },
- [TIPC_NLA_MEDIA_NAME] = { .type = NLA_STRING },
- [TIPC_NLA_MEDIA_PROP] = { .type = NLA_NESTED }
-};
-
static void bearer_disable(struct net *net, struct tipc_bearer *b);
/**
diff --git a/net/tipc/link.c b/net/tipc/link.c
index 0c2944f..cb807be 100644
--- a/net/tipc/link.c
+++ b/net/tipc/link.c
@@ -196,14 +196,6 @@ struct tipc_link {
static const char *link_co_err = "Link tunneling error, ";
static const char *link_rst_msg = "Resetting link ";
-/* Properties valid for media, bearar and link */
-static const struct nla_policy tipc_nl_prop_policy[TIPC_NLA_PROP_MAX + 1] = {
- [TIPC_NLA_PROP_UNSPEC] = { .type = NLA_UNSPEC },
- [TIPC_NLA_PROP_PRIO] = { .type = NLA_U32 },
- [TIPC_NLA_PROP_TOL] = { .type = NLA_U32 },
- [TIPC_NLA_PROP_WIN] = { .type = NLA_U32 }
-};
-
/* Send states for broadcast NACKs
*/
enum {
diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c
index 91fce70..75992b5 100644
--- a/net/tipc/name_table.c
+++ b/net/tipc/name_table.c
@@ -44,15 +44,10 @@
#include "addr.h"
#include "node.h"
#include <net/genetlink.h>
+#include "netlink.h"
#define TIPC_NAMETBL_SIZE 1024 /* must be a power of 2 */
-static const struct nla_policy
-tipc_nl_name_table_policy[TIPC_NLA_NAME_TABLE_MAX + 1] = {
- [TIPC_NLA_NAME_TABLE_UNSPEC] = { .type = NLA_UNSPEC },
- [TIPC_NLA_NAME_TABLE_PUBL] = { .type = NLA_NESTED }
-};
-
/**
* struct name_info - name sequence publication info
* @node_list: circular list of publications made by own node
diff --git a/net/tipc/net.c b/net/tipc/net.c
index 77bf911..d7a5c11 100644
--- a/net/tipc/net.c
+++ b/net/tipc/net.c
@@ -41,11 +41,7 @@
#include "socket.h"
#include "node.h"
#include "bcast.h"
-
-static const struct nla_policy tipc_nl_net_policy[TIPC_NLA_NET_MAX + 1] = {
- [TIPC_NLA_NET_UNSPEC] = { .type = NLA_UNSPEC },
- [TIPC_NLA_NET_ID] = { .type = NLA_U32 }
-};
+#include "netlink.h"
/*
* The TIPC locking policy is designed to ensure a very fine locking
diff --git a/net/tipc/netlink.c b/net/tipc/netlink.c
index 8975b01..234cb93 100644
--- a/net/tipc/netlink.c
+++ b/net/tipc/netlink.c
@@ -42,18 +42,7 @@
#include "node.h"
#include "net.h"
#include <net/genetlink.h>
-
-static const struct nla_policy tipc_nl_policy[TIPC_NLA_MAX + 1] = {
- [TIPC_NLA_UNSPEC] = { .type = NLA_UNSPEC, },
- [TIPC_NLA_BEARER] = { .type = NLA_NESTED, },
- [TIPC_NLA_SOCK] = { .type = NLA_NESTED, },
- [TIPC_NLA_PUBL] = { .type = NLA_NESTED, },
- [TIPC_NLA_LINK] = { .type = NLA_NESTED, },
- [TIPC_NLA_MEDIA] = { .type = NLA_NESTED, },
- [TIPC_NLA_NODE] = { .type = NLA_NESTED, },
- [TIPC_NLA_NET] = { .type = NLA_NESTED, },
- [TIPC_NLA_NAME_TABLE] = { .type = NLA_NESTED, }
-};
+#include "netlink.h"
/* Users of the legacy API (tipc-config) can't handle that we add operations,
* so we have a separate genl handling for the new API.
diff --git a/net/tipc/netlink.h b/net/tipc/netlink.h
index 08a1db6..ff7a39da 100644
--- a/net/tipc/netlink.h
+++ b/net/tipc/netlink.h
@@ -36,7 +36,92 @@
#ifndef _TIPC_NETLINK_H
#define _TIPC_NETLINK_H
+#include <net/netlink.h>
+
extern struct genl_family tipc_genl_family;
+
+static const struct nla_policy tipc_nl_policy[TIPC_NLA_MAX + 1] = {
+ [TIPC_NLA_UNSPEC] = { .type = NLA_UNSPEC, },
+ [TIPC_NLA_BEARER] = { .type = NLA_NESTED, },
+ [TIPC_NLA_SOCK] = { .type = NLA_NESTED, },
+ [TIPC_NLA_PUBL] = { .type = NLA_NESTED, },
+ [TIPC_NLA_LINK] = { .type = NLA_NESTED, },
+ [TIPC_NLA_MEDIA] = { .type = NLA_NESTED, },
+ [TIPC_NLA_NODE] = { .type = NLA_NESTED, },
+ [TIPC_NLA_NET] = { .type = NLA_NESTED, },
+ [TIPC_NLA_NAME_TABLE] = { .type = NLA_NESTED, }
+};
+
+static const struct nla_policy tipc_nl_sock_policy[TIPC_NLA_SOCK_MAX + 1] = {
+ [TIPC_NLA_SOCK_UNSPEC] = { .type = NLA_UNSPEC },
+ [TIPC_NLA_SOCK_ADDR] = { .type = NLA_U32 },
+ [TIPC_NLA_SOCK_REF] = { .type = NLA_U32 },
+ [TIPC_NLA_SOCK_CON] = { .type = NLA_NESTED },
+ [TIPC_NLA_SOCK_HAS_PUBL] = { .type = NLA_FLAG }
+};
+
+static const struct nla_policy tipc_nl_net_policy[TIPC_NLA_NET_MAX + 1] = {
+ [TIPC_NLA_NET_UNSPEC] = { .type = NLA_UNSPEC },
+ [TIPC_NLA_NET_ID] = { .type = NLA_U32 }
+};
+
+static const struct nla_policy tipc_nl_node_policy[TIPC_NLA_NODE_MAX + 1] = {
+ [TIPC_NLA_NODE_UNSPEC] = { .type = NLA_UNSPEC },
+ [TIPC_NLA_NODE_ADDR] = { .type = NLA_U32 },
+ [TIPC_NLA_NODE_UP] = { .type = NLA_FLAG }
+};
+
+static const struct nla_policy tipc_nl_link_policy[TIPC_NLA_LINK_MAX + 1] = {
+ [TIPC_NLA_LINK_UNSPEC] = { .type = NLA_UNSPEC },
+ [TIPC_NLA_LINK_NAME] = { .type = NLA_STRING,
+ .len = TIPC_MAX_LINK_NAME },
+ [TIPC_NLA_LINK_MTU] = { .type = NLA_U32 },
+ [TIPC_NLA_LINK_BROADCAST] = { .type = NLA_FLAG },
+ [TIPC_NLA_LINK_UP] = { .type = NLA_FLAG },
+ [TIPC_NLA_LINK_ACTIVE] = { .type = NLA_FLAG },
+ [TIPC_NLA_LINK_PROP] = { .type = NLA_NESTED },
+ [TIPC_NLA_LINK_STATS] = { .type = NLA_NESTED },
+ [TIPC_NLA_LINK_RX] = { .type = NLA_U32 },
+ [TIPC_NLA_LINK_TX] = { .type = NLA_U32 }
+};
+
+/* Properties valid for media, bearar and link */
+static const struct nla_policy tipc_nl_prop_policy[TIPC_NLA_PROP_MAX + 1] = {
+ [TIPC_NLA_PROP_UNSPEC] = { .type = NLA_UNSPEC },
+ [TIPC_NLA_PROP_PRIO] = { .type = NLA_U32 },
+ [TIPC_NLA_PROP_TOL] = { .type = NLA_U32 },
+ [TIPC_NLA_PROP_WIN] = { .type = NLA_U32 }
+};
+
+static const struct nla_policy
+tipc_nl_bearer_policy[TIPC_NLA_BEARER_MAX + 1] = {
+ [TIPC_NLA_BEARER_UNSPEC] = { .type = NLA_UNSPEC },
+ [TIPC_NLA_BEARER_NAME] = { .type = NLA_STRING,
+ .len = TIPC_MAX_BEARER_NAME },
+ [TIPC_NLA_BEARER_PROP] = { .type = NLA_NESTED },
+ [TIPC_NLA_BEARER_DOMAIN] = { .type = NLA_U32 }
+};
+
+static const struct nla_policy tipc_nl_media_policy[TIPC_NLA_MEDIA_MAX + 1] = {
+ [TIPC_NLA_MEDIA_UNSPEC] = { .type = NLA_UNSPEC },
+ [TIPC_NLA_MEDIA_NAME] = { .type = NLA_STRING },
+ [TIPC_NLA_MEDIA_PROP] = { .type = NLA_NESTED }
+};
+
+static const struct nla_policy tipc_nl_udp_policy[TIPC_NLA_UDP_MAX + 1] = {
+ [TIPC_NLA_UDP_UNSPEC] = { .type = NLA_UNSPEC },
+ [TIPC_NLA_UDP_LOCAL] = { .type = NLA_BINARY,
+ .len = sizeof(struct sockaddr_storage)},
+ [TIPC_NLA_UDP_REMOTE] = { .type = NLA_BINARY,
+ .len = sizeof(struct sockaddr_storage)},
+};
+
+static const struct nla_policy
+tipc_nl_name_table_policy[TIPC_NLA_NAME_TABLE_MAX + 1] = {
+ [TIPC_NLA_NAME_TABLE_UNSPEC] = { .type = NLA_UNSPEC },
+ [TIPC_NLA_NAME_TABLE_PUBL] = { .type = NLA_NESTED }
+};
+
int tipc_nlmsg_parse(const struct nlmsghdr *nlh, struct nlattr ***buf);
struct tipc_nl_msg {
diff --git a/net/tipc/node.c b/net/tipc/node.c
index fa97d96..ee6f93c 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -41,6 +41,7 @@
#include "socket.h"
#include "bcast.h"
#include "discover.h"
+#include "netlink.h"
#define INVALID_NODE_SIG 0x10000
@@ -164,28 +165,6 @@ struct tipc_sock_conn {
struct list_head list;
};
-static const struct nla_policy tipc_nl_link_policy[TIPC_NLA_LINK_MAX + 1] = {
- [TIPC_NLA_LINK_UNSPEC] = { .type = NLA_UNSPEC },
- [TIPC_NLA_LINK_NAME] = {
- .type = NLA_STRING,
- .len = TIPC_MAX_LINK_NAME
- },
- [TIPC_NLA_LINK_MTU] = { .type = NLA_U32 },
- [TIPC_NLA_LINK_BROADCAST] = { .type = NLA_FLAG },
- [TIPC_NLA_LINK_UP] = { .type = NLA_FLAG },
- [TIPC_NLA_LINK_ACTIVE] = { .type = NLA_FLAG },
- [TIPC_NLA_LINK_PROP] = { .type = NLA_NESTED },
- [TIPC_NLA_LINK_STATS] = { .type = NLA_NESTED },
- [TIPC_NLA_LINK_RX] = { .type = NLA_U32 },
- [TIPC_NLA_LINK_TX] = { .type = NLA_U32 }
-};
-
-static const struct nla_policy tipc_nl_node_policy[TIPC_NLA_NODE_MAX + 1] = {
- [TIPC_NLA_NODE_UNSPEC] = { .type = NLA_UNSPEC },
- [TIPC_NLA_NODE_ADDR] = { .type = NLA_U32 },
- [TIPC_NLA_NODE_UP] = { .type = NLA_FLAG }
-};
-
static struct tipc_link *node_active_link(struct tipc_node *n, int sel)
{
int bearer_id = n->active_links[sel & 1];
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index 69c2905..56b8a96 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -42,6 +42,7 @@
#include "name_distr.h"
#include "socket.h"
#include "bcast.h"
+#include "netlink.h"
#define SS_LISTENING -1 /* socket is listening */
#define SS_READY -2 /* socket is connectionless */
@@ -126,14 +127,6 @@ static const struct proto_ops stream_ops;
static const struct proto_ops msg_ops;
static struct proto tipc_proto;
-static const struct nla_policy tipc_nl_sock_policy[TIPC_NLA_SOCK_MAX + 1] = {
- [TIPC_NLA_SOCK_UNSPEC] = { .type = NLA_UNSPEC },
- [TIPC_NLA_SOCK_ADDR] = { .type = NLA_U32 },
- [TIPC_NLA_SOCK_REF] = { .type = NLA_U32 },
- [TIPC_NLA_SOCK_CON] = { .type = NLA_NESTED },
- [TIPC_NLA_SOCK_HAS_PUBL] = { .type = NLA_FLAG }
-};
-
static const struct rhashtable_params tsk_rht_params;
/*
diff --git a/net/tipc/udp_media.c b/net/tipc/udp_media.c
index d63a911..f3b9d9a 100644
--- a/net/tipc/udp_media.c
+++ b/net/tipc/udp_media.c
@@ -48,20 +48,13 @@
#include <linux/tipc_netlink.h>
#include "core.h"
#include "bearer.h"
+#include "netlink.h"
/* IANA assigned UDP port */
#define UDP_PORT_DEFAULT 6118
#define UDP_MIN_HEADROOM 28
-static const struct nla_policy tipc_nl_udp_policy[TIPC_NLA_UDP_MAX + 1] = {
- [TIPC_NLA_UDP_UNSPEC] = {.type = NLA_UNSPEC},
- [TIPC_NLA_UDP_LOCAL] = {.type = NLA_BINARY,
- .len = sizeof(struct sockaddr_storage)},
- [TIPC_NLA_UDP_REMOTE] = {.type = NLA_BINARY,
- .len = sizeof(struct sockaddr_storage)},
-};
-
/**
* struct udp_media_addr - IP/UDP addressing information
*
--
2.1.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH net-next v1 2/2] tipc: add peer removal functionality
2016-01-05 9:56 [PATCH net-next v1 1/2] tipc: move netlink policies to netlink.h Richard Alpe
@ 2016-01-05 9:56 ` Richard Alpe
2016-01-05 21:47 ` [PATCH net-next v1 1/2] tipc: move netlink policies to netlink.h David Miller
1 sibling, 0 replies; 5+ messages in thread
From: Richard Alpe @ 2016-01-05 9:56 UTC (permalink / raw)
To: netdev; +Cc: tipc-discussion
Add TIPC_NL_PEER_REMOVE netlink command. This command can remove
an offline peer node from the internal data structures.
This will be supported by the tipc user space tool in iproute2.
Signed-off-by: Richard Alpe <richard.alpe@ericsson.com>
Reviewed-by: Jon Maloy <jon.maloy@ericsson.com>
Acked-by: Ying Xue <ying.xue@windriver.com>
---
include/uapi/linux/tipc_netlink.h | 1 +
net/tipc/net.c | 2 +-
net/tipc/netlink.c | 5 ++++
net/tipc/node.c | 60 +++++++++++++++++++++++++++++++++++----
net/tipc/node.h | 3 +-
5 files changed, 63 insertions(+), 8 deletions(-)
diff --git a/include/uapi/linux/tipc_netlink.h b/include/uapi/linux/tipc_netlink.h
index d4c8f14..25eb645 100644
--- a/include/uapi/linux/tipc_netlink.h
+++ b/include/uapi/linux/tipc_netlink.h
@@ -56,6 +56,7 @@ enum {
TIPC_NL_NET_GET,
TIPC_NL_NET_SET,
TIPC_NL_NAME_TABLE_GET,
+ TIPC_NL_PEER_REMOVE,
__TIPC_NL_CMD_MAX,
TIPC_NL_CMD_MAX = __TIPC_NL_CMD_MAX - 1
diff --git a/net/tipc/net.c b/net/tipc/net.c
index d7a5c11..bc6b4a6 100644
--- a/net/tipc/net.c
+++ b/net/tipc/net.c
@@ -135,7 +135,7 @@ void tipc_net_stop(struct net *net)
tn->own_addr);
rtnl_lock();
tipc_bearer_stop(net);
- tipc_node_stop(net);
+ tipc_node_stop_net(net);
rtnl_unlock();
pr_info("Left network mode\n");
diff --git a/net/tipc/netlink.c b/net/tipc/netlink.c
index 234cb93..87c3ffa 100644
--- a/net/tipc/netlink.c
+++ b/net/tipc/netlink.c
@@ -134,6 +134,11 @@ static const struct genl_ops tipc_genl_v2_ops[] = {
.cmd = TIPC_NL_NAME_TABLE_GET,
.dumpit = tipc_nl_name_table_dump,
.policy = tipc_nl_policy,
+ },
+ {
+ .cmd = TIPC_NL_PEER_REMOVE,
+ .doit = tipc_nl_peer_rm,
+ .policy = tipc_nl_policy,
}
};
diff --git a/net/tipc/node.c b/net/tipc/node.c
index ee6f93c..7334547 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -378,17 +378,21 @@ static void tipc_node_delete(struct tipc_node *node)
kfree_rcu(node, rcu);
}
-void tipc_node_stop(struct net *net)
+static void tipc_node_stop(struct tipc_node *node)
+{
+ if (del_timer(&node->timer))
+ tipc_node_put(node);
+ tipc_node_put(node);
+}
+
+void tipc_node_stop_net(struct net *net)
{
struct tipc_net *tn = net_generic(net, tipc_net_id);
struct tipc_node *node, *t_node;
spin_lock_bh(&tn->node_list_lock);
- list_for_each_entry_safe(node, t_node, &tn->node_list, list) {
- if (del_timer(&node->timer))
- tipc_node_put(node);
- tipc_node_put(node);
- }
+ list_for_each_entry_safe(node, t_node, &tn->node_list, list)
+ tipc_node_stop(node);
spin_unlock_bh(&tn->node_list_lock);
}
@@ -1508,6 +1512,50 @@ discard:
kfree_skb(skb);
}
+int tipc_nl_peer_rm(struct sk_buff *skb, struct genl_info *info)
+{
+ int err;
+ u32 addr;
+ struct net *net = sock_net(skb->sk);
+ struct nlattr *attrs[TIPC_NLA_NET_MAX + 1];
+ struct tipc_net *tn = net_generic(net, tipc_net_id);
+ struct tipc_node *peer;
+
+ /* We identify the peer by its net */
+ if (!info->attrs[TIPC_NLA_NET])
+ return -EINVAL;
+
+ err = nla_parse_nested(attrs, TIPC_NLA_NET_MAX,
+ info->attrs[TIPC_NLA_NET],
+ tipc_nl_net_policy);
+ if (err)
+ return err;
+
+ if (!attrs[TIPC_NLA_NET_ADDR])
+ return -EINVAL;
+
+ addr = nla_get_u32(attrs[TIPC_NLA_NET_ADDR]);
+
+ spin_lock_bh(&tn->node_list_lock);
+ list_for_each_entry_rcu(peer, &tn->node_list, list) {
+ if (peer->addr != addr)
+ continue;
+
+ if (peer->state == SELF_DOWN_PEER_DOWN ||
+ peer->state == SELF_DOWN_PEER_LEAVING) {
+ tipc_node_stop(peer);
+
+ spin_unlock_bh(&tn->node_list_lock);
+ return 0;
+ }
+ spin_unlock_bh(&tn->node_list_lock);
+ return -EBUSY;
+ }
+ spin_unlock_bh(&tn->node_list_lock);
+
+ return -ENXIO;
+}
+
int tipc_nl_node_dump(struct sk_buff *skb, struct netlink_callback *cb)
{
int err;
diff --git a/net/tipc/node.h b/net/tipc/node.h
index f39d9d0..8dfb6ba 100644
--- a/net/tipc/node.h
+++ b/net/tipc/node.h
@@ -51,7 +51,7 @@ enum {
#define TIPC_NODE_CAPABILITIES TIPC_BCAST_SYNCH
#define INVALID_BEARER_ID -1
-void tipc_node_stop(struct net *net);
+void tipc_node_stop_net(struct net *net);
void tipc_node_check_dest(struct net *net, u32 onode,
struct tipc_bearer *bearer,
u16 capabilities, u32 signature,
@@ -75,5 +75,6 @@ int tipc_nl_node_dump_link(struct sk_buff *skb, struct netlink_callback *cb);
int tipc_nl_node_reset_link_stats(struct sk_buff *skb, struct genl_info *info);
int tipc_nl_node_get_link(struct sk_buff *skb, struct genl_info *info);
int tipc_nl_node_set_link(struct sk_buff *skb, struct genl_info *info);
+int tipc_nl_peer_rm(struct sk_buff *skb, struct genl_info *info);
#endif
--
2.1.4
------------------------------------------------------------------------------
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net-next v1 1/2] tipc: move netlink policies to netlink.h
2016-01-05 9:56 [PATCH net-next v1 1/2] tipc: move netlink policies to netlink.h Richard Alpe
2016-01-05 9:56 ` [PATCH net-next v1 2/2] tipc: add peer removal functionality Richard Alpe
@ 2016-01-05 21:47 ` David Miller
2016-01-07 10:20 ` Richard Alpe
1 sibling, 1 reply; 5+ messages in thread
From: David Miller @ 2016-01-05 21:47 UTC (permalink / raw)
To: richard.alpe; +Cc: netdev, tipc-discussion
From: Richard Alpe <richard.alpe@ericsson.com>
Date: Tue, 5 Jan 2016 10:56:16 +0100
> Make the c files less cluttered and enable netlink attributes to be
> shared between files. This will prove useful in a future patch where a
> node message will contain a nested network.
>
> Signed-off-by: Richard Alpe <richard.alpe@ericsson.com>
> Acked-by: Jon Maloy <jon.maloy@ericsson.com>
netlink.h is included by more than one file, which means the tables
(might) be instantiated multiple times.
I'd really recommend not putting such tables in a header file that
is used in this way.
Thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next v1 1/2] tipc: move netlink policies to netlink.h
2016-01-05 21:47 ` [PATCH net-next v1 1/2] tipc: move netlink policies to netlink.h David Miller
@ 2016-01-07 10:20 ` Richard Alpe
2016-01-10 2:03 ` David Miller
0 siblings, 1 reply; 5+ messages in thread
From: Richard Alpe @ 2016-01-07 10:20 UTC (permalink / raw)
To: David Miller; +Cc: netdev, tipc-discussion
On 2016-01-05 22:47, David Miller wrote:
> From: Richard Alpe <richard.alpe@ericsson.com>
> Date: Tue, 5 Jan 2016 10:56:16 +0100
>
>> Make the c files less cluttered and enable netlink attributes to be
>> shared between files. This will prove useful in a future patch where a
>> node message will contain a nested network.
>>
>> Signed-off-by: Richard Alpe <richard.alpe@ericsson.com>
>> Acked-by: Jon Maloy <jon.maloy@ericsson.com>
>
> netlink.h is included by more than one file, which means the tables
> (might) be instantiated multiple times.
I thought about that, but I assumed unreferenced tables would be
optimized away by the compiler (?)
>
> I'd really recommend not putting such tables in a header file that
> is used in this way.
Alright, I will drop the patch.
Do you have any suggestion on how to handle the case where a policy
(table) is shared between c files, like the net policy in the
subsequent patch? I could perhaps use extern in the c files (which
seems frown upon) or duplicate the policy? :-S
Thanks for the review
Richard
>
> Thanks.
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net-next v1 1/2] tipc: move netlink policies to netlink.h
2016-01-07 10:20 ` Richard Alpe
@ 2016-01-10 2:03 ` David Miller
0 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2016-01-10 2:03 UTC (permalink / raw)
To: richard.alpe; +Cc: netdev, tipc-discussion
From: Richard Alpe <richard.alpe@ericsson.com>
Date: Thu, 7 Jan 2016 11:20:08 +0100
> Do you have any suggestion on how to handle the case where a policy
> (table) is shared between c files, like the net policy in the
> subsequent patch? I could perhaps use extern in the c files (which
> seems frown upon) or duplicate the policy? :-S
Probably you'll need to instantiate it in one source file, and export
it for the others to use.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-01-10 2:03 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-05 9:56 [PATCH net-next v1 1/2] tipc: move netlink policies to netlink.h Richard Alpe
2016-01-05 9:56 ` [PATCH net-next v1 2/2] tipc: add peer removal functionality Richard Alpe
2016-01-05 21:47 ` [PATCH net-next v1 1/2] tipc: move netlink policies to netlink.h David Miller
2016-01-07 10:20 ` Richard Alpe
2016-01-10 2:03 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.