/* the buffer needed is * (num SAs * 3 lines each * ~60 bytes per line) + one more line
*/
bufsize = (ipsec->count * 4 * 60) + 60;
buf = kzalloc(bufsize, GFP_KERNEL); if (!buf) return -ENOMEM;
p = buf;
p += scnprintf(p, bufsize - (p - buf), "SA count=%u tx=%u\n",
ipsec->count, ipsec->tx);
for (i = 0; i < NSIM_IPSEC_MAX_SA_COUNT; i++) { struct nsim_sa *sap = &ipsec->sa[i];
if (!sap->used) continue;
if (sap->xs->props.family == AF_INET6)
p += scnprintf(p, bufsize - (p - buf), "sa[%i] %cx ipaddr=%pI6c\n",
i, (sap->rx ? 'r' : 't'), &sap->ipaddr); else
p += scnprintf(p, bufsize - (p - buf), "sa[%i] %cx ipaddr=%pI4\n",
i, (sap->rx ? 'r' : 't'), &sap->ipaddr[3]);
p += scnprintf(p, bufsize - (p - buf), "sa[%i] spi=0x%08x proto=0x%x salt=0x%08x crypt=%d\n",
i, be32_to_cpu(sap->xs->id.spi),
sap->xs->id.proto, sap->salt, sap->crypt);
p += scnprintf(p, bufsize - (p - buf), "sa[%i] key=0x%08x %08x %08x %08x\n",
i, sap->key[0], sap->key[1],
sap->key[2], sap->key[3]);
}
len = simple_read_from_buffer(buffer, count, ppos, buf, p - buf);
/* find the first unused index */
ret = nsim_ipsec_find_empty_idx(ipsec); if (ret < 0) {
NL_SET_ERR_MSG_MOD(extack, "No space for SA in Rx table!"); return ret;
}
sa_idx = (u16)ret;
if (sa.xs->id.proto & IPPROTO_ESP)
sa.crypt = xs->ealg || xs->aead;
/* get the key and salt */
ret = nsim_ipsec_parse_proto_keys(dev, xs, sa.key, &sa.salt); if (ret) {
NL_SET_ERR_MSG_MOD(extack, "Failed to get key data for SA table"); return ret;
}
if (xs->xso.dir == XFRM_DEV_OFFLOAD_IN)
sa.rx = true;
/* the preparations worked, so save the info */
memcpy(&ipsec->sa[sa_idx], &sa, sizeof(sa));
/* the XFRM stack doesn't like offload_handle == 0, * so add a bitflag in case our array index is 0
*/
xs->xso.offload_handle = sa_idx | NSIM_IPSEC_VALID;
ipsec->count++;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.