3
3
*
4
4
* Copyright (c) 2000-2017, Ericsson AB
5
5
* Copyright (c) 2005-2007, 2010-2013, Wind River Systems
6
- * Copyright (c) 2020, Red Hat Inc
6
+ * Copyright (c) 2020-2021 , Red Hat Inc
7
7
* All rights reserved.
8
8
*
9
9
* Redistribution and use in source and binary forms, with or without
40
40
#include "subscr.h"
41
41
42
42
static void tipc_sub_send_event (struct tipc_subscription * sub ,
43
- u32 found_lower , u32 found_upper ,
44
- u32 event , u32 port , u32 node )
43
+ struct publication * p ,
44
+ u32 event )
45
45
{
46
+ struct tipc_subscr * s = & sub -> evt .s ;
46
47
struct tipc_event * evt = & sub -> evt ;
47
48
48
49
if (sub -> inactive )
49
50
return ;
50
51
tipc_evt_write (evt , event , event );
51
- tipc_evt_write (evt , found_lower , found_lower );
52
- tipc_evt_write (evt , found_upper , found_upper );
53
- tipc_evt_write (evt , port .ref , port );
54
- tipc_evt_write (evt , port .node , node );
52
+ if (p ) {
53
+ tipc_evt_write (evt , found_lower , p -> sr .lower );
54
+ tipc_evt_write (evt , found_upper , p -> sr .upper );
55
+ tipc_evt_write (evt , port .ref , p -> sk .ref );
56
+ tipc_evt_write (evt , port .node , p -> sk .node );
57
+ } else {
58
+ tipc_evt_write (evt , found_lower , s -> seq .lower );
59
+ tipc_evt_write (evt , found_upper , s -> seq .upper );
60
+ tipc_evt_write (evt , port .ref , 0 );
61
+ tipc_evt_write (evt , port .node , 0 );
62
+ }
55
63
tipc_topsrv_queue_evt (sub -> net , sub -> conid , event , evt );
56
64
}
57
65
@@ -61,24 +69,23 @@ static void tipc_sub_send_event(struct tipc_subscription *sub,
61
69
* @found_lower: lower value to test
62
70
* @found_upper: upper value to test
63
71
*
64
- * Return: 1 if there is overlap, otherwise 0 .
72
+ * Returns true if there is overlap, otherwise false .
65
73
*/
66
- int tipc_sub_check_overlap (struct tipc_service_range * seq , u32 found_lower ,
67
- u32 found_upper )
74
+ bool tipc_sub_check_overlap (struct tipc_service_range * sr ,
75
+ u32 found_lower , u32 found_upper )
68
76
{
69
- if (found_lower < seq -> lower )
70
- found_lower = seq -> lower ;
71
- if (found_upper > seq -> upper )
72
- found_upper = seq -> upper ;
77
+ if (found_lower < sr -> lower )
78
+ found_lower = sr -> lower ;
79
+ if (found_upper > sr -> upper )
80
+ found_upper = sr -> upper ;
73
81
if (found_lower > found_upper )
74
- return 0 ;
75
- return 1 ;
82
+ return false ;
83
+ return true ;
76
84
}
77
85
78
86
void tipc_sub_report_overlap (struct tipc_subscription * sub ,
79
- u32 found_lower , u32 found_upper ,
80
- u32 event , u32 port , u32 node ,
81
- u32 scope , int must )
87
+ struct publication * p ,
88
+ u32 event , bool must )
82
89
{
83
90
struct tipc_subscr * s = & sub -> evt .s ;
84
91
u32 filter = tipc_sub_read (s , filter );
@@ -88,29 +95,25 @@ void tipc_sub_report_overlap(struct tipc_subscription *sub,
88
95
seq .lower = tipc_sub_read (s , seq .lower );
89
96
seq .upper = tipc_sub_read (s , seq .upper );
90
97
91
- if (!tipc_sub_check_overlap (& seq , found_lower , found_upper ))
98
+ if (!tipc_sub_check_overlap (& seq , p -> sr . lower , p -> sr . upper ))
92
99
return ;
93
-
94
100
if (!must && !(filter & TIPC_SUB_PORTS ))
95
101
return ;
96
- if (filter & TIPC_SUB_CLUSTER_SCOPE && scope == TIPC_NODE_SCOPE )
102
+ if (filter & TIPC_SUB_CLUSTER_SCOPE && p -> scope == TIPC_NODE_SCOPE )
97
103
return ;
98
- if (filter & TIPC_SUB_NODE_SCOPE && scope != TIPC_NODE_SCOPE )
104
+ if (filter & TIPC_SUB_NODE_SCOPE && p -> scope != TIPC_NODE_SCOPE )
99
105
return ;
100
106
spin_lock (& sub -> lock );
101
- tipc_sub_send_event (sub , found_lower , found_upper ,
102
- event , port , node );
107
+ tipc_sub_send_event (sub , p , event );
103
108
spin_unlock (& sub -> lock );
104
109
}
105
110
106
111
static void tipc_sub_timeout (struct timer_list * t )
107
112
{
108
113
struct tipc_subscription * sub = from_timer (sub , t , timer );
109
- struct tipc_subscr * s = & sub -> evt .s ;
110
114
111
115
spin_lock (& sub -> lock );
112
- tipc_sub_send_event (sub , s -> seq .lower , s -> seq .upper ,
113
- TIPC_SUBSCR_TIMEOUT , 0 , 0 );
116
+ tipc_sub_send_event (sub , NULL , TIPC_SUBSCR_TIMEOUT );
114
117
sub -> inactive = true;
115
118
spin_unlock (& sub -> lock );
116
119
}
0 commit comments