aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Maloy <jon.maloy@ericsson.com>2018-02-15 04:40:45 -0500
committerDavid S. Miller <davem@davemloft.net>2018-02-16 15:26:33 -0500
commit414574a0af36d329f560f542e650cc4a81cc1d69 (patch)
treef4a319ea2214e6fb3f8a12521001bf0b50add3a2
parentdf79d040dcd7d7e580c50edf40b82e677fe84801 (diff)
tipc: simplify interaction between subscription and topology connection
The message transmission and reception in the topology server is more generic than is currently necessary. By basing the funtionality on the fact that we only send items of type struct tipc_event and always receive items of struct tipc_subcr we can make several simplifications, and also get rid of some unnecessary dynamic memory allocations. Acked-by: Ying Xue <ying.xue@windriver.com> Signed-off-by: Jon Maloy <jon.maloy@ericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/tipc/name_table.c10
-rw-r--r--net/tipc/server.c170
-rw-r--r--net/tipc/server.h12
-rw-r--r--net/tipc/subscr.c40
-rw-r--r--net/tipc/subscr.h5
5 files changed, 88 insertions, 149 deletions
diff --git a/net/tipc/name_table.c b/net/tipc/name_table.c
index ed0457cc99d6..c0ca7be46f7a 100644
--- a/net/tipc/name_table.c
+++ b/net/tipc/name_table.c
@@ -810,14 +810,15 @@ int tipc_nametbl_withdraw(struct net *net, u32 type, u32 lower, u32 ref,
810 */ 810 */
811void tipc_nametbl_subscribe(struct tipc_subscription *s, bool status) 811void tipc_nametbl_subscribe(struct tipc_subscription *s, bool status)
812{ 812{
813 struct tipc_net *tn = net_generic(s->net, tipc_net_id); 813 struct tipc_server *srv = s->server;
814 struct tipc_net *tn = tipc_net(srv->net);
814 u32 type = tipc_subscrp_convert_seq_type(s->evt.s.seq.type, s->swap); 815 u32 type = tipc_subscrp_convert_seq_type(s->evt.s.seq.type, s->swap);
815 int index = hash(type); 816 int index = hash(type);
816 struct name_seq *seq; 817 struct name_seq *seq;
817 struct tipc_name_seq ns; 818 struct tipc_name_seq ns;
818 819
819 spin_lock_bh(&tn->nametbl_lock); 820 spin_lock_bh(&tn->nametbl_lock);
820 seq = nametbl_find_seq(s->net, type); 821 seq = nametbl_find_seq(srv->net, type);
821 if (!seq) 822 if (!seq)
822 seq = tipc_nameseq_create(type, &tn->nametbl->seq_hlist[index]); 823 seq = tipc_nameseq_create(type, &tn->nametbl->seq_hlist[index]);
823 if (seq) { 824 if (seq) {
@@ -837,12 +838,13 @@ void tipc_nametbl_subscribe(struct tipc_subscription *s, bool status)
837 */ 838 */
838void tipc_nametbl_unsubscribe(struct tipc_subscription *s) 839void tipc_nametbl_unsubscribe(struct tipc_subscription *s)
839{ 840{
840 struct tipc_net *tn = net_generic(s->net, tipc_net_id); 841 struct tipc_server *srv = s->server;
842 struct tipc_net *tn = tipc_net(srv->net);
841 struct name_seq *seq; 843 struct name_seq *seq;
842 u32 type = tipc_subscrp_convert_seq_type(s->evt.s.seq.type, s->swap); 844 u32 type = tipc_subscrp_convert_seq_type(s->evt.s.seq.type, s->swap);
843 845
844 spin_lock_bh(&tn->nametbl_lock); 846 spin_lock_bh(&tn->nametbl_lock);
845 seq = nametbl_find_seq(s->net, type); 847 seq = nametbl_find_seq(srv->net, type);
846 if (seq != NULL) { 848 if (seq != NULL) {
847 spin_lock_bh(&seq->lock); 849 spin_lock_bh(&seq->lock);
848 list_del_init(&s->nameseq_list); 850 list_del_init(&s->nameseq_list);
diff --git a/net/tipc/server.c b/net/tipc/server.c
index b8268c0882a7..7933fb92d852 100644
--- a/net/tipc/server.c
+++ b/net/tipc/server.c
@@ -84,9 +84,9 @@ struct tipc_conn {
84 84
85/* An entry waiting to be sent */ 85/* An entry waiting to be sent */
86struct outqueue_entry { 86struct outqueue_entry {
87 u32 evt; 87 bool inactive;
88 struct tipc_event evt;
88 struct list_head list; 89 struct list_head list;
89 struct kvec iov;
90}; 90};
91 91
92static void tipc_recv_work(struct work_struct *work); 92static void tipc_recv_work(struct work_struct *work);
@@ -154,6 +154,9 @@ static struct tipc_conn *tipc_conn_lookup(struct tipc_server *s, int conid)
154 return con; 154 return con;
155} 155}
156 156
157/* sock_data_ready - interrupt callback indicating the socket has data to read
158 * The queued job is launched in tipc_recv_from_sock()
159 */
157static void sock_data_ready(struct sock *sk) 160static void sock_data_ready(struct sock *sk)
158{ 161{
159 struct tipc_conn *con; 162 struct tipc_conn *con;
@@ -168,6 +171,10 @@ static void sock_data_ready(struct sock *sk)
168 read_unlock_bh(&sk->sk_callback_lock); 171 read_unlock_bh(&sk->sk_callback_lock);
169} 172}
170 173
174/* sock_write_space - interrupt callback after a sendmsg EAGAIN
175 * Indicates that there now is more is space in the send buffer
176 * The queued job is launched in tipc_send_to_sock()
177 */
171static void sock_write_space(struct sock *sk) 178static void sock_write_space(struct sock *sk)
172{ 179{
173 struct tipc_conn *con; 180 struct tipc_conn *con;
@@ -273,10 +280,10 @@ static struct tipc_conn *tipc_alloc_conn(struct tipc_server *s)
273 return con; 280 return con;
274} 281}
275 282
276int tipc_con_rcv_sub(struct net *net, int conid, struct tipc_conn *con, 283static int tipc_con_rcv_sub(struct tipc_server *srv,
277 void *buf, size_t len) 284 struct tipc_conn *con,
285 struct tipc_subscr *s)
278{ 286{
279 struct tipc_subscr *s = (struct tipc_subscr *)buf;
280 struct tipc_subscription *sub; 287 struct tipc_subscription *sub;
281 bool status; 288 bool status;
282 int swap; 289 int swap;
@@ -292,7 +299,7 @@ int tipc_con_rcv_sub(struct net *net, int conid, struct tipc_conn *con,
292 return 0; 299 return 0;
293 } 300 }
294 status = !(s->filter & htohl(TIPC_SUB_NO_STATUS, swap)); 301 status = !(s->filter & htohl(TIPC_SUB_NO_STATUS, swap));
295 sub = tipc_subscrp_subscribe(net, s, conid, swap, status); 302 sub = tipc_subscrp_subscribe(srv, s, con->conid, swap, status);
296 if (!sub) 303 if (!sub)
297 return -1; 304 return -1;
298 305
@@ -304,43 +311,27 @@ int tipc_con_rcv_sub(struct net *net, int conid, struct tipc_conn *con,
304 311
305static int tipc_receive_from_sock(struct tipc_conn *con) 312static int tipc_receive_from_sock(struct tipc_conn *con)
306{ 313{
307 struct tipc_server *s = con->server; 314 struct tipc_server *srv = con->server;
308 struct sock *sk = con->sock->sk; 315 struct sock *sk = con->sock->sk;
309 struct msghdr msg = {}; 316 struct msghdr msg = {};
317 struct tipc_subscr s;
310 struct kvec iov; 318 struct kvec iov;
311 void *buf;
312 int ret; 319 int ret;
313 320
314 buf = kmem_cache_alloc(s->rcvbuf_cache, GFP_ATOMIC); 321 iov.iov_base = &s;
315 if (!buf) { 322 iov.iov_len = sizeof(s);
316 ret = -ENOMEM;
317 goto out_close;
318 }
319
320 iov.iov_base = buf;
321 iov.iov_len = s->max_rcvbuf_size;
322 msg.msg_name = NULL; 323 msg.msg_name = NULL;
323 iov_iter_kvec(&msg.msg_iter, READ | ITER_KVEC, &iov, 1, iov.iov_len); 324 iov_iter_kvec(&msg.msg_iter, READ | ITER_KVEC, &iov, 1, iov.iov_len);
324 ret = sock_recvmsg(con->sock, &msg, MSG_DONTWAIT); 325 ret = sock_recvmsg(con->sock, &msg, MSG_DONTWAIT);
325 if (ret <= 0) { 326 if (ret == -EWOULDBLOCK)
326 kmem_cache_free(s->rcvbuf_cache, buf); 327 return -EWOULDBLOCK;
327 goto out_close; 328 if (ret > 0) {
329 read_lock_bh(&sk->sk_callback_lock);
330 ret = tipc_con_rcv_sub(srv, con, &s);
331 read_unlock_bh(&sk->sk_callback_lock);
328 } 332 }
329
330 read_lock_bh(&sk->sk_callback_lock);
331 ret = tipc_con_rcv_sub(s->net, con->conid, con, buf, ret);
332 read_unlock_bh(&sk->sk_callback_lock);
333 kmem_cache_free(s->rcvbuf_cache, buf);
334 if (ret < 0) 333 if (ret < 0)
335 tipc_conn_terminate(s, con->conid);
336 return ret;
337
338out_close:
339 if (ret != -EWOULDBLOCK)
340 tipc_close_conn(con); 334 tipc_close_conn(con);
341 else if (ret == 0)
342 /* Don't return success if we really got EOF */
343 ret = -EAGAIN;
344 335
345 return ret; 336 return ret;
346} 337}
@@ -442,33 +433,6 @@ static int tipc_open_listening_sock(struct tipc_server *s)
442 return 0; 433 return 0;
443} 434}
444 435
445static struct outqueue_entry *tipc_alloc_entry(void *data, int len)
446{
447 struct outqueue_entry *entry;
448 void *buf;
449
450 entry = kmalloc(sizeof(struct outqueue_entry), GFP_ATOMIC);
451 if (!entry)
452 return NULL;
453
454 buf = kmemdup(data, len, GFP_ATOMIC);
455 if (!buf) {
456 kfree(entry);
457 return NULL;
458 }
459
460 entry->iov.iov_base = buf;
461 entry->iov.iov_len = len;
462
463 return entry;
464}
465
466static void tipc_free_entry(struct outqueue_entry *e)
467{
468 kfree(e->iov.iov_base);
469 kfree(e);
470}
471
472static void tipc_clean_outqueues(struct tipc_conn *con) 436static void tipc_clean_outqueues(struct tipc_conn *con)
473{ 437{
474 struct outqueue_entry *e, *safe; 438 struct outqueue_entry *e, *safe;
@@ -476,50 +440,40 @@ static void tipc_clean_outqueues(struct tipc_conn *con)
476 spin_lock_bh(&con->outqueue_lock); 440 spin_lock_bh(&con->outqueue_lock);
477 list_for_each_entry_safe(e, safe, &con->outqueue, list) { 441 list_for_each_entry_safe(e, safe, &con->outqueue, list) {
478 list_del(&e->list); 442 list_del(&e->list);
479 tipc_free_entry(e); 443 kfree(e);
480 } 444 }
481 spin_unlock_bh(&con->outqueue_lock); 445 spin_unlock_bh(&con->outqueue_lock);
482} 446}
483 447
484int tipc_conn_sendmsg(struct tipc_server *s, int conid, 448/* tipc_conn_queue_evt - interrupt level call from a subscription instance
485 u32 evt, void *data, size_t len) 449 * The queued job is launched in tipc_send_to_sock()
450 */
451void tipc_conn_queue_evt(struct tipc_server *s, int conid,
452 u32 event, struct tipc_event *evt)
486{ 453{
487 struct outqueue_entry *e; 454 struct outqueue_entry *e;
488 struct tipc_conn *con; 455 struct tipc_conn *con;
489 456
490 con = tipc_conn_lookup(s, conid); 457 con = tipc_conn_lookup(s, conid);
491 if (!con) 458 if (!con)
492 return -EINVAL; 459 return;
493 460
494 if (!connected(con)) { 461 if (!connected(con))
495 conn_put(con); 462 goto err;
496 return 0;
497 }
498 463
499 e = tipc_alloc_entry(data, len); 464 e = kmalloc(sizeof(*e), GFP_ATOMIC);
500 if (!e) { 465 if (!e)
501 conn_put(con); 466 goto err;
502 return -ENOMEM; 467 e->inactive = (event == TIPC_SUBSCR_TIMEOUT);
503 } 468 memcpy(&e->evt, evt, sizeof(*evt));
504 e->evt = evt;
505 spin_lock_bh(&con->outqueue_lock); 469 spin_lock_bh(&con->outqueue_lock);
506 list_add_tail(&e->list, &con->outqueue); 470 list_add_tail(&e->list, &con->outqueue);
507 spin_unlock_bh(&con->outqueue_lock); 471 spin_unlock_bh(&con->outqueue_lock);
508 472
509 if (!queue_work(s->send_wq, &con->swork)) 473 if (queue_work(s->send_wq, &con->swork))
510 conn_put(con); 474 return;
511 return 0; 475err:
512} 476 conn_put(con);
513
514void tipc_conn_terminate(struct tipc_server *s, int conid)
515{
516 struct tipc_conn *con;
517
518 con = tipc_conn_lookup(s, conid);
519 if (con) {
520 tipc_close_conn(con);
521 conn_put(con);
522 }
523} 477}
524 478
525bool tipc_topsrv_kern_subscr(struct net *net, u32 port, u32 type, u32 lower, 479bool tipc_topsrv_kern_subscr(struct net *net, u32 port, u32 type, u32 lower,
@@ -542,7 +496,7 @@ bool tipc_topsrv_kern_subscr(struct net *net, u32 port, u32 type, u32 lower,
542 496
543 *conid = con->conid; 497 *conid = con->conid;
544 con->sock = NULL; 498 con->sock = NULL;
545 rc = tipc_con_rcv_sub(net, *conid, con, &sub, sizeof(sub)); 499 rc = tipc_con_rcv_sub(tipc_topsrv(net), con, &sub);
546 if (rc < 0) 500 if (rc < 0)
547 tipc_close_conn(con); 501 tipc_close_conn(con);
548 return !rc; 502 return !rc;
@@ -587,6 +541,7 @@ static void tipc_send_to_sock(struct tipc_conn *con)
587 struct outqueue_entry *e; 541 struct outqueue_entry *e;
588 struct tipc_event *evt; 542 struct tipc_event *evt;
589 struct msghdr msg; 543 struct msghdr msg;
544 struct kvec iov;
590 int count = 0; 545 int count = 0;
591 int ret; 546 int ret;
592 547
@@ -594,27 +549,28 @@ static void tipc_send_to_sock(struct tipc_conn *con)
594 549
595 while (!list_empty(queue)) { 550 while (!list_empty(queue)) {
596 e = list_first_entry(queue, struct outqueue_entry, list); 551 e = list_first_entry(queue, struct outqueue_entry, list);
597 552 evt = &e->evt;
598 spin_unlock_bh(&con->outqueue_lock); 553 spin_unlock_bh(&con->outqueue_lock);
599 554
600 if (e->evt == TIPC_SUBSCR_TIMEOUT) { 555 if (e->inactive)
601 evt = (struct tipc_event *)e->iov.iov_base;
602 tipc_con_delete_sub(con, &evt->s); 556 tipc_con_delete_sub(con, &evt->s);
603 } 557
604 memset(&msg, 0, sizeof(msg)); 558 memset(&msg, 0, sizeof(msg));
605 msg.msg_flags = MSG_DONTWAIT; 559 msg.msg_flags = MSG_DONTWAIT;
560 iov.iov_base = evt;
561 iov.iov_len = sizeof(*evt);
562 msg.msg_name = NULL;
606 563
607 if (con->sock) { 564 if (con->sock) {
608 ret = kernel_sendmsg(con->sock, &msg, &e->iov, 1, 565 ret = kernel_sendmsg(con->sock, &msg, &iov,
609 e->iov.iov_len); 566 1, sizeof(*evt));
610 if (ret == -EWOULDBLOCK || ret == 0) { 567 if (ret == -EWOULDBLOCK || ret == 0) {
611 cond_resched(); 568 cond_resched();
612 goto out; 569 goto out;
613 } else if (ret < 0) { 570 } else if (ret < 0) {
614 goto send_err; 571 goto err;
615 } 572 }
616 } else { 573 } else {
617 evt = e->iov.iov_base;
618 tipc_send_kern_top_evt(srv->net, evt); 574 tipc_send_kern_top_evt(srv->net, evt);
619 } 575 }
620 576
@@ -625,13 +581,12 @@ static void tipc_send_to_sock(struct tipc_conn *con)
625 } 581 }
626 spin_lock_bh(&con->outqueue_lock); 582 spin_lock_bh(&con->outqueue_lock);
627 list_del(&e->list); 583 list_del(&e->list);
628 tipc_free_entry(e); 584 kfree(e);
629 } 585 }
630 spin_unlock_bh(&con->outqueue_lock); 586 spin_unlock_bh(&con->outqueue_lock);
631out: 587out:
632 return; 588 return;
633 589err:
634send_err:
635 tipc_close_conn(con); 590 tipc_close_conn(con);
636} 591}
637 592
@@ -695,22 +650,14 @@ int tipc_server_start(struct tipc_server *s)
695 idr_init(&s->conn_idr); 650 idr_init(&s->conn_idr);
696 s->idr_in_use = 0; 651 s->idr_in_use = 0;
697 652
698 s->rcvbuf_cache = kmem_cache_create(s->name, s->max_rcvbuf_size,
699 0, SLAB_HWCACHE_ALIGN, NULL);
700 if (!s->rcvbuf_cache)
701 return -ENOMEM;
702
703 ret = tipc_work_start(s); 653 ret = tipc_work_start(s);
704 if (ret < 0) { 654 if (ret < 0)
705 kmem_cache_destroy(s->rcvbuf_cache);
706 return ret; 655 return ret;
707 } 656
708 ret = tipc_open_listening_sock(s); 657 ret = tipc_open_listening_sock(s);
709 if (ret < 0) { 658 if (ret < 0)
710 tipc_work_stop(s); 659 tipc_work_stop(s);
711 kmem_cache_destroy(s->rcvbuf_cache); 660
712 return ret;
713 }
714 return ret; 661 return ret;
715} 662}
716 663
@@ -731,6 +678,5 @@ void tipc_server_stop(struct tipc_server *s)
731 spin_unlock_bh(&s->idr_lock); 678 spin_unlock_bh(&s->idr_lock);
732 679
733 tipc_work_stop(s); 680 tipc_work_stop(s);
734 kmem_cache_destroy(s->rcvbuf_cache);
735 idr_destroy(&s->conn_idr); 681 idr_destroy(&s->conn_idr);
736} 682}
diff --git a/net/tipc/server.h b/net/tipc/server.h
index fcc72321362d..2de8709b467d 100644
--- a/net/tipc/server.h
+++ b/net/tipc/server.h
@@ -36,6 +36,7 @@
36#ifndef _TIPC_SERVER_H 36#ifndef _TIPC_SERVER_H
37#define _TIPC_SERVER_H 37#define _TIPC_SERVER_H
38 38
39#include "core.h"
39#include <linux/idr.h> 40#include <linux/idr.h>
40#include <linux/tipc.h> 41#include <linux/tipc.h>
41#include <net/net_namespace.h> 42#include <net/net_namespace.h>
@@ -68,7 +69,6 @@ struct tipc_server {
68 spinlock_t idr_lock; 69 spinlock_t idr_lock;
69 int idr_in_use; 70 int idr_in_use;
70 struct net *net; 71 struct net *net;
71 struct kmem_cache *rcvbuf_cache;
72 struct workqueue_struct *rcv_wq; 72 struct workqueue_struct *rcv_wq;
73 struct workqueue_struct *send_wq; 73 struct workqueue_struct *send_wq;
74 int max_rcvbuf_size; 74 int max_rcvbuf_size;
@@ -76,19 +76,13 @@ struct tipc_server {
76 char name[TIPC_SERVER_NAME_LEN]; 76 char name[TIPC_SERVER_NAME_LEN];
77}; 77};
78 78
79int tipc_conn_sendmsg(struct tipc_server *s, int conid, 79void tipc_conn_queue_evt(struct tipc_server *s, int conid,
80 u32 evt, void *data, size_t len); 80 u32 event, struct tipc_event *evt);
81 81
82bool tipc_topsrv_kern_subscr(struct net *net, u32 port, u32 type, u32 lower, 82bool tipc_topsrv_kern_subscr(struct net *net, u32 port, u32 type, u32 lower,
83 u32 upper, u32 filter, int *conid); 83 u32 upper, u32 filter, int *conid);
84void tipc_topsrv_kern_unsubscr(struct net *net, int conid); 84void tipc_topsrv_kern_unsubscr(struct net *net, int conid);
85 85
86/**
87 * tipc_conn_terminate - terminate connection with server
88 *
89 * Note: Must call it in process context since it might sleep
90 */
91void tipc_conn_terminate(struct tipc_server *s, int conid);
92int tipc_server_start(struct tipc_server *s); 86int tipc_server_start(struct tipc_server *s);
93 87
94void tipc_server_stop(struct tipc_server *s); 88void tipc_server_stop(struct tipc_server *s);
diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
index c6de1452db69..c3e0b924e8c2 100644
--- a/net/tipc/subscr.c
+++ b/net/tipc/subscr.c
@@ -52,22 +52,19 @@ static u32 htohl(u32 in, int swap)
52 52
53static void tipc_subscrp_send_event(struct tipc_subscription *sub, 53static void tipc_subscrp_send_event(struct tipc_subscription *sub,
54 u32 found_lower, u32 found_upper, 54 u32 found_lower, u32 found_upper,
55 u32 event, u32 port_ref, u32 node) 55 u32 event, u32 port, u32 node)
56{ 56{
57 struct tipc_net *tn = net_generic(sub->net, tipc_net_id); 57 struct tipc_event *evt = &sub->evt;
58 struct kvec msg_sect; 58 bool swap = sub->swap;
59 59
60 if (sub->inactive) 60 if (sub->inactive)
61 return; 61 return;
62 msg_sect.iov_base = (void *)&sub->evt; 62 evt->event = htohl(event, swap);
63 msg_sect.iov_len = sizeof(struct tipc_event); 63 evt->found_lower = htohl(found_lower, swap);
64 sub->evt.event = htohl(event, sub->swap); 64 evt->found_upper = htohl(found_upper, swap);
65 sub->evt.found_lower = htohl(found_lower, sub->swap); 65 evt->port.ref = htohl(port, swap);
66 sub->evt.found_upper = htohl(found_upper, sub->swap); 66 evt->port.node = htohl(node, swap);
67 sub->evt.port.ref = htohl(port_ref, sub->swap); 67 tipc_conn_queue_evt(sub->server, sub->conid, event, evt);
68 sub->evt.port.node = htohl(node, sub->swap);
69 tipc_conn_sendmsg(tn->topsrv, sub->conid, event,
70 msg_sect.iov_base, msg_sect.iov_len);
71} 68}
72 69
73/** 70/**
@@ -137,10 +134,11 @@ static void tipc_subscrp_timeout(struct timer_list *t)
137 134
138static void tipc_subscrp_kref_release(struct kref *kref) 135static void tipc_subscrp_kref_release(struct kref *kref)
139{ 136{
140 struct tipc_subscription *sub = container_of(kref, 137 struct tipc_subscription *sub;
141 struct tipc_subscription, 138 struct tipc_net *tn;
142 kref); 139
143 struct tipc_net *tn = net_generic(sub->net, tipc_net_id); 140 sub = container_of(kref, struct tipc_subscription, kref);
141 tn = tipc_net(sub->server->net);
144 142
145 atomic_dec(&tn->subscription_count); 143 atomic_dec(&tn->subscription_count);
146 kfree(sub); 144 kfree(sub);
@@ -156,11 +154,11 @@ void tipc_subscrp_get(struct tipc_subscription *subscription)
156 kref_get(&subscription->kref); 154 kref_get(&subscription->kref);
157} 155}
158 156
159static struct tipc_subscription *tipc_subscrp_create(struct net *net, 157static struct tipc_subscription *tipc_subscrp_create(struct tipc_server *srv,
160 struct tipc_subscr *s, 158 struct tipc_subscr *s,
161 int conid, bool swap) 159 int conid, bool swap)
162{ 160{
163 struct tipc_net *tn = net_generic(net, tipc_net_id); 161 struct tipc_net *tn = tipc_net(srv->net);
164 struct tipc_subscription *sub; 162 struct tipc_subscription *sub;
165 u32 filter = htohl(s->filter, swap); 163 u32 filter = htohl(s->filter, swap);
166 164
@@ -179,7 +177,7 @@ static struct tipc_subscription *tipc_subscrp_create(struct net *net,
179 } 177 }
180 178
181 /* Initialize subscription object */ 179 /* Initialize subscription object */
182 sub->net = net; 180 sub->server = srv;
183 sub->conid = conid; 181 sub->conid = conid;
184 sub->inactive = false; 182 sub->inactive = false;
185 if (((filter & TIPC_SUB_PORTS) && (filter & TIPC_SUB_SERVICE)) || 183 if (((filter & TIPC_SUB_PORTS) && (filter & TIPC_SUB_SERVICE)) ||
@@ -197,7 +195,7 @@ static struct tipc_subscription *tipc_subscrp_create(struct net *net,
197 return sub; 195 return sub;
198} 196}
199 197
200struct tipc_subscription *tipc_subscrp_subscribe(struct net *net, 198struct tipc_subscription *tipc_subscrp_subscribe(struct tipc_server *srv,
201 struct tipc_subscr *s, 199 struct tipc_subscr *s,
202 int conid, bool swap, 200 int conid, bool swap,
203 bool status) 201 bool status)
@@ -205,7 +203,7 @@ struct tipc_subscription *tipc_subscrp_subscribe(struct net *net,
205 struct tipc_subscription *sub = NULL; 203 struct tipc_subscription *sub = NULL;
206 u32 timeout; 204 u32 timeout;
207 205
208 sub = tipc_subscrp_create(net, s, conid, swap); 206 sub = tipc_subscrp_create(srv, s, conid, swap);
209 if (!sub) 207 if (!sub)
210 return NULL; 208 return NULL;
211 209
diff --git a/net/tipc/subscr.h b/net/tipc/subscr.h
index cfd0cb3a1da8..64ffd32d15e6 100644
--- a/net/tipc/subscr.h
+++ b/net/tipc/subscr.h
@@ -49,7 +49,6 @@ struct tipc_conn;
49 * struct tipc_subscription - TIPC network topology subscription object 49 * struct tipc_subscription - TIPC network topology subscription object
50 * @subscriber: pointer to its subscriber 50 * @subscriber: pointer to its subscriber
51 * @seq: name sequence associated with subscription 51 * @seq: name sequence associated with subscription
52 * @net: point to network namespace
53 * @timer: timer governing subscription duration (optional) 52 * @timer: timer governing subscription duration (optional)
54 * @nameseq_list: adjacent subscriptions in name sequence's subscription list 53 * @nameseq_list: adjacent subscriptions in name sequence's subscription list
55 * @subscrp_list: adjacent subscriptions in subscriber's subscription list 54 * @subscrp_list: adjacent subscriptions in subscriber's subscription list
@@ -58,7 +57,7 @@ struct tipc_conn;
58 */ 57 */
59struct tipc_subscription { 58struct tipc_subscription {
60 struct kref kref; 59 struct kref kref;
61 struct net *net; 60 struct tipc_server *server;
62 struct timer_list timer; 61 struct timer_list timer;
63 struct list_head nameseq_list; 62 struct list_head nameseq_list;
64 struct list_head subscrp_list; 63 struct list_head subscrp_list;
@@ -69,7 +68,7 @@ struct tipc_subscription {
69 spinlock_t lock; /* serialize up/down and timer events */ 68 spinlock_t lock; /* serialize up/down and timer events */
70}; 69};
71 70
72struct tipc_subscription *tipc_subscrp_subscribe(struct net *net, 71struct tipc_subscription *tipc_subscrp_subscribe(struct tipc_server *srv,
73 struct tipc_subscr *s, 72 struct tipc_subscr *s,
74 int conid, bool swap, 73 int conid, bool swap,
75 bool status); 74 bool status);