Commit 13a2e898 authored by Ying Xue's avatar Ying Xue Committed by David S. Miller

tipc: convert topology server to use new server facility

As the new TIPC server infrastructure has been introduced, we can
now convert the TIPC topology server to it.  We get two benefits
from doing this:

1) It simplifies the topology server locking policy.  In the
original locking policy, we placed one spin lock pointer in the
tipc_subscriber structure to reuse the lock of the subscriber's
server port, controlling access to members of tipc_subscriber
instance.  That is, we only used one lock to ensure both
tipc_port and tipc_subscriber members were safely accessed.

Now we introduce another spin lock for tipc_subscriber structure
only protecting themselves, to get a finer granularity locking
policy.  Moreover, the change will allow us to make the topology
server code more readable and maintainable.

2) It fixes a bug where sent subscription events may be lost when
the topology port is congested.  Using the new service, the
topology server now queues sent events into an outgoing buffer,
and then wakes up a sender process which has been blocked in
workqueue context.  The process will keep picking events from the
buffer and send them to their respective subscribers, using the
kernel socket interface, until the buffer is empty. Even if the
socket is congested during transmission there is no risk that
events may be dropped, since the sender process may block when
needed.

Some minor reordering of initialization is done, since we now
have a scenario where the topology server must be started after
socket initialization has taken place, as the former depends
on the latter.  And overall, we see a simplification of the
TIPC subscriber code in making this changeover.
Signed-off-by: default avatarYing Xue <ying.xue@windriver.com>
Signed-off-by: default avatarJon Maloy <jon.maloy@ericsson.com>
Signed-off-by: default avatarPaul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent c5fa7b3c
...@@ -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
...@@ -136,8 +136,6 @@ static int tipc_core_start(void) ...@@ -136,8 +136,6 @@ 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) if (!res)
res = tipc_cfg_init(); res = tipc_cfg_init();
if (!res) if (!res)
...@@ -146,6 +144,8 @@ static int tipc_core_start(void) ...@@ -146,6 +144,8 @@ static int tipc_core_start(void)
res = tipc_socket_init(); res = tipc_socket_init();
if (!res) if (!res)
res = tipc_register_sysctl(); res = tipc_register_sysctl();
if (!res)
res = tipc_subscr_start();
if (res) if (res)
tipc_core_stop(); tipc_core_stop();
......
...@@ -402,7 +402,8 @@ static int bind(struct socket *sock, struct sockaddr *uaddr, int uaddr_len) ...@@ -402,7 +402,8 @@ 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))
return -EACCES; return -EACCES;
return (addr->scope > 0) ? return (addr->scope > 0) ?
......
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,13 +56,13 @@ struct tipc_subscription; ...@@ -52,13 +56,13 @@ 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;
}; };
......
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