Commit c7b67aef authored by David S. Miller's avatar David S. Miller

Merge branch 'tipc'

Paul Gortmaker says:

====================
This is a rework of the content sent earlier[1], with the following changes:

	-drop the Kconfig --> modparam conversion patch; this was
	 requested to be replaced[2] with a dynamic port quantity resizing.
	 Ying and Erik were discussing how best to achieve this, and then
	 vacation schedules got in the way, so implementing that will
	 come (hopefully) in the next round.

	-rework the sk_rcvbuf patch to allow memory resizing via sysctl
	 as per what Ying and Neil discussed[3]

	-add 4 more seemingly straigtforward and relatively small changes
	 from Ying (the last 4 in the series).

	-add cosmetic UAPI comment update patch from Ying.

That said, the largest change is still the one where we make use of
the fact that linux supports kernel threads and do the server like
operations within kernel threads.  As Jon says:

   We remove the last remnants of the TIPC native API, to make it
   possible to simplify locking policy and solve a problem with lost
   topology events.

   First, we introduce a socket-based alternative to the native API.

   Second, we convert the two remaining users of the native API, the
   TIPC internal topology server and the configuarion server, to use the
   new API.

   Third, we remove the remaining code pertaining to the native API.

I have re-tested this collection of commits between 32 and 64 bit x86
machines using the standard tipc test suite, and build tested for ppc.

