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);
1215 struct tipc_crypto *tx, *rx; in tipc_crypto_key_flush() local
1221 rx = c; in tipc_crypto_key_flush()
1222 tx = tipc_net(rx->net)->crypto_tx; in tipc_crypto_key_flush()
1223 if (cancel_delayed_work(&rx->work)) { in tipc_crypto_key_flush()
1224 kfree(rx->skey); in tipc_crypto_key_flush()
1225 rx->skey = NULL; in tipc_crypto_key_flush()
1226 atomic_xchg(&rx->key_distr, 0); in tipc_crypto_key_flush()
1227 tipc_node_put(rx->node); in tipc_crypto_key_flush()
1230 k = atomic_xchg(&rx->peer_rx_active, 0); in tipc_crypto_key_flush()
1259 static bool tipc_crypto_key_try_align(struct tipc_crypto *rx, u8 new_pending) in tipc_crypto_key_try_align() argument
1267 spin_lock(&rx->lock); in tipc_crypto_key_try_align()
1268 key = rx->key; in tipc_crypto_key_try_align()
1277 if (tipc_aead_users(rx->aead[key.pending]) > 0) in tipc_crypto_key_try_align()
1281 tmp1 = tipc_aead_rcu_ptr(rx->aead[key.pending], &rx->lock); in tipc_crypto_key_try_align()
1284 rcu_assign_pointer(rx->aead[key.pending], NULL); in tipc_crypto_key_try_align()
1288 tmp2 = rcu_replace_pointer(rx->aead[key.passive], tmp2, lockdep_is_held(&rx->lock)); in tipc_crypto_key_try_align()
1294 tipc_crypto_key_set_state(rx, new_passive, 0, new_pending); in tipc_crypto_key_try_align()
1295 rcu_assign_pointer(rx->aead[new_pending], tmp1); in tipc_crypto_key_try_align()
1297 rcu_assign_pointer(rx->aead[new_passive], tmp2); in tipc_crypto_key_try_align()
1300 pr_info_ratelimited("%s: key[%d] -> key[%d]\n", rx->name, key.pending, in tipc_crypto_key_try_align()
1304 spin_unlock(&rx->lock); in tipc_crypto_key_try_align()
1322 struct tipc_crypto *rx, in tipc_crypto_key_pick_tx() argument
1337 skb_cb->tx_clone_ctx.rx = rx; in tipc_crypto_key_pick_tx()
1392 static void tipc_crypto_key_synch(struct tipc_crypto *rx, struct sk_buff *skb) in tipc_crypto_key_synch() argument
1395 struct tipc_crypto *tx = tipc_net(rx->net)->crypto_tx; in tipc_crypto_key_synch()
1397 u32 self = tipc_own_addr(rx->net); in tipc_crypto_key_synch()
1404 rx->key_master = ehdr->master_key; in tipc_crypto_key_synch()
1405 if (!rx->key_master) in tipc_crypto_key_synch()
1418 !atomic_cmpxchg(&rx->key_distr, 0, KEY_DISTR_SCHED)) { in tipc_crypto_key_synch()
1422 if (queue_delayed_work(tx->wq, &rx->work, delay)) in tipc_crypto_key_synch()
1423 tipc_node_get(rx->node); in tipc_crypto_key_synch()
1427 atomic_xchg(&rx->key_distr, 0); in tipc_crypto_key_synch()
1431 cur = atomic_read(&rx->peer_rx_active); in tipc_crypto_key_synch()
1435 atomic_cmpxchg(&rx->peer_rx_active, cur, new) == cur) { in tipc_crypto_key_synch()
1441 atomic64_set(&rx->sndnxt, 0); in tipc_crypto_key_synch()
1446 tx->name, cur, new, rx->name); in tipc_crypto_key_synch()
1553 void tipc_crypto_timeout(struct tipc_crypto *rx) in tipc_crypto_timeout() argument
1555 struct tipc_net *tn = tipc_net(rx->net); in tipc_crypto_timeout()
1580 spin_lock(&rx->lock); in tipc_crypto_timeout()
1581 key = rx->key; in tipc_crypto_timeout()
1582 if (!key.pending || tipc_aead_users(rx->aead[key.pending]) <= 0) in tipc_crypto_timeout()
1588 rx->timer2 = jiffies; in tipc_crypto_timeout()
1589 tipc_crypto_key_set_state(rx, key.passive, key.active, 0); in tipc_crypto_timeout()
1590 this_cpu_inc(rx->stats->stat[STAT_SWITCHES]); in tipc_crypto_timeout()
1591 pr_info("%s: key[%d] is activated\n", rx->name, key.pending); in tipc_crypto_timeout()
1596 if (!key.pending || tipc_aead_users(rx->aead[key.pending]) > -10) in tipc_crypto_timeout()
1599 tipc_crypto_key_set_state(rx, key.passive, key.active, 0); in tipc_crypto_timeout()
1600 tipc_crypto_key_detach(rx->aead[key.pending], &rx->lock); in tipc_crypto_timeout()
1601 pr_debug("%s: key[%d] is removed\n", rx->name, key.pending); in tipc_crypto_timeout()
1608 if (time_before(jiffies, rx->timer1 + TIPC_RX_ACTIVE_LIM) && in tipc_crypto_timeout()
1609 tipc_aead_users(rx->aead[key.active]) > 0) in tipc_crypto_timeout()
1616 rx->timer2 = jiffies; in tipc_crypto_timeout()
1617 tipc_crypto_key_set_state(rx, key.passive, 0, key.pending); in tipc_crypto_timeout()
1618 tipc_aead_users_set(rx->aead[key.pending], 0); in tipc_crypto_timeout()
1619 pr_debug("%s: key[%d] is deactivated\n", rx->name, key.active); in tipc_crypto_timeout()
1626 if (time_before(jiffies, rx->timer2 + TIPC_RX_PASSIVE_LIM) && in tipc_crypto_timeout()
1627 tipc_aead_users(rx->aead[key.passive]) > -10) in tipc_crypto_timeout()
1630 tipc_crypto_key_set_state(rx, 0, key.active, key.pending); in tipc_crypto_timeout()
1631 tipc_crypto_key_detach(rx->aead[key.passive], &rx->lock); in tipc_crypto_timeout()
1632 pr_debug("%s: key[%d] is freed\n", rx->name, key.passive); in tipc_crypto_timeout()
1635 spin_unlock(&rx->lock); in tipc_crypto_timeout()
1649 tipc_crypto_do_cmd(rx->net, cmd); in tipc_crypto_timeout()
1816 int tipc_crypto_rcv(struct net *net, struct tipc_crypto *rx, in tipc_crypto_rcv() argument
1831 if (unlikely(!rx || tx_key == KEY_MASTER)) in tipc_crypto_rcv()
1835 key = rx->key; in tipc_crypto_rcv()
1841 if (tipc_crypto_key_try_align(rx, tx_key)) in tipc_crypto_rcv()
1846 aead = tipc_crypto_key_pick_tx(tx, rx, *skb, tx_key); in tipc_crypto_rcv()
1854 aead = tipc_aead_get(rx->aead[tx_key]); in tipc_crypto_rcv()
1859 stats = ((rx) ?: tx)->stats; in tipc_crypto_rcv()
1874 if (rx) { in tipc_crypto_rcv()
1880 rx->nokey = !(rx->skey || in tipc_crypto_rcv()
1881 rcu_access_pointer(rx->aead[n])); in tipc_crypto_rcv()
1883 rx->name, rx->nokey, in tipc_crypto_rcv()
1884 tx_key, rx->key.keys); in tipc_crypto_rcv()
1885 tipc_node_put(rx->node); in tipc_crypto_rcv()
1904 struct tipc_crypto *rx = aead->crypto; in tipc_crypto_rcv_complete() local
1911 rx = skb_cb->tx_clone_ctx.rx; in tipc_crypto_rcv_complete()
1913 (rx) ? tipc_node_get_id_str(rx->node) : "-", err, aead, in tipc_crypto_rcv_complete()
1930 if (!rx) { in tipc_crypto_rcv_complete()
1934 rx = tipc_node_crypto_rx(n); in tipc_crypto_rcv_complete()
1935 if (unlikely(!rx)) in tipc_crypto_rcv_complete()
1945 if (tipc_crypto_key_attach(rx, tmp, ehdr->tx_key, false) < 0) { in tipc_crypto_rcv_complete()
1962 rx->timer1 = jiffies; in tipc_crypto_rcv_complete()
1969 if (rx->key.passive && ehdr->tx_key == rx->key.passive) in tipc_crypto_rcv_complete()
1970 rx->timer2 = jiffies; in tipc_crypto_rcv_complete()
1983 tipc_crypto_key_synch(rx, *skb); in tipc_crypto_rcv_complete()
2001 if (rx) in tipc_crypto_rcv_complete()
2002 tipc_node_put(rx->node); in tipc_crypto_rcv_complete()
2008 struct tipc_crypto *tx = tn->crypto_tx, *rx; in tipc_crypto_do_cmd() local
2033 rx = tipc_node_crypto_rx_by_list(p); in tipc_crypto_do_cmd()
2034 pr_info("RX(%7.7s)\n%s", tipc_node_get_id_str(rx->node), in tipc_crypto_do_cmd()
2035 tipc_crypto_key_dump(rx, buf)); in tipc_crypto_do_cmd()
2060 rx = tipc_node_crypto_rx_by_list(p); in tipc_crypto_do_cmd()
2062 tipc_node_get_id_str(rx->node)); in tipc_crypto_do_cmd()
2065 stat = per_cpu_ptr(rx->stats, cpu)->stat[i]; in tipc_crypto_do_cmd()
2164 struct tipc_crypto *rx; in tipc_crypto_msg_rcv() local
2171 rx = tipc_node_crypto_rx_by_addr(net, msg_prevnode(hdr)); in tipc_crypto_msg_rcv()
2172 if (unlikely(!rx)) in tipc_crypto_msg_rcv()
2177 if (tipc_crypto_key_rcv(rx, hdr)) in tipc_crypto_msg_rcv()
2184 tipc_node_put(rx->node); in tipc_crypto_msg_rcv()
2285 static bool tipc_crypto_key_rcv(struct tipc_crypto *rx, struct tipc_msg *hdr) in tipc_crypto_key_rcv() argument
2287 struct tipc_crypto *tx = tipc_net(rx->net)->crypto_tx; in tipc_crypto_key_rcv()
2296 pr_debug("%s: message data size is too small\n", rx->name); in tipc_crypto_key_rcv()
2305 pr_debug("%s: invalid MSG_CRYPTO key size\n", rx->name); in tipc_crypto_key_rcv()
2309 spin_lock(&rx->lock); in tipc_crypto_key_rcv()
2310 if (unlikely(rx->skey || (key_gen == rx->key_gen && rx->key.keys))) { in tipc_crypto_key_rcv()
2311 pr_err("%s: key existed <%p>, gen %d vs %d\n", rx->name, in tipc_crypto_key_rcv()
2312 rx->skey, key_gen, rx->key_gen); in tipc_crypto_key_rcv()
2319 pr_err("%s: unable to allocate memory for skey\n", rx->name); in tipc_crypto_key_rcv()
2329 rx->key_gen = key_gen; in tipc_crypto_key_rcv()
2330 rx->skey_mode = msg_key_mode(hdr); in tipc_crypto_key_rcv()
2331 rx->skey = skey; in tipc_crypto_key_rcv()
2332 rx->nokey = 0; in tipc_crypto_key_rcv()
2336 spin_unlock(&rx->lock); in tipc_crypto_key_rcv()
2340 if (likely(skey && queue_delayed_work(tx->wq, &rx->work, 0))) in tipc_crypto_key_rcv()
2356 struct tipc_crypto *rx = container_of(dwork, struct tipc_crypto, work); in tipc_crypto_work_rx() local
2357 struct tipc_crypto *tx = tipc_net(rx->net)->crypto_tx; in tipc_crypto_work_rx()
2364 if (atomic_cmpxchg(&rx->key_distr, in tipc_crypto_work_rx()
2369 rc = tipc_crypto_key_distr(tx, key, rx->node); in tipc_crypto_work_rx()
2372 tx->name, key, tipc_node_get_id_str(rx->node), in tipc_crypto_work_rx()
2378 atomic_cmpxchg(&rx->key_distr, KEY_DISTR_COMPL, 0); in tipc_crypto_work_rx()
2382 if (rx->skey) { in tipc_crypto_work_rx()
2383 rc = tipc_crypto_key_init(rx, rx->skey, rx->skey_mode, false); in tipc_crypto_work_rx()
2386 rx->name, rc); in tipc_crypto_work_rx()
2395 kfree(rx->skey); in tipc_crypto_work_rx()
2396 rx->skey = NULL; in tipc_crypto_work_rx()
2401 if (resched && queue_delayed_work(tx->wq, &rx->work, delay)) in tipc_crypto_work_rx()
2404 tipc_node_put(rx->node); in tipc_crypto_work_rx()