diff options
author | Jon Maloy <jmaloy@redhat.com> | 2021-03-16 22:06:22 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2021-03-17 11:51:05 -0700 |
commit | 429189acac534378cee113b16fe3f18effac1697 (patch) | |
tree | 231fb792a5835641519e209c1195bbaa81774ee8 /net/tipc/subscr.c | |
parent | 09f78b851ea332a67ebaf7b4463a80a4d0d3d747 (diff) | |
download | linux-429189acac534378cee113b16fe3f18effac1697.tar.gz linux-429189acac534378cee113b16fe3f18effac1697.tar.bz2 linux-429189acac534378cee113b16fe3f18effac1697.zip |
tipc: add host-endian copy of user subscription to struct tipc_subscription
We reduce and localize the usage of the tipc_sub_xx() macros by adding a
corresponding member, with fields set in host-endian format, to struct
tipc_subscription.
Signed-off-by: Jon Maloy <jmaloy@redhat.com>
Acked-by: Ying Xue <ying.xue@windriver.com>
Acked-by: Hoang Le <hoang.h.le@dektech.com.au>
Acked-by: Tung Nguyen <tung.q.nguyen@dektech.com.au>
Acked-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc/subscr.c')
-rw-r--r-- | net/tipc/subscr.c | 45 |
1 files changed, 24 insertions, 21 deletions
diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c index 5f8dc0e7488f..8e00d739f03a 100644 --- a/net/tipc/subscr.c +++ b/net/tipc/subscr.c @@ -65,37 +65,32 @@ static void tipc_sub_send_event(struct tipc_subscription *sub, /** * tipc_sub_check_overlap - test for subscription overlap with the given values - * @seq: tipc_name_seq to check - * @found_lower: lower value to test - * @found_upper: upper value to test + * @subscribed: the service range subscribed for + * @found: the service range we are checning for match * * Returns true if there is overlap, otherwise false. */ -bool tipc_sub_check_overlap(struct tipc_service_range *sr, - u32 found_lower, u32 found_upper) +static bool tipc_sub_check_overlap(struct tipc_service_range *subscribed, + struct tipc_service_range *found) { - if (found_lower < sr->lower) - found_lower = sr->lower; - if (found_upper > sr->upper) - found_upper = sr->upper; - if (found_lower > found_upper) - return false; - return true; + u32 found_lower = found->lower; + u32 found_upper = found->upper; + + if (found_lower < subscribed->lower) + found_lower = subscribed->lower; + if (found_upper > subscribed->upper) + found_upper = subscribed->upper; + return found_lower <= found_upper; } void tipc_sub_report_overlap(struct tipc_subscription *sub, struct publication *p, u32 event, bool must) { - struct tipc_subscr *s = &sub->evt.s; - u32 filter = tipc_sub_read(s, filter); - struct tipc_service_range seq; - - seq.type = tipc_sub_read(s, seq.type); - seq.lower = tipc_sub_read(s, seq.lower); - seq.upper = tipc_sub_read(s, seq.upper); + struct tipc_service_range *sr = &sub->s.seq; + u32 filter = sub->s.filter; - if (!tipc_sub_check_overlap(&seq, p->sr.lower, p->sr.upper)) + if (!tipc_sub_check_overlap(sr, &p->sr)) return; if (!must && !(filter & TIPC_SUB_PORTS)) return; @@ -137,12 +132,14 @@ struct tipc_subscription *tipc_sub_subscribe(struct net *net, struct tipc_subscr *s, int conid) { + u32 lower = tipc_sub_read(s, seq.lower); + u32 upper = tipc_sub_read(s, seq.upper); u32 filter = tipc_sub_read(s, filter); struct tipc_subscription *sub; u32 timeout; if ((filter & TIPC_SUB_PORTS && filter & TIPC_SUB_SERVICE) || - (tipc_sub_read(s, seq.lower) > tipc_sub_read(s, seq.upper))) { + lower > upper) { pr_warn("Subscription rejected, illegal request\n"); return NULL; } @@ -157,6 +154,12 @@ struct tipc_subscription *tipc_sub_subscribe(struct net *net, sub->conid = conid; sub->inactive = false; memcpy(&sub->evt.s, s, sizeof(*s)); + sub->s.seq.type = tipc_sub_read(s, seq.type); + sub->s.seq.lower = lower; + sub->s.seq.upper = upper; + sub->s.filter = filter; + sub->s.timeout = tipc_sub_read(s, timeout); + memcpy(sub->s.usr_handle, s->usr_handle, 8); spin_lock_init(&sub->lock); kref_init(&sub->kref); if (!tipc_nametbl_subscribe(sub)) { |