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);
1101 static inline void tipc_crypto_key_set_state(struct tipc_crypto *c, in tipc_crypto_key_set_state() argument
1106 struct tipc_key old = c->key; in tipc_crypto_key_set_state()
1109 c->key.keys = ((new_passive & KEY_MASK) << (KEY_BITS * 2)) | in tipc_crypto_key_set_state()
1113 pr_debug("%s: key changing %s ::%pS\n", c->name, in tipc_crypto_key_set_state()
1114 tipc_key_change_dump(old, c->key, buf), in tipc_crypto_key_set_state()
1130 int tipc_crypto_key_init(struct tipc_crypto *c, struct tipc_aead_key *ukey, in tipc_crypto_key_init() argument
1141 rc = tipc_crypto_key_attach(c, aead, 0, master_key); in tipc_crypto_key_init()
1158 static int tipc_crypto_key_attach(struct tipc_crypto *c, in tipc_crypto_key_attach() argument
1166 spin_lock_bh(&c->lock); in tipc_crypto_key_attach()
1167 key = c->key; in tipc_crypto_key_attach()
1175 if (tipc_aead_users(c->aead[key.pending]) > 0) in tipc_crypto_key_attach()
1197 aead->crypto = c; in tipc_crypto_key_attach()
1198 aead->gen = (is_tx(c)) ? ++c->key_gen : c->key_gen; in tipc_crypto_key_attach()
1199 tipc_aead_rcu_replace(c->aead[new_key], aead, &c->lock); in tipc_crypto_key_attach()
1200 if (likely(c->key.keys != key.keys)) in tipc_crypto_key_attach()
1201 tipc_crypto_key_set_state(c, key.passive, key.active, in tipc_crypto_key_attach()
1203 c->working = 1; in tipc_crypto_key_attach()
1204 c->nokey = 0; in tipc_crypto_key_attach()
1205 c->key_master |= master_key; in tipc_crypto_key_attach()
1209 spin_unlock_bh(&c->lock); in tipc_crypto_key_attach()
1213 void tipc_crypto_key_flush(struct tipc_crypto *c) in tipc_crypto_key_flush() argument
1218 spin_lock_bh(&c->lock); in tipc_crypto_key_flush()
1219 if (is_rx(c)) { in tipc_crypto_key_flush()
1221 rx = c; in tipc_crypto_key_flush()
1238 c->flags = 0; in tipc_crypto_key_flush()
1239 tipc_crypto_key_set_state(c, 0, 0, 0); in tipc_crypto_key_flush()
1241 tipc_crypto_key_detach(c->aead[k], &c->lock); in tipc_crypto_key_flush()
1242 atomic64_set(&c->sndnxt, 0); in tipc_crypto_key_flush()
1243 spin_unlock_bh(&c->lock); in tipc_crypto_key_flush()
1471 struct tipc_crypto *c; in tipc_crypto_start() local
1477 c = kzalloc(sizeof(*c), GFP_ATOMIC); in tipc_crypto_start()
1478 if (!c) in tipc_crypto_start()
1483 c->wq = alloc_ordered_workqueue("tipc_crypto", 0); in tipc_crypto_start()
1484 if (!c->wq) { in tipc_crypto_start()
1485 kfree(c); in tipc_crypto_start()
1491 c->stats = alloc_percpu_gfp(struct tipc_crypto_stats, GFP_ATOMIC); in tipc_crypto_start()
1492 if (!c->stats) { in tipc_crypto_start()
1493 if (c->wq) in tipc_crypto_start()
1494 destroy_workqueue(c->wq); in tipc_crypto_start()
1495 kfree_sensitive(c); in tipc_crypto_start()
1499 c->flags = 0; in tipc_crypto_start()
1500 c->net = net; in tipc_crypto_start()
1501 c->node = node; in tipc_crypto_start()
1502 get_random_bytes(&c->key_gen, 2); in tipc_crypto_start()
1503 tipc_crypto_key_set_state(c, 0, 0, 0); in tipc_crypto_start()
1504 atomic_set(&c->key_distr, 0); in tipc_crypto_start()
1505 atomic_set(&c->peer_rx_active, 0); in tipc_crypto_start()
1506 atomic64_set(&c->sndnxt, 0); in tipc_crypto_start()
1507 c->timer1 = jiffies; in tipc_crypto_start()
1508 c->timer2 = jiffies; in tipc_crypto_start()
1509 c->rekeying_intv = TIPC_REKEYING_INTV_DEF; in tipc_crypto_start()
1510 spin_lock_init(&c->lock); in tipc_crypto_start()
1511 scnprintf(c->name, 48, "%s(%s)", (is_rx(c)) ? "RX" : "TX", in tipc_crypto_start()
1512 (is_rx(c)) ? tipc_node_get_id_str(c->node) : in tipc_crypto_start()
1513 tipc_own_id_string(c->net)); in tipc_crypto_start()
1515 if (is_rx(c)) in tipc_crypto_start()
1516 INIT_DELAYED_WORK(&c->work, tipc_crypto_work_rx); in tipc_crypto_start()
1518 INIT_DELAYED_WORK(&c->work, tipc_crypto_work_tx); in tipc_crypto_start()
1520 *crypto = c; in tipc_crypto_start()
1526 struct tipc_crypto *c = *crypto; in tipc_crypto_stop() local
1529 if (!c) in tipc_crypto_stop()
1533 if (is_tx(c)) { in tipc_crypto_stop()
1534 c->rekeying_intv = 0; in tipc_crypto_stop()
1535 cancel_delayed_work_sync(&c->work); in tipc_crypto_stop()
1536 destroy_workqueue(c->wq); in tipc_crypto_stop()
1542 tipc_aead_put(rcu_dereference(c->aead[k])); in tipc_crypto_stop()
1544 pr_debug("%s: has been stopped\n", c->name); in tipc_crypto_stop()
1547 free_percpu(c->stats); in tipc_crypto_stop()
1550 kfree_sensitive(c); in tipc_crypto_stop()
2082 static char *tipc_crypto_key_dump(struct tipc_crypto *c, char *buf) in tipc_crypto_key_dump() argument
2084 struct tipc_key key = c->key; in tipc_crypto_key_dump()
2091 if (is_rx(c)) in tipc_crypto_key_dump()
2094 c->timer2 + TIPC_TX_GRACE_PERIOD)) in tipc_crypto_key_dump()
2111 aead = rcu_dereference(c->aead[k]); in tipc_crypto_key_dump()
2123 if (is_rx(c)) in tipc_crypto_key_dump()
2125 atomic_read(&c->peer_rx_active)); in tipc_crypto_key_dump()