cregit-Linux how code gets into the kernel

Release 4.17 net/tipc/subscr.c

Directory: net/tipc
/*
 * net/tipc/subscr.c: TIPC network topology service
 *
 * Copyright (c) 2000-2017, Ericsson AB
 * Copyright (c) 2005-2007, 2010-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 "name_table.h"
#include "subscr.h"


static void tipc_sub_send_event(struct tipc_subscription *sub, u32 found_lower, u32 found_upper, u32 event, u32 port, u32 node) { struct tipc_event *evt = &sub->evt; if (sub->inactive) return; tipc_evt_write(evt, event, event); tipc_evt_write(evt, found_lower, found_lower); tipc_evt_write(evt, found_upper, found_upper); tipc_evt_write(evt, port.ref, port); tipc_evt_write(evt, port.node, node); tipc_topsrv_queue_evt(sub->net, sub->conid, event, evt); }

Contributors

PersonTokensPropCommitsCommitProp
Per Liden5349.53%19.09%
Jon Paul Maloy4037.38%654.55%
Ying Xue87.48%218.18%
Neil Horman54.67%19.09%
Paul Gortmaker10.93%19.09%
Total107100.00%11100.00%

/** * tipc_sub_check_overlap - test for subscription overlap with the * given values * * Returns 1 if there is overlap, otherwise 0. */
int tipc_sub_check_overlap(struct tipc_name_seq *seq, u32 found_lower, u32 found_upper) { if (found_lower < seq->lower) found_lower = seq->lower; if (found_upper > seq->upper) found_upper = seq->upper; if (found_lower > found_upper) return 0; return 1; }

Contributors

PersonTokensPropCommitsCommitProp
Per Liden4987.50%133.33%
Parthasarathy Bhuvaragan610.71%133.33%
Jon Paul Maloy11.79%133.33%
Total56100.00%3100.00%


void tipc_sub_report_overlap(struct tipc_subscription *sub, u32 found_lower, u32 found_upper, u32 event, u32 port, u32 node, u32 scope, int must) { struct tipc_subscr *s = &sub->evt.s; u32 filter = tipc_sub_read(s, filter); struct tipc_name_seq 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); if (!tipc_sub_check_overlap(&seq, found_lower, found_upper)) return; if (!must && !(filter & TIPC_SUB_PORTS)) return; if (filter & TIPC_SUB_CLUSTER_SCOPE && scope == TIPC_NODE_SCOPE) return; if (filter & TIPC_SUB_NODE_SCOPE && scope != TIPC_NODE_SCOPE) return; spin_lock(&sub->lock); tipc_sub_send_event(sub, found_lower, found_upper, event, port, node); spin_unlock(&sub->lock); }

Contributors

PersonTokensPropCommitsCommitProp
Jon Paul Maloy10157.39%450.00%
Per Liden6034.09%112.50%
Parthasarathy Bhuvaragan126.82%112.50%
Lijun Chen21.14%112.50%
Paul Gortmaker10.57%112.50%
Total176100.00%8100.00%


static void tipc_sub_timeout(struct timer_list *t) { struct tipc_subscription *sub = from_timer(sub, t, timer); struct tipc_subscr *s = &sub->evt.s; spin_lock(&sub->lock); tipc_sub_send_event(sub, s->seq.lower, s->seq.upper, TIPC_SUBSCR_TIMEOUT, 0, 0); sub->inactive = true; spin_unlock(&sub->lock); }

Contributors

PersonTokensPropCommitsCommitProp
Per Liden2732.93%110.00%
Ying Xue1821.95%440.00%
Jon Paul Maloy1720.73%220.00%
Kees Cook1214.63%110.00%
Lijun Chen78.54%110.00%
Paul Gortmaker11.22%110.00%
Total82100.00%10100.00%


static void tipc_sub_kref_release(struct kref *kref) { kfree(container_of(kref, struct tipc_subscription, kref)); }

Contributors

PersonTokensPropCommitsCommitProp
Parthasarathy Bhuvaragan1458.33%125.00%
Ying Xue729.17%125.00%
Jon Paul Maloy312.50%250.00%
Total24100.00%4100.00%


void tipc_sub_put(struct tipc_subscription *subscription) { kref_put(&subscription->kref, tipc_sub_kref_release); }

Contributors

PersonTokensPropCommitsCommitProp
Parthasarathy Bhuvaragan1680.00%133.33%
Jon Paul Maloy210.00%133.33%
Ying Xue210.00%133.33%
Total20100.00%3100.00%


void tipc_sub_get(struct tipc_subscription *subscription) { kref_get(&subscription->kref); }

Contributors

PersonTokensPropCommitsCommitProp
Parthasarathy Bhuvaragan1161.11%133.33%
Ying Xue633.33%133.33%
Jon Paul Maloy15.56%133.33%
Total18100.00%3100.00%


struct tipc_subscription *tipc_sub_subscribe(struct net *net, struct tipc_subscr *s, int conid) { 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))) { pr_warn("Subscription rejected, illegal request\n"); return NULL; } sub = kmalloc(sizeof(*sub), GFP_ATOMIC); if (!sub) { pr_warn("Subscription rejected, no memory\n"); return NULL; } INIT_LIST_HEAD(&sub->service_list); INIT_LIST_HEAD(&sub->sub_list); sub->net = net; sub->conid = conid; sub->inactive = false; memcpy(&sub->evt.s, s, sizeof(*s)); spin_lock_init(&sub->lock); kref_init(&sub->kref); if (!tipc_nametbl_subscribe(sub)) { kfree(sub); return NULL; } timer_setup(&sub->timer, tipc_sub_timeout, 0); timeout = tipc_sub_read(&sub->evt.s, timeout); if (timeout != TIPC_WAIT_FOREVER) mod_timer(&sub->timer, jiffies + msecs_to_jiffies(timeout)); return sub; }

Contributors

PersonTokensPropCommitsCommitProp
Jon Paul Maloy11647.54%833.33%
Parthasarathy Bhuvaragan5221.31%625.00%
Per Liden3614.75%14.17%
Allan Stephens218.61%28.33%
Ying Xue124.92%416.67%
Neil Horman41.64%14.17%
Kees Cook20.82%14.17%
Erik Hugne10.41%14.17%
Total244100.00%24100.00%


void tipc_sub_unsubscribe(struct tipc_subscription *sub) { tipc_nametbl_unsubscribe(sub); if (sub->evt.s.timeout != TIPC_WAIT_FOREVER) del_timer_sync(&sub->timer); list_del(&sub->sub_list); tipc_sub_put(sub); }

Contributors

PersonTokensPropCommitsCommitProp
Jon Paul Maloy3164.58%450.00%
Parthasarathy Bhuvaragan1122.92%225.00%
Per Liden510.42%112.50%
Ying Xue12.08%112.50%
Total48100.00%8100.00%


Overall Contributors

PersonTokensPropCommitsCommitProp
Jon Paul Maloy31439.95%1230.77%
Per Liden23730.15%12.56%
Parthasarathy Bhuvaragan12215.52%923.08%
Ying Xue546.87%923.08%
Allan Stephens232.93%37.69%
Kees Cook141.78%12.56%
Neil Horman91.15%12.56%
Lijun Chen91.15%12.56%
Paul Gortmaker30.38%12.56%
Erik Hugne10.13%12.56%
Total786100.00%39100.00%
Directory: net/tipc
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.
Created with cregit.