/** *structtipc_bc_base-basestructureforkeepingbroadcastsendstate *@link:broadcastsendlinkstructure *@inputq:datainputqueue;willonlycarrySOCK_WAKEUPmessages *@dests:arraykeepingnumberofreachabledestinationsperbearer *@primary_bearer:abearerhavinglinkstoallbroadcastdestinations,ifany *@bcast_support:indicatesifprimarybearer,ifany,supportsbroadcast *@force_bcast:forcesbroadcastformulticasttraffic *@rcast_support:indicatesifallpeernodessupportreplicast *@force_rcast:forcesreplicastformulticasttraffic *@rc_ratio:destcountaspercentageofclustersizewheresendmethodchanges *@bc_threshold:calculatedfromrc_ratio;ifdests>thresholdusebroadcast
*/ 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;
};
staticstruct 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:theMTUisdecrementedtogiveroomforatunnelheader,in *casethemessageneedstobesentasreplicast
*/ int tipc_bcast_get_mtu(struct net *net)
{ return tipc_link_mss(tipc_bc_sndlink(net));
}
/* tipc_bcbase_select_primary(): find a bearer with links to all destinations, *ifany,andmakeitprimarybearer
*/ staticvoid 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;
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_bcbase_xmit - broadcast a packet queue across one or more bearers * *Notethatnumberofreachabledestinations,asindicatedinthedests[] *array,maytransitionallydifferfromthenumberofdestinationsindicated *ineachsentbuffer.Wecansustainthis.Excessdestinationnodeswill *dropandneveracknowledgetheunexpectedpackets,andmissingdestinations *willeitherrequireretransmission(iftheyarejustabouttobeaddedto *thebearer),orberemovedfromthebuffer's'ackers'counter(ifthey *justwentdown)
*/ staticvoid tipc_bcbase_xmit(struct net *net, struct sk_buff_head *xmitq)
{ int bearer_id; struct tipc_bc_base *bb = tipc_bc_base(net); struct sk_buff *skb, *_skb; struct sk_buff_head _xmitq;
if (skb_queue_empty(xmitq)) return;
/* The typical case: at least one bearer has links to all nodes */
bearer_id = bb->primary_bearer; if (bearer_id >= 0) {
tipc_bearer_bc_xmit(net, bearer_id, xmitq); return;
}
/* We have to transmit across all bearers */
__skb_queue_head_init(&_xmitq); for (bearer_id = 0; bearer_id < MAX_BEARERS; bearer_id++) { if (!bb->dests[bearer_id]) continue;
staticvoid tipc_bcast_select_xmit_method(struct net *net, int dests, struct tipc_mc_method *method)
{ struct tipc_bc_base *bb = tipc_bc_base(net); unsignedlong exp = method->expires;
/* Broadcast supported by used bearer/bearers? */ if (!bb->bcast_support) {
method->rcast = true; return;
} /* Any destinations which don't support replicast ? */ if (!bb->rcast_support) {
method->rcast = false; return;
} /* Can current method be changed ? */
method->expires = jiffies + TIPC_METHOD_EXPIRE; if (method->mandatory) return;
if (!(tipc_net(net)->capabilities & TIPC_MCAST_RBCTL) &&
time_before(jiffies, exp)) return;
/* Configuration as force 'broadcast' method */ if (bb->force_bcast) {
method->rcast = false; return;
} /* Configuration as force 'replicast' method */ if (bb->force_rcast) {
method->rcast = true; return;
} /* Configuration as 'autoselect' or default method */ /* Determine method to use now */
method->rcast = dests <= bb->bc_threshold;
}
/* tipc_bcast_xmit - broadcast the buffer chain to all external nodes *@net:theapplicablenetnamespace *@pkts:chainofbufferscontainingmessage *@cong_link_cnt:setto1ifbroadcastlinkiscongested,otherwise0 *Consumesthebufferchain. *Returns0ifsuccess,otherwiseerrno:-EHOSTUNREACH,-EMSGSIZE
*/ int tipc_bcast_xmit(struct net *net, struct sk_buff_head *pkts,
u16 *cong_link_cnt)
{ struct tipc_link *l = tipc_bc_sndlink(net); struct sk_buff_head xmitq; int rc = 0;
/* Any other return value than -ELINKCONG is ignored */ if (tipc_node_xmit(net, &_pkts, dnode, selector) == -ELINKCONG)
(*cong_link_cnt)++;
} return0;
}
/* tipc_mcast_send_sync - deliver a dummy message with SYN bit *@net:theapplicablenetnamespace *@skb:socketbuffertocopy *@method:sendmethodtobeused *@dests:destinationnodesformessage. *Returns0ifsuccess,otherwiseerrno
*/ staticint tipc_mcast_send_sync(struct net *net, struct sk_buff *skb, struct tipc_mc_method *method, struct tipc_nlist *dests)
{ struct tipc_msg *hdr, *_hdr; struct sk_buff_head tmpq;
u16 cong_link_cnt = 0; struct sk_buff *_skb; int rc = 0;
/* Is a cluster supporting with new capabilities ? */ if (!(tipc_net(net)->capabilities & TIPC_MCAST_RBCTL)) return0;
hdr = buf_msg(skb); if (msg_user(hdr) == MSG_FRAGMENTER)
hdr = msg_inner_hdr(hdr); if (msg_type(hdr) != TIPC_MCAST_MSG) return0;
/* Clone packets before they are consumed by next call */ if (dests->local && !tipc_msg_reassemble(pkts, &localq)) {
rc = -ENOMEM; gotoexit;
} /* Send according to determined transmit method */ if (dests->remote) {
tipc_bcast_select_xmit_method(net, dests->remote, method);
if (dests->local) {
tipc_loopback_trace(net, &localq);
tipc_sk_mcast_rcv(net, &localq, &inputq);
} exit: /* This queue should normally be empty by now */
__skb_queue_purge(pkts); return rc;
}
/* tipc_bcast_rcv - receive a broadcast packet, and deliver to rcv link * *RCUislocked,nootherlocksset
*/ int tipc_bcast_rcv(struct net *net, struct tipc_link *l, struct sk_buff *skb)
{ struct tipc_msg *hdr = buf_msg(skb); struct sk_buff_head *inputq = &tipc_bc_base(net)->inputq; struct sk_buff_head xmitq; int rc;
__skb_queue_head_init(&xmitq);
if (msg_mc_netid(hdr) != tipc_netid(net) || !tipc_link_is_up(l)) {
kfree_skb(skb); return0;
}
if (likely(!msg_is_syn(hdr) && skb_queue_empty(defq))) return;
node = msg_orignode(hdr); if (node == tipc_own_addr(net)) return;
port = msg_origport(hdr);
/* Has the twin SYN message already arrived ? */
skb_queue_walk(defq, _skb) {
_hdr = buf_msg(_skb); if (msg_orignode(_hdr) != node) continue; if (msg_origport(_hdr) != port) continue;
match = true; break;
}
if (!match) { if (!msg_is_syn(hdr)) return;
__skb_dequeue(inputq);
__skb_queue_tail(defq, skb); return;
}
/* Deliver non-SYN message from other link, otherwise queue it */ if (!msg_is_syn(hdr)) { if (msg_is_rcast(hdr) != msg_is_rcast(_hdr)) return;
__skb_dequeue(inputq);
__skb_queue_tail(defq, skb); return;
}
/* Queue non-SYN/SYN message from same link */ if (msg_is_rcast(hdr) == msg_is_rcast(_hdr)) {
__skb_dequeue(inputq);
__skb_queue_tail(defq, skb); return;
}
/* Matching SYN messages => return the one with data, if any */
__skb_unlink(_skb, defq); if (msg_data_sz(hdr)) {
kfree_skb(_skb);
} else {
__skb_dequeue(inputq);
kfree_skb(skb);
__skb_queue_tail(inputq, _skb);
}
/* Deliver subsequent non-SYN messages from same peer */
skb_queue_walk_safe(defq, _skb, tmp) {
_hdr = buf_msg(_skb); if (msg_orignode(_hdr) != node) continue; if (msg_origport(_hdr) != port) continue; if (msg_is_syn(_hdr)) break;
__skb_unlink(_skb, defq);
__skb_queue_tail(inputq, _skb);
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.26 Sekunden
(vorverarbeitet am 2026-09-29)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.