net/tipc/bcast.c
Source file repositories/reference/linux-study-clean/net/tipc/bcast.c
File Facts
- System
- Linux kernel
- Corpus path
net/tipc/bcast.c- Extension
.c- Size
- 22565 bytes
- Lines
- 865
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: implementation source
- Status
- source implementation candidate
Why This File Exists
Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/tipc_config.hsocket.hmsg.hbcast.hlink.hname_table.h
Detected Declarations
struct tipc_bc_basefunction tipc_bcast_get_mtufunction tipc_bcast_toggle_rcastfunction tipc_bcbase_calc_bc_thresholdfunction tipc_bcbase_select_primaryfunction tipc_bcast_inc_bearer_dst_cntfunction tipc_bcast_dec_bearer_dst_cntfunction retransmissionfunction skb_queue_walkfunction tipc_bcast_select_xmit_methodfunction tipc_bcast_xmitfunction tipc_rcast_xmitfunction list_for_each_entry_safefunction tipc_mcast_send_syncfunction tipc_mcast_xmitfunction tipc_bcast_rcvfunction tipc_bcast_ack_rcvfunction tipc_bcast_sync_rcvfunction tipc_bcast_add_peerfunction tipc_bcast_remove_peerfunction tipc_bclink_reset_statsfunction tipc_bc_link_set_queue_limitsfunction tipc_bc_link_set_broadcast_modefunction tipc_bc_link_set_broadcast_ratiofunction tipc_nl_bc_link_setfunction tipc_bcast_initfunction tipc_bcast_stopfunction tipc_nlist_initfunction tipc_nlist_addfunction tipc_nlist_delfunction tipc_nlist_purgefunction tipc_bcast_get_modefunction tipc_bcast_get_broadcast_ratiofunction tipc_mcast_filter_msg
Annotated Snippet
struct tipc_bc_base {
struct tipc_link *link;
struct sk_buff_head inputq;
int dests[MAX_BEARERS];
int primary_bearer;
bool bcast_support;
bool force_bcast;
bool rcast_support;
bool force_rcast;
int rc_ratio;
int bc_threshold;
};
static struct tipc_bc_base *tipc_bc_base(struct net *net)
{
return tipc_net(net)->bcbase;
}
/* tipc_bcast_get_mtu(): -get the MTU currently used by broadcast link
* Note: the MTU is decremented to give room for a tunnel header, in
* case the message needs to be sent as replicast
*/
int tipc_bcast_get_mtu(struct net *net)
{
return tipc_link_mss(tipc_bc_sndlink(net));
}
void tipc_bcast_toggle_rcast(struct net *net, bool supp)
{
tipc_bc_base(net)->rcast_support = supp;
}
static void tipc_bcbase_calc_bc_threshold(struct net *net)
{
struct tipc_bc_base *bb = tipc_bc_base(net);
int cluster_size = tipc_link_bc_peers(tipc_bc_sndlink(net));
bb->bc_threshold = 1 + (cluster_size * bb->rc_ratio / 100);
}
/* tipc_bcbase_select_primary(): find a bearer with links to all destinations,
* if any, and make it primary bearer
*/
static void tipc_bcbase_select_primary(struct net *net)
{
struct tipc_bc_base *bb = tipc_bc_base(net);
int all_dests = tipc_link_bc_peers(bb->link);
int max_win = tipc_link_max_win(bb->link);
int min_win = tipc_link_min_win(bb->link);
int i, mtu, prim;
bb->primary_bearer = INVALID_BEARER_ID;
bb->bcast_support = true;
if (!all_dests)
return;
for (i = 0; i < MAX_BEARERS; i++) {
if (!bb->dests[i])
continue;
mtu = tipc_bearer_mtu(net, i);
if (mtu < tipc_link_mtu(bb->link)) {
tipc_link_set_mtu(bb->link, mtu);
tipc_link_set_queue_limits(bb->link,
min_win,
max_win);
}
bb->bcast_support &= tipc_bearer_bcast_support(net, i);
if (bb->dests[i] < all_dests)
continue;
bb->primary_bearer = i;
/* Reduce risk that all nodes select same primary */
if ((i ^ tipc_own_addr(net)) & 1)
break;
}
prim = bb->primary_bearer;
if (prim != INVALID_BEARER_ID)
bb->bcast_support = tipc_bearer_bcast_support(net, prim);
}
void tipc_bcast_inc_bearer_dst_cnt(struct net *net, int bearer_id)
{
struct tipc_bc_base *bb = tipc_bc_base(net);
tipc_bcast_lock(net);
bb->dests[bearer_id]++;
tipc_bcbase_select_primary(net);
Annotation
- Immediate include surface: `linux/tipc_config.h`, `socket.h`, `msg.h`, `bcast.h`, `link.h`, `name_table.h`.
- Detected declarations: `struct tipc_bc_base`, `function tipc_bcast_get_mtu`, `function tipc_bcast_toggle_rcast`, `function tipc_bcbase_calc_bc_threshold`, `function tipc_bcbase_select_primary`, `function tipc_bcast_inc_bearer_dst_cnt`, `function tipc_bcast_dec_bearer_dst_cnt`, `function retransmission`, `function skb_queue_walk`, `function tipc_bcast_select_xmit_method`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.