Lines Matching refs:rx

285 static bool tipc_crypto_key_try_align(struct tipc_crypto *rx, u8 new_pending);
287 struct tipc_crypto *rx,
290 static void tipc_crypto_key_synch(struct tipc_crypto *rx, struct sk_buff *skb);
305 static bool tipc_crypto_key_rcv(struct tipc_crypto *rx, struct tipc_msg *hdr);
1211 struct tipc_crypto *tx, *rx; in tipc_crypto_key_flush() local
1217 rx = c; in tipc_crypto_key_flush()
1218 tx = tipc_net(rx->net)->crypto_tx; in tipc_crypto_key_flush()
1219 if (cancel_delayed_work(&rx->work)) { in tipc_crypto_key_flush()
1220 kfree(rx->skey); in tipc_crypto_key_flush()
1221 rx->skey = NULL; in tipc_crypto_key_flush()
1222 atomic_xchg(&rx->key_distr, 0); in tipc_crypto_key_flush()
1223 tipc_node_put(rx->node); in tipc_crypto_key_flush()
1226 k = atomic_xchg(&rx->peer_rx_active, 0); in tipc_crypto_key_flush()
1255 static bool tipc_crypto_key_try_align(struct tipc_crypto *rx, u8 new_pending) in tipc_crypto_key_try_align() argument
1263 spin_lock(&rx->lock); in tipc_crypto_key_try_align()
1264 key = rx->key; in tipc_crypto_key_try_align()
1273 if (tipc_aead_users(rx->aead[key.pending]) > 0) in tipc_crypto_key_try_align()
1277 tmp1 = tipc_aead_rcu_ptr(rx->aead[key.pending], &rx->lock); in tipc_crypto_key_try_align()
1280 rcu_assign_pointer(rx->aead[key.pending], NULL); in tipc_crypto_key_try_align()
1284 tmp2 = rcu_replace_pointer(rx->aead[key.passive], tmp2, lockdep_is_held(&rx->lock)); in tipc_crypto_key_try_align()
1290 tipc_crypto_key_set_state(rx, new_passive, 0, new_pending); in tipc_crypto_key_try_align()
1291 rcu_assign_pointer(rx->aead[new_pending], tmp1); in tipc_crypto_key_try_align()
1293 rcu_assign_pointer(rx->aead[new_passive], tmp2); in tipc_crypto_key_try_align()
1296 pr_info_ratelimited("%s: key[%d] -> key[%d]\n", rx->name, key.pending, in tipc_crypto_key_try_align()
1300 spin_unlock(&rx->lock); in tipc_crypto_key_try_align()
1318 struct tipc_crypto *rx, in tipc_crypto_key_pick_tx() argument
1333 skb_cb->tx_clone_ctx.rx = rx; in tipc_crypto_key_pick_tx()
1388 static void tipc_crypto_key_synch(struct tipc_crypto *rx, struct sk_buff *skb) in tipc_crypto_key_synch() argument
1391 struct tipc_crypto *tx = tipc_net(rx->net)->crypto_tx; in tipc_crypto_key_synch()
1393 u32 self = tipc_own_addr(rx->net); in tipc_crypto_key_synch()
1400 rx->key_master = ehdr->master_key; in tipc_crypto_key_synch()
1401 if (!rx->key_master) in tipc_crypto_key_synch()
1414 !atomic_cmpxchg(&rx->key_distr, 0, KEY_DISTR_SCHED)) { in tipc_crypto_key_synch()
1418 if (queue_delayed_work(tx->wq, &rx->work, delay)) in tipc_crypto_key_synch()
1419 tipc_node_get(rx->node); in tipc_crypto_key_synch()
1423 atomic_xchg(&rx->key_distr, 0); in tipc_crypto_key_synch()
1427 cur = atomic_read(&rx->peer_rx_active); in tipc_crypto_key_synch()
1431 atomic_cmpxchg(&rx->peer_rx_active, cur, new) == cur) { in tipc_crypto_key_synch()
1437 atomic64_set(&rx->sndnxt, 0); in tipc_crypto_key_synch()
1442 tx->name, cur, new, rx->name); in tipc_crypto_key_synch()
1549 void tipc_crypto_timeout(struct tipc_crypto *rx) in tipc_crypto_timeout() argument
1551 struct tipc_net *tn = tipc_net(rx->net); in tipc_crypto_timeout()
1576 spin_lock(&rx->lock); in tipc_crypto_timeout()
1577 key = rx->key; in tipc_crypto_timeout()
1578 if (!key.pending || tipc_aead_users(rx->aead[key.pending]) <= 0) in tipc_crypto_timeout()
1584 rx->timer2 = jiffies; in tipc_crypto_timeout()
1585 tipc_crypto_key_set_state(rx, key.passive, key.active, 0); in tipc_crypto_timeout()
1586 this_cpu_inc(rx->stats->stat[STAT_SWITCHES]); in tipc_crypto_timeout()
1587 pr_info("%s: key[%d] is activated\n", rx->name, key.pending); in tipc_crypto_timeout()
1592 if (!key.pending || tipc_aead_users(rx->aead[key.pending]) > -10) in tipc_crypto_timeout()
1595 tipc_crypto_key_set_state(rx, key.passive, key.active, 0); in tipc_crypto_timeout()
1596 tipc_crypto_key_detach(rx->aead[key.pending], &rx->lock); in tipc_crypto_timeout()
1597 pr_debug("%s: key[%d] is removed\n", rx->name, key.pending); in tipc_crypto_timeout()
1604 if (time_before(jiffies, rx->timer1 + TIPC_RX_ACTIVE_LIM) && in tipc_crypto_timeout()
1605 tipc_aead_users(rx->aead[key.active]) > 0) in tipc_crypto_timeout()
1612 rx->timer2 = jiffies; in tipc_crypto_timeout()
1613 tipc_crypto_key_set_state(rx, key.passive, 0, key.pending); in tipc_crypto_timeout()
1614 tipc_aead_users_set(rx->aead[key.pending], 0); in tipc_crypto_timeout()
1615 pr_debug("%s: key[%d] is deactivated\n", rx->name, key.active); in tipc_crypto_timeout()
1622 if (time_before(jiffies, rx->timer2 + TIPC_RX_PASSIVE_LIM) && in tipc_crypto_timeout()
1623 tipc_aead_users(rx->aead[key.passive]) > -10) in tipc_crypto_timeout()
1626 tipc_crypto_key_set_state(rx, 0, key.active, key.pending); in tipc_crypto_timeout()
1627 tipc_crypto_key_detach(rx->aead[key.passive], &rx->lock); in tipc_crypto_timeout()
1628 pr_debug("%s: key[%d] is freed\n", rx->name, key.passive); in tipc_crypto_timeout()
1631 spin_unlock(&rx->lock); in tipc_crypto_timeout()
1645 tipc_crypto_do_cmd(rx->net, cmd); in tipc_crypto_timeout()
1812 int tipc_crypto_rcv(struct net *net, struct tipc_crypto *rx, in tipc_crypto_rcv() argument
1827 if (unlikely(!rx || tx_key == KEY_MASTER)) in tipc_crypto_rcv()
1831 key = rx->key; in tipc_crypto_rcv()
1837 if (tipc_crypto_key_try_align(rx, tx_key)) in tipc_crypto_rcv()
1842 aead = tipc_crypto_key_pick_tx(tx, rx, *skb, tx_key); in tipc_crypto_rcv()
1850 aead = tipc_aead_get(rx->aead[tx_key]); in tipc_crypto_rcv()
1855 stats = ((rx) ?: tx)->stats; in tipc_crypto_rcv()
1870 if (rx) { in tipc_crypto_rcv()
1876 rx->nokey = !(rx->skey || in tipc_crypto_rcv()
1877 rcu_access_pointer(rx->aead[n])); in tipc_crypto_rcv()
1879 rx->name, rx->nokey, in tipc_crypto_rcv()
1880 tx_key, rx->key.keys); in tipc_crypto_rcv()
1881 tipc_node_put(rx->node); in tipc_crypto_rcv()
1900 struct tipc_crypto *rx = aead->crypto; in tipc_crypto_rcv_complete() local
1907 rx = skb_cb->tx_clone_ctx.rx; in tipc_crypto_rcv_complete()
1909 (rx) ? tipc_node_get_id_str(rx->node) : "-", err, aead, in tipc_crypto_rcv_complete()
1926 if (!rx) { in tipc_crypto_rcv_complete()
1930 rx = tipc_node_crypto_rx(n); in tipc_crypto_rcv_complete()
1931 if (unlikely(!rx)) in tipc_crypto_rcv_complete()
1941 if (tipc_crypto_key_attach(rx, tmp, ehdr->tx_key, false) < 0) { in tipc_crypto_rcv_complete()
1958 rx->timer1 = jiffies; in tipc_crypto_rcv_complete()
1965 if (rx->key.passive && ehdr->tx_key == rx->key.passive) in tipc_crypto_rcv_complete()
1966 rx->timer2 = jiffies; in tipc_crypto_rcv_complete()
1979 tipc_crypto_key_synch(rx, *skb); in tipc_crypto_rcv_complete()
1997 if (rx) in tipc_crypto_rcv_complete()
1998 tipc_node_put(rx->node); in tipc_crypto_rcv_complete()
2004 struct tipc_crypto *tx = tn->crypto_tx, *rx; in tipc_crypto_do_cmd() local
2029 rx = tipc_node_crypto_rx_by_list(p); in tipc_crypto_do_cmd()
2030 pr_info("RX(%7.7s)\n%s", tipc_node_get_id_str(rx->node), in tipc_crypto_do_cmd()
2031 tipc_crypto_key_dump(rx, buf)); in tipc_crypto_do_cmd()
2056 rx = tipc_node_crypto_rx_by_list(p); in tipc_crypto_do_cmd()
2058 tipc_node_get_id_str(rx->node)); in tipc_crypto_do_cmd()
2061 stat = per_cpu_ptr(rx->stats, cpu)->stat[i]; in tipc_crypto_do_cmd()
2160 struct tipc_crypto *rx; in tipc_crypto_msg_rcv() local
2167 rx = tipc_node_crypto_rx_by_addr(net, msg_prevnode(hdr)); in tipc_crypto_msg_rcv()
2168 if (unlikely(!rx)) in tipc_crypto_msg_rcv()
2173 if (tipc_crypto_key_rcv(rx, hdr)) in tipc_crypto_msg_rcv()
2180 tipc_node_put(rx->node); in tipc_crypto_msg_rcv()
2281 static bool tipc_crypto_key_rcv(struct tipc_crypto *rx, struct tipc_msg *hdr) in tipc_crypto_key_rcv() argument
2283 struct tipc_crypto *tx = tipc_net(rx->net)->crypto_tx; in tipc_crypto_key_rcv()
2292 pr_debug("%s: message data size is too small\n", rx->name); in tipc_crypto_key_rcv()
2301 pr_debug("%s: invalid MSG_CRYPTO key size\n", rx->name); in tipc_crypto_key_rcv()
2305 spin_lock(&rx->lock); in tipc_crypto_key_rcv()
2306 if (unlikely(rx->skey || (key_gen == rx->key_gen && rx->key.keys))) { in tipc_crypto_key_rcv()
2307 pr_err("%s: key existed <%p>, gen %d vs %d\n", rx->name, in tipc_crypto_key_rcv()
2308 rx->skey, key_gen, rx->key_gen); in tipc_crypto_key_rcv()
2315 pr_err("%s: unable to allocate memory for skey\n", rx->name); in tipc_crypto_key_rcv()
2325 rx->key_gen = key_gen; in tipc_crypto_key_rcv()
2326 rx->skey_mode = msg_key_mode(hdr); in tipc_crypto_key_rcv()
2327 rx->skey = skey; in tipc_crypto_key_rcv()
2328 rx->nokey = 0; in tipc_crypto_key_rcv()
2332 spin_unlock(&rx->lock); in tipc_crypto_key_rcv()
2336 if (likely(skey && queue_delayed_work(tx->wq, &rx->work, 0))) in tipc_crypto_key_rcv()
2352 struct tipc_crypto *rx = container_of(dwork, struct tipc_crypto, work); in tipc_crypto_work_rx() local
2353 struct tipc_crypto *tx = tipc_net(rx->net)->crypto_tx; in tipc_crypto_work_rx()
2360 if (atomic_cmpxchg(&rx->key_distr, in tipc_crypto_work_rx()
2365 rc = tipc_crypto_key_distr(tx, key, rx->node); in tipc_crypto_work_rx()
2368 tx->name, key, tipc_node_get_id_str(rx->node), in tipc_crypto_work_rx()
2374 atomic_cmpxchg(&rx->key_distr, KEY_DISTR_COMPL, 0); in tipc_crypto_work_rx()
2378 if (rx->skey) { in tipc_crypto_work_rx()
2379 rc = tipc_crypto_key_init(rx, rx->skey, rx->skey_mode, false); in tipc_crypto_work_rx()
2382 rx->name, rc); in tipc_crypto_work_rx()
2391 kfree(rx->skey); in tipc_crypto_work_rx()
2392 rx->skey = NULL; in tipc_crypto_work_rx()
2397 if (resched && queue_delayed_work(tx->wq, &rx->work, delay)) in tipc_crypto_work_rx()
2400 tipc_node_put(rx->node); in tipc_crypto_work_rx()