Lines Matching refs:c

278 static inline void tipc_crypto_key_set_state(struct tipc_crypto *c,
282 static int tipc_crypto_key_attach(struct tipc_crypto *c,
300 static char *tipc_crypto_key_dump(struct tipc_crypto *c, char *buf);
1099 static inline void tipc_crypto_key_set_state(struct tipc_crypto *c, in tipc_crypto_key_set_state() argument
1104 struct tipc_key old = c->key; in tipc_crypto_key_set_state()
1107 c->key.keys = ((new_passive & KEY_MASK) << (KEY_BITS * 2)) | in tipc_crypto_key_set_state()
1111 pr_debug("%s: key changing %s ::%pS\n", c->name, in tipc_crypto_key_set_state()
1112 tipc_key_change_dump(old, c->key, buf), in tipc_crypto_key_set_state()
1128 int tipc_crypto_key_init(struct tipc_crypto *c, struct tipc_aead_key *ukey, in tipc_crypto_key_init() argument
1139 rc = tipc_crypto_key_attach(c, aead, 0, master_key); in tipc_crypto_key_init()
1156 static int tipc_crypto_key_attach(struct tipc_crypto *c, in tipc_crypto_key_attach() argument
1164 spin_lock_bh(&c->lock); in tipc_crypto_key_attach()
1165 key = c->key; in tipc_crypto_key_attach()
1173 if (tipc_aead_users(c->aead[key.pending]) > 0) in tipc_crypto_key_attach()
1195 aead->crypto = c; in tipc_crypto_key_attach()
1196 aead->gen = (is_tx(c)) ? ++c->key_gen : c->key_gen; in tipc_crypto_key_attach()
1197 tipc_aead_rcu_replace(c->aead[new_key], aead, &c->lock); in tipc_crypto_key_attach()
1198 if (likely(c->key.keys != key.keys)) in tipc_crypto_key_attach()
1199 tipc_crypto_key_set_state(c, key.passive, key.active, in tipc_crypto_key_attach()
1201 c->working = 1; in tipc_crypto_key_attach()
1202 c->nokey = 0; in tipc_crypto_key_attach()
1203 c->key_master |= master_key; in tipc_crypto_key_attach()
1207 spin_unlock_bh(&c->lock); in tipc_crypto_key_attach()
1211 void tipc_crypto_key_flush(struct tipc_crypto *c) in tipc_crypto_key_flush() argument
1216 spin_lock_bh(&c->lock); in tipc_crypto_key_flush()
1217 if (is_rx(c)) { in tipc_crypto_key_flush()
1219 rx = c; in tipc_crypto_key_flush()
1236 c->flags = 0; in tipc_crypto_key_flush()
1237 tipc_crypto_key_set_state(c, 0, 0, 0); in tipc_crypto_key_flush()
1239 tipc_crypto_key_detach(c->aead[k], &c->lock); in tipc_crypto_key_flush()
1240 atomic64_set(&c->sndnxt, 0); in tipc_crypto_key_flush()
1241 spin_unlock_bh(&c->lock); in tipc_crypto_key_flush()
1469 struct tipc_crypto *c; in tipc_crypto_start() local
1475 c = kzalloc(sizeof(*c), GFP_ATOMIC); in tipc_crypto_start()
1476 if (!c) in tipc_crypto_start()
1481 c->wq = alloc_ordered_workqueue("tipc_crypto", 0); in tipc_crypto_start()
1482 if (!c->wq) { in tipc_crypto_start()
1483 kfree(c); in tipc_crypto_start()
1489 c->stats = alloc_percpu_gfp(struct tipc_crypto_stats, GFP_ATOMIC); in tipc_crypto_start()
1490 if (!c->stats) { in tipc_crypto_start()
1491 if (c->wq) in tipc_crypto_start()
1492 destroy_workqueue(c->wq); in tipc_crypto_start()
1493 kfree_sensitive(c); in tipc_crypto_start()
1497 c->flags = 0; in tipc_crypto_start()
1498 c->net = net; in tipc_crypto_start()
1499 c->node = node; in tipc_crypto_start()
1500 get_random_bytes(&c->key_gen, 2); in tipc_crypto_start()
1501 tipc_crypto_key_set_state(c, 0, 0, 0); in tipc_crypto_start()
1502 atomic_set(&c->key_distr, 0); in tipc_crypto_start()
1503 atomic_set(&c->peer_rx_active, 0); in tipc_crypto_start()
1504 atomic64_set(&c->sndnxt, 0); in tipc_crypto_start()
1505 c->timer1 = jiffies; in tipc_crypto_start()
1506 c->timer2 = jiffies; in tipc_crypto_start()
1507 c->rekeying_intv = TIPC_REKEYING_INTV_DEF; in tipc_crypto_start()
1508 spin_lock_init(&c->lock); in tipc_crypto_start()
1509 scnprintf(c->name, 48, "%s(%s)", (is_rx(c)) ? "RX" : "TX", in tipc_crypto_start()
1510 (is_rx(c)) ? tipc_node_get_id_str(c->node) : in tipc_crypto_start()
1511 tipc_own_id_string(c->net)); in tipc_crypto_start()
1513 if (is_rx(c)) in tipc_crypto_start()
1514 INIT_DELAYED_WORK(&c->work, tipc_crypto_work_rx); in tipc_crypto_start()
1516 INIT_DELAYED_WORK(&c->work, tipc_crypto_work_tx); in tipc_crypto_start()
1518 *crypto = c; in tipc_crypto_start()
1524 struct tipc_crypto *c = *crypto; in tipc_crypto_stop() local
1527 if (!c) in tipc_crypto_stop()
1531 if (is_tx(c)) { in tipc_crypto_stop()
1532 c->rekeying_intv = 0; in tipc_crypto_stop()
1533 cancel_delayed_work_sync(&c->work); in tipc_crypto_stop()
1534 destroy_workqueue(c->wq); in tipc_crypto_stop()
1540 tipc_aead_put(rcu_dereference(c->aead[k])); in tipc_crypto_stop()
1542 pr_debug("%s: has been stopped\n", c->name); in tipc_crypto_stop()
1545 free_percpu(c->stats); in tipc_crypto_stop()
1548 kfree_sensitive(c); in tipc_crypto_stop()
2080 static char *tipc_crypto_key_dump(struct tipc_crypto *c, char *buf) in tipc_crypto_key_dump() argument
2082 struct tipc_key key = c->key; in tipc_crypto_key_dump()
2089 if (is_rx(c)) in tipc_crypto_key_dump()
2092 c->timer2 + TIPC_TX_GRACE_PERIOD)) in tipc_crypto_key_dump()
2109 aead = rcu_dereference(c->aead[k]); in tipc_crypto_key_dump()
2121 if (is_rx(c)) in tipc_crypto_key_dump()
2123 atomic_read(&c->peer_rx_active)); in tipc_crypto_key_dump()