[1] http://patchwork.ozlabs.org/patch/247687/
[2] http://patchwork.ozlabs.org/patch/247680/
[3] http://patchwork.ozlabs.org/patch/247688/
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents dafcc438 2537af9d
...@@ -26,7 +26,7 @@ Table : Subdirectories in /proc/sys/net ...@@ -26,7 +26,7 @@ Table : Subdirectories in /proc/sys/net
ipv4 IP version 4 x25 X.25 protocol ipv4 IP version 4 x25 X.25 protocol
ipx IPX token-ring IBM token ring ipx IPX token-ring IBM token ring
bridge Bridging decnet DEC net bridge Bridging decnet DEC net
ipv6 IP version 6 ipv6 IP version 6 tipc TIPC
.............................................................................. ..............................................................................
1. /proc/sys/net/core - Network core options 1. /proc/sys/net/core - Network core options
...@@ -207,3 +207,18 @@ IPX. ...@@ -207,3 +207,18 @@ IPX.
The /proc/net/ipx_route table holds a list of IPX routes. For each route it The /proc/net/ipx_route table holds a list of IPX routes. For each route it
gives the destination network, the router node (or Directly) and the network gives the destination network, the router node (or Directly) and the network
address of the router (or Connected) for internal networks. address of the router (or Connected) for internal networks.
6. TIPC
-------------------------------------------------------
The TIPC protocol now has a tunable for the receive memory, similar to the
tcp_rmem - i.e. a vector of 3 INTEGERs: (min, default, max)
# cat /proc/sys/net/tipc/tipc_rmem
4252725 34021800 68043600
#
The max value is set to CONN_OVERLOAD_LIMIT, and the default and min values
are scaled (shifted) versions of that same value. Note that the min value
is not at this point in time used in any meaningful way, but the triplet is
preserved in order to be consistent with things like tcp_rmem.
/* /*
* include/linux/tipc.h: Include file for TIPC socket interface * include/uapi/linux/tipc.h: Header for TIPC socket interface
* *
* Copyright (c) 2003-2006, Ericsson AB * Copyright (c) 2003-2006, Ericsson AB
* Copyright (c) 2005, 2010-2011, Wind River Systems * Copyright (c) 2005, 2010-2011, Wind River Systems
......
/* /*
* include/linux/tipc_config.h: Include file for TIPC configuration interface * include/uapi/linux/tipc_config.h: Header for TIPC configuration interface
* *
* Copyright (c) 2003-2006, Ericsson AB * Copyright (c) 2003-2006, Ericsson AB
* Copyright (c) 2005-2007, 2010-2011, Wind River Systems * Copyright (c) 2005-2007, 2010-2011, Wind River Systems
......
...@@ -8,6 +8,7 @@ tipc-y += addr.o bcast.o bearer.o config.o \ ...@@ -8,6 +8,7 @@ tipc-y += addr.o bcast.o bearer.o config.o \
core.o handler.o link.o discover.o msg.o \ core.o handler.o link.o discover.o msg.o \
name_distr.o subscr.o name_table.o net.o \ name_distr.o subscr.o name_table.o net.o \
netlink.o node.o node_subscr.o port.o ref.o \ netlink.o node.o node_subscr.o port.o ref.o \
socket.o log.o eth_media.o socket.o log.o eth_media.o server.o
tipc-$(CONFIG_TIPC_MEDIA_IB) += ib_media.o tipc-$(CONFIG_TIPC_MEDIA_IB) += ib_media.o
tipc-$(CONFIG_SYSCTL) += sysctl.o
...@@ -578,8 +578,7 @@ u32 tipc_bclink_acks_missing(struct tipc_node *n_ptr) ...@@ -578,8 +578,7 @@ u32 tipc_bclink_acks_missing(struct tipc_node *n_ptr)
* Returns 0 (packet sent successfully) under all circumstances, * Returns 0 (packet sent successfully) under all circumstances,
* since the broadcast link's pseudo-bearer never blocks * since the broadcast link's pseudo-bearer never blocks
*/ */
static int tipc_bcbearer_send(struct sk_buff *buf, static int tipc_bcbearer_send(struct sk_buff *buf, struct tipc_bearer *unused1,
struct tipc_bearer *unused1,
struct tipc_media_addr *unused2) struct tipc_media_addr *unused2)
{ {
int bp_index; int bp_index;
......
...@@ -75,7 +75,8 @@ void tipc_nmap_remove(struct tipc_node_map *nm_ptr, u32 node); ...@@ -75,7 +75,8 @@ void tipc_nmap_remove(struct tipc_node_map *nm_ptr, u32 node);
/** /**
* tipc_nmap_equal - test for equality of node maps * tipc_nmap_equal - test for equality of node maps
*/ */
static inline int tipc_nmap_equal(struct tipc_node_map *nm_a, struct tipc_node_map *nm_b) static inline int tipc_nmap_equal(struct tipc_node_map *nm_a,
struct tipc_node_map *nm_b)
{ {
return !memcmp(nm_a, nm_b, sizeof(*nm_a)); return !memcmp(nm_a, nm_b, sizeof(*nm_a));
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* net/tipc/config.c: TIPC configuration management code * net/tipc/config.c: TIPC configuration management code
* *
* Copyright (c) 2002-2006, Ericsson AB * Copyright (c) 2002-2006, Ericsson AB
* Copyright (c) 2004-2007, 2010-2012, Wind River Systems * Copyright (c) 2004-2007, 2010-2013, Wind River Systems
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
...@@ -38,12 +38,12 @@ ...@@ -38,12 +38,12 @@
#include "port.h" #include "port.h"
#include "name_table.h" #include "name_table.h"
#include "config.h" #include "config.h"
#include "server.h"
#define REPLY_TRUNCATED "<truncated>\n" #define REPLY_TRUNCATED "<truncated>\n"
static u32 config_port_ref; static DEFINE_MUTEX(config_mutex);
static struct tipc_server cfgsrv;
static DEFINE_SPINLOCK(config_lock);
static const void *req_tlv_area; /* request message TLV area */ static const void *req_tlv_area; /* request message TLV area */
static int req_tlv_space; /* request message TLV area size */ static int req_tlv_space; /* request message TLV area size */
...@@ -181,18 +181,7 @@ static struct sk_buff *cfg_set_own_addr(void) ...@@ -181,18 +181,7 @@ static struct sk_buff *cfg_set_own_addr(void)
if (tipc_own_addr) if (tipc_own_addr)
return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED return tipc_cfg_reply_error_string(TIPC_CFG_NOT_SUPPORTED
" (cannot change node address once assigned)"); " (cannot change node address once assigned)");
/*
* Must temporarily release configuration spinlock while switching into
* networking mode as it calls tipc_eth_media_start(), which may sleep.
* Releasing the lock is harmless as other locally-issued configuration
* commands won't occur until this one completes, and remotely-issued
* configuration commands can't be received until a local configuration
* command to enable the first bearer is received and processed.
*/
spin_unlock_bh(&config_lock);
tipc_core_start_net(addr); tipc_core_start_net(addr);
spin_lock_bh(&config_lock);
return tipc_cfg_reply_none(); return tipc_cfg_reply_none();
} }
...@@ -248,7 +237,7 @@ struct sk_buff *tipc_cfg_do_cmd(u32 orig_node, u16 cmd, const void *request_area ...@@ -248,7 +237,7 @@ struct sk_buff *tipc_cfg_do_cmd(u32 orig_node, u16 cmd, const void *request_area
{ {
struct sk_buff *rep_tlv_buf; struct sk_buff *rep_tlv_buf;
spin_lock_bh(&config_lock); mutex_lock(&config_mutex);
/* Save request and reply details in a well-known location */ /* Save request and reply details in a well-known location */
req_tlv_area = request_area; req_tlv_area = request_area;
...@@ -377,37 +366,31 @@ struct sk_buff *tipc_cfg_do_cmd(u32 orig_node, u16 cmd, const void *request_area ...@@ -377,37 +366,31 @@ struct sk_buff *tipc_cfg_do_cmd(u32 orig_node, u16 cmd, const void *request_area
/* Return reply buffer */ /* Return reply buffer */
exit: exit:
spin_unlock_bh(&config_lock); mutex_unlock(&config_mutex);
return rep_tlv_buf; return rep_tlv_buf;
} }
static void cfg_named_msg_event(void *userdata, static void cfg_conn_msg_event(int conid, struct sockaddr_tipc *addr,
u32 port_ref, void *usr_data, void *buf, size_t len)
struct sk_buff **buf,
const unchar *msg,
u32 size,
u32 importance,
struct tipc_portid const *orig,
struct tipc_name_seq const *dest)
{ {
struct tipc_cfg_msg_hdr *req_hdr; struct tipc_cfg_msg_hdr *req_hdr;
struct tipc_cfg_msg_hdr *rep_hdr; struct tipc_cfg_msg_hdr *rep_hdr;
struct sk_buff *rep_buf; struct sk_buff *rep_buf;
int ret;
/* Validate configuration message header (ignore invalid message) */ /* Validate configuration message header (ignore invalid message) */
req_hdr = (struct tipc_cfg_msg_hdr *)msg; req_hdr = (struct tipc_cfg_msg_hdr *)buf;
if ((size < sizeof(*req_hdr)) || if ((len < sizeof(*req_hdr)) ||
(size != TCM_ALIGN(ntohl(req_hdr->tcm_len))) || (len != TCM_ALIGN(ntohl(req_hdr->tcm_len))) ||
(ntohs(req_hdr->tcm_flags) != TCM_F_REQUEST)) { (ntohs(req_hdr->tcm_flags) != TCM_F_REQUEST)) {
pr_warn("Invalid configuration message discarded\n"); pr_warn("Invalid configuration message discarded\n");
return; return;
} }
/* Generate reply for request (if can't, return request) */ /* Generate reply for request (if can't, return request) */
rep_buf = tipc_cfg_do_cmd(orig->node, rep_buf = tipc_cfg_do_cmd(addr->addr.id.node, ntohs(req_hdr->tcm_type),
ntohs(req_hdr->tcm_type), buf + sizeof(*req_hdr),
msg + sizeof(*req_hdr), len - sizeof(*req_hdr),
size - sizeof(*req_hdr),
BUF_HEADROOM + MAX_H_SIZE + sizeof(*rep_hdr)); BUF_HEADROOM + MAX_H_SIZE + sizeof(*rep_hdr));
if (rep_buf) { if (rep_buf) {
skb_push(rep_buf, sizeof(*rep_hdr)); skb_push(rep_buf, sizeof(*rep_hdr));
...@@ -415,57 +398,51 @@ static void cfg_named_msg_event(void *userdata, ...@@ -415,57 +398,51 @@ static void cfg_named_msg_event(void *userdata,
memcpy(rep_hdr, req_hdr, sizeof(*rep_hdr)); memcpy(rep_hdr, req_hdr, sizeof(*rep_hdr));
rep_hdr->tcm_len = htonl(rep_buf->len); rep_hdr->tcm_len = htonl(rep_buf->len);
rep_hdr->tcm_flags &= htons(~TCM_F_REQUEST); rep_hdr->tcm_flags &= htons(~TCM_F_REQUEST);
} else {
rep_buf = *buf;
*buf = NULL;
}
/* NEED TO ADD CODE TO HANDLE FAILED SEND (SUCH AS CONGESTION) */ ret = tipc_conn_sendmsg(&cfgsrv, conid, addr, rep_buf->data,
tipc_send_buf2port(port_ref, orig, rep_buf, rep_buf->len); rep_buf->len);
if (ret < 0)
pr_err("Sending cfg reply message failed, no memory\n");
kfree_skb(rep_buf);
}
} }
static struct sockaddr_tipc cfgsrv_addr __read_mostly = {
.family = AF_TIPC,
.addrtype = TIPC_ADDR_NAMESEQ,
.addr.nameseq.type = TIPC_CFG_SRV,
.addr.nameseq.lower = 0,
.addr.nameseq.upper = 0,
.scope = TIPC_ZONE_SCOPE
};
static struct tipc_server cfgsrv __read_mostly = {
.saddr = &cfgsrv_addr,
.imp = TIPC_CRITICAL_IMPORTANCE,
.type = SOCK_RDM,
.max_rcvbuf_size = 64 * 1024,
.name = "cfg_server",
.tipc_conn_recvmsg = cfg_conn_msg_event,
.tipc_conn_new = NULL,
.tipc_conn_shutdown = NULL
};
int tipc_cfg_init(void) int tipc_cfg_init(void)
{ {
struct tipc_name_seq seq; return tipc_server_start(&cfgsrv);
int res;
res = tipc_createport(NULL, TIPC_CRITICAL_IMPORTANCE,
NULL, NULL, NULL,
NULL, cfg_named_msg_event, NULL,
NULL, &config_port_ref);
if (res)
goto failed;
seq.type = TIPC_CFG_SRV;
seq.lower = seq.upper = tipc_own_addr;
res = tipc_publish(config_port_ref, TIPC_ZONE_SCOPE, &seq);
if (res)
goto failed;
return 0;
failed:
pr_err("Unable to create configuration service\n");
return res;
} }
void tipc_cfg_reinit(void) void tipc_cfg_reinit(void)
{ {
struct tipc_name_seq seq; tipc_server_stop(&cfgsrv);
int res;
seq.type = TIPC_CFG_SRV;
seq.lower = seq.upper = 0;
tipc_withdraw(config_port_ref, TIPC_ZONE_SCOPE, &seq);
seq.lower = seq.upper = tipc_own_addr; cfgsrv_addr.addr.nameseq.lower = tipc_own_addr;
res = tipc_publish(config_port_ref, TIPC_ZONE_SCOPE, &seq); cfgsrv_addr.addr.nameseq.upper = tipc_own_addr;
if (res) tipc_server_start(&cfgsrv);
pr_err("Unable to reinitialize configuration service\n");
} }
void tipc_cfg_stop(void) void tipc_cfg_stop(void)
{ {
tipc_deleteport(config_port_ref); tipc_server_stop(&cfgsrv);
config_port_ref = 0;
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* net/tipc/core.c: TIPC module code * net/tipc/core.c: TIPC module code
* *
* Copyright (c) 2003-2006, Ericsson AB * Copyright (c) 2003-2006, Ericsson AB
* Copyright (c) 2005-2006, 2010-2011, Wind River Systems * Copyright (c) 2005-2006, 2010-2013, Wind River Systems
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include "name_table.h" #include "name_table.h"
#include "subscr.h" #include "subscr.h"
#include "config.h" #include "config.h"
#include "port.h"
#include <linux/module.h> #include <linux/module.h>
...@@ -50,7 +51,7 @@ u32 tipc_own_addr __read_mostly; ...@@ -50,7 +51,7 @@ u32 tipc_own_addr __read_mostly;
int tipc_max_ports __read_mostly; int tipc_max_ports __read_mostly;
int tipc_net_id __read_mostly; int tipc_net_id __read_mostly;
int tipc_remote_management __read_mostly; int tipc_remote_management __read_mostly;
int sysctl_tipc_rmem[3] __read_mostly; /* min/default/max */
/** /**
* tipc_buf_acquire - creates a TIPC message buffer * tipc_buf_acquire - creates a TIPC message buffer
...@@ -118,6 +119,7 @@ static void tipc_core_stop(void) ...@@ -118,6 +119,7 @@ static void tipc_core_stop(void)
tipc_nametbl_stop(); tipc_nametbl_stop();
tipc_ref_table_stop(); tipc_ref_table_stop();
tipc_socket_stop(); tipc_socket_stop();
tipc_unregister_sysctl();
} }
/** /**
...@@ -134,21 +136,22 @@ static int tipc_core_start(void) ...@@ -134,21 +136,22 @@ static int tipc_core_start(void)
res = tipc_ref_table_init(tipc_max_ports, tipc_random); res = tipc_ref_table_init(tipc_max_ports, tipc_random);
if (!res) if (!res)
res = tipc_nametbl_init(); res = tipc_nametbl_init();
if (!res)
res = tipc_subscr_start();
if (!res)
res = tipc_cfg_init();
if (!res) if (!res)
res = tipc_netlink_start(); res = tipc_netlink_start();
if (!res) if (!res)
res = tipc_socket_init(); res = tipc_socket_init();
if (!res)
res = tipc_register_sysctl();
if (!res)
res = tipc_subscr_start();
if (!res)
res = tipc_cfg_init();
if (res) if (res)
tipc_core_stop(); tipc_core_stop();
return res; return res;
} }
static int __init tipc_init(void) static int __init tipc_init(void)
{ {
int res; int res;
...@@ -160,6 +163,11 @@ static int __init tipc_init(void) ...@@ -160,6 +163,11 @@ static int __init tipc_init(void)
tipc_max_ports = CONFIG_TIPC_PORTS; tipc_max_ports = CONFIG_TIPC_PORTS;
tipc_net_id = 4711; tipc_net_id = 4711;
sysctl_tipc_rmem[0] = CONN_OVERLOAD_LIMIT >> 4 << TIPC_LOW_IMPORTANCE;
sysctl_tipc_rmem[1] = CONN_OVERLOAD_LIMIT >> 4 <<
TIPC_CRITICAL_IMPORTANCE;
sysctl_tipc_rmem[2] = CONN_OVERLOAD_LIMIT;
res = tipc_core_start(); res = tipc_core_start();
if (res) if (res)
pr_err("Unable to start in single node mode\n"); pr_err("Unable to start in single node mode\n");
......
/* /*
* net/tipc/core.h: Include file for TIPC global declarations * net/tipc/core.h: Include file for TIPC global declarations
* *
* Copyright (c) 2005-2006, Ericsson AB * Copyright (c) 2005-2006, 2013 Ericsson AB
* Copyright (c) 2005-2007, 2010-2011, Wind River Systems * Copyright (c) 2005-2007, 2010-2013, Wind River Systems
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
...@@ -80,6 +80,7 @@ extern u32 tipc_own_addr __read_mostly; ...@@ -80,6 +80,7 @@ extern u32 tipc_own_addr __read_mostly;
extern int tipc_max_ports __read_mostly; extern int tipc_max_ports __read_mostly;
extern int tipc_net_id __read_mostly; extern int tipc_net_id __read_mostly;
extern int tipc_remote_management __read_mostly; extern int tipc_remote_management __read_mostly;
extern int sysctl_tipc_rmem[3] __read_mostly;
/* /*
* Other global variables * Other global variables
...@@ -96,6 +97,18 @@ extern int tipc_netlink_start(void); ...@@ -96,6 +97,18 @@ extern int tipc_netlink_start(void);
extern void tipc_netlink_stop(void); extern void tipc_netlink_stop(void);
extern int tipc_socket_init(void); extern int tipc_socket_init(void);
extern void tipc_socket_stop(void); extern void tipc_socket_stop(void);
extern int tipc_sock_create_local(int type, struct socket **res);
extern void tipc_sock_release_local(struct socket *sock);
extern int tipc_sock_accept_local(struct socket *sock,
struct socket **newsock, int flags);
#ifdef CONFIG_SYSCTL
extern int tipc_register_sysctl(void);
extern void tipc_unregister_sysctl(void);
#else
#define tipc_register_sysctl() 0
#define tipc_unregister_sysctl()
#endif
/* /*
* TIPC timer and signal code * TIPC timer and signal code
......
...@@ -70,8 +70,7 @@ struct tipc_link_req { ...@@ -70,8 +70,7 @@ struct tipc_link_req {
* @dest_domain: network domain of node(s) which should respond to message * @dest_domain: network domain of node(s) which should respond to message
* @b_ptr: ptr to bearer issuing message * @b_ptr: ptr to bearer issuing message
*/ */
static struct sk_buff *tipc_disc_init_msg(u32 type, static struct sk_buff *tipc_disc_init_msg(u32 type, u32 dest_domain,
u32 dest_domain,
struct tipc_bearer *b_ptr) struct tipc_bearer *b_ptr)
{ {
struct sk_buff *buf = tipc_buf_acquire(INT_H_SIZE); struct sk_buff *buf = tipc_buf_acquire(INT_H_SIZE);
...@@ -346,8 +345,8 @@ static void disc_timeout(struct tipc_link_req *req) ...@@ -346,8 +345,8 @@ static void disc_timeout(struct tipc_link_req *req)
* *
* Returns 0 if successful, otherwise -errno. * Returns 0 if successful, otherwise -errno.
*/ */
int tipc_disc_create(struct tipc_bearer *b_ptr, int tipc_disc_create(struct tipc_bearer *b_ptr, struct tipc_media_addr *dest,
struct tipc_media_addr *dest, u32 dest_domain) u32 dest_domain)
{ {
struct tipc_link_req *req; struct tipc_link_req *req;
......
...@@ -62,7 +62,7 @@ static struct eth_bearer eth_bearers[MAX_ETH_BEARERS]; ...@@ -62,7 +62,7 @@ static struct eth_bearer eth_bearers[MAX_ETH_BEARERS];
static int eth_started; static int eth_started;
static int recv_notification(struct notifier_block *nb, unsigned long evt, static int recv_notification(struct notifier_block *nb, unsigned long evt,
void *dv); void *dv);
/* /*
* Network device notifier info * Network device notifier info
*/ */
...@@ -162,8 +162,7 @@ static void setup_bearer(struct work_struct *work) ...@@ -162,8 +162,7 @@ static void setup_bearer(struct work_struct *work)
*/ */
static int enable_bearer(struct tipc_bearer *tb_ptr) static int enable_bearer(struct tipc_bearer *tb_ptr)
{ {
struct net_device *dev = NULL; struct net_device *dev;
struct net_device *pdev = NULL;
struct eth_bearer *eb_ptr = &eth_bearers[0]; struct eth_bearer *eb_ptr = &eth_bearers[0];
struct eth_bearer *stop = &eth_bearers[MAX_ETH_BEARERS]; struct eth_bearer *stop = &eth_bearers[MAX_ETH_BEARERS];
char *driver_name = strchr((const char *)tb_ptr->name, ':') + 1; char *driver_name = strchr((const char *)tb_ptr->name, ':') + 1;
...@@ -178,15 +177,7 @@ static int enable_bearer(struct tipc_bearer *tb_ptr) ...@@ -178,15 +177,7 @@ static int enable_bearer(struct tipc_bearer *tb_ptr)
} }
/* Find device with specified name */ /* Find device with specified name */
read_lock(&dev_base_lock); dev = dev_get_by_name(&init_net, driver_name);
for_each_netdev(&init_net, pdev) {
if (!strncmp(pdev->name, driver_name, IFNAMSIZ)) {
dev = pdev;
dev_hold(dev);
break;
}
}
read_unlock(&dev_base_lock);
if (!dev) if (!dev)
return -ENODEV; return -ENODEV;
......
...@@ -155,8 +155,7 @@ static void setup_bearer(struct work_struct *work) ...@@ -155,8 +155,7 @@ static void setup_bearer(struct work_struct *work)
*/ */
static int enable_bearer(struct tipc_bearer *tb_ptr) static int enable_bearer(struct tipc_bearer *tb_ptr)
{ {
struct net_device *dev = NULL; struct net_device *dev;
struct net_device *pdev = NULL;
struct ib_bearer *ib_ptr = &ib_bearers[0]; struct ib_bearer *ib_ptr = &ib_bearers[0];
struct ib_bearer *stop = &ib_bearers[MAX_IB_BEARERS]; struct ib_bearer *stop = &ib_bearers[MAX_IB_BEARERS];
char *driver_name = strchr((const char *)tb_ptr->name, ':') + 1; char *driver_name = strchr((const char *)tb_ptr->name, ':') + 1;
...@@ -171,15 +170,7 @@ static int enable_bearer(struct tipc_bearer *tb_ptr) ...@@ -171,15 +170,7 @@ static int enable_bearer(struct tipc_bearer *tb_ptr)
} }
/* Find device with specified name */ /* Find device with specified name */
read_lock(&dev_base_lock); dev = dev_get_by_name(&init_net, driver_name);
for_each_netdev(&init_net, pdev) {
if (!strncmp(pdev->name, driver_name, IFNAMSIZ)) {
dev = pdev;
dev_hold(dev);
break;
}
}
read_unlock(&dev_base_lock);
if (!dev) if (!dev)
return -ENODEV; return -ENODEV;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* net/tipc/link.c: TIPC link code * net/tipc/link.c: TIPC link code
* *
* Copyright (c) 1996-2007, 2012, Ericsson AB * Copyright (c) 1996-2007, 2012, Ericsson AB
* Copyright (c) 2004-2007, 2010-2011, Wind River Systems * Copyright (c) 2004-2007, 2010-2013, Wind River Systems
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
...@@ -41,6 +41,8 @@ ...@@ -41,6 +41,8 @@
#include "discover.h" #include "discover.h"
#include "config.h" #include "config.h"
#include <linux/pkt_sched.h>
/* /*
* Error message prefixes * Error message prefixes
*/ */
...@@ -771,8 +773,7 @@ static void link_state_event(struct tipc_link *l_ptr, unsigned int event) ...@@ -771,8 +773,7 @@ static void link_state_event(struct tipc_link *l_ptr, unsigned int event)
* link_bundle_buf(): Append contents of a buffer to * link_bundle_buf(): Append contents of a buffer to
* the tail of an existing one. * the tail of an existing one.
*/ */
static int link_bundle_buf(struct tipc_link *l_ptr, static int link_bundle_buf(struct tipc_link *l_ptr, struct sk_buff *bundler,
struct sk_buff *bundler,
struct sk_buff *buf) struct sk_buff *buf)
{ {
struct tipc_msg *bundler_msg = buf_msg(bundler); struct tipc_msg *bundler_msg = buf_msg(bundler);
...@@ -1056,40 +1057,6 @@ static int link_send_buf_fast(struct tipc_link *l_ptr, struct sk_buff *buf, ...@@ -1056,40 +1057,6 @@ static int link_send_buf_fast(struct tipc_link *l_ptr, struct sk_buff *buf,
return tipc_link_send_buf(l_ptr, buf); /* All other cases */ return tipc_link_send_buf(l_ptr, buf); /* All other cases */
} }
/*
* tipc_send_buf_fast: Entry for data messages where the
* destination node is known and the header is complete,
* inclusive total message length.
* Returns user data length.
*/
int tipc_send_buf_fast(struct sk_buff *buf, u32 destnode)
{
struct tipc_link *l_ptr;
struct tipc_node *n_ptr;
int res;
u32 selector = msg_origport(buf_msg(buf)) & 1;
u32 dummy;
read_lock_bh(&tipc_net_lock);
n_ptr = tipc_node_find(destnode);
if (likely(n_ptr)) {
tipc_node_lock(n_ptr);
l_ptr = n_ptr->active_links[selector];
if (likely(l_ptr)) {
res = link_send_buf_fast(l_ptr, buf, &dummy);
tipc_node_unlock(n_ptr);
read_unlock_bh(&tipc_net_lock);
return res;
}
tipc_node_unlock(n_ptr);
}
read_unlock_bh(&tipc_net_lock);
res = msg_data_sz(buf_msg(buf));
tipc_reject_msg(buf, TIPC_ERR_NO_NODE);
return res;
}
/* /*
* tipc_link_send_sections_fast: Entry for messages where the * tipc_link_send_sections_fast: Entry for messages where the
* destination processor is known and the header is complete, * destination processor is known and the header is complete,
...@@ -1098,8 +1065,7 @@ int tipc_send_buf_fast(struct sk_buff *buf, u32 destnode) ...@@ -1098,8 +1065,7 @@ int tipc_send_buf_fast(struct sk_buff *buf, u32 destnode)
*/ */
int tipc_link_send_sections_fast(struct tipc_port *sender, int tipc_link_send_sections_fast(struct tipc_port *sender,
struct iovec const *msg_sect, struct iovec const *msg_sect,
const u32 num_sect, const u32 num_sect, unsigned int total_len,
unsigned int total_len,
u32 destaddr) u32 destaddr)
{ {
struct tipc_msg *hdr = &sender->phdr; struct tipc_msg *hdr = &sender->phdr;
...@@ -1115,7 +1081,10 @@ int tipc_link_send_sections_fast(struct tipc_port *sender, ...@@ -1115,7 +1081,10 @@ int tipc_link_send_sections_fast(struct tipc_port *sender,
* (Must not hold any locks while building message.) * (Must not hold any locks while building message.)
*/ */
res = tipc_msg_build(hdr, msg_sect, num_sect, total_len, res = tipc_msg_build(hdr, msg_sect, num_sect, total_len,
sender->max_pkt, !sender->user_port, &buf); sender->max_pkt, &buf);
/* Exit if build request was invalid */
if (unlikely(res < 0))
return res;
read_lock_bh(&tipc_net_lock); read_lock_bh(&tipc_net_lock);
node = tipc_node_find(destaddr); node = tipc_node_find(destaddr);
...@@ -1132,10 +1101,6 @@ int tipc_link_send_sections_fast(struct tipc_port *sender, ...@@ -1132,10 +1101,6 @@ int tipc_link_send_sections_fast(struct tipc_port *sender,
return res; return res;
} }
/* Exit if build request was invalid */
if (unlikely(res < 0))
goto exit;
/* Exit if link (or bearer) is congested */ /* Exit if link (or bearer) is congested */
if (link_congested(l_ptr) || if (link_congested(l_ptr) ||
tipc_bearer_blocked(l_ptr->b_ptr)) { tipc_bearer_blocked(l_ptr->b_ptr)) {
...@@ -1189,8 +1154,7 @@ int tipc_link_send_sections_fast(struct tipc_port *sender, ...@@ -1189,8 +1154,7 @@ int tipc_link_send_sections_fast(struct tipc_port *sender,
*/ */
static int link_send_sections_long(struct tipc_port *sender, static int link_send_sections_long(struct tipc_port *sender,
struct iovec const *msg_sect, struct iovec const *msg_sect,
u32 num_sect, u32 num_sect, unsigned int total_len,
unsigned int total_len,
u32 destaddr) u32 destaddr)
{ {
struct tipc_link *l_ptr; struct tipc_link *l_ptr;
...@@ -1204,6 +1168,7 @@ static int link_send_sections_long(struct tipc_port *sender, ...@@ -1204,6 +1168,7 @@ static int link_send_sections_long(struct tipc_port *sender,
const unchar *sect_crs; const unchar *sect_crs;
int curr_sect; int curr_sect;
u32 fragm_no; u32 fragm_no;
int res = 0;
again: again:
fragm_no = 1; fragm_no = 1;
...@@ -1250,18 +1215,15 @@ static int link_send_sections_long(struct tipc_port *sender, ...@@ -1250,18 +1215,15 @@ static int link_send_sections_long(struct tipc_port *sender,
else else
sz = fragm_rest; sz = fragm_rest;
if (likely(!sender->user_port)) { if (copy_from_user(buf->data + fragm_crs, sect_crs, sz)) {
if (copy_from_user(buf->data + fragm_crs, sect_crs, sz)) { res = -EFAULT;
error: error:
for (; buf_chain; buf_chain = buf) { for (; buf_chain; buf_chain = buf) {
buf = buf_chain->next; buf = buf_chain->next;
kfree_skb(buf_chain); kfree_skb(buf_chain);
}
return -EFAULT;
} }
} else return res;
skb_copy_to_linear_data_offset(buf, fragm_crs, }
sect_crs, sz);
sect_crs += sz; sect_crs += sz;
sect_rest -= sz; sect_rest -= sz;
fragm_crs += sz; fragm_crs += sz;
...@@ -1281,8 +1243,10 @@ static int link_send_sections_long(struct tipc_port *sender, ...@@ -1281,8 +1243,10 @@ static int link_send_sections_long(struct tipc_port *sender,
msg_set_fragm_no(&fragm_hdr, ++fragm_no); msg_set_fragm_no(&fragm_hdr, ++fragm_no);
prev = buf; prev = buf;
buf = tipc_buf_acquire(fragm_sz + INT_H_SIZE); buf = tipc_buf_acquire(fragm_sz + INT_H_SIZE);
if (!buf) if (!buf) {
res = -ENOMEM;
goto error; goto error;
}
buf->next = NULL; buf->next = NULL;
prev->next = buf; prev->next = buf;
...@@ -1446,7 +1410,7 @@ static void link_reset_all(unsigned long addr) ...@@ -1446,7 +1410,7 @@ static void link_reset_all(unsigned long addr)
} }
static void link_retransmit_failure(struct tipc_link *l_ptr, static void link_retransmit_failure(struct tipc_link *l_ptr,
struct sk_buff *buf) struct sk_buff *buf)
{ {
struct tipc_msg *msg = buf_msg(buf); struct tipc_msg *msg = buf_msg(buf);
...@@ -1901,8 +1865,8 @@ static void link_handle_out_of_seq_msg(struct tipc_link *l_ptr, ...@@ -1901,8 +1865,8 @@ static void link_handle_out_of_seq_msg(struct tipc_link *l_ptr,
* Send protocol message to the other endpoint. * Send protocol message to the other endpoint.
*/ */
void tipc_link_send_proto_msg(struct tipc_link *l_ptr, u32 msg_typ, void tipc_link_send_proto_msg(struct tipc_link *l_ptr, u32 msg_typ,
int probe_msg, u32 gap, u32 tolerance, int probe_msg, u32 gap, u32 tolerance,
u32 priority, u32 ack_mtu) u32 priority, u32 ack_mtu)
{ {
struct sk_buff *buf = NULL; struct sk_buff *buf = NULL;
struct tipc_msg *msg = l_ptr->pmsg; struct tipc_msg *msg = l_ptr->pmsg;
...@@ -1988,6 +1952,7 @@ void tipc_link_send_proto_msg(struct tipc_link *l_ptr, u32 msg_typ, ...@@ -1988,6 +1952,7 @@ void tipc_link_send_proto_msg(struct tipc_link *l_ptr, u32 msg_typ,
return; return;
skb_copy_to_linear_data(buf, msg, sizeof(l_ptr->proto_msg)); skb_copy_to_linear_data(buf, msg, sizeof(l_ptr->proto_msg));
buf->priority = TC_PRIO_CONTROL;
/* Defer message if bearer is already blocked */ /* Defer message if bearer is already blocked */
if (tipc_bearer_blocked(l_ptr->b_ptr)) { if (tipc_bearer_blocked(l_ptr->b_ptr)) {
...@@ -2145,8 +2110,7 @@ static void link_recv_proto_msg(struct tipc_link *l_ptr, struct sk_buff *buf) ...@@ -2145,8 +2110,7 @@ static void link_recv_proto_msg(struct tipc_link *l_ptr, struct sk_buff *buf)
* another bearer. Owner node is locked. * another bearer. Owner node is locked.
*/ */
static void tipc_link_tunnel(struct tipc_link *l_ptr, static void tipc_link_tunnel(struct tipc_link *l_ptr,
struct tipc_msg *tunnel_hdr, struct tipc_msg *tunnel_hdr, struct tipc_msg *msg,
struct tipc_msg *msg,
u32 selector) u32 selector)
{ {
struct tipc_link *tunnel; struct tipc_link *tunnel;
......
...@@ -51,8 +51,8 @@ u32 tipc_msg_tot_importance(struct tipc_msg *m) ...@@ -51,8 +51,8 @@ u32 tipc_msg_tot_importance(struct tipc_msg *m)
} }
void tipc_msg_init(struct tipc_msg *m, u32 user, u32 type, void tipc_msg_init(struct tipc_msg *m, u32 user, u32 type, u32 hsize,
u32 hsize, u32 destnode) u32 destnode)
{ {
memset(m, 0, hsize); memset(m, 0, hsize);
msg_set_version(m); msg_set_version(m);
...@@ -73,8 +73,8 @@ void tipc_msg_init(struct tipc_msg *m, u32 user, u32 type, ...@@ -73,8 +73,8 @@ void tipc_msg_init(struct tipc_msg *m, u32 user, u32 type,
* Returns message data size or errno * Returns message data size or errno
*/ */
int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect, int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
u32 num_sect, unsigned int total_len, u32 num_sect, unsigned int total_len, int max_size,
int max_size, int usrmem, struct sk_buff **buf) struct sk_buff **buf)
{ {
int dsz, sz, hsz, pos, res, cnt; int dsz, sz, hsz, pos, res, cnt;
...@@ -92,14 +92,9 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect, ...@@ -92,14 +92,9 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
return -ENOMEM; return -ENOMEM;
skb_copy_to_linear_data(*buf, hdr, hsz); skb_copy_to_linear_data(*buf, hdr, hsz);
for (res = 1, cnt = 0; res && (cnt < num_sect); cnt++) { for (res = 1, cnt = 0; res && (cnt < num_sect); cnt++) {
if (likely(usrmem)) skb_copy_to_linear_data_offset(*buf, pos,
res = !copy_from_user((*buf)->data + pos, msg_sect[cnt].iov_base,
msg_sect[cnt].iov_base, msg_sect[cnt].iov_len);
msg_sect[cnt].iov_len);
else
skb_copy_to_linear_data_offset(*buf, pos,
msg_sect[cnt].iov_base,
msg_sect[cnt].iov_len);
pos += msg_sect[cnt].iov_len; pos += msg_sect[cnt].iov_len;
} }
if (likely(res)) if (likely(res))
......
...@@ -719,9 +719,9 @@ static inline void msg_set_link_tolerance(struct tipc_msg *m, u32 n) ...@@ -719,9 +719,9 @@ static inline void msg_set_link_tolerance(struct tipc_msg *m, u32 n)
} }
u32 tipc_msg_tot_importance(struct tipc_msg *m); u32 tipc_msg_tot_importance(struct tipc_msg *m);
void tipc_msg_init(struct tipc_msg *m, u32 user, u32 type, void tipc_msg_init(struct tipc_msg *m, u32 user, u32 type, u32 hsize,
u32 hsize, u32 destnode); u32 destnode);
int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect, int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
u32 num_sect, unsigned int total_len, u32 num_sect, unsigned int total_len, int max_size,
int max_size, int usrmem, struct sk_buff **buf); struct sk_buff **buf);
#endif #endif
...@@ -440,7 +440,7 @@ static struct publication *tipc_nameseq_remove_publ(struct name_seq *nseq, u32 i ...@@ -440,7 +440,7 @@ static struct publication *tipc_nameseq_remove_publ(struct name_seq *nseq, u32 i
* sequence overlapping with the requested sequence * sequence overlapping with the requested sequence
*/ */
static void tipc_nameseq_subscribe(struct name_seq *nseq, static void tipc_nameseq_subscribe(struct name_seq *nseq,
struct tipc_subscription *s) struct tipc_subscription *s)
{ {
struct sub_seq *sseq = nseq->sseqs; struct sub_seq *sseq = nseq->sseqs;
...@@ -662,7 +662,7 @@ int tipc_nametbl_mc_translate(u32 type, u32 lower, u32 upper, u32 limit, ...@@ -662,7 +662,7 @@ int tipc_nametbl_mc_translate(u32 type, u32 lower, u32 upper, u32 limit,
* tipc_nametbl_publish - add name publication to network name tables * tipc_nametbl_publish - add name publication to network name tables
*/ */
struct publication *tipc_nametbl_publish(u32 type, u32 lower, u32 upper, struct publication *tipc_nametbl_publish(u32 type, u32 lower, u32 upper,
u32 scope, u32 port_ref, u32 key) u32 scope, u32 port_ref, u32 key)
{ {
struct publication *publ; struct publication *publ;
...@@ -753,7 +753,7 @@ void tipc_nametbl_unsubscribe(struct tipc_subscription *s) ...@@ -753,7 +753,7 @@ void tipc_nametbl_unsubscribe(struct tipc_subscription *s)
* subseq_list - print specified sub-sequence contents into the given buffer * subseq_list - print specified sub-sequence contents into the given buffer
*/ */
static int subseq_list(struct sub_seq *sseq, char *buf, int len, u32 depth, static int subseq_list(struct sub_seq *sseq, char *buf, int len, u32 depth,
u32 index) u32 index)
{ {
char portIdStr[27]; char portIdStr[27];
const char *scope_str[] = {"", " zone", " cluster", " node"}; const char *scope_str[] = {"", " zone", " cluster", " node"};
...@@ -792,7 +792,7 @@ static int subseq_list(struct sub_seq *sseq, char *buf, int len, u32 depth, ...@@ -792,7 +792,7 @@ static int subseq_list(struct sub_seq *sseq, char *buf, int len, u32 depth,
* nameseq_list - print specified name sequence contents into the given buffer * nameseq_list - print specified name sequence contents into the given buffer
*/ */
static int nameseq_list(struct name_seq *seq, char *buf, int len, u32 depth, static int nameseq_list(struct name_seq *seq, char *buf, int len, u32 depth,
u32 type, u32 lowbound, u32 upbound, u32 index) u32 type, u32 lowbound, u32 upbound, u32 index)
{ {
struct sub_seq *sseq; struct sub_seq *sseq;
char typearea[11]; char typearea[11];
...@@ -849,7 +849,7 @@ static int nametbl_header(char *buf, int len, u32 depth) ...@@ -849,7 +849,7 @@ static int nametbl_header(char *buf, int len, u32 depth)
* nametbl_list - print specified name table contents into the given buffer * nametbl_list - print specified name table contents into the given buffer
*/ */
static int nametbl_list(char *buf, int len, u32 depth_info, static int nametbl_list(char *buf, int len, u32 depth_info,
u32 type, u32 lowbound, u32 upbound) u32 type, u32 lowbound, u32 upbound)
{ {
struct hlist_head *seq_head; struct hlist_head *seq_head;
struct name_seq *seq; struct name_seq *seq;
......
...@@ -87,14 +87,15 @@ extern rwlock_t tipc_nametbl_lock; ...@@ -87,14 +87,15 @@ extern rwlock_t tipc_nametbl_lock;
struct sk_buff *tipc_nametbl_get(const void *req_tlv_area, int req_tlv_space); struct sk_buff *tipc_nametbl_get(const void *req_tlv_area, int req_tlv_space);
u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *node); u32 tipc_nametbl_translate(u32 type, u32 instance, u32 *node);
int tipc_nametbl_mc_translate(u32 type, u32 lower, u32 upper, u32 limit, int tipc_nametbl_mc_translate(u32 type, u32 lower, u32 upper, u32 limit,
struct tipc_port_list *dports); struct tipc_port_list *dports);
struct publication *tipc_nametbl_publish(u32 type, u32 lower, u32 upper, struct publication *tipc_nametbl_publish(u32 type, u32 lower, u32 upper,
u32 scope, u32 port_ref, u32 key); u32 scope, u32 port_ref, u32 key);
int tipc_nametbl_withdraw(u32 type, u32 lower, u32 ref, u32 key); int tipc_nametbl_withdraw(u32 type, u32 lower, u32 ref, u32 key);
struct publication *tipc_nametbl_insert_publ(u32 type, u32 lower, u32 upper, struct publication *tipc_nametbl_insert_publ(u32 type, u32 lower, u32 upper,
u32 scope, u32 node, u32 ref, u32 key); u32 scope, u32 node, u32 ref,
struct publication *tipc_nametbl_remove_publ(u32 type, u32 lower, u32 key);
u32 node, u32 ref, u32 key); struct publication *tipc_nametbl_remove_publ(u32 type, u32 lower, u32 node,
u32 ref, u32 key);
void tipc_nametbl_subscribe(struct tipc_subscription *s); void tipc_nametbl_subscribe(struct tipc_subscription *s);
void tipc_nametbl_unsubscribe(struct tipc_subscription *s); void tipc_nametbl_unsubscribe(struct tipc_subscription *s);
int tipc_nametbl_init(void); int tipc_nametbl_init(void);
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
* tipc_nodesub_subscribe - create "node down" subscription for specified node * tipc_nodesub_subscribe - create "node down" subscription for specified node
*/ */
void tipc_nodesub_subscribe(struct tipc_node_subscr *node_sub, u32 addr, void tipc_nodesub_subscribe(struct tipc_node_subscr *node_sub, u32 addr,
void *usr_handle, net_ev_handler handle_down) void *usr_handle, net_ev_handler handle_down)
{ {
if (in_own_node(addr)) { if (in_own_node(addr)) {
node_sub->node = NULL; node_sub->node = NULL;
......
This diff is collapsed.
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* net/tipc/port.h: Include file for TIPC port code * net/tipc/port.h: Include file for TIPC port code
* *
* Copyright (c) 1994-2007, Ericsson AB * Copyright (c) 1994-2007, Ericsson AB
* Copyright (c) 2004-2007, 2010-2011, Wind River Systems * Copyright (c) 2004-2007, 2010-2013, Wind River Systems
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
...@@ -43,60 +43,12 @@ ...@@ -43,60 +43,12 @@
#include "node_subscr.h" #include "node_subscr.h"
#define TIPC_FLOW_CONTROL_WIN 512 #define TIPC_FLOW_CONTROL_WIN 512
#define CONN_OVERLOAD_LIMIT ((TIPC_FLOW_CONTROL_WIN * 2 + 1) * \
typedef void (*tipc_msg_err_event) (void *usr_handle, u32 portref, SKB_TRUESIZE(TIPC_MAX_USER_MSG_SIZE))
struct sk_buff **buf, unsigned char const *data,
unsigned int size, int reason,
struct tipc_portid const *attmpt_destid);
typedef void (*tipc_named_msg_err_event) (void *usr_handle, u32 portref,
struct sk_buff **buf, unsigned char const *data,
unsigned int size, int reason,
struct tipc_name_seq const *attmpt_dest);
typedef void (*tipc_conn_shutdown_event) (void *usr_handle, u32 portref,
struct sk_buff **buf, unsigned char const *data,
unsigned int size, int reason);
typedef void (*tipc_msg_event) (void *usr_handle, u32 portref,
struct sk_buff **buf, unsigned char const *data,
unsigned int size, unsigned int importance,
struct tipc_portid const *origin);
typedef void (*tipc_named_msg_event) (void *usr_handle, u32 portref,
struct sk_buff **buf, unsigned char const *data,
unsigned int size, unsigned int importance,
struct tipc_portid const *orig,
struct tipc_name_seq const *dest);
typedef void (*tipc_conn_msg_event) (void *usr_handle, u32 portref,
struct sk_buff **buf, unsigned char const *data,
unsigned int size);
typedef void (*tipc_continue_event) (void *usr_handle, u32 portref);
/**
* struct user_port - TIPC user port (used with native API)
* @usr_handle: user-specified field
* @ref: object reference to associated TIPC port
*
* <various callback routines>
*/
struct user_port {
void *usr_handle;
u32 ref;
tipc_msg_err_event err_cb;
tipc_named_msg_err_event named_err_cb;
tipc_conn_shutdown_event conn_err_cb;
tipc_msg_event msg_cb;
tipc_named_msg_event named_msg_cb;
tipc_conn_msg_event conn_msg_cb;
tipc_continue_event continue_event_cb;
};
/** /**
* struct tipc_port - TIPC port structure * struct tipc_port - TIPC port structure
* @usr_handle: pointer to additional user-defined information about port * @sk: pointer to socket handle
* @lock: pointer to spinlock for controlling access to port * @lock: pointer to spinlock for controlling access to port
* @connected: non-zero if port is currently connected to a peer port * @connected: non-zero if port is currently connected to a peer port
* @conn_type: TIPC type used when connection was established * @conn_type: TIPC type used when connection was established
...@@ -110,7 +62,6 @@ struct user_port { ...@@ -110,7 +62,6 @@ struct user_port {
* @port_list: adjacent ports in TIPC's global list of ports * @port_list: adjacent ports in TIPC's global list of ports
* @dispatcher: ptr to routine which handles received messages * @dispatcher: ptr to routine which handles received messages
* @wakeup: ptr to routine to call when port is no longer congested * @wakeup: ptr to routine to call when port is no longer congested
* @user_port: ptr to user port associated with port (if any)
* @wait_list: adjacent ports in list of ports waiting on link congestion * @wait_list: adjacent ports in list of ports waiting on link congestion
* @waiting_pkts: * @waiting_pkts:
* @sent: # of non-empty messages sent by port * @sent: # of non-empty messages sent by port
...@@ -123,7 +74,7 @@ struct user_port { ...@@ -123,7 +74,7 @@ struct user_port {
* @subscription: "node down" subscription used to terminate failed connections * @subscription: "node down" subscription used to terminate failed connections
*/ */
struct tipc_port { struct tipc_port {
void *usr_handle; struct sock *sk;
spinlock_t *lock; spinlock_t *lock;
int connected; int connected;
u32 conn_type; u32 conn_type;
...@@ -137,7 +88,6 @@ struct tipc_port { ...@@ -137,7 +88,6 @@ struct tipc_port {
struct list_head port_list; struct list_head port_list;
u32 (*dispatcher)(struct tipc_port *, struct sk_buff *); u32 (*dispatcher)(struct tipc_port *, struct sk_buff *);
void (*wakeup)(struct tipc_port *); void (*wakeup)(struct tipc_port *);
struct user_port *user_port;
struct list_head wait_list; struct list_head wait_list;
u32 waiting_pkts; u32 waiting_pkts;
u32 sent; u32 sent;
...@@ -156,24 +106,16 @@ struct tipc_port_list; ...@@ -156,24 +106,16 @@ struct tipc_port_list;
/* /*
* TIPC port manipulation routines * TIPC port manipulation routines
*/ */
struct tipc_port *tipc_createport_raw(void *usr_handle, struct tipc_port *tipc_createport(struct sock *sk,
u32 (*dispatcher)(struct tipc_port *, struct sk_buff *), u32 (*dispatcher)(struct tipc_port *,
void (*wakeup)(struct tipc_port *), const u32 importance); struct sk_buff *),
void (*wakeup)(struct tipc_port *),
const u32 importance);
int tipc_reject_msg(struct sk_buff *buf, u32 err); int tipc_reject_msg(struct sk_buff *buf, u32 err);
int tipc_send_buf_fast(struct sk_buff *buf, u32 destnode);
void tipc_acknowledge(u32 port_ref, u32 ack); void tipc_acknowledge(u32 port_ref, u32 ack);
int tipc_createport(void *usr_handle,
unsigned int importance, tipc_msg_err_event error_cb,
tipc_named_msg_err_event named_error_cb,
tipc_conn_shutdown_event conn_error_cb, tipc_msg_event msg_cb,
tipc_named_msg_event named_msg_cb,
tipc_conn_msg_event conn_msg_cb,
tipc_continue_event continue_event_cb, u32 *portref);
int tipc_deleteport(u32 portref); int tipc_deleteport(u32 portref);
int tipc_portimportance(u32 portref, unsigned int *importance); int tipc_portimportance(u32 portref, unsigned int *importance);
...@@ -186,9 +128,9 @@ int tipc_portunreturnable(u32 portref, unsigned int *isunreturnable); ...@@ -186,9 +128,9 @@ int tipc_portunreturnable(u32 portref, unsigned int *isunreturnable);
int tipc_set_portunreturnable(u32 portref, unsigned int isunreturnable); int tipc_set_portunreturnable(u32 portref, unsigned int isunreturnable);
int tipc_publish(u32 portref, unsigned int scope, int tipc_publish(u32 portref, unsigned int scope,
struct tipc_name_seq const *name_seq); struct tipc_name_seq const *name_seq);
int tipc_withdraw(u32 portref, unsigned int scope, int tipc_withdraw(u32 portref, unsigned int scope,
struct tipc_name_seq const *name_seq); struct tipc_name_seq const *name_seq);
int tipc_connect(u32 portref, struct tipc_portid const *port); int tipc_connect(u32 portref, struct tipc_portid const *port);
...@@ -220,9 +162,6 @@ int tipc_send2port(u32 portref, struct tipc_portid const *dest, ...@@ -220,9 +162,6 @@ int tipc_send2port(u32 portref, struct tipc_portid const *dest,
unsigned int num_sect, struct iovec const *msg_sect, unsigned int num_sect, struct iovec const *msg_sect,
unsigned int total_len); unsigned int total_len);
int tipc_send_buf2port(u32 portref, struct tipc_portid const *dest,
struct sk_buff *buf, unsigned int dsz);
int tipc_multicast(u32 portref, struct tipc_name_seq const *seq, int tipc_multicast(u32 portref, struct tipc_name_seq const *seq,
unsigned int section_count, struct iovec const *msg, unsigned int section_count, struct iovec const *msg,
unsigned int total_len); unsigned int total_len);
......
This diff is collapsed.
/*
* net/tipc/server.h: Include file for TIPC server code
*
* Copyright (c) 2012-2013, Wind River Systems
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the names of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _TIPC_SERVER_H
#define _TIPC_SERVER_H
#include "core.h"
#define TIPC_SERVER_NAME_LEN 32
/**
* struct tipc_server - TIPC server structure
* @conn_idr: identifier set of connection
* @idr_lock: protect the connection identifier set
* @idr_in_use: amount of allocated identifier entry
* @rcvbuf_cache: memory cache of server receive buffer
* @rcv_wq: receive workqueue
* @send_wq: send workqueue
* @max_rcvbuf_size: maximum permitted receive message length
* @tipc_conn_new: callback will be called when new connection is incoming
* @tipc_conn_shutdown: callback will be called when connection is shut down
* @tipc_conn_recvmsg: callback will be called when message arrives
* @saddr: TIPC server address
* @name: server name
* @imp: message importance
* @type: socket type
* @enabled: identify whether server is launched or not
*/
struct tipc_server {
struct idr conn_idr;
spinlock_t idr_lock;
int idr_in_use;
struct kmem_cache *rcvbuf_cache;
struct workqueue_struct *rcv_wq;
struct workqueue_struct *send_wq;
int max_rcvbuf_size;
void *(*tipc_conn_new) (int conid);
void (*tipc_conn_shutdown) (int conid, void *usr_data);
void (*tipc_conn_recvmsg) (int conid, struct sockaddr_tipc *addr,
void *usr_data, void *buf, size_t len);
struct sockaddr_tipc *saddr;
const char name[TIPC_SERVER_NAME_LEN];
int imp;
int type;
int enabled;
};
int tipc_conn_sendmsg(struct tipc_server *s, int conid,
struct sockaddr_tipc *addr, void *data, size_t len);
/**
* tipc_conn_terminate - terminate connection with server
*
* Note: Must call it in process context since it might sleep
*/
void tipc_conn_terminate(struct tipc_server *s, int conid);
int tipc_server_start(struct tipc_server *s);
void tipc_server_stop(struct tipc_server *s);
#endif
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* net/tipc/socket.c: TIPC socket API * net/tipc/socket.c: TIPC socket API
* *
* Copyright (c) 2001-2007, 2012 Ericsson AB * Copyright (c) 2001-2007, 2012 Ericsson AB
* Copyright (c) 2004-2008, 2010-2012, Wind River Systems * Copyright (c) 2004-2008, 2010-2013, Wind River Systems
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
...@@ -43,8 +43,6 @@ ...@@ -43,8 +43,6 @@
#define SS_LISTENING -1 /* socket is listening */ #define SS_LISTENING -1 /* socket is listening */
#define SS_READY -2 /* socket is connectionless */ #define SS_READY -2 /* socket is connectionless */
#define CONN_OVERLOAD_LIMIT ((TIPC_FLOW_CONTROL_WIN * 2 + 1) * \
SKB_TRUESIZE(TIPC_MAX_USER_MSG_SIZE))
#define CONN_TIMEOUT_DEFAULT 8000 /* default connect timeout = 8s */ #define CONN_TIMEOUT_DEFAULT 8000 /* default connect timeout = 8s */
struct tipc_sock { struct tipc_sock {
...@@ -65,12 +63,15 @@ static u32 dispatch(struct tipc_port *tport, struct sk_buff *buf); ...@@ -65,12 +63,15 @@ static u32 dispatch(struct tipc_port *tport, struct sk_buff *buf);
static void wakeupdispatch(struct tipc_port *tport); static void wakeupdispatch(struct tipc_port *tport);
static void tipc_data_ready(struct sock *sk, int len); static void tipc_data_ready(struct sock *sk, int len);
static void tipc_write_space(struct sock *sk); static void tipc_write_space(struct sock *sk);
static int release(struct socket *sock);
static int accept(struct socket *sock, struct socket *new_sock, int flags);
static const struct proto_ops packet_ops; static const struct proto_ops packet_ops;
static const struct proto_ops stream_ops; static const struct proto_ops stream_ops;
static const struct proto_ops msg_ops; static const struct proto_ops msg_ops;
static struct proto tipc_proto; static struct proto tipc_proto;
static struct proto tipc_proto_kern;
static int sockets_enabled; static int sockets_enabled;
...@@ -143,7 +144,7 @@ static void reject_rx_queue(struct sock *sk) ...@@ -143,7 +144,7 @@ static void reject_rx_queue(struct sock *sk)
} }
/** /**
* tipc_create - create a TIPC socket * tipc_sk_create - create a TIPC socket
* @net: network namespace (must be default network) * @net: network namespace (must be default network)
* @sock: pre-allocated socket structure * @sock: pre-allocated socket structure
* @protocol: protocol indicator (must be 0) * @protocol: protocol indicator (must be 0)
...@@ -154,8 +155,8 @@ static void reject_rx_queue(struct sock *sk) ...@@ -154,8 +155,8 @@ static void reject_rx_queue(struct sock *sk)
* *
* Returns 0 on success, errno otherwise * Returns 0 on success, errno otherwise
*/ */
static int tipc_create(struct net *net, struct socket *sock, int protocol, static int tipc_sk_create(struct net *net, struct socket *sock, int protocol,
int kern) int kern)
{ {
const struct proto_ops *ops; const struct proto_ops *ops;
socket_state state; socket_state state;
...@@ -185,13 +186,17 @@ static int tipc_create(struct net *net, struct socket *sock, int protocol, ...@@ -185,13 +186,17 @@ static int tipc_create(struct net *net, struct socket *sock, int protocol,
} }
/* Allocate socket's protocol area */ /* Allocate socket's protocol area */
sk = sk_alloc(net, AF_TIPC, GFP_KERNEL, &tipc_proto); if (!kern)
sk = sk_alloc(net, AF_TIPC, GFP_KERNEL, &tipc_proto);
else
sk = sk_alloc(net, AF_TIPC, GFP_KERNEL, &tipc_proto_kern);
if (sk == NULL) if (sk == NULL)
return -ENOMEM; return -ENOMEM;
/* Allocate TIPC port for socket to use */ /* Allocate TIPC port for socket to use */
tp_ptr = tipc_createport_raw(sk, &dispatch, &wakeupdispatch, tp_ptr = tipc_createport(sk, &dispatch, &wakeupdispatch,
TIPC_LOW_IMPORTANCE); TIPC_LOW_IMPORTANCE);
if (unlikely(!tp_ptr)) { if (unlikely(!tp_ptr)) {
sk_free(sk); sk_free(sk);
return -ENOMEM; return -ENOMEM;
...@@ -203,6 +208,7 @@ static int tipc_create(struct net *net, struct socket *sock, int protocol, ...@@ -203,6 +208,7 @@ static int tipc_create(struct net *net, struct socket *sock, int protocol,
sock_init_data(sock, sk); sock_init_data(sock, sk);
sk->sk_backlog_rcv = backlog_rcv; sk->sk_backlog_rcv = backlog_rcv;
sk->sk_rcvbuf = sysctl_tipc_rmem[1];
sk->sk_data_ready = tipc_data_ready; sk->sk_data_ready = tipc_data_ready;
sk->sk_write_space = tipc_write_space; sk->sk_write_space = tipc_write_space;
tipc_sk(sk)->p = tp_ptr; tipc_sk(sk)->p = tp_ptr;
...@@ -219,6 +225,78 @@ static int tipc_create(struct net *net, struct socket *sock, int protocol, ...@@ -219,6 +225,78 @@ static int tipc_create(struct net *net, struct socket *sock, int protocol,
return 0; return 0;
} }
/**
* tipc_sock_create_local - create TIPC socket from inside TIPC module
* @type: socket type - SOCK_RDM or SOCK_SEQPACKET
*
* We cannot use sock_creat_kern here because it bumps module user count.
* Since socket owner and creator is the same module we must make sure
* that module count remains zero for module local sockets, otherwise
* we cannot do rmmod.
*
* Returns 0 on success, errno otherwise
*/
int tipc_sock_create_local(int type, struct socket **res)
{
int rc;
struct sock *sk;
rc = sock_create_lite(AF_TIPC, type, 0, res);
if (rc < 0) {
pr_err("Failed to create kernel socket\n");
return rc;
}
tipc_sk_create(&init_net, *res, 0, 1);
sk = (*res)->sk;
return 0;
}
/**
* tipc_sock_release_local - release socket created by tipc_sock_create_local
* @sock: the socket to be released.
*
* Module reference count is not incremented when such sockets are created,
* so we must keep it from being decremented when they are released.
*/
void tipc_sock_release_local(struct socket *sock)
{
release(sock);
sock->ops = NULL;
sock_release(sock);
}
/**
* tipc_sock_accept_local - accept a connection on a socket created
* with tipc_sock_create_local. Use this function to avoid that
* module reference count is inadvertently incremented.
*
* @sock: the accepting socket
* @newsock: reference to the new socket to be created
* @flags: socket flags
*/
int tipc_sock_accept_local(struct socket *sock, struct socket **newsock,
int flags)
{
struct sock *sk = sock->sk;
int ret;
ret = sock_create_lite(sk->sk_family, sk->sk_type,
sk->sk_protocol, newsock);
if (ret < 0)
return ret;
ret = accept(sock, *newsock, flags);
if (ret < 0) {
sock_release(*newsock);
return ret;
}
(*newsock)->ops = sock->ops;
return ret;
}
/** /**
* release - destroy a TIPC socket * release - destroy a TIPC socket
* @sock: socket to destroy * @sock: socket to destroy
...@@ -324,7 +402,9 @@ static int bind(struct socket *sock, struct sockaddr *uaddr, int uaddr_len) ...@@ -324,7 +402,9 @@ static int bind(struct socket *sock, struct sockaddr *uaddr, int uaddr_len)
else if (addr->addrtype != TIPC_ADDR_NAMESEQ) else if (addr->addrtype != TIPC_ADDR_NAMESEQ)
return -EAFNOSUPPORT; return -EAFNOSUPPORT;
if (addr->addr.nameseq.type < TIPC_RESERVED_TYPES) if ((addr->addr.nameseq.type < TIPC_RESERVED_TYPES) &&
(addr->addr.nameseq.type != TIPC_TOP_SRV) &&
(addr->addr.nameseq.type != TIPC_CFG_SRV))
return -EACCES; return -EACCES;
return (addr->scope > 0) ? return (addr->scope > 0) ?
...@@ -519,8 +599,7 @@ static int send_msg(struct kiocb *iocb, struct socket *sock, ...@@ -519,8 +599,7 @@ static int send_msg(struct kiocb *iocb, struct socket *sock,
res = -EISCONN; res = -EISCONN;
goto exit; goto exit;
} }
if ((tport->published) || if (tport->published) {
((sock->type == SOCK_STREAM) && (total_len != 0))) {
res = -EOPNOTSUPP; res = -EOPNOTSUPP;
goto exit; goto exit;
} }
...@@ -810,7 +889,7 @@ static void set_orig_addr(struct msghdr *m, struct tipc_msg *msg) ...@@ -810,7 +889,7 @@ static void set_orig_addr(struct msghdr *m, struct tipc_msg *msg)
* Returns 0 if successful, otherwise errno * Returns 0 if successful, otherwise errno
*/ */
static int anc_data_recv(struct msghdr *m, struct tipc_msg *msg, static int anc_data_recv(struct msghdr *m, struct tipc_msg *msg,
struct tipc_port *tport) struct tipc_port *tport)
{ {
u32 anc_data[3]; u32 anc_data[3];
u32 err; u32 err;
...@@ -1011,8 +1090,7 @@ static int recv_stream(struct kiocb *iocb, struct socket *sock, ...@@ -1011,8 +1090,7 @@ static int recv_stream(struct kiocb *iocb, struct socket *sock,
lock_sock(sk); lock_sock(sk);
if (unlikely((sock->state == SS_UNCONNECTED) || if (unlikely((sock->state == SS_UNCONNECTED))) {
(sock->state == SS_CONNECTING))) {
res = -ENOTCONN; res = -ENOTCONN;
goto exit; goto exit;
} }
...@@ -1233,10 +1311,10 @@ static u32 filter_connect(struct tipc_sock *tsock, struct sk_buff **buf) ...@@ -1233,10 +1311,10 @@ static u32 filter_connect(struct tipc_sock *tsock, struct sk_buff **buf)
* For all connectionless messages, by default new queue limits are * For all connectionless messages, by default new queue limits are
* as belows: * as belows:
* *
* TIPC_LOW_IMPORTANCE (5MB) * TIPC_LOW_IMPORTANCE (4 MB)
* TIPC_MEDIUM_IMPORTANCE (10MB) * TIPC_MEDIUM_IMPORTANCE (8 MB)
* TIPC_HIGH_IMPORTANCE (20MB) * TIPC_HIGH_IMPORTANCE (16 MB)
* TIPC_CRITICAL_IMPORTANCE (40MB) * TIPC_CRITICAL_IMPORTANCE (32 MB)
* *
* Returns overload limit according to corresponding message importance * Returns overload limit according to corresponding message importance
*/ */
...@@ -1246,9 +1324,10 @@ static unsigned int rcvbuf_limit(struct sock *sk, struct sk_buff *buf) ...@@ -1246,9 +1324,10 @@ static unsigned int rcvbuf_limit(struct sock *sk, struct sk_buff *buf)
unsigned int limit; unsigned int limit;
if (msg_connected(msg)) if (msg_connected(msg))
limit = CONN_OVERLOAD_LIMIT; limit = sysctl_tipc_rmem[2];
else else
limit = sk->sk_rcvbuf << (msg_importance(msg) + 5); limit = sk->sk_rcvbuf >> TIPC_CRITICAL_IMPORTANCE <<
msg_importance(msg);
return limit; return limit;
} }
...@@ -1327,7 +1406,7 @@ static int backlog_rcv(struct sock *sk, struct sk_buff *buf) ...@@ -1327,7 +1406,7 @@ static int backlog_rcv(struct sock *sk, struct sk_buff *buf)
*/ */
static u32 dispatch(struct tipc_port *tport, struct sk_buff *buf) static u32 dispatch(struct tipc_port *tport, struct sk_buff *buf)
{ {
struct sock *sk = (struct sock *)tport->usr_handle; struct sock *sk = tport->sk;
u32 res; u32 res;
/* /*
...@@ -1358,7 +1437,7 @@ static u32 dispatch(struct tipc_port *tport, struct sk_buff *buf) ...@@ -1358,7 +1437,7 @@ static u32 dispatch(struct tipc_port *tport, struct sk_buff *buf)
*/ */
static void wakeupdispatch(struct tipc_port *tport) static void wakeupdispatch(struct tipc_port *tport)
{ {
struct sock *sk = (struct sock *)tport->usr_handle; struct sock *sk = tport->sk;
sk->sk_write_space(sk); sk->sk_write_space(sk);
} }
...@@ -1531,7 +1610,7 @@ static int accept(struct socket *sock, struct socket *new_sock, int flags) ...@@ -1531,7 +1610,7 @@ static int accept(struct socket *sock, struct socket *new_sock, int flags)
buf = skb_peek(&sk->sk_receive_queue); buf = skb_peek(&sk->sk_receive_queue);
res = tipc_create(sock_net(sock->sk), new_sock, 0, 0); res = tipc_sk_create(sock_net(sock->sk), new_sock, 0, 1);
if (res) if (res)
goto exit; goto exit;
...@@ -1657,8 +1736,8 @@ static int shutdown(struct socket *sock, int how) ...@@ -1657,8 +1736,8 @@ static int shutdown(struct socket *sock, int how)
* *
* Returns 0 on success, errno otherwise * Returns 0 on success, errno otherwise
*/ */
static int setsockopt(struct socket *sock, static int setsockopt(struct socket *sock, int lvl, int opt, char __user *ov,
int lvl, int opt, char __user *ov, unsigned int ol) unsigned int ol)
{ {
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
struct tipc_port *tport = tipc_sk_port(sk); struct tipc_port *tport = tipc_sk_port(sk);
...@@ -1716,8 +1795,8 @@ static int setsockopt(struct socket *sock, ...@@ -1716,8 +1795,8 @@ static int setsockopt(struct socket *sock,
* *
* Returns 0 on success, errno otherwise * Returns 0 on success, errno otherwise
*/ */
static int getsockopt(struct socket *sock, static int getsockopt(struct socket *sock, int lvl, int opt, char __user *ov,
int lvl, int opt, char __user *ov, int __user *ol) int __user *ol)
{ {
struct sock *sk = sock->sk; struct sock *sk = sock->sk;
struct tipc_port *tport = tipc_sk_port(sk); struct tipc_port *tport = tipc_sk_port(sk);
...@@ -1841,13 +1920,20 @@ static const struct proto_ops stream_ops = { ...@@ -1841,13 +1920,20 @@ static const struct proto_ops stream_ops = {
static const struct net_proto_family tipc_family_ops = { static const struct net_proto_family tipc_family_ops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.family = AF_TIPC, .family = AF_TIPC,
.create = tipc_create .create = tipc_sk_create
}; };
static struct proto tipc_proto = { static struct proto tipc_proto = {
.name = "TIPC", .name = "TIPC",
.owner = THIS_MODULE, .owner = THIS_MODULE,
.obj_size = sizeof(struct tipc_sock) .obj_size = sizeof(struct tipc_sock),
.sysctl_rmem = sysctl_tipc_rmem
};
static struct proto tipc_proto_kern = {
.name = "TIPC",
.obj_size = sizeof(struct tipc_sock),
.sysctl_rmem = sysctl_tipc_rmem
}; };
/** /**
......
This diff is collapsed.
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* net/tipc/subscr.h: Include file for TIPC network topology service * net/tipc/subscr.h: Include file for TIPC network topology service
* *
* Copyright (c) 2003-2006, Ericsson AB * Copyright (c) 2003-2006, Ericsson AB
* Copyright (c) 2005-2007, Wind River Systems * Copyright (c) 2005-2007, 2012-2013, Wind River Systems
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
...@@ -37,10 +37,14 @@ ...@@ -37,10 +37,14 @@
#ifndef _TIPC_SUBSCR_H #ifndef _TIPC_SUBSCR_H
#define _TIPC_SUBSCR_H #define _TIPC_SUBSCR_H
#include "server.h"
struct tipc_subscription; struct tipc_subscription;
struct tipc_subscriber;
/** /**
* struct tipc_subscription - TIPC network topology subscription object * struct tipc_subscription - TIPC network topology subscription object
* @subscriber: pointer to its subscriber
* @seq: name sequence associated with subscription * @seq: name sequence associated with subscription
* @timeout: duration of subscription (in ms) * @timeout: duration of subscription (in ms)
* @filter: event filtering to be done for subscription * @filter: event filtering to be done for subscription
...@@ -52,28 +56,23 @@ struct tipc_subscription; ...@@ -52,28 +56,23 @@ struct tipc_subscription;
* @evt: template for events generated by subscription * @evt: template for events generated by subscription
*/ */
struct tipc_subscription { struct tipc_subscription {
struct tipc_subscriber *subscriber;
struct tipc_name_seq seq; struct tipc_name_seq seq;
u32 timeout; u32 timeout;
u32 filter; u32 filter;
struct timer_list timer; struct timer_list timer;
struct list_head nameseq_list; struct list_head nameseq_list;
struct list_head subscription_list; struct list_head subscription_list;
u32 server_ref;
int swap; int swap;
struct tipc_event evt; struct tipc_event evt;
}; };
int tipc_subscr_overlap(struct tipc_subscription *sub, int tipc_subscr_overlap(struct tipc_subscription *sub, u32 found_lower,
u32 found_lower,
u32 found_upper); u32 found_upper);
void tipc_subscr_report_overlap(struct tipc_subscription *sub, void tipc_subscr_report_overlap(struct tipc_subscription *sub, u32 found_lower,
u32 found_lower, u32 found_upper, u32 event, u32 port_ref,
u32 found_upper, u32 node, int must);
u32 event,
u32 port_ref,
u32 node,
int must_report);
int tipc_subscr_start(void); int tipc_subscr_start(void);
......
/*
* net/tipc/sysctl.c: sysctl interface to TIPC subsystem
*
* Copyright (c) 2013, Wind River Systems
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the names of the copyright holders nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* Alternatively, this software may be distributed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "core.h"
#include <linux/sysctl.h>
static struct ctl_table_header *tipc_ctl_hdr;
static struct ctl_table tipc_table[] = {
{
.procname = "tipc_rmem",
.data = &sysctl_tipc_rmem,
.maxlen = sizeof(sysctl_tipc_rmem),
.mode = 0644,
.proc_handler = proc_dointvec,
},
{}
};
int tipc_register_sysctl(void)
{
tipc_ctl_hdr = register_net_sysctl(&init_net, "net/tipc", tipc_table);
if (tipc_ctl_hdr == NULL)
return -ENOMEM;
return 0;
}
void tipc_unregister_sysctl(void)
{
unregister_net_sysctl_table(tipc_ctl_hdr);
}
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