diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2016-11-10 23:28:35 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2016-11-15 02:42:36 +0100 |
commit | 032d0526c9b52d1391fc14fa532ef5162e4c1822 (patch) | |
tree | 0b93b6b25bdfc10632e4c6c4d065c659eb623106 /src/data.c | |
parent | 450e45d9570450e6a10323902e4198c30cd312a0 (diff) |
socket: keep track of src address in sending packets
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'src/data.c')
-rw-r--r-- | src/data.c | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -34,9 +34,9 @@ struct encryption_ctx { struct decryption_ctx { struct padata_priv padata; struct sk_buff *skb; - void (*callback)(struct sk_buff *skb, struct wireguard_peer *, struct sockaddr_storage *, bool used_new_key, int err); + void (*callback)(struct sk_buff *skb, struct wireguard_peer *, struct endpoint *, bool used_new_key, int err); struct noise_keypair *keypair; - struct sockaddr_storage addr; + struct endpoint endpoint; uint64_t nonce; uint8_t num_frags; int ret; @@ -372,7 +372,7 @@ static void finish_decrypt_packet(struct decryption_ctx *ctx) } noise_keypair_put(ctx->keypair); - ctx->callback(ctx->skb, ctx->keypair->entry.peer, &ctx->addr, used_new_key, 0); + ctx->callback(ctx->skb, ctx->keypair->entry.peer, &ctx->endpoint, used_new_key, 0); return; err: @@ -403,10 +403,10 @@ static inline int start_decryption(struct padata_instance *padata, struct padata } #endif -void packet_consume_data(struct sk_buff *skb, size_t offset, struct wireguard_device *wg, void(*callback)(struct sk_buff *skb, struct wireguard_peer *, struct sockaddr_storage *, bool used_new_key, int err)) +void packet_consume_data(struct sk_buff *skb, size_t offset, struct wireguard_device *wg, void(*callback)(struct sk_buff *skb, struct wireguard_peer *, struct endpoint *, bool used_new_key, int err)) { int ret; - struct sockaddr_storage addr = { 0 }; + struct endpoint endpoint; unsigned int num_frags; struct sk_buff *trailer; struct message_data *header; @@ -414,7 +414,7 @@ void packet_consume_data(struct sk_buff *skb, size_t offset, struct wireguard_de uint64_t nonce; __le32 idx; - ret = socket_addr_from_skb(&addr, skb); + ret = socket_endpoint_from_skb(&endpoint, skb); if (unlikely(ret < 0)) goto err; @@ -459,7 +459,7 @@ void packet_consume_data(struct sk_buff *skb, size_t offset, struct wireguard_de ctx->callback = callback; ctx->nonce = nonce; ctx->num_frags = num_frags; - ctx->addr = addr; + ctx->endpoint = endpoint; ret = start_decryption(wg->parallel_receive, &ctx->padata, cpu); if (unlikely(ret)) { kmem_cache_free(decryption_ctx_cache, ctx); @@ -474,7 +474,7 @@ void packet_consume_data(struct sk_buff *skb, size_t offset, struct wireguard_de .callback = callback, .nonce = nonce, .num_frags = num_frags, - .addr = addr + .endpoint = endpoint }; begin_decrypt_packet(&ctx); finish_decrypt_packet(&ctx); |