Lines Matching full:rx

76 	STAT_BADMSGS = STAT_BADKEYS, /* rx only */
109 passive:2, /* rx only */
113 passive:2, /* rx only */
139 * @users: the number of the key users (TX/RX)
178 * struct tipc_crypto - TIPC TX/RX crypto structure
180 * @node: TIPC node (RX)
182 * @peer_rx_active: replicated peer RX active key index
183 * @key_gen: TX/RX key generation
188 * @work: delayed work sched for TX/RX
245 /* struct tipc_crypto_rx_ctx - RX context for callbacks */
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);
896 pr_err("RX: skb_cow_data() returned %d\n", nsg); in tipc_aead_decrypt()
911 pr_err("RX: skb_to_sgvec() returned %d, nsg %d\n", rc, nsg); in tipc_aead_decrypt()
1026 * @__rx: RX crypto handle if dest is "known"
1204 struct tipc_crypto *tx, *rx; in tipc_crypto_key_flush() local
1210 rx = c; in tipc_crypto_key_flush()
1211 tx = tipc_net(rx->net)->crypto_tx; in tipc_crypto_key_flush()
1212 if (cancel_delayed_work(&rx->work)) { in tipc_crypto_key_flush()
1213 kfree(rx->skey); in tipc_crypto_key_flush()
1214 rx->skey = NULL; in tipc_crypto_key_flush()
1215 atomic_xchg(&rx->key_distr, 0); in tipc_crypto_key_flush()
1216 tipc_node_put(rx->node); in tipc_crypto_key_flush()
1218 /* RX stopping => decrease TX key users if any */ in tipc_crypto_key_flush()
1219 k = atomic_xchg(&rx->peer_rx_active, 0); in tipc_crypto_key_flush()
1236 * tipc_crypto_key_try_align - Align RX keys if possible
1237 * @rx: RX crypto handle
1248 static bool tipc_crypto_key_try_align(struct tipc_crypto *rx, u8 new_pending) in tipc_crypto_key_try_align() argument
1256 spin_lock(&rx->lock); in tipc_crypto_key_try_align()
1257 key = rx->key; in tipc_crypto_key_try_align()
1266 if (tipc_aead_users(rx->aead[key.pending]) > 0) in tipc_crypto_key_try_align()
1270 tmp1 = tipc_aead_rcu_ptr(rx->aead[key.pending], &rx->lock); in tipc_crypto_key_try_align()
1273 rcu_assign_pointer(rx->aead[key.pending], NULL); in tipc_crypto_key_try_align()
1277 tmp2 = rcu_replace_pointer(rx->aead[key.passive], tmp2, lockdep_is_held(&rx->lock)); in tipc_crypto_key_try_align()
1283 tipc_crypto_key_set_state(rx, new_passive, 0, new_pending); in tipc_crypto_key_try_align()
1284 rcu_assign_pointer(rx->aead[new_pending], tmp1); in tipc_crypto_key_try_align()
1286 rcu_assign_pointer(rx->aead[new_passive], tmp2); in tipc_crypto_key_try_align()
1289 pr_info_ratelimited("%s: key[%d] -> key[%d]\n", rx->name, key.pending, in tipc_crypto_key_try_align()
1293 spin_unlock(&rx->lock); in tipc_crypto_key_try_align()
1300 * @rx: RX crypto handle (can be NULL)
1311 struct tipc_crypto *rx, in tipc_crypto_key_pick_tx() argument
1326 skb_cb->tx_clone_ctx.rx = rx; in tipc_crypto_key_pick_tx()
1368 * @rx: RX crypto handle
1371 * This function updates the peer node related data as the peer RX active key
1381 static void tipc_crypto_key_synch(struct tipc_crypto *rx, struct sk_buff *skb) in tipc_crypto_key_synch() argument
1384 struct tipc_crypto *tx = tipc_net(rx->net)->crypto_tx; in tipc_crypto_key_synch()
1386 u32 self = tipc_own_addr(rx->net); in tipc_crypto_key_synch()
1390 /* Update RX 'key_master' flag according to peer, also mark "legacy" if in tipc_crypto_key_synch()
1393 rx->key_master = ehdr->master_key; in tipc_crypto_key_synch()
1394 if (!rx->key_master) in tipc_crypto_key_synch()
1407 !atomic_cmpxchg(&rx->key_distr, 0, KEY_DISTR_SCHED)) { in tipc_crypto_key_synch()
1411 if (queue_delayed_work(tx->wq, &rx->work, delay)) in tipc_crypto_key_synch()
1412 tipc_node_get(rx->node); in tipc_crypto_key_synch()
1416 atomic_xchg(&rx->key_distr, 0); in tipc_crypto_key_synch()
1419 /* Case 2: Peer RX active key has changed, let's update own TX users */ in tipc_crypto_key_synch()
1420 cur = atomic_read(&rx->peer_rx_active); in tipc_crypto_key_synch()
1424 atomic_cmpxchg(&rx->peer_rx_active, cur, new) == cur) { in tipc_crypto_key_synch()
1430 atomic64_set(&rx->sndnxt, 0); in tipc_crypto_key_synch()
1435 tx->name, cur, new, rx->name); in tipc_crypto_key_synch()
1500 scnprintf(c->name, 48, "%s(%s)", (is_rx(c)) ? "RX" : "TX", in tipc_crypto_start()
1542 void tipc_crypto_timeout(struct tipc_crypto *rx) in tipc_crypto_timeout() argument
1544 struct tipc_net *tn = tipc_net(rx->net); in tipc_crypto_timeout()
1568 /* RX pending: having user -> active */ in tipc_crypto_timeout()
1569 spin_lock(&rx->lock); in tipc_crypto_timeout()
1570 key = rx->key; in tipc_crypto_timeout()
1571 if (!key.pending || tipc_aead_users(rx->aead[key.pending]) <= 0) in tipc_crypto_timeout()
1577 rx->timer2 = jiffies; in tipc_crypto_timeout()
1578 tipc_crypto_key_set_state(rx, key.passive, key.active, 0); in tipc_crypto_timeout()
1579 this_cpu_inc(rx->stats->stat[STAT_SWITCHES]); in tipc_crypto_timeout()
1580 pr_info("%s: key[%d] is activated\n", rx->name, key.pending); in tipc_crypto_timeout()
1584 /* RX pending: not working -> remove */ in tipc_crypto_timeout()
1585 if (!key.pending || tipc_aead_users(rx->aead[key.pending]) > -10) in tipc_crypto_timeout()
1588 tipc_crypto_key_set_state(rx, key.passive, key.active, 0); in tipc_crypto_timeout()
1589 tipc_crypto_key_detach(rx->aead[key.pending], &rx->lock); in tipc_crypto_timeout()
1590 pr_debug("%s: key[%d] is removed\n", rx->name, key.pending); in tipc_crypto_timeout()
1594 /* RX active: timed out or no user -> pending */ in tipc_crypto_timeout()
1597 if (time_before(jiffies, rx->timer1 + TIPC_RX_ACTIVE_LIM) && in tipc_crypto_timeout()
1598 tipc_aead_users(rx->aead[key.active]) > 0) in tipc_crypto_timeout()
1605 rx->timer2 = jiffies; in tipc_crypto_timeout()
1606 tipc_crypto_key_set_state(rx, key.passive, 0, key.pending); in tipc_crypto_timeout()
1607 tipc_aead_users_set(rx->aead[key.pending], 0); in tipc_crypto_timeout()
1608 pr_debug("%s: key[%d] is deactivated\n", rx->name, key.active); in tipc_crypto_timeout()
1612 /* RX passive: outdated or not working -> free */ in tipc_crypto_timeout()
1615 if (time_before(jiffies, rx->timer2 + TIPC_RX_PASSIVE_LIM) && in tipc_crypto_timeout()
1616 tipc_aead_users(rx->aead[key.passive]) > -10) in tipc_crypto_timeout()
1619 tipc_crypto_key_set_state(rx, 0, key.active, key.pending); in tipc_crypto_timeout()
1620 tipc_crypto_key_detach(rx->aead[key.passive], &rx->lock); in tipc_crypto_timeout()
1621 pr_debug("%s: key[%d] is freed\n", rx->name, key.passive); in tipc_crypto_timeout()
1624 spin_unlock(&rx->lock); in tipc_crypto_timeout()
1638 tipc_crypto_do_cmd(rx->net, cmd); in tipc_crypto_timeout()
1786 * @rx: RX crypto handle
1794 * Note: RX key(s) can be re-aligned, or in case of no key suitable, TX
1805 int tipc_crypto_rcv(struct net *net, struct tipc_crypto *rx, in tipc_crypto_rcv() argument
1820 if (unlikely(!rx || tx_key == KEY_MASTER)) in tipc_crypto_rcv()
1823 /* Pick RX key according to TX key if any */ in tipc_crypto_rcv()
1824 key = rx->key; in tipc_crypto_rcv()
1829 /* Unknown key, let's try to align RX key(s) */ in tipc_crypto_rcv()
1830 if (tipc_crypto_key_try_align(rx, tx_key)) in tipc_crypto_rcv()
1835 aead = tipc_crypto_key_pick_tx(tx, rx, *skb, tx_key); in tipc_crypto_rcv()
1843 aead = tipc_aead_get(rx->aead[tx_key]); in tipc_crypto_rcv()
1848 stats = ((rx) ?: tx)->stats; in tipc_crypto_rcv()
1863 if (rx) { in tipc_crypto_rcv()
1864 /* Mark rx->nokey only if we dont have a in tipc_crypto_rcv()
1869 rx->nokey = !(rx->skey || in tipc_crypto_rcv()
1870 rcu_access_pointer(rx->aead[n])); in tipc_crypto_rcv()
1872 rx->name, rx->nokey, in tipc_crypto_rcv()
1873 tx_key, rx->key.keys); in tipc_crypto_rcv()
1874 tipc_node_put(rx->node); in tipc_crypto_rcv()
1893 struct tipc_crypto *rx = aead->crypto; in tipc_crypto_rcv_complete() local
1900 rx = skb_cb->tx_clone_ctx.rx; in tipc_crypto_rcv_complete()
1901 pr_debug("TX->RX(%s): err %d, aead %p, skb->next %p, flags %x\n", in tipc_crypto_rcv_complete()
1902 (rx) ? tipc_node_get_id_str(rx->node) : "-", err, aead, in tipc_crypto_rcv_complete()
1919 if (!rx) { in tipc_crypto_rcv_complete()
1923 rx = tipc_node_crypto_rx(n); in tipc_crypto_rcv_complete()
1924 if (unlikely(!rx)) in tipc_crypto_rcv_complete()
1934 if (tipc_crypto_key_attach(rx, tmp, ehdr->tx_key, false) < 0) { in tipc_crypto_rcv_complete()
1947 /* Set the RX key's user */ in tipc_crypto_rcv_complete()
1950 /* Mark this point, RX works */ in tipc_crypto_rcv_complete()
1951 rx->timer1 = jiffies; in tipc_crypto_rcv_complete()
1957 /* Mark this point, RX passive still works */ in tipc_crypto_rcv_complete()
1958 if (rx->key.passive && ehdr->tx_key == rx->key.passive) in tipc_crypto_rcv_complete()
1959 rx->timer2 = jiffies; in tipc_crypto_rcv_complete()
1973 tipc_crypto_key_synch(rx, *skb); in tipc_crypto_rcv_complete()
1994 if (rx) in tipc_crypto_rcv_complete()
1995 tipc_node_put(rx->node); in tipc_crypto_rcv_complete()
2001 struct tipc_crypto *tx = tn->crypto_tx, *rx; in tipc_crypto_do_cmd() local
2026 rx = tipc_node_crypto_rx_by_list(p); in tipc_crypto_do_cmd()
2027 pr_info("RX(%7.7s)\n%s", tipc_node_get_id_str(rx->node), in tipc_crypto_do_cmd()
2028 tipc_crypto_key_dump(rx, buf)); in tipc_crypto_do_cmd()
2053 rx = tipc_node_crypto_rx_by_list(p); in tipc_crypto_do_cmd()
2054 j = scnprintf(buf, 200, "RX(%7.7s) ", in tipc_crypto_do_cmd()
2055 tipc_node_get_id_str(rx->node)); in tipc_crypto_do_cmd()
2058 stat = per_cpu_ptr(rx->stats, cpu)->stat[i]; in tipc_crypto_do_cmd()
2113 i += scnprintf(buf + i, 200 - i, "\tPeer RX active: %d\n", in tipc_crypto_key_dump()
2157 struct tipc_crypto *rx; in tipc_crypto_msg_rcv() local
2164 rx = tipc_node_crypto_rx_by_addr(net, msg_prevnode(hdr)); in tipc_crypto_msg_rcv()
2165 if (unlikely(!rx)) in tipc_crypto_msg_rcv()
2170 if (tipc_crypto_key_rcv(rx, hdr)) in tipc_crypto_msg_rcv()
2177 tipc_node_put(rx->node); in tipc_crypto_msg_rcv()
2269 * @rx: the RX crypto
2273 * schedules a RX work to attach the key to the corresponding RX crypto.
2278 static bool tipc_crypto_key_rcv(struct tipc_crypto *rx, struct tipc_msg *hdr) in tipc_crypto_key_rcv() argument
2280 struct tipc_crypto *tx = tipc_net(rx->net)->crypto_tx; in tipc_crypto_key_rcv()
2289 pr_debug("%s: message data size is too small\n", rx->name); in tipc_crypto_key_rcv()
2298 pr_debug("%s: invalid MSG_CRYPTO key size\n", rx->name); in tipc_crypto_key_rcv()
2302 spin_lock(&rx->lock); in tipc_crypto_key_rcv()
2303 if (unlikely(rx->skey || (key_gen == rx->key_gen && rx->key.keys))) { in tipc_crypto_key_rcv()
2304 pr_err("%s: key existed <%p>, gen %d vs %d\n", rx->name, in tipc_crypto_key_rcv()
2305 rx->skey, key_gen, rx->key_gen); in tipc_crypto_key_rcv()
2312 pr_err("%s: unable to allocate memory for skey\n", rx->name); in tipc_crypto_key_rcv()
2322 rx->key_gen = key_gen; in tipc_crypto_key_rcv()
2323 rx->skey_mode = msg_key_mode(hdr); in tipc_crypto_key_rcv()
2324 rx->skey = skey; in tipc_crypto_key_rcv()
2325 rx->nokey = 0; in tipc_crypto_key_rcv()
2329 spin_unlock(&rx->lock); in tipc_crypto_key_rcv()
2333 if (likely(skey && queue_delayed_work(tx->wq, &rx->work, 0))) in tipc_crypto_key_rcv()
2340 * tipc_crypto_work_rx - Scheduled RX works handler
2341 * @work: the struct RX work
2344 * or attaching a received session key on RX crypto.
2349 struct tipc_crypto *rx = container_of(dwork, struct tipc_crypto, work); in tipc_crypto_work_rx() local
2350 struct tipc_crypto *tx = tipc_net(rx->net)->crypto_tx; in tipc_crypto_work_rx()
2357 if (atomic_cmpxchg(&rx->key_distr, in tipc_crypto_work_rx()
2362 rc = tipc_crypto_key_distr(tx, key, rx->node); in tipc_crypto_work_rx()
2365 tx->name, key, tipc_node_get_id_str(rx->node), in tipc_crypto_work_rx()
2371 atomic_cmpxchg(&rx->key_distr, KEY_DISTR_COMPL, 0); in tipc_crypto_work_rx()
2375 if (rx->skey) { in tipc_crypto_work_rx()
2376 rc = tipc_crypto_key_init(rx, rx->skey, rx->skey_mode, false); in tipc_crypto_work_rx()
2379 rx->name, rc); in tipc_crypto_work_rx()
2388 kfree(rx->skey); in tipc_crypto_work_rx()
2389 rx->skey = NULL; in tipc_crypto_work_rx()
2394 if (resched && queue_delayed_work(tx->wq, &rx->work, delay)) in tipc_crypto_work_rx()
2397 tipc_node_put(rx->node); in tipc_crypto_work_rx()